]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/library/algebra/monoids.ma
A very nice experiment using notation: we define the notation for natural
[helm.git] / helm / software / 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 include "algebra/semigroups.ma".
16
17 record PreMonoid : Type ≝
18  { magma:> Magma;
19    e: magma
20  }.
21
22 record isMonoid (M:PreMonoid) : Prop ≝
23  { is_semi_group:> isSemiGroup M;
24    e_is_left_unit:
25     is_left_unit (mk_SemiGroup ? is_semi_group) (e M);
26    e_is_right_unit:
27     is_right_unit (mk_SemiGroup ? is_semi_group) (e M)
28  }.
29  
30 record Monoid : Type ≝
31  { premonoid:> PreMonoid;
32    monoid_properties:> isMonoid premonoid 
33  }.
34
35 notation "1" with precedence 89
36 for @{ 'munit }.
37
38 interpretation "Monoid unit" 'munit =
39  (cic:/matita/algebra/monoids/e.con _).
40   
41 definition is_left_inverse ≝
42  λM:Monoid.
43   λopp: M → M.
44    ∀x:M. (opp x)·x = 1.
45    
46 definition is_right_inverse ≝
47  λM:Monoid.
48   λopp: M → M.
49    ∀x:M. x·(opp x) = 1.
50
51 theorem is_left_inverse_to_is_right_inverse_to_eq:
52  ∀M:Monoid. ∀l,r.
53   is_left_inverse M l → is_right_inverse M r → 
54    ∀x:M. l x = r x.
55  intros;
56  generalize in match (H x); intro;
57  generalize in match (eq_f ? ? (λy.y·(r x)) ? ? H2);
58  simplify; fold simplify (op M);
59  intro; clear H2;
60  generalize in match (op_associative ? (is_semi_group ? (monoid_properties M)));
61  intro;
62  rewrite > H2 in H3; clear H2;
63  rewrite > H1 in H3;
64  rewrite > (e_is_left_unit ? (monoid_properties M)) in H3;
65  rewrite > (e_is_right_unit ? (monoid_properties M)) in H3;
66  assumption.
67 qed.