Skip to content

Models of the operations other than strings that agree with each language - #172

Merged
conao3 merged 88 commits into
unify-embedfrom
unify-s2
Dec 2, 2026
Merged

conao3 merged 88 commits into
unify-embedfrom
unify-s2

Conversation

@conao3

@conao3 conao3 commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Make every non-string operation that the seven translates accept either return the same value and the same failure as the language for every value of the model's types, or leave the function unextracted.

  • Each language compares its operations with the language on boundary values (Rust tests/ops, Python tests/ops, TypeScript test/verify/values.mjs, Clojure core_model_test/refused_test, PHP tests/Verify/operations.php, Go testdata/verify/operations, C maint/C/test-translate.sh), and has fixtures of the refused forms with their reasons.
  • Proofs of false statements that passed before now fail or are refused: overflow and undefined indexes in PHP ensures, endless loops proved by rfl (Python, PHP, TypeScript), assert under python -O, reference equality of TypeScript arrays, FMA contraction in Go, enumerators and -fshort-enums in C, Drop, cfg! and get_mut(i..) in Rust, Option Bool truthiness and NaN keys in Clojure, and names of functions that capture Lean names in every language.
  • Leanfran.Check leaves a function unextracted when a Lean block or another module of the project changes how Lean reads its translation: a macro or an elaborator for syntax of Lean, a syntax that starts like a syntax of Lean, or an instance that replaces a coercion of Lean (tests/lean/LeanfranTest/Syntax.lean).
  • The random tests of the seven languages draw the ends of the integer types, 2^31, 2^53±1, 2^63, NaN, ±0, ±Inf, empty and repeated elements and equal arguments, and fixtures that differ from their spec only at such a value report mismatch with the default runs and seed.
  • Validators judge with Lean's meaning: TypeScript's lengths count code points with zod, valibot and arktype, JSON Schema bounds above 2^53 and of fixed-width literals are exact in C, Go, TypeScript and PHP, and the UInt64/USize pattern of C, Go and TypeScript accepts exactly the strings that their decoders read.

Assisted-by: Claude Code

conao3 added 30 commits December 2, 2026 01:39
… them, and refuse functions that the flags, attributes, or pragmas change
…nd compare the models of the operations with JavaScript
…conditions

A literal of a fixed-width type wraps around as in Lean, and the bounds beyond 2^53 are exact.
- float64 products outside float64(...) and sums of unrounded operands are
  refused, since Go fuses them on arm64 and with GOAMD64=v3.
- Fields of the Lean types Char, Fin, USize, ISize, and of definitions that
  unfold to a type, are read as values of the Go type.
- Models name constants from the root, so that a Go function cannot take the
  place of one, and a method is no enum constructor.
- Constants and types that another build may define otherwise are refused, and
  a function that names a declaration in a file with build constraints
  replaces no spec.
- All panics and endless loops are one failure, since Go leaves their order
  open.
…om tests, and test functions that differ from their spec there
…tegers in random tests, and tell 0.0 from -0.0
conao3 added 28 commits December 2, 2026 07:51
…he decoders read, and read integral JSON numbers

A UInt64 and a USize are the pattern of the decimals of their range and of their
conditions, as in C. The decoders read only those decimals, and read 1.0 and 1e2 as
integers, as JSON Schema does. TypeScript keeps the bounds of the type where a
condition is looser, and wraps the literals of its fixed-width types.
…ince a block may not add coercions between standard types
…15186-thr_h7fkgc2qif

# Conflicts:
#	docs/c-development.md
#	docs/c-guide.md
#	langs/C/LeanC/Embed/Verify.lean
#	langs/C/LeanC/Verify/Translate.lean
#	langs/C/tests/verify/translation/unsupported.c
#	langs/C/tests/verify/translation/unsupported.txt
#	langs/Rust/crates/leanfran-macros/src/model.rs
#	langs/Rust/tests/verify/test.sh
@conao3
conao3 merged commit b8b74e6 into unify-embed Dec 2, 2026
33 of 34 checks passed
@conao3
conao3 deleted the unify-s2 branch December 2, 2026 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant