Download tests/check_math.py from Poindexter-Labs/Samples: direct link, hf CLI and curl.
- Browser
- Download file 1.68 kB
-
https://huggingface.co/datasets/Poindexter-Labs/Samples/resolve/main/tests/check_math.py
- Command line
-
hf download hf://datasets/Poindexter-Labs/Samples/tests/check_math.py
-
curl -L -o check_math.py https://huggingface.co/datasets/Poindexter-Labs/Samples/resolve/main/tests/check_math.py
1.68 kB
| """Independent exact counts for the finite-group arithmetic in PDS136 (no API).""" | |
| from collections import Counter | |
| from fractions import Fraction | |
| from itertools import permutations | |
| def semidirect(n, action): | |
| elements = [(a,b) for a in range(n) for b in range(2)] | |
| def mul(x,y): | |
| a,b=x;c,d=y | |
| return ((a + pow(action,b,n)*c)%n,(b+d)%2) | |
| return elements,mul,(0,0) | |
| def symmetric(n): | |
| elements=list(permutations(range(n))) | |
| def mul(x,y):return tuple(x[y[i]] for i in range(n)) | |
| return elements,mul,tuple(range(n)) | |
| def bundle_count(group): | |
| elements,mul,identity=group | |
| total=0 | |
| for g in elements: | |
| centralizer=[x for x in elements if mul(x,g)==mul(g,x)] | |
| squares=Counter(mul(x,x) for x in centralizer) | |
| ways={identity:1} | |
| for _ in range(5): | |
| nxt=Counter() | |
| for x,count in ways.items(): | |
| for square,multiplicity in squares.items():nxt[mul(x,square)]+=count*multiplicity | |
| ways=nxt | |
| total+=ways[identity] | |
| result=Fraction(total,len(elements)) | |
| assert result.denominator==1 | |
| return result.numerator | |
| if __name__=='__main__': | |
| actual={name:bundle_count(group) for name,group in [('D8',semidirect(4,3)),('SD16',semidirect(8,3)),('S3',symmetric(3)),('S4',symmetric(4))]} | |
| assert actual=={'D8':4864,'SD16':37248,'S3':502,'S4':32923},actual | |
| product=2**60*3**8*5**4*actual['D8']**2*actual['SD16']*actual['S3']*actual['S4'] | |
| assert product==2**84*3**9*5**4*11*19**2*41*73*97*251 | |
| print(actual) | |
| print('Burnside counts and final prime factorization agree. This checks the counting arithmetic, not the block-Picard classification theorem.') | |