You are on page 1of 98

# Formalisms and concepts

## SUPINFO International University http://www.supinfo.com

Formalisms and concepts

Chapter objectives
By studying this chapter, you will:

## Know the terminology associated with

logic programming.
Discover the different techniques and
problems.

## SUPINFO International University http://www.supinfo.com

Formalisms and concepts

Chapter plan
Next in this chapter, we will cover:

Symbolic A.I.
Calculations and reasoning.
System resolution by
predicates.

## SUPINFO International University http://www.supinfo.com

Formalisms and concepts

Symbolic A. I.

## SUPINFO International University http://www.supinfo.com

Symbolic AI

Part plan
In this part, we will cover:

## Evolution of formal logic.

The first-order logic.

Symbolic AI

## The connectionist I.A.: imitation of the

functioning of neural networks (simulation of
intelligence at a neurobiological level).

## The evolutionary I.A.: based on the genetic

algorithms (makes use of strategies inspired
by the natural evolution).

Symbolic AI

global level.

## Development of programs which reason on knowledge

(simulation of the intelligence on the psychological level,
through the use of symbolic manipulation).

## Reason means building new information from existing

information, using, for example, the mechanisms of
transformation.

Symbolic AI

## The symbolic A. I. is inspired by the psychology, which defines

the intelligence by the observation of behavior.

of the content).

Symbolic AI

## First study of human logic:

Antiquity and Middle Ages (Scholastic) syllogisms,
modal logic, quantification.
ARISTOTE (Greek philosopher - 300 B.C.)
main developer of classical logic.
studies on human reasoning.
Organon.

Symbolic AI

## Evolution of formal logic

Classical Logic:
Proposition: a decidable sentence.
Only two truth values, TRUE or FALSE
binary logic.
Reasoning by deduction.
syllogisms.

Symbolic AI

## The simplest logic is the propositional calculus. This type of

calculation does not manipulate numbers or numerical
expressions, but only the values of truth: TRUE, FALSE.

## All the men are mortals.

Premises: If all men are mortals and if Socrate is a man,
then Socrate is mortal.
Socrate is a man.

## Premises: HM, HM SH SM, SH

Conclusion: SM
SUPINFO International University http://www.supinfo.com
Symbolic AI

## All the dogs are birds

All the birds are barking

Valid conclusion:
Therefore, all the dogs are barking
????

Symbolic AI

## Formalization of the logic: Hume, Leibniz, Kant (XVIIIe) ...

Studies in epistemology (how do we know the world?).
Logic = algorithmic calculus (mechanically decidable).
Types of knowledge (Kantian):
Analytic (from reasoning, so deductive).
Synthetic a posteriori (from the experience, so inductive).
Synthetic a priori (categories of the spirit adapted to the
world).

Symbolic AI

## Evolution of formal logic

Formalization of the logic: Boole, Frege (XIXe), Russel, Hilbert,
Gdel (XXe) ...
Research on the unification between mathematics and logic.
Basis from the mathematical logic (Boolean, 1840).
FALSE = 0 ; TRUE = 1
OR = + ; AND = x

Symbolic AI

## The Probabilistic logic (uncertain knowledge)

The Temporal logic (taking time into account in reasoning)
The Fuzzy logic (multiple truth values)
The Multi-valued logic (3 possible values).
The modal logic (addition of modifiers).
.

Symbolic AI

## There are many applications and interest for logic in computer

science:
Writing of conditionals and correct stop conditions.
Realization of circuits based on logical gates in order to
construct functions of [0,1]n into [0,1]p.
Program proofs.
Satisfaction of properties through research functions.
Program corrections.
Databases using the research functions.

Symbolic AI

## There are many applications and interest for logic in computer

science (continued):
Typed functional programming (Python):
the type = the logical formula.
the program = the formal demonstration.
the evaluation = the normalization of the demonstration.
Logic programming (Prolog):
the description of the problem = the logical axioms.
the problem solving = the construction of a demonstration.

Symbolic AI

## The first-order logic

The logic deals with the truth. It is independent of the content of the
statement.
For example:
"If (he drives fast) then (he will crash)"
This statement may be true or false (but if he is a good driver and he
masters his driving he will perhaps not have an accident).
On the other hand:
"If (he drives fast) then ((he will drive faster) or (he will slow down))"
This statement will always be true no matter what the circumstances.

Symbolic AI

## From a syntactic point of view, the formal proofs produce exactly

statements that are always true.
Syntax - interpretation semantics.
Forward - interpretation truth values in the realm of possibilities

## Example: To sort a given Table1 into another Table2:

Table1 is a permutation of Table2.
The elements of Table2 are arranged in increasing order.

Symbolic AI

## The logic is useful to a computer programmer to specify and

verify a program:
{for the integers: x, y, z, t}
z 10 ; (x, y) (z, 1) ;
While (x > 0) do
(y, x) (y x, x1) ; t y ;

## What is the value of t?

Actually, t is equal to z!

Symbolic AI

programs

## The formal logic studies the rules of reasoning. It consists of:

the propositional calculus (elementary reasoning).
the predicate calculus (more complex reasoning).

Symbolic AI

## SUPINFO International University http://www.supinfo.com

Formalisms and concepts

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Part plan
In this parts, we will cover:

Propositional calculus.
Predicate calculus.

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

## The propositional calculus (or propositional logic, or CP0) is one

of the simplest logic, it is defined by:
a syntax that allows you to build correct propositions.
five logical connectives to combine the propositions.
the rules of inference (form of reasoning) can deduce new
truths: IF fever THEN illness.
a semantics that assigns truth values (TRUE, FALSE) to
proposals.

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

## For the syntax we have:

the atomic propositions (or basic). It is just simple
sentences. They allow to determine in an interpretation (or
context) if they are true or false.
They are representations.
We dont care about the internal structure.
We note them: A, B, C a , b, c,
For example:
A = I am in Paris
B = I am in France

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

set of atoms.

Atom.
Atomic formula.
Atomic variable.

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

## AND denoted , & (conjunction)

OR denoted V (disjunction)
NOT denoted ~,,
IMPLIES denoted
EQUIVALENT denoted ,=

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

## Example of inference in propositional calculus:

A and B are atoms and we have therefore two formulas:
A = I am in Paris
B = I am in France

## The formalization of inference rules:

A B,A B are formulas.
A B is a formula.
A B is a formula.
These formulas are also propositions.

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

Examples of formulas:
((a b) c ) , (a (FALSE b)).
Examples: these arent formulas:
(a b), (b b)

## Order of priorities: > > > .

Associativity:
and are left associative.
is right associative.

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

The order isnt total but partial and it is possible to represent the
proposals as a tree.
Examples:
((a b) c ) , (a (FALSE b)).

a b c FALSE b

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

The semantics:
A truth value (TRUE, FALSE) is given for each atomic
propositions, it is his valuation (or interpretation).
TRUE, FALSE are constants.
Notation of the formulas interpretation:
The valuation for the atom a is denoted by: v(a) or a.
The valuation for the formula A is denoted by: v(A) or A.

## Note: if we have a semantic equivalence, we will use the operator =,

for example: v(a) = a.
SUPINFO International University http://www.supinfo.com
Calculations and reasoning

Propositional calculus

## the satisfiability (denoted by):

Let A be a formula and v his interpretation. The relation of
satisfiability (denoted v A) is defined as follow:
If A is an atom a : v A if and only if a = TRUE
If A is a formula of the form a : v A if and only if v(a) =
FALSE
If A is a formula of the form a V b : v A if and only if v(a) =
TRUE or v(b) = FALSE
If A is a formula of the form a b : v A if and only if v(a) =
TRUE and v(b) = TRUE

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

The satisfiability:
A formula is satisfiable (or consistent) if there is at least one
interpretation v that makes it true: v A.
a b is satisfiable.

## A formula A is called not-satisfiable (or inconsistent or

contradictory) if and only if there is no v interpretation that makes it
true. A is a contradiction if and only if A is valid.
a a is not-satisfiable.

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

The satisfiability:
A formula A which is true for any v interpretation is a tautology, it is
called universally valid. We can also say v(A) = TRUE (or A =
TRUE). A is a tautology if and only if it is satisfied by all
interpretations: F
(a b) a b : is a tautology.
Theorem: A formula A is valid if and only if its negation A is not-
satisfiable:
A is valid.
v(A) = TRUE, for all v interpretations.
v(A) = FALSE, for all v interpretations.
A is not-satisfiable.
SUPINFO International University http://www.supinfo.com
Calculations and reasoning

Propositional calculus

The satisfiability:
Some definitions:
Model:
The v interpretation is a model for the formula A if v A.
v is a model for an set of formulas Ai , 1 i n if i, v Ai
Logical consequence:
The formula A is logical consequence of the formula Z (Z
A) if for all v such as v Z then v A or if all model of Z is a
model of A.

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

The satisfiability:
Let A be a set of formulas and B a formula, A B if and only
if A B are not-satisfiable.
A1, . . . , An B if and only if (A1 An B) is valid.
Let B be a formula. If A is a set not-satisfiable of formulas,
then B is a logical consequence of A.
If B is a valid formula, then B is logical consequence of any
set of formulas.

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

The satisfiability:
Proof of A B if and only if A and B is not-satisfiable.
Per hypothesis: Lets assume that A and B are satisfiable. There
is a v interpretation so that.
v satisfies B : v( B) = TRUE and v(B)=FALSE. But v
satisfies A, so we also have v(B) = TRUE.
Per hypothesis: Lets assume that A and B not-satisfiable.
Lets have v A and prove that v(B)=TRUE. If v(B)=FALSE
then v( B)=TRUE. Therefore v satisfies A and B, but its not
allowed according to hypothesis, therefore v(B)=TRUE.

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

The satisfiability:
We have A and B two formulas.
A is logically equivalent to B if and only if A B or (A B
and B A).
A B can be written as: (A B) (B A)
A B can be written as: A V B
(A B) = A V B (law of De Morgan)
If A is valid, and if A is empty, B is logical consequence of A
if and only if B is valid. B or B.

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

The satisfiability:
We have A, B and F formulas.
A = A
A V (F B) = (A V F) (A V B) (distributivity of V on and
conversely).
A (F V B) = (A F) V (A B) (distributivity of V on and
conversely).
A FALSE means that A is not-satisfiable. Because for
any model of A to be a model of False, then the set A must

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus
The satisfiability:
Proof of A F B if and only if A,F B
Per hypothesis: Let v be an interpretation: v A,F. Lets show that v
satisfies B.
v satisfies A therefore v satisfies F B, we have v(F)=TRUE
therefore v(F B)= TRUE = v(B)
Per reciprocal hypothesis (A, F B. show A F B): Let v be an
interpretation: v A. Lets show that v(F B) = TRUE.
If v(F)=TRUE then v satisfies A and F, therefore per
hypothesis v satisfies B. Therefore v(F B)=v(B)=TRUE
If v(F) = FALSE then v(F B) = TRUE
In both cases, we have v F B.
SUPINFO International University http://www.supinfo.com
Calculations and reasoning

Propositional calculus

The satisfiability:
A system of inference is correct if, for any rule of the system, the
conclusion is a logical consequence of its premise (the conjunction
of its premises) denoted*
A system of inference is complete if it is possible to prove any valid
formula:
A, A, then * A.

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

The satisfiability:
The formulas of the propositional calculus are inductive, which
means there is a principle of induction applicable:
If a property, true for any proposal, exists and we have the
formulas A and B, then the formulas A, (A B), (A B), (A
B) and (A B) are true.

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

The satisfiability:
Exercise:
A Logician listening to one of his friends evoke his passion for his
programming languages:
I love Lisp or I love Python.
If I love Lisp, then I love Python.
The logician may conclude that his friend loves Python. Why?

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

The satisfiability:
Let a be the propositional: I love Lisp and b the propositional: I
love Python'. The propositional can be rewritten as:
I love Lisp or I love Python: a b
If I love Lisp then I love Python: a b

(a b,a b) b

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

The satisfiability:
Interpretations where the two propositionals are true:
v(a) = v(b) = TRUE
a b a b : v(a) = FALSE, v(b) = TRUE
In both cases, the truth value of b is TRUE.

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

## There are algorithms to automatically decide of the satisfiability of

a set of formulas A by syntactic manipulation and not relying
anymore on the interpretations (cf. complete deductive system or
the sequent's calculus).

## The proof system is defined by a set of rules (the rules of

inference). Let P1 and P2 be the premises of the system and C
the goal, we note the proof by:
1 P1 2P2
C

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

## Modus Ponens (affirmation)

P = He is in Paris
1 P Q 2 P
Q = He is in France
Q

1 P Q 2 Q
P

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

## Some inference rules in the propositional calculus (continued):

R = He is a player Conjunction
S = He is French 1 R 2 S
T = He is English R&S

1 R & S 2 S
R S T

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

## Example of inference in propositional calculus:

Premises:
If I'm in Paris, I'm necessarily in France:
P F
When I am in France, I eat croissants:
F C
I'm in Paris:
P
Goal:
I'm in France and I eat croissants and / or madeleine cookies:
F (C M)

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

Demonstration (deductive):
P & (P F) F
F & (F C) C
C (C M)
F & (C M) F (C M)

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus
Exercise
Premises:
(B C) A
B
Goal:
A B
Demonstration (deductive):
( B) B
B (B C)
(B C) & ((B C) A) A
A& B (A B)
SUPINFO International University http://www.supinfo.com
Calculations and reasoning

Propositional calculus
Exercise
Premises:
A B
B C
A D
Goal:
C
Demonstration (deductive):
( A D) A
(A B) & A B
B & (B C) C

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

## To check the validity of the deduction, we can build trees

based on the connectors: a (b a):

a (b a)

a , (b a)

a,b a,a

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

## We have a direct relationship with the sequents and the valued

trees:
a (b a) = FALSE

a = TRUE , (b a) = FALSE

a b a a
a b a
a (b a)

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus
The algorithm of proof is based on the refutation:
Let A be a set of formulas and C a Goal. To demonstrate A
C we must demonstrate that A and C are not-satisfiable,
that is: A, C

## We have two rules of inference:

The resolution: A1 and A2 two formulas and a an atom.
A1 V a A2 V a
A1 V A2
The factorization: Let A be a formula and a an atom.
AVaVa
AVa
SUPINFO International University http://www.supinfo.com
Calculations and reasoning

Propositional calculus

## Lets consider the set of elementary propositions:

{a b c, a b c, b c , c} with c the refutation of c.

a b c a b c
b c c b b c c
b b c
c c

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

## Let A be a set of atoms and c an atom. A derivation by resolution

of c from the hypotheses of A is a sequence of atoms c1, . . . ,cn
such as i , 1 i n:
ci A
ak i such as ck
ci by factorization
j and k i such as cj ck
ci by resolution
A refutation of A is a derivation by resolution of from the
hypotheses of A.

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus
A refutation of A is a derivation by resolution of from the
hypotheses of A, therefore it can be depicted as a tree of refutation:
{a b c, a b c, b c , c} with c is the refutation of c.

b c c a b c a b c

b b c c
b
b c

c c

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus
The satisfaction of elementary formulas can be made by
substitutions and simplifications.
For example:
Substitutions of atoms by constants: (a c) c
a = TRUE
(TRUE c) c
c c = always true
OR
a = FALSE
(FALSE c) c
FALSE c = always true
SUPINFO International University http://www.supinfo.com
Calculations and reasoning

Propositional calculus

## Let A and B be two propositional formulas and c an atomic

proposition, we define by induction the formula A[c:=B] obtained
by substituting c in A.
Example:
Let A be the formula (c c b) and B the formula (a b):
(c c b) [c:=B] = (a b) (a b) b
(c c b) [c:=TRUE] = TRUE (TRUE) b

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

## Any propositional formula admits a conjunctive normal form (same

for disjunctive).
A clause is a disjunction C1 C2 Cn where each Ci is a
literal.
A literal is an atom or the negation of an atom: c, c
A propositional formula is said to be in the clausal form or in the
conjunctive normal form if it is a conjunction C1 C2 Cn
where each Ci is a clause.

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus
Method for transforming a propositional formula into its conjunctive
normal form.
Example:
(a (b c )) (c d)
Simplification of :
(a (b c )) ((c d) ( d c))
a ((b c) ( c b)) ((c d) ( d c))
Simplification of :
a (( b c) (c b)) ((c d) ( d c))
a (( b c) (c b)) (( c d) (d c))

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Propositional calculus

## Method for transforming a propositional formula into its conjunctive

normal form.
Example (continued):
Propagation of and simplification :
a (( b c) ( c b)) (( c d) (d c))
Distribution of operators and :
( a b c) ( a c b) ( c d) (d c)

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Predicate calculus

## The calculus of predicates: Through this calculation we realize

that any object satisfying a hypothesis also verifies the thesis.
For example:
Any absolute value is positive.
A reformulation would be:
For all number, if n is an absolute value then this implies that
n is positive.
The calculus of predicate us gives:
((n) Abs(n)) Positive(n).

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Predicate calculus

## The calculus of predicates is a quantified propositional calculus.

There is a relationship between the elementary propositions.
Term: Constant, Variable or Function(t1, , tn)
Atomic statement: Predicate(t1, . . . , tn) or t1 = t2

Example:
john goes to the sea goes(john, sea)
john goes to the sea or the mountains goes(john, sea) V
goes(john, mountains)

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Predicate calculus

## The calculus of predicates introduces the concept of variables

and quantifiers:
variable: symbol that can take various values.
: existential quantifier: x (there is an x).
: universal quantifier: x (for all x).

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Predicate calculus

## Example 1: all elephants are grey:

( x) elephant (x) color(x, grey)
Example 2: IF x is the father of y and y is the father of z THEN x is
the grandfather of z:
( x) ( y) IF father(x,y) & father(y,z) THEN grandfather(x,z)
( x) ( y) ( z) father(x,y) & father(y,z) grand-father(x, z)
Example 3: All men are mortals, and Socrates is a man, therefore
Socrates is mortal:
( x) human(x) mortal(x) & human(s) mortal(s)

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Predicate calculus

## Example 4: Lets consider the program:

{x, y, z, are integers}.
z 10; (x, y) (z, 1);
While (x > 0)
(y, x) (y x, x1);

## (x)(y)(z) ([0< x z y x! = z!]

[ 0 x1 z (y x) (x1)! = z!])

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Predicate calculus

## The truth is given by a model and an interpretation:

The model contains the objects (called elements of the
The interpretation specifies the reference of the symbols:
Symbols of constants objects.
Symbols of predicates relationships.
Symbols of functions functions.
A predicate is TRUE in a model, according to an interpretation, if
the relationship to which the symbol of the predicate refers, applies
to the objects in argument.

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Predicate calculus
The satisfiability:
An interpretation is a function that manipulates the symbols of the
predicate through its field.
A formula is satisfiable if it is true for at least one interpretation in
a field.
( a)( male(a) female(a))
A formula is not-satisfiable if it is true for no interpretation in any
field.
( a)(P(a)) ( b)( P(b))
A formula is valid if it is true for all the interpretations in all the
fields.
(( a) P(a)) ( a) ( P(a))
SUPINFO International University http://www.supinfo.com
Calculations and reasoning

Predicate calculus

## The satisfiability (continued):

We have A and B of formulas.
(( x) A) = ( x) ( A)
(( x) A) = ( x) ( A)
(( x) A) (( x) B) = ( x) (A B)
(( x) A) (( x) B) = ( x) (A B)

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Predicate calculus

## When we use quantifiers account must be taken of links between

the variables:
A variable is free if it is not within the scope of a quantifier (
or ), otherwise it is called bound.
Example:
( x)( y) (employee(x, y) leader(x, z))
x and y are bound.
z is free.

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Predicate calculus

## All the variables in the formulas are free.

The free variables (resp. bound) of the set of formulas of A are
those of A.
The free variables (resp. bound) of A op B where op
{ , ,,} are those of A and B.
The free variables (resp. bound) y distinct of x in ( x) A and
( x) A are those of A and the variables x are all bounded in ( x)
A and ( x) A.

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Predicate calculus

## A method for transforming a predicate into a conjunctive normal

form.
Example:
( a) p(a) ( b) q(b) ( b) (p(b) q(b))
Elimination of operators :
(( a) p(a) ( b) q(b)) ( b) (p(b) q(b))
The variables b are bound, they must be renamed:
(( a) p(a) ( b) q(b)) ( c) (p(c) q(c))
Propagation of the operator :
((( a) p(a)) (( b) q(b))) (( c) (p(c) q(c)))

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Predicate calculus

Example (continued):
Skolemization: Removal of existential quantifiers by elimination:
( p(F(a))) (( b) q(b))) ((p(F(c)) q(F(c))))
Removal of universal quantifiers:
( p(F(a)) q(b)) (p(F(c)) q(F(c)))
Distribution of operators and for a conjunctive normal form:
(( p(F(a)) q(b) (p(F(c))) (( p(F(a)) q(b) (q(F(c)))

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Predicate calculus

## Horn clause: disjunction of literals of which at most one is positive:

( A B C) is a Horn clause because logically equivalent
to: (A B) C
( C A B) isnt a Horn clause

## All Horn clause can be written in the form of an implication with:

Premise = conjunction of positive literals.
Goal = single positive literal.

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

Predicate calculus

## Definite clauses (or positive Horn clause): Horn clauses with

exactly one positive literal:
negative literals = body of the clause.
Fact = clause without negative literals.

## SUPINFO International University http://www.supinfo.com

Calculations and reasoning

## SUPINFO International University http://www.supinfo.com

Formalisms and concepts

predicates

## SUPINFO International University http://www.supinfo.com

The resolution of a system by predicates

Part plan
In this part, we will cover:

of the cubes.

## SUPINFO International University http://www.supinfo.com

The resolution of a system by predicates

Final state
Exercise:
Initial state a

c b

a b c

## You must apply the predicate calculus to induce the displacement

of the cubes, given that only a single cube can be moved at any
time. For a cube to move, there should be no other cube on top, a
cube is placed on the table or on another cube. Define the
predicates, make the displacements?

## SUPINFO International University http://www.supinfo.com

The resolution of a system by predicates

## Application to the displacement of the cubes

Definition of the states

## To define the states, we use the predicates:

on and free
The initial state:
on(c, a) on(a, table) on(b, table) free(c) free(b)

a b

Table (t)

## SUPINFO International University http://www.supinfo.com

The resolution of a system by predicates

## Application to the displacement of the cubes

Definition of the states

## The final state:

on(a, b) on(b, c) on(c, table) free(a)

Table (t)

## SUPINFO International University http://www.supinfo.com

The resolution of a system by predicates

## Application to the displacement of the cubes

The rules of displacement

## To define the rules, we add the predicates free and remove.

Rule 1: (to verify that a cube is free)
For any cube to be free, this implies that there is no cube on it.
( x) [ free(x) ( y) on(y,x) ]

## Rule 2: (to remove a cube)

If a free cube, which was on top of another cube, is removed, then it
implies that this later cube becomes free.
free(y) on(y,x) remove(y,x) free(x) and on(y,x)

Y
X X Y

## SUPINFO International University http://www.supinfo.com

The resolution of a system by predicates

## Application to the displacement of the cubes

The rules of displacement
To define the rules, we add the predicates stack and table:

## Rule 3: (to stack a cube)

If two cubes are free, one can be stacked upon the other, this
implies piling.
free(x) free(y) stack(y,x)
on(y,x) free(x) table(y)
Y
Y X
X

## Rule 4: (if a cube is on the table, it isnt on another cube)

x) [table(x) ( y) on(x,y)]

## SUPINFO International University http://www.supinfo.com

The resolution of a system by predicates

## Application to the displacement of the cubes

on(c, a) table(a) table(b) free(b)
b
free(c) free(b) c c free(c)
c b a table(b)
a b Table (t) a table(a)
Table (t) Table (t)
on(c, a)
decompose the initial facts
... find (mechanically)
the correct sequence
of transformations
decompose the goal

a b
b a c table(c)
c b on(b, c)
Table (t) c on(a, b)
on(a, b) on(b,c) table(c) free(a) Table (t)

## SUPINFO International University http://www.supinfo.com

The resolution of a system by predicates

## Application to the displacement of the cubes

find a rule for the transformation b free(b)
c c free(c)
R2 table(b)
b a
free(y) on(y,x) remove(y) Table (t) table(a)
a
on(c, a)
Table (t)
free(x) table(y) on(y,x)
verify the conditions
free(b)
R3 b c free(c)
free(x) free(y) table(y) b a table(b)
stack(y,x) Table (t) Table (t) table(a)
free(a)
on(y,x) free(x) table(y) c a table(c)
Table (t)
new state of the system

b
a c table(c)
b on(b, c)
Trying to satisfy one of the goals
c on(a, b)
SUPINFO International University http://www.supinfo.com Table (t)
The resolution of a system by predicates

## Application to the displacement of the cubes

table(a)
table(b)
c on(c, a) Initial state
free(b)
a b free(c)

R3 R2
table(a)
table(a)
table(b)
b on(b, c)
table(c)
c on(c, a)
free(a)
a free(b) a c b free(b)
free(c)

R3
table(a) table(b)
table(c) table(c)
a b c b a
b c a c a b on(b, c) on(a, b)
a c free(a) b c free(a)
free(b) free(c)
R3
a table(c)
on(b, c) c
b on(a, b) a
Final state c free(a) b
SUPINFO International University http://www.supinfo.com
The resolution of a system by predicates

## Application to the displacement of the cubes

Strategy to reach the final state: c
a b
on(a,b) on(b,c) on(c,table)
Initial state

## Try-out/Test to comply with the clause: on(a,b) (first goal)

Application of R3, where: x = a, y = b
R3-conditions:
free(a), free(b), stack(a,b) (sub-goals)
sub-goal1: free(a) R1 shows that a is not free for release
to free a R2 (with x = a): on(y,a), remove(y,a)
on(y,a) is accomplished by y = c (initial state)

## SUPINFO International University http://www.supinfo.com

The resolution of a system by predicates

## Application to the displacement of the cubes

Strategy to reach the final state: c
a b
Initial state

## execute: remove(c,a) (first command

intermediate state 1) a c b

## execute: stack(a,b) (second command

intermediate state 2) a
c b

Intermediate state 2

## SUPINFO International University http://www.supinfo.com

The resolution of a system by predicates

## Try-out/Test to comply with the second clause: on(b,c)

a
c b
We apply R3, where x = b, y = c
Intermediate state 2
R3 sub-goals: free(b), free(c), stack(b,c)
R1 shows that b is not free, therefore:
R2: remove(a,b)
undo the previous action c b a

## we get: free(b) Intermediate

state 3
(third command intermediate state 3)

## SUPINFO International University http://www.supinfo.com

The resolution of a system by predicates

## We check free(c) with R1 and execute: stack(b,c)

(fourth command intermediate state 4)
b
c a

Intermediate state 4

We execute: stack(a,b)
a
b
c
Final state

## SUPINFO International University http://www.supinfo.com

The resolution of a system by predicates

Conclusion:

## The execution order of the sub-goals is important:

First on(c,table), subsequently on(b,c), next on(a,b).
We need additional information called: meta-knowledge
Example of meta-knowledge:
Seek to satisfy low-level goals first.
(Otherwise) use some approach to fulfill the goals.
(Otherwise) adopt a blind approach to reach the goal if all
possibilities have been explored (time consuming approach).

## SUPINFO International University http://www.supinfo.com

The resolution of a system by predicates

## SUPINFO International University http://www.supinfo.com

Formalisms and concepts

Module Summary

Supplementary
... remain A.I. means to
interactive with = solutions:
its environment intelligent the heuristics
concepts

being intelligent:
The intelligent it is seeking
concepts do autonomy,
have their learning,
limits

## SUPINFO International University http://www.supinfo.com

Formalisms and concepts

## To go deeper into the matter

If you want to deepen your knowledge:

Publications

## From human S. RUSSEL &

intelligence to P.NORVIG: Artificial
artificial intelligence Intelligence
(Paperback) by (translated from
Hugues Bersini English) - Eyrolles,
2006
Artificial intelligence E. RICH:
and theoretical Artificial Intelligence
computer science (translated from
(2nd ed.) (Paper- English) Masson,
back) by J.-M. 1987
Alliot, T. Schiex, P.
Brisset
SUPINFO International University http://www.supinfo.com
Formalisms and concepts

End of module

## Thank you for your

attention
SUPINFO International University http://www.supinfo.com