notes 7: knowledge representation, the propositional calculus ics 270a winter 2003
TRANSCRIPT
Notes 7: Knowledge Representation, The Propositional Calculus
ICS 270A Winter 2003
ICS-270A: Notes 7: 2
Outline
Representing knowledge using logic Agent that reason logically
A knowledge based agent
Using constraints on feature values
A rich and implicit representation of the world state.
Representing and reasoning with logic Propositional logic
Syntax
Semantic
validity and models
Rules of inference for propositional logic
Resolution
Complexity of propositional inference.
Reading: Nillson Chapters 13,14, Russel and Norvig, Chapter 7
ICS-270A: Notes 7: 3
Why knowledge-base
The state of the world may require lots of information..
The agent knowledge of the state of the world: If s is world state K(s) is what the agent knows.
For economy: Not everything explicitly specified. Some facts can be inferred.
Agent may infer whatever he does not know explicitly.
Nillson: Constraints on feature values Block A is not on the floor
Issues: In what language to express what the agent knows about the world. How
explicit to make this knowledge. How to infer.
Description of the worldAgent knowledge of state
Agent explicit specificationof what he knows
ICS-270A: Notes 7: 4
Knowledge RepresentationDefined by: syntax, semantix
Assertions Conclusions(knowledge base)
Facts Facts
Inference
Imply
Computer
Real-World
Semantics
Reasoning: in the syntactic levelExample: zxzyyx |,
ICS-270A: Notes 7: 5
Constraints on the world
World so far were described by feature values: On(block,floor) On(A,B) Clear(C)
But some information is more complex Law: all human are mortal, all blue box are pushable
Negative information: block a is not on the floor
Either A or B are pushable
Examples: A lifting robot: features: Bat_ok, liftable, moves
Constraints on the worlds can be written in logic: Bat_ok and liftable moves
If moves is false and Bat_ok is true, we infer liftable is false.
Logical languages involve Syntax, the grammar
Semantics: the meaning of words and sentences
Inference rules: deriving new information that is correct.
ICS-270A: Notes 7: 6
The party example
If Alex goes, then Beki goes: A B
If Chris goes, then Alex goes: C A
Beki does not go: not B
Chris goes: C
Query: Is it possible to satisfy all these conditions?
Should I go to the party?
ICS-270A: Notes 7: 8
Example of Languages for Representation
Programming languages: Formal languages, not ambiguous, but cannot express partial
information. Not expressive enough.
Natural languages: very expressive but ambiguous: ex: small dogs and cats.
Good representation language: Both formal and can express partial information, can accommodate
inference
Main approach used in AI: Logic-based languages.
ICS-270A: Notes 7: 9
Propositional Logic
Syntax : Alphabet: {true,false,P,Q}
Connectives:
Well-Formed formulas: (wffs or sentences): w1, w2
If Alex_goes Beki_goes
Semantics: True means true
False means false
Symbols means objects in the world and they are true or false relative to a scenario, or a world, we refer to.
Meaning of a sentence is derived from its parts as defined by truth-tables.
},,,{ Q
)( PQP
SRQP )(
ICS-270A: Notes 7: 10
Truth tables for the logical connectives
ICS-270A: Notes 7: 11
A grammer for sentences in propositional logic
ICS-270A: Notes 7: 12
Truth Tables
Truth tables can be used to compute the truth value of any wff.
Can be used to find the truth of
Given n features there are 2n different worlds, different
interpretations.
Interpretation: any assignment of true and false to atoms
An interpretation satisfies a wff if the wff is assigned true under
the interpretation
A model: An interpretation is a model of a wff if the wff is satisfied in that
interpretation.
Satisfiability of a wff can be determined by the truth-table
Bat_on and turns-key_on Engine-starts
Wff is unsatisfiable or inconsistent it has no models
SQRP ))((
)( PP
)()()()( QPQPQPQP
ICS-270A: Notes 7: 13
Validity
ICS-270A: Notes 7: 14
Validity, Equivalence
Validity: A wff is Valid if it is true in all interpretations P P
Equivalence: two wffs are equivalent iff they have the same models. DeMorgan laws, law of contrapositive
If w1 is equivalent to w2 then: w1 w2 and w2 w1
Associative
Distributive
DeMorgan’s
)( 1221 wwww
321321321 )()( wwwwwwwww
)()()( 5121521 wwwwwww
))(
))(
2121
2121
wwww
wwww
ICS-270A: Notes 7: 15
Logical Entailment:truth in the world
KB ( ) entails a sentence, iff all the models of KB are models of alpha (in other words, any interpretation that satisfies KB satisfies alpha.)
If some sentences are true in the world it implies that some other sentences are true.
statement P is true whenever some other set KB of statements is true, then “KB entails P”.
Whenever means: In any possible world (model) in which every sentence of KB is true.
PQP
PP
ICS-270A: Notes 7: 16
Producing an additional wffs from a set of wffs From alpha infer beta
Sound inference rule: The conclusion is true whenever the premises are true.
Examples Modus ponens: { A and A B |-- B} is sound, resolution is sound.
Proof: A sequence of inference rules generating the desired conclusion from
the KB. Example: KB = From From KB
Rules of Inference
221 www
},{},,{ BAACBBAAC ABBA inferandCAAC inferand
C
ICS-270A: Notes 7: 17
Rules of inference
ICS-270A: Notes 7: 19
Resolution in Propositional Calculus
Using clauses as wffs Literal, clauses, conjunction of clauses (cnfs)
Resolution rule: Resolving (P V Q) and (P V Q) P
Generalize modus ponens, chaining . Resolving a literal with its negation yields empty clause.
Resolution is sound Resolution is NOT complete:
P and R entails P V R but you cannot infer P V R From (P and R) by resolution
Resolution is complete for refutation: adding (P) and (R) to (P and R) we can infer the empty clause.
Decidability of propositional calculus by resolution refutation: if a wff w is not entailed by KB then resolution refutation will terminate without generating the empty clause.
)( RQP
ICS-270A: Notes 7: 20
Soundness of resolution
ICS-270A: Notes 7: 21
The party example
If Alex goes, then Beki goes: A B
If Chris goes, then Alex goes: C A
Beki does not go: not B
Chris goes: C
Query: Is it possible to satisfy all these conditions?
Should I go to the party?
ICS-270A: Notes 7: 22
Example of proof by Refutation
Assume the claim is false and prove inconsistency: Example: can we prove that Chris will not come to the party?
Prove by generating the desired goal.
Prove by refutation: add the negation of the goal and prove no model
Proof:
Refutation:
AC
BBA
CinferAACfrom
AinferBBAfrom
,
,
)( CACBBA
AC
ICS-270A: Notes 7: 23
The moving robot examplebat_ok,liftable moves~moves, bat_ok
ICS-270A: Notes 7: 24
Converting wffs to Conjunctive clauses
1. Eliminate implications: ~(PQ) or (R P)
2. Reduce the scope of negation sign
3. Convert to cnfs using the associative and distributive laws
ICS-270A: Notes 7: 25
Converting wffs to Conjunctive clauses
1. Eliminate implications
2. Reduce the scope of negation sign
3. Convert to cnfs using the associative and distributive laws
QPQP )( )()( PRQP
)()( QPQP )()( PRQP
)()( QPQP )()( PRQP
)()( PRQPRP
)(),( PRQRP
ICS-270A: Notes 7: 26
Proof by refutation
Given a database in clausal normal form KB Find a sequence of resolution steps from KB to the
empty clauses
Use the search space paradigm:
• States: current cnf KB + new clauses
• Operators: resolution
• Initial state: KB + negated goal
• Goal State: a database containing the empty clause
• Search using any search method
ICS-270A: Notes 7: 27
Proof by refutation (contd.)
Or: Prove that KB has no model - PSAT
A cnf theory is a constraint satisfaction problem:
• variables: the propositions
• domains: true, false
• constraints: clauses (or their truth tables)
• Find a solution to the csp. If no solution no model.
• This is the satisfiability question
• Methods: Backtracking arc-consistency unit resolution, local search
ICS-270A: Notes 7: 28
Resolution refutation search strategies
Ordering strategies Breadth-first, depth-first
I-level resolvents are generated from level-(I-1) or less resolvents
Unit-preference: prefer resolutions with a literal
Set of support: Allows reslutions in which one of the resolvents is in the set of support
The set of support: those clauses coming from negation of the theorem or their decendents.
The set of support strategy is refutation complete
Linear input Restricted to resolutions when one member is in the input clauses
Linear input is not refutation complete
Example: (PVQ) (P V not Q) (not P V Q) (not P V not Q) have no model
ICS-270A: Notes 7: 29
Complexity of propositional inference
Checking truth tables is exponential
Satisfiability is NP-complete
However, frequently generating proofs is easy.
Propositional logic is monotonic If you can entail alpha from knowledge base KB and if you add sentences
to KB, you can infer alpha from the extended knowledge-base as well.
Inference is local Tractable Classes: Horn, 2-SAT
Horn theories:
Q <-- P1,P2,...Pn
Pi is an atom in the language, Q can be false.
Solved by modus ponens or “unit resolution”.
ICS-270A: Notes 7: 30
Summary
Representing knowledge using logic Using logic to represent and reason about knowledge
Logic, syntax, semantics and proof theory
Representing and reasoning with logic Propositional logic
Syntax
Semantic
validity and models
Rules of inference for propositional logic
Complexity of propositional inference.
Reading: Nillson Chaters 13, 14 Russel and Norvig Chapter 7.