简体   繁体   中英

How to instantiate a variable of forall in a hypothesis in 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 xl 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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM