Skip to content

Pair bidirectional states by their forward emissions - #89

Merged
Autoplectic merged 1 commit into
mainfrom
bidirectional-phase-tiebreak
Dec 5, 2026
Merged

Autoplectic merged 1 commit into
mainfrom
bidirectional-phase-tiebreak

Conversation

@Autoplectic

Copy link
Copy Markdown
Member

Summary

  • BidirectionalEpsilonMachine.from_forward paired forward and reverse causal states according to PYTHONHASHSEED for the alternating biased coins. The Eq. (15) graph has two closed components with the right stationary marginals and the same anatomy gap: the true joint, and the joint with the forward labels A and B swapped. _build_eq15_graph weights edges by the reverse machine's probabilities alone, so both components are valid chains, and the tie fell to the repr of the reverse state labels. Five of the seeds 0–7 gave the swapped joint.
  • Information measures were unaffected, since the swapped joint is a relabeling. But its forward coordinate no longer matched forward_machine: started from π(A, ·) / π⁺(A), the bidirectional machine emitted with B's coin, so word probabilities given a forward state were off by up to 0.3, and Pr(S⁺, S⁻) paired each forward state with the wrong reverse state.
  • New _forward_emission_mismatch checks Σ_γ π(α, γ) Pr(x | (α, γ)) = π⁺(α) Pr(x | α) for every forward state α and symbol x. _joint_pi_minimum_support keeps the marginal-matching components that pass it (exactly in symbolic mode, within marginal_tol otherwise) before the anatomy-gap and support tie-breaks, and falls back to the marginal-matching pool if none does.

Test plan

  • tests/test_bidirectional_construction.py, three new tests: the emission check accepts the true component and rejects the swapped one (mismatch 0.15); the bidirectional machine reproduces Pr(w | S⁺ = α) on all words of length 6; and the same check in subprocesses with PYTHONHASHSEED 0–7. Without the fix, the emission and hash-seed tests fail.
  • full fast suite: 2990 passed, 13 skipped
  • ruff check, ruff format --check on the changed files
  • ty check: exit 0, no diagnostics in the changed lines

For the alternating biased coins the Eq. (15) graph has two closed
components with the right stationary marginals and the same anatomy gap:
the true joint and the one with the forward labels swapped. The tie fell
to the repr of the reverse state labels, which depend on PYTHONHASHSEED,
so five of the seeds 0-7 paired the forward states out of phase.

_joint_pi_minimum_support now keeps only components whose forward states
emit as the forward machine does before applying the anatomy-gap and
support tie-breaks.
@Autoplectic
Autoplectic merged commit 6487993 into main Dec 5, 2026
10 checks passed
@Autoplectic
Autoplectic deleted the bidirectional-phase-tiebreak branch December 5, 2026 19:37
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