Skip to content

Commit c6f72de

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

File tree

8 files changed

+879
-2
lines changed

8 files changed

+879
-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: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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 (ff :=
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 ff in ff 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+
let ff' := eval unfold ff in ff in wlia wit1 ff'.
38+
Check eq_refl : wit1 = (RatProof (PsatzAdd (PsatzIn Z 2) (PsatzAdd (PsatzIn Z 1)
39+
(PsatzIn Z 0))) DoneProof :: nil)%list.
40+
let ff' := eval unfold ff in ff in wnia wit4 ff'.
41+
Check eq_refl : wit4 = (RatProof (PsatzAdd (PsatzIn Z 2) (PsatzAdd (PsatzIn Z 1)
42+
(PsatzIn Z 0))) DoneProof :: nil)%list.
43+
let ff' := eval unfold ff in ff in wnra_Q wit5 ff'.
44+
Check eq_refl : wit5 = (PsatzAdd (PsatzIn Q 2)
45+
(PsatzAdd (PsatzIn Q 1) (PsatzMulE (PsatzC (Qmake (Zpos (xI xH)) xH)) (PsatzIn Q 0))) :: nil)%list.
46+
Fail let ff' := eval unfold ff in ff in wsos_Q wit6 ff'.
47+
Fail let ff' := eval unfold ff in ff in wsos_Z wit6 ff'.
48+
(* Requires Csdp, not in CI
49+
let ff' := eval unfold ff in ff in wpsatz_Z 3 wit2 ff'.
50+
Check eq_refl : wit2 = (RatProof (PsatzAdd (PsatzC (Zpos xH))
51+
(PsatzAdd (PsatzIn Z 2) (PsatzAdd (PsatzIn Z 1) (PsatzIn Z 0)))) DoneProof
52+
:: nil)%list.
53+
let ff' := eval unfold ff in ff in wpsatz_Q 3 wit3 ff'.
54+
Check eq_refl : wit3 = (PsatzAdd (PsatzIn Q 0)
55+
(PsatzAdd (PsatzMulE (PsatzIn Q 2) (PsatzC (Qmake (Zpos xH) (xO xH))))
56+
(PsatzAdd (PsatzMulE (PsatzIn Q 1) (PsatzC (Qmake (Zpos xH) (xO xH))))
57+
(PsatzMulE (PsatzIn Q 0) (PsatzC (Qmake (Zpos xH) (xO xH)))))) :: nil)%list. *)
58+
(* (0) + 1/2 * (2) + 1/2 * (1) + 1/2 * (0) *)
59+
Abort.

0 commit comments

Comments
 (0)