Title: Automated Reasoning in Propositional Logic
1Automated Reasoning in Propositional Logic
2Problem
- Given
- KB a set of sentence
- ? a sentence
- Answer
- KB ? ?
3Deduction vs. Satisfiability Test
KB ? iff KB,?? is unsatisfiable
- Hence
- Deciding whether a set of sentences entails
another sentence, or not - Testing whether a set of sentences is
satisfiable, or not - are closely related problems
4Computational Approaches
- Enumeration of models
- Construction of a proof
- Battery-OK ? Bulbs-OK ? Headlights-Work
- Battery-OK ? Starter-OK ? ?Empty-Gas-Tank ?
Engine-Starts - Engine-Starts ? ?Flat-Tire ? Car-OK
- Headlights-Work
- Battery-OK
- Starter-OK
- ?Empty-Gas-Tank
- ?Car-OK
- Battery-OK ? Starter-OK ? (56)
- Battery-OK ? Starter-OK ? ?Empty-Gas-Tank ?
(97) - Engine-Starts ? (210)
- ?Engine-Starts ? Flat-Tire ? (38)
- Flat-Tire ? (1112)
5Enumeration of Models
- P Set of propositional symbols in KB,??
- n Size of P
- ENTAILS?(KB,?)
- For each of the 2n models on P do
- If it is a model of KB,?? then return no
Return yes
6Satisfiability Test as CSP
- Each propositional symbol is a variable
- The domain of each variable is True, False
- Each sentence in KB,?? is a constraint on the
value(s) taken by one or several variables - Recursive backtracking CSP techniques and
heuristics are applicable
7Construction of a Proof
- Battery-OK ? Bulbs-OK ? Headlights-Work
- Battery-OK ? Starter-OK ? ?Empty-Gas-Tank ?
Engine-Starts - Engine-Starts ? ?Flat-Tire ? Car-OK
- Headlights-Work
- Battery-OK
- Starter-OK
- ?Empty-Gas-Tank
- ?Car-OK
- Battery-OK ? Starter-OK ? (56)
- Battery-OK ? Starter-OK ? ?Empty-Gas-Tank ?
(97) - Engine-Starts ? (210)
- ?Engine-Starts ? Flat-Tire ? (38)
- Flat-Tire ? (1112)
8Construction of a Proof
- Battery-OK ? Bulbs-OK ? Headlights-Work
- Battery-OK ? Starter-OK ? ?Empty-Gas-Tank ?
Engine-Starts - Engine-Starts ? ?Flat-Tire ? Car-OK
- Headlight-Work
- Battery-OK
- Starter-OK
- ?Empty-Gas-Tank
- ?Car-OK
- Battery-OK ? Starter-OK ? (56)
- Battery-OK ? Starter-OK ? ?Empty-Gas-Tank ?
(97) - Engine-Starts ? (210)
- ?Engine-Starts ? Flat-Tire ? (38)
- Flat-Tire ? (1112)
- What do we need?
- A complete set of sound inference rules
- A complete search algorithm to decide which
rule to apply next and to which sentences
9Complementary Literals
- A literal is a either an atomic sentence or the
negated atomic sentence, e.g.
P or ?P - Two literals are complementary if one is the
negation of the other, e.g.
P and ?P
10Unit Resolution Rule
- Given two sentences L1 ? ? Lp and
M where Li,, Lp and M are all literals,
and M and Li are complementary literals - Infer L1 ? ? Li-1 ? Li1 ? ? Lp
11Examples
- From?Engine-Starts ? Car-OK
- Engine-Starts
- InferCar-OK
Modus ponens
- From?Engine-Starts ? Car-OK
- ?Car-OK
- Infer ?Engine-Starts
Modus tolens
12Another Example
- ?Engine-Starts ? Flat-Tire ? Car-OK
- Engine-Starts
- ?Flat-Tire
- Flat-Tire ? Car-OK
- Car-OK
13Detection of Unsatisfiability
- Car-OK
- ?Car-OK
- False
14Soundness of Unit Resolution
- Let m be a model of L1 ? ? Lp and
M where M and Li are complementary
literals - Li must be False in m, hence L1 ? ? Li-1 ?
Li1 ? ? Lp must be True
15Shortcoming of Unit Resolution
- From
- ?Engine-Starts ? Flat-Tire ? Car-OK
- Engine-Starts ? Empty-Gas-Tank
- we can infer nothing!
16Full Resolution Rule
- Given two sentences L1 ? ? Lp and
M1 ? ? Mq where L1,, Lp, M1,, Mq are all
literals, and Li and Mj are complementary
literals - Infer L1? ? Li-1?Li1??Lk?M1? ?
Mj-1?Mj1??Mk in which only one copy of each
literal is retained (factoring)
17Example
- From
- ?Engine-Starts ? Flat-Tire ? Car-OK
- Engine-Starts ? Empty-Gas-Tank
- Infer
- Empty-Gas-Tank ? Flat-Tire ? Car-OK
18Example
- From
- ?P ? Q (? P ? Q)
- ?Q ? R (? Q ? R)
- Infer
- ?P ? R (? P ? R)
19Not All Inferences are Useful!
- From
- ?Engine-Starts ? Flat-Tire ? Car-OK
- Engine-Starts ? ?Flat-Tire
- Infer
- ?Flat-Tire ? Flat-Tire ? Car-OK
20Not All Inferences are Useful!
- From
- ?Engine-Starts ? Flat-Tire ? Car-OK
- Engine-Starts ? ?Flat-Tire
- Infer
- ?Flat-Tire ? Flat-Tire ? Car-OK
tautology
21Not All Inferences are Useful!
- From
- ?Engine-Starts ? Flat-Tire ? Car-OK
- Engine-Starts ? ?Flat-Tire
- Infer
- ?Flat-Tire ? Flat-Tire ? Car-OK ? True
tautology
22Soundness of Full Resolution
Left as an exercise
23Full Resolution Rule
- Given two sentences L1 ? ? Lp and
M1 ? ? Mq - Infer L1? ? Li-1?Li1??Lk?M1? ?
Mj-1?Mj1??Mk
24Sentence ? Clause Form
Example (A ? ?B) ? (C ? D)
25Sentence ? Clause Form
Example (A ? ?B) ? (C ? D) 1. Eliminate ?
?(A ? ?B) ? (C ? D)
26Sentence ? Clause Form
Example (A ? ?B) ? (C ? D) 1. Eliminate ?
?(A ? ?B) ? (C ? D)2. Reduce scope of ? (?A ?
B) ? (C ? D)
27Sentence ? Clause Form
Example (A ? ?B) ? (C ? D) 1. Eliminate ?
?(A ? ?B) ? (C ? D)2. Reduce scope of ? (?A ?
B) ? (C ? D)3. Distribute ? over ? (?A ? (C ?
D)) ? (B ? (C ? D)) (?A ? C) ? (?A ? D) ? (B ?
C) ? (B ? D)
28Sentence ? Clause Form
Example (A ? ?B) ? (C ? D) 1. Eliminate ?
?(A ? ?B) ? (C ? D)2. Reduce scope of ? (?A ?
B) ? (C ? D)3. Distribute ? over ? (?A ? (C ?
D)) ? (B ? (C ? D)) (?A ? C) ? (?A ? D) ? (B ?
C) ? (B ? D) Set of clauses ?A ? C , ?A ? D ,
B ? C , B ? D
29Resolution Refutation Algorithm
- RESOLUTION-REFUTATION(KB,a)
- clauses ? set of clauses obtained from KB and ?a
- new ?
- Repeat
- For each C, C in clauses do res ?
RESOLVE(C,C) If res contains the empty clause
then return yes - new ? new U resIf new ? clauses then return no
- clauses ? clauses U new
30Completeness of Resolution Refutation
Left as an exercise
31Example
- ?Battery-OK ? ?Bulbs-OK ? Headlights-Work
- ?Battery-OK ? ?Starter-OK ? Empty-Gas-Tank ?
Engine-Starts - ?Engine-Starts ? Flat-Tire ? Car-OK
- Headlights-Work
- Battery-OK
- Starter-OK
- ?Empty-Gas-Tank
- ?Car-OK
- ?Flat-Tire
- ?Starter-OK ? Empty-Gas-Tank ? Engine-Starts
- ?Battery-OK ? Empty-Gas-Tank ? Engine-Starts
- ?Battery-OK ? ?Starter-OK ? Engine-Starts
- ?Engine-Starts ? Flat-Tire
- ?Engine-Starts ? Car-OK
32Example
- ?Battery-OK ? ?Bulbs-OK ? Headlights-Work
- ?Battery-OK ? ?Starter-OK ? Empty-Gas-Tank ?
Engine-Starts - ?Engine-Starts ? Flat-Tire ? Car-OK
- Headlight-Work
- Battery-OK
- Starter-OK
- ?Empty-Gas-Tank
- ?Car-OK
- ?Flat-Tire
- ?Starter-OK ? Empty-Gas-Tank ? Engine-Starts
- ?Battery-OK ? Empty-Gas-Tank ? Engine-Starts
- ?Battery-OK ? ?Starter-OK ? Engine-Starts
- ?Engine-Starts ? Flat-Tire
- ?Engine-Starts ? Car-OK
33Example
Battery-OK Starter-OK ?Empty-Gas-Tank ?Car-OK
?Flat-Tire ?Battery-OK ? ?Starter-OK ?
Engine-Starts ?Engine-Starts ? Flat-Tire
34Example
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)
35Resolution 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 - Simplifications heuristics
- Remove any clause containing two complementary
literals (tautology) - Remove any clause C that contains all the
literals of another clause C - If a symbol always appears with the same sign,
remove all the clauses that contain it (pure
symbol)
36Example (Set-of-Support)
- ?Battery-OK ? ?Bulbs-OK ? Headlights-Work
- ?Battery-OK ? ?Starter-OK ? Empty-Gas-Tank ?
Engine-Starts - ?Engine-Starts ? Flat-Tire ? Car-OK
- Headlight-Work
- Battery-OK
- Starter-OK
- ?Empty-Gas-Tank
- ?Car-OK
- ?Flat-Tire
37Example (Set-of-Support)
- ?Battery-OK ? ?Bulbs-OK ? Headlights-Work
- ?Battery-OK ? ?Starter-OK ? Empty-Gas-Tank ?
Engine-Starts - ?Engine-Starts ? Flat-Tire ? Car-OK
- Headlight-Work
- Battery-OK
- Starter-OK
- ?Empty-Gas-Tank
- ?Car-OK
- ?Flat-Tire
- ?Engine-Starts ? Car-OK
- ?Engine-Starts
- ?Battery-OK ? ?Starter-OK ? Empty-Gas-Tank
- ?Starter-OK ? Empty-Gas-Tank
- Empty-Gas-Tank
- False
Note the goal-directed flavor
38Resolution 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 - Simplifications heuristics
- Remove any clause containing two complementary
literals (tautology) - Remove any clause C that contains all the
literals of another clause C - If a symbol always appears with the same sign,
remove all the clauses that contain it (pure
symbol)
39Example (Shortest-Clause)
- ?Battery-OK ? ?Bulbs-OK ? Headlights-Work
- ?Battery-OK ? ?Starter-OK ? Empty-Gas-Tank ?
Engine-Starts - ?Engine-Starts ? Flat-Tire ? Car-OK
- Headlight-Work
- Battery-OK
- Starter-OK
- ?Empty-Gas-Tank
- ?Car-OK
- ?Flat-Tire
40Example (Shortest-Clause)
- ?Battery-OK ? ?Bulbs-OK ? Headlights-Work
- ?Battery-OK ? ?Starter-OK ? Empty-Gas-Tank ?
Engine-Starts - ?Engine-Starts ? Flat-Tire ? Car-OK
- Headlight-Work
- Battery-OK
- Starter-OK
- ?Empty-Gas-Tank
- ?Car-OK
- ?Flat-Tire
- ?Engine-Starts ? Car-OK
- ?Engine-Starts
- ?Bulbs-OK ? Headlights-Work
- ?Battery-OK ? ?Starter-OK ? Empty-Gas-Tank
- ?Starter-OK ? Empty-Gas-Tank
- Empty-Gas-Tank
- False
41Resolution 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 - Simplifications heuristics
- Remove any clause containing two complementary
literals (tautology) - Remove any clause C that contains all the
literals of another clause C - If a symbol always appears with the same sign,
remove all the clauses that contain it (pure
symbol)
42Example (Pure Literal)
- ?Battery-OK ? ?Bulbs-OK ? Headlights-Work
- ?Battery-OK ? ?Starter-OK ? Empty-Gas-Tank ?
Engine-Starts - ?Engine-Starts ? Flat-Tire ? Car-OK
- Headlights-Work
- Battery-OK
- Starter-OK
- ?Empty-Gas-Tank
- ?Car-OK
- ?Flat-Tire
43When to Use Logic?
- When the knowledge base is large and can be made
explicit - When formulating a problem as a CSP problem
would yield complex constraints - When the agents environment is conveniently
described by true or false sentences
44Summary
- Entailment problem
- Resolution rule
- Clause form of a set of sentences
- Resolution refutation algorithm
- Resolution heuristics