Knowledge Representation Review
- Representing the world in terms of state spaces, operators and goal tests assumes the world is static
- Need to create an agent that has knowledge about the world (a knowledge base) and can reason using that knowledge
Knowledge representation language
- The objective is to express knowledge in a computer tractable form. A KR language has 2 aspects:
- syntax: specifies the legal symbols
- semantics: specifies the meaning of these symbols; what they refer to in the real world
- Facts about the real world are encoded in the KR language
Reasoning
- Reasoning is the process by which the agent constructs new representations in the KR language from old representations (in the KR language). Proper reasoning ensures that the new representations correspond to correct facts in the real world. See picture on page 158. This relationship is called entailment.
Entailment
- Call the representations in the KR language sentences, then entailment means that the new sentences generated are necessarily true given that the old sentences are true.
- A sentence is true if the state of affairs it describes exists in the real world. Truth is established by the semantics of the KR language and the state of the real world. Examples?
Inference procedure
- An inference procedure is used to generate new sentences that are entailed by the old sentences (the knowledge base).
- entailment: KB |= P
- inference: KB |- P
- 2 desirable properties of inference procedures:
- Soundness: if Q |- R then Q |= R (i.e., inference only produces entailment)
- Completeness: if Q |= R then Q |- R (i.e., inference produces all entailments)
- a proof theory of a language specifies the sound inference steps
Inference in computers
- The computer knows nothing about the semantics of the KR language or the real world
- To show that KB |= Q the computer must show this to be true under all interpretations
- A sentence that is true under all interpretations is valid; formal inference rules derive valid conclusions
Formal Logics
- Defined by syntax, semantics & proof theory
- Ontological commitments (the nature of reality; the kinds of existence):
- propositional logic: statements (propositions)
- predicate calculus: statements, objects, and relations between objects
- probability theory: statements
- Epistemological commitments (states of knowledge):
- propositional logic: true, false or unknown
- predicate calculus: true, false or unknown
- probability theory: degree of belief (will cover later)
Propositional Logic Syntax
- The constants T and F are sentences
- Any propositional symbol (P, Q, R, S, ....) is a sentence
- If Q and R are sentences then so is:
- (Q)
- Q ^ R conjunction
- Q | R disjunction
- ~ Q negation
- Q => R implication
- Q <=> R equivalence
- Rules apply recursively to produce complex sentences. Examples?
Grammar of propositional logic
- See fig 6.8:
- sentence -> atomic sentence | complex sentence
- atomic sentence -> True | False | P | Q | R ....
- complex sentence -> (sentence) |
sentence connective sentence
| ~sentence
connective -> ^ | <=> => ~
Semantics of propositional logic
- Need to specify the interpretation of the propositional symbols and constants and the meaning of connectives:
- a proposition is true when the fact it refers to holds
- the constant true is always interpreted as a true fact and false as a fact that is not true
- connectives are interpreted as functions
Semantic continued
- Rules for complex sentences (the meanings of logical connectives)
- Q ^ R is True iff Q is True and R is True
- Q | R is True iff Q is True or R is True
- ~Q is True iff Q is not True (False)
- Q => R is True iff Q is not True or R is True
- Q <=> R is True iff Q is True and R is True or Q is False and R is False
- These rules can be expressed in truth tables (see page 168, Fig 6.9 of text)
Truth Tables
Implication
- Implication does not require a causation relationship: it is a claim about the truth of Q when P is true. If P is false, then P => Q is true regardless of Q’s status.
- P => Q is equivalent to ~P | Q
Truth tables for entailment
- Can use truth tables to test for entailment: Given a premise P and a conclusion C (i.e., premise => conclusion), build a truth table for the sentence P => C and check that all rows are true. If all rows are true then the sentence is valid.
Entailment example
Common Inference Rules
- Modus Ponens: {Q=>R, Q} |- R
- And Elimination: {P1 ^ P2 ... ^ Pn} |- Pi
- And Introduction: {P1, P2 ... ,Pn} |- {P1 ^ P2 ... ^ Pn}
- Or Introduction: Pi |- {P1 | P2 ... | Pi | ... | Pn}
- Double Negation Elimination: ~ ~ Q |- Q
- Unit Resolution: {Q | R, ~R} |- Q
- Resolution: {Q | R, ~Q | P} |- {R | P}
Note that sentences are separated by commas
Completeness and Complexity
- Propositional logic using truth tables is complete: enumerate all 2n rows for the n proposition symbols in the target sentence. But this is exponential in n.
- In general checking a set of sentence for satisfiability is NP-complete
- There is a subset of propositional logic for which polynomial time algorithms exist: Horn logic (Prolog). All sentences have the form: P1 ^ P2 ^ ... ^ Pn => Q where Pi are non-negative prop. symbols
Wumpus World
- Wumpus world: (see fig 6.2 on pg 154) a 4x4 grid (not all connected) inhabited by a wumpus, bottomless pits, and some gold. The agents task is to find the goal. Need to specify the agent’s percepts, actions and goals:
- Percepts:
- wumpus smells: stench in adjacent cells
- breeze adjacent to bottomless pits
- glitter where gold is
- agent feels a bump when walks into a wall
- wumpus screams when dies
Wumpus world continued
- Actions:
- go forward, turn right, turn left
- grab gold
- shoot one arrow
- climb out of cave from start square
- die (eaten by wumpus or fall into bottomless pit)
- Goal:
- grab gold and leave as quickly as possible
Example
Example continued
- Enter at [1,1]
- Percepts: [none,none,none,none,none]
- Infer that [1,2] and [2,1] are ok
- Move to [2,1]
- Percepts: [none,breeze,none,none,none]
- Infer that a pit may be at either [2,2] or [3,1]
- Move back to [1,1] and then to [1,2]
- Percepts: [stench,none,none,none,none]
- Infer: wumpus at [1,1] (already been there), [2,2] (would have smelled it at [2,1]) or [1,3]
also no breeze so pit must be at [2,2] (would have felt breeze
at [1,2]), or [1,3]
Example continued
- formalize last inference:
- Current percepts: ~S[1,1], ~S[2,1], S[1,2]
~B[1,1], B[2,1], ~B[1,2]
- Domain knowledge:
R1: ~S[1,1] => ~W[1,1] ^ ~W[1,2] ^ ~W[2,1]
R2: ~S[2,1] => ~W[1,1] ^ ~W[2,1] ^ ~W[2,2] ^ W[3,1]
R3: ~S[1,2] => ~W[1,1] ^ ~W[1,2] ^ ~W[2,2] ^ W[1,3]
R4: S[1,2] => W[1,3] | W[1,2] | W[2,2] | W[1,1]
Example continued
- Inference:
1. ~S[1,1], R1 |- ~W[1,1] ^ ~W[1,2] ^ ~W[2,1]
2. ~S[1,1], R1 |- ~W[1,1] , ~W[1,2], ~W[2,1]
3. ~S[2,1], R2 |- ~W[2,2] , ~W[2,1] , ~W[3,1]
4. ~S[1,2], R4 |- W[1,3] | W[1,2] | W[2,2] | W[1,1]
5. 4, 2a |- W[1,3] | W[1,2] | W[2,2]
6. 5, 3a |- W[1,3] | W[1,2]
7. 6, 2b |- W[1,3]