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

avoid sortedness errors with polymorphically let-bound constants #544

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MichaelRawson
Copy link
Contributor

Fixes bug 1 of #542 by providing a fast path for constants in getResultSort that also does not assert a condition that isn't true for let-bound constants.

A TFX1 $let might capture sort variables. Consider e.g. polymorphic lists and the following axiom.

tff(bug, axiom, ![A: $tType]: $let(x: list(A), x := nil(A), e)).

In the expression e, x: list(A). But this is a non-polymorphic constant (both term and type arity 0) with a variable in its result sort, which SortHelper doesn't like. It seems to be eliminated just fine in later FOOLing around.

// fast path for constants
// also avoids assertion failures below with $let-bound constants,
// which have arity 0 but their sort may contain sort variables (!)
if(!t->arity()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to this paper, let binders can be non-constant as well. Not saying I have a better idea for now, just that in general we should expect this in other cases as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. By some miracle we actually seem to parse and process these beasts correctly (which then triggers the old assertion again). They could even have type arguments. :-O

Proposal: flag let-bound symbols and exempt them from such assertions. This was my original idea but it seemed too heavy-handed for just constants.

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

Successfully merging this pull request may close these issues.

None yet

2 participants