]> matita.cs.unibo.it Git - helm.git/blob - matita/library/algebra/monoids.ma
tagged 0.5.0-rc1
[helm.git] / matita / library / algebra / monoids.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 set "baseuri" "cic:/matita/algebra/monoids/".
16
17 include "algebra/semigroups.ma".
18
19 record PreMonoid : Type ≝
20  { magma:> Magma;
21    e: magma
22  }.
23
24 record isMonoid (M:PreMonoid) : Prop ≝
25  { is_semi_group:> isSemiGroup M;
26    e_is_left_unit:
27     is_left_unit (mk_SemiGroup ? is_semi_group) (e M);
28    e_is_right_unit:
29     is_right_unit (mk_SemiGroup ? is_semi_group) (e M)
30  }.
31  
32 record Monoid : Type ≝
33  { premonoid:> PreMonoid;
34    monoid_properties:> isMonoid premonoid 
35  }.
36
37 notation "1" with precedence 89
38 for @{ 'munit }.
39
40 interpretation "Monoid unit" 'munit =
41  (cic:/matita/algebra/monoids/e.con _).
42   
43 definition is_left_inverse ≝
44  λM:Monoid.
45   λopp: M → M.
46    ∀x:M. (opp x)·x = 1.
47    
48 definition is_right_inverse ≝
49  λM:Monoid.
50   λopp: M → M.
51    ∀x:M. x·(opp x) = 1.
52
53 theorem is_left_inverse_to_is_right_inverse_to_eq:
54  ∀M:Monoid. ∀l,r.
55   is_left_inverse M l → is_right_inverse M r → 
56    ∀x:M. l x = r x.
57  intros;
58  generalize in match (H x); intro;
59  generalize in match (eq_f ? ? (λy.y·(r x)) ? ? H2);
60  simplify; fold simplify (op M);
61  intro; clear H2;
62  generalize in match (op_associative ? (is_semi_group ? (monoid_properties M)));
63  intro;
64  rewrite > H2 in H3; clear H2;
65  rewrite > H1 in H3;
66  rewrite > (e_is_left_unit ? (monoid_properties M)) in H3;
67  rewrite > (e_is_right_unit ? (monoid_properties M)) in H3;
68  assumption.
69 qed.