Upload
others
View
14
Download
0
Embed Size (px)
Citation preview
11/15/2017
1
First-Order Predicate Calculus
Deepak KumarNovember 2017
Propositional Logic - Syntax• Sentences – Well-formed formulas (wffs)
• Any atom is a wff [Atomic Sentences]e.g. 𝑃, 𝑄, 𝑅, 𝑅3
• Complex Sentences• If ω1and ω2 are wffs, then so are
ω1ω1∨ ω2 disjunctionω1∧ ω2 conjunctionω1⇒ ω2 implication¬ ω1 negation
• There are no other wffs.
• Literals are atomic wffs
𝑃,¬ 𝑃2
Examples
𝑃(𝑃 ∨ 𝑄) ⇒ ¬P𝑃 ∧ 𝑄¬ ¬ P
P ⇒⇒ ¬P X
etc.
11/15/2017
2
Propositional Logic - Semantics
• How symbols relate to the domain/world
Atomic SentencesInterpretation of symbols & constants
True is True
False is False
𝑃𝐼: Bryn Mawr is in Pennsylvania
Meaning of a symbol is its truth value, given its interpretation.
P is True, given 𝑃𝐼
Complex SentencesUse meaning of connectives.
3
Propositional Logic - Key Ideas
• (un)Satisfiability
• Validity
• Entailment (Δ ⊨ ω)
• Inference & Theorem Proving (Δ ⊢𝑅 ω)
• Rules of Inference
• Soundness (Δ ⊢𝑅 ω implies Δ ⊨ ω)
• Completeness (Whenever Δ ⊨ ω, ∃Δ ⊢𝑅 ω)
• Reductio ad Absurdum (if Δ has a model, but Δ ∪ {¬ω} does not, it must be that Δ ⊨ ω )
• Resolution rule of inference (sound, but not complete)
• Resolution with Reductio is sound and complete.
• Wffs as clauses (also, Definite and Horn clauses)
• Forward & Backward Chaining Inference
4
11/15/2017
3
Propositional Logic - Key Ideas
• (un)Satisfiability
• Validity
• Entailment (Δ ⊨ ω)
• Inference & Theorem Proving (Δ ⊢𝑅 ω)
• Rules of Inference
• Soundness (Δ ⊢𝑅 ω implies Δ ⊨ ω)
• Completeness (Whenever Δ ⊨ ω, ∃Δ ⊢𝑅 ω)
• Reductio ad Absurdum (if Δ has a model, but Δ ∪ {¬ω} does not, it must be that Δ ⊨ ω )
• Resolution rule of inference (sound, but not complete)
• Resolution with Reductio is sound and complete.
• Wffs as clauses (also, Definite and Horn clauses)
• Forward & Backward Chaining Inference
5
Propositional Logicis not very expressive.
But useful for learningthe fundamentals.
First-Order Predicate Calculus (FOPC)
Components
• Object constants: A, B, Deepak, etc.
• Function Constants: fatherOf, colorOf, etc.
• Relation Constants: Parent, On, Clear, Sibling, etc.
• Variables: 𝑥, 𝑦, 𝑧, 𝑢, 𝑣, 𝑤, etc.
• Connectives: ∨, ∧, ¬, ⇒
• Quantifiers: ∀, ∃
• Delimiters: (, ), [, ]
6
11/15/2017
4
Objects, Functions, Relations
Object constants: these are objects or individuals in the domain…
A, B, Deepak, Red, Car54, etc.
Function Constants: operate on objects and denote other objects
𝑓𝑎𝑡ℎ𝑒𝑟𝑂𝑓1, 𝑐𝑜𝑙𝑜𝑟𝑂𝑓1, 𝑑𝑖𝑠𝑡𝑎𝑛𝑐𝑒2etc.
Relation Constants: Denote properties on, between objects
Parent2, On2, Clear1, Sibling2, etc.
7
FOPC - Syntax
Terms
• An object is a term
• A function constant of arity, n followed by n terms is a term (functional expression)
e.g. 𝑚𝑜𝑡ℎ𝑒𝑟𝑂𝑓(Sally), 𝑐𝑜𝑙𝑜𝑟𝑂𝑓 A
Wffs – represent propositions
• Atomic wffs relation-constantn(term1, term2,…termn)
e.g. Parent(Ginny, Lily)
• Propositional wffsIf ω1and ω2 are wffs, then so are
ω1ω1∨ ω2 disjunctionω1∧ ω2 conjunctionω1⇒ ω2 implication¬ ω1 negation
8
11/15/2017
5
FOPC - Syntax
Terms
• An object is a term
• A function constant of arity, n followed by n terms is a term (functional expression)
e.g. 𝑚𝑜𝑡ℎ𝑒𝑟𝑂𝑓(Sally), 𝑐𝑜𝑙𝑜𝑟𝑂𝑓 A
Wffs – represent propositions
• Atomic wffs relation-constant(…)
e.g. Parent(Ginny, Lily)
• Propositional wffsIf ω1and ω2 are wffs, then so are
ω1ω1∨ ω2 disjunctionω1∧ ω2 conjunctionω1⇒ ω2 implication¬ ω1 negation
9
Save for later…
Variables: 𝑥, 𝑦, 𝑧, 𝑢, 𝑣, 𝑤, etc.Quantifiers: ∀, ∃
FOPC - SemanticsObjects The world can have infinite objects/individuals
- concrete- abstract- fictional
As long as it is a name and we need to say something about it.
Functions Denote objects, we may not have a name for…
fn(o1, o2, …, on) -> object
Relations Denote properties
Heavy(𝑥) On(A, B)Big(𝑦) Clear(A)Human(Deepak) Block(A)
Interpretation
• An atomic wff is True/False just in case the relation denoted by it holds for its arguments.
10
11/15/2017
6
FOPC Example - Blocksworld
• Objects A, B, C, Table
• Relations On2, Clear1
On(C, Table) On(A, C) On(B, A)Clear(B) Clear(A) Clear(C) Clear(Table)
• Example Knowledge Base
Δ = {On(C, Table), On(A, C), On(B, A), Clear(B)}
11
B
A
CTable
FOPC Example - Blocksworld
• Objects A, B, C, Table
• Relations On2, Clear1
On(C, Table) On(A, C) On(B, A)Clear(B) Clear(A) Clear(C) Clear(Table)
• Example Knowledge Base
Δ = {On(C, Table), On(A, C), On(B, A), Clear(B)}
12
B
A
CTable
But, how to make generalStatements about the world?
11/15/2017
7
Variables & Quantifiers• Variables – A variable is a term. i.e. it denotes/can denote an object.
• Universal Quantifier (∀ - “for-all”)
if ω is a wff and 𝑥 is a variable then
(∀𝑥) ω is a wff
∀𝑥 (ω) is a wff
∀𝑥 [ω] is a wff
ω is the scope of the variable.E.g.
∀𝑥 [ P(x) ⇒ R(x) ]
• Existential Quantifier (∃ - “there exists”)
if ω is a wff and 𝑥 is a variable then
(∃ 𝑥) ω is a wffe.g.
∃ 𝑥 [ P(𝑥) ⇒ ∃ 𝑦 [ R(𝑥, 𝑦) ⇒ S(𝑓(𝑥) ] ]
13
Semantics of ∀ and ∃
In a given domain
∀𝑥 ω(x) has value True
Just in case ω(x) has value True for all assignments of x to objects in the domain.
e.g. On2, Clear1
∀𝑥 [ On(x, C) ⇒ ¬Clear(C) ]
Just in case x=A/B/C/Table are True.
14
11/15/2017
8
Semantics of ∀ and ∃
In a given domain
∀𝑥 ω(x) has value True
Just in case ω(x) has value True for all assignments of x to objects in the domain.
e.g. On2, Clear1
∀𝑥 [ On(x, C) ⇒ ¬Clear(c) ]
Just in case x=A/B/C/Table are True.
Similarly,
∃x ω(x) has value True
Just in case ω(x) is True for atleast one assignment for x in the domain.
15
Example
Tell King(John)
Tell Person(Richard)
Tell ∀𝑥 [ King(𝑥) ⇒ Person(𝑥) ]
Queries
1. King(John)?
2. ∃x Person(x)?
But, we want to know who is a person!
3. ASK-VARS(KB, Person(x))
16
11/15/2017
9
Example
Tell King(John)
Tell Person(Richard)
Tell ∀𝑥 [ King(𝑥) ⇒ Person(𝑥) ]
Queries
1. King(John)?
True
2. ∃x Person(x)?
True
But, we want to know who is a person!
3. ASK-VARS(KB, Person(x))
17
Example
Tell King(John)
Tell Person(Richard)
Tell ∀𝑥 [ King(𝑥) ⇒ Person(𝑥) ]
Queries
1. King(John)?
True
2. ∃x Person(x)?
True
But, we want to know who is a person!
3. ASK-VARS(KB, Person(x))
x = Richardx = John
18
11/15/2017
10
Example
Tell King(John)
Tell Person(Richard)
Tell ∀𝑥 [ King(𝑥) ⇒ Person(𝑥) ]
Queries
1. King(John)?
True
2. ∃x Person(x)?
True
But, we want to know who is a person!
3. ASK-VARS(KB, Person(x))
x = Richardx = John
19
Tell ∀x [ King(x) ∧ Greedy(x) ⇒ Evil(x) ]Tell King(John)Tell Greedy(John)
Query
Evil(John)?True
Blocksworld
On(x, y) : x is on top of y
Clear(x) : x is clear
Block(x) : x is a block
On(B, A)On(A, C)On(C, Table)Block(A)Block(B)Block(C)∀x, y [ Block(x) ∧ Block(y) ∧ On(x, y) ⇒ ¬Clear(y) ]
20
11/15/2017
11
Blocksworld
On(x, y) : x is on top of y
Clear(x) : x is clear
Block(x) : x is a block
On(B, A)On(A, C)On(C, Table)Block(A)Block(B)Block(C)∀x, y [ Block(x) ∧ Block(y) ∧ On(x, y) ⇒ ¬Clear(y) ]
21
Isa(x, y) : x is a y
Isa(A, Block)Isa(B, Block)Isa(C, Block)
Blocksworld
On(x, y) : x is on top of y
Clear(x) : x is clear
Block(x) : x is a block
On(B, A)On(A, C)On(C, Table)Block(A)Block(B)Block(C)∀x, y [ Isa(x, Block) ∧ Isa(y, Block) ∧ On(x, y) ⇒ ¬Clear(y) ]
22
Isa(x, y) : x is a y
Isa(A, Block)Isa(B, Block)Isa(C, Block)
11/15/2017
12
23
Marge Vernon Petunia Lily James Arthur Molly
Mrs Dursley Mr Dursley Mrs Evans Mr Evans Mr Potter Mrs Potter Septimus Cedrella
Dudley Harry Ginny Ron George Fred Percy Charlie Bill
James Albus Lily
Hermione
Hugo Rose
24
Marge Vernon Petunia Lily James Arthur Molly
Mrs Dursley Mr Dursley Mrs Evans Mr Evans Mr Potter Mrs Potter Septimus Cedrella
Dudley Harry Ginny Ron George Fred Percy Charlie Bill
James Albus Lily
Hermione
Hugo Rose
Predicates
1. Female(x) : x is female2. Male(x) : x is male3. Parent(x, y) : x is a parent of y4. Married(x, y) : x is married to y
11/15/2017
13
25
Marge Vernon Petunia Lily James Arthur Molly
Mrs Dursley Mr Dursley Mrs Evans Mr Evans Mr Potter Mrs Potter Septimus Cedrella
Dudley Harry Ginny Ron George Fred Percy Charlie Bill
James Albus Lily
Hermione
Hugo Rose
Predicates
1. Female(x) : x is female2. Male(x) : x is male3. Parent(x, y) : x is a parent of y4. Married(x, y) : x is married to y
Symbols
Marge, Vernon, James1, James2, Albus, Lily, Harry, etc.
Female(Marge)Female(Petunia)Female(Lily)Male(James1)Male(Vernon)Etc.
Married(Vernon, Petunia)Married(Lily, James1)Married(Arthur, Molly)Married(Harry, Ginny)Married(Ron, Hermione)Etc.
Parent(Harry, James2)Parent(Ginny, James2)Parent(Petunia, Dudley)Parent(Vernon, Dudley)Parent(Molly, Bill)Etc.
26
Marge Vernon Petunia Lily James Arthur Molly
Mrs Dursley Mr Dursley Mrs Evans Mr Evans Mr Potter Mrs Potter Septimus Cedrella
Dudley Harry Ginny Ron George Fred Percy Charlie Bill
James Albus Lily
Hermione
Hugo Rose
Predicates
1. Female(x) : x is female2. Male(x) : x is male3. Parent(x, y) : x is a parent of y4. Married(x, y) : x is married to y
Symbols
Marge, Vernon, James1, James2, Albus, Lily, Harry, etc.
Female(Marge)Female(Petunia)Female(Lily)Male(James1)Male(Vernon)Etc.
Married(Vernon, Petunia)Married(Lily, James1)Married(Arthur, Molly)Married(Harry, Ginny)Married(Ron, Hermione)Etc.
Parent(Harry, James2)Parent(Ginny, James2)Parent(Petunia, Dudley)Parent(Vernon, Dudley)Parent(Molly, Bill)Etc.
Facts
11/15/2017
14
Modeling Relationships
• Spouse(x, y) : x is a spouse of y
• Wife(x, y) : x is a wife of y
• Husband(x, y)
• Father(x, y), Mother(x, y)
• Sibling(x, y), Brother(x, y), Sister(x, y)
• GrandParent/GrandMother/GrandFather
• GrandChild/GrandDaughter/GrandSon
• Aunt/Uncle/AuntOrUncle
• Cousin
• Niece/Nephew/NieceOrNephew
• Child/Daughter/Son
• Etc.
27
Modeling Relationships
• Spouse(x, y) : x is a spouse of y
• Husband/Wife
• Mother/Father
28
11/15/2017
15
Modeling Relationships
• Spouse(x, y) : x is a spouse of y
∀x, y [Married(x, y) ⇒ Spouse(x, y) ]
• Husband/Wife*
∀x, y [ Female(x) ∧ Married(x, y) ⇒ Wife(x, y) ]
• Mother/Father
∀x, y [ Female(x) ∧ Parent(x, y) ⇒ Mother(x, y) ]
29
Modeling Relationships…
• Sibling(x, y) : x is a sibling of y
∀x, y [[∃z Father(z, x) ∧ Father(z, y)] ∧ [∃w Mother(w, x) ∧ Mother(w, y)] ∧ (x≠y) ⇒ Sibling(x, y) ]
30
11/15/2017
16
Modeling Relationships
• Spouse(x, y) : x is a spouse of y
• Wife(x, y) : x is a wife of y
• Husband(x, y)
• Father(x, y), Mother(x, y)
• Sibling(x, y), Brother(x, y), Sister(x, y)
• GrandParent/GrandMother/GrandFather
• GrandChild/GrandDaughter/GrandSon
• Aunt/Uncle/AuntOrUncle
• Cousin
• Niece/Nephew/NieceOrNephew
• Child/Daughter/Son
• Etc.
31
Another Example (From R&N)
• Domain: people, songs, albums, disks (CDs)
CopyOf(d, a) : disk d is a copy of album aOwns(p, d) : person p owns disk dSings(p, s, a) : album a includes recording of song s sung by pWrote(p, s) : person p wrote song s
Constants: McCartney, Gershwin, Joe, EleanorRigby, TheManILove, Revolver, BillieHoliday, Joe
32
11/15/2017
17
Another Example…
1. Gershwin wrote The Man I Love
Wrote(Gershwin, TheManILove)
2. Gershwin did not write Eleanor Rigby
¬ Wrote(Gershwin, EleanorRigby)
3. Either Gershwin or McCartney wrote The Man I Love
Wrote(Gershwin, TheManILove) ∨ Wrote(McCartney, TheManILove)
4. Joe has written at least one song
∃s Wrote(Joe, s)
5. Joe owns a copy of Revolver
∃x CopyOf(x, Revolver) ∧ Owns(Joe, x)
33
Another Example…
6. Every song that McCartney sings on revolver was written by McCartney
∀s [Sings(McCartney, s, Revolver) ⇒ Wrote(McCartney, s) ]
7. Gershwin did not write any of the songs on Revolver
¬[ ∃s Wrote(Gershwin, s) ∧ ∃p Sings(p, s, Revolver) ]
8. Every song that Gershwin wrote has been recorded on some album
∀s [ Wrote(Gershwin, s) ⇒ ∃p,a Sings(p, s, a) ]
34
11/15/2017
18
Another Example…
9. There is a single album that contains every song that Joe has written
∃a [∀s Wrote(Joe, s) ⇒∃p Sings(p, s, a) ]
10. Joe owns a copy of an album that has Billy Holiday singing The Man I Love
∃d, a, s [CopyOf(d, a) ∧ Owns(Joe, d) ∧ Sings(BillieHoliday, TheManILove, a)]
35
Another Example…
11. Joe owns a copy of every album that has a song sung by McCartney
∀a [ ∃s Sings(McCartney, s, a) ⇒∃d CopyOf(d, a) ∧ Owns(Joe, d) ]
12. Joe owns a copy of every album on which all the songs are sung by Billie Holiday
∀a [ [∀s, p Sings(p, s, a) ⇒ Sings(BillieHolliday, s, a)] ⇒∃d CopyOf(d, a) ∧ Owns(Joe, d) ]
36
11/15/2017
19
FOPC Exercise
The law says that it is a crime for an American to sell weapons to hostile nations. The country Nono, an enemy of America, has some missiles, and all of its missiles were sold to it by Colonel West, who is American.
Use the following relations:
American(x) : “x is an American”Enemy(x, y) : “x is an enemy of y”Hostile(x) : “x is hostile”Criminal(x) : “x is a criminal”Missile(x) : “x is a missile”Weapon(x) : “x is a weapon”Owns(x, y) : “x owns y”Sells(x, y, z) : “x sells y to z”
To write FOPC wffs for the following:
1. … it is a crime for an American to sell weapons to hostile nations:
2. Nono… has some missiles:
3. … all of its missiles were sold to it by Colonel West:
4. Also, Missiles are weapons:
5. And, an enemy of America is hostile:
6. …West, who is American:
7. The country Nono, an enemy of America:37