doc-src/Exercises/2000/a1/Snoc.thy
author kleing
Mon, 29 Dec 2003 06:49:26 +0100
changeset 14333 14f29eb097a3
parent 13739 f5d0a66c8124
permissions -rw-r--r--
\<^bsub> .. \<^esub>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13739
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
     1
(*<*)
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
     2
theory Snoc = Main:
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
     3
(*>*)
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
     4
subsection  {* Lists *}
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
     5
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
     6
text {*
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
     7
Define a primitive recursive function @{text snoc} that appends an element
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
     8
at the \emph{right} end of a list. Do not use @{text"@"} itself.
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
     9
*}
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
    10
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
    11
consts
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
    12
  snoc :: "'a list => 'a => 'a list"
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
    13
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
    14
text {*
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
    15
Prove the following theorem:
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
    16
*}
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
    17
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
    18
theorem rev_cons: "rev (x # xs) = snoc (rev xs) x"
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
    19
(*<*)oops(*>*)
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
    20
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
    21
text {*
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
    22
Hint: you need to prove a suitable lemma first.
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
    23
*}
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
    24
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
    25
(*<*)
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
    26
end
f5d0a66c8124 exercise collection
kleing
parents:
diff changeset
    27
(*>*)