Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

instantiate can produce terms that are not parsable #68

Open
htzh opened this issue Jun 8, 2022 · 1 comment
Open

instantiate can produce terms that are not parsable #68

htzh opened this issue Jun 8, 2022 · 1 comment

Comments

@htzh
Copy link

htzh commented Jun 8, 2022

For example:

utop # t1;;
- : term = `\x. s x`
utop # x1, type_of x1;;
- : term * hol_type = (`x`, `:A->bool`)
utop # let s1 = frees t1 |> hd;;
val s1 : term = `s`
utop # instantiate (term_match [] s1 x1) t1;;
- : term = `\x. x x`

The last term is semantically (and type-wise) okay but will not be accepted by the parser (even with explicit type annotations). The reason is that the two xs have different types so the bound variable is not renamed. On the other hand the following sequence produces the correct renaming:

utop # t2;;
- : term = `\x. s + x`
utop # x2, type_of x2;;
- : term * hol_type = (`x`, `:num`)
utop # let s2 = frees t2 |> hd;;
val s2 : term = `s`
utop # instantiate (term_match [] s2 x2) t2;;
- : term = `\x'. x + x'`
@PetrosPapapa
Copy link
Contributor

PetrosPapapa commented Jun 13, 2022

Hate to say it, but that's a known problem. See this paper for a more detailed discussion and examples with worse consequences.
Typing, in particular, is a common source of unexpected results. See the bottom of this post for relevant comments and the same copied code here to help you inspect the types of variables in your terms (at the cost of significant verbosity).
Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants