Chapter2 Logic: by Engineer Mike
Chapter2 Logic: by Engineer Mike
By Engineer Mike
2.1 Propositional logic
This logic is easiest to work with, but also has limited expressive power.
It powers a number of applications, for instance the digital logic in chip
design.
This takes propositions and considers how they can be combined and
manipulated.
It finds it’s application in the design of the electric circuits that makes up
computers.
They tire closely to the digital and the Boolean logics.
2.1.1 Prepositions
This is a statement which is either true or false.
The lower case letters such as p, q, and r are used to represent
propositions.
Such letters are called Prepositional variable.
For the rest of this discussion and class we will be using the letters p, q,
and r as our prepositional variables and they can either be true or false.
NB: the prepositional variables are like variables in any programming
language such as java where something like int x can take any integer
value
2.1.2 Logical operators
The logical positions are combined with the logical operators or the logical
connectives.
They are represented by words such as ‘and’,‘or’,and ‘not’ in English.
The logical operators corresponding to the English words are as:
‘and’ corresponds to ∧
‘or’ corresponds to ∨
‘not’ corresponds to ¬
Definition2.1
Let p and q be propositions. Then p ∨ q, p ∧ q, and ¬p are propositions, whose
truth values are given by the rules:
• p ∧ q is true when both p is true and q is true, and in no other case,
• p ∨ q is true when either p is true, or q is true, or both p and q are true, and in no other
case
• ¬p is true when p is false, and in no other case
Simply put the operators
• ∧ referred to as conjunction (and)
• ∨ referred to as disjunction (or)
• ¬ referred to as negation (not)
Note:
p ∧ q is read as ‘p and q’, p ∨ q is read as ‘p or q’, and ¬p is read as ‘not p’
2.1.3 Precedence rules
Logic operators like any mathematical operators can be used in more
complicated expression such as p∧¬q or (p∨ q)∧(q∨r).
compound proposition is a proposition made up of simpler propositions and
logical operators.
parentheses can be used in compound expressions to indicate the order in
which the operators are to be evaluated just like in normal mathematics.
In absence of parentheses, the order of evaluation is determined by
precedence rules.
The ¬ has higher precedence than ∧, and ∧ has precedence over ∨ meaning
in the absence of parentheses, any ¬ operators are evaluated first, followed
by any ∧ operators, followed by any ∨ operators.
Example:
i. The expression ¬p∨q∧r is equivalent to the expression (¬p) ∨(q ∧r)
ii. Also the expression p∨q∧q∨r is equivalent to p ∨(q ∧q)∨r.
2.1.4 Logical equivalence
Suppose we want to verify that, in fact, (p∧q) ∧r and p∧(q∧r) do always have the same
value.
To do so, we have to consider all possible combinations of values of p, q, and r, and
This is done by checking for all such combinations, the two compound expressions do
indeed have the same value.
It is convenient to organize this computation into a truth table.
A truth table is a table that shows the value of one or more compound propositions for
each possible combination of values of the propositional variables that they contain
Simply it is:
A truth table is a diagram with rows and columns showing how the true or the falsity
of a proposition varies with that of its component.
We call each such combination a situation
A truth Table example
Fig 2.1 explanation
The figure 2.1 is a truth table that compares the value of (p∧q)∧r to the
value of p∧(q∧r) for all possible values of p, q, and r.
There are eight rows in the table because there are exactly eight different
ways in which truth values can be assigned to p, q, and r.
In this table, we see that the last two columns, representing the values
of(p∧q)∧r and p∧(q∧r),are identical.
2.1.5 More logical operaters
There are other logical operators besides ∧,∨,and¬. We will consider
the conditional operator,→,
The biconditional operator,↔,
The exclusive or operator,⊕.
These operators can be completely defined by a truth table that shows their
values for the four possible combinations of truth values of p and q.
Definition2.2.
For any propositions p and q, we define the propositions p → q, p ↔ q, and
p⊕q according to the truth table as shown bellow:
Precedence Rules
The exclusive or operator, ⊕, has the same precedence as ∨ (or).
The conditional operator, →, has lower precedence than ∧ (and), ∨, ¬, and
⊕, therefore we evaluated after them.
Finally, the biconditional operator,↔, has the lowest precedence and is
therefore evaluated last.
For example, the expression p→ q∧r ↔¬p⊕s is evaluated as if it were
written(p→ (q∧r)) ↔ ((¬p)⊕s).
But again you should always include the parentheses!
2.1.6 Implications in English
The fact that all entries in the last column are true tells us that this
expression is a tautology
Note that for any compound proposition P, P is a tautology if and only if ¬P is
contradiction
Definition 2.4: Cont.