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 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')
def test_P15():
    print('P15 program, floor of average of inputs, with debug printing:')
    p = Program(num_prog_inputs=2)
    p.create_add_component()
    p.create_and_component()
    p.create_xor_component()
    p.create_bitshiftright_component(1)
    timed_synthesis(p, BVT.P15, 100000, True)
def inc_dec_and_or_with(comp, number):
    p = Program()
    p.create_increment_component()
    p.create_decrement_component()
    p.create_and_component()
    p.create_or_component()
    for _ in range(number):
        comp(p)
    return p
Exemplo n.º 5
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()
Exemplo n.º 6
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()
Exemplo n.º 7
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()
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')
Exemplo n.º 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()
def test_P16():
    print('P16 program, find max:')
    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()
    timed_synthesis(p, lambda x, y: max(x, y), 20000, False)
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 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 first8_program_no_xor():
    p = Program()
    p.create_increment_component()
    p.create_decrement_component()
    p.create_and_component()
    # p.create_negate_component()
    # p.create_xor_component()
    p.create_or_component()
    p.create_not_component()
    return p
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 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 equal_components(num_prog_inputs, num_each_component):
    p = Program(num_prog_inputs=num_prog_inputs)
    for _ in range(num_each_component):
        p.create_increment_component()
        # p.create_decrement_component()
        # p.create_add_component()
        # p.create_subtract_component()
        # p.create_divide_component()
        p.create_and_component()
        p.create_or_component()
        # p.create_xor_component()
        # p.create_negate_component()
        p.create_not_component()
        # p.create_bitshiftright_component(1)
        # p.create_bitshiftleft_component(-1)
        # p.create_ule_component()
        # p.create_ult_component()
    return p
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
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