src/HOL/AxClasses/Group.thy
author wenzelm
Sat, 01 Dec 2001 18:52:32 +0100
changeset 12338 de0f4a63baa5
parent 11072 8f47967ecc80
child 14981 e73f8140af78
permissions -rw-r--r--
renamed class "term" to "type" (actually "HOL.type");
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
     1
(*  Title:      HOL/AxClasses/Group.thy
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
     3
    Author:     Markus Wenzel, TU Muenchen
10681
wenzelm
parents: 10134
diff changeset
     4
    License:    GPL (GNU GENERAL PUBLIC LICENSE)
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
     5
*)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
     6
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
     7
theory Group = Main:
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
     8
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
     9
subsection {* Monoids and Groups *}
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    10
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    11
consts
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    12
  times :: "'a => 'a => 'a"    (infixl "[*]" 70)
11072
wenzelm
parents: 10681
diff changeset
    13
  invers :: "'a => 'a"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    14
  one :: 'a
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    15
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    16
12338
de0f4a63baa5 renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents: 11072
diff changeset
    17
axclass monoid < type
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    18
  assoc:      "(x [*] y) [*] z = x [*] (y [*] z)"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    19
  left_unit:  "one [*] x = x"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    20
  right_unit: "x [*] one = x"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    21
12338
de0f4a63baa5 renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents: 11072
diff changeset
    22
axclass semigroup < type
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    23
  assoc: "(x [*] y) [*] z = x [*] (y [*] z)"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    24
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    25
axclass group < semigroup
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    26
  left_unit:    "one [*] x = x"
11072
wenzelm
parents: 10681
diff changeset
    27
  left_inverse: "invers x [*] x = one"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    28
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    29
axclass agroup < group
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    30
  commute: "x [*] y = y [*] x"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    31
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    32
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    33
subsection {* Abstract reasoning *}
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    34
11072
wenzelm
parents: 10681
diff changeset
    35
theorem group_right_inverse: "x [*] invers x = (one::'a::group)"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    36
proof -
11072
wenzelm
parents: 10681
diff changeset
    37
  have "x [*] invers x = one [*] (x [*] invers x)"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    38
    by (simp only: group.left_unit)
11072
wenzelm
parents: 10681
diff changeset
    39
  also have "... = one [*] x [*] invers x"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    40
    by (simp only: semigroup.assoc)
11072
wenzelm
parents: 10681
diff changeset
    41
  also have "... = invers (invers x) [*] invers x [*] x [*] invers x"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    42
    by (simp only: group.left_inverse)
11072
wenzelm
parents: 10681
diff changeset
    43
  also have "... = invers (invers x) [*] (invers x [*] x) [*] invers x"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    44
    by (simp only: semigroup.assoc)
11072
wenzelm
parents: 10681
diff changeset
    45
  also have "... = invers (invers x) [*] one [*] invers x"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    46
    by (simp only: group.left_inverse)
11072
wenzelm
parents: 10681
diff changeset
    47
  also have "... = invers (invers x) [*] (one [*] invers x)"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    48
    by (simp only: semigroup.assoc)
11072
wenzelm
parents: 10681
diff changeset
    49
  also have "... = invers (invers x) [*] invers x"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    50
    by (simp only: group.left_unit)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    51
  also have "... = one"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    52
    by (simp only: group.left_inverse)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    53
  finally show ?thesis .
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    54
qed
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    55
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    56
theorem group_right_unit: "x [*] one = (x::'a::group)"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    57
proof -
11072
wenzelm
parents: 10681
diff changeset
    58
  have "x [*] one = x [*] (invers x [*] x)"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    59
    by (simp only: group.left_inverse)
11072
wenzelm
parents: 10681
diff changeset
    60
  also have "... = x [*] invers x [*] x"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    61
    by (simp only: semigroup.assoc)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    62
  also have "... = one [*] x"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    63
    by (simp only: group_right_inverse)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    64
  also have "... = x"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    65
    by (simp only: group.left_unit)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    66
  finally show ?thesis .
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    67
qed
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    68
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    69
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    70
subsection {* Abstract instantiation *}
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    71
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    72
instance monoid < semigroup
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    73
proof intro_classes
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    74
  fix x y z :: "'a::monoid"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    75
  show "x [*] y [*] z = x [*] (y [*] z)"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    76
    by (rule monoid.assoc)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    77
qed
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    78
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    79
instance group < monoid
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    80
proof intro_classes
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    81
  fix x y z :: "'a::group"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    82
  show "x [*] y [*] z = x [*] (y [*] z)"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    83
    by (rule semigroup.assoc)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    84
  show "one [*] x = x"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    85
    by (rule group.left_unit)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    86
  show "x [*] one = x"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    87
    by (rule group_right_unit)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    88
qed
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    89
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    90
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    91
subsection {* Concrete instantiation *}
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    92
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    93
defs (overloaded)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    94
  times_bool_def:   "x [*] y == x ~= (y::bool)"
11072
wenzelm
parents: 10681
diff changeset
    95
  inverse_bool_def: "invers x == x::bool"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    96
  unit_bool_def:    "one == False"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    97
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    98
instance bool :: agroup
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    99
proof (intro_classes,
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   100
    unfold times_bool_def inverse_bool_def unit_bool_def)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   101
  fix x y z
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   102
  show "((x ~= y) ~= z) = (x ~= (y ~= z))" by blast
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   103
  show "(False ~= x) = x" by blast
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   104
  show "(x ~= x) = False" by blast
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   105
  show "(x ~= y) = (y ~= x)" by blast
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   106
qed
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   107
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   108
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   109
subsection {* Lifting and Functors *}
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   110
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   111
defs (overloaded)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   112
  times_prod_def: "p [*] q == (fst p [*] fst q, snd p [*] snd q)"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   113
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   114
instance * :: (semigroup, semigroup) semigroup
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   115
proof (intro_classes, unfold times_prod_def)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   116
  fix p q r :: "'a::semigroup * 'b::semigroup"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   117
  show
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   118
    "(fst (fst p [*] fst q, snd p [*] snd q) [*] fst r,
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   119
      snd (fst p [*] fst q, snd p [*] snd q) [*] snd r) =
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   120
       (fst p [*] fst (fst q [*] fst r, snd q [*] snd r),
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   121
        snd p [*] snd (fst q [*] fst r, snd q [*] snd r))"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   122
    by (simp add: semigroup.assoc)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   123
qed
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   124
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   125
end