340 likes | 360 Views
SAT-solving. SAT-solving techniques: Unit-propagation Local-search. Introduction: logic in AI. Introduction:. Automated reasoning. Motivating example. Logic: Syntax Model semantics Logical entailment. The AI dream in the 60’s:.
E N D
SAT-solving SAT-solving techniques: Unit-propagation Local-search Introduction: logic in AI
Introduction: Automated reasoning Motivating example Logic: Syntax Model semantics Logical entailment
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 ??
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 inference allows us to derive systematically new knowledge from the existing one. Automating deduction? More recently: SAT-solving Underlying premises:
1. Marcus was a man. • Was Marcus loyal to Caesar? • Did Marcus hate Caesar? Example: • The following knowledge is given : 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?
Conversion to the First Order Logic: • Representation of facts: 1. Marcus was a man. man(Marcus) 2. Marcus was a Pompeian. Pompeian(Marcus) 4. Caesar was a ruler. ruler(Caesar) 8. Marcus tried to assassinate Caesar. try_assassinate(Marcus, Caesar)
( ) ~(loyal_to(x,Caesar) hates(x,Caesar)) XOR Conversion tothe 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) 6. Everyone is loyal to someone. x yloyal_to(x,y) 7. People only try to assassinate rulers to whom they are not loyal. xy person(x) ruler(y) try_assassinate(x,y) ~loyal_to(x,y)
Try, for example, to prove that he was not : Prove that he did: The “theorem” ? • Was Marcus loyal to Caesar? ~loyal_to(Marcus,Caesar) • Did Marcus hate Caesar? hates(Marcus,Caesar)
xy person(x) ruler(y) try_assassinate(x,y) ~loyal_to(x,y) + substitution: x/Marcus y/Caesar AND person(Marcus) ruler(Caesar) try_assassi-nate(Marcus,Caesar) ~loyal_to(Marcus,Caesar) person(Marcus) try_assassinate(Marcus, Caesar) Extra rule: x man(x) person(x) ruler(Cesar) 8. 4. 1. man(Marcus) Done! Done! Done! A proof using backward-reasoning problem-reduction: ~loyal_to(Marcus,Caesar) + Modus ponens
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)
The only applicable rule is: x Roman(x) loyal_to(x,Caesar) hates(x,Caesar) Modus ponens??? Problems:2) Deductive 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) “ • How do we handle x andy ?
xy person(x) ruler(y) try_assassinate(x,y) ~loyal_to(x,y) In general: more complex + substitution: x/Marcus y/Caesar Problems:2) Deductive problem solving: • How to compute substitutions in the general case? • 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?
The formal model semantics of Logic The meaning of “Logical entailment”
The alphabet: connectors punctuation weather_is_rainy ~ joe_has_an_umbrella ) ( Atomic propositions Well-formed formulas: ~weather_is_rainy joe_has_an_umbrellaweather_is_rainy Notation: p, q, r : atomic propositions. Basic concepts: In propositional logic:
1. Intuitive (natural) semantics: Semantics (meaning) • In general (for all knowledge representation formalisms): • 2 approaches to define semantics: • Describe the meaning by means of a natural language • Exs. (propositional logic): • : “implies” • ~ : “not true that” • : “or” • p q : “p if and only if q” • ~ p r : “not p and r” • every symbol and every well-formed formula gets meaning through the associated natural language
2. Transformational semantics: p ~ q p q p r q r q r p p q r Semantics (2) • Describe the meaning by converting to an associated “mathematical” object • In propositional logic : • the set of all propositional symbols that are logically entailed by the given formulas: Logically entailed p q r
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: • “what is a complete set of the derivation rules” • This is exactly what Automated Reasoning aims to find out! • BUT by: • Interpretations • Models
Also provides (indirectly) truth values for each well-formed formula p q ~p p q p q p q p q T T F T T T T T F F F T F F F T T F T T F F F T F F T T Interpretation: = a function that assigns a truth value to each “atomic” formula Truth table
S Example: p ~ q q r p p Model: p q r p ~q q r T F T T T T Model • Given a set of formulas S: a model is an interpretation that makes all formulas in S true
S Example: p ~ q q r p (the only) Model: p q r r p T F T T 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. F: r p
Given a set of formulas S: S is satisfiable or consistent if S has a model. Satisfiability and consistency Example of an unsatisfiable set:S = { p, ~p} Relation between satisfiability and logical consequence: • Given a set of formulas S and a formula F: S|=F if and only if S U {F} is unsatisfiable/inconsistent. Automated reasoning and SAT-checking can solve the same problems.
constants The alphabet: connectors variables Yvonne x Yvette ~ y z function symbols predicate symbols f g h q p Terms: Yvonne y f(x, g(Yvette)) punctuation , ) Well-formed formulas: ( quantifiers p(Yvonne) p(x) ~q(x) z p(z) x y p(x) q(y) p(f(Yvonne, Yvette)
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.
Example: { {0}, {x,y}, {s}, {odd,even}, Con, Pun, Quan} • Alphabet: • 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))), ...
A y x 0 odd s Booleans “even” true D = N 1 0 3 2 false Example: Interpretation: • a function that maps constants to D, and = a set D (the domain), and • a function that maps function symbols to functions: D -> D, and • a function that maps predicate symbols to predicates: D-> Booleans.
Assigning truth values: 1. To ground atomic formulas: • form:p(f(a), g(a,b)) I( odd( s ( s( 0 ) ) ) ) ) = ? = I (odd) (I(s) ( I(s) (I(0)) )) = “even”(succ ( succ (0) )) = “even” (succ (1 )) = “even” (2) = true Example:
Assigning truth values (2): 2. For closed well-formed formulas: (= no non-quantified variables) • x F(x) is true if: • for all d D: I( F(d) ) = true • x F(x) is true if: • there exists d D such that: I( F(d) ) = true • further: use the truth tables. I(x odd( s ( x ) ) odd(x) )= ? = true if for all d in N: I (odd( s (d) ) odd(d) ) = true Example: = “even”(succ(d)) “even”(d) Assume: d = 0, then: = falsetrue Truth tables: false !
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. Semantics / Logical entailment: • Exactly as in propositional logic ! • Given a set of formulas S: S is inconsistent or unsatisfiable if S has no models. Example:S = { p(a), ~p(a)}
V C y Marcus x Caesar D = world of ~40 VC. “Caesar” “was_ruler” true true “Marcus” Boolean “was_pompeian” false false Boolean Marcus example: A F = ruler person P man try_assassinate Pompeian Roman loyal_to hates “Intended” interpretation: Is a model IF ALL FORMULAS ARE CORRECT
A C V Marcus F = y Caesar x person ruler P man try_assassinate Pompeian Roman loyal_to hates N 3 4 Marcus example: 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”
YES ! Model ?? 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.
person(x) mortal(x) person(Socrates) mortal(Socrates) January(x) cold(x) January(21/1/01) cold(21/1/01) P(x) Q(x) P(A) Q(A) “Logic is all form, no content” 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.