""" import itertools import satx n, m = 5, 8 opt = 1 while True: print('OPTIMAL? : {}'.format(opt)) satx.engine(opt.bit_length(), cnf_path='aux.cnf') # x[i][j] is the color at row i and column j x = satx.matrix(dimensions=(n, m)) # at least one corners of different color for any rectangle inside the board for i1, i2 in itertools.combinations(range(n), 2): for j1, j2 in itertools.combinations(range(m), 2): assert satx.one_of([x[i1][j1], x[i1][j2], x[i2][j1], x[i2][j2]]) != \ satx.one_of([x[i1][j1], x[i1][j2], x[i2][j1], x[i2][j2]]) satx.apply_single(satx.flatten(x), lambda t: t < opt) if satx.satisfy('slime'): print(x) break else: opt += 1
import satx k = 33 e = 80 satx.engine(bits=3 * e, cnf_path='sum_of_three_cubes_33_unknown_representation.cnf', simplify=True, signed=True) x = satx.integer() y = satx.integer() z = satx.integer() assert satx.one_of([x ** 3 - y ** 3 - z ** 3, x ** 3 + y ** 3 - z ** 3]) == k assert x > 8866128975287528 if satx.satisfy(solver='./slime', log=True): print(x, y, z, x ** 3 - y ** 3 - z ** 3, x ** 3 + y ** 3 - z ** 3) else: print('Infeasible...')
import satx satx.engine(32, cnf_path='aux.cnf') mapping = {1: 'r', 2: 'ry', 3: 'g', 4: 'y'} R, RY, G, Y = 1, 2, 3, 4 table = [(R, R, G, G), (RY, R, Y, R), (G, G, R, R), (Y, R, RY, R)] # v[i] is the color for the ith vehicle traffic light v = satx.vector(size=4) # p[i] is the color for the ith pedestrian traffic light p = satx.vector(size=4) satx.apply_single(v, lambda t: t.is_in([R, RY, G, Y])) satx.apply_single(p, lambda t: t.is_in([R, G])) for i in range(4): assert satx.dot([v[i], p[i], v[(i + 1) % 4], p[(i + 1) % 4]], [1, 10, 100, 1000]) == satx.one_of( [satx.dot(t, [1, 10, 100, 1000]) for t in table]) while satx.satisfy('kissat'): vv = [mapping[t.value] for t in v] pp = [mapping[t.value] for t in p] for a, b in zip(vv, pp): print(a, b, end=', ') print() print(80 * '-')