CookBook/Solutions.thy
author Christian Urban <urbanc@in.tum.de>
Thu, 09 Oct 2008 12:58:50 -0400
changeset 21 2356e5c70d98
parent 15 9da9ba2b095b
child 25 e2f9f94b26d4
permissions -rw-r--r--
added a proof and tuned the rest

theory Solutions
imports Main
uses "antiquote_setup.ML"
     "antiquote_setup_plus.ML"
begin

chapter {* Solutions to Most Exercises *}

text {* \solution{fun:revsum} *}

ML {* 
  fun rev_sum t =
  let
   fun dest_sum (Const (@{const_name plus}, _) $ u $ u') = 
                                                      u' :: dest_sum u
     | dest_sum u = [u]
   in
     foldl1 (HOLogic.mk_binop @{const_name plus}) (dest_sum t)
   end;
*}

text {* \solution{fun:makesum} *}

ML {*
  fun make_sum t1 t2 =
      HOLogic.mk_nat (HOLogic.dest_nat t1 + HOLogic.dest_nat t2)
*}

end