Skip to content

tlapm and SANY accept ambiguous expressions with inconsistent semantics #28

Closed

Description

@lemmy

{} \in SUBSET {} \cap {} is one example. It should be rejected.

In the Summary of TLA+, operator precedence is a range, and the relative precedence of two operators is unspecified when their ranges overlap. SUBSET and \cap are both 8–8, as are UNION, \cup, and \. An unspecified precedence is a syntax error: the same rule makes A \/ B /\ C illegal. The 1997 note The Operators of TLA+ (§1.4.1) states this directly: \cap, \cup, \, SUBSET, and UNION have equal precedence, and equal precedence is how TLA+ refuses an ambiguous expression.

tlapm gives both operators precedence 8 and accepts the expression. It parses it as {} \in SUBSET ({} \cap {}), which is true, and OBVIOUS proves it. Its precedence resolver never rejects an overlapping range.

SANY gives SUBSET precedence 10–13 and \cap precedence 8–8, so the ranges do not overlap. It accepts the expression and parses it as {} \in ((SUBSET {}) \cap {}), which is false. TLC evaluates that reading.

Both tools therefore accept an expression Lamport leaves unspecified, and they give it different meanings. tlapm proves a theorem that TLC evaluates to false.

SANY has parsed these expressions this way for as long as the tools have been in version control: SUBSET, UNION, and DOMAIN are 100–130 in the initial import of 2009. TLC and Apalache both parse with SANY, so they have accepted the SANY reading essentially. One possible resolution is to declare that reading the language, overruling the precedence ranges in the Summary of TLA+. Whichever reading is chosen, tlapm and SANY have to agree on it.

Related: tlaplus/tlapm#213, tlaplus/tlaplus#892.

Activity

  1. muenchnerkindl commented on Nov 3, 2026

    @muenchnerkindl
    Contributor

    Personally, I am in favor of rejecting such expressions. Unless the precedence is obvious beyond any doubt (think of x=0 /\ y=42), parentheses should be used for disambiguation.

  2. added
    bug
    on Nov 3, 2026
  3. lemmy commented on Nov 3, 2026

    @lemmy
    MemberAuthor

    Assessing the potential blast radius of the SANY breaking change proposed in tlaplus/tlaplus#1508.

    @konnov, could you estimate the impact on Apalache if SANY changes its behavior as proposed?

  4. konnov commented on Nov 3, 2026

    @konnov

    4. Assessing the potential blast radius of the SANY breaking change proposed in tlaplus/tlaplus#1508.
    @konnov, could you estimate the impact on Apalache if SANY changes its behavior as proposed?

    We only have to fix https://github.com/apalache-mc/apalache/blob/main/tla-io/src/main/scala/at/forsyte/apalache/io/lir/PrettyWriter.scala to reflect the change in priorities.

  5. ahelwer commented on Nov 3, 2026

    @ahelwer
    Collaborator

    It would be interesting to know which came first, the 8-8 documentation or the 10-13 implementation. It could be a transcription error when creating the SANY operator table or it could be a usability improvement decided upon during SANY development which was never backported to the docs for whatever reason. Absent that I think it makes sense to just choose between 10-13 and 8-8 depending on which seems to be more intuitive when writing expressions. Historically SANY behavior has been the de facto language spec, which this RFC process is somewhat changing (a good thing).

  6. lemmy commented on Nov 4, 2026

    @lemmy
    MemberAuthor

    tlaplus/Examples#252 and tlaplus/CommunityModules#140 show which Examples and CommunityModules break when making SANY adhere to the precedence rules in Summary of TLA+.

  7. cnewcom commented on Nov 5, 2026

    @cnewcom

    FWIW, I agree with Stephan here:

    1. Personally, I am in favor of rejecting such expressions. Unless the precedence is obvious beyond any doubt (think of x=0 /\ y=42), parentheses should be used for disambiguation.

    ... and Markus' investigation suggests that the amount of breakage isn't too bad, IMO

    8. tlaplus/Examples#252 and tlaplus/CommunityModules#140 show which Examples and CommunityModules break when making SANY adhere to the precedence rules in Summary of TLA+.

  8. lemmy commented on Nov 5, 2026

    @lemmy
    MemberAuthor

    SLC member in favor of aligning with Summary of TLA+

  9. konnov commented on Nov 5, 2026

    @konnov

    10. @konnov and @muratdem: Are you aye, nay, or abstain?

    in favor (aye)

  10. Calvin-L commented on Nov 6, 2026

    @Calvin-L

    I am also in favor.

  11. 9 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions