﻿<?xml version="1.0" encoding="utf-8"?>
<math:math
  xmlns:math="http://www.adammil.net/math/math.xsd"
  xmlns:h="http://www.w3.org/1999/xhtml" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.adammil.net/math/math.xsd math.xsd">

<!-- Logic -->
<topic id="topLogic" name="Logic" description="The study of propositions and deductive reasoning.">
  <definition id="dOpenSentence" name="open sentence">
    An <imp>open sentence</imp> is a boolean expression that contains unbound variables. The truth of an open sentence
    cannot be evaluated until specific values are substituted for the unbound variables. If a set of values makes an
    open sentence true when substituted for the unbound variables, the values are said to <imp>satisfy</imp> the
    sentence. Typically, a <r ref="U">universe of discourse</r> is defined, from which the values can be chosen.
    <el/>
    Here are some example open sentences:
    <ol>
      <li>`S sube ZZ` (`S` is unbound)</li>
      <li>`y^2-5y+6=0` (`y` is unbound)</li>
    </ol>
  </definition>

  <definition id="dImplication" name="implication" shortMath="=>, |==, :.">
    A <imp>logical implication</imp> is a statement that relates two propositions. If `P` and `Q` and `P` implies `Q`,
    then `P` is called the <imp>hypothesis</imp> (or <imp>antecedant</imp>) and `Q` is called the
    <imp>conclusion</imp> (or <imp>consequent</imp>). The implication can be written as `P => Q`, `P |== Q`, or
    `P :. Q` (in decreasing order of popularity), all of which can be read "`P` implies `Q`" or "`P` entails `Q`".
    A logical implication is false only if the hypothesis is true but the conclusion is false.
    <el/>
    When the sentence "if A, then B" is encountered, where `A` or `B` is an open sentence, it is generally interpreted
    as a universally quantified implication: `(AA x in UU)(A => B)`.
  </definition>

  <definition id="dUniversalQuantifier" name="universal quantifier" shortMath="AA">
    The symbol `AA` (read "for all" or "for every") is called the <imp>universal quantifier</imp>. It is generally
    followed by a variable name, a set or expression restricting that variable, and open sentence about that variable.
    This forms a new sentence which asserts that all possible substitutions for the variable satisfy the open sentence.
    If the set is omitted, it is assumed to be <r ref="U">`UU`</r>.
    <el/>
    For instance, the sentence `A sube B` can be defined using the universal quantifier: `(AA x in A)(x in B)`. This
    says that every element in `A` exists in `B`, which is exactly what `A sube B` means. The parentheses in the
    sentence are not strictly required. `AA x in A (x in B)` means the same thing, as does `AA x in A` `x in B`.
    Note that the sentence containing the universal quantifier may be false. For example: `(AA n in NN)(n &lt; 0)`.
    This asserts that all natural numbers are negative, but the assertion is false.
  </definition>

  <definition id="dExistentialQuantifier" name="existential quantifier" shortMath="EE">
    The symbol `EE` (read "there exists") is called the <imp>existential quantifier</imp>. It is generally
    followed by a variable name, a set or expression restricting that variable, and open sentence about that variable.
    This forms a new sentence which asserts that there exists at least one substition for the variable that satisfies
    the open sentence. If the set is omitted, it is assumed to be <r ref="U">`UU`</r>.
    <el/>
    For instance, the sentence `a div b` can be defined using the existential quantifier: `(EE t in ZZ)(at=b)`. This
    says that there exists an integer `t` such that `at=b`. The parentheses in the sentence are not strictly required.
    `EE t in ZZ (at=b)` means the same thing, as does `EE t in ZZ` `at=b`.
    Note that the sentence containing the existential quantifier may be false. For example: `(EE n in NN)(n &lt; 0)`.
    This asserts that there exists at least one natural number that is negative, but the assertion is false.
  </definition>

  <definition id="dTruthSet" name="truth set">
    A <imp>truth set</imp> of an open sentence is the complete set of values that, when substituted for the open
    variables in the sentence, make it true. For example, the truth set of `x^2-4x-5=0` (`UU=RR`) is {-1,5}.
  </definition>

  <definition id="dCounterexample" name="counterexample">
    A <imp>counterexample</imp> is a set of values that, when substituted into a logical implication, makes the
    hypothesis of the implication true and the conclusion false.
  </definition>

  <definition id="dVacuouslyTrue" name="vacuously true">
    A <imp>vacuously true</imp> statement is a logical implication that is true, but the truth set of its hypothesis
    is the empty set. An example of a vacuously true statement is: "If `x` is a real number with `x^2&lt;0`, then
    `x=17`." The statement is true because there does not exist a counterexample, but it's rather useless
    because there is no situation to which this statement can be applied.
  </definition>

  <hypothesis id="tLogicalDeMorgan" name="De Morgan's Law">
    Given propositions `P` and `Q`:
    <ol type="i">
      <li>`not (P ^^ Q) = not P vv not Q`, and</li>
      <li>`not (P vv Q) = not P ^^ not Q`, and</li>
      <li>`not (P => Q) = P ^^ not Q`, and</li>
      <li>`not (AA x)(P(x)) = (EE x)(not P(x))`, and</li>
      <li>`not (EE x)(P(x)) = (AA x)(not P(x))`</li>
    </ol>
  </hypothesis>
</topic>

<!-- Number theory -->
<topic id="topNumbers" name="Number theory" description="The study of numbers and their properties.">
  <!-- Number theory : Even and odd numbers -->
  <topic id="topNumbersEvenOdd" name="Even and odd numbers"
         description="Definitions and hypotheses regarding even and odd numbers.">
    <definition id="dEvenOdd" name="even and odd numbers" defines="even odd">
      For `x in ZZ`:
      <ul>
        <li>
          "`x` is <imp>even</imp>" means: `(EE t in Z)(x=2t)` -- there exists an integer `t` such that `x=2t`. More
          concisely, `x` is even if `2 div x`.
        </li>
        <li>
          "`x` is <imp>odd</imp>" means: `(EE y in Z)(x=2y+1)` -- there exists an integer `y` such that `x=2t+1`.
          More concisely, `x` is odd if `2 !div x`.
        </li>
      </ul>
      Note that according to this definition, the number zero is considered even.
    </definition>

    <hypothesis id="hSumsOfOddAndEven" name="Sums of odd and even numbers" tags="even odd">
      <ul>
        <li>If `a` is even and `b` is even, then `(a+b)` and `(a-b)` are even.</li>
        <li>If `a` is even and `b` is odd, then `(a+b)` and `(a-b)` are odd.</li>
        <li>If `a` is odd and `b` is odd, then `(a+b)` and `(a-b)` are even.</li>
      </ul>
    </hypothesis>

    <theorem id="tProductsOfOddAndEven" name="Products of odd and even numbers" tags="even odd">
      <text>
        <ol type="1">
          <li>If `a` is even or `b` is even, then `ab` is even.</li>
          <li>If `a` is odd and `b` is odd, then `ab` is odd.</li>
        </ol>
      </text>
      <proof>
        <ol type="1">
          <li>To prove (1) above, assume `a` is even, and `b` is any integer. In the special case where `a=0`, `ab=0`,
            which is even. If `a != 0`, then we have `2 div a and a div ab`. By <r ref="tDivisorIsTransitive"/>, we have
            `2 | ab`, which means that `ab` is even. By a parallel argument, `ab` is even if `b` is even and `a` is
            any integer.
          </li>
          <li>To prove (2) above, let `a` and `b` be any two odd numbers. Then by definition there exist integers
            `m` and `n` such that `a=2m+1` and `b=2n+1`. Then `ab = (2m+1)(2n+1) = (4mn+2m+2n+1) = 2(2mn+m+n)+1`.
            Since there exists an integer `z = 2mn+m+n` where `2z+1 = ab`, then `ab` must be odd, by definition.
          </li>
        </ol>
      </proof>
    </theorem>
  </topic>

  <topic id="topNumbersDivisibility" name="Divisibility"
         description="Divisibility among the integers and natural numbers">
    <definition id="dDivisor" name="divisor" shortMath="(EE t in ZZ)(x*t=y)">
      Given `x,y in ZZ` with `x != 0`, `x` is a <imp>divisor</imp> of `y` if there exists an integer `t` such that
      `x*t=y`.
      <subdef>`(EE t in ZZ)(x*t=y)`</subdef>
      If `x` is a divisor of `y`, we can also say "`x` divides `y`", and we write "`x div y`". 0 is not a divisor of
      any integer, but all nonzero integers are divisors of zero, and of course 1 is a divisor of every integer. A
      <imp>proper divisor</imp> of `y` is a divisor `x` such that `x != y`.
      <el/>
      Similarly, given `a,b in NN`, `a div b` if `(EE u in NN)(a*u=b)`.
      <el/>
      If `y` is not zero, then there are only finitely many divisors, because by <r ref="tDivisorIsNotGreater"/>,
      `|x|&lt;=|y|`.
    </definition>

    <definition id="dMultiple" name="multiple" shortMath="{n*t:t in ZZ}">
      For `n in ZZ`, the set of multiples of `n` is
      <subdef>`{n*t:t in ZZ}`</subdef>
      The set of multiples of `n` can be abbreviated `nZZ`. Each element of this set is called a <imp>multiple</imp>
      of `n`.
    </definition>

    <definition id="dCommonDivisor" name="common divisor" tags="divisor">
      For `x,y in ZZ`, `t` is a <imp>common divisor</imp> of `x` and `y` if `t div x and t div y`.
      <el/>
      Every pair of integers has at least one common divisor, because 1 divides every integer. If `x` or `y` is
      nonzero, then there are only finitely many common divisors. (See <d ref="divisor"/>.)
    </definition>

    <definition id="dGCD" name="GCD" tags="divisor">
      For `x,y in ZZ`, `t` is the <imp>greatest common divisor (GCD)</imp> of `x` and `y` if:
      <subdef>`t div x and t div y and (AA u in ZZ)(u div x and u div y => u &lt;= t)`</subdef>
      This definition says that `t` is the GCD of `x` and `y` if it is a common divisor of `x` and `y`, and every other
      common divisor is less than or equal to `t`. The greatest common divisor of `x` and `y` is written `GCD(x,y)`.
      <el/>
      If `x` or `y` is nonzero then a GCD exists because there are only finitely many common divisors
      (see <d ref="common divisor"/>), and one of them is the greatest. If `x` and `y` are both zero, then there is no
      GCD because there are infinitely many common divisors. The GCD is always positive because 1 is a common divisor
      of every pair of integers, and 1 is greater than all nonpositive integers.
    </definition>

    <definition id="dCommonMultiple" name="common multiple" tags="multiple">
      For `x,y in ZZ`, `t` is a <imp>common multiple</imp> of `x` and `y` if `t` is a multiple of `x` and `t` is a
      multiple of `y`.
    </definition>
    
    <definition id="dLCM" name="LCM" tags="multiple">
      For `x,y in ZZ-{0}`, `t` is the <imp>least common multiple (LCM)</imp> of `x` and `y` if:
      <ol type="i">
        <li>`t` is a positive common multiple of `x` and `y`, and</li>
        <li>Every positive common multiple of `x` and `y` is greater than or equal to `t`.</li>
      </ol>
      Note that if `x=0` or `y=0`, the least common multiple is defined to be zero.
      The least common multiple of `x` and `y` is written `LCM(x,y)`.
    </definition>

    <theorem id="tNonzeroIntegersHaveLCM" name="Nonzero integers have LCM" tags="multiple LCM">
      <text>Given `x,y in Z-{0}`, there exists a positive common multiple of `x` and `y`.</text>
      <proof>
        Let `z=xyc`, where `c in {-1,1}`. If `xy` is negative, let `c=-1`. Otherwise, let `c=1`. Then, `z>0`, and since
        `z=xyc`, `z` is a multiple of both `x` and `y`. Therefore, every pair of nonzero integers `x` and `y` has a
        positive common multiple. Furthermore, since the set of possible positive common multiples is bounded from
        below (by zero), there exists a common multiple that is less than or equal to all others. So every pair
        of nonzero integers has a least common multiple.
      </proof>
    </theorem>
    
    <theorem id="tDivisorDividesMultiple" name="Divisor divides multiples" shortMath="a div b => a div nb"
             tags="divisor multiple">
      <text>If `a div b`, then `a div nb` for all `n in ZZ`.</text>
      <proof>
        If `a div b`, then there exists an integer `m` such that `am=b`. Given any integer `n`, `n*b=n*am=a*nm`, and
        clearly `a div a*nm`. Therefore, `a div nb`.
      </proof>
    </theorem>

    <hypothesis id="hDivisorsOfProduct" name="Divisors of a product" tags="divisor multiple"
                shortMath="a div b and c div d => a div bd and c div bd and ac div bd">
      <subdef>If `a div b and c div d`, then `a div bd and c div bd and ac div bd`.</subdef>
    </hypothesis>

    <theorem id="tDivisorOfSum" name="Divisor of a sum" tags="divisor"
                shortMath="a div b and b div c => a div (b+c) and a div (b-c)">
      <text>If `a div b and b div c`, then `a div b+c and a div b-c`.</text>
      <proof>
        If `a div b` and `a div c`, then there exist integers `m` and `n` such that `am=b` and `an=c`. Then
        `b+c=am+an=a(m+n)`. Clearly, `a div a(m+n)`, so `a div b+c`. Similarly, `a div b-c`.
      </proof>
    </theorem>

    <theorem id="tDivisorIsTransitive" name="Divisors are transitive" tags="divisor"
             shortMath="a div b and b div c => a div c">
      <text>If `a div b and b div c`, then `a div c`.</text>
      <proof>
        If `a div b` and `b div c`, then by definition there exist integers `m` and `n` such that `am=b` and `bn=c`.
        Substituting `am` for `b` in `bn=c`, we get `amn=c`. Because there exists an integer `mn` such that
        `a*mn=c`, `a div c`.
      </proof>
    </theorem>

    <theorem id="tDivisorIsNotGreater" name="Divisors are not greater" tags="divisor"
                shortMath="a,b in NN and a div b => a&lt;=b">
      <text>For `a,b in NN`, if `a div b`, then `a&lt;=b`.</text>
      <proof>By <d ref="divisor"/>, there exists a natural number `m` such that `am=b`. By
        <r ref="tNaturalProductIsNotSmaller"/>, we know that `a&lt;=am`, and since `am=b`, `a&lt;=b`.
        <el/>
        This can be extended to the integers because the absolute value of a nonzero integer is a natural
        number. For `x,y in ZZ` where `y != 0`, if `x div y` then `|x|&lt;=|y|`
      </proof>
    </theorem>

    <hypoCorollary id="hProperDivisorIsLEHalf" ref="tDivisorIsNotGreater" tags="divisor"
                   name="Proper divisors are not greater than half"
                   shortMath="a,b in NN and a div b and a!=b => a&lt;=b/2">
      <subdef>For `a,b in NN`, if `a div b and a!=b`, then `a&lt;=b/2`.</subdef>
    </hypoCorollary>

    <hypoCorollary id="hSymmetricDivisorsAreAbsEqual" ref="tDivisorIsNotGreater" tags="divisor"
                   name="Symmetric divisors have the same magnitude" shortMath="a div b and b div a => |a|=|b|">
      <subdef>If `a div b and b div a`, then `|a|=|b|`.</subdef>
    </hypoCorollary>

    <hypothesis id="hProductOfDivisors" name="Product of divisors" tags="divisor"
                   shortMath="a,b,c in NN and a div b and b div c and a&lt;=sqrt(c) and b&lt;=sqrt(c) => ab div c">
      <subdef>For `a,b,c in NN`, if `a div b and b div c and a&lt;=sqrt(c) and b&lt;=sqrt(c)`, then `ab div c`.</subdef>
    </hypothesis>

    <hypothesis id="hOddsHaveOddDivisors" name="Odd numbers have odd divisors" tags="odd divisor"
                shortMath='b "is odd" and a div b => a "is odd"'>
      <subdef>If `b` is odd and `a div b`, then `a` is odd.</subdef>
      This basically says that all divisors of odd numbers are themselves odd.
    </hypothesis>

    <hypothesis id="hCommonDivisorsDivideGCD" name="Common divisors divide GCD" tags="GCD divisor"
                shortMath="t div x and t div y => t div GCD(x,y)">
      <subdef>If `t` is a common divisor of `x` and `y`, then `t div GCD(x,y)`.</subdef>
    </hypothesis>

    <hypothesis id="hProductOfRelativePrimes" name="Product of relative primes" tags="prime GCD">
      <subdef>If `GCD(a,b)=1` (ie, `a` and `b` are relatively prime) and `t!=0`, then `GCD(at,bt)=|t|`.</subdef>
      If `a` and `b` are relatively prime, then their sets of divisors have nothing in common except 1. So if we
      multiply both numbers by `t`, the sets of divisors of the resulting products will have nothing in common except
      1 and `|t|`, so the GCD of the products will be `|t|`.
    </hypothesis>

    <hypothesis id="hRelationshipBetweenGCDandLCM" name="Relationship between GCD and LCM" tags="GCD LCM"
                shortMath="LCM(x,y)=(xy)/(GCD(x,y))">
      <subdef>`LCM(x,y)=(xy)/(GCD(x,y))`</subdef>
      If `d=GCD(x,y)` then `d div x and d div y`. By definition, there exist integers `m` and `n` such that `x=md` and
      `y=nd`. Then `xy=md*nd`. We can divide `xy` by `d`, producing `(xy)/d=mnd`. This quantity is still a common
      multiple of `x` and `y` (because it's equal to both `nx` and `my`). Because `d=GCD(x,y)`, `m` and `n` are
      the smallest possible numbers such that `x=md` and `y=nd`. That is to say, `mnd=(xy)/d` is the least common
      multiple.
    </hypothesis>
  </topic>

  <topic id="topNumbersNatural" name="Natural Numbers" description="Properties of the set of positive integers.">
    <definition id="dPrime" name="prime" defines="composite">
      For `t in NN` where `t>1`, `t` is <imp>prime</imp> if the only divisors of `t` are 1 and `t` itself. More
      concisely, if `t` is prime, then:
      <subdef>`(AA x in NN)(x div t => [x=1 or x=t])`</subdef>
      If `t` is not prime (and `t>1`), then `t` is <imp>composite</imp>. That is:
      <subdef>`(EE u,v in NN)(u>1 and v>1 and t=uv)`</subdef>
      The number 1 is neither prime nor composite.
    </definition>
    
    <theorem id="tNaturalProductIsNotSmaller" name="Product of natural number factors is not less"
             shortMath="a,b in NN => ab>=a and ab>=b">
      <text>For all `a,b in NN`, `ab>=a and ab>=b`. That is, the product of two natural numbers is at least as large
        as both of its factors.
      </text>
      <proof>
        We'll first prove that `ab>=a`. Because `b` is a natural number, we know that `b>=1`. This gives two cases:
        <ol>
          <li>`b=1`. Since `n xx 1=n` for all `n`, we know that `ab=a`.</li>
          <li>`b>1`. Recall that if `x>y and c>0`, then `cx > cy`. If `x=b`, `y=1`, `c=a`, we have `b>1` and `a>0`
            (because `a` is a natural number), so `ab>a`.
          </li>
        </ol>
        Therefore, `ab>=a`. By a parallel argument, `ab>=b`.
      </proof>
    </theorem>
  </topic>

  <topic id="topNumbersInteger" name="Integers" description="Properties of the integers.">
    <definition id="dLinearDiophantine" defines="linearDiophantine" name="a linear Diophantine equation">
      A linear Diophantine equation is an equation of the form `ax+by=c`, where all variables are integers.
    </definition>

    <definition id="dRelativelyPrime" name="relatively prime" tags="prime" shortMath="GCD(x,y)=1">
      Two numbers `x` and `y` are <imp>relatively prime</imp> means:
      <subdef>GCD(x,y)=1</subdef>
    </definition>
    
    <theorem id="tDiophantineNonSolutions" name="Linear Diophantine non-solutions" tags="linearDiophantine">
      <text>Given `a,b,c,d in ZZ`, if `d div a` and `d div b` and `d !div c`, then the equation
        `ax+by=c` has no integer solution for `x` and `y`.
      </text>
      <proof>
        Assume by way of contradiction that the equation does have an integer solution. Then by
        <r ref="tDivisorDividesMultiple"/> we know that `d div ax and d div by`, and by <r ref="tDivisorOfSum"/>,
        we know that `d div (ax+by)`, which means that `d div c`.
        However, we've stated that `d !div c`, so that is impossible. Therefore, the equation has no solutions.
      </proof>
    </theorem>

    <corollary id="tDiophantineNonSolutions2" name="Linear Diophantine non-solutions 2" tags="linearDiophantine"
               ref="tDiophantineNonSolutions">
      <text>Given `a,b,c in ZZ` with `a` and `b` not both equal to zero, and `d=GCD(a,b)`. If the diophantine equation
        `ax+by=c` has an integer solution for `x` and `y`, then `d div c`. (Note that this is not the same as saying
        "If `d div c`, then the equation has a solution.)
      </text>
      <proof>
        We'll prove this by proving the contrapositive: if `d !div c`, then the diophantine equation has no solutions.
        Because `d=GCD(a,b)`, `d div a and d div b` by <d ref="GCD"/>, and by applying
        <r ref="tDiophantineNonSolutions"/>, we can see that the equation has no solutions.
      </proof>
    </corollary>
  </topic>

  <topic id="topNumbersRational" name="Rational Numbers" description="Properties of the rational numbers.">
    <definition id="dRational" name="rational">
      For `x in RR`, `x` is <imp>rational</imp> means:
      <subdef>`(EE p in ZZ,q in NN)(x=p/q)`</subdef>
      That is, a rational number is a number that can be expressed as the quotient of an integer and a natural number.
    </definition>

    <theorem id="tRationalsAreIncomplete" name="the set of rational numbers does not have the completeness property"
             shortName="the rationals are not complete" tags="rational completeness">
      <text>`QQ` does not have <r ref="the completeness property"/>.</text>
      <proof>
        To prove this theorem, we need to be able to show that there exists a subset of the rationals that is bounded
        above but doesn't have a rational <r ref="lub"/> or that there exists a subset of the rationals that is bounded
        below but doesn't have a rational <r ref="glb"/>.
        <el/>
        Consider the set `S={n in QQ : n>0 and n^2&lt;2}`. `S` is a subset of the rationals. We will prove that this
        set does not have a rational lub. Since `sqrt(2)` is clearly an upper bound for this set, but `sqrt(2)` is
        irrational, a rational lub (call it `p`) would have to be near to, but greater or less than `sqrt(2)`. We'll
        consider each case.
        <ol>
          <li>
            `0 &lt; p^2 &lt; 2`. If `0 &lt; p^2 &lt; 2` then `p in S` and so `p` must be the maximum of `S`.
            Then, by definition there is no element of `S` greater than `p`. But consider `q = p + (2-p^2)/(p+2) =
            (2p+2)/(p+2)`. If it can be proven that `q > p` and `q^2 &lt; 2`, then `q in S`, and that would contradict
            `p` being the lub of `S`. Since `p^2 &lt; 2`, then `2-p^2 > 0`, and since `p > 0`, then `p+2 > 0`.
            Therefore, `(2-p^2)/(p+2)` is positive, and so `q > p`. It only remains to show that `q^2 &lt; 2`. `q^2-2 =
            ((2p+2)^2)/((p+2)^2) - 2 = (4p^2+8p+4)/((p+2)^2) - 2 = (4p^2+8p+4-(2p^2+8p+8))/((p+2)^2) =
            (2p^2-4)/((p+2)^2) = (2(p^2-2))/((p+2)^2)`. Since `p^2 &lt; 2`, `p^2-2 &lt; 0`, so the numerator is
            negative. And since `p > 0`, the denominator is positive. Thus, `q^2-2 &lt; 0`, so `q^2 &lt; 2`. So `S`
            does not have a maximum, and if it has a rational lub, it cannot be less than `sqrt(2)`.
          </li>
          <li>
            `p^2 > 2`. If `p^2 > 2` and `p` is the lub of `S`, then there can exist no rational number `q` such that
            `sqrt(2) &lt; q &lt; p`. But consider the same formula as above, `q = p + (2-p^2)/(p+2) = (2p+2)/(p+2)`.
            If it can be proven that `q &lt; p` and `q^2 > 2`, then that would contradict `p` being the lub of `S`.
            Since `p^2 > 2`, then `2-p^2 &lt; 0`, and since `p > 0`, then `p+2 > 0`. Therefore, `(2-p^2)/(p+2)` is
            negative, so `q &lt; p`. It only remains to show that `q^2 > 2`. `q^2-2 = (2(p^2-2))/((p+2)^2)`, and since
            `p^2 > 2`, then the numerator is positive, and since `p > 0`, the denominator is positive. Therefore,
            `q^2-2 > 0`, so `q^2 > 2`. So `S` cannot have a rational lub greater than `sqrt(2)`.
          </li>
        </ol>
        Since `S` cannot have a rational lub that is less than, equal to, or greater than `sqrt(2)`, `S` cannot have
        a rational lub. Therefore, `QQ` does not have the completeness property.
      </proof>
    </theorem>
  </topic>

  <topic id="topNumbersReals" name="Real Numbers" description="Properties of the real numbers.">
    <definition id="dSetBounds" name="upper and lower bounds" defines="setBound">
      For `x in RR` and `S sube RR`, "`x` is an <imp>upper bound</imp> for `S`" means:
      <subdef>`(AA y in S)(x >= y)`</subdef>
      Similarly, "`x` is a <imp>lower bound</imp> for `S`" means:
      <subdef>`(AA y in S)(x &lt;= y)`</subdef>
      An upper of a set does not need to be a member of that set, but if the set does contain its own
      upper bound, it is called an <r ref="extremum"/> of the set.
      <el/>
      If a set has an upper bound, it is said to be <imp>bounded above</imp>, and if it has a lower bound, it is said
      to be <imp>bounded below</imp>. A set with both an upper and lower bound is <imp>bounded</imp>. If it does not
      have both, it is <imp>unbounded</imp>.
    </definition>

    <definition id="dExtremum" name="extrema" defines="maximum minimum" tags="setBound">
      Given `S sube RR`, `x` is said to be the <imp>maximum</imp> (or <imp>largest element</imp>) of `S`,
      and we write `x="max "S`, if `x in S` and `x` is an <r ref="dSetBounds">upper bound</r> for `S`.
      <el/>
      Similarly, `y` is said to be the <imp>minimum</imp> (or <imp>smallest element</imp>) of
      `S`, and we write `x="min "S`, if `y in S` and `y` is a <r ref="dSetBounds">lower bound</r> for `S`.
      <el/>
      An <imp>extremum</imp> (plural "extrema") is either a minimum or a maximum. Not all sets have a minimum or a
      maximum. Note the difference between an extremum and an upper or lower bound. An extremum of `S` is in `S`, but
      an upper or lower bound need not be.
    </definition>

    <definition id="dSuperlativeBound" name="lub and glb" defines="setBound lub glb">
      For `x in RR` and `S sube RR`, `x` is the <imp>least upper bound (lub)</imp> (or <imp>supremum</imp>) of `S`
      (denoted "lub of `S`" or "`"sup " S`") if:
      <subdef>`(AA y in S)(x >= y) and (AA z in RR)(z" is an upper bound for "S => z >= x)`</subdef>
      Similarly, "`x` is the <imp>greatest lower bound (glb)</imp> (or <imp>infimum</imp>) of `S`" (denoted
      "glb of `S`" or "`"inf " S`") means:
      <subdef>`(AA y in S)(x &lt;= y) and (AA z in RR)(z" is a lower bound for "S => z &lt;= x)`</subdef>
      If a set contains its own least upper bound, then the set has a <r ref="minimum"/> equal to the lub. Similarly,
      if a set contains its own greatest lower bound, the set has a <r ref="maximum"/> equal to the glb.
    </definition>

    <definition id="dCompletenessProperty" name="the completeness property" defines="completeness">
      For `S sube RR`, `S` has the <imp>completeness property</imp> if:
      <ol>
        <li>Every nonempty subset `T` of `S` which is bounded above by an element of `RR` has a <r ref="lub"/>
          in `S`, and
        </li>
        <li>Every nonempty subset `T` of `S` which is bounded below by an element of `RR` has a <r ref="glb"/>
          in `S`.
        </li>
      </ol>
      Note that the lub and glb must be in `S`, though they need not be in `T`.
    </definition>

    <theorem id="tNotAllSetsHaveExtrema" shortName="Not all bounded sets have extrema"
             name="Some non-empty, bounded sets do not have extrema" tags="setBound">
      <text>
        Some non-empty subsets of the real numbers do not have <r ref="extrema"/>, even if they are bounded. That is,
        even though the set may be bounded above or below, they lack a maximum or minimum element (or both). This of
        course can only be the case for infinite sets.
        Consider the set `S=[0,1]`. Clearly, the infimum of this set is 0, and the supremum is 1. Both 0 and 1
        are also in the set, so the set has both extrema. Now consider the set `T=[0,1)`. 1 is clearly an upper bound
        for this set, but is it the <emph>least</emph> upper bound? In fact it is, and `T` has no maximum element.
      </text>
      <proof>
        By definition, the set `T` contains every number `n` where `0 &lt;= n &lt; 1`. Assume by way of contradiction
        that there does exist an upper bound for `T` (call it `u`) that is less than 1. Since `u` would have to be
        very close to 1, we won't consider `u &lt;= 0`. Then we have `0 &lt; u &lt; 1`. But given any such `u`, we can
        always find another number `v` such that `u &lt; v &lt; 1`, which would contradict `u` being an upper bound.
        For instance, let `v=(u+1)/2`. If we can prove that `u &lt; (u+1)/2 &lt; 1`, then we will have shown that any
        number less than 1 cannot be an upper bound for `T`. Similarly, we will have shown that `T` has no maximum
        element, since a greater element that is also within `T` can always be found.
        We will now prove that `u &lt; (u+1)/2 &lt; 1`. Because `u &lt; 1`,
        `u+u=2u &lt; u+1 &lt; 2`. Then, dividing by 2, we can see that `u &lt; (u+1)/2 &lt; 1`.
      </proof>
    </theorem>
  </topic>
</topic>

<!-- Sets -->
<topic id="topSets" name="Sets" description="Sets are unordered groups of distinct objects.">
  <!-- Sets : Definitions -->
  <topic id="topSetDefs" name="Definitions" description="The definitions of sets and related terms.">
    <definition id="dSet" name="a set" defines="set emptySet U">
      A set is an unordered collection of objects. The objects in a set are called its <imp>elements</imp> or
      <imp>members</imp>.
      Sets contain only distinct objects, so the sets {1,2,3} and {3,2,2,1} are equal.
      <el/>
      If `x` is a member of set `S`, we write `x in S`. If `x` is not a member of set `S`, we write `x !in S`.
      <el/>
      There are a number of special sets with the following denotations:
      <ul>
        <li>
          `O/`: This represents the <imp>empty set</imp> (also known as the <imp>null set</imp>). The empty set has
          no elements.
        </li>
        <li>
          `NN`: This represents the <imp>natural numbers</imp> (also known as <imp>counting numbers</imp>).
          Unfortunately, there is no general agreement as to this set's exact definition. It can refer to either the
          set of positive integers or the set of
          non-negative integers. In contexts where `NN` represents the non-negative integers, `PP` often represents
          the positive integers (however, a few authors even use `PP` to represent the non-negative integers). Where
          `NN` represents the positive integers, `WW` often represents the non-negative
          integers. `NN_0` is sometimes used to indicate the non-negative integers, and `NN^**` or
          `NN^+` are sometimes used to indicate the positive integers.
          <el/>
          To avoid ambiguity, the following symbols are recommended:
          <table>
            <tr><th>Set</th><th>Symbol</th></tr>
            <tr><td>integers</td><td>`ZZ`</td></tr>
            <tr><td>positive integers</td><td>`ZZ^+`</td></tr>
            <tr><td>non-negative integers</td><td>`ZZ^**`</td></tr>
            <tr><td>negative integers</td><td>`ZZ^-`</td></tr>
          </table>
          On this web site, `NN` will denote the positive integers.
        </li>
        <li>
          `WW`: This represents the <imp>whole numbers</imp>, which are usually defined to be the non-negative
          integers. But `WW` is occasionally used to represent the positive integers, so to avoid ambiguity it may be
          best to use the symbols above. On this web site, `WW` represents the non-negative integers.
        </li>
        <li>
          `QQ`: This represents the <imp>rational numbers</imp>, which are all the numbers that can be represented as
          an integer divided by a natural number (a positive integer).
        </li>
        <li>
          `RR`: This represents the <imp>real numbers</imp>.
        </li>
        <li>
          `CC`: This represents the <imp>complex numbers</imp>.
        </li>
        <li>
          `UU`: This is the <imp>universe of discourse</imp>, which is a set that represents the overall framework of
          the given situation. Usually this is some standard set such as `RR` or `ZZ`.
        </li>
      </ul>
      
      Notation such as `QQ^+` for positive rational numbers or `RR^(>=0)` for non-negative real numbers is sometimes
      used.
    </definition>

    <definition id="dSubSuperSet" name="subset" defines="properSubset superset properSuperset"
                shortMath="(AA x in A)(x in B)">
      A <imp>subset</imp> of a set `B` is another set `A` such that:
      <subdef>`(AA x in A)(x in B)`</subdef>
      This definition says that all elements in `A` exist in `B`.
      If `A` is a subset of `B`, we write `A sube B`. Note that a set is always a subset of itself, and `O/` is a
      subset of every set. If `A` is a subset of `B` and `A != B`, then we write `A sub B` and say that `A` is a
      <imp>proper subset</imp> of `B`. Notice how the `sub` and `sube` symbols resemble the `&lt;` and `&lt;=` symbols.
      The negated forms of these symbols are `!sub` and `!sube`.
      <el/>
      A <imp>superset</imp> of a set `B` is another set `A` such that `B sube A`. We can write `A supe B` to denote
      this. If `A` is a superset of `B` and `A != B`, we say `A` is a <imp>proper superset</imp> of `B`, and we write
      `A sup B`. The negated forms are `!sup` and `!supe`.
    </definition>

    <definition id="dUnion" name="union" shortMath="(AA x in C)(x in A or x in B)">
      The <imp>union</imp> of two sets `A` and `B` is a set `C` such that:
      <subdef>`(AA x in C)(x in A or X in B)`</subdef>
      This definition says that the union of `A` and `B` contains all of the elements that exist in either `A` or `B`
      (or both). The union of `A` and `B` is written `A uu B` (read "`A` union `B`"). Union is commutative,
      associative, and <r ref="tUnionIsDistributive">distributive</r>.
    </definition>

    <definition id="dIntersection" name="intersection" shortMath="(AA x in C)(x in A and x in B)">
      The <imp>intersection</imp> of two sets `A` and `B` is a set `C` such that:
      <subdef>`(AA x in C)(x in A and x in B)`</subdef>
      This definition says that the intersection of `A` and `B` contains all the elements that exist in both `A` and
      `B`. The intersection of `A` and `B` is written `A nn B` (read "`A` intersect `B`"). Intersection is commutative,
      associative, and <r ref="tIntersectionIsDistributive">distributive</r>.
    </definition>

    <definition id="dSetDifference" name="set difference" shortMath="(AA x in C)(x in A and x !in B)">
      The <imp>difference</imp> of two sets `A` and `B` is a set `C` such that:
      <subdef>`(AA x in C)(x in A and x !in B)`</subdef>
      This definition says that the difference of `A` and `B` contains all elements that exist in `A` but not in `B`.
      The difference of `A` and `B` is written `A-B` (read "`A` minus `B`").
    </definition>

    <definition id="dSetComplement" name="set complement" shortMath="UU-A" tags="U">
      The <imp>complement</imp> of a set `A` is equal to `UU-A`, where `UU` is the universe of discourse. The complement
      of `A` is written `A'`. So if `x in A` then `x !in A'`, and vice versa.
      Because the set complement operation depends on the universe of discourse, it is only
      meaningful if a universe has been defined (or can be assumed).
    </definition>

    <definition id="dPowerSet" name="power set" tags="powerSet" shortMath="{S:S sube A}">
      Given a set `A`, the <imp>power set</imp> of `A` (written `PS(A)`) is the set containing all subsets of `A`
      (including `A` itself):
      <subdef>`PS(A) = {S:S sube A}`</subdef>
      Note that the power set of the empty set is a set containing the empty set (ie, {`O/`}), not the empty set
      itself. Power set is <r ref="tPowerSetOverIntersection">distributive over intersection</r>, but not over union.
    </definition>

    <definition id="dCartesianProduct" name="cartesian product" defines="setProduct setFactor"
                shortMath="{(x,y):x in A and y in B}">
      The <imp>cartesian product</imp> of two sets `A` and `B` is a third set containing all possible ordered pairs
      `(x,y)` where `x in A` and `y in B`.
      <subdef>`A xx B = {(x,y) : x in A and y in B}`</subdef>
      `A` and `B` are called <imp>factors</imp> of `A xx B`. The cartesian product is also known as the <imp>cross
      product</imp>, or simply the <imp>product</imp>. The cartesian product is not associative or commutative, but
      <r ref="tSetProductIsDistributive">it is distributive</r>.
      <el/>
      More generally, the cartesian product of `N` sets `S_1 xx S_2 xx ... xx S_N` is a set containing all possible
      ordered lists `(c_1, c_2, ..., c_N)` where `c_i in S_i` (ie, `c_1 in S_1, c_2 in S_2`, etc).
    </definition>
    
    <definition id="dCardinality" name="cardinality">
      The <imp>cardinality</imp> of a set is the number of elements it contains. The cardinality of a set `A` is
      written `|A|`.
    </definition>

    <definition id="dDisjoint" name="disjoint" shortMath="A nn B = O/">
      Two sets `A` and `B` are disjoint if they have no elements in comment. That is, if `A nn B = O/`.
    </definition>

    <definition id="dInterval" name="interval" shortMath="(AA u,v in S)(AA x in RR)(u &lt; x &lt; v => x in S)">
      Given `S sube RR`, `S` is an interval if:
      <subdef>`(AA u,v in S)(AA x in RR)(u &lt; x &lt; v => x in S)`</subdef>
      By this definition, `O/` is not an interval, any set containing a single real number is an interval, and
      any finite set containing more than one real number is not an interval (because given any two distinct
      elements of the set, there would be a real number between them that is not in the set).
    </definition>
  </topic>

  <!-- Sets : Hypotheses -->
  <topic id="topSetHypos" name="Hypotheses" description="Hypotheses and theorems related to sets.">
    <hypothesis id="hPowerSetCardinality" name="Cardinality of a power set" shortMath="2^|A|"
                tags="cardinality powerSet">
      The cardinality of the power set `PS(A)` is equal to `2^|A|`, which is the number of permutations that can be
      formed from elements of `A`.
    </hypothesis>

    <hypothesis id="hSetProductCardinality" name="Cardinality of the cartesian product" tags="cardinality setProduct"
                shortMath="|A||B|">
      The cardinality of the cartesian product `A xx B` is equal to `|A||B|`.
    </hypothesis>

    <theorem id="tSubsetOfSubset" name="Subset is transitive" shortMath="`A sube B and B sube C => A sube C`">
      <text>If `A sube B and B sube C`, then `A sube C`.</text>
      <proof>
        Given `x in A`, we need to show that `x in C`. By <d ref="subset"/> we know that if `x in A`, then `x in B`,
        and if `x in B`, then `x in C`. Therefore, `x in C`.
      </proof>
    </theorem>

    <theorem id="tSubsetImpliesSubPowerSet" name="Subset implies sub-power-set" tags="powerSet"
             shortMath="A sube B => PS(A) sube PS(B)">
      <text>If `A sube B`, then `PS(A) sube PS(B)`.</text>
      <proof>
        Given `S in PS(A)`, we need to show that `S in PS(B)`. By <d ref="power set"/>, we know that
        `S sube A`, and by <r ref="tSubsetOfSubset"/> we know that `S sube B`. And if `S sube B`, then `S in PS(B)`,
        by the definition of power set. Therefore, `PS(A) sube PS(B)`.
      </proof>
    </theorem>

    <corollary id="tSubPowerSetImpliesSubset" name="Sub-power-set implies subset" ref="tSubsetImpliesSubPowerSet"
               tags="powerSet" shortMath="PS(A) sube PS(B) => A sube B">
      <text>If `PS(A) sube PS(B)`, then `A sube B`.</text>
      <proof>
        We know that `A in PS(A)` by <d ref="power set"/>, and by <d ref="subset"/> we know that `A in PS(B)`, which
        means that `A sube B`.
      </proof>
    </corollary>

    <theorem id="tSubsetOfIntersections" name="Subset of intersections"
             shortMath="A sube B and C sube D => A nn C sube B sube D">
      <text>If `A sube B` and `C sube D`, then `A nn C sube B nn D`.</text>
      <proof>
        Given `z in A nn C`, we need to show that `z in B nn D`. If `z in A nn C`, then by <d ref="intersection"/>,
        we know that `z in A` and `z in C`. Then, by <d ref="subset"/>, we know that `z in B` and `z in D`, which means
        that `z in B nn D`, as desired. Therefore `A nn C sube B nn D`.
      </proof>
    </theorem>

    <theorem id="tSymmetricSubsetEquality" name="Symmetric subset equality" shortMath="A sube B and B sube A => A=B">
      <text>If `A sube B` and `B sube A`, then `A=B`.</text>
      <proof>By <d ref="subset"/> we know that every element in `A` is in `B`, and every element in `B` is in `A`.
        Thus, all possible elements are in both sets or neither. Since there are no differences between the sets,
        they must be equal.
      </proof>
    </theorem>
    
    <theorem id="tSetDeMorgan" shortName="De Morgan's Law" name="De Morgan's Law for Sets">
      <text>
        For any sets `A` and `B`:
        <ol type="i">
          <li>`(A uu B)' = A' nn B'`, and</li>
          <li>`(A nn B)' = A' uu B'`</li>
        </ol>
      </text>
      <proof>
        This proof has two parts.
        <ol>
          <li>
            To prove (1) above, we will show that the two sides of the equation are subsets of each other.
            <ol type="a">
              <li>First we'll show that `(A uu B)' sube A' nn B'`.
                Given `x in (A uu B)'`, we need to show that `x in A' nn B'`. We know that
                `x !in A uu B`, by <d ref="set complement"/>. Then, because `x !in A uu B`, we know that
                `x !in A and x !in B`, by <d ref="union"/>. If `x !in A`, then `x in A'`, by definition. Similarly,
                `x in B'`. Therefore, `x in A' nn B'`.
              </li>
              <li>Now we'll show that `A' nn B' sube (A uu B)'`. Given `x in A' nn B'`, we need to show that
                `x in (A uu B)'`. We know that `x in A'` and `x in B'`, by <d ref="intersection"/>. Then by
                <d ref="set complement"/>, we know that `x !in A` and `x !in B`. Then, `x !in A uu B`, which means
                that `x in (A uu B)'`, as desired.
              </li>
            </ol>
            Since they are subsets of each other, we know that they are equal by <r ref="tSymmetricSubsetEquality"/>.
          </li>

          <li>
            To prove (2) above, we will show that the two sides of the equation are subsets of each other.
            <ol type="a">
              <li>First we'll show that `(A nn B)' sube A' uu B'`. Given `x in (A nn B)'`, we need to show that
                `x in A' uu B'`. We know that `x !in A nn B`, by <d ref="set complement"/>, which means
                that `x !in A and x !in B`. This means `x in A' and x in B'`, which means that `x in A' uu B'`, as
                desired.
              </li>
              <li>Now we'll show that `A' uu B' sube (A nn B)'`. Given `x in A' uu B'`, we need to show that
                `x in (A nn B)'`. We know that `x in A' or x in B'`, by <d ref="union"/>, which means that
                `x !in A or x !in B`, by <d ref="set complement"/>. This means that `x` is not in both `A` and `B`,
                so it's not in `A nn B`, which means it is in `(A nn B)'`.
              </li>
            </ol>
            Since they are subsets of each other, we know that they are equal by <r ref="tSymmetricSubsetEquality"/>.
          </li>
        </ol>
      </proof>
    </theorem>

    <theorem id="tSubsetOfPowerSets" name="Subset of power sets" tags="subset powerSet"
             shortMath="A sube B and C sube D => A xx C sube B xx D">
      <text>If `A sube B and C sube D`, then `A xx C sube B xx D`.</text>
      <proof>Given any `(x,y) in A xx C`, we need to be able to show that `(x,y) in B xx D`. We know from
        <d ref="setProduct"/> that if `(x,y) in A xx C`, then `x in A` and `y in C`. And given that
        `A sube B and C sube D`, we further know that `x in B and y in D`, by <d ref="subset"/>. And then it becomes
        clear that `(x,y) in B xx D`.
      </proof>
    </theorem>

    <theorem id="tCancelingSubsetFactors" name="Canceling subset factors" tags="subset setProduct setFactor"
             shortMath="A xx B sube A xx C and A != O/ => B sube C">
      <text>If `A xx B sube A xx C and A != O/`, then `B sube C`.</text>
      <proof>
        Given `y in B`, we need to show that `y in C`. Because `A != O/`, we know `A` contains at least one element,
        so we'll take `x in A` as well. Now `(x,y) in A xx B`, and by <d ref="subset"/>, we know that
        `(x,y) in A xx C`, which means that `y in C`, by <d ref="setProduct"/>.
      </proof>
    </theorem>

    <corollary id="tCancelingEqualSetFactors" name="Canceling equal set factors" ref="tCancelingSubsetFactors"
               tags="setProduct setFactor" shortMath="A xx B = A xx C and A != O/ => B = C">
      <text>If `A xx B = A xx C and A != O/`, then `B = C`.</text>
      <proof>
        To show that `B = C`, we will show that `B sube C` and `C sube B`. Since `A xx B = A xx C`, we know that
        `A xx B sube A xx C`, by <d ref="subset"/>. And given that `A != O/`, we can apply
        <r ref="tCancelingSubsetFactors"/> to show that `B sube C`. Similarly, we can show that `C sube B`. Therefore,
        by <r ref="tSymmetricSubsetEquality"/>, `B = C`.
      </proof>
    </corollary>

    <theorem id="tIntersectionIsDistributive" name="Intersection is distributive"
             shortMath="A nn (B uu C) = (A nn B) uu (A nn C)">
      <text>`A nn (B uu C) = (A nn B) uu (A nn C)`</text>
      <proof>
        To prove the equality, we will show that each side of the equation is a subset of the other.

        <ol>
          <li>Suppose `x in A nn (B uu C)`. We know that `x in A and x in B uu C`. The union gives two possibilities,
            and we'll examine both:
            <ol type="a">
              <li>`x in B`. If `x in B`, then we know `x in A nn B`, and that `x in (A nn B) uu (A nn C)`, by
                <d ref="intersection"/> and <d ref="union"/>, respectively.
              </li>
              <li>`x in C`. By a parallel argument, if `x in C`, then `x in (A nn B) uu (A nn C)`.</li>
            </ol>
            Because `x in (A nn B) uu (A nn C)` in both cases, we know that `A nn (B uu C) sube (A nn B) uu (A nn C)`.
          </li>
          <li>Now suppose `x in (A nn B) uu (A nn C)`. We need to show that `x in A nn (B uu C)`. The union gives two
            cases, which we'll examine:
            <ol type="a">
              <li>`x in (A nn B)`. In this case `x in A` and `x in B`. Then it's clear that `x in B uu C`, and
                `x in A nn (B uu C)`.
              </li>
              <li>`x in (A nn C)`. By a parallel argument, `x in A nn (B uu C)`.</li>
            </ol>
            Because `x in A nn (B uu C)` in both cases, we know that `(A nn B) uu (A nn C) sube A nn (B uu C)`.
          </li>
        </ol>
        
        Because the two sets are subsets of each other, we know they are equal by <r ref="tSymmetricSubsetEquality"/>.
      </proof>
    </theorem>

    <theorem id="tUnionIsDistributive" name="Union is distributive"
             shortMath="A uu (B nn C) = (A uu B) nn (A uu C)">
      <text>`A uu (B nn C) = (A uu B) nn (A uu C)`</text>
      <proof>
        To prove the equality, we will show that each side of the equation is a subset of the other.

        <ol>
          <li>Suppose `x in A uu (B nn C)`. The union gives two possibilities, and we'll examine both:
            <ol type="a">
              <li>`x in A`. If `x in A`, then we know `x in A uu B and x in A uu C`, and that
                `x in (A uu B) nn (A uu C)`, by <d ref="union"/> and <d ref="intersection"/>, respectively.
              </li>
              <li>`x in (B nn C)`. We know that `x in B and x in C`. Then clearly `x in A uu B and x in A uu C`, and so
                then `x in (A uu B) nn (A uu C)`.
              </li>
            </ol>
            Because `y in (A uu B) nn (A uu C)` in both cases, we know that `A uu (B nn C) sube (A uu B) nn (A uu C)`.
          </li>
          <li>Now suppose `y in (A uu B) nn (A uu C)`. We need to show that `y in A uu (B nn C)`. By
            <d ref="intersection"/>, we know that `y in A uu B and y in A uu C`. Now either `y in A` or `y !in A`,
            and we'll examine both cases.
            <ol type="a">
              <li>`y in A`. If `y in A`, then clearly `y in A uu (B nn C)`.</li>
              <li>`y !in A`. If `y !in A`, then in order for `y in A uu B and A in A uu C` to be true,
                `y in B and y in C` must be true. Therefore `y in B nn C`, and then clearly `y in A uu (B nn C)`.
              </li>
            </ol>
            Because `y in A uu (B nn C)` in both cases, we know that `(A uu B) nn (A uu C) sube A uu (B nn C)`.
          </li>
        </ol>
        
        Because the two sets are subsets of each other, we know they are equal by <r ref="tSymmetricSubsetEquality"/>.
      </proof>
    </theorem>

    <theorem id="tSetProductIsDistributive" name="Cartesian product is distributive" tags="setProduct">
      <text>
        The <r ref="cartesian product"/> distributes over union, intersection, and subtraction:
        <ul>
          <li>`A xx (B uu C) = (A xx B) uu (A xx C)`</li>
          <li>`A xx (B nn C) = (A xx B) nn (A xx C)`</li>
          <li>`A xx (B - C) = (A xx B) - (A xx C)`</li>
        </ul>
      </text>
      <proof>
        This proof is broken up into three sub-proofs: <r ref="tSetProductDistributesOverUnion">cartesian product
        distributes over union</r>, <r ref="tSetProductDistributesOverIntersection">cartesian product distributes
        over intersection</r>, and <r ref="tSetProductDistributesOverDifference">cartesian product distributes
        over difference</r>.
      </proof>
    </theorem>

    <theorem id="tSetProductDistributesOverUnion" shortName="Cartesian product is distributive"
             name="Cartesian product distributes over union" shortMath="A xx (B uu C) = (A xx B) uu (A xx C)">
      <text>`A xx (B uu C) = (A xx B) uu (A xx C)`</text>
      <proof>
        To prove that the two sets are equal, we'll show that they are subsets of each other.
        <ol type="1">
          <li>Given `(x,y) in A xx (B uu C)`, we need to show that `(x,y) in (A xx B) uu (A xx C)`. By
            <d ref="setProduct"/>, we know that `x in A` and `y in B uu C`. This gives two cases:
            <ol type="a">
              <li>`y in B`. If `y in B`, then `(x,y) in A xx B`, and so `(x,y) in (A xx B) uu (A xx C)`.</li>
              <li>`y in C`. By a parallel argument, `(x,y) in (A xx B) uu (A xx C)`.</li>
            </ol>
            In both cases, `(x,y) in (A xx B) uu (A xx C)`, so `A xx (B uu C) sube (A xx B) uu (A xx C)`.
          </li>
          <li>
            Given `(x,y) in (A xx B) uu (A xx C)`, we need to show that `(x,y) in A xx (B uu C)`. The union gives
            two cases:
            <ol type="a">
              <li>
                `(x,y) in (A xx B)`. By <d ref="setProduct"/>, we know that `x in A and y in B`. Therefore,
                `y in B uu C`, so `(x,y) in A xx (B uu C)`.
              </li>
              <li>`(x,y) in (A xx C)`. By a parallel argument, `(x,y) in A xx (B uu C)`.</li>
            </ol>
            In both cases, `(x,y) in A xx (B uu C)`, so `(A xx B) uu (A xx C) sube A xx (B uu C)`.
          </li>
        </ol>
        Because each side of the equation is a subset of the other, they must be equal.
      </proof>
    </theorem>

    <theorem id="tSetProductDistributesOverIntersection" shortName="Cartesian product is distributive"
             name="Cartesian product distributes over intersection" shortMath="A xx (B nn C) = (A xx B) nn (A xx C)">
      <text>`A xx (B nn C) = (A xx B) nn (A xx C)`</text>
      <proof>
        To prove that the two sets are equal, we'll show that they are subsets of each other.
        <ol type="1">
          <li>Given `(x,y) in A xx (B nn C)`, we need to show that `(x,y) in (A xx B) nn (A xx C)`. By
            <d ref="setProduct"/>, we know that `x in A` and `y in B nn C`, so clearly
            `(x,y) in (A xx B) and (x,y) in (A xx C)`. In other words, `(x,y) in (A xx B) nn (A xx C)`, so
            `A xx (B nn C) sube (A xx B) nn (A xx C)`.
          </li>
          <li>
            Given `(x,y) in (A xx B) nn (A xx C)`, we need to show that `(x,y) in A xx (B nn C)`.
            We know that `(x,y) in (A xx B) and (x,y) in (A xx C)`. By <d ref="setProduct"/>,
            `x in A and y in B and y in C`. Therefore, `y in B nn C` and `(x,y) in A xx (B nn C)`,
            so `(A xx B) nn (A xx C) sube A xx (B nn C)`.
          </li>
        </ol>
        Because each side of the equation is a subset of the other, they must be equal.
      </proof>
    </theorem>

    <theorem id="tSetProductDistributesOverDifference" shortName="Cartesian product is distributive"
             name="Cartesian product distributes over difference" shortMath="A xx (B - C) = (A xx B) - (A xx C)">
      <text>`A xx (B - C) = (A xx B) - (A xx C)`</text>
      <proof>
        To prove that the two sets are equal, we'll show that they are subsets of each other.
        <ol type="1">
          <li>
            Given `(x,y) in A xx (B - C)`, we need to show that `(x,y) in (A xx B) - (A xx C)`. By
            <d ref="setProduct"/>, we know that `x in A` and `y in B - C`, which means that `y in B and y !in C`,
            by <d ref="set difference"/>. That means `(x,y) in (A xx B)` but `(x,y) !in (A xx C)`, and so
            `(x,y) in (A xx B) - (A xx C)`. Therefore, `A xx (B - C) sube (A xx B) - (A xx C)`.
          </li>
          <li>
            Given `(x,y) in (A xx B) - (A xx C)`, we need to show that `(x,y) in A xx (B - C)`.
            We know that `(x,y) in (A xx B) and (x,y) !in (A xx C)`. By <d ref="setProduct"/>,
            `x in A and y in B and y !in C`. Therefore, `y in B - C` and `(x,y) in A xx (B - C)`,
            so `(A xx B) - (A xx C) sube A xx (B - C)`.
          </li>
        </ol>
        Because each side of the equation is a subset of the other, they must be equal.
      </proof>
    </theorem>

    <theorem id="tPowerSetOverIntersection" name="Power set distributes over intersection"
             tags="set powerSet" shortMath="PS(A nn B) = PS(A) nn PS(B)">
      <text>`PS(A nn B) = PS(A) nn PS(B)` (<r ref="power set"/> distributes over intersection)</text>
      <proof>
        We will prove the equality by showing that the two sets are subsets of each other.
        <ol type="1">
          <li>
            Given `S in PS(A nn B)`, `S sube A nn B` by <d ref="power set"/>. Clearly, then, `S sube A` and `S sube B`.
            And this means that `S in PS(A)` and `S in PS(B)`, so `S in PS(A) nn PS(B)`, and
            `PS(A nn B) sube PS(A) nn PS(B)`.
          </li>
          <li>
            Given `T in PS(A) nn PS(B)`, we know that `T sube A and T sube B` by <d ref="power set"/>, and so
            `T sube A nn B`, which means `T in PS(A nn B)`, so `PS(A) nn PS(B) sube PS(A nn B)`.
          </li>
        </ol>
        Thus, `PS(A nn B) = PS(A) nn PS(B)`.
        <el/>
        Note that power set does not distribute over union (ie, `PS(A uu B) = PS(A) uu PS(B)` is not true in general).
        As a counterexample, consider the case where `A={1,2}` and `B={3,4}`. Then `A uu B = {1,2,3,4}`, which means
        that `{1,2,3,4} in PS(A uu B)`. However, `PS(A) = {O/,{1},{2},{1,2}}` and `PS(B) = {O/,{3},{4},{3,4}}`.
        Clearly, `{1,2,3,4} !in PS(A) uu PS(B)`, so `PS(A uu B) != PS(A) uu PS(B)` in this case.
      </proof>
    </theorem>
  </topic>
</topic>

<!-- Functions -->
<topic id="topFunctions" name="Functions" description="Functions are sets of ordered pairs mapping from a domain to a codomain.">
  <!-- Functions : Definitions -->
  <topic id="topFunctionDefs" name="Definitions" description="The definitions of functions and related terms.">
    <definition id="dFunction" name="a function" defines="function domain codomain"
                shortMath='f:A->B = S, S sube A xx B'>
      A <imp>function</imp> from `A` to `B` is set of ordered pairs `S sube A xx B` such that:
      <subdef>
        <ol type="a">
          <li>`(AA u in A)(EE v in B)((u,v) in S)`, and</li>
          <li>`(AA u in A)(AA v,w in B)((u,v) in S and (u,w) in S => v=w)`</li>
        </ol>
      </subdef>

      For sets `A` and `B`, "`f:A->B`" means `f` is a function from `A` to `B`. If `f` is a function, then
      "`f(u)=v`" means `(u,v) in f`.
      <el/>
      The set `A` is called the function's <imp>domain</imp> and the set `B` is called the function's
      <imp>codomain</imp>. The above definition basically says that a) for every element `u` in `A`, `f(u) in B`,
      and b) if `f(u)=v and f(u)=w`, then `v=w` (ie, each element of the function's domain maps to exactly one
      element of the function's codomain). The word "range" is sometimes used to refer to a function's codomain,
      and sometimes to refer to its <r ref="image set"/>.
    </definition>

    <definition id="dImageSet" name="image set" defines="imageSet" shortMath="{f(t):t in A}">
      The <imp>image set</imp> of a function is the subset of the function's <r ref="codomain"/>
      onto which elements of its <r ref="domain" /> are mapped.
      <el/>
      The image set of a function `f:A->B`, is defined as
      <subdef>`{f(t):t in A}`</subdef>
      and may be written as `Im(f) or f(A)`.
    </definition>

    <definition id="dSurjective" name="surjective" shortMath="Im(f)=B">
      A function is <imp>surjective</imp> if the function's image set equals its codomain.
      <el/>
      A function `f:A->B` is surjective (or "<imp>onto</imp>") if
      <subdef>`(AA v in B)(EE u in A)(f(u)=v)</subdef>
      More concisely, `f` is surjective if `Im(f)=B`. This essentially means that every element of the function's
      codomain is mapped to by some element of its domain.
    </definition>

    <definition id="dInjective" name="injective" shortMath="(AA u,w in A)(f(u)=f(w) => u=w)">
      A function is <imp>injective</imp> (or "<imp>one-to-one</imp>") if no element of its
      <r ref="codomain"/> is mapped to by more than one element of its domain.
      <el/>
      A function `f:A->B` is injective if
      <subdef>`(AA u,w in A)(f(u)=f(w) => u=w)`</subdef>
      This means that no element of the function's <r ref="codomain"/> is mapped to by more than one
      element of its domain. In order for a function to be <r ref="invertibleFunction">invertible</r>, it
      must be one-to-one.
    </definition>

    <definition id="dBijective" name="bijective">
      A function is <imp>bijective</imp> if it is both <r ref="surjective"/> and <r ref="injective"/>.
    </definition>

    <definition id="dComposition" name="composition" shortMath="(g@f)(x) = g(f(x))">
      Given `f:A->B` and `g:B->C`, the <imp>composition</imp> of `f` and `g` (written `g@f` and read "`g`
      composition `f`" or "`g` of `f`") is the subset of `A xx C` equal to
      <subdef>`{(u,w) in A xx C : g(f(u))=w}`</subdef>
      In other words, `(u,w) in g@f` means `w=g(f(u))`, and `(g@f)(x) = g(f(x))` for all `x`.
    </definition>

    <definition id="dStrictlyIncreasing" name="strictly increasing" shortMath="(AA x,y in RR)(x&lt;y => f(x)&lt;f(y)">
      For a function `f` with domain `RR`, `f` is <imp>strictly increasing</imp> if:
      <subdef>`(AA x,y in RR)(x&lt;y => f(x)&lt;f(y))`</subdef>
    </definition>
  </topic>

  <!-- Functions : Hypotheses -->
  <topic id="topFunctionHypos" name="Hypotheses" description="Hypotheses and theorems related to functions.">
    <hypothesis id="hBijectiveCardinality" tags="cardinality" shortName="Domain/codomain cardinality"
                name="Domain/codomain cardinality given a bijective function"
                shortMath='f:A->B "where" f "is bijective" => |A|=|B|'>
      If there exists a <r ref="bijective"/> function from `A` to `B`, then `|A|=|B|`.
    </hypothesis>

    <hypothesis id="hBijectivityInFiniteDomains" shortName="Bijectivity in finite, equal domains/codomains"
                name="Surjectivity implies injectivity and vice versa for finite, equal domains and codomains"
                tags="surjective injective bijective">
      Given `f:A->B` where `A=B` and `A` and `B` are finite, any <r ref="surjective"/> or
      <r ref="injective"/> function must be <r ref="bijective"/>.
    </hypothesis>

    <hypoCorollary id="hBijectivityInInfiniteDomains" ref="hBijectivityInFiniteDomains"
                   tags="bijective surjective injective" shortName="Bijectivity in equal, infinite domains/codomains"
               name="Surjectivity does not imply injectivity and vice versa in infinite, equal domains and codomains">
      Given `f:A->A` where `A` is infinite, there exist functions that are <r ref="injective"/> but not
      <r ref="surjective"/> and vice versa.
    </hypoCorollary>

    <theorem id="hEmptyCodomainRule" shortName="Empty codomain rule" shortMath="B=O/ => A=O/"
             name="Empty codomain implies empty domain">
      <text>Given `f:A->B`, if `B=O/`, then `A=O/`.</text>
      <proof>Assume by way of contradiction that `B=O/` but `A!=O/`. Then there is an element `u in A`. By the
        <d ref="function"/>, there exists an element `v in B` such that
        `(u,v) in A xx B`. But `B=O/` so there can be no such element. Therefore, if `B=O/`, then `A=O/`.<br/>
      </proof>
    </theorem>

    <theorem id="hEmptyDomainRule" shortName="Empty domain rule" shortMath="A=O/ => f=O/"
             name="Empty domain implies empty function and image set">
      <text>Given `f:A->B`, if `A=O/`, then `f=O/ and Im(f)=O/`.</text>
      <proof>This theorem is really two theorems in one, so we'll address each separately.
        <ol>
          <li>
            Assume by way of contradiction that `A=O/` but `f!=O/`. Then by <d ref="function"/>, there is an
            element `(u,v) in A xx B`, but because `A=O/`, this cannot be the case. Therefore, if `A=O/`, then `B=O/`.
          </li>
          <li>
            Assume by way of contradiction that `A=O/` but `Im(f)!=O/`. Then, there exists an element `v` in the image
            set. By <d ref="image set"/>, there exists an element `u in A` such that `f(u)=v`. But since `A=O/`, that
            cannot be the case. Therefore, if `A=O/`, then `Im(f)=O/`.
          </li>
        </ol>
      </proof>
    </theorem>

    <hypothesis id="hNumberOfFunctions" shortName="Number of distinct functions" shortMath="|B|^|A|"
                name="Number of distinct functions for a finite domain and codomain">
      The number of distinct functions from a finite domain `A` to a finite codomain `B` is given by
      `|B|^|A|`. This is the number of distinct lists of length `|A|` that can formed using elements
      from `B`.
    </hypothesis>

    <hypothesis id="hNumberOfInjectives" shortName="Number of distinct injective functions" tags="injective"
                name="Number of distinct injective functions for a finite domain and codomain"
                shortMath="(|B|!)/((|B|-|A|)!)">
      The number of distinct injective functions from a finite domain `A` to a finite domain `B` is
      given by `{(0,if |A|>|B|),((|B|!)/((|B|-|A|)!),otherwise):}}`. This is equal to the number of
      permutations of `B` containing `|A|` elements.
    </hypothesis>

    <hypothesis id="hNumberOfSurjectives" shortName="Number of distinct surjective functions" tags="surjective"
                name="Number of distinct surjective functions for a finite domain and codomain"
                shortMath="|B|^(|A|-|B|)xx|B|!">
      The number of distinct surjective functions from a finite domain `A` to a finite domain `B`
      is given by `{(0,if |A|&lt;|B|),(|B|^(|A|-|B|)xx|B|!,otherwise):}}`. This is equal to the number of
      permutations of `B` times the number of unique lists of length `|A|-|B|`
      that can be formed using elements from `B`.
    </hypothesis>

    <hypothesis id="hNumberOfBijectives" tags="bijective" shortName="Number of distinct bijective functions"
                name="Number of distinct bijective functions for a finite domain and codomain" shortMath="|B|!">
      The number of distinct injective functions from a finite domain `A` to a finite domain `B` is
      given by `{(0,if |A|!=|B|),(|B|!,otherwise):}}`. This is equal to the number of permutations of `B`.
    </hypothesis>
  </topic>
</topic>
 
</math:math>
