Debian Codegraph @

src/Algebra/Field_test.v

raw
1 From Coq Require Import BinPosDef.
2 Require Import Crypto.Util.Decidable Crypto.Util.Notations.
3 Require Import Crypto.Algebra.Ring Crypto.Algebra.Field.
4
5 Module _fsatz_test.
6 Section _test.
7 Context {F eq zero one opp add sub mul inv div}
8 {fld:@Hierarchy.field F eq zero one opp add sub mul inv div}
9 {eq_dec:DecidableRel eq}.
10 Local Infix "=" := eq. Local Notation "a <> b" := (not (a = b)).
11 Local Infix "=" := eq : type_scope. Local Notation "a <> b" := (not (a = b)) : type_scope.
12 Local Notation "0" := zero. Local Notation "1" := one.
13 Local Infix "+" := add. Local Infix "*" := mul.
14 Local Infix "-" := sub. Local Infix "/" := div.
15
16 Lemma inv_hyp a b c d (H:a*inv b=inv d*c) (bnz:b<>0) (dnz:d<>0) : a*d = b*c.
17 Proof using Type*. fsatz. Qed.
18
19 Lemma inv_goal a b c d (H:a=b+c) (anz:a<>0) : inv a*d + 1 = (d+b+c)*inv(b+c).
20 Proof using Type*. fsatz. Qed.
21
22 Lemma div_hyp a b c d (H:a/b=c/d) (bnz:b<>0) (dnz:d<>0) : a*d = b*c.
23 Proof using Type*. fsatz. Qed.
24
25 Lemma div_goal a b c d (H:a=b+c) (anz:a<>0) : d/a + 1 = (d+b+c)/(b+c).
26 Proof using Type*. fsatz. Qed.
27
28 Lemma inv_inv x (H:x <> 0) : 1/(1/x) = x.
29 Proof using Type*. fsatz. Qed.
30
31 Lemma zero_neq_one : 0 <> 1.
32 Proof using Type*. fsatz. Qed.
33
34 Lemma only_two_square_roots x y : x * x = y * y -> x <> opp y -> x = y.
35 Proof using Type*. intros; fsatz. Qed.
36
37 Lemma transitivity_contradiction a b c (ab:a=b) (bc:b=c) (X:a<>c) : False.
38 Proof using Type*. fsatz. Qed.
39
40 Lemma algebraic_contradiction a b c (A:a+b=c) (B:a-b=c) (X:a*a - b*b <> c*c) : False.
41 Proof using Type*. fsatz. Qed.
42
43 Lemma division_by_zero_in_hyps (bad:1/0 + 1 = (1+1)/0): 1 = 1.
44 Proof using Type*. fsatz. Qed.
45 Lemma division_by_zero_in_hyps_eq_neq (bad:1/0 + 1 = (1+1)/0): 1 <> 0.
46 Proof using Type*.
47 fsatz. Qed.
48 Lemma division_by_zero_in_hyps_neq_neq (bad:1/0 <> (1+1)/0): 1 <> 0.
49 Proof using Type*.
50 fsatz. Qed.
51 Import BinNums.
52
53 Context {char_ge_16:@Ring.char_ge F eq zero one opp add sub mul 16}.
54
55 Local Notation two := (one+one) (only parsing).
56 Local Notation three := (one+one+one) (only parsing).
57 Local Notation seven := (three+three+one) (only parsing).
58 Local Notation nine := (three+three+three) (only parsing).
59
60 Lemma fractional_equation_solution x (A:x<>1) (B:x<>opp two) (C:x*x+x <> two) (X:nine/(x*x + x - two) = three/(x+two) + seven*inv(x-1)) : x = opp one / (three+two).
61 Proof using Type*. fsatz. Qed.
62
63 Lemma fractional_equation_no_solution x (A:x<>1) (B:x<>opp two) (C:x*x+x <> two) (X:nine/(x*x + x - two) = opp three/(x+two) + seven*inv(x-1)) : False.
64 Proof using Type*. fsatz. Qed.
65
66 Local Notation "x ^ 2" := (x*x).
67 Lemma recursive_nonzero_solving
68 (a sqrt_a d x y : F)
69 (Hpoly : a * x^2 + y^2 = one + d * x^2 * y^2)
70 (Hsqrt : sqrt_a^2 = a)
71 (Hfrac : (sqrt_a / y)^2 <> d)
72 : x^2 = (y^2 - one) / (d * y^2 - a).
73 Proof using eq_dec fld. fsatz. Qed.
74
75 Local Notation "x ^ 3" := (x^2*x).
76 Lemma weierstrass_associativity_main a b x1 y1 x2 y2 x4 y4
77 (A: y1^2=x1^3+a*x1+b)
78 (B: y2^2=x2^3+a*x2+b)
79 (C: y4^2=x4^3+a*x4+b)
80 (Hi3: x2 <> x1)
81 λ3 (Hλ3: λ3 = (y2-y1)/(x2-x1))
82 x3 (Hx3: x3 = λ3^2-x1-x2)
83 y3 (Hy3: y3 = λ3*(x1-x3)-y1)
84 (Hi7: x4 <> x3)
85 λ7 (Hλ7: λ7 = (y4-y3)/(x4-x3))
86 x7 (Hx7: x7 = λ7^2-x3-x4)
87 y7 (Hy7: y7 = λ7*(x3-x7)-y3)
88 (Hi6: x4 <> x2)
89 λ6 (Hλ6: λ6 = (y4-y2)/(x4-x2))
90 x6 (Hx6: x6 = λ6^2-x2-x4)
91 y6 (Hy6: y6 = λ6*(x2-x6)-y2)
92 (Hi9: x6 <> x1)
93 λ9 (Hλ9: λ9 = (y6-y1)/(x6-x1))
94 x9 (Hx9: x9 = λ9^2-x1-x6)
95 y9 (Hy9: y9 = λ9*(x1-x9)-y1)
96 : x7 = x9 /\ y7 = y9.
97 Proof using Type*. fsatz_prepare_hyps; split; fsatz. Qed.
98 End _test.
99 End _fsatz_test.