Title: Term
Description: None
Copyright (c) 1999 Steven J. Metsker.
Copyright (c) 2001 The Open For Business Project - www.ofbiz.org
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The Term interface defines the core elements of the logic
engine.
Terms are the central objects in the logic programming
data model, which is basically as follows:
- A Program is a collection of Rules.
- A Rule is a series of Structures.
- A Structure is an Object associated with a collection of
Terms.
- Structures and Variables are Terms.
The statement that "Structures and Variables are Terms"
has both a loose meaning and a literal meaning. Loosely, the
statement means that the contents of a structure are other
structures and variables. For example, the terms of
plays(jim, Game) are the structure
jim and the variable Game . The
literal meaning is that class Structure and
class Variable implement the interface
Term .
In addition to residing at the core of the data model,
the Term interface also defines unification. Unification is
a kind of matching, and is the basic step in the execution
of a logic program. Roughly speaking, two structures can
unify if their variables can take on values to make the
structures equal. To prove itself against a program, a
Structure:
- Unifies with the head of a Rule.
- Asks the Rule to prove its remaining structures.
This simple algorithm is the execution model of a logic
engine. A structure can unify with another structure if
their functors are equal, and if their terms can unify. An
uninstantiated variable unifies with a term by instantiating
to it. An instantiated variable can unify with another term
if its instantiation can unify with the term.
The other methods declared by the Term interface define
behavior that must exist in all terms, whether they are
structures or variables. This behavior includes a method for
creating provable version of a term, and a method for
returning the value of term in a function.
author: Steven J. Metsker version: 1.0 |