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);


22 
br ext 1;


23 
br ext 1;


24 
br meta_eq_to_obj_eq 1;


25 
br (thm "binop_def") 1;


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);


35 
br ext 1;


36 
br meta_eq_to_obj_eq 1;


37 
br (thm "inv_def") 1;


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);


74 
ba 1;


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);


78 
ba 1;


79 
br (binop_assoc RS ssubst) 1;


80 
br inv_closed 1;


81 
ba 1;


82 
ba 1;


83 
ba 1;


84 
be ssubst 1;


85 
br (binop_assoc RS subst) 1;


86 
br inv_closed 1;


87 
ba 1;


88 
ba 1;


89 
ba 1;


90 
br (inv_ax2 RS ssubst) 1;


91 
ba 1;


92 
br (e_ax1 RS ssubst) 1;


93 
ba 1;


94 
br refl 1;


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);


108 
ba 1;


109 
br (binop_assoc RS subst) 1;


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


111 
ba 1;


112 
br (e_closed) 1;


113 
br (inv_ax2 RS ssubst) 1;


114 
ba 1;


115 
br (e_ax1 RS ssubst) 1;


116 
br e_closed 1;


117 
br refl 1;


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);


122 
ba 1;


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


124 
ba 1;


125 
ba 1;


126 
br e_closed 1;


127 
ba 1;


128 
val idempotent_e = result();


129 


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


131 
br idempotent_e 1;


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


133 
br (binop_assoc RS ssubst) 1;


134 
ba 1;


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);


138 
br binop_assoc 1;


139 
by (afs [inv_closed] 1);


140 
ba 1;


141 
by (afs [inv_closed] 1);


142 
br (inv_ax2 RS ssubst) 1;


143 
ba 1;


144 
br (e_ax1 RS ssubst) 1;


145 
by (afs [inv_closed] 1);


146 
br refl 1;


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);


153 
ba 1;


154 
ba 1;


155 
by (afs [inv_closed] 1);


156 
br (inv_ax1 RS ssubst) 1;


157 
ba 1;


158 
ba 1;


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);


166 
ba 1;


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 ";


172 
br sym 1;


173 
br inv_unique 1;


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);


178 
ba 1;


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);


188 
ba 1;


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


190 
br inv_ax1 1;


191 
ba 1;


192 
br (binop_assoc RS subst) 1;


193 
ba 1;


194 
ba 1;


195 
by (afs [inv_closed] 1);


196 
be ssubst 1;


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;
