Mid-Term Assessment

Question 1

a

Let AA and BB be two sets with A=20|A| = 20, B=25|B| = 25 and AB=35|A \cup B| = 35. Find AB|A \cap B|

\begin{align} |A \cap B| &= |A| + |B| - |A \cup B| \\ &= 20 + 25 - 35 \\ &= 10 \end{align}


b

In a group of 100 people, 73 people can speak English and 43 can speak Spanish.

A=Set of those that can speak EnglishA = \text{Set of those that can speak English} B=Set of those that can speak SpanishB = \text{Set of those that can speak Spanish}

A=73|A| = 73 B=43|B| = 43 AB=100|A \cup B| = 100

i

How many can speak both English and Spanish?

ABA \cap B is the set of people who speak both English and Spanish.

$$ \begin{align} |A \cap B| &= |A| + |B| - |A \cup B| \ &= 73 + 43 - 100 \ &= 16

\end{align} $$

ii

How many can speak English only?

ABA - B is the set of people who speak English only.

\begin{align} |A - B| &= |A| - |A \cap B| \\ &= 73 - 16 \\ &= 57 \end{align}

iii

How many can speak Spanish only?

BAB - A is the set of people who speak Spanish only.

\begin{align} |B - A| &= |B| - |A \cap B| \\ &= 43 - 16 \\ &= 27 \end{align}

iv

Draw a Venn Diagram to show this information.

discrete-midterm-2022.drawio (2)


c

Let AA and BB be two sets. Determine which of the following statements are true and which are false. Prove each statement is true and give a counter example.

i

P(AB)=P(A)P(B)P(A \cap B) = P(A) \cap P(B)

The statement P(AB)=P(A)P(B)P(A \cap B) = P(A) \cap P(B) is true

Proof

I will show that P(AB)P(A)P(B)P(A \cap B) \subseteq P(A) \cap P(B) and P(A)P(B)P(AB)P(A) \cap P(B) \subseteq P(A \cap B)

Suppose XP(AB)X \in P(A \cap B). Since XP(AB)X \in P(A \cap B), we infer XABX \subseteq A \cap B. Therefore, XAX \subseteq A and XBX \subseteq B. Therefore, XP(A)X \in P(A) and XP(B)X \in P(B). Therefore, XP(A)P(B)X \in P(A) \cap P(B) Which means, P(AB)P(A)P(B)P(A \cap B) \subseteq P(A) \cap P(B).

Suppose XP(A)P(B)X \in P(A) \cap P(B). Since XP(A)P(B)X \in P(A) \cap P(B), we infer XP(A)X \in P(A) and XP(B)X \in P(B) Therefore, XAX \subseteq A and XBX \subseteq B Therefore, XABX \subseteq A \cap B Therefore, XP(AB)X \in P(A \cap B) Which means, P(A)P(B)P(AB)P(A) \cap P(B) \subseteq P(A \cap B)

This concludes the proof.

ii

P(AB)=P(A)P(B)P(A \cup B) = P(A) \cup P(B)

The statement P(AB)=P(A)P(B)P(A \cup B) = P(A) \cup P(B) is false.

Proof

I give a proof by counterexample.

A={1}A = \{1\} B={2}B = \{2\}

AB={1,2}A \cup B = \{1, 2\}

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

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

Therefore, P(AB)P(A)P(B)P(A \cup B) \ne P(A) \cup P(B)

This concludes the proof.

iii

P(A)P(B)P(AB)P(A) \cup P(B) \subseteq P(A \cup B)

The statement P(A)P(B)P(AB)P(A) \cup P(B) \subseteq P(A \cup B) is true

Proof

I show that XP(A)P(B)XP(AB)X \in P(A) \cup P(B) \rightarrow X \in P(A \cup B)

Suppose XP(A)P(B)X \in P(A) \cup P(B) Therefore, XP(A)X \in P(A) or XP(B)X \in P(B) Therefore, XAX \subseteq A or XBX \subseteq B Therefore, XP(AB)X \subseteq P(A \cup B)

This means that XP(A)P(B)XP(AB)X \in P(A) \cup P(B) \rightarrow X \in P(A \cup B)

This concludes the proof.


Question 2

a

Which of the following are functions? If f is not a function explain why.

i

f:RR with f(x)=11x2f : \mathbb{R} \rightarrow \mathbb{R} \text { with } f(x) = \frac{1}{1−x^2}

To be a function, every element in the domain has to have an image in the co-domain.

1,1R-1, 1 \in \mathbb{R}

However, f(1)f(-1) and f(1)f(1) don't exist.

f(1)=1112= Undefined due to divide by 0 f(1) = \frac{1}{1-1^2} = \text{ Undefined due to divide by 0 } f(1)=11(1)2= Undefined due to divide by 0 f(-1) = \frac{1}{1-(-1)^2} = \text{ Undefined due to divide by 0 }

Therefore, this is not a function.

ii

f:ZZ with f(x)=x2f : \mathbb{Z} \rightarrow \mathbb{Z} \text { with } f(x) = \frac{x}{2}

To be a function, every element in the domain has to have an image in the co-domain.

3Z3 \in \mathbb{Z} f(3)=3/2=1.5f(3) = 3/2 = 1.5 1.5Z1.5 \notin \mathbb{Z}

3 and all other odd numbers don't have an image. Therefore, this is not a function.

iii

f:RRf : \mathbb{R} \rightarrow \mathbb{R} with f(x)=ln(x)f(x) = ln(x)

To be a function, every element in the domain has to have an image in the co-domain.

0R0 \in \mathbb{R} f(0)=ln(0)=Undefinedf(0) = ln(0) = \text{Undefined}

Therefore, this is not a function.


b

Let f:RRf : \mathbb{R} \rightarrow \mathbb{R} and g:RRg : \mathbb{R} \rightarrow \mathbb{R} with f(x)=x+2f(x) = x + 2 and g(x)=xg(x) = -x. Find g o fg \ o \ f, (g o f)1(g \ o \ f)^{-1}, f1f^{-1}, g1g^{-1}

  • g o f=g(f(x))=g(x+2)=(x+2)=x2g \ o \ f = g(f(x)) = g(x + 2) = -(x + 2) = -x - 2
  • (g o f)1=x2(g \ o \ f)^{-1} = -x - 2
    • Proof
      • (g o f)=y(g \ o \ f) = y
      • x2=y-x - 2 = y
      • x=y+2-x = y + 2
      • x=y2x = -y - 2
  • f1=x2f^{-1} = x - 2
    • Proof
      • f(x)=yf(x) = y
      • x+2=yx + 2 = y
      • x=y2x = y - 2
  • g1=(x)1=xg^{-1} = (-x)^{-1} = -x

c

Let f:RRf : \mathbb{R}^{*} \rightarrow \mathbb{R} with f(x)=x+1xf(x) = \frac{x + 1}{x} where R\mathbb{R}^{*} is the set of all real numbers different from 0.

i

Determine whether or not f is a one to one function

This function is one to one (injective).

Proof

Let a,bRa, b \in \mathbb{R}^{*}

I will show that f(a)=f(b)a=bf(a) = f(b) \rightarrow a = b

f(a)=f(b)f(a) = f(b) a+1a=b+1b\frac{a + 1}{a} = \frac{b + 1}{b} b(a+1)=a(b+1)b(a + 1) = a(b + 1) ba+a=ab+aba + a = ab + a (ba+b)ab=(ab+a)ba(ba + b) - ab = (ab + a) - ba b=ab = a

Therefore, this function is one to one.

This concludes the proof.

ii

Determine whether or not ff is an onto function.

This function is onto (surjective).

Proof

Show that for any element yRy \in R, there exists xRx \in R^{*} such that f(x)=yf(x) = y

f(x)=y    x+1x=y    x+1=xy    x=xy1Rf(x) = y \implies \frac{x+1}{x} = y \implies x+1 = xy \implies x = xy - 1 \in \mathbb{R}

Hence, for all yRy \in \mathbb{R} there exists xRx \in \mathbb{R}^{*} such that f(x)=yf(x) = y

This concludes the proof.


d

Given a function F:P({a,b,c})ZF : P(\{a, b, c\}) \rightarrow \mathbb{Z} is defined by F(A)=AF(A) = |A| for all AP({a,b,c})A \in P(\{a, b, c\})

i

Is F a one-to-one function? Prove or give counter-example.

F is not a one-to-one function, as every element of P({a,b,c})P(\{a, b, c\}) does not have a unique image in Z\mathbb{Z}.

In other words, f(a)=f(b)f(a) = f(b) does not imply a=ba = b

Proof

I show proof by counterexample.

A={a,b}A = \{a, b\}, B={b,c}B =\{b, c\} A,BP({a,b,c})A, B \in P(\{a, b, c\})

F(A)=2,F(B)=2F(A) = 2, F(B) = 2

F(A)=F(B),ABF(A) = F(B), A \ne B, therefore, this function is not one-to-one.

ii

Is F an onto function? Prove or give a counter-example.

F is not an onto (surjective) function.

Proof by Counter-example

100Z100 \in \mathbb{Z} F(X)=100F(X) = 100

There is no XX in the set of P({a,b,c})P(\{a, b, c\}) such that X=100|X| = 100. Therefore, this function is not onto (surjective).


e

Let f:ABf : A \rightarrow B and g:BCg : B \rightarrow C by functions. Prove that if g o fg \ o \ f is one-to-one then ff is also one-to-one.

Proof

Since g o fg \ o \ f is a one to one function, we show that for all a,bAa, b \in A if aba \ne b then f(a)f(b)f(a) \ne f(b)

g o fg \ o \ f is a one to one function, hence, given a,bAa, b \in A with aba \ne b then (gof)(a)(gof)(b)(gof)(a) \ne (gof)(b)

This means that g(f(a))g(f(b))g(f(a)) \ne g(f(b)).

This means that f(a)f(b)f(a) \ne f(b), which implies ff is a one to one function.


Question 3

a

Let p,q,r,sp, q, r, s be four propositions.

Assuming that pp and rr are false and that qq and ss are true, find the truth value of each of the following propositions:

i

((p¬q)(qr))(s¬q)((p \land \neg q) \rightarrow (q \land r)) \rightarrow (s \lor \neg q)

Answer

((p¬q)(qr))(s¬q)((p \land \neg q) \rightarrow (q \land r)) \rightarrow (s \lor \neg q) (F(qr))(s¬q)(F \rightarrow (q \land r)) \rightarrow (s \lor \neg q) (FF)(s¬q)(F \rightarrow F) \rightarrow (s \lor \neg q) T(s¬q)T \rightarrow (s \lor \neg q) TTT \rightarrow T True

ii

((pq)(qs))((¬rp)(qs))((p \lor q) \land (q \lor s)) \rightarrow ((\neg r \lor p) \land (q \lor s))

Answer

((pq)(qs))((¬rp)(qs))((p \lor q) \land (q \lor s)) \rightarrow ((\neg r \lor p) \land (q \lor s)) (TT)((¬rp)(qs))(T \land T) \rightarrow ((\neg r \lor p) \land (q \lor s)) T((¬rp)(qs))T \rightarrow ((\neg r \lor p) \land (q \lor s)) T(TT)T \rightarrow (T \land T) TTT \rightarrow T True


b

Let pp, qq and rr be 3 propositions defined as follows: * pp means "Sofia is happy" * qq means "Sofia paints a picture" * rr means "Samir is happy"

Express each of the 3 following compound propositions symbolically by using pp, qq and rr and appropriate logical symbols.

i

If Sofia is happy and paints a picture then Samir isn't happy.

(pq)¬r(p \land q) \rightarrow \neg r

ii

Sofia is happy only if she paints a picture.

pqp \rightarrow q

iii

Sofia either paints a picture or she is not happy.

q¬pq \lor \neg p


c

Give the contrapositive, the converse and the inverse of each of the following statements:

i

xR\forall x \in \mathbb{R} if x>3x > 3 then x2>9x^{2} > 9

P(x)=x>3P(x) = x > 3 Q(x)=x2>9Q(x) = x^2 > 9

Contrapositive form

xR\forall x \in \mathbb{R}, if ¬Q(x)\neg Q(x) then ¬P(x)\neg P(x) xR\forall x \in \mathbb{R}, if x29x^2 \le 9 then x3x \le 3

Converse form

xR\forall x \in \mathbb{R}, if Q(x)Q(x) then P(x)P(x) xR\forall x \in \mathbb{R}, if x2>9x^2 > 9 then x>3x > 3

Inverse form

xR\forall x \in \mathbb{R}, if ¬P(x)\neg P(x) then ¬Q(x)\neg Q(x) xR\forall x \in \mathbb{R} if x3x \le 3 then x29x^{2} \le 9

ii

xR\forall x \in \mathbb{R} if x(x+1)>0x(x + 1) > 0 then x>0x > 0 or x<1x < -1

P(x)=x(x+1)>0P(x) = x(x + 1) > 0 Q(x)=x>0Q(x) = x > 0 or x<1x < -1

Contrapositive form

xR\forall x \in \mathbb{R} if ¬Q(x)\neg Q(x) then ¬P(x)\neg P(x) xR\forall x \in \mathbb{R} if ($x \le 0$ and x1x \ge -1) then x(x+1)0x(x + 1) \le 0

Converse form

xR\forall x \in \mathbb{R} if Q(x)Q(x) then P(x)P(x) xR\forall x \in \mathbb{R} if (x>0(x > 0 or x<1)x < -1) then x(x+1)>0x(x + 1) > 0

Inverse form

xR\forall x \in \mathbb{R} if ¬P(x)\neg P(x) then ¬Q(x)\neg Q(x) xR\forall x \in \mathbb{R} if (x(x+1)0)(x(x + 1) \le 0) then (x0(x \le 0 and x1)x \ge -1)


d

A tautology is a proposition that is always is always true. Let p,q,rp, q, r be three propositions, show that (p(qr))((p¬q)r)(p \rightarrow (q \lor r)) \Leftrightarrow ((p \land \neg q) \rightarrow r) is a tautology.

I will prove the tautology using truth tables.

pp qq rr p(qr)p \rightarrow (q \lor r) ((p¬q)r)((p \land \neg q) \rightarrow r) (p(qr))((p¬q)r)(p \rightarrow (q \lor r)) \Leftrightarrow ((p \land \neg q) \rightarrow r)
0 0 0 1 1 1
0 1 0 1 1 1
0 0 1 1 1 1
1 0 0 0 0 1
1 1 0 1 1 1
1 0 1 1 1 1

As you can see from the truth table, (p(qr))((p¬q)r)(p \rightarrow (q \lor r)) \Leftrightarrow ((p \land \neg q) \rightarrow r) is a tautology, as the statements on either side of the material equivalence operator are equivalent.


Question 4

a

Let P(x, y) by a boolean function. Assume that x y P(x,y)\exists x \ \forall y \ P(x, y) is True and the domain of discourse is nonempty. Which of the following must also be true? If the statement is true, explain your answer; otherwise, give a counter-example.

i

x y ¬P(x,y)\forall x \ \exists y \ \neg P(x, y)

False

We know the negation of xy¬P(x,y)\forall x \exists y \neg P(x, y), which is x y P(x,y)\exists x \ \forall y \ P(x, y) is true, therefore the statement must be false.

ii

x y P(x,y)\forall x \ \forall y \ P(x, y)

False

We give an example to show that this statement can be False while the given statement is true.

Let P(x,y)P(x, y) be the propositional function xyx \le y with domain of discourse as the natural numbers.

x y P(x,y)\exists x \ \forall y \ P(x, y) is True when x=1x = 1 since 1y1 \le y for all yNy \in N

However, x y P(x,y)\forall x \ \forall y \ P(x, y) is False as we can find a counter-example like x=3,y=1x = 3, y = 1 ($3 \le 1$) which is false.

iii

x y P(x,y)\exists x \ \exists y \ P(x, y)

True

Since x y P(x,y)\exists x \ \forall y \ P(x, y) is True, we know there is an xx value where, for all yy, P(x,y)P(x, y) is True.

Therefore, the same xx value clearly has at least one yy value where P(x,y)P(x, y).

Therefore, xyP(x,y)\exists x \exists y P(x, y) is true.


b

Given the following argument:

  • "The football game will be cancelled only if it rains."
  • "It rained, therefore the football game was cancelled."

Assume pp means "it rains" whereas qq means "football game cancelled"

i

Translate this argument to symbolic form.

qpq \rightarrow p pp q\therefore q

ii

Construct the truth table.

qq pp qpq \rightarrow p (qp)p(q \rightarrow p) \land p ((qp)p)q((q \rightarrow p) \land p) \rightarrow q
0 0 1 0 1
0 1 1 1 0
1 0 0 0 1
1 1 1 1 1

iii

Determine if this argument is a valid argument or not.

This argument is not valid.

The proposition ((qp)p)q((q \rightarrow p) \land p) \rightarrow q is not a tautology, because it is False when qq is False and pp is True.

This is an incorrect argument using the fallacy of affirming the consequent.


c

Say whether or not the following argument is a valid argument. Explain your answer.

a) Successful candidates for this job must have either a Master's degree or five years of work experience. b) Johny has a Master's degree. c) Johnny got the job d) \therefore Johnny does not have five years of work experience.

pp: means the candidate was successful. qq: means the candidate has a masters degree. r: means the candidate has five years of work experience.

p(qr)p \rightarrow (q \lor r) qq pp


¬r\therefore \neg r

We can represent as a true table:

p q r p(qr)p \rightarrow (q \lor r) (p(qr))qp(p \rightarrow (q \lor r)) \land q \land p ¬r\neg r ((p(qr))qp)¬r((p \rightarrow (q \lor r)) \land q \land p) \rightarrow \neg r
0 0 0 1 0 1 1
0 1 0 1 0 1 1
0 0 1 1 0 0 1
0 1 1 1 0 0 1
1 0 0 0 0 1 1
1 1 0 1 1 1 1
1 0 1 1 0 0 1
1 1 1 1 1 0 0

From this, we can see this is not a valid argument as the proposition ((p(qr))qp)¬r((p \rightarrow (q \lor r)) \land q \land p) \rightarrow \neg r is not a tautology.

There is an example where the premise is true but the conclusion is false.


d

Let P(x)P(x) and Q(x)Q(x) be two predicates and suppose DD is the domain of xx.

For the statement forms in each pair, determine whether the have the same truth value for every choice of P(x)P(x), Q(x)Q(x), DD or not.

i

xD,(P(x)Q(x))\forall x \in D, (P(x) \land Q(x)), and (xD,P(x))(xD,Q(x))(\forall x \in D, P(x)) \land (\forall x \in D, Q(x))

These two statements have the same truth value.

Proof

In the first statement, we see that for all xDx \in D, P(x)Q(x)P(x) \land Q(x) is true. This means for all xDx \in D, P(x)P(x) is true. It also means for all xDx \in D, Q(x)Q(x) is true. This means (xD,P(x))(xD,Q(x))(\forall x \in D, P(x)) \land (\forall x \in D, Q(x))

Therefore, these statements have the same truth value.

ii

xD,(P(x)Q(x))\forall x \in D, (P(x) \lor Q(x)), and (xD,P(x))(xD,Q(x))(\forall x \in D, P(x)) \lor (\forall x \in D, Q(x))

These two statements do not have the same truth value.

Proof

I prove that these statements do not have the same true value with a counterexample.

D={1,2}D = \{1, 2\} P(1)=TP(1) = T P(2)=FP(2) = F

Q(1)=FQ(1) = F Q(2)=TQ(2) = T

The statement P(x)Q(x)P(x) \lor Q(x) is true for all xDx \in D: P(1)Q(1)P(1) \lor Q(1), P(2)Q(2)P(2) \lor Q(2)

However, it is not true that xD,P(x)\forall x \in D, P(x), as P(2)=FP(2) = F. It is also not true that xD,Q(x)\forall x \in D, Q(x) as Q(1)=FQ(1) = F. This means that (xD,P(x))(xD,Q(x))(\forall x \in D, P(x)) \lor (\forall x \in D, Q(x)) is false.

Therefore, these statements do not have the same truth value.

Question 5

a

Use rules of boolean algebra to simplify the following boolean expressions:

i

ab(a+b)(b+b)\overline{ab}(\overline{a} + b)(\overline{b} + b)

\begin{align} \overline{ab}(\overline{a} + b)(\overline{b} + b) &= \overline{ab}(\overline{a} + b)1 \text{ -- Complement law} \\ &= \overline{ab}(\overline{a} + b) \text{ -- Idempotent} \\ &= \overline{ab}\overline{a} + \overline{ab}b \text{ -- Distributive} \\ &= (\overline{a} + \overline{b})\overline{a} + (\overline{a} + \overline{b})b \text{ -- De Morgan's} \\ &= \overline{a}\overline{a} + \overline{a}\overline{b} + \overline{a}b + \overline{b}b \text{ -- Distributive} \\ &= \overline{a} +\overline{a}\overline{b} + \overline{a}b + 0 \text{ -- Idempotent and Complement} \\ &= \overline{a} + \overline{a}(\overline{b} + b) + 0 \text{ -- Distributive} \\ &= \overline{a} + \overline{a}.1 + 0 \text{ -- Idempotent} \\ &= \overline{a} + \overline{a} \text{ -- Identity} \\ &= \overline{a} \text{ -- Idempotent} \end{align}


ii

a(a+b)+(b+aa)(a+b)\overline{a}(a + b) + (b + aa)(a + \overline{b})

$$ \begin{align} \overline{a}(a + b) + (b + aa)(a + \overline{b}) &= \overline{a}(a + b) + (b + a)(a + \overline{b}) \text{ -- Idempotent law} \ &= \overline{a}(a + b) + (a + b)(a + \overline{b}) \text{ -- Commutative law} \ &= (a + b) . (\overline{a} + (a + \overline{b})) \text{ -- Distributive law (factorise (a+b))} \ &= (a + b) . ((\overline{a} + a) + b) \text{ -- Associative law} \ &= (a + b) . (1 + \overline{b}) \text{ -- Complement law} \ &= (a + b) . 1 \text{ -- Tautology} \ &= (a + b) \text{ -- Identity}

\end{align} $$


b

Use the duality principle to find out the dual of the following equation:

ab+cd=(a+c)(a+d)(b+c)(b+d)ab + c\overline{d} = (a + c)(a + \overline{d})(b + c)(b + \overline{d})

Answer

The dual was determined using these steps:

  • changing each OR (+) sign to an AND (.) sign
  • changing each AND (.) sign to an OR (+) sign.
  • changing each 0 to 1 and each 1 to 0

(a+b).(c+d)=(a.c)+(a.d)+(b.c)+(b.d)(a + b) . (c + \overline{d}) = (a . c) + (a . \overline{d}) + (b . c) + (b . \overline{d})


c

The lights in a classroom are controlled by two switches: one at the back and one at the front of the room.

Moving either switch to the opposite position turns the light off if they were on and on if they were off.

Assume the lights have installed so that when both switches are in the down position, the lights are off. Let P and Q be the input to switches and R be the output (light on/off), design a circuit to control the switches and give its corresponding truth table.

The boolean expression that can represent the circuit is:

R=PQ+PQR = P\overline{Q} + \overline{P}Q

The truth table is:

P Q R
0 0 0
0 1 1
1 0 1
1 1 0

Circuit:

mid-term-assessment-circuit-q5


d

i

Fill in the K-map for the Boolean function

F(x,y,z)=x.y.z+x.y.z+x.y.z+x.y.zF(x, y, z) = \overline{x}.\overline{y}.\overline{z} + \overline{x} . \overline{y} . z + x . \overline{y} . \overline{z} + x . \overline{y} . z

xy 00 01 11 10
z --- --- --- ---
0 1 0 0 1
1 1 0 0 1

ii

Use the previous K-map and find a minimisation, as the sum of three terms, of the expression.

F(x,y,z)=xy+xyF(x, y, z) = \overline{x}\overline{y} + x\overline{y}