예제 #1
0
    static void tst12(clause_kind k) {
        sat_solver<relevancy_extension> solver;

        literal l1 = solver.mk_var();
        literal l2 = solver.mk_var();
        
        solver.mk_aux_clause(l1, l2, k);

        solver.push_scope();

        SASSERT(!solver.is_relevant(l1));
        SASSERT(!solver.is_relevant(l2));

        solver.assign(l1, mk_axiom());
        solver.propagate();

        SASSERT(solver.is_relevant(l1));
        SASSERT(!solver.is_relevant(l2));

        solver.assign(l2, mk_axiom());
        solver.propagate();

        SASSERT(solver.is_relevant(l1));
        SASSERT(!solver.is_relevant(l2));
        
        solver.pop_scope(1);

        SASSERT(!solver.is_relevant(l1));
        SASSERT(!solver.is_relevant(l2));
    }
예제 #2
0
    static void tst1() {
        core_theory t;
        t.m_params.m_relevancy_lvl = 0;
        
        enode * n1  = t.mk_const();
        enode * n2  = t.mk_const();
        enode * n3  = t.mk_const();
        
        literal eq1 = t.mk_eq(n1,n2);
        literal eq2 = t.mk_eq(n2,n3);
        literal eq3 = t.mk_eq(n1,n3);

        literal l1   = t.mk_lit();
        literal l2   = t.mk_lit();
        t.mk_main_clause(l1, l2, ~eq3);
        t.mk_main_clause(~l2, ~eq3);
        t.mk_main_clause(~l1, ~eq2);

        t.push_scope();
        t.assign(eq1, mk_axiom());
        t.propagate();

        t.push_scope();
        t.assign(eq2, mk_axiom());
        t.propagate();
        SASSERT(t.get_assignment(eq3) == l_true);
        SASSERT(t.inconsistent());
        bool r = t.m_sat->resolve_conflict();
        SASSERT(r);
    }
예제 #3
0
파일: gate.cpp 프로젝트: sukwon0709/byterun
    static void tst10() {
        sat_solver<gate_extension> s;
        
        literal l1 = s.mk_var();
        literal l2 = s.mk_var();
        literal l3 = s.mk_var();
        
        s.push_scope();
        s.assign(l1, mk_axiom());
        s.push_scope();
        literal l4 = s.mk_var();
        literal l5 = s.mk_var();
        literal l6 = s.mk_iff(l4, l5);
        literal l7 = s.mk_var();
        literal l8 = s.mk_or(l6, l7);
        s.assign(l8, mk_axiom());
        s.mk_transient_clause(~l8, l3);
        s.mk_transient_clause(~l8, l2);
        s.mk_transient_clause(literal_vector(~l3, ~l1, ~l2));
        SASSERT(s.inconsistent());
#ifdef  Z3DEBUG
        bool r = 
#endif
            s.resolve_conflict();
        SASSERT(r);
        SASSERT(s.m_scope_lvl == 1);
        s.pop_scope(1);
        SASSERT(s.m_ref_count[l4.var()] > 0);
        SASSERT(s.m_ref_count[l5.var()] > 0);
        SASSERT(s.m_ref_count[l6.var()] > 0);
        SASSERT(s.m_ref_count[l7.var()] > 0);
        SASSERT(s.m_ref_count[l8.var()] > 0);
        s.push_scope();
        s.assign(~l1, mk_axiom());
        s.push_scope();
        s.assign(l5, mk_axiom());
        s.mk_transient_clause(~l5, ~l4);
        s.propagate();
        SASSERT(s.get_assignment(l6) == l_false);
        SASSERT(s.get_assignment(l8) == l_undef);
#ifdef  Z3DEBUG
        s.del_learned_clauses();
        SASSERT(s.m_ref_count[l7.var()] == 0);
        SASSERT(s.m_ref_count[l8.var()] ==  0);
        SASSERT(s.m_ref_count[l4.var()] > 0);
        SASSERT(s.m_ref_count[l5.var()] > 0);
        SASSERT(s.m_ref_count[l6.var()] > 0);
#endif 
        s.mk_transient_clause(l6, l3);
        s.mk_transient_clause(l6, l2);
        s.mk_transient_clause(literal_vector(~l3, l1, ~l2));
        SASSERT(s.inconsistent());
#ifdef  Z3DEBUG
        r = 
#endif
            s.resolve_conflict();
        SASSERT(r);
    }
예제 #4
0
    static void tst4() {
        sat_solver<relevancy_extension> solver;

        literal l1 = solver.mk_var();
        literal l2 = solver.mk_var();
        literal l3 = solver.mk_var();
        literal l4 = solver.mk_ite(l1, l2, l3);
        solver.propagate();

        solver.push_scope();

        solver.assign(l1, mk_axiom());
        solver.propagate();

        SASSERT(!solver.is_relevant(l1));
        SASSERT(!solver.is_relevant(l2));
        SASSERT(!solver.is_relevant(l3));
        SASSERT(!solver.is_relevant(l4));
        
        solver.mark_as_relevant(l4.var());
        solver.propagate();

        SASSERT(solver.is_relevant(l1));
        SASSERT(solver.is_relevant(l2));
        SASSERT(!solver.is_relevant(l3));
        SASSERT(solver.is_relevant(l4));

        solver.pop_scope(1);
        solver.propagate();

        SASSERT(!solver.is_relevant(l1));
        SASSERT(!solver.is_relevant(l2));
        SASSERT(!solver.is_relevant(l3));
        SASSERT(!solver.is_relevant(l4));

        solver.assign(~l1, mk_axiom());
        solver.propagate();

        SASSERT(!solver.is_relevant(l1));
        SASSERT(!solver.is_relevant(l2));
        SASSERT(!solver.is_relevant(l3));
        SASSERT(!solver.is_relevant(l4));
        
        solver.mark_as_relevant(l4.var());
        solver.propagate();
        
        SASSERT(solver.is_relevant(l1));
        SASSERT(!solver.is_relevant(l2));
        SASSERT(solver.is_relevant(l3));
        SASSERT(solver.is_relevant(l4));
    }
예제 #5
0
파일: gate.cpp 프로젝트: sukwon0709/byterun
    static void tst5() {
        sat_solver<gate_extension> solver;

        literal l1 = solver.mk_var();
        literal l2 = solver.mk_var();
        literal l3 = solver.mk_var();

        solver.push_scope();

        solver.assign(l1, mk_axiom());

        solver.propagate();
        
        solver.push_scope();

        literal l4 = solver.mk_or(l1, l2);

        solver.mk_main_clause(l4, l3);

        SASSERT(solver.get_assignment(l4) == l_true);
        
        solver.pop_scope(1);

        SASSERT(solver.get_assignment(l4) == l_true);
    }
static declaration update_declaration(declaration d, optional<level_param_names> const & ps,
                                      optional<expr> const & type, optional<expr> const & value) {
    level_param_names _ps = ps ? *ps : d.get_univ_params();
    expr _type = type ? *type : d.get_type();
    expr _value;
    if (d.is_definition()) {
        _value = value ? *value : d.get_value();
    } else {
        lean_assert(!value);
    }
    if (d.is_constant_assumption()) {
        if (is_eqp(d.get_type(), _type) && is_eqp(d.get_univ_params(), _ps))
            return d;
        if (d.is_axiom())
            return mk_axiom(d.get_name(), _ps, _type);
        else
            return mk_constant_assumption(d.get_name(), _ps, _type);
    } else {
        if (is_eqp(d.get_type(), _type) && is_eqp(d.get_value(), _value) && is_eqp(d.get_univ_params(), _ps))
            return d;
        if (d.is_theorem())
            return mk_theorem(d.get_name(), _ps, _type, _value, d.get_height());
        else
            return mk_definition(d.get_name(), _ps, _type, _value,
                                 d.get_height(), d.use_conv_opt());
    }
}
예제 #7
0
    static void tst10() {
        sat_solver<relevancy_extension> solver;

        literal l1 = solver.mk_var();
        literal l2 = solver.mk_var();
        literal l3 = solver.mk_or(l1, l2);
        
        solver.assign(l1, mk_axiom());
        solver.assign(l2, mk_axiom());
        solver.propagate();

        SASSERT(!solver.is_relevant(l1));
        SASSERT(!solver.is_relevant(l2));
        SASSERT(!solver.is_relevant(l3));
        
        solver.mark_as_relevant(l3.var());
        solver.propagate();
        
        SASSERT(solver.is_relevant(l1) || solver.is_relevant(l2));
        SASSERT(solver.is_relevant(l1) != solver.is_relevant(l2));
        SASSERT(solver.is_relevant(l3));
    }
예제 #8
0
파일: gate.cpp 프로젝트: sukwon0709/byterun
    static void tst11() {
        sat_solver<gate_extension> s;

        literal l0 = s.mk_var();
        literal l1 = s.mk_var();
        literal l2 = s.mk_var();
        
        s.push_scope();
        s.assign(~l1, mk_axiom());
        s.assign(~l2, mk_axiom());
        s.push_scope();
        literal l3 = s.mk_or(l1, l2);
        SASSERT(s.get_assignment(l3) == l_false);
        s.mk_main_clause(l0, l1, l3);
        SASSERT(s.m_ref_count[l3.var()] == 3);
        s.pop_scope(1);
        SASSERT(s.m_ref_count[l3.var()] == 2);
        SASSERT(s.get_assignment(l3) == l_false);
        s.assert_lit(l1);
        s.propagate();
        SASSERT(s.inconsistent());
    }
예제 #9
0
    static void tst14() {
        sat_solver<relevancy_extension> solver;

        literal l1 = solver.mk_var();
        literal l2 = solver.mk_var();

        solver.push_scope();
        
        solver.assign(l1, mk_axiom());

        solver.mk_aux_clause(l1, l2, CLS_MAIN);
        solver.propagate();
        
        SASSERT(solver.is_relevant(l1));
    }
예제 #10
0
declaration unfold_untrusted_macros(environment const & env, declaration const & d, optional<unsigned> const & trust_lvl) {
    if (!trust_lvl || contains_untrusted_macro(*trust_lvl, d)) {
        expr new_t = unfold_untrusted_macros(env, d.get_type(), trust_lvl);
        if (d.is_theorem()) {
            expr new_v = unfold_untrusted_macros(env, d.get_value(), trust_lvl);
            return mk_theorem(d.get_name(), d.get_univ_params(), new_t, new_v);
        } else if (d.is_definition()) {
            expr new_v = unfold_untrusted_macros(env, d.get_value(), trust_lvl);
            return mk_definition(d.get_name(), d.get_univ_params(), new_t, new_v,
                                 d.get_hints(), d.is_trusted());
        } else if (d.is_axiom()) {
            return mk_axiom(d.get_name(), d.get_univ_params(), new_t);
        } else if (d.is_constant_assumption()) {
            return mk_constant_assumption(d.get_name(), d.get_univ_params(), new_t);
        } else {
            lean_unreachable();
        }
    } else {
        return d;
    }
}
예제 #11
0
void initialize_declaration() {
    g_dummy = new declaration(mk_axiom(name(), level_param_names(), expr()));
}