Next: , Previous: , Up: CS389r Homework   [Contents][Index]


4.5 Homework 4

                        Homework Assignment 4
                               CS 389r
                         Unique Number: 53119
                             Fall, 2021

                       Given:  September 28, 2021
                        Due:   October    7, 2021

Here are some web pointers to information that can help you with this homework.

This assignment is based on the material from Moore’s Recursion and Induction notes. Please read through section 11 before attempting to do the homework.

Your homework assignment is to provide solutions for problems 41, 44, 45, (48 – 50).

These problems may ask you to prove something that is not a theorem. In this case, provide a counterexample demonstrating that the conjecture is false for some input. Then propose and prove the “intended” theorem. For example, adding a hypothesis can restrict the domain of input so that the conjecture holds.

Furthermore, for some theorems, you may need to state and prove lemmas to aid in the proof process.

NOTE: After this assignment, we will start using the proof builder. This will allow you to accomplish your homework with much less writing.

Here are some definitions you may wish to use for this (and future) homework assignment(s).

(defun tree-copy (x)
  (if (consp x)
      (cons (tree-copy (car x))
            (tree-copy (cdr x)))
    x))

(defun app (x y)
  (if (consp x)
      (cons (car x) (app (cdr x) y))
    y))

(defun rev (x)
  (if (consp x)
      (app (rev (cdr x)) (cons (car x) nil))
    nil))

(defun mapnil (x)
  (if (consp x)
      (cons nil (mapnil (cdr x)))
    nil))

(defun swap-tree (x)
  (if (consp x)
      (cons (swap-tree (cdr x))
            (swap-tree (car x)))
    x))

(defun mem (e x)
  (if (consp x)
      (if (equal e (car x))
          t
        (mem e (cdr x)))
    nil))

(defun sub (x y)
  (if (consp x)
      (if (mem (car x) y)
          (sub (cdr x) y)
        nil)
    t))

(defun int (x y)
  (if (consp x)
      (if (mem (car x) y)
          (cons (car x) (int (cdr x) y))
        (int (cdr x) y))
    nil))



Next: Homework 5, Previous: Homework 3, Up: CS389r Homework   [Contents][Index]