A term in Prolog and CG theory
Definition - CG theory
Definition - Prolog
A partial order is a relation between elements of a set. That is, it defines relationships between all of the elements of a set, and these relationships obey three axioms (given below).
For example, "≤" is a partial order over the natural numbers. For example:
Thus a partial order over a set S defines relationships between all of the elements of S, and these relationships all obey the following three axioms or rules:
For all elements A of S, it is true that:
A ≤ A
For all elements A, B, and C in S, this rule allows us to infer that:
A ≤ B
B ≤ C
A ≤ C
For example, since
it must also be true that
For all elements A and B of S, it is true that:
A ≤ B
B ≤ A
A = B
For example, since "2 ≤ 2" and "2 ≥ 2", it must be true that "2=2".
A term in Prolog.
For example, consider the following program:
father(Terah, Abraham). father(Abraham, Isaac). father(Isaac, Jacob). father(Jacob, Judah). ancestor(A,D) :- father(A,D). ancestor(A,D) :- father(F,D), ancestor(A,F).
This program contains two predicates: father/2 and ancestor/2. The father/2 predicate consists of four facts, while the ancestor/2 predicate consists of two rules.
A predicate can be a mix of facts and rules.
A term in programming.
A primitive is an action which you, as a programmer, is allowed to take without writing a whole lot of code.
For example, Prolog+CG has a number of built-in predicates, such as:
As another example, if you have the following two lines of code:
ancestor(A,D) :- father(A,D). ancestor(A,D) :- father(F,D), ancestor(A,F).
then you have the primitive called ancestor/2. This is because you now have an easy way of finding out whether an entity is an ancestor of another entity. You don't need to write a lot to find out, and therefore it is a primitive.
A term in Prolog.
The program database is the sequence of clauses making up the program.
In Prolog, the data are usually written as facts. Since the data are incorporated into the program, we speak of the program database. This principle is known as "Program as data".
A term in Prolog+CG.
In Prolog+CG, the following kinds of data are available:
lists are discussed in Module 2.
Booleans are data with one of the following two values: