Logic Structures & Mathematical Reasoning

Topics covered here are as follows:

Logic

Definitions:
Logic is the study of the principles and methods that distinguish between a valid and an invalid argument.
Statement is a declarative sentence that is either true (T) or false (F) but not both. A statement is also referred to as a proposition.
Examples:

If a proposition is true, we say that it has a truth value of "True". If a proposition is false, its truth value is "falseQuot. The truth values "true" and "false" are, respectively, denoted by the letters T and F.

Examples:
AND, OR, NOT are called Logical Connectives.

Symbolic Representation

Statements are symbolically represented by letters such as P, p, q, r, s, T, . . .
Examples:
The table below shows the details of logic connectivity
Logic Connectivity

Examples

Truth Table

Truth table specifies the truth value of a compound proposition for all possible truth values of its constituent propositions.

Negation(~)

If p is a statement variable, then negation of p,"not p", is denoted as "~p".
It has opposite truth value from p i.e., if p is true, then ~p is false; if p is false, then ~p is true.

Truth Table for ~p
p ~p
T F
F T

Conjunction (∧)

Assume p and q are statements and the conjunction of p and q is "p and q", denoted as "p ∧q".
Note the following regarding the conjunction
The Truth Table for p∧q is illustrated below:

Truth Table for p∧q
p qp∧q
T T T
T F F
F T F
F F F

Disjunction (∨) or Inclusive OR

Assume p and q are statements and the disjunction of p and q is "p or q", denoted as "p ∨q".
Note the following regarding the disjunction
The Truth Table for p∨q is illustrated below:

Truth Table for p∨q
p qp∨q
T T T
T F T
F T T
F F F

Exclusive OR

When OR is used in its exclusive sense, the statement "p or q" mean "p or q but not both" or "p or q but not p and q" which translates into symbols as (p∨q) ∧ ~(p∧q). It is abbreviated as p⊕q or p XOR q. The Truth Table for p XOR q is illustrated below:

Truth Table for p⊕q
p qp⊕q
T T F
T F T
F T T
F F F

Conditional Statements

Consider the following statement: "If you get an A in Computer Science, then I will buy you your favorite phone." This statement is composed of two simpler statements:
p:"You will get an A in Computer Science"
q:"I will buy you your favorite phone."

The original statement is then saying:
if p is true, then q is true, or simply, if p, then q.
This can also be expressed as: p implies q. It is denoted by p → q.
p → q. is false when p is true and q is false; otherwise it is true.
In p → q., the statement p is called the hypothesis (or antecedent) and q is called the conlcusion (or consequent)
The Truth Table for p → q is illustrated below:

Truth Table for p → q
p qp→q
T T T
T F F
F T T
F F T

Biconditional

Assume p and q are statement variables, the biconditional of p and q is "p if and only if q".
it is denoted p ↔ q. "if and only if" is abbreviated as iff.
The symbol (double headed arrwo) "↔" is the biconditional operator.
Note the following regarding the biconditional
The Truth table for p ↔ q is illustrated below.

Truth Table for p↔q
p qp↔q
T T T
T F F
F T F
F F T

Logic and Bit Operations

Computer bit operations correspond to the logical connectives. By replacing true by a one and false by a zero in the truth tables for the operators ∧, ∨, and ⊕, the tables shown for the corresponding bit operations are obtained.
Throughout this lesson and in various programming languages, the following notations will be used: AND, OR, and XOR for the operators ∧, ∨, and ⊕.
Truth Value of Bit
Truth Value Bit
T 1
F 0


The table for the bit operators is shown below:
Bit Operators



Practice Exercise and Solution

Exercise 1:
Find the bitwise AND, bitwise OR, and bitwise XOR of the bit strings 01 1011 0110 and 11 0001 1101.
Please note that in this lesson, bit strings will be split into blocks of four bits to make them easier to read.

Solution:
The bitwise AND, bitwise OR, and bitwise XOR of these strings are obtained by taking the AND, OR, and XOR of the corresponding bits:

Logical equivalency

Definition:
If two logical expressions have the same logical values in the truth table, then these two expressions are logically equivalent.
For example, ~(~p) ≡ p and the Truth table is as under:

Truth Table for ~(~p)
p ~q~(~p)
T F T
F T F

Practice Exercise and Solution

Exercise 2:
Show (prove) that ~(p∧q) and ~p &8743 ~q are not logically equivalent
Solution:
Logical Equivalency Solution



Exercise 3:
Find the truth table for the below:
  1. ~p ∧ q
  2. ~p ∧ (q ∨ ~r)
  3. (p∨q) ∧ *#126(p∧q)


solutions:
Logical Equivalency Solution

Logical Equivalency Solution

Logical Equivalency Solution

Tautology

A tautology is a statement form that is always true regardless of the truth values of the statement variables. A tautology is represented by the symbol “t”. Example: The statement q ∨ ~q is a tautology and q ∨ ~q ≡ t. The truth table of this statement is as follows:

Truth Table for q ∨ ~q
q ~qq ∨ ~q
T F T
F T T

Contradiction

A contradiction is a statement form that is always false regardless of the truth values of the statement variables. A contradiction is represented by the symbol "c".
So if we have to prove that a given statement form is contradiction, we need to show the truth table for the statement form and if in the column of the given statement form all the entries are F, then we say that statement form is contradiction.
Let us see the following example: The statement form q ∧ ~ q is a contradiction.

Truth Table for q ∧ ~ q
q ~qq ∧ ~ q
T F F
F T F
Based on the last column, all the entries are F, hence it is a contradiction and it is noted as q ∧ ~ q ≡ c

Remarks

Logical Equivalence Invloving Tautology

Example: Show that r ∧ t ≡ r

Truth Table for r ∧ t
r tr ∧ t
T T T
F T F

Exercises

Exercise 4: Tautology
Use truth table to show that ( p ∧q ) ∨(~ p ∨( p ∧~q )) is a tautology.
Solution:
Tautology Solution

Exercise 5: Contradiction
Use truth table to show that (p ∧ ~q) ∧ (~p ∨q) is a contradiction.
Solution:
Contradiction Solution

Translation from English to Synbols

Let r = "It is cold", and s = "It is sunny"
SentenceSymbolic Form
It is not cold. ~r
It is cold and sunny. r ∧ s
It is cold or sunny. r ∨ s
It is not cold but sunny. ~r ∧ s
It is neither cold nor sunny. ~r ∧ ~s

Exercises and Solutions

Exercise 6:
Let p, q and r be the following propositions:

Question: Write the following propositions using p, q, and r and logical connectives.
  1. To get an A in this class it is necessary for you to get an A on the final exam. Solution: p → r
  2. You do exery in this textbook; You get an A on the final exam, implies, you get an A in this class. Solution: q ∧ p → r
  3. Getting an A on the final exam and doing every evercise in this textbook is sufficient for getting an A in this class. Solution: p ∧ q → r
Exercise 7:
Let p, q and r be the following propositions:

Question: Express the following propositions as an English sentence.
  1. p → q. Solution: If you have flu, then you will miss the final exam.
  2. ~q → r. Solution: If you don’t miss the final exam, you will pass the course.
  3. ~p ∧ ~q → r. Solution: If you neither have flu nor miss the final exam, then you will pass the course.

Application of Logic

NOT-Gate

A NOT-gate (or inverter) is a circuit with one input and one output signal. If the input signal is 1, the output signal is 0. Conversely, if the input signal is 0, then the output signal is 1.

Not Gate

AND-Gate

An AND-gate is a circuit with two input signals and one output signal. If both input signals are 1, the output signal is 1. Otherwise the output signal is 0. Symbolic representation & Input/Output Table is shown below. And Gate

OR-Gate

An OR-gate is a circuit with two input signals and one output signal. If both input signals are 0, then the output signal is 0. Otherwise, the output signal is 1. Symbolic representation & Input/Output Table is shown below. OR Gate

Combinatorial Circuit:

A Combinational Circuit is a compound circuit consisting of the basic logic gates such as NOT, AND, OR.
Combinatorial Circuit

Exercise and Solution

Determine the output for a given input:
Indicate the output of the circuit below when the input signals are P = 1, Q = 0 and R = 0. See the diagram below:

Combinatorial Circuit Question

Solution:
Combinatorial Circuit Answer

For more details, please contact me here.
Date of last modification: 2024