logical inference - university of texas at san antoniobylander/cs3793/notes/logic.pdfcs 3793/5233...
TRANSCRIPT
Logic
⊲ Logic
Propositional Logic
Examples
Proof Procedures
Consistency-BasedDiagnosis
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 2
We want to tell our computers facts that aretrue of the world.“It is raining.”
Some of these facts specify how one thing isrelated to another.“It is raining implies it is wet.”
We want our computers to be able to inferwhat else must be true of the world.“It is wet.”
A logic is a system for inference from facts.
Syntax
Logic
Propositional Logic
⊲ Syntax
Informal Semantics
Informal Example
Formal Semantics 1
Formal Semantics 2
Examples
Proof Procedures
Consistency-BasedDiagnosis
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 3
A proposition is something that is true or false. An atomic proposition or atom consists of a
single symbol. (≈ boolean variable) A compound proposition is constructed from
simpler propositions p and q using logical
operators (≈ boolean expression):
– ¬p (read “not p”)–negation
– 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 ←.]
Informal Semantics
Logic
Propositional Logic
Syntax
⊲InformalSemantics
Informal Example
Formal Semantics 1
Formal Semantics 2
Examples
Proof Procedures
Consistency-BasedDiagnosis
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 4
Semantics maps between symbols and the world.
Begin with a task domain. Choose symbols in the computer to denote
propositions.Symbol ≈ variable name
Tell the system knowledge about the domain.Knowledge ≈ code and inputs
Ask the system true/false questions.Ask questions ≈ run a function
The system should answer true, false orunknown as appropriate.
You can interpret the answer because youknow the meaning of the symbols.
Informal Semantics Example
Logic
Propositional Logic
Syntax
Informal Semantics
⊲InformalExample
Formal Semantics 1
Formal Semantics 2
Examples
Proof Procedures
Consistency-BasedDiagnosis
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 5
In computer:sw up ∧ power ∧ unlit l1→ l1 broken
In user’s mind: sw up = switch is up,power = there is power in,unlit l1 = light #1 isn’t lit,l1 broken = light #1 is broken
The computer doesn’t know the meaning ofthe symbols.
The user can interpret the symbols using theirmeaning.
Formal Semantics 1
Logic
Propositional Logic
Syntax
Informal Semantics
Informal Example
⊲FormalSemantics 1
Formal Semantics 2
Examples
Proof Procedures
Consistency-BasedDiagnosis
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 6
An interpretation I maps atoms to true orfalse.
Based on how logical operators work, aninterpretation maps each proposition to a truthvalue.
Propositions may have different truth values indifferent interpretations.
p q ¬p p ∧ q p ∨ q p→ q q ← p p↔ q
true true false true true true true truetrue false false false true false false falsefalse true true false true true true falsefalse false true false false true true true
Formal Semantics 2
Logic
Propositional Logic
Syntax
Informal Semantics
Informal Example
Formal Semantics 1
⊲FormalSemantics 2
Examples
Proof Procedures
Consistency-BasedDiagnosis
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 7
A knowledge base is a set of propositions thatthe agent is given as being true.
A model of knowledge base is aninterpretation in which all the propositions inthe knowledge base are true.
If KB is a knowledge base and p is aproposition, KB entails p (written KB |= p)if p is true in every model of KB.
KB |= p means that no interpretation exists inwhich KB is true and p is false.
If KB |= p we also say p logically follows fromKB, or p is a logical consequence of KB.
Simple Example
Logic
Propositional Logic
Examples
⊲ Simple Example
Simple Example
ElectricalEnvironment
Representation
Proof Procedures
Consistency-BasedDiagnosis
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 8
KB = p→ q, p, s→ r
p q r s model?I1 true true true trueI2 false false false falseI3 true true false falseI4 true true true falseI5 true true false true
Which of p, q, r, s are entailed by KB?
Simple Example
Logic
Propositional Logic
Examples
Simple Example
⊲ Simple Example
ElectricalEnvironment
Representation
Proof Procedures
Consistency-BasedDiagnosis
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 9
KB = p→ q, p, s→ r
p q r s model of KB?I1 true true true true yesI2 false false false false noI3 true true false false yesI4 true true true false yesI5 true true false true no
Which of p, q, r, s are entailed by KB?p and q
Electrical Environment
Logic
Propositional Logic
Examples
Simple Example
Simple Example
⊲ElectricalEnvironment
Representation
Proof Procedures
Consistency-BasedDiagnosis
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 10
Representation
Logic
Propositional Logic
Examples
Simple Example
Simple Example
ElectricalEnvironment
⊲ Representation
Proof Procedures
Consistency-BasedDiagnosis
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 11
light l1 live w0 ∧ ok l1→ lit l1light l2 live w1 ∧ up s2→ live w0down s1 live w2 ∧ down s2→ live w0up s2 live w3 ∧ up s1→ live w1up s3 live w3 ∧ down s1→ live w2ok l1 live w4 ∧ ok l2→ lit l2ok l2 live w3 ∧ up s3→ live w4ok cb1 live w3→ live p1ok cb2 live w5 ∧ ok cb1→ live w3live outside live w6→ live p2
live w5 ∧ ok cb2→ live w6live outside→ live w5
Proofs
Logic
Propositional Logic
Examples
Proof Procedures
⊲ Proofs
Brute Force
CSP Inference
Definite Clauses
Example
Contradiction
Inference Rules
Resolution
Example
Consistency-BasedDiagnosis
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 12
A proof is a derivation that a propositionlogically follows from a knowledge base.
Given a proof procedure, KB ⊢ p means p canbe derived or proved from KB.
Recall KB |= p means KB entails p, that p istrue in all models of KB.
A proof procedure is sound if KB ⊢ p only ifKB |= p. Anything that is proved is alsoentailed.
A proof procedure is complete if KB |= p thenalso KB ⊢ p. Everything that is entailed canbe proved.
Brute Force Inference
Logic
Propositional Logic
Examples
Proof Procedures
Proofs
⊲ Brute Force
CSP Inference
Definite Clauses
Example
Contradiction
Inference Rules
Resolution
Example
Consistency-BasedDiagnosis
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 13
Enumerate all interpretations. Determine which interpretations are models of
the KB. Determine which atoms (and any other
propositions of interest) are true in all models(or false in all models).
This is Ω(2n) where n is the number of atoms.
CSP Inference
Logic
Propositional Logic
Examples
Proof Procedures
Proofs
Brute Force
⊲ CSP Inference
Definite Clauses
Example
Contradiction
Inference Rules
Resolution
Example
Consistency-BasedDiagnosis
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 14
Set up KB as a CSP. Each atom is a variablewith two possible values. Each proposition inthe KB is a constraint.
Solutions of CSP = models of KB. Run arc consistency/domain splitting. Don’t stop after finding one CSP solution (KB
model). Find them all. Determine which atoms are true in all models
(or false in all models). This is still potentially exponential, but more
efficient than brute force. See Section 4.6.1.
Definite Clause Inference
Logic
Propositional Logic
Examples
Proof Procedures
Proofs
Brute Force
CSP Inference
⊲ Definite Clauses
Example
Contradiction
Inference Rules
Resolution
Example
Consistency-BasedDiagnosis
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 15
Suppose all propositions in KB are definite
clauses, either:
– an atom (e.g., an observation), or– of the form p→ q, where p and q are
atoms (e.g., a rule about the behavior ofthe world)
– of the form p1 ∧ . . . ∧ pk → q, where q andeach pi are atoms
Running CSP inference is efficient (linear inthe length of the KB).
See Section 5.2.
Definite Clause Example
Logic
Propositional Logic
Examples
Proof Procedures
Proofs
Brute Force
CSP Inference
Definite Clauses
⊲ Example
Contradiction
Inference Rules
Resolution
Example
Consistency-BasedDiagnosis
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 16
KB = a, b, a→ c, b ∧ c→ d, d ∧ e→ f
Know a and b.
Derive c from a and a→ c.
Derive d from b and c and b ∧ c→ d
Cannot derive e or f .
Proof by Contradiction
Logic
Propositional Logic
Examples
Proof Procedures
Proofs
Brute Force
CSP Inference
Definite Clauses
Example
⊲ Contradiction
Inference Rules
Resolution
Example
Consistency-BasedDiagnosis
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 17
Suppose we want to determine if KB |= p. Let KB′ = KB ∪ ¬p Determine that no model exists for KB′. Conclude that KB |= p. Should probably show that KB has at least
one model.
Inference Rules
Logic
Propositional Logic
Examples
Proof Procedures
Proofs
Brute Force
CSP Inference
Definite Clauses
Example
Contradiction
⊲ Inference Rules
Resolution
Example
Consistency-BasedDiagnosis
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 18
Modus ponens is an inference rule. If p is true,and if p→ q is true, then q is true.
That is, if KB |= p and KB |= p→ q, thenKB |= q.
Resolution inference rule (really, two rules)
– If KB |= p ∨ q and KB |= ¬p, thenKB |= q.
– If KB |= p ∨ q and KB |= ¬p ∨ r, thenKB |= q ∨ r.
Remember p and q and r can be anypropositions, not just atoms.
Resolution Theorem Proving
Logic
Propositional Logic
Examples
Proof Procedures
Proofs
Brute Force
CSP Inference
Definite Clauses
Example
Contradiction
Inference Rules
⊲ Resolution
Example
Consistency-BasedDiagnosis
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 19
Resolution theorem proving is a sound andcomplete inference procedure for propositionallogic.
Transform the KB to conjunctive normal
form, meaning each propositions in the KB isof the form l or l1 ∨ . . . ∨ lk, where each li is aliteral, an atom or the negation of an atom.
To show KB |= p, let KB′ = KB ∪ ¬p,and ensure KB′ is in CNF.
Proof is by deriving a contradiction, deriveboth a and ¬a for some atom a.
Worst-case exponential-time. Lots ofapproaches to reduce the exponential.
Resolution Example
Logic
Propositional Logic
Examples
Proof Procedures
Proofs
Brute Force
CSP Inference
Definite Clauses
Example
Contradiction
Inference Rules
Resolution
⊲ Example
Consistency-BasedDiagnosis
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 20
KB = a∨b, b∨c, ¬a∨¬b, ¬a∨¬c, ¬b∨¬c
To prove KB |= b, add ¬b and prove acontradiction using the resolution inference rule.
~b V ~c~a V ~ca V b~b
a c
b V c
b
~a V ~b
~b ~c ~a
a V ~c~a V c b V ~c
Conflicts
Logic
Propositional Logic
Examples
Proof Procedures
Consistency-BasedDiagnosis
⊲ Conflicts
Conflict Example
Conflict Example
ElectricalEnvironment
Representation
Electrical Conflicts
Diagnosis
Diagnosis Examples
Diagnosis Examples
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 21
Assume components are working normally. Need a set of assumables A, e.g.,
A = ok l1, ok l2, ok s1, . . . Show that KB ∪A leads to a contradiction,
which implies A is false, that something’swrong. In this case, A is called a conflict.
Want to isolate the problem, e.g., is there asingle fault that is consistent with KB?
C is a minimal conflict if C ⊆ A, C is aconflict, and no proper subset of C is aconflict.
Conflict Example
Logic
Propositional Logic
Examples
Proof Procedures
Consistency-BasedDiagnosis
Conflicts
⊲ Conflict Example
Conflict Example
ElectricalEnvironment
Representation
Electrical Conflicts
Diagnosis
Diagnosis Examples
Diagnosis Examples
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 22
A = c, d, e, z
KB = ¬a ∨ ¬b, c→ a, d→ b, e→ b
A is a conflict.Assuming A implies ¬a ∨ ¬b is false.
What subsets of A are minimal conflicts?
Conflict Example
Logic
Propositional Logic
Examples
Proof Procedures
Consistency-BasedDiagnosis
Conflicts
Conflict Example
⊲ Conflict Example
ElectricalEnvironment
Representation
Electrical Conflicts
Diagnosis
Diagnosis Examples
Diagnosis Examples
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 23
A = c, d, e, z
KB = ¬a ∨ ¬b, c→ a, d→ b, e→ b
A is a conflict.Assuming A implies ¬a ∨ ¬b is false.
What subsets of A are minimal conflicts?c, d and c, e
Electrical Environment
Logic
Propositional Logic
Examples
Proof Procedures
Consistency-BasedDiagnosis
Conflicts
Conflict Example
Conflict Example
⊲ElectricalEnvironment
Representation
Electrical Conflicts
Diagnosis
Diagnosis Examples
Diagnosis Examples
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 24
Representation
Logic
Propositional Logic
Examples
Proof Procedures
Consistency-BasedDiagnosis
Conflicts
Conflict Example
Conflict Example
ElectricalEnvironment
⊲ Representation
Electrical Conflicts
Diagnosis
Diagnosis Examples
Diagnosis Examples
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 25
up s1 live w0 ∧ ok l1→ lit l1up s2 live w1 ∧ up s2 ∧ ok s2→ live w0up s3 live w2 ∧ down s2 ∧ ok s2→ live w0live outside live w3 ∧ up s1 ∧ ok s1→ live w1¬lit l1 live w3 ∧ down s1 ∧ ok s1→ live w2¬lit l2 live w4 ∧ ok l2→ lit l2
live w3 ∧ up s3 ∧ ok s3→ live w4live w3→ live p1live w5 ∧ ok cb1→ live w3live w6→ live p2live w5 ∧ ok cb2→ live w6live outside→ live w5
Electrical Conflicts
Logic
Propositional Logic
Examples
Proof Procedures
Consistency-BasedDiagnosis
Conflicts
Conflict Example
Conflict Example
ElectricalEnvironment
Representation
⊲ElectricalConflicts
Diagnosis
Diagnosis Examples
Diagnosis Examples
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 26
Each ok atom is an assumable. This issimplified by no ok atoms for wires.
To infer lit l1 (which would contradict¬lit l1), need ok cb1, ok s1, ok s2 and ok l1.
ok cb1, ok s1, ok s2, ok l1 is a conflict. To infer lit l2 (which would contradict¬lit l2), need ok cb1, ok s3 and ok l2.
ok cb1, ok s3, ok l2 is a conflict.
Diagnosis
Logic
Propositional Logic
Examples
Proof Procedures
Consistency-BasedDiagnosis
Conflicts
Conflict Example
Conflict Example
ElectricalEnvironment
Representation
Electrical Conflicts
⊲ Diagnosis
Diagnosis Examples
Diagnosis Examples
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 27
If C is a minimal conflict, then some elementof C is false.
Explanation: C is a conjunction of assumablesa1 ∧ a2 ∧ . . ..If C is false, then ¬C = ¬a1 ∨ ¬a2 ∨ . . . istrue.
Some element of each minimal conflict mustbe false.
A diagnosis is a subset of assumables D ⊆ A
such that D includes at least one element fromeach minimal conflict.
A diagnosis D is minimal if no subset of D isa diagnosis.
Diagnosis Examples
Logic
Propositional Logic
Examples
Proof Procedures
Consistency-BasedDiagnosis
Conflicts
Conflict Example
Conflict Example
ElectricalEnvironment
Representation
Electrical Conflicts
Diagnosis
⊲DiagnosisExamples
Diagnosis Examples
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 28
In the first example, c, d and c.e wereminimal conflicts.
What are the minimal diagnoses?
In the second example, the minimal conflictswere ok cb1, ok s1, ok s2, ok l1 andok cb1, ok s3, ok l2.
What are the minimal diagnoses?
Diagnosis Examples
Logic
Propositional Logic
Examples
Proof Procedures
Consistency-BasedDiagnosis
Conflicts
Conflict Example
Conflict Example
ElectricalEnvironment
Representation
Electrical Conflicts
Diagnosis
Diagnosis Examples
⊲DiagnosisExamples
The Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 29
In the first example, c, d and c.e wereminimal conflicts.
What are the minimal diagnoses?c and d.e
In the second example, the minimal conflictswere ok cb1, ok s1, ok s2, ok l1 andok cb1, ok s3, ok l2.
What are the minimal diagnoses?ok cb1 and several double fault possibilities:ok s1, ok s3, ok s1, ok l2,ok s2, ok s3, ok s2, ok l2,ok l1, ok s3, ok l1, ok l2,
Limitations of Logic
Logic
Propositional Logic
Examples
Proof Procedures
Consistency-BasedDiagnosis
The Limitations ofLogic
⊲Limitations ofLogic
CS 3793/5233 Artificial Intelligence Logical Inference – 30
Assumes we can write down the truth.
– The world is round.– The sky is blue.– What goes up must come down.
Assumes our observations are always true.
– Optical illusions.– Photoshopping.– Referees and umpires.
Assumes our inferences are certain.
– Overturned convictions.– Car accidents.– Scams.
No real-world inference is truly logical.