|
| 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