Prolog Syntax and Meaning: Ivan Bratko
Prolog Syntax and Meaning: Ivan Bratko
DATA OBJECTS
data objects
simple objects
constants
atoms
numbers
variables
structures
x15
x_15
aBC_CBa7
alpha_beta_algorithm
taxi_35
peter
miss_Jones2
missJones
ATOMS, CTD.
(2) Strings of special characters
--->
.
<
<==>
>
<<
++
..
.::.
::=
[]
ATOMS, CTD.
(3) Strings in single quotes
X_35
Peter
Britney Spears
Integers
1
1313
-55
-0.0045
1.34E-21
1.34e-21
Results
_x35
Object2B
Participant_list
_335
ANONYMOUS VARIABLES
visible_block( B) :see( B, _, _).
Equivalent to:
visible_block( B) :see( B, X, Y).
STRUCTURES
arguments
FUNCTORS
TREE REPRESENTATION
OF STRUCTURES
Often, structures are pictured as trees
date( 17, june, 2006)
date
17
june
2006
(6,4)
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(1,1), point(2,3))
S = seg
point
1
point
1
ARITHMETIC EXPRESSIONS
ARE ALSO STRUCTURES
For example: (a + b) * (c - 5)
MATCHING
EXAMPLE OF MATCHING
For example:
?- date( D1, M1, 2006) = date( D2, june, Y2),
date( D1, M1, 2006) = date( 17, M3, Y3).
D1 = 17, D2 = 17, M1 = june, M3 = june,
Y2 = 2006, Y3 = 2006
MATCHING
MATCHING UNIFICATION
AN INTERESTING SEGMENT
DECLARATIVE MEANING
DECLARATIVE vs PROCEDURAL
MEANING OF
PROLOG PROGRAMS
Consider:
P :- Q, R.
Procedural readings:
To solve problem P, first solve subproblem Q and then R.
To satisfy P, first satisfy Q and then R.
PROCEDURAL MEANING
execute
instantiation of variables