Skip to content

Commit 07232c0

Browse files
mattulbrichwadoon
authored andcommitted
added psg4-cleaned-continued
1 parent 0210666 commit 07232c0

File tree

17 files changed

+339
-171
lines changed

17 files changed

+339
-171
lines changed

key.core/src/main/antlr4/KeYLexer.g4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ MODAILITYGENERIC:
480480
-> more, pushMode(modGeneric);
481481
*/
482482
//BACKSLASH: '\\';
483+
483484
ERROR_UKNOWN_ESCAPE: '\\' IDENT;
484485
ERROR_CHAR: .;
485486

key.core/src/main/java/de/uka/ilkd/key/scripts/AbstractCommand.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,6 @@ public List<ProofScriptArgument> getArguments() {
6060
}
6161

6262

63-
public @Nullable Object evaluateArguments(EngineState state, ScriptCommandAst arguments)
64-
throws Exception {
65-
if (parameterClazz != null) {
66-
Object obj = parameterClazz.getDeclaredConstructor().newInstance();
67-
return state.getValueInjector().inject(this, obj, arguments);
68-
}
69-
return null;
70-
}
71-
7263
@Override
7364
public void execute(AbstractUserInterfaceControl uiControl, ScriptCommandAst args,
7465
EngineState stateMap)
@@ -98,6 +89,10 @@ public void execute(ScriptCommandAst args) throws ScriptException, InterruptedEx
9889

9990
@Override
10091
public String getDocumentation() {
101-
return "";
92+
if (documentation == null) {
93+
documentation = ArgumentsLifter.extractDocumentation(parameterClazz);
94+
}
95+
return documentation;
10296
}
97+
10398
}

key.core/src/main/java/de/uka/ilkd/key/scripts/AssertCommand.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
package de.uka.ilkd.key.scripts;
55

66

7+
import de.uka.ilkd.key.scripts.meta.Documentation;
78
import de.uka.ilkd.key.scripts.meta.Option;
89

910
/**
1011
* Halts the script if some condition is not met.
12+
* <p>
13+
* See exported documentation at {@link Parameters} at the end of this file.
1114
*
1215
* @author lanzinger
1316
*/
@@ -30,7 +33,7 @@ public void execute(ScriptCommandAst arguments) throws ScriptException, Interrup
3033

3134
if (state().getProof().openEnabledGoals().size() != args.goals) {
3235
throw new ScriptException("Assertion failed: number of open goals is "
33-
+ state.getProof().openGoals().size() + ", but should be " + args.goals);
36+
+ state().getProof().openGoals().size() + ", but should be " + args.goals);
3437
}
3538
}
3639

@@ -42,6 +45,15 @@ public String getName() {
4245
/**
4346
* The Assigned parameters (currently only the passed goals).
4447
*/
48+
@Documentation("""
49+
The assert command checks if the number of open and enabled goals is equal to the given number.
50+
If not, the script is halted with an error message.
51+
52+
Deprecated: This command is deprecated and should not be used in new scripts.
53+
The name of this command is likely to change since "assert" will
54+
be used for a more general purpose. You may find that this is called
55+
"failUnless".
56+
""")
4557
public static class Parameters {
4658
/**
4759
* The number of open and enabled goals.

key.core/src/main/java/de/uka/ilkd/key/scripts/AssumeCommand.java

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,73 @@
44
package de.uka.ilkd.key.scripts;
55

66

7+
import de.uka.ilkd.key.logic.ChoiceExpr;
8+
import de.uka.ilkd.key.logic.SequentFormula;
79
import de.uka.ilkd.key.logic.Term;
8-
import de.uka.ilkd.key.rule.NoPosTacletApp;
9-
import de.uka.ilkd.key.rule.Taclet;
10-
import de.uka.ilkd.key.rule.TacletApp;
10+
import de.uka.ilkd.key.logic.TermFactory;
11+
import de.uka.ilkd.key.logic.op.FormulaSV;
12+
import de.uka.ilkd.key.logic.op.SchemaVariable;
13+
import de.uka.ilkd.key.logic.op.SchemaVariableFactory;
14+
import de.uka.ilkd.key.rule.*;
15+
import de.uka.ilkd.key.rule.tacletbuilder.TacletGoalTemplate;
16+
import de.uka.ilkd.key.scripts.meta.Documentation;
1117
import de.uka.ilkd.key.scripts.meta.Option;
12-
18+
import org.jspecify.annotations.NonNull;
19+
import org.jspecify.annotations.NullMarked;
20+
import org.jspecify.annotations.Nullable;
1321
import org.key_project.logic.Name;
14-
import org.key_project.logic.op.sv.SchemaVariable;
22+
import org.key_project.util.collection.DefaultImmutableMap;
23+
import org.key_project.util.collection.ImmutableList;
24+
import org.key_project.util.collection.ImmutableSet;
1525

1626
/**
17-
* The assume command takes one argument: * a formula to which the command is applied
27+
* The assume statement for proof debugging purposes
28+
* <p>
29+
* See exported documentation at @{@link FormulaParameter} at the end of this file.
1830
*/
31+
@NullMarked
1932
public class AssumeCommand extends AbstractCommand {
2033
private static final Name TACLET_NAME = new Name("UNSOUND_ASSUME");
2134

35+
/**
36+
* The taclet that is used to implement the assume command.
37+
* <p>
38+
* The taclet UNSOUND_ASSUME { \add( b ==> ) } is obviously unsound, but it is used for
39+
* debugging
40+
* purposes. It is constructed programmatically here, because it should not show up in the
41+
* sources
42+
* of the key repository.
43+
* <p>
44+
* (Earlier versions had the unsound axion taclet amongst the axioms in KeY and special-cased
45+
* around it.)
46+
*/
47+
private static @Nullable Taclet assumeTaclet;
48+
2249
public AssumeCommand() {
2350
super(FormulaParameter.class);
2451
}
2552

26-
@Override
27-
public String getName() {
28-
return "assume";
53+
private static @NonNull Taclet createAssumeTaclet() {
54+
if (assumeTaclet == null) {
55+
TacletApplPart applPart = new TacletApplPart(Sequent.EMPTY_SEQUENT, ImmutableList.of(),
56+
ImmutableList.of(), ImmutableList.of(), ImmutableList.of());
57+
FormulaSV sv = SchemaVariableFactory.createFormulaSV(new Name("b"));
58+
Term b = new TermFactory().createTerm(sv);
59+
TacletGoalTemplate goal = new TacletGoalTemplate(
60+
Sequent.createAnteSequent(new Semisequent(ImmutableList.of(new SequentFormula(b)))),
61+
ImmutableList.of());
62+
assumeTaclet = new NoFindTaclet(TACLET_NAME, applPart, ImmutableList.of(goal),
63+
ImmutableList.of(), new TacletAttributes(),
64+
DefaultImmutableMap.nilMap(), ChoiceExpr.TRUE, ImmutableSet.empty());
65+
}
66+
return assumeTaclet;
2967
}
3068

3169
@Override
32-
public String getDocumentation() {
33-
return """
34-
The assume command is an unsound taclet rule and takes one argument:
35-
36-
The command adds the formula passed as argument to the antecedent
37-
a formula #2 to which the command is applied""";
70+
public String getName() {
71+
return "assume";
3872
}
3973

40-
@Override
4174
public void execute(ScriptCommandAst arguments) throws ScriptException, InterruptedException {
4275
var parameter = state().getValueInjector()
4376
.inject(this, new FormulaParameter(), arguments);
@@ -52,8 +85,12 @@ public void execute(ScriptCommandAst arguments) throws ScriptException, Interrup
5285
state().getFirstOpenAutomaticGoal().apply(app);
5386
}
5487

88+
@Documentation("""
89+
The assume command is an unsound debug command. It takes one argument, a formula,
90+
that is added to the antecedent of the current goal. The command is implemented
91+
using a local unsound taclet, UNSOUND_ASSUME.""")
5592
public static class FormulaParameter {
56-
@Option("#2")
93+
@Option(value = "#2", help = "The formula to be assumed.")
5794
public Term formula;
5895
}
5996
}

0 commit comments

Comments
 (0)