180 likes | 390 Vues
Erik Sandewall 2010. Introduction to Logic for Artificial Intelligence Lecture 2. Relational Logic, Datalog (a Restricted Predicate Logic). Use the operators not, and, or, etc like for propositional logic, but:
E N D
Erik Sandewall 2010 Introduction to Logic for Artificial IntelligenceLecture 2
Relational Logic, Datalog(a Restricted Predicate Logic) • Use the operators not, and, or, etc like for propositional logic, but: • The elements of the logic expressions can consist of a predicate with its arguments, and are not restricted to proposition symbols • Proposition symbols are considered as predicates with zero arguments • The arguments of predicates may be constant symbols or variables • Examples (in CKL): constant symbol may be London, apple-3, variable may be written .a3 or a3
Relational Logic: Quantifiers • Use the operators not, and, or, etc like for propositional logic, but also: • [all .v P] where .v is a variable and P is a formula • [exists .v P] where .v is a variable and P is a formula • Evaluation rule: consider for example evaluation in an episode, i.e. an instance of a microworld that has a specific set of entities associated with it. • [all .v P] is true in that episode if P is true for all values of .v among the associated entities • [exists .v P] is true in that episode if P is true for some value of .v among the associated entities • Compare the operator 'some' that is used in the introductory example in lab2b.
Equivalence rules for quantifiers • The rules from propositional logic continue to hold • Choice of variable may be changed, by substitution throughout • [all x [all y P]] == [all y [all x P]] and same for exists • [not [all x P]] == [exists x [not P]] and similar for exists/all • [and [all x P][all x Q]] == [all x [and P Q]] • [or [exists x P][exists x Q]] == [exists x [or P Q]] • [or [all x P] Q] == [all x [or P Q]] if no x in Q • [and [exists x P] Q] == [exists x [and P Q]] if no x in Q • [exists x P] == P == [all x P] if no x in P • Actually, 'no x in Q' means 'no free x in Q' • A quantified expression encapsulates its variable so that it is not 'free' outside. Substitution within that scope is OK.
Some terms • Vocabulary for a logic formula: set of predicate symbols containing all those that occur in the formula (and maybe some more], with an indication of arity (i.e. its number of arguments] for each of them, even 0 arity • Domain: non-empty set of objects • Interpretation for a predicate: mapping from the set of all argument sequences over the domain, to T or F • Interpretation for a logic formula: an assignment of an interpretation to each predicate in its vocabulary • Model for a logic formula: an interpretation where the value of the formula is T • Joint vocabulary: like before • p == q holds if they have the same value for all interpretations in all their joint vocabularies
Relevance • Interpretation for a logic formula: an assignment of an interpretation to each predicate in its vocabulary • Model for a logic formula: an interpretation where the value of the formula is T • Joint vocabulary: like before • p == q holds if they have the same value for all interpretations in all their joint vocabularies • This definition for == is what one shall use in order to validate the correctness of the equivalence rules for the quantifiers.
Domains • Vocabulary for a logic formula: set of predicate symbols containing all those that occur in the formula (and maybe some more], with an indication of arity (i.e. its number of arguments] for each of them, even 0 arity • Domain: non-empty set of objects • Interpretation for a predicate: mapping from the set of all argument sequences over the domain, to T or F • Recall e.g.: [not [all x P]] == [exists x [not P]] • This rule is sound since the two sides obtain the same truth-value regardless of the choice of domain and the choice of the expression P.
Resolution for Relational Clause Logic • Convert given formulas to clause form like for propositional logic, making sure that quantifiers are outermost • The following applies if the resulting clauses only use 'all' and none of them uses 'exists' • Remove all quantifiers • Use a modified resolution rule where variable substitutions can be made. Examples: • [P .x .y] unifies with [-P a b] with .x = a, .y = b • [P .x b] unifies with [-P a .y] with the same bindings • [P .x] unifies with [-P .y] with .x = .y • [P a] does not unify with [-P b] • (continued)
Resolution for Relational Clause Logic • Use a modified resolution rule where variable substitutions can be made. Examples: • [P .x .y] unifies with [-P a b] with .x = a, .y = b • [P .x b] unifies with [-P a .y] with the same bindings • [P .x] unifies with [-P .y] with .x = .y • [P a] does not unify with [-P b] • To resolve two clauses, one must find substitutions whereby one pair of literals unify, and the same substitutions are applied to the rest of the clauses. Examples: • {[P a]}, {[-P .x], [Q .x]} resolve to {[Q a]} • {[P a .x], [R .x c]}, {[-P .y b], [-R d .y]} resolve to {[R b c], [-R d a]} • Notice that the same also resolve to {[P a d], [-P c b]}
Standard Predicate Logic(No types, no equality) • Arguments of predicates may be arbitrary terms, formed from variables and constant symbols by composition using function symbols. • Vocabulary for a logic formula: set of predicate symbols and function symbols containing all those that occur in the formula (and maybe some more], with an indication of arity (i.e. its number of arguments] for each of them, even 0 arity • Domain: non-empty set of objects • Interpretation for a predicate: mapping from the set of all argument sequences over the domain, to T or F • Interpretation for a function symbol: mapping from the set of all argument sequences over the domain, to the a member of the domain • Interpretation for a logic formula: an assignment of an interpretation to each predicate and function symbol in its vocabulary • Model for a logic formula: an interpretation where the value of the formula is T • Constant symbols may be considered as functions of arity zero
Equivalence rules • The same rules apply as for the case of relational predicate logic. No additions needed.
Resolution: Examples of Unification • [P .x .y] unifies with [-P (f a) b] with .x = (f a), .y = b • [P .x (f .y)] unifies with [-P (f a) .z] with .x = (f a), .y =.y,.z = (f .y) • but also with e.g. .x = (f a), .y = .w, .z = (f .w) • [P .x (f .y)] unifies with [-P (f .x) .y], but only using different substitutions in the two given literals, for example: • .x = (f .z), .y = w in the first one, • .x = .z, .y = (f .w) in the second one • But also e.g. .x = (f .x), .y = .y resp. .x = .x, .y = (f .y) • [P (f .x)] does not unify with [-P (g .y)], nor with [-P (g .x)]
Resolution: Examples • Consider (imp [P .x] [P (+ 1 .x)]) and [P 0] • Rewrite these as {[-P .x] [P (+ 1 .x)]} and {[P 0]} • Resolution gives {[P (+ 1 0)]} • How can this be simplified? Use additional clauses • {[= (+ .a 0) .a]} • {[-P .a] [/= .a .b] [P .b]} where /= is negation of = • The first of these gives {[= (+ 1 0) 1]} by substitution • Two resolution steps give {[P 1]} • Therefore, there is a need for two inference rules: resolution and substitution • Resolution is always done with built-in substitution (i.e. unification), but in principle it's sufficient to use primitive resolution + substitution.
Equality • Recall the axiom that was used above: • {[-P .a] [/= .a .b] [P .b]} • In order to use equality throughout, one needs one axiom similar to this for each predicate of one argument, • One needs two for each predicate of two arguments (one for each arg) • This is called an axiom schema. Notice that for a given vocabulary there is a fixed number of instances of the axiom schema. • Alternative 1: Second-order logic • [all .P (or (not [.P .a]) [/= .a .b] [.P .b])] i.e. • [-.P .a] [/= .a .b] [.P .b] • Alternative 2: Consider = as a part of the logic, just like quantifiers. Advantage: avoid messing up proofs with trivial uses of equality.
Equality • Important: equality is a predicate like all the others (unless one extends the logic considerably) • Equality axioms: • [all .x [= .x .x]] • [all .x [all .y (imp [= .x .y][= .y .x])]] • [all .x [all .y [all .z (imp (and [= .x .y][= .y .z]) [= .x .z])]]] • Schema for argument equality like in the example above • Also, if a and b are two different constant symbols, this does not in itself mean that [/= a b]. Some interpretations can assign the same value to them. • Applications may make separate statement of unique names assumption: different constant symbols have different values • Applications may also make separate statement of closed world assumption: each member of the domain is the value of some constant symbol.
Equality • Applications may make separate statement of unique names assumption: different constant symbols have different values • Expressed as a schema • [all .x (not (and [= .x a][= .x b]))] • that is instantiated for all combinations of different constant symbols a and b in the chosen vocabulary. • Applications may also make separate statement of closed world assumption: each member of the domain is the value of some constant symbol. • Expressed as a schema • [all .x (or [= .x c1][= .x c2] ... [= .x cn])] • listing all the constant symbols in the minimal vocabulary of the given premises.
Skolemization • In order to use the resolution method for a given set of premises, they shall be converted to conjunctive normal form preceded only by universal quantifiers (all), not by existential quantifiers. • What if the given set of premises do produce an expression with existential quantifiers as well?? • Method, example: [all .x [exists .y [P .x .y]]] is replaced by • [all .x [P .x (g .x)]] where g is a 'new' function symbol • i.e. one that is not already in the vocabulary • For [all .x [all .y [exists .z ----]]] replace .z by (g .x .y) • Intuitively reasonable • Formally nonobvious since the rewritten formula is not equivalent to the given one
Skolemization • In order to use the resolution method for a given set of premises, they shall be converted to conjunctive normal form preceded only by universal quantifiers (all), not by existential quantifiers. • What if the given set of premises do produce an expression with existential quantifiers as well?? • Method, example: [all .x [exists .y [P .x .y]]] is replaced by • [all .x [P .x (g .x)]] where g is a 'new' function symbol • i.e. one that is not already in the vocabulary • Intuitively reasonable • Formally problematic since the rewritten formula is not equivalent to the given one • But: the first formula is inconsistent if and only if the second one is. • Therefore, if resolution is used for proof by contradiction, this is a technique that works, but only then.