-
Notifications
You must be signed in to change notification settings - Fork 63
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
Translation of Cryptol parallel comprehensions introduces unnecessary coercions #1507
Comments
So basically, what we need is a variant of
instead of
and then make the translator use (Actually, I'm really not a fan of how Cryptol allows comprehension branches to have different lengths, because in my experience the implicit truncation can lead to bugs. I'd prefer for Cryptol to require all comprehension branches to have the same length, which would simplify both Cryptol's typing rules and the SAW translation.) |
Indeed, that's basically what I had in mind. As to restricting comprehensions to be the same length... I don't hate that idea, but I think it would break a lot of idiomatic Cryptol; lots of recursive stream definitions would need to add a |
Is there a particular reason we made the SAWCore zip a primitive?
It seems like we could just have easily defined it as:
|
when we can easily tell that the length of the branches are the same. This avoids unneccessary coercions. Fixes #1507
when we can easily tell that the length of the branches are the same. This avoids unneccessary coercions. Fixes #1507
I just dived into the git history, and I found that |
Do you think we should leave it as-is, or use the proposed defined version above? |
Consider this definition from the Cryptol prelude
When translated to SAWCore we get:
Notice we are coercing from
seq (tcMin n n) (a*b)
toseq n (a*b)
. This arises from the semantics of Cryptol's parallel comprehensions, where branches may be different lengths. However, it the fairly common case where they are actually the same length, this coercion is unnecessary and makes reasoning about the resulting term much harder (e.g., after extraction to Coq).It would be nice if we could notice this situation and use a more direct SAWCore zipping primitive that unifies the input and output types, and avoid the need for coercions.
The text was updated successfully, but these errors were encountered: