First Order Logic
First Order Logic
First Order Logic
Propositional Logic
A proposition is a declarative sentence (a
sentence that declares a fact) that is either
true or false, but not both.
Are the following sentences propositions?
(Yes)
Propositional Variables
Propositional Variables variables that
represent propositions: p, q, r, s
E.g. Proposition p Today is Friday.
Truth values T, F
Negation
DEFINITION 1
Let p be a proposition. The negation of p, denoted by p, is the
statement
It is not the case that p.
The proposition p is read not p. The truth value of the negation of
p, p is the opposite of the truth value of p.
Examples
Truth Table
Truth table:
T
F
F
T
Conjunction
DEFINITION 2
Let p and q be propositions. The conjunction of p and q, denoted
by p q, is the proposition p and q. The conjunction p q is true
when both p and q are true and is false otherwise.
Examples
Disjunction
DEFINITION 3
Let p and q be propositions. The disjunction of p and q, denoted by
p q, is the proposition p or q. The conjunction p q is false
when both p and q are false and is true otherwise.
Note:
E.g. Students who have taken calculus or computer science can take
this class. those who take one or both classes.
proposition is true.
E.g. Students who have taken calculus or computer science, but not
both, can take this class. only those who take one of them.
Exclusive
DEFINITION 4
Let p and q be propositions. The exclusive or of p and q, denoted by
p q, is the proposition that is true when exactly one of p and q is true
and is false otherwise.
p
T
T
F
F
pq
T
F
T
F
T
F
F
F
T
T
F
F
q
T
F
T
F
pq
pq
T
T
T
F
T
T
F
F
T
F
T
F
F
T
T
F
8
Conditional Statements
DEFINITION 5
Let p and q be propositions. The conditional statement p q, is the
proposition if p, then q. The conditional statement is false when p is
true and q is false, and true otherwise. In the conditional statement p
T
F
F
T
T
T
F
F
pq
|T
|T
|T
|F
9
11
Biconditional Statement
DEFINITION 6
Let p and q be propositions. The biconditional statement p q is
the proposition p if and only if q. The biconditional statement p
q is true when p and q have the same truth values, and is false
otherwise. Biconditional statements are also called bi-implications.
Let p be the statement You can take the flight and let q
be the statement You buy a ticket. Then p q is the
statement
You can take the flight if and only if you buy a ticket.
Implication:
If you buy a ticket you can take the flight.
If you dont buy a ticket you cannot take the flight.
12
q
T
F
T
F
p q
T
F
F
T
13
q) (p q).
p q
pq
(p q) (p q)
T
T
F
F
T
F
T
F
F
T
F
T
T
T
F
T
T
F
F
F
T
F
T
F
14
E.g. p q = (p ) q
Operator
Precedence
p q r = (p q ) r
p q r = p (q r)
2
3
4
5
15
s) q.
16
a (c f).
17
xy
xy
0
0
1
1
0
1
0
1
0
1
1
1
0
0
0
1
0
1
1
0
18
Example: Find the bitwise OR, bitwise AND, and bitwise XOR of
the bit string 01 1011 0110 and 11 0001 1101.
Solution:
01 1011 0110
11 0001 1101
------------------11 1011 1111 bitwise OR
01 0001 0100 bitwise AND
10 1010 1011 bitwise XOR
19
Propositional Equivalences
DEFINITION 1
A compound proposition that is always true, no matter what the
truth values of the propositions that occurs in it, is called a
tautology. A compound proposition that is always false is called a
contradiction. A compound proposition that is neither a tautology
or a contradiction is called a contingency.
p p
p p
T
F
F
T
T
T
F
F
20
Logical Equivalences
DEFINITION 2
The compound propositions p and q are called logically equivalent if p
q is a tautology. The notation p q denotes that p and q are
logically equivalent.
p q
pq
T
T
F
F
T
F
T
F
F
F
T
T
T
F
T
T
T
F
T
T
21
Logical Equivalence
Two statements have the same truth table
De Morgans Law
De Morgans Law
TT
T
Note: The above examples can also be done using truth tables.
23
Predicates
Statements involving variables are neither
true nor false.
E.g. x > 3, x = y + 3, x + y = z
x is greater than 3
x: subject of the statement
is greater than 3: the predicate
Predicates
Example: Let P(x) denote the statement x >
3. What are the truth values of P(4) and
P(2)?
Solution: P(4) 4 > 3, true
P(3) 2 > 3, false
26
Predicates
Example: Let A(c,n) denote the statement Computer c is
connected to network n, where c is a variable
representing a computer and n is a variable representing
a network. Suppose that the computer MATH1 is
connected to network CAMPUS2, but not to network
CAMPUS1. What are the values of A(MATH1, CAMPUS1)
and A(MATH1, CAMPUS2)?
Solution: A(MATH1, CAMPUS1) MATH1 is connect to CAMPUS1, false
A(MATH1, CAMPUS2) MATH1 is connect to CAMPUS2, true
27
28
Quantifiers
Quantification: express the extent to
which a predicate is true over a range
of elements.
Universal quantification: a predicate is
true for every element under
consideration
Existential quantification: a predicate
is true for one or more element under
consideration
A domain must be specified.
29
Universal Quantifier
The universal quantification of P(x) is the statement
P(x) for all values of x in the domain.
The notation xP(x) denotes the universal quantification of P(x). Here is
called the Universal Quantifier. We read xP(x) as for all xP(x) or for
of xP(x).
30
Universal Quantification
A statement xP(x) is false, if and only if P(x) is not
always true where x is in the domain. One way to show
31
Universal Quantifier
Example: What does the statement xN(x)
mean if N(x) is Computer x is connected to the
network and the domain consists of all
computers on campus?
Solution: Every computer on campus is connected to the
network.
32
Existential Quantification
DEFINITION 2
33
Existential Quantification
Example: Let P(x) denote the statement x > 3. What
Existential Quantification
If the domain is empty, xQ(x) is false because there
can be no element in the domain for which Q(x) is true.
The existential quantification xP(x) is the same as
the disjunction P(x1) V P(x2) V VP(xn)
Quantifiers
Statement When True?
When False?
xP(x)
xP(x)
35
Uniqueness Quantifier
Uniqueness quantifier ! or 1
true.
36
Precedence of Quantifiers
Precedence of Quantifiers
and have higher precedence than all logical operators.
E.g. xP(x) V Q(x) is the same as ( xP(x)) V Q(x)
37
Solution:
If the domain consists of students in the class
xC(x)
where C(x) is the statement x has studied calculus.
If the domain consists of all people
x(S(x) C(x)
where S(x) represents that person x is in this class.
If we are interested in the backgrounds of people in subjects
besides calculus, we can use the two-variable quantifier Q(x,y)
for the statement student x has studies subject y. Then we
38
would replace C(x) by Q(x, calculus) to obtain xQ(x, calculus)
or
x(S(x) Q(x, calculus))