-
Notifications
You must be signed in to change notification settings - Fork 30
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
[CN] Meta-issue: syntax overhaul #304
Comments
One more:
- Optional explicit type declarations on take and let (and anywhere else
they make sense), to help with documentation and debugging.
…On Wed, Jun 5, 2024 at 8:01 AM Dhruv Makwana ***@***.***> wrote:
A few existing issues have touched upon the current syntax. The solutions
for those bring function and `predicate a lot closer together.
1. Remove if-restriction (#266
<https://urldefense.com/v3/__https://github.com/rems-project/cerberus/issues/266__;!!IBzWLUs!WrxvcyM3niw6bzUcqm6-Ie4GOUQSynOR3z6wU7H4tQ3kLFlYzo0A3OgxEQikoeBN1lwPcMBP3UKDw47Z9u4Oo2pOtPdI$>
)
2. Remove predicate pointer first restriction (#303
<https://urldefense.com/v3/__https://github.com/rems-project/cerberus/issues/303__;!!IBzWLUs!WrxvcyM3niw6bzUcqm6-Ie4GOUQSynOR3z6wU7H4tQ3kLFlYzo0A3OgxEQikoeBN1lwPcMBP3UKDw47Z9u4Oo-UGJ1EW$>
)
3. Unify namespaces for functions and predicates (#288
<https://urldefense.com/v3/__https://github.com/rems-project/cerberus/issues/288__;!!IBzWLUs!WrxvcyM3niw6bzUcqm6-Ie4GOUQSynOR3z6wU7H4tQ3kLFlYzo0A3OgxEQikoeBN1lwPcMBP3UKDw47Z9u4Oo1tr5Hzx$>
)
Though not strictly dependent on the above 3, it may be sensible to wait
until they are finished for the next tasks (which are closer to
nice-to-haves).
4. Add base type heap and disallow that to be used in arguments or in
data types
5a. Add new unified syntax and map to existing backend
5b. Optional but good engineering: refactor backend to match new sytnax
As mentioned in #288
<https://urldefense.com/v3/__https://github.com/rems-project/cerberus/issues/288__;!!IBzWLUs!WrxvcyM3niw6bzUcqm6-Ie4GOUQSynOR3z6wU7H4tQ3kLFlYzo0A3OgxEQikoeBN1lwPcMBP3UKDw47Z9u4Oo1tr5Hzx$>,
at the end of this we could write things like
i32 add_one(i32 x) {
let y = x + 1;
y;
}
heap<i32> intQueueAux(i32 x) {
return (add_one(x));
}
heap<i32> intQueue0(i32 x) {
intQueueAux(0);
}
heap<i32> intQueue(i32 x) {
let y = add_one(x);
let* q = intQueueAux(y);
return y;
}
Pros:
- Concise.
- Generics are familiar to many (and monads familiar to theorists).
- Make polymorphism easier to add and explain later.
- Makes the type of locks easier to add and explain later.
Cons:
- Needs a few restrictions to keep things first-order for now (no
heap<_> values in datatypes or in arguments).
- Not requiring a return (and using return as the monad heap<_> )
could be confusing for C developers.
- Still unsure about let*. Maybe let <id> = *<heap_expr>;? Like in
Idris
<https://urldefense.com/v3/__https://idris2.readthedocs.io/en/latest/tutorial/interfaces.html*notation__;Iw!!IBzWLUs!WrxvcyM3niw6bzUcqm6-Ie4GOUQSynOR3z6wU7H4tQ3kLFlYzo0A3OgxEQikoeBN1lwPcMBP3UKDw47Z9u4Oo2Bt_g88$>
).
i32 add_one(i32 x) {
return x + 1;
}
heap intQueueAux(i32 x) {
return (heap(add_one(x)));
}
heap intQueue(i32 x) {
return intQueueAux(0);
}
heap intQueue(i32 x) {
let y = add_one(x);
let q = *intQueueAux(y);
return heap(q);
}
—
Reply to this email directly, view it on GitHub
<https://urldefense.com/v3/__https://github.com/rems-project/cerberus/issues/304__;!!IBzWLUs!WrxvcyM3niw6bzUcqm6-Ie4GOUQSynOR3z6wU7H4tQ3kLFlYzo0A3OgxEQikoeBN1lwPcMBP3UKDw47Z9u4Oo1dJoef8$>,
or unsubscribe
<https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/ABVQQC2V6YY3QNIU2OANNALZF342HAVCNFSM6AAAAABI2R66LOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGMZTKNZRG42TQMI__;!!IBzWLUs!WrxvcyM3niw6bzUcqm6-Ie4GOUQSynOR3z6wU7H4tQ3kLFlYzo0A3OgxEQikoeBN1lwPcMBP3UKDw47Z9u4OoxPdRZbJ$>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Added, thanks |
Are the type annotations in declaration specs ever not fully determined by the declaration? If not, why have a separate form for the declaration spec at all? Concretely:
The arguments could also be removed. I like concretely bringing them into CN scope in the same block. |
The reason for this aspect of the |
There are enough spec-related tickets (you can see a list of them here) that I've lost track of the broader language design issues we're considering. Here's a rough grouping of the current tickets. Predicates
Taken together, these issues address two broad points:
Syntactic sugar
Local vs global reasoning (and library models)
These issues are related to how specifications are associated with functions, and how/when specs are trusted vs. verified by CN. There are two use cases to keep in mind:
Solver hints
Types
Datatypes |
It's not clear when the parser shifts from CN to C and back. I can write |
&x only works for globals in specifications of C functions. Lemmas have to be “pure” in that they cannot refer to C objects. |
That is a reasonable restriction but doesn't actually stop me. I can define temp variables equal to the term I wanted to put into the lemma arguments and it works. I'll make a full issue but this is the transformation:
What is the restriction really doing for us here besides boilerplate? |
Sorry, I think I misunderstood. If you'd like to be able to write What we can't really support is having a lemma whose statement refers to things like |
A few existing issues have touched upon the current syntax. The solutions for those bring
function
andpredicate
a lot closer together.function
s #483Though not strictly dependent on the above, it may be sensible to wait until they are finished for the next tasks (which are closer to nice-to-haves).
5a. Add new unified syntax and map to existing backend
5b. Optional but good engineering: refactor backend to match new sytnax
As mentioned in #288, at the end of this we could write things like
Pros:
Cons:
return
(and usingreturn
as the monadheap<_>
) could be confusing for C developers.take
. Maybelet*
orlet <id> = *<heap_expr>;
? Like in Idris' !-notation could be nice.The text was updated successfully, but these errors were encountered: