You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tlapm and SANY accept ambiguous expressions with inconsistent semantics #28
{} \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.
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.
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?
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).
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
Activity
muenchnerkindl commentedon Nov 3, 2026
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.Give SUBSET, UNION, and DOMAIN their documented precedence.
lemmy commentedon Nov 3, 2026
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?
konnov commentedon Nov 3, 2026
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.
ahelwer commentedon Nov 3, 2026
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).
lemmy commentedon Nov 4, 2026
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+.
cnewcom commentedon Nov 5, 2026
FWIW, I agree with Stephan here:
... and Markus' investigation suggests that the amount of breakage isn't too bad, IMO
lemmy commentedon Nov 5, 2026
SLC member in favor of aligning with Summary of TLA+
konnov commentedon Nov 5, 2026
in favor (aye)
Preserve the SANY binding of SUBSET against \ and \union.
Preserve the SANY binding of SUBSET against \ and \union.
Parenthesize SUBSET and UNION where precedence is unspecified.
Calvin-L commentedon Nov 6, 2026
I am also in favor.
Preserve the SANY binding of SUBSET against \ and \union. (#140)
9 remaining items
Make % non-associative.
Reject expressions with ambiguous precedence.
Make % non-associative.
Reject expressions with ambiguous precedence.
Make % non-associative.
Reject expressions with ambiguous precedence.
Make % non-associative.
Reject expressions with ambiguous precedence.
Make % non-associative.
Reject expressions with ambiguous precedence.
Make % non-associative.
Reject expressions with ambiguous precedence.
Make % non-associative.
lemmy commentedon Nov 20, 2026
All done: