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

Better parameterized instantiation support #441

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

quaeler
Copy link
Contributor

@quaeler quaeler commented Apr 13, 2020

  • Supporting parameterized instantiation used in specification definition in which temporal actions are involved.

[Bug][Tools]

- Supporting parameterized instantiation used in specification definition in which temporal actions are involved.

[Bug][Tools]
@quaeler quaeler added the Tools The command line tools - TLC, SANY, ... label Apr 13, 2020
@quaeler
Copy link
Contributor Author

quaeler commented Apr 13, 2020

This commit does not break any of the existing unit tests, which lessens slightly my trepidation in this change.

A review of the investigation

Using this module and inner-module as reference, i'll discuss what was originally working and what was not.

What was working

  • Model checking with the SPECIFICATION as SpecB
  • Model checking with the INIT / NEXT as ParamInstance's Init and Next

What was failing

  • Model checking with the SPECIFICATION as SpecA

Why was this failing

In SpecProcessor#processConfigSpec(ExprNode, Context, List) we encountered the logic problem that the predicate embodying the SpecA assignment (Z7(7)!Spec) does have a non-zero-length argument this, and it is also considered a custom operation (opcode == 0,) so it remains unprocessed in lines 1100-1289 (whereas SpecB, as it is a conjunction, gets processed in lines 1104-1110.)
This results in the instance variable initPredVec have a zero-size and so this check will fail the launch of TLC.

The remediation

The changes embodied in this PR augment the logic in processConfigSpec(...) to handle the non-zero-length argument case for an action whose operator's body is an instance of SubstInNode, whose body is another instance of OpApplNode.

At this point, we need to hand curate the current Context instance to capture the mapping between the argument(s)'s value(s) and the variable name(s), so that when the tool and the workers are evaluating expressions later on, they have the value available to them. This is commented on in the changes introduced in this method.

Also discussed in those comments, we are ensuring in this Context curation, and the context curations in Tool#getInitStates(...) and in Tool#getNextStatesImplSubstInKind(...), that we do not double-map the variable name within the Context. If we do not observe this, a later mapping of the variable name will occur during recursive calls of processConfigSpec(...) / getInitStates(...) / getNextStatesImplSubstInKind(...) done to process the invoked inner module actions, and this mapping will be valueless (because at that point we've lost the argument value.)


Z7(cardinality) == INSTANCE Ring

SpecA == Z7(7)!Spec
Copy link
Member

Choose a reason for hiding this comment

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

Did you also look into operator instantiation (see section 5 of TLA+2 guide) or do you expect no special handling is required in TLC?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not, will verify and address if kaput.

Copy link
Member

@lemmy lemmy Apr 14, 2020

Choose a reason for hiding this comment

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

Section 2.1 of current-tools.pdf suggests a simple workaround. To what extent does is this related?

Please add test cases if operator instantiation is different.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what you mean by related, but since the suggested workaround has a zero-length argument list, its functioning will not be affected by these code changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has not affected the handling of infix operator definitions; e.g

ModSanityCheck == Z7(7)!$$(5,9) < 7

where the inner module has this definition

  x $$ y == (x + y) % cardinality

evaluates correctly. I'm unable to create a correctly parsed prefix or postfix operator definition even in older builds of the Toolbox/TLATools, though TLA documentation implies this is supposed to work.

@lemmy
Copy link
Member

lemmy commented Apr 14, 2020

Non-exhaustive set of background information/context:

http://discuss.tlapl.us/msg01141.html

- Unit tests making sure instantiated parameterized infix operators still work as expected
- Improving error message for a pre-existing metadata directory to hint at setting the millisecond naming on directory creation
- Removing the 1 second pause in the unit tests covering this new functionality

[Bug][Tools]
- De-conjunct-ing SpecA so that the originally intended test case is hit.
- Comments and pedantry

[Bug][Tools]
- Temporal properties always-eventually using parameterized instances (both failing and succeeding) unit tests
- Refactoring the original unit test as my janky implementation of a config-file-per-test-in-the-same-class was falling apart in parallel runners
- Comments about future refactorings outside the scope of these changes

[Bug][Tools]
- Expanding inner module actions to allow for a clearer specification feature strong fairness; adding unit test featuring strong fairness declared on a parameterized instance's action
- Renaming recently added unit test classes to conform to the 'Test' class name suffix
- Excluding the abstract test class which creates config files from the ant junit task

[Bug][Tools]
- Excluding the abstract test class which creates config files from a missed ant junit task - thanks Markus

[Bug][Tools]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tools The command line tools - TLC, SANY, ...
Development

Successfully merging this pull request may close these issues.

None yet

2 participants