Thursday, April 29, 2010

how to prove it - ch3, sec3.1(Proof Strategies) ex

In this section, we learn how to prove statements of the type $P \rightarrow Q$.

Strategy#1 Suppose P is true and from it derive that Q is also true.

Strategy#2 Prove the contrapositive. We know that $P \rightarrow Q$ $\equiv$ $\lnot Q \rightarrow \lnot P$

In the course of figuring out a proof, we have "givens" which are the statements that are facts or hypothesis or assumptions and "goal" that needs to be proven. We start with some givens and goal, apply a proof strategy and get different givens and goal. In other words, application of a proof strategy transforms a problem into another problem which is(hopefully) easier to solve.

We usually do "hit and trial" to figure out which strategy actually works and with practice it might start coming from gut feeling also.

For example the proof of $P \rightarrow Q$ with strategy#2 can be thought as follows...

Scratch work:

Before using any strategy -

givens: -
goal: $P \rightarrow Q$

After applying strategy#2

givens: -
goal: $\lnot Q \rightarrow \lnot P$

After applying strategy#1

givens: $\lnot Q$
goal: $\lnot P$

and the formal proof(after we've thought through the strategy will look like following)..

We're proving the contrapositive.
Suppose Q is false.
[Proof of $\lnot P$ goes here]
Therefore $P \rightarrow Q$

Notice that, it is usual to use a lot of logical notations in the scratch work to figure out the proof, but the final write up of the proof should be in plain english and simple to understand as much possible.

=======================================================================================

Ex-1
(a)
Hypotheses:
n is an integer larger than 1
n is not prime

Conclusion: $2^n - 1$ is not prime

For n = 6, hypotheses are true as 6 is larger than 1 and also not a prime. Theorem tells us that $2^6 - 1$ should not be a prime, which is true as $2^6 - 1$ = 63 is not a prime.

(b) 15 is not prime, so hypotheses are true.
$2^{15} - 1$ = 32767( = 7 * 4681) is not a prime so conclusion is also correct.

(c) 11 is prime, so hypotheses are false. So, theorem does not tell anything.


Ex-2
(a)
Hypotheses: $b^2 > 4ac$
Conclusion: $ax^2 + bx + c = 0$ has exactly two real solutions

(b) Because a,b and c are free variables while x is not. Fixing the values of a,b and c fixes the True/False value of the statement.

(c)
$(-5)^2 - 4(2)(3)$ = 26 > 0, so hypothesis is true and as per the theorem $2x^2 - 5x + 3 = 0$ should have two real solutions, which is true. 1 and 3/2 are two solutions.

(d)
$4^2 - 4(2)(3)$ = -8, -8 < 0 so hypothesis is false. So theorem does not tell anything.


Ex-3
Hypotheses:
n is a natural number
n > 2
n is not prime

Conclusion:
2n+13 is not prime

The instance for n = 8 is a counterexample. As 8 is a natural number, greater than 2 and not prime; so hypotheses are true. But 2(8)+13 = 29 is a prime, so conclusion is false.


Ex-4
Suppose 0 < a < b. Then b-a > 0.
b+a > 0 because both b and a are greater than 0
so (b-a)(b+a) > 0
=> $b^2 - a^2$ > 0
Since $b^2 - a^2$ > 0, it follows $a^2 < b^2$. Therefore if 0 < a < b then $a^2 < b^2$.


Ex-5
Suppose a < b < 0, Then a-b < 0
a+b < 0 because both b and a are less than 0
so (a-b)(a+b) > 0 (multiplication of two negative real numbers is a positive real number)
=> $a^2 - b^2$ > 0
Since $a^2 - b^2$ > 0, it follows $a^2 > b^2$. Therefore if a < b < 0 then $a^2 > b^2$.


Ex-6
Suppose 0 < a < b, Then a < b
On dividing both sides by ab we get
$\frac{a}{ab} < \frac{b}{ab}$
It follows, $\frac{1}{b} < \frac{1}{a}$
Therefore if 0 < a < b, then $\frac{1}{b} < \frac{1}{a}$

Ex-7 Suppose a is a real number and $a^3 > a$
So $a^3 - a$ > 0 ....... (i)
$a^2$ > 0 as a is real,
so $a^2 + 1$ > 0 ........(ii)

on multiplying eq (i) and (ii) we get
$(a^3 - a)(a^2 + 1)$ > 0
=> $a^5 - a$ > 0

It follows that $a^5 > a$, So if a is a real number and $a^3 > a$, then $a^5 > a$.


Ex-8 We will prove the contrapositive, If $x \notin B$ then $x \in D$.
Given that, $A \setminus B \subseteq C \cap D$
it means $\forall y [y \in (A \setminus B) \rightarrow y \in (C \cap D)]$
So, $\forall y [(y \in A \land y \notin B) \rightarrow (y \in C \land y \in D)]$

Now it must be true for y = x also, so
$(x \in A \land x \notin B) \rightarrow (x \in C \land x \in D)$ is true.

It is given that $x \in A$ and suppose $x \notin B$
=> $x \in C \land x \in D$
It follows that $x \in D$

So If $x \notin B$ then $x \in D$. And hence, If $x \notin D$ then $x \in B$


Ex-9 We will prove the contrapositive, If $\frac{a+b}{2} > b$ then $a > b$

Suppose $\frac{a+b}{2} > b$

on multiplying both sides by 2, we get
$a+b > 2b$

on subtracting b from both sides we get
$a > b$

So, If $\frac{a+b}{2} > b$ then $a > b$

And hence, If $a < b$ then $\frac{a+b}{2} < b$


Ex-10 We will prove the contrapositive, If x = 8 then $\frac{x^{1/3} + 5}{x^2 + 6} \neq \frac{1}{x}$

Suppose x = 8, Then $\frac{x^{1/3} + 5}{x^2 + 6}$
= $\frac{8^{1/3} + 5}{8^2 + 6}$
= $\frac{2+5}{64+6}$
= $\frac{7}{70}$
= $\frac{1}{10}$ $\neq$ $\frac{1}{8}$

And hence, If $\frac{x^{1/3} + 5}{x^2 + 6}$ = $\frac{1}{x}$ then $x \neq 8$


Ex-11 We'll prove the contrapositive. If $c \leq d$ then $ac < bd$.

Suppose $c \leq d$

on multiplying it with $a$ (given that $a > o$)
$ac \leq ad$ ............. (i)

also given that $a < b$

on multiplying it with $d$ (given that $d > 0$)
$ad < bd$ ........... (ii)

From eq (i) and (ii)
$ac \leq ac < bd$

It follows, $ad < bd$

And hence, If $ac \geq bd$ then $c > d$


Ex-12
It is given that $3x + 2y \leq 5$
=> $x \leq \frac{5 - 2y}{3}$

Suppose $x > 1$, then
$1 < x \leq \frac{5 - 2y}{3}$
=> $1 < \frac{5 - 2y}{3}$
=> $3 < 5 - 2y$
=> $2y < 5 - 3$
=> $y < 1$

Thus, If $x > 1$ then $y < 1$


Ex-13
Suppose $x^2 + y = -3$ ....... (i)
$2x - y = 2$ .......(ii)

From eq (i)
$y = -3 - x^2$

substituting the value of y in eq (ii)
$2x - (-3 - x^2) = 2$
=> $2x + 3 + x^2 = 2$
=> $x^2 +2x + 1 = 0$
=> $(x + 1)^2 = 0$
=> $x + 1 = 0$
=> $x = -1$

So, If $x^2 + y = -3$ and $2x - y = 2$ then $x = -1$


Ex-14 Prove that, If x > 3 and y < 2 then $x^2 - 2y > 5$.

Suppose x < 3 and y < 2

Since 0 < 3 < x, so from the theorem proven in Ex-4, it follows that
$3^2 < x^2$
=> $x^2 > 9$ ...... (i)

On multiplying -2 with both sides of y < 2
-2y > -4 ..... (ii)(sign changes because we're multiplying by a negative number)

Adding eq (i) and (ii)
$x^2 - 2y > 9 - 4$
=> $x^2 - 2y > 5$

Thus, If x > 3 and y < 2 then $x^2 - 2y > 5$


Ex-15
(a) We've proven that
$(x = 7) \rightarrow \frac{2x - 5}{x - 4}=3$
and NOT
$\frac{2x - 5}{x - 4}=3 \rightarrow (x = 7)$

and $(A \rightarrow B)$ is not logically equivalent to $(B \rightarrow A)$

(b) Suppose $\frac{2x - 5}{x - 4} = 3$
on multiplying both sides with (x - 4), which is $\neq 0$, we get
2x - 5 = 3(x - 4)
=> 2x - 5 = 3x - 12
=> 2x - 3x = -12 + 5
=> -x = -7
=> x = 7

Thus, If $\frac{2x - 5}{x - 4} = 3$ then x = 7


Ex-16
(a) The flaw is in, Since $x \neq 3$ so $x^2 \neq 9$. This is not true, as $x^2 = 9$ for x = -3

(b) One counterexample is, x = -3 and y = 1 as $(-3)^2(1) = 9(1)$

Monday, April 26, 2010

how to prove it - ch2, sec2.3(More On Sets) ex

So far we've learnt 3 ways to represent sets.
- By listing all elements e.g. {1,2,3,4} represents a set that contains 1,2,3 and 4
- By using ellipsis, e.g. {1,2,3,4,...} represents set of all positive integers
- By using elementhood test as in {x | P(x)}, e.g. {x | $x^2 = 9$} represents set {-3,3}. And if we want to be more precise and S is the universe of discourse then we say {$x \in S | P(x)$}

This section introduces another way called "index set" or "index family" which is to write
{$x_i | i \in I$} where $x_i$ is some function of i.
For example {$n^2 | n \in N$} represents set of square of all natural numbers.
Note that set of square of all natural numbers can also be represented by

{$x | \exists i \in N (i^2 = x)$}

This means ($x \in \{n^2 | n \in N\}$) $\equiv$ ($\exists n \in N (x = n^2)$)

In general, ($x \in \{x_i | i \in I\}$) $\equiv$ ($\exists i \in I (x = x_i)$)

Family Of Set A set, all of whose elements are sets.
For example, Power Set of a set S is the set of all the subsets of S, i.e. {A | A $\subseteq$ S}.
So an element x belonging to power set of S means $x \subseteq S$

Intersection of all the sets in a family of set F is denoted by $\cap F$ = {$x | \forall A \in F (x \in A)$}

Union of all the sets in a family of set F is denoted by $\cup F$ = {$x | \exists A \in F (x \in A)$}

Alternatively
A family F of sets $A_i$ can be convenienty defined as {$A_i | i \in I$}.

There exists, additional notations for intersection/union of family based on above definition.

$\cap F$ = ${\cap}_{i \in I}A_i$ = {$x | \forall i \in I (x \in A_i)$}

and

$\cup F$ = ${\cup}_{i \in I}A_i$ = {$x | \exists i \in I (x \in A_i)$}




======================================================================================
$P(A)$ in all of these exercises represents Power Set of A and $F$ represents famility of set.

Ex-1(a) $F \subseteq P(A)$
= $\forall x (x \in F \rightarrow x \in P(A))
= $\forall x (x \in F \rightarrow x \subseteq A)$
= $\forall x [x \in F \rightarrow (\forall y (y \in x \rightarrow y \in A))]

Ex-1(b) $A \subseteq \{2n+1 | n \in N\}$
= $\forall x [x \in A \rightarrow x \in \{2n+1 | n \in N\}]$
= $\forall x [x \in A \rightarrow \exists n \in N (2n+1 = x)]$

Ex-1(c) $\{n^2+n+1 | n \in N\} \subseteq \{2n+1 | n \in N\}$
= $\forall x [x \in \{n^2+n+1 | n \in N\} \rightarrow x \in \{2n+1 | n \in N\}$
= $\forall x [\exists n \in N (n^2+n+1 = x) \rightarrow \exists n \in N (2n+1 = x)]$

Ex-1(d) $\lnot [P({\cup}_{i \in I}A_i) \subseteq {\cup}_{i \in I} P(A_i)]$
= $\lnot [\forall x (x \in P({\cup}_{i \in I}A_i) \rightarrow x \in {\cup}_{i \in I} P(A_i)]$
= $\exists x \lnot[(x \in P({\cup}_{i \in I}A_i) \rightarrow x \in {\cup}_{i \in I} P(A_i)]$
= $\exists x \lnot[x \notin P({\cup}_{i \in I}A_i) \lor x \in {\cup}_{i \in I} P(A_i)]$
= $\exists x [x \in P({\cup}_{i \in I}A_i) \land x \notin {\cup}_{i \in I} P(A_i)]$
= $\exists x [x \subseteq ({\cup}_{i \in I}A_i) \land \lnot (\exists i \in I (x \in P(A_i)))]$
= $\exists x [\forall y (y \in x \rightarrow y \in ({\cup}_{i \in I}A_i)) \land \lnot (\exists i \in I (x \subseteq A_i))]$
= $\exists x [\forall y (y \in x \rightarrow \exists i \in I (y \in A_i)) \land \forall i \in I \lnot (x \subseteq A_i)]$
= $\exists x [\forall y (y \in x \rightarrow \exists i \in I (y \in A_i)) \land \forall i \in I \exists y (y \in x \land y \notin A_i)]$


Ex-2(a) $x \in \cup F \setminus \cup G$
= $x \in \cup F \land x \notin \cup G$
= $\exists A \in F (x \in A) \land \lnot \exists A \in G (x \in A)$
= $\exists A \in F (x \in A) \land \forall A \in G (x \notin A)$

Ex-2(b) $\{x \in B | x \notin C \} \in P(A)$
= $\{x \in B | x \notin C \} \subseteq A$
= $\forall y [y \in \{x \in B | x \notin C \} \rightarrow y \in A]$
= $\forall y [y \in B \land y \notin C \rightarrow y \in A]$

Ex-2(c) $x \in {\cap}_{i \in I}(A_i \cup B_i)$
= $\forall i \in I [x \in (A_i \cup B_i)]$
= $\forall i \in I [x \in A_i \lor x \in B_i]$

Ex-2(d) $x \in ({\cap}_{i \in I}A_i) \cup ({\cap}_{i \in I}B_i)$
= $x \in ({\cap}_{i \in I}A_i) \lor x \in ({\cap}_{i \in I}B_i)$
= $\forall i \in I (x \in A_i) \lor \forall i \in I (x \in B_i)$


Ex-3 $P(\{\emptyset\}) = \{\emptyset, \{\emptyset\}\}$


Ex-4
$\cap F$ = {red, blue}
$\cup F$ = {red, green, blue, orange, purple}


Ex-5
$\cap F$ = $\emptyset$ , Mathematicians would say that $\cap F$ is undefined for this case
$\cup F$ = {3, 7, 12, 5, 16, 23}


Ex-6 I = {2, 3, 4, 5} and for each $i \in I$ $A_i$ = {i, i+1, i-1, 2i}
(a) Find all $A_i$
$A_2$ = {2, 3, 1, 4}
$A_3$ = {3, 4, 2, 6}
$A_4$ = {4, 5, 3, 8}
$A_5$ = {5, 6, 4, 10}

(b)
${\cap}_{i \in I}A_i$ = {4}
${\cup}_{i \in I}A_i$ = {1, 2, 3, 4, 5, 6, 8, 10}


Ex-7 trivial, passed


Ex-8 I = {2, 3} ; for all $i \in I$ $A_i$ = {i, 2i} and $B_i$ = {i, i+1}
(a)
$A_2$ = {2, 4}
$A_3$ = {3, 6}

$B_2$ = {2, 3}
$B_3$ = {3, 4}

(b)
Find ${\cap}_{i \in I}(A_i \cup B_i)$

$(A_2 \cup B_2)$ = {2, 3, 4}
$(A_3 \cup B_3)$ = {3, 4, 6}

${\cap}_{i \in I}(A_i \cup B_i)$ = {3, 4}


Find, $({\cap}_{i \in I}A_i) \cup ({\cap}_{i \in I}B_i)$
= {} $\cup$ {3}
= {3}

(c) They are not equivalent.


Ex-9 I = {1,2}; $A_i$ = {i, 2i}; $B_i$ = {3i, 4i}

$A_1$ = {1,2}
$A_2$ = {2,4}

$B_1$ = {3,4}
$B_2$ = {6,8}

$A_1 \cap B_1$ = { }
$A_2 \cap B_2$ = { }
So, ${\cup}_{i \in I}(A_i \cap B_i)$ = { } .............result-a

${\cup}_{i \in I}A_i$ = {1,2,4}
${\cup}_{i \in I}B_i$ = {3,4,6,8}
So,
$({\cup}_{i \in I}A_i) \cap ({\cup}_{i \in I}B_i)$ = {4} ............result-b

clearly result-a and result-b are not same.


Ex-10 $x \in P(A \cap B)$
= $x \subseteq (A \cap B)$
= $\forall y [y \in x \rightarrow y \in (A \cap B)]$
= $\forall y [y \in x \rightarrow (y \in A \land y \in B)]$
= $\forall y [y \notin x \lor (y \in A \land y \in B)]$
= $\forall y [(y \notin x \lor y \in A) \land (y \notin x \lor y \in B)]$
= $\forall y [(y \in x \rightarrow y \in A) \land (y \in x \rightarrow y \in B)]$
= $[\forall y (y \in x \rightarrow y \in A)] \land [\forall y (y \in x \rightarrow y \in A)]$
= $(x \subseteq A) \land (x \subseteq B)$
= $x \in P(A) \land x \in P(B)$


Ex-11 A = {1} and B = {2}
$P(A \cup B)$
= $P(\{1,2\})$
= {$\emptyset$, {1}, {2}, {1,2}}

$P(A) \cup P(B)$
= $P(\{1\}) \cup P(\{2\})$
= {$\emptyset$, {1}} $\cup$ {$\emptyset$, {2}}
= {$\emptyset$, {1}, {2}}

clearly the two are not equal.


Ex-12(a) LHS
= $x \in {\cup}_{i \in I}(A_i \cup B_i)$
= $\exists i \in I [x \in (A_i \cup B_i)]$
= $\exists i \in I [x \in A_i \lor x \in B_i]$
= $\exists i \in I (x \in A_i) \lor \exists i \in I (x \in B_i)$
= $(x \in {\cup}_{i \in I}A_i) \lor (x \in {\cup}_{i \in I}B_i)$
= $x \in [({\cup}_{i \in I}A_i) \cup ({\cup}_{i \in I}B_i)]$
= RHS

Ex-12(b) LHS
$x \in (\cap F)\cap(\cap G)$
= $x \in (\cap F) \land x \in (\cap G)$
= $[\forall A \in F (x \in A)] \land [\forall A \in G (x \in A)]$

RHS
$x \in \cap (F \cup G)$
= $\forall A \in (F \cup G) (x \in A)$
= $\forall A [A \in (F \cup G) \rightarrow (x \in A)]$
= $\forall A [(A \in F) \lor (A \in G) \rightarrow (x \in A)]$
= $\forall A [\lnot ((A \in F) \lor (A \in G)) \lor (x \in A)]$
= $\forall A [((A \notin F) \land (A \notin G)) \lor (x \in A)]$
= $\forall A [((A \notin F) \lor (x \in A)) \land ((A \notin G) \lor (x \in A))]$
= $\forall A [(A \in F \rightarrow x \in A) \land (A \in G \rightarrow x \in A)]$
= $[\forall A \in F (x \in A)] \land [\forall A \in G (x \in A)]$

clearly both sides are equal

Ex-12(c) LHS
= $x \in {\cap}_{i \in I}(A_i \setminus B_i)$
= $\forall i \in I (x \in A_i \setminus B_i)$
= $\forall i \in I (x \in A_i \land x \notin B_i)$
= $[\forall i \in I (x \in A_i))] \land [\forall i \in I (x \notin B_i))]$
= $(x \in {\cap}_{i \in I}A_i) \land [\forall i \in I \lnot (x \in B_i)]$
= $(x \in {\cap}_{i \in I}A_i) \land \lnot [\exists i \in I (x \in B_i)]$
= $(x \in {\cap}_{i \in I}A_i) \land \lnot (x \in {\cap}_{i \in I}B_i)$
= $x \in ({\cap}_{i \in I}A_i) \setminus ({\cap}_{i \in I}B_i)$
= RHS


Ex-13

(a)
$B_3 = A_{1,3} \cup A_{2,3}$
$B_3 = \{1,3,4\} \cup \{2,3,5\}$
$B_3 = \{1,2,3,4,5\}$

$B_4 = A_{1,4} \cup A_{2,4}$
$B_4 = \{1,4,5\} \cup \{2,4,6\}$
$B_4 = \{1,2,4,5,6\}$

(b) ${\cap}_{j \in J}B_j$
= $B_3 \cap B_4$
= $\{1,2,3,4,5\} \cap \{1,2,4,5,6\}$
= $\{1,2,4,5\}

(c) Let $C_i$ = ${\cap}_{j \in J}A_{i,j}$ = $A_{i,3} \cap A_{i,4}$

$C_1 = $A_{1,3} \cap A_{1,4}$
= $\{1,3,4\} \cap \{1,4,5\}$
= $\{1,4\}$

$C_2 = $A_{2,3} \cap A_{2,4}$
= $\{2,3,5\} \cap \{2,4,6\}$
= $\{2\}$

${\cup}_{i \in I}({\cap}_{j \in J}A_{i,j})$
= ${\cup}_{i \in I}C_i$
= $C_1 \cup C_2$
= $\{1,4\} \cup \{2\}$
= $\{1,2,4\}$

clearly ${\cap}_{j \in J}({\cup}_{i \in I}A_{i,j})$ and ${\cup}_{i \in I}({\cap}_{j \in J}A_{i,j})$ are not equal.

(d)
$x \in {\cap}_{j \in J}({\cup}_{i \in I}A_{i,j})$
= $\forall j \in J (x \in {\cup}_{i \in I}A_{i,j})$
= $\forall j \in J \exists i \in I (x \in A_{i,j})$

$x \in {\cup}_{i \in I}({\cap}_{j \in J}A_{i,j})$
= $\exists i \in I (x \in {\cap}_{j \in J}A_{i,j})$
= $\exists i \in I \forall j \in J (x \in A_{i,j})$

clearly, they are not equivalent.

Ex-14
(a) $x \in \cup F$ means
$\exists A (A \in F \land x \in A)$
For $F = \emptyset$, above is not possible because there is no A
and hence, for any x $x \notin \cup F$ if $F = \emptyset$
$\therefore \cup \emptyset = \emptyset$

(b)
$x \in \cap F$ means
$\forall A (A \in F \rightarrow x \in A)$
For $F = \emptyset$, above is definitely true because there is no A to check for
and hence, for any x $x \in \cap \emptyset$ is always true
$\therefore \cap \emptyset = U$, where $U$ is the universe of discourse

However, for the reasons specified in the book it is too confusing(because $U$ will be context dependant) and mathematicians consider $\cap \emptyset$ undefined.


Ex-15

(a) Let us take a look at the two possiblities..

1. R belongs to the class of sets where set is an element of itself Then R is an element of itself, BUT elements of R are the sets which are not element of themselves. So, we have a contradiction here and its not possible.

2. R belongs to the class of sets where set is not element of itself Then R is not an element of itself, BUT R is the set of ALL such sets which are not element of themselves. So, we have a contracition here and its not possible.

Hence, R can not exist.

(b) This means a set can never be an element of itself. And hence, a universe of discourse of ALL the sets is meaningless.

Wednesday, April 21, 2010

how to prove it - ch2, sec2.2(Equivalence Involving Quantifiers) ex

To understand various equivalences involving quantifiers, it is important to realize that

$\forall x P(x)$ = $P(x_1) \land P(x_2) \land P(x_3)....$
$\exists x P(x)$ = $P(x_1) \lor P(x_2) \lor P(x_3)....$

With above, we can easily check the Quantifier Negation Laws:

$\lnot \exists x P(x)$ = $\forall x \lnot P(x)$
$\lnot \forall x P(x)$ = $\exists x \lnot P(x)$

Ordering of quantifiers does not matter when both are of the same kind(either existential or universal) so $\exists x \exists y (T(x,y) \land P(x,y))$ = $\exists y \exists x (T(x,y) \land P(x,y))$
This suggests that a good way of reading the pair of quantifiers $\exists x \exists y ..$ would be "there are objects x and y such that..."
and a good way of reading the pair of quantifiers $\forall x \forall y..$ would be "for all objects x and y..$

One more important thing to realize is that when we talk about objects x and y, we are not ruling out the possibility that x and y are the same object.


Bounded Quantifiers: If set A is the universe of discourse then we can write statements like
$\forall x \in A, P(x)$, which actually means $\forall x (x \in A \rightarrow P(x))$ and
$\exists x \in A, P(x)$, which actually means $\exists x (x \in A \land P(x))$

and it should be easy to prove that $\lnot \forall x \in A, P(x)$ = $\exists x \in A, \lnot P(x)$ and $\lnot \exists x \in A, P(x)$ = $\forall x \in A, \lnot P(x)$


It is also obvious that for $A = \phi$, $\exists x \in A, P(x)$ is always False and $\forall x \in A, P(x)$ is always True. These statements are called "vacuously" true.

More equivalences:
Universal quantifier distributes over conjunction that is $\forall x (E(x) \land T(x))$ = $\forall x E(x) \land \forall x T(x)$
Existential quantifier distributes over disjunction that is $\exists x (E(x) \lor T(x))$ = $\exists x E(x) \lor \exists x T(x)$

Another special quantifier notation is introduced here, $\exists ! x P(x)$ means There exists exactly one x such that P(x) is true.

=============================================================================
Ex-1(a) Let us first write the given statement in logical form..
$\forall x [M(x) \rightarrow \exists y F(x,y) \land H(y)]$

M(x) means, x is majoring in Maths
F(x,y) means, x and y are friends
H(y) means, y needs help with homework

Now Let us negate the statement.
$\lnot \forall x [M(x) \rightarrow \exists y F(x,y) \land H(y)]$
=$\lnot \forall x [\lnot M(x) \lor \exists y (F(x,y) \land H(y))]$
=$\exists x \lnot [\lnot M(x) \lor \exists y (F(x,y) \land H(y))]$
=$\exists x [M(x) \land \lnot \exists y (F(x,y) \land H(y))]$
=$\exists x [M(x) \land \forall y \lnot (F(x,y) \land H(y))]$
=$\exists x [M(x) \land \forall y (\lnot F(x,y) \lor \lnot H(y))]$
=$\exists x [M(x) \land \forall y (F(x,y) \rightarrow \lnot H(y))]$

The negated statement in English is, There exists someone who is majoring in Maths and all of his friends don't need help with homework.

Ex-1(b) Logical form of original statement is...
$\forall x \exists y [R(x,y) \land \forall z \lnot L(y,z)]$

R(x,y) means, x and y are roommates
L(y,z) means, y likes z

Its negation is...

$\lnot \forall x \exists y [R(x,y) \land \forall z \lnot L(y,z)]$
=$\exists x \lnot \exists y [R(x,y) \land \forall z \lnot L(y,z)]$
=$\exists x \forall y \lnot [R(x,y) \land \forall z \lnot L(y,z)]$
=$\exists x \forall y [\lnot R(x,y) \lor \lnot \forall z \lnot L(y,z)]$
=$\exists x \forall y [\lnot R(x,y) \lor \exists z L(y,z)]$
=$\exists x \forall y [R(x,y) \rightarrow \exists z L(y,z)]$

In English, There is someone such that all of his room-mates have someone they like.

Ex-1(c) $\forall x (x \in A \cup B \rightarrow x \in C \setminus D)$
=$\forall x [(x \notin A \cup B) \lor (x \in C \setminus D)]$

Its negation is...

$\lnot \forall x [(x \notin A \cup B) \lor (x \in C \setminus D)]$
=$\exists x \lnot [(x \notin A \cup B) \lor (x \in C \setminus D)]$
=$\exists x [(x \in A \cup B) \land (x \notin C \setminus D)]$

Ex-1(d) $\lnot \exists x \forall y [y > x \rightarrow \exists z (z^2 + 5z = y)]$
=$\forall x \lnot \forall y [y > x \rightarrow \exists z (z^2 + 5z = y)]$
=$\forall x \exists y \lnot [y > x \rightarrow \exists z (z^2 + 5z = y)]$
=$\forall x \exists y \lnot [\lnot(y > x) \lor \exists z (z^2 + 5z = y)]$
=$\forall x \exists y [y > x \land \lnot \exists z (z^2 + 5z = y)]$
=$\forall x \exists y [y > x \land \forall z \lnot (z^2 + 5z = y)]$
=$\forall x \exists y [y > x \land \forall z (z^2 + 5z \neq y)]$



Ex-2(a) Original statement is
$\exists x [F(x) \land \lnot \exists y R(x,y)]$

F(x) means, x is in Freshman class
R(x,y) means, x and y are roommates

Its negation is

$\lnot \exists x [F(x) \land \lnot \exists y R(x,y)]$
=$\forall x \lnot [F(x) \land \lnot \exists y R(x,y)]$
=$\forall x [\lnot F(x) \lor \exists y R(x,y)]$
=$\forall x [F(x) \rightarrow \exists y R(x,y)]$

In English, Everyone in freshman class has atleast one roommate.

Ex-2(b) Original statement is...
$(\forall x \exists y L(x,y)) \land (\lnot \exists z \forall w L(z,w))$

L(x,y) means, x likes y

Its negation is...
$\lnot [(\forall x \exists y L(x,y)) \land (\lnot \exists z \forall w L(z,w))]$
=$\lnot (\forall x \exists y L(x,y)) \lor \lnot (\lnot \exists z \forall w L(z,w))$
=$(\exists x \lnot \exists y L(x,y)) \lor (\exists z \forall w L(z,w))$
=$(\exists x \forall y \lnot L(x,y)) \lor (\exists z \forall w L(z,w))$

In English, Either there exists someone whom everyone dislikes or there exists someone whom everyone likes.

Ex-2(c) $\lnot \forall a \in A \exists b \in B (a \in C \leftrightarrow b \in C)$
=$\exists a \in A \lnot \exists b \in B (a \in C \leftrightarrow b \in C)$
=$\exists a \in A \forall b \in B \lnot (a \in C \leftrightarrow b \in C)$

Ex-2(d) $\lnot \forall y > 0 \exists x (ax^2 + bx + c = y)$
=$\exists y > 0 \lnot \exists x (ax^2 + bx + c = y)$
=$\exists y > 0 \forall x (ax^2 + bx + c \neq y)$


Ex-3(a) Let us try it for some x < 7 values, if we could find even a single x for which a,b,c can't exist then this statement is false.

for x = 0; a = b = c = 0
for x = 1; a = 1, b = c = 0
for x = 2; a = 1, b = 1, c = 0
for x = 3; a = 1, b = 1, c = 1
for x = 4; a = 2, b = c = 0

clearly, the statement is True.

Ex-3(b) clearly x = 1 and x = 7, both fulfill the condition, so its False.

Ex-3(c) clearly *only* x = 9 (-1 is not a natural number) fulfills the condition, so its True.

Ex-3(d) x = y = 9 fulfill the condition, so its True.


Ex-4 Given: $\lnot \exists x P(x)$ = $\forall x \lnot P(x)$

To Prove: $\lnot \forall x P(x)$ = $\exists x \lnot P(x)$

RHS = $\exists x \lnot P(x)$
= $\lnot \lnot (\exists x \lnot P(x))$
= $\lnot (\lnot \exists x \lnot P(x))$
= $\lnot (\forall x \lnot (\lnot P(x)))$
= $\lnot \forall x P(x)$
= LHS


Ex-5 $\lnot \exists x \in A P(x)$
=$\lnot \exists x (x \in A \land P(x))$
=$\forall x \lnot (x \in A \land P(x))$
=$\forall x (x \notin A \lor \lnot P(x))$
=$\forall x (x \in A \rightarrow \lnot P(x))$
=$\forall x \in A \lnot P(x)$



Ex-6 From Quantifier negation law
$\lnot \exists x (P(x) \lor Q(x))$
= $\forall x (\lnot P(x) \land \lnot Q(x))$
= $(\forall x \lnot P(x)) \land (\forall x \lnot Q(x))$
= $(\lnot \exists x P(x)) \land (\lnot \exists x Q(x))$
= $\lnot (\exists x P(x)) \land \lnot (\exists x Q(x))$
= $\lnot [\exists x P(x) \lor \exists x Q(x)]$

so we proved
$\lnot \exists x (P(x) \lor Q(x))$ = $\lnot [\exists x P(x) \lor \exists x Q(x)]$

now, taking negation of both sides we get
$\exists x (P(x) \lor Q(x))$ = $\exists x P(x) \lor \exists x Q(x)$


Ex-7 $\exists x (P(x) \rightarrow Q(x))$
= $\exists x (\lnot P(x) \lor Q(x))$ ...Existential quantifier distributes over $\lor$
= $(\exists x \lnot P(x)) \lor (\exists x Q(x))$
= $(\lnot \forall x P(x)) \lor (\exists x Q(x))$
= $\forall x P(x) \rightarrow \exists x Q(x)$


Ex-8 $(\forall x \in A P(x)) \land (\forall x \in B P(x))$
= $(\forall x (x \in A \rightarrow P(x))) \land (\forall x (x \in B \rightarrow P(x)))$
= $\forall x (x \in A \rightarrow P(x)) \land (x \in B \rightarrow P(x))$
= $\forall x (x \notin A \lor P(x)) \land (x \notin B \lor P(x))$
= $\forall x [((x \notin A \lor P(x)) \land x \notin B) \lor ((x \notin A \lor P(x)) \land P(x))]$
= $\forall x [((x \notin A \land x \notin B) \lor (P(x) \land x \notin B)) \lor P(x)]$
= $\forall x [(x \notin A \land x \notin B) \lor (P(x) \land x \notin B) \lor P(x)]$
= $\forall x [(x \notin A \land x \notin B) \lor ((P(x) \land x \notin B) \lor P(x))]$
= $\forall x [(x \notin A \land x \notin B) \lor P(x)$
= $\forall x [\lnot (x \in A \lor x \in B) \lor P(x)]$
= $\forall x [\lnot (x \in A \cup B) \lor P(x)]$
= $\forall x [x \in A \cup B \rightarrow P(x)]$
= $\forall x \in A \cup B$ $P(x)$


Ex-9 No.
Let say P(x) means, x has red hair and Q(x) means, x has brown eyes

Then, $\forall x (P(x) \lor Q(x))$ means, Everyone has red hair or brown eyes or both.

And, $\forall x P(x) \lor \forall x Q(x)$ means, Either everyone has red hair or everyone has brown eyes.

Clearly, both mean different things.


Ex-10(a) In ex-8 we proved that
$(\forall x \in A P(x)) \land (\forall x \in B P(x))$ = $\forall x \in A \cup B$ $P(x)$

So,
$(\forall x \in A \lnot P(x)) \land (\forall x \in B \lnot P(x))$ = $\forall x \in A \cup B$ $\lnot P(x)$

negating both sides, we get
$(\exists x \in A P(x)) \lor (\exists x \in B P(x))$ = $\exists x \in A \cup B$ $P(x)$

Ex-10(b) No.
$\exists x \in (A \cap B) P(x)$
= $\exists x (x \in (A \cap B) \land P(x))$
= $\exists x (x \in A \land x \in B \land P(x))$

Since, existential quantifier does not distribute over $\land$ so it can not be equivalent to what is asked in the exercise.


Ex-11 $A \subseteq B$ in logical form is $\forall x (x \in A \rightarrow x \in B)$

$A \setminus B = \emptyset$ in logical form is...
$\lnot \exists x (x \in A \setminus B)$

which is...
= $\forall x \lnot (x \in A \setminus B)$
= $\forall x \lnot ( x \in A \land x \notin B)$
= $\forall x (x \notin A \lor x \in B)$
= $\forall x (x \in A \rightarrow x \in B)$

clearly, both the statements are same.


Ex-12

(a) x has exactly one student.

(b) There is atleast one person having exactly one student.

(c) There is exactly one teacher who has one or more students.

(d) There is atleast one person who has exactly one teacher.

(e) There is only one teacher-student pair.

(f) There is only one teacher-student pair. (e) and (f) are same.

Monday, April 19, 2010

how to prove it - ch2, sec2.1(quantifiers) ex

This section introduces the two well known quantifiers, universal($\forall$) meaning "for all" and existential($\exists$) meaning "there exists".

It also says that quantifier "binds" a variable, that is, a variable that is bound by a quantifier can always be replaced with a new variable without changing the meaning of the statement. For example $\forall x P(x)$ = $\forall y P(y)$

One statement can also contain more than one quantifier, for example, $\forall x \exists y (x + y = 5)$ is a valid statement that means, for all values of x there exists at lease one y such that (x + y = 5).
It may be best in these cases to think about the quantifiers one at a time , in order.

Quantifiers have higher precedence than conditional/biconditional which means $\forall x P(x) \rightarrow Q(x)$ means $[\forall x P(x)] \rightarrow Q(x)$ and not $\forall x [P(x) \rightarrow Q(x)]$

================================================================================================

Ex-1(a) $\forall x [\exists y F(x,y) \rightarrow S(x)]$
where F(x,y) means x has forgiven y
S(x) means x is a saint

Ex-1(b) $\lnot \exists x C(x) \land [\forall y D(y) \land S(x,y)]$
C(x) means, x is in Calculus class
D(y) means, y is in discrete math class
S(x,y) means, x is smarter than y

Ex-1(c) $\forall x L(x, Mary) \land \lnot(x = Mary)$
L(x,Mary) means, x likes Mary
x = Mary means, x is Mary

Ex-1(d) $ [\exists x P(x) \land S(Jane, x)] \land [\exists y P(y) \land S(Roger,y)]$
P(x) means, x is a police officer
S(x,y) means, x saw y

Ex-1(e) $ \exists x P(x) \land S(Jane, x) \land S(Roger, x)$


Ex-2(a) $ \forall x [B(x,Cash) \rightarrow \exists y R(y) \land U(y,x)]$
B(x,y) means, x bought a Rolls Royce with y
R(y) means, y is Rich
U(y,x) means, y is Uncle of x

Ex-2(b) This statement says, "If anyone in the dorm has the measles, then everyone who has a friend in the dorm will have to be quarantined."

$\exists x (D(x) \land M(x)) \rightarrow \forall z [ \exists y (F(z,y) \land D(y)) \rightarrow Q(z) ]$

D(x) means, x lives in the form
F(x,y) means, x and y are friends
M(x) means, x has measles
Q(x) means, x has to be quarantined

Ex-2(c) This statement says, "If there does not exists anyone who failed the test, then everybody with grade A will tutor someone with grade D"

$\lnot \exists x F(x) \rightarrow \forall y (A(y) \rightarrow \exists z D(z) \land T(y,z))$

F(x) means, x has failed the test
A(y) means, y got grade A
D(z) means, z got grade D
T(y,z) means, y will tutor z

Ex-2(d) $ \exists x D(x) \rightarrow D(Jones)$
D(x) means, x can do it

Ex-2(e) $ D(Jones) \rightarrow \forall x D(x)$


Ex-3(a) $\forall z [(z>x) \rightarrow (z > y)]$

this statements is about x and y, that is values of x,y fix the True/False value of the statement.. x,y are the free variables

Ex-3(b) $\forall a \exists x [(ax^2 + 4x -2 = 0) \leftrightarrow (a \geq -2)]$

clearly, there is no free variable.

Ex-3(c) $\forall x [(x^3 - 3x < 3) \rightarrow x < 10]$
no free variables

Ex-3(d) $[\exists x (x^2 + 5x = w)] \land [\exists y (4 - y^2 = w)] \rightarrow -10 < w < 10$
w is the free variable


Ex-4(a) Every unmarried man is unhappy.

Ex-4(b) y is a sibling(sister) of one of x's parent.


Ex-5(a) Every prime number except 2 is odd.

Ex-5(b) There exists a perfect number such that all the other perfect numbers are either less or equal to it.


Ex-6(a) It means, there exists atleast one person who is parent of everyone. clearly its False.

Ex-6(b) It means, Everyone is a parent. clearly its False.

Ex-6(c) It means, There does not exist anyone who is parent of someone. clearly its False.

Ex-6(d) It means, There exists someone who is parent of none. its True.

Ex-6(e) It means, There exists someone who is not parent of someone. its True.


Ex-7(a) using $y = 2x$ we can find a y for any x, clearly its True.

Ex-7(b) It means, there exists a y such that for all x, $2x - y = 0$. clearly its False.

Ex-7(c) Using y = x/2, for odd x there would not be any y which is a natural number. so its False. This would be true if universe of discourse was real numbers.

Ex-7(d) True

Ex-7(e) holds true for y = z = 50; y = 40 , z = 60 ..etc. Clearly its True.

Ex-7(f) This statement will fail for x = 100, there is no y which is greater than 100 for which there exists some (natural number)z such that $y + z = 100$. Clearly its False.


Ex-8(a) True

Ex-8(b) False

Ex-8(c) True

Ex-8(d) False

Ex-8(e) True

Ex-8(f) True


Ex-9(a) True

Ex-9(b) False

Ex-9(c) False

Ex-9(d) True

Ex-9(e) True

Ex-9(f) True

Sunday, April 18, 2010

globalizing a web app

I'm involved in globalizing a web-app, which was not designed keeping g11n in mind. This material might be trivial but I'm noting down here things that are coming up(so that its quicker/easier the next time).

We realise, we need to store 4 user preferences(at least) to make decisions on what to do/show

Country
Locale
Currency
Time-Zone

We're putting following things in, stuff is chosen based on logged in user's preferences.

For Client Side:
Resource Bundles per country-locale
CSS per country-locale
Display Images per country-locale
Client Side validations per country-locale

For Server Side:
App properties per country-locale
A Validation framework where we can write different validation rules for different country-locale pair
Each date is stored as long + timezone string
Oracle DB instance needs to support UTF-8 encoding and VARCHAR2 with char semantics

Friday, April 16, 2010

how to prove it - ch1, sec1.5(the conditional and biconditional connectives) ex

This section introduces the Conditional($\rightarrow$) and the Biconditional($\leftrightarrow$) logical connectives and a form of valid reasoning, which is

$\frac{P \rightarrow Q , P}{\therefore Q}$

Another important thing to learn is, what these connectives usually translate in English to, Conditional can translate to

If P then Q
Q, if P
Q, when P
Q unless $\lnot$P
P only if Q
P is a sufficient condition for Q
Q is a necessary condition for P

and Biconditional can translate to

P if and only if Q
P iff Q
P is the necessary and sufficient condition for Q

Some important equivalences...

$P \rightarrow Q$ = $\lnot P \lor Q$ = $\lnot Q \rightarrow \lnot P$ (this last one is known as contrapositive law)

$P \leftrightarrow Q$ = $P \rightarrow Q \land Q \rightarrow P$

=========================================================================================

Ex-1(a)
$S \lor \lnot E \rightarrow \lnot H$ where
S = Unpleasant smell
E = Explosive
H = Hydrogen

Ex-1(b) $F \land H \rightarrow D$

Ex-1(c) $F \lor H \rightarrow D$
= $\lnot(F \lor H) \lor D$
= $(\lnot F \land \lnot H) \lor D$
= $(\lnotF \lor D) \land (\lnot H \lor D)$
= $(F \rightarrow D) \land (H \rightarrow D)$

Ex-1(d) $A \rightarrow (O \rightarrow P)$ or $(A \land O) \rightarrow P$
A means $x \neq 2$
O means x is odd
P means x is prime


Ex-2(a) $S \rightarrow P \land A$
S means, Marry will sell her house
P means, she can get a good price
A means, she finds a nice apartment

Ex-2(b) $M \rightarrow C \land D$
C means, having a good credit history
D means, an adequate down payment
M means, getting the mortgate

Ex-2(c) Given sentence is equivalent to, If someone does not stop John then he'll kill himself. Its logical form is.. $\lnot S \rightarrow K$

where S means, someone stops john and
K means, john kills himself

Ex-2(d) $D(x,4) \lor D(x,6) \rightarrow \lnot P(x)$
where D(x,y) means, x is divisible by y and
P(x) means x is prime

Ex-3
(a) $R \rightarrow W \land \lnot S$
R means, its raining
W means, its windy
S means, sun is shining

(b) $W \land \lnot S \rightarrow R$ , clearly its the converse of (a)

(c) $R \rightarrow W \land \lnot S$, its same as (a)

(d) $W \land \lnot S \rightarrow R$ , clearly its the converse of (a)

(e) $S \lor \lnot W \rightarrow \lnot R$
= $\lnot(\lnot S \land W) \rightarrow \lnot R$
= $R \rightarrow \lnot S \land W$
= $R \rightarrow W \land \lnot S$ , same as (a)

(f) $(R \rightarrow W) \land (R \rightarrow \lnot S)$
= $(\lnot R \lor W) \land (\lnot R \lor \lnot S)$
= $((\lnot R \lor W) \land \lnot R) \lor ((\lnot R \lor W) \land \lnot S))$
= $\lnot R \lor ((\lnot R \lor W) \land \lnot S))$
= $\lnot R \lor ((\lnot R \land \lnot S) \lor (W \land \lnot S))$
= $(\lnot R \lor (\lnot R \land \lnot S)) \lor (W \land \lnot S)$
= $\lnot R \lor (W \land \lnot S)$
= $R \rightarrow W \land \lnot S$, same as (a)

(g) $(W \rightarrow R) \lor (\lnot S \rightarrow R)$
= $(\lnot W \lor R) \lor (S \lor R)$
= $(\lnot W \lor S) \lor (R \lor R)$
= $\lnot(W \land \lnot S) \lor R$
= $W \land \lnot S \rightarrow R$, converse of (a)

Ex-4(a)
S means, Sales will go up
E means, Expenses will go up
H means, Boss will be Happy

Logical form of given statement is $(S \lor E) \land (S \rightarrow H) \land (E \rightarrow \lnot H)$ and $\therefore$ $\lnot (S \land E)$















SEH$S \lor E$$S → H$$E → \lnot H$$(S \lor E) \land (S → H) \land (E → \lnot H)$$\lnot(S \land E)
FFFFTTFT
TFFTFTFT
FTFTTTTT
TTFTFTFF
FFTFTTFT
TFTTTTTT
FTTTTFFT
TTTTTFFF


Clearly all the places where $(S \lor E) \land (S \rightarrow H) \land (E \rightarrow \lnot H)$ is T, $\lnot (S \land E)$ is also T . So, $\lnot (S \land E)$ can be inferred from $(S \lor E) \land (S \rightarrow H) \land (E \rightarrow \lnot H)$ and the argument is valid.

Ex-4(b)
X means, Tax rate goes up
U means, Unemployment rate goes up
R means, there will be a recession
G means, GNP goes up

logical form of the given statement is $(X \land U \rightarrow R) \land (G \rightarrow \lnot R) \land (G \land X)$, $\therefore$ $\lnot U$























XURG$X \land U → R$$G → \lnot R$$G \land X$$(X \land U → R) \land (G → \lnot R) \land (G \land X)$$\lnot U$
FFFFTTFFT
TFFFTTFFT
FTFFTTFFF
TTFFFTFFF
FFTFTTFFT
TFTFTTFFT
FTTFTTFFF
TTTFTTFFF
FFFTTTFFT
TFFTTTTTT
FTFTTTFFF
TTFTFTTFF
FFTTTFFFT
TFTTTFTFT
FTTTTFFFF
TTTTTFTFF


using the same argument as earlier, its a valid argument.

Ex-4(c)
W means, Warning light will come on
P means, Pressure is too high
R means, Relief valve is clogged

logical form is $(W \leftrightarrow P \land R) \land \lnot R$ , $\therefore$ $W \leftrightarrow P$















WPR$P \land R$$W ↔ P \land R$$W ↔ P$
FFFFTT
TFFFFF
FTFFTF
TTFFFT
FFTFTT
TFTFFF
FTTTFF
TTTTTT


we can see an inconsistency at line 3, so its not a valid argument.


Ex-5(a) $P \leftrightarrow Q$
= $(P \rightarrow Q) \land (Q \rightarrow P)$
= $(\lnot P \lor Q) \land (\lnot Q \lor P)$
= $((\lnot P \lor Q) \land \lnot Q) \lor ((\lnot P \lor Q) \land P)$
= $((\lnot P \land \lnot Q) \lor (Q \land \lnot Q)) \lor ((\lnot P \land P) \lor (Q \land P))$
= $(\lnot P \land \lnot Q) \lor (Q \land P)$
= $(P \land Q) \lor (\lnot P \land \lnot Q)$

Ex-5(b) $(P \rightarrow Q) \lor (P \rightarrow R)$
= $(\lnot P \lor Q) \lor (\lnot P \lor R)$
= $(\lnot P \lor \lnot P) \lor (Q \lor R)$
= $\lnot P \lor (Q \lor R)$
= $P \rightarrow (Q \lor R)$


Ex-6(a) $(P \rightarrow R) \land (Q \rightarrow R)$
= $(\lnot P \lor R) \land (\lnot Q \lor R)$
= $((\lnot P \lor R) \land \lnot Q) \lor ((\lnot P \lor R) \land R)$
= $((\lnot P \lor R) \land \lnot Q) \lor R$
= $((\lnot P \land \lnot Q) \lor (R \land \lnot Q)) \lor R$
= $(\lnot(P \lor Q)) \lor ((R \land \lnot Q) \lor R)$
= $(\lnot(P \lor Q)) \lor R$
= $P \lor Q \rightarrow R$

Ex-6(b) $(P \rightarrow R) \lor (Q \rightarrow R)$ = $P \land Q \rightarrow R$
Here is the proof...
$(P \rightarrow R) \lor (Q \rightarrow R)$
= $(\lnot P \lor R) \lor (\lnot Q \lor R)$
= $(\lnot P \lor \lnot Q) \lor (R \lor R)$
= $\lnot(P \land Q) \lor R$
= $P \land Q \rightarrow R$


Ex-7(a)














PQR$P → Q$$Q → P$$Q → R$$R → Q$$(P → Q) \land (Q → R)$$P ↔ Q$$R ↔ Q$$(P ↔ Q) \lor (R ↔ Q)$$P → R$$(P → R) \land ((P ↔ Q) \lor (R ↔ Q))$
FFFTTTTTTTTTT
TFFFTTTFFTTFF
FTFTFFTFFFFTF
TTFTTFTFTFTFF
FFTTTTFTTFTTT
TFTFTTFFFFFTF
FTTTFTTTFTTTT
TTTTTTTTTTTTT


Match column 8 and 13, clearly both are same.

Ex-7(b)
$(P \rightarrow Q) \lor (Q \rightarrow R)$
= $(\lnot P \lor Q) \lor (\lnot Q \lor R)$
= $\lnot P \lor (Q \lor \lnot Q) \lor R$
= $\lnot P \lor (TRUE) \lor R$
= TRUE

Ex-8 $P \land Q$
= $\lnot(\lnot P \lor \lnot Q)$
= $\lnot(P \rightarrow \lnot Q)$

Ex-9 $P \leftrightarrow Q$
= $(P \rightarrow Q) \land (Q \rightarrow P)$ , now using Ex-8
= $\lnot((P \rightarrow Q) \rightarrow \lnot(Q \rightarrow P))$


Ex-10

(a) $P \rightarrow (Q \rightarrow R)$
= $\lnot P \lor (\lnot Q \lor R)$
= $\lnot P \lor \lnot Q \lor R$

(b) $Q \rightarrow (P \rightarrow R)$
= $\lnot Q \lor (\lnot P \lor R)$
= $\lnot Q \lor \lnot P \lor R$
= $\lnot P \lor \lnot Q \lor R$ , clearly its same as (a)

(c) $(P \rightarrow Q) \land (P \rightarrow R)$
= $(\lnot P \lor Q) \land (\lnot P \lor R)$
= $((\lnot P \lor Q) \land \lnot P) \lor ((\lnot P \lor Q) \land R)$
= $(\lnot P) \lor ((\lnot P \land R) \lor (Q \land R))$
= $\lnotP \lor (\lnot P \land R) \lor (Q \land R)$
= $(\lnot P \lor (\lnot P \land R)) \lor (Q \land R)$
= $\lnot P \lor (Q \land R)

we've reduced original form to disjunctive normal form(disjunction of conjunctions) here

(d) $(P \land Q) \rightarrow R$
= $\lnot(P \land Q) \lor R$
= $\lnot P \lor \lnot Q \lor R$
clearly its same as (a) and (b)

(e) $P \rightarrow (Q \land R)$
= $\lnot P \lor (Q \land R)$
clearly its same as (c)

how to prove it - ch1, sec1.4(operations on sets) ex

This section introduces set operations: Intersection, Union and Difference ($\cap , \cup$ and \)

Most important take away of this section is that, there are two main ways to prove equivalence of two sets
1. By drawing venn diagrams
2. By converting set operations into logic statements(with logic connectives) and then using logical equivalences. Following are the conversion of 3 basic set operations...
x $\in$ $A \cup B$ = $(x \in A) \lor (x \in B)$
x $\in$ $A \cap B$ = $(x \in A) \land (x \in B)$
x $\in$ $A \setminus B$ = $(x \in A) \land \lnot(x \in B)$


Ex-1(a) {3, 12}
Ex-1(b) {1,3,7,12,20,35} \ {x | x is a prime} = {1,12,20,35}
Ex-1(c) {1,3,12,35} $\cup$ ({3,7,12,20} \ {x | x is a prime}) = {1,3,12,35} $\cup$ {12,20} = {1,3,12,20,35}


Ex-2(a) {United States, Germany, China, Australia, France, India, Brazil}
Ex-2(b) {Germany} \ {x | x is a country in Europe} = {}
Ex-2(c) {Germany, France} \ A = {France}

Ex-4 look in the attached pic


Ex-5(a)
x $\in$ $A \setminus (A \cap B)$
= $(x \in A) \land x \notin (A \cap B)$
= $(x \in A) \land \lnot((x \in A) \land (x \in B))$
= $(x \in A) \land (\lnot (x \in A) \lor \lnot (x \in B))$
= $((x \in A) \land \lnot (x \in A)) \lor ((x \in A) \land \lnot (x \in B))$
= $(x \in A) \land \lnot (x \in B)$
= $x \in A \setminus B$

Ex-5(b)
x $\in$ $A \cup (B \cap C)$
= $(x \in A) \lor (x \in (B \cap C))$
= $(x \in A) \lor ((x \in B) \land (x \in C))$
= $((x \in A) \lor (x \in B)) \land ((x \in A) \lor (x \in C))$
= $(x \in A \cup B) \land (x \in A \cup C)$
= $x \in (A \cup B) \cap (A \cup C)$


Ex-6 look in the attached pic


Ex-7(a)

x $\in$ $(A \cup B) \setminus C$
= $(x \in (A \cup B)) \land (x \notin C)$
= $((x \in A) \lor (x \in B)) \land (x \notin C)$
= $((x \in A) \land (x \notin C)) \lor ((x \in B) \land (x \notin C))$
= $(x \in A \setminus C) \lor (x \in B \setminus C)$
= $x \in (A \setminus C) \cup (B \setminus C)$

Ex-7(b)

x $\in$ $A \cup (B \setminus C)$
= $(x \in A) \lor x \in (B \setminus C)$
= $(x \in A) \lor ((x \in B) \land \lnot(x \in C))$
= $((x \in A) \lor (x \in B)) \land ((x \in A) \lor \lnot(x \in C))$
= $(x \in (A \cup B)) \land \lnot((x \in C) \land \lnot(x \in A))$
= $(x \in (A \cup B)) \land \lnot(x \in (C \setminus A))$
= $x \in (A \cup B) \setminus (C \setminus A)$


Ex-8

(a) x $\in$ $(A \setminus B) \setminus C$
= $(x \in (A \setminus B)) \land (x \notin C)$
= $((x \in A) \land (x \notin B)) \land (x \notin C)$
= $(x \in A) \land (x \notin B) \land (x \notin C)$
= $(x \in A) \land \lnot((x \in B) \lor (x \in C))$
= $(x \in A) \land \lnot(x \in (B \cup C))$
= $x \in A \setminus (B \cup C)$

(b) x $\in$ $A \setminus (B \setminus C)$
= $(x \in A) \land \lnot(x \in (B \setminus C))$
= $(x \in A) \land \lnot((x \in B) \land \lnot(x \in C))$
= $(x \in A) \land ((x \notin B) \lor (x \in C))$
= $((x \in A) \land (x \notin B)) \lor ((x \in A) \land (x \in C))$
= $(x \in (A \setminus B)) \lor (x \in (A \cap C))$
= $x \in (A \setminus B) \cup (A \cap C)$

(c) from analysis of b, clearly b and c are same

(d) x $\in$ $(A \setminus B) \cap (A \setminus C)$
= $(x \in (A \setminus B)) \land (x \in (A \setminus C))$
= $((x \in A) \land (x \notin B)) \land ((x \in A) \land (x \notin C))$
= $((x \in A) \land (x \in A)) \land ((x \notin B) \land (x \notin C))$
= $(x \in A) \land \lnot((x \in B) \lor (x \in C))$
= $(x \in A) \land \lnot(x \in (B \cup C))$
= $x \in A \setminus (B \cup C)$


(e) from analysis of a and d, clearly a,d and e are same


Ex-9
A = {1,2,3)
B = {2,4}

$(A \cup B)$ = {1,2,3,4}
$(A \cup B) \setminus B$ = {1,3} , which is not A

Ex-11(a) Look in the attached pic, its clear that $(A \cup B) \setminus C \hspace{2} \subseteq \hspace{2} A \cup (B \setminus C)$

Ex-11(b)
Clearly, for two can be made non-equal by making $A \cap C$ non-empty
A = {1,2,3,4}
B = {3,4,5,6}
C = {0,2,3,4,7}

$(A \cup B) \setminus C$ = {1,5,6}
$A \cup (B \setminus C)$ = {1,2,3,4,5,6}

Rest of the exercises are pretty similar to the ones done, so I'm passing them :)


Thursday, April 15, 2010

how to prove it, ch-1, sec 1.3(Variables and Sets) ex

With variables we can have general statements containing free variables, True/False of which is fixed only when variable is fixed to a value unlike propositional statement whose value is fixed.

Writing a set definition using elementhood test means writing it like {x | P(x)} where P(x) is the desired test/predicate.

In general $y \in \lbrace x \in A | P(x) \rbrace$ means the same thing as $(y \in A) \land P(y)$
=========================================================================================

Ex-1(a) $D(6) \land D(9) \land D(15)$ where D(x) means "x is divisible by 3"

Ex-1(b) $D(x,2) \land D(x,3) \land \lnot D(x,4)$ where D(x,y) means "x is divisible by y"

Ex-1(c) $N(x) \land N(y) \land (P(x) \lor P(y)) \land \lnot (P(x) \land P(y))$ where N(x) means "x is a natutal number" and P(x) means "x is a prime number"


Ex-2(a) $M(x) \land M(y) \land (Taller(x,y) \lor Taller(y,x))$ where M(x) means "x is a Man" and Taller(x,y) means "x is taller than y"

Ex-2(b) $(B(x) \lor B(y)) \land (R(x) \lor R(y))$ where B(x) means "x has brown eyes" and R(x) means "x has red hair"

Ex-2(c)
$(B(x) \land R(x)) \lor (B(y) \land R(y))$ where B(x) means "x has brown eyes" and R(x) means "x has red hair"


Ex-3(a) {x | x is a planet}

Ex-3(b) {x | x is an university}

Ex-3(c) {x | x is a state of USA}

Ex-3(d) {x | x is province or territory in canada}

Ex-4(a) {$x^2$ | $x \in Z+$}

Ex-4(b) {$2^x$ | $x \in N$}

Ex-4(c) {$x \in Z | (x \geq 10) \land (x \leq 19)$}


Ex-5(a) $(-3 \in R) \land (13 - 2*-3 > 1)$ = $(-3 \in R) \land (19 > 1)$
bound variable is 'x', no free variables and statement is True.

Ex-5(b) $(4 \in R-) \land (5 > 1)$
bound variable is 'x', no free variables, but statement is False as $4 \in R-$ is False.

Ex-5(c) $\lnot((5 \in R) \land (3 > c))$
bound variable is 'x', one free variable 'c'


Ex-6(a) $(w \in R) \land (13 - 2w > c)$
bound variable is 'x'; free variables are 'w' and 'c'

Ex-6(b) P(y) means "y is a prime number"
$(4 \in R) \land P(5)$
bound variables are 'x' and 'y'; no free variables; statement is True.

Ex-6(c) P(y) means "y is a prime number"
$P(4) \land (5 > 1)$
bound variables are 'x' and 'y'; no free variables; statement is False


Ex-7(a) {x | x is or was husband of Elizabeth Taylor }

Ex-7(b) $\lbrace \land, \lor, \lnot \rbrace$

Ex-7(c) {"Daniel J. Velleman"}


Ex-8(a) $\lbrace x \in R | x^2 - 4x + 3 = 0 \rbrace$ = {1,3}

Ex-8(b) $\lbrace x \in R | x^2 -2x + 3 = 0 \rbrace$ = $\phi$

Ex-8(c) $\lbrace x \in R | 5 \in \lbrace y \in R | x^2 + y^2 < 50 \rbrace \rbrace$
= {$x \in R | x^2 + 5^2 < 50$}
= {$x \in R | x^2 < 25$}
= {1,2,3,...}

Tuesday, April 13, 2010

how to prove it - ch1, sec1.2 ex

Validity:To prove validity of an argument of the form $premises \Rightarrow conclusion$ we need to create the truth table and see that all the cases where premises are true, conclusion must be true.

Tautology: A statement that is always true.

Contradiction: A statement that is always false.

This section also introduces various equivalences such as DeMorgan's laws, Commutative laws, Associative laws, Idempotent laws, Distributive laws, Double Negation law and Absorption laws($P \lor (P \land Q) \equiv P$ and $P \land (P \lor Q) \equiv P$)

There are two ways to prove the equivalence of two complex logical statements.
  1. Draw truth tables for both and see if they are exactly the same.
  2. Use equivalence relations described above to see if one can be transformed into other


===========================================================================================

Ex-1(a)










PQ$\lnot P$$\lnot P \lor Q$
FFTT
TFFF
FTTT
TTFT



Ex-1(b)










SG$\lnot S$$\lnot G$$S \lor G$$\lnot S \lor \lnot G$$(S \lor G) ∧ (\lnot S \lor \lnot G)$
FFTTFTF
TFFTTTT
FTTFTTT
TTFFTFF



Ex-2(a)










PQ$\lnot P$$(Q \lor \lnot P)$$P \land (Q \lor \lnot P)$$\lnot (P \land (Q \lor \lnot P))$
FFTTFT
TFFFFT
FTTTFT
TTFTTF


Ex-2(b)














PQR$\lnot P$$P \lor Q$$\lnot P \lor R$$(P \lor Q) \land (\lnot P \lor R)$
FFFTFTF
TFFFTFF
FTFTTTT
TTFFTFF
FFTTFTF
TFTFTTT
FTTTTTT
TTTFTTT


Ex-3(a) '+' denotes exclusive or










PQP+Q
FFF
TFT
FTT
TTF


Ex-3(b)
In general, to find the formula from truth table, take the rows where the output of unknown formula is T, for each such row take negation/conjunction of input propositions in such a way that they produce T and then take disjunction of them all.

For above truth table, P+Q is T for 2 cases
1. P = T, Q = F : this suggests $P \land \lnot Q$
2. P = F, Q = T : this suggests $\lnot P \land Q$

taking disjunction of above 2, we get
$(P \land \lnot Q) \lor (\lnot P \land Q)$

Let us see the truth table for this:










PQ$\lnot P$$\lnot Q$$P \land \lnot Q$$\lnot P \land Q$$(P \land \lnot Q) \lor (\lnot P \land Q)$
FFTTFFF
TFFTTFT
FTTFFTT
TTFFFFF


Ex-4
Using DeMorgan's law we can easily see that $P \lor Q \equiv \lnot(\lnot P \land \lnot Q)$ . Let us justify it with the truth table.











PQ$\lnot P$$\lnot Q$$\lnot P \land \lnot Q$$\lnot(\lnot P \land \lnot Q)$$P \lor Q$
FFTTTFF
TFFTFTT
FTTFFTT
TTFFFTT


Ex-5(a)
$\downarrow$ means nor(not or)










PQ$P ↓ Q$
FFT
TFF
FTF
TTF


Ex-5(b)
Its easily seen that it is NOT OR that is $\lnot (P \lor Q)$

Ex-5(c)
$\lnot P \equiv (P \downarrow P)$
$P \lor Q \equiv \lnot(P \downarrow Q) \equiv (P \downarrow Q) \downarrow (P \downarrow Q)$
$P \land Q \equiv \lnot(\lnot P \lor \lnot Q) \equiv \lnot P \downarrow \lnot Q \equiv (P \downarrow P) \downarrow (Q \downarrow Q)$

Ex-6(a)
| means nand (Not And)










PQP|Q
FFT
TFT
FTT
TTF


Ex-6(b) $\lnot(P \land Q)$

Ex-6(c)
$\lnot P \equiv P|P$
$P \lor Q \equiv \lnot(\lnot P \land \lnot Q) \equiv \lnot P | \lnot Q \equiv (P|P)|(Q|Q)$
$P \land Q \equiv \lnot(\lnot(P \land Q)) \equiv \lnot(P|Q) \equiv (P|Q)|(P|Q)$

Ex-7(a)














JmPmPc$Jm \land Pm$$\lnot(Jm \land Pm)$$Pm \lor Pc$
FFFFTF
TFFFTF
FTFFTT
TTFTFT
FFTFTT
TFTFTT
FTTFTT
TTTTFT

clearly the argument is valid.

Ex-7(b)






















BFPC$B \lor F$$P \lor C$$F \land C$$\lnot(F \land C)$$B \land P$$\lnot(B \land P)$
FFFFFFFTFT
TFFFTFFTFT
FTFFTFFTFT
TTFFTFFTFT
FFTFFTFTFT
TFTFTTFTTF
FTTFTTFTFT
TTTFTTFTTF
FFFTFTFTFT
TFFTTTFTFT
FTFTTTTFFT
TTFTTTTFFT
FFTTFTFTFT
TFTTTTFTTF
FTTTTTTFFT
TTTTTTTFTF

clearly argument is not valid at row # 6

Ex-7(c)














JBS$\lnot B$$\lnot S$$J \lor B$$\lnot S \lor \lnot B$$J \lor \lnot S$
FFFTTFTT
TFFTTTTT
FTFFTTTT
TTFFTTTT
FFTTFFTF
TFTTFTTT
FTTFFTFF
TTTFFTFT

clearly argument is valid.

Ex-7(d)














SBE$\lnot B$$S \land B$$E \land \lnot B$$(S \land B) \lor (E \land \lnot B)$$S \land E$$\lnot(S \land E)$
FFFTFFFFT
TFFTFFFFT
FTFFFFFFT
TTFFTFTFT
FFTTFTTFT
TFTTFTTTF
FTTFFFFFT
TTTFTFTTF

clearly argument is not valid at row # 6 and 8.

Ex-8










PQ$\lnot P$$\lnot Q$$P \land Q$$\lnot P \land \lnot Q$a = $(P \land Q) \lor (\lnot P \land \lnot Q)$b = $\lnot P \lor Q$$P \lor \lnot Q$$Q \lor \lnot P$c = $(P \lor \lnot Q) \land (Q \lor \lnot P)$d = $\lnot(P \lor Q)$$Q \land P$e = $(Q \land P) \lor \lnot P$
FFTTFTTTTTTTFT
TFFTFFFFTFFFFF
FTTFFFFTFTFFFT
TTFFTFTTTTTFTT

clearly a $\equiv$ c and b $\equiv e$ and d is equivalent to none

Ex-9










PQ$\lnot P$$\lnot Q$$P \lor Q$$\lnot P \lor \lnot Q$a = $(P \lor Q)\land (\lnot P \lor \lnot Q)$$\lnot P \land \lnot Q$b = $(P \lor Q)\land (\lnot P \land \lnot Q)$c = $(P \lor Q)\lor (\lnot P \lor \lnot Q)$
FFTTFTFTFT
TFFTTTTFFT
FTTFTTTFFT
TTFFTFFFFT


clearly a is none, b is contradiction and c is tautology















PQR$\lnot P$$\lnot R$$Q \lor \lnot R$$P \land (Q \lor \lnot R)$$\lnot P \lor R$d = $(P \land (Q \lor \lnot R)) \lor (\lnot P \lor R)$
FFFTTTFTT
TFFFTTTFT
FTFTTTFTT
TTFFTTTFT
FFTTFFFTT
TFTFFFFTT
FTTTFTFTT
TTTFFTTTT

clearly d is tautology.

Ex-10 Its trivial, pass.

Ex-11(a)
$\lnot(\lnot P \land \lnot Q)$
= $\lnot\lnot P \lor \lnot\lnot Q$ ...DeMorgan's Law
= $P \lor Q$ ...Double Negation Law

Ex-11(b)
$(P \land Q) \lor (P \land \lnot Q)$
= $((P \land Q) \lor P) \land ((P \land Q) \lor \lnot Q))$ ...Distribution Law
= $P \land ((P \land Q) \lor \lnot Q))$ ...Absorption Law
= $P \land ((P \lor \lnot Q) \land (Q \lor \lnot Q))$ ...Distribution Law
= $P \land (P \lor \lnot Q)$
= $P$ ...Absorption law

Ex-11(c)
$\lnot (P \land \lnot Q) \lor (\lnot P \land Q)$
= $(\lnot P \lor Q) \lor (\lnot P \land Q)$ ...DeMorgan's and then Double Negation law
= $((\lnot P \lor Q) \lor \lnot P) \land (\lnot P \lor Q) \lor Q))$ ...Distribution law
= $((\lnot P \lor \lnot P) \lor Q) \land (\lnot P \lor (Q \lor Q))$ ...Commutative and Associative laws
= $(\lnot P \lor Q) \land (\lnot P \lor Q)$ ...Idempotent law
= $\lnot P \lor Q$ ...Idempotent law

Ex-12(a)
$\lnot(\lnot P \lor Q) \lor (P \land \lnot R)$
= $(P \land \lnot Q) \lor (P \land \lnot R)$ ...DeMorgan's, Double Negation law
= $((P \land \lnot Q) \lor P) \land ((P \land \lnot Q) \lor \lnot R)$ ...Distribution law
= $P \land ((P \land \lnot Q) \lor \lnot R)$ ...Absorption law
= $(P \land (P \land \lnot Q)) \lor (P \land \lnot R)$ ...Distribution law
= $(P \land \lnot Q) \lor (P \land \lnot R)$ ...Associative, Idempotent law


Ex-12(b)
$\lnot(\lnot P \land Q) \lor (P \land \lnot R)$
= $(P \lor \lnot Q) \lor (P \land \lnot R)$ ...DeMorgan's, Double Negation law
= $((P \lor \lnot Q) \lor P) \land ((P \lor \lnot Q) \lor \lnot R)$ ...Distribution law
= $(P \lor \lnot Q) \land ((P \lor \lnot Q) \lor \lnot R)$ ...Commutative,Associative law
= $P \lor \lnot Q$ ...Absorption law

Ex-12(c)
$(P \land R) \lor (\lnot R \land (P \lor Q))$
$(P \land R) \lor ((\lnot R \land P) \lor (\lnot R \land Q))$ ...Distribution law
$(P \land R) \lor (\lnot R \land P) \lor (\lnot R \land Q)$
$((P \land R) \lor (\lnot R \land P)) \lor (\lnot R \land Q)$
$(P \land (R \lor \lnot R)) \lor (\lnot R \land Q)$ ...Distribution law
$(P \land TRUE) \lor (\lnot R \land Q)$ ...Tautology
$ P \lor (\lnot R \land Q)$


Ex-13
LHS
= $\lnot(P \lor Q)$
= $\lnot(\lnot\lnot P \lor \lnot\lnot Q)$ ...Double Negation law
= $\lnot(\lnot(\lnot P \land \lnot Q))$ ...First DeMorgan's law
= $\lnot P \land \lnot Q$ ...Double Negation law
= RHS

Ex-14
$(P \land (Q \land R)) \land S$
= $((P \land Q) \land R) \land S$
= $((P \land Q) \land (R \land S))$
= $(P \land Q) \land (R \land S)$

Ex-15 $2^n$

Ex-16
Using the same strategy as described in Ex-3(b)..

output holds true for
P = F, Q = F ; suggests $\lnot P \land \lnot Q$
P = T, Q = F ; suggests $P \land \lnot Q$
P = T, Q = T ; suggests $P \land Q$

taking disjunction of all
$(\lnot P \land \lnot Q) \lor (P \land \lnot Q) \lor (P \land Q)$
= $(\lnot P \land \lnot Q) \lor ((P \land \lnot Q) \lor (P \land Q))$ ...Commutative law
= $(\lnot P \land \lnot Q) \lor (((P \land \lnot Q) \lor P) \land ((P \land \lnot Q) \lor Q))$ ...Distribution law
= $(\lnot P \land \lnot Q) \lor (P \land ((P \land \lnot Q) \lor Q))$ ...Absorption law
= $(\lnot P \land \lnot Q) \lor (P \land ((P \lor Q) \land (\lnot Q \lor Q)))$ ...Distribution law
= $(\lnot P \land \lnot Q) \lor (P \land (P \lor Q))$ ...Tautology
= $(\lnot P \land \lnot Q) \lor P$ ...Absorption law
= $(\lnot P \lor P) \land (\lnot Q \lor P)$ ...Distribution law
= $\lnot Q \lor P$ ...Tautology

Ex-17
Again using the same strategy as described in Ex-3(b)..we get

$(P \land \lnot Q) \lor (\lnot P \land Q)$

Ex-18
Suppose the conclusion of an argument is a tautology. What can you say about the validity of the argument?
We can say, its always valid because for all the cases where premises are true conclusion will also be true(as its a tautology).

What if conclusion is contradiction?
We can't say anything.

What if one of the premises is a tautology?
We can't say anything.

What if one of the premises is a contradiction?
We can say, the argument is always valid as all premises will never be true.

how to prove it - ch1, sec1.1 ex

Ex-1(a)
P $\equiv$ We have a reading assignment.
Q $\equiv$ We have homework.
R $\equiv$ We have a test.

$(P \lor Q) \land \lnot(Q \land R)$

Ex-1(b)
P $\equiv$ You will go skiing.
Q $\equiv$ There will be snow.

$\lnot P \lor (P \land \lnot Q)$

Ex-1(c)
P $\equiv \sqrt{7} < 2$
Q $\equiv \sqrt{7} = 2$

$\lnot (P \lor Q)$

Ex-2(a)
J $\equiv$ John is telling the truth.
B $\equiv$ Bill is telling the truth.

$(J \land B) \lor (\lnot J \land \lnot B)$

Ex-2(b)
F $\equiv$ I'll have fish.
C $\equiv$ I'll have chicken.
P $\equiv$ I'll have mashed potatoes.

$(F \lor C) \land \lnot (F \land P)$

Ex-2(c)
P $\equiv$ 3 is a common divisor of 6.
Q $\equiv$ 3 is a common divisor of 9.
R $\equiv$ 3 is a common divisor of 15.

$P \land Q \land R$

Ex-3(a) $(A \lor B) \land \lnot (A \land B)$
Ex-3(b) $\lnot A \land \lnot B$
Ex-3(c) $\lnot A \lor \lnot B$
Ex-3(d) $\lnot A \land \lnot B$

Ex-4 a and c only

Ex-5(a)
$\lnot (P \land \lnot S) = \lnot P \lor S$ means: Either I will not buy the pants or I'll buy the shirt
Ex-5(b) I will neither buy pants nor shirt.
Ex-5(c) Either I'll not buy pants or I'll not buy the shirt... Or we could say... I'll not buy both pants and shirt.

Ex-7(a)
Premises:
Jane and Pete won't both win the math prize. $\equiv \lnot (Jm \land Pm)$
Pete will either win the math prize or the chemistry prize. $\equiv (Pm \lor Pc)$
Jane will win the math prize. $\equiv Jm$

Conclusion:
Pete will win the chemistry prize. $\equiv Pc$

Reasoning is valid.

Ex-7(b)
Premises:
The main course will be either beef or fish. $\equiv B \lor F$
The vegetable will be either peas or corn. $\equiv P \lor C$
We will not have both fish as a main course and corn as a vegetable. $\equiv \lnot (F \land C)$

Conclusion:
We will not have both beef as a main course and peas as a vegetable. $\equiv \lnot (B \land P)$

Reasoning is not valid because when B = true, P = true, F = false, C = false; all the premises are true but the conclusion is false.

Ex-7(c)
Premises:
Either John or Bill is telling the truth. $\equiv J \lor B$
Either Sam or Bill is lying. $\equiv \lnot S \lor \lnot B$

Conclusion:
Either John is telling the truth or Sam is lying. $\equiv J \lor \lnot S$

Reasoning is valid.

Ex-7(d)
Premises:
Either sales will go up and the boss will be happy, or expenses will go up and the boss won't be happy. $\equiv (S \land B) \lor (E \land \lnot B)$

Conclusion:
Sales and expenses will not both go up. $\equiv \lnot (S \land E)$

Reasoning is not valid because when S = true, B = true, E = true; the premise is true but conclusion is false.

Monday, April 12, 2010

how to prove it - intro exercises

Ex-1 (a)
Using the formula
$2^{15} - 1$ = $2^{3*5} -1$
a = 5, b = 3
$2^b -1$ = $2^3 - 1$ = 7

and

$1 + 2^b + 2^{2b} + ... + 2^{(a-1)b}$ = $1 + 2^3 + 2^{2*3} + 2^{3*3} + 2^{4*3}$ = 4681

Ex-1 (b)
$2^{32767} - 1$ = $2^{7*4681} - 1$
b = 7, so
x = $2^7 - 1$ = 127

Ex-2




































n$3^n - 1$$3^n - 2^n$
121
285
32619
48065
5242211
6728665
721862059
865606305
91968219171
105904858025


2 conjectures are:
$3^n - 2^n$ is prime for prime n
$3^n - 1$ is never prime except for n = 1

Ex-3(a)
2*3*5*7 + 1 = 211

Ex-3(b)
2*3*5*7*11 + 1 = 2311

Ex-4
x = (n+1)! + 2 = (5+1)! + 2 = 722
5 consecutive non-prime numbers are x, x + 1, x + 2, x + 3, x + 4 = 722,723,724,725,726

Ex-5
Use: If $2^n - 1$ is prime $\Rightarrow$ $2^{(n-1)}(2^n - 1)$ is perfect number
$2^5 - 1 = 31$ is prime $\Rightarrow$ $2^{(5-1)}(2^5 - 1)$ = 496 is perfect number
$2^7 - 1 = 127$ is prime $\Rightarrow$ $2^{(7-1)}(2^7 - 1)$ = 8128 is perfect number

Ex-6 There are no more triplet primes other than 3,5,7 where adjacent numbers in the list differ by 2.

Proof: I'll prove it by contradiction. Let say p, p+2, p+4 (p > 3)be such a triplet prime list.

Since one of the 3 consecutive numbers has to be divisible by 3, so
one out of p, p+1 or p+2 is divisible by 3. Since p and p+2 are primes by assumption so p+1 is divisible by 3. But then p+4 = (p+1)+3 and hence p+4 should be divisible by 3 and this is a contradiction.

Tuesday, April 6, 2010

Generic Matrix[T] impl in Scala v2.8+

This is my attempt to learn how to implement generic math libraries(generic in the sense that they can work with any "Numeric" type such as Int,Long,Double,...etc) in Scala. Similar efforts have been tried at following places..

http://stackoverflow.com/questions/485896/how-does-one-write-the-pythagoras-theorem-in-scala
http://dcsobral.blogspot.com/search/label/matrix

I got enough guidance from scala community here, and from this write-up[warn: PDF] on new array impl in scala v2.8 .

Here is the result...


//Generic Rep for m X n immutable matrix
class Matrix[T: ClassManifest] private (private val elems: Array[Array[T]])(n: Numeric[T]) {

import n.mkNumericOps

val rows = elems.size //Returns # of rows
val cols = elems(0).size //Returns # of cols

//Returns jth elem in ith row
// 0 <= i < rows And 0 <= j < cols
def apply(i: Int, j: Int): T = elems(i)(j)

//Returns ith row, 0 <= i < rows
def row(i: Int): Array[T] = elems(i).clone

//Returns ith col, 0 <= i < cols
def col(i: Int): Array[T] = elems.map(_(i))

def *(that: Matrix[T]): Matrix[T] = {
if(this.cols != that.rows)
throw new IllegalArgumentException("Can't be multiplied")
else {
val newArr = Array.ofDim[T](this.rows, that.cols)

for(i <- 0 to this.rows-1) {
for(j <- 0 to that.cols-1) {
newArr(i)(j) = this.row(i).zip(that.col(j)).map(a => a._1 * a._2).sum(n)
}
}
new Matrix(newArr)(n)
}
}

/* ------------ More Matrix Operations ----------- */
}

object Matrix {

def apply[T](elems: Array[Array[T]])(implicit n: Numeric[T],m: ClassManifest[T]): Matrix[T] =
new Matrix[T](clone(elems))(n)

private def clone[T: ClassManifest](arr: Array[Array[T]]): Array[Array[T]] = arr.map(_.clone)
}