comp 2600 formal methods for software engineeing review
play

COMP 2600: Formal Methods for Software Engineeing (Review of Set - PowerPoint PPT Presentation

COMP 2600: Formal Methods for Software Engineeing (Review of Set Theory) Dirk Pattinson Australian National University Semester 2, 2013 Dirk Pattinson (ANU) COMP 2600 Semester 2, 2013 1 / 11 Why should we study set theory? Set Theory as


  1. COMP 2600: Formal Methods for Software Engineeing (Review of Set Theory) Dirk Pattinson Australian National University Semester 2, 2013 Dirk Pattinson (ANU) COMP 2600 Semester 2, 2013 1 / 11

  2. Why should we study set theory? Set Theory as Foundation All aspects of mathematics can ultimately be ‘compiled’ down to set theory. Programming Programs as functions that map structured sets of inputs to (structured) sets of outputs. Types are sets (of values). Set Theory as a Discipline ▸ much foundational work on ‘Sets as Foundation’ ▸ here: just need the basics Dirk Pattinson (ANU) COMP 2600 Semester 2, 2013 2 / 11

  3. Set Theory Basics Basic Constructs ▸ set membership: x ∈ A ▸ set equality: A = B linked by extensionality: A = B ↔ ∀ x . ( x ∈ A ↔ x ∈ B ) Derived Concept: Subsets A ⊆ B ≡ ∀ x . ( x ∈ A → x ∈ B ) Notation ▸ explicit enumeration: A = { 1 , 2 , 12 , 17 , ’polar bear’ } ▸ comprehension: A = { x ∈ N ∣ x even } Simplest Consequence ▸ order doesn’t matter: { 1 , 2 , 12 } = { 12 , 1 , 2 } ▸ multiplicity doesn’t matter: { 1 , 1 , 2 } = { 1 , 2 } Dirk Pattinson (ANU) COMP 2600 Semester 2, 2013 3 / 11

  4. Some Sets that We All Know and Love Numbers N is the set of natural numbers; Z is the set of integers; Q is the set of rational numbers; R is the set of real numbers. (constructed using the axiom of infinity) Booleans and Characters Bool = {⊺ , �} is the set of truth values, Char is the set of (ASCII) characters. The empty set ▸ can be defined: ∅ = { x ∈ N ∣ x ≠ x } ▸ is a subset of every set: ∅ ⊆ A ▸ should not be confused with {∅} . Dirk Pattinson (ANU) COMP 2600 Semester 2, 2013 4 / 11

  5. Interlude: Set Theory as Assembly Language Compiling ∅ ⊆ A : The Ingredients ▸ ∅ ≡ { x ∈ N ∣ x ≠ x } ▸ A ⊆ B ≡ ∀ x ( x ∈ A → x ∈ B ) Assember Proof of ∅ ⊆ A ∀ x ( x ∈ { x ∈ N ∣ x ≠ x } → x ∈ A ≡∀ x ( x ∈ N ∧ x ≠ x → x ∈ A ) ≡∀ x ( x ∈ N ∧ � → x ∈ A ) ≡∀ x . ⊺ ≡ ⊺ (But we’re not going to do any more gymnastics at this low level.) Dirk Pattinson (ANU) COMP 2600 Semester 2, 2013 5 / 11

  6. Caveat on Notation Dots ... ▸ O = { 1 , 3 , 5 , 7 ,... } is the set of odd numbers. Or is it? ▸ Maybe { 1 , 3 , 5 , 7 ,... } is the set of numbers not divisible by 2 or 13? Comprehension to the Rescue O = { x ∈ N ∣ x odd } (of course dots are OK if we really agree on what we mean . . . ) Russel’s Paradox ▸ Comprehension: { x ∈ A ∣ φ ( x )} is a set whenver φ ( x ) is a formula. ▸ for otherwise, R = { x ∣ x ∉ x } would also be a set ▸ and R ∈ R ∨ R ∉ R → � would follow, a contradiction! Dirk Pattinson (ANU) COMP 2600 Semester 2, 2013 6 / 11

  7. New Sets from Old Power Sets, Products, Union and Intersection ▸ can all be ‘compiled’ into primitive constructions just using ∈ , = ▸ we don’t do this here – too bureaucratic. Products and Powersets and Unions P( A ) = { B ∣ B ⊆ A } the powerset of A A × B = {( a , b ) ∣ a ∈ A and b ∈ B } the cartesisian product of A and B A ∪ B = { x ∣ x ∈ A or x ∈ B } the union of A and B Illegal? Unrestricted Comprehension? – No, justified by specific axioms. Intersection is Definable A ∩ B = { x ∈ A ∣ x ∈ B } the intersection of A and B (if you like assembler, try to show that A ∩ B = B ∩ A ;-) ) Dirk Pattinson (ANU) COMP 2600 Semester 2, 2013 7 / 11

  8. Union and Intersection of Families Union and Intersection of Families Suppose that D i is a set for all i ∈ I (and I is a set). D i = { x ∣ ∃ i ∈ I . ( x ∈ D i )} and ⋂ D i = { x ∣ ∀ i ∈ I . ( x ∈ D i )} ⋃ i ∈ I i ∈ I is the union and intersection of all D i (again, ⋃ is definable and ⋃ needs an axiom) Example Let I = { 0 , 1 ,..., 26 } and D i contain the first i letters of the alphabet. D i = { a , b ,..., z } and ⋂ D i = ∅ ⋃ i ∈ I i ∈ I and, if J = { 2 , 4 , 7 } D i = { a , b , c , d , e , f , g } and ⋂ D i = { a , b } ⋃ i ∈ J i ∈ J Dirk Pattinson (ANU) COMP 2600 Semester 2, 2013 8 / 11

  9. Relations and Functions Definition If A and B are sets then a subset R ⊆ A × B is a relation between A and B . People often write xRy to mean ( x , y ) ∈ R . Flavours of Relations A relation R between A and itself is ▸ reflexive , if ∀ x ∈ A . ( x , x ) ∈ R (can always go from x to itself) ▸ transitive , if ∀ x , y , z . ( x , y ) ∈ R ∧ ( y , z ) ∈ R → ( x , z ) ∈ R Reflexivity: Self Loops Transitivity: Two Hops in One Go Dirk Pattinson (ANU) COMP 2600 Semester 2, 2013 9 / 11

  10. Functions Definition A relation R between A and B is functional if both ▸ ∀ x ∈ A . ∃ y ∈ B . ( x , y ) ∈ R (left-totality, every x maps somewhere) ▸ ∀ x , y , z . ( x , y ) ∈ R ∧ ( x , z ) ∈ R → y = z (right-uniqueness, only one function value) If f is a functional relation between A and B , we call f a function and write f ∶ A → B . A functional relation Dirk Pattinson (ANU) COMP 2600 Semester 2, 2013 10 / 11

  11. References Chapter 5 of Grassman and Tremblay is called Sets and Relations. 5.1 Sets and Set Operations. You must know this. 5.2 Tuples, Sequences and Power-sets. 5.2.1 Introduction: should know. 5.2.2 Tuples and Cartesian Products: must know. 5.2.3 Sequences and Strings: We’ll get to this. 5.2.4 Power-sets: should know. 5.2.5 Types and Signatures: We’ll cover this. 5.3 Relations: We’ll be talking about this. 5.4 Properties of Relations: We’ll be talking about this. Dirk Pattinson (ANU) COMP 2600 Semester 2, 2013 11 / 11

Recommend


More recommend