Artificial Intelligence: Lecture 2: Propositional Logic 2 Solve Problems
Artificial Intelligence: Lecture 2: Propositional Logic 2 Solve Problems
❑ R → ¬(C)
❑G
❑ G → (Y ∨ C)
❑ ¬(Y)
Entailment
❑ Entailment means that one thing follows from another
KB╞ α
Does :
1- P ⊨ Q1?
2- P ⊨ Q2?
3- P ⊨ Q3?
Inference
❑ KB ├i α : sentence α can be derived from KB by procedure i, i proves α
Logical inference is used to create new sentences that logically follow from
a given set of sentences (KB).
A B A→B OK?
True True True
True False False
False True True
False False True
Soundness of modus Tollens
(the way that denies by denying)
A B A→B B OK?
True True True
Sentences Representations
1. p q
2. r → p
3. r → s
4. s → t
Using the resolution rule (an example)
1. Anna is skiing or it is not snowing.
2. It is snowing or Bart is playing hockey.
Anna is skiing or Bart is playing hockey ??
Propositions
p Anna is skiing
q Bart is playing hockey
r it is snowing
Sentences Representations
1. p r pq
Resolution Rule
2. r q Anna is skiing or Bart is playing hockey
Resolution Refutation Principle
❑ Resolution refutation proves a theorem by negating the
statement to be proved and adding this negated goal to the
set of axioms that are known to be true.
❑ Use the resolution rule of inference to show that this leads
to a contradiction.
❑ Once the theorem prover shows that the negated goal is
inconsistent with the given set of axioms, it follows that the
original goal must be consistent.
Example (resolution refutation)
❑Using resolution refutation principle, show that C D is a
logical consequence of:
S = {A B, A D, C B}
Moves, Bat_ok
Example
1. Battery-OK Bulbs-OK Headlights-Work
2. Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts
3. Engine-Starts Flat-Tire Car-OK
4. Headlights-Work
5. Battery-OK
6. Starter-OK
7. Empty-Gas-Tank
8. Car-OK
9. Flat-Tire
10. Starter-OK Empty-Gas-Tank Engine-Starts
11. Battery-OK Empty-Gas-Tank Engine-Starts
12. Battery-OK Starter-OK Engine-Starts
13. Engine-Starts Flat-Tire
14. Engine-Starts Car-OK
15. .....
Example
…
Battery-OK
Starter-OK
Empty-Gas-Tank
Car-OK
Flat-Tire
…
Battery-OK Starter-OK Engine-Starts
Engine-Starts Flat-Tire
…
Battery-OK Starter-OK Flat-Tire
…
Starter-OK Flat-Tire
…
Flat-Tire
…
False (empty clause)
Resolution Heuristics
❑ Set-of-support heuristics:
❑ At least one ancestor of every inferred clause comes from a
❑ Shortest-clause heuristics:
❑Generate a clause with the fewest literals first
❑Unit Resolution
❑ Simplifications heuristics:
❑ Remove any clause containing two complementary literals (tautology)
❑ If a symbol always appears with the same “sign”, remove all the clauses that
contain it (pure symbol)
Example (Set-of-Support)
1. Battery-OK Bulbs-OK Headlights-Work
2. Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts
3. Engine-Starts Flat-Tire Car-OK
4. Headlight-Work
5. Battery-OK
6. Starter-OK
7. Empty-Gas-Tank
8. Car-OK
9. Flat-Tire
Example (Set-of-Support)
1. Battery-OK Bulbs-OK Headlights-Work
2. Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts
3. Engine-Starts Flat-Tire Car-OK
4. Headlight-Work
5. Battery-OK
6. Starter-OK
Note the goal-directed
7. Empty-Gas-Tank
flavor
8. Car-OK
9. Flat-Tire
10. Engine-Starts Car-OK
11. Engine-Starts
12. Battery-OK Starter-OK Empty-Gas-Tank
13. Starter-OK Empty-Gas-Tank
14. Empty-Gas-Tank
15. False
Example (Shortest-Clause)
1. Battery-OK Bulbs-OK Headlights-Work
2. Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts
3. Engine-Starts Flat-Tire Car-OK
4. Headlight-Work
5. Battery-OK
6. Starter-OK
7. Empty-Gas-Tank
8. Car-OK
9. Flat-Tire
Example (Shortest-Clause)
1. Battery-OK Bulbs-OK Headlights-Work
2. Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts
3. Engine-Starts Flat-Tire Car-OK
4. Headlight-Work
5. Battery-OK
6. Starter-OK
7. Empty-Gas-Tank
8. Car-OK
9. Flat-Tire
10. Engine-Starts Car-OK
11. Engine-Starts
12. Bulbs-OK Headlights-Work
13. Battery-OK Starter-OK Empty-Gas-Tank
14. Starter-OK Empty-Gas-Tank
15. Empty-Gas-Tank
16. False
Example (Pure Literal)
1. Battery-OK Bulbs-OK Headlights-Work
2. Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts
3. Engine-Starts Flat-Tire Car-OK
4. Headlights-Work
5. Battery-OK
6. Starter-OK
7. Empty-Gas-Tank
8. Car-OK
9. Flat-Tire
Horn sentences
❑A Horn sentence or Horn clause has the form:
P1 P2 P3 ... Pn → Q
or alternatively (P → Q) = (P Q)
P1 P2 P3 ... Pn Q
where Ps and Q are non-negated atoms
Horn clause =
proposition symbol; or
(conjunction of symbols) symbol
E.g., C (B A) (C D B)
❑Avoid loops:
❑check if new sub-goal is already on the goal stack
❑ Now, suppose we have the fact "dog(fido)" and we query whether "animal(fido)".
❑ In forward chaining, we will successively add "carnivore(fido)", "mammal(fido)",
"vertebrate(fido)", and "animal(fido)". The query will then succeed immediately. The
total work is proportional to the height of the hierarchy.
❑ In backward chaining, the query " animal(fido)" will unify with the first rule, and
generate the subquery " sponge(fido)", which will initiate a search for Fido through all
the subdivisions of sponges, and so on. Ultimately, it searches the entire taxonomy of
animals looking for Fido.
Propositional logic is a weak language
❑ Hard to identify “individuals” (e.g., Mary, 3)
❑ Can’t directly talk about properties of individuals or relations between
individuals (e.g., “Bill is tall”)
❑ Generalizations, patterns, regularities can’t easily be represented (e.g.,
“all triangles have 3 sides”)
❑ First-Order Logic (abbreviated FOL or FOPC) is expressive enough to
concisely represent this kind of information
❑ FOL adds relations, variables, and quantifiers, e.g.,
❑ “Every elephant is gray”: x (elephant(x) → gray(x))