moved axclass tutorial examples to top dir;
authorwenzelm
Tue Oct 03 18:30:56 2000 +0200 (2000-10-03)
changeset 10134537206cc738f
parent 10133 e187dacd248f
child 10135 c2a4dccf6e67
moved axclass tutorial examples to top dir;
src/HOL/AxClasses/Group.thy
src/HOL/AxClasses/Product.thy
src/HOL/AxClasses/README.html
src/HOL/AxClasses/ROOT.ML
src/HOL/AxClasses/Semigroups.thy
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/HOL/AxClasses/Group.thy	Tue Oct 03 18:30:56 2000 +0200
     1.3 @@ -0,0 +1,124 @@
     1.4 +(*  Title:      HOL/AxClasses/Group.thy
     1.5 +    ID:         $Id$
     1.6 +    Author:     Markus Wenzel, TU Muenchen
     1.7 +*)
     1.8 +
     1.9 +theory Group = Main:
    1.10 +
    1.11 +subsection {* Monoids and Groups *}
    1.12 +
    1.13 +consts
    1.14 +  times :: "'a => 'a => 'a"    (infixl "[*]" 70)
    1.15 +  inverse :: "'a => 'a"
    1.16 +  one :: 'a
    1.17 +
    1.18 +
    1.19 +axclass monoid < "term"
    1.20 +  assoc:      "(x [*] y) [*] z = x [*] (y [*] z)"
    1.21 +  left_unit:  "one [*] x = x"
    1.22 +  right_unit: "x [*] one = x"
    1.23 +
    1.24 +axclass semigroup < "term"
    1.25 +  assoc: "(x [*] y) [*] z = x [*] (y [*] z)"
    1.26 +
    1.27 +axclass group < semigroup
    1.28 +  left_unit:    "one [*] x = x"
    1.29 +  left_inverse: "inverse x [*] x = one"
    1.30 +
    1.31 +axclass agroup < group
    1.32 +  commute: "x [*] y = y [*] x"
    1.33 +
    1.34 +
    1.35 +subsection {* Abstract reasoning *}
    1.36 +
    1.37 +theorem group_right_inverse: "x [*] inverse x = (one::'a::group)"
    1.38 +proof -
    1.39 +  have "x [*] inverse x = one [*] (x [*] inverse x)"
    1.40 +    by (simp only: group.left_unit)
    1.41 +  also have "... = one [*] x [*] inverse x"
    1.42 +    by (simp only: semigroup.assoc)
    1.43 +  also have "... = inverse (inverse x) [*] inverse x [*] x [*] inverse x"
    1.44 +    by (simp only: group.left_inverse)
    1.45 +  also have "... = inverse (inverse x) [*] (inverse x [*] x) [*] inverse x"
    1.46 +    by (simp only: semigroup.assoc)
    1.47 +  also have "... = inverse (inverse x) [*] one [*] inverse x"
    1.48 +    by (simp only: group.left_inverse)
    1.49 +  also have "... = inverse (inverse x) [*] (one [*] inverse x)"
    1.50 +    by (simp only: semigroup.assoc)
    1.51 +  also have "... = inverse (inverse x) [*] inverse x"
    1.52 +    by (simp only: group.left_unit)
    1.53 +  also have "... = one"
    1.54 +    by (simp only: group.left_inverse)
    1.55 +  finally show ?thesis .
    1.56 +qed
    1.57 +
    1.58 +theorem group_right_unit: "x [*] one = (x::'a::group)"
    1.59 +proof -
    1.60 +  have "x [*] one = x [*] (inverse x [*] x)"
    1.61 +    by (simp only: group.left_inverse)
    1.62 +  also have "... = x [*] inverse x [*] x"
    1.63 +    by (simp only: semigroup.assoc)
    1.64 +  also have "... = one [*] x"
    1.65 +    by (simp only: group_right_inverse)
    1.66 +  also have "... = x"
    1.67 +    by (simp only: group.left_unit)
    1.68 +  finally show ?thesis .
    1.69 +qed
    1.70 +
    1.71 +
    1.72 +subsection {* Abstract instantiation *}
    1.73 +
    1.74 +instance monoid < semigroup
    1.75 +proof intro_classes
    1.76 +  fix x y z :: "'a::monoid"
    1.77 +  show "x [*] y [*] z = x [*] (y [*] z)"
    1.78 +    by (rule monoid.assoc)
    1.79 +qed
    1.80 +
    1.81 +instance group < monoid
    1.82 +proof intro_classes
    1.83 +  fix x y z :: "'a::group"
    1.84 +  show "x [*] y [*] z = x [*] (y [*] z)"
    1.85 +    by (rule semigroup.assoc)
    1.86 +  show "one [*] x = x"
    1.87 +    by (rule group.left_unit)
    1.88 +  show "x [*] one = x"
    1.89 +    by (rule group_right_unit)
    1.90 +qed
    1.91 +
    1.92 +
    1.93 +subsection {* Concrete instantiation *}
    1.94 +
    1.95 +defs (overloaded)
    1.96 +  times_bool_def:   "x [*] y == x ~= (y::bool)"
    1.97 +  inverse_bool_def: "inverse x == x::bool"
    1.98 +  unit_bool_def:    "one == False"
    1.99 +
   1.100 +instance bool :: agroup
   1.101 +proof (intro_classes,
   1.102 +    unfold times_bool_def inverse_bool_def unit_bool_def)
   1.103 +  fix x y z
   1.104 +  show "((x ~= y) ~= z) = (x ~= (y ~= z))" by blast
   1.105 +  show "(False ~= x) = x" by blast
   1.106 +  show "(x ~= x) = False" by blast
   1.107 +  show "(x ~= y) = (y ~= x)" by blast
   1.108 +qed
   1.109 +
   1.110 +
   1.111 +subsection {* Lifting and Functors *}
   1.112 +
   1.113 +defs (overloaded)
   1.114 +  times_prod_def: "p [*] q == (fst p [*] fst q, snd p [*] snd q)"
   1.115 +
   1.116 +instance * :: (semigroup, semigroup) semigroup
   1.117 +proof (intro_classes, unfold times_prod_def)
   1.118 +  fix p q r :: "'a::semigroup * 'b::semigroup"
   1.119 +  show
   1.120 +    "(fst (fst p [*] fst q, snd p [*] snd q) [*] fst r,
   1.121 +      snd (fst p [*] fst q, snd p [*] snd q) [*] snd r) =
   1.122 +       (fst p [*] fst (fst q [*] fst r, snd q [*] snd r),
   1.123 +        snd p [*] snd (fst q [*] fst r, snd q [*] snd r))"
   1.124 +    by (simp add: semigroup.assoc)
   1.125 +qed
   1.126 +
   1.127 +end
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/HOL/AxClasses/Product.thy	Tue Oct 03 18:30:56 2000 +0200
     2.3 @@ -0,0 +1,20 @@
     2.4 +(*  Title:      HOL/AxClasses/Product.thy
     2.5 +    ID:         $Id$
     2.6 +    Author:     Markus Wenzel, TU Muenchen
     2.7 +*)
     2.8 +
     2.9 +theory Product = Main:
    2.10 +
    2.11 +axclass product < "term"
    2.12 +
    2.13 +consts
    2.14 +  product :: "'a::product => 'a => 'a"    (infixl "[*]" 70)
    2.15 +
    2.16 +
    2.17 +instance bool :: product
    2.18 +  by intro_classes
    2.19 +
    2.20 +defs (overloaded)
    2.21 +  product_bool_def: "x [*] y == x & y"
    2.22 +
    2.23 +end
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/HOL/AxClasses/README.html	Tue Oct 03 18:30:56 2000 +0200
     3.3 @@ -0,0 +1,17 @@
     3.4 +<!-- $Id$ -->
     3.5 +<html>
     3.6 +
     3.7 +<head>
     3.8 +<title>HOL/AxClasses</title>
     3.9 +</head>
    3.10 +
    3.11 +<body>
    3.12 +<h1>HOL/AxClasses</h1>
    3.13 +
    3.14 +These are the HOL examples of the tutorial <a
    3.15 +href="http://isabelle.in.tum.de/doc/axclass.pdf">Using Axiomatic Type
    3.16 +Classes in Isabelle</a>.  See also FOL/ex/NatClass for the natural
    3.17 +number example.
    3.18 +
    3.19 +</body>
    3.20 +</html>
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/HOL/AxClasses/ROOT.ML	Tue Oct 03 18:30:56 2000 +0200
     4.3 @@ -0,0 +1,4 @@
     4.4 +
     4.5 +time_use_thy "Semigroups";
     4.6 +time_use_thy "Group";
     4.7 +time_use_thy "Product";
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/HOL/AxClasses/Semigroups.thy	Tue Oct 03 18:30:56 2000 +0200
     5.3 @@ -0,0 +1,21 @@
     5.4 +(*  Title:      HOL/AxClasses/Semigroups.thy
     5.5 +    ID:         $Id$
     5.6 +    Author:     Markus Wenzel, TU Muenchen
     5.7 +*)
     5.8 +
     5.9 +theory Semigroups = Main:
    5.10 +
    5.11 +consts
    5.12 +  times :: "'a => 'a => 'a"    (infixl "[*]" 70)
    5.13 +
    5.14 +axclass semigroup < "term"
    5.15 +  assoc: "(x [*] y) [*] z = x [*] (y [*] z)"
    5.16 +
    5.17 +
    5.18 +consts
    5.19 +  plus :: "'a => 'a => 'a"    (infixl "[+]" 70)
    5.20 +
    5.21 +axclass plus_semigroup < "term"
    5.22 +  assoc: "(x [+] y) [+] z = x [+] (y [+] z)"
    5.23 +
    5.24 +end