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

Fix specifying a spec in the cli args #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/tlacli/cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CFG:
"""
Internal representation of a .cfg.
"""
spec: str = "Spec"
spec: t.Optional[str] = None
invariants: ss = field(default_factory=set)
properties: ss = field(default_factory=set)
constants: t.Dict[str, str] = field(default_factory=dict)
Expand All @@ -34,7 +34,9 @@ def merge(self, other: 'CFG') -> 'CFG':
out.invariants = self.invariants | other.invariants
out.properties = self.properties | other.properties
out.model_values = self.model_values | other.model_values


out.spec = other.spec or self.spec

# if two CFGs def the same constant, we use the _second_ one
out.constants.update(self.constants)
out.constants.update(other.constants)
Expand All @@ -43,7 +45,8 @@ def merge(self, other: 'CFG') -> 'CFG':
def format_cfg(cfg: CFG) -> str:
"""Convert a CFG into a format that can be read by TLC."""
# XXX temporarily just using sorted to enforce ordering
out = [f"SPECIFICATION {cfg.spec}"]
spec = cfg.spec or "Spec"
out = [f"SPECIFICATION {spec}"]
for inv in sorted(cfg.invariants):
out.append(f"INVARIANT {inv}")

Expand Down
2 changes: 1 addition & 1 deletion src/tlacli/tools/tlc.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def setup(parser: _SubParsersAction) -> None:
tlc_args = parser_tlc.add_argument_group("tlc_args", "Runtime values for the TLC model checker")
# https://lamport.azurewebsites.net/tla/tlc-options.html

cfg_args.add_argument("--spec", "--specification", default="Spec", help="The TLA+ specification operator, defaults to Spec")
cfg_args.add_argument("--spec", "--specification", default=None, help="The TLA+ specification operator, defaults to Spec")
cfg_args.add_argument("--cfg", help="A template cfg for default values")

# action=extend is python 3.8 only...
Expand Down