Debian Codegraph @

src/Util/Tactics/UniquePose.v

raw
1 Require Export Crypto.Util.FixCoqMistakes.
2 Require Import Crypto.Util.Tactics.FindHyp.
3
4 (** [pose proof defn], but only if no hypothesis of the same type exists.
5 most useful for proofs of a proposition *)
6 Tactic Notation "unique" "pose" "proof" constr(defn) :=
7 let T := type of defn in
8 tryif let H := find_hyp T in fail 2 "Already a hypothesis" H "of type" T
9 then fail
10 else pose proof defn.
11
12 (** [pose defn], but only if that hypothesis doesn't exist *)
13 Tactic Notation "unique" "pose" constr(defn) :=
14 tryif let H := find_hyp_with_body defn in fail 2 "Already a hypothesis" H "with body" defn
15 then fail
16 else pose defn.
17
18 (** [assert T], but only if no hypothesis of the same type exists.
19 most useful for proofs of a proposition *)
20 Tactic Notation "unique" "assert" constr(T) :=
21 tryif let H := find_hyp T in fail 2 "Already a hypothesis" H "of type" T
22 then fail
23 else assert T.
24
25 (** [assert T], but only if no hypothesis of the same type exists.
26 most useful for proofs of a proposition *)
27 Tactic Notation "unique" "assert" constr(T) "by" tactic3(tac) :=
28 tryif let H := find_hyp T in fail 2 "Already a hypothesis" H "of type" T
29 then fail
30 else assert T by tac.