![Page 1: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/1.jpg)
11
Artificial Intelligence
CS 165A
Tuesday, October 30, 2007
Knowledge and reasoning (Ch 7)
• Propositional logic First-order logic (Ch 8)
1
![Page 2: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/2.jpg)
2
Notes
• HW#2 due today
• HW#3 due Thursday, November 8th
– Posted tonight
• Midterm on Tuesday, November 13th
• Just in case there’s any confusion, in the slides:
is the same as (implies)
↔ is the same as (equivalence)
![Page 3: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/3.jpg)
3
Implication and entailment
• What is the difference between implication and entailment?
P Q (P Q) P Q
Implication Entailment
P is a proposition (“It is raining”)
Q is a proposition (“The grass is wet”)
This sentence has a specific semantic interpretation – it’s not a general rule
It may be true or false, depending on the values of P and Q
P and Q are variables – they can stand for any propositions in the KB
This sentence has no specific semantic interpretation – it is a general rule
It is always true, independent of the values of P and Q
![Page 4: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/4.jpg)
4
Implication and entailment
• What is the difference between implication and entailment?
P Q ( ) Implication Entailment
P is a proposition (“It is raining”)
Q is a proposition (“The grass is wet”)
This sentence has a specific semantic interpretation – it’s not a general rule
It may be true or false, depending on the values of P and Q
and are variables – they can stand for any propositions in the KB
This sentence has no specific semantic interpretation – it is a general rule
It is always true, independent of the values of and
( )
![Page 5: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/5.jpg)
5
Implication and entailment
• What is the difference between implication and entailment?
P Q ( ) Implication Entailment
P is a proposition (“It is raining”)
Q is a proposition (“The grass is wet”)
This sentence has a specific semantic interpretation – it’s not a general rule
It may be true or false, depending on the values of P and Q
and are variables – they can stand for any propositions in the KB
This sentence has no specific semantic interpretation – it is a general rule
It is always true, independent of the values of and
( ),
![Page 6: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/6.jpg)
6
Important Inference Rules for Propositional Logic
Issues?
![Page 7: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/7.jpg)
7
Example
KB
R S
P W
S
R
P
P Q
What can we infer ( ) if we add this sentence with no inference rules?
P Q
What can we infer ( ) if we then add this inference procedure:
( )
Nothing
Q and S ( ),
![Page 8: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/8.jpg)
8
false Q
Why is false Q always true?
• Answer #1: Since P Q ↔ P Q , so
false Q ↔ true Q , which is always true
• Answer #2: That is how the symbol is defined and interpreted. (We could invent another logical symbol that is interpreted differently.)
![Page 9: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/9.jpg)
9
Precedence of operators (logical connectives)
• Levels of precedence, evaluating left to right1. (NOT)2. (AND, conjunction)3. (OR, disjunction)4. (implies, conditional)5. (equivalence, biconditional)
• P Q R– (P (Q)) R
• P Q R– P (Q R)
• P Q R S– P ((Q R) S)
Corrections
![Page 10: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/10.jpg)
10
Things to know!
• What is a sound inference procedure?– The procedure only generates entailed sentences
• What is a complete inference procedure?– The procedure can find a proof for any sentence that is entailed
• What is a satisfiable sentence?– There are some interpretations for which it is true
• What is an unsatisfiable sentence?– There is no interpretation for which it is true
• What is a valid sentence?– It is true under all possible interpretations
![Page 11: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/11.jpg)
11
Resolution Rule: one rule for all inferences
rprqqp
,
Propositional calculus resolution
rp
rqqp
,
ca
cbba
,or
Remember: p q p q, so let’s rewrite it as:
Resolution is really the “chaining” of implications.
Would like to show that resolution is sound and (essentially) complete (use Deduction Rule for proof)
![Page 12: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/12.jpg)
12
Show that (α β) (β γ) (α γ)
α β γ α β β γ αβ βγ α γ
0 0 0 0 1 0 0
0 0 1 0 1 0 1
0 1 0 1 0 0 0
0 1 1 1 1 1 1
1 0 0 1 1 1 1
1 0 1 1 1 1 1
1 1 0 1 0 0 1
1 1 1 1 1 1 1
This is always true for all propositions α, β, and γ, so we can make it an inference rule
Soundness:
![Page 13: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/13.jpg)
13
Show that (α β ) (β γ) (α γ)
α β γ α β β γ α β β γ α γ
0 0 0 0 1 0 0
0 0 1 0 1 0 1
0 1 0 1 0 0 0
0 1 1 1 1 1 1
1 0 0 1 1 1 1
1 0 1 1 1 1 1
1 1 0 1 0 0 1
1 1 1 1 1 1 1
This is always true for all propositions α, β, and γ, so we can make it an inference rule
Soundness:
![Page 14: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/14.jpg)
14
Conversion to Conjunctive Normal Form: CNF
• Resolution rule is stated for conjunctions of disjunctions
• Question: – Can every statement in PC be represented this way?
• Answer: Yes– Can show every sentence in propositional logic is equivalent to
conjunction of disjunctions Conjunctive normal form (CNF)
• Procedure for obtaining CNF– Replace (P Q) with (P Q) and (Q P)– Eliminate implications: Replace (P Q) with (P Q)– Move inwards: , (P Q), (P Q)– Distribute over , e.g.: (P Q) R becomes (P R) (Q R)
[What about (P Q) R ?]– Flatten nesting: (P Q) R becomes P Q R
![Page 15: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/15.jpg)
15
Propositional logic is quite limited
• Propositional logic has simple syntax and semantics, and limited expressiveness– Though it is handy to illustrate the process of inference
• However, it only has one representational device, the proposition, and cannot generalize– Input: facts; Output: facts
– Result: Many, many rules are necessary to represent any non-trivial world
– It is impractical for even very small worlds
• The solution?– First-order logic, which can represent propositions, objects, and
relations between objects
– Worlds can be modeled with many fewer rules
![Page 16: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/16.jpg)
16
First-Order Logic
Chapter 8
![Page 17: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/17.jpg)
17
First-Order Logic (FOL)
• Also known as First-Order Predicate Calculus– Propositional logic is also known as Propositional Calculus
• An extension to propositional logic in which quantifiers can bind variables in sentences– Universal quantifier ( )– Existential quantifier ( )– Variables: x, y, z, a, joe, table…
• Examples x Beautiful (x) x Beautiful (x)
A method of analysis or calculation using a special symbolic notation
![Page 18: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/18.jpg)
18
Propositional logic vs. FOL
• Propositional logic:– P stands for “All men are mortal”
– Q stands for “Socrates is a man”
– What can you infer from P and Q? Nothing!
• First-order logic: x Man (x) Mortal (x)
– Man (Socrates)
– What can you infer from these? Can infer Mortal (Socrates)
![Page 19: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/19.jpg)
19
First-Order Logic (cont.)
• FOL can express anything that can be programmed
• It is by far the most studied and best understood logic in use
• It does have limits, however– Quantifiers ( and ) can only be applied to objects, not to
functions or predicates Cannot write P P (mom) = good This is why it’s called first-order
– This limits its expressiveness
• Let’s look at the syntax of first-order logic– I.e., what logical expressions can you legally construct?
![Page 20: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/20.jpg)
20
FOL Syntax
• Symbols– Object symbols (constants): P, Q, Fred, Desk, True, False, …
These refer to things
– Predicate symbols: Heavy, Smart, Mother, … These are true or false statements about objects: Smart(rock)
– Function symbols: Cosine, IQ, MotherOf, … These return objects, exposing relations: IQ(rock)
– Variables: x, y, , … These represent unspecified objects
– Logical connectives to construct complex sentences: , , , , – Quantifiers: (universal), (existential)
– Equality: =
• Usually variables will be lower-case, other symbols capitalized
![Page 21: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/21.jpg)
21
FOL Syntax (cont.)
• Terms– Logical expressions that refer to objects (evaluates to an object)
– Can be constants, variables, functions
• Examples– P
– 2001
– Richard
– x
– y
– BrotherOf (Richard)
– Age (NephewOf (x)) [Why not AgeOf ( ) ? (No reason...!)]
Remember – syntax and semantics are different, and separate!!
![Page 22: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/22.jpg)
22
FOL Syntax
• Note on predicates and functions: typical usage– Beautiful (y) “y is beautiful”– Mother (x) “x is a Mother”– BrotherOf (x, y) “x is a brother of y”– NextTo (x, y) “x is next to y”
– BrotherOf (x) “the brother of x”– NextTo (y) “a thing next to y”– SquareRoot (x) “the square root of x”
Predicates
Functions
![Page 23: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/23.jpg)
23
FOL Sentences
• Sentences state facts– Just like in propositional logic…
• 3 types of sentences:– Atomic sentences (atoms)
– Logical (complex) sentences
– Quantified sentences – (universal), (existential)
![Page 24: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/24.jpg)
24
Sentences
1. Atomic sentence– A predicate applied to some terms
Brothers (Bill, FatherOf (John)) [Does the reverse follow?] LessThan (3, 5)
– Equality – states that two terms refer to the same object x = MotherOf (y) Instructor (cs165a) = Turk This is equivalent to the predicate: Equal (Instructor (cs165a), Turk)
2. Logical (complex) sentence – logical combination of other sentences Brothers (Bill, HusbandOf (Sue))– Above (Sky, Ground) Below (Ground, Sky)– Brothers (Bill, John) Brothers (John, Bill)
3. Quantified sentence – sentences with quantified variables x,y ParentOf (x, y) ChildOf (y, x) x US-President (x)
Constant, variable, or function – evaluates to an object
![Page 25: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/25.jpg)
25
Universal Quanitifer (“For all…”)
<variables> <sentence> x – “For all x…” x, y – “For all x and y…”
• Examples– “Everything is beautiful”
x Beautiful (x) Equivalent to: i Beautiful (xi)
– Beautiful (Joe) Beautiful (Mary) Beautiful (apple) Beautiful (dirt) Beautiful (death) …
– “All men are mortal” x Man (x) Mortal (x)
– “Everyone in the class is smart” x Enrolled (x, cs165a) Smart (x)
– What does this mean: x Enrolled (x, cs165a) Smart (x) “Everything is enrolled in cs165a and is smart” !!
![Page 26: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/26.jpg)
26
Expansion of universal quantifier
x Enrolled(x, cs165a) Smart(x)
• This is equivalent to– Enrolled (Tom, cs165a) Smart (Tom)
Enrolled (Mary, cs165a) Smart (Mary) Enrolled (Chris, cs165a) Smart (Chris) Enrolled (chair, cs165a) Smart (chair) Enrolled (dirt, cs165a) Smart (dirt) Enrolled (surfboard, cs165a) Smart (surfboard) Enrolled (tooth, cs165a) Smart (tooth) Enrolled (Mars, cs165a) Smart (Mars) …
– Everything!
• So, x Enrolled (x, cs165a) Smart (x) is equivalent to– Enrolled (Tom, cs165a) Smart (Tom)
Enrolled (chair, cs165a) Smart (chair) …
![Page 27: 11 Artificial Intelligence CS 165A Tuesday, October 30, 2007 Knowledge and reasoning (Ch 7) Propositional logic First-order logic (Ch 8) 1](https://reader036.vdocuments.site/reader036/viewer/2022062322/5697bffc1a28abf838cc15cb/html5/thumbnails/27.jpg)
27
Existential Quantifier (“There exists…”)
<variables> <sentence> x – “There exists an x such that…” x, y – “There exist x and y such that…”
• Examples– “Somebody likes me”
x Likes (x, Me) ??? Equivalent to: i Likes (xi, Me)
– Likes (Joe, Me) Likes (Mary, Me) Likes (apple, Me) Likes (dirt, Me) Likes (death, Me) …
Really “Something likes me” x Person (x) Likes (x, Me) x Enrolled (x, cs165a) WillReceiveAnA+ (x)