VST icon indicating copy to clipboard operation
VST copied to clipboard

`ecareful_unify` can't handle evars in if-then-else

Open mansky1 opened this issue 3 years ago • 2 comments

In investigating why sep_apply failed on a fairly simple example, I discovered that ecareful_unify (which ecancel uses to resolve evars) fails on if-then-else expressions.

Example:

Require Import VST.floyd.seplog_tactics.

Goal forall (a b c : bool), (if a then b else c) = if a then b else c.
Proof.
  intros.
  evar (a' : bool).
  replace a with a' at 2.
  unfold a'.
  Fail ecareful_unify.

For cancel this is only a minor annoyance, but for sep_apply it means that trying to apply a lemma with an if-then-else on the LHS of the |-- will fail with no useful error (unless all arguments are explicitly provided).

mansky1 avatar Jul 22 '22 11:07 mansky1

Maybe I wrote this part of the code, but I cannot remember everything. ecareful_unify looks weaker than unify and do less evar instantiation. You want to unify if ?a then b else c with if a then b else c. This seems natural and enhancing ecareful_unify seems no harm.

QinshiWang avatar Jul 29 '22 21:07 QinshiWang

I wrote this tactic because unify is too strong. But in what case unify is too strong?

On Fri, Jul 29, 2022, 5:29 PM Qinshi Wang @.***> wrote:

Maybe I wrote this part of the code, but I cannot remember everything. ecareful_unify looks weaker than unify and do less evar instantiation. You want to unify if ?a then b else c with if a then b else c. This seems natural and enhancing ecareful_unify seems no harm.

— Reply to this email directly, view it on GitHub https://github.com/PrincetonUniversity/VST/issues/609#issuecomment-1199958074, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABVWI6MCBOYE5XROWFASUFLVWREMZANCNFSM54LDOFMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

bcip avatar Jul 31 '22 06:07 bcip

As long as a,a' have type bool, then PR #684 fixes this. The more general case (arbitrary inductive datatype with two constructors) would be a bit more fiddly to implement.

andrew-appel avatar May 25 '23 16:05 andrew-appel