CS计算机代考程序代写 ; Homework 1

; Homework 1
; Spring 2021

; Please have a look at the notes for lectures 1, 2 and 3

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; homework at the end of lecture1.scm

;; You should read Sections 1.1.1 through 1.1.6, and solve Exercises
;; 1.1 through 1.5, in Abelson and Sussman.

;; To prepare for the next class, read Sections 1.1.7 and 1.1.8, as well
;; as Section 1.2.1.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; homework at the end of lecture2.scm

;; in preparation for the next class, please read, in Abelson and Sussman, Section 1.2.1

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; homework at the end of lecture3.scm

;; 1. Exercise 1.7 from A&S
;; 2. Exercise 1.8 from A&S
;
;; 3. Exercise 1.9 from A&S, with additional requirements
;
;; consider two procedures for adding two positive integers
;

(define (my-plus-version-1 a b)
(if (= a 0)
b
(inc (my-plus-version-1 (dec a) b))))

(define (my-plus-version-2 a b)
(if (= a 0)
b
(my-plus-version-2 (dec a) (inc b))))

;; where

(define (inc x) (+ x 1))

(define (dec x) (- x 1))

;; Using the substitution model, illustrate the process generated by each
;; procedure in evaluating (my-plus 4 5). Are the processes recursive or
;; iterative?
;
;; Certify each procedure, using the appropriate technique, as determined
;; by your answer to the classification question above: for the recursive
;; procedure, give a proof based on the size of (one of) the arguments; for
;; the iterative procedure, give a proof which uses an invariant (which you
;; must first discover)