I am trying to prove that Z3 is a group.
Class Group G : Type :=
{
e : G;
mult : G -> G -> G;
inv : G -> G;
left_id : forall x:G, mult e x = x;
left_inv : forall x:G, mult (inv x) x = e;
assoc : forall x y z:G,
mult x (mult y z) = mult (mult x y) z
}.
Record Z_3 : Type := Z3
{
n :> nat;
proof : n < 3
}.
(* Inhabitants of Z_3 type *)
Proposition lt_0_3 : 0 < 3.
Proof.
repeat constructor.
Qed.
Definition z3_0 : Z_3 := (Z3 0 lt_0_3).
Proposition lt_1_3 : 1 < 3.
Proof.
repeat constructor.
Qed.
Definition z3_1 : Z_3 := (Z3 1 lt_1_3).
Proposition lt_2_3 : 2 < 3.
Proof.
repeat constructor.
Qed.
Definition z3_2 : Z_3 := (Z3 2 lt_2_3).
(* End of inhabitants definition *)
Proposition three_ne_0 : 3 <> 0.
Proof.
intro. discriminate.
Qed.
Definition Z3_op (x y: Z_3) : Z_3 :=
let a := (x + y) mod 3 in
Z3 a (Nat.mod_upper_bound _ 3 three_ne_0).
Lemma Z_3_inv_lemma (k: nat) : (3 + k) < 3 -> False.
Proof.
intro. inversion_clear H. inversion_clear H0. inversion_clear H. inversion_clear H0.
Qed.
Lemma void {t : Set} : False -> t.
Proof.
intro. contradiction H.
Qed.
Definition Z_3_inv (x : Z_3) : Z_3 :=
match x with
| Z3 0 pf => Z3 0 pf
| Z3 1 pf => Z3 2 lt_2_3
| Z3 2 pf => Z3 1 lt_1_3
| Z3 (S (S (S k))) pf => void (Z_3_inv_lemma k pf)
end.
Proposition Z3_left_id : forall x: Z_3, (Z3_op z3_0 x) = x.
Proof.
intro. unfold Z3_op. destruct x. inversion proof0.
-
Here I am stuck:
1 subgoal (ID 46)
n0 : nat
proof0 : n0 < 3
H0 : n0 = 2
============================
{|
n := (z3_0 + {| n := n0; proof := proof0 |}) mod 3;
proof := Nat.mod_upper_bound
(z3_0 + {| n := n0; proof := proof0 |}) 3
three_ne_0 |} = {| n := n0; proof := proof0 |}
rewrite H0.
doesn't work. Sorry, it's too hard for me to move further when these records are involved.