Sunteți pe pagina 1din 27

General Methods of Acquiring

Knowledge
• Deductive
– New knowledge follows from prior knowledge by reasoning
– E.g., Math proofs or logical inference
• Inductive
– New knowledge based on observations of the world
– E.g., we may learn that apples fall from trees as a child by
watching apples fall from trees
• Deduction-induction combination
– E.g., use a theory (e.g., deductive knowledge base) and examples
from world (inductive oriented) to generate new information,
predictions
Logic: Chapter 7
• Deductive reasoning
– Logical inferences in a formal language
– Preserve truth with each inference
– Reasoning assumed to be same as logical proof
• Logical formalisms
– Termed “Knowledge representation”
– Use logical languages
• E.g., propositional logic or predicate calculus
– Application to AI
• A new language
– E.g., to specify start state, goals, knowledge, inference rules
• Inference rules
– A logical way to work from start state to goals using knowledge
Overall Approach
Inputs Processing Outputs

Logical Agent
Goal or task
statement
Reasoning
(search)
Knowledge Goal, plus
steps to
achieve goal

Rely on logical formalisms


Propositional Logic
• Syntax
– What are the sentences or well-formed
formulas (wffs)?
• Semantics
– Correspondence to truth values (true/false)
• Proof theory
– Deductive inference mechanisms
Syntax: What are the wffs?
• A constant is a wff
true, false
• Propositional symbols are wffs
– Symbols: variables standing for true or false & names of other
wffs
– E.g., P, Q, A, B
• A wff with parentheses is a wff
E.g., (true), (P)
• If P is a wff, and Q is a wff, then
P Ÿ Q is a wff
P ⁄ Q is a wff
P fi Q is a wff
P ¤ Q is a wff
ÿ P is a wff
Semantics:
What Do the wffs Mean?
• Defined by truth tables, see Figure 7.8, p. 207
• world
– Logic symbols refer to aspects of real world situation
– Symbol, J may mean “Jane”
– Symbol, K may mean “Jane’s child is 8 yrs old”
– We provide this interpretation of the symbols
• model
– A mapping from symbols to truth values
– A label for a row in a truth table
When is a KB true?
• KB = Knowledge Base
– A KB is a collection of wffs
– E.g., KB = { (A⁄C), (B⁄ÿC) }
• A KB is true when the conjunction of all
KB wffs in a row in the corresponding truth
table are true
• M(KB) = the set of all rows in the truth table
that are true for KB
Example
• Let KB = { (A⁄C), (B⁄ÿC) }
• What is M(KB)?
• Method
– Form a truth table with columns A, B, C
– Write down wffs of KB in additional columns
– Determine when conjunction of wffs in KB are true
– Determine M(KB)
Entailment
KB |= a
|= is symbol for entailment; a is another wff
KB entails a iff a is true in all models where KB is true
• Entailment means
– Add a to the KB and preserve truth
– a is new knowledge
• Entailment is the first requirement for an inference
procedure or mechanism
– We want to infer new statements that are true
Inference Procedures
• An inference procedure lets us mechanically
preserve truth
– E.g., if A and B are in the KB, then we can insert the
new wff: “A Ÿ B” into the KB
A Ÿ B is true in all models where KB is true, so
KB |= A Ÿ B
• Additional requirements for a specific inference
procedure
– Generation: create new sentences a
– Verification: check if some a is entailed
KB |-i a
a can be derived from KB with a specific inference
procedure
Inference Problem & Approaches
• Inference problem
– Given a KB
• E.g., KB = {P, P ⁄ Q},
– How do we determine if a new wff, a, logically follows
from the KB?
– i.e., how do we determine if: KB |= a
• Approaches
– Enumeration method
– Inference rules & proof construction
Enumeration Method
• Given
– KB and a wff a
• Question: Is KB |= a
• Method
– Compute M(KB)
– Compute M(a)
KB |= a iff M(KB) Õ M(a)
(KB entails a iff a is true in all models where KB is true)
Why?
KB |= a iff M(KB) Õ M(a)
• Consider again KB = { (A⁄C), (B⁄ÿC) }
– Recall that M(KB) = {4, 5, 7, 8}
• Let a be (A ⁄ B ⁄ C)
M(a) = {2, 3, 4, 5, 6, 7, 8}
• Would we expect KB |= a ?

• Let a be (A Ÿ B)
M(a) = {7, 8}
• Would we expect KB |= a ?
Example
• Let KB = { (A⁄C), (B⁄ÿC) }
• Let a = A⁄B
• Is it true that KB |= a ?

KB |= a iff M(KB) Õ M(a)


Inference Rules & Proof Construction:
A Simple Inference Procedure
• Say KB = {A1, A2, A3, … }
• How to derive new true wffs?
– Assume our logical language has “and”
– Usual notation: ^
• Then, define the following inference procedure
– Given two wff’s, X and Y from KB
– Create a new wff by: X ^ Y
– Call this procedure |-and Because each wff
in the KB is true, a
KB |-and A1 ^ A2
conjunction of two
KB |-and A2 ^ A2 wffs from the KB
must also be true
Inference Procedure #2: Modus Ponens
Given that: Call this
a fi b ΠKB modus ponens
And or KB |-mp
a ΠKB
Then:
KB |= b We are reasoning over M(KB);
assume that M(KB) <> {}
• Justification
– To see that modus ponens preserves truth, recall:
a fi b = ÿa ⁄ b
– We know that:
• a Œ KB (I.e., a is true)
– Therefore ÿa œ KB (because, otherwise, M(KB) = {})
– Therefore because ÿa ⁄ b Œ KB (i.e., a fi b Œ KB),
• b must be true
– Therefore KB |= b
Example: Modus Ponens
• Given: KB = { P Ÿ Q => R, P Ÿ Q }
• Prove: R using KB |-mp
Solution
• KB = { P Ÿ Q => R, P Ÿ Q }
• Let a = P Ÿ Q, and Let b = R
• KB has wffs of form: a fi b, a
• By modus ponens, KB |= R
Example
• Using our enumeration procedure, and our
definition of entailment:
KB |= a iff M(KB) Õ M(a)
• Prove that:
{ a fi b, a} |= b
Inference Procedure #3: Unit Resolution
Given that:
a ⁄ b Œ KB Call this
And unit resolution
ÿb Œ KB
Then:
KB |= a

• Justification
– To see that unit resolution preserves truth:
• Note that ÿb is true (i.e., ÿb Œ KB),
– Therefore, b is false
– Therefore because a ⁄ b Œ KB,
• a must be true
– Therefore KB |= a
Example
• Given: KB = { (PŸ R) ⁄ Q, ÿQ }
• Prove: PŸ R
– Using unit resolution
Solution
• KB = { (PŸ R) ⁄ Q, ÿQ }
• Let a = (PŸ R), Let b = Q
• KB has wffs of form: a ⁄ b, ÿ b
• By unit resolution, KB |= (PŸ R)
Inference Procedure #4: Resolution
Given that:
a ⁄ b Œ KB Call this
And resolution
g ⁄ ÿb Œ KB
Then:
KB |= a ⁄ g
• Justification
– To see that resolution preserves truth:
• Note that for any symbol P, either P is true or ÿP is true
• So, either b or ÿb is true
– Case 1: b is true
• ÿb is false, therefore g is true (since g ⁄ ÿb Œ KB)
– Case 2: ÿb is true
• b is false, therefore a is true (since a ⁄ b Œ KB)
– Therefore since either Case 1 or Case 2 must apply
• a ⁄ g must be true
– Therefore, KB |= a ⁄ g
Resolution Example
• Given: KB = { (PŸ R) ⁄ Q, ÿQ ⁄ (R ŸS) }
• Prove: (PŸ R) ⁄ (R ŸS)
Solution
• KB = { (PŸ R) ⁄ Q, ÿQ ⁄ (R ŸS) }
• Let a = (PŸ R)
• Let g = (R ŸS)
• Let b = Q
• KB has wffs of form: a ⁄ b, ÿ b ⁄ g
• By resolution, KB |= (PŸ R) ⁄ (R ŸS)
Example Application
• Reasoning about statements in natural language
• Given
– Statements in natural language
– And a goal (theorem) to prove
• Convert statements in natural language to
(propositional) logic
• Convert theorem into logic
• Apply inference “operators” until theorem (goal)
is reached
Example (Exercise 7.9, p. 238)
If the unicorn is mythical, then it is immortal, but if
it is not mythical, then it is a mortal mammal. If the
unicorn is either immortal or a mammal, then it is
horned. The unicorn is magical if it is horned.
• Prove that the unicorn is magical.

1) Translate English sentences into logic


2) Use inference to prove

S-ar putea să vă placă și