src/HOL/ex/LocaleGroup.ML
author paulson
Fri Dec 11 10:41:53 1998 +0100 (1998-12-11)
changeset 6024 cb87f103d114
parent 5848 99dea3c24efb
permissions -rw-r--r--
new Close_locale synatx
wenzelm@5250
     1
(*  Title:      HOL/ex/LocaleGroup.ML
wenzelm@5250
     2
    ID:         $Id$
wenzelm@5250
     3
    Author:     Florian Kammueller, University of Cambridge
wenzelm@5250
     4
wenzelm@5250
     5
Group theory via records and locales.
wenzelm@5250
     6
*)
wenzelm@5250
     7
wenzelm@5250
     8
Open_locale "groups";
wenzelm@5250
     9
print_locales LocaleGroup.thy;
wenzelm@5250
    10
wenzelm@5250
    11
val simp_G = simplify (simpset() addsimps [Group_def]) (thm "Group_G");
wenzelm@5250
    12
Addsimps [simp_G, thm "Group_G"];
wenzelm@5250
    13
wenzelm@5250
    14
paulson@5845
    15
Goal "e : carrier G";
paulson@5845
    16
by (simp_tac (simpset() addsimps [thm "e_def"]) 1);
paulson@5845
    17
qed "e_closed";
wenzelm@5250
    18
wenzelm@5250
    19
(* Mit dieser Def ist es halt schwierig *)
paulson@5845
    20
Goal "op # : carrier G -> carrier G -> carrier G";
wenzelm@5250
    21
by (res_inst_tac [("t","op #")] ssubst 1);
paulson@5318
    22
by (rtac ext 1);
paulson@5318
    23
by (rtac ext 1);
paulson@5318
    24
by (rtac meta_eq_to_obj_eq 1);
paulson@5318
    25
by (rtac (thm "binop_def") 1);
wenzelm@5250
    26
by (Asm_full_simp_tac 1);
paulson@5845
    27
qed "binop_funcset";
wenzelm@5250
    28
paulson@5845
    29
Goal "[| x: carrier G; y: carrier G |] ==> x # y : carrier G";
paulson@5845
    30
by (asm_simp_tac
paulson@5845
    31
    (simpset() addsimps [binop_funcset RS funcset_mem RS funcset_mem]) 1);
paulson@5845
    32
qed "binop_closed";
wenzelm@5250
    33
paulson@5845
    34
Addsimps [binop_closed, e_closed];
wenzelm@5250
    35
paulson@5845
    36
Goal "INV : carrier G -> carrier G";
paulson@5845
    37
by (asm_simp_tac (simpset() addsimps [thm "inv_def"]) 1);
paulson@5845
    38
qed "inv_funcset";
wenzelm@5250
    39
paulson@5848
    40
Goal "x: carrier G ==> i(x) : carrier G";
paulson@5845
    41
by (asm_simp_tac (simpset() addsimps [inv_funcset RS funcset_mem]) 1);
paulson@5845
    42
qed "inv_closed"; 
wenzelm@5250
    43
paulson@5845
    44
Goal "x: carrier G ==> e # x = x";
paulson@5845
    45
by (asm_simp_tac (simpset() addsimps [thm "e_def", thm "binop_def"]) 1);
paulson@5845
    46
qed "e_ax1";
wenzelm@5250
    47
paulson@5848
    48
Goal "x: carrier G ==> i(x) # x = e";
paulson@5845
    49
by (asm_simp_tac
paulson@5845
    50
    (simpset() addsimps [thm "binop_def", thm "inv_def", thm "e_def"]) 1);
paulson@5845
    51
qed "inv_ax2";
wenzelm@5250
    52
paulson@5845
    53
Addsimps [inv_closed, e_ax1, inv_ax2];
paulson@5845
    54
paulson@5845
    55
Goal "[| x: carrier G; y: carrier G; z: carrier G |]\
wenzelm@5250
    56
\               ==> (x # y) # z = x # (y # z)";
paulson@5845
    57
by (asm_simp_tac (simpset() addsimps [thm "binop_def"]) 1);
paulson@5845
    58
qed "binop_assoc";
wenzelm@5250
    59
paulson@5845
    60
Goal "[|f : A -> A -> A; i: A -> A; e1: A;\
paulson@5845
    61
\        ! x: A. (f (i x) x = e1); ! x: A. (f e1 x = x);\
paulson@5845
    62
\        ! x: A. ! y: A. ! z: A.(f (f x y) z = f (x) (f y z)) |] \
paulson@5845
    63
\     ==> (| carrier = A, bin_op = f, inverse = i, unit = e1 |) : Group";
paulson@5845
    64
by (asm_simp_tac (simpset() addsimps [Group_def]) 1);
paulson@5845
    65
qed "GroupI";
wenzelm@5250
    66
wenzelm@5250
    67
(*****)
wenzelm@5250
    68
(* Now the real derivations *)
wenzelm@5250
    69
paulson@5845
    70
Goal "[| x # y  =  x # z;  \
paulson@5845
    71
\        x : carrier G ; y : carrier G; z : carrier G |] ==> y = z";
wenzelm@5250
    72
by (res_inst_tac [("P","%r. r = z")] (e_ax1 RS subst) 1);
paulson@5318
    73
by (assume_tac 1);
wenzelm@5250
    74
(* great: we can use the nice syntax even in res_inst_tac *)
paulson@5845
    75
by (res_inst_tac [("P","%r. r # y = z")] (inv_ax2 RS subst) 1);
paulson@5318
    76
by (assume_tac 1);
paulson@5845
    77
by (asm_simp_tac (simpset() delsimps [inv_ax2] addsimps [binop_assoc]) 1);
paulson@5845
    78
by (asm_simp_tac (simpset() addsimps [binop_assoc RS sym]) 1);
paulson@5845
    79
qed "left_cancellation";
wenzelm@5250
    80
wenzelm@5250
    81
paulson@5845
    82
(* Here are the other directions of basic lemmas. 
paulson@5845
    83
   They needed a cancellation (left) to be able to show the other
paulson@5845
    84
   directions of inverse and unity axiom.*)
paulson@5845
    85
Goal "x: carrier G ==> x # e = x";
paulson@5845
    86
by (rtac left_cancellation 1);
paulson@5845
    87
by (etac inv_closed 2);
paulson@5845
    88
by (auto_tac (claset(), simpset() addsimps [binop_assoc RS sym]));
paulson@5845
    89
qed "e_ax2";
paulson@5845
    90
paulson@5845
    91
Addsimps [e_ax2];
paulson@5845
    92
paulson@5845
    93
Goal "[| x: carrier G; x # x = x |] ==> x = e";
paulson@5845
    94
by (forw_inst_tac [("P","%y. x # x = y")] (e_ax2 RS ssubst) 1);
paulson@5845
    95
by (etac left_cancellation 2);
paulson@5845
    96
by Auto_tac;
paulson@5845
    97
qed "idempotent_e";
wenzelm@5250
    98
paulson@5848
    99
Goal  "x: carrier G ==> x # i(x) = e";
paulson@5318
   100
by (rtac idempotent_e 1);
paulson@5845
   101
by (Asm_simp_tac 1);
paulson@5848
   102
by (subgoal_tac "(x # i(x)) # x # i(x) = x # (i(x) # x) # i(x)" 1);
paulson@5845
   103
by (asm_simp_tac (simpset() delsimps [inv_ax2]
paulson@5845
   104
			    addsimps [binop_assoc]) 2);
paulson@5845
   105
by Auto_tac;
paulson@5845
   106
qed "inv_ax1";
paulson@5845
   107
paulson@5845
   108
Addsimps [inv_ax1];
paulson@5845
   109
paulson@5848
   110
Goal "[| x # y = e; x: carrier G; y: carrier G |] ==> y = i(x)";
paulson@5845
   111
by (res_inst_tac [("x","x")] left_cancellation 1);
paulson@5845
   112
by Auto_tac;
paulson@5845
   113
qed "inv_unique";
paulson@5845
   114
paulson@5848
   115
Goal "x : carrier G ==> i(i(x)) = x";
paulson@5848
   116
by (res_inst_tac [("x","i(x)")] left_cancellation 1);
paulson@5845
   117
by Auto_tac;
paulson@5845
   118
qed "inv_inv";
paulson@5845
   119
paulson@5845
   120
Addsimps [inv_inv];
paulson@5845
   121
paulson@5848
   122
Goal "[| x : carrier G; y : carrier G |] ==> i(x # y) = i(y) # i(x)";
paulson@5845
   123
by (rtac (inv_unique RS sym) 1);
paulson@5848
   124
by (subgoal_tac "(x # y) # i(y) # i(x) = x # (y # i(y)) # i(x)" 1);
paulson@5845
   125
by (asm_simp_tac (simpset() delsimps [inv_ax1, inv_ax2]
paulson@5845
   126
			    addsimps [binop_assoc]) 2);
paulson@5845
   127
by Auto_tac;
paulson@5845
   128
qed "inv_prod";
wenzelm@5250
   129
wenzelm@5250
   130
paulson@5845
   131
Goal "[| y # x = z # x;  x : carrier G; y : carrier G; \
paulson@5845
   132
\        z : carrier G |] ==> y = z";
wenzelm@5250
   133
by (res_inst_tac [("P","%r. r = z")] (e_ax2 RS subst) 1);
paulson@5318
   134
by (assume_tac 1);
paulson@5845
   135
by (res_inst_tac [("P","%r. y # r = z")] (inv_ax1 RS subst) 1);
paulson@5318
   136
by (assume_tac 1);
paulson@5845
   137
by (asm_simp_tac (simpset() delsimps [inv_ax1] 
paulson@5845
   138
		  addsimps [binop_assoc RS sym]) 1);
paulson@5845
   139
by (asm_simp_tac (simpset() addsimps [binop_assoc]) 1);
paulson@5845
   140
qed "right_cancellation";
paulson@5845
   141
paulson@6024
   142
Close_locale "groups";
wenzelm@5250
   143
wenzelm@5250
   144
(* example what happens if export *)
wenzelm@5250
   145
val Left_cancellation = export left_cancellation;