0% found this document useful (0 votes)
18 views33 pages

PROPOSITIONAL LOGIC - Part A - Last Version

Uploaded by

janabadareen34
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views33 pages

PROPOSITIONAL LOGIC - Part A - Last Version

Uploaded by

janabadareen34
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 33

A KNOWLEDGE-BASED

AGENT
and PROPOSITIONAL
LOGIC
CHAPTER 7
A Knowledge-Based Agent (1)
 A knowledge-based agent consists of a knowledge
base (KB) and an inference engine (IE)

Input from Inference Output


A knowledge base is a set of sentences. environmen (actions)
Engine
Here “sentence” is used as a technical term. It is related t
but not identical to the sentences of English and other Learning
natural languages. (KB
Knowledge update)
 Each sentence is expressed in a language called a Base
knowledge representation language and represents
some assertion about the world. Agent
A Knowledge-Based Agent (2)
The Inference engine derives new sentences from
the input and KB
The inference mechanism depends on
representation in KB Input from Inference Output
environmen Engine (actions)
The agent operates as follows: t
Learning
1. It receives percepts from environment
(KB
2. It computes what action it should perform (by IE Knowledge update)
and KB)
Base
3. It performs the chosen action (some actions are
simply inserting inferred new facts into KB).
Agent
Why use a knowledge base? a collection of
sentences
To learn with experiences and take action as per the knowledge.
knowledge representation
 Knowledge representation and reasoning is the part of Artificial intelligence which concerned
with AI agents thinking and how thinking contributes to intelligent behavior of agents.
 It is responsible for representing information about the real world so that a computer can
understand and can utilize this knowledge to solve the complex real-world problems.
 It is also a way which describes how we can represent knowledge in artificial intelligence.
Knowledge representation is not just storing data into some database, but it also enables an
intelligent machine to learn from that knowledge and experiences so that it can behave
intelligently like a human.
What is a Logic?
 Logic is a formal language for representing information such that conclusions can be drawn
 The sentences are expressed according to the syntax of the representation language
Semantics define the “meaning" of sentences;
The truth of each sentence with respect to each possible world.
E.g., the language of arithmetic
 X+ Y = 4 is true in a world where X=3; Y =1
 X+ Y = 4 is true in a world where X=2; Y=2
 X+ Y = 4 is false in a world where X=3; Y =2
Models
 A model m is a term that used in place of “possible world”.
 If a sentence α is true in model m, we say that m satisfies α or sometimes m is a model of α
m is a model of a sentence  if  is true in m
M() is the set of all models of 
Entailment
 Entailment means a sentence follows logically from another sentence.
 The sentence α entails the sentence β
M(β)

 if and only if, in every model in which α is true, β is also true.

M(α)
 KB |= a if and only if M(KB) M(a)
Knowledge base KB entails sentence a if and only if a is true in all
worlds where KB is true

M(a)
Entailment in the Wumpus world
 Situation after detecting nothing in [1,1], moving right, detecting breeze in [1,2]
 Consider possible models (models) for ?

1 2 3
Wumpus models m2
m1

All possible models in this reduced Wumpus world.

m5
m3
m4

1
m8
m6
1 2 3
m7

KB = {No Breeze in square [1,1], Breeze in square [1,2]}


Wumpus models
KB = Wumpus-world rules + observations
KB Observations =
{No Breeze in square [1,1], Breeze in square [1,2]}

1 = “There is no pit in [2,1]”? KB |= 1 ?


2 = “There is no pit in [2,2].”? KB |= 2 ?
Wumpus models
1 = “There is no pit in [2,1]”?
Wumpus models
2 = “There is no pit in [2,2].”?
Model Checking
• In Wumpus world, the entailment is applied to derive conclusions from KB; i.e. a logical inference is
carried out by checking the models. The algorithm used in this process is called as model checking.
• Model Checking is an inference algorithm that enumerates all possible models (of KB) to check that α is
true in all models in which KB is true, that is, that M(KB) ⊆ M(α). Thus KB ⊨ α
• Model checking algorithm can be expensive (or impractical) because KB can have too many models (or it
can have infinite models in some logics).
Propositional Logic
 Is the simplest form of logic where all the sentences are made by propositions (symbols)
It is also called Boolean logic (0 or 1)

A proposition is a declarative sentence (that is, a sentence that declares a fact) that is either
true or false, but not both.

 The syntax of propositional logic defines the allowable sentences

 Two types of sentences:


 Atomic sentences
 Complex sentences
Atomic Sentences
 Consist of a single proposition symbol (or variable)  Other examples

 In propositional logic, symbolic variables are used to represent the logic,  “Ahmad is smart”  p
and we can use any symbol for a representing a proposition
 “Ahmad is hardworking”  q
A proposition symbol can be
 “Amman is the capital of Jordan”
A symbol stand for any arbitrary fact
 Start with an uppercase letter and may contain other letters or subscripts
 The conventional letters used for propositional variables are p, q, r, s,..,etc..
 The value of the symbol can be True or False
 For example: there is a breeze in square 1,1 B1,2

 Or logical constants True, False


Complex sentences
 Are constructed from simpler sentences, using parentheses and logical connectives.
 There are five connectives in common use:
Logical Connectives
1. Negation ( ¬ ) : A sentence such as ¬ P is called negation of P.
 Example: ¬ B1,3

2. Conjunction (∧) : A sentence which has ∧ connective such as, P ∧ Q is


called a conjunction.
 Example: Ahmad is smart and hardworking. It can be written as,
p= Ahmad is smart,
q= Ahmad is hardworking. p ∧ q .

3.Disjunction (∨) : A sentence which has ∨ connective, such as P ∨ Q. is called


disjunction, where P and Q are the propositions.
 Example: “Ahmad is a doctor or engineer",
Here p= “Ahmad is Doctor”. q= “Ahmad is engineer”, so we can write it as p ∨ q.
Logical Connectives
 Implication (→): A sentence such as P → Q, is called an implication. Implications are
also known as if-then rules.

 In the conditional statement p → q, p is called the hypothesis (or premise), and q is


called the conclusion (or consequence).

 Example:
 If it is raining, then the street is wet.
Let p= “It is raining”, and q= “Street is wet”, so it is represented as p → q
 if the sky is cloudy, then the sun is not visible.
Let p= “the sky is cloudy”, and q= “the sun is not visible”, so it is represented as p → q
Logical Connectives
1. Biconditional: A sentence such as P⇔ Q is a Biconditional sentence,
 Example: I am alive if only if I am breathing
p= “I am alive” , q=“I am breathing”, it can be represented as p ⇔ q.

 There are some other common ways to express p ↔ q:


 “p is necessary and sufficient for q”
 “if p then q, and conversely”
 “p iff q.” “p exactly when q.”
Precedence of connectives
Precedence Operators

First Precedence Parenthesis

Second Precedence Negation

Third Precedence Conjunction(AND)

Fourth Precedence Disjunction(OR)

Fifth Precedence Implication

Six Precedence Biconditional


Validity and Inference
 Truth tables can be used to test sentences for validity
 One row for each possible combination of truth values for the symbols in the sentence
 The final value must be True for every sentence
Validity and satisfiability
A sentence is valid if it is true in all models,
 e.g., True,A A, A  A, (A  (A  B))  B

Validity is connected to inference via the Deduction Theorem:


 KB ╞ α if and only if (KB  α) is valid

A sentence is satisfiable if it is true in some model


 e.g., A B,
 (determining satisfiability of sentences is NP-complete)

A sentence is unsatisfiable if it is false in all models


 e.g., A  A

Satisfiability is connected to inference via the following:


 KB ╞ α if and only if (KB α) is unsatisfiable
?? Satisfiable

P Q ~Q P->Q P->~Q ANS

F F T T T T

F T F T T T

T F T F T F

T T F T F F
?? Unsatisfiable

P Q R ~Q ~R P->Q P->R ~Q ^ ~ R ANS

F F F T T T T T F

F F T T F T T F F

F T F F T T T F F

F T T F F T T F F

T F F T T F F T F

T F T T F F T F F

T T F F T T F F F

T T T F F T T F F
Inference and Derivation
inference rules allow the construction of new sentences from existing sentences
A sentence  can be derived from  or the sentence α entails the sentence β.


 |-  or

an inference procedure generates new sentences on the basis of inference rules
if all the new sentences are entailed, the inference procedure is called sound or
truth-preserving
Logical equivalence
To manipulate logical sentences, we need some rewrite rules.
Two sentences are logically equivalent (≡) if only if they are true in same models: α ≡ ß
Inference Rules
 Modus Ponens
 from an implication and its premise one can infer the conclusion
 For example:

if    and  is given , then  can be inferred


P  Q, P
 Proof by Truth table:
Q

 Modus Tollens
P  Q,
Q
P
Inference Rules
 double-negation elimination
 a double negations infers the positive sentence  P
P
 And-elimination
 from a conjunct, one can infer any of the conjuncts
 Proof by Truth table:
PQ PQ
Or
P Q

General Form 1  2 ...  n


i
Inference Rules
And-introduction 1, 2, … , n
 from a list of sentences, one can infer their
conjunction
1  2 ...  n

 Or-introduction
 from a sentence, one can infer its disjunction with P
anything else
PQ
Wumpus world- Sample
Let Pi,j be true if there is a pit in [i, j]. Knowledge Base
Let Bi,j be true if the agent perceives a breeze in [i, j].

Let Si,j be true if the agent perceives a stanch in [i, j].


? ? ?
Let Wi,j be true if there is a Wampus in [i, j]. 3

 Let Gi,j be true if there is a Gold in [i, j]. ? ? ?


 "Pits cause breezes in adjacent squares" 2
I.e., “A square is breezy if and only if there is an adjacent pit“
B1,1  (P1,2  P2,1) 1 A ? ?
B2,1  (P1,1  P2,2  P3,1)
 " Wumpus causes stench in adjacent squares"
I.e., “A square is stenchy if and only if there is an adjacent Wumpus“ 1 2 3
S1,1  (W1,2  W2,1)
S2,1  (W1,1  W2,2  W3,1)

Notice that we need one such sentence for every square!
 KB can be expressed as the conjunction of all these sentences
Wumpus world- Sample
Knowledge Base
3 ? ? ?
KB:
B1,1  (P1,2  P2,1)
? ?
2 ? B2,1  (P1,1  P2,2  P3,1)
B1,2  (P1,1  P2,2  P1,3)
?
1 A ? …
1 2 3
Start:  P1,1,  B1,1 , S1,1 , W1,1
Wumpus world- Sample ? ? ?
Knowledge Base 3

How to prove ¬P ? ? ?
1,2
2 ??
OK
 S1: B1,1  (P1,2  P2,1)
 S2: B2,1 (P1,1  P2,2  P3,1) ?
1
 S3:  P1,1 A ??
OK
 S4:  B1,1
 S5:  S1,1 1 2 3
 S6: W
1,1 …..

 We apply biconditional elimination to S1 to obtain S7 : (B1,1 ⇒ (P1,2 ∨ P2,1)) ∧ ((P1,2 ∨ P2,1) ⇒ B1,1) .

 Then we apply And-Elimination to S7 to obtain S8 : ((P1,2 ∨ P2,1) ⇒ B1,1)

 S8 = Logical equivalence for contraposition  S9 : (¬B1,1 ⇒ ¬(P1,2 ∨ P2,1)) .

 Now we can apply Modus Ponens with S9 and S4 ( B1,1), to obtain S10 : ¬(P1,2 ∨ P2,1)

 Finally, we apply De Morgan’s rule, giving the conclusion S11 : ¬P 1,2 ∧ ¬P2,1
 That is, neither [1,2] nor [2,1] contains a pit.
Wumpus world- Sample Knowledge Base
 ? ? ?
How to prove that there is no a S1: B1,1  (P1,2  P2,1)
3
pit in [2,2] ( P2,2)?  S2: B2,1 (P1,1  P2,2  P3,1)
 S3: B1,2 (P1,1  P2,2  P1,3) OK ? ?
2 A
 S4:  P1,1
2
 S5:  B1,1
Breeze ?
 S6:  S1,1 KB 1 A 1
OK
AA
 S7: W1,1
 S8: ¬P1,2 1 2 3

 S9:
S10:¬PB2,1
1,2
 S11: ¬ B2,1

You might also like