Skip to content

Stabilizer phases 1 4#3

Open
mbahram wants to merge 1682 commits into
KirillBelovTest:mainfrom
WolframResearch:stabilizer-phases-1-4
Open

Stabilizer phases 1 4#3
mbahram wants to merge 1682 commits into
KirillBelovTest:mainfrom
WolframResearch:stabilizer-phases-1-4

Conversation

@mbahram
Copy link
Copy Markdown
Contributor

@mbahram mbahram commented May 2, 2026

Summary

Rebuild the Stabilizer subsystem of QuantumFramework into a 15-file
Kernel/Stabilizer/ subdir, with 5 phases of feature work and a
185-test suite (8 tiers; code, structural, physics, integration,
hygiene, symbolic, frame, graph state). Includes user-facing
documentation under OngoingProjects/Stabilizer/Documentation/.

What changed

Kernel (QuantumFramework/Kernel/Stabilizer/, 15 files):

  • The 493-LOC PauliStabilizer.m monolith is split into one file per
    concern (PauliStabilizer, Constructors, NamedCodes, GateUpdates,
    Measurement, Properties, Conversions, Compose, Synthesis (in
    Conversions), RandomClifford, Formatting, SymbolicMeasure,
    StabilizerFrame, InnerProduct, PauliMeasure, GraphState).
  • Phase 2 hygiene: PauliStabilizer::nonclifford message replaces silent
    passthrough; MakeBoxes[..., TraditionalForm] is OOM-gated on Qubits ≤ 8;
    RandomClifford promoted to public symbol.
  • Phase 3 SymPhase (FangYing23): StabilizerMeasure, SubstituteOutcomes,
    SampleOutcomes allocate fresh \[FormalS][k] outcome symbols.
  • Phase 4 Frame + Inner Products + Pauli measurement (GarMar15,
    GarMarCro12, PatGuh26): StabilizerFrame head, StabilizerInnerProduct,
    StabilizerExpectation, ps["M", "XZZXI"].
  • Phase 5 Graph state (AndBri05): GraphState, LocalComplement.
  • Quiet cleanup: 15 pre-existing Quiet[...] calls across QF kernel
    replaced with explicit handling or message-tag-restricted forms.

Public API added to PacletInfo.wl Symbols + Usage.m (10 new):
PauliStabilizer, RandomClifford, StabilizerMeasure,
SubstituteOutcomes, SampleOutcomes, StabilizerFrame,
StabilizerInnerProduct, StabilizerExpectation, GraphState,
LocalComplement.

Tests (Tests/PauliStabilizer.wlt, 8 tiers, 185 tests):
Tier 1 code · Tier 2 AG-symplectic invariants · Tier 3 physics
(textbook stabilizer states, 5-qubit code distance d=3, Steane
logical X-bar/Z-bar (anti)commutation, 5Q syndrome uniqueness across
all 15 single-qubit Pauli errors, Heisenberg conjugation) · Tier 4
QF integration · Tier 5 Phase-2 hygiene · Tier 6 Phase-3 symbolic

  • KNOWN LIMITATIONS · Tier 7 Phase-4 frame/IP/measure · Tier 8
    graph state.

Documentation (OngoingProjects/Stabilizer/Documentation/):

  • API.md — per-function reference for all 10 public symbols
    (49 verified code blocks).
  • synthesis-implementation.md — capability tour through
    package-design-synthesis.md §1–§11 with 26 verified blocks.
  • ROADMAP.md — 21 partial / deferred / known-bug items with
    concrete next steps.
  • verify-API.wls, verify-synthesis-implementation.wls
    re-runnable wolframscript verifiers; output should match the
    embedded "Verified output" blocks in the corresponding doc.

Why

Original Stabilizer kernel was a 493-LOC monolith with no tests, no
docs, several typos (duplicate "SteaneCode", "QuantumSttate" alias),
silent-failure on unknown gates, and MakeBoxes that OOMed for
n > 10. The audit at OngoingProjects/Stabilizer/paulistabilizer-source-audit.md
identifies all the gaps; the synthesis at
OngoingProjects/Stabilizer/package-design-synthesis.md distills
target capabilities from 28 papers; this PR closes 5 of the 10 v1
priorities from the synthesis (others tracked in ROADMAP).

Test plan

  • wolframscript -f Tests/RunTests.wls returns 217/217 passing.
  • wolframscript -f OngoingProjects/Stabilizer/Documentation/verify-API.wls
    runs all 56 code blocks cleanly.
  • wolframscript -f OngoingProjects/Stabilizer/Documentation/verify-synthesis-implementation.wls
    runs all 26 code blocks cleanly.
  • ?PauliStabilizer returns a usage message.
  • QuantumCircuitOperator[{"H" -> 1, "CNOT" -> {1, 2}}][Method -> "Stabilizer"]
    still works (regression test for the latent Automatic-pattern bug fixed in this PR).

Notes for reviewer

  • ROADMAP.md tracks 21 follow-up items, including a known recursion bug
    in ps["Dagger"]["Dagger"] (latent in Phase 1; tracked as A.3) and
    the GarMarCro12 closed-form inner product (A.1) that would replace
    the current O(2ⁿ) direct-vector fallback. None of these are
    blocking — current behavior is correct, just direct-vector for n > 8.
  • OngoingProjects/Stabilizer/tex/ (~28 paper TeX sources) and
    OngoingProjects/Stabilizer/External Packages/ (QuantumClifford.jl,
    Stim — embedded git repos) are excluded via local .gitignore;
    re-fetch instructions in paper-fetch-report.md.
  • Commit 9b3b1ec4 on this branch (QSVT notebook + audit notes + image)
    is unrelated to the Stabilizer work — it landed during a parallel
    sync. Carry it through or rebase out, your call.

mbahram and others added 30 commits October 11, 2025 16:27
major rev to quantum computing intro book
major rev quantum intro course
major rev quantum intro course
majore rev intro quantum course
major rev intro quantum course
Adds the dimension argument to the `QuantumOperator` constructor when creating inverse operators in `QuantumTensorNetwork`.
This ensures that the dimension is correctly specified for these operators.

Adds check to `QuditBasis` construction, ensuring a valid basis.
major rev quantum intro course
updating the content for intro course to quantum
minor revision
Updates TensorNetwork to use integer indices instead of string indices.
This change improves performance and consistency.

Also, updates the Cotengra paclet dependency to version 0.4.
Improves the performance of generating random quantum states by directly accessing the matrix data, avoiding unnecessary object construction.
more cleaning up, still some issues with JD
Corrects an issue where the wrong dimensions were used
when creating inverse `QuantumOperator` instances for
non-computational inputs/outputs within the tensor network.

It now uses `#["InputDimensions"]` and `#["OutputDimensions"]`
to ensure correct dimensions.
cleaning up, JD issue is resolved
Ensures that the `QuantumOperator` constructor receives explicit basis
information when creating inverse operators for computational circuits
in `QuantumTensorNetwork`. This improves the robustness and clarity
of the tensor network construction process.
mbahram added 30 commits May 6, 2026 16:53
Introduce the Choi-tableau CliffordChannel head per Yashin25 (arxiv:
2504.14101) Section 2.3. A Clifford channel from |A| qubits to |B|
qubits is encoded as

  CliffordChannel[<|
    UA           -> k * 2|A| bit matrix,
    UB           -> k * 2|B| bit matrix,
    c            -> length-k bit vector (signs),
    InputQubits  -> nA,
    OutputQubits -> nB,
    Source       -> origin tag
  |>]

Each row [u_A | u_B | c] encodes a Pauli superoperator
  Pi(u_A | u_B | c)[rho_A] = (-1)^c * 2^|A| * Tr[rho_A P(u_A)] P(u_B)
and the channel is the (1/2^{|A|+|B|}) sum of these rows.

Phase 8.1 ships:
  - Public CliffordChannel head (PacletInfo + Usage entries).
  - PackageScope predicate CliffordChannelQ.
  - Constructors:
      CliffordChannel[ps_PauliStabilizer]   -- pure-state-as-channel:
          nA=0, UB = stabilizer rows, c from signs.
      CliffordChannel[Identity, n]          -- identity channel on n qubits:
          UA = UB = I_{2n}, c = 0.
  - Accessors: UA, UB, c, InputQubits, OutputQubits, Rank, Tableau
      (assembled [UA | UB | c]).
  - Composition stub cc1[cc2] -> Failed with CliffordChannel::compose
    message; Phase 8.2 will implement vector-space intersection per
    Yashin25 Section 3.2.

Tests: 18 in Tests/CliffordChannel.wlt covering predicate validity,
identity-channel UA/UB/c/Rank, PauliStabilizer-as-Choi-tableau (1Q,
5Q-code, Bell-state shape), Tableau accessor dimensions, composition
stub message.

Total suite: 334/334 passing (was 316; +18 new CliffordChannel tests).

ROADMAP B.2 updated: Phase 8.1 DONE, Phase 8.2 (composition + Pauli-
channel round-trip + cc[ps] state-evolution) listed as next milestone.

This branch (claude/phase8-clifford-channel) stacks on
claude/phase7-hybrid-interop (Phase 7.1 + 7.2) which stacks on
stabilizer-phases-1-4 (Phase 6 + 6.5).
Adds 28 new tests across HybridInterop.wlt and CliffordChannel.wlt
to broaden coverage of the consolidation+interop work shipped in
Phases 7.1, 7.2, and 8.1. No kernel changes.

Tests/HybridInterop.wlt (15 -> 29):
  TIER E -- Pauli-string QMO on named QEC code states:
    Phase7-QMO-Steane-Stabilizer-Deterministic
    Phase7-QMO-GHZ3-Stab-ZZI-Deterministic
    Phase7-QMO-GHZ3-Stab-XXX-Deterministic
    Phase7-QMO-GHZ3-Anticommuting-NonDeterministic
  TIER F -- Channel edge cases:
    Phase7.2-QC-BitFlip-zero-IdentityNoOp
    Phase7.2-QC-BitFlip-one-FullX
    Phase7.2-QC-BitFlip-Symbolic-ProbSumToOne
    Phase7.2-QC-PhaseFlip-Z-on-zero-StaysZ
    Phase7.2-QC-BitFlip-on-Bell-Q1-NumBranches
    Phase7.2-QC-Depolarizing-IdentityBranchUnchanged
  TIER G -- QMO direct equivalence to ps[M, ...]:
    Phase7-QMO-vs-PS-M-Equivalence-ZZ
    Phase7-QMO-vs-PS-M-Equivalence-Random3Q-12reps
  TIER H -- QMO + StabilizerFrame fallback:
    Phase7-QMO-on-StabilizerFrame-FallbackEvaluates
  TIER I -- Pauli sign-prefix label edge case:
    Phase7-QMO-NegativePauli-Label-NotStringForm
      (documents that QuantumOperator[-pauli] produces a Times[]
       label, not a string; the Phase 7.1 fast path correctly skips
       it and falls back. Phase 7.3 may extend the gate.)

Tests/CliffordChannel.wlt (18 -> 32):
  TIER E -- More PauliStabilizer-as-CliffordChannel cases:
    Phase8.1-Tableau-Dimensions-Steane
    Phase8.1-Steane-Rank
    Phase8.1-9QubitCode-Rank
    Phase8.1-RandomClifford-RankMatchesQubits
  TIER F -- Identity-channel sanity for varied n:
    Phase8.1-Identity-Tableau-Dimensions-5q
    Phase8.1-Identity-Invariants-Across-n
  TIER G -- Choi-tableau invariants on UB side:
    Phase8.1-UB-Rank-MatchesGenerators
    Phase8.1-UB-ShapeSanity
  TIER H -- Properties contract:
    Phase8.1-Properties-Contains-Core
    Phase8.1-Source-Tag-PS
    Phase8.1-Source-Tag-Identity
  TIER I -- Predicate idempotence:
    Phase8.1-Predicate-Idempotent
  TIER J -- Composition stub firings:
    Phase8.1-Compose-Stub-Identity-on-State
    Phase8.1-Compose-Stub-State-on-Identity

Total suite: 362/362 passing (was 334).
…s-package tests (+100 tests)

Three new test files cover (1) outcome-correctness against textbook
physics, (2) cross-package validation against Stim, and (3) cross-
package validation against QuantumClifford.jl.

Tests/Correctness_TextbookResults.wlt (41 tests) verifies numerical
and set-theoretic outcomes (not just internal consistency) against
established stabilizer-formalism literature:
  Bell-state correlations (TIER A): exp values of XX, YY, ZZ, etc.
  GHZ-3 correlations (TIER B): XXX, ZZI, IZZ stabilizer expectations.
  5-qubit code (TIER C): all stabilizers give +1; all 15 single-qubit
    Pauli errors produce 15 distinct syndromes (defining property of
    a [[5,1,3]] code).
  Steane / Shor codes (TIER D, E): all stabilizers give +1 on |0_L>.
  Cluster-state stabilizers (TIER F): K_i = X_i tensor prod Z_j over
    neighbors j -- linear chain match + circuit/GraphState round-trip.
  Inner products (TIER G): Bell self = 1, |Phi+|Phi-> = 0, |0|0> = 1,
    |0|1> = 0, |0|+> = 1/sqrt(2).
  Heisenberg-picture conjugation (TIER H): HZH=X, SZS=Z, SXS=Y, etc.
  Got97 stabilizer-group properties (TIER I): pairwise commutation
    for named codes.
  AarGot04 measurement statistics (TIER J): all stabilizers
    deterministic on encoded |0_L>.
  Channel-mixture averages (TIER K): BitFlip / PhaseFlip / Depolarizing
    average eigenvalues match (1 - 2p) / (1 - 2p) / (1 - p) on Pauli
    targets.

Tests/CrossPackage_Stim.wlt (44 tests) cross-validates against Stim
(Gidney / Google Quantum AI, arxiv:2103.02202):
  TIER A-C: doc-derived gate-conjugation rules from
    External Packages/Stim/doc/gates.md (Stabilizer Generators
    sections) -- I, X, Y, Z, H, S, S_DAG, V (=SQRT_X), SQRT_X_DAG,
    plus CNOT / CZ / SWAP / Bell / GHZ multi-step circuits.
  TIER D-F: Bell, 5Q-code, random Clifford uniformity.
  TIER G: live Stim fixture comparison via
    Tests/fixtures/generate_stim_fixtures.py (uses
    stim.TableauSimulator); 11 cases (Bell phi+/phi-, GHZ-3,
    cluster-4, single-qubit eigenstates, CNOT^2, SWAP after H).
    Fixture JSON committed so the WL tests run without stim
    installed.

Tests/CrossPackage_QuantumClifford.wlt (15 tests) cross-validates
against QuantumClifford.jl (Krastanov / QuantumSavory):
  TIER A: Pauli arithmetic identities from test_paulis.jl
    (X*Z = -iY, Z*X = +iY, XZ = X tensor Z, prodphase
    correspondences).
  TIER B: comm() relation -- XX-YY commute, XZ-YZ anticommute.
  TIER C: random_stabilizer pairwise commutation + squares-to-I.
  TIER D: tensor-product semantics.
  TIER E: inner-product values.
  TIER F: package-on-disk smoke check (live JC.jl fixtures
    deferred until Julia is installed; pattern documented).

Tests/fixtures/ (new directory):
  generate_stim_fixtures.py -- Python script using stim 1.15.0 to
    dump canonical TableauSimulator outputs.
  stim_fixtures.json -- committed snapshot of 11 cases. Re-run the
    .py script when adding cases.

Test totals: 462/462 passing (was 362; +100 new tests).
  PauliStabilizer.wlt:           249
  QuantumDistance.wlt:            32
  Roundtrips.wlt:                 20
  HybridInterop.wlt:              29
  CliffordChannel.wlt:            32
  Correctness_TextbookResults:    41  (NEW)
  CrossPackage_Stim:              44  (NEW)
  CrossPackage_QuantumClifford:   15  (NEW)
…composition

Phase 7.3 (label-detection extension):
  Extended stabilizerPauliLabelFromQMO in HybridInterop.m to recognize
  three additional label expressions beyond plain Pauli strings:
    Superscript[X|Y|Z|I, CircleTimes[m]]   -> "XXXX..."  (m letters)
    Times[-1, Superscript[...]]            -> "-XXXX..."
    Times[-1, str matching Pauli]          -> "-" <> str
  This routes QMOs built as QuantumOperator[-"XX"] (label is
  -Superscript[X, CircleTimes[2]], not a string) through the AG
  tableau fast path. PauliX/PauliY/PauliZ Basis labels still fall
  back (they are Symbol heads, not Pauli expressions).

Phase 8.2 (Choi-tableau composition + state evolution + QC interop):
  Implement CliffordChannel composition cc1[cc2] = cc1 . cc2 via
  Boolean linear algebra per Yashin25 Section 3.2:

    1. Stack cc2.UB (k1 rows) above cc1.UA (k2 rows) into
       (k1+k2) x 2nB matrix.
    2. Compute LEFT null space lambda such that
       lambda . stackedB = 0 (mod 2), equivalent to
       NullSpace[Transpose[stackedB], Modulus -> 2].
    3. For each kernel vector lambda = (lam1, lam2):
        UA = lam1 . cc2.UA  (mod 2)
        UC = lam2 . cc1.UB  (mod 2)
        c  = lambda . concat(cc2.c, cc1.c)  (mod 2)
    4. Drop trivial all-zero rows; deduplicate.

  Phase-correction beta term (Yashin25 row-summation Eq) deferred
  to Phase 8.3; simple XOR is correct for deterministic channels.

  Also adds:
    cc[ps_PauliStabilizer] state evolution: identity, state-prep,
      and compose-and-convert paths. Tested via stabilizer-set
      preservation on Bell, |00>, |000>, 5Q-code.
    CliffordChannel[qc_QuantumChannel]: detects deterministic
      single-Pauli channels via label; emits stochastic notice
      and returns identity-shaped placeholder for BitFlip etc.
    cliffordChannelToPauliStabilizer helper: state-prep Choi
      tableau back to PauliStabilizer head.

Tests added:
  Tests/HybridInterop.wlt: 5 new in TIER J/K (Phase 7.3 detection
    of -XX/ZZZ; deterministic measurement on Bell; PauliX-Basis
    falls through). 34 total.
  Tests/CliffordChannel.wlt: 9 new in TIER K-O (composition
    Identity-on-State preserves UB+c, associativity on Bell,
    rank-preservation across n, cc[ps] state evolution for
    Identity_2/3/5 on Bell/|000>/5Q, QC->CC stochastic notice,
    Compose-Identity-on-RandomCliffordState valid+rank=3). 41 total.

Total suite: 476/476 passing (was 462; +14 new tests).

ROADMAP updated:
  Phase 7.3 DONE; Phase 7.4 (real StabilizerFrame decomp +
    matrix-iteration detector) tracked next.
  B.2: Phase 8.1+8.2 DONE; Phase 8.3 (Yashin25 row-sum beta phase
    correction for stochastic channels) tracked.
…se tracking in CliffordChannel composition

Phase 7.4 (HybridInterop):
- Extended stabilizerPauliLabelFromQMO with stabilizerPauliFromMatrix
  fallback that iterates 4^n * {+1, -1} candidates against the QMO's
  MatrixRepresentation when the symbolic label is None or non-Pauli.
- Default cap $stabilizerPauliMatrixSearchMaxQubits = 4 keeps the
  search bounded; tunable via Block for tests.
- Routes QuantumOperator[matrix] QMOs through the AG fast path.

Phase 8.3 (CliffordChannel composition phase tracking):
- Added stabilizerRowSumAGPhase: cumulative AG g-function phase mod 4
  for F2-summing Pauli rows.
- Added stabilizerContractionPhase: |Phi+>_BB contraction sign
  (-1)^(sum_q x_q z_q) for the combined u_B Pauli (Y_B^T = -Y_B).
- Composition c_new now = (lambda . cConcat) XOR (rowSumPhase +
  contractionPhase) / 2 mod 2.
- This makes S^2 = Z (X-row picks up sign), S^3 = S-inverse (X to -Y)
  flow correctly through cc[ps] state evolution.
- Rewrote cliffordChannelToPauliStabilizer using the string-list
  PauliStabilizer constructor (handles single-qubit case correctly).

Tests:
- CliffordChannel.wlt: 41 to 76 tests (TIER P/Q/R/S/T: row-sum AG
  phase helper, contraction phase helper, S/H/X compositions with
  state evolution physics, random-circuit cross-validation against
  PauliStabilizer evolution).
- HybridInterop.wlt: 37 to 52 tests (TIER L: matrix-iteration
  detector on Pauli matrices, multi-qubit XZ/YY, Hadamard/projector
  rejection, fast-path verification on Bell, max-qubit cap test).
- Path-resolution fixes for CrossPackage_Stim.wlt and
  CrossPackage_QuantumClifford.wlt (use Directory[] fallback when
  $InputFileName isn't set under TestReport.

529/529 tests passing.
EOF
)
…Tests/Stabilizer/

WL-idiom audit (per /Users/mohammadb/.claude/skills/wl-native-style/SKILL.md):

- Constructors.m
  - agPickIndependent: replaced AppendTo + Break with Internal`Bag +
    Catch/Throw. Removed hanging Module variables i, candidate, augmented.
  - agExtendToSymplecticBasis: converted Do + AppendTo into Fold over
    Range[n]. Removed hanging Module variables.
- Conversions.m
  - ps["Circuit"] AG-canonical synthesis: replaced gates = {} +
    AppendTo[gates, gate] with Internal`Bag + StuffBag. Genuinely sequential
    state-machine algorithm so Do remains; only the gate-accumulation
    pattern changes.
- CliffordChannel.m
  - stabilizerRowSumAGPhase: replaced nested Do over selected rows / qubits
    with Fold + vectorized MapThread per qubit.
- Measurement.m
  - rowsum: replaced Total @ Table[..., {j, n}] with Total @ MapThread over
    the X / Z bit axes.
- PauliMeasure.m
  - ps["M", pauliString]: removed unused Module variables (recoverable,
    groupSign, postPs, newRowSign, newGensArr) flagged by audit. Refactored
    the anticommuting-row sign update from imperative Do + Module mutation
    to a vectorized MapAt + Thread + ReplacePart pattern.

No Do / For / While / AppendTo remains except for genuine state-machine
algorithms (AG circuit synthesis, AG measurement, RandomClifford Mallows
sampler) where the wl-native-style skill explicitly endorses the pattern.

Tests reorganized:

- Created Tests/Stabilizer/ subdirectory.
- Moved 7 stabilizer-related test files via git mv (preserves history):
  PauliStabilizer.wlt, CliffordChannel.wlt, HybridInterop.wlt,
  Roundtrips.wlt, Correctness_TextbookResults.wlt, CrossPackage_*.wlt.
- Moved Tests/fixtures/ to Tests/Stabilizer/fixtures/ (Stim JSON).
- Tests/QuantumDistance.wlt remains at top level (general QF, not
  stabilizer-specific).
- Tests/RunTests.wls now recurses (FileNames *.wlt with Infinity).
- Path-resolution fix in CrossPackage_*.wlt for the new layout.

New comprehensive coverage matrix:

- Tests/Stabilizer/AuditMatrix.wlt -- 155 tests across 15 TIERs:
  TIER 1 every PauliStabilizer constructor input form (string list,
    sign-prefixed, stab+destab halves, integer register, named codes,
    Random named pattern, QCO, QO, QS, association forms);
  TIER 2 every property in ps["Properties"] (all 30+);
  TIER 3 every Clifford gate method (H, S, S-dag, X, Y, Z, V, V-dag,
    CNOT/CX, CZ, SWAP, Permute, PadRight/Left, Dagger/Inverse, op->order);
  TIER 4 non-Clifford P[theta] / T / T-dag returning StabilizerFrame;
  TIER 5 measurement (Z-basis, Pauli-string, multi-qubit, SymbolicMeasure,
    SubstituteOutcomes, SampleOutcomes);
  TIER 6 InnerProduct + Expectation (Phase 6.5 demoted ops);
  TIER 7 composition + tensor product;
  TIER 8 StabilizerFrame constructors / properties / methods;
  TIER 9 GraphState constructors / properties / conversion;
  TIER 10 LocalComplement involutivity + graph / GraphState dispatch;
  TIER 11 CliffordChannel head / predicate / accessors / composition /
    cc[ps] state evolution;
  TIER 12 hybrid interop (qmo[ps] Pauli fast path, Phase 7.4 matrix
    detector, named Pauli channels);
  TIER 13 AG symplectic invariant on circuit-built fixtures;
  TIER 14 cross-package comparison vs live Stim fixtures + QC.jl
    canonical agPhase ZZZ * XXX = -i YYY pattern;
  TIER 15 round-trip exact-equality matrix per Phase 5c contract.

Test counts:

- Pre-audit: 529 / 529.
- Post-audit: 684 / 684 (155 new audit-matrix tests, plus the existing
  529 unchanged).
…ation + verify-*.wls

Rewrite API.md from scratch (~1100 lines -> ~750 lines) with the current
public surface after Phases 1-8.3 + WL-idiom audit:

- 5 top-level public symbols: PauliStabilizer, StabilizerFrame, GraphState,
  LocalComplement, CliffordChannel (was 4 -- CliffordChannel was missing).
- Every constructor input form documented with a code example.
- Every property in Properties.m grouped (Shape / Signs / Bit views /
  Stabilizer-Destabilizer slices / Pauli-string lists / Display /
  Materialization).
- Every Clifford and non-Clifford gate method documented.
- Symbolic measurement (Phase 3 demoted, Phase 6 method-grade).
- Inner product + Expectation (Phase 6.5 method-grade).
- StabilizerFrame full surface.
- GraphState + LocalComplement.
- CliffordChannel (Phase 8.1 / 8.2 / 8.3): constructors, properties,
  composition algorithm with phase tracking + contraction sign, state
  evolution, helpers.
- Hybrid interop (Phase 7): qmo[ps], qmo[sf], qc[ps], qc[sf]; the four
  Pauli-label detection paths (string, Times[-1, ...], Superscript,
  matrix-iteration Phase 7.4); named Pauli channels.
- Cross-package fixtures (Stim live JSON + QC.jl hand-coded canonical).
- Updated quick-reference card.
- References: 9 paper anchors with arxiv IDs.

Delete:

- synthesis-implementation.md (931 lines): the section-by-section
  capability tour from the original 28-paper synthesis. Now redundant with
  ROADMAP.md (status tracker) + Tests/Stabilizer/AuditMatrix.wlt
  (executable verification).
- verify-API.wls (546 lines): re-ran 49 code blocks from API.md with
  Print-output diff. Superseded by Tests/Stabilizer/*.wlt files which use
  VerificationTest with proper assertions and run under TestReport.
- verify-synthesis-implementation.wls (378 lines): same justification,
  for the now-deleted synthesis-implementation.md.

Net: 1855 lines of stale content removed. Documentation/ now contains
exactly 3 markdown files: API.md (per-function reference), ROADMAP.md
(deferred items), post-mortem-phase-5c.md (Phase 5c learning record).

ROADMAP.md and post-mortem-phase-5c.md updated to remove dangling
references to the deleted files.

Tests: 684 / 684 passing.
Renames (lowercase + drop redundant qualifier):

- OngoingProjects/Stabilizer/Documentation/API.md -> api.md
- OngoingProjects/Stabilizer/Documentation/ROADMAP.md -> roadmap.md
- OngoingProjects/Stabilizer/Documentation/post-mortem-phase-5c.md -> postmortem.md

All cross-references updated repo-wide (api.md, roadmap.md, postmortem.md,
paulistabilizer-source-audit.md). Inline mentions normalized to lowercase.

api.md audit -- additions to ensure complete coverage of the public
surface, after a kernel-source inventory:

- PauliStabilizer constructor entries:
  - PauliStabilizer[qo, n] -- the optional pad-to-n second arg.
  - PauliStabilizer[t_?PauliTableauQ] / [sign, t] / [signs, t] -- the
    tableau-only positional forms.
  - PauliStabilizer[basis] -- the rank-3 array-of-{0,1,-1} form.
  - PauliStabilizer[shortcut] -- documented the full
    String | Rule | List shortcut argument set.

- PauliStabilizer method entries:
  - ps[] / ps[q__Integer] / ps[{q...}] -- the implicit measurement
    shortcut shortcuts.
  - ps["RowSum", h, i] -- the AG row-multiplication primitive (low-level
    but exposed).

- New "Connections to other QuantumFramework heads" section under
  PauliStabilizer with the 9-row dispatch matrix:
  QuantumState[ps], QuantumOperator[ps], QuantumCircuitOperator[ps],
  qo[ps], qmo[ps], qc[ps], cc[ps], QuantumTensorProduct[ps_a, ps_b],
  Method -> "Stabilizer".

- New "Internals (PackageScope)" section listing the predicates and
  helpers a contributor needs to know:
  PauliStabilizerQ, ConcretePauliStabilizerQ, PauliTableauQ,
  PauliStabilizerApply, FromFullTableau, PauliRow, QuantumOperatorTableau,
  agPhase, rowsum.

- One-line predicate notes added at the top of each StabilizerFrame /
  GraphState / CliffordChannel section (StabilizerFrameQ, GraphStateQ,
  CliffordChannelQ).

- StabilizerFrame Association-form constructor documented.

- CliffordChannel idempotent constructor (CliffordChannel[cc]) documented.

- Hybrid interop: new "Helpers (PackageScope)" subsection covering
  stabilizerPauliLabelFromQMO, stabilizerPauliFromMatrix,
  stabilizerPauliMatrixFromString, stabilizerCliffordChannelMixture,
  $stabilizerPauliMatrixSearchMaxQubits.

- Removed the stale "ps['Properties'] returns short list" warning -- that
  was a paclet-cache pollution issue, not a real bug; the test suite
  passes the full 40-key list.

Net diff: api.md grew by ~120 lines covering ~25 newly-documented entries
that were dispatchable in the kernel but not surfaced in the previous
draft.

Tests: 684 / 684 passing.
…patch table

Tests/Stabilizer/Connections.wlt -- 52 tests explicitly exercising every
cross-head connection point in api.md, both single-hop and multi-hop:

CONNECTION 1  -- QuantumState[ps]                            (UpValue)
CONNECTION 2  -- ps[Operator]                                (working accessor)
CONNECTION 3  -- ps[Circuit]                                 (working accessor)
CONNECTION 4  -- qo @ ps                                     (UpValue)
CONNECTION 5  -- qmo[ps]                                     (UpValue, hybrid interop)
CONNECTION 6  -- qc[ps]                                      (UpValue, hybrid interop)
CONNECTION 7  -- cc[ps]                                      (DownValue, Phase 8)
CONNECTION 8  -- QuantumTensorProduct[ps_a, ps_b]            (DownValue)
CONNECTION 9  -- QuantumCircuitOperator[..][Method -> Stabilizer]
CONNECTION 10 -- StabilizerFrame cross-head: qmo[sf], qc[sf]
CONNECTION 11 -- GraphState <-> PauliStabilizer round-trip

CHAIN 1  -- ps -> QuantumState -> Tr[ZZ rho] vs ps[Expectation, ZZ]
CHAIN 2  -- ps -> Circuit -> apply on QuantumState -> matches ps[State]
CHAIN 3  -- qo UpValue chain matches direct method-chain
CHAIN 4  -- QF circuit -> Method Stabilizer -> CC composition -> back to PS
CHAIN 5  -- ps[M, ZZ] keys vs qmoZZ[ps] keys
CHAIN 6  -- Bell via two paths (QCO + QS tomography) agree
CHAIN 7  -- 5Q code: all stabilizers measured deterministically via qmo[ps]
CHAIN 8  -- Bell -> qcBitFlip -> branch probabilities sum to 1
CHAIN 9  -- Random Clifford via Method Stabilizer matches direct apply (6 reps)
CHAIN 10 -- ps -> QuantumState -> DensityMatrix -> rank 1, trace 1 (pure)
CHAIN 11 -- QuantumTensorProduct: PS-path vs QS-path agree on materialization

api.md correction surfaced by the audit:

- The kernel declares
    QuantumOperator[ps_PauliStabilizer] := ps[Circuit][QuantumOperator]
    QuantumCircuitOperator[ps_PauliStabilizer] := ps[Circuit]
  at Conversions.m:146-147. These are DownValues against the host paclet protected
  QuantumOperator / QuantumCircuitOperator symbols and SILENTLY fail to attach.
  QuantumOperator[ps] and QuantumCircuitOperator[ps] do not behave as documented.

  api.md updated: the connections table now has a Status column marking
  the two as silently inactive (protected symbol) with the working
  accessor (ps[Operator] / ps[Circuit]) called out. Two regression tests
  document the gotcha (intentional False expectations -- promote to True
  if/when the kernel uses Unprotect to fix the dispatch).

Tests: 684 -> 736 (+52). All passing.
…uantumOperator[ps] and QuantumCircuitOperator[ps] dispatch fires

Fix the audit finding from Tests/Stabilizer/Connections.wlt:

  QuantumCircuitOperator[ps_PauliStabilizer] := ps[Circuit]
  QuantumOperator[ps_PauliStabilizer]        := ps[Circuit][QuantumOperator]

declared at Conversions.m:146-147 were DownValues against the host-paclet
Protected QuantumOperator / QuantumCircuitOperator symbols. They silently
failed to attach so the rules never fired -- callers got back a malformed
QuantumOperator wrapping the PauliStabilizers tableau as a value, not the
materialized operator.

Fix: convert both `:=` to `^:=` so the rules attach as UpValues on
_PauliStabilizer (the inner-head pattern). UpValues live in the inner
heads UpValues table, bypassing the outer symbols Protected restriction.

Verification:

  QuantumOperator[psBell]               === ps[Circuit][QuantumOperator]   -> True
  QuantumCircuitOperator[psBell]        === ps[Circuit]                    -> True
  QuantumState[psBell]                  === ps[State]                      -> True (already worked)

Updated:

- QuantumFramework/Kernel/Stabilizer/Conversions.m: both := -> ^:= with a
  comment block citing this fix.
- Tests/Stabilizer/Connections.wlt: the two regression tests that
  intentionally documented the bug (Conn2-DownValue-Inactive,
  Conn3-DownValue-Inactive) flipped to assert True under new IDs
  Conn2-QuantumOperatorOfPS-UpValue-Active and
  Conn3-QuantumCircuitOperatorOfPS-UpValue-Active.
- OngoingProjects/Stabilizer/Documentation/api.md: connections matrix
  updated. Both rows now ✅ active. Status column collapsed since all 9
  dispatch points are active. Implementation note records the fix date.

Tests: 736 / 736 passing.
Batch 1 (quick bug fixes):

A.3 -- ps[Dagger][Dagger] no longer cascades on non-canonical inputs.
  GateUpdates.m:106-118: switch the inner inverse-matrix PauliStabilizer
  to use all-+1 signs (was ps[Signs], which propagated phase asymmetry into
  the recursive composition step). Also detect a singular symplectic matrix
  (Det == 0 mod 2) and emit PauliStabilizer::singular with $Failed instead
  of letting the cascade run. Result: dag^2 === ps for AG-canonical
  fixtures (Bell, GHZ-3, HSH, integer registers); singular-matrix inputs
  produce a clean error message.

A.11 -- pauliStringMatrix on 1-qubit input.
  InnerProduct.m:113-125: wrap KroneckerProduct @@ mats with
  If[Length[mats] == 1, First[mats], ...] so the n=1 case doesn't trigger
  KroneckerProduct::argmu and produce an unevaluated expression that
  breaks downstream Re[<v|P|v>].

A.12 -- ps[Stabilizers] formatter on symbolic phases.
  Formatting.m: PauliForm now routes signs through pauliFormSignString[s]
  which handles {1, -1, otherwise -> ToString[s, InputForm] <> "*"} so
  symbolic phases (FormalS[k] from SymbolicMeasure) format as readable
  prefixes instead of throwing StringJoin::string.

A.13 -- GraphState[ps_PauliStabilizer] non-graph-form input.
  GraphState.m: now emits GraphState::nongraph and returns $Failed when the
  input PauliStabilizer is not in graph-state form (each row must be X at
  one position and I or Z elsewhere; Y or off-diagonal X are rejected).
  Linear cluster, Bell stabilizers continue to convert correctly.

Batch 2 (closed-form algorithms):

A.1 -- ps[InnerProduct, other, Method -> "ClosedForm"] now available.
  InnerProduct.m: O(n^3) closed-form magnitude per GarMarCro12 §3, gated
  on ConcretePauliStabilizerQ. Returns 0 if S_psi and S_phi disagree on
  any sign in their intersection; returns 2^(-s/2) where s = n -
  dim(intersection) otherwise. Default method remains "Direct" (full
  complex inner product via vector materialization, n <= 8). The complex
  phase under "ClosedForm" is deferred -- magnitude only.

A.2 -- ps[Expectation, pauli] closed-form, no fallback.
  InnerProduct.m: replace direct-vector fallback with AG-cumulative-i-power
  tracking via stabilizerRowSumAGPhase. Algorithm:
    1. P anticommutes with any stabilizer => 0.
    2. Decompose pVec = sum c_i g_i over F_2 via LinearSolve.
    3. If LinearSolve fails (P in N(S) \ S), return 0.
    4. Compute cumulative AG phase mod 4 via stabilizerRowSumAGPhase;
       odd phase asserts P not in S (defensive); even phase / 2 gives the
       sign bit.
    5. Final <P> = targetSign * (-1)^agSignBit * prod_i signs[i]^c_i.
  Correctly handles <Bell|YY|Bell> = -1 (Y = i*X*Z; previously needed
  direct-vector fallback). Verified against direct-vector for n in
  {1, 2, 3} on 24 random Cliffords.

Tests added (TIER 16, 17, 18 in AuditMatrix.wlt):

- 21 new tests covering all six fixes:
  - 3 tests for A.11 (Expectation on 1-qubit cleanly).
  - 1 test for A.12 (symbolic-phase format doesn't error).
  - 2 tests for A.13 (nongraph emits, valid graph still works).
  - 5 tests for A.3 (Dagger involution + singular detection).
  - 6 tests for A.1 (closed-form magnitude, opt-in Method).
  - 4 tests for A.2 (closed-form Expectation across canonical and
    edge cases).

Tests: 736 -> 757 (+21). All passing.
….7 (closed-form entropy)

A.4 -- SymbolicMeasure now records deterministic-outcome polynomials.

  Stabilizer/SymbolicMeasure.m: introduce an "Outcomes" association key on
  the PauliStabilizer Association. Each deterministic measurement whose
  outcome involves prior symbols allocates a fresh symbol m_k and stores
  {m_k -> polynomial} in the Outcomes map. The non-deterministic case
  forwards the existing Outcomes map to the post-state.

  substituteOutcomes now applies the user rules and the Outcomes map
  iteratively to a fixed point so derived outcomes resolve correctly.
  sampleOutcomes only picks random values for FREE symbols (those not
  already constrained by the Outcomes map) and lets substituteOutcomes
  propagate the rest.

  Bell-state ZZ-correlation test in PauliStabilizer.wlt is updated:
  Phase3-LIMITATION-DeterministicOutcomeNotStamped renamed to
  Phase3-A4-DeterministicOutcomeStamped-via-OutcomesMap. The test now
  verifies (a) m_1 outcomes vary, (b) the Outcomes map is populated, and
  (c) the stab signs after substitution mirror the user-supplied m_1
  value: signs go from {1, 1} (m_1=0, |00>) to {-1, 1} (m_1=1, |11>;
  ZI flips sign while ZZ stays +1, since the 5Q-style AG-derived
  generating set uses {ZI, ZZ}).

A.7 -- Closed-form polynomial-time stabilizer entropy.

  Stabilizer/Entropy.m (new file): implements stabilizerEntropy[ps,
  partition] per Fattal-Cubitt-Yamamoto-Bravyi-Chuang 2004 Theorem 1:

      S(A) = rank_{F_2}(stabilizer generators restricted to A) - |A|

  Cost: O(n^3) (rank computation), independent of |A|. Closed-form
  works at any qubit count -- verified at n = 12 where Schmidt-rank
  materialization would OOM. Method-grade dispatch:

      ps["Entropy", q]            -- single-qubit partition
      ps["Entropy", {q1, q2, ...}] -- multi-qubit partition

  Sanity tests cover Bell, |00>, GHZ-3, Cluster-4, 5Q code, and a
  GHZ-12 scaling test. All entropy units are in log_2 (so 1 means
  one bit of bipartite entanglement entropy).

Tests added (TIER 19, 20 in AuditMatrix.wlt):

- 2 tests for A.4 (Outcomes map populated; substitute mirrors m_1).
- 6 tests for A.7 (separable, Bell, GHZ-3, Cluster-4, 5Q, GHZ-12).

Tests: 757 -> 766 (+9). All passing.
….10 (generator-order canonicalization)

A.10 -- generator-order canonicalization across constructor paths.

  Constructors.m: after agPickIndependent picks linearly-independent rows
  during PauliStabilizer[qs_QuantumState] tomography, sort the resulting
  stabilizer rows by `Ordering[FirstPosition[#, 1] & /@ stabBits]` so the
  canonical order matches the integer-constructor convention
  (PauliStabilizer[n] = {Z_1, Z_2, ..., Z_n}).

  Result:
    - PauliStabilizer[QuantumState["00"]]["Stabilizers"]
        === PauliStabilizer[2]["Stabilizers"]                   (* True *)
    - QCO[Method -> "Stabilizer"]["Stabilizers"]
        === QCO[QS["00"], Method -> "Stabilizer"]["Stabilizers"] (* True *)

  The Integration-MethodStabilizer-ExplicitState test in
  PauliStabilizer.wlt previously had to use Sort[] on both sides; the
  ordered comparison now passes too.

A.8 -- StabilizerStateQ public symbol (the small subitem).

  PauliStabilizer.m: PackageExport StabilizerStateQ. Returns True when:
    - expr is a structurally-valid PauliStabilizer
    - expr is a single-component StabilizerFrame
  Returns False otherwise (including QuantumState; for state-vector
  stabilizer detection, use PauliStabilizer[qs] explicitly which runs
  4^n tomography).

  PacletInfo.wl: register the new public symbol.
  Usage.m: add usage message.

  The other two A.8 sub-items (CliffordTableau distinct head;
  StabilizerRankDecomposition automatic decomposition) remain deferred
  -- they are 100+ LOC each and warrant separate phases.

Tests added (TIER 21, 22 in AuditMatrix.wlt):

- 3 tests for A.10 (QS-vs-Int order, 2-qubit + 3-qubit, Method-Stabilizer
  default vs explicit-QS).
- 6 tests for A.8 (StabilizerStateQ on PS, named-code, Frame, Integer,
  QuantumState, multi-component Frame).

Tests: 766 -> 775 (+9). All passing.
…or follow-up)

Updates the roadmap to reflect the A-series resolution sweep on 2026-05-07:

DONE this session (10 items):
- A.1  ps[InnerProduct, ..., Method -> ClosedForm] -- O(n^3) magnitude per GarMarCro12
- A.2  ps[Expectation] AG-i-factor tracking (no direct-vector fallback for in-S Paulis)
- A.3  Dagger involution + singular-matrix detection
- A.4  SymbolicMeasure deterministic-outcome stamping via Outcomes Association
- A.7  StabilizerEntropy closed-form O(n^3) per FCYBC04 Theorem 1
- A.8 (sub) StabilizerStateQ public symbol (other A.8 sub-items deferred)
- A.10 Generator order canonicalization across QS / Int / Method-Stabilizer paths
- A.11 pauliStringMatrix single-qubit KroneckerProduct guard
- A.12 PauliForm symbolic-phase formatter
- A.13 GraphState[ps] non-graph-form ::nongraph + $Failed

REMAINING (3 items):
- A.5  Reid24 / Winderl23 optimal Clifford circuit synthesis (research-grade,
       ~250 LOC + 8 tests). AG synthesis remains correct, just non-optimal.
       Scoped for follow-up PR.
- A.6  LocalComplement VOP tracking. Depends on B.3 (24-element LocalClifford
       table). Scoped for follow-up alongside B.3.
- A.8 (sub) CliffordTableau distinct head + StabilizerRankDecomposition
       Bravyi-2016 path. ~300 LOC + 12 tests; warrants a separate phase.

CLOSED (inherent):
- A.9  GlobalPhase non-propagation through gate updates (documented contract).

Test count: 684 -> 775 (+91 tests across batches 1+2, 3, 4 and Connections.wlt).

Adds an A-series-sweep lesson at the top of the roadmap recording the
process insight: most "deferred for v1" items had clean polynomial-time
implementations once the v1 phase shipped; re-audit yearly to retire stale
"deferred" labels.
Introduce a self-contained verification audit for the QuantumFramework stabilizer subsystem. Adds a 132-test wolframscript harness (stabilizer-formulas-test.wls), the formula reference (stabilizer-formulas.md), a README with run instructions and quick status (126 pass / 6 fail), and a findings report (findings-report.md) documenting three confirmed issues (F1–F3) with reproductions and suggested fixes. Run with: wolframscript -f OngoingProjects/Stabilizer/Formula_Test/stabilizer-formulas-test.wls.
PauliStabilizer["5QubitCode" | "SteaneCode" | "9QubitCode"] previously
listed logical X-bar (XXXXX, XXXXXXX, XXXXXXXXX) as the n-th generator,
which made the prepared state |+_L> -- the +1 eigenstate of X-bar in the
codespace -- rather than the |0_L> the api docstring promises.

Replace the n-th generator with logical Z-bar (ZZZZZ, ZZZZZZZ, ZZZZZZZZZ)
on the unsigned variants and -Z-bar on the *Code1 variants so the constructors
return |0_L> and |1_L> respectively, matching Got97 §3.5, Got00 §4, and
Nielsen-Chuang §10.5.

Also update existing tests that hardcoded the old (buggy) stabilizer set:
- Tests/Stabilizer/PauliStabilizer.wlt: 5 tests touching 5Q stabilizers,
  including re-derived sign updates for the X1 / Z3 measurement tests
  (gen 5 is now Z-bar = ZZZZZ, so X1 anti-commutes with both gens 4 and 5,
  while Z3 commutes with both -- the hardcoded sign vectors changed
  accordingly).
- Tests/Stabilizer/AuditMatrix.wlt: 2 tests hardcoding 5Q / Steane n-th
  generator strings.
- Tests/Stabilizer/CliffordChannel.wlt: Phase8.2-cc-ps-Identity5-On-5QubitCode
  expected sorted stabilizer list.
- Tests/Stabilizer/Correctness_TextbookResults.wlt: rename
  Steane-Logical-X-Expectation-Plus1-on-Logical-Zero (which was only
  true for the buggy |+_L> state) to Steane-Logical-Z-Expectation-Plus1-on-Logical-Zero
  (the correct physical assertion for |0_L>), and add
  Steane-Logical-X-Expectation-Zero-on-Logical-Zero documenting that
  X-bar flips |0_L> to the orthogonal |1_L>.

Refs: OngoingProjects/Stabilizer/Formula_Test/findings-report.md F1 + P1.
…s (P2, F2)

ps["M", pauli_string] previously updated only the SIGNS of the stabilizer
group on the random-outcome branch (when P anti-commutes with at least one
stabilizer); the tableau itself was left intact. Result: the post-state
was NOT a +-P eigenstate of the measured Pauli, contradicting AG section 3
Case I. Single-qubit ps["M", q_integer] was already correct -- this only
affected multi-qubit Pauli-string measurements.

Aaronson-Gottesman section 3 Case I says: pick the first stabilizer row that
anti-commutes with P (call it k), replace row k with (-1)^b * P, and use that
k row to row-multiply every OTHER anti-commuting generator so they all commute
with the new k. The sign update was already correct; this patch adds the row
update by writing pVec symplectic bits into newTableau[[1, All, gen+kIdx]]
(X block) and newTableau[[2, All, gen+kIdx]] (Z block).

After the patch, pVec is the new k-th stabilizer (up to plus/minus) and the
expectation of P on the post-state equals plus or minus 1 as expected.
Verified by S5-F2-PostMeas-State-IsEigenstate-STRICT in
Tests/Stabilizer/Formulas.wlt.

Refs: OngoingProjects/Stabilizer/Formula_Test/findings-report.md F2 + P2.
…bleau path (P3, F3)

CliffordChannel[ps_state][ps_state'] (state-prep channel applied to a same-dim
PauliStabilizer) previously emitted CliffordChannel::stateevol and fell through
to dense materialization via QuantumChannel[cc][ps["State"]]. The api.md doc
specifies that nA == 0 (zero input qubits, the state-prep case) should return
the state encoded by cc -- the input ps is meaningless for a state-prep
channel.

The tableau-only conversion already exists as cliffordChannelToPauliStabilizer
(PackageScope helper). This patch swaps the dense fallback for that helper, so
the dispatch returns a PauliStabilizer matching the prepared state at O(n^2)
instead of O(2^n).

Verified by S16-F3-CliffordChannel-StatePrep-Yields-Zeros-STRICT in
Tests/Stabilizer/Formulas.wlt.

Refs: OngoingProjects/Stabilizer/Formula_Test/findings-report.md F3 + P3.
…P1/P2/P3 fixes

Tests/Stabilizer/Formulas.wlt (new) -- 132 top-level VerificationTests, a
.wlt mirror of OngoingProjects/Stabilizer/Formula_Test/stabilizer-formulas-test.wls
generated by stripping the s0..s25 section-list wrappers and the standalone
.wls driver so TestReport[file] discovers every test. The .wls remains the
canonical authoring location and provides per-section reporting; this .wlt
mirror runs as part of the regular Tests/RunTests.wls battery.

Full battery now reports 908/908 passing (132 from Formulas.wlt + 776 from
the prior Tests/Stabilizer/* and Tests/QuantumDistance.wlt suites).

OngoingProjects/Stabilizer/Formula_Test/findings-report.md: rewrite the
"Verification status" and "Patches" sections to record that all three
findings (F1 / F2 / F3) are resolved by Patches P1 / P2 / P3 on this
branch. The patch text itself is preserved as historical documentation.

OngoingProjects/Stabilizer/Formula_Test/README.md: status block flips to
"132/132 passing (post-fix)" and the TestID-to-finding table now also
links each F-tag to the patch that resolved it.

OngoingProjects/Stabilizer/Formula_Test/stabilizer-formulas-test.wls:
the six previously-failing TestIDs carry permanent F1/F2/F3 infixes
(e.g. S3-F1-..., S5-F2-..., S16-F3-...) so a future regression on any of
them surfaces directly under the corresponding finding tag.

Refs: OngoingProjects/Stabilizer/Formula_Test/findings-report.md
      OngoingProjects/Stabilizer/Formula_Test/README.md
Introduce a pure WL standalone Suzuki–Trotter package (OngoingProjects/Trotterization/Trotterization.wl) implementing TrotterizationMatrices, TrotterizationCoefficients and TrotterizationOrdering. The package encodes Suzuki's recursion for coefficient sequences and operator expansion and supports output forms ("Flat", "Steps", "Unitary").

Add a comprehensive wolframscript test runner (OngoingProjects/Trotterization/test-trotterization.wls) that compares the standalone implementation against QuantumFramework (per-gate and full-unitary equality), verifies coefficient parity, convergence behavior, form-option shapes, notebook replication (trace and spectral norms), a 4-qubit transverse-Ising case, symbolic-time handling, and gate-count formulas (tests T1..T10).
Brings the v2.0 named-constructor refactor (fa0d011) and 12 other
post-divergence commits on main into the stabilizer subsystem branch so
PR #3 stops reporting merge conflicts.

Conflict resolution:

- QuantumFramework/Kernel/PauliStabilizer.m (modify/delete) -- this branch
  removed the legacy single-file kernel in commit 27b36f6 (Phase 1-4
  rebuild) and split it across QuantumFramework/Kernel/Stabilizer/*.m.
  Kept the deletion. Ported the two v2.0 changes from fa0d011 into the
  new home:

    - Stabilizer/Conversions.m: QuantumOperatorTableau now uses
      QuantumOperator["X"[d] -> #] / "Z"[d] -> # form (was {"X", d} / {"Z", d}).
    - Stabilizer/PauliStabilizer.m: PauliStabilizerApply gate-rewrite
      pattern uses "C"[g -> t_, c_, _] (was {"C", g -> t_, c_, _}).

Test fix:

- Tests/Stabilizer/PauliStabilizer.wlt: Phase2-NonClifford-Message used
  "FooBarUnknownGate" as the trigger. Under v2.0 unknown names short-
  circuit at the QuantumOperator construction with QuantumOperator::invalidName
  before PauliStabilizerApply ever runs, so the Head check no longer matches
  PauliStabilizer. Switched to a single "T" gate -- v2.0 accepts the name,
  PauliStabilizer dispatch returns a StabilizerFrame which falls through to
  the True branch in PauliStabilizerApply, emitting exactly one
  PauliStabilizer::nonclifford message and returning the prior PauliStabilizer
  unchanged.

All other changes auto-merged. Stabilizer-affected test surface (11 files,
908 tests) verified green after the merge:

  Tests/QuantumDistance.wlt: 32/32
  Tests/Stabilizer/AuditMatrix.wlt: 194/194
  Tests/Stabilizer/CliffordChannel.wlt: 76/76
  Tests/Stabilizer/Connections.wlt: 52/52
  Tests/Stabilizer/Correctness_TextbookResults.wlt: 42/42
  Tests/Stabilizer/CrossPackage_QuantumClifford.wlt: 15/15
  Tests/Stabilizer/CrossPackage_Stim.wlt: 44/44
  Tests/Stabilizer/Formulas.wlt: 132/132
  Tests/Stabilizer/HybridInterop.wlt: 52/52
  Tests/Stabilizer/PauliStabilizer.wlt: 249/249
  Tests/Stabilizer/Roundtrips.wlt: 20/20

  Total: 908 / 908 passed.
minor bugs in standalone function, nothing to do with QF
more tests based on papers
Update Stabilizer API reference and add symbol notebooks; small but wide-ranging kernel edits across stabilizer modules. Key changes:

- Revise OngoingProjects/Stabilizer/Documentation/api.md: rewording to remove phase-status noise, clarify global-phase contract and limitations, simplify method tables and verification notes, and update examples and citations.
- Add new documentation notebooks for top-level symbols (CliffordChannel, GraphState, LocalComplement, PauliStabilizer, StabilizerFrame, StabilizerStateQ).
- CliffordChannel.m: rework comments and messages to reflect current support (composition with Boolean nullspace + AG phase tracking, contraction-sign correction), tighten handling of stochastic channels (emit notice and fallback), clarify state-evolution dispatch and messages.
- Compose.m, Constructors.m, Conversions.m, Entropy.m, Formatting.m, GateUpdates.m and other kernel files: comment cleanups, clarifications of contracts/limits (e.g. global-phase handling, performance notes), formatting improvements (symbolic sign rendering), and reliability fixes (use of UpValues for circuit/operator conversions).

These edits are primarily documentation clarifications, API contract wording, and developer-facing comments plus modest behavioral fixes (message wording, UpValue attachment, and documented fallbacks) to align implementation with the current roadmap and tests.
Add a new wolframscript (build_paulistabilizer_doc.wl) that programmatically generates the PauliStabilizer reference notebook (Documentation/English/ReferencePages/Symbols/PauliStabilizer.nb). The script loads the QuantumFramework paclet, sets deterministic CellIDs, and includes helpers to construct styled notebook cells (usage, notes, examples, options, see-also, metadata) and safe Input/Output example rendering via the front-end parser. Also update the existing PauliStabilizer.nb reference page to reflect the generated content.
Add several wolframscript doc-builders under OngoingProjects/Stabilizer (CliffordChannel, GraphState, LocalComplement, StabilizerFrame, StabilizerStateQ) and update the existing build_paulistabilizer_doc.wl. Update multiple reference notebooks in Documentation/English/ReferencePages/Symbols (CliffordChannel.nb, GraphState.nb, LocalComplement.nb, PauliStabilizer.nb, QuantumState.nb, StabilizerFrame.nb, StabilizerStateQ.nb) and add a backup QuantumState.nb.bak. Also modify the CliffordChannel kernel implementation (QuantumFramework/Kernel/Stabilizer/CliffordChannel.m) to align with the documentation changes.
- Property and Named-states tables converted to canonical 2ColumnTableMod
  format (ModInfo + TableText cells, no TagBox wrapper), matching the
  structure used by QuantumOperator.nb and other QF reference pages.
- 17 ExampleText cells converted from plain named-char text (e.g.
  \[VerticalBar]0\[RightAngleBracket], \[Psi]\[Psi]\[Dagger]) to
  TextData with InlineFormula cells.  Math typography: TemplateBox
  Kets/Bras, SuperscriptBox for rho^2 / psi-dagger, SqrtBox for
  Sqrt[qs], SubscriptBox for r_x / u_i / p_i.
- Schmidt-basis math corrected: was using BraKet template (inner
  product); now uses two Ket templates for the product state.
- Fix 5 over-escaped backslash-quote bugs in PureStateQ, MixedStateQ,
  Bend, Purify, Unpurify property descriptions.
Add a project-local cheat-sheet describing how to use paclet-doc-rewrite-template for QuantumFramework documentation rewrites. The new file includes a QF-specific invocation snippet (the "QF shortcut"), symbol status table, quick references (paclet root, docs dir, tests, conventions), guidance on when to update the canonical template, and links to related files and backups.
Refine error and boundary handling across the stabilizer kernel and docs:

- CliffordChannel.m: For stochastic channels emit a clean CliffordChannel::stochastic message and return $Failed instead of returning a misleading "Identity" placeholder; callers that need tableau-level stochastic application should use the qc[ps] form (see HybridInterop).
- HybridInterop.m: When a QuantumMeasurementOperator maps to a non-Pauli basis, emit a single PauliStabilizer::nonpaulibasis notice and route through the dense state-vector path (qmo[ps["State"]]) to avoid duplicate ::nonclifford messages and cascading handling.
- Measurement.m: Add bounds checks for single-index and index-list measurements; emit PauliStabilizer::partition for out-of-range indices and return $Failed (consistent with stabilizerEntropy behavior).
- PauliStabilizer.m: Short-circuit PauliStabilizerApply to propagate $Failed without re-emitting messages, accept StabilizerFrame results from modern non-Clifford boundaries, and convert unknown-gate results into a single PauliStabilizer::nonclifford message followed by $Failed to stop the fold.

Also update corresponding documentation notebooks (CliffordChannel.nb, PauliStabilizer.nb) to reflect these changes.
Clean up and clarify comments across the Stabilizer kernel and remove an obsolete deprecation message. Changes include: clarify stochastic-channel behavior in CliffordChannel, note basis-aware measurement routing in Conversions/HybridInterop, simplify AG phase/rowsum comments in Measurement, tighten descriptions in PauliStabilizer/Properties, and update PauliStabilizerApply comments to better distinguish Clifford vs non-Clifford outcomes. Also remove the PauliStabilizer::tdeprecated message string in GateUpdates.m. No algorithmic changes were introduced aside from removing the deprecated message; these edits improve readability and reduce misleading documentation.
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.

4 participants