-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgroups_Z.v
71 lines (61 loc) · 2.76 KB
/
groups_Z.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Require Import ZArith.
Add LoadPath ".".
Require Import groups.
Instance semigroupZ : Semigroup Z :=
{
mult := Z.add;
assoc := Z.add_assoc;
}.
Instance monoidZ : Monoid Z :=
{
e := 0;
left_id := Z.add_0_l;
}.
Instance groupZ : Group Z :=
{
inv := Z.opp;
left_inv := Z.add_opp_diag_l;
}.
Open Scope group_scope.
Section Z_Groups.
Variable G: Type.
Context `{Hgr: Group G}.
Definition pow_z (a: G) (z: Z) : G :=
match z with
| Z0 => e
| Zpos x => pow G a (Pos.to_nat x)
| Zneg x => inv (pow G a (Pos.to_nat x))
end.
Notation "a ** b" := (pow_z a b) (at level 35, right associativity).
Lemma pow_a_n_plus_1_Z : forall (a: G) (n: Z), (pow_z a (Z.succ n)) = a * pow_z a n.
Proof.
intros a n. unfold Z.succ. unfold Z.add.
destruct n.
- simpl. reflexivity.
- simpl. rewrite (Pos2Nat.inj_add p 1). rewrite Nat.add_comm. rewrite <- a_pow_m_n. simpl. rewrite (right_id G). reflexivity.
- rewrite <- Pos2Z.add_pos_neg. induction p using Pos.peano_ind.
+ simpl. rewrite (right_id G). rewrite right_inv. reflexivity.
+ rewrite <- Pos.add_1_l. rewrite <- Pos2Z.add_neg_neg. rewrite Z.add_assoc. rewrite Z.add_opp_diag_r. rewrite Z.add_0_l. rewrite Pos2Z.add_neg_neg. unfold pow_z. rewrite Pos.add_comm. rewrite Pos2Nat.inj_add. simpl. rewrite <- a_pow_m_n. rewrite inv_prod. simpl. rewrite (right_id G). rewrite assoc. rewrite right_inv. rewrite left_id. reflexivity.
Qed.
Lemma pow_a_n_minus_1_Z : forall (a: G) (n: Z), (pow_z a (Z.pred n)) = inv(a) * pow_z a n.
Proof.
intros a n. unfold Z.pred. unfold Z.add.
destruct n.
- simpl. repeat rewrite (right_id G). reflexivity.
- rewrite <- Pos2Z.add_pos_neg. induction p using Pos.peano_ind.
+ simpl. rewrite (right_id G). rewrite left_inv. reflexivity.
+ rewrite Pplus_one_succ_l. rewrite Pos.add_1_l. rewrite Pos2Z.inj_succ. rewrite pow_a_n_plus_1_Z. rewrite assoc. rewrite left_inv. rewrite left_id. rewrite <- Z.add_1_r. rewrite <- Z.add_assoc. rewrite Pos2Z.add_pos_neg. simpl (Z.pos_sub 1 1). rewrite Z.add_0_r. reflexivity.
- simpl. rewrite (Pos2Nat.inj_add p 1). rewrite <- a_pow_m_n. rewrite inv_prod. simpl (pow G a (Pos.to_nat 1)). rewrite (right_id G). reflexivity.
Qed.
Proposition a_pow_m_n_Z : forall (a: G) (n m: Z), (pow_z a n)*(pow_z a m) = pow_z a (n + m).
Proof.
intros. induction n using Z.peano_ind.
- simpl. apply left_id.
- rewrite pow_a_n_plus_1_Z. rewrite <- assoc. rewrite IHn. rewrite <- pow_a_n_plus_1_Z. rewrite Z.add_succ_l. reflexivity.
- rewrite pow_a_n_minus_1_Z. rewrite <- assoc. rewrite IHn.
rewrite Z.add_pred_l. rewrite pow_a_n_minus_1_Z. reflexivity.
Qed.
Definition order (a: G) (n: nat) :=
pow G a n = e /\ (forall k, 0 < k < n -> pow G a k <> e).
End Z_Groups.
Close Scope group_scope.