Skip to content

Commit 60e56c8

Browse files
mattulbrichwadoon
authored andcommitted
added psg4-cleaned-continued
1 parent 62754c5 commit 60e56c8

File tree

17 files changed

+337
-171
lines changed

17 files changed

+337
-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: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,72 @@
44
package de.uka.ilkd.key.scripts;
55

66

7-
import de.uka.ilkd.key.logic.Term;
7+
import de.uka.ilkd.key.logic.*;
8+
import de.uka.ilkd.key.logic.op.FormulaSV;
89
import de.uka.ilkd.key.logic.op.SchemaVariable;
9-
import de.uka.ilkd.key.rule.NoPosTacletApp;
10-
import de.uka.ilkd.key.rule.Taclet;
11-
import de.uka.ilkd.key.rule.TacletApp;
10+
import de.uka.ilkd.key.logic.op.SchemaVariableFactory;
11+
import de.uka.ilkd.key.rule.*;
12+
import de.uka.ilkd.key.rule.tacletbuilder.TacletGoalTemplate;
13+
import de.uka.ilkd.key.scripts.meta.Documentation;
1214
import de.uka.ilkd.key.scripts.meta.Option;
1315

1416
import org.key_project.logic.Name;
17+
import org.key_project.util.collection.DefaultImmutableMap;
18+
import org.key_project.util.collection.ImmutableList;
19+
import org.key_project.util.collection.ImmutableSet;
20+
21+
import org.jspecify.annotations.NonNull;
22+
import org.jspecify.annotations.NullMarked;
23+
import org.jspecify.annotations.Nullable;
1524

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

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

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

3168
@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""";
69+
public String getName() {
70+
return "assume";
3871
}
3972

40-
@Override
4173
public void execute(ScriptCommandAst arguments) throws ScriptException, InterruptedException {
4274
var parameter = state().getValueInjector()
4375
.inject(this, new FormulaParameter(), arguments);
@@ -52,8 +84,12 @@ public void execute(ScriptCommandAst arguments) throws ScriptException, Interrup
5284
state().getFirstOpenAutomaticGoal().apply(app);
5385
}
5486

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

0 commit comments

Comments
 (0)