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

Changes in support of an F* fix removing eta equivalence #442

Merged
merged 8 commits into from
May 14, 2021

Conversation

nikswamy
Copy link
Contributor

This PR is in anticipation of a fix for an unsoundness landing in F* master soon. @aseemr and I have been working on it.

F* no longer supports eta equivalence, since it is incompatible with functional extensionality and subtyping.
On the plus side, F* has become more extensional: functional extensionality is actually provable now, rather than being an axiom.

This means however, that proofs that were relying on eta equivalence need to be revised. The main change in this PR is to a proof in LoopCombinators that was relying on eta and propositional extensionality in a rather tricky way. The code comment there has an explanation.

I expect the change to F* to land later today or tomorrow. If you approve, I can push the merge button at the right time to synchronize with the F* change.

Thanks!

Copy link
Contributor

@polubelova polubelova left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Contributor

@msprotz msprotz left a comment

Choose a reason for hiding this comment

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

Thanks for this very technical proof...

A couple questions:

  • @aseemr you changed the precondition of C.Loops.while ... is this related? does this mean that preconditions should always be eta-expanded from here on? any guidelines we can communicate to HACL* developers would be helpful
  • a lot of the proof steps are done "by tactic"... is this cosmetic, a personal preference, or is there some deep reason for these proofs to be performed with e.g. l_to_r?

Thanks!

Jonathan

@msprotz
Copy link
Contributor

msprotz commented May 13, 2021

FYI this build failed because of:

[STDERR]/home/everest/hacl-star/lib/Lib.LoopCombinators.fst(102,4-102,10): (Error 228) user tactic failed: `t_trefl: cannot unify (i: a{p i}) and (i: a{q i})` (see also /home/everest/hacl-star/lib/Lib.LoopCombinators.fst(103,45-103,54))
[STDERR]1 error was reported (see above)
[STDERR]make[1]: *** [Makefile:405: obj/Lib.LoopCombinators.fst.checked] Error 1

but I assume this will start working once the F* change lands?

@aseemr
Copy link
Contributor

aseemr commented May 13, 2021

Hi Jonathan, yes that eta expansion is related. The way the precondition is written in C.Loops is fun h -> inv h and here it was written h. To prove these two equal, we earlier had eta equality but not anymore. So I had to expand it here too. I would say no special guidelines as such ... most of the times the preconditions are more than simple inv.

The failure is because the proof requires some changes that Nik did in F* nik_remove_eta. So we discussed that we will first merge F*, get a green here, and then merge it.

@msprotz
Copy link
Contributor

msprotz commented May 13, 2021

Thanks... so if the function requires test: ... Stack (fun h -> inv h) and you pass it an argument of type .. -> Stack inv, it's now a typing error, correct?

Will it always be a typing error from here on, or just in certain cases? (If it's the former, it's a surprising enough change that I should send a heads-up to other HACL folks who may not be following such F* changes closely.)

@nikswamy
Copy link
Contributor Author

That particular proof is quite technical. It does require a tactic to rewrite with propositional extensionality, then refinement-type equality, at depth. SMT-based proofs cannot do that. This kind of thing shouldn't come up very often.

@aseemr
Copy link
Contributor

aseemr commented May 13, 2021

It also has to do with the $ on the argument of C.Loops.while ... if that $ was not there subtyping would kick in and this would work. But with $, we try to prove equal which is not possible now in the absence of eta.

@msprotz
Copy link
Contributor

msprotz commented May 13, 2021

Ah I see. Barely anyone uses $ (@tahina-pro was the one who introduced the $ here if I recall correctly) so I don't expect this will be a problem for day-to-day uses of HACL*. Thanks for the clarification!

@tahina-pro
Copy link
Contributor

tahina-pro commented May 13, 2021

I was using $ to empirically help in second-order unification of the pre and postconditions of the while loop test, but I certainly do not claim any expertise on that.

@nikswamy
Copy link
Contributor Author

Weird, I'm seeing failures now in Hacl.Impl.Exponentiation that I wasn't seeing before. Will take a look later this evening.

@polubelova polubelova merged commit 37df90e into master May 14, 2021

//////////////////////////////////////////////////////////
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Marina! I would never have figured this out myself. Much appreciated!

@karthikbhargavan karthikbhargavan deleted the fstar_remove_eta branch September 6, 2022 14:45
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.

5 participants