Skip to content

Commit f5da0b3

Browse files
committed
Retrieve computational part of micromega from Stdlib
1 parent ece2815 commit f5da0b3

File tree

8 files changed

+895
-2
lines changed

8 files changed

+895
-2
lines changed

doc/corelib/index-list.html.template

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,4 +200,15 @@ through the <tt>Require Import</tt> command.</p>
200200
theories/Corelib/ring/field_checker.v
201201
theories/Corelib/ring/field_eval.v
202202
</dd>
203+
204+
<dt id="micromega"> <a href="#micromega"><b>micromega</b></a>:
205+
The micromega tactics
206+
</dt>
207+
<dd>
208+
theories/Corelib/micromega/micromega_formula.v
209+
theories/Corelib/micromega/micromega_witness.v
210+
theories/Corelib/micromega/micromega_tactics.v
211+
theories/Corelib/micromega/micromega_checker.v
212+
theories/Corelib/micromega/micromega_eval.v
213+
</dd>
203214
</dl>

test-suite/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ UNIT_TESTS := unit-tests
188188
DISABLED_SUBSYSTEMS?=
189189

190190
VSUBSYSTEMS := prerequisite success failure bugs bugs-nocoqchk output output-coqtop \
191-
output-modulo-time $(INTERACTIVE) $(COMPLEXITY) modules stm \
191+
output-modulo-time micromega $(INTERACTIVE) $(COMPLEXITY) modules stm \
192192
coqdoc ssr $(wildcard primitive/*) ltac2 coqchk
193193

194194
# All subsystems
@@ -281,6 +281,7 @@ summary:
281281
$(call summary_dir, "Interactive tests", interactive); \
282282
$(call summary_dir, "Miscellaneous tests", misc); \
283283
$(call summary_dir, "Complexity tests", complexity); \
284+
$(call summary_dir, "Micromega tests", micromega); \
284285
$(call summary_dir, "Module tests", modules); \
285286
$(call summary_dir, "Primitive tests", primitive); \
286287
$(call summary_dir, "STM tests", stm); \
@@ -377,7 +378,7 @@ $(addsuffix .log,$(wildcard prerequisite/*.v)): %.v.log: %.v
377378
} > "$@"
378379
$(HIDE)$(call REPORT_TIMER,$@)
379380

380-
$(addsuffix .log,$(wildcard bugs/*.v ssr/*.v success/*.v failure/*.v stm/*.v modules/*.v primitive/*/*.v ltac2/*.v coqchk/*.v)): %.v.log: %.v $(PREREQUISITELOG)
381+
$(addsuffix .log,$(wildcard bugs/*.v ssr/*.v success/*.v failure/*.v stm/*.v micromega/*.v modules/*.v primitive/*/*.v ltac2/*.v coqchk/*.v)): %.v.log: %.v $(PREREQUISITELOG)
381382
$(SHOW) "TEST $< $(call get_coq_prog_args_in_parens,"$<")"
382383
$(HIDE){ \
383384
opts="$(if $(findstring modules/,$<),-R modules Mods)"; \
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
From Corelib Require Import BinNums RatDef micromega_formula micromega_witness.
2+
From Corelib Require Import micromega_tactics.
3+
4+
Goal True.
5+
Proof.
6+
(* x + 2 y <= 3 -> 2 x + y <= 3 -> x + y <= 2 *)
7+
pose (ffQ :=
8+
IMPL
9+
(EQ
10+
(A isBool
11+
{|
12+
Flhs := PEadd (PEX _ xH) (PEmul (PEc (Qmake (Zpos (xO xH)) xH)) (PEX _ (xO xH)));
13+
Fop := OpLe;
14+
Frhs := PEc (Qmake (Zpos (xI xH)) xH)
15+
|} tt) (TT isBool)) None
16+
(IMPL
17+
(EQ
18+
(A isBool
19+
{|
20+
Flhs := PEadd (PEmul (PEc (Qmake (Zpos (xO xH)) xH)) (PEX _ xH)) (PEX _ (xO xH));
21+
Fop := OpLe;
22+
Frhs := PEc (Qmake (Zpos (xI xH)) xH)
23+
|} tt) (TT isBool)) None
24+
(EQ
25+
(A isBool
26+
{| Flhs := PEadd (PEX _ xH) (PEX _ (xO xH)); Fop := OpLe; Frhs := PEc (Qmake (Zpos (xO xH)) xH) |} tt)
27+
(TT isBool))) : BFormula (Formula Q) isProp).
28+
let ff' := eval unfold ffQ in ffQ in wlra_Q wit0 ff'.
29+
Check eq_refl : wit0 = (PsatzAdd (PsatzIn Q 2)
30+
(PsatzAdd (PsatzIn Q 1) (PsatzMulE (PsatzC (Qmake (Zpos (xI xH)) xH)) (PsatzIn Q 0))) :: nil)%list.
31+
(* indeed, ff is normalized to:
32+
~ (x + y - 2 > 0 /\ - 2 x - y + 3 >= 0 /\ - x - 2 y + 3 >= 0)
33+
\-----v-----/ \-------v--------/ \-------v--------/
34+
(0) (1) (2)
35+
witness is (2) + (1) + 3 * (0) meaning that (0) /\ (1) /\ (2) implies 0 > 0
36+
which is inconsistent and proves the original formula by contraposite. *)
37+
(* 2 * x <= 1 -> x <= 0 *)
38+
pose (ffZ :=
39+
IMPL
40+
(A isProp
41+
{|
42+
Flhs := PEmul (PEc (Zpos (xO xH))) (PEX _ xH);
43+
Fop := OpLe;
44+
Frhs := PEc (Zpos xH)
45+
|} tt) None
46+
(A isProp
47+
{|
48+
Flhs := PEX _ xH;
49+
Fop := OpLe;
50+
Frhs := PEc Z0
51+
|} tt) : BFormula (Formula Z) isProp).
52+
let ff' := eval unfold ffZ in ffZ in wlia wit1 ff'.
53+
Check eq_refl : wit1 = (CutProof (PsatzIn Z 1)
54+
(RatProof (PsatzAdd (PsatzIn Z 0) (PsatzIn Z 1)) DoneProof) :: nil)%list.
55+
let ff' := eval unfold ffZ in ffZ in wnia wit2 ff'.
56+
Check eq_refl : wit2 = (CutProof (PsatzIn Z 1)
57+
(RatProof (PsatzAdd (PsatzIn Z 0) (PsatzIn Z 1)) DoneProof) :: nil)%list.
58+
let ff' := eval unfold ffQ in ffQ in wnra_Q wit3 ff'.
59+
Check eq_refl : wit3 = (PsatzAdd (PsatzIn Q 2)
60+
(PsatzAdd (PsatzIn Q 1) (PsatzMulE (PsatzC (Qmake (Zpos (xI xH)) xH)) (PsatzIn Q 0))) :: nil)%list.
61+
Fail let ff' := eval unfold ffQ in ffQ in wsos_Q wit4 ff'.
62+
Fail let ff' := eval unfold ffZ in ffZ in wsos_Z wit5 ff'.
63+
(* Requires Csdp, not in CI
64+
let ff' := eval unfold ffZ in ffZ in wpsatz_Z 3 wit6 ff'.
65+
Check eq_refl : wit6 = (RatProof (PsatzAdd (PsatzC (Zpos xH))
66+
(PsatzAdd (PsatzIn Z 1) (PsatzMulE (PsatzC (Zpos (xO xH))) (PsatzIn Z 0))))
67+
DoneProof :: nil)%list.
68+
let ff' := eval unfold ffQ in ffQ in wpsatz_Q 3 wit7 ff'.
69+
Check eq_refl : wit7 = (PsatzAdd (PsatzIn Q 0)
70+
(PsatzAdd (PsatzMulE (PsatzIn Q 2) (PsatzC (Qmake (Zpos xH) (xO xH))))
71+
(PsatzAdd (PsatzMulE (PsatzIn Q 1) (PsatzC (Qmake (Zpos xH) (xO xH))))
72+
(PsatzMulE (PsatzIn Q 0) (PsatzC (Qmake (Zpos xH) (xO xH)))))) :: nil)%list. *)
73+
(* (0) + 1/2 * (2) + 1/2 * (1) + 1/2 * (0) *)
74+
Abort.

0 commit comments

Comments
 (0)