Repository navigation
feat: assume a text holds at most 2^53 - 1 code points - #100
Merged
Merged
Conversation
Decision 12 makes `length` and `<` on `Text` count and compare code
points, as the solvers' `str.len` and `str.<` do, so a program that
orders texts is no longer an error. The cases pin it before the
compiler does: a contract that holds and one that breaks for each,
enum ordering still refused, and a pair across U+FFFF ("z" before
"😀"), where UTF-16 order disagrees. A TypeScript case pins the
generated module. text-ordered-law pins that cvc5 proves no order
law of `str.<`, so such an obligation is undecided.
Refs #83
`length` on a text and `<`, `<=`, `>`, `>=` between texts now check, prove and run. The checker writes them as their own nodes, so each backend can't confuse them with list length or integer order: proofs use `str.len`, `str.<` and `str.<=`, and the interpreter compares Rust strings, whose UTF-8 order is code-point order. JavaScript's `.length` and `<` count and compare UTF-16 units, which disagree with the solvers above U+FFFF. Generated TypeScript calls its own `textLength$` and `textLess$` instead, emitted only in the modules that use them, and the differential samples gain U+FF5A, which UTF-16 orders after U+1D11E, so a unit-based helper fails it. Refs #83
SMT-LIB's str.len is unbounded, so the solvers can't show that arithmetic on `length(text)` stays within `i64`: cvc5 answers with a text 2^63 code points long. The measurement runs the scripts Accord writes for twelve functions with no limit, a limit on parameters, a limit at every use, and a saturated length, under five seeds. A limit at every use proves 36 of 45 scripts against 26 and 23, keeps every proof the others give, and stays clear of cvc5#13161. Saturating the length loses four proofs. Refs #83
The limit must decide arithmetic on a length wherever it is taken: of a parameter, a field, an element, inside `all`, `any` and `count`, and through a callee's contract. The fault case checks it decides nothing it shouldn't: 2000 times a length can still leave `i64`. Refs #83
Without a limit, no proof that arithmetic on a text's length stays within `i64` goes through, and callers assume a callee's length fits. 2^53 - 1 is the most a JavaScript string holds, so generated code guarantees it; native code will have to check it. Every script now states the limit of each length its assertions take, under the quantifiers around it, as the measurement did. The pass runs where every script reaches the solvers, so no generator can miss it. It never states the limit of a definition's parameter, which would limit every string and contradict the theory, and it skips quantifiers it doesn't recognize. The receipt lists the assumption where a proof can rest on it. Refs #83
Sequela02
changed the base branch from
feat/stage-11-text-code-points
to
main
November 19, 2026 06:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to 11b (#99), stacked on it: every text is assumed to hold at most 2^53 − 1 code points, so arithmetic on
length(text)can be proved to stay withini64.The problem
SMT-LIB's
str.lenis unbounded. On #99,length(word) + 1andlength(word) * 2are undecided on "stays withini64": cvc5 answers with a text 2^63 code points long and Z3 answers unknown. Callers also assume a callee'si64result fits.The change
obligation/lengths.rsasserts(<= (str.len X) 9007199254740991)for each(str.len X)an assertion holds, under the guards andlets of the quantifiers around it. 2^53 − 1 is the most a JavaScript string holds, so generated code guarantees it.Solvers::decide_calls, where every script reaches the solvers: proofs, call contracts,countaxioms, mutants, open-case searches anddiff.define-fun's parameter. That would say every string is short, which the theory of strings contradicts, so every claim would be proved. Each use of a definition is expanded first, with its bound names renamed so no argument is captured.Int, or of a shape other than the list-index guard, and nothing to a script with nostr.len.not_provedgainstext_assumptionswhere the function or a callee's contract takes a text's length. Docs:syntax.md,receipt.md, row 6 ofnative-code-constraints.md(native code must guarantee or check the limit).The measurement
docs/design/measurements/2026-11-18-text-length-limit: the 45 scripts #99's compiler writes for twelve functions, run with no limit, a limit on parameters (A), a limit at every use (B, this PR) and a saturated length, five seeds per solver.Review focus
Verification
On Windows, with the pinned Z3 5.3.3 and cvc5 1.4.2:
text-length-limit.accordwas written first: 7 of its 17 obligations were undecided before the change, and all 17 are proved after.text-length-limit-fault.accordstays undecided, as it must.cargo fmt --all --checkpasses;cargo clippy --workspace --all-targets --locked -- -D warningsis clean;cargo test --workspace --locked --no-fail-fastpasses.score.py --self-testandmaterials.py target/debug/accordpass; review hashes are unchanged.Not established: Linux and macOS (CI with
full-ci). Not measured: nested lists of texts, texts in enum fields, large programs.A separate finding, filed on its own: false contracts over
List<Text>come out undecided rather than refuted, because Z3 answers unknown. The limit doesn't change it.Risk note
Two-way door: a new trusted assumption, listed in the receipt; the receipt schema doesn't change. Blast radius: scripts that take a text's length, which only exist since #99; every other script is unchanged, so its ledger entries are reused. Evidence: the cases, unit tests and measurement above.
Refs #83
Atrium-Closes: 01a1f241-0f3c-74d1-97c0-e14fa2ac3cf6