CS440/ECE448: Intro to Artificial Intelligence Lecture 7: Propositional logic Prof. Julia Hockenmaier juliahmr@illinois.edu http://cs.illinois.edu/fa11/cs440 Thursdayʼs key concepts Combining CSP search and inference: Ordering variables (minimum remaining value, degree heuristics) Ordering values (forward checking, MAC) Global constraints: Constraint hypergraph; auxiliary variables Continuous domains: bounds consistency CS440/ECE448: Intro AI 2 Path consistency and arc consistency X is arc consistent with respect to Y if for every value of X there exists some value of Y such that C(X,Y) is satisfied. X and Y are path consistent with respect to Z if for every pair of values of X and Y that satisfy C(X, Y), there exists some value of Z such that C(X,Z) and C(Y,Z) is satisfied. CS440/ECE448: Intro AI 3 Global (n-ary) constraints: Constraint Hypergraph F T U W R O C 1000 C 100 C 10 TWO + TWO = FOUR CS440/ECE448: Intro AI 4
Propositional logic Propositional logic Syntax: What is the language of well-formed formulas of propositional logic? Semantics: What is the interpretation of a well-formed formula in propositional logic? Inference rules and algorithms: How can we reason with propositional logic? Syntax: the building blocks Variables: Constants: p q r (true), (false) Unary connectives: (negation) Binary connectives: (conjunction) (disjunction) (implication) Syntax: well-formed formulas WFF Atomic Complex Atomic% % Constant Variable WFF Atomic (Complex) Complex % WFF WFF WFF WFF WFF WFF WFF
Semantics: truth values The interpretation v of a well-formed formula under a model v is a truth value: v {true, false}. A model (=valuation) v is a complete* assignment of truth values to variables: v(p) = true v(q) = false, *each variable is either true or false With n variables, there are 2 n different models Models of (ʻM() ): set of models where is true Interpretation v of Interpretation of constants: v = true, v = false Interpretation of variables defined by v p v = v(p) Interpretation of connectives given by truth tables if.then: if.then: p v p v p v q v p q v p q v p q v true false true true true true true false true true false false true false false true false true true false false false false true Validity and satisfiability is valid in a model m ( m ) iff m M() = the model m satisfies ( is true in m) is valid ( ) iff m: m M() ( is true in all possible models. is a tautology.) Inference in propositional logic is satisfiable iff m: m M() ( is true in at least one model, M() # )
Entailment Definition: entails $ ( $ ) iff M() M($) Entailment is monotonic: If $, then % $ for any % Proof: M( %) M() M($) We also write,% $ or {,%} $ for % $ Logical equivalence is equivalent to $ ( $ ) iff M() = M($) $ $ Commutativity $ $ ( $) % ($ %) Associativity ( $) % ($ %) ($ %) ( $) ( %) Distributivity ($ %) ( $) ( %) Entailment and implication entails $ ( $ ) iff $ is valid ( $) Proof: If v M(): v = true by definition. % %So $ v = true only if $ v = true (v M($)) Thus, v M() implies v M($). If v M(): v = false by definition. % %So $ v = true regardless of $ v Thus, when v M(), v M($) or v M($). More logical equivalences ( $) $ DeMorgan ( $) $ $ $ Implication elimination $ $ Contraposition
Biconditional (equivalence) We can also define a binary connective : $ ( $) ($ ) ( $) ( $ ) (( $) $) ( $) ) (( $) ($ $)) (( ) ($ )) % % % ( $) ($ ) Literals and clauses Literal: p, p, q, q, an atomic formula, or a negated atomic formula Clause: p, p, p q, q p, a literal (= unit clause), or a disjunction of literals CS440/ECE448: Intro AI 17 Normal Forms Every formula in propositional logic has two equivalent normal forms: Conjunctive Normal Form (CNF) a conjunction of clauses (p 11 p 1n ) (p 21 p 2m ) Disjunctive Normal Form (DNF) a disjunction of conjoined literals (q 11 q 1n ) (q 21 q 2m ) Inference in propositional logic We often have prior domain knowledge. Given a knowledge base KB = {& 1,, & n } (a set of formulas that are true), how do we know is valid given KB? Validity: KB (shorthand for & 1 & n ) Satisfiability: m: m M(KB) m M() ( M(KB) shorthand for M(& 1 & n )
Inference in propositional logic How do we know whether is valid or satisfiable given KB? Model checking: (semantic inference) Enumerate all models for KB and. Theorem proving: (syntactic inference) Use inference rules to derive from KB. Modus ponens $ '''''''''''''''' $ And-elimination $ '''''''''' $ Inference rules Inference rules: equivalences $ $ Commutativity $ $ As inference rules: $ $ $ $ '''' '''' '''' ''''' $ $ $ $ Theorem proving as search Proving from KB: States: sets of formulas that are true. Initial state: KB Goal state: any state that contains Actions: a set of inference rules
Inference procedures A procedure P that derives from KB KB P is sound if it only derives valid sentences: if KB P, then KB (soundness) is complete if it derives any valid sentence: if KB, then KB P (completeness) The resolution rule Unit resolution: p 1 p i-1 p i p i+1 p n p i '''''''''''''''''''''''''''' p 1 p i-1 p i+1 p n Full resolution: p 1 p i p n q 1 p i q m '''''''''''''''''''''''''''''''' p 1 p n q 1 q m Final step: factoring (remove any duplicate literals from the result A A A) Proof by contradiction How do we prove that $? entails $ ( $ ) iff $ not satisfiable. Proof: $ not satisfiable iff ( $) Assume ( $). $) % % % % % % $. Thus, ( $) $. A resolution algorithm Goal: prove $ by showing that $ is not satisfiable (false) Observation: Resolution derives a contradiction (false) if it derives the empty clause: p i p i ''''''' CS440/ECE448: Intro AI 28
function PLresolution(, $) input: formula, // knowledge base formula $ // query clauses := CNF( $) new := {} while true: for each c1, c2 in clauses do resolvents := resolve(c1, c2) if in resolvents then return true; new := new resolvents if new clauses then return false; clauses := clauses new CS440/ECE448: Intro AI 29 Completeness of Resolution Resolution closure RC(S): The set of all clauses that can be derived by resolution from a set of clauses S. If S is finite, RC(S) is finite. Ground resolution theorem: If RC(S) contains, S is not satisfiable. If RC(S) does not contain, S is satisfiable. CS440/ECE448: Intro AI 30 If RC(S) doesnʼt contain Todayʼs key concepts S is satisfiable, because we can build a model for its variables p 1.p n : For i from 1.n: if a clause in RC(S) contains p i and all its other literals are false, then assign false to p i otherwise assign true to p i CS440/ECE448: Intro AI 31 Syntax of propositional logic: propositional variables, connectives, well-formed formulas Semantics of propositional logic: interpretations, models, truth tables Inference with propositional logic: model-checking, resolution CS440/ECE448: Intro AI 32
Your tasks Reading: 7.3-7.5.2 Compass quiz: due Thursday at 2am. CS440/ECE448: Intro AI 33