Closed yvting closed 6 years ago
The bug is caused by the function replace_metaterm_vars
in metaterm.ml
. I have pushed a fix to the branch renaming-fix
.
find_free_constants
to compute the top-level constants in a metaterm.replace_metaterm_vars
. First, it makes use of find_free_constants
and other functions to compute free variables of metaterms. Second, the new implementation divides free variables into two parts: the first contains free variables that are unchanged and the second contains free variables that are renamed or substituted for. Using those information, it decides whether to rename bound variables and what they should be renamed into to avoid conflicts. See the comments in code for details.Let me know if you have any question.
BTW, I feel that it is very cumbersome to use explicit names for bound variables in metaterms. It seems better to represent them using debruijn indexes, like in terms.
I've tried to De Bruijn-ify metaterms a number of times, but never had the tenacity to see it through. I think it is a good idea nevertheless.
Renaming of bound variables in a metaterm does not check clash of names between renamed variables and top-level constants
Consider the following (contrived) example:
To prove
rename_failure
, the firstintro
introduces a new eigenvariable namedp
. The secondintro
introduces a variable namedp1
which is the first fresh name that does not conflict withp
. This triggers the renaming of bound variablep1
. Because the renaming process does not consider conflicts with top-level constants, it wrongly decides thatp2
is the first fresh name that does not capture free variables after renaming. As such, the final goal becomesforall (p2:i), p2 = p2
which is provable.Using
rename_failure
, we can easily provefalse
, as follows: