Professional Documents
Culture Documents
NOT:
OR:
: BB B
AND:
: BB B
IMPLIES:
: B B B
EQUIVALENT:
: B B B
p q
T T
T F
F T
F F
p pq pq pq pq pq
F
T
T
T
T
T
F
T
F
F
F
F
T
T
F
T
F
T
T
F
F
T
T
F
Logical equivalence
Two expressions are equivalent if they have the same truth table.
Example: Use truth tables to show that p q p q
Equivalence between operations defined on boolean variables and set operations
Let A, B be two subsets of universe U and p and q be defined as
p( x ) is true if and only if x A
q( x ) is true if and only if x B
p( x ) is true if and only if x Ac = { A = A = U \ A.
p q( x ) is true if and only if x A B.
p q( x ) is true if and only if x A B.
Definitions:
Sentence: statement that takes a value true or false.
Proposition: sentence with no variables.
Predicate: sentence which contains variables.
Special predicates:
Tautology: always true
Contradiction: always false
Ovidiu Bagdasar
Page 1 of 4
( p q) p q
( p q) p q
Distributive Law
p (q r ) ( p q) ( p r )
p (q r ) ( p q) ( p r )
Associative Law
p (q r ) ( p q) ( p r )
p (q r ) ( p q) ( p r )
Observation: Applying to an expression has the following effect:
p becomes p (and of course, p becomes p)
becomes , becomes
Example: ( p (q r )) p ( p r ).
Quantifiers and their negation
universal quantifier:
(for all)
Example: x N[ x + 3 2]
existential quantifier:
(there exists)
Example: x N[ x + 3 > 4]
By negation becomes (the proposition negates): ( x [ p( x )]) x [ p( x )]
Example: ( x N[ x + 3 2]) x N[ x + 3 < 2]
By negation becomes (the proposition negates): ( x [ p( x )]) x [ p( x )]
Example: ( x N[ x 2 > 4]) x N[ x 2 4]
Ovidiu Bagdasar
Page 2 of 4
x = 4
x = +4
r:
x2 = 16
( a) p r;
( f ) q r;
E 4.4. Decide which of the sentences below, are universally true, which are universally false,
and which are neither. Then write the predicates below in symbolic form:
(i) ( x + 3)2 > 8, x N;
(ii) 2x = 9, x N.
E 4.5. Check (using truth tables) which statements are logically equivalent
(i) ( a b) b and a b
(ii) ( a b) a and a
(iii) ( a b c) (( a b) c) and b c
(iv) a b and b a.
E 4.6. Below, y is a variable of type Nat, c is of type Ehar and s and t are of type Str. Represent the following conditions formally, using only standard functions of the data types Nat,
Ehar, Str and , , , , .
(i) y is either less than 3, or greater than 6 but less than 10. y is not seven.
(ii) The first character of s is b and the second character of s is a.
(iii) If s starts with c then t starts with c.
(iv) s and t have similar starting characters, but their second characters are distinct.
(v) c is an upper case vowel, and the first two characters of t are the same if and only if the
first two characters of s are the same.
(vi) s is the string fred or y has the value 16, but not both.
E 4.7. Use quantifiers to express formally the following predicates:
(i) There is a natural number whose square is greater than 7
(ii) Whatever real number x, x2 = ( x2 + 1) is false.
Ovidiu Bagdasar
Page 3 of 4
Ovidiu Bagdasar
Page 4 of 4