type date = int*int*int type name = string type bday = name*date - - PowerPoint PPT Presentation

type date int int int type name string type bday name
SMART_READER_LITE
LIVE PREVIEW

type date = int*int*int type name = string type bday = name*date - - PowerPoint PPT Presentation

SE 3M04 SE 3M04 Fall 2003 Consider the following declarations type date = int*int*int type name = string type bday = name*date type bdayset = bday set val s : bdayset from a system that stores names and birthdays. Jacques Carette,


slide-1
SLIDE 1

SE 3M04 Fall 2003

SE 3M04

Consider the following declarations

type date = int*int*int type name = string type bday = name*date type bdayset = bday set val s : bdayset

from a ”system” that stores names and birthdays.

Jacques Carette, 09/2003 –1–

slide-2
SLIDE 2

SE 3M04 Fall 2003

SE 3M04

Consider the following declarations

type date = int*int*int type name = string type bday = name*date type bdayset = bday set val s : bdayset

from a ”system” that stores names and birthdays.

  • Each person can only have one birthday

∀(a, b) : bday.∀(c, d) : bday.(a, b) ∈ s ∧ (c, d) ∈ s ∧ (a = c → b = d)

Jacques Carette, 09/2003 –1-a–

slide-3
SLIDE 3

SE 3M04 Fall 2003

SE 3M04

  • There is no one with name “n” in s We can define a predicate

P : string*bdayset → bool which expresses this: fun P(n, s) = ∀(a, b) : bday.(a, b) ∈ s ∧ a = n fun P(n, s) = ∀(a, b) ∈ s.a = n

We would then use P(Jacques, s) to verify if Jacques is (or is not) in s.

Jacques Carette, 09/2003 –2–

slide-4
SLIDE 4

SE 3M04 Fall 2003

SE 3M04

  • There is no one with name “n” in s We can define a predicate

P : string*bdayset → bool which expresses this: fun P(n, s) = ∀(a, b) : bday.(a, b) ∈ s ∧ a = n fun P(n, s) = ∀(a, b) ∈ s.a = n

We would then use P(Jacques, s) to verify if Jacques is (or is not) in s.

  • The set of names of people born on date “d” Define a function

LN : date*bdayset → name set, fun LN(d, s) = {a | ((a, d) ∈ s)}

Jacques Carette, 09/2003 –2-a–

slide-5
SLIDE 5

SE 3M04 Fall 2003

SE 3M04

  • There is no one with name “n” in s We can define a predicate

P : string*bdayset → bool which expresses this: fun P(n, s) = ∀(a, b) : bday.(a, b) ∈ s ∧ a = n fun P(n, s) = ∀(a, b) ∈ s.a = n

We would then use P(Jacques, s) to verify if Jacques is (or is not) in s.

  • The set of names of people born on date “d” Define a function

LN : date*bdayset → name set, fun LN(d, s) = {a | ((a, d) ∈ s)}

  • There is a person born on date “d”

∃n : name.(n, d) ∈ s

Jacques Carette, 09/2003 –2-b–