Debian Codegraph @

src/Curves/Weierstrass/AffineProofs.v

raw
1 From Coq Require Import BinNums.
2 From Coq Require Import Morphisms.
3 Require Import Crypto.Spec.WeierstrassCurve Crypto.Curves.Weierstrass.Affine.
4 Require Import Crypto.Algebra.Field Crypto.Algebra.Hierarchy.
5 Require Import Crypto.Util.Decidable Crypto.Util.Tactics.DestructHead Crypto.Util.Tactics.BreakMatch.
6 From Coq Require Import BinPos.
7
8 Module W.
9 Section W.
10 Context {F Feq Fzero Fone Fopp Fadd Fsub Fmul Finv Fdiv} {a b:F}
11 {field:@Algebra.Hierarchy.field F Feq Fzero Fone Fopp Fadd Fsub Fmul Finv Fdiv}
12 {Feq_dec:DecidableRel Feq}.
13 Local Infix "=" := Feq : type_scope. Local Notation "a <> b" := (not (a = b)) : type_scope.
14 Local Notation "0" := Fzero. Local Notation "1" := Fone.
15 Local Infix "+" := Fadd. Local Infix "-" := Fsub. Local Infix "*" := Fmul.
16 Local Notation "4" := (1+1+1+1). Local Notation "27" := (4*4 + 4+4 +1+1+1).
17
18 Local Ltac Algebra_split :=
19 repeat match goal with
20 | |- Proper _ _ => cbv [Proper respectful]; intros
21 | |- Equivalence _ => split; [intros ? | intros ??? | intros ????? ]
22 | |- monoid => split
23 | |- group => split
24 | |- commutative_group => split
25 | |- is_associative => split; intros ???
26 | |- is_commutative => split; intros ??
27 | |- is_left_inverse => split; intros ?
28 | |- is_right_inverse => split; intros ?
29 | |- is_left_identity => split; intros ?
30 | |- is_right_identity => split; intros ?
31 end.
32
33 Global Instance commutative_group
34 char_ge_3
35 {char_ge_12:@Ring.char_ge F Feq Fzero Fone Fopp Fadd Fsub Fmul 12%positive} (* FIXME: shouldn't need we need 4, not 12? *)
36 {discriminant_nonzero:id(4*a*a*a + 27*b*b <> 0)}
37 : commutative_group(eq:=W.eq(a:=a)(b:=b))(op:=W.add(char_ge_3:=char_ge_3))(id:=W.zero)(inv:=W.opp).
38 Proof using Type.
39 Time
40 cbv [W.opp W.eq W.zero W.add W.coordinates proj1_sig];
41 repeat match goal with
42 | _ => progress Algebra_split
43 | H: _ /\ _ |- _ => destruct H
44 | |- _ /\ _ => split
45 | _ => progress break_match
46 | _ => progress break_match_hyps
47 end; try contradiction; trivial.
48 Time par: abstract (fsatz || (cbv [id] in *; fsatz)).
49 Time Qed.
50 End W.
51 End W.