Library TLC.LibIntTactics
IMPORTANT: requires the CSDP package to be installed on the system
sudo apt get install ubuntu package coinor-csdp
For documentation, see the Micromega chapter from Coq reference manual:
"Micromega: tactics for solving arithmetic goals over ordered rings"
DISCLAIMER: WORK IN PROGRESS
Set Implicit Arguments.
Require Import Coq.micromega.Psatz.
From TLC Require Import LibTactics.
From TLC Require Export LibInt.
math_lia tactic
Ltac math_lia_core tt :=
math_setup; lia.
Tactic Notation "math_lia" :=
math_lia_core tt.
Binding for nat --TODO: is it useful?
Ltac nat_math_lia :=
nat_math_setup; lia.
math_nia tactic
Ltac math_nia_core tt :=
math_setup; nia.
Tactic Notation "math_nia" :=
math_nia_core tt.
Binding for nat --TODO: is it useful?
Ltac nat_math_nia :=
nat_math_setup; nia.
math_dia
Definition Zdiv_hyp (P:Prop) := P.
Lemma Z_div_mod' : forall a b : int,
Zdiv_hyp ((b > 0)%Z) ->
let (q, r) := Z.div_eucl a b in
a = (b * q)%I + r /\ (0 <= r < b)%Z.
Proof using. applys Z_div_mod. Qed.
Ltac Zdiv_eliminate_step tt :=
match goal with |- context[ Z.div_eucl ?X ?Y ] =>
generalize (@Z_div_mod' X Y);
destruct (Z.div_eucl X Y)
end.
Ltac math_dia_generalize_all_prop tt :=
repeat match goal with H: ?T |- _ =>
match type of T with Prop => gen H end end.
Ltac Zdiv_eliminate tt :=
math_dia_generalize_all_prop tt;
unfold Z.div;
repeat (Zdiv_eliminate_step tt).
Ltac Zdiv_instantiate_hyp_steps tt :=
match goal with H: Zdiv_hyp ?P -> _ |- _ =>
specializes H __;
[ idtac
| try Zdiv_instantiate_hyp_steps tt ]
end.
Ltac Zdiv_instantiate_hyp tt :=
Zdiv_instantiate_hyp_steps tt.
Ltac math_dia_setup :=
math_0; math_1; math_2; math_3; Zdiv_eliminate tt;
intros; try Zdiv_instantiate_hyp_steps tt; unfolds Zdiv_hyp.
Ltac math_dia_core tt :=
math_dia_setup; math_nia.
Tactic Notation "math_dia" :=
math_dia_core tt.