Propositional Logic - PowerPoint PPT Presentation

About This Presentation
Title:

Propositional Logic

Description:

squares adjacent to wumpus are smelly - squares adjacent to pits are breezy ... shooting kills wumpus if you are facing it - shooting uses up the only arrow ... – PowerPoint PPT presentation

Number of Views:91
Avg rating:3.0/5.0
Slides: 41
Provided by: vladimir5
Category:

less

Transcript and Presenter's Notes

Title: Propositional Logic


1
Propositional Logic
  • Reading Ch. 7, AIMA 2nd Ed.
  • (skip 7.6-7.7)

2
Logic for knowledge representation
  • Important problem knowledge representation
    solving the problems of
  • How to represent knowledge about problem domain
  • How to reason using this knowledge in order to
    answer queries or make decisions
  • Knowledge-based agents
  • Have knowledge representation in a formal
    language
  • Can reason about world using inference in the
    language
  • Can decide what action to take by inferring that
    the action is good
  • Declarative agents
  • Declare to agents facts about world
  • Pose questions to get answers

3
Declarative knowledge-based agents
4
Wumpus world
  • Performance measureGold 1000, death 1000, step
    1, arrow 10
  • Environment- squares adjacent to wumpus are
    smelly- squares adjacent to pits are breezy-
    glitter iff gold is in the same square- shooting
    kills wumpus if you are facing it- shooting uses
    up the only arrow- grabbing picks up gold if in
    the same square- releasing drops the gold in
    same square
  • SensorsBreeze, glitter, smell
  • ActuatorsLeft, right turn, forward, grab,
    release, shoot

5
Wumpus world characterization
  • Observable
  • No only local perception
  • Deterministic
  • Yes outcomes explicite
  • Episodic
  • No sequential actions
  • Discrete
  • Yes
  • Single-agent
  • Yes

6
Exploring wumpus world

A
7
Exploring wumpus world
B
A

8
Exploring wumpus world
B

A
9
Exploring wumpus world
B
S

A
10
Exploring wumpus world
P
ok
B
S

W
A
How can we make these inferences automatically?
11
Logic
  • Logic is a formal language for representing
    information such that conclusions can be drawn
  • A logic includes
  • Syntax specifies symbols in the language and how
    they can be combined to form sentences
  • Semantics specifies what facts in the world a
    semantics refers to.Assigns truth values to
    sentences based on their meaning in the world.
  • Inference procedure mechanical method for
    computing (deriving) new (true) sentences from
    existing sentences

12
Example
  • Language of arithmetic
  • 4xy gt 0 is a sentence, 4xlty0 is not
  • 4xy gt 0 is true iff number 4xy is greater than
    zero
  • 4xy gt 0 is true in a world where x0, y 1
  • 4xy gt 0 is false in a world where x0, y 0
  • Hence, to build a logic-based representation
  • Define a set of primitive symbols and the
    associated semantics
  • Logic defines the ways of putting there symbols
    together in order to represent true facts about
    world
  • Logic defines ways of inferring new sentences
    from existing ones

13
Propositional (Boolean) logic
  • Simple language (but useful for key ideas and
    definitions)
  • Language syntax
  • Atoms/Symbols P12, B11, W33,, IS_HOT, IS_BREEZY,
    ?, User defines meaning of symbols.
  • Connectives ? (and), ? (or), ? (implies), ?
    (iff), ? (not)
  • Sentences or Well-formed-formulae (wff)
  • A symbol is a sentence
  • If S is a sentence, ?S (negation) is a sentence
  • If S and T are sentences, S?T (conjunction), S?T
    (disjunction), S?T (implication), S?T
    (equivalence) are sentences
  • A finite number of applications of (1)-(3) is a
    sentence

14
Symbols Sentences of Wumpus world
  • Pij is pit in (i,j)
  • Bij is breeze in (i,j)
  • Wij is wumpus in (i,j)
  • ?B11
  • Pits cause breezes in adjacent squares
  • B11 ? ( P12 ? P21 )
  • B12 ? ( P11 ? P22 ? P13 )

15
Semantics
  • Association of elements of logical language
    (atoms sentences) with real world
  • Propositional logic associate atoms with
    propositionsE.g.,
  • P12 is associated with pit is in cell (1,2)
  • B11 is associated with breeze is felt in cell
    (1,1)
  • W33 is associated with wumpus is in (3,3)
  • IS_HOT is associated with I am taking cs440
  • Association of atoms with propositions
    interpretationIf atom ? has value TRUE (1),
    then its interpretation P is true in the world
    otherwise ? has value FALSE (0)
  • E.g., P12 1 means pit is in cell (1,2) is true

16
Propositional truth tables
  • Used to compute values of any sentence, given
    values of atoms
  • Establishes meaning of propositional connectives
  • The basic truth table can be used to evaluate any
    sentence by applying the rules recursively ?A ?
    ( A?B ) ?0 ? ( 0?1 ) 1 ? ( 0?1 ) 1 ? 1 1

17
Models
  • A model is an interpretation of a set of
    sentences such that each sentence is True? is
    a model of a sentence S if S is true in ? ( an
    interpretation of S satisfies ? )
  • A mathematical structure that represents the
    (problem in) real world.
  • Some other notions
  • Unsatisfiable there is no interpretation that
    satisfies S

18
Models of Wumpus world
  • Situation after detecting nothing in (1,1),
    moving up, breeze in (2,1)
  • What are the possible models for P?, assuming
    only pits?
  • P12, P22, P31 ? 0,1
  • 8 possible models

19
Models of Wumpus world
Are these the models of Wumpusworld?
20
Wumpus Knowledge Base (KB)
  • KB S1, S2, , SN set of all sentences
    describing our current knowledge of the world,
    where each sentence is in propositional logic
  • Wumpus world KBS1 ?B11S2 B21S3 B11 ? ( P12
    ? P21 )S4 B21 ? ( P11 ? P22 ? P31 )S5 ?P11
  • Remember, models are interpretations where all Si
    are true
  • How to find models?

21
Model checking Enumeration of symbols in
sentences
  • Check for valid models by enumerating all
    possible symbols interpretations KB S1 ? S2 ?
    S3 ? S4 ? S5

22
Model checking Enumeration of symbols in
sentences
  • Models are shown in red!
  • How many enumerations? 27

23
Models of Wumpus world
  • Rows of the truth table where the last column
    (KB) is true (I.e., all sentences are true)

KB
24
Inference entailment
  • Given KB, what else can we conclude about the
    world?E.g., does a goal (a.k.a. query,
    conclusion, theorem) sentence G follow from KB?
  • Note we do not know semantics.Hence we have to
    determine if all models of KB are models of G.
  • I.e., KB entails G, ( KB G ) iff G is true
    whenever KB is true
  • KB G iff KB ? G is valid(A sentence is valid
    iff it is true under all possible
    interpretations)
  • KB G iff KB ? ?G is unsatisfiable

25
Wumpus world entailment
  • G (1,2) is safe
  • Does KB G ?

YES!
M(KB)?M(G)
KB
G
26
Wumpus world entailment (II)
  • G ?P12
  • Column KB?G is all 1, hence it is valid. Thus,
    KB G.
  • Conclusion G follows from KB no matter what the
    interpretations

27
Inference by enumeration properties
  • The truth table method of inference is complete
    for Propositional Logic because we can always
    enumerate all 2N rows for the N propositional
    symbols that occur.
  • But this is exponential in N. In general, it has
    been shown that the problem of checking if a set
    of sentences in PL is satisfiable is NP-complete.
  • Can be implemented using which search procedure?
  • Depth-first search.
  • (The truth table method of inference is not
    complete for First-Order Logic.)

28
Inference procedures
  • Inference methods
  • Model checking
  • Enumeration (seen previously)
  • Improved backtracking local search
  • Inference using sound rules of inference
  • Derive new sentences that are true in all cases
    where premises are true.E.g., ( P 1 and P?Q
    1 ) ? Q 1
  • Construct a proof that a given sentence G can be
    derived from KB using a sequence of inference
    rules
  • Rules R are sound if, for a KB and sentence G, KB
    - G under rules R implies KB G
  • If when KB G there exists a proof of G from KB
    using R, then the R is complete
  • If R is sound and complete we can prove
    entailment by searching for a proof

29
(Some) Sound rules of inference
30
Using SRI in Wumpus world
  • S1 ?B11S2 B21S3 B11 ? ( P12 ? P21 ) KBS4
    B21 ? ( P11 ? P22 ? P31 )S5 ?P11
  • S6 (B11?(P12?P21))?( P12?P21)?B11) S3
    equivalence elimin.
  • S7 (P12?P21)?B11 S6 and elimination
  • S8 ? B11? ?( P12 ? P21 ) S7 negation
  • S9 ?( P12 ? P21 ) S1, S8, modus ponens
  • S10 ?P12 ? ?P21 S9 DeMorgan
  • Monotonicity property
  • adding new sentences to a KB does not change
    entailment ( KB G ? KB ? S G ). It can
    only lead to new conclusions.

31
Inference using Resolution
  • A single rule sufficient for complete inference
    procedure, when coupled with a complete search
    algorithm ( A ?
    B, ?A) leads to B ( A ?
    B, ?A ? C) leads to B ? C

32
Resolution in Wumpus world
  • Continue from previous example by moving A into
    (1,2) and not feeling breeze
  • S1 ?B11, S2 B21, S3 B11 ? ( P12 ? P21 ), S4
    B21 ? ( P11 ? P22 ? P31 ), S5 ?P11 KB
  • S10 ?P12 ? ?P21 previously inferred
  • S11 ?B12 percept
  • S12 B12 ? ( P11 ? P22 ? P13 ) rule
  • S13 ? P22 S11 S12 equiv. elim., add elim,
    modus ponens
  • S14 ? P13
  • S15 P11 ? P22 ? P31 S4 S2 equiv. elim.
    modus ponens
  • S16 P11 ? P31 S15, S13 resolution
  • S17 P31 S16, S5 resolution

33
Resolution algorithm CNF
  • How to effectively use resolution? It only
    applies to disjunctions of symbols.
  • CNF conjunctive normal forms
  • Every KB can be represented as a CNF
  • Every sentence can be represented as a
    conjunction of disjunctions of literals
  • Method
  • Eliminate equivalences (conjunction of
    implications)
  • Eliminate implications (disjunctions of negation
    symbols/sent)
  • Propagate negations to literals (DeMorgan)
  • Done!

34
CNF in Wumpus world
  • S3 B11 ? ( P12 ? P21 )
  • ( B11 ? ( P12 ? P21 ) ) ? ( ( P12 ? P21 ) ?B11 )
  • ( ?B11 ? ( P12 ? P21 ) ) ? (?( P12 ? P21 ) ? B11
    )
  • ( ?B11 ? P12 ? P21 ) ? ( (? P12 ? ? P21 ) ? B11 )
  • ( ?B11 ? P12 ? P21 ) ? ( ? P12 ? B11 ) ? ( ? P21
    ? B11 )
  • CNF

35
Resolution refutation algorithm
  • Relies on proof by contradiction
    (refutation)Assume goal sentence is false,
    prove KB does not hold.
  • Remember, KB G iff KB ? ?G is unsatisfiable,
    i.e., KB ? ?G
  • Algorithm
  • Convert all sentences in KB to CNFs
  • Resolve all pairs of CNFs into new clauses
  • Check for contradiction
  • Resolution refutation is complete

36
Resolution refutation in Wumpus world
KB
G
37
Special case Horn clauses and forward- backward
chaining
  • Restricted set of clauses Horn
    clausesdisjunction of literals where at most
    one is positive, e.g.,?A ? ?B ? C or ?A ? ?B
  • Why Horn clauses?
  • Every Horn clause can be written as an
    implication, e.g.,?A ? ?B ? C ? ( A ? B ) ? C
    ( A ? B ) ? C ?A ? ?B ? ( A ? B ) ( A ? B
    ) ? 0 (integrity constraint)
  • Inference in Horn clauses can be done using
    forward-backward (F-B) chaining in linear time

38
Example of FC
39
How good is PL as a representational language?
  • Not very expressive
  • Cannot express complex environments concisely
  • E.g., need to write separate rules for every
    square in Wumpus world even though they do not
    change from square to squareBij ? ( Pi,j-1 ?
    Pi,j1 ? Pi-1,j ? Pi1,j ), for all (i,j)
  • E.g., to specify there is exactly one wumpus in
    the world, need to specify
  • There is at least one ?
  • There is at most one ?

40
Announcement
  • New assignment type mini project-presentations
  • Prepared by a team of two students
  • Related to a topic discussed in class
  • Presented in class, 15-20 mins
  • Will be graded, 15 of total grade (new grade
    distribution final 30, midterm 30, hw 25,
    presentation 15)
  • First presentationOct 15, Bayesian network
    software
  • Prepare slides and handouts (web page, pdf file
    is ok) for the class
Write a Comment
User Comments (0)
About PowerShow.com