Logical Inference
CS 3793/5233 Artificial Intelligence Logical Inference – 1 Logic
⊲ Logic We want to tell our computers facts that are Propositional Logic
Examples true of the world. Proof Procedures “It is raining.” Consistency-Based Diagnosis Some of these facts specify how one thing is The Limitations of Logic related to another. “It is raining implies it is wet.” We want our computers to be able to infer what else must be true of the world. “It is wet.” A logic is a system for inference from facts.
CS 3793/5233 Artificial Intelligence Logical Inference – 2 Syntax
Logic A proposition is something that is true or false. Propositional Logic An atomic proposition or atom consists of a ⊲ Syntax Informal Semantics single symbol. (≈ boolean variable) Informal Example Formal Semantics 1 A compound proposition is constructed from Formal Semantics 2
Examples simpler propositions p and q using logical Proof Procedures operators (≈ boolean expression): Consistency-Based Diagnosis – ¬p (read “not p”)–negation The Limitations of Logic – p ∧ q (read “p and q”)–conjunction – p ∨ q (read “p or q”)–disjunction – p → q (read “p implies q”)–implication – q ← p (read “q if p”)–implication – p ↔ q (read “p iff q”)–equivalence [Note: I prefer using → to ←.]
CS 3793/5233 Artificial Intelligence Logical Inference – 3 Informal Semantics
Logic Semantics maps between symbols and the world. Propositional Logic Syntax Informal Begin with a task domain. ⊲ Semantics Informal Example Choose symbols in the computer to denote Formal Semantics 1 Formal Semantics 2 propositions. Examples Symbol ≈ variable name Proof Procedures Consistency-Based Tell the system knowledge about the domain. Diagnosis Knowledge ≈ code and inputs The Limitations of Logic Ask the system true/false questions. Ask questions ≈ run a function The system should answer true, false or unknown as appropriate. You can interpret the answer because you know the meaning of the symbols.
CS 3793/5233 Artificial Intelligence Logical Inference – 4 Informal Semantics Example
Logic In computer: Propositional Logic Syntax sw up ∧ power ∧ unlit l1 → l1 broken Informal Semantics Informal ⊲ Example In user’s mind: sw up = switch is up, Formal Semantics 1 Formal Semantics 2 power = there is power in, Examples unlit l1 = light #1 isn’t lit, Proof Procedures l broken Consistency-Based 1 = light #1 is broken Diagnosis The computer doesn’t know the meaning of The Limitations of Logic the symbols. The user can interpret the symbols using their meaning.
CS 3793/5233 Artificial Intelligence Logical Inference – 5 Formal Semantics 1
Logic An interpretation I maps atoms to true or Propositional Logic Syntax false. Informal Semantics Informal Example Based on how logical operators work, an Formal ⊲ Semantics 1 Formal Semantics 2 interpretation maps each proposition to a truth Examples value. Proof Procedures Propositions may have different truth values in Consistency-Based Diagnosis different interpretations. The Limitations of Logic p q ¬p p ∧ q p ∨ q p → q q ← p p ↔ q true true false true true true true true true false false false true false false false false true true false true true true false false false true false false true true true
CS 3793/5233 Artificial Intelligence Logical Inference – 6 Formal Semantics 2
Logic A knowledge base is a set of propositions that Propositional Logic Syntax the agent is given as being true. Informal Semantics Informal Example A model of knowledge base is an Formal Semantics 1 Formal ⊲ Semantics 2 interpretation in which all the propositions in Examples the knowledge base are true. Proof Procedures KB p Consistency-Based If is a knowledge base and is a Diagnosis proposition, KB entails p (written KB |= p) The Limitations of Logic if p is true in every model of KB. KB |= p means that no interpretation exists in which KB is true and p is false. If KB |= p we also say p logically follows from KB, or p is a logical consequence of KB.
CS 3793/5233 Artificial Intelligence Logical Inference – 7 Simple Example
Logic KB = {p → q, p, s → r} Propositional Logic
Examples ⊲ Simple Example p q r s model? Simple Example Electrical Environment I1 true true true true Representation I2 false false false false Proof Procedures Consistency-Based I3 true true false false Diagnosis The Limitations of I4 true true true false Logic I5 true true false true
Which of p, q, r, s are entailed by KB?
CS 3793/5233 Artificial Intelligence Logical Inference – 8 Simple Example
Logic KB = {p → q, p, s → r} Propositional Logic
Examples Simple Example p q r s model of KB? ⊲ Simple Example Electrical Environment I1 true true true true yes Representation I2 false false false false no Proof Procedures Consistency-Based I3 true true false false yes Diagnosis The Limitations of I4 true true true false yes Logic I5 true true false true no
Which of p, q, r, s are entailed by KB? p and q
CS 3793/5233 Artificial Intelligence Logical Inference – 9 Electrical Environment
Logic
Propositional Logic
Examples Simple Example Simple Example Electrical ⊲ Environment Representation
Proof Procedures Consistency-Based Diagnosis The Limitations of Logic
CS 3793/5233 Artificial Intelligence Logical Inference – 10 Representation
Logic light l live w ok l lit l Propositional Logic 1 0 ∧ 1 → 1 Examples light l2 live w1 ∧ up s2 → live w0 Simple Example Simple Example down s1 live w2 ∧ down s2 → live w0 Electrical Environment up s2 live w3 ∧ up s1 → live w1 ⊲ Representation Proof Procedures up s3 live w3 ∧ down s1 → live w2 Consistency-Based Diagnosis ok l1 live w4 ∧ ok l2 → lit l2 The Limitations of Logic ok l2 live w3 ∧ up s3 → live w4 ok cb1 live w3 → live p1 ok cb2 live w5 ∧ ok cb1 → live w3 live outside live w6 → live p2 live w5 ∧ ok cb2 → live w6 live outside → live w5
CS 3793/5233 Artificial Intelligence Logical Inference – 11 Proofs
Logic A proof is a derivation that a proposition Propositional Logic
Examples logically follows from a knowledge base. Proof Procedures Given a proof procedure, KB ⊢ p means p can ⊲ Proofs Brute Force be derived or proved from KB. CSP Inference Definite Clauses Recall KB |= p means KB entails p, that p is Example Contradiction true in all models of KB. Inference Rules Resolution A proof procedure is sound if KB ⊢ p only if Example Consistency-Based KB |= p. Anything that is proved is also Diagnosis The Limitations of entailed. Logic A proof procedure is complete if KB |= p then also KB ⊢ p. Everything that is entailed can be proved.
CS 3793/5233 Artificial Intelligence Logical Inference – 12 Brute Force Inference
Logic Enumerate all interpretations. Propositional Logic Examples Determine which interpretations are models of Proof Procedures the KB. Proofs ⊲ Brute Force Determine which atoms (and any other CSP Inference Definite Clauses propositions of interest) are true in all models Example Contradiction (or false in all models). Inference Rules n Resolution This is Ω(2 ) where n is the number of atoms. Example Consistency-Based Diagnosis The Limitations of Logic
CS 3793/5233 Artificial Intelligence Logical Inference – 13 CSP Inference
Logic Set up KB as a CSP. Each atom is a variable Propositional Logic
Examples with two possible values. Each proposition in Proof Procedures the KB is a constraint. Proofs Brute Force Solutions of CSP = models of KB. ⊲ CSP Inference Definite Clauses Run arc consistency/domain splitting. Example Contradiction Don’t stop after finding one CSP solution (KB Inference Rules Resolution model). Find them all. Example Consistency-Based Determine which atoms are true in all models Diagnosis The Limitations of (or false in all models). Logic This is still potentially exponential, but more efficient than brute force. See Section 4.6.1.
CS 3793/5233 Artificial Intelligence Logical Inference – 14 Definite Clause Inference
Logic Suppose all propositions in KB are definite Propositional Logic
Examples clauses, either:
Proof Procedures Proofs – an atom (e.g., an observation), or Brute Force CSP Inference – of the form p → q, where p and q are ⊲ Definite Clauses Example atoms (e.g., a rule about the behavior of Contradiction Inference Rules the world) Resolution Example – of the form p1 ∧ . . . ∧ pk → q, where q and Consistency-Based Diagnosis each pi are atoms The Limitations of Logic Running CSP inference is efficient (linear in the length of the KB). See Section 5.2.
CS 3793/5233 Artificial Intelligence Logical Inference – 15 Definite Clause Example
Logic KB = {a, b, a → c, b ∧ c → d, d ∧ e → f} Propositional Logic
Examples Proof Procedures Know a and b. Proofs Brute Force CSP Inference Definite Clauses Derive c from a and a → c. ⊲ Example Contradiction Inference Rules d b c b c d Resolution Derive from and and ∧ → Example Consistency-Based Diagnosis Cannot derive e or f. The Limitations of Logic
CS 3793/5233 Artificial Intelligence Logical Inference – 16 Proof by Contradiction
Logic Suppose we want to determine if KB |= p. Propositional Logic ′ Examples Let KB = KB ∪ {¬p} Proof Procedures KB′ Proofs Determine that no model exists for . Brute Force Conclude that KB |= p. CSP Inference Definite Clauses Should probably show that KB has at least Example ⊲ Contradiction one model. Inference Rules Resolution Example Consistency-Based Diagnosis The Limitations of Logic
CS 3793/5233 Artificial Intelligence Logical Inference – 17 Inference Rules
Logic Modus ponens is an inference rule. If p is true, Propositional Logic
Examples and if p → q is true, then q is true. Proof Procedures That is, if KB |= p and KB |= p → q, then Proofs Brute Force KB |= q. CSP Inference Definite Clauses Resolution inference rule (really, two rules) Example Contradiction ⊲ Inference Rules – If KB |= p ∨ q and KB |= ¬p, then Resolution Example KB |= q. Consistency-Based Diagnosis – If KB |= p ∨ q and KB |= ¬p ∨ r, then The Limitations of KB q r Logic |= ∨ . Remember p and q and r can be any propositions, not just atoms.
CS 3793/5233 Artificial Intelligence Logical Inference – 18 Resolution Theorem Proving
Logic Resolution theorem proving is a sound and Propositional Logic
Examples complete inference procedure for propositional Proof Procedures logic. Proofs Brute Force Transform the KB to conjunctive normal CSP Inference Definite Clauses form, meaning each propositions in the KB is Example Contradiction of the form l or l1 ∨ . . . ∨ lk, where each li is a Inference Rules ⊲ Resolution literal, an atom or the negation of an atom. Example ′ Consistency-Based To show KB |= p, let KB = KB ∪ {¬p}, Diagnosis ′ The Limitations of and ensure KB is in CNF. Logic Proof is by deriving a contradiction, derive both a and ¬a for some atom a. Worst-case exponential-time. Lots of approaches to reduce the exponential.
CS 3793/5233 Artificial Intelligence Logical Inference – 19 Resolution Example
Logic KB = {a∨b, b∨c, ¬a∨¬b, ¬a∨¬c, ¬b∨¬c} Propositional Logic
Examples Proof Procedures To prove KB |= b, add ¬b and prove a Proofs Brute Force contradiction using the resolution inference rule. CSP Inference Definite Clauses Example ~b a V b b V c ~a V ~b ~a V ~c ~b V ~c Contradiction Inference Rules Resolution ⊲ Example a c ~a V c b V ~c a V ~c Consistency-Based Diagnosis The Limitations of Logic b ~b ~c ~a
CS 3793/5233 Artificial Intelligence Logical Inference – 20 Conflicts
Logic Assume components are working normally. Propositional Logic Examples Need a set of assumables A, e.g., Proof Procedures A = {ok l1,ok l2,ok s1,...} Consistency-Based Diagnosis Show that KB ∪ A leads to a contradiction, ⊲ Conflicts Conflict Example which implies A is false, that something’s Conflict Example Electrical wrong. In this case, A is called a conflict. Environment Representation Want to isolate the problem, e.g., is there a Electrical Conflicts Diagnosis single fault that is consistent with KB? Diagnosis Examples Diagnosis Examples C is a minimal conflict if C ⊆ A, C is a The Limitations of Logic conflict, and no proper subset of C is a conflict.
CS 3793/5233 Artificial Intelligence Logical Inference – 21 Conflict Example
Logic A = {c,d,e,z} Propositional Logic
Examples Proof Procedures KB = {¬a ∨ ¬b, c → a, d → b, e → b} Consistency-Based Diagnosis Conflicts ⊲ Conflict Example A is a conflict. Conflict Example Electrical Assuming A implies ¬a ∨ ¬b is false. Environment Representation Electrical Conflicts Diagnosis What subsets of A are minimal conflicts? Diagnosis Examples Diagnosis Examples The Limitations of Logic
CS 3793/5233 Artificial Intelligence Logical Inference – 22 Conflict Example
Logic A = {c,d,e,z} Propositional Logic
Examples Proof Procedures KB = {¬a ∨ ¬b, c → a, d → b, e → b} Consistency-Based Diagnosis Conflicts Conflict Example A is a conflict. ⊲ Conflict Example Electrical Assuming A implies ¬a ∨ ¬b is false. Environment Representation Electrical Conflicts A Diagnosis What subsets of are minimal conflicts? Diagnosis Examples c,d c,e Diagnosis Examples { } and { } The Limitations of Logic
CS 3793/5233 Artificial Intelligence Logical Inference – 23 Electrical Environment
Logic
Propositional Logic
Examples
Proof Procedures Consistency-Based Diagnosis Conflicts Conflict Example Conflict Example Electrical ⊲ Environment Representation Electrical Conflicts Diagnosis Diagnosis Examples Diagnosis Examples The Limitations of Logic
CS 3793/5233 Artificial Intelligence Logical Inference – 24 Representation
Logic up s live w ok l lit l Propositional Logic 1 0 ∧ 1 → 1 Examples up s2 live w1 ∧ up s2 ∧ ok s2 → live w0 Proof Procedures up s3 live w2 ∧ down s2 ∧ ok s2 → live w0 Consistency-Based Diagnosis live outside Conflicts live w3 ∧ up s1 ∧ ok s1 → live w1 Conflict Example lit l live w down s ok s live w Conflict Example ¬ 1 3 ∧ 1 ∧ 1 → 2 Electrical Environment ¬lit l2 live w4 ∧ ok l2 → lit l2 ⊲ Representation Electrical Conflicts live w3 ∧ up s3 ∧ ok s3 → live w4 Diagnosis Diagnosis Examples live w3 → live p1 Diagnosis Examples live w5 ∧ ok cb1 → live w3 The Limitations of Logic live w6 → live p2 live w5 ∧ ok cb2 → live w6 live outside → live w5
CS 3793/5233 Artificial Intelligence Logical Inference – 25 Electrical Conflicts
Logic Each ok atom is an assumable. This is Propositional Logic
Examples simplified by no ok atoms for wires. Proof Procedures To infer lit l1 (which would contradict Consistency-Based Diagnosis ¬lit l1), need ok cb1, ok s1, ok s2 and ok l1. Conflicts Conflict Example {ok cb1,ok s1,ok s2,ok l1} is a conflict. Conflict Example Electrical lit l Environment To infer 2 (which would contradict Representation Electrical ¬lit l2), need ok cb1, ok s3 and ok l2. ⊲ Conflicts Diagnosis {ok cb1,ok s3,ok l2} is a conflict. Diagnosis Examples Diagnosis Examples The Limitations of Logic
CS 3793/5233 Artificial Intelligence Logical Inference – 26 Diagnosis
Logic If C is a minimal conflict, then some element Propositional Logic
Examples of C is false. Proof Procedures Explanation: C is a conjunction of assumables Consistency-Based Diagnosis a1 ∧ a2 ∧ . . .. Conflicts Conflict Example If C is false, then ¬C = ¬a1 ∨ ¬a2 ∨ . . . is Conflict Example Electrical Environment true. Representation Electrical Conflicts Some element of each minimal conflict must ⊲ Diagnosis Diagnosis Examples be false. Diagnosis Examples A diagnosis is a subset of assumables D ⊆ A The Limitations of Logic such that D includes at least one element from each minimal conflict. A diagnosis D is minimal if no subset of D is a diagnosis.
CS 3793/5233 Artificial Intelligence Logical Inference – 27 Diagnosis Examples
Logic In the first example, {c,d} and {c.e} were Propositional Logic Examples minimal conflicts. Proof Procedures What are the minimal diagnoses? Consistency-Based Diagnosis Conflicts Conflict Example In the second example, the minimal conflicts Conflict Example Electrical Environment were {ok cb1,ok s1,ok s2,ok l1} and Representation Electrical Conflicts {ok cb1,ok s3,ok l2}. Diagnosis Diagnosis What are the minimal diagnoses? ⊲ Examples Diagnosis Examples The Limitations of Logic
CS 3793/5233 Artificial Intelligence Logical Inference – 28 Diagnosis Examples
Logic In the first example, {c,d} and {c.e} were Propositional Logic Examples minimal conflicts. Proof Procedures What are the minimal diagnoses? Consistency-Based Diagnosis {c} and {d.e} Conflicts Conflict Example In the second example, the minimal conflicts Conflict Example Electrical Environment were {ok cb1,ok s1,ok s2,ok l1} and Representation Electrical Conflicts {ok cb1,ok s3,ok l2}. Diagnosis Diagnosis Examples What are the minimal diagnoses? Diagnosis ⊲ Examples {ok cb1} and several double fault possibilities: The Limitations of Logic {ok s1,ok s3}, {ok s1,ok l2}, {ok s2,ok s3}, {ok s2,ok l2}, {ok l1,ok s3}, {ok l1,ok l2},
CS 3793/5233 Artificial Intelligence Logical Inference – 29 Limitations of Logic Assumes we can write down the truth. Logic
Propositional Logic – The world is round. Examples – The sky is blue. Proof Procedures Consistency-Based – What goes up must come down. Diagnosis The Limitations of Assumes our observations are always true. Logic Limitations of – Optical illusions. ⊲ Logic – Photoshopping. – Referees and umpires. Assumes our inferences are certain. – Overturned convictions. – Car accidents. – Scams. No real-world inference is truly logical.
CS 3793/5233 Artificial Intelligence Logical Inference – 30