-
Notifications
You must be signed in to change notification settings - Fork 29
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
Use KeYParser.g4 for parsing proof scripts #3021
base: main
Are you sure you want to change the base?
Conversation
* master: (69 commits) [floats] optimising float termination rules [floats] reconducting a proof Move functionality for relevant Java files from NodeInfo to new class ProofJavaSourceCollection fix error in logging formatting strings fix the collection of JUnit tests on jenkins [floats] missing rules for double assignments [floats] re-implementing a Z3FP solver. also show message of the chained cause of the exception in IssueDialog [floats] added missing unary minus repairing cast to integer in JML translation. [floats] repairing float-cast rules [floats] repairing cast to float [floats] nasty method call missing [floats] introducing overloaded operator handler [floats] missing functions in LDT lookup Set the interactive flag for builtin rule applications coming from BuiltInRuleMenuItem correctly allowing [] after parameter names in JML model methods Fix potential stack overflow in ExplorationStepsList allow arrays and general types in JML. (KeYProject#1681) fixes KeYProject#1682 ...
* master: (37 commits) missing NPE check in MasterHandlerTest Fix KeYProject#1696 (wrong hash for heapAtPre) a two-state method needs the invariant also at pre-state (try to fix KeYProject#1689) Fix KeYProject#1690 Fix failing test case Fixed rule "wellFormedStoreObjectEQ" [floats] repairing JML interpretation of equality on floats and doubles. add comment to find AutoSuite fix NPE remove test filter fix, swap argument in assertEquals only recoder uses junit4 translate the remaining Junit4 parts fix merge issues hopefully fixing gradle test filters new category "owntest" for tests with an own gradle task falsely marked as test migrate TestTacletEquality fix gradle settings, remove autosuite try to fix RAP ... # Conflicts: # key/key.core/src/test/java/de/uka/ilkd/key/macros/scripts/TestProofScriptCommand.java # key/key.core/src/test/java/de/uka/ilkd/key/macros/scripts/meta/ValueInjectorTest.java # key/key.core/src/test/java/de/uka/ilkd/key/proof/proverules/ProveRulesTest.java # key/key.core/src/test/java/de/uka/ilkd/key/proof/runallproofs/performance/DataRecordingTestFile.java
* origin/master: (166 commits) Use generic method correctly avoid creating proof obligations in ProofManagementDialog It is unnecessary to create proof obligations in most cases there and creating some proof obligations changes state shared with a large part of KeY (see KeYProject#1715). use base directory for InfFlow tests partly revert 0eca94d to restore tests in automaticInfFlow.txt adding proofs for SMT lemmas. JavaDoc for changed methods + Doubles for timeout jdiv and jmod support in SMT translation via definitions. Checkstyle/SonarQube Avoid reopening popup menu when selection button is pressed Bug fixes from the IdentityHashMap case study Solve missing plugin in shadowJar by adding `mergeServiceFiles()` SonarQube Checkstyle mark JSpinner backgrounds correctly when an error occurs Deactivate SMT button when no proof is loaded Check formatting with Spotless Add JavaDoc Modify problems using solver sockets Minor changes checkstyle ...
* master: (30 commits) Spotless: Don't join manually split lines Fixed two more files with broken comments (KeYProject#1710) manual formatting corrections (not for recoder, tests, and resources) applied spotless rules to .key files applied spotless rules to Java sources define KeY code style, remove options not supported by Eclipse formatter, enable spotless toggles, removed license header from spotless configuration, removed indentation config for .key files (did not really work) Fix Jenkins master script after !559 Temporarily disable reloading sort.proof.gz because of KeYProject#1720 ChoiceExpr: En-/Disabling taclets/goal templates using boolean expression Split `testRunAllProofs` into two tasks Fast fix: Do not run pipeline defined by the Jenkinsfile on "Master" worker Focus first cell in the taclet instantiation dialog on open Close more dialogs on escape press and code deduplication Allow ApplyTacletDialog to be closed by pressing Escape Fix getMainWindow infinite recursion Fix Exception when parsing "<unknown>" URL on Windows Disable exploration tree updates when disabled Remove space from taclet proof save file name Allows to have an expression on the lhs in a set statement. Hence, further logging commands fixed ... # Conflicts: # key/key.core/src/main/java/de/uka/ilkd/key/api/ScriptApi.java # key/key.core/src/main/java/de/uka/ilkd/key/control/KeYEnvironment.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/AllCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/AssertCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/AssumeCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/AutoCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/AxiomCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/CutCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/EngineState.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/HideCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/InstantiateCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/JavascriptCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/LetCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/MacroCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/NoArgumentCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/ProofScriptCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/ProofScriptEngine.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/RewriteCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/RuleCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/SMTCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/SaveInstCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/SaveNewNameCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/SchemaVarCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/SelectCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/SetEchoCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/TryCloseCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/UnhideCommand.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/meta/Converter.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/meta/NoSpecifiedConverterException.java # key/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/meta/ValueInjector.java # key/key.core/src/main/java/de/uka/ilkd/key/nparser/KeyAst.java # key/key.core/src/main/java/de/uka/ilkd/key/proof/io/AbstractProblemLoader.java # key/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlFacade.java # key/key.core/src/test/java/de/uka/ilkd/key/logic/TestLocalSymbols.java # key/key.core/src/test/java/de/uka/ilkd/key/macros/scripts/TestProofScriptCommand.java # key/key.core/src/test/java/de/uka/ilkd/key/proof/proverules/ProveRulesTest.java # key/key.core/src/test/java/de/uka/ilkd/key/proof/runallproofs/ProveTest.java # key/key.core/src/test/java/de/uka/ilkd/key/proof/runallproofs/performance/DataRecordingTestFile.java # key/key.core/src/test/java/de/uka/ilkd/key/proof/runallproofs/proofcollection/TestFile.java # key/key.ui/src/main/java/de/uka/ilkd/key/gui/ProofScriptWorker.java # key/key.ui/src/main/java/de/uka/ilkd/key/gui/WindowUserInterfaceControl.java # key/key.ui/src/main/java/de/uka/ilkd/key/gui/actions/ProofScriptInputAction.java # key/key.ui/src/main/java/de/uka/ilkd/key/ui/ConsoleUserInterfaceControl.java
* master: (160 commits) .git-blame-ignore-revs: ignore formatting commits Update checkstyle configuration to 10.6.0 Move subprojects to top level Keep PositionInfo in ForToWhileTransformation log instead of disabling EditMostRecentFileAction on error Remove KeYDesktop interface, use java.awt.Desktop directly Logview open log file fallback: Browse dir Fixing a few typos in example files reducing the binary filesize by only including the necessary example files Fix typo in comment Checkstyle Immediately resize proof tree font Fix Z3 counterexample generation Recalculate all unique names on every change since the algorithm is incremental and does not change old names. SonarCube Add comments and move main method to tests Improve naming of recent files Keep entry class private, it's not used outside the class corrected the formatting Test for polarity check during replay ...
I agree that the current parser is more a proof-of-concept solution than future-proof. However: With many ideas around proof scripts, which should possibly discuss how this should go now: The script debugger has its ways of communicating to the server, scripts can be in .key files, they were at a point interactively editable, and the plan is to have them in JML code. Do they all go to the same background linear script language or is the base language itself more than a sequence of commands? |
* refs/remotes/origin/main: (1809 commits) Bump the gradle-deps group across 1 directory with 5 updates Also depend on `checker-qual` artifact Bump the github-actions-deps group with 5 updates Minor refactoring to remove duplicate code fixing the broken automode resolve reviewer requests applied formatting style disable automatic formatting of Java code blocks in comments/JavaDoc removed formatter version lock and added new keys (via new styleMerge tool) added small utility to merge xml formatter style files add javadoc add javadoc reformat fix finalize() deprecation fix error in expecting proof script if there is none fix compile errors due to merging forgot ProofScriptEntry fix compile errors Removal of the Triple class Removal of Quadruple.java fix auto merger in github workflow ... # Conflicts: # key.core/src/main/java/de/uka/ilkd/key/control/KeYEnvironment.java # key.core/src/main/java/de/uka/ilkd/key/macros/scripts/AllCommand.java # key.core/src/main/java/de/uka/ilkd/key/macros/scripts/AutoCommand.java # key.core/src/main/java/de/uka/ilkd/key/macros/scripts/EngineState.java # key.core/src/main/java/de/uka/ilkd/key/macros/scripts/HideCommand.java # key.core/src/main/java/de/uka/ilkd/key/macros/scripts/ProofScriptEngine.java # key.core/src/main/java/de/uka/ilkd/key/macros/scripts/SaveInstCommand.java # key.core/src/main/java/de/uka/ilkd/key/macros/scripts/UnhideCommand.java # key.core/src/main/java/de/uka/ilkd/key/macros/scripts/meta/ValueInjector.java # key.core/src/main/java/de/uka/ilkd/key/nparser/KeyAst.java # key.core/src/main/java/de/uka/ilkd/key/nparser/ParsingFacade.java # key.core/src/main/java/de/uka/ilkd/key/proof/init/KeYUserProblemFile.java # key.core/src/main/java/de/uka/ilkd/key/proof/io/AbstractProblemLoader.java # key.core/src/main/java/de/uka/ilkd/key/speclang/PositionedString.java # key.core/src/main/java/de/uka/ilkd/key/speclang/njml/JmlFacade.java # key.core/src/test/java/de/uka/ilkd/key/logic/TestLocalSymbols.java # key.core/src/test/java/de/uka/ilkd/key/macros/scripts/TestProofScriptCommand.java # key.core/src/test/java/de/uka/ilkd/key/proof/proverules/ProveRulesTest.java # key.core/src/test/java/de/uka/ilkd/key/proof/runallproofs/ProveTest.java # key.core/src/test/java/de/uka/ilkd/key/proof/runallproofs/performance/DataRecordingTestFile.java # key.core/src/test/java/de/uka/ilkd/key/proof/runallproofs/proofcollection/TestFile.java # key.core/tacletProofs/seqPerm2/Taclet_schiffl_lemma_2.proof # key.ui/src/main/java/de/uka/ilkd/key/gui/ProofScriptWorker.java # key.ui/src/main/java/de/uka/ilkd/key/gui/WindowUserInterfaceControl.java # key.ui/src/main/java/de/uka/ilkd/key/gui/actions/ProofScriptInputAction.java # key.ui/src/main/java/de/uka/ilkd/key/ui/ConsoleUserInterfaceControl.java
* adds script block commands arguments
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.
First round of review. Some feedback. Could not review the whole thing.
| string_literal | ||
| BACKTICK (term | seq) BACKTICK | ||
| term | ||
| seq; |
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.
I really do not like the ambiguity.
Can we make this IDENTIFIER without ticks and any composed term/seq in ticks?
I would prefer single ticks compared to back ticks. I do not think we need single-character parameters (and if: Use strings ...)
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.
I really do not like the ambiguity.
Not my language.
Can we make this IDENTIFIER without ticks and any composed term/seq in ticks?
What do you mean by this IDENTIFIER?
In macro tryclose
, the tryclose
is still evaluated as a string and not sent to the expression evaluation. This adds unnecessary complexity.
I would prefer single ticks compared to back ticks
- single quotes
'
are often used currently as string quotes in proof scripts - backticks are only necessary to avoid ambiguous situations:
command p=2
could be a formula or the parameterp
to be 2.
(and if: Use strings ...)
No. The advantage of separation is that the parser is eager to give feedback on syntactical correctness. Otherwise, these errors appears only on evaluation of commands.
key.core/src/main/java/de/uka/ilkd/key/control/KeYEnvironment.java
Outdated
Show resolved
Hide resolved
key.core/src/main/java/de/uka/ilkd/key/macros/scripts/AbstractCommand.java
Outdated
Show resolved
Hide resolved
key.core/src/main/java/de/uka/ilkd/key/macros/scripts/ExprEvaluator.java
Outdated
Show resolved
Hide resolved
key.core/src/main/java/de/uka/ilkd/key/macros/scripts/LetCommand.java
Outdated
Show resolved
Hide resolved
key.core/src/main/java/de/uka/ilkd/key/macros/scripts/LetCommand.java
Outdated
Show resolved
Hide resolved
Reply to me-from-the-past:
After implementing a/the script language for JML: This was compiled down to a linear script. So it seems that a list of individual proof commands looks like the right level of abstraction. |
This PR gives the current state a proper syntax in alignment with the KeY grammar. So the list of proof commands are still preserved. Giving the commands the possibility to receive a block of sub-commands arises from your We need a quoting symbol for terms for the ambiguities, |
This PR removes the hand-written parser for proof scripts and uses a few rules in
KeYParser.g4
instead.Since the start of proof scripts, the KeYParser has changed and became an ANTLR4 grammar. This allows us to easily write a grammar for our proof scripts. (Or just copy the few rules from Sarah and mine proof script parser). This eliminates the handwritten proof script parser with the following benefits:
Proof Scripts are a first-class citizen in KeY files. You do not need to put your proof script into a string literal:
Please note an ambiguity in the grammar:
rule b ==> c
could either be interpreted as a command with one or two arguments:b ==>
and a termc
, orb ==> c
.b
and a semi-sequent==> c
.Use quotes or better backticks to clarify these situations.
Also, avoid using hyphens in identifiers. The grammar should follow the KeY grammar as best as possible. Backwards-compatiblity is tried to preserve.
Earlier and better syntax errors. (during reading the KeY file)
Better positioning information, as these are tucked to gather on the
ParseContext
s.Proper data structure: no triple of strings is pushed through KeY.
You do not need to put your arguments in quotes. Literals, terms and sequents are parsed.
Tried to achieve backward-compatibility. If the proof script is given as a string, the parsing is delayed until the execution. The same is valid for arguments.
Note there is a difference between
f(x)
and "f(x)". The first one is parsed directly as a term and can only passed to term or string arguments. The second one is parsed as a string. By meta-information on commands, the string is lazily converted to a term if necessary.The term
f(x)
might be parsed early with the input file, but the expression is evaluated (translated from parse tree toTerm
) on command-execution time, hence, the use of goal-local variables should be possible.Additions to Proof Scripts
The interface of commands and the syntax received an extension to support commands like
AllCommand
in a uniform way.AllCommand
(onAll hide \
f(x)`) executes the sub-command specified by the arguments on all goals. In SaG scripts we used
foreach { ... }` to achieve this behavior.The extension adapts the command syntax to take a list of sub-commands in curly brackets.
The new syntax for
onAll
is alsoonAll { hide \
f(x)`; }. Commands receive the code block using the key
#blockinside the map as a parse tree, that can be sent back to the
ScriptEngineusing
#execute(state, statements)`. The new syntax allows to build new commands liketry {<sub>}
-- executes<sub>
ignoring errorsrepeat { <sub> }
-- executes<sub>
as long as there are changes on the sequent.matching <term> { <sub> }
-- execute on all goals where<term>
is prescense.