Logic PDF
Logic PDF
Logic PDF
Deduction
An important part of human reasoning
• Given a set of
• Assumptions (Facts)
• Or disprove an assertion
Logic, Page 1
Wang: CIS 630: Artificial Intelligence
Basic Concepts
Objects (Constants)
Variables
Functions
Predicates
Connectives
Quantifiers
Logic, Page 2
Wang: CIS 630: Artificial Intelligence
Objects
JOHN
MARY
BASKETBALL
TRIANGLE
Quantifiers
Variables
Logic, Page 3
Wang: CIS 630: Artificial Intelligence
Functions
exp(0) = 1
next-day(THURSDAY) = FRIDAY
brother(JOHN) = JIM
Predicates
(or functions returning True or False)
Loves(JOHN, MARY)
Man(SOCRATES)
Sunny(THURDAY)
Logic, Page 4
Wang: CIS 630: Artificial Intelligence
Connectives
∧ AND
∨ OR
¬ NOT
⊃ IMPLIES
Quantifiers
Logic, Page 5
Wang: CIS 630: Artificial Intelligence
Literals
• No Quantifiers
Defined recursively
Logic, Page 6
Wang: CIS 630: Artificial Intelligence
Terms Predicates
Feathers
Atoms Negation
Feathers(x)
Well-formed formulas
∀x[Feathers(x) ⊃ Bird(x)]
Logic, Page 7
Wang: CIS 630: Artificial Intelligence
Block A
Block B
On(A, B)
On-relation
Logic, Page 8
Wang: CIS 630: Artificial Intelligence
• Distributivity
x ∧ (y ∨ z) = (x ∧ y) ∨ (x ∧ z)
x ∨ (y ∧ z) = (x ∨ y) ∧ (x ∨ z)
• DeMorgan's Laws
¬ ( x ∨ y) = (¬x ∧ ¬y)
¬ ( x ∧ y) = (¬x ∨ ¬y)
¬ ( ¬x) = x
¬∀ x[E(x)] = ∃x[¬E(x)]
¬∃ x[E(x)] = ∀x[¬E(x)]
Logic, Page 9
Wang: CIS 630: Artificial Intelligence
If P ⊃ Q and P is true
Then Q is true
• Syllogism
If P ⊃ Q and Q ⊃ R
Then P ⊃ R
Logic, Page 10
Wang: CIS 630: Artificial Intelligence
Logic, Page 11
Wang: CIS 630: Artificial Intelligence
Man(Marcus)
Pompeian(Marcus)
∀x [Pompeian(x) ⊃ Roman(x)]
Ruler(Caesar)
∀x ∃y LoyalTo(x,y)
Logic, Page 12
Wang: CIS 630: Artificial Intelligence
TryAssassinate(Marcus, Caesar)
Logic, Page 13
Wang: CIS 630: Artificial Intelligence
Resolution
A way of mechanizing deduction
• Unification
• Theorem proving
Logic, Page 14
Wang: CIS 630: Artificial Intelligence
Logic, Page 15
Wang: CIS 630: Artificial Intelligence
[¬Brick(x)∨((On(x,(Support(x)) ∧ ¬Pyramid(Support(x))
∧[¬On(x,y) ∨ ¬On(y,x)]
∧[Brick(z) ∨ ¬Equal(x,z)])]
[(¬Brick(x) ∨ (On(x,(Support(x))∧¬Pyramid(Support(x)))
∧(¬Brick(x) ∨ ¬On(x,y) ∨ ¬On(y,x))
∧(¬Brick(x) ∨ Brick(z) ∨ ¬Equal(x,z))]
in another step
[(¬Brick(x) ∨ On(x,Support(x))
∧(¬Brick(x) ∨¬Pyramid(Support(x))
∧(¬Brick(x) ∨ ¬On(x,y) ∨ ¬On(y,x))
∧(¬Brick(x) ∨ Brick(z) ∨ ¬Equal(x,z))]
Logic, Page 16
Wang: CIS 630: Artificial Intelligence
(¬Brick(x) ∨ On(x,Support(x))
(¬Brick(x) ∨¬Pyramid(Support(x))
(¬Brick(x) ∨ ¬On(x,y) ∨ ¬On(y,x))
(¬Brick(x) ∨ Brick(z) ∨ ¬Equal(x,z))
So we finally arrive at
(¬Brick(x) ∨ On(x,(Support(x))
(¬Brick(w) ∨¬Pyramid((Support(w)))
(¬Brick(u) ∨ ¬On(u,y) ∨ ¬On(y,u))
(¬Brick(v) ∨ Brick(z) ∨ ¬Equal(v,z))
Logic, Page 17
Wang: CIS 630: Artificial Intelligence
Basics of Resolution
Given
¬P ∨ Q
P∨R
We can conclude
Q∨R
OR given
¬Feathers(Squigs) ∨ Bird(Squigs)
Feathers(Squigs)
We can conclude
Bird(Squigs)
Logic, Page 18
Wang: CIS 630: Artificial Intelligence
Unification
Q(x)
P(x) ==> FAIL
P(x)
P(y) ==> {y → x}
(Book version: x/y)
P(Marcus)
P(y) ==> {y → Marcus} (or Marcus/y)
P(Marcus)
P(Julius) ==> FAIL
P(x,x)
P(y,z) ==> {x → y, y → z}
Logic, Page 19
Wang: CIS 630: Artificial Intelligence
Hate(x,y)
Hate(Marcus,z)
We could produce:
{x → Marcus, y → z}
{x → Marcus, z → y}
{x → Marcus, y → Caesar, z → Caesar}
{x → Marcus, y → Polonius, z → Polonius}
Logic, Page 20
Wang: CIS 630: Artificial Intelligence
Unification
Two literals: L1 and L2
• Return FAIL
2. If the predicate names are not the same or they have different
number of arguments, return FAIL.
Logic, Page 21
Wang: CIS 630: Artificial Intelligence
Resolution Algorithm
3. Convert the negated goal to clause form, and add to the set
of facts
Logic, Page 22
Wang: CIS 630: Artificial Intelligence
Heuristics
Still needed
• Set of support
• Unit preference
• Breadth-first
Logic, Page 23
Wang: CIS 630: Artificial Intelligence
Example
PROVE
∀x [R(x) ⊃ L(x)]
∀x [D(x) ⊃ ¬L(x)]
∃x [D(x) ∧ I(x)]
∃x [I(x) ∧ ¬R(x)]
Logic, Page 24
Wang: CIS 630: Artificial Intelligence
• Negate conclusion
Logic, Page 25
Wang: CIS 630: Artificial Intelligence
Resolve
and
Logic, Page 26
Wang: CIS 630: Artificial Intelligence
Logic, Page 27
Wang: CIS 630: Artificial Intelligence
• Abduction
• Analogy
• Induction
Robins fly
Sparrows fly ==> Birds fly
Hawks fly (what about ostrich?)
Logic, Page 28
Wang: CIS 630: Artificial Intelligence
Abduction
If P ⊃ Q, and Q
Abduce P
• Approximate reasoning
Logic, Page 29
Wang: CIS 630: Artificial Intelligence
Analogy
• How is it used?
Logic, Page 30