-
Notifications
You must be signed in to change notification settings - Fork 36
Introducing some structure for model method bodies #3571
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
base: main
Are you sure you want to change the base?
Conversation
restricted to ifs and intermediate variables
and spotlessing
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3571 +/- ##
============================================
+ Coverage 39.54% 39.58% +0.03%
- Complexity 17753 17778 +25
============================================
Files 2103 2103
Lines 127774 127810 +36
Branches 21500 21504 +4
============================================
+ Hits 50527 50590 +63
+ Misses 71050 71026 -24
+ Partials 6197 6194 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
My questions would also be:
Maybe we should add a |
Because thus jml model method bodies can remain purely logical expressions and their definition can be directly expanded into the sequent. That is a fundamental asset of model methods as they are implemented in KeY (like related constructs in other verification frameworks). Dealing with loops in particular would make this impossible. This was driven by trying to relax notation while keeping the verification-system power of the type definitions. How does the JavaDL-definition axiom or taclet for model methods look like in jmlparser?
I think actually, it does. In KeY, however, the expansion mechanism for non-model methods, is conservative and uses [] box-semantics to be on the safe side.
I would refrain from putting jml model methods into modalities, It's their power to define functions directly. I would be happy to intrdoduce ghost methods that can use any code. They do not even need to be pure. |
key.core/src/main/java/de/uka/ilkd/key/speclang/njml/Translator.java
Outdated
Show resolved
Hide resolved
8ff2ffe
to
2b160d3
Compare
as otherwise namespaces would complain about double insertion.
08bb0c0
to
92806e4
Compare
The implementation renders the local variables into "let expressions" which are Is it bad that subst makes it to the surface here? Could also be easily avoided by expanding them during translation. ... On the other hand: It renders the user-defined structure into the logic. There are fully automatic (OSS-)taclets in place that expand the substitutions. |
No. Trust the sound rules in KeY. IMHO, it is strange that you do not use updates here instead of substitutions. |
Well observed. The reason behind this that updates operate only on global program variables whereas substitutions operate on logical variables which are not part of a global namespace. It would not be advisable to clutter the program varoable namespace with symbols needed for temporary local value assignment. |
The feature has been mentioned in the keydocs (although they are not very structured) The Boyer Moore example has been adapted to the new syntax capabilities. |
# Conflicts: # key.ui/examples/heap/BoyerMoore/BM(BM__bm((I)).JML normal_behavior operation contract.0.proof
method_declaration: typespec IDENT param_list (method_body|SEMI_TOPLEVEL); | ||
method_body: LBRACE RETURN expression SEMI_TOPLEVEL RBRACE; | ||
method_declaration: typespec IDENT param_list (method_body=mbody_block | SEMI_TOPLEVEL); | ||
mbody_block: LBRACE mbody_var* mbody_statement RBRACE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why am I not allowed to have variable decls inside if-then-else constructs? Flow analysis too hard?
Intended Change
This is a new feature request by users that wanted to use model methods.
The PR introduces method bodies that allow some statements. It is limited to
This is still rather limited but allows you to structure your code already quite a bit.
The restrictions are:
var
(due to a restriction in the lexer/parser)The only thing that needs to be done is then to interpret these structures into a term.
My running example is the following which explains itself:
Plan
Type of pull request
Ensuring quality
Additional information and contact(s)
The contributions within this pull request are licensed under GPLv2 (only) for inclusion in KeY.