feat: add (little endian) option to Number Notation#22135
Draft
JasonGross wants to merge 1 commit into
Draft
Conversation
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>
Draft
4 tasks
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.
Summary
(little endian)option to theNumber Notationcommand that causes the plugin to build digit lists in little-endian order (least significant digit first)of_luint/to_luintetc.) and uses them in the defaultNumber Notationfornat_scope/hex_nat_scopelia(zify) fails to recognize largenatliterals #22122: with little-endian digit lists,zifycan provide smooth support for large number literalsDetails
When
(little endian)is specified, the OCaml plugin reverses the digit order when constructingDecimal.uint/Hexadecimal.uintterms. For example, the literal123producesD3(D2(D1 Nil))instead ofD1(D2(D3 Nil)).No new Rocq inductive types are needed — we reuse the existing
Decimal.uint/Hexadecimal.uint/Number.uintetc. 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 objectinterp/primNotations.ml{,i}—little_endianfield + reversed digit construction/readingtheories/Corelib/Init/Nat.v—of_luint/to_luint+Number Notationusing little-endianCompanion PR
Stdlib changes: coq/stdlib#XXX
Test plan
opam exec --switch=rocq-dev -- dune build -p rocq-runtimesucceeds123parses correctly,to_luint 123 = D3(D2(D1 Nil)),of_luint (D3(D2(D1 Nil))) = 123🤖 Generated with Claude Code