Natural Numbers and Lists Exam - Problem Solutions, Exams of Engineering

Solutions to problems 1-4 from the natural numbers and lists exam, focusing on proving 3≠2 using formal inference rules, tableau proof of equality and append rules for lists, and defining and proving properties of the sum function for natural number lists.

Typology: Exams

Pre 2010

Uploaded on 08/09/2009

koofers-user-jzv-2
koofers-user-jzv-2 🇺🇸

9 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSE 607
Natural Numbers and Lists Exam
Exam # 4 May 6, 2002
This is an open-book and open-notes examination. Do all problems in 80 minutes. Make sure you
justify your steps using the formal inference rules to earn full credit.
1. (10 points) Consider the following theory of natural numbers
A0. x = x
A1. (SUC(x : nat) =0)
A2. SUC(x : nat) = SUC(y : nat) x=y
A3. x:nat + 0 =x
A4. x:nat + SUC(y : nat) = SUC(x+y)
Prove 32.
2. (10 points) Give tableau proof of the following
A0. x=x
A1. ¬(SUC(x : nat) = 0)
A2. SUC(x : nat) = SUC(y : nat) x = y
A3. x: nat + 0 = x
A4. x: nat + SUC(y : nat) = SUC (x+y)
A5. x : nat + 1 = SUC(x)
A6. x : nat + y : nat = y + x
A7. x : nat 0 = 0
A8. x : nat SUC(y : nat) = xy + x
A9. x : nat 1 =x
A10. 0 x : nat =0
A11. 1 x:nat = x
A12. SUC(x : nat) y : nat = x y + y
A13. (x : nat + y : nat) z : nat = xz + y z
G1: x y z [(xy)z = x (y z)]
3. (15 points) Consider the following tableau where APPEND is denoted by ++. You may
  !"$#!% &%('*) #(+)", -
list, etc.
A0. x = x
A1. ¬([ ] = h::t)
A2. ((h1::t1) = (h2::t2)) (h1 = h2) ^ (t1 = t2)
A3. [ ] ++ l = l
A4. (h :: t) ++ l = h :: (t ++ l)
A5. l ++ [ ] = l
A6. l1 ++ ( l2 ++ l3) = (l1 ++ l2) ++ l3
A7. MAP f [ ] = [ ]
A8. MAP f (h :: t) = f(h) :: (MAP f t)
G1. l1 l2 f . MAP f(l1 ++ l2) = MAP f l1 + MAP f l2
pf2

Partial preview of the text

Download Natural Numbers and Lists Exam - Problem Solutions and more Exams Engineering in PDF only on Docsity!

CSE 607

Natural Numbers and Lists Exam Exam # 4 May 6, 2002

This is an open-book and open-notes examination. Do all problems in 80 minutes. Make sure you justify your steps using the formal inference rules to earn full credit.

  1. (10 points) Consider the following theory of natural numbers

A0. x = x A1. (SUC(x : nat) =0) A2. SUC(x : nat) = SUC(y : nat) x=y A3. x:nat + 0 =x A4. x:nat + SUC(y : nat) = SUC(x+y) Prove 3≠2.

  1. (10 points) Give tableau proof of the following

A0. x=x A1. ¬(SUC(x : nat) = 0) A2. SUC(x : nat) = SUC(y : nat) x = y A3. x: nat + 0 = x A4. x: nat + SUC(y : nat) = SUC (x+y) A5. x : nat + 1 = SUC(x) A6. x : nat + y : nat = y + x A7. x : nat • 0 = 0 A8. x : nat • SUC(y : nat) = x•y + x A9. x : nat • 1 =x A10. 0 • x : nat = A11. 1 • x:nat = x A12. SUC(x : nat) • y : nat = x • y + y A13. (x : nat + y : nat) • z : nat = x•z + y • z

G1: ∀x y z [(x•y)•z = x • (y • z)]

  1. (15 points) Consider the following tableau where APPEND is denoted by ++. You may

       !"$#!% &%('*) #(+)", - list, etc.

A0. x = x A1. ¬([ ] = h::t) A2. ((h1::t1) = (h2::t2)) (h1 = h2) ^ (t1 = t2) A3. [ ] ++ l = l A4. (h :: t) ++ l = h :: (t ++ l) A5. l ++ [ ] = l A6. l1 ++ ( l2 ++ l3) = (l1 ++ l2) ++ l A7. MAP f [ ] = [ ] A8. MAP f (h :: t) = f(h) :: (MAP f t) G1. ∀l1 l2 f. MAP f(l1 ++ l2) = MAP f l1 + MAP f l

  1. Consider the following theory of lists. A0. x = x A1. ¬([ ] = h::t)

A2. ((h1::t1) = (h2::t2)).0/21345 5 7678:9 ;=<?>@BA&C76 (h1 = h2) ^ (t1 = t2)

D0E2F(GHGI*J KLJ?J:GNMOJG KQP!R?SM&KKT T7UJG K

list = h :: (t ++ x)

a. (5 points) Define a function sum that sums the natural numbers in a list, e.g sum ( [1 ;2; 3])=6. Using your definition, show that it computes the sum of [1; 2; 3].

b. (5 points) Set up the induction to prove: ∀x: (nat) list y: (nat) list. Sum(x ++ y) = sum(x) ++ sum (y). Identify the formula F you are using in the induction and show the induction goal.

c. (5 points) Do the proof using the definition of sum and assumption A0- A4. You may assume the addition on the natural numbers is defined with all of its properties.