File size: 2,180 Bytes
d1c6c9a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
"""Run exact channel, rank, and witness examples without network access."""
from __future__ import annotations
import argparse,json,sys
from collections import Counter
from pathlib import Path
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/"src"))
from noulith.third import (
    all_components, example_point, certify_scalar, predicted_rank, direct_block_rank,
    optimal_calibration_subfamily, calibration_classes,
)
from noulith.algebra import TwistedAlgebra
def main():
    parser=argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--m",type=int,default=6)
    args=parser.parse_args()
    if args.m<6:parser.error("The third-deficit recipe requires m >= 6.")
    m=args.m;q=example_point(m,"twin");cert=certify_scalar(m,q)
    rank=predicted_rank(m,q)
    independent=direct_block_rank(m,q,m-3) if m<=8 else None
    if independent is not None and independent!=rank:raise AssertionError("Independent rank disagrees")
    selected=optimal_calibration_subfamily(m)
    classes=calibration_classes(m,selected)
    visible_q=example_point(m,"generic");visible=certify_scalar(m,visible_q)
    assert visible.visible
    algebra=TwistedAlgebra(m,visible_q);blocks=visible.full_partition(m)
    raw=algebra.isolated_response(blocks)
    assert len(blocks)==m-3
    assert raw==algebra.isolated_unit(blocks)*visible.normalized_response and raw!=0
    print(json.dumps({
        "channels":m,"blocks":m-3,"component_count":len(all_components(m)),
        "components_by_kind":dict(Counter(c[0] for c in all_components(m))),
        "twin_visible":cert.visible,"twin_predicted_rank":rank,"twin_independent_rank":independent,
        "independent_rank_note":"Computed through m=8; omitted above eight because the route is exponential",
        "state_dimension":2**m,"selected_twin_constraints":selected,"selected_count":len(selected),
        "remaining_scale_classes":len(classes),"generic_witness_verified_in_original_algebra":True,
        "generic_witness_raw_response":str(raw),
        "scope":"Exact examples in the manuscript's abstract model"
    },indent=2))
    return 0
if __name__=="__main__":raise SystemExit(main())