You are on page 1of 25

# Formal Logic

## The simplest variant of formal logic is the

propositional logic.
A proposition is a simple declarative
statement that is either true or false but
not both.
Discrete Mathematics
FORMAL LOGIC

Discrete Mathematics
1 2

Which of the following statements are Letters are used to denote propositions, in
called propositions? formal notation, the letters p, q, r, and s
1. Washington, D.C., is the capital of the (plus the letters subscripted with natural
United States of America. numbers, such as p1, q2, and r127) are
2. Toronto is the capital of Canada. called propositional letter. Propositional
3. 1 + 1 = 2.
letters are similar to Boolean (logical)
4. 2 + 2 = 3
variables. The truth value of a proposition
5. What time is it?
is true, denoted by T, if it is a true
proposition and false, denoted by F, if it is
7. X + 1 = 2
a false proposition.
8. X + y = z

## Discrete Mathematics Discrete Mathematics

3 4

1
Since the English Language is often Truth tables are especially valuable in the
ambiguous, and the meaning of the words determination of the truth values of
can vary from context to context, English propositions constructed from simpler
translations of the symbols applied in propositions.
propositional connectives cannot define
their meanings precisely. A precise
definition of each symbol used in
propositional connectives is given by a
truth table. Truth tables are used to
display the relationships between the
truth values of propositions.
Discrete Mathematics Discrete Mathematics
5 6

## Propositional Connectives Truth table for the negation of a proposition

Negation operator ()
The negation of a proposition (p) can P P P P

## also be considered as the result of the F T 0 1

operation of the negation operator on a T F 1 0
proposition. The negation operator
constructs a new proposition from an Logical truth table displays the
existing proposition. relationship using the binary bits 0 & 1,
It is commonly called the not operator. T(1) & F(0)

## Discrete Mathematics Discrete Mathematics

7 8

2
Example 1. What is the negation of the Conjuction operator ()
proposition p, if the proposition p denotes The conjunction of propositions is
today is Friday. commonly called the AND operator
denoted by p q (p and q). The
Example 2. What is the negation of the proposition is true when both p and q are
proposition p, if the proposition p denotes true and is false otherwise.
You are older than 16years old.

## Discrete Mathematics Discrete Mathematics

9 10

Truth table for the conjunction of Example 3. What is the conjunction of the
propositions (AND) propositions p q where p is the
proposition today is Friday and q is the
P Q PQ P Q PQ proposition it is raining today.
F F F 0 0 0
F T F 0 1 0 Example 4. What is the conjunction of the
T F F 1 0 0
propositions p q where p is the
T T T 1 1 1
proposition You are a computer science
major and q is the proposition You are a
freshman.

## Discrete Mathematics Discrete Mathematics

11 12

3
Disjunction operator () Truth table for the disjunction of
The disjunction of propositions is propositions (OR)
commonly called the OR operator
P Q PQ P Q PQ
denoted by p q (p or q). The proposition
F F F 0 0 0
is false when both p and q are both false F T T 0 1 1
and true otherwise. T F T 1 0 1
T T T 1 1 1

13 14

## The use of the connective or in a Exclusive Or ()

disjunction corresponds to one of the two The exclusive or (XOR) of propositions p
ways the word or is used in English, and q, denoted by p q, is the
namely, in an inclusive way. A disjunction proposition that is true when exactly one
is true when either of the two propositions of p and q is true and is false otherwise.
in it is true or when both are true. For The other way the word or is used in
instance, the inclusive or in a statement, English, in an exclusive way. For instance,
Students who have taken calculus or a statement says Soup or salad comes
computer science can take this class. with entre.

## Discrete Mathematics Discrete Mathematics

15 16

4
Truth table for the exclusive or of Conditional or Implication ()
propositions The implication p q is the proposition
that is false when p is true and q is false
P Q PQ P Q PQ
and true otherwise. In this implication p is
F F F 0 0 0
called the hypothesis (or antecedent or
F T T 0 1 1
T F T 1 0 1
premise) and q is called the conclusion (or
T T F 1 1 0
consequence).

17 18

## Implications usually arise in many places q when p

in mathematical reasoning, thus, a wide q whenever p
variety of terminology is used to express
a necessary condition for p is q
p q. Some of the common ways of
expressing this implication are: q follows from p
if p, then q a sufficient condition for q is p
p implies q
if p, q
p only if q
p is sufficient for q
q if p
q is necessary for p
Discrete Mathematics Discrete Mathematics
19 20

5
In mathematical reasoning implication is Truth table for the implication of
considered in a more general sort than in propositions
English. The mathematical concept of an
implication is independent of a cause-and- P Q PQ P Q PQ

## effect relationship between hypothesis F F T 0 0 1

F T T 0 1 1
and conclusion. The definition of an
T F F 1 0 0
implication specifies its truth values; it is T T T 1 1 1
not based on English usage.

## Discrete Mathematics Discrete Mathematics

21 22

There are some related implications that Example 5. The implication p q is denoted
can be formed from the implication p q. as If today is Thursday, then I have a test
The proposition q p is called the today.
converse of p q. Inverse of the implication (p q)

The inverse of the proposition p q is the If today is not Thursday, then I dont have a
test today.
proposition p q.
Converse of the implication (q p)
The contrapositive of p q is the
If I have a test today then today is
proposition q p.
Thursday.
Contrapositive of the implication (q p)
If I do not have a test today then today is not
Thursday.
Discrete Mathematics Discrete Mathematics
23 24

6
Biconditional or Equivalence () Truth table for the biconditional of
The biconditional p q is the proposition propositions
that is true when p and q have the same
truth values and is false otherwise. P Q PQ P Q PQ
Note that the biconditional p q is F F T 0 0 1
precisely true when both the implications F T F 0 1 0
p q and q p are true. Due to this, the T F F 1 0 0
terminology p if and only if q is used for T T T 1 1 1
this biconditional. Other common ways of
expressing the proposition p q are: p
is necessary and sufficient for q and if p
then q, conversely.

## Discrete Mathematics Discrete Mathematics

25 26

Example 6. Let proposition p denotes Tom Example 7. Translate the following English
eats herbed halibut and q denotes sentence into a propositional/logical
Kathie eats key lime pie interpret the expression.
following connectives in English You cannot ride the roller coaster if you are
statement: under 4 feet tall unless you are older than 16
a. p
years old.
b. p q
Example 8. Translate the following English
c. p q
sentence into a propositional/logical
d. p q expression.
e. (p) (q) You can access the internet from campus
f. P (q) only if you are a computer science major or
you are not a freshman.
Discrete Mathematics Discrete Mathematics
27 28

7
Logic and bit operations Computer bit operations correspond to the
A bit can be used to represent a truth logical connectives. By replacing true by 1
value, since there are two truth values and false by 0 in the truth tables for the
namely true and false. As is customarily operators (OR), (AND) and (XOR)
done, the bit value 1 is used to represent for the corresponding bit operations are
true and a bit 0 to represent false. A obtained. Information is often represented
variable called Boolean variable if its value using bit strings, which are sequences of
is either true or false. zeroes and ones.

29 30

## Bit Operations Example 9. Find the bitwise OR, and bitwise

A bit string is a sequence of zero or more AND of the bit strings 0110110110 and
bits. The length of this string is the 1100011101.
number of bits in the string. Bit operation
on strings can only be performed on
strings having the same length (equal
number of bits in a string) and its result is
also a bit string of the same length. The
same propositional connective symbols
are used in bit operation like , and to
represent the bitwise AND, bitwise OR and
bitwise XOR.

## Discrete Mathematics Discrete Mathematics

31 32

8
Logic Gates In describing computer circuits, a
At the basic level, computer memory has specialized notation for propositional logic
two states, which are identified as the two is used. Special physical devices, called
logical values or Boolean values of T and gates, implement the AND (), OR () and
F. Computer operations are thought of as NOT/Negation () operations. A set of
being composed of operations on these gates to represent a circuit is called
Boolean values and hence, as operations combinational circuit or combinatorial
of propositional logic. network.

33 34

## Logic gates Logic gates

NOT gate AND gate NOR gate NAND gate

## Discrete Mathematics Discrete Mathematics

35 36

9
Truth table for the NOR Gate Truth table for the NAND Gate
P Q (P Q) P Q (P Q)
F F T F F T
F T F F T T
T F F T F T
T T F
T T F

P Q (P Q) P Q (P Q)
0 0 1 0 0 1
0 1 0 0 1 1
1 0 0 1 0 1
1 1 0 1 1 0

37 38

## Truth Table for the XNOR Gate Combinatorial Circuit

P Q (P Q) A set of gates used to represent certain
F F T propositional logic is called a
F T F
combinatorial circuit or network. The
gates represent an operation and the
T F F
wires going through are the operands.
T T T
Using the logic gates, a combinatorial
P Q (P Q) circuit is, roughly the analogue of a
0 0 1 formula. The Boolean circuit
0 1 0 (combinatorial circuit) for the formula,
1 0 0
1 1 1

## Discrete Mathematics Discrete Mathematics

39 40

10
Combinatorial Circuit Combinatorial Circuit

41 42

## Logic Gate IC Example: Obtain the operating function

(using a truth table) of a light bulb that is
controlled by two switches.

## Discrete Mathematics Discrete Mathematics

43 44

11
Tree They are useful in constructing networks
It is a connected undirected graph that with the least expensive set of telephone
contains no simple circuit. Since a tree lines linking distributed computers. Trees
cannot have a simple circuit, a tree can be used to construct efficient codes
cannot contain multiple edges or loops. for storing and transmitting data. Trees
Therefore any tree must be a simple can model procedures that are carried out
graph. Trees are particularly useful in using a sequence of decisions. This makes
computer science. It is often used to trees valuable in the study of sorting
construct efficient algorithm for locating algorithms.
items in the list.

45 46

## Tree Trees are often defined as undirected

graphs with the property that there is a
unique simple path between every pair of
vertices. In many applications of trees a
particular vertex of a tree is designated as
the root.

## Discrete Mathematics Discrete Mathematics

47 48

12
Example of trees Expression Tree
a It is a simple visual representation for
the way that a formula is built from
propositions and logical operators. A
proposition is represented by a single
node.
b c d
Representation for proposition p

e f g p

49 50

## For an expression involving two Expression trees

propositions and a logical operator, the
propositions are represented as nodes at (pq) r
the same level, then at a higher level, a
node represents the result of applying the
operator to the two propositions. The
(pq) r
nodes representing the propositions and
the node representing the result of the
operation are joined by lines. p q
p q
pq (pq) r

## Discrete Mathematics Discrete Mathematics

51 52

13
Expression tree Example 10. Determine the expression tree
for the following propositions and its truth
table.
a. (p q) r
b. p (q r)
c. ((p q) r) p
d. (q r) (p (q r))
e. p (p q)
f. ((p q) (p q)) ((p q) (p
q))
g. (((p q)) ((q r))) (((p
((s)))) (((r s) (q))))
Discrete Mathematics Discrete Mathematics
53 54

## Example 11. Determine the combinatorial Propositional equivalence

circuit with its truth table and expression tree It is the type of step commonly used in
representing the following propositions. mathematical argument. The technique
a. ((p q) p) r replaces the statement with another
b. p (q r) statement having the same truth value.
c. p (q r)
Because of this, methods that produce
propositions with the same truth value as
d. (p q) (p r)
a given compound proposition are used
e. (p (p q))
extensively in the construction of
f. (((((p)) (q)) r) ((((q)) (r)) mathematical arguments.
s))
g. (p q r) (p q s) (p r s)
(p q s) (p q s)
Discrete Mathematics Discrete Mathematics
55 56

14
In logic, a tautology is a formula which is In classical logic, a contradiction is the
true in every possible interpretation. a exact opposite of a tautology. It consists
tautology is a formula whose negation is of a logical incompatibility between two or
unsatisfiable. Meaning, it is a compound more propositions. It occurs when the
proposition that is always true, no matter propositions, taken together, yield two
what the truth values of the propositions conclusions which form the logical, usually
that occur in it. Unsatisfiable statements opposite inversions of each other.
are also known, formally, as
is always false).
Discrete Mathematics Discrete Mathematics
57 58

## Contingent In philosophy and logic, contingency is

A formula that is neither a tautology nor a the status of propositions that are neither
contradiction is said to be logically true under every possible valuation (i.e.
contingent. Such a formula can be made tautologies) nor false under every
either true or false based on the values possible valuation (i.e. contradictions). A
assigned to its propositional variables. contingent proposition is neither
The double turnstile notation is used to necessarily true nor necessarily false.
indicate that S is a tautology. The tee Propositions that are contingent may be
symbol is sometimes used to denote an so because they contain logical
arbitrary tautology, with the dual symbol connectives which, along with the truth
(falsum) representing an arbitrary value of any of its atomic parts, determine
contradiction. the truth value of the proposition.

## Discrete Mathematics Discrete Mathematics

59 60

15
The definition of tautology can be Verifying tautologies
extended to sentences in predicate logic, The problem of determining whether a
which may contain quantifiers, unlike formula is a tautology is fundamental in
sentences of propositional logic. In propositional logic. If there are n variables
propositional logic, there is no distinction occurring in a formula then there are 2n
between a tautology and a logically valid distinct valuations for the formula.
formula. Therefore the task of determining whether
or not the formula is a tautology is a
finite, mechanical one: one need only
evaluate the truth value of the formula
under each of its possible valuations.
Discrete Mathematics Discrete Mathematics
61 62

One algorithmic method for verifying that Truth table for the compound proposition
every valuation causes this sentence to be (p q) p
true is to make a truth table that includes
every possible valuation. P Q PQ (P Q) P

p p F T F T
T F F T
P P P P
T T T T
F T T

T F T

## Discrete Mathematics Discrete Mathematics

63 64

16
Contradiction Truth table for the compound proposition
Truth table for the compound proposition (p (p q))
p p
P Q PQ P ( P Q) (P ( P Q))
F F F T F
P P P P
F T T T F
F T F
T F T T F
T F F
T T T T F

65 66

## Example of a Contingency Logical Equivalence

Truth table for the compound proposition Logical equivalence means that 2 different
(p q) compound propositions have the same
truth values in all possible cases. The
P Q PQ (P Q)
propositions p and q are considered
F F F T
F T T F
logically equivalent if p q is a tautology.
T F T F The notation p q denotes that p and q
T T T F are logically equivalent.
Example of logically equivalent compound
propositions

## Discrete Mathematics Discrete Mathematics

67 68

17
Example of a Logical Equivalence Table of Logical Equivalence
Truth table for the compound proposition Equivalence Name
(p q) and p q pTp Identity Laws
pFp
pTT Domination Laws
P Q P Q (PQ) P Q PQ pFF
F F F T T T T ppp Idempotent laws
ppp
F T T F T F F
p p Law of the excluded middle
T F T F F T F
(p p)
T T T F F F F (p) p Double negation law
(p (p q)) q Modus Ponens
((p q) p) q Modus Tolledo Ponens

69 70

## Equivalence Name Equivalence Name

((p q) (q r)) (p r) Law of Syllogism (p r) (r p) Contrapositive
pqqp Commutative laws (p (r q)) ((p r) q)
pqqp ((p r) (p r) p Contradiction
(p q) r p (q r) Associative laws ((p r) r) r Absorption Law
(p q) r p (q r) ((p r) r) r
p (q r) (p q) (q r) Distributive laws (p q) ((p q) (p q))
p (q r) (p q) (q r)
(p q) ((p q) (p q))
(p q) p q De Morgans laws (p F) (p)
(p q) p q

## Discrete Mathematics Discrete Mathematics

71 72

18
Prove that (p (p q)) p q Since (p p) F
(by the 2nd De Morgan Law) (p (p q)) F (p q)
(p (p q)) p (p q) By commutative law for disjunction
(by the 1st De Morgan Law) (p (p q)) (p q) F
(p (p q)) p [(p) q) By the identity law for F
(by the double negation law) (p (p q)) p q
(p (p q)) p (p q)
(by the 2nd distributive law)
(p (p q)) (p p) (p q)

73 74

## Predicates A given group of predicates is often

A property or relationship between objects referred to as formulas. M(x, y), Q(x, y, z)
is called a predicate. A description of a and P(x) are referred to as atomic
predicate in logic is called a formula. A formula. From the given statement P(x) in
formula is a statement that is neither true example 1, the first part containing the
nor false. The following are examples of variable x is called the subject of the
predicates: statement. The second part is greater
a. P(x) denotes x > 3 than 3 is called the predicate since it
b. M(x, y) denotes x = y + 3 refers to a property that the subject of the
c. Q(x, y, z) denotes x + y = z
statement can have. The statement P(x)
is also said to be the value of the
propositional function P at x.

## Discrete Mathematics Discrete Mathematics

75 76

19
Once a value is assigned to the variable x, Statement may also involve more than
the statement P(x) becomes a proposition one variable as seen from the given
and has a truth value. statement in M(x, y) in example 2 of the
sample of predicates, the statement
Example 1. Let P(x) denote the statement
denoted by M(x, y) where x and y are
x > 3. What are the truth values of the variables and M is the predicate. When
propositions P(4) and P(2)? values are assigned to x and y, the
statement M(x, y) has a truth value.
Example 2. Let M(x, y) denote the
statement x = y + 3. What are the truth
values of the propositions M(1, 2) and
M(3, 0)?

77 78

## Similarly, the predicate Q(x, y, z) from In general, statements involving the n

sample 3 denoting the statement x + y = variables x1, x2, x3,, xn can be denoted
z. When values are assigned to the by P(x1, x2, x3,, xn).
variables x, y, z, this statement has a
truth value. A statement in the form P(x1, x2, x3,, xn)
Example 3. Let Q(x, y, z) denote the is the value of the propositional P at the
statement x + y = z. What are the truth n-tuple (x1, x2, x3, , xn), and P is also
values of the proposition Q(1, 2, 3) and called a predicate.
Q(0, 2, 1)?

## Discrete Mathematics Discrete Mathematics

79 80

20
Quantifiers The universal quantification states that
A Quantifier is a created proposition from the proposition P(x) is true for all values
a propositional function. The two types of of x in the particular domain called the
quantifiers are called the universal universe of discourse, given by the
quantification and the existential notation symbol (universal quantifier).
quantification. The universe of discourse specifies the
Universal Quantifier possible values of the variable x. The
Many mathematical statements assert notation x P(x) is expressed as
that a property is true for all values of a o for all x, P(x)
variable in a particular domain. o for every x, P(x)

## Discrete Mathematics Discrete Mathematics

81 82

When all the elements of the universe of Example 4. Let P(x) be the statement x +
discourse can be listed (i.e. x1, x2, x3,, 1 > x. What is the truth value of
xn) then it follows that the universal quantification x P(x), where the universe
quantification x P(x) is the same as the of discourse is the set of real numbers?
conjunction.
Example 5. Let Q(x) be the statement x <
P(x1) P(x2) P(x3) P(xn) 2. What is the truth of the value of
quantification x Q(x), where the universe
Since this conjunction is true if and only if of discourse is the set of real numbers?
P(x1), P(x2), P(x3),, P(xn) are all true.

## Discrete Mathematics Discrete Mathematics

83 84

21
Existential Quantifier The notation x P(x) is also expressed as
Many mathematical statements assert o there is an x such that P(x)
that there is an element with a certain o there is at least one x such that P(x),
property. The existential quantification of o for some x P(x)
P(x) is the proposition there exist an
element x in the universe of discourse
such that P(x) is true, given by the
notation symbol (existential quantifier).

## Discrete Mathematics Discrete Mathematics

85 86

When all the elements of the universe of Example 6. Let P(x) denote the statement x >
discourse can be listed (i.e. x1, x2, x3,, 3. Write down the quantifier satisfying the
xn) then it follows that the existential statement.
quantification x P(x) is the same as the If P(x) is true where the universe of
disjunction. discourse is the set of real numbers.
Example 7. Let P(x) x + 1 = x. Express the
truth value of the quantification x P(x),
P(x1) P(x2) P(x3) P(xn) where the universe of discourse is the set of
real numbers.
Since this disjunction is true if and only if Example 8. Let P(x) denote x2 10. Express
at least one of P(x1), P(x2), P(x3),, P(xn) the truth value of the quantification x P(x)
is true. and the universe of discourse consists of the
positive integers not greater than 4?
Discrete Mathematics Discrete Mathematics
87 88

22
Quantification with conjunction and When a quantifier is used on the variable
disjunction x or when a value is assigned to this
variable then the occurrence of this
Formula Translation
variable is bound. An occurrence of a
x (P(x) Q(x)) For some particular choice of x, both P(x) and variable that is not bound by a quantifier
Q(x) are true.
or set equal to a particular value is said to
x (P(x) Q(x)) For every choice of x, both P(x) and Q(x) are be free. All the variables that occur in a
true. propositional function must be bound to
x (P(x) Q(x)) For some particular choice of x, P(x) or Q(x) turn into a proposition. This can be done
or both are true.
using a combination of universal
x (P(x) Q(x)) For every choice of x, both P(x) or Q(x) or quantifiers, existential quantifiers and
both are true.
value assignments.

89 90

## Table of Logical Relations for Quantified Many mathematical statements involve

Formulas multiple quantifications of propositional
functions involving more than 1 variable.
Quantified Formula for 1 variable It is important to note that the order of
x (P(x) Q(x)) (x P(x)) (x Q(x)) the quantifiers is important, unless all the
x (P(x) Q(x)) (x P(x)) (x Q(x)) quantifiers are all universal quantifiers or
x (P(x) Q(x)) (x P(x)) (x Q(x)) all are existential quantifiers. These
(x P(x)) (x Q(x)) x (P(x) Q(x))
quantifiers are usually classified as nested
quantifiers.

## Discrete Mathematics Discrete Mathematics

91 92

23
Table of quantifiers for 2 variables Ex. Translate the statement Every student
in this class has studied calculus.
Formula Translation
Let the proposition S(x) denote x is in
xy P(x, y) P(x, y) is true for every pair x, y.
yx P(x, y) P(x, y) is true for every pair x, y. this class.
xy P(x, y) For every x there is a y for which P(x, y) is Let the proposition P(x) denote x has
true.
studied calculus.
xy P(x, y) There is an x for which P(x, y) is true for
every y.
xy P(x, y) There is a pair x, y for which P(x, y) is
true.
yx P(x, y) There is a pair x, y for which P(x, y) is
true.

## Discrete Mathematics Discrete Mathematics

93 94

Example 9. Translate the given statement Example 10. Assume that the universe of
into English expression. discourse for the variables x and y is the
x (C(x) y (C(y) F(x,y))) set of all real numbers. Express the truth
Let C(x) denotes x has a computer. value of the statement & prove that xy
F(x, y) denotes x and y are friends and the (x+y = y+x)
universe of discourse for both x and y is
Example 11. Assume that the universe of
the set of all students in school.
discourse for the variables x and y is the
Translation:
set of all real numbers. Express the truth
The statement says that for every student
x in the school, x has a computer or there value of the statement and prove that
is a student y such that y has a computer xy (x+y = 0)
and x and y are friends.
Discrete Mathematics Discrete Mathematics
95 96

24
Example 12. Assume that the universe of
discourse for the variables x and y is the
set of integers. Using the proposition P(x,
y) that denotes x + y = 17. Confirm the
truth value and prove the following
statements by citing examples for,
a. xy (P(x, y)) is true.
b. yx (P(x, y)) is false.

Discrete Mathematics
97

25