Repository navigation
Description
Problem
A language-1.2 definition or theorem that applies utf8_decode, split_exact, format_decimal, parse_decimal, or length on String must state Classical.choice in its axiom policy, and so must everything that calls it. A project that keeps its policies free of Classical.choice cannot use these primitives. For example, it cannot use utf8_decode to turn input into a String, so it has to write its own table-driven conversion.
This is a design request, not a conformance defect:
- §17.12 lets a computational definition declare a nonempty exact policy for trusted dependencies in its fixed Lean implementation.
- §17.12 Runtime bounds says outright that "the split and the decoder pin
Classical.choice", sosplit_exact_fitsandutf8_decode_lengthobserve it too. - §17.17 requires every production root theorem to observe exactly
Classical.choice,Quot.soundandpropext, so this request only concerns declaration policies, not certificates.
#301 asks for evaluation and laws for the text primitives and does not address their axiom set.
The format_decimal case differs from the others. Nothing in the SPEC pins it, and the dependency comes from how LexLean's runtime is arranged rather than from what the function needs.
Reproduction
Run at pinned 3877351 (lexlean 0.4.0, language 1.2, Lean 4.32.1). origin/main and origin/release/v0.5 were read, not run: language/runtime-1.2/library/src/Portable.lex.tex is unchanged from the pin, and compiler/expected/verify/audit/output.txt on release/v0.5 lists the same axioms.
A project with language = "1.2" and the builtin lexicon sources lexlean.std.bool and lexlean.std.nat, with one module holding one definition and no axioms member:
\begin{lexlean}{M}
\useglossary{lexlean.std.nat@1.2.0}
\title{Natural number addition}
\begin{semanticmodule}
definition{
name: f,
parameters: [n : UInt8],
result: String,
body: (prim format_decimal n : String),
executable: true
}
\end{semanticmodule}
\end{lexlean}
error[LLV7005]: `K1.M.f` violates its none axiom policy: observed [Classical.choice, Quot.sound, propext]
The same probe, one primitive at a time:
| Body | Observed axioms |
|---|---|
prim utf8_decode b |
Classical.choice, Quot.sound, propext |
prim length s on String |
Classical.choice, Quot.sound, propext |
prim split_exact s d (4 : UInt32) |
Classical.choice, Quot.sound, propext |
prim format_decimal n at UInt8 and at Int |
Classical.choice, Quot.sound, propext |
prim parse_decimal s at UInt8 |
Classical.choice, Quot.sound, propext |
prim join xs sep |
propext |
prim utf8_encode s, prim equal on String or Bytes |
none |
Where the axioms come from
#print axioms under Lean 4.32.1:
- From Lean core:
String.fromUTF8?andByteArray.validateUTF8,String.toListandString.length(whose body isb.toList.length),String.splitOn,String.toInt?all report[propext, Classical.choice, Quot.sound]. - From the runtime, for
format_decimal:toStringatUInt8has no axioms,toStringatInthas[propext], andLexLeanRuntime.formatDecimalandLexLeanRuntime.Decimal.formathave none. ButDecimalbundlesparseandformatin one instance, andinstDecimalOfFixedOfToStringandinstDecimalIntreport[propext, Classical.choice, Quot.sound]. TheirparseusesString.toInt?. Formatting pays for parsing.
Proposed direction
format_decimal: separate format from parse in the runtime (two classes or two instances), soformat_decimalobserves nothing at fixed widths andpropextatInt. This change does not touch any sentence of the SPEC.utf8_decode: define it withoutString.fromUTF8?. As a feasibility check, a 28-line plain-Lean decoder overList UInt8that builds withString.ofListand accepts only if the re-encoding equals the input depends on[propext, Quot.sound].#evalagreed withString.fromUTF8?on the eight byte sequences tried: overlong, surrogate, above U+10FFFF,0xFF, truncated, lone continuation,⊕,a. It has not been proved equal toString.fromUTF8?, and that proof, the preservation lemmas that depend on it, and the §17.12 sentence above would be part of the work.lengthonStringandsplit_exact: the same question. These depend onString.toListandString.splitOn; no replacement has been tried.
If the maintainers prefer to keep the choice dependency for items 2 and 3, that is a reasonable answer, since §17.12 already states it for the split and the decoder. Item 1 stands on its own either way.
Accepted when
format_decimalat a fixed width verifies with noaxiomsmember.- If item 2 is accepted,
utf8_decodeverifies with a policy that does not nameClassical.choice, and §17.12 Runtime bounds andutf8_decode_lengthstate what then holds. - Existing fixtures for these primitives keep their outcomes.
- A register row and fixture cover this (R3).
Activity
afflom commentedon Nov 3, 2026
Read-only triage confirms #396's slice/join/closed-decision work does not resolve these four dependencies. In current v0.5 and #396, Decimal still couples formatting to the instance containing String.toInt? parsing; String length, split_exact and utf8_decode still call String.length, String.splitOn and String.fromUTF8? respectively. Committed audit records corroborate the choice-bearing dependencies; no fresh runtime result is claimed.
The narrowest next change is isolating language-1.2 format_decimal from parsing evidence (first check whether direct ToString suffices). It needs an actual native-1.2 authoring→verify regression with exact axiom policy, numeric boundaries and unchanged parsing refusals; existing legacy SM-18/19 coverage does not establish this. Keep frozen older-language runtime bytes and coordinate any runtime edit with #396's v0.5 integration wave.
Decoder/split replacements also touch the explicitly pinned §17.12 contract and preservation laws, so a small sample corpus alone is insufficient. String length must retain its character-count contract. No policy weakening, duplicate #396 patch or separate regeneration has been started; #301/#376 remain open.
afflom commentedon Nov 3, 2026
Formatting isolation is now tracked as scoped #434 (SM-39), assigned to the maintainer for release/v0.5. Source analysis found a complete four-source change: the native runtime, both native preservation graphs, and the production certificate constructor. Some Decimal evidence nodes are shared by formatting and parsing, so a runtime-only or global node replacement would break existing parse proofs.
We are preparing the native language-1.2 row/scenario/regression before implementation; legacy SM-19 is insufficient evidence for this policy change. No test, identity regeneration or build is claimed, and no competing writer will start while Host owns the validation phase. This parent remains open for the other primitives and design decisions.