ICS 253-01 Logic & Sets (An Overview) Week 1
description
Transcript of ICS 253-01 Logic & Sets (An Overview) Week 1
2/17/2008 Sultan Almuhammadi 1
ICS 253-01
Logic & Sets(An Overview)
Week 1
2/17/2008 Sultan Almuhammadi 2
Keywords (1):
Proposition ConjunctionDisjunctionNegation Compound propositionTruth TableLogically equivalence
2/17/2008 Sultan Almuhammadi 3
Getting started Proposition:
true/false statement cannot be both at the same time e.g. Today is Monday
Conjunction: (and) p ^ q
Disjunction: (or) p v q
Negation: (not) ~p
2/17/2008 Sultan Almuhammadi 4
Example:
p ^ q is a “compound” proposition (logical expression)
The value of this proposition (expression) depends on the values of p and q.
2/17/2008 Sultan Almuhammadi 5
Truth table: p ^ q
p q p ^ q
T T T
T F F
F T F
F F F
2/17/2008 Sultan Almuhammadi 6
Truth table: p v q
p q p v q
T T T
T F T
F T T
F F F
2/17/2008 Sultan Almuhammadi 7
Keywords (2)
Conditional proposition:
if p then q p q
Biconditional proposition: p if and only if q
p q
2/17/2008 Sultan Almuhammadi 8
Keywords (2)Conditional proposition: if p then q (read: p implies q )
p q
Biconditional proposition: p if and only if q
(write: p iff q for short)
p q
2/17/2008 Sultan Almuhammadi 9
Keywords (2)Conditional proposition: if p then q (read: p implies q )
p q
Biconditional proposition: p if and only if q
(write: p iff q for short)
p q
p -> q
p <--> q
2/17/2008 Sultan Almuhammadi 10
Truth Tables: if_then and iff
p q p -> q p <-> q
T T T T
T F F F
F T T F
F F T T
2/17/2008 Sultan Almuhammadi 11
Truth Tables (Example)
p q ~p ~p v q p -> q
T T ?
T F ?
F T ?
F F ?
2/17/2008 Sultan Almuhammadi 12
Truth Tables
p q ~p ~p v q p -> q
T T F ?
T F F ?
F T T ?
F F T ?
2/17/2008 Sultan Almuhammadi 13
Truth Tables
p q ~p ~p v q p -> q
T T F T ?
T F F F ?
F T T T ?
F F T T ?
2/17/2008 Sultan Almuhammadi 14
Truth Tables
p q ~p ~p v q p -> q
T T F T T
T F F F F
F T T T T
F F T T T
2/17/2008 Sultan Almuhammadi 15
Truth Tables
p q ~p ~p v q p -> q
T T F T T
T F F F F
F T T T T
F F T T T
Logically equivalent
(~p v q) = (p -> q)
2/17/2008 Sultan Almuhammadi 16
Exer 1. (p -> q) = (~p v q) If it is Wednesday, John has
discussion. It is not Wed, or John has discussion.
If you don’t study hard, you will fail. Study hard or you fail.
I have a meeting on Friday. I have a meeting today, or it is not
Friday.
2/17/2008 Sultan Almuhammadi 17
Logical Equivalence: p q (p -> q ) (~p v q ) ~( p v q ) ~p ^ ~q [De Morgan’s] ~( p ^ q ) ~p v ~q [De Morgan’s] (p <--> q) (p -> q) ^ (q -> p) (p <--> q) (~p v q) ^ (~q v p) Remember: I use = for
2/17/2008 Sultan Almuhammadi 18
Binary Logic Binary Logic
p has one of two values: True / False p cannot have both. Values can be {T,F}, {0,1}, {High, Low}
n-ary Logic p has one of n valuse: e.g. 1, 2, …, n Conjunction, disjunction, and negation are
defined over these n values. Sounds weird?
2/17/2008 Sultan Almuhammadi 19
Keywords (3):- Propositional logic- First order logic- Domain of discourse- Sets- Natural Numbers (N)- Integers (Z)- Rational Numbers (Q)- Irrational Numbers ( Q’ )- Real Numbers (R)- Prime numbers
2/17/2008 Sultan Almuhammadi 20
First Order Logic- Propositional logic
- E.g. p ^ q -> r
- First order logic- E.g. p(x) ^ q(y)- x and y are from some Domain of
discourse.- The value of p(x) depends on x.
2/17/2008 Sultan Almuhammadi 21
Sets- Notations:
- Upper case letters: A, B X, Y- Elements can be listed in braces {…}- E.g. A = {1, 2, 5}- Elements can be described:- E.g. B = set of all even numbers.- Or B = {x | x is an even number}- E.g. C = {a : a is even and 1< a <10}- The size of set A is denoted by |A|- E.g. |A| = 3 , |B| = ∞ , |C| = 4
2/17/2008 Sultan Almuhammadi 22
Sets- Membership
- x A // x belongs to A, - y A
- Subsets- A B // can be equal - B N // proper-subset
- The Empty Set: denoted by = { }- The Universe: U = set of all
elements.
2/17/2008 Sultan Almuhammadi 23
Set Operations- Intersection
- A B = { x | x A and xB}- Union
- A B = { x | x A or xB}- Complement
- E’ = Ē = { x | x E }
2/17/2008 Sultan Almuhammadi 24
Number Systems- Integers:
- Z = { …, -3, -2, -1, 0, 1, 2, 3, …}- Z+ = {1, 2, 3, …} (positive integers)
- Natural Numbers:- N = {0, 1, 2, 3, … } (nonnegative integers)
- Rational Numbers:- Q = {a/b | a, bZ and b 0}
- Irrational Numbers:- Q’ = { x | x R and x Q}
- Prime numbers:- {x | x N and x is divisible by 1 and x only}
2/17/2008 Sultan Almuhammadi 25
Examples:- Which of the following is true?
- 2 N- 2 Z- 2 N Z- x N x Z- N Z Z Z
2/17/2008 Sultan Almuhammadi 26
Warm up:- Domain of discourse (the domain)
- Set {x | x is prime}- Set {x | x is even and x is prime}
- For all x, P(x) x P(x)- For some x, P(x) x P(x)- Eg. x, x > 1 (domain = N) x, x > 1 (domain = N) x, y, x > y (domain = N)
2/17/2008 Sultan Almuhammadi 27
Exer 1: x y (x > y) (domain of discourse is R) x y (x > y) (domain of discourse is N) x y (x < y) (domain of discourse is Z) x y (x > y) (domain of discourse is Q) x y (x < y) (domain of discourse is N) x y (x < y) (domain of discourse is Z)
2/17/2008 Sultan Almuhammadi 28
Exer 1: Solution x y (x > y) (domain of discourse is R)
- False, for x = 1, y = 2 x y (x > y) (domain of discourse is N)
- True, for x = 2, y = 1 x y (x < y) (domain of discourse is Z)
- True, for y = x + 1 x y (x > y) (domain of discourse is Q)
- False, for y = x + 1 x y (x < y) (domain of discourse is N)
- False, for y = x x y (x < y) (domain of discourse is Z)
- False, for y = x - 1
2/17/2008 Sultan Almuhammadi 29
Negation:- E.g.
- Domain: set of all horses- p(x) : x is a black horse- q(x): x is a white horse
- Universal quantifier x p(x) /* all horses are black */- Negation: ~ x p(x) = x ~p(x)
- Existential quantifier x p(x)- Negation: ~ x p(x) = x ~p(x)
2/17/2008 Sultan Almuhammadi 30
Negation:
- e.g.1. x y (x > y) - = x [ y (x > y) ] - Negation: ~ x [ y (x > y) ] - = x ~ y (x > y)- = x y ~ ( x > y)- = x y ( x ≤ y)
- e.g.2. x y z (x < z) ^ (z < y) - Negation: ~ x y z (x < z) ^ (z < y)- = x y z ~ [ (x < z) ^ (z < y) ]- = x y z (x ≥ z) V (z ≥ y)
2/17/2008 Sultan Almuhammadi 31
Exer 2: Domain = all cs253 students p(x, q) = student x solved question q Write the following in symbolic notation:A. Everybody got full mark.B. Nobody got full mark.C. Negation of A. (Not everybody got full mark). D. Negation of B.E. There was a hard question nobody solved it.F. Negation of E.Solution: ?
2/17/2008 Sultan Almuhammadi 32
Quiz (A1)
(A1: for practice only, not counted) Domain = all cs253 students p(x, q) = student x solved question q Write the following in symbolic notation:“There is exactly one student who got full mark.”
Solution: ?