Document 13440930

advertisement
Predicates
Mathematics for Computer Science
MIT 6.042J/18.062J
Propositions with variables
Predicate Logic
Example:
P(x,y) ::= [x + 2 = y]
Quantifiers ∀,∃
Albert R Meyer,
February 17, 2010
Albert R Meyer,
lec 3W.1
Predicates
February 17, 2010
lec 3W.2
Quantifiers
P(x,y) ::= [x + 2 = y]
x = 1 and y = 3: P(1,3) is true
∀x
For ALL x
x = 1 and y = 4: P(1,4) is false
∃y
There EXISTS some y
NOT(P(1,4)) is true
Albert R Meyer,
∀ is
February 17, 2010
like AND
lec 3W.4
Let t range over 6.042 staff
B(t) ::= [t took 6.042 Before]
∀s. P(s)
∃t. B(t)
same as
same as
B(Stav) OR B(Rich) OR
B(Megumi) OR…OR B(Oscar)
P(Stav) AND P(Rich) AND
P(Megumi) AND…AND P(Oscar)
February 17, 2010
February 17, 2010
∃ is like OR
Let s range over 6.042 staff
P(s) ::= [s is Pumped about 6.042]
Albert R Meyer,
Albert R Meyer,
lec 3W.3
lec 3W.5
Albert R Meyer,
February 17, 2010
lec 3W.6
1
Existential Quantifier
Universal Quantifier
Let x, y range over N
x, y range over N
Q(y) ::= ∃x. x < y
Q(3) is T ([x<3] is T for x=1)
Q(1) is T ([x<1] is T for x=0)
Q(0) is F ([x<0] is not T
for any x in N)
Albert R Meyer,
February 17, 2010
lec 3W.7
virus attack, I: ∀∃
lec 3W.9
Alternating Quantifiers
G ::= ∀x∃y. x < y
Albert R Meyer,
G is:
February 17, 2010
lec 3W.10
H ::= ∃y∀x. x ≤< y
H is:
Domain
F
F
T
F
N
Z-
T
F
T
February 17, 2010
Albert R Meyer,
Reverse the Quantifiers
x, y range over Domain of Discourse
N
ints < 0
reals < 0
lec 3W.8
Example: d is MITviruscan,
protects against all viruses
∀∃ is expensive!
Domain
February 17, 2010
IThat’s
have one
defense
good
what
we want!
against every attack.
against MYDOOM,
use Defender
against ILOVEYOU, use Norton
against BABLAS,
use Zonealarm…
February 17, 2010
Albert R Meyer,
virus attack, II:∃∀
For every virus, I have a defense:
Albert R Meyer,
R(y) ::= ∀x. x < y
R(1) is F ([x<1] is F for x=5)
R(8) is F ([x<8] is F for x=12)
R(10100) is F
([x<10100] is F for x=10100)
lec 3W.15
Albert R Meyer,
February 17, 2010
lec 3W.16
2
Team Problems
Problems
1& 2
Albert R Meyer,
February 17, 2010
lec 3W.38
3
MIT OpenCourseWare
http://ocw.mit.edu
6.042J / 18.062J Mathematics for Computer Science
Spring 2010
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
Download