Skip to content
Snippets Groups Projects
Commit e4012a4d authored by Felipe Cerqueira's avatar Felipe Cerqueira
Browse files

Add tactic for splitting conjunction

parent b6c93d38
No related branches found
No related tags found
No related merge requests found
...@@ -403,8 +403,16 @@ Ltac exploit x := ...@@ -403,8 +403,16 @@ Ltac exploit x :=
|| refine ((fun x y => y x) (x _ _) _) || refine ((fun x y => y x) (x _ _) _)
|| refine ((fun x y => y x) (x _) _). || refine ((fun x y => y x) (x _) _).
(* Feed tactic -- exploit with multiple arguments. (* This tactic feeds the precondition of an implication in order to derive the conclusion
(taken from http://comments.gmane.org/gmane.science.mathematics.logic.coq.club/7013) *) (taken from http://comments.gmane.org/gmane.science.mathematics.logic.coq.club/7013).
Usage: feed H.
H: P -> Q ==becomes==> H: P
____
Q
After completing this proof, Q becomes a hypothesis in the context. *)
Ltac feed H := Ltac feed H :=
match type of H with match type of H with
| ?foo -> _ => | ?foo -> _ =>
...@@ -412,15 +420,39 @@ Ltac feed H := ...@@ -412,15 +420,39 @@ Ltac feed H :=
assert foo as FOO; [|specialize (H FOO); clear FOO] assert foo as FOO; [|specialize (H FOO); clear FOO]
end. end.
(* Generalization of feed for multiple hypotheses.
feed_n is useful for accessing conclusions of long implications.
Usage: feed_n 3 H.
H: P1 -> P2 -> P3 -> Q.
We'll be asked to prove P1, P2 and P3, so that Q can be inferred. *)
Ltac feed_n n H := match constr:(n) with Ltac feed_n n H := match constr:(n) with
| O => idtac | O => idtac
| (S ?m) => feed H ; [| feed_n m H] | (S ?m) => feed H ; [| feed_n m H]
end. end.
(* ************************************************************************** *) (* ************************************************************************** *)
(** * New tactics for ssreflect *) (** * New tactics for ssreflect *)
(* ************************************************************************** *) (* ************************************************************************** *)
(* Tactic for simplifying a sum with constant term.
Usage: simpl_sum_const in H.
H: \sum_(2 <= x < 4) 5 > 0 ==becomes==> H: 5 * (4 - 2) > 0 *)
Ltac simpl_sum_const := Ltac simpl_sum_const :=
rewrite ?big_const_nat ?big_const_ord ?big_const_seq iter_addn ?muln1 ?mul1n ?mul0n rewrite ?big_const_nat ?big_const_ord ?big_const_seq iter_addn ?muln1 ?mul1n ?mul0n
?muln0 ?addn0 ?add0n. ?muln0 ?addn0 ?add0n.
\ No newline at end of file
(* Tactic for splitting all conjunctions in a hypothesis.
Usage: split_conj H.
H: A /\ (B /\ C) ==becomes==> H1: A
H2: B
H3: C *)
Ltac split_conj X :=
hnf in X;
repeat match goal with
| H : ?p /\ ?q |- _ =>
let x' := H in
let y' := fresh H in
destruct H as [x' y']
end.
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment