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

Fixing #3089, and some unifier fixes #3091

Merged
merged 11 commits into from
Nov 14, 2023
Merged

Fixing #3089, and some unifier fixes #3091

merged 11 commits into from
Nov 14, 2023

Conversation

mtzguido
Copy link
Member

#3089 revealed that the unifier is not using primops for its normalization to WHNF, but I believe it should. While it is using primops in some localized places (see e.g. let equal around line 4176), it's not the case for the whnf function called in compress_tprob. Adding Primops there fixes the problem in #3089, but uncovers two other issues due to the extra normalization:

1- We are not handling equality of universe values (causing a regression in FStar.Reflection.Typing), or other lazy opaque terms. I fixed by this making the unifier expand lazy terms to their representation, as long as this is sound, i.e. if the repr is complete. This is case for universes, fixing this issue.

2- The unifier cannot match N (a literal) with - X (a negation, i.e. an application of op_Minus). I made this work by rewriting the problem into -N (still a literal) and X. This was uncovered by a failing tactic in Vale code. I've added an F* test for it now.

Everest came back green locally.

mtzguido added a commit to mtzguido/mitls-fstar that referenced this pull request Nov 13, 2023
This stopped working after making the unifier reduce primops
(FStarLang/FStar#3091), as it has no knowledge
of arithmetic (except for the treatment of literals and negation).
Hence, a problem like `3 =?= n+1` fails.
@mtzguido
Copy link
Member Author

Actually it does lead to one regression: project-everest/mitls-fstar#258

@mtzguido
Copy link
Member Author

I rebased the PR and removed point (2). The only failure caused by this fact is in a use of the canonicalization tactic (FStar.Tactics.Canon) since it was trying to interpret terms as arithmetic formulas, and relying on the fact that if repr t = e, then repr (-t) = Neg e, which is now not true if t is a literal. It's a simple fix to make the tactic smarter, and arguably the right thing to do instead of specializing some arithmetic fact into the unifier. The miTLS patch is still needed.

The unifier must handle equating two concrete universe
levels (among other things), as we already do for embedded terms
and other constants. Make it so for all lazy terms that have
a "faithful" representation.
Taken from Vale
One can use SMTQuery for that.
@mtzguido mtzguido enabled auto-merge November 14, 2023 18:32
@mtzguido mtzguido merged commit 085657b into FStarLang:master Nov 14, 2023
@mtzguido mtzguido deleted the 3089 branch November 14, 2023 18:42
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

Successfully merging this pull request may close these issues.

None yet

1 participant