Conversation
|
I added an example with polymorphic sequences (based on heap/simple/seq.key) and completed the proof. That should show that the matching logic works |
|
Hmm, the slicing tests fail due to a parser error, seemingly in sliced proof files. @WolframPfeifer do you interact at all with the |
|
I tested some of the runAllProofs tests that fail on the CI. They work on my machine. I don't know what the issue is |
|
All tests pass now. This PR is ready for review. |
0f8b28a to
5f9de0a
Compare
...re/src/main/java/de/uka/ilkd/key/rule/match/vm/instructions/MatchGenericSortInstruction.java
Show resolved
Hide resolved
key.core/src/main/java/de/uka/ilkd/key/rule/inst/GenericSortCondition.java
Outdated
Show resolved
Hide resolved
|
I am trying to use the feature from this PR to implement a polymorphic theory of sets. How can I instantiate the generic sort with a concrete one? I declared sets like this (internally in the rules shipped with KeY, because of Then, I tried to load a problem: The definitions and rules seem to load correctly. However, when trying to load the problem, I get this exception: @Drodt What am I doing wrong? How does instantiation of a polymorphic sort work? |
The problem is that The definitions should be: Right now, we need this verbose syntax for KeY to know that these functions are parametric. It is unclear, however, that what you wrote is an error. Perhaps one really wants to define such functions. |
Since T is a generic type, I would argue that I agree that sEmpty profits from an explicit type argument. [Relieves us from having to do type inference and with subtyping that can also be challenging, esp. if we do not necessarily have a lattice.] I would argue that sSingleton can go without the type argument if the static type of the first argument is meant. |
Do we currently prohibit a function with a generic return sort? If so, I can add a check for the parametric case.
This very primitive type inference is something we can add later on. I would suggest after #3773, which kind of validates the parametric function approach. |
Ah, of course 🤦! Thanks for the explanation (and also the work to implement this nice and long-desired feature)! I implemented a basic theory of polymorphic sets in #3777 now. However, one question remains: At the moment, polymorphic types are unusable in JML, right? Do you have an idea what needs to be done there? |
I think the verbosity is not a problem. It is similar to other tools (e.g. VeriFast), and in my opinion inherent with parametric types. But I agree that some primitive inference would be nice here. However, two following points that came to my mind:
|
Thanks for using it :)
I'm not sure how sort integration into JML works at the moment in general. It should be possible to use the Java generic syntax on DL functions (i.e., |
Not sure if I understand exactly what you mean but generic sorts are fine in taclets, even in parametric sorts and functions. See the examples I added in this PR.
That's exactly what I do in RustyKeY 😄. I did not do this here because (1) it was not part of @mattulbrich's origina design and (2) then we need a new syntax for |
Yes, I have seen these. But these are not user files, right? That is, if you try to load them in the KeY GUI, you get an exception (Sth like "Generic sort not allowed"), because the generic sorts have been removed already. So it is not possible to have a \problem block that refers to a polymorphic sort (only to concrete instances), and likewise with a \rules block in a user file. That is what I mean by adding rules later. |
Related Issue
Based on #3384. Thanks, @mattulbrich @wadoon
Intended Change
Adds polymorphic sorts as proposed by Ulbrich and Weigl and adds polymorphic functions as an obvious extension. This PR also adds matching logic, which has been tested in RustyKeY and JavaKeY.
The syntax is very verbose right now. Generic parameters are written as
<[E1, E2, E3]>. As an example, see polymorphic sequences:In the future, the syntax may be simplified and parameters may be partially inferred.
Additionally, polymorphic datatypes are supported:
The taclet generation for data types is changed accordingly.
To allow for taclets where an input is required (e.g., induction over
List<[int]>), we had to modify the input for terms and instantiations in proof files to allow sort specification, i.e.,x:List<[int]>. Consequently, the sort is also now emitted for all instantiations in all proof files.Plan
Remove SortDependingFunction? (Also simplifies grammar!)(Future work)Make sequences, sets, etc. polymorphic?(Future work)Type of pull request
Ensuring quality
.github/workflows/tests.ymlAdditional information and contact(s)
The contributions within this pull request are licensed under GPLv2 (only) for inclusion in KeY.