44package 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 ;
89import 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 ;
1214import de .uka .ilkd .key .scripts .meta .Option ;
1315
1416import 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
1931public 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