62 2 PROLOG Syntax and Meaning PPJSP
62 2 PROLOG Syntax and Meaning PPJSP
data objects
constants variables
atoms numbers
SYNTAX FOR DATA OBJECS
alpha_beta_algorithm taxi_35
• Integers
1 1313 0 -55
_x35 _335
visible_block( B) :-
see( B, _, _).
Equivalent to:
visible_block( B) :-
see( B, X, Y).
STRUCTURES
functor arguments
date
17 june 2006
• Therefore all structured objects in Prolog can be viewed
as trees
P2 = (2,3) (6,4)
S T
(4,2)
P1=(1,1) (7,1)
P1 = point( 1, 1) P2 = point( 2, 3)
S = seg( P1, P2) = seg( point(1,1), point(2,3))
T = triangle( point(4,2), point(5,4), point(7,1))
LINE SEGMENT
S = seg
point point
1 1 2 3
ARITHMETIC EXPRESSIONS
ARE ALSO STRUCTURES
• For example: (a + b) * (c - 5)
*( +( a, b), -( c, 5))
*
+ -
a b c 5
MATCHING
• For example:
?- date( D1, M1, 2006) = date( D2, june, Y2),
date( D1, M1, 2006) = date( 17, M3, Y3).
?- X = f(X).
• Procedural readings:
• To solve problem P, first solve subproblem Q and then R.
• To satisfy P, first satisfy Q and then R.
PROCEDURAL MEANING
program
success/failure indication
goal list execute
instantiation of variables
procedure execute( Program, GoalList, Success)