44package de .uka .ilkd .key .scripts ;
55
66
7+ import de .uka .ilkd .key .logic .ChoiceExpr ;
8+ import de .uka .ilkd .key .logic .SequentFormula ;
79import 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 ;
1117import 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 ;
1321import 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
1932public 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