Assignment 2 – A Taste of Proofs
Due Fri 4/14 11:59pm
Consider the function flcon:
#lang racket (define (flcon xs ys) (match xs ['() ys] [(cons hd tl) (cons hd (flcon tl (cons hd ys)))]))
0.
Give the value of the expression (flcon '(S C U N) '(3 9 6)). You can use DrRacket to compute the results.
Give a one sentence English description of what flcon does, in terms of its arguments xs and ys.
—
In exercise 1–4, we will prove (flcon xs (append ys zs)) ≡ (append (flcon xs ys) zs) by induction on xs.
1. For the case xs := '(), we need to show the equivalence
(flcon '() (append ys zs)) ≡ (append (flcon '() ys) zs).
Use the computation rules in the slides to prove it.
2. For the case xs := (cons l ls), what is the induction hypothesis?
3. Use the computation rules in the slides to show the equivalence
(flcon (cons l ls) (append ys zs)) ≡
(cons l (flcon ls (append (cons l ys) zs))).
You may assume that for all w, us and vs, (append (cons w us) vs) ≡ (cons w (append us vs)).
4. Combine exercise 1–3 to show that for all xs, (flcon xs (append ys zs)) ≡ (append (flcon xs ys) zs).
In exercise 4, you may assume that for all l and ls,
(append (flcon (cons l ls) ys) zs) ≡
(cons l (append (flcon ls (cons l ys)) zs)).