Skip to content

feat: add (little endian) option to Number Notation#22135

Draft
JasonGross wants to merge 1 commit into
rocq-prover:masterfrom
JasonGross:littleendian-numeral-notation
Draft

feat: add (little endian) option to Number Notation#22135
JasonGross wants to merge 1 commit into
rocq-prover:masterfrom
JasonGross:littleendian-numeral-notation

Conversation

@JasonGross

Copy link
Copy Markdown
Member

Summary

  • Adds a (little endian) option to the Number Notation command that causes the plugin to build digit lists in little-endian order (least significant digit first)
  • Adds little-endian nat conversion functions (of_luint/to_luint etc.) and uses them in the default Number Notation for nat_scope/hex_nat_scope
  • Motivated by lia (zify) fails to recognize large nat literals #22122: with little-endian digit lists, zify can provide smooth support for large number literals

Details

When (little endian) is specified, the OCaml plugin reverses the digit order when constructing Decimal.uint/Hexadecimal.uint terms. For example, the literal 123 produces D3(D2(D1 Nil)) instead of D1(D2(D3 Nil)).

No new Rocq inductive types are needed — we reuse the existing Decimal.uint/Hexadecimal.uint/Number.uint etc. with a different endianness convention.

Files changed

  • plugins/syntax/g_number_string.mlg — grammar rule for (little endian)
  • plugins/syntax/number_string.ml{,i} — parse new option, pass to notation object
  • interp/primNotations.ml{,i}little_endian field + reversed digit construction/reading
  • theories/Corelib/Init/Nat.vof_luint/to_luint + Number Notation using little-endian

Companion PR

Stdlib changes: coq/stdlib#XXX

Test plan

  • opam exec --switch=rocq-dev -- dune build -p rocq-runtime succeeds
  • Manual test: 123 parses correctly, to_luint 123 = D3(D2(D1 Nil)), of_luint (D3(D2(D1 Nil))) = 123
  • CI

🤖 Generated with Claude Code

Add a `(little endian)` option to the `Number Notation` command that
causes the plugin to build digit lists in little-endian order (least
significant digit first). This is motivated by issue rocq-prover#22122: with
little-endian digit lists, zify can provide smooth support for large
number literals.

Changes:
- Grammar: new `(little endian)` modifier for Number Notation
- Plugin: `little_endian` field on notation objects, with reversed
  digit construction (rocquint_of_rawnum_le) and reading
  (rawnum_of_rocquint_le) functions
- Nat.v: add of_luint/to_luint conversion functions and use them
  in the default Number Notation for nat_scope/hex_nat_scope

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coqbot-app coqbot-app Bot added the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant