Please enable JavaScript.
Coggle requires JavaScript to display documents.
Prolog (Query (Compund Terms (parent(variable,constant) (binding (parent(P…
Prolog
Query
Compund Terms
parent(atom,constant)
parent(variable,constant)
binding
parent(P,esther)
P = herbert
parent(P,brian)
false
parent(constant,variable)
parent(esther,Child)
parent(variable,variable)
parent(Parent,Child)
SemiColon ;
Comma (,)
parent(margaret,X) , parent(X,holly)
True/False
parent(Parent,kim) , parent(Grandparent,Parent)
Parent = margaret ;
Grandparent = esther ;
Parent = margaret ;
Grandparent = herbert ;
false
Syntax
Terms
Constants
Variables
Underscore
Compound Terms
parent(kim,holly)
kim is a parent of holly
kim \(\to\) holly
parent(kim,holly
2 1 3
kim = parent of holly
parent(kim,holly)
inverse(2) 3 1
holly = child of kim
Pattern Matching
Unification
Period(.)
Logical Program
You don't run
Procedural vs Logical Meaning
Rules
Simple
greatgrandparent(GGP,GGC) :-
parent(GGP,GP) , parent(GP,P) , parent(P,GGC)
Notice the role of unification/bindings
Recursive
ancestor(X,Y) :- parent(X,Y)
ancestor(X,Y) :- \(\qquad \qquad\)
parent(Z,Y) ,
ancestor(X,Z)
Scope
greatgrandparent(GGP,GGC) :-
grandparent(GGP,P) , parent(P,GGC)
grandparent(GP,GC) :-
parent(GP,P) , parent(P,GC)
List
Operator
| operator