Open
Conversation
Self-contained TLA+ encoding of the Quantum Arithmetic (QA) generator algebra and its axiom system. Seven named temporal invariants (A1, A2, S1, S2, T1, T2, NT); six have paired non-vacuity counterexample specs. - QuantumArithmetic.tla: sigma/mu/lambda_k with paired failure actions and absorbing-stutter on fail; 90 init / 374 distinct at CAP=20. - QuantumArithmeticAxioms.tla: EXTENDS base; adds observer-layer vars (obs_float, obs_cross_count) + Project action + the seven axiom invariants. 470 distinct at CAP=20; 686 distinct at CAP=24. - Six negative specs, one per runtime-checkable invariant, each producing a minimal 2-state counterexample. MIT license. Reproduces in <30 s wall-time on a 4-core workstation with tla2tools.jar. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Will Dale <th3r3dbull@gmail.com>
Collaborator
|
Thank you for your contribution! Below are a few questions that arose after reading your modules – most of them reflect me being not at all familiar with Quantum Arithmetic:
Once more, these are just questions from my side. Other maintainers may have different comments. |
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.
Quantum Arithmetic — Axiom System as TLA+ Temporal Invariants
A self-contained TLA+ specification of the Quantum Arithmetic (QA)
generator algebra, with its six compliance axioms plus Theorem NT
(Observer Projection Firewall) encoded as TLA+ temporal invariants over
the reachable state graph. Each runtime-checkable invariant has a paired
non-vacuity spec that produces a minimal counterexample, mirroring the
proof-pair discipline common in the Paxos / distributed-snapshot
exemplars elsewhere in this corpus.
The package is self-contained: no external dependencies beyond the
TLA+ standard modules (
Naturals,Integers,TLC). Reproducing everyresult requires only
tla2tools.jar.Why this might be interesting to TLA+ users
First-class failure algebra. Failures (
OUT_OF_BOUNDS,FIXED_Q_VIOLATION,ILLEGAL) are modelled as absorbing-stutterstate variables, not silent transition blocks. This gives TLC a
concrete way to measure generator-set differentials on a
failure-class-by-failure-class basis.
Observer-projection firewall as temporal invariant. Theorem NT
of the QA axiom block asserts that the continuous–discrete
boundary is crossed exactly twice per trace (input at
Init, outputat a dedicated
Projectaction). This is encoded here with twoobserver-layer variables (
obs_float,obs_cross_count) and twodistinct invariants:
Inv_T2_FirewallRespected(spatial firewall — observer stateimmutable during discrete evolution)
Inv_NT_NoObserverFeedback(temporal bound — at most twoboundary crossings).
To our knowledge this is the first TLA+ encoding of a
continuous–discrete firewall as a runtime-checkable property.
Axiom hygiene. Six of the seven invariants (A1, A2, S2, T1, T2, NT)
have dedicated non-vacuity counterexample specs, so the positive
result is demonstrably non-vacuous on each axiom. S1 (no
^2operator on state variables) is structural and documented as such.
Duo-modular packing. The
qtag = 24 * phi9(a) + phi24(a)packingputs
qtagin[0, 239]and preserves both the mod-9 and mod-24invariants simultaneously — an efficient hash for TLC's fingerprint
set and a research object in its own right.
Background — one-paragraph QA
Quantum Arithmetic is a modular-arithmetic framework over pairs
(b, e)with derived coordinatesd = b + eanda = b + 2e. Dynamicslive in the discrete integer layer; continuous functions enter only as
observer projections at the input and output boundaries. The system
uses three generator actions:
e → e + 1b ↔ e(b, e) → (k·b, k·e)fork ∈ KSetEach generator is paired with explicit failure actions (
OUT_OF_BOUNDSwhen successor exceeds
CAP,FIXED_Q_VIOLATIONwhen successor breaksduo-modular invariance). The failure states are absorbing — once in a
fail state, the tuple is frozen.
The six compliance axioms are:
b, e ∈ {1..CAP}Inv_A1_NoZero)d = b+e,a = b+2eInv_A2_DerivedCoords)^2operator; useb*bb, e, d, a ∈ NatInv_S2_IntegerState)Inv_T1_IntegerPathTime)Inv_T2_FirewallRespected)Plus Theorem NT (Observer Projection Firewall): boundary crossed
exactly twice per trace, encoded as
Inv_NT_NoObserverFeedback.Module inventory
QuantumArithmetic.tlab, e ∈ 1..CAP).QuantumArithmetic.cfgCAP = 20,KSet = {2, 3}).QuantumArithmeticAxioms.tlaobs_float,obs_cross_count) +Projectaction + the seven axiom invariants.QuantumArithmeticAxioms.cfgQuantumArithmeticAxioms_cap24.cfgQuantumArithmeticAxioms_negative_A1.tlab' = 0, violatesInv_A1_NoZero.QuantumArithmeticAxioms_negative_A2.tlad' ≠ b' + e', violatesInv_A2_DerivedCoords.QuantumArithmeticAxioms_negative_S2.tlab' = "ghost"(non-Nat), violatesInv_S2_IntegerState.QuantumArithmeticAxioms_negative_T1.tlalastMove' = "t_continuous"outside alphabet.QuantumArithmeticAxioms_negative_T2.tlaobs_float' = 42during discrete step.QuantumArithmeticAxioms_negative_NT.tlaobs_cross_countpast 2.QuantumArithmeticAxioms_negative_*.cfgLICENSENOTICE.md8 TLA+ modules + 9 configs + 1 README + 1 LICENSE + 1 NOTICE = 20 files
(plus
manifest.json).Reproduction
From this directory, with
tla2tools.jaron the path (referenced hereby
$TLA2TOOLS):Expected results
QuantumArithmetic@ CAP=20QuantumArithmeticAxioms@ CAP=20QuantumArithmeticAxioms@ CAP=24QuantumArithmeticAxioms_negative_A1Inv_A1_NoZeroviolated (b'=0 counterexample)QuantumArithmeticAxioms_negative_A2Inv_A2_DerivedCoordsviolated (d'=99 ≠ b'+e')QuantumArithmeticAxioms_negative_S2Inv_S2_IntegerStatefails to evaluate (b'="ghost" — string ∉ Nat)QuantumArithmeticAxioms_negative_T1Inv_T1_IntegerPathTimeviolated (lastMove' out of alphabet)QuantumArithmeticAxioms_negative_T2Inv_T2_FirewallRespectedviolated (obs_float' modified by QA step)QuantumArithmeticAxioms_negative_NTInv_NT_NoObserverFeedbackviolated (3rd boundary crossing attempted)All counterexamples are minimal (Init + 1 step). The wall-time budget on
a 4-core commodity workstation (OpenJDK 21 + TLC) is under 30 s for
the full package including the scale test.
Note on the S2 counterexample. TLC reports
Error: Evaluating invariant Inv_S2_IntegerState failed(rather than themore familiar "Invariant X is violated") because the successor-state
assignment
b' = "ghost"produces a state on which the invariant'sb \in Natpredicate is undefined — TLC cannot decide whether a stringis a natural number. This is the expected outcome for a type-domain
violation: the invariant fails, but via an evaluation error rather than
a boolean violation. Either way, the negative spec demonstrates S2 is
non-vacuous.
Design notes
Why
EXTENDSrather than a single monolithic moduleQuantumArithmeticAxioms.tlaEXTENDS QuantumArithmeticso that thegenerator algebra and the axiom invariants are separable concerns. This
matches the upstream convention in
specifications/Paxos/(wherePaxos.tlacomposesConsensus.tla) and lets the base be reused byother extension modules (e.g., alternative axiom systems, or
domain-specific refinements at larger
CAP).The
Projectaction and the observer-layer variablesThe base spec has no notion of a continuous/observer layer.
QuantumArithmeticAxioms.tlaintroduces two variables:obs_float ∈ 0..(3·CAP)— observer scalar. Set to0atInit(symbolic "input seed") and updated exactly once by the
Projectaction to the current value of the QA coord
a.obs_cross_count ∈ {1, 2}— number of boundary crossings so far.1atInit(input crossing);2afterProjectfires (outputcrossing). Reaching
3would indicate observer-layer feedback intothe discrete layer, which Theorem NT forbids.
The extended
Next_exthas three disjuncts:QA_firewalled: a base-specNextmove PLUSUNCHANGED <<obs_float, obs_cross_count>>. Only fires whenobs_cross_count = 1.Project: the output boundary crossing.PostProjectStutter: absorbing afterProject.Why
Inv_S1_NoSquareOperatorisb * b >= 0TLA+ has no native
^2or**operator on state variables in therelevant modules; S1's "no libm-ULP-drift-prone squaring" rule is
syntactic over module text, not a state predicate over reachable
values. To keep all seven axioms as named invariants in a single
consistent stack,
Inv_S1_NoSquareOperatoris defined as the triviallytrue state predicate
b * b >= 0. This locks in theb*bconvention atthe module level (any future author introducing
b^2would diff againstthis predicate) and satisfies TLC's preference for state invariants to
reference at least one state variable. The S1 enforcement at the text
level is handled by an external linter in the source repo.
References
Primary TLA+ references:
on Programming Languages and Systems 16(3), 872–923. DOI:
10.1145/177492.177726.
for Hardware and Software Engineers. Addison-Wesley.
ISBN 978-0-321-14306-8.
Vanzetto, H. (2012). TLA+ Proofs. FM 2012 (LNCS 7436), 147–154.
License
MIT — see
LICENSE. Suggested citation form inNOTICE.md.