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