Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to constrain steps #18

Merged
merged 4 commits into from
May 11, 2020
Merged

Add ability to constrain steps #18

merged 4 commits into from
May 11, 2020

Conversation

pxlcoder
Copy link
Collaborator

A list of constraints can now be specified alongside the step command, enabling the user to specify paths of execution. The length of the list represents the number of transitions, and the i-th element of the list is the constraint applied to the i-th transition.

If an empty string is specified as a constraint at a particular index, no constraint will be applied to the corresponding transition.

This functionality is implemented by creating an auxiliary predicate for each constraint. After these predicates have been created, a master path predicate is generated, containing a conjunction of the auxiliary predicates. Finally, the run command calls path[first] to apply the master predicate beginning at the first state.

Usage example:

(aldb) load models/river_crossing.als
Reading model from models/river_crossing.als...done.
(aldb) step ["Chicken in far"]

S2
----
far: { Chicken, Farmer }
near: { Fox, Grain }

(aldb) step ["", "far=Chicken+Farmer+Grain"]

S4
----
far: { Chicken, Farmer, Grain }
near: { Fox }

(aldb) history

(-3)
----
S1
----
far: {  }
near: { Chicken, Farmer, Fox, Grain }

(-2)
----
S2
----
far: { Chicken, Farmer }
near: { Fox, Grain }

(-1)
----
S3
----
far: { Chicken }
near: { Farmer, Fox, Grain }

Closes #17.

Copy link
Member

@liangdrew liangdrew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to print out the current state again if a constraint is unsatisfiable:

(aldb) current

S1
----
far: {  }
near: { Chicken, Farmer, Fox, Grain }

(aldb) step [Chicken=far]
Cannot perform step. Transition constraint is unsatisfiable.

S1
----
far: {  }
near: { Chicken, Farmer, Fox, Grain }

(aldb)

README.md Outdated Show resolved Hide resolved
src/commands/CommandConstants.java Outdated Show resolved Hide resolved
README.md Outdated

Specify an integer value of n >= 1. By default, n = 1.

A list of constraints may also be specified, as a comma-separated list enclosed by square brackets.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be more clear that the user can either specify the number of steps or a list of constraints. Something like: "Instead of a numeric number of steps, step constraints may be specified as a comma-separated list enclosed in square brackets."

Copy link
Collaborator

@aman-dureja aman-dureja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good. Please manually test it with the musical chairs model before merging; that model is more complex than RCP and is useful for exposing potential bugs.

@pxlcoder pxlcoder merged commit 5530b25 into master May 11, 2020
@pxlcoder pxlcoder deleted the step-with-constraints branch May 11, 2020 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to constrain steps
4 participants