# HG changeset patch # User haftmann # Date 1153486064 -7200 # Node ID e56fa3c8b1f1693f40477792d35007e3b29c36cf # Parent 0af885e3dabfb09abe5ff9c6c0f06157309b3277 adaption to changes in class_package diff -r 0af885e3dabf -r e56fa3c8b1f1 src/HOL/ex/Classpackage.thy --- a/src/HOL/ex/Classpackage.thy Fri Jul 21 14:47:22 2006 +0200 +++ b/src/HOL/ex/Classpackage.thy Fri Jul 21 14:47:44 2006 +0200 @@ -13,26 +13,26 @@ assumes assoc: "x \<^loc>\ y \<^loc>\ z = x \<^loc>\ (y \<^loc>\ z)" instance nat :: semigroup - "m \ n == m + n" + "m \ n \ m + n" proof fix m n q :: nat from semigroup_nat_def show "m \ n \ q = m \ (n \ q)" by simp qed instance int :: semigroup - "k \ l == k + l" + "k \ l \ k + l" proof fix k l j :: int from semigroup_int_def show "k \ l \ j = k \ (l \ j)" by simp qed instance (type) list :: semigroup - "xs \ ys == xs @ ys" + "xs \ ys \ xs @ ys" proof fix xs ys zs :: "'a list" show "xs \ ys \ zs = xs \ (ys \ zs)" proof - - from semigroup_list_def have "\xs ys::'a list. xs \ ys == xs @ ys". + from semigroup_list_def have "\xs ys\'a list. xs \ ys \ xs @ ys" . thus ?thesis by simp qed qed @@ -41,28 +41,25 @@ fixes one :: 'a ("\<^loc>\") assumes neutl: "\<^loc>\ \<^loc>\ x = x" -instance nat :: monoidl - "\ == 0" +instance monoidl_num_def: nat :: monoidl and int :: monoidl + "\ \ 0" + "\ \ 0" proof fix n :: nat - from semigroup_nat_def monoidl_nat_def show "\ \ n = n" by simp -qed - -instance int :: monoidl - "\ == 0" -proof + from monoidl_num_def show "\ \ n = n" by simp +next fix k :: int - from semigroup_int_def monoidl_int_def show "\ \ k = k" by simp + from monoidl_num_def show "\ \ k = k" by simp qed instance (type) list :: monoidl - "\ == []" + "\ \ []" proof fix xs :: "'a list" show "\ \ xs = xs" proof - - from semigroup_list_def have "\xs ys::'a list. xs \ ys == xs @ ys" . - moreover from monoidl_list_def have "\ == []::'a list" by simp + from mult_list_def have "\xs ys\'a list. xs \ ys \ xs @ ys" . + moreover from monoidl_list_def have "\ \ []\'a list" by simp ultimately show ?thesis by simp qed qed @@ -70,13 +67,13 @@ class monoid = monoidl + assumes neutr: "x \<^loc>\ \<^loc>\ = x" -instance (type) list :: monoid +instance monoid_list_def: (type) list :: monoid proof fix xs :: "'a list" show "xs \ \ = xs" proof - - from semigroup_list_def have "\xs ys::'a list. xs \ ys == xs @ ys" . - moreover from monoidl_list_def have "\ == []::'a list" by simp + from mult_list_def have "\xs ys\'a list. xs \ ys \ xs @ ys" . + moreover from monoid_list_def have "\ \ []\'a list" by simp ultimately show ?thesis by simp qed qed @@ -84,22 +81,19 @@ class monoid_comm = monoid + assumes comm: "x \<^loc>\ y = y \<^loc>\ x" -instance nat :: monoid_comm +instance monoid_comm_num_def: nat :: monoid_comm and int :: monoid_comm proof fix n :: nat - from semigroup_nat_def monoidl_nat_def show "n \ \ = n" by simp + from monoid_comm_num_def show "n \ \ = n" by simp next fix n m :: nat - from semigroup_nat_def monoidl_nat_def show "n \ m = m \ n" by simp -qed - -instance int :: monoid_comm -proof + from monoid_comm_num_def show "n \ m = m \ n" by simp +next fix k :: int - from semigroup_int_def monoidl_int_def show "k \ \ = k" by simp + from monoid_comm_num_def show "k \ \ = k" by simp next fix k l :: int - from semigroup_int_def monoidl_int_def show "k \ l = l \ k" by simp + from monoid_comm_num_def show "k \ l = l \ k" by simp qed definition (in monoid) @@ -150,7 +144,7 @@ abbreviation (in monoid) abbrev_npow :: "'a \ nat \ 'a" (infix "\<^loc>\" 75) - "x \<^loc>\ n == npow n x" + "x \<^loc>\ n \ npow n x" lemma (in monoid) npow_def: "x \<^loc>\ 0 = \<^loc>\" @@ -179,11 +173,11 @@ class group_comm = group + monoid_comm -instance int :: group_comm - "\
k == - (k::int)" +instance group_comm_int_def: int :: group_comm + "\
k \ - (k\int)" proof fix k :: int - from semigroup_int_def monoidl_int_def group_comm_int_def show "\
k \ k = \" by simp + from group_comm_int_def show "\
k \ k = \" by simp qed lemma (in group) cancel: @@ -225,12 +219,12 @@ instance group < monoid proof - fix x :: "'a::group" + fix x :: "'a\group" from group.neutr show "x \ \ = x" . qed lemma (in group) all_inv [intro]: - "(x::'a) \ monoid.units (op \<^loc>\) \<^loc>\" + "(x\'a) \ monoid.units (op \<^loc>\) \<^loc>\" unfolding units_def proof - fix x :: "'a" @@ -293,31 +287,32 @@ "x \<^loc>\ k \ pow k x" lemma (in group) int_pow_zero: - "x \<^loc>\ (0::int) = \<^loc>\" + "x \<^loc>\ (0\int) = \<^loc>\" using npow_def pow_def by simp lemma (in group) int_pow_one: - "\<^loc>\ \<^loc>\ (k::int) = \<^loc>\" + "\<^loc>\ \<^loc>\ (k\int) = \<^loc>\" using pow_def nat_pow_one inv_one by simp instance group_prod_def: (group, group) * :: group - mult_prod_def: "x \ y == let (x1, x2) = x; (y1, y2) = y in + mult_prod_def: "x \ y \ let (x1, x2) = x; (y1, y2) = y in (x1 \ y1, x2 \ y2)" - mult_one_def: "\ == (\, \)" - mult_inv_def: "\
x == let (x1, x2) = x in (\
x1, \
x2)" + mult_one_def: "\ \ (\, \)" + mult_inv_def: "\
x \ let (x1, x2) = x in (\
x1, \
x2)" by default (simp_all add: split_paired_all group_prod_def assoc neutl invl) instance group_comm_prod_def: (group_comm, group_comm) * :: group_comm 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 = ((2\nat) \ \ \ 3, (2\int) \ \ \ \
3, [1\nat, 2] \ \ \ [1, 2, 3])" + "y = (2 \ int, \
2 \ int) \ \ \ (3, \
3)" -code_generate "op \" "\" "inv" +code_generate "op \" \ inv code_generate (ml, haskell) x code_generate (ml, haskell) y +code_serialize ml (_) code_serialize ml (-) end