5250

1 
(* Title: HOL/ex/LocaleGroup.ML


2 
ID: $Id$


3 
Author: Florian Kammueller, University of Cambridge


4 


5 
Group theory via records and locales.


6 
*)


7 


8 
Open_locale "groups";


9 
print_locales LocaleGroup.thy;


10 


11 
val simp_G = simplify (simpset() addsimps [Group_def]) (thm "Group_G");


12 
Addsimps [simp_G, thm "Group_G"];


13 


14 


15 
goal LocaleGroup.thy "e : carrier G";


16 
by (afs [thm "e_def"] 1);


17 
val e_closed = result();


18 


19 
(* Mit dieser Def ist es halt schwierig *)


20 
goal LocaleGroup.thy "op # : carrier G > carrier G > carrier G";


21 
by (res_inst_tac [("t","op #")] ssubst 1);

5318

22 
by (rtac ext 1);


23 
by (rtac ext 1);


24 
by (rtac meta_eq_to_obj_eq 1);


25 
by (rtac (thm "binop_def") 1);

5250

26 
by (Asm_full_simp_tac 1);


27 
val binop_funcset = result();


28 


29 
goal LocaleGroup.thy "!! x y. [ x: carrier G; y: carrier G ] ==> x # y : carrier G";


30 
by (afs [binop_funcset RS funcset2E1] 1);


31 
val binop_closed = result();


32 


33 
goal LocaleGroup.thy "inv : carrier G > carrier G";


34 
by (res_inst_tac [("t","inv")] ssubst 1);

5318

35 
by (rtac ext 1);


36 
by (rtac meta_eq_to_obj_eq 1);


37 
by (rtac (thm "inv_def") 1);

5250

38 
by (Asm_full_simp_tac 1);


39 
val inv_funcset = result();


40 


41 
goal LocaleGroup.thy "!! x . x: carrier G ==> x  : carrier G";


42 
by (afs [inv_funcset RS funcsetE1] 1);


43 
val inv_closed = result();


44 


45 


46 
goal LocaleGroup.thy "!! x . x: carrier G ==> e # x = x";


47 
by (afs [thm "e_def", thm "binop_def"] 1);


48 
val e_ax1 = result();


49 


50 
goal LocaleGroup.thy "!! x. x: carrier G ==> (x ) # x = e";


51 
by (afs [thm "binop_def", thm "inv_def", thm "e_def"] 1);


52 
val inv_ax2 = result();


53 


54 
goal LocaleGroup.thy "!! x y z. [ x: carrier G; y: carrier G; z: carrier G ]\


55 
\ ==> (x # y) # z = x # (y # z)";


56 
by (afs [thm "binop_def"] 1);


57 
val binop_assoc = result();


58 


59 
goal LocaleGroup.thy "!! G f i e1. [f : G > G > G; i: G > G; e1: G;\


60 
\ ! x: G. (f (i x) x = e1); ! x: G. (f e1 x = x);\


61 
\ ! x: G. ! y: G. ! z: G.(f (f x y) z = f (x) (f y z)) ] \


62 
\ ==> ( carrier = G, bin_op = f, inverse = i, unit = e1 ) : Group";


63 
by (afs [Group_def] 1);


64 
val GroupI = result();


65 


66 
(*****)


67 
(* Now the real derivations *)


68 


69 
goal LocaleGroup.thy "!! x y z. [ x : carrier G ; y : carrier G; z : carrier G;\


70 
\ x # y = x # z ] ==> y = z";


71 
(* remarkable: In the following step the use of e_ax1 instead of unit_ax1


72 
is better! It doesn't produce G: Group as subgoal and the nice syntax stays *)


73 
by (res_inst_tac [("P","%r. r = z")] (e_ax1 RS subst) 1);

5318

74 
by (assume_tac 1);

5250

75 
(* great: we can use the nice syntax even in res_inst_tac *)


76 
by (res_inst_tac [("P","%r. r # y = z")] subst 1);


77 
by (res_inst_tac [("x","x")] inv_ax2 1);

5318

78 
by (assume_tac 1);


79 
by (stac binop_assoc 1);


80 
by (rtac inv_closed 1);


81 
by (assume_tac 1);


82 
by (assume_tac 1);


83 
by (assume_tac 1);


84 
by (etac ssubst 1);


85 
by (rtac (binop_assoc RS subst) 1);


86 
by (rtac inv_closed 1);


87 
by (assume_tac 1);


88 
by (assume_tac 1);


89 
by (assume_tac 1);


90 
by (stac inv_ax2 1);


91 
by (assume_tac 1);


92 
by (stac e_ax1 1);


93 
by (assume_tac 1);


94 
by (rtac refl 1);

5250

95 
val left_cancellation = result();


96 


97 


98 
(* here are the other directions of basic lemmas, they needed a cancellation (left) *)


99 
(* to be able to show the other directions of inverse and unity axiom we need:*)


100 
goal LocaleGroup.thy "!! x. x: carrier G ==> x # e = x";


101 
(* here is a problem with res_inst_tac: in Fun there is a


102 
constant inv, and that gets addressed when we type in .


103 
We have to use the defining term and then fold the def of inv *)


104 
by (res_inst_tac [("x","inverse G x")] left_cancellation 1);


105 
by (fold_goals_tac [thm "inv_def"]);


106 
by (fast_tac (claset() addSEs [inv_closed]) 1);


107 
by (afs [binop_closed, e_closed] 1);

5318

108 
by (assume_tac 1);


109 
by (rtac (binop_assoc RS subst) 1);

5250

110 
by (fast_tac (claset() addSEs [inv_closed]) 1);

5318

111 
by (assume_tac 1);


112 
by (rtac (e_closed) 1);


113 
by (stac inv_ax2 1);


114 
by (assume_tac 1);


115 
by (stac e_ax1 1);


116 
by (rtac e_closed 1);


117 
by (rtac refl 1);

5250

118 
val e_ax2 = result();


119 


120 
goal LocaleGroup.thy "!! x. [ x: carrier G; x # x = x ] ==> x = e";


121 
by (forw_inst_tac [("P","%y. x # x = y")] (e_ax2 RS forw_subst) 1);

5318

122 
by (assume_tac 1);

5250

123 
by (res_inst_tac [("x","x")] left_cancellation 1);

5318

124 
by (assume_tac 1);


125 
by (assume_tac 1);


126 
by (rtac e_closed 1);


127 
by (assume_tac 1);

5250

128 
val idempotent_e = result();


129 


130 
goal LocaleGroup.thy "!! x. x: carrier G ==> x # (x ) = e";

5318

131 
by (rtac idempotent_e 1);

5250

132 
by (afs [binop_closed,inv_closed] 1);

5318

133 
by (stac binop_assoc 1);


134 
by (assume_tac 1);

5250

135 
by (afs [inv_closed] 1);


136 
by (afs [binop_closed,inv_closed] 1);


137 
by (res_inst_tac [("t","x  # x # x ")] subst 1);

5318

138 
by (rtac binop_assoc 1);

5250

139 
by (afs [inv_closed] 1);

5318

140 
by (assume_tac 1);

5250

141 
by (afs [inv_closed] 1);

5318

142 
by (stac inv_ax2 1);


143 
by (assume_tac 1);


144 
by (stac e_ax1 1);

5250

145 
by (afs [inv_closed] 1);

5318

146 
by (rtac refl 1);

5250

147 
val inv_ax1 = result();


148 


149 


150 
goal LocaleGroup.thy "!! x y. [ x: carrier G; y: carrier G; \


151 
\ x # y = e ] ==> y = x ";


152 
by (res_inst_tac [("x","x")] left_cancellation 1);

5318

153 
by (assume_tac 1);


154 
by (assume_tac 1);

5250

155 
by (afs [inv_closed] 1);

5318

156 
by (stac inv_ax1 1);


157 
by (assume_tac 1);


158 
by (assume_tac 1);

5250

159 
val inv_unique = result();


160 


161 
goal LocaleGroup.thy "!! x. x : carrier G ==> x   = x";


162 
by (res_inst_tac [("x","inverse G x")] left_cancellation 1);


163 
by (fold_goals_tac [thm "inv_def"]);


164 
by (afs [inv_closed] 1);


165 
by (afs [inv_closed] 1);

5318

166 
by (assume_tac 1);

5250

167 
by (afs [inv_ax1,inv_ax2,e_ax1,e_ax2,e_closed,inv_closed,binop_closed] 1);


168 
val inv_inv = result();


169 


170 
goal LocaleGroup.thy "!! x y. [ x : carrier G; y : carrier G ]\


171 
\ ==> (x # y)  = y  # x ";

5318

172 
by (rtac sym 1);


173 
by (rtac inv_unique 1);

5250

174 
by (afs [binop_closed] 1);


175 
by (afs [inv_closed,binop_closed] 1);


176 
by (afs [binop_assoc,inv_closed,binop_closed] 1);


177 
by (res_inst_tac [("x1","y")] (binop_assoc RS subst) 1);

5318

178 
by (assume_tac 1);

5250

179 
by (afs [inv_closed] 1);


180 
by (afs [inv_closed] 1);


181 
by (afs [inv_ax1,inv_ax2,e_ax1,e_ax2,e_closed,inv_closed,binop_closed] 1);


182 
val inv_prod = result();


183 


184 


185 
goal LocaleGroup.thy "!! x y z. [ x : carrier G; y : carrier G;\


186 
\ z : carrier G; y # x = z # x] ==> y = z";


187 
by (res_inst_tac [("P","%r. r = z")] (e_ax2 RS subst) 1);

5318

188 
by (assume_tac 1);

5250

189 
by (res_inst_tac [("P","%r. y # r = z")] subst 1);

5318

190 
by (rtac inv_ax1 1);


191 
by (assume_tac 1);


192 
by (rtac (binop_assoc RS subst) 1);


193 
by (assume_tac 1);


194 
by (assume_tac 1);

5250

195 
by (afs [inv_closed] 1);

5318

196 
by (etac ssubst 1);

5250

197 
by (afs [binop_assoc,inv_closed,inv_ax1,e_ax2] 1);


198 
val right_cancellation = result();


199 


200 
(* example what happens if export *)


201 
val Left_cancellation = export left_cancellation;
