def P15():
    p = Program(num_prog_inputs=2)
    p.create_add_component()
    p.create_and_component()
    p.create_xor_component()
    p.create_bitshiftright_component(1)
    return ProgramSynthesis(p, BVT.P15, 'P15')
def alternative_increment():
    ps = []
    p = Program(num_prog_inputs=1)
    # p.create_increment_component()
    p.create_bitshiftleft_component(1)
    p.create_bitshiftright_component(1)
    p.create_ule_component()
    p.create_ult_component()
    p.create_bvredor_component()
    p.create_and_component()
    p.create_add_component()
    oracle = BVT.Psimple_inc
    ps_short = ProgramSynthesis(p, oracle, 'P Simple')
    ps_short.find_shortest_program = True
    ps.append(ps_short)
    return ps
def Pinc_dec_and_or(comp, number):
    ps = []
    for p in [
            BVT.Psimple_inc, BVT.Psimple_dec, BVT.P1, BVT.P2, BVT.P5, BVT.P6
    ]:
        ps.append(
            ProgramSynthesis(inc_dec_and_or_with(comp, number), p, p.__name__))
    return ps
def P16():
    p = Program(num_prog_inputs=2)
    p.create_xor_component()
    p.create_xor_component()
    p.create_negate_component()
    p.create_and_component()
    p.create_ule_component()
    return ProgramSynthesis(p, BVT.P16, 'P16')
Пример #5
0
def test_simple():
    p = Program()
    p.create_decrement_component()
    p.create_decrement_component()
    p.create_increment_component()
    p.create_increment_component()
    print('Simple increment program:')
    ProgramSynthesis(p, BVT.Psimple_inc, 'Simple').timed_synthesis()
def P7():
    p = Program()
    p.create_increment_component()
    p.create_and_component()
    p.create_or_component()
    p.create_not_component()
    p.create_add_component()
    p.create_xor_component()
    return ProgramSynthesis(p, BVT.P7, 'P7')
def P8_bitshiftleft1():
    p = Program()
    p.create_decrement_component()
    p.create_not_component()
    p.create_and_component()
    p.create_bitshiftleft_component(1)
    p.create_bitshiftleft_component(1)
    p.create_bitshiftleft_component(1)
    return ProgramSynthesis(p, BVT.P8, 'P8 BitShiftL1')
Пример #8
0
def test_P16():
    print('Find max program (also P16):')
    p = Program(num_prog_inputs=2)
    p.create_xor_component()
    p.create_xor_component()
    p.create_negate_component()
    p.create_and_component()
    p.create_ule_component()
    ProgramSynthesis(p, lambda x, y: max(x, y), 'Find Max').timed_synthesis()
Пример #9
0
def test_P15():
    p = Program(num_prog_inputs=2)
    p.create_add_component()
    p.create_and_component()
    p.create_xor_component()
    p.create_bitshiftright_component(1)
    print('P15 program, floor of average of inputs, with debug printing:')
    ProgramSynthesis(p, BVT.P15, 'P15', timeout=20000,
                     print_debug=True).timed_synthesis()
Пример #10
0
def test_P20():
    print('P20 program, determine if power of 2:')
    p = Program()
    p.create_decrement_component()
    p.create_and_component()
    p.create_bvredor_component()
    p.create_or_component()
    p.create_bitshiftright_component(BV_LENGTH - 1)
    ProgramSynthesis(p, BVT.P20, 'P20', timeout=20000).timed_synthesis()
Пример #11
0
def test_insufficient():
    print('PSimple, testing insufficient components')
    p = Program()
    p.create_and_component()
    p.create_bvredor_component()
    p.create_ule_component()
    p.create_or_component()
    ProgramSynthesis(p, BVT.Psimple_dec,
                     'PSimple_insufficient').timed_synthesis()
def P8_decrement():
    p = Program()
    p.create_decrement_component()
    p.create_not_component()
    p.create_and_component()
    p.create_decrement_component()
    p.create_decrement_component()
    p.create_decrement_component()
    return ProgramSynthesis(p, BVT.P8, 'P8 Dec')
def shortestComparison_P7():
    ps = []
    p = Program(num_prog_inputs=1)
    p.create_not_component()
    p.create_increment_component()
    p.create_and_component()
    p.create_or_component()
    p.create_decrement_component()
    p.create_and_component()
    oracle = BVT.P7
    ps_short = ProgramSynthesis(p, oracle, 'Shortest')
    ps_short.find_shortest_program = True
    ps.append(ps_short)
    ps_no_short = ProgramSynthesis(p, oracle, 'No Shortest')
    ps_no_short.find_shortest_program = False
    ps.append(ps_no_short)
    return ps
def shortestComparison_P14():
    ps = []
    p = Program(num_prog_inputs=2)
    p.create_bitshiftleft_component(-1)
    p.create_increment_component()
    p.create_subtract_component()
    p.create_and_component()
    p.create_divide_component()
    p.create_xor_component()
    oracle = BVT.P14
    ps_short = ProgramSynthesis(p, oracle, 'Shortest')
    ps_short.find_shortest_program = True
    ps.append(ps_short)
    ps_no_short = ProgramSynthesis(p, oracle, 'No Shortest')
    ps_no_short.find_shortest_program = False
    ps.append(ps_no_short)
    return ps
def shortestComparison_P1():
    ps = []
    p = Program()
    p.create_decrement_component()
    p.create_and_component()
    p.create_xor_component()
    p.create_xor_component()
    p.create_decrement_component()
    p.create_add_component()
    oracle = BVT.P1
    ps_short = ProgramSynthesis(p, oracle, 'Shortest')
    ps_short.find_shortest_program = True
    ps.append(ps_short)
    ps_no_short = ProgramSynthesis(p, oracle, 'No Shortest')
    ps_no_short.find_shortest_program = False
    ps.append(ps_no_short)
    return ps
def shortestComparison_P20():
    ps = []
    p = Program(num_prog_inputs=1)
    p.create_decrement_component()
    p.create_bitshiftright_component(BV_LENGTH - 1)
    p.create_and_component()
    p.create_bvredor_component()
    p.create_or_component()
    p.create_and_component()
    p.create_add_component()
    oracle = BVT.P20
    ps_short = ProgramSynthesis(p, oracle, 'Shortest')
    ps_short.find_shortest_program = True
    ps.append(ps_short)
    ps_no_short = ProgramSynthesis(p, oracle, 'No Shortest')
    ps_no_short.find_shortest_program = False
    ps.append(ps_no_short)
    return ps
def shortestComparison_P16():
    ps = []
    p = Program(num_prog_inputs=2)
    p.create_xor_component()
    p.create_xor_component()
    p.create_and_component()
    p.create_negate_component()
    p.create_ule_component()
    p.create_and_component()
    p.create_add_component()
    oracle = BVT.P16
    ps_short = ProgramSynthesis(p, oracle, 'Find Shortest')
    ps_short.find_shortest_program = True
    ps.append(ps_short)
    ps_no_short = ProgramSynthesis(p, oracle, 'No Find Shortest')
    ps_no_short.find_shortest_program = False
    ps.append(ps_no_short)
    return ps
def shortestComparison_P21():
    ps = []
    p = Program(num_prog_inputs=1)
    p.create_negate_component()
    p.create_and_component()
    p.create_add_component()
    p.create_xor_component()
    p.create_add_component()
    p.create_bitshiftright_component(2)
    p.create_or_component()
    oracle = BVT.P21
    ps_short = ProgramSynthesis(p, oracle, 'Shortest')
    ps_short.find_shortest_program = True
    ps.append(ps_short)
    ps_no_short = ProgramSynthesis(p, oracle, 'No Shortest')
    ps_no_short.find_shortest_program = False
    ps.append(ps_no_short)
    return ps
Пример #19
0
    # p = Program(num_prog_inputs=1)
    # p.create_bitshiftright_component(1)
    # p.create_constand_component(0x55555555)
    # p.create_constand_component(0x55555555)
    # p.create_bitshiftright_component(2)
    # p.create_constand_component(0x33333333)
    # p.create_constand_component(0x33333333)
    # p.create_add_component()
    # p.create_add_component()
    # prog = ProgramSynthesis(p, count_bits, 'count bits', print_debug=True).iterative_synthesis()
    # print(prog)

    for i in range(64):
        if count_bit_parity(i) != count_bit_parity_test(i):
            print(i)

    p = Program(num_prog_inputs=1)
    p.create_xor_component()
    p.create_xor_component()
    p.create_xor_component()
    p.create_constand_component(1)
    p.create_bitshiftright_component(1)
    p.create_bitshiftright_component(2)
    p.create_bitshiftright_component(4)
    prog = ProgramSynthesis(p,
                            count_bit_parity,
                            'count bits',
                            print_debug=True).iterative_synthesis()
    print(prog)
    print('done')
def P1through8except3():
    ps = []
    for p in [BVT.P1, BVT.P2, BVT.P4, BVT.P5, BVT.P6, BVT.P7, BVT.P8]:
        ps.append(ProgramSynthesis(first8_program(), p, p.__name__))
    return ps
Пример #21
0
def test_P7():
    print('P7 program, isolate the rightmost 0-bit:')
    ProgramSynthesis(equal_components(1, 1), BVT.P7, 'P7').timed_synthesis()
Пример #22
0
def test_P6():
    print('P6 program, turn on rightmost 0-bit:')
    ProgramSynthesis(equal_components(1, 1), BVT.P6, 'P6').timed_synthesis()
def P1_2_5_8():
    ps = []
    for p in [BVT.P1, BVT.P2, BVT.P5, BVT.P6, BVT.P7, BVT.P8]:
        ps.append(ProgramSynthesis(first8_program_no_xor(), p, p.__name__))
    return ps