All Downloads are FREE. Search and download functionalities are using the official Maven repository.

z3-z3-4.12.6.src.smt.arith_eq_solver.h Maven / Gradle / Ivy

There is a newer version: 4.13.0.1
Show newest version
/*++
Copyright (c) 2007 Microsoft Corporation

Module Name:

    arith_eq_solver.h

Abstract:

    Solver for linear arithmetic equalities.

Author:

    Nikolaj Bjorner (nbjorner) 2012-02-25

--*/
#pragma once

#include "ast/arith_decl_plugin.h"
#include "ast/rewriter/arith_rewriter.h"

/**
   \brief Simplifier for the arith family.
*/
class arith_eq_solver {
    typedef rational numeral;

    ast_manager&              m;
    params_ref                m_params;
    arith_util                m_util;
    arith_rewriter            m_arith_rewriter;

    bool is_neg_poly(expr * t) const;

    void prop_mod_const(expr * e, unsigned depth, numeral const& k, expr_ref& result);

    bool gcd_test(vector& values);
    unsigned find_abs_min(vector& values);
    void gcd_normalize(vector& values);
    void substitute(vector& r, vector const& s, unsigned   index);
    bool solve_integer_equations_units(
        vector > & rows,
        vector&          unsat_row
        );

    bool solve_integer_equations_omega(
        vector > & rows,
        vector&        unsat_row
        );

    void compute_hnf(vector >& A);

    bool solve_integer_equations_hermite(
        vector > & rows,
        vector&         unsat_row
        );

    bool solve_integer_equations_gcd(
        vector > & rows,
        vector&        unsat_row
        );

public:
    arith_eq_solver(ast_manager & m, params_ref const& p = params_ref());
    ~arith_eq_solver() = default;

    // Integer linear solver for a single equation.
    // The array values contains integer coefficients
    //
    // Determine integer solutions to:
    //
    // a+k = 0
    //
    // where a = sum_i a_i*k_i
    //

    typedef vector row;
    typedef vector     matrix;

    bool solve_integer_equation(
        row&             values,
        unsigned&        index,
        bool&            is_fresh
        );

    // Integer linear solver.
    // Determine integer solutions to:
    //
    // a+k = 0
    //
    // where a = sum_i a_i*k_i
    //
    // Solution, if there is any, is returned as a substitution.
    // The return value is "true".
    // If there is no solution, then return "false".
    // together with equality "eq_unsat", such that
    //
    //   eq_unsat = 0
    //
    // is implied and is unsatisfiable over the integers.
    //

    bool solve_integer_equations(vector& rows, row& unsat_row);

};





© 2015 - 2024 Weber Informatics LLC | Privacy Policy