Closed cu1ch3n closed 1 year ago
Thanks for the report. Trying to figure out what went wrong.
Could you leave a note here for posterity saying what the bug was?
Thanks for asking for this. It turns out that the bug is not yet fully fixed. Here is a simpler example that still triggers this unsoundness:
Kind u type.
Type i u.
Type p, q, r u -> o.
Define dd : o -> prop by
dd (q i).
Theorem lem: forall X Y,
dd X ->
dd Y ->
(X = r i -> false) ->
(Y = r i -> false).
intros. case H1. case H2. apply H3 to H4.
Theorem foo: forall F, dd F -> false.
intros.
apply lem to H1 H1 _ _. search. case H1.
Theorem bar: dd (q i).
search.
Theorem unsound: false.
apply foo to bar.
The issue is that apply with unknowns calls search
to finish the generated subgoals, but doesn't make sure that the different invocations of search
have compatible instances for generated meta-variables. Needs a more careful implementation than the quick hack I attempted earlier.
By the way, this is a very old bug in Abella. Seems to happen even in pre 2.0.x.
Thanks, although your example didn't actually use p : u -> o, so it could be a little simpler! It's interesting that this has been around this long and not discovered.
Pre 2.0.x the search
tactic basically didn't handle equality, so this bug was never triggered. Now that we eagerly destruct equalities when they enter the context during search
, it seems that we accidentally instantiate variables that should not be instantiated. I'm trying a few potential fixes out now.
Turns out this issue was noted at least twice earlier in two different issues: #113 and #127. Sadly, we didn't weed out all the cases where search
was implicitly invoked without protecting the bind state for meta-variables. Might be worth it to methodically check every single tactic once again.
We (@jiangsy) found that there might be a bug in the equality check, and we could exploit it to prove false. Here is an working example tested on abella-2.0.7 and the lastest abella-2.0.8-dev: