Skip to content

Fix SMT SetOf n-ary extensionality axiom - #266

Open
ylht wants to merge 2 commits into
tlaplus:mainfrom
ylht:codex/fix-setof-nary-smt
Open

Fix SMT SetOf n-ary extensionality axiom#266
ylht wants to merge 2 commits into
tlaplus:mainfrom
ylht:codex/fix-setof-nary-smt

Conversation

@ylht

@ylht ylht commented May 4, 2026

Copy link
Copy Markdown

Summary

Fix the SMT extensionality helper axiom for SetOf_n so n-ary set comprehensions pass all n bound-domain arguments to the SMT SetOf_n application.

Refs #265.

Scope

This PR is intentionally limited to an SMT backend arity fix. It does not add general TLAPS support for TLA+ constructs that bind more than one variable, and it does not address support in the Zenon or Isabelle backends.

The broader multi-variable binding limitation is discussed in #265 and in the TLAPS unsupported features documentation.

Root Cause

SetOf_n is declared as taking n domain arguments plus one predicate/function argument:

SetOf_n(a1, ..., an, P)

But assert_issetof n encoded the assertion as if every SetOf_n were unary:

SetOf_n(a, P)

This is accidentally correct for n = 1, but wrong for n >= 2.

Changes

  • Give P the type idv^n -> idv in assert_issetof n.
  • Quantify n bound-domain arguments.
  • Build SetOf_n(a1, ..., an, P) in the trigger and assertion.
  • Add a minimal SMT regression test using a two-variable set comprehension.

Validation

New regression test on the fixed binary:

tlapm --cleanfp --nofp test/fast/regression/setof_nary_smt_test.tla

Result:

[INFO]: All 2 obligations proved.

The same test fails on 471b481 with fingerprints disabled:

[ERROR]: 1/2 obligations failed.

Build:

DUNE_PROFILE=release OCAMLPARAM='_,O3=1,unbox-closures=1,rounds=2' opam exec -- dune build src/tlapm.exe

@ylht
ylht marked this pull request as ready for review May 4, 2026 15:23
@muenchnerkindl

Copy link
Copy Markdown
Contributor

As noted in the related issue, TLAPS not supporting constructs binding more than one variable applies in a much broader sense than just for the SMT backend. While your fix may go some way for introducing support for the SMT backend specifically, supporting such constructs needs more pervasive changes to tlapm and the different backends. Note that

THEOREM {x+y : x \in {1}, y \in {1}} = 2
OBVIOUS

outputs error message concerning SMT, Zenon, and Isabelle.

@ylht

ylht commented May 4, 2026

Copy link
Copy Markdown
Author

Thanks, that makes sense. I agree this PR does not implement general support for multi-variable binders across TLAPS and all backends.

I will update the PR description to make the scope explicit: this is only an SMT backend arity fix for the existing SetOf_n encoding, not a full fix for #265. I will also change "Closes #265" to "Refs #265".

If you prefer not to accept partial SMT-only support for this unsupported construct, I can close the PR.

Signed-off-by: 叶落寒塘 <22316734+ylht@users.noreply.github.com>
wkirschenmann pushed a commit to wkirschenmann/tlapm that referenced this pull request Aug 21, 2026
… and survey them

Two fixes to the upstream section.

**tlaplus#286 is ours**, not an external reference, and the plan now says so
plainly: same team, opened 2026-07-27, still unanswered, and its four
patch families ARE our items 3, 6, 14, 15 and 20 -- already-public
proposals re-implemented, not contributions of this branch. What the
branch adds on them is what tlaplus#286 could not offer: single-topic reviewable
commits with stated invariants and mechanical gates, and attribution per
commit instead of per patch set.

**Other people's PRs get their own section**, after checking upstream:
`master` is at 4600b24, exactly this branch's base, so nothing has landed
since the fork and only the open PRs matter.

  * tlaplus#284 (open, LGTM) kills orphaned provers via `exec setpriv
    --pdeathsig KILL` when *tlapm dies*. Same family as our item 2,
    complementary failure mode: ours covers tlapm alive but its kill
    ignored (SIGHUP set to SIG_IGN by nohup, inherited through exec).
    Neither subsumes the other, and tlaplus#284 supplies the SIGKILL escalation
    our fix lacks -- reference it, do not duplicate it.
  * tlaplus#285 (open) modifies `let_normalize`/`except_normalize`, the two
    functions item 15 calls per hypothesis. Textual conflict certain; the
    per-hypothesis equivalence argument must be re-established with the
    oracle afterwards. Kept in the survey for that reason only.
  * tlaplus#275 (open) makes SANY an opt-in parser, so item 7 keeps its value --
    but the editor floor is now 95 % parse, and SANY does semantic
    analysis inside "parsing", which item 19 does not assume.
  * tlaplus#268 (open, extends the merged tlaplus#241) is the feature items 18-19
    currently break: the decomposition code actions locate steps by
    range, and scoped re-elaboration leaves inner positions stale. This
    is why those modes stay flag-gated.
  * tlaplus#283 (merged) gives a deterministic Z3 budget -- worth adopting in
    measurement protocol P2 to remove prover-side variance.
  * tlaplus#266 (open) changes an SMT axiom, so item 3's subset gate must be
    re-run against it; tlaplus#248 (open) upgrades Z3 and invalidates absolutes.
  * tlaplus#264 closed without adopting an LLM policy -- escalated to the TLA+
    Foundation board. The stated maintainer position (human first
    contact, per-commit disclosure of models used) is the one to assume,
    and the 441-lines-for-most-of-the-gain framing is what answers the
    review-workload concern behind it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CUUoeEmuL3jsYhUb3UrhJH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants