COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple...
Transcript of COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple...
![Page 1: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/1.jpg)
Click to edit Present’s Name
Week 3 – Practical ReasoningDavid Rajaratnam
COMP4418Knowledge Representation and Reasoning
![Page 2: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/2.jpg)
COMP4418 – KRR
Practical Reasoning - My Interests● Cognitive Robotics.● Connect high level
cognition with low-level sensing/actuators.
● Logical reasoning to make robot behave intelligently.
● Baxter Blocksworld video...
![Page 3: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/3.jpg)
COMP4418 – KRR
Recap of Weeks 1 & 2● Week 1: Propositional logic
– Simple propositions: “Socrates is bald”– Semantics: meaning decided using truth tables– Syntax: provability decided using inference rules – resolution for CNF– But... limited expressivity
● Week 2: First-order logic– Able to capture properties of objects and relationships between objects– Semantics: meaning decided using interpretations– Syntax: provability using inference rules - resolution + unification for CNF– highly expressive but... undecidable.
![Page 4: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/4.jpg)
COMP4418 – KRR
A Brief Overview of KRR Formalisms
![Page 5: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/5.jpg)
COMP4418 – KRR
Many Formalisms in KRR
Propositional logic
First-order logic
Expressivity
![Page 6: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/6.jpg)
COMP4418 – KRR
Many Formalisms in KRR
Propositional logic – Satisfiablity is NP-complete
First-order logic – Satisfiability is undecidable
Expressivity
ComputationalComplexity
*actually semi-decidable, but distinction is not important for this course.
![Page 7: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/7.jpg)
COMP4418 – KRR
Many Formalisms in KRR
Propositional logic – Satisfiablity is NP-complete
First-order logic – Satisfiability is undecidable
Expressivity
ComputationalComplexity
Many important problems:● Scheduling● Timetabling● Vehicle routing
![Page 8: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/8.jpg)
COMP4418 – KRR
Many Formalisms in KRR
Propositional logic – Satisfiablity is NP-complete
First-order logic – Satisfiability is undecidable
Expressivity
ComputationalComplexity
![Page 9: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/9.jpg)
COMP4418 – KRR
Many Formalisms in KRR
Propositional logic – Satisfiablity is NP-complete
First-order logic – Satisfiability is undecidable
Expressivity
ComputationalComplexity
Propositional fragmentsWhen speed is important:● Databases
![Page 10: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/10.jpg)
COMP4418 – KRR
Many Formalisms in KRR
Propositional logic – Satisfiablity is NP-complete
First-order logic – Satisfiability is undecidable
Expressivity
ComputationalComplexity
Higher-order logics – some interest
Propositional fragmentsWhen speed is important:● Databases
![Page 11: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/11.jpg)
COMP4418 – KRR
Many Formalisms in KRR
Propositional logic – Satisfiablity is NP-complete
First-order logic – Satisfiability is undecidable
Expressivity
ComputationalComplexity
![Page 12: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/12.jpg)
COMP4418 – KRR
Many Formalisms in KRR
Propositional logic – Satisfiablity is NP-complete
First-order logic – Satisfiability is undecidable
Expressivity
ComputationalComplexity
Decidable
![Page 13: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/13.jpg)
COMP4418 – KRR
Many Formalisms in KRR
Propositional logic – Satisfiablity is NP-complete
First-order logic – Satisfiability is undecidable
Expressivity
ComputationalComplexity
Description logics, modal logics,Answer Set Programming
Many interesting problems:● Planning● Reasoning about
knowledge
Decidable
![Page 14: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/14.jpg)
COMP4418 – KRR
Horn Clauses
![Page 15: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/15.jpg)
COMP4418 – KRR
Clause RecapFrom weeks 1 & 2:
● Every formula can be converted to Conjunctive Normal Form (CNF)● Any CNF can be viewed as a set of clauses● Entailment checking with resolution is complete (proof by refutation)● So using sets of clauses provides:
– Intuitive language for expressing knowledge
– Simple proof procedure that can be implemented
vs
![Page 16: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/16.jpg)
COMP4418 – KRR
Reading Clauses as ImplicationClauses can be intuitively interpreted in two ways:
● As disjunction:
● As implication:
– for syntactic convenience:– so can be read as: if “child” and “male” then “boy”
To understand why this makes sense go back to the truth tables:
Modified from: KR & R @ Brachman & Levesque 2005
![Page 17: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/17.jpg)
COMP4418 – KRR
Horn Clauses● Horn clause is a clause with at most one positive literal
● A positive (or definite) clause has exactly one positive literal
● A negative clause (or constraint) has no positive literals
– Note, since
– Hence
– Also know as a goal when performing refutation proof ● A fact is a definite clause with no negative literals (i.e., a single positive literal):
Modified from: KR & R @ Brachman & Levesque 2005
( or )
![Page 18: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/18.jpg)
COMP4418 – KRR
Resolution with Horn Clauses 1Two options:
PosNeg
Neg
PosPos
Pos
Examples:
Modified from: KR & R @ Brachman & Levesque 2005
![Page 19: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/19.jpg)
COMP4418 – KRR
Resolution with Horn Clauses 2It is possible to rearrange derivations (of negative clauses) so that all new derived clauses are negative clauses:
Given clauses:
Modified from: KR & R @ Brachman & Levesque 2005
Derived positive clause Only derive
negative clauses
![Page 20: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/20.jpg)
COMP4418 – KRR
SLD ResolutionCan change derivations such that each derived clause is a resolvent of the previous derived (negative) one and some positive clause in the original set of clauses
● Since each derived clause is negative, one parent must be positive (and so from original set) and one negative.
● Continue working backwards until both parents of derived clause are from the original set of clauses
● Eliminate all other clauses not on direct path
Modified from: KR & R @ Brachman & Levesque 2005
c1
c2
c3
cn
cn1
new
old
![Page 21: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/21.jpg)
COMP4418 – KRR
SLD Example
Modified from: KR & R @ Brachman & Levesque 2005
To show that derive a contradiction from
Note: Horn clauses capture a very intuitive way that we express knowledge.
![Page 22: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/22.jpg)
COMP4418 – KRR
SLD Resolution (formal)An SLD-derivation of a clause c from a set of clauses S is a sequence of clauses c1, c2, ... cn such that cn = c, and
1. c1 S
2. ci+1 is a resolvent of ci and a clause in S
Written as:
Modified from: KR & R @ Brachman & Levesque 2005
SLD mean S(elected) literals L(inear) form D(efinite) clauses
![Page 23: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/23.jpg)
COMP4418 – KRR
In General SLD is incompleteSLD resolution is not complete for general clauses.An example:
Modified from: KR & R @ Brachman & Levesque 2005
So S is unsatisfiable, that is: , but
SLD cannot derive the contradition because it needs to eventually perform resolution on the intermediate clauses and and(or )
![Page 24: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/24.jpg)
COMP4418 – KRR
Completeness of SLD● But SLD resolution IS complete for Horn clauses.
● This is a good result as searching for appropriate clauses to resolve on is simpler for SLD resolution.
● Satisfiability for propositional Horn clauses is P-complete.● Nothing is for free: loss of expressivity.● Cannot express simple (positive) disjunctions.
Modified from: KR & R @ Brachman & Levesque 2005
Theorem: If H is a set of Horn clauses then iff
c1
c2
c3
cn
cn1
new
old
n is polynomial in number of clauses
![Page 25: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/25.jpg)
COMP4418 – KRR
Back to the KRR Overview
Propositional logic – Satisfiablity is NP-complete
First-order logic – Satisfiability is undecidable
Expressivity
ComputationalComplexity
Propositional fragments – Horn clauses
![Page 26: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/26.jpg)
COMP4418 – KRR
Back to the KRR Overview
Propositional logic – Satisfiablity is NP-complete
First-order logic – Satisfiability is undecidable
Expressivity
ComputationalComplexity
Propositional fragments – Horn clausesTractable
Decidable
![Page 27: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/27.jpg)
COMP4418 – KRR
First-Order (FO) ClausesWeek 2 recap:
● Conversion to FO CNF is same as propositional case except:– Standardise variable names– Skolemise (getting rid of existential quantifiers)– Drop universal quantifiers
● FO resolution is same as propositional case except:– Find substitutions to unify the two clauses
Modified from: KR & R @ Brachman & Levesque 2005
![Page 28: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/28.jpg)
COMP4418 – KRR
First-Order (FO) Horn Clauses● Same as propositional case except in a FO language● SLD-resolution also same; with addition of unification● Completeness of FO Horn also holds
● But...
Modified from: KR & R @ Brachman & Levesque 2005
Theorem: If H is a set of Horn clauses then iff
![Page 29: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/29.jpg)
COMP4418 – KRR
First-Order (FO) Horn Clauses● FO Horn is undecidable. With Horn SLD resolution we can still
generate an infinite sequence of resolvents.
Modified from: KR & R @ Brachman & Levesque 2005
KB:
Query:
Should fail since
![Page 30: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/30.jpg)
COMP4418 – KRR
Basis for Logic Programming● Since FO Horn is undecidable it is also very expressive● FO Horn and SLD resolution form the basis for Prolog
– A general purpose programming language based on logic– Provides an intuitive language for expressing knowledge– Prolog is Turing-complete– Prolog is a form of declarative programming – you specify
what the program should do not how it should do it
Modified from: KR & R @ Brachman & Levesque 2005
![Page 31: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/31.jpg)
COMP4418 – KRR
Prolog
Modified from: KR & R @ Brachman & Levesque 2005
….go to Prolog slides
![Page 32: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/32.jpg)
COMP4418 – KRR
Concluding Remarks
Modified from: KR & R @ Brachman & Levesque 2005
![Page 33: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/33.jpg)
COMP4418 – KRR
Conclusion● Scoped out the KRR landscape and relationship between formalisms● Looked at propositional and first-order Horn clauses and SLD resolution
– Empasised distinction between Semantics vs Syntax● Entailment (meaning)● Inference (symbol manipulation)
● Looked at Prolog– Turing complete: general purpose programming language– Declarative programming allows for compact representations
Modified from: KR & R @ Brachman & Levesque 2005
![Page 34: COMP4418 - WebCMS3 · COMP4418 – KRR Recap of Weeks 1 & 2 Week 1: Propositional logic – Simple propositions: “Socrates is bald” – Semantics: meaning decided using truth](https://reader033.fdocuments.in/reader033/viewer/2022051918/600a2c2738c3bb28825e28c3/html5/thumbnails/34.jpg)
COMP4418 – KRR
Coming Weeks● Prolog's expressivity comes with a cost
– Efficiency issues and undecidability– Operational behaviour violates logical semantics; cut (!) operator,
ordering of clauses.● In coming weeks will look at more specialised logics that take a different
approach to balance expressibility-computability-efficiency
Modified from: KR & R @ Brachman & Levesque 2005