author | Christian Urban <urbanc@in.tum.de> |
Fri, 17 Oct 2008 17:41:34 -0400 | |
changeset 40 | 35e1dff0d9bb |
parent 35 | d5c090b9a2b1 |
child 47 | 4daf913fdbe1 |
permissions | -rw-r--r-- |
theory Solutions imports Base 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