Rules can be rephrased such that variables appearing only in the body of a rule are existencially quantfied. The rule can be read For any X, Y and Z, if X is a child of Z and Z is a child of Y, then X is a grand child of Y. Prolog by Examplechild_of(john, ann).child_of(john, alex).child_of(ann,bob).grand_child_of(X,Y) :- child_of(X,Z), child_of(Z,Y).All variables (starting with capital letters) are universally quantified. Bk, which i the syntax adopted in Prolog.įoundations of Logic and Constraint Programming Bk can be written in the form of an if expression H B1 B2. Example: A grand child is the child of the child, i.e.grand_child_of(X,Y) :- child_of (X,Z), child_of(Z,Y).The name rule is due to the fact that a definite clause, H B1 B2. Example: The knowledge that John is a child of Ann and Alex, and that Ann is a child of Bob, is expressed by two facts, namely child_of(john, ann).child_of(john, alex).child_of(ann, bob).A rule has one or more negative literals (the body of the clause), and is used to infer predicates from other predicates. A fact has no negative literals and expresses positive knowledge that is definite (no disjunctions). This predicate may have several alternative definitions (both facts and rules). clauses with at most one positive literal (the head of the clause). Prolog by ExampleA Prolog program is composed by facts and rules, which are special cases of definite (or Horn) clauses, i.e.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
June 2023
Categories |