Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to instantiate a variable of forall in a hypothesis in Coq?

Tags:

coq

I have two hypotheses

IHl: forall (lr : list nat) (d x : nat), d = x \/ In x l' -> (something else)
Head : d = x

I want to apply IHl on Head as it satisfies d = x \/ In x l of IHl. I tried apply with tactic which fails with a simple hint Error: Unable to unify.

Which tactic should I use to instantiate variables in a hypothesis?

like image 727
xywang Avatar asked Jul 20 '15 11:07

xywang


People also ask

Which tactic will resolve any goal using a false hypothesis?

contradiction. If there is a hypothesis that is equivalent to False or two contradictory hypotheses in the context, you can use the contradiction tactic to prove any goal.

What is a tactic in Coq?

Tactics specify how to transform the proof state of an incomplete proof to eventually generate a complete proof. Proofs can be developed in two basic ways: In forward reasoning, the proof begins by proving simple statements that are then combined to prove the theorem statement as the last step of the proof.


1 Answers

Your hypothesis IHl takes 4 arguments: lr : list nat, d : nat, x : nat, and _ : d = x \/ In x l'.

Your hypothesis Head : d = x does not have the proper type to be passed as the 4th argument. You need to turn it from a proof of equality into a proof of a disjunction. Fortunately, you can use:

or_introl
     : forall A B : Prop, A -> A \/ B

which is one of the two constructors of the or type.

Now you might have to pass explicitly the B Prop, unless it can be figured out in the context by unification.

Here are things that should work:

(* To keep IHl but use its result, given lr : list nat *)
pose proof (IHl lr _ _ (or_introl Head)).

(* To transform IHl into its result, given lr : list nat *)
specialize (IHl lr _ _ (or_introl Head)).

There's probably an apply you can use, but depending on what is implicit/inferred for you, it's hard for me to tell you which one it is.

like image 131
Ptival Avatar answered Nov 12 '22 20:11

Ptival