[Skip Navigation] [CSUSB] / [CNS] / [Comp Sci & Eng Dept] / [R J Botting] / [ MATHS ] / logic_30_Sets
[Contents] [Source Text] || [Notation] || [Copyright] || [Contact] [Search ]
Fri Jun 27 17:36:24 PDT 2008

Contents


    Sets

      This introduces set theory from the point of view of a computer professional using ASCII. For the traditional notation see [ sets.html ]

      There is a less formal introduction to this theory in [ intro_sets.html ]

      Rapid History

      Sets are implicit in much of Aristotlean logic (Ancient Greece... Medieval). George Cantor (1800's) developed the theory as part of his research into the mathematics of infinity. Sets rapidly became the language of modern mathematics. Russell (1990's) uncovered paradoxes in the Cantor theory. This lead to the Zermelo-Frankel axiomatic theory(THEORY below), Halmos's Naive set theory, and Whitehead and Russell's Theory of Types.

      Introduction

      These notes are about a language that lets talk both naturally and rigorously at the same time. Everyday language is full of references to sets of objects, classes, types of things, and on. The simple notation proposed here makes much of this rigorous. Sets also form a foundation for several more complex ideas which together form a simple yet effective way of talking about complex pieces of software - such IBM's CICS(Customer Information C?? Systems), elevators, or Hotel Bookings for example.

      For example, using the language of sets we can say:

    1. birds ==> fly, all birds fly.
    2. penguins ==> birds, penguins are birds.

      And so conclude (in the face of the evidence):

    3. penguins ==> fly.

      So we might rethink our assumptions:

    4. birds = flightless | flying. Birds are flying or flightless.

      This might lead us to think about how big the various sets are and conclude that most birds are not flightless...

      Types

      Every object belongs to a type T -- where the type describes the kind of things that can be done to the object or could produce objects of the type. For any type T there is an another type symbolized by @T with objects that are sets of objects of type T.

      .Note

    5. THEORY::=
      Net{
        The use of sets is only distantly related to the theories of sets developed my mathematicians and logicians between 1850 through about 1940: [ logic_32_Set_Theory.html ]


      }=::THEORY.
      A key point is that in theory one can re-express statements in MATHS that use sets into expressions that use predicates instead.

      Some sets are not types - A type by definition is a universal set or domain of discourse, but a set is determined by the type of element plus some rule(predicate) indicating what is in the set. We assume that whenever we have a set of some kind or other than it is a set of objects of the same type. However a subset (or a set for short) does belong to a type and so determines the types of the elements in it. It is therefore safe to use a subset of a type in a declaration of a variable of the right type, and with values/properties limited to those of the set(compare type and subtype in Ada).

      The restriction that each set has elements all of the same type is not a particularly restrictive rule given the freedom with which we can construct types as we need them.

      The main expressions involving sets in MATHS are:

      Set Expressions

        Constructors


        Table
        FormMeaningType(Notes)
        {} $() null set Ambiguous type.
        Tuniversal set @T
        {e1} $(e1) set(e1) singleton @T(e1:T)
        e1 {e1}@type(e1)(only if context requires a set)
        {e1,e2,e3,...} set(e1,e2,e3,...) $(e1,e2,e3,...) set of enumerated items@T(extension)
        {x:T || W(x)} {x:T. W(x)} $[x:T](W(x)) set(x:T WHERE W(x)) set of things satisfying a property W @T(intension)
        $ Net{...}structured settype(Net{...})
        $ Nameset of elements with structure Nametype(Name)

        (Close Table)

        There is also a more readable format that is suitable for large sets made up of complex objects -- [ Long Format ] below.

        Long Format Representation

        For example
      1. my_pets::@Animals=following,
        • stranger, AKA "Megan"
        • shadow
        • ginger

        The raw source code is:

         .Set
         	element
         	element, comment.
         	...
         .Close.Set
        An element in a long set can be several lines long. It starts with an indentation. Each element is an expression and may be terminated by a comma and a comment. Comments are ignored.

        Long sets are normally used with a definition like this:

         Name::@Type = following,
        When rendered for display or printing a long set should shown as an unordered list with each element marked with a bullet or similar marker.

        Enumerating Finite Sets

        In computing and software engineering we often need to introduce and then describe a finite set of distinct named elements. One way to this is:
          Instead of
           	T::Sets,
           	e1::T,
           	e2::T,
           	...
           	e[n]::T,
           	|- T = {e1,e2,...e[n]}.

        If the elements e1,e2,...,e[n] are distinct and free identifiers then the following syntax is natural short hand:
         	T::={e1,e2,...,e[n]}
        It defines T and declares the elements in T. For example:
         	Direction::={down, up}.
        means
           	Direction::Sets.
           	down::Direction.
           	up::Direction.
           	|- Direction={down, up}.

        Note, that the above does not guarantee that the elements have to be different -- even if we use different identifiers for the elements. As written, it is possible for some else to take our document and reuse it with a substitution which makes two variables the same. To stop this, and to be very clear about what we want we must add extra assumptions like this:

         	Direction::={down, up}.
         	|- down <> up.
        or
         	Lights::={Green, Amber, Red}.
         	|- 3 Lights.
        See Cardinality below. This is a little clumsy and counter-intuitive, and so I may add a new notation that handles this.

        If you want the elements to be in order then see [ math_77_Enumerations.html ]

        Summary of Set Operators


        Table
        SymbolsExampleMeaningType
        & ∩ ANDS1 & S2Intersection@T><@T->@T
        & ∩ AND& βIntersection@@T->@T
        | ∪ ORS1|S2union@T><@T->@T
        | ∪ ORunion@@T->@T
        ~ NOTS1 ~ S2Complement@T><@T->@T
        @ \powset SetOf@S1powerset,set_of_subsets@T->@@T
        >< ProductS1><S2Cartesian product@T><@T->@(T><T)

        (Close Table)

        Summary of Predicates


        Table
        SymbolsExampleMeaningType
        in ∈e1 in S1membershipT><@T->@
        <>S1 <> S2inequality@T><@T->@
        !=S1 != S2inequality@T><@T->@
        ==S1 == S2equality@T><@T->@
        ==> ARES1 ==> S2subset or equal@T><@T->@
        =>>S1 =>> S2proper subset@T><@T->@
        somesome S1S1<>{}@T->@
        -S1some S1@T->@
        nono S1S1={}@T->@
        allall S1S1=T@T->@
        andS1 and S2some(S1&S2)@T->@

        (Close Table)

      Syntax of Set Expressions

    6. propositional_expression::= set_theoretical_proposition |...,

    7. set_theoretical_proposition::= |[T:Types] (expression(T) "in" expression(@T) | expression(@T) "=" expression(@T) | expression(@T)),

    8. For T:Types, expression(@T)::= simple_set_expression | union | intersection,

    9. union::= SERIAL(intersection,"|"),
       	Dog | Cat

    10. intersection::= SERIAL(complementary_set_expression,"&"),
       	Shot_haired & Barkless & Dog

    11. complementary_set_expression::= Cartesian_product #(complement Cartesian_product)
    12. complement::="but_not" | "~", The text form is used in EBCDIC.
       	Animal~Dog

    13. Cartesian_product::= SERIAL(possible_prefix_set_expression, "><"). Note: Cartesian products are sets of pairs of elements and are actually a subset of a different type.
       	Point = Real >< Real.

    14. possible_prefixed_set_expression::= #( "|" | "&") simple_set_expression. Note: in fact the simple expression must return a set of sets for a prefix to be OK. If there are 2 prefixes then it must be a set of set of sets.
       	|{ {1,2}, {2,3} }
    15. = {1, 2, 3}.
       	&{ {1,2}, {2,3} }
    16. = {2}.

    17. simple_set_expression::=set_name | elementary_set |"("set_expression")" | set_of_sets | set_of_maps | set_of_relations | simple_set_expression"."relational_expression | relational_expression "("set_expression")".
       	Animal
       	{ shadow, ginger }
       	( A \cup B ~ C )
       	@Animal
       	A<>->B
        shadow.breeds
      	breeds(shadow)

    18. set_of_sets::= "@" simple_set_expression | simple_set_expression "@" expression(Nat0).
       	@Animals
       	Animals@2
    19. @A = { B | B==>A }.
    20. A@n = { B:@A | Card(B) = n }.


        A@n was new and tentative on Thu Aug 19 at 11:20:05 PDT 1999 but became standard notation
      1. 2008-06-27 Fri Jun 27 08:06 .

    21. elementary_set::= intention | extension | singleton | empty_set |type_name | "$"structure_description,
    22. empty_set::="{}"|"$()",
    23. intention::= "{" loose_binding #(","loose_binding ) "||" proposition "}" | "$" loose_bindings "(" proposition ")",
    24. extension::= finite_extension |informal_extension,
    25. finite_extension::="{" list_of_elements "}"| "$(" list_of_elements ")"
    26. informal_extension::= "{" list_of_elements "..." "}"|"$(" list_of_elements "..." ")",

      An informal extension will stop most automatic proof checkers from validating results.

    27. list_of_elements::= element #(punctuation element),
    28. singleton::= "{"element"}" | "$(" element ")".

    29. For Type T, e:T, e::@T={e}.

    30. element::= expression,

      MATHS has a special way to define a set - by describing it as a collection of tuples under some constraint. Any piece of documentation contains declarations and axioms that can be interpreted this way. Examples might be:

    31. my_circle::=$ Net{x,y:Real, x^2+y^2=y^2 },
    32. CIRCLE::=Net{x,y:Real, r:Real, x0,y0:Real, (x-x0)^2+(y-y0)^2=r^2 },
    33. (CIRCLE)|-my_circle=$ CIRCLE(r=>1, (x0,y0)=>(0,0)}

    34. structure_description::= "$" documentation, [ notn_13_Docn_Syntax.html ] and [ notn_14_Docn_Semantics.html ]

    35. structure_expression::=R(expression), [ notn_12_Expressions.html ]


    36. |-structure_expression= "(" identifier "=>" expression #( (|",") identifier "=>" expression) ")",

      Semantics of Set Expressions

        Definitions

        (intension_semantics): For Type T, W:predicate, x:variable(T), {x:T||W(x)}::@T= `set of all x in T that satisfy W(x)`.

        (in): For Type T, A:@T, t:T, t in A ::@=`it is true that t is a member of set A`.

      1. |- (set0): t in {x:T||W(x)} iff W(t).

        {}::@T= {x:T||false},

      2. T::@T= {x:T||true},

        (singleton_semantics): For a,b,c,...: T, {a}::@T={x:T||x=a}.

        (coerced_singleton): For a,b,c,...: T, a::@T={a}.

        (extension_semantics): For a,b,c,...: T, {a,b,c,...} ::@T= {a} | {b} | {c}|... .

        (projection_semantics): For f,x,W, {f(x) || for some x:T (W)}::= {y || for some x:T(y=f(x) and (W))}.

      3. For f,x,X,W, {f(x) || x:X}::= {y || for some x:X(y=f(x))}.


      4. (Set Operators)|- (union_semantics): For A,B: @T, A | B = {x:T || x in A or x in B }.


      5. (Set Operators)|- (intersection_semantics): For A,B: @T, A & B = {x:T || x in A and x in B }.

        Equality of sets


      6. |- (eqsets): for A,B:@T, if for all x:T(x in A iff x in B) then A=B.

        An object is a set when and only when membership solely determines equality. "Bags" have the same abstract operators as "Sets" but two bags are equal only when their members occur the same number of times in both Bags. Formally a "Bag of X's" is an object of type Nat^X. The most general form of this model will be found under [ semiring in math_41_Two_Operators ]

      7. For A,B:@T, A<>B iff not(A=B).

        Conveniences

      8. For x,y:T1, x is y::=(x = y),
      9. For x:T1,X:@T1, x is_a X::=(x in X).

        Cardinality

        How many elements are in this set?
      10. For X:@T, n:Nat0, |X| = n iff for n x:T (x:X).
      11. For Type T, Card[T]::@T->Nat0= map[X:@T](|X|).
      12. For Type T, X:@T, Card(X)::Nat0= Card[T](X).
      13. For Type T, A:@T, n:Nat0, A@n = { X:@T || Card[T](X) = n }.

        Note: avoid using /Card(n) or /|_|(n) as it does not define the types of objects being counted.


      14. |- (cardinality_of_union): for Type T, α, β:FiniteSet(T) ( Card(α | β ) = | α | + | β | - |α & β| ).

        Quantifiers expressed using sets

      15. For all X:@T, X=T iff for all x:T(x in X),

        A set in a context that demands a proposition is true iff there exists at least one member.

      16. For X:@T, X::@= for some x:T(x in X),

      17. For X:@T, for some x:T(x in X) = Card(X)>0.

      18. For X:@T, if |X|=1 then the(A)::= the(x:T||x in A).

        There are short hand ways of stating properties of sets so that they can be used easily:

      19. some(X)::= (X<>{}).
      20. no(X)::= (X={}).
      21. all(X)::= (X=T).
      22. A and B::= some (A & B).

        Here is a readable distfix expression:

      23. no A and B::= no (A & B).

        Set Operators

      24. For T:Types, A,B:@T, A & B::= {x:T || x in A and x in B} ,
      25. ::= "&".
      26. &::@@T -> @T,
      27. |-For β:@@T, &β={x:T || for all B:β(x in B)}.
      28. (above)|-A & B = &{A,B}.
      29. For T:Types, A,B:@T, A | B::= {x:T || x in A or x in B},
      30. ::= "|".
      31. |::@@T -> @T,
      32. |-For β:@@T, |β={x:T || for some B:β (x in B)},
      33. (above)|-A | B = |{A,B}.
      34. For T:Types, A,B:@T, A ~ B::= {x:T || x in A and not x in B},
      35. "but_not"::="~".


      36. (above)|-(@T,|,{},&,T,~) in Boolean_algebra.
        1. A&B = B&A.
        2. A|B = B|A.
        3. A&(B&C) = (A&B)&C.
        4. A|(B|C) = (A|B)|C.
        5. A | A = A.
        6. A & A = A.
        7. A~A={}.
        8. ...


        (Cartesian products): these look like set expressions but are really part of the MATHS theory of types.

      37. For T:Types, A,B:@T, A><B::@(T><T)={ (a,b) || a in A and b in B }.


        (subset): predicates.

      38. For T:Types, A,B:@T, A==>B::= for all a in A(a in B),
      39. ::= "==>".
      40. A<==B::= B==>A.
      41. all A are B::= (A==>B).
      42. For T:Types, A,B:@T, A=>>B::= A ==>B and A<>B,
      43. ::= "=>>".
      44. A<<=B::= B=>>A.

        The Axiom of Choice

        MATHS assumes that given a collection of disjoint sets, then we can choose one member of each to be a representative of that set. Formally:

      45. Choice::@=For all A:Sets, π:partitions(A), some choice:π-->A, all B:π ( choice(B) in B).

        Notice that this assumption is obviously true for finite cases.... it is some the weirder infinite sets that make it doubtful.

        The following formally asserts that the axiom of choice is part of the MATHS system:

      46. |- (axiom_of_choice): Choice.

        This appears in other forms as part of the theory of relations and functions, [ Choice in logic_5_Maps ]

        The axiom of choice was used long before Zermelo made it an explicit axiom in 1904. It appears as the axiom of selection in Principia Mathematica. It was discussed for a long time but is used by praticing mathematicians without qualams. For more history, see [ Axiom_of_Choice ] in the Wikipedia.

        Also see Skolem functions in [ logic_5_Maps.html ]

      Proofs involving Sets

        The following proof patterns are common:
        Table
        To proveAssumeDeriveNotes
        A==>Ba:Ab:B
        no(A)a:ARAA
        A=Ba:Aa:BAnd also
        -b:Bb:A

        (Close Table)

        There are a large number of provable facts about sets

      1. (above)|- (glb): A<==A&B==>B.
      2. (above)|- (lub): A==>B|A<==B.

        There are also some easily proved derivation rules

      3. (above)|- (seteq): A=B iff A==>B and B==>A.
      4. (above)|- (converse): A==>B iff T~B==>T~A.
      5. (above)|- (barbara): If A==>B==>C then A==>C.
      6. (above)|- (celarent): If no A are B and all C are B then no C is B.
      7. (above)|- (darii): If all M is P and some S are M then some S are P.
      8. (above)|- (ferio): If no M is P and some S are M then some S are T~P.

        And so on thru most of the medieval catagorical syllogisms [ syllogisms.html ]

      Families of sets

      [ logic_31_Families_of_Sets.html ]

      Chapter 42 -- Partly Baked Idea

      This comes from rereading section 42 of Principia Mathematica and noticing a couple of odd theorems about the union and intersection of sets of sets of set.

      I doubt if they will be useful.

      They force the use of a nonstandard notation for the set extension of a function, so I'm enclosing them in a Net.

    37. Chapter_14::PBI=following
      Net

      1. |-NONSTANDARD.
      2. T::Types.
      3. |-Set Operators // :: infix( T^T, @T, @T).
      4. For all f:T->T, A:@T, f//A = { f(x) || x:A }.
      5. For A,B,C:@T.
      6. (-1)|-| //{ {A,B}, {C} } = { |{A,B}, |{C} } = {A|B, C}.
      7. (-1)|-| | //{ {A,B}, {C} } = | {A|B, C } = A | B | C.
      8. (Set Operators)|-|{{A,B}, {C}} = {A,B,C }.
      9. (Set Operators)|-||{{A,B}, {C}} = |{A,B,C } = A | B | C.
      10. (above)|-| | //{ {A,B}, {C} } = ||{{A,B}, {C}} .

        Whiehead and Russell (PM *42) prove that

      11. (above)|- (infinite_union_associative): For all κ: @@@T, | |// κ = | | κ.
      12. (above)|- (infinite_intersection_associative): For all κ: @@@T, & &// κ = & | κ.


      (End of Net)

      MinTerms

    38. MINTERM::={ A:Sets, B:@A, p::=map[ a:A] (map b:B(a in b)). For each a in A there is an array of true/false values, one for each set in B, named p(a). We can partition A into cells of elements with the same array of values:
    39. P::=A/p Thus, given for a1,a2:A, a1 =/p a2, for all b:B, a1 in b iff a2 in b.


    }=::MINTERM.

    Tree by Knuth

      [Knuth 69, Vol 1, Section 2.3 Trees p305]

      A typical tree is T where


      1. T::=(nodes=>{1,1.1,1.2,1.2.3}, root=>1, m=>2, subtree=>(T1,T2)),
      2. T1:=(nodes=>{1.1}, root=>1.1, m=>0, subtree=>()),
      3. T2:=(nodes=>{1.2,1.2.3}, root=>1.2, m=>1, subtree=>(T3)),
      4. T3:=(nodes=>{1.2.3}, root=>1.2.3, m=>0, subtree=>()).

      Definition of a tree

    1. TREE::=
      Net{

      1. |-numbers.
      2. nodes::Finite(Sets),
      3. root::nodes,
      4. fan_out::Nat0,
      5. subtree::1..fan_out->@nodes, -- These are ordered trees
      6. |-nodes~{root}>== {subtree(i) || i:1..m},
      7. |-For all i:1..m, subtree(i) in $ TREE.

      }=::TREE.

      |-For T:$ TREE, i:Nat0, T[i]::=T.subtree[i].

      ??{convergence because lim |nodes|=0}??

    2. forest::={F:@TREES||for T1,T2:F(no T1&T2)}


    3. (above)|-if T:$ TREE then T~{root} in forest.

    Idea

    This is a new idea designed to handle natural expressions like flightless bird. An epithet is a word or phrase written in front of the name of a set (not an expression). It is always a subset of the named set.
  1. constrained_set_name::= #epithet set_name. Like this perhaps
  2. flightless bird

    There is a risk of confusion when talking about sets of strings.

    A formal justification for the syntax is by defining a prefix operator on sets of the correct type:

  3. flightless::prefix(@animal) = S+>{b:S. b can not fly}.
  4. For A:@Animal, flightless A::@Animal = {b:A. b can not fly}.

    Should this be abbreviated to

     		flightless::epithet(Animal) = `_ can not fly'.

. . . . . . . . . ( end of section Sets) <<Contents | End>>

Notes on MATHS Notation

Special characters are defined in [ intro_characters.html ] that also outlines the syntax of expressions and a document.

Proofs follow a natural deduction style that start with assumptions ("Let") and continue to a consequence ("Close Let") and then discard the assumptions and deduce a conclusion. Look here [ Block Structure in logic_25_Proofs ] for more on the structure and rules.

The notation also allows you to create a new network of variables and constraints. A "Net" has a number of variables (including none) and a number of properties (including none) that connect variables. You can give them a name and then reuse them. The schema, formal system, or an elementary piece of documentation starts with "Net" and finishes "End of Net". For more, see [ notn_13_Docn_Syntax.html ] for these ways of defining and reusing pieces of logic and algebra in your documents. A quick example: a circle = Net{radius:Positive Real, center:Point}.

For a complete listing of pages in this part of my site by topic see [ home.html ]

Notes on the Underlying Logic of MATHS

The notation used here is a formal language with syntax and a semantics described using traditional formal logic [ logic_0_Intro.html ] plus sets, functions, relations, and other mathematical extensions.

For a more rigorous description of the standard notations see

  • STANDARD::= See http://www.csci.csusb.edu/dick/maths/math_11_STANDARD.html

    Glossary

  • above::reason="I'm too lazy to work out which of the above statements I need here", often the last 3 or 4 statements. The previous and previous but one statments are shown as (-1) and (-2).
  • given::reason="I've been told that...", used to describe a problem.
  • given::variable="I'll be given a value or object like this...", used to describe a problem.
  • goal::theorem="The result I'm trying to prove right now".
  • goal::variable="The value or object I'm trying to find or construct".
  • let::reason="For the sake of argument let...", introduces a temporary hypothesis that survives until the end of the surrounding "Let...Close.Let" block or Case.
  • hyp::reason="I assumed this in my last Let/Case/Po/...".
  • QED::conclusion="Quite Easily Done" or "Quod Erat Demonstrandum", indicates that you have proved what you wanted to prove.
  • QEF::conclusion="Quite Easily Faked", -- indicate that you have proved that the object you constructed fitted the goal you were given.
  • RAA::conclusion="Reducto Ad Absurdum". This allows you to discard the last assumption (let) that you introduced.

    End