Title: 159'302 LECTURE
1159.302 LECTURE
1
Propositional Logic Syntax
Source MIT OpenCourseWare
2Propositional Logic
What is a logic?
A formal language
3Propositional Logic
What is a logic?
A formal language
- Syntax what expressions are legal
4Propositional Logic
What is a logic?
A formal language
- Syntax what expressions are legal
- Semantics what legal expressions mean
5Propositional Logic
What is a logic?
A formal language
- Syntax what expressions are legal
- Semantics what legal expressions mean
- Proof System a way of manipulating syntactic
expressions to get other syntactic expressions
(which will tell us something new)
6Propositional Logic
What is a logic?
A formal language
- Syntax what expressions are legal
- Semantics what legal expressions mean
- Proof System a way of manipulating syntactic
expressions to get other syntactic expressions
(which will tell us something new)
Why proofs?
- Two kinds of inferences an agent might want to
make
7Propositional Logic
What is a logic?
A formal language
- Syntax what expressions are legal
- Semantics what legal expressions mean
- Proof System a way of manipulating syntactic
expressions to get other sytactic expressions
(which will tell us something new)
Why proofs?
- Two kinds of inferences an agent might want to
make
- Multiple percepts gt conclusions about the world
8Propositional Logic
What is a logic?
A formal language
- Syntax what expressions are legal
- Semantics what legal expressions mean
- Proof System a way of manipulating syntactic
expressions to get other sytactic expressions
(which will tell us something new)
Why proofs?
- Two kinds of inferences an agent might want to
make
- Multiple percepts gt conclusions about the world
- Current state operator gt properties of next
state
9Propositional Logic
Syntax what youre allowed to write
- for(thing tfizz t fuzz t)
10Propositional Logic
Syntax what youre allowed to write
- for(thing tfizz t fuzz t)
- Colorless green ideas sleep furiously.
11Propositional Logic
Syntax what youre allowed to write
- for(thing tfizz t fuzz t)
- Colorless green ideas sleep furiously.
Sentences (wwfs well-formed formulas)
12Propositional Logic
Syntax what youre allowed to write
- for(thing tfizz t fuzz t)
- Colorless green ideas sleep furiously.
Sentences (wwfs well-formed formulas)
- true and false are sentences
13Propositional Logic
Syntax what youre allowed to write
- for(thing tfizz t fuzz t)
- Colorless green ideas sleep furiously.
Sentences (wwfs well-formed formulas)
- true and false are sentences
- Propositional variables are sentences P, Q, R, Z
14Propositional Logic
Syntax what youre allowed to write
- for(thing tfizz t fuzz t)
- Colorless green ideas sleep furiously.
Sentences (wwfs well-formed formulas)
- true and false are sentences
- Propositional variables are sentences P, Q, R, Z
- If f and ? are sentences, then so are
15Propositional Logic
Syntax what youre allowed to write
- for(thing tfizz t fuzz t)
- Colorless green ideas sleep furiously.
Sentences (wwfs well-formed formulas)
- true and false are sentences
- Propositional variables are sentences P, Q, R, Z
- If f and ? are sentences, then so are
- Nothing else is a sentence
16Precedence
17159.302 LECTURE
2
Propositional Logic Semantics
Source MIT OpenCourseWare
18Propositional Logic
Semantics
- Meaning of a sentence is truth value t, f
19Propositional Logic
Semantics
- Meaning of a sentence is truth value t, f
- Interpretation is an assignment of truth values
to the propositional variables
holds( , i) Sentence is t in
interpretation i
20Propositional Logic
Semantics
- Meaning of a sentence is truth value t, f
- Interpretation is an assignment of truth values
to the propositional variables
holds( , i) Sentece is t in
interpretation i
fails( , i) Sentence is f in
interpretation i
21Propositional Logic
Semantic Rules
holds(true, i) for all i
22Propositional Logic
Semantic Rules
holds(true, i) for all i
fails(false, i) for all i
23Propositional Logic
Semantic Rules
holds(true, i) for all i
fails(false, i) for all i
holds( , i) if and only if fails(
, i) (negation)
24Propositional Logic
Semantic Rules
holds(true, i) for all i
fails(false, i) for all i
holds( , i) if and only if fails(
, i) (negation)
holds( , i) iff holds( ,i) and
holds( , i) (conjunction)
25Propositional Logic
Semantic Rules
holds(true, i) for all i
fails(false, i) for all i
holds( , i) if and only if fails(
, i) (negation)
holds( , i) iff holds( ,i) and
holds( , i) (conjunction)
holds( , i) iff holds( ,i) or holds(
, i) (disjunction)
26Propositional Logic
Semantic Rules
holds(true, i) for all i
fails(false, i) for all i
holds( , i) if and only if fails(
, i) (negation)
holds( , i) iff holds( ,i) and
holds( , i) (conjunction)
holds( , i) iff holds( ,i) or holds(
, i) (disjunction)
holds( P, i) iff i(P) t
fails( P, i) iff i(P) f
27Propositional Logic
Some important shorthand
(antecedent consequent)
28Propositional Logic
Some important shorthand
(antecedent consequent)
29Propositional Logic
Some important shorthand
(antecedent consequent)
30Propositional Logic
Some important shorthand
(antecedent consequent)
Note that implication is not causality, if P is
f then is t
31Propositional Logic
Terminology
A sentence is valid iff its truth value is t in
all interpretations
A sentence is satisfiable iff its truth value is
t in at least one interpretation
A sentence is unsatisfiable iff its truth value
is f in all interpretations
All are finitely decidable.
32Examples
contrapositive
33Examples
contrapositive
34Examples
contrapositive
35Examples
contrapositive
36Examples
contrapositive
37Satisfiability
- Related to constraint satisfaction
- Given a sentence S, try to find an
interpretation i such that holds(S,i)
- Analogous to finding an assignment of values to
variables such that the constraints hold
38Satisfiability
- Related to constraint satisfaction
- Given a sentence S, try to find an
interpretation i such that holds(S,i)
- Analogous to finding an assignment of values to
variables such that the constraints hold
- Brute force method enumerate all
interpretations and check
39Satisfiability
- Related to constraint satisfaction
- Given a sentence S, try to find an
interpretation i such that holds(S,i)
- Analogous to finding an assignment of values to
variables such that the constraints hold
- Brute force method enumerate all
interpretations and check
Heuristic search Constraint propagation Stochastic
search
40Satisfiability Problems
- Scheduling nurses to work in a hospital
- propositional variables represent for example,
that Pat is working on Tuesday at 2pm
- constraints on the schedule are represented
using logical expressions over the variables
- propositional variables represent state of the
program
- use logic to describe how the program works and
to assert there is a bug
- if the sentence is satisfiable, youve found the
bug!
41159.302 LECTURE
3
Propositional Logic Proof
Source MIT OpenCourseWare
42A Good lecture?
- If today is sunny, then Tomas will be happy
- If Tomas is happy, the lecture will be good
Should we conclude that the lecture will be good?
43Checking Interpretations
Good lecture!
44Adding a variable
45Entailment
- A knowledge base (KB) entails a sentence S iff
every interpretation that makes KB true also
makes S true
46Computing Entailment
- enumerate all interpretations
- select those in which all elements of KB are true
- check to see if S is true in all of those
interpretations
47Computing Entailment
- enumerate all interpretations
- select those in which all elements of KB are true
- check to see if S is true in all of those
interpretations
- Way too many interpretations, in general!!
48Entailment and Proof
- A proof is a way to test whether a KB entails a
sentence, without enumerating all possible
interpretations
49Proof
- A proof is a sequence of sentences
- First ones are premises (KB)
- Then, you can write down on the next line the
result of applying an inference rule to previous
lines
- When S is on a line, you have proved S from KB
- If inference rules are sound, then any S you can
prove from KB is entailed by KB
- If inference rules are complete, then any S that
is entailed KB can be proven from KB
50Natural Deduction
Modus ponens
51Natural Deduction
Modus ponens
Modus tolens
52Natural Deduction
Modus ponens
Modus tolens
And-Introduction
53Natural Deduction
Modus ponens
Modus tolens
And-Introduction
And-Elimination
54Natural Deduction Example
Prove S
55Natural Deduction Example
Prove S
56Natural Deduction Example
Prove S
57Natural Deduction Example
Prove S
58Natural Deduction Example
Prove S
59Natural Deduction Example
Prove S
60Proof Systems
- There are many natural deduction systems they
are typically proof checkers, sound but not
complete
61Proof Systems
- There are many natural deduction systems they
are typically proof checkers, sound but not
complete
- Natural deduction uses lots of inference rules
which introduces a large branching factor in the
search for a proof.
62Proof Systems
- There are many natural deduction systems they
are typically proof checkers, sound but not
complete
- Natural deduction uses lots of inference rules
which introduces a large branching factor in the
search for a proof.
- In general, you need to do proof by cases
which introduces even more branching.
Prove R
63Propositional Resolution
Resolution rule
- Single inference rule is a sound and complete
proof system
- Requires all sentences to be converted to
conjunctive normal form
64159.302 LECTURE
4
Propositional Logic Conjunctive Normal Form (CNF)
Source MIT OpenCourseWare
65Conjunctive Normal Form
CNF Formulas
66Conjunctive Normal Form
CNF Formulas
67Conjunctive Normal Form
CNF Formulas
, which is a disjunction of literals
68Conjunctive Normal Form
CNF Formulas
, which is a disjunction of literals
69Conjunctive Normal Form
CNF Formulas
, which is a disjunction of literals
, each of which is a variable or the negation of
a variable.
70Conjunctive Normal Form
CNF Formulas
, which is a disjunction of literals
, each of which is a variable or the negation of
a variable.
- Each clause is a requirement that must be
satisfied and can be satisfied in multiple ways
71Conjunctive Normal Form
CNF Formulas
, which is a disjunction of literals
, each of which is a variable or the negation of
a variable.
- Each clause is a requirement that must be
satisfied and can be satisfied in multiple ways
- Every sentence in propositional logic can be
written in CNF
72Converting to CNF
- Eliminate arrows using definitions
73Converting to CNF
- Eliminate arrows using definitions
- Drive in negations using De Morgans Laws
74Converting to CNF
- Eliminate arrows using definitions
- Drive in negations using De Morgans Laws
75Converting to CNF
- Eliminate arrows using definitions
- Drive in negations using De Morgans Laws
- Every sentence can be converted to CNF, but it
may grow exponentially in size
76CNF Conversion Example
77CNF Conversion Example
- Eliminate arrows using definitions
78CNF Conversion Example
- Eliminate arrows using definitions
- Drive in negations using De Morgans Laws
79CNF Conversion Example
- Eliminate arrows using definitions
- Drive in negations using De Morgans Laws
80159.302 LECTURE
5
Propositional Resolution
Source MIT OpenCourseWare
81Propositional Resolution
Resolution rule
Resolution refutation
- Convert all sentences to CNF
- Negate the desired conclusion (converted to CNF)
- Apply resolution rule until either
- Derive false (a contradiction)
Resolution refutation is sound and complete
- If we derive a contradiction, then the
conclusion follows from the axioms
- If we cant apply anymore, then the conclusion
cannot be proven from the axioms
82Propositional Resolution
Prove R
83Propositional Resolution
Prove R
84Propositional Resolution
Prove R
unnecessary
85The Power of False
Prove Z
- Any conclusion follows from a contradiction
and so strict logic systems are very brittle.
86Example Problem
Convert to CNF
Prove R
87Example Problem
Prove R
88Example Problem
Prove R
89Proof Strategies
Unit Preference prefer a resolution step
involving a unit clause (clause with one literal).
- Produces a shorter clause which is good since
we are trying to produce a zero-length clause,
that is, a contradiction.
Set of support choose a resolution involving the
negated goal or any clause derived from the
negated goal.
- Were trying to produce a contradiction that
follows from the negated goal, so these are
relevant clauses
- If a contradiction exists, one can find one
using the set-of-support strategy.