mirror of
				https://github.com/Z3Prover/z3
				synced 2025-11-04 13:29:11 +00:00 
			
		
		
		
	add non-units method
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
		
							parent
							
								
									39ed27101e
								
							
						
					
					
						commit
						c59a957737
					
				
					 5 changed files with 55 additions and 0 deletions
				
			
		| 
						 | 
					@ -372,6 +372,21 @@ extern "C" {
 | 
				
			||||||
        Z3_CATCH_RETURN(0);
 | 
					        Z3_CATCH_RETURN(0);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Z3_ast_vector Z3_API Z3_solver_get_non_units(Z3_context c, Z3_solver s) {
 | 
				
			||||||
 | 
					        Z3_TRY;
 | 
				
			||||||
 | 
					        LOG_Z3_solver_get_non_units(c, s);
 | 
				
			||||||
 | 
					        RESET_ERROR_CODE();
 | 
				
			||||||
 | 
					        init_solver(c, s);
 | 
				
			||||||
 | 
					        Z3_ast_vector_ref * v = alloc(Z3_ast_vector_ref, *mk_c(c), mk_c(c)->m());
 | 
				
			||||||
 | 
					        mk_c(c)->save_object(v);
 | 
				
			||||||
 | 
					        expr_ref_vector fmls = to_solver_ref(s)->get_non_units(mk_c(c)->m());
 | 
				
			||||||
 | 
					        for (expr* f : fmls) {
 | 
				
			||||||
 | 
					            v->m_ast_vector.push_back(f);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        RETURN_Z3(of_ast_vector(v));
 | 
				
			||||||
 | 
					        Z3_CATCH_RETURN(0);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static Z3_lbool _solver_check(Z3_context c, Z3_solver s, unsigned num_assumptions, Z3_ast const assumptions[]) {
 | 
					    static Z3_lbool _solver_check(Z3_context c, Z3_solver s, unsigned num_assumptions, Z3_ast const assumptions[]) {
 | 
				
			||||||
        for (unsigned i = 0; i < num_assumptions; i++) {
 | 
					        for (unsigned i = 0; i < num_assumptions; i++) {
 | 
				
			||||||
            if (!is_expr(to_ast(assumptions[i]))) {
 | 
					            if (!is_expr(to_ast(assumptions[i]))) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2038,6 +2038,7 @@ namespace z3 {
 | 
				
			||||||
        stats statistics() const { Z3_stats r = Z3_solver_get_statistics(ctx(), m_solver); check_error(); return stats(ctx(), r); }
 | 
					        stats statistics() const { Z3_stats r = Z3_solver_get_statistics(ctx(), m_solver); check_error(); return stats(ctx(), r); }
 | 
				
			||||||
        expr_vector unsat_core() const { Z3_ast_vector r = Z3_solver_get_unsat_core(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
 | 
					        expr_vector unsat_core() const { Z3_ast_vector r = Z3_solver_get_unsat_core(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
 | 
				
			||||||
        expr_vector assertions() const { Z3_ast_vector r = Z3_solver_get_assertions(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
 | 
					        expr_vector assertions() const { Z3_ast_vector r = Z3_solver_get_assertions(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
 | 
				
			||||||
 | 
					        expr_vector non_units() const { Z3_ast_vector r = Z3_solver_get_non_units(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
 | 
				
			||||||
        expr proof() const { Z3_ast r = Z3_solver_get_proof(ctx(), m_solver); check_error(); return expr(ctx(), r); }
 | 
					        expr proof() const { Z3_ast r = Z3_solver_get_proof(ctx(), m_solver); check_error(); return expr(ctx(), r); }
 | 
				
			||||||
        friend std::ostream & operator<<(std::ostream & out, solver const & s);
 | 
					        friend std::ostream & operator<<(std::ostream & out, solver const & s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6121,6 +6121,14 @@ extern "C" {
 | 
				
			||||||
    */
 | 
					    */
 | 
				
			||||||
    Z3_ast_vector Z3_API Z3_solver_get_units(Z3_context c, Z3_solver s);
 | 
					    Z3_ast_vector Z3_API Z3_solver_get_units(Z3_context c, Z3_solver s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					       \brief Return the set of non units in the solver state.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					       def_API('Z3_solver_get_non_units', AST_VECTOR, (_in(CONTEXT), _in(SOLVER)))
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Z3_ast_vector Z3_API Z3_solver_get_non_units(Z3_context c, Z3_solver s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
       \brief Check whether the assertions in a given solver are consistent or not.
 | 
					       \brief Check whether the assertions in a given solver are consistent or not.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -256,3 +256,32 @@ expr_ref_vector solver::get_units(ast_manager& m) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return result;
 | 
					    return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					expr_ref_vector solver::get_non_units(ast_manager& m) {
 | 
				
			||||||
 | 
					    expr_ref_vector result(m), fmls(m);
 | 
				
			||||||
 | 
					    get_assertions(fmls);
 | 
				
			||||||
 | 
					    family_id bfid = m.get_basic_family_id();
 | 
				
			||||||
 | 
					    expr_mark marked;
 | 
				
			||||||
 | 
					    for (unsigned i = 0; i < fmls.size(); ++i) {
 | 
				
			||||||
 | 
					        expr* f = fmls.get(i);
 | 
				
			||||||
 | 
					        if (marked.is_marked(f)) continue;
 | 
				
			||||||
 | 
					        marked.mark(f);
 | 
				
			||||||
 | 
					        if (!is_app(f)) {
 | 
				
			||||||
 | 
					            result.push_back(f);
 | 
				
			||||||
 | 
					            continue;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        app* _f = to_app(f);
 | 
				
			||||||
 | 
					        if (_f->get_family_id() == bfid) {
 | 
				
			||||||
 | 
					            if (_f->get_num_args() > 0 && m.is_bool(_f->get_arg(0))) {
 | 
				
			||||||
 | 
					                fmls.append(_f->get_num_args(), _f->get_args());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else if (m.is_eq(f) || m.is_distinct(f)) {
 | 
				
			||||||
 | 
					                result.push_back(f);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else {
 | 
				
			||||||
 | 
					            result.push_back(f);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -236,6 +236,8 @@ public:
 | 
				
			||||||
    */
 | 
					    */
 | 
				
			||||||
    expr_ref_vector get_units(ast_manager& m);
 | 
					    expr_ref_vector get_units(ast_manager& m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    expr_ref_vector get_non_units(ast_manager& m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class scoped_push {
 | 
					    class scoped_push {
 | 
				
			||||||
        solver& s;
 | 
					        solver& s;
 | 
				
			||||||
        bool    m_nopop;
 | 
					        bool    m_nopop;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue