type date int int int type name string type bday name
play

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,


  1. 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, 09/2003 –1–

  2. 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. • 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–

  3. SE 3M04 SE 3M04 Fall 2003 • 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–

  4. SE 3M04 SE 3M04 Fall 2003 • 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–

  5. SE 3M04 SE 3M04 Fall 2003 • 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–

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend