]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/matita/library/algebra/groups.ma
1. The last commit that fixed unification of compound coercions with
[helm.git] / helm / matita / library / algebra / groups.ma
index 0f759434f85fd07b48935e418cd99a35664878e7..ae6b525e3906d9b6f5b153b0c767ed6c47faed08 100644 (file)
@@ -17,18 +17,39 @@ set "baseuri" "cic:/matita/algebra/groups/".
 include "algebra/monoids.ma".
 include "nat/le_arith.ma".
 
-record isGroup (M:Monoid) (opp: M -> M) : Prop ≝
- { opp_is_left_inverse: is_left_inverse M opp;
-   opp_is_right_inverse: is_right_inverse M opp
+record PreGroup : Type ≝
+ { premonoid:> PreMonoid;
+   opp: premonoid -> premonoid
+ }.
+
+record isGroup (G:PreGroup) : Prop ≝
+ { is_monoid: isMonoid G;
+   opp_is_left_inverse: is_left_inverse (mk_Monoid ? is_monoid) (opp G);
+   opp_is_right_inverse: is_right_inverse (mk_Monoid ? is_monoid) (opp G)
  }.
  
 record Group : Type ≝
- { monoid: Monoid;
-   opp: monoid -> monoid;
-   group_properties: isGroup ? opp
+ { pregroup:> PreGroup;
+   group_properties:> isGroup pregroup
  }.
-coercion cic:/matita/algebra/groups/monoid.con.
+
+(*notation < "G"
+for @{ 'monoid $G }.
+
+interpretation "Monoid coercion" 'monoid G =
+ (cic:/matita/algebra/groups/monoid.con G).*)
+
+notation < "G"
+for @{ 'type_of_group $G }.
+
+interpretation "Type_of_group coercion" 'type_of_group G =
+ (cic:/matita/algebra/groups/Type_of_Group.con G).
+
+notation < "G"
+for @{ 'magma_of_group $G }.
+
+interpretation "magma_of_group coercion" 'magma_of_group G =
+ (cic:/matita/algebra/groups/Magma_of_Group.con G).
 
 notation "hvbox(x \sup (-1))" with precedence 89
 for @{ 'gopp $x }.
@@ -50,11 +71,11 @@ intros;
 unfold left_cancellable;
 unfold injective;
 intros (x y z);
-rewrite < (e_is_left_unit ? ? (monoid_properties G));
-rewrite < (e_is_left_unit ? ? (monoid_properties G) z);
-rewrite < (opp_is_left_inverse ? (group_properties G) x);
-rewrite > (semigroup_properties G);
-rewrite > (semigroup_properties G);
+rewrite < (e_is_left_unit ? (is_monoid ? (group_properties G)));
+rewrite < (e_is_left_unit ? (is_monoid ? (group_properties G)) z);
+rewrite < (opp_is_left_inverse ? (group_properties G) x);
+rewrite > (associative ? (is_semi_group ? (is_monoid ? (group_properties G))));
+rewrite > (associative ? (is_semi_group ? (is_monoid ? (group_properties G))));
 apply eq_f;
 assumption.
 qed.
@@ -67,34 +88,124 @@ unfold right_cancellable;
 unfold injective;
 simplify;fold simplify (op G); 
 intros (x y z);
-rewrite < (e_is_right_unit ? ? (monoid_properties G));
-rewrite < (e_is_right_unit ? ? (monoid_properties G) z);
-rewrite < (opp_is_right_inverse ? (group_properties G) x);
-rewrite < (semigroup_properties G);
-rewrite < (semigroup_properties G);
+rewrite < (e_is_right_unit ? (is_monoid ? (group_properties G)));
+rewrite < (e_is_right_unit ? (is_monoid ? (group_properties G)) z);
+rewrite < (opp_is_right_inverse ? (group_properties G) x);
+rewrite < (associative ? (is_semi_group ? (is_monoid ? (group_properties G))));
+rewrite < (associative ? (is_semi_group ? (is_monoid ? (group_properties G))));
 rewrite > H;
 reflexivity.
 qed.
 
-(*
-record enumerable (T:Type) : Type ≝
+
+record finite_enumerable (T:Type) : Type ≝
  { order: nat;
    repr: nat → T;
-   repr_inj: ∀n,n'. n≤order → n'≤order → repr n ≠ repr n';
-   repr_sur: ∀x.∃n.n≤order ∧ repr n = x
+   index_of: T → nat;
+   index_of_sur: ∀x.index_of x ≤ order;
+   index_of_repr: ∀n. n≤order → index_of (repr n) = n;
+   repr_index_of: ∀x. repr (index_of x) = x
  }.
  
+notation "hvbox(C \sub i)" with precedence 89
+for @{ 'repr $C $i }.
+
+(* CSC: multiple interpretations in the same file are not considered in the
+ right order
+interpretation "Finite_enumerable representation" 'repr C i =
+ (cic:/matita/algebra/groups/repr.con C _ i).*)
+notation "hvbox(|C|)" with precedence 89
+for @{ 'card $C }.
+
+interpretation "Finite_enumerable order" 'card C =
+ (cic:/matita/algebra/groups/order.con C _).
 
+record finite_enumerable_SemiGroup : Type ≝
+ { semigroup:> SemiGroup;
+   is_finite_enumerable:> finite_enumerable semigroup
+ }.
+
+notation < "S"
+for @{ 'semigroup_of_finite_enumerable_semigroup $S }.
+
+interpretation "Semigroup_of_finite_enumerable_semigroup"
+ 'semigroup_of_finite_enumerable_semigroup S
+=
+ (cic:/matita/algebra/groups/semigroup.con S).
+
+notation < "S"
+for @{ 'magma_of_finite_enumerable_semigroup $S }.
+
+interpretation "Magma_of_finite_enumerable_semigroup"
+ 'magma_of_finite_enumerable_semigroup S
+=
+ (cic:/matita/algebra/groups/Magma_of_finite_enumerable_SemiGroup.con S).
+notation < "S"
+for @{ 'type_of_finite_enumerable_semigroup $S }.
+
+interpretation "Type_of_finite_enumerable_semigroup"
+ 'type_of_finite_enumerable_semigroup S
+=
+ (cic:/matita/algebra/groups/Type_of_finite_enumerable_SemiGroup.con S).
+
+interpretation "Finite_enumerable representation" 'repr S i =
+ (cic:/matita/algebra/groups/repr.con S
+  (cic:/matita/algebra/groups/is_finite_enumerable.con S) i).
+
+notation "hvbox(ι e)" with precedence 60
+for @{ 'index_of_finite_enumerable_semigroup $e }.
+
+interpretation "Index_of_finite_enumerable representation"
+ 'index_of_finite_enumerable_semigroup e
+=
+ (cic:/matita/algebra/groups/index_of.con _
+  (cic:/matita/algebra/groups/is_finite_enumerable.con _) e).
 theorem foo:
- ∀G:SemiGroup.
-  enumerable (carrier G) →
-   left_cancellable (carrier G) (op G) →
-    right_cancellable (carrier G) (op G) →
-     ∃e:G. is_left_unit ? e.
-intros (G H);
-unfold left_cancellable in H1;
-letin x ≝ (repr ? H O);
-letin f ≝ (λy.x·(repr ? H y));
-generalize in match (H1 x);
-intro;
-*)
\ No newline at end of file
+ ∀G:finite_enumerable_SemiGroup.
+  left_cancellable ? (op G) →
+  right_cancellable ? (op G) →
+   ∃e:G. isMonoid (mk_PreMonoid G e).
+intros;
+letin f ≝ (λn.ι(G \sub O · G \sub n));
+cut (∀n.n ≤ order ? (is_finite_enumerable G) → ∃m.f m = n);
+[ letin EX ≝ (Hcut O ?);
+  [ apply le_O_n
+  | clearbody EX;
+    clear Hcut;
+    unfold f in EX;
+    elim EX;
+    clear EX;
+    letin HH ≝ (eq_f ? ? (repr ? (is_finite_enumerable G)) ? ? H2);
+    clearbody HH;
+    rewrite > (repr_index_of ? (is_finite_enumerable G)) in HH;
+    apply (ex_intro ? ? (G \sub a));
+    letin GOGO ≝ (refl_eq ? (repr ? (is_finite_enumerable G) O));
+    clearbody GOGO;
+    rewrite < HH in GOGO;
+    rewrite < HH in GOGO:(? ? % ?);
+    rewrite > (associative ? G) in GOGO;
+    letin GaGa ≝ (H ? ? ? GOGO);
+    clearbody GaGa;
+    clear GOGO;
+    constructor 1;
+    [ simplify;
+      apply (semigroup_properties G)
+    | unfold is_left_unit; intro;
+      letin GaxGax ≝ (refl_eq ? (G \sub a ·x));
+      clearbody GaxGax;
+      rewrite < GaGa in GaxGax:(? ? % ?);
+      rewrite > (associative ? (semigroup_properties G)) in GaxGax;
+      apply (H ? ? ? GaxGax)
+    | unfold is_right_unit; intro;
+      letin GaxGax ≝ (refl_eq ? (x·G \sub a));
+      clearbody GaxGax;
+      rewrite < GaGa in GaxGax:(? ? % ?);
+      rewrite < (associative ? (semigroup_properties G)) in GaxGax;
+      apply (H1 ? ? ? GaxGax)
+    ]
+  ]
+|
+].