# HG changeset patch # User haftmann # Date 1155555977 -7200 # Node ID 58f65fc90cf403f8de672591a76b69eb530bbfe6 # Parent 39964c8dcd54d515d6d766c4e5b559cfee2a0d5a adaptions to improvements diff -r 39964c8dcd54 -r 58f65fc90cf4 src/HOL/ex/Classpackage.thy --- a/src/HOL/ex/Classpackage.thy Mon Aug 14 13:46:16 2006 +0200 +++ b/src/HOL/ex/Classpackage.thy Mon Aug 14 13:46:17 2006 +0200 @@ -211,18 +211,12 @@ with cancel show ?thesis .. qed -interpretation group < monoid +instance group < monoid proof - - fix x :: "'a" + fix x from neutr show "x \<^loc>\ \<^loc>\ = x" . qed -instance group < monoid -proof - fix x :: "'a\group" - from group.neutr show "x \ \ = x" . -qed - lemma (in group) all_inv [intro]: "(x\'a) \ monoid.units (op \<^loc>\) \<^loc>\" unfolding units_def @@ -305,12 +299,17 @@ by default (simp_all add: split_paired_all group_prod_def assoc neutl invl comm) definition - "x = ((2\nat) \ \ \ 3, (2\int) \ \ \ \
3, [1\nat, 2] \ \ \ [1, 2, 3])" - "y = (2 \ int, \
2 \ int) \ \ \ (3, \
3)" + "X a b c = (a \ \ \ b, a \ \ \ b, [a, b] \ \ \ [a, b, c])" + "Y a b c = (a, \
a) \ \ \ \
(b, \
c)" + +definition + "x1 = X (1::nat) 2 3" + "x2 = X (1::int) 2 3" + "y2 = Y (1::int) 2 3" code_generate "op \" \ inv -code_generate (ml, haskell) x -code_generate (ml, haskell) y +code_generate (ml, haskell) X Y +code_generate (ml, haskell) x1 x2 y2 code_serialize ml (-) diff -r 39964c8dcd54 -r 58f65fc90cf4 src/HOL/ex/Codegenerator.thy --- a/src/HOL/ex/Codegenerator.thy Mon Aug 14 13:46:16 2006 +0200 +++ b/src/HOL/ex/Codegenerator.thy Mon Aug 14 13:46:17 2006 +0200 @@ -85,24 +85,24 @@ h :: nat "h = g" -code_alias - "Codegenerator.f" "Mymod.f" - "Codegenerator.g" "Mymod.A.f" - "Codegenerator.h" "Mymod.A.B.f" +code_constname + f "Mymod.f" + g "Mymod.A.f" + h "Mymod.A.B.f" code_generate (ml, haskell) n one "0::int" "0::nat" "1::int" "1::nat" code_generate (ml, haskell) fac -code_generate (ml, haskell) +code_generate xor -code_generate (ml, haskell) +code_generate "op + :: nat \ nat \ nat" "op - :: nat \ nat \ nat" "op * :: nat \ nat \ nat" "op < :: nat \ nat \ bool" "op <= :: nat \ nat \ bool" -code_generate (ml, haskell) +code_generate Pair fst snd Let split swap swapp appl code_generate (ml, haskell) k @@ -114,13 +114,13 @@ fac "op div :: int \ int \ int" "op mod :: int \ int \ int" -code_generate (ml, haskell) +code_generate Inl Inr -code_generate (ml, haskell) +code_generate None Some -code_generate (ml, haskell) +code_generate hd tl "op @" ps qs -code_generate (ml, haskell) +code_generate mut1 mut2 code_generate (ml, haskell) "op @" filter concat foldl foldr hd tl @@ -143,7 +143,7 @@ rotate1 rotate splice -code_generate (ml, haskell) +code_generate foo1 foo3 code_generate (ml, haskell) "op = :: bool \ bool \ bool" @@ -153,9 +153,10 @@ "op = :: 'a + 'b \ 'a + 'b \ bool" "op = :: 'a option \ 'a option \ bool" "op = :: 'a list \ 'a list \ bool" + "op = :: point \ point \ bool" "op = :: mut1 \ mut1 \ bool" "op = :: mut2 \ mut2 \ bool" -code_generate (ml, haskell) +code_generate f g h code_serialize ml (-)