320 likes | 455 Views
A brief review of Logic. CS4320/CS5314 Artificial Intelligence References: Logic for applications, A. Nerode, A. Shore, Springer-Verlag ed. Artificial Intelligence, a modern approach, Russel, Norvig, Prentice Hall ed. Applications of Logic. Programming paradigms Verifications of programs
E N D
A brief review of Logic CS4320/CS5314 Artificial Intelligence References: Logic for applications, A. Nerode, A. Shore, Springer-Verlag ed. Artificial Intelligence, a modern approach, Russel, Norvig, Prentice Hall ed.
Applications of Logic • Programming paradigms • Verifications of programs • Interactive, concurrent, distributed, fault tolerant and real time computing • Knowledge-based systems • Deductive databases • Etc…
Knowledge-based systems • Core of a KB system Knowledge base (facts about our world) • Formal language to express knowledge and a way to reason about facts a logic. • Formal language knowledge representation language • Deriving new facts inference mechanism
Propositional logic • Definition: propositions are statements that assume either a true value of false value (boolean expressions) • Definition: the way statements are combined forms the syntax of logic • Definition: the way we interpret statements forms the semantics of logic
The language • Connectives: ,,,,, • Parentheses: (,) • Propositional letters: A,A1,A2,…B,B1… Definition: the language is defined inductively by • Propositional letters are propositions • If x,y are propositions so are (xy),(xy), (xy),(xy), (x) • Nothing else is a proposition Exercise: show that the above language is a context-free language
DNF and CNF • Definition: a propositional formula is in disjunctive normal form if it is of the form: x1…xn where xi is a proposition containing only the connectors and . • Definition: a conjunctive normal form is defined similarly. • Property: any proposition can be written in CNF or DNF Exercise: find DNF for (AB)C and (AB)(C)
Truth assignments and valuations • Semantics for propositional logic: assigning truth values to propositions • Definition: a truth assignment A is a function which assigns to each propositional letter A a unique truth value A(A) {T,F} • Definition: a truth valuation V is a function which assign to each proposition x a unique truth value V(x) in accordance with truth tables
Tautologies and Validitity • Definition: a proposition x is said to be valid if for any valuation V, V(x)=T. The proposition is called a tautology. • Definition: two propositions x,y such that for any valuation V, V(x)=V(y) are called logically equivalent (written xy) Exercise: show that ((pq)p)q and (q(pq))p are tautologies
Consequences • Definition: let be a set of propositions. Then x is a consequence of if for any valuation V, we have V(y)=T for all y in implies V(x)=T • We will write ⊧x. • It reads entails x. • Example:{p,pq} ⊧ ? Exercise: when do we have ⊧x if is an empty set? (in this case we will write ⊧x ) This notion gives a semantic notion of consequence Remark: generation of new facts in a KB
Models • Definition: a valuation V is a model of if V(x)=T for every x in . M() denotes the set of all models of .
Formal reasoning 1 • Inference rule premises, hypotheses ⊧ consequence In propositional logic: • Modus ponens AB,A ⊧ B or A,AB ⊧ B • Modus tollens AB, B ⊧ A • Conjunction A,B ⊧ AB
Formal Reasoning 2 • Simplification AB ⊧ A • Addition (disjunction) A ⊧ AB • Disjunctive syllogism AB, A ⊧ B • Hypothetical syllogism AB,BC ⊧ AC
An other set of inference rules for PL • Modus ponens • Simplification (and-elimination) • Addition (or-introduction) • Double negation elimination • Unit resolution AB, B ⊧ A • Resolution AB, BC ⊧ AC
Formal reasoning system • Definition: a formal reasoning system (or a formal theory) is a 1. set of wffs 2. set of axioms 3. set of inference rules Example: euclidean geometry
Proof • How do we describe reasoning? Proof? Theorem? • Definition: a proof is a finite sequence of wffs where each wff is either an axiom or can be derived from previous wffs in the sequence using inference rules Example:w1,…,wn is a proof. What are w1 and wn?
Consistency vs. Completeness • Definition: a formal theory is consistent if you cannot prove both w and w. • We hope our formal theories to be consistent. • Definition: a formal theory is complete if you can always prove either w or w • We hope our formal theories to be also complete. • However, it is not always possible.
Conditional proof • Assume you have A1A2…AnB • Each Ai is written vertically with a P (premise) • Use the rules seen previously to derive B Exercise: show (AB)(AC)ABC
Indirect proof • Assume we want to prove AB • We do not know where to start, so we use AB BA • Still can’t do it? Use AB BAfalse (proof by contradiction) Example: (AB)(AC)(BD)DC. Write each premise with P, then the negated conclusion with P for IP and show false
Exercises Show that (AB)(AB)B using equivalences only Show that (ABC)A(CB) is not a tautology Give a formal proof using CP of (ABC)AC
Predicate calculus • Wffs as defined so far are too restrictive • A wff represents a sentence as a whole and “hides” some information • Syllogisms with quantifiers cannot be conveniently represented with propositional logic (at least we cannot verify if inference is correct) • Predicate calculus aims at solving this problem
Syntax of predicate calculus • Variables: x,y,z,… • Constants: a,b,c,… • Functions: f,g,h,… • Predicates: p,q,r,… • Connective symbols: ,,,, • Quantifier: • Punctuation: (,)
Terms and Atoms • Definition: a term is either a variable, a constant or a function applied to arguments that are terms ex: a,x, f(x), g(x,h(b)) are terms • Definition: an atomic formula (or atom) is a predicate applied to arguments that are terms ex: p(x), q(f(x),g(y)) • In each case, respect the arity of the function or the predicate symbol.
Well formed formulas • Definition: wffs are defined inductively as: 1. any atom is a wff 2. if V and W are wff and x is a variable, then (V), V, VW, VW, VW, xW, xW are also wffs. • Precedence: first, followed with , then
Scope of a quantifier • Definition: the scope of a quantifier is the wff in which variables are influenced by the quantifier. It depends on the (,) • Definition: a variable is bound if it lies in the scope of a quantifier or if is the quantifier variable itself. • Definition: a variable not bound is called free Example: x p(x,y)q(x). What is the scope of the quantifier? What variables are bound? What variables are free?
Interpretation - Example • x y s(x,y) • It is true for D=N the set of natural numbers • s(x,y) means y is successor of x What is the interpretation of this formula?
Model in 1st order logic • Definition: an interpretation for a wff W is a model of W is W is true w.r.t the interpretation
Validity and Satisfiability • Definition: a wff is valid if it is true for any interpretation. Otherwise it is invalid • Definition: a wff is unsatisfiable if it is false for any interpretation. Otherwise it is satisfiable • Example: x y s(x,y) is satisfiable but not valid. Why? • (yx p(x,y)xy p(x,y)) is unsatisfiable
Equivalence in 1st order logic • Definition: two wffs W,W’ are equivalent if they have the same truth value with respect to every interpretation
Useful equivalences • W(x) xW(x) • W(x) xW(x) • x(W(x)W’(x)) xW(x)xW’(x) • x(W(x)W’(x)) xW(x)xW’(x) • (W(x)W’(x)) xW(x)xW’(x) • xy W(x,y) yx W(x,y) • xy W(x,y) yx W(x,y)
Restricted equivalences • Assume V does not have variable x • x(VW(x)) VxW(x) • x(VW(x)) VxW(x) • x(VW(x)) VxW(x) • x(VW(x)) VxW(x) • x(VW(x)) VxW(x) • x(VW(x)) VxW(x) • x(W(x)V) xW(x)V • x(W(x)V) xW(x)V
Prenex Normal Forms • Definition: a wff is in prenex conjunctive normal form (resp. prenex disjunctive normal form) if it is written Q1x1…Qnxn (W1...Wn) where Wi is a conjunction of literals resp Q1x1…Qnxn (W1...Wn) where Wi is a disjunction of literals • Property: any wff has an equivalent prenex normal form
Algorithm • Rename the variables in W so that no quantifiers use the same variable name and bound var. are distinct from free var. • Move quantifiers to the left using the equivalence seen in previous slides