feat: Implement u32_less_than comparison primitive for Aiur#319
Open
arthurpaulino wants to merge 1 commit intomainfrom
Open
feat: Implement u32_less_than comparison primitive for Aiur#319arthurpaulino wants to merge 1 commit intomainfrom
u32_less_than comparison primitive for Aiur#319arthurpaulino wants to merge 1 commit intomainfrom
Conversation
9ac5d73 to
74f3596
Compare
less_than for full Goldilocks field elementsAdd a constrained comparison operation for 32-bit unsigned integers, returning 1 if x < y and 0 otherwise. The algorithm byte-decomposes both operands into 4 little-endian bytes, then computes y - x - 1 via a borrow chain of 8 u8_sub lookups (2 per byte). The final borrow determines the result: no borrow means x < y, borrow means x >= y. No canonicality enforcement is needed since u32 values are below 2^32, which is well within the Goldilocks prime (p = 2^64 - 2^32 + 1), so the 4-byte decomposition is unique. Resources per operation: 24 auxiliaries, 8 Bytes2 lookups, 2 polynomial constraints (one decomposition sum per operand). Changes span Lean (Term, Meta, Check, Bytecode, Compile) and Rust (bytecode, FFI, execute, trace, constraints), plus end-to-end tests.
74f3596 to
376cfb6
Compare
u32_less_than comparison primitive for Aiur
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.
Add a constrained comparison operation for 32-bit unsigned integers, returning 1 if x < y and 0 otherwise. The algorithm byte-decomposes both operands into 4 little-endian bytes, then computes y - x - 1 via a borrow chain of 8 u8_sub lookups (2 per byte). The final borrow determines the result: no borrow means x < y, borrow means x >= y.
No canonicality enforcement is needed since u32 values are below 2^32, which is well within the Goldilocks prime (p = 2^64 - 2^32 + 1), so the 4-byte decomposition is unique.
Resources per operation: 24 auxiliaries, 8 Bytes2 lookups, 2 polynomial constraints (one decomposition sum per operand).
Changes span Lean (Term, Meta, Check, Bytecode, Compile) and Rust (bytecode, FFI, execute, trace, constraints), plus end-to-end tests.