<<

Review of Basic Logic

Ben Pfaff October 24, 2001

Contents

1 Notation 1

2 Tautologies 3

3 Substitution 4

4 Polarity 4 4.1 Polarity ...... 5

5 Removal of Quantifiers 5 5.1 Force of Quantifiers ...... 5 5.2 Removal of Strict Universal Force ...... 5 5.3 Removal of Strict Existential Force ...... 6

6 Unification 6

7 Deductive Tableaux 6 7.1 Simple Operations on Tableau ...... 6 7.2 Deductions on Tableaux ...... 7 7.2.1 Basic Deductions ...... 7 7.2.2 Resolution in Propositional Logic ...... 7 7.2.3 Resolution in Logic ...... 8 7.2.4 Equivalence ...... 8 7.2.5 Removal of Quantifiers ...... 8

1 Notation

There are two textbooks on the reading list for this exam: Enderton, A Mathematical Introduction to Logic, and Manna and Waldinger, The Deductive Foundations of Computer Programming. These texts use completely different notation for logical operations. The table below summarizes the two notations. The comps mostly use Enderton’s notation, as will I.

1 Enderton Manna meaning > true logical truth ⊥ false logical untruth ¬a not a ; logical “not” a ∧ b a and b conjunction; logical “and” a ∨ b a or b disjunction; logical “or” a → b if a then b implication; conditional if a then b else c conditional a ↔ b a ≡ b equivalence; biconditional; “if and only if” a + b exclusive disjunction; logical “xor”; equivalent to (a∧¬b)∨(b∧¬a) a ↓ b logical “nor”; equivalent to ¬(a ∨ b) a | b logical “nand”; equivalent to ¬(a ∧ b) a < b logical “less than”; equivalent to (¬a) ∧ b a > b logical “greater than”; equivalent to a ∧ (¬b) ∃x F (∃x)F existential qualifier; “there exists x such that F” ∀x F (∀x)F universal qualifier; “for all x, F” (∀∗)F universal closure: (∀x1, . . . , xn)F for all free variables xi in F (∃∗)F existential closure: (∃x1, . . . , xn)F for all free variables xi in F P t1 . . . tn P (t1, . . . , tn) application of predicate P ft1 . . . tn f(t1, . . . , tn) application of function f a ≈ b a = b equality Σ |= τ tautological implication; every truth assignment that satisfies ev- ery sentence in Σ also satisfies sentence τ; symbol |= pronounced “models” |=U τ sentence τ is true in structure U σ |= =| τ tautological equivalence; σ |= =| τ if and only if σ |= τ and τ |= σ Γ ` ϕ formula ϕ is a theorem deducible from set of formulas Γ Th K the theory of K; Th K = {σ : σ is true in every member of K} Mod Σ the class of all models of Σ; the class of all structures for the lan- guage in which every member of Σ is true Cn Σ consequences of Σ; Cn Σ = {σ :Σ |= σ} = Th Mod Σ N the set of natural numbers {0, 1, 2,... } Z the set of integers {..., −2, −1, 0, 1, 2,... } x αt α with free instances of x replaced by t

The precedence of connectives and qualifiers is listed below, from highest to lowest. Associativity is to the right:(a → b → c) ↔ (a → (b → c).

¬ ∃ ∀ ∧ ∨ other connectives

Definitions (from Enderton except where specified):

• Propositional logic is logic involving variables, constants, logical connectives, true and false, and func- tions. Predicate logic or first-order logic adds quantifiers (∀ and ∃ and predicates. • Enderton regards ¬ and → as the fundamental connective and ∀ as the fundamental qualifier, and considers all other connectives (∧, ∨, . . . ) and qualifiers (∃) as abbreviations for combinations of these. • An alphabet is a set of symbols. • An expression is a finite sequence of symbols from an alphabet. It need not be in any sensible form.

2 • A term is an expression, either a single constant symbol or variable or a function that has terms as its arguments. A term must be syntactically correct. • An atomic formula is an expression that applies a predicate to a set of terms. An atomic formula must be syntactically correct. Manna calls this a proposition. • A wff or well-formed formula is an expression built up from atomic formulas by use of connective symbols and quantifiers. Manna calls this a sentence. An atomic formula is a wff. A wff must be syntactically correct. • A variable x is captured if it is qualified by ∀x, and free otherwise. Manna uses bound in place of captured. • A valid wff is one that is always true, regardless of the truth values of its free variables. A satisfiable wff is one that is true for at least one assignment of its free variables. • A sentence is a wff that has no free variables. On the other hand, Manna’s sentences are Enderton’s wffs; a closed sentence is one that has no free variables. • A structure specifies a set of things for the ∀ quantifier to refer to and meanings for functions and predicate symbols. Each structure U contains:

– A nonempty set |U| called the universe of U, used as the domain for ∀. – A subset of |U|n as the domain for each n-argument predicate. – A member of |U| for each constant. – A mapping from every member of |U|n to |U| for each n-argument function.

Manna refers to structures as interpretations and to a universe as a domain. • A class of structures K is an elementary class or first-order class if and only if K = Mod τ for some sentence τ. K is an elementary class in the wider sense if and only if K = Mod Σ for some set of sentences Σ. • A theory is a set of sentences closed under logical implication. A set of sentences T is a theory if and only if for every σ such that T |= σ, sigma is in T .

2 Tautologies

These are useful for simplification but nonobvious at least to my eye. F, G, and H represent arbitrary wffs.

• (true → G) ↔ G (false → F) ↔ true (F → true) ↔ true (F → false) ↔ ¬F • (F ↔ true) ↔ F (F ↔ false) ↔ ¬F • [(F → G) ∧ (G → H)] → (F → H) [(F ↔ G) ∧ (G ↔ H)] → (F ↔ H) • (F → G) ↔ (¬G → ¬F) (F ↔ G) ↔ (¬F ↔ ¬G)

3 • (F ∧ (G ∨ H)) ↔ ((F ∧ G) ∨ (F ∧ H)) (F ∨ (G ∧ H)) ↔ ((F ∨ G) ∧ (F ∨ H)) ((F ∨ G) → H) ↔ ((F → H) ∧ (G → H)) ((F ∧ G) → H) ↔ ((F → H) ∨ (G → H)) (F → (G ∨ H)) ↔ ((F → G) ∨ (F → H)) (F → (G ∧ H)) ↔ ((F → G) ∧ (F → H)) ((F ∧ G) → H) ↔ (F → (G → H)) • ¬(F ∨ G) ↔ (¬F ∧ ¬G) ¬(F ∧ G) ↔ (¬F ∨ ¬G) ¬(F → G) ↔ (F ∧ ¬G) ¬(F ↔ G) ↔ (F ↔ ¬G) • (F → G) ↔ (¬F ∨ G) (F ↔ G) ↔ ((F ∧ G) ∨ (¬F ∧ ¬G)) (F ↔ G) ↔ ((F → G) ∧ (G → F)) • (∀x)(∀y)F ↔ (∀y)(∀x)F (∃x)(∃y)F ↔ (∃y)(∃x)F (∃y)(∀x)F → (∀x)(∃y)F • ¬(∀x)F ↔ (∃x)¬F ¬(∃x)F ↔ (∀x)¬F • (∀x)[F ∧ G] ↔ ((∀x)F ∧ (∀x)G) (∀x)[F ∨ G] ↔ ((∀x)F ∨ (∀x)G) (∃x)[F → G] ↔ ((∀x)F → (∃x)G) • (∃x)[F ∧ G] → [(∃x)F ∧ (∃x)G] [(∀x)F ∨ (∀x)G] → (∀x)[F ∨ G] [(∃x)F → (∀x)G] → (∀x)[F → G] (∀x)[F → G] → [(∀x)F → (∀x)G] (∀x)[F ↔ G] → [(∀x)F ↔ (∀x)G]

3 Substitution

If we first write F[G], and then later write F[H], the latter is the sentence obtained by replacing every occurrence of G in F[G] by H (Manna 30). G and H are not limited to single symbols; they may both be complex subsentences. The substitution is performed in one pass. If G is not present in F, then F[G] and F[H] are the same sentence. If F[G] contains subsentences of the form G1 ∧ G2 ∧ G3 ∧ · · · ∧ Gn, treat them as if they are parenthesized from the left: (··· ((G1 ∧ G2) ∧ G3) ∧ · · · ∧ Gn), and similarly for ∨. Similarly, if we we first write FhGi, and then later write FhHi, the latter is the sentence obtained by replacing zero or more occurrences of G in FhGi by H. This is called “partial substitution” (Manna 32). Multiple substitutions are available, too: first write F[G1,..., Gn], then later write F[H1,..., Hn] (Manna 33). If there is a choice of substitutions, apply the larger one: in F[P,P ∨Q], substitute for P ∨Q by preference. Multiple partial substitutions work similarly, except that there is no preference for larger substitutions. If quantifiers are involved, substitution is more complex (Manna 175). We must observe the rules for “safe substitution” in a replacement of F[G] by F[H]. First, only free instances of G are replaced. Second that, if H contains a quantifier such that substitution of G by H would capture a free variable y, we must first rename the variable y in the quantifier to a new variable y0 that does not occur in F[G] or in H.

4 Polarity

The polarity of a subsentence is +, −, or (±) (Manna 41, 92, 191). The polarity of a full sentence is either + or −, depending on its ; if unspecified, assume +. Given a polarity π, −π is the opposite polarity:

4 if π is +, −π is −; if π is −, −π is +; otherwise, both π and −π are ±. Polarity are shown as superscripts in the list below, which can be used to determine the polarity of subsentences given the polarity of a full sentence: sentence polarity of subsentences [¬F]π ¬F −π [F ∨ G]π F π ∨ Gπ [F ∧ G]π F π ∧ Gπ [F → G]π F −π → Gπ [F ↔ G]π F ± ↔ G± [(∀x)F]π (∀x)F π [(∃x)F]π (∃x)F π

A polarity is said to be positive if it is + or ±, negative if it is − or ±, strictly positive if it is +, or strictly negative if it is −. Given ShE+i, the notation ShF +i denotes the result of replacing zero or more strictly positive occurrences of E with F (Manna 45). There is similar notation for replacement of strictly negative occurrences. In both cases, there are no restrictions on the polarity of F; it will have the same polarity as E, since polarity is a function of context, not content.

4.1 Polarity Proposition This is the polarity proposition: given E, F, and ShE+i, the sentence (E → F) → (ShE+i → ShF +i) is valid. Similarly, given E, F, and ShE−i, the sentence (E → F) → (ShF −i → ShE−i) is valid (Manna 46, 193). (This is not important but there was a question about it on one of the sample exams.)

5 Removal of Quantifiers

This section explains how to remove quantifiers from sentences in predicate logic. Removal of quantifiers is called skolemization.

5.1 Force of Quantifiers A quantifier has universal force if it is a universal quantifier and (∀x)F has positive polarity, or if it is an existential quantifier and (∃x)F has negative polarity (Manna 194). A quantifier has existential force if it is a existential quantifier and (∃x)F has positive polarity, or if it is an universal quantifier and (∀x)F has negative polarity. A quantifier has both forces if it has both polarities. Suppose we have a quantifier on variable x somewhere inside a sentence F. If x does not occur free in F and the quantifier in question is not in the of any other quantifier, we can remove the quantifier and replace it by a new quantifier on x at the beginning of F. The new one is a universal quantifier if the original had strict universal force, or an existential quantifier if the original had strict existential force; we cannot do this if it has both forces (Manna 197).

5.2 Removal of Strict Universal Force Suppose F is a closed sentence that contains a quantified subsentence S of strict universal force of the form (. . . z)∀P[z]. Then we can replace the quantified subsentence by a new subsentence without a quantifier while preserving validity (but not equivalence). If S is not within the scope of any quantifiers of existential force, the new subsentence is P[a], where a is a new constant. If S is within the scope of quantifiers of existential force, the new subsentence is P[f(y1, . . . , yn)], where y1, . . . , yn are the distinct variables quantified by those quantifiers (Manna 211).

5 5.3 Removal of Strict Existential Force Suppose F is a closed sentence that contains a quantified subsentence S of strict existential force of the form (. . . y)∃P. If S is not within the scope of any quantifier of universal force or any quantifier with the same variable y, we may drop the quantifier entirely, replacing S by P. The new sentence is equivalent to the original (Manna 215).

6 Unification

Unification is a method for making substitutions that convert similar sentences into identical ones (Manna 217). A substitution is a set {x1 ← e1, . . . , xn ← en}. The result of applying a substitution Θ to an expression e is written e/Θ. Such substitutions are carried out with respect to the rules for safe substitution already discussed. The composition of two substitutions Θ and λ, written Θ  λ, has the same effect upon application as first applying Θ, then applying λ (Manna 218). A substitution Θ is said to be more general than another substitution φ, written Θ gen φ, if φ can be obtained as a composition of Θ with some other substitution λ; i.e., there exists λ such that Θ  λ = φ (Manna 220). Note that every substitution is more general than itself because Θ  { } = Θ. A substitution Θ is a unifier of expressions d and e if d/Θ = e/Θ, and Θ is said to unify d and e (Manna 221). A unifier of d and e is most-general if it is more general than every unifier of d and e (Manna 222). There is a general algorithm for unification, but I won’t discuss it (Manna 223).

7 Deductive Tableaux

A deductive tableau is a two-column table used for formal proofs (Manna 53). Each row in the table contains either an assertion in the left column or a goal in the right column. Goals and assertions are sentences; conceptually, an assertion is something that we know to be true and a goal is something we are trying to prove. In propositional logic, a tableau with assertions A1,..., An and goals G1,... Gm is logically equivalent to the sentence (A1 ∧ · · · ∧ An) → (G1 ∨ · · · ∨ Gm) (Manna 55). The truth of this sentence is the truth of the tableau, and vice versa. If a tableau has no assertions, A1 ∧ · · · ∧ An is taken as true; if a tableau has no goals, G1 ∨ · · · ∨ Gm is taken as false. In predicate logic, we take universal closure of all the assertions and existential closure of all the goals to form the associated sentence; i.e., ((∀∗)A1 ∧· · ·∧(∀∗)An) → ((∃∗)G1 ∨· · ·∨(∃∗)Gm) (Manna 239). Otherwise the definition is the same. Two tableaux are equivalent if their associated sentences are equivalent. A tableau that has a valid sentence is said to be valid, and vice versa. Two tableaux have the same validity if they are both valid or both not valid.

7.1 Simple Operations on Tableau

In the descriptions below, Ai refers to the ith of n assertions in a tableau, Gj refers to the jth of m goals, and unsubscripted A and G refer to arbitrary sentences not necessarily part of a tableau. None of these operations are necessary in a proof, but they are useful to keep in mind.

• implied-row property (Manna 59): If (A1 ∧ · · · ∧ An) → A is valid, then the tableau obtained by adding A as an assertion is equivalent to the original; similarly, if G → (G1 ∨ · · · ∨ Gm) is valid, we may add G as a goal. As a consequence, any valid assertion, such as true, may be dropped from a tableau, as may any contradictory (always false) goal, such as false. • duality (Manna 61): A tableau containing a goal G is equivalent to the tableau containing instead the assertion ¬G; a tableau containing an assertion A is equivalent to the tableau containing instead the goal ¬A.

6 • renaming (Manna 246): In a tableau in predicate logic, we may rename variables within a row as long as the renaming doesn’t give distinct variables the same name. • instantiation (Manna 247): In a tableau in predicate logic, we may add a new row that is the same as an existing row except that one or more variables are replaced by terms.

7.2 Deductions on Tableaux We use a tableau to prove a sentence G by making G the single goal of a tableau, called the initial tableau (Manna 65). We may also include as assertions any number of sentences known to be true. Deductions on tableaux are performed by adding, never removing, assertions and goals, based on de- ductive rules for tableaux (65). Most of these deductive rules preserve equivalence; the skolemization rule preserves validity only. Assertions and goals are always simplified according to a catalog in Manna before being added to a tableau (Manna 65, 68). These simplifications are simple things that always shorten the length of the sentence; e.g., ¬(¬F) becomes F and true ∧ F becomes F. (Manna says that these simplifications are “fundamental” to the deductive tableau method but never explains why.) If a new row contains the goal true or the assertion false, then the tableau is valid and we have proved our original goal G (Manna 65).

7.2.1 Basic Deductions These deductions preserve equivalence and validity.

• rewriting rule (Manna 67): We can use a tautology to transform an assertion or goal into an equivalent one, then add the result into the tableau as a new assertion or goal.

• and-split rule (Manna 69): If a tableau contains an assertion of the form A1 ∧ A2, we can add two new assertions, A1 and A2.

• or-split rule (Manna 70): If a tableau contains a goal of the form G1 ∨ G2, we can add two new goals, G1 and G2. • if-split rule (Manna 70): If a tableau contains a goal of the form A → G, we can add a new assertion A and a new goal G. • new valid assertions (Manna 99): If A is a sentence known to be valid, we may add it as a new assertion.

7.2.2 Resolution in Propositional Logic

If A1[P] and A2[P] are assertions, we can add a new assertion A1[false] ∨ A2[true] (Manna 75). P must occur in both A1[P] and A2[P]. This is the AA form of the resolution rule; there are four forms in all:

Form Existing New AA assertion A1[P] assertion A2[P] assertion A1[false] ∨ A2[true] AG assertion A[P] goal G[P] goal ¬A[false] ∧ G[true] GA assertion A[P] goal G[P] goal G[false] ∧ ¬A[true] GG goal G1[P] goal G2[P] goal G1[false] ∧ G2[true]

Common examples (Manna 84):

• identity: If P is both an assertion and a goal, then we may add a new goal true. • contradiction: If we have two assertions P and ¬P, then we may add a new assertion false. • excluded middle: If we have two goals P and ¬P, then we may add a new goal true.

7 • forward chaining/modus ponens: If we have assertions P and P → Q, then we may add a new assertion P. • backward chaining: If we have an assertion P → Q and a goal Q, we may add a new goal P. • clausal resolution: If we have assertions P ∨ Q and (¬P) ∨ R, then we may add a new assertion Q ∨ R.

Polarity strategy (Manna 89): Assign a + polarity to each goal and − polarity to each assertion. Then, suppose we have a resolution of two goals or assertions F1[P] and F2[P] and that we replace the former by F1[false] and the latter by F2[true]. The resolution is in accordance with polarity if at least one occurrence of P in F1[P] is negative and at least one occurrence of P in F2[P] is positive. A resolution not in accordance with polarity will always be implied by one of the given assertions or goals and we could use the original in place of the derived assertion or goal.

7.2.3 Resolution in Predicate Logic We can perform resolution in a tableau in predicate logic in the same way as in a tableau in propositional logic, but we can also take some additional liberties (Manna 259). Only a simple version of the AA form of the rule will be described here. Suppose we have assertions A1[P] 0 0 and A2[P ], where P and P are free, quantifier-free subsentences and A1 and A2 have no free variables in 0 common. Find a most-general unifier Θ of P and P , then let A1Θ be the result of safe substitution of Θ to A1, and similarly for A2Θ. Then, we can add a new assertion A1Θ[false] ∨ A2Θ[true] to the tableau, preserving equivalence.

7.2.4 Equivalence

If we have two assertions A1[P ↔ Q] and A2[P], we may add a new assertion A1[false] ∨ A2hQi (Manna 104). A1 must contain at least one occurrence of P ↔ Q and A2 must contain at least one occurrence of P. There are other versions, and a polarity strategy (Manna 112), but I won’t describe them here.

7.2.5 Removal of Quantifiers We can remove quantifiers from goals and assertions in tableaux in predicate logic. To remove quantifiers of strict universal force, suppose that we have an assertion or goal A that contains one selected subsentence S of the form (. . . z)∀(P[z]) (Manna 286). First, rename the bound and free variables in A, if necessary, so that they are all distinct. Second, let the bound variables of all quantifiers of existential force surrounding S be y1, . . . , yn, and let all the free variables in A be x1, . . . , xm. Then, we may replace S by P[f(x1, . . . , xm, y1, . . . , yn)], or if m = n = 0 then by P[a] where a is a new constant. To remove quantifiers of strict existential force, suppose that we have an assertion or goal A that contains one selected subsentence S of the form (. . . z)∃(P[z]) that is not in the scope of any quantifier of universal force (Manna 290). First, rename the bound variables of A to ensure that S is not in the scope of any other quantifier with the same variable, if necessary. Second, rename y or the free variables of A to ensure that the name y is distinct from the free variables’ names. Then, we may simply drop the quantifier of existential force; i.e., replace S by P[y].

8