Skip to content

Reversible arithmetic, point 2 of #336: comparisons - #338

Merged
tatopenn-cell merged 7 commits into
mainfrom
arithmetic-compare
Oct 2, 2026
Merged

tatopenn-cell merged 7 commits into
mainfrom
arithmetic-compare

Conversation

@tatopenn-cell

Copy link
Copy Markdown
Owner

Point 2 of #336. Builds on #337 (contains its commit until #337 is merged).

  • compare_registers(sv, n, a, b, out, op): |a, b, z⟩ → |a, b, z ⊕ [a op b]⟩, inputs unchanged; '<' is the comparator of Cuccaro et al. (quant-ph/0410184, Sect. 4.3), high bit of a − b
  • compare_constant(sv, n, b, c, out, op): classical c; '<' is the most significant qubit after the reverse φADD(c) (Beauregard, quant-ph/0205095, Sect. 2.1, Fig. 4)
  • op: '<', '>', '<=', '>=', '==', '!=' (derived by swapping operands and negating the output)

Tests: Cuccaro comparator circuit (1–3 bits) and Beauregard reverse φADD circuit (c < 2^n) built from engine gates, compared on every basis state; every comparison checked on every basis state; superposition gets entangled with the output.

Docs: Step 5 on api/arithmetic.md, nav label, README line.

@codecov

codecov Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.61111% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
dense_evolution/circuits/arithmetic.py 98.57% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@tatopenn-cell
tatopenn-cell merged commit 6019020 into main Oct 2, 2026
9 checks passed
@tatopenn-cell
tatopenn-cell deleted the arithmetic-compare branch October 2, 2026 13:36
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