Discrete Structures

Lecture Notes, 17 Nov 2010

Last Update: 17 November 2010

Note: NEW or UPDATED material is highlighted

Note: A username and password may be required to access certain documents. Please contact Bill Rapaport.

Index to all lecture notes
…Previous lecture

§4.3: Recursive Definitions (cont'd)

  1. Given Peano's axioms & the recursive definition of "+", we can add;
    can we also multiply?

    1. Recursive definition of "*":

      • base case:

          m * 0 =def 0

      • recursive case:

          m * S(n) =def (m * n) + m

    2. Notes:

      1. The recursive case could also be written:

          m * (n+1) =def (m*n) + m
          which makes it look like the distributive law

      2. If both + and * are thought of as functions that take ordered pairs of natural numbers as I/P,
        then + returns the first element
        and * returns the second element
        when the second element = 0

      3. * is defined in terms of 0, S, and +;
        + was defined in terms of 0 & S;
        0 & S were defined by Peano's axioms;
        Peano's axioms were expressed in terms of FOL & set theory.

    3. E.g.)

      • What is 4*3?

        Use the recursive case to compute this,
        letting m=4 and S(n)=3 (∴ n=2):

          4*3 = 4*S(2), by def of 3 as S(2)
                = (4*2)+4, by rec def of 4*S(2)
                = (4*S(1))+4, by def of 2 as S(1)
                = ((4*1)+4)+4, by rec def of 4*S(1)
                = ((4*S(0))+4)+4, by def of 1 as S(1)
                = (((4*0)+4)+4)+4, by rec def of 4*S(0)
                = (((0)+4)+4)+4, by rec def of 4*0
                = 12, by def of +

  2. We can also define predicates & relations recursively:

    1. The predicate "is divisible by 3" can be defined recursively as follows:

        Notation: "3|n" for: 3 divides n (i.e., n is divisible by 3)
        (where "divides" and "is divisible by" mean
        "evenly divisible with no remainder")

      • Base Case:

          (∀n ≤ 9)[3|n ↔ n ∈ {0,3,6,9}]

          • i.e., there are 4 base cases!

      • Recursive Case:

          (∀n > 9)[3|n ↔ 3|(sum of digits of n)]

    2. E.g.)


        3|975 ↔ 3|(9+7+5), by rec case, because 975 > 9
                  ↔ 3|21, by arithmetic
                  ↔ 3|(2+1), by rec case, because 21 > 9
                  ↔ 3|3, by arithmetic
        But 3|3 is true, by base case
        ∴ 3|975 (in fact, 975/3=325)

    3. E.g.)


        3/325 ↔ 3|(3+2+5) ↔ 3|10 ↔ 3|1+0 ↔ 3|1
        But ¬(3|1), by base case
        ∴ ¬(3|325) (in fact 325/3=108, remainder = 1)

  3. Recursion is the heart of CS!

    1. Church-Turing Thesis:

        A function is "computable" iff it can be expressed recursively

    2. See my "What Is Computation?"

    3. Other things—like set and "strings" (sequences of symbols)—
      can also be defined recursively;
      see "A Recursive Definition of Strings"

    4. And here's a recursive definition of WFF of FOL:

      1. Recursive Def of "Term" of FOL:

        1. Base Case:

            Any variable is a term.
            Any constant is a term.

        2. Recursive Case:

            Let t1, …, tn be terms.
            Let f be an n-place function symbol.
            Then f(t1, …, tn) is a term.

      2. Recursive Def of "WFF" of FOL:

        1. Base Case:

            Let P be an n-place predicate.
            Let t1, …, tn be terms.
            Then the "string" P(t1, …, tn) is a(n atomic) well-formed formula (WFF) of FOL.

        2. Recursive Case:

            Let A,B be WFFs of FOL.
            Let v be a variable.

            1. ¬A
            2. (A ∨ B)
            3. (A ∧ B)
            4. (A → B)
            5. (A ↔ B)
            6. ∀vA
            7. ∃vA

          are (molecular) WFFs of FOL

        3. Closure clause: Nothing else is a WFF of FOL

      3. Let A be a WFF of FOL.
        Then A is a proposition =def A has no free variables.
        And A is a propositional function =def A has a free variable.

      4. E.g.)

        1. If "+" is a function symbol for the addition function,
          then +(x,y) is a term,
          by the recursive case of the definition of "term".

          • For convenience, we can write it as "x+y", instead.

        2. If "Odd" is a predicate, then Odd(x+y) is a WF propositional function,
          by the base case of the def of WFF.

        3. But Even(Odd(x)+Odd(y)) is not WF!

          • Because the base case only allows a term to be the argument of a predicate!

        4. P(a,b), where a,b are constants, is a WF proposition,
          by the base case

        5. Q(c), where c is a constant, is a WF proposition
          by the base case

        6. P(x,y), where x,y are variables, is a WF propositional function, by the base case

        7. ¬P(a,b) is a WF proposition by rec case (i)
          & the base case

        8. ¬Q(c) is a WF proposition by rec case (i) & the base case

        9. (P(a,b) ∨ ¬Q(c)) is a WF proposition by rec case (ii),
          because each of the constitutent WFFs is WF,
          the first one by the base case,
          and the second one by rec case (ii) (& the base case)

        10. ((P(a,b) ∨ ¬Q(c)) → ¬P(a,b)) is a WF proposition
          by rec case (iv),
          because each of the constituent WFFs is WF,
          the first one (i.e., the antecedent) by the previous example
          and the second one (i.e., the consequent) by the third example

        11. ∀x((P(a,b) ∨ ¬Q(c)) → ¬P(a,b)) is a WF proposition
          by rec case (vi),
          because the scope of the quantifier is WF by the previous example.

          • Notes:

            1. This way of doing things doesn't require brackets
              in the recursive definition of quantified propositions

            2. The quantifier's variable, x, is "vacuous":

              • It doesn't appear in the scope.
              • This is odd, but legitimate.

                • Here's a real example: ∀x[2+2=4]

                  • This says: For all things x in the domain, 2+2=4.
                    That's true of anything in any domain!

        12. ∃xP(x), where x is a variable, is WF by rec case (vii),
          because P(x) is a WF propositional function by the base case.

        1. Question:

          • "⊕" is the symbol for exclusive disjunction.
            Let A,B be WFFs of FOL.
            Is (A ⊕ B) a WFF of FOL?

        2. Answer:

          • Not according to the above definition.
          • But surely it "should be" considered as a WFF of FOL, right?
          • Here's how we can use it without changing the definition of WFF:

            • We can define the symbol "⊕" as follows:

                Let A,B be any 2 WFFs of FOL.
                Then let (A ⊕ B) be an abbreviation for:

                  ((A ∨ B) ∧ ¬(A ∧ B))

            • In other words,
              any time that we use (A ⊕ B),
              we would just be being lazy,
              and we should really write out the full definition,
              which is a WFF of FOL.

§§7.1–7.2: Recurrence Relations

  1. Recursive Def (of a sequence {an}):

    1. Normally, an = f(n) "explicitly";
      the nth term of the sequence would be defined directly in terms of n

    2. Questions:

      1. What's the relation between f & h?
      2. Can we compute f, given h?

Next lecture…

Text copyright © 2010 by William J. Rapaport (rapaport@buffalo.edu)
Cartoon links and screen-captures appear here for your enjoyment. They are not meant to infringe on any copyrights held by the creators. For more information on any cartoon, click on it, or contact me.