CS 245 Assignment 1 Solutions
1. The proof is by induction on the structure of F orm(LP ). Base case. Let p ∈ Atom(LP ), then the formula p contains no parenthesis and therefore has the same number of left and right parenthesis. Let R(A) be the property that the formula A has the same number of left and right parenthesis. Our induction hypothesis is that R(A) and R(B) for A, B ∈ F orm(LP ), R(A). Induction step. Assuming the induction hypothesis holds then the formula (¬A) has exactly one more left and one more right parenthesis and therefore still has the same number of left and right parenthesis. If the induction hypothesis holds the number of left parenthesis in (A ∗ B) where ∗ is some connective other than negation is the number of left parenthesis in A, say n plus the number of left parenthesis in B, say m, plus one, or n + m + 1. Similarly, the number of right parenthesis in (A ∗ B) is the number of right parenthesis in A, say l, plus the number of right parenthesis in B, say k, plus one, or l + k + 1. Since R(A) and R(B) hold the number of left parenthesis in A equals the number of right parenthesis in A, so n = l, and the number of left parenthesis in B equals the number of right parenthesis in B, so m = k. Therefore the number of left parenthesis in (A ∗ B), n + m + 1, equals the number of right parenthesis in (A ∗ B), l + k + 1. We have satified [1], [2] and [3] of Theorem 2.2.4 where R(A) is the property that a formula has the same number of left and right parenthesis, therefore all formula in F orm(LP ) have the same number of left and right parenthesis. 2. We break the sentence “A solution will not be found unless the problem is understood and a new device is built.” into the fragments: p = “a solution will be found”, q = “the problem is understood”, and r = “a new device is built”.
Then the above sentence can be translated into propositional logic as (p → (q ∧ r)). If A and B are two english sentence fragments then A unless B can be translated into propositional logic as ((¬q) → p), ((¬p) → q), or p ∨ q where A and B are translated into 1
the propositional symbols p and q, respecively. We chose to use the second translation above which is why the implication shows up in the resulting propositional formula. Above we used the latter of the translations. The conjunction in the formula is there because of the “and” in the sentence. No negation appears in the formula because (¬(¬p)) is logically equivalent to p and negation appears in both the sentence as “not” and when translating “unless” into propositional logic. The sentence “y is an integer only if z is not real or x is rational ” can be converted into the fragments: p = “y is an integer”, q = “z is a real”, and r = “x is rational”.
The sentence is translated into propositional logic as (p → ((¬q) ∨ r)). p only if q is usually thought of as ((¬q) → (¬p)), however this is logically equivalent to (p → q) and is the reason for the why the implication shows up in the above formula. In the sentence z is not a real thus the reason for (¬q) being in the formula. Finally, the disjustion appears because of the “or” in the sentence. 3. We show the given expression (((¬p) ↔ q) ↔ (p ↔ (¬q))) can be constructed using rules defined in Definition 2.2.2. 1 2 3 4 5 6 7
p (¬p) q ((¬p) ↔ q) (¬q) (p↔ (¬q)) (((¬p) ↔ q) ↔ (p ↔ (¬q)))
[1] [2] [1] [3] [2] [3] [3]
on Line 1 on on on on
Lines 2 and 3, with ∗ =↔ Line 3 Lines 1 and 5, with ∗ =↔ Lines 4 and 6, with ∗ =↔
By Definition 2.2.2. it follows that (((¬p) ↔ q) ↔ (p ↔ (¬q))) ∈ Form(LP ). 4. We prove the following property for all the propositional formulas by structural induction (Theorem 2.2.4): For any formula A ∈ Form(LP ), the length of A, denoted length(A), which is the sum of the number of atoms, the number of connectives, and the number of parentheses in A, is either 1 or ≥4. Proof. Base case. For any p ∈ Form(LP ), the property holds because length(p) = 1.
Induction step. (Induction hypothesis) Suppose that both A ∈ Form(LP ) and B ∈ Form(LP ) satisfy the property, i.e., length(A) is either 1 or ≥ 4, the same for B. For (¬A), length((¬A)) = length(A) + 3, because of the connective ¬ and two parentheses. Therefore, length((¬A)) ≥4. 2
For (A ∗ B), where ∗ ∈ {∨, ∧, →, ↔}. length((A ∗ B)) = length(A) + length(B) + 3 because of the connective ∗ and two parentheses, which means length((A ∗ B)) > 4. By Theorem 2.2.4, we know that every formula A ∈ Form(LP ) satisfies this property, so there are no formulae in Form(LP ) of length 2 or 3.
5. To see if either formula is a tautology, contradiction, or neither we construct truth tables for each formula. p 0 1 0 1 p 0 1 0 1 0 1 0 1
q 0 0 1 1 0 0 1 1
r 0 0 0 0 1 1 1 1
q 0 0 1 1
(p → q)
(((p ↔ q) ↔ r)
↔ ((¬p) ∨ q) 1 1 1 1 ↔ 0 0 0 0 0 0 0 0
((¬p) ↔ ((¬q) ↔ (¬r))))
From the truth tables we see ((p → q) ↔ ((¬p) ∨ q)) is a tautology and (((p ↔ q) ↔ r) ↔ ((¬p) ↔ ((¬q) ↔ (¬r)))) is a contradiction.
3