示例#1
0
#Ops = extend_ops_cwise(PO.named_clone("UM"))
#Ops = extend_ops_cwise(PO.named_clone("UP0"))
#Ops = extend_ops_cwise(PO.named_clone("UP1"))
#Ops = extend_ops_cwise(PO.named_clone("F"))

for op in Ops:
    print("Name:", op.name)

n = 3
Dn = [list(a) for a in product([0, 1], repeat=n)]  # {0,1}^n
min_preimages = []

passes = True
while passes:
    #A, A_gens = UA.rand_subalg(Dn, Ops, Progress=False)
    A, A_gens = UA.FancySet(initial=Dn), []
    Theta, Theta_gens = UA.rand_cong(A,
                                     Ops,
                                     num_gen=randrange(n),
                                     Progress=False)
    min_preimages = UA.FancySet(
        initial=[meet_set(C) for C in UA.cong_classes(Theta, A)])
    stdout.write(str(len(min_preimages)) + " ")
    stdout.flush()
    #for a,b in product(A,repeat=2):
    for a in A:
        b = a
        S = simon_sum(Theta, a, b)
        if (S != 0 and not (a == b in min_preimages)) or (
                S == 0 and a == b in min_preimages):
            passes = False
    [ "MPT0k for 2 <= k < inf" ] + [ "MPT0inf" ] + \
    [ "MT1k for 2 <= k < inf" ] + [ "MT1inf" ]  + \
    [ "MPT1k for 2 <= k < inf" ] + [ "MPT1inf" ]

print("Possible clones:")
for name in Names:
    print("  ", name)
inp = input("Input a clone name: ")
print("Clone name", inp, "provided")
Ops = PO.named_clone(inp)
print("Corresponding operations:")
for op in Ops:
    print("  ", op.name)

n = 5
A = UA.FancySet(initial=[list(a)
                         for a in list(product([0, 1], repeat=n))])  # {0,1}^n

stats = dict()
for ng in range(n**2, 0, -1):
    stats[ng] = 0
    total = 10**3
    for count in range(total):
        R, G = UA.rand_subalg(A, Ops, num_gen=ng, Progress=False)
        if len(R) == len(A):
            stats[ng] += 1
        stdout.write("\r" + str(ng) + ": " +
                     str(round(count / total * 100, 4)) + "%    ")
        if count % 10 == 0: stdout.flush()
    stdout.write("\n  " + "Generators = " + str(ng) + ", success = " +
                 str(round(stats[ng] / total * 100, 4)) + "%\n")
#----------------------------------------------------------------------------}}}1
Ops = PO.named_clone("MP")
#Ops = PO.named_clone("DM")
#Ops = PO.named_clone("AP0")
#Ops = PO.named_clone("AP1")
#Ops = PO.named_clone("AP")
#Ops = PO.named_clone("MPT0inf")
#Ops = PO.named_clone("MPT1inf")
#Ops = PO.named_clone("MEETP")

print("Ops")
for op in Ops:
    print(op.name)
n = 3
Dn = [list(a) for a in list(product([0,1],repeat=n))]
#A, A_gens = UA.rand_subalg(Dn, Ops, Progress=False)
A = UA.FancySet( initial=Dn )
Theta, Theta_gens = UA.rand_cong(A, Ops, num_gen=randrange(n), Progress=False)

f = cong_to_oracle(n, Theta, A)
print(f)

print('A:')
print(str(A))
print("Theta has classes:")
for C in UA.cong_classes(Theta, A):
  print(C)

structure = gen_oracle_op(n, f)
Phi = Qobj( inpt=structure, dims=[[2]*2*n, [2]*2*n] )
#print(Phi)