Lecture_24_Foundations_of_Logic_Programming_Part_II
Lecture_24_Foundations_of_Logic_Programming_Part_II
30
That’s all very nice, but how can we answer a query
using a logic program?
32
Logic Programming’s Computational Mechanism
33
Logical Variables
34
Substitution
Definition:
A substitution is a function from variables to terms (such that the number of
variables which are not mapped to themselves is finite). A substitution θ is
denoted by
θ = {X1/t1, …, Xn/tn}
where X1, …, Xn are different variables, t1, …, tn are different terms and we
assume is ti different to Xi, for i = 1, …, n
35
Substitution vs. Assignment
So, in a logic program, the equation X=a (a is constant) has as solution the
variable substitution {X/a}
• This substitution is also a solution to the equation a = X
36
Substitution vs. Assignment
So, in a logic program, the equation X=a (a is constant) has as solution the
variable substitution {X/a}
• This substitution is also a solution to the equation a = X
37
Unification
f(X) = f(g(Y))
• It is solvable in the sense that application of the substitution θ = {X/g(Y)} to
both sides of the equation makes them syntactically equal
f(X)θ -> f(g(Y))
38
Most General Unifier
• This is a unifier for which there is no other unifier more general than it
39
The Computational Model
1. The only possible values, at least in the pure model, are terms over a given
signature.
4. Control, which is entirely handled by the abstract machine (except for some
possible annotations in PROLOG) is based on the process of automatic
backtracking.
40