35
L I P 6 C L I P 6 C Logique pour l’Informatique Avancée Spécialité IAD Responsable: Jean-Gabriel Ganascia [email protected] ACASA ACASA - Université Pierre et Marie CURIE Université Pierre et Marie CURIE ACASA ACASA - Université Pierre et Marie CURIE Université Pierre et Marie CURIE C N R S C N R S Cours Mercredi 8H30 – 10H30 Salle 201, couloir 23-24, 2 e étage Documents: http://ganascia.name/LIA

Introduction

Embed Size (px)

Citation preview

Page 1: Introduction

LLIIPP66

CC

LLIIPP66

CC

Logique pour l’Informatique AvancéeSpécialité IAD

Responsable: Jean-Gabriel Ganascia

[email protected]

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

Cours Mercredi 8H30 – 10H30

Salle 201, couloir 23-24, 2e étage

Documents: http://ganascia.name/LIA

Page 2: Introduction

LLIIPP66

CC

LLIIPP66

CC

Organisation TD/TME

• Groupe 1: Marie-Jeanne Lesot

TD: mardi 8H30-10H30salle 102 Couloir 23-24

TME: mardi 10H45-12H45non encore définie

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

TME: mardi 10H45-12H45non encore définie

• Groupe 2: Iza Marfisi Schottman

TD: jeudi 8H30-10H30salle 102 Couloir 23-24

TME: jeudi 10H45-12H45non encore définie

Page 3: Introduction

LLIIPP66

CC

LLIIPP66

CC

Aristotle 384 – 322 BC

The heart of Aristotelian Logic is the deductive syllogism:

Deduction

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

A, B, C, D, … are swans

All swans are white

A, B, C, D, … are white

Deduction

Page 4: Introduction

LLIIPP66

CC

LLIIPP66

CC

History of Logic(-500 – …)

1. Describing the correct way of reasoning –Philosophy(Aristotle, …)

2. Mathematizing Logic –Philosophy(Leibniz, Boole, …)

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

(Leibniz, Boole, …)

3. Mechanizing Mathematics –Mathematics(Hilbert, Herbrand, Tarski…)

4. Computerizing the Proof –Mathematics, Logic, AI & Computer Science (…)

Page 5: Introduction

LLIIPP66

CC

LLIIPP66

CC

Practical Use of Logic in Computer Sciences

• Automatic Theorem Proving • Proof of Programs, Model Checking, …

– Safety

• Automated Deduction

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

• Automated Deduction– Artificial Intelligence

• Programming Language– PROLOG, DATALOG, …

• Knowledge Representation– AI, Data Bases, Semantic Web…

Page 6: Introduction

LLIIPP66

CC

LLIIPP66

CC

Course Program

• Propositional and Predicate Calculus

– Syntax and semantics

• Proof Theory

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

• Proof Theory

• Automatic Theorem Proving: the Resolution

Rule

• PROLOG: Programming in Logic

Page 7: Introduction

LLIIPP66

CC

LLIIPP66

CC

PROLOG

• PROLOG = PROgramming in LOGic

• PROLOG is an intuitive language (Seymour Papert wanted to make children program with

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

Papert wanted to make children program with PROLOG)

• PROLOG is built on an automatic theorem prover

• LOGIC: theoretical grounding of PROLOG

Page 8: Introduction

LLIIPP66

CC

LLIIPP66

CC

Cours LIA: logique // PROLOG

1. Introduction à la logique des propositions (sémantique) + PROLOG pour BB

2. Logique des propositions (suite sémantique, syntaxe) + PROLOG

3. Logique des propositions

5. Résolution de base, filtrage, unification + PROLOG programmation dynamique unification

6. Résolution générale + PROLOG (entrées – sorties, analyseur syntaxique)

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

3. Logique des propositions (systèmes formels, démonstration) + PROLOG (variable anonyme, graphes)

4. Logique des prédicats, quantificateurs… syntaxe et sémantiquePROLOG (coupure)

syntaxique)

7. Stratégie de résolution + PROLOG DCG

8. Stratégie SLD + objets en PROLOG

9. Preuve complétude, modalités + PROLOG avec contraintes

10. Sémantique logiques modales

Page 9: Introduction

LLIIPP66

CC

LLIIPP66

CC

Representation in Logic

• Sign, Meaning and Truth

• Proposition

• The Propositional Language

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

• The Propositional Language

• Limits of the Propositional Language

• The Predicate Logic

Page 10: Introduction

LLIIPP66

CC

LLIIPP66

CC

• Expression, Meaning, ReferencesSign

GraphicsWorld

Expressions ReferencesMeaning

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

• Sign: graphic with meaning (i.e. intended to express)– Examples: “horse”, “reality”, “John”, “�”,

“�”, “֠”, “�”

Page 11: Introduction

LLIIPP66

CC

LLIIPP66

CC

Proposition• Meaning = truth value∈ {true, false}

– “Earth is blue”

– “The green square is behind the red triangle”

– “A book was published”

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

Page 12: Introduction

LLIIPP66

CC

LLIIPP66

CC

The Propositional Language• Atom: elementary propositions

– “It was raining”– “The cube is green”

• Connectors– Binary: «∧ », « ∨ », « ⊃ », « ≡ », …

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

– Binary: «∧ », « ∨ », « ⊃ », « ≡ », …– Unary: « ¬ »

• Composed Propositions– If A and B are propositions, « ¬ A»,

« A ∧ B », « A∨ B », « A⊃ B », « A≡ B» are propositions

Page 13: Introduction

LLIIPP66

CC

LLIIPP66

CC

Representation in Logic• Representation in Propositional Logic

– The small red pentagon is above the blue cylinder– The yellow diamond is left to the cylinder– There is a big red parallelepiped– The green diamond is above the parallelepiped– The cylinder is green

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

Page 14: Introduction

LLIIPP66

CC

LLIIPP66

CC

Representation in Logic (2)

There is an object at the right of a cube

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

There is an object at the right of a cube

A dodecahedronis at the right of a big cube

A pyramid is at right of a cube

Page 15: Introduction

LLIIPP66

CC

LLIIPP66

CC

Propositional Logic

How to translate those sentences in propositional logic:

1. There is an object right to a green cube2. Every successor of an even number is odd

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

3. 72 is an even number4. The successor of 72 is odd

Introduction of propositional functions (predicates):event(X): « X is even » is a proposition for all values of X.

Page 16: Introduction

LLIIPP66

CC

LLIIPP66

CC

Representation in Predicate Logic

Notion of propositional function:

1. X is even: even(X)

2. 72 is an even number even(72)

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

3. The successor of 72 is oddodd(successor(72))

4. Every successor of an even number is odd∀∀∀∀x (even(x) ⊃⊃⊃⊃ odd(successor(x)))

5. There is an object to the right of a green cube∃∃∃∃x ∃∃∃∃y (right_of(x, y)&cube(y)&green(y))

Page 17: Introduction

LLIIPP66

CC

LLIIPP66

CC

Knowledge Representation in Logic

Exercise: represent in logic the two following sentences:

“the barbers shave those who don’t shave by themselves”

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

barber(X) ∧ ¬shave(Y, Y) ⇒ shave(X, Y)

“there is no barber who shaves someone who shaves himself”

¬(barber(X) ∧ shave(X,Y) ∧ shave(Y,Y))

Page 18: Introduction

LLIIPP66

CC

LLIIPP66

CC

Propositional Logic: semantic

• Truth Tables

• Satisfiability, validity, unsatisfiability

• Logical Consequence

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

• Logical Consequence

• Limitation of Truth Tables

• Semantic Trees

• Herbrand Theorem

Page 19: Introduction

LLIIPP66

CC

LLIIPP66

CC

Truth Table

• Every atom a has a truth value: true (v) or false (f)

• How to compute the truth value of a composed proposition? « A ∧ B » « A ∨ B » « A ⊃ B » « ¬ A »

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

A\B v f

v v f

f f f

A\B v f

v v v

f v f

A\B v f

v v f

f v v

A

v f

f v

« A ∧ B » « A ∨ B » « A ⊃ B » « ¬ A »

Page 20: Introduction

LLIIPP66

CC

LLIIPP66

CC

Example

• Each line of the truth table is called an interpretationvvffv

vvvfv

fffvv

vvvvv

(A ⊃⊃⊃⊃(B ⊃⊃⊃⊃C))(B ⊃C)CBA

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

interpretation

vvfff

vvvff

vffvf

vvvvf

vvffv

Page 21: Introduction

LLIIPP66

CC

LLIIPP66

CC

Validity

• A formula A is said to be valid if it is trueon all the lines of the truth table, i.e. in all the

vvvv

(A ⊃⊃⊃⊃(B ⊃⊃⊃⊃A))(B ⊃A)BA

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

in all the interpretations– Example:

(A⊃⊃⊃⊃(B⊃⊃⊃⊃A)) vvff

vfvf

vvfv

vvvv

Page 22: Introduction

LLIIPP66

CC

LLIIPP66

CC

Validity: an other example

• Another example: (A⊃⊃⊃⊃(B⊃⊃⊃⊃C))⊃⊃⊃⊃((A⊃⊃⊃⊃B)⊃⊃⊃⊃(A⊃⊃⊃⊃C))

vv

(A⊃⊃⊃⊃(B⊃⊃⊃⊃C))⊃⊃⊃⊃((A⊃⊃⊃⊃B)⊃⊃⊃⊃(A⊃⊃⊃⊃C))

f

v

(A⊃B)⊃(A⊃C)

f

v

(A⊃C)

v

v

(A⊃B)

fffvv

vvvvv

(A⊃(B⊃C))(B⊃C)CBA

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS v

vvvvvv

v

v

v

v

v

v

f

v

v

v

v

f

v

f

v

v

v

v

f

f

v

vvfff

vvvff

vffvf

vvvvf

vvffv

vvvfv

fffvv

Page 23: Introduction

LLIIPP66

CC

LLIIPP66

CC

Satisfiability• A formula A is said

to be satisfiableif it is true on at least one line of its truth table, i.e. in at least on ffvv

(A ⊃(B ⊃¬A))(B ⊃¬A)BA

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

least on interpretation

– Example: (A⊃⊃⊃⊃(B⊃⊃⊃⊃¬A))

vvff

vvvf

vvfv

ffvv

Page 24: Introduction

LLIIPP66

CC

LLIIPP66

CC

Satisfiability – Unsatisfiability – Validity

• A formula is said to be– “satisfiable” if and only if it is true on at least

one line of the truth table

– “valid” if and only if it is true on all lines of the truth table

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

truth table

– “unsatisfiable” if and only if it is false on all lines of the truth table, i.e. if it is never true

• Remarks :– F is unsatisfiableiff ¬F is valid

– F is unsatisfiableiff F is not satisfiable

Page 25: Introduction

LLIIPP66

CC

LLIIPP66

CC

Logical consequence

• A is a logical consequence of B if A is true on all the lines of the truth table where B is true– Example: (A⊃B) is a logical consequence of B.

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

Notation╞ A means A is a valid formula

B╞ A means A is a logical consequence of B

Page 26: Introduction

LLIIPP66

CC

LLIIPP66

CC

Deduction Theorem

Deduction Theorem:B is a logical consequence of A (A╞ B ) if and only if A⊃B is valid (╞ A ⊃⊃⊃⊃ B )

Equivalent definitions:

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

Equivalent definitions:• ╞ A if and only if (¬A) ╞ A• A╞ if and only if ╞ (¬A)

• A╞ B if and only if ╞ A ⊃⊃⊃⊃ B• ╞ A if and only if (¬A) ╞ A

Page 27: Introduction

LLIIPP66

CC

LLIIPP66

CC

Proof of the Deduction Theorem

• If╞ A ⊃⊃⊃⊃ B then we are on line 1, 3 et 4 and in all these cases A ╞ B

Indeed, if A is true, (line 1), B is true and in the 2 other cases, A is false

vvv

(A ⊃ B )BA

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

other cases, A is false

• If A ╞ B then╞ A ⊃⊃⊃⊃ B If A is true, (line 1), B is true and if A is false, no

matter the value of B, which corresponds to lines 1, 3 and 4 vff

vvf

ffv

Page 28: Introduction

LLIIPP66

CC

LLIIPP66

CC

Theorems• Reductio ad absurdum theorem: p is a logical consequence of f1,

f2, … fq iff f 1 ∧ f2, …∧ fq ∧ ¬p is unsatisfiable

• Atom substitution theorem: if a is a valid formula built on

atomic propositions p1, p2, … pq every formula a’ built by

replacing p, p , … p with P , P , … P is a is also a tautology

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

replacing p1, p2, … pq with P1, P2, … Pq is a is also a tautology

(i.e. a valid formula).

• Theorem: if A is valid and if B is a logical consequence of A,

then B is valid [if╞ A ⊃⊃⊃⊃ B and╞ A then╞ B ]

Page 29: Introduction

LLIIPP66

CC

LLIIPP66

CC

Exercise (cf. Kleene)Brown, Jones and Smith are suspected of tax fraud; they

testify as follows:

Brown: Jones is guilty and Smith is innocent

Jones: If Brown is guilty, then Smith is also guilty

Smith: I am innocent, but at least one of the two others is guilty

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

guilty

B, J and S are the three propositions Brown is innocent, Jones is Innocentand Smith is innocent.

Brown: ¬J ∧ S

Jones: ¬B ⊃ ¬S

Smith: S ∧ (¬J ∨ ¬B)

Page 30: Introduction

LLIIPP66

CC

LLIIPP66

CC

Exercise (continued)

1. Are the testimony compatible?

2. Does the testimony of anyone follow from the testimony of another?

3. If all are innocent, who made a wrong testimony?

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

testimony?

4. If all the testimonies are true, who is guilty, who is innocent?

5. If the innocent tell the truth and the guilty lie, who is guilty, who is innocent?

Page 31: Introduction

LLIIPP66

CC

LLIIPP66

CC

Truth table

fvfffv

fvfvfv

vfffvv

fvfvvv

S ∧ (¬J ∨ ¬B)¬B ⊃ ¬S¬J ∧ SBSJ

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS fvffff

fvfvff

vfvfvf

vvvvvf

fvfffv

Page 32: Introduction

LLIIPP66

CC

LLIIPP66

CC

Are the testimony compatible?

fvfffv

fvfvfv

vfffvv

fvfvvv

S ∧ (¬J ∨ ¬B)¬B ⊃ ¬S¬J ∧ SBSJ

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS fvffff

fvfvff

vfvfvf

vvvvvf

fvfffv

Page 33: Introduction

LLIIPP66

CC

LLIIPP66

CC

Does the testimony of anyone follow from the testimony of another?

fvfvfv

vfffvv

fvfvvv

S ∧ (¬J ∨ ¬B)¬B ⊃ ¬S¬J ∧ SBSJ

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS fvffff

fvfvff

vfvfvf

vvvvvf

fvfffv

Page 34: Introduction

LLIIPP66

CC

LLIIPP66

CC

If testimonies are all true, who is innocent?

vfffvv

fvfvvv

S ∧ (¬J ∨ ¬B)¬B ⊃ ¬S¬J ∧ SBSJ

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS

fvffff

fvfvff

vfvfvf

vvvvvf

fvfffv

fvfvfv

vfffvv

Page 35: Introduction

LLIIPP66

CC

LLIIPP66

CC

If innocent tell the truth and guilty lie?

fvfvfv

vfffvv

fvfvvv

S ∧ (¬J ∨ ¬B)¬B ⊃ ¬S¬J ∧ SBSJ

ACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIEACASA ACASA -- Université Pierre et Marie CURIEUniversité Pierre et Marie CURIE

CCNNRRSS

CCNNRRSS fvffff

fvfvff

vfvfvf

vvvvvf

fvfffv