170 likes | 310 Views
Erik Sandewall 2010. Introduction to Logic for Artificial Intelligence Lecture 1. Uses of Formal Logic in A.I. In preconditions of actions In postconditions of actions Contents of knowledgebases/beliefbases Contents of messages Queries Embedded expressions in action scripts
E N D
Erik Sandewall 2010 Introduction to Logic for Artificial IntelligenceLecture 1
Uses of Formal Logic in A.I. • In preconditions of actions • In postconditions of actions • Contents of knowledgebases/beliefbases • Contents of messages • Queries • Embedded expressions in action scripts • Methods for planning and plan revision • Obtaining conclusions from knowledgebase • Many more
Uses of Formal Logic in A.I. • To summarize: • Expressions for evaluation, and use of their value • Expressions for matching, obtaining variable values as the result • Drawing conclusions from logic expressions • In order to master these techniques, it is necessary to be precise about the character of logic formulas and the operations on them. This requires: • Basic concepts • Equivalence rules • Inference rules
Propositional logicExpressions and Evaluation • (not p) T -> F, F -> T • (and p q) TT -> T, TF -> F, FT -> F, FF -> F • (or p q) TT -> T, TF -> F, FT -> F, FF -> F • (imp p q) TT -> T, TF -> F, FT -> T, FF -> T • (eqv p q) TT -> T, TF -> F, FT -> F, FF -> T
Propositional logicConventional Notations • (not p) ¬p, ~p -p • (and p q) p q, p & q p * q • (or p q) p q p + q • (imp p q) p → q, p q • (eqv p q) p ↔ q, p q
Equivalence Relation between Formulas • If p and q are two formulas, then we write • p == q • if and only if the value of p equals the value of q for each possible value of their elements. E.g. • (and p q) == (and p q) • (and p (or q r)) == (or (and p q)(and p r)) • Notice that each of these lines contains a relation between two logic formulas, not a single logic formula • It is important to write it as == and not as =, since = will be used for another purpose and within formulas
Equivalence rules for not, and and or • (not (not p)) == p • (and p p) == p • (and p q) == (and q p) • (and p (and q r)) == (and (and p q) r) • similar to these for or instead of and • (not (and p q)) == (or (not p)(not q)) • (not (or p q)) == (and (not p)(not q)) • (and p (or q r)) == (or (and p q)(and p r)) • (or p (and q r)) == (and (or p q)(or p r)) • (imp p q) == (or (not p) q) • (eqv p q) == (or (and p q)(and (not p)(not q)))
Some terms • Vocabulary for a logic formula: set of symbols containing all those that occur in the formula (and maybe some more) • Interpretation for a logic formula: a mapping from a vocabulary for it, to truth-values T or F • Model for a logic formula: an interpretation where the value of the formula is T • Joint vocabulary for two (or more) logic formulas: something that is a vocabulary for each one of them (but there is of course a smallest joint vocabulary) • p == q holds if they have the same value for all interpretations in all their joint vocabularies
Some terms • Vocabulary for a logic formula: set of symbols containing all those that occur in the formula (and maybe some more) • Interpretation for a logic formula: a mapping from a vocabulary for it, to truth-values T or F • Model for a logic formula: an interpretation where the value of the formula is T • Joint vocabulary for two (or more) logic formulas: something that is a vocabulary for each one of them (but there is of course a smallest joint vocabulary) • p == q holds if they have the same value for all interpretations in all their joint vocabularies • p |= q holds if, considering all interpretations in their joint vocabularies, if p is true in one then q is also true there. This is pronounced p entails q (Swedish: "innebär")
Some entailment rules • (and p q) |= p • General rule: if p == q then p |= q • General rule: if p |= q and q |= p then p == q • (not p) |= (imp p q) • (and p (not p)) |= q • Also, write p, q |= r if r is true in all interpretations where both p and q are true. (Allow two or more premises). Obtain: • p, (imp p q) |= q /modus ponens/ • p, q |= (and p q)
A very simple proof • (imp a b) • (imp b c) • (imp (and c d) e) • a • d • --------------------------- • b • c • (and c d) • e
Inference rule • For organizing proofs, it is customary to identify a limited number of entailment rules and to require that only these shall be used each time a line is added to the proof • The selected entailment rules are called the inference rules of this particular inference system • Uses of the inference rules are expressed using |- instead of |= • A proof with C1, C2, ... Cn as premises and D as conclusion is summarized as C1, C2, ... Cn |- D
Resolution Method for Theorem-ProvingTransformations on Given Premises • Rewrite all uses of imp and eqv using and, or, not • Move all uses of not inwards, (not (and a b)) == (or (not a)(not b)) • Replace (not (not p)) by p • Move uses of or inside and, (or p (and q r)) == (and (or p q)(or p r)) • Rewrite (or p (or q r)) as (or p q r), with arbitrary number of arguments, and similarly for and • The result is an expression on conjunctive normal form • Consider the arguments of and as separate formulas, obtaining a set of or-expressions with literals as their arguments • Consider these or-expressions as having a set of literals as its argument, not a sequence of them. Results are called clauses. • For convenience we shall write (not p) as -p
Resolution Method for Theorem-ProvingInference Rule • Only one single inference rule is sufficient: • {p} A, {-p} B |- A B • assuming p is not a member of A and -p is not a member of B • Some examples: • {a, b, c}, {-a, d, e} |- {b, c, d, e} • {a, b, c}, {-a, b, e} |- {b, c, e} • {a, b, c}, {-a, -b, d} |- {b, c, -b, d} • This conclusion is correct, but useless for further proof! • {a}, {b}, {c}, {-a, -b, -c, d} |- {d}
Resolution Method for Theorem-ProvingMetatheorems • If there exists a proof with C1, C2, ... Cn as premises and D as the consequence, then we write C1, C2, ... Cn |- D • Metatheorems: • Soundness: if C1, C2, ... Cn |- D then C1, C2, ... Cn |= D • Completeness: if C1, C2, ... Cn |= D then C1, C2, ... Cn |- D • Both of these hold - but completeness is more difficult to prove • Soundness is automatic provided that each inference rule is in fact an entailment rule
Proof by Contradiction • Given a set of propositions C1, C2, ... Cn and desired conclusion D • We want to show that C1, C2, ... Cn |= D • Transform the problem by considering C1, C2, ... Cn, (not D) and try to prove a contradiction e.g. (and p (not p)) for some p • Write contradiction as , or as {} in the case of resolution • If this can be proved then we have a proof for what we want to show. • In the case of resolution proofs: • Add (not D) to the given propositions before the conversion to clause form • Technically, we have a meta-theorem: • if C1, C2, ... Cn, (not D) |= then C1, C2, ... Cn |= D