Skip to content

Commit dd5bc18

Browse files
Fill in some lemmas
1 parent 2c4ec21 commit dd5bc18

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

coq_error_metrics/lemmas.v

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,51 @@ Section HelperLemmas.
3030

3131
(* NB: x is not reflexive *)
3232

33-
Lemma lt0_NonZeroSameSign x y : x < 0 -> NonZeroSameSign x y -> y < 0.
34-
Proof. Admitted.
33+
Lemma lt0_NonZeroSameSign : forall x y, x < 0 -> NonZeroSameSign x y -> y < 0.
34+
Proof. rewrite /NonZeroSameSign. move=> x y H1 H2.
35+
case: H2 => H3; lra. Qed.
3536

36-
Lemma gt0_NonZeroSameSign x y : 0 < x -> NonZeroSameSign x y -> 0 < y.
37-
Proof. Admitted.
37+
Lemma gt0_NonZeroSameSign : forall x y, 0 < x -> NonZeroSameSign x y -> 0 < y.
38+
Proof. rewrite /NonZeroSameSign. move=> x y H1 H2.
39+
case: H2 => H3; lra. Qed.
3840

3941
Lemma NonZeroSameSignMulGen : forall (a a' b b' : R),
4042
(NonZeroSameSign a a') -> (NonZeroSameSign b b') ->(NonZeroSameSign (a * b) (a' * b')).
41-
Proof. Admitted.
43+
Proof. rewrite /NonZeroSameSign. move=> a a' b b' H1 H2.
44+
case: H1 => H3; case: H2 => H4.
45+
left.
46+
split; destruct H3; destruct H4; apply mulr_gt0 => //.
47+
right.
48+
split; destruct H3; destruct H4.
49+
replace (a * b) with (b * a) by lra.
50+
51+
remember (- b) as n.
52+
replace b with (- n) by lra.
53+
assert (0 < n) by lra.
54+
suff opp: 0 < (n * a) by lra.
55+
apply mulr_gt0 => //.
56+
57+
remember (- b') as n.
58+
replace b' with (- n) by lra.
59+
assert (0 < n) by lra.
60+
suff opp: (0 < n * a') by lra.
61+
apply mulr_gt0 => //.
62+
63+
destruct H3. destruct H4.
64+
right.
65+
remember (- a) as n. remember (- a') as n'.
66+
replace a with (- n) by lra. replace a' with (- n') by lra.
67+
assert (0 < n) by lra. assert (0 < n') by lra.
68+
split.
69+
suff opp: (0 < n * b) by lra. apply mulr_gt0 => //.
70+
suff opp: (0 < n' * b') by lra. apply mulr_gt0 => //.
71+
72+
destruct H3. destruct H4.
73+
left. split.
74+
suff opp: (0 < (- a) * (- b)) by lra.
75+
apply mulr_gt0 => //; lra.
76+
suff opp: (0 < (- a') * (- b')) by lra.
77+
apply mulr_gt0 => //; lra. Qed.
4278

4379
(* TODO: prove that it is transitive + reflexive; derive the following from the above lemma *)
4480

0 commit comments

Comments
 (0)