From 7e7e62c62fcccd11f5c8e22677b4523863a48f4b Mon Sep 17 00:00:00 2001 From: apoursh <8867770+apoursh@users.noreply.github.com> Date: Thu, 19 Nov 2026 13:30:48 -0500 Subject: [PATCH] Apply the width-13 Clifford Gram and its inverse to requested fibres --- .../CLASS-ALGEBRA.json | 165 ++ .../CLASS-ALGEBRA.md | 23 + .../clifford-transported-fibre-gram/PROOF.md | 45 + .../clifford-transported-fibre-gram/README.md | 39 + .../SOURCE-PINS.json | 114 ++ .../SOURCES.json | 90 + .../clifford-transported-fibre-gram/TASK.json | 93 + .../VERIFY.json | 90 + .../build_classes.py | 53 + .../check_classes.py | 61 + .../class_algebra.py | 114 ++ .../clifford-transported-fibre-gram/gram.py | 134 ++ .../native_classes.g | 19 + .../readout.py | 146 ++ .../retained/SCHEDULE.json | 271 +++ .../retained/fibre.py | 177 ++ .../retained/predecessor/RETAINED.json | 74 + .../retained/predecessor/contract.py | 195 +++ .../predecessor/source/engine/INPUTS.json | 72 + .../predecessor/source/engine/contractions.py | 236 +++ .../predecessor/source/engine/source/LICENSE | 201 +++ .../source/engine/source/PR5698-NOTICE.md | 9 + .../source/engine/source/PR5704-NOTICE.md | 33 + .../source/engine/source/PR5704-quadratic.py | 283 +++ .../predecessor/source/row/bell_reads.py | 128 ++ .../predecessor/source/row/compile_row.py | 247 +++ .../predecessor/source/row/raw_row.py | 284 +++ .../retained/width13-spectrum.json | 1519 +++++++++++++++++ .../verify_gram.py | 110 ++ .../verify_readout.py | 191 +++ 30 files changed, 5216 insertions(+) create mode 100644 research/clifford-transported-fibre-gram/CLASS-ALGEBRA.json create mode 100644 research/clifford-transported-fibre-gram/CLASS-ALGEBRA.md create mode 100644 research/clifford-transported-fibre-gram/PROOF.md create mode 100644 research/clifford-transported-fibre-gram/README.md create mode 100644 research/clifford-transported-fibre-gram/SOURCE-PINS.json create mode 100644 research/clifford-transported-fibre-gram/SOURCES.json create mode 100644 research/clifford-transported-fibre-gram/TASK.json create mode 100644 research/clifford-transported-fibre-gram/VERIFY.json create mode 100644 research/clifford-transported-fibre-gram/build_classes.py create mode 100644 research/clifford-transported-fibre-gram/check_classes.py create mode 100644 research/clifford-transported-fibre-gram/class_algebra.py create mode 100644 research/clifford-transported-fibre-gram/gram.py create mode 100644 research/clifford-transported-fibre-gram/native_classes.g create mode 100644 research/clifford-transported-fibre-gram/readout.py create mode 100644 research/clifford-transported-fibre-gram/retained/SCHEDULE.json create mode 100644 research/clifford-transported-fibre-gram/retained/fibre.py create mode 100644 research/clifford-transported-fibre-gram/retained/predecessor/RETAINED.json create mode 100644 research/clifford-transported-fibre-gram/retained/predecessor/contract.py create mode 100644 research/clifford-transported-fibre-gram/retained/predecessor/source/engine/INPUTS.json create mode 100644 research/clifford-transported-fibre-gram/retained/predecessor/source/engine/contractions.py create mode 100644 research/clifford-transported-fibre-gram/retained/predecessor/source/engine/source/LICENSE create mode 100644 research/clifford-transported-fibre-gram/retained/predecessor/source/engine/source/PR5698-NOTICE.md create mode 100644 research/clifford-transported-fibre-gram/retained/predecessor/source/engine/source/PR5704-NOTICE.md create mode 100644 research/clifford-transported-fibre-gram/retained/predecessor/source/engine/source/PR5704-quadratic.py create mode 100644 research/clifford-transported-fibre-gram/retained/predecessor/source/row/bell_reads.py create mode 100644 research/clifford-transported-fibre-gram/retained/predecessor/source/row/compile_row.py create mode 100644 research/clifford-transported-fibre-gram/retained/predecessor/source/row/raw_row.py create mode 100644 research/clifford-transported-fibre-gram/retained/width13-spectrum.json create mode 100644 research/clifford-transported-fibre-gram/verify_gram.py create mode 100644 research/clifford-transported-fibre-gram/verify_readout.py diff --git a/research/clifford-transported-fibre-gram/CLASS-ALGEBRA.json b/research/clifford-transported-fibre-gram/CLASS-ALGEBRA.json new file mode 100644 index 0000000000..cbee453d50 --- /dev/null +++ b/research/clifford-transported-fibre-gram/CLASS-ALGEBRA.json @@ -0,0 +1,165 @@ +{ +"classes":[ +{"size":1,"fixed":8,"representatives":[[1,2,4,8,16,32,64,128]]}, +{"size":987033600,"fixed":1,"representatives":[[154,29,55,73,118,33,251,224]]}, +{"size":987033600,"fixed":1,"representatives":[[42,98,59,245,15,85,165,198]]}, +{"size":329011200,"fixed":1,"representatives":[[194,245,128,166,5,82,143,80]]}, +{"size":329011200,"fixed":1,"representatives":[[42,68,222,16,40,150,76,9]]}, +{"size":987033600,"fixed":1,"representatives":[[148,211,117,173,154,193,22,185]]}, +{"size":987033600,"fixed":1,"representatives":[[12,254,217,49,93,7,62,237]]}, +{"size":1480550400,"fixed":1,"representatives":[[44,208,158,123,160,196,75,245]]}, +{"size":1480550400,"fixed":1,"representatives":[[178,14,118,201,167,84,222,107]]}, +{"size":1184440320,"fixed":1,"representatives":[[117,186,49,214,200,79,180,213]]}, +{"size":1184440320,"fixed":1,"representatives":[[141,25,146,248,190,37,63,252]]}, +{"size":329011200,"fixed":1,"representatives":[[42,28,89,20,121,225,38,248]]}, +{"size":1974067200,"fixed":1,"representatives":[[148,92,234,47,105,104,164,132]]}, +{"size":36556800,"fixed":1,"representatives":[[148,47,108,122,240,41,153,9]]}, +{"size":1579253760,"fixed":1,"representatives":[[181,94,208,41,23,69,31,21]]}, +{"size":3384115200,"fixed":1,"representatives":[[226,135,81,47,123,219,75,180]]}, +{"size":2632089600,"fixed":1,"representatives":[[231,237,30,164,118,139,248,6]]}, +{"size":493516800,"fixed":2,"representatives":[[194,16,78,230,46,247,12,54]]}, +{"size":164505600,"fixed":2,"representatives":[[194,146,231,40,134,187,130,58]]}, +{"size":493516800,"fixed":2,"representatives":[[197,55,22,26,8,20,107,73]]}, +{"size":370137600,"fixed":2,"representatives":[[42,223,98,199,129,25,131,158]]}, +{"size":370137600,"fixed":2,"representatives":[[95,188,85,7,143,2,140,76]]}, +{"size":592220160,"fixed":2,"representatives":[[119,62,242,34,183,156,99,237]]}, +{"size":164505600,"fixed":2,"representatives":[[89,66,216,101,202,121,52,152]]}, +{"size":54835200,"fixed":2,"representatives":[[194,123,14,193,111,187,130,211]]}, +{"size":123379200,"fixed":2,"representatives":[[86,114,172,52,93,59,60,219]]}, +{"size":41126400,"fixed":2,"representatives":[[232,159,179,86,135,43,76,48]]}, +{"size":92534400,"fixed":2,"representatives":[[33,30,96,168,49,32,204,104]]}, +{"size":92534400,"fixed":2,"representatives":[[150,177,85,206,245,15,163,255]]}, +{"size":61689600,"fixed":2,"representatives":[[232,80,90,191,69,196,130,248]]}, +{"size":197406720,"fixed":2,"representatives":[[118,42,240,89,25,227,210,21]]}, +{"size":109670400,"fixed":2,"representatives":[[65,203,139,2,211,95,157,104]]}, +{"size":658022400,"fixed":2,"representatives":[[241,178,184,242,90,116,201,87]]}, +{"size":12185600,"fixed":2,"representatives":[[220,125,224,203,172,77,115,192]]}, +{"size":526417920,"fixed":2,"representatives":[[34,175,29,217,44,122,5,114]]}, +{"size":1128038400,"fixed":2,"representatives":[[108,66,67,192,128,241,209,101]]}, +{"size":877363200,"fixed":2,"representatives":[[97,40,33,147,246,168,167,243]]}, +{"size":82252800,"fixed":3,"representatives":[[93,57,125,85,223,5,122,129]]}, +{"size":82252800,"fixed":3,"representatives":[[136,7,100,190,106,169,140,191]]}, +{"size":123379200,"fixed":3,"representatives":[[42,158,160,46,192,177,131,223]]}, +{"size":123379200,"fixed":3,"representatives":[[229,170,69,68,198,196,214,90]]}, +{"size":41126400,"fixed":3,"representatives":[[1,193,172,225,185,10,13,14]]}, +{"size":46267200,"fixed":3,"representatives":[[127,234,236,158,100,33,76,101]]}, +{"size":15422400,"fixed":3,"representatives":[[1,230,135,72,181,132,107,79]]}, +{"size":7711200,"fixed":3,"representatives":[[6,139,138,104,202,121,253,3]]}, +{"size":7711200,"fixed":3,"representatives":[[1,171,69,160,159,33,164,205]]}, +{"size":164505600,"fixed":3,"representatives":[[194,119,41,230,73,144,107,54]]}, +{"size":54835200,"fixed":3,"representatives":[[32,193,184,149,23,197,21,140]]}, +{"size":197406720,"fixed":3,"representatives":[[27,66,91,129,188,58,101,19]]}, +{"size":10281600,"fixed":4,"representatives":[[241,248,41,37,26,30,151,180]]}, +{"size":15422400,"fixed":4,"representatives":[[251,36,203,199,37,51,165,67]]}, +{"size":3427200,"fixed":4,"representatives":[[191,40,120,202,175,118,254,170]]}, +{"size":3855600,"fixed":4,"representatives":[[1,204,69,138,180,108,107,101]]}, +{"size":1285200,"fixed":4,"representatives":[[56,47,230,178,135,154,182,79]]}, +{"size":963900,"fixed":4,"representatives":[[238,147,149,118,101,188,215,26]]}, +{"size":64260,"fixed":4,"representatives":[[1,199,40,36,48,32,168,68]]}, +{"size":10967040,"fixed":4,"representatives":[[42,28,218,214,56,35,107,181]]}, +{"size":3655680,"fixed":4,"representatives":[[42,46,180,147,79,127,168,135]]}, +{"size":13160448,"fixed":4,"representatives":[[242,144,61,228,54,120,244,159]]}, +{"size":514080,"fixed":5,"representatives":[[1,140,138,111,122,201,77,3]]}, +{"size":514080,"fixed":5,"representatives":[[1,230,224,134,119,74,169,141]]}, +{"size":321300,"fixed":5,"representatives":[[1,40,198,202,17,200,64,170]]}, +{"size":685440,"fixed":5,"representatives":[[120,170,125,80,224,32,64,161]]}, +{"size":16065,"fixed":6,"representatives":[[1,230,224,236,29,32,169,141]]}, +{"size":5355,"fixed":6,"representatives":[[175,217,170,125,190,85,155,245]]}, +{"size":10880,"fixed":6,"representatives":[[1,96,102,225,249,171,64,105]]}, +{"size":255,"fixed":7,"representatives":[[1,235,237,225,249,32,64,105]]}, +{"size":329011200,"fixed":0,"representatives":[[32,57,133,76,234,200,17,81]]}, +{"size":1974067200,"fixed":0,"representatives":[[201,133,191,158,129,229,135,24]]}, +{"size":1579253760,"fixed":0,"representatives":[[151,214,54,11,144,217,9,96]]}, +{"size":526417920,"fixed":0,"representatives":[[60,220,203,186,37,133,74,161]]}, +{"size":164505600,"fixed":0,"representatives":[[200,110,217,245,24,12,235,215]]}, +{"size":27417600,"fixed":0,"representatives":[[201,65,253,221,9,44,99,191]]}, +{"size":609280,"fixed":0,"representatives":[[201,165,25,57,237,44,99,91]]}, +{"size":2256076800,"fixed":0,"representatives":[[108,32,33,41,105,122,209,140]]}, +{"size":1754726400,"fixed":0,"representatives":[[145,156,85,2,67,128,151,230]]}, +{"size":3158507520,"fixed":0,"representatives":[[103,29,224,202,59,123,105,97]]}, +{"size":2368880640,"fixed":0,"representatives":[[227,240,64,89,106,98,101,58]]}, +{"size":157925376,"fixed":0,"representatives":[[242,56,95,43,27,187,107,238]]}, +{"size":5573836800,"fixed":0,"representatives":[[209,255,139,43,149,49,125,71],[134,149,130,47,108,131,93,132]]} +], +"characters":[ +[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], +[35,0,-2,2,0,-2,0,1,-1,-1,1,1,-1,-3,-1,0,0,0,2,0,1,1,1,-2,0,2,-2,-1,3,-1,3,3,1,-1,-1,0,2,-4,0,1,-3,-2,-1,-1,3,-5,-2,0,-1,2,3,6,-1,7,3,-5,0,2,5,-1,-9,-5,-6,11,3,14,-21,1,-1,0,2,1,-3,5,0,-1,0,0,0,1], +[51,-2,0,0,2,0,-2,-1,1,1,-1,1,-1,-3,-1,0,0,0,2,0,1,1,1,2,4,-2,2,3,-1,3,-1,1,-1,-3,1,2,0,0,-4,-3,1,-2,-1,-1,-5,3,-2,0,-1,2,3,-2,7,-1,3,11,4,6,1,-9,-1,-5,-6,11,19,6,-21,2,0,-1,1,2,-2,6,-1,0,1,1,1,0], +[85,0,0,-2,-2,0,0,-1,-1,-1,-1,-2,0,2,0,-1,-1,2,0,2,1,1,1,2,0,2,2,1,1,1,1,0,2,4,2,1,1,-2,-2,-3,-3,-2,-3,-3,-3,-3,-2,-4,-3,6,5,6,5,5,5,5,6,4,5,-11,-11,-11,-10,21,21,22,-43,-1,1,1,-1,-1,3,-5,1,1,0,0,0,0], +[119,-1,1,-1,1,1,-1,-1,1,1,-1,0,0,0,0,0,0,1,1,1,1,1,1,-1,-1,3,-1,-1,3,-1,3,2,2,2,0,0,2,5,1,1,5,3,3,3,-1,7,3,3,3,7,7,11,3,11,7,-1,5,5,9,11,19,15,15,31,23,35,63,-1,-1,0,0,-1,-1,-1,0,-1,-1,-1,-1,0], +[135,1,-1,1,-1,-1,1,1,-1,-1,1,0,0,0,0,0,0,1,1,1,1,1,1,3,3,-1,3,3,-1,3,-1,0,0,0,2,2,0,1,5,5,1,3,3,3,7,-1,3,3,3,7,7,3,11,3,7,15,9,9,5,19,11,15,15,31,39,27,63,0,0,-1,-1,0,0,0,-1,0,0,0,0,-1], +[238,0,0,-2,2,-1,1,0,0,0,-2,1,1,1,-1,0,1,-2,0,-1,2,-2,0,2,0,1,5,2,2,-2,2,3,-1,-5,-1,0,1,-5,-1,2,-2,1,2,-2,-6,-6,-2,4,2,-3,2,9,-2,14,-2,14,-6,4,8,10,-22,-2,-11,30,-18,49,-98,-1,1,-1,-1,-1,3,-5,0,1,0,-1,3,0], +[510,1,1,3,-1,1,-1,0,0,-1,1,-1,1,3,-1,-1,0,-1,1,-1,-2,2,1,3,1,1,5,2,2,-2,3,1,-1,-3,-1,-1,0,3,-1,-2,2,5,2,-2,10,10,-1,-3,-1,1,2,13,-2,14,14,30,-5,-3,5,-6,26,14,9,46,-2,69,174,-1,1,0,2,3,7,15,-1,0,0,0,0,0], +[595,-1,1,1,-1,1,1,1,-1,0,0,1,-1,5,1,0,-1,-1,1,-1,1,-3,-2,1,-1,-1,-1,-1,3,3,2,5,-1,1,1,0,1,7,-1,1,1,-5,-5,-1,-1,7,1,-1,-2,-5,-1,11,-1,23,-13,-5,-1,1,10,-5,35,-5,11,43,-13,91,203,2,0,-1,1,-2,2,10,0,1,0,0,0,0], +[595,0,0,-2,-2,-1,-1,1,1,0,0,3,1,-1,0,0,-1,0,2,1,-1,-1,0,0,-6,1,-7,7,-1,-1,0,-3,-1,1,0,0,1,1,1,-1,-1,-3,3,-5,3,3,0,2,0,5,-5,-3,-5,11,3,51,0,10,0,-5,-5,3,5,35,-45,-35,35,-1,-1,0,0,3,3,19,0,1,-1,1,5,0], +[918,0,0,2,-2,1,-1,0,0,-2,0,0,0,0,0,1,0,0,2,-1,-2,2,-2,0,6,1,-3,2,2,6,0,0,0,0,-2,1,0,-1,-5,-2,2,-3,2,6,-6,-6,0,6,0,-7,2,-3,22,6,6,54,0,18,-2,-22,10,6,-15,38,150,-27,-90,0,0,0,-2,0,0,0,1,0,0,-1,3,0], +[1190,1,1,-1,3,-1,1,0,0,1,-1,-2,0,2,0,0,-1,1,3,-1,2,-2,-1,1,7,1,-3,2,2,6,1,-2,0,2,-2,0,-1,-1,3,2,-2,1,2,6,10,10,1,-1,-3,-3,2,1,22,6,22,70,1,11,-5,26,-6,22,5,54,166,-7,182,0,0,1,1,4,4,20,0,-1,0,0,0,0], +[1275,1,-1,-1,1,1,1,-1,1,0,0,2,0,6,0,-1,0,-3,-1,-1,-3,1,0,-1,5,3,3,3,-1,-1,0,2,0,6,0,1,0,-1,7,1,1,-1,-5,-9,7,-1,-1,-3,0,-1,-1,-1,15,-9,-21,35,5,15,0,35,-5,-13,15,35,155,15,195,3,-1,0,0,-1,-1,15,1,0,0,0,0,0], +[1512,-1,1,1,-1,1,-1,0,0,1,1,0,0,0,1,0,0,-1,1,-1,0,0,1,-3,3,1,-3,0,0,0,1,0,0,0,-1,0,0,-5,-1,4,-4,-3,0,0,8,-8,-3,3,1,1,8,21,-8,24,8,-24,-9,9,17,16,-64,-24,-39,136,-24,189,-504,0,0,1,-1,0,0,0,0,0,0,1,-3,-1], +[1785,0,0,0,0,0,0,-1,-1,-1,-1,1,1,9,1,0,0,0,4,0,1,1,1,-4,0,-4,-4,-3,-3,-3,-3,3,-1,3,-1,0,0,0,0,-3,-3,4,1,1,-15,-15,4,0,1,4,9,-12,-7,-7,9,-55,0,12,5,9,9,25,36,121,57,84,441,2,0,0,2,2,6,30,0,0,0,0,0,0], +[1785,0,0,2,-2,0,2,-1,1,-1,-1,1,-1,-3,1,0,0,2,0,-2,-1,-1,1,2,-4,0,4,5,1,-3,-3,-1,1,3,-1,0,0,2,-2,3,-1,4,-3,5,-15,9,-2,0,1,0,1,-4,-3,-11,-7,65,-10,12,5,29,-11,1,-24,81,-103,84,-399,-2,0,0,2,2,-10,30,0,0,0,0,0,0], +[2295,1,-1,-1,1,0,0,-1,1,0,0,0,0,0,1,1,0,1,-1,0,-3,1,-2,3,-3,0,0,-1,3,3,2,0,0,0,1,-1,0,-4,4,-3,-3,0,-1,3,-5,-13,3,-3,-2,8,3,24,3,27,7,15,9,-9,10,-25,-65,-33,-24,143,87,216,-657,0,0,-1,1,0,0,0,-1,0,0,0,0,0], +[2856,1,-1,-3,-1,-1,1,0,0,0,0,-2,0,-6,0,0,0,-1,-1,-1,0,0,0,-3,1,1,-3,0,0,0,0,-2,0,-6,-2,0,0,3,-1,-4,4,1,0,0,-8,8,1,-3,0,5,8,25,-8,24,8,-24,-5,3,16,0,80,40,45,200,40,273,840,0,0,0,-2,0,-8,-24,0,0,1,1,1,0], +[2856,1,-1,-1,1,-1,1,0,0,1,1,0,0,0,1,0,0,-1,1,-1,0,0,1,1,-1,-3,1,0,0,0,1,2,-2,-6,1,0,0,-1,-5,-4,4,-3,0,0,-8,8,-3,3,1,1,8,-19,24,-8,8,40,11,21,1,-64,16,-24,-39,136,296,21,-504,-2,0,1,1,-2,2,-6,0,0,-1,0,-4,0], +[2975,-1,-1,-1,-1,0,0,1,1,0,0,1,1,-7,0,0,-1,1,1,0,-1,-1,0,-3,5,-4,4,3,3,-5,0,5,1,5,0,0,-1,-4,-4,3,3,4,-1,7,-1,-1,1,-7,0,4,-9,-4,-1,31,-17,15,5,5,0,-25,-25,31,20,-65,95,140,-385,1,1,0,0,-3,5,5,0,-1,0,0,0,0], +[2975,-1,1,1,-1,0,0,1,-1,0,0,1,1,1,0,0,1,-1,-3,0,1,-3,0,1,3,4,4,3,-1,-1,0,-3,1,5,0,0,-1,4,-4,-3,-3,4,-1,-5,-13,-5,1,-5,0,12,3,12,19,-5,-1,55,15,5,0,-65,-25,-41,-20,135,255,140,-665,1,-1,0,0,1,-3,5,0,-1,0,0,0,0], +[3213,-1,-1,1,1,-1,-1,-1,1,0,2,0,0,0,1,0,0,-1,1,1,3,-1,0,3,-3,1,9,1,-3,-3,-2,0,0,0,-1,0,0,1,1,-1,-1,-3,-3,9,17,-7,3,-3,-2,-11,1,-3,1,9,-19,69,-9,9,8,-35,37,-27,21,85,-147,189,693,0,0,1,-1,0,0,0,0,0,0,-1,3,0], +[3213,1,1,1,1,1,1,1,1,0,0,0,0,0,-1,0,0,1,1,1,1,1,0,-3,-3,-3,-3,-3,-3,-3,-4,0,0,0,-1,0,0,1,1,1,1,-3,-3,-3,13,13,-3,-3,-4,13,13,-3,-3,-3,13,-51,9,9,8,-35,-35,-51,-51,205,141,189,-819,0,0,-1,-1,0,0,0,0,0,0,-1,3,0], +[3400,-1,-1,1,1,0,0,0,0,0,0,3,-1,3,0,0,0,1,-1,2,0,0,0,1,-1,2,2,0,0,0,0,-1,-1,7,0,-2,-2,-2,-2,0,0,6,8,8,8,8,-3,3,0,14,8,14,8,8,40,40,5,-5,0,40,40,72,30,200,200,190,840,2,0,0,0,-2,2,10,1,1,0,0,0,0], +[3570,-1,-1,1,1,1,1,0,0,0,0,-2,0,-6,0,0,0,1,-5,-3,2,2,0,-3,-1,1,9,-2,-2,6,0,2,0,6,0,0,0,1,1,-2,-2,1,2,-6,2,2,1,3,0,1,-6,-7,-14,18,34,66,5,15,0,10,10,-14,-15,-110,50,105,210,0,0,0,0,0,8,24,0,0,-1,1,5,0], +[3570,0,0,2,2,-1,-1,0,0,0,0,0,0,0,-1,0,0,0,-2,-1,-2,-2,-2,0,-2,-1,-1,-2,-2,-2,-2,-2,2,6,1,0,0,-1,-1,2,2,-9,-6,-6,-6,-6,0,6,2,7,2,7,2,2,-30,-30,16,6,10,50,50,18,39,178,178,231,882,-1,1,1,1,3,7,15,0,0,0,0,0,0], +[3570,2,0,0,-2,1,-1,0,0,0,0,-2,0,-6,-1,0,0,0,2,1,2,-2,-2,2,-4,-1,3,-2,-2,2,-2,2,0,6,1,0,0,-3,1,-2,2,7,6,-6,-10,6,-2,0,2,-13,-2,-1,2,18,-30,50,-4,6,10,30,-50,34,-21,98,-142,231,-798,3,-1,1,1,-1,-1,15,0,0,0,0,0,0], +[3808,1,-1,1,-1,0,0,0,0,1,-1,-2,0,-6,0,0,0,-1,3,0,0,0,1,-3,1,0,0,0,0,0,3,-2,0,10,2,0,-2,4,-4,0,0,-8,0,0,16,-16,1,-3,3,0,0,16,0,0,32,-96,-5,7,-7,16,-16,-32,0,96,-32,112,-672,0,0,0,2,0,-8,40,0,1,0,-1,3,0], +[4200,-1,1,-1,-3,1,-1,0,0,0,0,-2,0,-6,0,0,0,-1,-1,-1,0,0,0,1,-3,-3,1,0,0,0,0,0,-2,-12,0,0,0,-1,3,4,-4,1,0,0,8,-8,1,-3,0,5,8,-15,24,-8,8,40,15,15,0,80,0,40,45,200,360,105,840,-2,0,0,0,-2,-6,-30,0,0,0,0,0,1], +[4760,1,-1,-1,1,1,-1,0,0,-1,-1,2,0,-2,0,0,1,1,-1,1,0,0,1,-1,1,-1,-5,0,0,0,1,4,-2,8,2,0,-1,5,1,4,-4,-1,0,0,-8,8,-1,1,-3,-13,-8,7,8,40,-8,-40,1,-1,5,-16,64,-40,-5,56,-104,287,952,-2,0,1,-1,2,-2,-10,0,-1,0,0,0,0], +[5712,0,0,0,0,0,0,0,0,0,0,-1,1,3,-1,0,0,-2,2,0,0,0,0,-2,-6,4,4,0,0,0,-4,3,1,15,1,0,0,0,0,0,0,-4,0,16,0,0,2,6,-4,-4,0,12,16,16,16,16,-6,6,-8,0,0,80,-36,80,336,-84,336,-2,0,-1,1,-2,-6,-30,0,0,0,1,-3,0], +[5950,0,0,0,0,-1,-1,0,0,0,0,-4,0,4,0,0,1,2,-2,1,-2,-2,0,-2,2,1,1,2,2,2,0,2,-2,10,0,0,1,-3,-3,2,2,5,-10,6,6,6,2,-2,0,13,-2,-19,-2,-2,14,-50,-10,10,0,30,30,-34,-35,190,-130,-35,-770,1,-1,0,0,1,5,-35,0,1,0,0,0,0], +[5950,1,1,-1,-1,-1,-1,0,0,0,0,2,0,6,0,0,0,-1,-3,-1,2,2,0,3,1,-1,-1,-6,2,2,0,4,2,-8,0,0,-2,-1,-1,2,2,-1,-2,6,-2,-2,-1,-3,0,15,-10,-17,-10,38,14,30,-5,25,0,-10,-10,14,15,-210,190,175,-210,-1,-1,0,0,3,-5,-5,0,1,0,0,0,0], +[7140,-1,-1,-1,-1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,2,0,0,-1,1,1,2,-6,-4,-4,4,-1,4,0,12,-2,0,0,2,2,0,0,6,-4,-12,-4,-4,-3,-3,3,-2,-4,22,20,-12,4,100,-11,21,-5,-4,-4,-60,30,4,484,-42,-252,-3,1,-1,1,1,1,-15,0,0,0,0,0,0], +[8160,-1,1,-1,1,0,0,0,0,-1,1,-2,0,-6,0,0,0,-1,3,0,0,0,1,1,5,0,0,0,0,0,-1,2,0,6,2,-2,0,-4,4,0,0,-8,0,0,-16,16,1,-3,3,0,0,-16,0,0,32,160,-1,-21,5,-16,16,-32,0,96,224,-48,-672,0,0,-1,-1,4,-4,60,1,0,0,0,0,0], +[8925,-1,-1,-3,1,2,0,1,-1,0,0,0,0,0,0,0,0,1,3,0,-1,-1,0,1,-1,2,6,-3,1,-3,0,-4,0,-12,0,0,0,0,4,-1,3,6,-7,9,5,-19,-3,3,0,-6,-3,-10,-7,33,13,-155,5,15,0,-15,25,21,-30,165,125,-210,-315,0,0,0,0,4,-4,60,0,0,0,0,0,0], +[8925,1,1,-1,3,1,-1,1,-1,0,0,1,-1,-3,0,0,0,1,-1,-1,-1,-1,0,1,3,-3,1,5,1,-3,0,3,1,15,0,0,0,-1,3,-5,-1,1,1,-7,13,-11,1,3,0,5,5,-15,-15,-23,13,85,-15,15,0,-55,-15,37,45,245,-195,105,1365,-2,0,0,0,-2,-6,-30,0,0,0,0,0,0], +[8960,0,0,-2,2,0,0,0,0,-1,1,0,0,8,0,0,-1,0,-2,0,0,0,1,0,2,0,0,0,0,0,-1,-4,0,-4,2,0,-1,4,-4,0,0,0,0,0,0,0,0,2,3,-8,0,8,0,0,0,0,-16,14,5,64,-64,0,-40,256,-256,392,-1792,0,0,-1,-1,0,8,-40,0,-1,0,0,0,1], +[9639,0,0,0,0,0,0,-1,-1,1,1,0,0,0,0,0,0,0,0,0,-1,-1,1,0,0,0,0,-1,7,-1,-3,0,0,0,0,0,0,0,0,3,3,0,7,-9,-9,-9,0,0,-3,0,-9,0,15,-33,39,-105,0,0,9,-9,-9,-9,0,-9,-153,0,567,-3,-1,0,0,-3,9,81,0,0,1,0,4,0], +[10200,-1,1,3,1,-1,1,0,0,0,0,0,0,0,0,-1,0,1,-3,1,0,0,0,-1,-1,-1,-5,0,0,0,0,2,-2,-6,0,1,0,-3,1,-4,4,3,0,0,8,-8,3,3,0,-9,-8,11,8,40,-8,-40,5,-15,0,0,-80,24,15,120,-40,435,-1800,-2,0,0,0,2,-10,30,1,0,0,0,0,0], +[11900,0,0,-2,-2,0,0,0,0,0,0,-1,-1,7,0,0,1,-2,0,2,0,0,0,-2,-8,-2,-2,4,4,4,0,1,1,-7,0,0,-1,-2,-2,0,0,2,-4,-4,12,12,2,4,0,-6,-4,10,-20,-20,28,220,10,20,0,-20,-20,-4,10,60,-260,-70,700,1,1,0,0,1,1,65,0,-1,0,0,0,0], +[11900,1,1,-1,-1,0,0,0,0,0,0,3,-1,3,0,0,0,-1,1,0,0,0,0,-1,1,0,8,-4,-4,4,0,-5,-1,11,0,0,2,-4,-4,0,0,0,4,-4,4,4,3,-3,0,16,-12,-8,12,44,-4,-100,-5,5,0,20,20,-36,0,220,-260,-280,-420,-1,1,0,0,-1,-5,35,0,-1,0,0,0,0], +[13056,0,0,2,-2,0,0,0,0,1,-1,0,0,0,-1,1,0,0,-2,0,0,0,1,0,2,0,0,0,0,0,-1,-4,0,-12,1,1,0,-4,4,0,0,0,0,0,0,0,0,-6,-1,-8,0,8,0,0,0,0,-16,6,1,-64,64,0,24,256,-256,456,2304,0,0,-1,1,0,8,24,1,0,-1,0,-4,0], +[13600,0,0,0,0,0,0,0,0,0,0,2,0,-2,0,-1,1,2,-2,0,0,0,0,-2,2,-4,-4,0,0,0,0,-4,2,-8,0,-1,1,0,0,0,0,-4,0,0,0,0,2,-2,0,-20,0,-4,32,32,32,160,-10,10,0,0,0,32,-20,160,800,-260,160,2,0,0,0,-2,2,10,-1,1,0,0,0,0], +[14280,-1,-1,-1,-1,0,0,0,0,0,0,-1,1,3,0,0,0,3,-1,-2,0,0,0,-1,-5,2,2,0,0,0,0,1,-1,-3,0,0,0,2,2,0,0,-10,8,-8,8,8,-1,3,0,14,-8,-2,8,8,-24,104,-5,15,0,-40,-40,8,30,200,-440,-210,840,2,0,0,0,2,-2,6,0,0,1,-1,-5,0], +[14280,1,1,-1,-1,0,0,0,0,0,0,1,-1,-3,-1,0,0,1,3,-2,0,0,2,1,-5,2,2,0,0,0,-2,1,-1,-3,-1,0,0,2,2,0,0,-2,-8,8,-8,-8,1,3,2,6,-8,22,8,8,40,40,1,-21,-10,-40,-40,-56,54,72,328,294,-1848,2,0,1,-1,-2,10,-30,0,0,0,0,0,0], +[14688,-1,1,-1,1,0,0,0,0,-1,1,0,0,0,1,0,0,-1,-1,0,0,0,-1,-3,-3,0,0,0,0,0,1,0,0,0,1,2,0,-4,4,0,0,0,0,0,-16,16,-3,-3,1,8,0,24,0,0,32,-96,-9,-9,-17,-16,16,96,-24,224,96,216,2016,0,0,1,1,0,0,0,-1,0,0,-1,3,0], +[16065,-1,-1,-1,-1,0,0,1,-1,1,-1,0,0,0,0,0,0,-1,-1,2,-1,3,-1,3,3,-2,6,1,-3,-3,1,0,0,0,-2,0,0,2,2,3,3,-6,1,-3,-19,5,3,3,-3,2,5,-6,-11,-3,17,105,-9,-9,-5,41,-31,-39,-30,329,-159,378,-2583,0,0,1,1,0,0,0,0,0,0,0,0,0], +[16065,0,0,2,-2,-1,1,-1,1,1,1,0,0,0,-1,0,0,0,2,1,-1,-1,-1,0,6,-1,3,-3,1,-3,3,0,0,0,1,0,0,5,1,-1,-5,3,-3,-3,-15,9,0,6,-1,-1,1,-21,-19,21,33,-135,0,18,-5,-19,-59,57,39,329,33,-189,1449,0,0,0,-2,0,0,0,0,0,0,0,0,0], +[16065,0,0,2,2,-1,-1,1,-1,1,-1,0,0,0,1,0,0,0,2,-1,-1,3,-1,0,-6,3,3,1,5,-3,-3,0,0,0,1,0,0,-1,-1,-1,-1,3,1,-3,-3,21,0,-6,1,-13,5,3,-3,21,-15,-135,0,18,-5,41,-31,-87,51,89,417,-189,441,0,0,0,-2,0,0,0,0,0,0,0,0,0], +[16065,0,0,2,2,1,1,-1,-1,1,1,0,0,0,-1,0,0,0,2,-1,1,1,-1,0,-6,-1,-9,5,-3,-3,3,0,0,0,1,0,0,-1,-1,1,1,3,1,9,-15,-15,0,-6,-1,11,-7,3,-7,9,-15,225,0,18,-5,41,41,-15,-21,209,-447,-189,-1071,0,0,0,-2,0,0,0,0,0,0,0,0,0], +[16065,1,1,-1,-1,0,0,-1,-1,1,1,0,0,0,0,0,0,1,-1,2,1,1,-1,-3,3,-2,6,5,5,-3,-1,0,0,0,-2,0,0,2,2,-3,-3,-6,1,9,1,1,-3,3,3,2,-7,-6,1,33,-47,-15,9,-9,-5,41,41,-63,-30,-31,129,378,1953,0,0,-1,1,0,0,0,0,0,0,0,0,0], +[17850,-1,1,-1,1,-1,1,0,0,0,0,-1,1,3,0,0,0,1,5,-1,-2,2,0,3,-1,-3,1,-2,-2,2,0,-1,1,3,0,0,0,-1,-5,2,-2,5,-2,-14,14,-2,-1,3,0,-7,-10,5,-6,10,10,90,5,-15,0,-10,70,-22,-15,170,-70,525,2730,1,-1,0,0,-3,-7,-15,0,0,0,0,0,0], +[17850,0,2,-2,0,-1,1,0,0,0,0,-1,-1,-9,0,0,0,0,-2,1,-2,2,0,2,0,3,-1,-2,-2,-6,0,3,-1,3,0,0,0,1,-3,2,-2,-1,6,2,6,-10,2,0,0,-5,-2,15,-6,-22,-54,-70,0,30,0,-50,30,74,-45,10,570,-105,-630,2,0,0,0,2,6,30,0,0,0,0,0,0], +[18360,-1,1,1,-1,-1,1,0,0,-1,-1,0,0,0,0,1,0,-1,1,1,0,0,1,-3,3,-1,3,0,0,0,1,0,0,0,2,-1,0,1,5,-4,4,3,0,0,8,-8,-3,3,-3,7,-8,3,8,-24,-40,120,-9,9,5,64,-16,-72,15,-104,696,27,792,0,0,1,-1,0,0,0,-1,0,0,0,0,0], +[19040,1,-1,1,-1,0,0,0,0,1,-1,0,0,0,1,0,0,-1,-1,0,0,0,-1,1,1,0,0,0,0,0,-3,4,0,-4,1,0,2,4,-4,0,0,0,0,0,16,-16,-3,-3,1,8,0,-8,0,0,32,160,-5,-37,-5,16,-16,96,-24,224,352,56,2016,0,0,0,-2,4,4,20,0,-1,0,0,0,0], +[23800,-1,-1,-1,-1,0,0,0,0,0,0,-1,-1,7,0,0,1,-1,3,-2,0,0,0,-1,3,-2,-2,0,0,0,0,-3,1,13,0,0,1,2,2,0,0,2,8,8,8,8,-1,-5,0,-6,-8,-6,-8,-8,-40,-40,15,-5,0,-40,-40,56,10,120,120,490,-3080,-2,0,0,0,2,6,-50,0,1,0,0,0,0], +[23800,1,-1,1,3,1,-1,0,0,0,0,-2,0,2,0,0,-1,-1,-1,1,0,0,0,-3,1,-1,3,0,0,0,0,-2,0,-14,0,0,1,1,-3,4,-4,7,0,0,-8,8,1,5,0,11,-8,7,8,-24,-40,120,-5,-5,0,-80,0,-8,35,-40,760,175,-1960,0,0,0,0,0,-8,40,0,1,0,0,0,0], +[26775,0,0,0,0,-1,-1,-1,-1,0,0,3,1,-9,0,0,0,0,0,-1,-1,-1,0,0,0,3,-5,-1,-1,7,0,3,1,-9,0,0,0,3,3,-1,-1,3,-1,7,15,15,0,0,0,3,-1,-21,-9,-41,-9,-105,0,0,0,15,15,-9,-45,375,-105,315,-3465,1,1,0,0,-3,-3,45,0,0,0,0,0,0], +[26775,0,0,0,0,-1,-1,1,1,0,0,-3,-1,9,0,0,0,0,0,-1,-1,-1,0,0,0,3,-5,3,-5,-5,0,3,1,-9,0,0,0,3,3,-1,-1,3,7,-1,-9,-9,0,0,0,3,-1,-21,15,31,39,-105,0,0,0,15,15,-57,-45,-345,-105,315,1575,1,1,0,0,-3,-3,45,0,0,0,0,0,0], +[28560,0,0,2,2,0,0,0,0,-1,-1,-2,0,-6,1,0,0,-2,0,2,0,0,1,2,4,2,-6,0,0,0,-3,-2,0,-6,-1,0,0,2,2,0,0,-2,0,0,0,0,-2,0,1,6,-16,-2,-16,48,16,80,10,12,5,-16,-16,16,6,336,-368,-546,336,0,0,0,2,-4,4,-60,0,0,0,0,0,0], +[28917,0,0,0,0,0,0,-1,1,-2,0,0,0,0,0,0,0,0,0,0,3,-1,-2,0,0,0,0,1,5,-3,0,0,0,0,0,0,0,0,0,3,3,0,5,-15,9,-15,0,0,0,0,9,0,-15,9,21,-99,0,0,-18,-27,45,-99,0,333,405,0,-2835,0,0,0,0,0,0,0,0,0,0,1,-3,0], +[30464,0,0,2,-2,0,0,0,0,1,-1,0,0,8,0,0,-1,0,-2,0,0,0,1,0,-6,0,0,0,0,0,3,0,0,8,0,0,-1,-4,4,0,0,0,0,0,0,0,0,2,3,-8,0,-24,0,0,0,0,0,-10,9,-64,64,0,-40,256,768,-280,-1792,0,0,0,0,0,0,-64,0,-1,1,0,4,0], +[32130,-1,-1,1,1,1,1,0,0,0,0,0,0,0,-1,0,0,-1,1,1,-2,-2,2,3,-3,-3,-3,-2,6,6,-2,0,0,0,-1,0,0,1,1,-2,-2,-3,2,-6,2,2,3,-3,2,13,10,-3,-6,42,-46,-30,-9,9,-10,10,10,18,-51,-398,258,189,882,0,0,1,-1,0,0,0,0,0,0,0,0,0], +[32130,1,-1,1,-1,1,-1,0,0,0,0,0,0,0,1,0,0,1,1,-1,2,-2,2,3,3,1,-3,-2,-2,-6,2,0,0,0,-1,0,0,-5,-1,-2,2,-3,-2,-6,-2,14,3,3,-2,1,-10,21,-14,-30,-14,-30,9,9,-10,70,-10,18,-39,82,642,189,2898,0,0,-1,-1,0,0,0,0,0,0,0,0,0], +[32130,1,1,1,1,-1,-1,0,0,0,0,0,0,0,1,0,0,1,1,1,-2,-2,2,-3,-3,1,9,-2,-2,6,2,0,0,0,-1,0,0,1,1,2,2,-3,2,-6,-14,-14,-3,-3,-2,-11,10,-3,-14,18,-14,210,9,9,-10,10,10,66,21,-158,-318,189,-2142,0,0,-1,-1,0,0,0,0,0,0,0,0,0], +[34425,0,0,0,0,1,1,-1,-1,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,5,-3,5,-3,-3,0,0,0,0,0,-1,0,-3,-3,1,1,-3,-7,-15,9,9,0,0,0,-3,1,-27,17,33,9,-135,0,0,0,-15,-15,105,45,-375,-135,405,-2295,0,0,0,0,0,0,0,-1,0,0,0,0,0], +[34425,0,0,0,0,1,1,1,1,0,0,0,0,0,0,-1,0,0,0,1,1,1,0,0,0,5,-3,1,1,9,0,0,0,0,0,-1,0,-3,-3,1,1,-3,1,9,-15,-15,0,0,0,-3,1,-27,-7,-39,-39,-135,0,0,0,-15,-15,-39,45,345,-135,405,4185,0,0,0,0,0,0,0,-1,0,0,0,0,0], +[34560,0,0,-2,2,0,0,0,0,-1,1,0,0,0,-1,1,0,0,-2,0,0,0,1,0,-6,0,0,0,0,0,3,0,0,0,-1,1,0,4,-4,0,0,0,0,0,0,0,0,-6,-1,-8,0,-24,0,0,0,0,0,-18,5,64,-64,0,24,256,768,-216,2304,0,0,0,2,0,0,0,1,0,0,0,0,-1], +[38080,0,0,0,0,0,0,0,0,0,0,2,0,-10,0,0,-1,-2,-2,0,0,0,0,-2,-2,0,0,0,0,0,0,-2,0,10,0,0,1,0,0,0,0,8,0,0,0,0,2,2,0,-8,0,-8,0,0,64,64,10,10,0,0,0,-64,-40,-320,-320,280,2240,0,0,0,0,4,4,-44,0,1,1,-1,-5,0], +[38556,0,0,0,0,0,0,0,0,-1,-1,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,-4,-4,-4,3,0,0,0,0,0,0,0,0,0,0,0,-4,12,12,12,0,0,3,0,12,0,12,12,-36,156,0,0,-9,-36,-36,-36,0,-36,-612,0,2268,-3,-1,0,0,-3,9,81,0,0,1,1,1,0], +[43520,0,0,0,0,0,0,0,0,0,0,0,0,-8,1,-1,1,0,4,0,0,0,-2,0,-4,0,0,0,0,0,2,-4,0,-4,1,1,-1,0,0,0,0,0,0,0,0,0,0,4,-2,16,0,-16,0,0,0,0,-16,-4,10,0,0,0,16,-512,512,176,-512,0,0,-1,1,0,8,-40,1,-1,0,0,0,0], +[47600,0,0,0,0,0,0,0,0,0,0,-1,1,3,0,0,0,0,-4,0,0,0,0,4,0,-4,-4,0,0,0,0,-3,-1,17,0,0,2,0,0,0,0,-4,0,16,0,0,-4,0,0,-4,0,12,-16,-16,48,-80,0,20,0,0,0,-16,60,-400,240,140,-1680,2,0,0,0,-2,-6,50,0,-1,0,0,0,0], +[48195,0,0,0,0,0,0,-1,-1,0,0,0,0,0,0,0,0,0,0,0,-1,-1,0,0,0,0,0,-5,3,-5,0,0,0,0,0,0,0,0,0,3,3,0,3,3,3,3,0,0,0,0,3,0,27,-21,3,51,0,0,0,-45,-45,-45,0,-45,-765,0,2835,3,1,0,0,3,-9,-81,0,0,-1,1,5,0], +[51408,0,0,-2,-2,0,0,0,0,1,1,0,0,0,0,0,0,0,-2,-2,0,0,1,0,6,2,-6,0,0,0,-3,0,0,0,2,0,0,-2,-2,0,0,6,0,0,0,0,0,6,-3,-2,16,6,-16,48,-48,144,0,-18,-7,16,16,-48,30,16,-48,-378,-1008,0,0,0,2,0,0,0,0,0,0,-1,3,0], +[53550,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,-2,-2,0,0,0,-3,5,2,-6,2,0,6,2,-18,0,0,0,-3,-3,-2,-2,-3,6,6,6,6,0,0,0,-3,-2,21,6,-10,30,-210,0,0,0,30,30,-66,45,30,-210,-315,-1890,-1,-1,0,0,3,3,-45,0,0,0,0,0,0], +[57120,0,0,0,0,0,0,0,0,0,0,2,0,6,-1,0,0,2,2,0,0,0,-2,-2,6,4,4,0,0,0,-2,0,-2,-12,1,0,0,0,0,0,0,-4,0,0,0,0,2,-6,2,-4,0,12,-32,-32,32,160,6,6,10,0,0,32,-36,-352,288,-84,672,-2,0,1,1,-2,-6,-30,0,0,0,0,0,0], +[65536,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,-2,2,-2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-32,16,0,0,0,0,0,0,-512,0,0,0,0,-2,0,0,64,-1,1,-1,0,-4,1], +[68850,0,0,0,0,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,-1,2,2,0,0,0,-5,3,6,-2,6,0,0,0,0,0,-2,0,3,3,2,2,3,-6,-6,-6,-6,0,0,0,3,2,27,10,-6,-30,-270,0,0,0,-30,-30,66,-45,-30,-270,-405,1890,0,0,0,0,0,0,0,1,0,0,0,0,0], +[85050,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,-6,10,-6,0,0,0,0,0,0,0,0,0,-6,-6,0,-6,-6,-6,-6,0,0,0,0,-6,0,42,-54,-6,90,0,0,0,90,90,90,0,90,-1350,0,-5670,0,0,0,0,0,0,0,0,0,0,0,0,-1] +]} diff --git a/research/clifford-transported-fibre-gram/CLASS-ALGEBRA.md b/research/clifford-transported-fibre-gram/CLASS-ALGEBRA.md new file mode 100644 index 0000000000..8f6a27b1da --- /dev/null +++ b/research/clifford-transported-fibre-gram/CLASS-ALGEBRA.md @@ -0,0 +1,23 @@ +# Recognizing relative classes and compiling the central kernel + +Use columns in the four-qubit binary Pauli convention. Bits 0 through 3 pair with bits 4 through 7. For each symplectic map $S$ and each of the 256 vectors $v$, find the first monic linear dependence of the sequence $v,Sv,\ldots$ by binary elimination. Record its polynomial and the bits $\langle v,S^jv\rangle$ through that degree, including the final bit. A symplectic conjugation permutes the vectors and preserves both quantities. The resulting histogram is therefore constant on each conjugacy class. + +The included native representatives cover all 81 ordinary classes of $G=\mathrm{Sp}(8,2)$, of order 47,377,612,800. Their histograms are pairwise distinct. This finite check proves that each accepted symplectic input has an unambiguous class label. The two ordinary columns that coincide across every rationalized character are combined for the central calculation. The other 79 columns stand alone. Thus relative maps supplied by the caller can be located in the rational table by evaluating a histogram, with no group enumeration. + +Let $n_j$ be the rational-class sizes, $r_B$ a sum of the ordinary characters in Galois orbit $B$, and $d_B$ the common constituent degree. Orthogonality gives the orbit length $m_B=\sum_j n_jr_B(j)^2/|G|$ and $d_B=r_B(1)/m_B$. For per-element coefficients constant on rational classes, the central character transform and its inverse are + +$$ + T_{Bj}=n_jr_B(j)/r_B(1),\qquad (T^{-1})_{jB}=d_Br_B(j)/|G|. +$$ + +All packet sums are real on these classes. Put $F_j=(-64)^{\dim\operatorname{Fix}(S_j)}$. The integer class matrix is $M=T^{-1}\operatorname{diag}(TF)T$. Its column at the identity is $F$. The width-13 Gram operator uses $M/16^{12}$. Apply powers or scalar polynomials to class coefficients in this 80-dimensional space. Use the resulting coefficient at the relative class for each requested source/target pair. + +`native_classes.g` obtains ordinary representatives and character values directly from the natural group acting faithfully on the 255 nonzero vectors, using GAP 4.14 (The GAP Group). Reversing the order of the high four coordinates transports the native antidiagonal pairing to the Pauli convention. The class ordering is derived from the histograms. An optional rebuild compares signatures, sizes, fixed dimensions and every packet entry, so arbitrary choices of representatives may vary. From this directory run + +```sh +gap -A -q -b -T native_classes.g > /tmp/sp8-classes.json +python3.12 -IB build_classes.py /tmp/sp8-classes.json +python3.12 -IB check_classes.py +``` + +The registered Python replay also checks 405 changes of symplectic basis, packet orthogonality, the adjoint identity $n_iM_{ij}=n_jM_{ji}$, all character eigenvectors, the identity coefficient of the squared kernel and the two width-13 spectral endpoints. diff --git a/research/clifford-transported-fibre-gram/PROOF.md b/research/clifford-transported-fibre-gram/PROOF.md new file mode 100644 index 0000000000..a379b688f4 --- /dev/null +++ b/research/clifford-transported-fibre-gram/PROOF.md @@ -0,0 +1,45 @@ +# Fibre coordinates and the width-13 normal operator + +Let $G=\operatorname{Sp}(8,2)$ and $W_p=X^xZ^z$ for $p=16x+z$. Fix $U_S$ for each $S\in G$ using the transvection word returned by the #7800 binary reduction. For an axis $a$, use the Gaussian-dyadic unitary $R_a=(1+i)(I+iP_a)/2$, $P_a=i^{x_a\cdot z_a\bmod2}W_a$. A word in application order $a_1,\ldots,a_\ell$ gives $U_S=R_{a_\ell}\cdots R_{a_1}$. Each word has $\ell\le16$. Our coefficient indexed by $(S,p)$ refers to the absolute lift $V_{S,p}=W_p U_S$. Define $A$ with columns $(\operatorname{vec}V_{S,p}/4)^{\otimes13}$, using the computational row/column order. All inner products are conjugate-linear in the first entry. [Pinned Bell lifts and projective-coordinate conventions](https://github.com/apoursh/integer-mult-bounds/blob/fdc90699f4a64139ed6d84cdbf9a606ff0ccd32e/research/clifford-sparse-row/PROOF.md) + +## Read out a batch on one observation chart + +Consider the #7800 Bell decoder $B$. At a raw address denote the twelve 4-bit shifts of its adjacent pairs by $s$, the twelve free second nibbles by $v$, and the two singleton nibbles by $y$. Compute the partial Walsh transform $T(s,w,y)=\sum_v(-1)^{w\cdot v}Y(s,v,y)$. For a supplied affine-quadratic chart, #7813 produces a common complex scalar, affine support equations and a quadratic phase function for $T$ on its support. Its restrictions to the singleton directions have the same kernel $U$ of dimension $e\le8$ at every choice of $(s,w)$. Each translated and character-modulated nonempty slice fits in one Fourier bin of a coset of $U$ after removing a common quadratic phase. These data depend only on the chart. [Predecessor elimination and bin construction](https://github.com/apoursh/integer-mult-bounds/blob/65573785774c6bbac12485a4d90cd82778d25e36/research/clifford-compact-pauli-fibre/PROOF.md) + +Start with the 4,265 identity-fibre records $(I,J,n,\delta)$, where $I,J$ are input/output six-tuples, $n$ is the integer numerator and $i^\delta$ the compiler correction. On the output labels compute two tables using the fixed word for $S$. Write $U_S W_u U_S^*=i^{\gamma(u)}W_{Su}$ and $U_SW_tU_S^\mathsf{T}=i^{\theta(t)}W_{L(t)}$. The latter label action is affine. Transport replaces $J$ by $(L(t):t\in J)$ and changes the correction to + +$$\delta' = \delta+\gamma(\mathop{\bigoplus} J)-\sum_{t\in J}\theta(t)\pmod4.$$ + +Indeed the six Bell phases multiply, and removing the ordinary Weyl phase on their sum gives the block transport phase. The correction undoes this phase. Six labels cancel the affine offset in their XOR. The ratio is independent of lifting the same symplectic map through a Pauli and a Gaussian unit: a Pauli contributes the sum of the six conjugation signs, which is the sign on their XOR, and the sixth power of its squared unit is one. Thus this traversal gives the same records as composing the output symplectic maps before independently choosing their lifts. The correctness extends to arbitrary chart amplitudes because the two linear functionals agree term by term. + +Write $(x_o,z_o)=\bigoplus J'$ and $(x_i,z_i)=\bigoplus I$. The corrected singleton entry at $y+(x_o,x_i)$ gets the raw entry at $y$ with sign $(-1)^{(z_o,z_i)\cdot y}$. Both translations and the constant $i^{\delta'}$ are allowed by the shared bin calculation. After the per-coset transforms, chirp rotations and the common scalar, the compiler produces its corrected $16\times16$ target matrix. Right multiply by $U_S^*$ and take the sixteen length-16 Walsh transforms of its shifted diagonals to extract the trace against every $W_p U_S$. In the raw-sum convention of #7813 the final denominator is $4096$, from the Bell factor $4$, compiler denominator $1024$ and trace division by $16$, in addition to the supplied chart denominator and lift denominator. Tensoring each specified absolute lift thirteen times gives the corresponding one-hot complex coefficient. The procedure also evaluates $BY$ off the image of $A$. [Executable](readout.py) · [Direct off-image and gauge checks](verify_readout.py) + +One batch performs one Gauss sum in at most 48 variables and one chart/singleton basis construction. There are $512\ell$ elementary label/phase steps to tabulate a target, twelve label fields per read, at most 4,265 signed bin updates and $256(e+4)$ complex Walsh additions/subtractions per target. Each of the $\ell$ right-lift factors needs 256 two-term Gaussian combinations, followed by a common $(1\pm i)/2$ per entry. These counts exclude binary section solves, phase evaluation, phase rotations, reading the chart/circuit and writing 256 complex coefficients per target. All raw-observation access is through the supplied chart; the circuit constructor reads its specification once. Each unrotated singleton component before the common chart scalar has magnitude at most $12{,}800$ by the sum of absolute weights. A lift factor can increase an integer numerator component by at most four and adds one denominator bit. The final trace adds at most four numerator bits. Calls on separate pieces of a linear combination can be added with their actual complex weights. + +## An exact scalar convolution on every matrix entry + +For a coefficient vector $c$ write $M_T=\sum_b c_{T,b}V_{T,b}$. The inverse is $c_{T,b}=\operatorname{Tr}(V_{T,b}^*M_T)/16$, by orthogonality of the $W_b$. This is a scaled isometry with $\lVert M_T\rVert_F^2=16\sum_b|c_{T,b}|^2$. + +For $D=V_{S,p}^*V_{T,b}$ put $\tau=\operatorname{Tr}D$, $g=S^{-1}T$, and $k=\dim\ker(g-I)$. The trace of conjugation by $D$ on all matrices equals $|\tau|^2$. In the Weyl basis it equals the sum of the signs on the fixed Weyl labels. Indeed a fixed label's conjugation phase squares to one since its square is scalar. These signs form a character on the fixed subspace because two Weyl labels multiply to their sum up to scalar. The sum is either zero or $2^k$. In the latter case $\tau\in\mathbb Z[i,1/2]$ has this norm and equals a Gaussian unit times $(1+i)^k$: clear powers of two and factor in $\mathbb Z[i]$, using $2=-i(1+i)^2$. Hence $\tau^4=(-4)^k$ if it is nonzero. In both cases $\tau^{13}=(-64)^k\tau$. + +It follows that $K=A^*A$ has coefficient entry $(\tau/16)^{13}=16^{-12}(-64)^k\operatorname{Tr}(V_{S,p}^*V_{T,b})/16$. Substituting into the inverse coordinate formula gives, for **every** $c$, + +$$M_{Kc}(S)=\sum_{T\in G} f(S^{-1}T)M_c(T),\qquad f(g)=16^{-12}(-64)^{\dim\operatorname{Fix}(g)}.$$ + +The matrix entries of $M_c$ therefore give 256 independent copies of a scalar central convolution. The group size is 47,377,612,800. The nonzero/zero Pauli-trace pattern, its complex phases and cancellations all survive the change of coordinates. Computing the single-step weight needs only an eight-column binary rank since $\ker(S^{-1}T-I)=\ker(T-S)$. + +## Compile a complete filter before receiving its input + +In an irreducible character $\chi$ of degree $d$, convolution by $f$ has eigenvalue $\lambda_\chi=\sum_g f(g)\chi(g)/d$. The real rational packet sums in the accompanying table suffice, since inversion preserves $f$, Galois-conjugate characters have the same rational eigenvalue here, and $\chi(g^{-1})=\overline{\chi(g)}$. For a function $H$ on the 52 distinct eigenvalues the scalar kernel of $H(K)$ is + +$$h(g)=|G|^{-1}\sum_{\chi}d\,H(\lambda_\chi)\chi(g^{-1}).$$ + +For a packet of size $n$ use its character sum, whose value at the identity is $nd$, and keep the same constituent degree $d$ in the inverse transform. This gives at most 80 dot products of length 80. Concrete eight-column inputs are recognized in the same class order by the native certificate. The independent spectral multiplicity check uses $\sum_{\chi:\lambda_\chi=\lambda}d^2$ on the quotient, with an additional factor of 256 for the original Gram. [Geometric class lookup and regeneration](CLASS-ALGEBRA.md) · [Spectrum from #7772](https://github.com/aliromman/integer-mult-bounds/blob/1398fbdca3536389d8ac3c8b3aaa408f03e8f6c2/research/clifford-threshold-conditioning/RESULT.json) + +Taking $H(\lambda)=1/\lambda$ gives the exact inverse Gram kernel because all levels are positive. For one of the #7809 schedules put $p(X)=\prod_j(1-h_jX)$ and $q(X)=(1-p(X))/X$. Starting at $d_0$ with supplied $t$, each update is $d\leftarrow d+h_j(t-Kd)$. Induction gives the final value $p(K)d_0+q(K)t$. Thus two scalar kernels per schedule suffice, including its odd-denominator last shift where prescribed. The verifier independently multiplies the actual 51 or 52 integral class operators with rational step sizes, checks each of the 80 residual entries, and verifies $Kq+p=I$ and $KK^{-1}=I$ as exact class functions. [Pinned schedules](https://github.com/apoursh/integer-mult-bounds/blob/7efc2c67b32e305d20e484dc3afa9229ab119269/research/clifford-accelerated-dyadic-decoder/PROOF.md) · [Consumer and filters](gram.py) · [Checks](verify_gram.py) + +## Cost on named coefficient blocks + +An input dictionary denotes complete support in its named fibres; omitted fibres are exactly zero. Count $m$ supplied 256-entry blocks across all input dictionaries, $u$ distinct named source fibres in their union and $r$ distinct requested output fibres. Synthesize the $m$ matrices once, using sixteen length-16 Walsh transforms plus a lift for each. Each output needs at most $u$ relative class queries (or $u$ binary ranks for a single Gram application), $256m$ real-weight/complex-entry multiply-adds, and one adjoint lift followed by sixteen length-16 transforms. Each block change thus costs $1024$ complex Walsh additions and $256\ell$ two-term lift combinations. A zero or shared input/output may reduce work. The input contains up to $256m$ complex values plus eight 8-bit columns per named target; output size is $256r$ complex values. The example programs store source matrices and output blocks, the fixed class inventory or Bell read list where applicable, and ordinary header/work arrays. A query has no loop over unlisted intermediate group elements, even when the mathematically intermediate vectors are dense. All targets can be named, incurring their output size. [Block representation and executable](gram.py) + +Exact coefficient sizes are measurable. Over *all* 80 classes take the least common denominator across the kernels used by an action and use that denominator for every numerator. Its bit length and the maximum absolute numerator bit length are respectively $(145,145)$ for $K^{-1}$, $(11381,11381)$ for the 51-step pair, and $(7500,7500)$ for the 52-step pair. The Gram itself admits denominator $16^{12}$. Suppose supplied real and imaginary components have a shared positive denominator $D$ and numerator magnitude at most $2^B$. Let $L\le16$ be the largest lift length, $H$ the chosen common kernel denominator and $J$ the largest numerator bit length. An unreduced common denominator for a returned component is $D H 2^{2L+4}$. Its numerator magnitude is bounded by $\max(1,m)2^{B+8+4L+J}$: each Walsh bank contributes a factor of 16, each lift at most $4^L$ to each component of its numerator, and the scalar sum contributes at most $m2^J$. Shorter lift denominators can be padded to $2^L$ within the same bound. These are arithmetic/word counts on supplied blocks; $A^*y$ and $By$ for a general observation may both have dense support. Evaluating $By$ at requested targets does not certify it vanishes elsewhere. The cost of producing complete support for either schedule input, a full array of outputs, and a multiplication supplier are separate questions. diff --git a/research/clifford-transported-fibre-gram/README.md b/research/clifford-transported-fibre-gram/README.md new file mode 100644 index 0000000000..ec3279dad6 --- /dev/null +++ b/research/clifford-transported-fibre-gram/README.md @@ -0,0 +1,39 @@ +# Query any Clifford fibre and apply the width-13 Gram operator + +For the four-qubit width-13 dictionary, a change of Pauli coordinates turns the full Gram matrix into **256 independent copies of one scalar convolution** on $\operatorname{Sp}(8,2)$. Given coefficient blocks on known source fibres, the program evaluates any requested target blocks of the Gram, its exact inverse, or either complete #7809 schedule. A second consumer evaluates the specified Bell inverse on arbitrary affine-quadratic observations. Every requested symplectic target shares one partial Walsh transform, including queries outside the Clifford column span. [Proof, absolute lifts and resource bounds](PROOF.md) + +| Supplied input | Requested quantity | Work shared across queries | +|---|---|---| +| One 104-bit affine-quadratic chart | All 256 Bell decoder coefficients in each named fibre | One Gauss sum in at most 48 variables and one singleton basis. At most 4,265 signed bin updates per target. | +| Coefficients on $m$ complete source blocks, $r$ target blocks | $Kc$ or $K^{-1}c$ | Synthesize each source matrix once. At most $mr$ binary ranks or relative class lookups, and $256mr$ real-weight/complex-entry multiply-adds. | +| Starting coefficients $d_0$ and adjoint values $t$ on supplied supports | The final $d$ of either 51 or 52 updates $d\gets d+h(t-Kd)$ | Two scalar kernels compiled on 80 rational classes; the query cost depends on source and target counts and coefficient sizes. | + +Here each omitted source fibre has zero coefficients. General observations can have dense $A^*y$ and $By$; preparing their complete supports has a separate cost. For a known mixture $y=Ac$, the first normal-operator query gives $A^*y$ directly. The minimum common denominators for the compiled inverse Gram, 51-step pair and 52-step pair have bit lengths 145, 11,381 and 7,500, respectively. This contribution concerns decoder arithmetic at the existing width and multiplication bound. [Class recognition and reproducible GAP table](CLASS-ALGEBRA.md) · [Independent spectrum](https://github.com/aliromman/integer-mult-bounds/blob/1398fbdca3536389d8ac3c8b3aaa408f03e8f6c2/research/clifford-threshold-conditioning/RESULT.json) + +Ali Romman's #7815 recovers *unknown* support from a supplied exact tensor train, including any 19 four-qubit terms at width 13. Its complete output can supply the mixture above after rephasing the reported columns. Read its signature as $W_{\mathrm{output},\mathrm{input}}$, with signature index $16\,\mathrm{input}+\mathrm{output}$. Identify $S$ by conjugating the eight basis Weyls. If its normalized unitary $W/(1+i)^h=\eta W_pU_S$, multiply its coefficient by $\eta^{13}$ to express it in this package's convention. The 256 trace coordinates of `extract` identify $p$ and $\eta$. [Tensor-train decoder and signature format](https://github.com/aliromman/integer-mult-bounds/blob/34a20a30596467409e7361534d52495819787a78/research/clifford-unknown-support-decoder/README.md) + +## Reproduce + +Use CPython 3.12 and its standard library from the repository root. + +```sh +python3.12 -B scripts/research_package.py --package research/clifford-transported-fibre-gram +``` + +`readout.py input.json` accepts the #5704 `circuit`, optional `initial` address and `targets`. A target is the array of eight column images in the four-qubit binary Pauli convention. The output order is $16x+z$ with Gaussian rational pairs. The two independent readout oracles check every transported record at four targets, complex phases on literal tensor columns, and arbitrary nonmember observations. [Readout](readout.py) · [Oracle](verify_readout.py) + +`gram.py input.json` accepts the actions `gram`, `canonical`, `schedule51`, and `schedule52`. The first two take one list of source blocks. The schedules take two lists giving $d_0$ and $t$, respectively. Within each block, omitted Pauli indices are zero. Exact rational strings are accepted. For example, this request applies $K$ to the identity coefficient and asks for the fibre of a single X-axis transvection. The Pauli-identity output is $(-1+i)/128$. + +```json +{"action":"gram","inputs":[[{"target":[1,2,4,8,16,32,64,128],"coefficients":{"0":["1","0"]}}]],"targets":[[17,2,4,8,16,32,64,128]]} +``` + +The ordinary/optimized checks regenerate the filters, compare actual scheduled convolution factors in the class basis, and test literal thirteenth powers of complex traces, including zeros and nonzero odd-dimensional fixed spaces. [Gram consumer](gram.py) · [Independent checks](verify_gram.py) · [Verifier manifest](VERIFY.json) + +## Open next questions + +Which observation producers admit a direct compact description of $A^*y$ on a few fibres, or of its sum against the compiled scalar kernels, even when $y$ lies outside the Clifford span? An end-to-end estimate would include producing those values, moving them to this interface and delivering the requested outputs. + +## Credit + +The affine-quadratic signature and Gaussian contraction machinery are due to Ali Romman, with their retained notices. Nick Petalas and Ali Romman provided the fixed-space character calculations and spectral blocks, building on alephnan's Clifford sector work. The Bell compiler, compact identity-fibre consumer and scalar schedules are earlier work by apoursh. The native class construction uses the GAP Group's software. This extension and verification were prepared by apoursh with substantial OpenAI Codex assistance, under Apache-2.0. [Source pins](SOURCE-PINS.json) · [Retained notices](retained/predecessor/source/engine/source/) · [Public collaboration claim](https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19756386) diff --git a/research/clifford-transported-fibre-gram/SOURCE-PINS.json b/research/clifford-transported-fibre-gram/SOURCE-PINS.json new file mode 100644 index 0000000000..799da316d2 --- /dev/null +++ b/research/clifford-transported-fibre-gram/SOURCE-PINS.json @@ -0,0 +1,114 @@ +[ + { + "local": "retained/SCHEDULE.json", + "repository": "apoursh/integer-mult-bounds", + "commit": "7efc2c67b32e305d20e484dc3afa9229ab119269", + "path": "research/clifford-accelerated-dyadic-decoder/SCHEDULE.json", + "sha256": "77a6ffadc3eb0ec32ddde33898e3dc528e0cdcf3907e565a9fee6ee0a48f5055", + "git_blob": "8285a6ed622d68544ece2ecf668f54bf5b2e8bc2" + }, + { + "local": "retained/fibre.py", + "repository": "apoursh/integer-mult-bounds", + "commit": "65573785774c6bbac12485a4d90cd82778d25e36", + "path": "research/clifford-compact-pauli-fibre/fibre.py", + "sha256": "7f44deb22fb3dde89d71473120e98ce6eb9cef7a29ff2140893ec079db5af105", + "git_blob": "414fbb37a77da20ba933e7e552ada8f00cc2b738" + }, + { + "local": "retained/predecessor/RETAINED.json", + "repository": "apoursh/integer-mult-bounds", + "commit": "65573785774c6bbac12485a4d90cd82778d25e36", + "path": "research/clifford-compact-pauli-fibre/predecessor/RETAINED.json", + "sha256": "4bac919b0b78bfd312c6e6f5642644267f38ab6d6aa7125dc45b6d718ccfc046", + "git_blob": "520317e6511abc0b97674d4b9938e45abbfca51b" + }, + { + "local": "retained/predecessor/contract.py", + "repository": "apoursh/integer-mult-bounds", + "commit": "65573785774c6bbac12485a4d90cd82778d25e36", + "path": "research/clifford-compact-pauli-fibre/predecessor/contract.py", + "sha256": "ad127f9bb72b57360c2e93471c988488721848047e3c9914af094ad36701612e", + "git_blob": "11df2cef1492019bfc52f073fcfd3b02192b39f9" + }, + { + "local": "retained/predecessor/source/engine/INPUTS.json", + "repository": "apoursh/integer-mult-bounds", + "commit": "65573785774c6bbac12485a4d90cd82778d25e36", + "path": "research/clifford-compact-pauli-fibre/predecessor/source/engine/INPUTS.json", + "sha256": "c62bd55fd36c136ba2ec34f6d91ed481497932fadc7134d0b7e5c10009fd588c", + "git_blob": "f9d4fd920651b002370ffb5084dbef2abaa5ed44" + }, + { + "local": "retained/predecessor/source/engine/contractions.py", + "repository": "apoursh/integer-mult-bounds", + "commit": "65573785774c6bbac12485a4d90cd82778d25e36", + "path": "research/clifford-compact-pauli-fibre/predecessor/source/engine/contractions.py", + "sha256": "a2fc065d6f293ddcffe5b6eec7fff0fdf57c8e3d4c6be355bd92e87d3f1865ef", + "git_blob": "76c807deceea0b1a6b64b50735253959b07c144d" + }, + { + "local": "retained/predecessor/source/engine/source/LICENSE", + "repository": "apoursh/integer-mult-bounds", + "commit": "65573785774c6bbac12485a4d90cd82778d25e36", + "path": "research/clifford-compact-pauli-fibre/predecessor/source/engine/source/LICENSE", + "sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "git_blob": "261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64" + }, + { + "local": "retained/predecessor/source/engine/source/PR5698-NOTICE.md", + "repository": "apoursh/integer-mult-bounds", + "commit": "65573785774c6bbac12485a4d90cd82778d25e36", + "path": "research/clifford-compact-pauli-fibre/predecessor/source/engine/source/PR5698-NOTICE.md", + "sha256": "1f55b3e4bb80a60611b1fca0622da5a99fe7877446f03d0edd1dc8f3a5abadd2", + "git_blob": "56712e3195faf8c83319100065183b8b2488809d" + }, + { + "local": "retained/predecessor/source/engine/source/PR5704-NOTICE.md", + "repository": "apoursh/integer-mult-bounds", + "commit": "65573785774c6bbac12485a4d90cd82778d25e36", + "path": "research/clifford-compact-pauli-fibre/predecessor/source/engine/source/PR5704-NOTICE.md", + "sha256": "a77adc71861e3b9c73c703c5db5b671f61a1101d85d14cca08547e21d6d8dce4", + "git_blob": "b96b400e5ca04b3a9003a8b2c70a2461972d39d7" + }, + { + "local": "retained/predecessor/source/engine/source/PR5704-quadratic.py", + "repository": "apoursh/integer-mult-bounds", + "commit": "65573785774c6bbac12485a4d90cd82778d25e36", + "path": "research/clifford-compact-pauli-fibre/predecessor/source/engine/source/PR5704-quadratic.py", + "sha256": "d406584aed1479b75c387bc964b9e797b2f4f75e5f8c6bbea00df07f7d590a91", + "git_blob": "ce3c86ec07fd5767741e02ff0c88b93ba9164fb4" + }, + { + "local": "retained/predecessor/source/row/bell_reads.py", + "repository": "apoursh/integer-mult-bounds", + "commit": "65573785774c6bbac12485a4d90cd82778d25e36", + "path": "research/clifford-compact-pauli-fibre/predecessor/source/row/bell_reads.py", + "sha256": "44942462cd7778d23042bf827fb313d0e7acf99aa5b9793e411503e83d3421b7", + "git_blob": "32b2ed2a94dc77d04709fedb420bf0ffd6d74f73" + }, + { + "local": "retained/predecessor/source/row/compile_row.py", + "repository": "apoursh/integer-mult-bounds", + "commit": "65573785774c6bbac12485a4d90cd82778d25e36", + "path": "research/clifford-compact-pauli-fibre/predecessor/source/row/compile_row.py", + "sha256": "4e6420f6dcccfd76d64a3b14d94dbdd4803bfd780c921a225d8f29b5d9f0565b", + "git_blob": "daf35d6a26993ed00cfc25a9e16c9136fba2a275" + }, + { + "local": "retained/predecessor/source/row/raw_row.py", + "repository": "apoursh/integer-mult-bounds", + "commit": "65573785774c6bbac12485a4d90cd82778d25e36", + "path": "research/clifford-compact-pauli-fibre/predecessor/source/row/raw_row.py", + "sha256": "40fb7b900409d1908e01683830f44670417338412753ba77a37ea203f94aafa7", + "git_blob": "1787feb76acf78e3fd314bf3e0ecbe6cb2432316" + }, + { + "local": "retained/width13-spectrum.json", + "repository": "aliromman/integer-mult-bounds", + "commit": "1398fbdca3536389d8ac3c8b3aaa408f03e8f6c2", + "path": "research/clifford-threshold-conditioning/RESULT.json", + "sha256": "d032d5e63820f4ffe246d21adcd8d272f04dfd635a6fc519c4a81a366ca41d49", + "git_blob": "039f22ba0bfec63c02fb3a97959766b8ec3a1bfa" + } +] diff --git a/research/clifford-transported-fibre-gram/SOURCES.json b/research/clifford-transported-fibre-gram/SOURCES.json new file mode 100644 index 0000000000..e0ddb1d50a --- /dev/null +++ b/research/clifford-transported-fibre-gram/SOURCES.json @@ -0,0 +1,90 @@ +{ + "schema_version": 1, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "75d77b328ea02ded535e7f23aee5b1e55d0bb1a8", + "sha256": "154c3d30455d778fd3343b6b4851f0fa4665f0f7625b0adb3675e2bafbbf6bf1" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + } + ], + "cited_research": [ + { + "pr": 5704, + "head": "daa4d9dbd102d2a3677afc5614c56466bd2cf3a2", + "author": "aliromman", + "title": "Make complete Clifford replay 5.17x faster with exact quadratic states", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/5704" + }, + { + "pr": 5727, + "head": "8b74ecd0eea26d95b400e56435d35fbd261dc49b", + "author": "aliromman", + "title": "Add exact phase-sensitive Clifford contractions and attained finite-span errors", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/5727" + }, + { + "pr": 7772, + "head": "1398fbdca3536389d8ac3c8b3aaa408f03e8f6c2", + "author": "aliromman", + "title": "Determine sharp four-qubit Clifford threshold conditioning", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/7772" + }, + { + "pr": 7799, + "head": "7f08a74037788311cc6b7da27297b25f1b188e45", + "author": "apoursh", + "title": "Prove the sharp Gaussian-dyadic four-qubit Clifford tensor width is 13 (no κ)", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/7799" + }, + { + "pr": 7800, + "head": "fdc90699f4a64139ed6d84cdbf9a606ff0ccd32e", + "author": "apoursh", + "title": "Compile the width-13 Clifford decoder into 4,265 Bell reads and certify its dense input cost (no κ)", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/7800" + }, + { + "pr": 7801, + "head": "9d15f66abc9ccf760ca5f7ea442adeb87b8f7115", + "author": "apoursh", + "title": "Evaluate the 4,265-term Clifford identity row on a compact input with one Gauss sum", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/7801" + }, + { + "pr": 7805, + "head": "d3df403a13bee082a8cef62f190024aaf0cd08dd", + "author": "apoursh", + "title": "Determine the exact odd denominator of the canonical width-13 Clifford decoder", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/7805" + }, + { + "pr": 7809, + "head": "7efc2c67b32e305d20e484dc3afa9229ab119269", + "author": "apoursh", + "title": "Prove sharp 52- and 51-pass bounds for width-13 Clifford decoding", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/7809" + }, + { + "pr": 7813, + "head": "65573785774c6bbac12485a4d90cd82778d25e36", + "author": "apoursh", + "title": "Compute all 256 Pauli coefficients from one compact width-13 observation", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/7813" + }, + { + "pr": 7815, + "head": "34a20a30596467409e7361534d52495819787a78", + "author": "aliromman", + "title": "Recover all unknown Clifford terms from exact tensor trains", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/7815" + } + ] +} diff --git a/research/clifford-transported-fibre-gram/TASK.json b/research/clifford-transported-fibre-gram/TASK.json new file mode 100644 index 0000000000..5a9983a53d --- /dev/null +++ b/research/clifford-transported-fibre-gram/TASK.json @@ -0,0 +1,93 @@ +{ + "schema_version": 1, + "task_id": "uniform-transfer-audit", + "original_card": { + "id": "uniform-transfer-audit", + "question": "Can one of the selected record's five inherited assumptions be proved at its actual caller?", + "starting_points": [ + "docs/research/current-priorities.md", + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md" + ], + "methods": [ + "Construct and independently check one source-bound instance of the stated first experiment.", + "Seek an exact counterexample or target-specific complete-budget obstruction to that same proposed change." + ], + "acceptance_gate": "Identify the proposition and what would change downstream; do not equate a finite replay with a universal proof.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read revision 8, the selected review and live exact-source handoffs. Then follow this card's bounded first_experiment.", + "scope": "Source-bound orientation only, not a supplier replay or theorem proof." + }, + "first_experiment": "Choose one assumption ID (native_all_columns, owned_erasure, compiler, precision_tape, analytic_recovery), one quantified implication and exact dependency closure. Check current handoffs, including #5625 row reentry and #5707 root-prefix lowering, without treating their partial scope as the whole theorem. Prove or falsify that implication with a caller-bound argument; stop at the chosen obligation. Finite tests or root digits do not discharge an all-size statement.", + "bottleneck_link": "Judge the actual current supplier contract and complete signed target/paid bill; frozen-profile ceilings require an applicability proof.", + "allowed_variations": [ + "One exact source head, helper/cut region or quantified proposition and changed hypothesis; check live handoffs first. Different seeds are not different scopes." + ], + "scope_change_triggers": [ + "Changing source head, helper/cut domain, operation alphabet or caller boundary without recording the new scope.", + "Treating an archived proposal or local numerical pass as complete supplier admission." + ], + "overlap_terms": [ + "native_all_columns", + "owned_erasure", + "compiler", + "precision_tape", + "analytic_recovery" + ], + "existing_checks": [ + { + "scope": "PR #4100: proposed unconditional construction and finite checks, without independent acceptance.", + "evidence": "research/unconditional-batched-crt/README.md", + "remaining": "Independent proof audit of one caller-bound all-size implication; all other premises remain explicit.", + "status": "author-checked", + "source_commit": "337d04939571a637aeab54a0f58f54fde811663a", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "Selected PR5599: complete helper-subspace construction and independent caller replay; five framework assumptions remain.", + "evidence": "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md", + "remaining": "The next experiment must identify uncovered source-specific work. Successor archive intake does not transfer this admission.", + "status": "reviewed", + "source_commit": "09dd0965711ca7eeb169057a420abab1c9052137", + "selected_record_sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5" + } + ] + }, + "priority_revision": 8, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "selection_nonce": "af9f1a5bd5ca9ffa60b9bd99f8a25990", + "scope_key": "cdee6027333168fe48af", + "scope_status": "changed", + "actual_scope": "Compute the width-13 Pauli readout at named symplectic targets on affine-quadratic observations and apply the Gram, inverse Gram and decoder schedules from explicitly listed input fibres to requested output fibres.", + "scope_change_reason": "The previous interface produced only an identity-target readout. Spectral schedule certificates also left open how to apply their dense intermediates to sparse input and requested outputs.", + "bottleneck_link": "Specifies an exact cost and working representation for known-input and named-output operations in the four-qubit width-13 caller.", + "stop_rule": "Check phase-sensitive transport and off-image readout on literal probes, classify supplied relative group elements, and compare all-class polynomial identities with iterative central convolution and literal Gram entries.", + "outcome": "completed", + "evidence": "The package README, proof and registered verification commands describe the exact scope and controls.", + "author": "apoursh", + "ai_assistance": "Substantial OpenAI Codex assistance with mathematical derivation, verification and review.", + "open_questions": [ + { + "question": "Can requested-fibre inverse evaluation share the work across a structured, densely encoded coefficient input?", + "why_it_matters": "A sparse-to-requested interface still sums explicitly supplied occupied fibres.", + "first_step": "Choose a producer giving a common class or tensor representation for its occupied fibres and bound the contraction cost.", + "blocked_by": "Arbitrary undisclosed support requires an input interface and a way to bound read access." + } + ], + "claim": "https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19756386", + "overlap": "Read #1163, recent #1166 handoffs, active #7111 work and recent PRs; checked relevant all-state PR searches. The local overlap cache and sparse inventory have limited coverage. Compared #7812–#7814 and the active width-13 unknown-support discussion #7811 and PR #7815 to the claimed scope.", + "upstream_refresh": { + "date_utc": "2026-11-19", + "canonical_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "selected_orientation": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "selected": "The selected result is #7000. The revision-8 catalogue refers to the earlier #5599.", + "before_submission": "Fetched canonical main again and checked the current work against the live PR queue." + } +} diff --git a/research/clifford-transported-fibre-gram/VERIFY.json b/research/clifford-transported-fibre-gram/VERIFY.json new file mode 100644 index 0000000000..9d0d7ca533 --- /dev/null +++ b/research/clifford-transported-fibre-gram/VERIFY.json @@ -0,0 +1,90 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-E", + "-s", + "-W", + "error", + "-B", + "{package}/verify_readout.py" + ], + "timeout_seconds": 120, + "checks": "Absolute-phase arbitrary-fibre Bell transport, affine-quadratic input and independently contracted probes" + }, + { + "argv": [ + "{python}", + "-E", + "-s", + "-O", + "-W", + "error", + "-B", + "{package}/verify_readout.py" + ], + "timeout_seconds": 120, + "checks": "Absolute-phase arbitrary-fibre Bell transport, affine-quadratic input and independently contracted probes under optimized Python" + }, + { + "argv": [ + "{python}", + "-E", + "-s", + "-W", + "error", + "-B", + "{package}/check_classes.py" + ], + "timeout_seconds": 120, + "checks": "Complete rational class recognition, independent character table checks and integer matrix" + }, + { + "argv": [ + "{python}", + "-E", + "-s", + "-O", + "-W", + "error", + "-B", + "{package}/check_classes.py" + ], + "timeout_seconds": 120, + "checks": "Complete rational class recognition, independent character table checks and integer matrix under optimized Python" + }, + { + "argv": [ + "{python}", + "-E", + "-s", + "-W", + "error", + "-B", + "{package}/verify_gram.py" + ], + "timeout_seconds": 120, + "checks": "Sparse-to-requested Gram and inverse maps, both decoder schedules and direct tensor products" + }, + { + "argv": [ + "{python}", + "-E", + "-s", + "-O", + "-W", + "error", + "-B", + "{package}/verify_gram.py" + ], + "timeout_seconds": 120, + "checks": "Sparse-to-requested Gram and inverse maps, both decoder schedules and direct tensor products under optimized Python" + } + ] +} diff --git a/research/clifford-transported-fibre-gram/build_classes.py b/research/clifford-transported-fibre-gram/build_classes.py new file mode 100644 index 0000000000..954a1cebc2 --- /dev/null +++ b/research/clifford-transported-fibre-gram/build_classes.py @@ -0,0 +1,53 @@ +"""Compare the complete native GAP output against the retained rational class data.""" +import argparse +from pathlib import Path +import json +import sys + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) +from class_algebra import IDENTITY, apply_columns, data, require, signature, source_semantics + + +def reverse_high_nibble(x): + # GAP's preserved form is antidiagonal. Reverse the high four coordinates + # to pair low bit i with high bit 4+i, as in the project's Pauli convention. + return (x & 15) | sum(((x >> (4 + i)) & 1) << (7-i) for i in range(4)) + + +def adapt(raw): + return tuple(reverse_high_nibble(apply_columns(raw, reverse_high_nibble(1 << i))) for i in range(8)) + + +def build(path): + raw_reps, sizes, packet_rows = json.loads(path.read_text().replace('\\\n','')) + reps = list(map(adapt,raw_reps)) + labels = [signature(m) for m in reps] + require(len(set(labels)) == len(reps) == len(sizes) == 81, "Native conjugacy class coverage") + columns = list(zip(*packet_rows,strict=True)) + packets = {} + for i, col in enumerate(columns): + packets.setdefault(col, []).append(i) + groups = [sorted(v,key=labels.__getitem__) for v in packets.values()] + groups.sort(key=lambda ids: (reps[ids[0]] != IDENTITY, labels[ids[0]])) + result = [] + for indices in groups: + fixed = {sum(apply_columns(reps[i],v)==v for v in range(256)) for i in indices} + require(len(fixed)==1, "Disagreement inside rational class") + count = fixed.pop() + require(count.bit_count()==1, "Fixed space size") + result.append({"size":sum(sizes[i] for i in indices),"fixed":count.bit_length()-1, + "representatives":[list(reps[i]) for i in indices]}) + rows = sorted([r[ids[0]] for ids in groups] for r in packet_rows) + return {"classes":result, "characters":rows} + + +if __name__ == "__main__": + parser=argparse.ArgumentParser(description=__doc__) + parser.add_argument("raw", type=Path) + args=parser.parse_args() + actual=build(args.raw) + expected=data() + require(source_semantics(actual["classes"],actual["characters"]) == + source_semantics(expected["classes"],expected["characters"]), "Native table mismatch") + print("PASS native Sp(8,2) class representatives, sizes and rationalized characters") diff --git a/research/clifford-transported-fibre-gram/check_classes.py b/research/clifford-transported-fibre-gram/check_classes.py new file mode 100644 index 0000000000..f0470963a6 --- /dev/null +++ b/research/clifford-transported-fibre-gram/check_classes.py @@ -0,0 +1,61 @@ +"""Check geometric class recognition, character orthogonality and integral convolution.""" +from fractions import Fraction +from pathlib import Path +from random import Random +import sys + +sys.path.insert(0,str(Path(__file__).resolve().parent)) +from class_algebra import GROUP_ORDER, IDENTITY, apply_columns, class_index, data, gram_class_matrix, pairing, require + + +def transvection(axis, vector): + return vector ^ (axis if pairing(axis, vector) else 0) + + +def main(): + registry = data() + cs, rows = registry["classes"], registry["characters"] + sizes = [c["size"] for c in cs] + mass = sum(sizes) + require(len(rows) == len(cs) == 80 and mass == GROUP_ORDER and class_index(IDENTITY) == 0, + "Incorrect group or identity") + rng = Random(52) + for j, c in enumerate(cs): + for r in c["representatives"]: + require(class_index(r) == j, "Representative lookup") + for _ in range(5): + a = rng.randrange(1,256) + r = [transvection(a,apply_columns(r,transvection(a,v))) for v in IDENTITY] + require(class_index(r) == j,"Change of symplectic basis") + bad = list(IDENTITY) + bad[0] ^= 2 + try: + class_index(bad) + except ValueError: + pass + else: + raise ValueError("Accepted a nonsymplectic matrix") + shell = [(-64)**c["fixed"] for c in cs] + matrix = gram_class_matrix() + require(all(sizes[i]*matrix[i][j] == sizes[j]*matrix[j][i] + for i in range(80) for j in range(80)),"Central multiplication lacks adjoint symmetry") + spectrum = set() + for i,r in enumerate(rows): + for t in rows[i+1:]: + require(sum(n*a*b for n,a,b in zip(sizes,r,t,strict=True)) == 0, + "Packet orthogonality") + theta = Fraction(sum(n*c*x for n,c,x in zip(sizes,r,shell,strict=True)), r[0]) + require(theta.denominator == 1 and all(sum(a*b for a,b in zip(row,r,strict=True)) == theta*v + for row,v in zip(matrix,r,strict=True)), + "Character eigenvector of the actual matrix") + spectrum.add(theta / 16**12) + require(len(spectrum)==52 and min(spectrum) == Fraction(470624175,2**32) + and max(spectrum) == Fraction(7841980575,2**30), "Published width-13 endpoints") + require(sum(c1*c2 for c1,c2 in zip(matrix[0],shell)) == sum(n*s*s for n,s in zip(sizes,shell)), + "Literal identity coefficient of the square") + print("PASS all 81 ordinary classes recognized, 405 conjugations, 80 rational packets," + " exact adjoint symmetry, 52 levels and both width-13 endpoints") + + +if __name__ == "__main__": + main() diff --git a/research/clifford-transported-fibre-gram/class_algebra.py b/research/clifford-transported-fibre-gram/class_algebra.py new file mode 100644 index 0000000000..46d7854c70 --- /dev/null +++ b/research/clifford-transported-fibre-gram/class_algebra.py @@ -0,0 +1,114 @@ +"""Recognize native Sp(8,2) classes and multiply width-13 central kernels.""" +from collections import Counter +from functools import cache +import json +from pathlib import Path + +HERE = Path(__file__).resolve().parent +GROUP_ORDER = 47377612800 +IDENTITY = tuple(1 << i for i in range(8)) + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def apply_columns(columns, vector): + result = 0 + while vector: + bit = vector & -vector + result ^= columns[bit.bit_length()-1] + vector ^= bit + return result + + +def pairing(a, b): + return (((a >> 4) & b) ^ ((b >> 4) & a)).bit_count() & 1 + + +def signature(columns): + """For each cyclic vector, record its minimal polynomial and pairings with its iterates.""" + require(len(columns) == 8 and all(type(x) is int and 0 <= x < 256 for x in columns), + "Expected eight four-qubit Pauli-label columns") + require(all(pairing(columns[i], columns[j]) == pairing(1 << i, 1 << j) + for i in range(8) for j in range(i)), "Nonsymplectic input") + action = [apply_columns(columns, v) for v in range(256)] + types = Counter() + for vector in range(256): + current = vector + pivots = {} + pair_bits = 0 + for degree in range(9): + pair_bits |= pairing(vector, current) << degree + reduced, relation = current, 1 << degree + while reduced and reduced.bit_length() in pivots: + value, polynomial = pivots[reduced.bit_length()] + reduced ^= value + relation ^= polynomial + if reduced == 0: + break + pivots[reduced.bit_length()] = (reduced, relation) + current = action[current] + require(reduced == 0, "No relation on nine eight-bit vectors") + types[(relation, pair_bits)] += 1 + return tuple(sorted(types.items())) + + +@cache +def data(): + return json.loads((HERE / "CLASS-ALGEBRA.json").read_text()) + + +@cache +def lookup(): + codebook = {signature(tuple(rep)): j for j, cl in enumerate(data()["classes"]) + for rep in cl["representatives"]} + require(len(codebook) == 81, "Incomplete ordinary class recognition") + return codebook + + +def class_index(columns): + """Zero-based rational class index. The identity class has index zero.""" + return lookup()[signature(tuple(columns))] + + +def divisible(n, d): + q, r = divmod(n, d) + require(r == 0, "Nonintegral class-algebra coefficient") + return q + + +@cache +def gram_class_matrix(): + """Integer M for convolution by F(s)=(-64)^dimFix(s) on rational class coefficients. + + Column l is the convolution of F with the indicator of rational class l. + The normalized width-13 operator uses M/16^12. + """ + classes = data()["classes"] + rows = data()["characters"] + sizes = [c["size"] for c in classes] + shell = [(-64)**c["fixed"] for c in classes] + require(len(rows) == len(classes) == 80 and sum(sizes) == GROUP_ORDER, "Class census") + # Evaluating a class sum on an irreducible gives size*packet_value/packet_degree. + # The inverse character transform has coefficients degree*packet_value/|G|, + # where degree is the degree of one constituent. All packet sums are real. + scaled = [] + for row in rows: + orbit = divisible(sum(n*v*v for n, v in zip(sizes,row,strict=True)), GROUP_ORDER) + degree = divisible(row[0], orbit) + evaluations = [divisible(n*v, row[0]) for n,v in zip(sizes,row,strict=True)] + eigenvalue = sum(a*b for a,b in zip(evaluations, shell, strict=True)) + scaled.append((row, [degree*eigenvalue*v for v in evaluations])) + matrix = tuple(tuple(divisible(sum(row[i]*weighted[j] for row,weighted in scaled), + GROUP_ORDER) for j in range(80)) for i in range(80)) + require([r[0] for r in matrix] == shell, "Convolution of F with identity") + return matrix + + +def source_semantics(classes, characters): + # Representatives may differ across GAP builds. Compare the invariants of + # all representatives, in addition to the sizes and the complete packet table. + return ([([signature(rep) for rep in c["representatives"]],c["size"],c["fixed"]) + for c in classes], characters) diff --git a/research/clifford-transported-fibre-gram/gram.py b/research/clifford-transported-fibre-gram/gram.py new file mode 100644 index 0000000000..c1f946e405 --- /dev/null +++ b/research/clifford-transported-fibre-gram/gram.py @@ -0,0 +1,134 @@ +"""Apply the width-13 Gram, canonical inverse Gram, or either exact decoder schedule on named fibres.""" +import argparse +from fractions import Fraction +from functools import cache +import json +from math import lcm, prod +from pathlib import Path + +from class_algebra import GROUP_ORDER, class_index, data +from readout import HERE, ZERO, decode_paulis, rotate_right, synthesize_paulis +from compile_row import compose, inverse + +GRAM_DEN = 16**12 + + +def fixed_dimension(left, right): + pivots = {} + for a, b in zip(left, right, strict=True): + v = a ^ b + while v and v.bit_length() in pivots: + v ^= pivots[v.bit_length()] + if v: + pivots[v.bit_length()] = v + return 8-len(pivots) + + +def steps(which): + src = json.loads((HERE / 'retained' / 'SCHEDULE.json').read_text()) + if which == 'schedule52': + return [Fraction(n,1< ForAll([1..8], j -> + (not IsZero(form[i][j])) = (i+j=9))) then Error("Unexpected natural pairing"); fi; +space := GF(2)^8;; +vectors := Difference(AsList(space), [Zero(space)]);; +action := ActionHomomorphism(g, vectors, OnRight, "surjective");; +h := Image(action);; +classes := ConjugacyClasses(h);; +tbl := CharacterTable(h);; +chars := List(Irr(tbl),ValuesOfClassFunction);; +if Size(h) <> 47377612800 or Length(classes) <> 81 or + List(classes,Size) <> SizesConjugacyClasses(tbl) then Error("Class order"); fi; +labels := List(vectors, v -> Sum([1..8], i->IntFFE(v[i])*2^(i-1)));; +reps := List(classes, c -> List([0..7], i -> labels[Position(labels,2^i)^Representative(c)]));; +Print([reps,List(classes,Size),RationalizedMat(chars)],"\n"); +QUIT; diff --git a/research/clifford-transported-fibre-gram/readout.py b/research/clifford-transported-fibre-gram/readout.py new file mode 100644 index 0000000000..9320b8ba81 --- /dev/null +++ b/research/clifford-transported-fibre-gram/readout.py @@ -0,0 +1,146 @@ +"""Decode specified symplectic fibres of one compact chart in the compiled Bell basis.""" +import argparse +from fractions import Fraction +from functools import cache +import json +from pathlib import Path +import sys + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE / "retained")) +from fibre import PartialWalsh, Q, SingletonBasis, iter_reads, label_sum, pack, walsh +from bell_reads import decompose, step +from compile_row import IDENTITY, is_symplectic + +ZERO = (0, 0) + + +@cache +def base_reads(): + return tuple(iter_reads()) + + +@cache +def target_axes(target): + if not is_symplectic(target): + raise ValueError("Expected eight columns of a binary symplectic matrix") + return decompose(target) + + +def transports(target): + """One 256-label table per action, including both absolute phase exponents.""" + axes = target_axes(target) + def follow(label, bell): + phase = 0 + for axis in axes: + label, increment = step(axis, label, bell) + phase += increment + return label, phase % 4 + return [[follow(i, action) for i in range(256)] for action in (False, True)] + + +def translated_reads(target): + ordinary, bell = transports(target) + for read in base_reads(): + lifted = [bell[t] for t in read.output_labels] + outputs = tuple(t for t, _ in lifted) + _, gamma = ordinary[label_sum(read.output_labels)] + transport = (sum(p for _, p in lifted) - gamma) % 4 + yield read._replace(output_labels=outputs, correction_i=(read.correction_i - transport) % 4) + + +def rotate_right(matrix, target, adjoint): + """Right-multiply by the canonical lift or adjoint. Return numerator and power of two.""" + axes = target_axes(tuple(target)) + sign = -1 if adjoint else 1 + for axis in (axes if adjoint else reversed(axes)): + x, z = divmod(axis, 16) + exponent = ((x & z).bit_count() & 1) + sign + result = [ZERO]*256 + for c in range(16): + phase = (exponent + 2*(z & c).bit_count()) % 4 + for r in range(16): + j = r + (c << 4) + a, b = matrix[j] + t, u = Q.multiply_i(matrix[r + ((c ^ x) << 4)], phase) + v, w = a+t, b+u + result[j] = v-sign*w, w+sign*v + matrix = result + return matrix, len(axes) + + +def decode_paulis(matrix): + """Numerators of all trace pairings with X^x Z^z (without the 1/16).""" + outputs = [] + for x in range(16): + diag = [matrix[(c ^ x) | (c << 4)] for c in range(16)] + a, b = map(list, zip(*diag)) + walsh(a) + walsh(b) + outputs.extend(zip(a,b)) + return outputs + + +def synthesize_paulis(coefficients): + """Entries of sum c_(x,z) X^x Z^z; Walsh in z is its own transpose.""" + if len(coefficients) != 256: + raise ValueError("Expected 256 coefficient pairs") + result = [ZERO]*256 + for x in range(16): + left, right = map(list, zip(*coefficients[16*x:16*x+16])) + walsh(left) + walsh(right) + for c, val in enumerate(zip(left, right)): + result[(x ^ c) | (c << 4)] = val + return result + + +class BatchReadout: + """Compile the transformed observation once, independent of the target list.""" + def __init__(self, chart): + self.transform = PartialWalsh(chart) + self.basis = SingletonBasis(self.transform) + + def evaluate(self, target): + target = tuple(target) + basis = self.basis + size = len(basis.points) + bins = {s: ([0]*size,[0]*size) for s in range(256) if basis.cosets.split(s)[0] == s} + hits = 0 + for read in translated_reads(target): + labels = read.output_labels + read.input_labels + out, inp = label_sum(read.output_labels), label_sum(read.input_labels) + point = (pack([t & 15 for t in labels]) << 56) | (pack([t >> 4 for t in labels]) << 8) + move = (out >> 4) | (inp & 240) + phase_mask = (out & 15) | ((inp & 15) << 4) + found = basis.locate(point, move, phase_mask) + if found is not None: + s, freq, phase = found + phase = (phase + read.correction_i) % 4 + bins[s][phase % 2][freq] += read.numerator if phase < 2 else -read.numerator + hits += 1 + weighted = [ZERO]*256 + for s,(real,imag) in bins.items(): + walsh(real) + walsh(imag) + for i,v in enumerate(basis.points): + weighted[s ^ v] = Q.multiply_i((real[i],imag[i]), basis.chirp[i]) + gauged, power = rotate_right(weighted,target,True) + denominator = 1 << (self.transform.denominator + power) + coeffs = [tuple(Fraction(a,denominator) for a in Q.multiply(self.transform.scalar,entry)) + for entry in decode_paulis(gauged)] + return coeffs, dict(terms=4265, hits=hits, lift_steps=power, + walsh_additions=256*(len(basis.support)+4)) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("input", type=Path, help="JSON with circuit, optional initial address, and targets") + args = parser.parse_args() + data = json.loads(args.input.read_bytes()) + compiled = BatchReadout(Q.signature(104,data["circuit"],initial=data.get("initial",0))) + outputs = [] + for t in data["targets"]: + alphas, stats = compiled.evaluate(t) + outputs.append({"target":t,"coefficients":[[str(a),str(b)] for a,b in alphas], **stats}) + print(json.dumps({"chart_gauss_sums":1,"outputs":outputs})) diff --git a/research/clifford-transported-fibre-gram/retained/SCHEDULE.json b/research/clifford-transported-fibre-gram/retained/SCHEDULE.json new file mode 100644 index 0000000000..8285a6ed62 --- /dev/null +++ b/research/clifford-transported-fibre-gram/retained/SCHEDULE.json @@ -0,0 +1,271 @@ +{ + "width": 13, + "target_contraction_bits": 128, + "dyadic_steps_numerator_and_fraction_bits": [ + [ + 16235024724083224395359823436643253233985060541178529464128234987963972511524430, + 266 + ], + [ + 290221599984547371426095893968688576590336715685307957390394351699883619242, + 250 + ], + [ + 20759518831968770215992325737141837234675814767551269797515768913240005, + 236 + ], + [ + 13400269619305904983103956230798591927252828970295216170819282, + 205 + ], + [ + 7768397226843759158361126859959686065355191018524402596, + 184 + ], + [ + 1061846493480964117330722486058983726907763264856036, + 171 + ], + [ + 2253847972392885451668735299675711035638267489260, + 162 + ], + [ + 9479333862502341328575410033896046829000364509, + 154 + ], + [ + 653787064491433453447888997699129206345850, + 140 + ], + [ + 1362056384357153028016435411873185846554, + 131 + ], + [ + 1415035306222108780768404475433412823, + 121 + ], + [ + 712571350633276207458375110843254314, + 120 + ], + [ + 46762494885308751114455866649088564, + 116 + ], + [ + 23670554216410503938700944872991962, + 115 + ], + [ + 798539871675354356462702640865583, + 110 + ], + [ + 405924434768305131201873842440005, + 109 + ], + [ + 6961356541377184033568720621113, + 103 + ], + [ + 113260165950977994196951406931, + 97 + ], + [ + 114349206008198936448845170459, + 97 + ], + [ + 3871197078402568161028612542, + 92 + ], + [ + 995450677303517527121643225, + 90 + ], + [ + 254312216829365791600419802, + 88 + ], + [ + 263945255345629647342859946, + 88 + ], + [ + 69128519257188717161225224, + 86 + ], + [ + 9149362842863212565456280, + 83 + ], + [ + 4713308131171957988265356, + 82 + ], + [ + 1234437843878369949307593, + 80 + ], + [ + 162019967009036055846622, + 77 + ], + [ + 82851119493257074012477, + 76 + ], + [ + 21699102724424471765173, + 74 + ], + [ + 688637327394299945915, + 69 + ], + [ + 689034007882430303027, + 69 + ], + [ + 390583849039640491773106, + 78 + ], + [ + 202524958761295069808277, + 77 + ], + [ + 109363477731099337696470, + 76 + ], + [ + 112095209732995875847372, + 76 + ], + [ + 115728547863597182747587, + 76 + ], + [ + 480408041712839467917308, + 78 + ], + [ + 4166227723089498578913127, + 81 + ], + [ + 8694736117751997034253483, + 82 + ], + [ + 77769584164337306806378377, + 85 + ], + [ + 355518099036970545400586866, + 87 + ], + [ + 100730128060474987863499612, + 85 + ], + [ + 51846389442891537870918918, + 84 + ], + [ + 52883317231749368628337296, + 84 + ], + [ + 3732940039888190726706162094, + 90 + ], + [ + 18294769204497078876830199810, + 92 + ], + [ + 37542711258304089594301973056, + 93 + ], + [ + 3094429534017791627166708082217, + 99 + ], + [ + 7220335579374847130055652191839, + 100 + ], + [ + 15128322166309203510592795068615, + 101 + ], + [ + 23692732315048013780354269170988041, + 111 + ] + ], + "norm_optimal_dyadic_fraction_bits": 192, + "norm_optimal_dyadic_numerators": [ + 859475052549165482811305455414865991096807340106825388339, + 1006908445457488960557756639438044878703595582121840670999, + 1180042024314432763730583572916079744725028306649681283665, + 1635775100012927854382807157079906241119860312465666159069, + 1988709690072002344540448476149679855420345580014595839436, + 2226853497496590860588359323085127324655140945845069625626, + 2420050832895838469497851685375491856984460867244234868387, + 2605659451348026670698277063705720628087769899752830937538, + 2944395180023270137891440807894999855257632379099145086974, + 3140688192024821481250734185478404957577364476881197544901, + 3341157651090236697679284008732529265898007238294727784253, + 3365023062883739289832919340601614758696608769488205562783, + 3533274216027952573601408269431526191899622775000495736272, + 3576993019600871445453897621630767329494563677277007359513, + 3861501875441639064688623446530872220405635135534475142910, + 3925860240033699068783370138970305764806942380655648940162, + 4308870995337672945882011599371528029940173617456835212180, + 4486697423692198676780610232559991091121905813587456595436, + 4529838747941271569452737543360407091661946603023187295012, + 4907325459509328810821638146454873691725959298218977646838, + 5047535680237308533248910324969354099973945328286407362634, + 5158066738588737881820325941297067525390242141957021540956, + 5353449224592715969010896900128972114397364913265099018351, + 5608379470030481761855605647050940201404190474320589201870, + 5938322160935363800225363509023433844364762346129369179457, + 6118332051146203973534367340494825287482716266252038381659, + 6409811831289322535659489818898654358061439211090398633350, + 6731135991661158598837266824277521189352463850364714725037, + 6884641557974267991044803334218883484147107365013904495616, + 7213344523754344775825533276544741454937925477566144918599, + 7325001557730663323134909412091081960144259467234547933398, + 8111112937334618597536788369338758376019944229387072178705, + 8411086109873357754052640672463960544163427143836319367115, + 9080246860286922611003532090070889758818405608839383586839, + 9304126808714028360727181721755904670693932165381353437529, + 9608751371657165987185653790288292582858732240130034076332, + 9975717937056278642922727970213855966377789249804178261065, + 10815737180814123767009785805004756706174379357546545579983, + 11286236022023968138701707926367324667192329654545834731518, + 12618817964264207161824703070914240434142317465873297280369, + 14421518708936486981261060249872627133205108160947709711716, + 16344353101450138227354963240062708338148403296790232790848, + 16825027585504518921673920152093609645268678588979852664594, + 17161568581151902022192938183651136483219073403934938410257, + 18928253234724281370515039404323165067510131582897075095675, + 23191374938146150486938241734086605260978496106837162637434, + 23795520070867650923991499017620479513970449742849056734033, + 30645745749020409104485468038848124112319246785061549906448, + 35753370041986549464346932311634027232400996533638746408163, + 37455911473209746128941962907330832121362126825940680340490 + ], + "norm_optimal_final_reciprocal": [ + 4294967296, + 470624175 + ] +} diff --git a/research/clifford-transported-fibre-gram/retained/fibre.py b/research/clifford-transported-fibre-gram/retained/fibre.py new file mode 100644 index 0000000000..414fbb37a7 --- /dev/null +++ b/research/clifford-transported-fibre-gram/retained/fibre.py @@ -0,0 +1,177 @@ +"""All 256 Pauli outputs of the width-13 identity symplectic fibre, exactly.""" +import argparse +from fractions import Fraction +from functools import cache +import json +from pathlib import Path +import sys + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE / "predecessor")) +from contract import BinaryMap, Q, Spectrum, apply, iter_reads, label_sum, pack, parity, polar, split_address, transpose + +MASK48 = (1 << 48) - 1 + + +def separate(address): + rows, cols = map(split_address, divmod(address, 1 << 52)) + pairs = rows[:-1] + cols[:-1] + shifts = pack([a ^ b for a, b in zip(pairs[::2], pairs[1::2], strict=True)]) + singleton = rows[-1] | (cols[-1] << 4) + return (shifts << 8) | singleton, pack(pairs[1::2]) + + +@cache +def plan(): + records = [] + for read in iter_reads(): + labels = read.output_labels + read.input_labels + fixed = pack([t >> 4 for t in labels]) + wave = pack([t & 15 for t in labels]) + out, inp = label_sum(read.output_labels), label_sum(read.input_labels) + move = (out >> 4) | ((inp >> 4) << 4) + sign = (out & 15) | ((inp & 15) << 4) + Q.need(read.correction_i == 0 and out >> 4 == inp >> 4, "Identity-fibre conventions") + records.append(((wave << 56) | (fixed << 8), move, sign, read.numerator)) + return tuple(records) + + +class Section(BinaryMap): + """Linear reduction, including a canonical remainder for inconsistent right sides.""" + def split(self, word): + witness = 0 + for bit, (pivot, preimage) in self.descending: + if word >> bit & 1: + word ^= pivot + witness ^= preimage + return word, witness + + def __init__(self, columns): + super().__init__(columns) + self.descending = sorted(self.pivots.items(), reverse=True) + + +class PartialWalsh: + """Return affine support equations and a quadratic phase on all Bell/singleton bits.""" + def __init__(self, state): + n, offset, cols, terms, real, imag, denominator = state + Q.need(n == 104, "This decoder consumes 104-bit charts") + self.offset, self.free_offset = separate(offset) + parts = [separate(c) for c in cols] + self.fixed = Section(f for f, _ in parts) + self.free = [v for _, v in parts] + self.phase = dict(terms) + kernel = self.fixed.kernel + restricted = Q.substitute(self.phase, [transpose(kernel, 1 << j) << 1 for j in range(len(cols))]) + restricted.pop(0, None) + spectrum = Spectrum(len(kernel), restricted) + self.spectrum_map = Section(polar(len(kernel), restricted)) + self.restricted = restricted + self.anchor = spectrum.origin + self.scalar = Q.multiply((real, imag), spectrum.value) + self.denominator = denominator + 12 # numerator / 4096 after the final trace + self.free_kernel = [apply(self.free, k) for k in kernel] + polar_columns = polar(len(cols), self.phase) + self.twist_columns = [transpose(kernel, col) for col in polar_columns] + + def slice(self, word): + fixed, wave = word & ((1 << 56)-1), word >> 56 + rem, t = self.fixed.split(fixed ^ self.offset) + free = self.free_offset ^ apply(self.free, t) + frequency = apply(self.twist_columns, t) ^ transpose(self.free_kernel, wave) + residual, u = self.spectrum_map.split(frequency ^ self.anchor) + syndrome = rem | (residual << 56) + phase = (Q.value(self.phase, t) + 2*parity(wave & free) + - Q.value(self.restricted, u) + 2*parity(self.anchor & u)) % 4 + return syndrome, phase + + +def walsh(values): + """Unnormalized binary Walsh transform in place, on real Gaussian components.""" + stride = 1 + while stride < len(values): + for start in range(0, len(values), 2*stride): + for i in range(start, start + stride): + a, b = values[i], values[i + stride] + values[i], values[i + stride] = a + b, a - b + stride *= 2 + + +class SingletonBasis: + def __init__(self, transform): + self.transform = transform + zero_syndrome, zero_phase = transform.slice(0) + singletons = [transform.slice(1 << i) for i in range(104)] + self.affine = Section(s ^ zero_syndrome for s, _ in singletons[:8]) + self.support = self.affine.kernel + self.cosets = Section(self.support) + # The extension of the phase off its support is a quadratic polynomial. + # Its polar columns restricted to the eight singleton directions identify + # each read's modulating sign without a separate phase fit at each output. + self.twists = [] + for h in self.support: + twist = 0 + slope = (transform.slice(h)[1] - zero_phase) % 4 + for i, (_, base) in enumerate(singletons): + delta = (transform.slice((1 << i) ^ h)[1] - base - slope) % 4 + Q.need(delta in (0, 2), "Non-quadratic phase derivative") + twist |= (delta // 2) << i + self.twists.append(twist) + self.points = [apply(self.support, u) for u in range(1 << len(self.support))] + self.chirp = [(transform.slice(v)[1] - zero_phase) % 4 for v in self.points] + + def locate(self, labels, move, sign): + syndrome, _ = self.transform.slice(labels) + remainder, witness = self.affine.split(syndrome) + if remainder: + return None + representative, _ = self.cosets.split(witness ^ move) + raw_point = representative ^ move + word = labels | raw_point + frequency = transpose(self.twists, word) ^ transpose(self.support, sign) + phase = (self.transform.slice(word)[1] + 2*parity(raw_point & sign)) % 4 + return representative, frequency, phase + + +def fibre(state): + """Return the linear decoder as pairs of Fractions at index 16*x+z.""" + transform = PartialWalsh(state) + basis = SingletonBasis(transform) + size = len(basis.points) + bins = {s: ([0]*size, [0]*size) for s in range(256) if basis.cosets.split(s)[0] == s} + supported = 0 + for labels, move, sign, weight in plan(): + hit = basis.locate(labels, move, sign) + if hit is not None: + s, freq, phase = hit + bins[s][phase % 2][freq] += weight if phase < 2 else -weight + supported += 1 + matrices = [[0]*256, [0]*256] + for s, (real, imag) in bins.items(): + walsh(real) + walsh(imag) + for i, v in enumerate(basis.points): + a, b = Q.multiply_i((real[i], imag[i]), basis.chirp[i]) + matrices[0][s ^ v], matrices[1][s ^ v] = a, b + outputs = [] + for x in range(16): + real, imag = [[m[(b ^ x) | (b << 4)] for b in range(16)] for m in matrices] + walsh(real) + walsh(imag) + for item in zip(real, imag, strict=True): + value = Q.multiply(transform.scalar, item) + outputs.append(tuple(Fraction(a, 1 << transform.denominator) for a in value)) + stats = dict(gauss=1, gauss_variables=len(transform.fixed.kernel), + singleton_dimension=len(basis.support), supported_terms=supported, + accumulation_updates=supported, walsh_adds=256*(len(basis.support)+4)) + return outputs, stats + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("input", type=Path, help="JSON with a #5704 circuit and optional initial address") + data = parser.parse_args().input.read_bytes() + request = json.loads(data) + state = Q.signature(104, request["circuit"], initial=request.get("initial", 0)) + values, stats = fibre(state) + print(json.dumps({"input_bytes":len(data), "outputs":[[str(a),str(b)] for a,b in values], **stats})) diff --git a/research/clifford-transported-fibre-gram/retained/predecessor/RETAINED.json b/research/clifford-transported-fibre-gram/retained/predecessor/RETAINED.json new file mode 100644 index 0000000000..520317e651 --- /dev/null +++ b/research/clifford-transported-fibre-gram/retained/predecessor/RETAINED.json @@ -0,0 +1,74 @@ +[ + { + "local": "source/engine/INPUTS.json", + "repository": "CrocSwap/integer-mult-bounds", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "path": "research/clifford-exact-contractions/INPUTS.json", + "sha256": "c62bd55fd36c136ba2ec34f6d91ed481497932fadc7134d0b7e5c10009fd588c", + "git_blob": "f9d4fd920651b002370ffb5084dbef2abaa5ed44" + }, + { + "local": "source/engine/contractions.py", + "repository": "CrocSwap/integer-mult-bounds", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "path": "research/clifford-exact-contractions/contractions.py", + "sha256": "a2fc065d6f293ddcffe5b6eec7fff0fdf57c8e3d4c6be355bd92e87d3f1865ef", + "git_blob": "76c807deceea0b1a6b64b50735253959b07c144d" + }, + { + "local": "source/engine/source/LICENSE", + "repository": "CrocSwap/integer-mult-bounds", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "path": "research/clifford-exact-contractions/source/LICENSE", + "sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "git_blob": "261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64" + }, + { + "local": "source/engine/source/PR5698-NOTICE.md", + "repository": "CrocSwap/integer-mult-bounds", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "path": "research/clifford-exact-contractions/source/PR5698-NOTICE.md", + "sha256": "1f55b3e4bb80a60611b1fca0622da5a99fe7877446f03d0edd1dc8f3a5abadd2", + "git_blob": "56712e3195faf8c83319100065183b8b2488809d" + }, + { + "local": "source/engine/source/PR5704-NOTICE.md", + "repository": "CrocSwap/integer-mult-bounds", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "path": "research/clifford-exact-contractions/source/PR5704-NOTICE.md", + "sha256": "a77adc71861e3b9c73c703c5db5b671f61a1101d85d14cca08547e21d6d8dce4", + "git_blob": "b96b400e5ca04b3a9003a8b2c70a2461972d39d7" + }, + { + "local": "source/engine/source/PR5704-quadratic.py", + "repository": "CrocSwap/integer-mult-bounds", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "path": "research/clifford-exact-contractions/source/PR5704-quadratic.py", + "sha256": "d406584aed1479b75c387bc964b9e797b2f4f75e5f8c6bbea00df07f7d590a91", + "git_blob": "ce3c86ec07fd5767741e02ff0c88b93ba9164fb4" + }, + { + "local": "source/row/bell_reads.py", + "repository": "apoursh/integer-mult-bounds", + "commit": "fdc90699f4a64139ed6d84cdbf9a606ff0ccd32e", + "path": "research/clifford-sparse-row/bell_reads.py", + "sha256": "44942462cd7778d23042bf827fb313d0e7acf99aa5b9793e411503e83d3421b7", + "git_blob": "32b2ed2a94dc77d04709fedb420bf0ffd6d74f73" + }, + { + "local": "source/row/compile_row.py", + "repository": "apoursh/integer-mult-bounds", + "commit": "fdc90699f4a64139ed6d84cdbf9a606ff0ccd32e", + "path": "research/clifford-sparse-row/compile_row.py", + "sha256": "4e6420f6dcccfd76d64a3b14d94dbdd4803bfd780c921a225d8f29b5d9f0565b", + "git_blob": "daf35d6a26993ed00cfc25a9e16c9136fba2a275" + }, + { + "local": "source/row/raw_row.py", + "repository": "apoursh/integer-mult-bounds", + "commit": "fdc90699f4a64139ed6d84cdbf9a606ff0ccd32e", + "path": "research/clifford-sparse-row/raw_row.py", + "sha256": "40fb7b900409d1908e01683830f44670417338412753ba77a37ea203f94aafa7", + "git_blob": "1787feb76acf78e3fd314bf3e0ecbe6cb2432316" + } +] diff --git a/research/clifford-transported-fibre-gram/retained/predecessor/contract.py b/research/clifford-transported-fibre-gram/retained/predecessor/contract.py new file mode 100644 index 0000000000..11df2cef14 --- /dev/null +++ b/research/clifford-transported-fibre-gram/retained/predecessor/contract.py @@ -0,0 +1,195 @@ +"""Contract #7800's identity row with a #5704 affine-quadratic observation. + +apoursh with substantial OpenAI Codex assistance. Apache-2.0. +""" +from collections import Counter, defaultdict +from fractions import Fraction +from hashlib import sha256 +import json +from functools import cache +from pathlib import Path +import sys + +HERE = Path(__file__).resolve().parent +for record in json.loads((HERE / "RETAINED.json").read_text()): + if sha256((HERE / record["local"]).read_bytes()).hexdigest() != record["sha256"]: + raise ValueError("Changed retained source: " + record["local"]) +sys.path[:0] = [str(HERE / "source" / "engine"), str(HERE / "source" / "row")] +from contractions import Q, gauss, solution +from raw_row import RAW_DENOMINATOR, iter_reads, label_sum, pack, split_address + + +def parity(bits): + return bits.bit_count() & 1 + + +def transpose(columns, vector): + return sum(parity(column & vector) << j for j, column in enumerate(columns)) + + +def apply(columns, vector): + out = 0 + for j in Q.bits(vector): + out ^= columns[j] + return out + + +class BinaryMap: + """One elimination: a kernel basis and a right inverse on the image.""" + def __init__(self, columns): + self.pivots = {} + self.kernel = [] + for j, column in enumerate(columns): + word, witness = column, 1 << j + while word: + bit = word.bit_length() - 1 + if bit not in self.pivots: + self.pivots[bit] = (word, witness) + break + pivot, preimage = self.pivots[bit] + word ^= pivot + witness ^= preimage + if not word: + self.kernel.append(witness) + + def preimage(self, word): + witness = 0 + while word: + pivot = self.pivots.get(word.bit_length() - 1) + if pivot is None: + return None + word ^= pivot[0] + witness ^= pivot[1] + return witness + + +def polar(dimension, phase): + columns = [0] * dimension + for mask, coefficient in phase.items(): + if mask.bit_count() == 2: + a, b = Q.bits(mask) + columns[a] ^= 1 << b + columns[b] ^= 1 << a + elif mask and coefficient & 1: + columns[mask.bit_length() - 1] ^= mask + return columns + + +class Spectrum: + """Return a Fourier coefficient as a rotation of one exact Gauss sum.""" + def __init__(self, dimension, phase): + self.phase = phase + self.map = BinaryMap(polar(dimension, phase)) + equations = [] + for r in self.map.kernel: + q = Q.value(phase, r) + Q.need(q % 2 == 0, "An element of the radical has even phase") + equations.append((r, q // 2)) + _, forms = solution(dimension, equations) + self.origin = sum((form & 1) << j for j, form in enumerate(forms)) + twisted = dict(phase) + Q.affine(twisted, self.origin << 1, 2) + self.value = gauss(dimension, twisted) + Q.need(self.value != (0, 0), "Nonzero Fourier anchor") + + def rotation(self, frequency): + u = self.map.preimage(self.origin ^ frequency) + if u is None: + return None + return (2 * parity(self.origin & u) - Q.value(self.phase, u)) % 4 + + +def address_parts(address): + """Linear map from raw 104 bits to (52 shift bits, 52 free bits).""" + row, col = divmod(address, 1 << 52) + r, c = split_address(row), split_address(col) + pairs = r[:-1] + c[:-1] + shifts = [a ^ b for a, b in zip(pairs[::2], pairs[1::2], strict=True)] + return pack([*shifts, r[-1] ^ c[-1]]), pack([*pairs[1::2], r[-1]]) + + +@cache +def read_plan(): + plan = defaultdict(list) + for read in iter_reads(): + labels = read.output_labels + read.input_labels + singleton = label_sum(labels) + Q.need(singleton < 16 and read.correction_i == 0, "Identity trace convention") + shift = pack([t >> 4 for t in labels]) + frequency = pack([*(t & 15 for t in labels), singleton]) + plan[shift].append((frequency, read.numerator)) + return {s: tuple(terms) for s, terms in sorted(plan.items())} + + +def contract(state, plan=None, denominator=RAW_DENOMINATOR): + """Linear (unconjugated) observation contraction on a signature() output. + + A plan maps a packed shift to (frequency, signed integer weight) pairs. + Each weight has the stated common denominator. + """ + n, offset, cols, terms, real, imag, exponent = state + Q.need(n == 104, "This row consumes a 104-bit state") + if plan is None: + plan = read_plan() + shift0, point0 = address_parts(offset) + parts = [address_parts(c) for c in cols] + support = BinaryMap(s for s, _ in parts) + points = [v for _, v in parts] + intersections = [] + for shift, table in plan.items(): + witness = support.preimage(shift ^ shift0) + if witness is not None: + intersections.append((witness, table)) + counts = Counter(buckets=len(intersections), dimension=len(support.kernel), gauss=0) + if not intersections: + return (Fraction(0), Fraction(0)), dict(counts) + + kernel = support.kernel + phase = dict(terms) + restricted = Q.substitute(phase, [transpose(kernel, 1 << j) << 1 for j in range(len(cols))]) + restricted.pop(0, None) + spectrum = Spectrum(len(kernel), restricted) + counts["gauss"] = 1 + polar_cols = polar(len(cols), phase) + point_directions = [apply(points, k) for k in kernel] + total = [0, 0] + for witness, table in intersections: + point = point0 ^ apply(points, witness) + twist = transpose(kernel, apply(polar_cols, witness)) + constant = Q.value(phase, witness) + for frequency, weight in table: + counts["terms"] += 1 + exponent_i = spectrum.rotation(twist ^ transpose(point_directions, frequency)) + if exponent_i is None: + continue + counts["supported"] += 1 + angle = (constant + 2 * parity(point & frequency) + exponent_i) % 4 + total[angle % 2] += weight if angle < 2 else -weight + numerator = Q.multiply((real, imag), Q.multiply(spectrum.value, total)) + return tuple(Fraction(x, denominator << exponent) for x in numerator), dict(counts) + + +def one_cell(state, shifts, masks, signature, numerator): + """Contract the actual weight numerator/4096 on a single Walsh cell.""" + frequencies = [(apply(masks, w), numerator * (-1)**parity(w & signature)) + for w in range(1 << len(masks))] + return contract(state, {pack(shifts): frequencies}, RAW_DENOMINATOR << len(masks)) + + +def main(): + """Evaluate a literal #5704 circuit on one computational basis input.""" + import argparse + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("input", type=Path, help="JSON with circuit and optional initial address") + args = parser.parse_args() + data = args.input.read_bytes() + request = json.loads(data) + counters = {} + state = Q.signature(104, request["circuit"], initial=request.get("initial", 0), counters=counters) + result, execution = contract(state) + print(json.dumps({"real": str(result[0]), "imag": str(result[1]), "input_bytes": len(data), + "producer": counters, "consumer": execution}, sort_keys=True)) + + +if __name__ == "__main__": + main() diff --git a/research/clifford-transported-fibre-gram/retained/predecessor/source/engine/INPUTS.json b/research/clifford-transported-fibre-gram/retained/predecessor/source/engine/INPUTS.json new file mode 100644 index 0000000000..f9d4fd9206 --- /dev/null +++ b/research/clifford-transported-fibre-gram/retained/predecessor/source/engine/INPUTS.json @@ -0,0 +1,72 @@ +[ + { + "local": "PR5704-quadratic.py", + "origin": "research/exact-clifford-quadratic-replay/quadratic.py", + "head": "daa4d9dbd102d2a3677afc5614c56466bd2cf3a2", + "sha256": "d406584aed1479b75c387bc964b9e797b2f4f75e5f8c6bbea00df07f7d590a91", + "git_blob": "ce3c86ec07fd5767741e02ff0c88b93ba9164fb4" + }, + { + "local": "PR5704-PROOF.md", + "origin": "research/exact-clifford-quadratic-replay/PROOF.md", + "head": "daa4d9dbd102d2a3677afc5614c56466bd2cf3a2", + "sha256": "e5039414a02e36cdeab82fb9803fc4de0c3e0f3997e8812ef9d227e5d417ec91", + "git_blob": "559f9f4b207783c6eb908450b63eed3431594c22" + }, + { + "local": "PR5704-NOTICE.md", + "origin": "research/exact-clifford-quadratic-replay/NOTICE.md", + "head": "daa4d9dbd102d2a3677afc5614c56466bd2cf3a2", + "sha256": "a77adc71861e3b9c73c703c5db5b671f61a1101d85d14cca08547e21d6d8dce4", + "git_blob": "b96b400e5ca04b3a9003a8b2c70a2461972d39d7" + }, + { + "local": "PR5526-PROOF.md", + "origin": "research/clifford-pointwise-faithfulness/PROOF.md", + "head": "df0137efd35e11b4445734bf612bdd4c7ebc330c", + "sha256": "45483e4b5f604a5e70602c5caaa4394d4a0d0d1a6d0b6e8a93b836d50b23f764", + "git_blob": "465009d9d1b6947e80e6f1e868022f47ddab1f3c" + }, + { + "local": "clifford_exact.py", + "origin": "research/exact-clifford-quadratic-replay/source/source/clifford_exact.py", + "head": "daa4d9dbd102d2a3677afc5614c56466bd2cf3a2", + "sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962", + "git_blob": "166841a037f069249f6f7f6dedb89248812f59e2" + }, + { + "local": "prune_native.py", + "origin": "research/exact-clifford-quadratic-replay/source/source/prune_native.py", + "head": "daa4d9dbd102d2a3677afc5614c56466bd2cf3a2", + "sha256": "f2b37c183a10922eabc8e0436b426a08866430e96bd0adc7e178951c7fbb5257", + "git_blob": "8c3e11b2408fa96eefa3ebe7952d1b11b90b772b" + }, + { + "local": "PHYSICAL.json", + "origin": "research/exact-clifford-quadratic-replay/source/PHYSICAL.json", + "head": "daa4d9dbd102d2a3677afc5614c56466bd2cf3a2", + "sha256": "f78ba861d23ff33f2c9ffeca8c3ab6a7f1ec906f38adff5d325c13efb187c7c3", + "git_blob": "375b30b8c7aa16df521deaec04f16d1af8532abd" + }, + { + "local": "CONSTRUCTION.json.gz", + "origin": "research/exact-clifford-quadratic-replay/source/CONSTRUCTION.json.gz", + "head": "daa4d9dbd102d2a3677afc5614c56466bd2cf3a2", + "sha256": "00d13d7774adf087f93bc58d4c5860e296f8408c0ee25a4db254a056f8da7dec", + "git_blob": "31c6d481dd8b32e30d3c137bd2561a59a9d9fcc0" + }, + { + "local": "PR5698-NOTICE.md", + "origin": "research/exact-clifford-quadratic-replay/source/NOTICE.md", + "head": "daa4d9dbd102d2a3677afc5614c56466bd2cf3a2", + "sha256": "1f55b3e4bb80a60611b1fca0622da5a99fe7877446f03d0edd1dc8f3a5abadd2", + "git_blob": "56712e3195faf8c83319100065183b8b2488809d" + }, + { + "local": "LICENSE", + "origin": "research/exact-clifford-quadratic-replay/source/source/LICENSE", + "head": "daa4d9dbd102d2a3677afc5614c56466bd2cf3a2", + "sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "git_blob": "261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64" + } +] diff --git a/research/clifford-transported-fibre-gram/retained/predecessor/source/engine/contractions.py b/research/clifford-transported-fibre-gram/retained/predecessor/source/engine/contractions.py new file mode 100644 index 0000000000..76c807dece --- /dev/null +++ b/research/clifford-transported-fibre-gram/retained/predecessor/source/engine/contractions.py @@ -0,0 +1,236 @@ +"""Exact Clifford contractions with absolute phase. Apache-2.0. + +Classical affine-support and quadratic Gauss-sum methods. Prepared by +Ali Romman with substantial OpenAI Codex assistance. +""" +from fractions import Fraction +from hashlib import sha256 +import importlib.util +import json +from pathlib import Path +import sys + +ROOT = Path(__file__).resolve().parent + + +def load_source(name, filename): + records = json.loads((ROOT / 'INPUTS.json').read_text()) + record = next(x for x in records if x['local'] == filename) + path = ROOT / 'source' / filename + if sha256(path.read_bytes()).hexdigest() != record['sha256']: + raise ValueError('Changed frozen input: ' + filename) + spec = importlib.util.spec_from_file_location(name, path) + module = importlib.util.module_from_spec(spec) + sys.modules[name] = module + spec.loader.exec_module(module) + return module + + +Q = load_source('contraction_quadratic', 'PR5704-quadratic.py') + + +def add(a, b): + return a[0] + b[0], a[1] + b[1] + + +def conjugate(a): + return a[0], -a[1] + + +def power(a, exponent): + Q.need(type(exponent) is int and exponent >= 0, 'Nonnegative integral exponent') + result = (1, 0) + while exponent: + if exponent & 1: + result = Q.multiply(result, a) + a = Q.multiply(a, a) + exponent >>= 1 + return result + + +def solution(n, equations): + """Return every binary solution as affine coordinate forms, or None.""" + rows = {} + for mask, rhs in equations: + Q.validate_integer(mask, 1 << n, 'Equation variable mask') + Q.validate_integer(rhs, 2, 'Equation right side') + while mask: + pivot = mask.bit_length() - 1 + if pivot not in rows: + rows[pivot] = (mask, rhs) + break + other, value = rows[pivot] + mask ^= other + rhs ^= value + if not mask and rhs: + return None + free = [j for j in range(n) if j not in rows] + forms = [0] * n + for k, j in enumerate(free): + forms[j] = 1 << (k + 1) + for pivot in sorted(rows): + mask, rhs = rows[pivot] + forms[pivot] = rhs + for j in Q.bits(mask ^ (1 << pivot)): + forms[pivot] ^= forms[j] + return len(free), forms + + +def gauss(n, poly): + """Return sum_x i**q(x) as an exact Gaussian integer.""" + Q.need(type(n) is int and n >= 0, 'Nonnegative Gauss dimension') + for mask, coefficient in poly.items(): + Q.validate_integer(mask, 1 << n, 'Phase variable mask') + Q.need(type(coefficient) is int and 0 < coefficient < 4, + 'Canonical nonzero phase coefficient') + Q.need(mask.bit_count() <= 2 and (mask.bit_count() != 2 or coefficient == 2), + 'Only even quadratic terms') + poly = dict(poly) + scalar = (1, 0) + while n: + last = 1 << (n - 1) + a = poly.pop(last, 0) + linear = 0 + for mask in list(poly): + if mask & last: + linear ^= mask ^ last + del poly[mask] + n -= 1 + if a & 1: + scalar = Q.multiply(scalar, (1, 1 if a == 1 else -1)) + Q.affine(poly, linear << 1, -a) + elif linear: + resolved = solution(n, [(linear, a // 2)]) + Q.need(resolved is not None, 'A nonzero linear form takes both values') + n, forms = resolved + poly = Q.substitute(poly, forms) + scalar = (2 * scalar[0], 2 * scalar[1]) + elif a: + return (0, 0) + else: + scalar = (2 * scalar[0], 2 * scalar[1]) + return Q.multiply_i(scalar, poly.get(0, 0)) + + +def inner(left, right): + """Return the exact inner product of two valid engine states. + + Inputs come from signature or choi. Arbitrary serialized states are not + admitted without the source engine's construction contract. + """ + n, offset, cols, terms, a, b, den = left + m, other, cols2, terms2, c, d, den2 = right + Q.need(n == m, 'Equal state dimensions') + r = len(cols) + allcols = cols + cols2 + equations = [(sum(((v >> i) & 1) << j for j, v in enumerate(allcols)), + ((offset ^ other) >> i) & 1) for i in range(n)] + resolved = solution(len(allcols), equations) + if resolved is None: + return Fraction(0), Fraction(0) + dimension, forms = resolved + phase = Q.substitute(dict(terms2), forms[r:]) + for mask, coefficient in Q.substitute(dict(terms), forms[:r]).items(): + Q.term(phase, mask, -coefficient) + total = Q.multiply(Q.multiply((a, -b), (c, d)), gauss(dimension, phase)) + return Fraction(total[0], 1 << (den + den2)), Fraction(total[1], 1 << (den + den2)) + + +def choi(n, circuit): + """Return a normalized Choi state, retaining one common Bell phase.""" + Q.need(type(n) is int and n >= 0, 'Nonnegative circuit width') + preparation = [('C', (1 << j) | (1 << (n + j)), 1) for j in range(n)] + preparation.append(('D', tuple(1 << j if j < n else 0 for j in range(2 * n)), + (1,) * n + (0,) * n)) + expanded = [] + for gate in circuit: + # Validate the original arity and domain before extension. + Q.signature(n, [gate]) + kind = gate[0] + if kind == 'P': + expanded.append(('P', tuple(gate[1]) + tuple(1 << j for j in range(n, 2 * n)))) + elif kind == 'D': + expanded.append(('D', tuple(gate[1]) + (0,) * n, tuple(gate[2]) + (0,) * n)) + else: + expanded.append(gate) + return Q.signature(2 * n, preparation + expanded) + + +def trace(n, circuit): + result = inner(choi(n, []), choi(n, circuit)) + return result[0] * (1 << n), result[1] * (1 << n) + + +def kernel(states): + """Return normalized trace(U_i^* U_j) for valid equal-width circuits.""" + return [[inner(a, b) for b in states] for a in states] + + +def residual_norm(gram, coefficients, width): + """Return ||sum c_i U_i^(tensor width)||_HS^2 / d^width.""" + Q.need(type(width) is int and width > 0, 'Positive tensor width') + size = len(coefficients) + Q.need(len(gram) == size and all(len(row) == size for row in gram), 'Gram dimensions') + result = (Fraction(0), Fraction(0)) + for i, a in enumerate(coefficients): + for j, b in enumerate(coefficients): + result = add(result, Q.multiply(Q.multiply(conjugate(a), b), power(gram[i][j], width))) + Q.need(result[1] == 0 and result[0] >= 0, 'A valid Gram norm is real and nonnegative') + return result[0] + + +def decide(n, circuits, coefficients): + """Apply the credited four-width theorem to one fixed expanded residual.""" + Q.need(len(circuits) == len(coefficients), 'One fixed coefficient per circuit') + for a in coefficients: + Q.need(len(a) == 2 and all(type(x) in (int, Fraction) for x in a), + 'Exact rational real and imaginary coefficients') + gram = kernel([choi(n, c) for c in circuits]) + first = 4 * n + 4 if n else 1 + norms = [residual_norm(gram, coefficients, f) for f in range(first, first + 4)] + return dict(widths=list(range(first, first + 4)), norms=norms, + all_positive_widths_zero=all(x == 0 for x in norms)) + + +def divide(a, b): + scale = b[0] ** 2 + b[1] ** 2 + Q.need(scale != 0, 'Nonzero complex pivot') + value = Q.multiply(a, conjugate(b)) + return Fraction(value[0]) / scale, Fraction(value[1]) / scale + + +def best_approximation(states, target, width): + """Minimize the normalized squared residual in the supplied finite span. + + Coefficients may depend on this width. Dependent columns are permitted. + This operation does not admit a physical readout or new native queries. + """ + Q.need(type(width) is int and width > 0, 'Positive tensor width') + size = len(states) + gram = kernel(states + [target]) + matrix = [[power(gram[i][j], width) for j in range(size)] + + [power(gram[i][size], width)] for i in range(size)] + pivots = [] + for col in range(size): + row = next((r for r in range(len(pivots), size) if matrix[r][col] != (0, 0)), None) + if row is None: continue + k = len(pivots) + matrix[k], matrix[row] = matrix[row], matrix[k] + pivot = matrix[k][col] + matrix[k] = [divide(x, pivot) for x in matrix[k]] + for r in range(size): + if r != k: + factor = matrix[r][col] + matrix[r] = [add(x, Q.multiply((-factor[0], -factor[1]), y)) + for x, y in zip(matrix[r], matrix[k])] + pivots.append(col) + Q.need(all(row[-1] == (0, 0) for row in matrix[len(pivots):]), 'Consistent Gram normal equations') + coefficients = [(Fraction(0), Fraction(0))] * size + for row, col in enumerate(pivots): coefficients[col] = matrix[row][-1] + residual = residual_norm(gram, [(-x, -y) for x, y in coefficients] + [(1, 0)], width) + # Orthogonality is an independently inspectable optimum certificate. + for i in range(size): + value = (Fraction(0), Fraction(0)) + for j in range(size): value = add(value, Q.multiply(power(gram[i][j], width), coefficients[j])) + Q.need(value == power(gram[i][size], width), 'Exact residual orthogonality') + return dict(coefficients=coefficients, squared_residual=residual, span_rank=len(pivots)) diff --git a/research/clifford-transported-fibre-gram/retained/predecessor/source/engine/source/LICENSE b/research/clifford-transported-fibre-gram/retained/predecessor/source/engine/source/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/clifford-transported-fibre-gram/retained/predecessor/source/engine/source/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/research/clifford-transported-fibre-gram/retained/predecessor/source/engine/source/PR5698-NOTICE.md b/research/clifford-transported-fibre-gram/retained/predecessor/source/engine/source/PR5698-NOTICE.md new file mode 100644 index 0000000000..56712e3195 --- /dev/null +++ b/research/clifford-transported-fibre-gram/retained/predecessor/source/engine/source/PR5698-NOTICE.md @@ -0,0 +1,9 @@ +# Attribution + +Ali Romman with substantial OpenAI Codex assistance. Apache-2.0. + +Dugongue PR5687 supplies the actual two-line C coframe proposal and its complete profile, source interpretation and moment/tail proof. The native-dual-suppliers source supplies the actual restriction, native maps and main normalizers. Preserve Cao Yifan PR4610/4470, Cinna Davis and the native/frame/helper/ROW/controller lineage, DaysSky, Nick Petalas, Ryanson Jonathan, zxv, Jacob Alan Sussman, and every retained phase, scalar, compiler, precision, stock and analytic notice. + +Seventeen source files are retained byte for byte. Their original comments and attribution remain unchanged. INPUTS.json and SOURCES.json give exact commits, paths, Git objects and SHA256 hashes. Dinic's integral flow algorithm and the submodular graph-cut construction are classical methods, not new mathematics claimed here. + +The new work is the complete 423-frame binary optimization, four additional folds, exact emitted physical program and phase certificates, finite optimality headroom bound, stronger full gain, and charged higher-moment transfer. No global literature priority, independent human acceptance or new kappa is claimed. diff --git a/research/clifford-transported-fibre-gram/retained/predecessor/source/engine/source/PR5704-NOTICE.md b/research/clifford-transported-fibre-gram/retained/predecessor/source/engine/source/PR5704-NOTICE.md new file mode 100644 index 0000000000..b96b400e5c --- /dev/null +++ b/research/clifford-transported-fibre-gram/retained/predecessor/source/engine/source/PR5704-NOTICE.md @@ -0,0 +1,33 @@ +# Attribution + +Ali Romman with substantial OpenAI Codex assistance. Apache-2.0. + +The affine-support and quadratic-phase representation is classical stabilizer +simulation. Credit Jeroen Dehaene and Bart De Moor, Physical Review A 68, 042318 +(2003), and the phase-sensitive stabilizer literature, including Bravyi, Browne, +Calpin, Campbell, Gosset and Howard (arXiv:1808.00128). The proof gives a direct +induction for this exact Gaussian-dyadic gate grammar. No discovery or optimal +simulation-complexity claim is made. + +Charles Bethin PR662 supplies the byte-exact table evaluator and prior runtime +work. Its retained NOTICE credits icekylinx, DreamingOfClouds, chafreaky, Jeremy +Kothe and the prior Clifford/wrapper/compiler lineage. Its source and notice +are frozen in tables/. They are used as a comparison engine and finite oracle. + +Ali Romman PR5698 supplies the complete actual restricted-C coframe construction, +source replay and proof checks. Its 32 package files and all nested notices are +frozen in source/. replay.py and verify_source.py are explicitly marked derived +copies with only source paths and state-equality calls changed. Preserve +Dugongue PR5687, Cao Yifan PR4610/4470, Cinna Davis, DaysSky, Nick Petalas, +Ryanson Jonathan, zxv, Jacob Alan Sussman and all native/helper/phase/ROW/controller, +compiler, precision and stock attribution in those retained files. + +BigCactusLabs PR702 and Joshua Snider's cold-wrapper quadratic certificate are +related independent finite amplitude/phase audits. Their scopes and credit are +separate from this implementation. No source contribution is reassigned here. + +The new contribution is the exact polynomial-state engine, explicit full-source +integration, proof-check preservation binding, independent representation tests, +all-actual-state cross-check and complete same-fixture runtime evidence. There +is no change to the mathematical construction, selected result or physical bill. +No independent human review or proof-kernel acceptance is claimed. diff --git a/research/clifford-transported-fibre-gram/retained/predecessor/source/engine/source/PR5704-quadratic.py b/research/clifford-transported-fibre-gram/retained/predecessor/source/engine/source/PR5704-quadratic.py new file mode 100644 index 0000000000..ce3c86ec07 --- /dev/null +++ b/research/clifford-transported-fibre-gram/retained/predecessor/source/engine/source/PR5704-quadratic.py @@ -0,0 +1,283 @@ +"""Exact affine-support states for the retained Gaussian-dyadic gate grammar. + +The method is classical stabilizer simulation. This implementation keeps the +absolute Gaussian-integer scalar. Ali Romman with substantial OpenAI Codex +assistance. Apache-2.0. +""" + + +def need(condition, message): + if not condition: + raise ValueError(message) + + +def bits(mask): + while mask: + bit = mask & -mask + yield bit.bit_length() - 1 + mask ^= bit + + +def term(poly, mask, value): + value = (poly.get(mask, 0) + value) % 4 + if value: + poly[mask] = value + else: + poly.pop(mask, None) + + +def affine(poly, form, coefficient): + """Add a coefficient times an affine Boolean form, modulo four.""" + coefficient %= 4 + if not coefficient: + return + constant = form & 1 + term(poly, 0, coefficient * constant) + signed = coefficient * (1 - 2 * constant) + indices = list(bits(form >> 1)) + for i in indices: + term(poly, 1 << i, signed) + if coefficient & 1: + for k, i in enumerate(indices): + for j in indices[k + 1:]: + term(poly, (1 << i) | (1 << j), 2) + + +def product(poly, left, right): + """Add twice the product of two affine Boolean forms.""" + a, b = left & 1, right & 1 + u, v = list(bits(left >> 1)), list(bits(right >> 1)) + term(poly, 0, 2 * a * b) + if b: + for i in u: + term(poly, 1 << i, 2) + if a: + for j in v: + term(poly, 1 << j, 2) + for i in u: + for j in v: + term(poly, (1 << i) | (1 << j), 2) + + +def substitute(poly, forms): + result = {} + for mask, coefficient in poly.items(): + if not mask: + term(result, 0, coefficient) + elif mask.bit_count() == 1: + affine(result, forms[mask.bit_length() - 1], coefficient) + else: + need(mask.bit_count() == 2 and coefficient == 2, + 'A phase must have only even quadratic terms') + i, j = bits(mask) + product(result, forms[i], forms[j]) + return result + + +def value(poly, argument): + return sum(c for mask, c in poly.items() if argument & mask == mask) % 4 + + +def basis(columns): + """Return reduced binary columns with their original coordinates.""" + rows = {} + for j, column in enumerate(columns): + vector, coordinates = column, 1 << j + while vector: + pivot = vector.bit_length() - 1 + if pivot not in rows: + rows[pivot] = (vector, coordinates) + break + other, witness = rows[pivot] + vector ^= other + coordinates ^= witness + need(vector != 0, 'Support columns must be independent') + for pivot in sorted(rows): + vector, witness = rows[pivot] + for other in sorted(rows): + if other > pivot and rows[other][0] >> pivot & 1: + x, y = rows[other] + rows[other] = (x ^ vector, y ^ witness) + return rows + + +def coordinates(rows, vector): + result = 0 + for pivot in sorted(rows, reverse=True): + if vector >> pivot & 1: + column, witness = rows[pivot] + vector ^= column + result ^= witness + return None if vector else result + + +def multiply_i(pair, power): + a, b = pair + return ((a, b), (-b, a), (-a, -b), (b, -a))[power % 4] + + +def multiply(left, right): + a, b = left + c, d = right + return a * c - b * d, a * d + b * c + + +def normalize(pair, denominator): + need(pair != (0, 0), 'A unitary state cannot be zero') + while denominator and not ((pair[0] | pair[1]) & 1): + pair = (pair[0] // 2, pair[1] // 2) + denominator -= 1 + return pair, denominator + + +def matrix_vector(rows, vector): + return sum(((row & vector).bit_count() & 1) << j for j, row in enumerate(rows)) + + +def validate_integer(value_, limit, message): + need(type(value_) is int and 0 <= value_ < limit, message) + + +def signature(n, circuit, initial=0, counters=None): + """Return a canonical exact state without an exponential vector. + + A state is scalar times i^q(z) at offset xor columns*z. The columns + remain independent. The returned tuple describes every amplitude. + """ + need(type(n) is int and n >= 0, 'The width must be a nonnegative integer') + validate_integer(initial, 1 << n, 'Initial basis index') + columns, offset, poly = [], initial, {} + scalar, denominator = (1, 0), 0 + counts = counters if counters is not None else {} + + def count(key): + counts[key] = counts.get(key, 0) + 1 + + for gate in circuit: + need(isinstance(gate, (tuple, list)) and gate, 'Nonempty gate record') + kind = gate[0] + r = len(columns) + if kind == 'P': + need(len(gate) == 2 and len(gate[1]) == n, 'Permutation dimensions') + rows = gate[1] + for row in rows: + validate_integer(row, 1 << n, 'Binary permutation row') + basis(rows) + offset = matrix_vector(rows, offset) + columns = [matrix_vector(rows, x) for x in columns] + elif kind == 'X': + need(len(gate) == 2, 'Translation record') + validate_integer(gate[1], 1 << n, 'Translation mask') + offset ^= gate[1] + elif kind == 'phase': + need(len(gate) == 2 and type(gate[1]) is int, 'Global phase record') + term(poly, 0, gate[1]) + elif kind == 'D': + need(len(gate) == 3 and len(gate[1]) == len(gate[2]) == n, + 'Diagonal dimensions') + rows, linear = gate[1], gate[2] + for i in range(n): + validate_integer(rows[i], 1 << n, 'Binary diagonal row') + need(type(linear[i]) is int and linear[i] % 2 == (rows[i] >> i & 1), + 'Diagonal parity lift') + for j in range(i): + need((rows[i] >> j & 1) == (rows[j] >> i & 1), + 'Symmetric diagonal matrix') + forms = [(offset >> i & 1) | + sum((column >> i & 1) << (j + 1) for j, column in enumerate(columns)) + for i in range(n)] + for i, coefficient in enumerate(linear): + affine(poly, forms[i], coefficient) + for j in bits(rows[i] >> (i + 1)): + product(poly, forms[i], forms[i + 1 + j]) + elif kind == 'C': + need(len(gate) == 3 and type(gate[2]) is int and gate[2] in (-1, 1), + 'Translation-root record and sign') + q, sign = gate[1:] + validate_integer(q, 1 << n, 'Translation-root mask') + witness = coordinates(basis(columns), q) + scalar = multiply(scalar, (1, sign)) + denominator += 1 + term(poly, 1 << r, -sign) + if witness is None: + columns.append(q) + count('independent_root') + else: + # The last variable has zero output after this substitution. + forms = [(1 << (i + 1)) | (((witness >> i) & 1) << (r + 1)) + for i in range(r)] + [1 << (r + 1)] + poly = substitute(poly, forms) + last = 1 << r + coefficient = poly.pop(last, 0) + neighbours = 0 + for mask in list(poly): + if mask & last: + need(mask.bit_count() == 2 and poly[mask] == 2, + 'Dependent-root quadratic term') + neighbours ^= mask ^ last + del poly[mask] + if coefficient & 1: + scalar = multiply(scalar, (1, 1 if coefficient == 1 else -1)) + affine(poly, neighbours << 1, -coefficient) + count('odd_elimination') + else: + scalar = (2 * scalar[0], 2 * scalar[1]) + constant = coefficient // 2 + if neighbours: + pivot = (neighbours & -neighbours).bit_length() - 1 + free = [i for i in range(r) if i != pivot] + forms = [0] * r + for j, i in enumerate(free): + forms[i] = 1 << (j + 1) + forms[pivot] = constant | sum( + 1 << (j + 1) for j, i in enumerate(free) if neighbours >> i & 1) + poly = substitute(poly, forms) + if constant: + offset ^= columns[pivot] + columns = [columns[i] ^ (columns[pivot] if neighbours >> i & 1 else 0) + for i in free] + count('even_restriction') + else: + need(constant == 0, 'A unitary root cannot annihilate the state') + count('even_free') + scalar, denominator = normalize(scalar, denominator) + else: + raise ValueError('Unknown gate: ' + str(kind)) + need(len(columns) <= n, 'Support dimension cannot exceed width') + counts['peak_support_rank'] = max(counts.get('peak_support_rank', 0), len(columns)) + + rows = basis(columns) + reduced_offset, shift = offset, 0 + for pivot in sorted(rows, reverse=True): + if reduced_offset >> pivot & 1: + column, witness = rows[pivot] + reduced_offset ^= column + shift ^= witness + ordered = [rows[p] for p in sorted(rows)] + forms = [(shift >> i & 1) | sum(((witness >> i) & 1) << (j + 1) + for j, (_, witness) in enumerate(ordered)) for i in range(len(columns))] + poly = substitute(poly, forms) + scalar = multiply_i(scalar, poly.pop(0, 0)) + scalar, denominator = normalize(scalar, denominator) + return (n, reduced_offset, tuple(x for x, _ in ordered), tuple(sorted(poly.items())), + scalar[0], scalar[1], denominator) + + +def amplitude(state, index): + n, offset, columns, terms, real, imag, denominator = state + validate_integer(index, 1 << n, 'Amplitude index') + argument = coordinates(basis(columns), index ^ offset) + if argument is None: + return (0, 0), 0 + pair = multiply_i((real, imag), value(dict(terms), argument)) + return pair, denominator + + +def equal_operators(left, right): + """Compare valid retained Clifford objects, including absolute phase. + + Their tableaus must be derived from their circuits by the retained exact + constructors. An arbitrary supplied tableau is not a valid input contract. + """ + return (left.n == right.n and left.tab == right.tab and + signature(left.n, left.circuit) == signature(right.n, right.circuit)) diff --git a/research/clifford-transported-fibre-gram/retained/predecessor/source/row/bell_reads.py b/research/clifford-transported-fibre-gram/retained/predecessor/source/row/bell_reads.py new file mode 100644 index 0000000000..32b2ed2a94 --- /dev/null +++ b/research/clifford-transported-fibre-gram/retained/predecessor/source/row/bell_reads.py @@ -0,0 +1,128 @@ +"""Emit the phase-corrected Bell measurements for the compiled Clifford row. + +Use --emit for the identity fibre in order. Labels have four low Z bits +and four high X bits. apoursh with substantial OpenAI Codex assistance. +Apache-2.0. Phase correction is from PR7799. +""" +import argparse +from functools import cache +import json +from typing import NamedTuple + +from compile_row import DENOMINATOR, IDENTITY, SEED, apply, iter_terms, pairing + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def parity(value): + return value.bit_count() % 2 + + +def q0(v): + return parity((v >> 4) & v) + + +def transvection(axis, vector): + return vector ^ (axis if pairing(axis, vector) else 0) + + +def decompose(matrix): + """Write a symplectic map as a sequence of transvections in application order.""" + columns = list(matrix) + corrections = [] + for i, target in enumerate(IDENTITY): + source = columns[i] + if source == target: + continue + if pairing(source, target): + axes = (source ^ target,) + else: + middle = next(v for v in range(256) + if pairing(v, source) and pairing(v, target) + and all(pairing(source ^ v, fixed) == 0 for fixed in IDENTITY[:i])) + axes = (source ^ middle, middle ^ target) + for axis in axes: + columns = [transvection(axis, v) for v in columns] + corrections.append(axis) + require(tuple(columns) == IDENTITY, "transvection reduction failed") + return tuple(reversed(corrections)) + + +def step(axis, v, bell): + """Phase exponent modulo four of a transvection on one unphased Weyl label.""" + out = transvection(axis, v) + exponent = 0 + if out != v: + exponent = 1 + q0(axis) + 2 * parity((axis & 15) & (v >> 4)) + if bell: + if q0(axis): + exponent += 1 + else: + exponent += 2 + 2 * parity((out & 15) & (axis >> 4)) + out ^= axis + return out, exponent % 4 + + +def label_sum(labels): + total = 0 + for label in labels: + total ^= label + return total + + +@cache +def transported_seed(matrix): + """Return the six output labels and the seed's transport phase exponent.""" + labels = list(SEED) + weight = label_sum(SEED) + phase = 0 + for axis in decompose(matrix): + next_weight, gamma = step(axis, weight, False) + values = [step(axis, label, True) for label in labels] + labels = [value for value, _ in values] + phase += sum(theta for _, theta in values) - gamma + weight = next_weight + # Independent affine check. q(Sv+b)=q(v) fixes the offset b uniquely. + offset = labels[0] + require(all(q0(apply(matrix, u) ^ offset) == q0(u) for u in (0, *IDENTITY)), + "Bell offset violates transpose parity") + require(all(label == apply(matrix, v) ^ offset for v, label in zip(SEED, labels, strict=True)) + and weight == label_sum(labels), "misordered symplectic transport") + return tuple(labels), phase % 4 + + +class Read(NamedTuple): + numerator: int + input_labels: tuple[int, ...] + output_labels: tuple[int, ...] + correction_i: int + + +def iter_reads(target=IDENTITY): + """Weight is numerator/DENOMINATOR. Multiply the corrected singleton by i^correction_i.""" + for term in iter_terms(target): + i, phase_i = transported_seed(term.input_map) + j, phase_j = transported_seed(term.output_map) + yield Read(term.numerator, i, j, (phase_i - phase_j) % 4) + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--emit", action="store_true", help="emit one JSON object per identity-fibre read") + args = parser.parse_args() + pairs = set() + for read in iter_reads(): + pair = read.input_labels, read.output_labels + require(pair not in pairs, "repeated literal Bell address") + pairs.add(pair) + if args.emit: + print(json.dumps(dict(read._asdict(), denominator=DENOMINATOR))) + if not args.emit: + print(f"PASS_BELL_READS distinct_pairs={len(pairs)}") + + +if __name__ == "__main__": + main() diff --git a/research/clifford-transported-fibre-gram/retained/predecessor/source/row/compile_row.py b/research/clifford-transported-fibre-gram/retained/predecessor/source/row/compile_row.py new file mode 100644 index 0000000000..daf35d6a26 --- /dev/null +++ b/research/clifford-transported-fibre-gram/retained/predecessor/source/row/compile_row.py @@ -0,0 +1,247 @@ +"""Compile the shear-character certificate in PR7799 into signed Bell reads. + +Binary vectors have four low Z bits and four high X bits, least significant +bit for qubit one. A matrix is the tuple of images of the standard basis. +apoursh, with substantial OpenAI Codex and separate agent assistance. +Apache-2.0. The seed, character cases and plane selection are from PR7799. +""" +import argparse +from collections import Counter, defaultdict +from functools import cache +from itertools import combinations, combinations_with_replacement +import json +from typing import NamedTuple + + +IDENTITY = tuple(1 << i for i in range(8)) +DENOMINATOR = 1024 +SEED = (0, 1, 2, 4, 8, 128) +UPPER = tuple(combinations_with_replacement(range(4), 2)) + + +class Term(NamedTuple): + numerator: int + input_map: tuple[int, ...] + output_map: tuple[int, ...] + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def apply(columns, vector): + result = 0 + while vector: + bit = vector & -vector + result ^= columns[bit.bit_length() - 1] + vector ^= bit + return result + + +def compose(left, right): + return tuple(apply(left, v) for v in right) + + +def pairing(u, v): + return (((u >> 4) & v) ^ ((v >> 4) & u)).bit_count() % 2 + + +def span(basis): + points = [0] + for v in basis: + points += [u ^ v for u in points] + return points + + +def is_symplectic(matrix): + return (len(matrix) == 8 and all(isinstance(v, int) and 0 <= v < 256 for v in matrix) + and all(pairing(matrix[i], matrix[j]) == pairing(IDENTITY[i], IDENTITY[j]) + for i, j in combinations(range(8), 2))) + + +@cache +def shear(mask): + """Send (z,x) to (z+B x,x), with B's upper triangle given by mask.""" + result = list(IDENTITY) + for index, (i, j) in enumerate(UPPER): + if mask & (1 << index): + result[4 + i] ^= 1 << j + if i != j: + result[4 + j] ^= 1 << i + return tuple(result) + + +def pair_mask(u, v): + return sum(((((u >> i) & (v >> j)) ^ ((u >> j) & (v >> i))) & 1) << k + for k, (i, j) in enumerate(UPPER)) + + +def quadratic_address(v): + return sum(1 << k for k, (i, j) in enumerate(UPPER) if v & (1 << i) and v & (1 << j)) + + +def select_plane(ch): + # Match the deterministic binary ordering used by the PR7799 verifier. + values = tuple((ch & quadratic_address(v)).bit_count() % 2 for v in range(16)) + + def polar(u, v): + return values[u] ^ values[v] ^ values[u ^ v] + + if any(all(polar(v, b) == 0 for b in (1, 2, 4, 8)) for v in range(1, 16)): + return next(w for w in combinations(range(1, 16), 3) + if len(set(span(w))) == 8 and all(polar(i, j) == 0 for i, j in combinations(w, 2))) + r = next(v for v in range(1, 16) if values[v] == 0) + hyperplane = [u for u in range(16) if polar(r, u) == 0] + z2 = next(v for v in hyperplane if v not in (0, r)) + dual = next(x for x in range(1, 16) if all((x & v).bit_count() % 2 == 0 for v in hyperplane)) + return r, z2, dual << 4 + + +def canonical_basis(points): + basis = [] + for v in sorted(points): + if v not in span(basis): + basis.append(v) + return tuple(basis) + + +def extend_basis(w): + z = list(w) + z.append(next(v for v in range(1, 256) if v not in span(z) and all(pairing(v, u) == 0 for u in z))) + x = [] + for i in range(4): + x.append(next(v for v in range(1, 256) + if all(pairing(v, u) == int(i == j) for j, u in enumerate(z)) + and all(pairing(v, b) == 0 for b in x))) + matrix = tuple(z + x) + require(is_symplectic(matrix), "plane transporter is not symplectic") + return matrix + + +def walsh(characters): + values = [0] * 1024 + for ch in characters: + values[ch] = 1 + step = 1 + while step < len(values): + for start in range(0, len(values), 2 * step): + for i in range(start, start + step): + j = i + step + values[i], values[j] = values[i] + values[j], values[i] - values[j] + step *= 2 + return values + + +def normalizer_representatives(w, p_basis): + if len(p_basis) == 3: + return [0] + dual = next(v for v in w if v >> 4) + p = span(p_basis) + representatives = {} + for mask in range(1024): + b_dual = apply(shear(mask), dual) ^ dual + key = min(b_dual ^ u for u in p) + representatives.setdefault(key, mask) + require(len(representatives) == 4, "mixed-plane normalizer index") + return sorted(representatives.values()) + + +def iter_terms(target=IDENTITY): + """Yield numerator / DENOMINATOR weights on transported coset *sums*. + + Apply the source and target transporters to SEED via the affine Bell + action and undo the singleton/transport phases as specified in PROOF.md. + The weighted sum of those 16-by-16 blocks is the target's fibre matrix + on the image of the observation map. Target defaults to the identity. + """ + require(is_symplectic(target), "invalid target symplectic matrix") + by_plane = defaultdict(list) + for ch in range(1024): + by_plane[canonical_basis(span(select_plane(ch)))].append(ch) + for w, chars in sorted(by_plane.items()): + pure = tuple(z for z in w if z < 16) + h = span(tuple(pair_mask(u, v) for u, v in combinations(pure, 2))) + representatives = normalizer_representatives(w, pure) + g = extend_basis(w) + values = walsh(chars) + divisor = 4 if len(pure) == 2 else 1 + for delta, value in enumerate(values): + if not value or delta != min(delta ^ offset for offset in h): + continue + require(value % divisor == 0, "coefficient needs a finer denominator") + for b in representatives: + right = compose(shear(b), g) + left = compose(target, compose(shear(delta ^ b), g)) + yield Term(value // divisor, right, left) + + +def seed_subgroup(): + hats = [pair_mask(1 << i, 1 << j) for i, j in combinations(range(3), 2)] + return tuple(shear(mask) for mask in span(hats)) + + +@cache +def inverse(matrix): + # Binary symplectic inverse from the images of a paired basis. + return tuple(sum(pairing(matrix[i ^ 4], u) << i for i in range(8)) for u in IDENTITY) + + +def bell_tuple(matrix): + # q(L v)=q(v) gives = q(u)+q(S^-1 u), hence b from the + # images of basis vectors under the inverse. q(e_j)=0. + inv = inverse(matrix) + offset = 0 + for j in range(8): + v = inv[j ^ 4] + offset |= (((v >> 4) & v).bit_count() % 2) << j + return tuple(apply(matrix, v) ^ offset for v in SEED) + + +def check(target): + accum = Counter() + seen = set() + terms = list(iter_terms(target)) + subgroup = seed_subgroup() + for weight, right, left in terms: + products = {compose(left, compose(c, inverse(right))) for c in subgroup} + key = frozenset(products) + require(len(products) == 8 and key not in seen, "repeated or malformed coset") + seen.add(key) + for item in products: + accum[item] += weight + require({k: v for k, v in accum.items() if v} == {target: DENOMINATOR}, + "signed coset sum is not the single target") + require(len(accum) == 8304, "expanded union size") + mass_by_input = Counter() + for term in terms: + mass_by_input[bell_tuple(term.input_map)] += abs(term.numerator) + require(Counter(mass_by_input.values()) == {128: 29, 192: 10, 224: 8, 240: 8, 288: 12}, + "absolute coefficient mass by input") + require(8 * sum(m*m for m in mass_by_input.values()) * 64 == 1319 * DENOMINATOR**2, + "simultaneous squared norm bound") + numerators = [term.numerator for term in terms] + require(len(terms) == 4265 and sum(abs(w) for w in numerators) == 12800, + "row sparsity or absolute mass") + require(sum(w*w for w in numerators) == DENOMINATOR**2 // 8, "squared row mass") + require(any(w % 2 for w in numerators), "denominator 1024 not attained") + return len(accum) + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--emit", action="store_true", help="emit the identity row as JSON lines") + args = parser.parse_args() + if args.emit: + for term in iter_terms(): + print(json.dumps(term._asdict(), separators=(",", ":"))) + return + covered = check(IDENTITY) + # Hadamard on each qubit swaps the two coordinate registers. + require(check(IDENTITY[4:] + IDENTITY[:4]) == covered, "translated support") + print(f"PASS_COMPRESSED_CLIFFORD_ROW terms=4265 group_terms=34120 union={covered}" + " denominator=1024 absolute_mass=25/2 squared_mass=1/8 row_norm_squared=2^45") + + +if __name__ == "__main__": + main() diff --git a/research/clifford-transported-fibre-gram/retained/predecessor/source/row/raw_row.py b/research/clifford-transported-fibre-gram/retained/predecessor/source/row/raw_row.py new file mode 100644 index 0000000000..1787feb76a --- /dev/null +++ b/research/clifford-transported-fibre-gram/retained/predecessor/source/row/raw_row.py @@ -0,0 +1,284 @@ +"""Exact computational-basis coefficients of the compiled identity decoder. + +A row or column address is a 52-bit integer, with the first register in +the most significant nibble. A returned numerator has denominator 4096. +apoursh, with substantial OpenAI Codex assistance. Apache-2.0. +""" +import argparse +from collections import Counter, defaultdict +from dataclasses import dataclass +from functools import cache +from itertools import islice +import json + +from bell_reads import iter_reads, label_sum +from compile_row import DENOMINATOR + + +BITS = 52 +RAW_DENOMINATOR = 4 * DENOMINATOR + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def pack(nibbles): + return sum(nibble << (4 * i) for i, nibble in enumerate(nibbles)) + + +def split_address(address): + if not isinstance(address, int) or not 0 <= address < 1 << BITS: + raise ValueError("row and column must be unsigned 52-bit addresses") + return tuple((address >> (4 * j)) & 15 for j in reversed(range(13))) + + +@dataclass(frozen=True) +class Bucket: + masks: tuple[int, ...] + numerators: tuple[int, ...] + + def signature(self, point): + return sum(((mask & point).bit_count() % 2) << j for j, mask in enumerate(self.masks)) + + def point_at(self, signature, index): + """Unrank the free bits, then solve the parity equations by leading bit.""" + pivots = sorted((mask.bit_length()-1, j) for j, mask in enumerate(self.masks)) + pivot_bits = {bit for bit, _ in pivots} + point = 0 + for bit in range(BITS): + if bit not in pivot_bits: + point |= (index & 1) << bit + index >>= 1 + for bit, j in pivots: + target = (signature >> j) & 1 + value = target ^ ((self.masks[j] & point).bit_count() % 2) + point |= value << bit + return point + + +def make_bucket(terms): + masks = [] + pivots = {} + weights = Counter() + for frequency, weight in terms: + address = 0 + while frequency: + bit = frequency.bit_length()-1 + if bit not in pivots: + pivots[bit] = len(masks) + masks.append(frequency) + j = pivots[bit] + frequency ^= masks[j] + address ^= 1 << j + weights[address] += weight + # Orthogonality of the independent masks makes every sign pattern attainable. + table = [weights[i] for i in range(1 << len(masks))] + step = 1 + while step < len(table): + for start in range(0, len(table), 2 * step): + for i in range(start, start + step): + a, b = table[i], table[i+step] + table[i], table[i+step] = a+b, a-b + step *= 2 + return Bucket(tuple(masks), tuple(table)) + + +@cache +def raw_plan(): + terms = defaultdict(list) + for read in iter_reads(): + labels = read.output_labels + read.input_labels + shifts = tuple(t >> 4 for t in labels) + singleton = label_sum(labels) + require(singleton < 16, "identity trace is not diagonal in this term") + require(read.correction_i == 0, "identity term has an unexpected phase") + frequency = pack([*(t & 15 for t in labels), singleton]) + terms[shifts].append((frequency, read.numerator)) + return {key: make_bucket(value) for key, value in sorted(terms.items())} + + +def coefficient_numerator(row, column): + r, c = split_address(row), split_address(column) + if r[-1] != c[-1]: + return 0 + pairs = r[:-1] + c[:-1] + shifts = tuple(a ^ b for a, b in zip(pairs[::2], pairs[1::2], strict=True)) + bucket = raw_plan().get(shifts) + if bucket is None: + return 0 + point = pack((*pairs[1::2], r[-1])) + return bucket.numerators[bucket.signature(point)] + + +def matrix_addresses(shifts, point): + addresses = [] + singleton = (point >> 48) & 15 + for start in (0, 6): + address = 0 + for index in range(start, start+6): + v = (point >> (4*index)) & 15 + address = (address << 8) | ((v ^ shifts[index]) << 4) | v + addresses.append((address << 4) | singleton) + return tuple(addresses) + + +def probe_at(index): + """One nonzero coordinate, in deterministic bucket/signature/free-bit order.""" + if not isinstance(index, int) or index < 0: + raise ValueError("probe index must be a nonnegative integer") + for shifts, bucket in raw_plan().items(): + size = 1 << (BITS-len(bucket.masks)) + for signature, numerator in enumerate(bucket.numerators): + if numerator != 0: + if index < size: + point = bucket.point_at(signature, index ^ (index >> 1)) + row, col = matrix_addresses(shifts, point) + return row, col, numerator + index -= size + raise ValueError("probe index outside the nonzero support") + + +def cell_geometry(shifts, bucket): + def address(signature, index): + row, column = matrix_addresses(shifts, bucket.point_at(signature, index)) + return (row << BITS) | column + + origin = address(0, 0) + directions = [origin ^ address(0, 1 << j) for j in range(BITS - len(bucket.masks))] + return address, directions + + +def iter_probes(): + """Stream the exact nonzero support of the identity row in probe_at order.""" + for shifts, bucket in raw_plan().items(): + address, directions = cell_geometry(shifts, bucket) + size = 1 << len(directions) + for signature, numerator in enumerate(bucket.numerators): + if not numerator: + continue + pointer = address(signature, 0) + for i in range(size): + row, col = divmod(pointer, 1 << BITS) + yield row, col, numerator + if i + 1 < size: + # Consecutive reflected Gray words flip this one free bit. + delta = i + 1 + pointer ^= directions[(delta & -delta).bit_length() - 1] + + +def first_last_addresses(): + """Extrema of the nonzero row on a row-major tape, over affine Walsh cells.""" + first, last = 1 << (2*BITS), -1 + for shifts, bucket in raw_plan().items(): + address, generators = cell_geometry(shifts, bucket) + pivots = {} + for v in generators: + while v: + bit = v.bit_length() - 1 + if bit not in pivots: + pivots[bit] = v + break + v ^= pivots[bit] + require(len(pivots) == BITS - len(bucket.masks), "address map lost a free bit") + directions = [pivots[bit] for bit in sorted(pivots, reverse=True)] + for i, n in enumerate(bucket.numerators): + if not n: + continue + lo = hi = address(i, 0) + for direction in directions: + lo = min(lo, lo ^ direction) + hi = max(hi, hi ^ direction) + first, last = min(first, lo), max(last, hi) + return first, last + + +def check_diagonal_columns(): + # For U=Z^z, the raw column is supported on equal row and column + # addresses. There r=s for every pair, leaving 24 pair bits and one + # free singleton. Push these free bits through the parity equations. + outputs = [0] * 16 + for shifts, bucket in raw_plan().items(): + require(shifts[:6] == shifts[6:], "diagonal fixture shift layout") + image = {0} + for bit in range(24): + basis_point = (1 << bit) | (1 << (bit+24)) + character = bucket.signature(basis_point) + image |= {s ^ character for s in image} + multiplicity = 2**24 // len(image) + shift_sum = label_sum(shifts[:6]) + for singleton in range(16): + offset = bucket.signature(singleton << 48) + total = sum(bucket.numerators[s ^ offset] for s in image) * multiplicity + for z in range(16): + sign = (-1) ** (((shift_sum ^ singleton) & z).bit_count() % 2) + outputs[z] += sign * total + require(outputs == [RAW_DENOMINATOR * 4**13] + [0]*15, + "normalized diagonal Clifford recovery from raw address weights") + + +def check(): + counts = Counter() + cells = 0 + checked = 0 + plan = raw_plan() + for shifts, bucket in plan.items(): + size = 1 << (BITS - len(bucket.masks)) + cells += len(bucket.numerators) + for signature, n in enumerate(bucket.numerators): + counts[n] += size + for index in (0, size-1): + point = bucket.point_at(signature, index) + require(bucket.signature(point) == signature, "unranking a Walsh class") + require(coefficient_numerator(*matrix_addresses(shifts, point)) == n, + "raw address lookup mismatch") + checked += 1 + expected = {0: 77827831060496384, 128: 10133099161583616, -128: 10133099161583616, + 512: 492581209243648, -512: 492581209243648} + require(counts == expected and len(plan) == 22, "raw coefficient multiplicities") + support = sum(count for n, count in counts.items() if n) + require(support == 151 * 2**47, "raw query bill") + require(sum(n*n*count for n,count in counts.items()) == RAW_DENOMINATOR**2 * 2**45, + "computational and Bell row norms disagree") + for index in (0, 1, support//2, support-2, support-1): + row, col, n = probe_at(index) + require(n == coefficient_numerator(row, col) and n != 0, "nonzero-support unranking") + require(list(islice(iter_probes(), 64)) == [probe_at(i) for i in range(64)], + "stream order disagrees with indexed access") + check_diagonal_columns() + first, last = first_last_addresses() + require(first == 0x00000000000210000000000021 and first + last == (1 << (2*BITS)) - 1, + "row-major tape extrema") + for address in (first, last): + require(coefficient_numerator(*divmod(address, 1 << BITS)) != 0, "inactive tape endpoint") + print(f"PASS_RAW_IDENTITY_ROW buckets={len(plan)} Walsh_cells={cells}" + f" boundary_lookups={checked} nonzero_coordinates={support} squared_norm=2^45" + f" first={first:026x} last={last:026x}") + + +def integer(text): + return int(text, 0) + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + action = parser.add_mutually_exclusive_group() + action.add_argument("--entry", type=integer, nargs=2, metavar=("ROW", "COLUMN")) + action.add_argument("--probe-index", type=integer, + help="unrank one nonzero coordinate, starting at zero") + args = parser.parse_args() + if args.entry is not None: + row, col = args.entry + numerator = coefficient_numerator(row, col) + elif args.probe_index is not None: + row, col, numerator = probe_at(args.probe_index) + else: + check() + return + print(json.dumps({"row": row, "column": col, "numerator": numerator, + "denominator": RAW_DENOMINATOR})) + + +if __name__ == "__main__": + main() diff --git a/research/clifford-transported-fibre-gram/retained/width13-spectrum.json b/research/clifford-transported-fibre-gram/retained/width13-spectrum.json new file mode 100644 index 0000000000..039f22ba0b --- /dev/null +++ b/research/clifford-transported-fibre-gram/retained/width13-spectrum.json @@ -0,0 +1,1519 @@ +{ + "source_files": 18, + "projective_order": 12128668876800, + "width": 13, + "rows": [ + { + "row": 1, + "quotient_degree": 1, + "multiplicity": 651, + "clifford_degree": 16, + "regular_dimension": 256, + "eigenvalue": [ + 470624175, + 4294967296 + ] + }, + { + "row": 2, + "quotient_degree": 35, + "multiplicity": 1518660, + "clifford_degree": 560, + "regular_dimension": 313600, + "eigenvalue": [ + 7841980575, + 1073741824 + ] + }, + { + "row": 3, + "quotient_degree": 51, + "multiplicity": 1611753, + "clifford_degree": 816, + "regular_dimension": 665856, + "eigenvalue": [ + 22846598775, + 4294967296 + ] + }, + { + "row": 4, + "quotient_degree": 85, + "multiplicity": 3148145, + "clifford_degree": 1360, + "regular_dimension": 1849600, + "eigenvalue": [ + 26774973225, + 4294967296 + ] + }, + { + "row": 5, + "quotient_degree": 119, + "multiplicity": 118482, + "clifford_degree": 1904, + "regular_dimension": 3625216, + "eigenvalue": [ + 359889075, + 2147483648 + ] + }, + { + "row": 6, + "quotient_degree": 135, + "multiplicity": 211575, + "clifford_degree": 2160, + "regular_dimension": 4665600, + "eigenvalue": [ + 1132984125, + 4294967296 + ] + }, + { + "row": 7, + "quotient_degree": 238, + "multiplicity": 5425992, + "clifford_degree": 3808, + "regular_dimension": 14500864, + "eigenvalue": [ + 4120362675, + 1073741824 + ] + }, + { + "row": 8, + "quotient_degree": 510, + "multiplicity": 620620, + "clifford_degree": 8160, + "regular_dimension": 66585600, + "eigenvalue": [ + 439864425, + 2147483648 + ] + }, + { + "row": 9, + "quotient_degree": 595, + "multiplicity": 620620, + "clifford_degree": 9520, + "regular_dimension": 90630400, + "eigenvalue": [ + 188513325, + 1073741824 + ] + }, + { + "row": 10, + "quotient_degree": 595, + "multiplicity": 2637635, + "clifford_degree": 9520, + "regular_dimension": 90630400, + "eigenvalue": [ + 3204726525, + 4294967296 + ] + }, + { + "row": 11, + "quotient_degree": 918, + "multiplicity": 9570847, + "clifford_degree": 14688, + "regular_dimension": 215737344, + "eigenvalue": [ + 15074084025, + 8589934592 + ] + }, + { + "row": 12, + "quotient_degree": 1190, + "multiplicity": 4765475, + "clifford_degree": 19040, + "regular_dimension": 362521600, + "eigenvalue": [ + 5790052125, + 8589934592 + ] + }, + { + "row": 13, + "quotient_degree": 1275, + "multiplicity": 4765475, + "clifford_degree": 20400, + "regular_dimension": 416160000, + "eigenvalue": [ + 2702024325, + 4294967296 + ] + }, + { + "row": 14, + "quotient_degree": 1512, + "multiplicity": 28353468, + "clifford_degree": 24192, + "regular_dimension": 585252864, + "eigenvalue": [ + 27113003775, + 8589934592 + ] + }, + { + "row": 15, + "quotient_degree": 1785, + "multiplicity": 22608300, + "clifford_degree": 28560, + "regular_dimension": 815673600, + "eigenvalue": [ + 2289090375, + 1073741824 + ] + }, + { + "row": 16, + "quotient_degree": 1785, + "multiplicity": 3878875, + "clifford_degree": 28560, + "regular_dimension": 815673600, + "eigenvalue": [ + 1570944375, + 4294967296 + ] + }, + { + "row": 17, + "quotient_degree": 2295, + "multiplicity": 38434110, + "clifford_degree": 36720, + "regular_dimension": 1348358400, + "eigenvalue": [ + 6053372325, + 2147483648 + ] + }, + { + "row": 18, + "quotient_degree": 2856, + "multiplicity": 4592588, + "clifford_degree": 45696, + "regular_dimension": 2088124416, + "eigenvalue": [ + 2324997675, + 8589934592 + ] + }, + { + "row": 19, + "quotient_degree": 2856, + "multiplicity": 36173280, + "clifford_degree": 45696, + "regular_dimension": 2088124416, + "eigenvalue": [ + 2289090375, + 1073741824 + ] + }, + { + "row": 20, + "quotient_degree": 2975, + "multiplicity": 28260375, + "clifford_degree": 47600, + "regular_dimension": 2265760000, + "eigenvalue": [ + 6867271125, + 4294967296 + ] + }, + { + "row": 21, + "quotient_degree": 2975, + "multiplicity": 42578965, + "clifford_degree": 47600, + "regular_dimension": 2265760000, + "eigenvalue": [ + 10346688495, + 4294967296 + ] + }, + { + "row": 22, + "quotient_degree": 3213, + "multiplicity": 6330324, + "clifford_degree": 51408, + "regular_dimension": 2642782464, + "eigenvalue": [ + 356080725, + 1073741824 + ] + }, + { + "row": 23, + "quotient_degree": 3213, + "multiplicity": 49512177, + "clifford_degree": 51408, + "regular_dimension": 2642782464, + "eigenvalue": [ + 11140239825, + 4294967296 + ] + }, + { + "row": 24, + "quotient_degree": 3400, + "multiplicity": 7757750, + "clifford_degree": 54400, + "regular_dimension": 2959360000, + "eigenvalue": [ + 6597966375, + 17179869184 + ] + }, + { + "row": 25, + "quotient_degree": 3570, + "multiplicity": 15825810, + "clifford_degree": 57120, + "regular_dimension": 3262694400, + "eigenvalue": [ + 3204726525, + 4294967296 + ] + }, + { + "row": 26, + "quotient_degree": 3570, + "multiplicity": 7757750, + "clifford_degree": 57120, + "regular_dimension": 3262694400, + "eigenvalue": [ + 1570944375, + 4294967296 + ] + }, + { + "row": 27, + "quotient_degree": 3570, + "multiplicity": 45216600, + "clifford_degree": 57120, + "regular_dimension": 3262694400, + "eigenvalue": [ + 2289090375, + 1073741824 + ] + }, + { + "row": 28, + "quotient_degree": 3808, + "multiplicity": 42503604, + "clifford_degree": 60928, + "regular_dimension": 3712221184, + "eigenvalue": [ + 64552348575, + 34359738368 + ] + }, + { + "row": 29, + "quotient_degree": 4200, + "multiplicity": 12412400, + "clifford_degree": 67200, + "regular_dimension": 4515840000, + "eigenvalue": [ + 1068242175, + 2147483648 + ] + }, + { + "row": 30, + "quotient_degree": 4760, + "multiplicity": 10550540, + "clifford_degree": 76160, + "regular_dimension": 5800345600, + "eigenvalue": [ + 3204726525, + 8589934592 + ] + }, + { + "row": 31, + "quotient_degree": 5712, + "multiplicity": 29089346, + "clifford_degree": 91392, + "regular_dimension": 8352497664, + "eigenvalue": [ + 29452962825, + 34359738368 + ] + }, + { + "row": 32, + "quotient_degree": 5950, + "multiplicity": 56520750, + "clifford_degree": 95200, + "regular_dimension": 9063040000, + "eigenvalue": [ + 6867271125, + 4294967296 + ] + }, + { + "row": 33, + "quotient_degree": 5950, + "multiplicity": 39564525, + "clifford_degree": 95200, + "regular_dimension": 9063040000, + "eigenvalue": [ + 9614179575, + 8589934592 + ] + }, + { + "row": 34, + "quotient_degree": 7140, + "multiplicity": 51622285, + "clifford_degree": 114240, + "regular_dimension": 13050777600, + "eigenvalue": [ + 20907025425, + 17179869184 + ] + }, + { + "row": 35, + "quotient_degree": 8160, + "multiplicity": 67824900, + "clifford_degree": 130560, + "regular_dimension": 17045913600, + "eigenvalue": [ + 48070897875, + 34359738368 + ] + }, + { + "row": 36, + "quotient_degree": 8925, + "multiplicity": 26376350, + "clifford_degree": 142800, + "regular_dimension": 20391840000, + "eigenvalue": [ + 1068242175, + 2147483648 + ] + }, + { + "row": 37, + "quotient_degree": 8925, + "multiplicity": 62172825, + "clifford_degree": 142800, + "regular_dimension": 20391840000, + "eigenvalue": [ + 5035998825, + 4294967296 + ] + }, + { + "row": 38, + "quotient_degree": 8960, + "multiplicity": 106392000, + "clifford_degree": 143360, + "regular_dimension": 20552089600, + "eigenvalue": [ + 34336355625, + 17179869184 + ] + }, + { + "row": 39, + "quotient_degree": 9639, + "multiplicity": 42729687, + "clifford_degree": 154224, + "regular_dimension": 23785042176, + "eigenvalue": [ + 3204726525, + 4294967296 + ] + }, + { + "row": 40, + "quotient_degree": 10200, + "multiplicity": 113041500, + "clifford_degree": 163200, + "regular_dimension": 26634240000, + "eigenvalue": [ + 16023632625, + 8589934592 + ] + }, + { + "row": 41, + "quotient_degree": 11900, + "multiplicity": 52752700, + "clifford_degree": 190400, + "regular_dimension": 36252160000, + "eigenvalue": [ + 3204726525, + 4294967296 + ] + }, + { + "row": 42, + "quotient_degree": 11900, + "multiplicity": 79129050, + "clifford_degree": 190400, + "regular_dimension": 36252160000, + "eigenvalue": [ + 9614179575, + 8589934592 + ] + }, + { + "row": 43, + "quotient_degree": 13056, + "multiplicity": 33761728, + "clifford_degree": 208896, + "regular_dimension": 43637538816, + "eigenvalue": [ + 7477695225, + 17179869184 + ] + }, + { + "row": 44, + "quotient_degree": 13600, + "multiplicity": 82897100, + "clifford_degree": 217600, + "regular_dimension": 47349760000, + "eigenvalue": [ + 35251991775, + 34359738368 + ] + }, + { + "row": 45, + "quotient_degree": 14280, + "multiplicity": 63303240, + "clifford_degree": 228480, + "regular_dimension": 52203110400, + "eigenvalue": [ + 3204726525, + 4294967296 + ] + }, + { + "row": 46, + "quotient_degree": 14280, + "multiplicity": 137910630, + "clifford_degree": 228480, + "regular_dimension": 52203110400, + "eigenvalue": [ + 27926902575, + 17179869184 + ] + }, + { + "row": 47, + "quotient_degree": 14688, + "multiplicity": 48532484, + "clifford_degree": 235008, + "regular_dimension": 55228760064, + "eigenvalue": [ + 19109665575, + 34359738368 + ] + }, + { + "row": 48, + "quotient_degree": 16065, + "multiplicity": 55390335, + "clifford_degree": 257040, + "regular_dimension": 66069561600, + "eigenvalue": [ + 2492565075, + 4294967296 + ] + }, + { + "row": 49, + "quotient_degree": 16065, + "multiplicity": 65940875, + "clifford_degree": 257040, + "regular_dimension": 66069561600, + "eigenvalue": [ + 2967339375, + 4294967296 + ] + }, + { + "row": 50, + "quotient_degree": 16065, + "multiplicity": 87041955, + "clifford_degree": 257040, + "regular_dimension": 66069561600, + "eigenvalue": [ + 3916887975, + 4294967296 + ] + }, + { + "row": 51, + "quotient_degree": 16065, + "multiplicity": 169562250, + "clifford_degree": 257040, + "regular_dimension": 66069561600, + "eigenvalue": [ + 3815150625, + 2147483648 + ] + }, + { + "row": 52, + "quotient_degree": 16065, + "multiplicity": 118693575, + "clifford_degree": 257040, + "regular_dimension": 66069561600, + "eigenvalue": [ + 5341210875, + 4294967296 + ] + }, + { + "row": 53, + "quotient_degree": 17850, + "multiplicity": 52752700, + "clifford_degree": 285600, + "regular_dimension": 81567360000, + "eigenvalue": [ + 1068242175, + 2147483648 + ] + }, + { + "row": 54, + "quotient_degree": 17850, + "multiplicity": 124345650, + "clifford_degree": 285600, + "regular_dimension": 81567360000, + "eigenvalue": [ + 5035998825, + 4294967296 + ] + }, + { + "row": 55, + "quotient_degree": 18360, + "multiplicity": 93447640, + "clifford_degree": 293760, + "regular_dimension": 86294937600, + "eigenvalue": [ + 3679500825, + 4294967296 + ] + }, + { + "row": 56, + "quotient_degree": 19040, + "multiplicity": 73853780, + "clifford_degree": 304640, + "regular_dimension": 92805529600, + "eigenvalue": [ + 22433085675, + 34359738368 + ] + }, + { + "row": 57, + "quotient_degree": 23800, + "multiplicity": 195938600, + "clifford_degree": 380800, + "regular_dimension": 145008640000, + "eigenvalue": [ + 5951634975, + 4294967296 + ] + }, + { + "row": 58, + "quotient_degree": 23800, + "multiplicity": 226083000, + "clifford_degree": 380800, + "regular_dimension": 145008640000, + "eigenvalue": [ + 6867271125, + 4294967296 + ] + }, + { + "row": 59, + "quotient_degree": 26775, + "multiplicity": 254343375, + "clifford_degree": 428400, + "regular_dimension": 183526560000, + "eigenvalue": [ + 6867271125, + 4294967296 + ] + }, + { + "row": 60, + "quotient_degree": 26775, + "multiplicity": 118693575, + "clifford_degree": 428400, + "regular_dimension": 183526560000, + "eigenvalue": [ + 3204726525, + 4294967296 + ] + }, + { + "row": 61, + "quotient_degree": 28560, + "multiplicity": 158258100, + "clifford_degree": 456960, + "regular_dimension": 208812441600, + "eigenvalue": [ + 16023632625, + 17179869184 + ] + }, + { + "row": 62, + "quotient_degree": 28917, + "multiplicity": 250273881, + "clifford_degree": 462672, + "regular_dimension": 214065379584, + "eigenvalue": [ + 6256847025, + 4294967296 + ] + }, + { + "row": 63, + "quotient_degree": 30464, + "multiplicity": 231508992, + "clifford_degree": 487424, + "regular_dimension": 237582155776, + "eigenvalue": [ + 1373454225, + 1073741824 + ] + }, + { + "row": 64, + "quotient_degree": 32130, + "multiplicity": 131881750, + "clifford_degree": 514080, + "regular_dimension": 264278246400, + "eigenvalue": [ + 2967339375, + 4294967296 + ] + }, + { + "row": 65, + "quotient_degree": 32130, + "multiplicity": 166171005, + "clifford_degree": 514080, + "regular_dimension": 264278246400, + "eigenvalue": [ + 7477695225, + 8589934592 + ] + }, + { + "row": 66, + "quotient_degree": 32130, + "multiplicity": 237387150, + "clifford_degree": 514080, + "regular_dimension": 264278246400, + "eigenvalue": [ + 5341210875, + 4294967296 + ] + }, + { + "row": 67, + "quotient_degree": 34425, + "multiplicity": 118693575, + "clifford_degree": 550800, + "regular_dimension": 303380640000, + "eigenvalue": [ + 2492565075, + 4294967296 + ] + }, + { + "row": 68, + "quotient_degree": 34425, + "multiplicity": 254343375, + "clifford_degree": 550800, + "regular_dimension": 303380640000, + "eigenvalue": [ + 5341210875, + 4294967296 + ] + }, + { + "row": 69, + "quotient_degree": 34560, + "multiplicity": 158878720, + "clifford_degree": 552960, + "regular_dimension": 305764761600, + "eigenvalue": [ + 830855025, + 1073741824 + ] + }, + { + "row": 70, + "quotient_degree": 38080, + "multiplicity": 168808640, + "clifford_degree": 609280, + "regular_dimension": 371222118400, + "eigenvalue": [ + 3204726525, + 4294967296 + ] + }, + { + "row": 71, + "quotient_degree": 38556, + "multiplicity": 170918748, + "clifford_degree": 616896, + "regular_dimension": 380560674816, + "eigenvalue": [ + 3204726525, + 4294967296 + ] + }, + { + "row": 72, + "quotient_degree": 42525, + "multiplicity": 314188875, + "clifford_degree": 680400, + "regular_dimension": 462944160000, + "eigenvalue": [ + 5341210875, + 4294967296 + ] + }, + { + "row": 73, + "quotient_degree": 42525, + "multiplicity": 314188875, + "clifford_degree": 680400, + "regular_dimension": 462944160000, + "eigenvalue": [ + 5341210875, + 4294967296 + ] + }, + { + "row": 74, + "quotient_degree": 43520, + "multiplicity": 265270720, + "clifford_degree": 696320, + "regular_dimension": 484861542400, + "eigenvalue": [ + 35251991775, + 34359738368 + ] + }, + { + "row": 75, + "quotient_degree": 47600, + "multiplicity": 316516200, + "clifford_degree": 761600, + "regular_dimension": 580034560000, + "eigenvalue": [ + 9614179575, + 8589934592 + ] + }, + { + "row": 76, + "quotient_degree": 48195, + "multiplicity": 213648435, + "clifford_degree": 771120, + "regular_dimension": 594626054400, + "eigenvalue": [ + 3204726525, + 4294967296 + ] + }, + { + "row": 77, + "quotient_degree": 51408, + "multiplicity": 322846524, + "clifford_degree": 822528, + "regular_dimension": 676552310784, + "eigenvalue": [ + 18160116975, + 17179869184 + ] + }, + { + "row": 78, + "quotient_degree": 53550, + "multiplicity": 356080725, + "clifford_degree": 856800, + "regular_dimension": 734106240000, + "eigenvalue": [ + 9614179575, + 8589934592 + ] + }, + { + "row": 79, + "quotient_degree": 57120, + "multiplicity": 316516200, + "clifford_degree": 913920, + "regular_dimension": 835249766400, + "eigenvalue": [ + 16023632625, + 17179869184 + ] + }, + { + "row": 80, + "quotient_degree": 65536, + "multiplicity": 381308928, + "clifford_degree": 1048576, + "regular_dimension": 1099511627776, + "eigenvalue": [ + 67299257025, + 68719476736 + ] + }, + { + "row": 81, + "quotient_degree": 68850, + "multiplicity": 356080725, + "clifford_degree": 1101600, + "regular_dimension": 1213522560000, + "eigenvalue": [ + 7477695225, + 8589934592 + ] + } + ], + "distinct_levels": [ + { + "eigenvalue": [ + 470624175, + 4294967296 + ], + "rows": [ + 1 + ], + "eigenspace_dimension": 256 + }, + { + "eigenvalue": [ + 359889075, + 2147483648 + ], + "rows": [ + 5 + ], + "eigenspace_dimension": 3625216 + }, + { + "eigenvalue": [ + 188513325, + 1073741824 + ], + "rows": [ + 9 + ], + "eigenspace_dimension": 90630400 + }, + { + "eigenvalue": [ + 439864425, + 2147483648 + ], + "rows": [ + 8 + ], + "eigenspace_dimension": 66585600 + }, + { + "eigenvalue": [ + 1132984125, + 4294967296 + ], + "rows": [ + 6 + ], + "eigenspace_dimension": 4665600 + }, + { + "eigenvalue": [ + 2324997675, + 8589934592 + ], + "rows": [ + 18 + ], + "eigenspace_dimension": 2088124416 + }, + { + "eigenvalue": [ + 356080725, + 1073741824 + ], + "rows": [ + 22 + ], + "eigenspace_dimension": 2642782464 + }, + { + "eigenvalue": [ + 1570944375, + 4294967296 + ], + "rows": [ + 16, + 26 + ], + "eigenspace_dimension": 4078368000 + }, + { + "eigenvalue": [ + 3204726525, + 8589934592 + ], + "rows": [ + 30 + ], + "eigenspace_dimension": 5800345600 + }, + { + "eigenvalue": [ + 6597966375, + 17179869184 + ], + "rows": [ + 24 + ], + "eigenspace_dimension": 2959360000 + }, + { + "eigenvalue": [ + 7477695225, + 17179869184 + ], + "rows": [ + 43 + ], + "eigenspace_dimension": 43637538816 + }, + { + "eigenvalue": [ + 1068242175, + 2147483648 + ], + "rows": [ + 29, + 36, + 53 + ], + "eigenspace_dimension": 106475040000 + }, + { + "eigenvalue": [ + 19109665575, + 34359738368 + ], + "rows": [ + 47 + ], + "eigenspace_dimension": 55228760064 + }, + { + "eigenvalue": [ + 2492565075, + 4294967296 + ], + "rows": [ + 48, + 67 + ], + "eigenspace_dimension": 369450201600 + }, + { + "eigenvalue": [ + 2702024325, + 4294967296 + ], + "rows": [ + 13 + ], + "eigenspace_dimension": 416160000 + }, + { + "eigenvalue": [ + 22433085675, + 34359738368 + ], + "rows": [ + 56 + ], + "eigenspace_dimension": 92805529600 + }, + { + "eigenvalue": [ + 5790052125, + 8589934592 + ], + "rows": [ + 12 + ], + "eigenspace_dimension": 362521600 + }, + { + "eigenvalue": [ + 2967339375, + 4294967296 + ], + "rows": [ + 49, + 64 + ], + "eigenspace_dimension": 330347808000 + }, + { + "eigenvalue": [ + 3204726525, + 4294967296 + ], + "rows": [ + 10, + 25, + 39, + 41, + 45, + 60, + 70, + 71, + 76 + ], + "eigenspace_dimension": 1645529044992 + }, + { + "eigenvalue": [ + 830855025, + 1073741824 + ], + "rows": [ + 69 + ], + "eigenspace_dimension": 305764761600 + }, + { + "eigenvalue": [ + 3679500825, + 4294967296 + ], + "rows": [ + 55 + ], + "eigenspace_dimension": 86294937600 + }, + { + "eigenvalue": [ + 29452962825, + 34359738368 + ], + "rows": [ + 31 + ], + "eigenspace_dimension": 8352497664 + }, + { + "eigenvalue": [ + 7477695225, + 8589934592 + ], + "rows": [ + 65, + 81 + ], + "eigenspace_dimension": 1477800806400 + }, + { + "eigenvalue": [ + 3916887975, + 4294967296 + ], + "rows": [ + 50 + ], + "eigenspace_dimension": 66069561600 + }, + { + "eigenvalue": [ + 16023632625, + 17179869184 + ], + "rows": [ + 61, + 79 + ], + "eigenspace_dimension": 1044062208000 + }, + { + "eigenvalue": [ + 67299257025, + 68719476736 + ], + "rows": [ + 80 + ], + "eigenspace_dimension": 1099511627776 + }, + { + "eigenvalue": [ + 35251991775, + 34359738368 + ], + "rows": [ + 44, + 74 + ], + "eigenspace_dimension": 532211302400 + }, + { + "eigenvalue": [ + 18160116975, + 17179869184 + ], + "rows": [ + 77 + ], + "eigenspace_dimension": 676552310784 + }, + { + "eigenvalue": [ + 9614179575, + 8589934592 + ], + "rows": [ + 33, + 42, + 75, + 78 + ], + "eigenspace_dimension": 1359456000000 + }, + { + "eigenvalue": [ + 5035998825, + 4294967296 + ], + "rows": [ + 37, + 54 + ], + "eigenspace_dimension": 101959200000 + }, + { + "eigenvalue": [ + 20907025425, + 17179869184 + ], + "rows": [ + 34 + ], + "eigenspace_dimension": 13050777600 + }, + { + "eigenvalue": [ + 5341210875, + 4294967296 + ], + "rows": [ + 52, + 66, + 68, + 72, + 73 + ], + "eigenspace_dimension": 1559616768000 + }, + { + "eigenvalue": [ + 1373454225, + 1073741824 + ], + "rows": [ + 63 + ], + "eigenspace_dimension": 237582155776 + }, + { + "eigenvalue": [ + 5951634975, + 4294967296 + ], + "rows": [ + 57 + ], + "eigenspace_dimension": 145008640000 + }, + { + "eigenvalue": [ + 48070897875, + 34359738368 + ], + "rows": [ + 35 + ], + "eigenspace_dimension": 17045913600 + }, + { + "eigenvalue": [ + 6256847025, + 4294967296 + ], + "rows": [ + 62 + ], + "eigenspace_dimension": 214065379584 + }, + { + "eigenvalue": [ + 6867271125, + 4294967296 + ], + "rows": [ + 20, + 32, + 58, + 59 + ], + "eigenspace_dimension": 339864000000 + }, + { + "eigenvalue": [ + 27926902575, + 17179869184 + ], + "rows": [ + 46 + ], + "eigenspace_dimension": 52203110400 + }, + { + "eigenvalue": [ + 15074084025, + 8589934592 + ], + "rows": [ + 11 + ], + "eigenspace_dimension": 215737344 + }, + { + "eigenvalue": [ + 3815150625, + 2147483648 + ], + "rows": [ + 51 + ], + "eigenspace_dimension": 66069561600 + }, + { + "eigenvalue": [ + 16023632625, + 8589934592 + ], + "rows": [ + 40 + ], + "eigenspace_dimension": 26634240000 + }, + { + "eigenvalue": [ + 64552348575, + 34359738368 + ], + "rows": [ + 28 + ], + "eigenspace_dimension": 3712221184 + }, + { + "eigenvalue": [ + 34336355625, + 17179869184 + ], + "rows": [ + 38 + ], + "eigenspace_dimension": 20552089600 + }, + { + "eigenvalue": [ + 2289090375, + 1073741824 + ], + "rows": [ + 15, + 19, + 27 + ], + "eigenspace_dimension": 6166492416 + }, + { + "eigenvalue": [ + 10346688495, + 4294967296 + ], + "rows": [ + 21 + ], + "eigenspace_dimension": 2265760000 + }, + { + "eigenvalue": [ + 11140239825, + 4294967296 + ], + "rows": [ + 23 + ], + "eigenspace_dimension": 2642782464 + }, + { + "eigenvalue": [ + 6053372325, + 2147483648 + ], + "rows": [ + 17 + ], + "eigenspace_dimension": 1348358400 + }, + { + "eigenvalue": [ + 27113003775, + 8589934592 + ], + "rows": [ + 14 + ], + "eigenspace_dimension": 585252864 + }, + { + "eigenvalue": [ + 4120362675, + 1073741824 + ], + "rows": [ + 7 + ], + "eigenspace_dimension": 14500864 + }, + { + "eigenvalue": [ + 22846598775, + 4294967296 + ], + "rows": [ + 3 + ], + "eigenspace_dimension": 665856 + }, + { + "eigenvalue": [ + 26774973225, + 4294967296 + ], + "rows": [ + 4 + ], + "eigenspace_dimension": 1849600 + }, + { + "eigenvalue": [ + 7841980575, + 1073741824 + ], + "rows": [ + 2 + ], + "eigenspace_dimension": 313600 + } + ], + "minimum": [ + 470624175, + 4294967296 + ], + "maximum": [ + 7841980575, + 1073741824 + ], + "minimum_dimension": 256, + "maximum_dimension": 313600, + "gram_condition": [ + 101244, + 1519 + ], + "inverse_squared_norm": [ + 4294967296, + 470624175 + ], + "second_moment": [ + 930080652310818734947227759375, + 72057594037927936 + ], + "one_qubit_calibration": { + "projective_elements": 24, + "closure_products": 576, + "quotient_character_counts": [ + [ + -64, + 12 + ], + [ + 1, + 8 + ], + [ + 4096, + 4 + ] + ], + "multiplicities": [ + 651, + 715, + 1365 + ], + "eigenvalues": [ + [ + 1953, + 2048 + ], + [ + 2145, + 2048 + ], + [ + 4095, + 4096 + ] + ], + "eigenspace_dimensions": [ + 4, + 4, + 16 + ], + "gram_second_moment": [ + 25184259, + 1048576 + ], + "literal_cubic_annihilator": true, + "normalization_controls": 3 + } +} diff --git a/research/clifford-transported-fibre-gram/verify_gram.py b/research/clifford-transported-fibre-gram/verify_gram.py new file mode 100644 index 0000000000..ce70f87b86 --- /dev/null +++ b/research/clifford-transported-fibre-gram/verify_gram.py @@ -0,0 +1,110 @@ +"""Check the source spectra, all central kernels and literal absolute-phase tensor Gram entries.""" +from collections import Counter +from fractions import Fraction +from math import gcd, lcm +from random import Random + +from class_algebra import GROUP_ORDER, class_index, data, gram_class_matrix +from gram import (GRAM_DEN, HERE, apply_blocks, extract, fixed_dimension, inverse_transform, kernels, + spectral_packets, steps, synthesize) +from compile_row import compose, inverse +from readout import ZERO +from verify_readout import Q, TARGETS, literal_trace, plus, power, require, symplectic +import json + + +def recurrence(schedule, matrix): + # Replay each factor by integral multiplication in the *class* basis, exact common scaling. + p = [1]+[0]*79 + den = 1 + for h in schedule: + a,b = h.as_integer_ratio() + scale = b*GRAM_DEN + p = [scale*old-a*sum(x*y for x,y in zip(row,p,strict=True)) for row,old in zip(matrix,p,strict=True)] + den *= scale + common = gcd(den,*p) + p = [x//common for x in p] + den //= common + return tuple(Fraction(x,den) for x in p) + + +def moment_checks(): + src = json.loads((HERE/'retained'/'width13-spectrum.json').read_text())['rows'] + known = Counter() + for row in src: + known[Fraction(*row['eigenvalue'])] += row['quotient_degree']**2 + actual = Counter() + for row,d,eigen in spectral_packets(): + actual[eigen] += row[0]*d + require(actual==known and sum(actual.values())==GROUP_ORDER and len(known)==52,'Independent spectrum') + classes = data()['classes'] + matrix = gram_class_matrix() + shell = [Fraction((-64)**c['fixed'],GRAM_DEN) for c in classes] + eigen = [e for _,_,e in spectral_packets()] + require(inverse_transform(eigen)==tuple(shell),'Inverse transform Gram') + ident = [1]+[0]*79 + for name in ['canonical','schedule51','schedule52']: + filters = kernels(name) + p,q = (ident,filters[0]) if name=='canonical' else filters + if name!='canonical': + require(recurrence(steps(name),matrix)==p,'Independent class convolution schedule') + scale = lcm(*(v.denominator for v in q)) + nums = [v.numerator*(scale//v.denominator) for v in q] + kq = [Fraction(sum(x*y for x,y in zip(row,nums,strict=True)),scale*GRAM_DEN) for row in matrix] + require(all(a==(i if name=='canonical' else i-h) for a,i,h in zip(kq,ident,p,strict=True)), 'Inverse/affine kernel') + kernel_den = lcm(*(v.denominator for f in filters for v in f)) + coeff_bits = max((abs(v.numerator)*(kernel_den//v.denominator)).bit_length() for f in filters for v in f) + print(name,'common coefficient denominator bits',kernel_den.bit_length(),'largest signed-magnitude numerator bits',coeff_bits) + + +def direct_tests(): + rng = Random(7813) + targets = TARGETS+(symplectic([rng.randrange(1,256) for _ in range(14)]),) + entries = {} + for k,t in enumerate(targets[:3]): + blocks = [ZERO]*256 + for j in range(3): + blocks[(k*81+j*75)%256]=(Fraction(2*j-k,3),Fraction(5*k-j,7)) + entries[t] = blocks + require(extract(t,synthesize(t,blocks))==blocks,'Change of basis') + outputs = apply_blocks('gram',(entries,),targets) + stats = Counter() + for t in targets: + for p in (0,75,81,150,156,162,237,255,7,28,48,97): + want = ZERO + for u,block in entries.items(): + for b,c in enumerate(block): + if c==ZERO: + continue + tau=literal_trace(t,p,u,b) + k=fixed_dimension(t,u) + stats['nonzero' if tau!=ZERO else 'zero']+=1 + stats['imag']+=tau[1]!=0 + stats['odd_fix']+=(k%2==1 and tau!=ZERO) + term=power(tuple(v/16 for v in tau),13) + want=plus(want,Q.multiply(term,c)) + require(outputs[t][p]==want,'Direct tensor Gram mismatch') + require(all(stats[key]>0 for key in ('nonzero','zero','imag','odd_fix')), 'Degenerate tensor tests') + # Delta d0 and t on two different source fibres. Literal traces convert the already independently + # checked scalar class weights back to the original coefficient coordinates at selected outputs. + t,u=targets[:2] + d0=[ZERO]*256; d0[0]=(1,-2) + rhs=[ZERO]*256; rhs[17]=(3,1) + for name in ('schedule51','schedule52','canonical'): + fs=kernels(name) + inputs=({t:d0},{u:rhs}) if len(fs)==2 else ({u:rhs},) + got=apply_blocks(name,inputs,targets[2:3]) + v=targets[2] + scales=[f[class_index(compose(inverse(v),s))]/16 for f,s in zip(fs,(t,u) if len(fs)==2 else (u,),strict=True)] + for p in range(0,256,9): + terms=[Q.multiply(d0[0],literal_trace(v,p,t,0)), Q.multiply(rhs[17],literal_trace(v,p,u,17))] + if len(fs)==1: + terms=terms[1:] + expected=tuple(sum(c*w[j] for c,w in zip(scales,terms,strict=True)) for j in range(2)) + require(got[v][p]==expected,'Affine schedule exact complex coefficient') + print('PASS literal Gram pairings',dict(stats),'and 87 filtered output pairs.') + + +if __name__=='__main__': + moment_checks() + direct_tests() diff --git a/research/clifford-transported-fibre-gram/verify_readout.py b/research/clifford-transported-fibre-gram/verify_readout.py new file mode 100644 index 0000000000..a70d28f6d4 --- /dev/null +++ b/research/clifford-transported-fibre-gram/verify_readout.py @@ -0,0 +1,191 @@ +"""Compare transported chart readouts to literal Bell contractions and tensor columns.""" +from collections import defaultdict +from hashlib import sha256 +import json +from fractions import Fraction +from functools import cache +from pathlib import Path +from random import Random +import sys + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +from readout import (BatchReadout, HERE, IDENTITY, Q, ZERO, base_reads, iter_reads, + label_sum, pack, target_axes, translated_reads) +from bell_reads import transvection +from compile_row import apply +from raw_row import split_address + + +def require(ok, message): + if not ok: + raise ValueError(message) + + +def plus(left, right): + return left[0]+right[0], left[1]+right[1] + + +def conjugate(value): + return value[0], -value[1] + + +def power(value, exponent): + a = (1,0) + for _ in range(exponent): + a = Q.multiply(a,value) + return a + + +def symplectic(axes): + mat = IDENTITY + for axis in axes: + mat = tuple(transvection(axis,v) for v in mat) + return mat + + +TARGETS = (IDENTITY, symplectic([1,18,2]), symplectic([33,64,19,129,79]), IDENTITY[4:]+IDENTITY[:4]) + + +@cache +def lift(target): + """Build lift columns by left action of (1+i)(I+iP)/2 on literal basis states.""" + matrix = [[(int(r==c),0) for c in range(16)] for r in range(16)] + axes = target_axes(target) + for axis in axes: + x,z = divmod(axis,16) + exponent = ((x&z).bit_count()%2)+1 + v = [] + for r in range(16): + phase = exponent + 2*((z&(r^x)).bit_count()%2) + v.append([Q.multiply((1,1), plus(matrix[r][c],Q.multiply_i(matrix[r^x][c],phase))) + for c in range(16)]) + matrix = v + return matrix,len(axes) + + +def translated_lift(target, p): + mat, den = lift(target) + x,z = divmod(p,16) + return [[Q.multiply_i(a,2*((z&(r^x)).bit_count()%2)) for a in mat[r^x]] for r in range(16)],den + + +def literal_trace(target, p, other, b): + a,d = translated_lift(target,p) + v,e = translated_lift(other,b) + total = ZERO + for row, col in zip(a,v,strict=True): + for x,y in zip(row,col,strict=True): + total = plus(total,Q.multiply(conjugate(x),y)) + return tuple(Fraction(n,1<<(d+e)) for n in total) + + +def literal_dense(chart,target): + _,offset,columns,terms,a,b,den = chart + buckets = defaultdict(list) + for read in iter_reads(target): + out,inp = label_sum(read.output_labels),label_sum(read.input_labels) + all_labels=read.output_labels+read.input_labels + buckets[tuple(v>>4 for v in all_labels)].append( + (pack([v&15 for v in all_labels]),out,inp,read.numerator,read.correction_i)) + singleton = [[ZERO for _ in range(16)] for _ in range(16)] + for i in range(1<>4) + cc=c[-1]^(t>>4) + atom=Q.multiply_i((n*y[0],n*y[1]), phase+2*signs) + singleton[rr][cc]=plus(singleton[rr][cc],atom) + result=[] + for p in range(256): + matrix,e=translated_lift(target,p) + val=ZERO + for row,block in zip(matrix,singleton): + for u,v in zip(row,block): + val=plus(val,Q.multiply(conjugate(u),v)) + result.append(tuple(Fraction(n,4096<<(den+e)) for n in val)) + return result + + +def one_column(target,p,phase): + """Recover the eight-bit Choi chart by querying all literal matrix entries, then tensor.""" + mat,d=translated_lift(target,p) + vals={16*r+c:v for r,row in enumerate(mat) for c,v in enumerate(row) if v!=ZERO} + o=min(vals); basis=[]; span={0} + for v in vals: + w=v^o + if w not in span: + basis.append(w) + span.update([s^w for s in span]) + require(len(vals)==len(span),"Choi support") + unit=vals[o]; phases={} + for i in range(1<>4)<<(52+4*j)) | ((v&15)<<(4*j)) + offset=sum(place(o,j) for j in range(13)) + dirs=tuple(place(v,j) for j in range(13) for v in basis) + polys=tuple((t<<(len(basis)*j),v) for j in range(13) for t,v in phase_terms.items() if v) + coef=Q.multiply_i(power(unit,13),phase) + return (104,offset,dirs,polys,*coef,26+13*d) + + +def off_image(): + charts=[] + rng=Random(7800) + for target in TARGETS: + read=next(r for r in iter_reads(target) if r.numerator) + row=0;col=0 + for j in range(6): + v,w=rng.randrange(16),rng.randrange(16) + row=(row<<8)|(((read.output_labels[j]>>4)^v)<<4)|v + col=(col<<8)|(((read.input_labels[j]>>4)^w)<<4)|w + o=((row<<4|3)<<52)|(col<<4|5) + charts.append((104,o,(1,2,1<<53,1<<17,1<<52),((1,1),(3,2),(20,2)),3,-5,3)) + affected=0 + for chart in charts: + batch=BatchReadout(chart) + for target in TARGETS: + v,_=batch.evaluate(target) + require(v==literal_dense(chart,target),"Off-image literal Bell/Pauli trace") + affected+=any(z!=ZERO for z in v) + require(affected>=3,"Control failed to exercise nonzero off-image contractions") + return affected + + +def main(): + for pin in json.loads((HERE / "SOURCE-PINS.json").read_text()): + require(sha256((HERE / pin["local"]).read_bytes()).hexdigest() == pin["sha256"], + "Retained source digest: " + pin["local"]) + for t in TARGETS: + require(list(translated_reads(t))==list(iter_reads(t)),"Transport cocycle differs from original list") + for n,t in enumerate(TARGETS): + p=(49*n+23)%256 + batch=BatchReadout(one_column(t,p,n)) + for target in (t,TARGETS[(n+1)%len(TARGETS)]): + out,_=batch.evaluate(target) + expected=[ZERO]*256 + if t==target: + expected[p]=Q.multiply_i((1,0),n) + require(out==expected,"Complex Pauli coefficient on a literal dense-lift tensor") + print("PASS",len(TARGETS)*len(base_reads()),"literal transported read records;", + "8 phase-sensitive tensor readouts; 16 off-image/all-Pauli comparisons with", off_image(),"nonzero.") + + +if __name__=="__main__": + main()