"""A minimal executable CQW -> Split -> Unison cycle. Run from the package root: python examples/minimal_cycle.py The oracle is explicit and charged; no information is recovered from nothing. """ from pathlib import Path import sys sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'src')) import numpy as np from axiomesh.core import Memory, weave, split_with_tether, hole_certificate p = 101 Q = np.array([[1, 0, 0]], dtype=np.int64) a = np.eye(3, dtype=np.int64); a[0, 1] = 1 b = np.eye(3, dtype=np.int64); b[1, 2] = 1 ops = {"a": a, "b": b} h = np.array([3, 4, 2], dtype=np.int64) partial = Memory(np.array([[1, 0, 0], [0, 1, 0]], dtype=np.int64), np.array([3, 4], dtype=np.int64), p) result = weave(Q, ops, partial) assert result.status == "ambiguous" print('Before acquisition:', hole_certificate(result.closure, partial)) result = weave(Q, ops, partial, oracle=lambda row: int(row @ h) % p, observation_budget=1, erasure_budget=1) assert result.status == "committed" assert result.offspring.run(["b", "a"]).tolist() == [9] fracture = split_with_tether(Q, ops, result.memory, partitions=[["a"], ["b"]]) rejoined = fracture.reunify() assert rejoined.status == "committed" assert rejoined.offspring.run(["b", "a"]).tolist() == [9] print({'observations_acquired': result.acquisitions, 'tether_symbols': fracture.tether_symbols, 'regenerated_output': rejoined.offspring.run(['b', 'a']).tolist()})