Automated reasoning and theorem proving Introduction logic in

  • Slides: 39
Download presentation
Automated reasoning and theorem proving Introduction: logic in AI Automated reasoning: Resolution Unification Normalization

Automated reasoning and theorem proving Introduction: logic in AI Automated reasoning: Resolution Unification Normalization

Introduction: Motivating example Automated reasoning Logic: Syntax Model semantics Logical entailment

Introduction: Motivating example Automated reasoning Logic: Syntax Model semantics Logical entailment

The AI dream in the 60’s: ¤ Logic allows to express almost everything ‘formally’.

The AI dream in the 60’s: ¤ Logic allows to express almost everything ‘formally’. ¤ Logic also allows to prove “theorems” based on the information given. è Can we exploit this to build automated reasoning systems ? ? 3

Underlying premises: ¤ Logic is the ‘assembly language’ of knowledge and is closely related

Underlying premises: ¤ Logic is the ‘assembly language’ of knowledge and is closely related to natural language. In logic almost all kinds of knowledge can be represented formally and unambiguously. ¤Since computers are supposed to process the knowledge, it should be expressed formally and unambiguously. ¤Logical deduction allows us to derive systematically new knowledge from the existing one. Automating deduction ? ? 4

Example: ¤ The following knowledge is given : 1. Marcus was a man. 2.

Example: ¤ The following knowledge is given : 1. Marcus was a man. 2. Marcus was a Pompeian. 3. All Pompeians were Romans. 4. Caesar was a ruler. 5. All Romans were either loyal to Caesar or hated him. 6. Everyone is loyal to someone. 7. People only try to assassinate rulers to whom they are not loyal. 8. Marcus tried to assassinate Caesar. ¤ Can we automatically answer the following questions? u Was Marcus loyal to Caesar? u Did Marcus hate Caesar? 5

Conversion to the First Order Logic: ¤ Representation of facts: 1. Marcus was a

Conversion to the First Order Logic: ¤ Representation of facts: 1. Marcus was a man(Marcus) 2. Marcus was a Pompeian(Marcus) 4. Caesar was a ruler(Caesar) 8. Marcus tried to assassinate Caesar. try_assassinate(Marcus, Caesar) 6

Conversion to the First Order Logic (2): ¤ General representation (representation of rules): 3.

Conversion to the First Order Logic (2): ¤ General representation (representation of rules): 3. All Pompeians were Romans. x Pompeian(x) Roman(x) 5. All Romans were either loyal to Caesar or hated him. x Roman(x) (loyal_to(x, Caesar) hates(x, Caesar)) ~(loyal_to(x, Caesar) hates(x, Caesar)) XOR 6. Everyone is loyal to someone. x y loyal_to(x, y) 7. People only try to assassinate rulers to whom they are not loyal. x y person(x) ruler(y) try_assassinate(x, y) ~loyal_to(x, y) 7

The “theorem” ? Was Marcus loyal to Caesar? Try, for example, to prove that

The “theorem” ? Was Marcus loyal to Caesar? Try, for example, to prove that he was not : ~loyal_to(Marcus, Caesar) Did Marcus hate Caesar? Prove that he did: hates(Marcus, Caesar) 8

A proof using backwardreasoning problem-reduction: ~loyal_to(Marcus, Caesar) x y person(x) ruler(y) try_assassinate(x, y) ~loyal_to(x,

A proof using backwardreasoning problem-reduction: ~loyal_to(Marcus, Caesar) x y person(x) ruler(y) try_assassinate(x, y) ~loyal_to(x, y) + substitution: x/Marcus y/Caesar person(Marcus) ruler(Caesar) try_assassinate(Marcus, Caesar) ~loyal_to(Marcus, Caesar) AND + Modus ponens person(Marcus) try_assassinate(Marcus, Caesar) Extra rule: x man(x) person(x) man(Marcus) 1. ruler(Cesar) Done! 4. 8. Done! 9

Problems: 1) knowledge representation: ¤ Natural language is imprecise / ambiguous è see “People

Problems: 1) knowledge representation: ¤ Natural language is imprecise / ambiguous è see “People only try …” ¤ Obvious information is easily forgotten. è see man <-> person ¤ Some information is more difficult to represent in logic. è Vb. : “perhaps …”, “possibly…”, “probably…”, “the chance of … is 45%”, ¤ Logic is inconvenient from a software engineering perspective. è too ‘fine-grained’ (like an assembly language) 10

Problems: 2) Problem solving: ¤ All trade-offs that we had with search methods based

Problems: 2) Problem solving: ¤ All trade-offs that we had with search methods based on states space representation: è backward/forward, tree/graph, OR-tree/AND-OR, control aspects, . . . ¤ What deduction rules are needed in general? è Example: prove “ hates(Marcus, Caesar) “ The only applicable rule is: x Roman(x) loyal_to(x, Caesar) hates(x, Caesar) Modus ponens? ? ? ¤ How do we handle x and y ? 11

Problems: 2) Problem solving (2): ¤ How to compute substitutions in the general case

Problems: 2) Problem solving (2): ¤ How to compute substitutions in the general case ? x y person(x) ruler(y) try_assassinate(x, y) ~loyal_to(x, y) In general: more complex + substitution: x/Marcus y/Caesar ¤ Which theorem do we try to prove? è Ex. : loyal_to(Marcus, Caesar) or ~loyal_to(Marcus, Caesar) ¤ How to handle equality of objects? è Problem: combinatorial explosion of the derived equalities (reflexivity, symmetry, transitivity, …) ¤ How to guarantee correctness/completeness? 12

The formal model semantics of Logic The meaning of “Logical entailment”

The formal model semantics of Logic The meaning of “Logical entailment”

Propositional logic

Propositional logic

Basic concepts: In propositional logic: The alphabet: connectors weather_is_rainy ~ joe_has_an_umbrella Atomic propositions punctuation

Basic concepts: In propositional logic: The alphabet: connectors weather_is_rainy ~ joe_has_an_umbrella Atomic propositions punctuation ( ) Well-formed formulas: ~ weather_is_rainy joe_has_an_umbrella weather_is_rainy Notation: p, q, r : atomic propositions. 15

Semantics (meaning) ¤ In general (for all knowledge representation formalisms): è 2 approaches to

Semantics (meaning) ¤ In general (for all knowledge representation formalisms): è 2 approaches to define semantics: 1. Intuitive (natural) semantics: è Describe the meaning by means of a natural language è Exs. (propositional logic): u : “implies” u ~ : “not true that” u : “or” u p q : “p if and only if q” u ~ p r : “not p and r” è every symbol and every well-formed formula gets meaning through the associated natural language 16

Semantics (2) 2. Transformational semantics: è Describe the meaning by converting to an associated

Semantics (2) 2. Transformational semantics: è Describe the meaning by converting to an associated “mathematical” object è In propositional logic : u the set of all propositional symbols that are logically entailed by the given formulas: Logically entailed p p ~q p q r p q q p r p q r r q r 17

But how to define “logical entailment” ? ¤ NOT as: è Everything that we

But how to define “logical entailment” ? ¤ NOT as: è Everything that we can derive from the formulas ¤ SINCE: è At this moment we do not know yet: u “what is a complete set of the derivation rules” è This is exactly what Automated Reasoning aims to find out! ¤ BUT by: è Interpretations è Models 18

Interpretation: = a function that assigns a truth value to each “atomic” formula Also

Interpretation: = a function that assigns a truth value to each “atomic” formula Also provides (indirectly) truth values for each well-formed formula p T T F F q T F ~p F F T T p q T F F F p q T T T F p q T F T T p q T F F T Truth table 19

Model ¤ Given a set of formulas S: a model is an interpretation that

Model ¤ Given a set of formulas S: a model is an interpretation that makes all formulas in S true Example: p ~q p S q r Model: p T q F r T p ~q q r T T p T 20

Logical entailment: ¤ Given a set of formulas S and a formula F: F

Logical entailment: ¤ Given a set of formulas S and a formula F: F is logically entailed by S ( S |= F ), if all models of S also make F true. Example: p ~q p S F: q r r p (the only) Model: p T q F r T r p T 21

Predicate logic

Predicate logic

constants Yvonne Yvette The alphabet: connectors variables x ~ y z function symbols quantifiers

constants Yvonne Yvette The alphabet: connectors variables x ~ y z function symbols quantifiers predicate symbols punctuation f g , ) h q p ( Terms: y Yvonne f(x, g(Yvette)) Well-formed formulas: p(Yvonne) p(x) ~q(x) z p(z) x y p(x) q(y) p(f(Yvonne, Yvette) 23

Formally: ¤ An alphabet consists of variables, constants, function symbols, predicate symbols (all user-defined)

Formally: ¤ An alphabet consists of variables, constants, function symbols, predicate symbols (all user-defined) and of connectors, punctuations en quantifiers. ¤ Terms are either: è variables, è constants, è function symbols provided with as many terms as arguments, as the function symbol expects. ¤ Well-formed formulas are constructed from predicate symbols, provided with terms as arguments, and from connectors, quantifiers and punctuation – according to the rules of the connectors. 24

Example: è Alphabet: { {0}, {x, y}, {s}, {odd, even}, Con, Pun, Quan} è

Example: è Alphabet: { {0}, {x, y}, {s}, {odd, even}, Con, Pun, Quan} è Terms: { 0, s(0), s(s(0)), s(s(s(0))), x, s(x), s(s(x)), s(s(s(x))), y, s(y), s(s(y)), s(s(s(y))), … … …} è Well-formed formulas: odd(0), even(s(0)), … odd(x), odd(s(y)), … odd(x) even(s(s(x))), … x ( odd(x) even(s(x)) ), … odd(y) x (even( s(x))), . . . 25

Interpretation: = a set D (the domain), and ¤ a function that maps constants

Interpretation: = a set D (the domain), and ¤ a function that maps constants to D, and ¤ a function that maps function symbols to functions: D -> D, and ¤ a function that maps predicate symbols to predicates: D -> Booleans. x Booleans true false Example: y A 0 s odd “even” 0 1 2 D=N 3 26

Assigning truth values: 1. To ground atomic formulas: è form: p(f(a), g(a, b)) Example:

Assigning truth values: 1. To ground atomic formulas: è form: p(f(a), g(a, b)) Example: I( odd( s ( s( 0 ) ) ) = ? = I (odd) ( I(s) ( I(0) ) = “even” ( succ ( 0 ) ) ) = “even” ( succ ( 1 ) ) = “even” ( 2 ) = true 27

Assigning truth values (2): 2. For closed well-formed formulas: (= no non-quantified variables) è

Assigning truth values (2): 2. For closed well-formed formulas: (= no non-quantified variables) è x F(x) is true if: u for all d D: I( F(d) ) = true è x F(x) is true if: u there exists d D such that: I( F(d) ) = true è further: use the truth tables. Example: I( x odd( s ( x ) ) odd(x) ) = ? = true if for all d in N: I (odd( s (d) ) odd(d) ) = true = “even” ( succ(d) ) “even” (d) Assume: d = 0, then: = false true Truth tables: false ! 28

Semantics / Logical entailment: ¤ Exactly as in propositional logic ! ¤ Given a

Semantics / Logical entailment: ¤ Exactly as in propositional logic ! ¤ Given a set of formulas S: a model is an interpretation that makes all formulas in S true. ¤ Given a set of formulas S and a formula F: F is logically entailed by S ( S |= F ), if all models of S also make F true. ¤ Additional: inconsistency: ¤ Given a set of formulas S: S is inconsistent if S has no models. Example: S = { p(a), ~p(a)} 29

Marcus example: Marcus C y x ruler V A F= Caesar P man person

Marcus example: Marcus C y x ruler V A F= Caesar P man person Pompeian try_assassinate Roman loyal_to hates “Intended” interpretation: D = world of ~40 VC. “Caesar” true Boolean false “Marcus” “was_pompeian” “was_ruler” true false Boolean Is a model IF ALL FORMULAS ARE CORRECT 30

Marcus example: Marcus C x y V A F= Caesar P man person ruler

Marcus example: Marcus C x y V A F= Caesar P man person ruler Pompeian try_assassinate Roman loyal_to hates N 3 4 I(man) = I(person)= I(Roman) = “natural number” I(try_assassinate) = “ > ” I(Pompeian) = “even number” I(loyal_to) = “divides” I(ruler) = “prime number” I(hates) = “doesn’t divide” 31

Model ? ? YES ! 1. Marcus was a man. 4 is a natural

Model ? ? YES ! 1. Marcus was a man. 4 is a natural number 2. Marcus was Pompeian. 4 is an even number 4. Caesar was a ruler. 3 is a prime number 8. Marcus tried to assassinate Caesar. 4 > 3 3. All Pompeians were Romans. Even numbers are naturals. 5. All Romans were either loyal to Caesar or hated him. A number either divides 3 or doesn’t divide 3. 6. Everybody is loyal to somebody. Each number is a divisor of some number. 7. People try to assassinate only those rulers to whom they are not loyal. A natural number that is greater than a prime number doesn’t divide the prime number. 32

“Logic is all form, no content” person(x) mortal(x) person(Socrates) January(x) cold(x) January(21/1/01) P(x) Q(x)

“Logic is all form, no content” person(x) mortal(x) person(Socrates) January(x) cold(x) January(21/1/01) P(x) Q(x) P(A) mortal(Socrates) cold(21/1/01) Q(A) Only the underlying structure of a set of logical formulas is important for the conclusions! (up to the names isomorphism) But from the knowledge representation perspective also the ‘contents’ is important. 33

Relation with respect to other courses:

Relation with respect to other courses:

Logic as a foundation for AI A much deeper and more formal study of

Logic as a foundation for AI A much deeper and more formal study of Logic for Knowledge Representation and Reasoning ! 35

Programming Languages and Programming Methodologies Logic-based programming languages (Prolog/CLP) 36

Programming Languages and Programming Methodologies Logic-based programming languages (Prolog/CLP) 36

Selected Topics in Logic Programming Formal studies of semantics and formal methods (analysis, termination)

Selected Topics in Logic Programming Formal studies of semantics and formal methods (analysis, termination) of logic-based programming languages (also beyond Prolog) 37

Fundamentals of Artificial Intelligence Logic-based programming languages (Prolog/CLP) Formal semantics and analysis First Order

Fundamentals of Artificial Intelligence Logic-based programming languages (Prolog/CLP) Formal semantics and analysis First Order predicate Logic Techniques for automated reasoning Problem-representation in logic Mostly in the exercises 38

Methodology for knowledge representation? ¤ Very complicated. Not many simple guidelines. ¤ Basis: èChoose

Methodology for knowledge representation? ¤ Very complicated. Not many simple guidelines. ¤ Basis: èChoose an alphabet that allows us to represent all objects and all relations from the problem domain: u What are the basic objects, functions and relations in your problem domain ? – Ontology: represent only the RELEVANT information u Choose constants, function and predicate symbols to represent them. è Translate every sentence in a natural language in one or more corresponding logical formulas. 39