Library / Bond Contract / Bond Contract examples
Bond Contract examples
An exact GHZ factorization, a product of Hadamards, and a budget fault.
- Example 1 — the braid fits in bond width 2
- Example 2 — a product state stays at bond width 1
- Example 3 — spending the budget on purpose
Example 1 — the braid fits in bond width 2
Lattice script
bonds = Lattice.bonds(width=3, chi=8, epsilon=1e-12, order="line")
bonds.apply("H", on=0)
bonds.apply("CNOT", control=0, target=1)
bonds.apply("CNOT", control=1, target=2)
report = bonds.report()
assert report.discarded == 0
assert report.chi_used == 2This is the canary. A later change to the splitting rule that drops a zero singular value and reports a nonzero discarded weight fails the laboratory even if the amplitudes still look right.
Example 2 — a product state stays at bond width 1
Lattice script
bonds = Lattice.bonds(width=12, chi=1, epsilon=1e-12, order="line")
for wire in range(12):
bonds.apply("H", on=wire)
assert bonds.report().discarded == 0
assert bonds.report().chi_used == 1Example 3 — spending the budget on purpose
A brickwork of two-wire rotations on a line will demand bond width. With χ = 4 and a tight ε the second layer is expected to fault on a width-12 fixture stored with the laboratory. The fault carries the discarded weight of the attempt so the next ε or χ is chosen from evidence. The script does not return the truncated state with a success flag.
Lattice script
bonds = Lattice.bonds(width=12, chi=4, epsilon=1e-10, order="line") bonds.run(BRICKWORK_FIXTURE) # Budget fault once discarded weight would pass 1e-10 # bonds still holds the last successful layer