Skip to content
Snippets Groups Projects
Commit 24839b33 authored by dgelessus's avatar dgelessus
Browse files

Merge implementations of :constants, :init and :exec

parent 0c2896e4
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:help :browse :help :browse
``` ```
%% Output %% Output
``` ```
:browse :browse
``` ```
Show information about the current state. Show information about the current state.
The output shows the names of all sets, constants, and variables defined by the current machine, as well as a list of enabled operations (and possible parameter values) in the current state. The output shows the names of all sets, constants, and variables defined by the current machine, as well as a list of enabled operations (and possible parameter values) in the current state.
:browse :browse
Show information about the current state. Show information about the current state.
The output shows the names of all sets, constants, and variables defined by the current machine, as well as a list of enabled operations (and possible parameter values) in the current state. The output shows the names of all sets, constants, and variables defined by the current machine, as well as a list of enabled operations (and possible parameter values) in the current state.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:help :exec :help :exec
``` ```
%% Output %% Output
``` ```
:exec OPERATION [PREDICATE] :exec OPERATION [PREDICATE]
``` ```
Execute an operation. Execute an operation.
The predicate is used to select the operation's parameter values. The parameters can be fully specified explicitly (e. g. `:exec op param1 = 123 & param2 = {1, 2}`), or they can be partially constrained (e. g. `:exec op param1 > 100 & card(param2) >= 2`) to let ProB find a valid combination of parameters. If there are multiple valid combinations of parameters that satisfy the predicate, it is undefined which one is selected by ProB. The predicate is used to select the operation's parameter values. The parameters can be fully specified explicitly (e. g. `:exec op param1 = 123 & param2 = {1, 2}`), or they can be partially constrained (e. g. `:exec op param1 > 100 & card(param2) >= 2`) to let ProB find a valid combination of parameters. If there are multiple valid combinations of parameters that satisfy the predicate, it is undefined which one is selected by ProB.
If no predicate is specified, the parameters are not constrained, and ProB will select an arbitrary valid combination of parameters. If no predicate is specified, the parameters are not constrained, and ProB will select an arbitrary valid combination of parameters.
:exec OPERATION [PREDICATE] :exec OPERATION [PREDICATE]
Execute an operation. Execute an operation.
The predicate is used to select the operation's parameter values. The parameters can be fully specified explicitly (e. g. `:exec op param1 = 123 & param2 = {1, 2}`), or they can be partially constrained (e. g. `:exec op param1 > 100 & card(param2) >= 2`) to let ProB find a valid combination of parameters. If there are multiple valid combinations of parameters that satisfy the predicate, it is undefined which one is selected by ProB. The predicate is used to select the operation's parameter values. The parameters can be fully specified explicitly (e. g. `:exec op param1 = 123 & param2 = {1, 2}`), or they can be partially constrained (e. g. `:exec op param1 > 100 & card(param2) >= 2`) to let ProB find a valid combination of parameters. If there are multiple valid combinations of parameters that satisfy the predicate, it is undefined which one is selected by ProB.
If no predicate is specified, the parameters are not constrained, and ProB will select an arbitrary valid combination of parameters. If no predicate is specified, the parameters are not constrained, and ProB will select an arbitrary valid combination of parameters.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:help :constants :help :constants
``` ```
%% Output %% Output
``` ```
:constants [PREDICATE] :constants [PREDICATE]
``` ```
Set up the current machine's constants. Set up the current machine's constants.
This is a shorthand for `:exec SETUP_CONSTANTS [PREDICATE]`. This is a shorthand for `:exec SETUP_CONSTANTS [PREDICATE]`.
:constants [PREDICATE] :constants [PREDICATE]
Set up the current machine's constants. Set up the current machine's constants.
This is a shorthand for `:exec SETUP_CONSTANTS [PREDICATE]`. This is a shorthand for `:exec SETUP_CONSTANTS [PREDICATE]`.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:help :init :help :init
``` ```
%% Output %% Output
``` ```
:init [PREDICATE] :init [PREDICATE]
``` ```
Initialise the current machine with the specified predicate Initialise the current machine with the specified predicate
This is a shorthand for `:exec INITIALISATION [PREDICATE]`. This is a shorthand for `:exec INITIALISATION [PREDICATE]`.
:init [PREDICATE] :init [PREDICATE]
Initialise the current machine with the specified predicate Initialise the current machine with the specified predicate
This is a shorthand for `:exec INITIALISATION [PREDICATE]`. This is a shorthand for `:exec INITIALISATION [PREDICATE]`.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:browse :browse
``` ```
%% Output %% Output
Machine: repl Machine: repl
Sets: (none) Sets: (none)
Constants: (none) Constants: (none)
Variables: (none) Variables: (none)
Operations: Operations:
INITIALISATION() INITIALISATION()
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
::load ::load
MACHINE Counter MACHINE Counter
CONSTANTS min_value, max_value CONSTANTS min_value, max_value
PROPERTIES min_value : MININT..0 & max_value : 0..MAXINT & min_value <= max_value PROPERTIES min_value : MININT..0 & max_value : 0..MAXINT & min_value <= max_value
VARIABLES value VARIABLES value
INVARIANT value : min_value..max_value INVARIANT value : min_value..max_value
INITIALISATION value :: min_value..max_value INITIALISATION value :: min_value..max_value
OPERATIONS OPERATIONS
add(diff) = SELECT add(diff) = SELECT
value+diff : min_value..max_value value+diff : min_value..max_value
THEN THEN
value := value+diff value := value+diff
END END
END END
``` ```
%% Output %% Output
Loaded machine: Counter Loaded machine: Counter
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:browse :browse
``` ```
%% Output %% Output
Machine: Counter Machine: Counter
Sets: (none) Sets: (none)
Constants: min_value, max_value Constants: min_value, max_value
Variables: value Variables: value
Operations: Operations:
SETUP_CONSTANTS() SETUP_CONSTANTS()
SETUP_CONSTANTS() SETUP_CONSTANTS()
SETUP_CONSTANTS() SETUP_CONSTANTS()
SETUP_CONSTANTS() SETUP_CONSTANTS()
More operations may be available (MAX_OPERATIONS/MAX_INITIALISATIONS reached) More operations may be available (MAX_OPERATIONS/MAX_INITIALISATIONS reached)
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
min_value..max_value min_value..max_value
``` ```
%% Output %% Output
:eval: NOT-INITIALISED :eval: NOT-INITIALISED
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
value value
``` ```
%% Output %% Output
:eval: NOT-INITIALISED :eval: NOT-INITIALISED
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:constants min_value=5 & max_value=-5 :constants min_value=5 & max_value=-5
``` ```
%% Output %% Output
java.lang.IllegalArgumentException: Executing operation $setup_constants with predicate min_value=5 & max_value=-5 produced errors: Could not execute operation SETUP_CONSTANTS in state root with additional predicate java.lang.IllegalArgumentException: Executing operation $setup_constants with predicate min_value=5 & max_value=-5 produced errors: Could not execute operation SETUP_CONSTANTS in state root with additional predicate
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:constants min_value=-1 & max_value=2 :constants min_value=-1 & max_value=2
``` ```
%% Output %% Output
Machine constants set up using operation 2: $setup_constants() Executed operation: $setup_constants()
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:browse :browse
``` ```
%% Output %% Output
Machine: Counter Machine: Counter
Sets: (none) Sets: (none)
Constants: min_value, max_value Constants: min_value, max_value
Variables: value Variables: value
Operations: Operations:
INITIALISATION() INITIALISATION()
INITIALISATION() INITIALISATION()
INITIALISATION() INITIALISATION()
INITIALISATION() INITIALISATION()
More operations may be available (MAX_OPERATIONS/MAX_INITIALISATIONS reached) More operations may be available (MAX_OPERATIONS/MAX_INITIALISATIONS reached)
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
min_value..max_value min_value..max_value
``` ```
%% Output %% Output
$\{-1,0,1,2\}$ $\{-1,0,1,2\}$
{−1,0,1,2} {−1,0,1,2}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
value value
``` ```
%% Output %% Output
:eval: NOT-INITIALISED :eval: NOT-INITIALISED
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:init value=-100 :init value=-100
``` ```
%% Output %% Output
Error from ProB: ProB reported Errors Error from ProB: ProB reported Errors
Error: INITIALISATION FAILS (/Users/Shared/Uni/SHK/ProB2/prob2-jupyter-kernel/notebooks/tests/(machine from Jupyter cell).mch:6:15 to 6:44) Error: INITIALISATION FAILS (/Users/Shared/Uni/SHK/ProB2/prob2-jupyter-kernel/notebooks/tests/(machine from Jupyter cell).mch:6:15 to 6:44)
// Source code not known // Source code not known
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:init value=2 :init value=2
``` ```
%% Output %% Output
Machine initialised using operation 7: $initialise_machine() Executed operation: $initialise_machine()
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:browse :browse
``` ```
%% Output %% Output
Machine: Counter Machine: Counter
Sets: (none) Sets: (none)
Constants: min_value, max_value Constants: min_value, max_value
Variables: value Variables: value
Operations: Operations:
add(-3) add(-3)
add(-2) add(-2)
add(-1) add(-1)
add(0) add(0)
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
value value
``` ```
%% Output %% Output
$2$ $2$
2 2
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:exec add diff=-1 :exec add diff=-1
``` ```
%% Output %% Output
Executed operation: add(-1) Executed operation: add(-1)
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:browse :browse
``` ```
%% Output %% Output
Machine: Counter Machine: Counter
Sets: (none) Sets: (none)
Constants: min_value, max_value Constants: min_value, max_value
Variables: value Variables: value
Operations: Operations:
add(-2) add(-2)
add(-1) add(-1)
add(0) add(0)
add(1) add(1)
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
value value
``` ```
%% Output %% Output
$1$ $1$
1 1
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:stats :stats
``` ```
%% Output %% Output
**Explored States:** 4/9 **Explored States:** 4/9
**Transitions:** 16 **Transitions:** 16
Explored States: 4/9 Explored States: 4/9
Transitions: 16 Transitions: 16
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Useful error messages are shown when an operation cannot be executed. Useful error messages are shown when an operation cannot be executed.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:constants :constants
``` ```
%% Output %% Output
java.lang.IllegalArgumentException: Executing operation $setup_constants with predicate 1=1 produced errors: Machine is already initialised, cannot execute SETUP_CONSTANTS java.lang.IllegalArgumentException: Executing operation $setup_constants with predicate 1=1 produced errors: Machine is already initialised, cannot execute SETUP_CONSTANTS
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:init :init
``` ```
%% Output %% Output
java.lang.IllegalArgumentException: Executing operation $initialise_machine with predicate 1=1 produced errors: Machine is already initialised, cannot execute INITIALISATION java.lang.IllegalArgumentException: Executing operation $initialise_machine with predicate 1=1 produced errors: Machine is already initialised, cannot execute INITIALISATION
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:exec nope :exec nope
``` ```
%% Output %% Output
java.lang.IllegalArgumentException: Executing operation nope with predicate 1=1 produced errors: Unknown Operation nope java.lang.IllegalArgumentException: Executing operation nope with predicate 1=1 produced errors: Unknown Operation nope
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:exec add 1=0 :exec add 1=0
``` ```
%% Output %% Output
java.lang.IllegalArgumentException: Executing operation add with predicate 1=0 produced errors: Could not execute operation add in state 6 with additional predicate (but a transition for operation exists) java.lang.IllegalArgumentException: Executing operation add with predicate 1=0 produced errors: Could not execute operation add in state 6 with additional predicate (but a transition for operation exists)
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
::load ::load
MACHINE NoConstants MACHINE NoConstants
VARIABLES z VARIABLES z
INVARIANT z : MININT..MAXINT INVARIANT z : MININT..MAXINT
INITIALISATION z :: {0, 1} INITIALISATION z :: {0, 1}
END END
``` ```
%% Output %% Output
Loaded machine: NoConstants Loaded machine: NoConstants
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:constants :constants
``` ```
%% Output %% Output
java.lang.IllegalArgumentException: Executing operation $setup_constants with predicate 1=1 produced errors: Could not execute operation SETUP_CONSTANTS in state root java.lang.IllegalArgumentException: Executing operation $setup_constants with predicate 1=1 produced errors: Could not execute operation SETUP_CONSTANTS in state root
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:init z = -1 :init z = -1
``` ```
%% Output %% Output
Error from ProB: ProB reported Errors Error from ProB: ProB reported Errors
Error: INITIALISATION FAILS (/Users/Shared/Uni/SHK/ProB2/prob2-jupyter-kernel/notebooks/tests/(machine from Jupyter cell).mch:4:15 to 4:26) Error: INITIALISATION FAILS (/Users/Shared/Uni/SHK/ProB2/prob2-jupyter-kernel/notebooks/tests/(machine from Jupyter cell).mch:4:15 to 4:26)
// Source code not known // Source code not known
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
`SETUP_CONSTANTS` and `INITIALISATION` can be used as operation names. `SETUP_CONSTANTS` and `INITIALISATION` can be used as operation names.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
::load ::load
MACHINE Foo MACHINE Foo
CONSTANTS x CONSTANTS x
PROPERTIES x : MININT..MAXINT PROPERTIES x : MININT..MAXINT
VARIABLES y VARIABLES y
INVARIANT y : MININT..MAXINT INVARIANT y : MININT..MAXINT
INITIALISATION y :: MININT..MAXINT INITIALISATION y :: MININT..MAXINT
END END
``` ```
%% Output %% Output
Loaded machine: Foo Loaded machine: Foo
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:exec SETUP_CONSTANTS x = 1 :exec SETUP_CONSTANTS x = 1
``` ```
%% Output %% Output
Executed operation: $setup_constants() Executed operation: $setup_constants()
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:exec INITIALISATION y = 2 :exec INITIALISATION y = 2
``` ```
%% Output %% Output
Executed operation: $initialise_machine() Executed operation: $initialise_machine()
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
x x
``` ```
%% Output %% Output
$1$ $1$
1 1
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
y y
``` ```
%% Output %% Output
$2$ $2$
2 2
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Local variables can be used in operation predicates. Local variables can be used in operation predicates.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
::load ::load
MACHINE Counter MACHINE Counter
CONSTANTS min_value, max_value CONSTANTS min_value, max_value
PROPERTIES min_value : MININT..0 & max_value : 0..MAXINT & min_value <= max_value PROPERTIES min_value : MININT..0 & max_value : 0..MAXINT & min_value <= max_value
VARIABLES value VARIABLES value
INVARIANT value : min_value..max_value INVARIANT value : min_value..max_value
INITIALISATION value :: min_value..max_value INITIALISATION value :: min_value..max_value
OPERATIONS OPERATIONS
add(diff) = SELECT add(diff) = SELECT
value+diff : min_value..max_value value+diff : min_value..max_value
THEN THEN
value := value+diff value := value+diff
END END
END END
``` ```
%% Output %% Output
Loaded machine: Counter Loaded machine: Counter
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:let one 1 :let one 1
``` ```
%% Output %% Output
$1$ $1$
1 1
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:let two 2 :let two 2
``` ```
%% Output %% Output
$2$ $2$
2 2
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:constants min_value=-one & max_value=two :constants min_value=-one & max_value=two
``` ```
%% Output %% Output
Machine constants set up using operation 0: $setup_constants() Executed operation: $setup_constants()
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
min_value..max_value min_value..max_value
``` ```
%% Output %% Output
$\{-1,0,1,2\}$ $\{-1,0,1,2\}$
{−1,0,1,2} {−1,0,1,2}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:init value=one :init value=one
``` ```
%% Output %% Output
Machine initialised using operation 3: $initialise_machine() Executed operation: $initialise_machine()
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
value value
``` ```
%% Output %% Output
$1$ $1$
1 1
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:exec add diff=-one :exec add diff=-one
``` ```
%% Output %% Output
Executed operation: add(-1) Executed operation: add(-1)
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
value value
``` ```
%% Output %% Output
$0$ $0$
0 0
......
...@@ -28,11 +28,13 @@ import com.google.inject.Singleton; ...@@ -28,11 +28,13 @@ import com.google.inject.Singleton;
import de.prob.animator.ReusableAnimator; import de.prob.animator.ReusableAnimator;
import de.prob.animator.domainobjects.ErrorItem; import de.prob.animator.domainobjects.ErrorItem;
import de.prob.animator.domainobjects.FormulaExpand;
import de.prob.exception.ProBError; import de.prob.exception.ProBError;
import de.prob.scripting.ClassicalBFactory; import de.prob.scripting.ClassicalBFactory;
import de.prob.statespace.AnimationSelector; import de.prob.statespace.AnimationSelector;
import de.prob.statespace.StateSpace; import de.prob.statespace.StateSpace;
import de.prob.statespace.Trace; import de.prob.statespace.Trace;
import de.prob.statespace.Transition;
import de.prob2.jupyter.commands.AssertCommand; import de.prob2.jupyter.commands.AssertCommand;
import de.prob2.jupyter.commands.BrowseCommand; import de.prob2.jupyter.commands.BrowseCommand;
import de.prob2.jupyter.commands.BsymbCommand; import de.prob2.jupyter.commands.BsymbCommand;
...@@ -302,6 +304,24 @@ public final class ProBKernel extends BaseKernel { ...@@ -302,6 +304,24 @@ public final class ProBKernel extends BaseKernel {
this.setCurrentMachineDirectory(machineDirectory); this.setCurrentMachineDirectory(machineDirectory);
} }
public @NotNull DisplayData executeOperation(final @NotNull String name, final @Nullable String predicate) {
final Trace trace = this.animationSelector.getCurrentTrace();
final String translatedOpName = Transition.unprettifyName(name);
final String modifiedPredicate;
if (predicate == null) {
modifiedPredicate = "1=1";
} else {
modifiedPredicate = this.insertLetVariables(predicate);
}
final List<Transition> ops = trace.getStateSpace().transitionFromPredicate(trace.getCurrentState(), translatedOpName, modifiedPredicate, 1);
assert !ops.isEmpty();
final Transition op = ops.get(0);
this.animationSelector.changeCurrentAnimation(trace.add(op));
trace.getStateSpace().evaluateTransitions(Collections.singleton(op), FormulaExpand.TRUNCATE);
return new DisplayData(String.format("Executed operation: %s", op.getRep()));
}
@Override @Override
public @NotNull String getBanner() { public @NotNull String getBanner() {
return "ProB Interactive Expression and Predicate Evaluator (on Jupyter)\nType \":help\" for more information."; return "ProB Interactive Expression and Predicate Evaluator (on Jupyter)\nType \":help\" for more information.";
......
...@@ -64,19 +64,7 @@ public final class ConstantsCommand implements Command { ...@@ -64,19 +64,7 @@ public final class ConstantsCommand implements Command {
@Override @Override
public @NotNull DisplayData run(final @NotNull ParsedArguments args) { public @NotNull DisplayData run(final @NotNull ParsedArguments args) {
final Trace trace = this.animationSelector.getCurrentTrace(); return this.kernelProvider.get().executeOperation(Transition.SETUP_CONSTANTS_NAME, args.get(PREDICATE_PARAM).orElse(null));
final String predicate;
if (!args.get(PREDICATE_PARAM).isPresent()) {
predicate = "1=1";
} else {
predicate = this.kernelProvider.get().insertLetVariables(args.get(PREDICATE_PARAM).get());
}
final List<Transition> ops = trace.getStateSpace().transitionFromPredicate(trace.getCurrentState(), "$setup_constants", predicate, 1);
assert !ops.isEmpty();
final Transition op = ops.get(0);
this.animationSelector.changeCurrentAnimation(trace.add(op));
trace.getStateSpace().evaluateTransitions(Collections.singleton(op), FormulaExpand.TRUNCATE);
return new DisplayData(String.format("Machine constants set up using operation %s: %s", op.getId(), op.getRep()));
} }
@Override @Override
......
...@@ -70,21 +70,7 @@ public final class ExecCommand implements Command { ...@@ -70,21 +70,7 @@ public final class ExecCommand implements Command {
@Override @Override
public @NotNull DisplayData run(final @NotNull ParsedArguments args) { public @NotNull DisplayData run(final @NotNull ParsedArguments args) {
final Trace trace = this.animationSelector.getCurrentTrace(); return this.kernelProvider.get().executeOperation(args.get(OPERATION_PARAM), args.get(PREDICATE_PARAM).orElse(null));
final String translatedOpName = Transition.unprettifyName(args.get(OPERATION_PARAM));
final String predicate;
if (!args.get(PREDICATE_PARAM).isPresent()) {
predicate = "1=1";
} else {
predicate = this.kernelProvider.get().insertLetVariables(args.get(PREDICATE_PARAM).get());
}
final List<Transition> ops = trace.getStateSpace().transitionFromPredicate(trace.getCurrentState(), translatedOpName, predicate, 1);
assert !ops.isEmpty();
final Transition op = ops.get(0);
this.animationSelector.changeCurrentAnimation(trace.add(op));
trace.getStateSpace().evaluateTransitions(Collections.singleton(op), FormulaExpand.TRUNCATE);
return new DisplayData(String.format("Executed operation: %s", op.getRep()));
} }
@Override @Override
......
...@@ -64,19 +64,7 @@ public final class InitialiseCommand implements Command { ...@@ -64,19 +64,7 @@ public final class InitialiseCommand implements Command {
@Override @Override
public @NotNull DisplayData run(final @NotNull ParsedArguments args) { public @NotNull DisplayData run(final @NotNull ParsedArguments args) {
final Trace trace = this.animationSelector.getCurrentTrace(); return this.kernelProvider.get().executeOperation(Transition.INITIALISE_MACHINE_NAME, args.get(PREDICATE_PARAM).orElse(null));
final String predicate;
if (!args.get(PREDICATE_PARAM).isPresent()) {
predicate = "1=1";
} else {
predicate = this.kernelProvider.get().insertLetVariables(args.get(PREDICATE_PARAM).get());
}
final List<Transition> ops = trace.getStateSpace().transitionFromPredicate(trace.getCurrentState(), "$initialise_machine", predicate, 1);
assert !ops.isEmpty();
final Transition op = ops.get(0);
this.animationSelector.changeCurrentAnimation(trace.add(op));
trace.getStateSpace().evaluateTransitions(Collections.singleton(op), FormulaExpand.TRUNCATE);
return new DisplayData(String.format("Machine initialised using operation %s: %s", op.getId(), op.getRep()));
} }
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment