Exemplo n.º 1
0
 def test_resolution_solver(self):
     clauses = [
         'a || b', '!a || b || e', 'a || !b', 'b || !e', 'd || !e',
         '!b || !c || !f', 'a || !e', '!b || f', '!b || c'
     ]
     assert not full_resolution(cnf.sentence(clauses))
     assert full_resolution(cnf.sentence(clauses[1:]))
Exemplo n.º 2
0
def plot_random_cnf(k_sat, num_symbols, max_num_clauses, step_size,
                    num_trials):
    """
    Example usage:
        
    import matplotlib.pyplot as plt
    from random_cnf import plot_random_cnf
    (x,y) = plot_random_cnf(3,5,150,10,50)
    plt.plot(x,y)
    
    """
    x_values = []
    y_values = []
    for l in range(1, max_num_clauses, step_size):
        satisfiable_count = 0
        for trial in range(num_trials):
            if full_resolution(generate_random_cnf(k_sat, num_symbols, l)):
                satisfiable_count += 1
        x_values.append(l)
        y_values.append(satisfiable_count / num_trials)
    return x_values, y_values
Exemplo n.º 3
0
 def test_full_resolution_6(self):
     clauses = ['a || b', '!a || b', 'FALSE']
     assert not full_resolution(cnf.sentence('\n'.join(clauses)))
Exemplo n.º 4
0
 def test_full_resolution_5(self):
     clauses = ['a || b', '!a', '!b || c', 'c || d', '!d || !e', 'e']
     assert full_resolution(cnf.sentence('\n'.join(clauses)))
Exemplo n.º 5
0
 def test_full_resolution_3(self):
     clauses = ['a || b', '!a', '!b || !c', 'c']
     assert not full_resolution(cnf.sentence('\n'.join(clauses)))
     assert full_resolution(cnf.sentence('\n'.join(clauses[:-1])))