Boolean Logic
Total Page:16
File Type:pdf, Size:1020Kb
Math 1090 Part one: Boolean Logic Saeed Ghasemi York University 18th June 2018 Saeed Ghasemi (York University) Math 1090 18th June 2018 1 / 97 Alphabets of Boolean Logic 0 00 1 Symbols for variables. We denote them by p; q; r;::: or p ; q ; p0; r12 and so on. 2 Symbols for constants. There are two of them, \>" (read \top" or \true") and ? (read \bottom" or \false"). 3 Brackets: \(" and \)". 4 Boolean connectives: :, ^, _, ! and ≡ We will denote the alphabet of propositional (Boolean) logic by V. Some textbooks use less connectives e.g., only : and ^, the other three connectives can be defined using these two. However out alphabet V would contain all five connectives. Saeed Ghasemi (York University) Math 1090 18th June 2018 2 / 97 Definition Given an alphabet A (i.e. a set of symbols) a string (or expression or word) over A is a finite ordered sequence of symbols in A. 0 We use letters A; B; C; A ; B0 ::: to denote strings. Examples If A = fa; b; c; 0; 1g then aaab01, ba1, 01b11 are strings. Note that ab 6= ba since the order matters. These are strings over V pq !:p0? ((p()_ ≡ r ^ rq)(p> The concatenation of two strings A and B is the new string AB. The empty string which we will denote by λ is the unique string such that λA = Aλ = A for any string A. Note that the notion of equality \=" is not part of our alphabet V. It comes from \metatheory" or \metamathematics". Saeed Ghasemi (York University) Math 1090 18th June 2018 3 / 97 Well-formed formulas Definition A string over A is a well-formed formula (wff in short) if it is obtained by applying the following three steps finitely many times 1 Every variable and constant symbol is a wff (these are called \atomic formulas"). 2 If A is a wff then (:A) is also a wff. 3 If A and B are wff, then so are (A ^ B), (A _ B), (A ! B) and A ≡ B. Examples of wff : •? • (p ≡ q) • (((:p) _ q) !?) Note. In this chapter when we say \formula" we mean well-formed formula over the Boolean alphabet. Saeed Ghasemi (York University) Math 1090 18th June 2018 4 / 97 Let WFF denote the set of all well-formed formulas. Equivalently we can define WFF as follows Definition WFF is the smallest subset of the set of all strings over V such that 1 WFF contains all the variables and > and ? (the constant symbols), 2 if A 2 WFF then (:A) 2 WFF , 3 if A; B 2 WFF then (A ^ B), (A _ B), (A ! B) and (A ≡ B) also belong to WFF . • From now on when we say formula we mean a well-formed formula. • In order to verify whether a string is a formula (a wff), we can either \parse the string top-down" or \parse the string bottom-up". Saeed Ghasemi (York University) Math 1090 18th June 2018 5 / 97 Example Suppose we want to show that A = ((p _ (:q)) !?) is a wff. Method 1 (parsing top-down). Suppose B = (p _ (:q)) is a wff (for a moment), then A = (B !?) is a formula, since ? is also formula. So it is enough to show that B is a formula. p is a formula, so if (:q) is a formula then so is B = (p _ (:q)). But (:q) is also a formula since q is a formula. Method 2 (parsing bottom-up). q is a formula and hence (:q) is a formula. Now both p and (:q) are formulas, therefore (p _ (:q)) is a formula. Since (p _ (:q)) and ? are formulas, so is A. Saeed Ghasemi (York University) Math 1090 18th June 2018 6 / 97 Priorities: dropping the redundant brackets We make the following conventions to be able to avoid writing so many brackets. Outermost brackets are redundant. The priorities of connectives, decreasing from left to right, are: :, ^, _, ! and ≡. If a formula looks like · · · ^ A ^ ::: for a subformula A, the right ^ has the priority over the left ^, meaning the formula is · · · ^ (A ^ ::: . The same is true for _, ! and ≡. Examples: •:p stands for (:p) • p _ q _ r stands for (p] _ (q _ r)) • p ! q !? stands for (p ! (q !?)) • p ^ :q _ r stands for ((p ^ (:q)) _ r) Saeed Ghasemi (York University) Math 1090 18th June 2018 7 / 97 Induction on the complexity of the formulas Definition The complexity of each formula is the number of its connectives. For example the complexities of :p ≡ q ! > and (p _ (:q)) ! (p ! (:q)) are 3 and 5, respectively. Fact A formula has complexity zero if and only if it is an atomic formula. Suppose P(A) is an statement about the formula A and suppose we want to prove by induction on the formula complexity that P(A) holds for every formula A. Then Saeed Ghasemi (York University) Math 1090 18th June 2018 8 / 97 Induction on the complexity of the formulas (Basis): Show that P(A) holds for every atomic formula A (variables and constants). (Induction Hypothesis): For a given n, assume P(A) holds for every formula A of complexity less that n. Show that P(A) holds for every formula A with complexity n. If you can follow these steps then the Induction Principle implies that P(A) holds for every formula (compare this with the usual induction on natural numbers). Saeed Ghasemi (York University) Math 1090 18th June 2018 9 / 97 Induction on the complexity of the formulas In practice, in order to use induction on the formulas complexity show that P(A) is true for every A, essentially you need to show that P(A) is true for constants and variables (basis). Assume P(A) and P(B) hold for formulas A and B (I. H.) and prove that P(:A), P(A ^ B), P(A _ B), P(A ! B) and P(A ≡ B) also hold, by using I.H. Theorem Every formula has the same number of right and left brackets. Proof. Prove by induction on the formula complexity. See your notes from the class or the textbook, Theorem 1.2.3. Saeed Ghasemi (York University) Math 1090 18th June 2018 10 / 97 Definition (Immediate Predecessor) Constants and Variables do not have any immediate predecessors. For a formula A the immediate predecessor of :A is just A. For formulas A and B the immediate predecessors of A ^ B, A _ B, A ! B and A ≡ B are A and B. Example: The immediate predecessors of (p _ q) ≡ (:p _ r) are p _ q and :p _ r. Theorem (Unique Readability) For any formula the set of its immediate predecessors is uniquely defined. Proof. See Theorem 1.2.5 of the textbook. The unique readability implies that there is a unique way of constructing each formula from its variables, constants and connectives (and brackets, if you wish). Saeed Ghasemi (York University) Math 1090 18th June 2018 11 / 97 Inductive definition on formulas We can define a concept or a function on the set of all formulas (WFF) inductively (recursively) following these steps: First define the concept for atomic formulas (variables and constants). Define the concept for :A assuming that it is defined for A (by recalling the definition of the concept for A). Define the concept for A ^ B, A _ B, A ! B and A ≡ B assuming that it is defined for formulas A and B. Saeed Ghasemi (York University) Math 1090 18th June 2018 12 / 97 Semantics of Boolean formulas The set of all possible truth values for propositional (Boolean) logic is \true", denoted by t and \false", denoted by f. The semantics of this logic means assigning a\truth values" to formulas so that The truth value of > is always t and the truth value of ? is always f . The truth value each variable is either t or f. The truth value of formulas is decided (calculated) by its truth table. Before dealing with truth table we would like to formalize the above conditions and the definition of truth table. Definition A state is a function that takes atomic formulas (variables and constants) as inputs and assigns either t or f (outputs) to each of them with the condition that it always assigns t to > and f to ?. Saeed Ghasemi (York University) Math 1090 18th June 2018 13 / 97 0 We usually denotes states with v; v ; v0; v1;::: (v for \value"!). States are defined only on atomic formulas. We want to extend the definition of states to the set of all formulas (to WFF). We do this recursively (meaning, using inductive definition on formulas). Assume v is a state and A is formula such that v(A) is defined. Define v(:A) as follows v(:A) = t iff v(A) = f v(:A) = f iff v(A) = t The truth table of \negation" (:) A :A t f f t Saeed Ghasemi (York University) Math 1090 18th June 2018 14 / 97 Now assume v(A) and v(B) are defined for formulas A and B. Lets define the value of v(A ^ B). Since each v(A) v(B) both can be either true or false, there are four possibilities. Possibility (1): v(A) = t and v(B) = t. In this case define v(A ^ B) = t. Possibility (2): v(A) = t and v(B) = f. In this case define v(A ^ B) = f. Possibility (3): v(A) = f and v(B) = t. In this case define v(A ^ B) = f. Possibility (4): v(A) = f and v(B) = f.