0% found this document useful (0 votes)
54 views40 pages

Foundations of AI: Ch. 12: Propositional Logic

This document provides an overview of propositional logic and its applications to knowledge representation for intelligent agents. It discusses: 1) How agents can think rationally by representing portions of the world in a knowledge base using a formal logic. This allows the agent's knowledge and inferences to influence its behavior. 2) It introduces the "Wumpus World" as an example domain that can be represented using propositional logic. 3) The basics of propositional logic including syntax, semantics, and how logical implication can be used to determine if a proposition follows from a knowledge base. It discusses converting formulas to conjunctive and disjunctive normal forms. 4) Methods for determining logical implication including truth tables
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
54 views40 pages

Foundations of AI: Ch. 12: Propositional Logic

This document provides an overview of propositional logic and its applications to knowledge representation for intelligent agents. It discusses: 1) How agents can think rationally by representing portions of the world in a knowledge base using a formal logic. This allows the agent's knowledge and inferences to influence its behavior. 2) It introduces the "Wumpus World" as an example domain that can be represented using propositional logic. 3) The basics of propositional logic including syntax, semantics, and how logical implication can be used to determine if a proposition follows from a knowledge base. It discusses converting formulas to conjunctive and disjunctive normal forms. 4) Methods for determining logical implication including truth tables
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 40

Foundations of AI: Ch.

12
Propositional Logic

Rational Thinking, Logic, Resolution


Contents

ƒ Agents that think rationally

ƒ The wumpus world

ƒ Propositional logic: syntax and semantics

ƒ Logical entailment

ƒ Logical derivation (resolution)

07/2
Agents that Think Rationally

ƒ Until now, the focus has been on agents that act rationally.
ƒ Often, however, rational action requires rational (logical)
thought on the agent’s part.
ƒ To that purpose, portions of the world must be represented
in a knowledge base, or KB.
ƒ A KB is composed of sentences in a language with a truth
theory (logic), i.e. we (being external) can interpret sentences
as statements about the world. (semantics)
ƒ Through their form, the sentences themselves have a causal
influence on the agent’s behavior in a way that is correlated
with the contents of the sentences. (syntax)
ƒ Interaction with the KB through ASK and TELL (simplified):
ASK(KB,α) = yes exactly when α follows from the KB
TELL(KB,α) = KB’ so that α follows from KB’
FORGET(KB,α) = KB’ non-monotonic (will not be discussed)
07/3
3 Levels
In the context of knowledge representation, we can distinguish
three levels [Newell 1990]:
Knowledge level: Most abstract level. Concerns the total knowledge
contained in the KB. For example, the automated DB information
system knows that a trip from Freiburg to Basel costs 18€.
Logical level: Encoding of knowledge in a formal language.
Price(Freiburg, Basel, 18.00)
Implementation level: The internal representation of the sentences,
for example:
• As a string “Price(Freiburg, Basel, 18.00)”
• As a value in a matrix
When ASK and TELL are working correctly, it is possible to remain
on the knowledge level. Advantage: very comfortable user
interface. The user has his/her own mental model of the world
(statements about the world) and communicates it to the agent
(TELL). 07/4
A Knowledge-based Agent

A knowledge-based agent uses its knowledge base to


ƒ represent its background knowledge
ƒ store its observations
ƒ store its executed actions
ƒ … derive actions

07/5
The Wumpus World (1)
ƒ A 4 x 4 grid
ƒ In the square containing the wumpus and in the directly
adjacent squares, the agent perceives a stench.
ƒ In the squares adjacent to a pit, the agent perceives a
breeze.
ƒ In the square where the gold is, the agent perceives a
glitter.
ƒ When the agent walks into a wall, it perceives a bump.
ƒ When the wumpus is killed, its scream is heard
everywhere.
ƒ Percepts are represented as a 5-tuple, e.g.,

[Stench, Breeze, Glitter, None, None]

means that it stinks, there is a breeze and a glitter, but


no bump and no scream. The agent cannot perceive its
own location!
07/6
The Wumpus World (2)

ƒ Actions: Go forward, turn right by 90°, turn


left by 90°, pick up an object in the same
square (grab), shoot (there is only one
arrow), leave the cave (only works in
square [1,1]).
ƒ The agent dies if it falls down a pit or
meets a live wumpus.
ƒ Initial situation: The agent is in square
[1,1] facing east. Somewhere exists a
wumpus, a pile of gold and 3 pits.
ƒ Goal: Find the gold and leave the cave.

07/7
The Wumpus World (3):
A Sample Configuration

07/8
The Wumpus World (4)

[1,2] and [2,1] are safe:

07/9
The Wumpus World (5)

The wumpus is in [1,3]!

07/10
Declarative Languages
Before a system that is capable of learning, thinking,
planning, explaining, … can be built, one must find a way
to express knowledge.
We need a precise, declarative language.
• Declarative: System believes P iff it considers P to be
true (one cannot believe P without an idea of what it
means for the world to fulfill P).
• Precise: We must know,
– which symbols represent sentences,
– what it means for a sentence to be true, and
– when a sentence follows from other sentences.
One possibility: Propositional Logic
07/11
Basics of Propositional Logic (1)

Propositions: The building blocks of propositional logic are


indivisible, atomic statements (atomic propositions), e.g.,
ƒ “The block is red”
ƒ “The wumpus is in [1,3]”
and the logical connectives “and”, “or” and “not”, which we
can use to build formulae.

07/12
Basics of Propositional Logic (2)

We are interested in knowing the following:


ƒ When is a proposition true?
ƒ When does a proposition follow from a knowledge base
(KB)?
ƒ Symbolically:
ƒ Can we (syntactically) define the concept of derivation,
ƒ Symbolically:
such that it is equivalent to the concept of logical
implication conclusion?
Æ Meaning and implementation of ASK

07/13
Syntax of Propositional Logic

Countable alphabet of atomic propositions: P, Q, R, …


Logical formulae:

Operator precedence: . (use brackets when


necessary)
Atom: atomic formula
Literal: (possibly negated) atomic formula
Clause: disjunction of literals
07/14
Semantics: Intuition

Atomic propositions can be true (T) or false (F).


The truth of a formula follows from the truth of
its atomic propositions (truth assignment or
interpretation) and the connectives.
Example:

ƒ If P and Q are false and R is true, the


formula is false
ƒ If P and R are true, the formula is true
regardless of what Q is.
07/15
Semantics: Formally
A truth assignment of the atoms in ∑, or an interpretation
over ∑, is a function

Interpretation or of a formula :

I satisfies is true under I, when .

07/16
Example

07/17
Terminology

An interpretation I is called a model of ϕ if .


An interpretation is a model of a set of formulae if it fulfils all
formulae of the set.
A formula ϕ is
ƒ satisfiable if there exists I that satisfies ϕ,
ƒ unsatisfiable if ϕ is not satisfiable,
ƒ falsifiable if there exists I that doesn’t satisfy ϕ, and
ƒ valid (a tautology) if holds for all I.
Two formulae are
ƒ logically equivalent holds for
all I.
07/18
The Truth Table Method
How can we decide if a formula is satisfiable, valid, etc.?
ÆGenerate a truth table
Example: Is valid?

Since the formula is true for all possible combinations of


truth values (satisfied under all interpretations), ϕ is valid.
Satisfiability, falsifiability, unsatisfiability likewise.
07/19
Normal Forms
ƒ A formula is in conjunctive normal form (CNF) if it
consists of a conjunction of disjunctions of literals , i.e.,
if it has the following form:

ƒ A formula is in disjunctive normal form (DNF) if it


consists of a disjunction of conjunctions of literals:

ƒ For every formula, there exists at least one equivalent


formula in CNF and one in DNF.
ƒ A formula in DNF is satisfiable iff one disjunct is
satisfiable.
ƒ A formula in CNF is valid iff every conjunct is valid.
07/20
Producing CNF

The result is a conjunction of disjunctions of literals


An analogous process converts any formula to an
equivalent formula in DNF.
• During conversion, formulae can expand
exponentially.
• Note: Conversion to CNF formula can be done
polynomially if only satisfiability should be preserved
07/21
Logical Implication: Intuition
A set of formulae (a KB) usually provides an incomplete
description of the world, i.e., leaves the truth values of a
proposition open.
Example:
is definitive with respect to S, but leaves P, Q, R open
(although they cannot take on arbitrary values).
Models of the KB:

In all models of the KB, is true, i.e., follows logically


from KB. 07/22
Logical Implication: Formal

The formula ϕ follows logically from the KB if ϕ is true in all


models of the KB (symbolically ):

Note: The symbol is a meta-symbol


Some properties of logical implication relationships:
• Deduction theorem:
• Contraposition theorem:
• Contradiction theorem: is unsatisfiable iff
Question: Can we determine without considering all
interpretations (the truth table method)?

07/23
Proof of the Deduction Theorem

“⇒” Assumption: , i.e., every model of


is also a model of .
Let I be any model of KB. If I is also a model of
ϕ, then it follows that I is also a model of .
This means that I is also a model of , i.e.,
.
“⇐” Assumption: . Let I be any model
of KB that is also a model of , i.e., .
From the assumption, I is also a model of
and thereby also of , i.e., .
07/24
Proof of the Contraposition Theorem

(1)

(2)

Note:
(1) and (2) are applications of the deduction theorem.
07/25
Inference Rules, Calculi and Proofs
We can often derive new formulae from formulae in the
KB. These new formulae should follow logically from the
syntactical structure of the KB formulae.
Example: If the KB is
then is a logical consequence of KB
Æ Inference rules, e.g.,

Calculus: Set of inference rules (potentially including so-


called logical axioms)
Proof step: Application of an inference rule on a set of
formulae.
Proof: Sequence of proof steps where every newly-
derived formula is added, and in the last step, the goal
formula is produced. 07/26
Soundness and Completeness
In the case where in the calculus C there is a proof for a
formula ϕ, we write

(optionally without subscript C).


A calculus C is sound (or correct) if all formulae that are
derivable from a KB actually follow logically.

This normally follows from the soundness of the


inference rules and the logical axioms.
A calculus is complete if every formula that follows
logically from the KB is also derivable with C from the
KB:
07/27
Resolution: Idea

We want a way to derive new formulae that does not


depend on testing every interpretation.
Idea: We attempt to show that a set of formulae is
unsatisfiable.
Condition: All formulae must be in CNF.
But: In most cases, the formulae are close to CNF
(and there exists a fast satisfiability-preserving
transformation – Theoretical Computer Science
course).
Nevertheless: In the worst case, this derivation
process requires an exponential amount of time (this
is, however, probably unavoidable).
07/28
Resolution: Representation
Assumption: All formulae in the KB are in CNF.
Equivalently, we can assume that the KB is a set of clauses.
Due to commutativity, associativity, and idempotence of ∨,
clauses can also be understood as sets of literals. The empty
set of literals is denoted by .
Set of clauses: Δ
Set of literals: C, D
Literal:

Negation of a literal:

An interpretation I satisfies C iff there exists such that


- . I satisfies Δ if for all , i.e.,
, for all I.
07/29
The Resolution Rule

. . –

are called resolvents of the parent clauses


. and . – . and are the resolution
literals.
Example: resolves with to
.
Note: The resolvent is not equivalent to the parent
clauses, but it follows from them!
Notation:
07/30
Derivations
We say D can be derived from Δ using resolution,
i.e.,

if there exist C1, C2, C3, …, Cn = D such that

Lemma (soundness) If , then .


Proof idea: Since all follow logically from
, the lemma results through induction over the
length of the derivation.

07/31
Completeness?
Is resolution also complete, i.e., is

valid? It holds only for clauses. Consider:

But it can be shown that resolution is refutation-


complete: Δ is unsatisfiable implies
Theorem: Δ is unsatisfiable iff
With the help of the contradiction theorem, we can show
that if .

07/32
Resolution: Overview
ƒ Resolution is a refutation-complete proof process.
There are others (Davis-Putnam Procedure,
Tableaux Procedure, …).
ƒ In order to implement the process, a strategy
must be developed to determine which resolution
steps will be executed and when.
ƒ In the worst case, a resolution proof can take
exponential time. This, however, very probably
holds for all other proof procedures.
ƒ For CNF formulae in propositional logic, the Davis-
Putnam Procedure (backtracking over all truth
values) is probably (in practice) the fastest
complete process that can also be taken as a type
of resolution process. 07/33
Where is the Wumpus?
The Situation

07/34
Where is the Wumpus?
Knowledge of the Situation

∨ ∨ ∨

07/35
Clausal Representation of the
Wumpus World

07/36
Resolution Proof for the Wumpus World

07/37
From Knowledge to Action
We can now infer new facts, but how do we
translate knowledge into action?
Negative selection: Excludes any provably
dangerous actions.

Positive selection: Only suggests actions that are


provably safe.

Differences?
From the suggestions, we must still select an
action. 07/38
Problems with Propositional Logic
Although propositional logic suffices to represent the wumpus world,
it is rather involved.

1. Rules must be set up for each square.

We need a time index for each proposition to represent the validity


of the proposition over time Æ further expansion of the rules.

Æ More powerful logics exist, in which we can use object variables.


Æ First-Order Predicate Logic
07/39
Summary
ƒ Rational agents require knowledge of their world in
order to make rational decisions.
ƒ With the help of a declarative (knowledge-
representation) language, this knowledge is
represented and stored in a knowledge base.
ƒ We use propositional logic for this (for the time
being).
ƒ Formulae of propositional logic can be valid,
satisfiable or unsatisfiable.
ƒ The concept of logical implication is important.
ƒ Logical implication can be mechanized by using an
inference calculus Æ resolution.
ƒ Propositional logic quickly becomes impractical
when the world becomes too large (or infinite). 07/40

You might also like