Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I usually can understand structural Induction but i'm getting lost in the base case here. COSC 2300 Exam #2 Part 3: Lists and Trees as
I usually can understand structural Induction but i'm getting lost in the base case here.
COSC 2300 Exam #2 Part 3: Lists and Trees as Inductively Defined Types. The following questions test your understanding of inductively defined types in general use cons, first, and rest to create and process lists. and lists and trees in particular. You may 15 pts.|6. Consider the functions operating on lists defined as follows: (defun square (xs) (if (consp xs) (cons (* (first xs) (first xs)) (square (rest xs))) NIL)) s (defun mul (xs) f (consp xs) (first xs) (mul (rest xs))) Prove using structural induction on lists that (mul (square xs)) (* (mul xs) (mul xs)) = You may use any basic arithmetic facts you like, without giving justification. For example, you can just simply use the following fact without giving it a second thought: Solution: Base case,zs=NIL. Then (mul (square xs)) (mul (mul (square NIL) ) NIL)) = = (* (* (mul (mul NIL) (mul NIL)) xs) (mul xs)) = = Induction case, rs cons(a, rsl). Then (mul (square xs)) (mul = (mul (cons (* a a) (square xsl))) - (* a a) (mul (square xs1))) = (* (* a a) (* (mul xs1) (mul xsl)) By Ind. Hyp = (* (* a (mul xsl)) (* a (mul xsl)) = (* (mul (cons a xs 1)) (mul (cons a xsl))) = (* (mul xs) (mul xs)) (square (cons a xsl))) = COSC 2300 Exam #2 Part 3: Lists and Trees as Inductively Defined Types. The following questions test your understanding of inductively defined types in general use cons, first, and rest to create and process lists. and lists and trees in particular. You may 15 pts.|6. Consider the functions operating on lists defined as follows: (defun square (xs) (if (consp xs) (cons (* (first xs) (first xs)) (square (rest xs))) NIL)) s (defun mul (xs) f (consp xs) (first xs) (mul (rest xs))) Prove using structural induction on lists that (mul (square xs)) (* (mul xs) (mul xs)) = You may use any basic arithmetic facts you like, without giving justification. For example, you can just simply use the following fact without giving it a second thought: Solution: Base case,zs=NIL. Then (mul (square xs)) (mul (mul (square NIL) ) NIL)) = = (* (* (mul (mul NIL) (mul NIL)) xs) (mul xs)) = = Induction case, rs cons(a, rsl). Then (mul (square xs)) (mul = (mul (cons (* a a) (square xsl))) - (* a a) (mul (square xs1))) = (* (* a a) (* (mul xs1) (mul xsl)) By Ind. Hyp = (* (* a (mul xsl)) (* a (mul xsl)) = (* (mul (cons a xs 1)) (mul (cons a xsl))) = (* (mul xs) (mul xs)) (square (cons a xsl))) =Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started