1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 set "baseuri" "cic:/matita/algebra/groups/".
17 include "algebra/monoids.ma".
18 include "nat/le_arith.ma".
19 include "datatypes/bool.ma".
20 include "nat/compare.ma".
22 record PreGroup : Type ≝
23 { premonoid:> PreMonoid;
24 opp: premonoid -> premonoid
27 record isGroup (G:PreGroup) : Prop ≝
28 { is_monoid: isMonoid G;
29 opp_is_left_inverse: is_left_inverse (mk_Monoid ? is_monoid) (opp G);
30 opp_is_right_inverse: is_right_inverse (mk_Monoid ? is_monoid) (opp G)
34 { pregroup:> PreGroup;
35 group_properties:> isGroup pregroup
41 interpretation "Monoid coercion" 'monoid G =
42 (cic:/matita/algebra/groups/monoid.con G).*)
45 for @{ 'type_of_group $G }.
47 interpretation "Type_of_group coercion" 'type_of_group G =
48 (cic:/matita/algebra/groups/Type_of_Group.con G).
51 for @{ 'magma_of_group $G }.
53 interpretation "magma_of_group coercion" 'magma_of_group G =
54 (cic:/matita/algebra/groups/Magma_of_Group.con G).
56 notation "hvbox(x \sup (-1))" with precedence 89
59 interpretation "Group inverse" 'gopp x =
60 (cic:/matita/algebra/groups/opp.con _ x).
62 definition left_cancellable ≝
63 λT:Type. λop: T -> T -> T.
64 ∀x. injective ? ? (op x).
66 definition right_cancellable ≝
67 λT:Type. λop: T -> T -> T.
68 ∀x. injective ? ? (λz.op z x).
70 theorem eq_op_x_y_op_x_z_to_eq:
71 ∀G:Group. left_cancellable G (op G).
73 unfold left_cancellable;
76 rewrite < (e_is_left_unit ? (is_monoid ? (group_properties G)));
77 rewrite < (e_is_left_unit ? (is_monoid ? (group_properties G)) z);
78 rewrite < (opp_is_left_inverse ? (group_properties G) x);
79 rewrite > (associative ? (is_semi_group ? (is_monoid ? (group_properties G))));
80 rewrite > (associative ? (is_semi_group ? (is_monoid ? (group_properties G))));
86 theorem eq_op_x_y_op_z_y_to_eq:
87 ∀G:Group. right_cancellable G (op G).
89 unfold right_cancellable;
91 simplify;fold simplify (op G);
93 rewrite < (e_is_right_unit ? (is_monoid ? (group_properties G)));
94 rewrite < (e_is_right_unit ? (is_monoid ? (group_properties G)) z);
95 rewrite < (opp_is_right_inverse ? (group_properties G) x);
96 rewrite < (associative ? (is_semi_group ? (is_monoid ? (group_properties G))));
97 rewrite < (associative ? (is_semi_group ? (is_monoid ? (group_properties G))));
103 record finite_enumerable (T:Type) : Type ≝
107 index_of_sur: ∀x.index_of x ≤ order;
108 index_of_repr: ∀n. n≤order → index_of (repr n) = n;
109 repr_index_of: ∀x. repr (index_of x) = x
112 notation "hvbox(C \sub i)" with precedence 89
113 for @{ 'repr $C $i }.
115 (* CSC: multiple interpretations in the same file are not considered in the
117 interpretation "Finite_enumerable representation" 'repr C i =
118 (cic:/matita/algebra/groups/repr.con C _ i).*)
120 notation < "hvbox(|C|)" with precedence 89
123 interpretation "Finite_enumerable order" 'card C =
124 (cic:/matita/algebra/groups/order.con C _).
126 record finite_enumerable_SemiGroup : Type ≝
127 { semigroup:> SemiGroup;
128 is_finite_enumerable:> finite_enumerable semigroup
132 for @{ 'semigroup_of_finite_enumerable_semigroup $S }.
134 interpretation "Semigroup_of_finite_enumerable_semigroup"
135 'semigroup_of_finite_enumerable_semigroup S
137 (cic:/matita/algebra/groups/semigroup.con S).
140 for @{ 'magma_of_finite_enumerable_semigroup $S }.
142 interpretation "Magma_of_finite_enumerable_semigroup"
143 'magma_of_finite_enumerable_semigroup S
145 (cic:/matita/algebra/groups/Magma_of_finite_enumerable_SemiGroup.con S).
148 for @{ 'type_of_finite_enumerable_semigroup $S }.
150 interpretation "Type_of_finite_enumerable_semigroup"
151 'type_of_finite_enumerable_semigroup S
153 (cic:/matita/algebra/groups/Type_of_finite_enumerable_SemiGroup.con S).
155 interpretation "Finite_enumerable representation" 'repr S i =
156 (cic:/matita/algebra/groups/repr.con S
157 (cic:/matita/algebra/groups/is_finite_enumerable.con S) i).
159 notation "hvbox(ι e)" with precedence 60
160 for @{ 'index_of_finite_enumerable_semigroup $e }.
162 interpretation "Index_of_finite_enumerable representation"
163 'index_of_finite_enumerable_semigroup e
165 (cic:/matita/algebra/groups/index_of.con _
166 (cic:/matita/algebra/groups/is_finite_enumerable.con _) e).
169 (* several definitions/theorems to be moved somewhere else *)
171 definition ltb ≝ λn,m. leb n m ∧ notb (eqb n m).
173 theorem not_eq_to_le_to_lt: ∀n,m. n≠m → n≤m → n<m.
175 elim (le_to_or_lt_eq ? ? H1);
181 theorem ltb_to_Prop :
196 | apply (not_eq_to_le_to_lt ? ? H H1)
200 | apply le_to_not_lt;
201 generalize in match (not_le_to_lt ? ? H1);
209 theorem ltb_elim: \forall n,m:nat. \forall P:bool \to Prop.
210 (n < m \to (P true)) \to (n ≮ m \to (P false)) \to
214 (match (ltb n m) with
215 [ true \Rightarrow n < m
216 | false \Rightarrow n ≮ m] \to (P (ltb n m))).
217 apply Hcut.apply ltb_to_Prop.
223 theorem Not_lt_n_n: ∀n. n ≮ n.
228 apply (not_le_Sn_n ? H).
231 theorem eq_pred_to_eq:
232 ∀n,m. O < n → O < m → pred n = pred m → n = m.
235 [ elim (Not_lt_n_n ? H)
236 | generalize in match H3;
238 generalize in match H2;
241 [ elim (Not_lt_n_n ? H2)
249 theorem le_pred_to_le:
250 ∀n,m. O < m → pred n ≤ pred m \to n ≤ m.
255 rewrite > (S_pred m);
263 theorem le_to_le_pred:
264 ∀n,m. n ≤ m → pred n ≤ pred m.
270 generalize in match H1;
273 [ elim (not_le_Sn_O ? H1)
284 (∀x,y.x≤n → y≤n → f x = f y → x=y) →
286 ∀x. x≤n \to ∃y.f y = x ∧ y ≤ n.
289 [ apply (ex_intro ? ? O);
291 rewrite < (le_n_O_to_eq ? H2);
292 rewrite < (le_n_O_to_eq ? (H1 O));
295 apply (nat_compare_elim (f (S n1)) x);
296 [ (* TODO: caso complicato, ma simile al terzo *)
298 apply (ex_intro ? ? (S n1));
306 let fSn1 ≝ f (S n1) in
308 match ltb fSn1 fx with
312 cut (∀x,y. x ≤ n1 → y ≤ n1 → f' x = f' y → x=y);
319 apply (ex_intro ? ? a);
321 [ generalize in match H4;
325 apply (ltb_elim (f (S n1)) (f a));
326 [ (* TODO: caso impossibile (uso l'iniettivita') *)
338 apply (ltb_elim (f (S n1)) (f m));
341 [ generalize in match (H2 m);
343 change in match n1 with (pred (S n1));
346 | generalize in match (H2 (S n1));
348 generalize in match (not_lt_to_le ? ? H5);
350 generalize in match (transitive_le ? ? ? H7 H6);
352 (* TODO: qui mi serve dimostrare che f m ≠ f (S n1) (per iniettivita'?) *)
354 | rewrite > (pred_Sn n1);
356 generalize in match (H2 (S n1));
358 generalize in match (lt_to_le_to_lt ? ? ? H4 H5);
367 apply (ltb_elim (f (S n1)) (f x1));
369 apply (ltb_elim (f (S n1)) (f y));
373 [ apply (H1 ? ? ? ? Hcut);
376 | apply eq_pred_to_eq;
377 [ apply (ltn_to_ltO ? ? H8)
378 | apply (ltn_to_ltO ? ? H7)
382 | (* pred (f x1) = f y absurd since y ≠ S n1 and thus f y ≠ f (S n1)
383 so that f y < f (S n1) < f x1; hence pred (f x1) = f y is absurd *)
385 [ generalize in match (lt_to_not_eq ? ? Hcut);
387 cut (f y ≠ f (S n1));
388 [ cut (f y < f (S n1));
389 [ rewrite < H9 in Hcut2;
392 generalize in match (le_S_S ? ? Hcut2);
394 generalize in match (transitive_le ? ? ? H11 H8);
396 rewrite < (S_pred (f x1)) in H12;
397 [ elim (not_le_Sn_n ? H12)
398 | fold simplify ((f (S n1)) < (f x1)) in H8;
399 apply (ltn_to_ltO ? ? H8)
401 | apply not_eq_to_le_to_lt;
403 | apply not_lt_to_le;
410 apply (H1 ? ? ? ? H11);
420 | (* f x1 = pred (f y) absurd since it implies S (f x1) = f y and
421 f x1 ≤ f (S n1) < f y = S (f x1) so that f x1 = f (S n1); by
422 injectivity x1 = S n1 that is absurd since x1 ≤ n1 *)
423 generalize in match (eq_f ? ? S ? ? H9);
425 rewrite < S_pred in H10;
426 [ rewrite < H10 in H7;
427 generalize in match (not_lt_to_le ? ? H8);
430 generalize in match (le_S_S ? ? H11);
432 generalize in match (antisym_le ? ? H12 H7);
434 generalize in match (inj_S ? ? H13);
436 generalize in match (H1 ? ? ? ? H14);
439 elim (not_le_Sn_n ? H5)
440 | apply (ltn_to_ltO ?? H7)
442 | apply (H1 ? ? ? ? H9);
452 ∀G:finite_enumerable_SemiGroup.
453 left_cancellable ? (op G) →
454 right_cancellable ? (op G) →
455 ∃e:G. isMonoid (mk_PreMonoid G e).
457 letin f ≝ (λn.ι(G \sub O · G \sub n));
458 cut (∀n.n ≤ order ? (is_finite_enumerable G) → ∃m.f m = n);
459 [ letin EX ≝ (Hcut O ?);
466 letin HH ≝ (eq_f ? ? (repr ? (is_finite_enumerable G)) ? ? H2);
468 rewrite > (repr_index_of ? (is_finite_enumerable G)) in HH;
469 apply (ex_intro ? ? (G \sub a));
470 letin GOGO ≝ (refl_eq ? (repr ? (is_finite_enumerable G) O));
472 rewrite < HH in GOGO;
473 rewrite < HH in GOGO:(? ? % ?);
474 rewrite > (associative ? G) in GOGO;
475 letin GaGa ≝ (H ? ? ? GOGO);
480 apply (semigroup_properties G)
481 | unfold is_left_unit; intro;
482 letin GaxGax ≝ (refl_eq ? (G \sub a ·x));
484 rewrite < GaGa in GaxGax:(? ? % ?);
485 rewrite > (associative ? (semigroup_properties G)) in GaxGax;
486 apply (H ? ? ? GaxGax)
487 | unfold is_right_unit; intro;
488 letin GaxGax ≝ (refl_eq ? (x·G \sub a));
490 rewrite < GaGa in GaxGax:(? ? % ?);
491 rewrite < (associative ? (semigroup_properties G)) in GaxGax;
492 apply (H1 ? ? ? GaxGax)