CS 401: Artificial Intelligence: Propositional Logic Semantics and Inference
CS 401: Artificial Intelligence: Propositional Logic Semantics and Inference
Propositional Logic
Semantics and Inference
Semantics
P: Pakistan is a peaceful country
Q: I like quality fish
Validity of form, not the actual content
Logic
Syntax: What sentences are allowed?
Semantics:
What are the possible worlds?
Which sentences are true in which worlds? (i.e., definition of truth)
1
2 3
Syntaxland Semanticsland
Examples
Propositional logic
Syntax: P (Q R); X1 (Raining Sunny)
Possible world: {P=true,Q=true,R=false,S=true} or 1101
Semantics: is true in a world iff is true and is true (etc.)
First-order logic
Syntax: x y P(x,y) Q(Joe,f(x)) f(x)=f(y)
Possible world: Objects o1, o2, o3; P holds for <o1,o2>; Q holds for <o3>;
f(o1)=o1; Joe=o3; etc.
Semantics: () is true in a world if =oj and holds for oj; etc.
Inference: entailment
Entailment: |= (“ entails ” or “ follows from ”) iff in
every world where is true, is also true
I.e., the -worlds are a subset of the -worlds [models() models()]
In the example, 2 |= 1
(Say 2 is Q R S W
1 is Q )
1
2
Inference: proofs
A proof is a demonstration of entailment between and
Method 1: model-checking
For every possible world, if is true make sure that is true too
OK for propositional logic (finitely many worlds); not easy for first-order logic
Method 2: theorem-proving
Search for a sequence of proof steps (applications of inference rules) leading
from to
E.g., from P (P Q), infer Q by Modus Ponens
Sound algorithm: everything it claims to prove is in fact entailed
Complete algorithm: every that is entailed can be proved
Quiz
What’s the connection between complete inference algorithms and
complete search algorithms?
Answer 1: they both have the words “complete…algorithm”
Answer 2: they both solve any solvable problem
Answer 3: Formulate inference as a search problem
Initial state: KB contains
Actions: apply any inference rule that matches KB, add conclusion
Goal test: KB contains
Hence any complete search algorithm yields a complete inference algorithm
Propositional logic syntax: The gruesome details
Given: a set of proposition symbols {X1,X2,…, Xn}
(we often add True and False for convenience)
Xi is a sentence
If is a sentence then is a sentence
If and are sentences then is a sentence
If and are sentences then is a sentence
If and are sentences then is a sentence
If and are sentences then is a sentence
And p.s. there are no other sentences!
Propositional logic semantics: The unvarnished truth
function PL-TRUE?(,model) returns true or false
if is a symbol then return Lookup(, model)
if Op() = then return not(PL-TRUE?(Arg1(),model))
if Op() = then return and(PL-TRUE?(Arg1(),model),
PL-TRUE?(Arg2(),model))
etc.
Pn=true Pn=false
KB?
α?
11111…1
0000…0
Satisfiability and entailment
A sentence is satisfiable if it is true in at least one world (cf
CSPs!)
Suppose we have a hyper-efficient SAT solver; how can we use it
to test entailment?
Suppose |=
Then is true in all worlds
Hence ( ) is false in all worlds
Hence is false in all worlds, i.e., unsatisfiable
So, add the negated conclusion to what you know, test for
(un)satisfiability; also known as reductio ad absurdum
Conjunctive normal form (CNF)
Replace biconditional by two implications
Every sentence can be expressed as a conjunction of clauses
Each clause is a disjunction of literals Replace by v