1

I am trying to write a tactic to check if my goal is an implication without having to introduce anything beforehand.

Furthermore I would like this tactic to be compatible with any amount of variables such that, for example, forall A B C D, (A/\B)->(C\/D) would still be considered as a valid form.

Ltac is_implication term :=
  match term with
  | ?A -> ?B => idtac term "is an implication"
  | _ => idtac term "is not an implication"; fail 1
  end.


Ltac universal_implication :=
  match goal with
  | [ |- forall _ , ?G]=>is_implication G
  | _=>idtac "Goal is not an universally quantified implication";fail 1
end.


Lemma toto: forall A B:Prop ,A->B.
universal_implication.

(*returns "Goal is not an universally quantified implication
Tactic failure".*)
4
  • Since an implication is just a (not that) fancy universal quantifier: What do you expect to match as an implication? Commented Jun 10 at 10:17
  • @JoJoModding Not sure if I understand the question but I would assume that in the expression forall A B, A->B one would consider A->B to be the implication. Or am I missing your point?
    – HouseCorgi
    Commented Jun 10 at 11:00
  • 1
    A -> B is a syntactic sugar for (forall x:A,B) that coq uses whenever x does not appear in B. So you should rephrase your goal into something like: "I want to detect if among the head products of a type, there is a non dependent one". This is probably possible but not trivial. Commented Jun 10 at 11:15
  • @PierreCourtieu Okay now I understand the issue, thanks I'll try something.
    – HouseCorgi
    Commented Jun 10 at 11:22

0

Browse other questions tagged or ask your own question.