--------------- Predicate Logic --------------- It is a generalization of propositional logic; involves predicates. Predicates: - Example: sentences "if it rains, Joe/Mary/Peter brings his/her umbrella" can be represented using unrelated prop. variables r, u, v, w, but notation is easier using a function U(x) to mean "x brings his/her umbrella" and prop. var. R to mean "it rains". - A predicate is a function that takes arguments from some specified domain and returns true or false, i.e., a predicate expresses some property of its arguments. The "arity" of a predicate is the number of arguments. A prop. variable can be seen as a predicate of arity 0. Quantifiers: - To express sentences such as "if it rains, someone brings their umbrella" or "if it rains, everyone brings their umbrella", we need new notation. - Universal quantifier (upside-down A): "for all", "for every", "for any", etc. asserts a statement for every value of the variable. E.g., forall x U(x) translates to "everyone brings their umbrella". - Existential quantifier (sideways E): "for some", "there exists", "there is", etc. asserts a statement for some value of the variable. E.g., exists x U(x) translates to "someone brings their umbrella". - These statements make sense only in a specific context, i.e., given a specified domain for the variables. - The result of applying a quantifier to a predicate is another predicate. Example: let S(x,y) denote "sibling of", F(x) denote "is female", M(x) denote "is male", and P(x,y,z) denote "x and y are parents of z". . exists y (S(x,y) /\ F(y)) means: x has a sister . exists v exists w (M(x) /\ S(x,v) /\ P(v,w,y)) means: x is y's uncle. Syntax of formulas: - A "first-order language" consists of . set of variable symbols (infinite): {x, y, ...} . set of predicate symbols, each with a fixed arity: {A_1, A_2, ...} . set of constant symbols representing fixed elements of the domain: {c_1, c_2,...} For example, the language of arithmetic (LA) can be defined as follows: . variables: x, y, z, x_1, x_2, ..., y_1, y_2, ..., z_1, z_2, ... . predicates: ==(x,y) (intended meaning: "x = y") L(x,y) (intended meaning: "x < y") S(x,y,z) (intended meaning: "x+y = z") P(x,y,z) (intended meaning: "xy = z") . constants: O (intended meaning: "0"), I (intended meaning: "1") - An "atomic formula" is a predicate applied to arguments (called "terms", either variables or constants), e.g., U(peter), or L(x,z). - More complex formulas are created using propositional connectives or quantifiers: if A and B are formulas, and x is a variable, then ~A, A /\ B, A \/ B, A -> B, A <-> B, forall x A, exists x A are formulas. - Precedence: quantifiers higher than all connectives, used like negation (e.g., forall x A /\ B means (forall x A) /\ B, which is different from forall x (A /\ B)). Free vs bound variables: - Variable x is "bound" in formula A if it appears in A within the scope of a quantifier on x. Variable x is "free" if it appears outside the scope of any quantifier. - Examples: . "forall x P(x) \/ exists y Q(x,y)": x is bound (in "P(x)") and free (in "Q(x,y)"); y is bound. . "forall x[P(x,y) -> exists x Q(x,y)]": every occurence of x is bound; every occurence of y is free. - Note in last example: "y" refers to same object everywhere it appears, but "x" could refer to different objects since first occurrence is bound under "forall x" while second occurrence is bound under "exists x". This is like local variables in programs: they "hide" values for same variable name outside current block. - Name of bound variables is meaningless: if A(x) is a formula with free variable x, and y is a variable that does not appear anywhere (bound or free) in A(x), then forall x A(x) has exactly the same meaning as forall y A(y) (i.e., the formulas are logically equivalent to each other). - Examples: . forall x P(x,z) <=> forall y P(y,z), . forall x P(x,y) not <=> forall y P(y,y). - In general, "rectifying" a formula by changing the names of all bound variables to be different from each other and from all free variables makes meaning clear and unambiguous and is always recommended. - Example: forall z (P(z,y) -> exists x Q(x,y)) is one rectified form of forall x(P(x,y) -> exists x Q(x,y)). - A rectified formula is logically equivalent to its original form, but what does logical equivalence mean for predicate formulas? Structures, valuations, interpretations: - A "structure" S for a first-order language L consists of: . a domain D (nonempty) . for each constant symbol c of L, an element c^S of D . for each n-ary predicate symbol A of L, a relation A^S over D^n . if L contains the equality predicate ==, then it must be associated with the equality relation over D^2 - Examples: for LA, consider two common structures . N: domain is N (natural numbers), predicates and constants are given their intended meaning; . Z: domain is Z (all integers), predicates and constants are given their intended meaning. - A "valuation" v associated with a structure S for a language L is a function that gives a value in D for each variable of L. - An "interpretation" I for L is a pair (S,v), where S is a structure and v is a valuation. Satisfiability and validity: - The truth-value of a formula F under an interpretation I=(S,v) is defined as follows: . if F is an atomic formula P(t_1,...,t_m), where each t_i is a term (either a variable or a constant), then F is true iff the relation A^S is satisfied by the values of t_1,...,t_m under I; For example, the formula L(x,O) is true for the interpretation (Z,v) where v(x)=-5, but false for the interpretation (Z,v) where v(x)=2. The same formula is false for the interpretation (N,v) for every possible valuation v. . if F consists of subformulas joined by a connective, then the value of F is obtained from the truth table for that connective, applied to the values of each subformula; . if F is of the form (forall x E), then F is true iff E is true for every value of x in the domain D (other variables keep their value under valuation v), i.e., F is true iff E is true under every interpretation (S,v') where v'=v except possibly for v'(x); For example, forall x (L(O,x) \/ ==(O,x)) is true under interpretation (N,v) for every valuation v, but the same formula is false under interpretation (Z,v) for every valuation v (the valuation is irrelevant in this case). . if F is of the form (exists x E), then F is true iff E is true for some value of x in the domain D (other variables keep their value under valuation v), i.e., F is true iff E is true under some interpretation (S,v') where v'=v except possibly for v'(x). For example, exists y L(y,O) is false under interpretation (N,v) for every valuation v, but the same formula is true under interpretation (Z,v) for every valuation v (the valuation is irrelevant in this case).