diff --git a/src/tlacli/cfg.py b/src/tlacli/cfg.py index e889efb..dfe86c1 100644 --- a/src/tlacli/cfg.py +++ b/src/tlacli/cfg.py @@ -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) @@ -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) @@ -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}") diff --git a/src/tlacli/tools/tlc.py b/src/tlacli/tools/tlc.py index 8b14770..a814323 100644 --- a/src/tlacli/tools/tlc.py +++ b/src/tlacli/tools/tlc.py @@ -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...