src/HOL/AxClasses/Group.thy
author haftmann
Fri, 17 Jun 2005 16:12:49 +0200
changeset 16417 9bc16273c2d4
parent 14981 e73f8140af78
child 17274 746bb4c56800
permissions -rw-r--r--
migrated theory headers to new format
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
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
     4
*)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
     5
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 14981
diff changeset
     6
theory Group imports Main begin
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
     7
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
     8
subsection {* Monoids and Groups *}
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
     9
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    10
consts
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    11
  times :: "'a => 'a => 'a"    (infixl "[*]" 70)
11072
wenzelm
parents: 10681
diff changeset
    12
  invers :: "'a => 'a"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    13
  one :: 'a
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    14
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    15
12338
de0f4a63baa5 renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents: 11072
diff changeset
    16
axclass monoid < type
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    17
  assoc:      "(x [*] y) [*] z = x [*] (y [*] z)"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    18
  left_unit:  "one [*] x = x"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    19
  right_unit: "x [*] one = x"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    20
12338
de0f4a63baa5 renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents: 11072
diff changeset
    21
axclass semigroup < type
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    22
  assoc: "(x [*] y) [*] z = x [*] (y [*] z)"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    23
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    24
axclass group < semigroup
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    25
  left_unit:    "one [*] x = x"
11072
wenzelm
parents: 10681
diff changeset
    26
  left_inverse: "invers x [*] x = one"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    27
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    28
axclass agroup < group
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    29
  commute: "x [*] y = y [*] x"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    30
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
subsection {* Abstract reasoning *}
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    33
11072
wenzelm
parents: 10681
diff changeset
    34
theorem group_right_inverse: "x [*] invers x = (one::'a::group)"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    35
proof -
11072
wenzelm
parents: 10681
diff changeset
    36
  have "x [*] invers x = one [*] (x [*] invers x)"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    37
    by (simp only: group.left_unit)
11072
wenzelm
parents: 10681
diff changeset
    38
  also have "... = one [*] x [*] invers x"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    39
    by (simp only: semigroup.assoc)
11072
wenzelm
parents: 10681
diff changeset
    40
  also have "... = invers (invers x) [*] invers x [*] x [*] invers x"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    41
    by (simp only: group.left_inverse)
11072
wenzelm
parents: 10681
diff changeset
    42
  also have "... = invers (invers x) [*] (invers x [*] x) [*] invers x"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    43
    by (simp only: semigroup.assoc)
11072
wenzelm
parents: 10681
diff changeset
    44
  also have "... = invers (invers x) [*] one [*] invers x"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    45
    by (simp only: group.left_inverse)
11072
wenzelm
parents: 10681
diff changeset
    46
  also have "... = invers (invers x) [*] (one [*] invers x)"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    47
    by (simp only: semigroup.assoc)
11072
wenzelm
parents: 10681
diff changeset
    48
  also have "... = invers (invers x) [*] invers x"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    49
    by (simp only: group.left_unit)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    50
  also have "... = one"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    51
    by (simp only: group.left_inverse)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    52
  finally show ?thesis .
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    53
qed
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    54
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    55
theorem group_right_unit: "x [*] one = (x::'a::group)"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    56
proof -
11072
wenzelm
parents: 10681
diff changeset
    57
  have "x [*] one = x [*] (invers x [*] x)"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    58
    by (simp only: group.left_inverse)
11072
wenzelm
parents: 10681
diff changeset
    59
  also have "... = x [*] invers x [*] x"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    60
    by (simp only: semigroup.assoc)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    61
  also have "... = one [*] x"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    62
    by (simp only: group_right_inverse)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    63
  also have "... = x"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    64
    by (simp only: group.left_unit)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    65
  finally show ?thesis .
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    66
qed
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    67
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
subsection {* Abstract instantiation *}
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    70
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    71
instance monoid < semigroup
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    72
proof intro_classes
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    73
  fix x y z :: "'a::monoid"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    74
  show "x [*] y [*] z = x [*] (y [*] z)"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    75
    by (rule monoid.assoc)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    76
qed
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    77
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    78
instance group < monoid
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    79
proof intro_classes
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    80
  fix x y z :: "'a::group"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    81
  show "x [*] y [*] z = x [*] (y [*] z)"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    82
    by (rule semigroup.assoc)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    83
  show "one [*] x = x"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    84
    by (rule group.left_unit)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    85
  show "x [*] one = x"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    86
    by (rule group_right_unit)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    87
qed
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    88
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
subsection {* Concrete instantiation *}
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    91
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    92
defs (overloaded)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    93
  times_bool_def:   "x [*] y == x ~= (y::bool)"
11072
wenzelm
parents: 10681
diff changeset
    94
  inverse_bool_def: "invers x == x::bool"
10134
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    95
  unit_bool_def:    "one == False"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    96
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    97
instance bool :: agroup
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    98
proof (intro_classes,
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
    99
    unfold times_bool_def inverse_bool_def unit_bool_def)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   100
  fix x y z
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   101
  show "((x ~= y) ~= z) = (x ~= (y ~= z))" by blast
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   102
  show "(False ~= x) = x" by blast
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   103
  show "(x ~= x) = False" by blast
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   104
  show "(x ~= y) = (y ~= x)" by blast
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   105
qed
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   106
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
subsection {* Lifting and Functors *}
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   109
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   110
defs (overloaded)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   111
  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
   112
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   113
instance * :: (semigroup, semigroup) semigroup
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   114
proof (intro_classes, unfold times_prod_def)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   115
  fix p q r :: "'a::semigroup * 'b::semigroup"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   116
  show
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   117
    "(fst (fst p [*] fst q, snd p [*] snd q) [*] fst r,
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   118
      snd (fst p [*] fst q, snd p [*] snd q) [*] snd r) =
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   119
       (fst p [*] fst (fst q [*] fst r, snd q [*] snd r),
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   120
        snd p [*] snd (fst q [*] fst r, snd q [*] snd r))"
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   121
    by (simp add: semigroup.assoc)
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   122
qed
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   123
537206cc738f moved axclass tutorial examples to top dir;
wenzelm
parents:
diff changeset
   124
end