Skip to content

tlapm and SANY accept ambiguous expressions with inconsistent semantics - #336

Open
lemmy wants to merge 6 commits into
mainfrom
mku-gh892
Open

lemmy wants to merge 6 commits into
mainfrom
mku-gh892

Conversation

@lemmy

@lemmy lemmy commented Nov 5, 2026

Copy link
Copy Markdown
Member

@lemmy lemmy self-assigned this Nov 5, 2026
@lemmy lemmy added bug An error, usually in the code. syntax parser Issues relating to TLAPM's syntax parser soundness Issues and PRs related to getting TLAPM to prove FALSE labels Nov 5, 2026
@lemmy
lemmy marked this pull request as ready for review November 6, 2026 02:29
@lemmy
lemmy requested a balanced review from Copilot November 6, 2026 16:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain to block approval of the operator-precedence changes.

No open issues 🎉

What changed in this PR

This PR addresses the tlapm side of the ambiguity reported in tlaplus/rfcs#28 by rejecting conflicting operator precedence unless associativity resolves it.

Changes:

  • Track canonical operator names so aliases retain consistent associativity.
  • Reject ambiguous expressions with a diagnostic requesting parentheses.
  • Add precedence regression tests and explicitly parenthesize affected LSP test expressions.
File Description
test/​parser/​precedence_tests.ml Tests ambiguity rejection, parentheses, associativity, and aliases.
test/​parser/​dune Registers the precedence test suite.
src/​pars/​pco.mli Documents canonical operator names in parser items.
src/​pars/​pco.ml Detects precedence conflicts during operator resolution.
src/​pars.mli Updates the exposed operator-item type.
src/​expr/​e_parser.ml Supplies canonical names for expression operators.
lsp/​test/​test_decompose_goal.ml Parenthesizes chained equivalence expressions.
lsp/​test/​test_decompose_assm.ml Parenthesizes chained implication expressions.

Review effort: Balanced

@lemmy
lemmy force-pushed the mku-gh892 branch 2 times, most recently from 4ac4f6b to da58bcd Compare November 7, 2026 02:17
@lemmy
lemmy requested a balanced review from Copilot November 7, 2026 02:32

This comment was marked as resolved.

@lemmy

lemmy commented Nov 7, 2026 •

Copy link
Copy Markdown
Member Author

This PR touches parts of the parser (@glondu, @ahelwer) as well as the LSP proof decomposition, i.e. formatting (@kape1395).

@ahelwer

ahelwer commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Please stop tagging me to review slop PRs that you don't understand

@lemmy
lemmy force-pushed the mku-gh892 branch 2 times, most recently from 684864c to 38a6f2a Compare November 8, 2026 16:57
@lemmy
lemmy requested a review from muenchnerkindl November 8, 2026 17:26
lemmy and others added 6 commits November 9, 2026 18:20
Precedence tests need to verify grouping, distinguish ambiguity from
unrelated syntax errors, and guard against rejecting valid input.

[Tests]

Co-authored-by: GPT-6.1 Sol Ultra <noreply@openai.com>
Signed-off-by: Markus Alexander Kuppe <github.com@lemmster.de>
Stable printer output does not guarantee preserved expression structure or
label scope. Round-trip checks must compare the original and reparsed
expressions.

[Tests]

Co-authored-by: GPT-6.1 Sol Ultra <noreply@openai.com>
Signed-off-by: Markus Alexander Kuppe <github.com@lemmster.de>
Associativity applies to repetitions of one infix operator, including its
aliases. Precedence resolution needs canonical operator names to distinguish
these chains from mixed operators.

[Refactor]

Co-authored-by: GPT-6.1 Sol Ultra <noreply@openai.com>
Signed-off-by: Markus Alexander Kuppe <github.com@lemmster.de>
Overlapping precedence ranges can leave expression grouping unspecified.
Require parentheses unless associativity resolves the conflict for the same
canonical operator.

Implements the decision in tlaplus/rfcs#28.

[Bug][Tests]

Co-authored-by: GPT-6.1 Sol Ultra <noreply@openai.com>
Signed-off-by: Markus Alexander Kuppe <github.com@lemmster.de>
The authoritative Summary of TLA+ and SANY's Operators.java define % as
non-associative (assocNone, precedence 100-110 in SANY). A % B % C requires
parentheses to specify its grouping.

Implements the decision in tlaplus/rfcs#28.

[Bug][Tests]

Co-authored-by: GPT-6.1 Sol Ultra <noreply@openai.com>
Signed-off-by: Markus Alexander Kuppe <github.com@lemmster.de>
Missing parentheses can change product nesting, subscript grouping, or label
scope when reparsed. LSP proof decomposition needs the printer to preserve
that structure when generating proof steps.

[Bug][Tests]

Co-authored-by: GPT-6.1 Sol Ultra <noreply@openai.com>
Signed-off-by: Markus Alexander Kuppe <github.com@lemmster.de>
@lemmy

lemmy commented Nov 10, 2026

Copy link
Copy Markdown
Member Author

@damiendoligez Would you prefer that I move the formatter changes (94d1a77) into a separate PR to keep this PR focused solely on the soundness issue?

@lemmy lemmy mentioned this pull request Nov 12, 2026
12 tasks

This branch has not been deployed

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

Labels

bug An error, usually in the code. soundness Issues and PRs related to getting TLAPM to prove FALSE syntax parser Issues relating to TLAPM's syntax parser

Development

Successfully merging this pull request may close these issues.

3 participants