From 8871cb120a6bb74f40c3b1911d614cddf7e6e0ce Mon Sep 17 00:00:00 2001
From: "Christoph M. Wintersteiger" <cwinter@microsoft.com>
Date: Sun, 17 Sep 2017 12:57:29 +0100
Subject: [PATCH 01/10] Fixed bug in fp.to_{s,u}bv

---
 src/ast/fpa/fpa2bv_converter.cpp | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/ast/fpa/fpa2bv_converter.cpp b/src/ast/fpa/fpa2bv_converter.cpp
index cd3b0ccca..cae357a32 100644
--- a/src/ast/fpa/fpa2bv_converter.cpp
+++ b/src/ast/fpa/fpa2bv_converter.cpp
@@ -3240,10 +3240,7 @@ void fpa2bv_converter::mk_to_bv(func_decl * f, unsigned num, expr * const * args
 
     // NaN, Inf, or negative (except -0) -> unspecified
     expr_ref c1(m), v1(m), unspec_v(m);
-    if (!is_signed)
-        c1 = m.mk_or(x_is_nan, x_is_inf, m.mk_and(x_is_neg, m.mk_not(x_is_nzero)));
-    else
-        c1 = m.mk_or(x_is_nan, x_is_inf);
+    c1 = m.mk_or(x_is_nan, x_is_inf);
     mk_to_bv_unspecified(f, num, args, unspec_v);
     v1 = unspec_v;
     dbg_decouple("fpa2bv_to_bv_c1", c1);
@@ -3335,18 +3332,18 @@ void fpa2bv_converter::mk_to_bv(func_decl * f, unsigned num, expr * const * args
     dbg_decouple("fpa2bv_to_bv_inc", inc);
     dbg_decouple("fpa2bv_to_bv_pre_rounded", pre_rounded);
 
-    expr_ref in_range(m);
+	pre_rounded = m.mk_ite(x_is_neg, m_bv_util.mk_bv_neg(pre_rounded), pre_rounded);
+
+	expr_ref ll(m), ul(m), in_range(m);
     if (!is_signed) {
-        expr_ref ul(m);
+		ll = m_bv_util.mk_numeral(0, bv_sz+3);
         ul = m_bv_util.mk_zero_extend(3, m_bv_util.mk_numeral(-1, bv_sz));
-        in_range = m_bv_util.mk_ule(pre_rounded, ul);
     }
     else {
-        expr_ref ll(m), ul(m);
         ll = m_bv_util.mk_sign_extend(3, m_bv_util.mk_concat(bv1, m_bv_util.mk_numeral(0, bv_sz-1)));
         ul = m_bv_util.mk_zero_extend(4, m_bv_util.mk_numeral(-1, bv_sz-1));
-        in_range = m.mk_and(m_bv_util.mk_sle(ll, pre_rounded), m_bv_util.mk_sle(pre_rounded, ul));
     }
+	in_range = m.mk_and(m_bv_util.mk_sle(ll, pre_rounded), m_bv_util.mk_sle(pre_rounded, ul));
     dbg_decouple("fpa2bv_to_bv_in_range", in_range);
 
     expr_ref rounded(m);

From 00651f8f211dd9b71b2e5b0b828df9a3815e26ed Mon Sep 17 00:00:00 2001
From: "Christoph M. Wintersteiger" <cwinter@microsoft.com>
Date: Sun, 17 Sep 2017 14:29:32 +0100
Subject: [PATCH 02/10] Tabs, formatting.

---
 src/api/dll/dll.cpp                           |  18 +-
 src/api/ml/z3native_stubs.h                   |   2 +-
 src/ast/fpa/fpa2bv_converter.cpp              |   8 +-
 src/ast/rewriter/bit2int.h                    |   2 +-
 src/ast/rewriter/bv_bounds.h                  |   6 +-
 src/duality/duality.h                         | 263 ++++++------
 src/duality/duality_wrapper.h                 | 401 +++++++++---------
 src/interp/iz3base.h                          |  34 +-
 src/interp/iz3checker.h                       |  34 +-
 src/interp/iz3hash.h                          |   8 +-
 src/interp/iz3interp.h                        |  46 +-
 src/interp/iz3pp.h                            |   6 +-
 src/interp/iz3scopes.h                        |   4 +-
 src/interp/iz3translate.h                     |   6 +-
 src/math/automata/automaton.h                 |   2 +-
 src/math/automata/boolean_algebra.h           |   4 +-
 src/math/polynomial/polynomial.h              |   4 +-
 src/math/polynomial/upolynomial.h             |   8 +-
 src/model/model_core.cpp                      |   6 +-
 src/muz/base/dl_context.h                     |   6 +-
 src/muz/base/dl_engine_base.h                 |   2 +-
 src/muz/duality/duality_dl_interface.h        |   4 +-
 src/muz/pdr/pdr_generalizers.h                |   2 +-
 src/muz/rel/dl_mk_similarity_compressor.h     |   2 +-
 src/muz/rel/dl_mk_simple_joins.h              |   2 +-
 src/muz/spacer/spacer_qe_project.cpp          |   2 +-
 src/muz/transforms/dl_mk_magic_sets.h         |   2 +-
 src/muz/transforms/dl_mk_unbound_compressor.h |   2 +-
 src/smt/diff_logic.h                          |  62 +--
 src/smt/smt_enode.h                           |   8 +-
 src/smt/smt_quantifier.h                      |   2 +-
 src/smt/smt_theory.h                          |   2 +-
 src/smt/theory_seq.h                          |   8 +-
 src/smt/theory_str.cpp                        |  10 +-
 src/smt/watch_list.cpp                        |   8 +-
 src/tactic/sls/sls_tracker.h                  |  16 +-
 src/test/bit_vector.cpp                       |  62 +--
 src/test/diff_logic.cpp                       |   2 +-
 src/test/expr_rand.cpp                        |   4 +-
 src/test/main.cpp                             |  98 ++---
 src/test/model_based_opt.cpp                  |   2 +-
 src/test/optional.cpp                         |   4 +-
 src/util/dependency.h                         |   2 +-
 src/util/hash.h                               |   2 +-
 src/util/inf_eps_rational.h                   |  20 +-
 src/util/inf_int_rational.h                   |  16 +-
 src/util/inf_rational.h                       |  14 +-
 src/util/inf_s_integer.h                      |  10 +-
 src/util/lp/bound_analyzer_on_row.h           |  38 +-
 src/util/lp/init_lar_solver.h                 |  22 +-
 src/util/lp/lar_core_solver.h                 |   2 +-
 src/util/lp/lar_solver.h                      |  30 +-
 src/util/lp/lp_bound_propagator.cpp           |  10 +-
 src/util/lp/lp_settings.h                     |  10 +-
 src/util/lp/lp_utils.h                        |   2 +-
 src/util/lp/stacked_vector.h                  |  26 +-
 src/util/lp/static_matrix.h                   |   2 +-
 src/util/lp/ul_pair.h                         |   4 +-
 src/util/map.h                                |   2 +-
 src/util/max_cliques.h                        |   4 +-
 src/util/rational.h                           |  16 +-
 src/util/stopwatch.h                          |   6 +-
 src/util/util.h                               |  20 +-
 63 files changed, 715 insertions(+), 717 deletions(-)

diff --git a/src/api/dll/dll.cpp b/src/api/dll/dll.cpp
index a0bd25d2e..74dc48153 100644
--- a/src/api/dll/dll.cpp
+++ b/src/api/dll/dll.cpp
@@ -15,16 +15,16 @@ Copyright (c) 2015 Microsoft Corporation
 BOOL APIENTRY DllMain( HMODULE hModule,
                        DWORD  ul_reason_for_call,
                        LPVOID lpReserved
-					 )
+                     )
 {
-	switch (ul_reason_for_call)
-	{
-	case DLL_PROCESS_ATTACH:
-	case DLL_THREAD_ATTACH:
-	case DLL_THREAD_DETACH:
-	case DLL_PROCESS_DETACH:
-		break;
-	}
+    switch (ul_reason_for_call)
+    {
+    case DLL_PROCESS_ATTACH:
+    case DLL_THREAD_ATTACH:
+    case DLL_THREAD_DETACH:
+    case DLL_PROCESS_DETACH:
+        break;
+    }
     return TRUE;
 }
 
diff --git a/src/api/ml/z3native_stubs.h b/src/api/ml/z3native_stubs.h
index ef81ac239..ec498dafe 100644
--- a/src/api/ml/z3native_stubs.h
+++ b/src/api/ml/z3native_stubs.h
@@ -36,5 +36,5 @@ Notes:
     #define DLL_LOCAL
   #endif
 #endif
-	
+    
 #endif
diff --git a/src/ast/fpa/fpa2bv_converter.cpp b/src/ast/fpa/fpa2bv_converter.cpp
index cae357a32..bc0364994 100644
--- a/src/ast/fpa/fpa2bv_converter.cpp
+++ b/src/ast/fpa/fpa2bv_converter.cpp
@@ -3332,18 +3332,18 @@ void fpa2bv_converter::mk_to_bv(func_decl * f, unsigned num, expr * const * args
     dbg_decouple("fpa2bv_to_bv_inc", inc);
     dbg_decouple("fpa2bv_to_bv_pre_rounded", pre_rounded);
 
-	pre_rounded = m.mk_ite(x_is_neg, m_bv_util.mk_bv_neg(pre_rounded), pre_rounded);
+    pre_rounded = m.mk_ite(x_is_neg, m_bv_util.mk_bv_neg(pre_rounded), pre_rounded);
 
-	expr_ref ll(m), ul(m), in_range(m);
+    expr_ref ll(m), ul(m), in_range(m);
     if (!is_signed) {
-		ll = m_bv_util.mk_numeral(0, bv_sz+3);
+        ll = m_bv_util.mk_numeral(0, bv_sz+3);
         ul = m_bv_util.mk_zero_extend(3, m_bv_util.mk_numeral(-1, bv_sz));
     }
     else {
         ll = m_bv_util.mk_sign_extend(3, m_bv_util.mk_concat(bv1, m_bv_util.mk_numeral(0, bv_sz-1)));
         ul = m_bv_util.mk_zero_extend(4, m_bv_util.mk_numeral(-1, bv_sz-1));
     }
-	in_range = m.mk_and(m_bv_util.mk_sle(ll, pre_rounded), m_bv_util.mk_sle(pre_rounded, ul));
+    in_range = m.mk_and(m_bv_util.mk_sle(ll, pre_rounded), m_bv_util.mk_sle(pre_rounded, ul));
     dbg_decouple("fpa2bv_to_bv_in_range", in_range);
 
     expr_ref rounded(m);
diff --git a/src/ast/rewriter/bit2int.h b/src/ast/rewriter/bit2int.h
index fe15d1ec5..fbbf2e6d1 100644
--- a/src/ast/rewriter/bit2int.h
+++ b/src/ast/rewriter/bit2int.h
@@ -75,7 +75,7 @@ protected:
     bool mk_mul(expr* a, expr* b, expr_ref& result);
     bool mk_comp(eq_type ty, expr* e1, expr* e2, expr_ref& result);
     bool mk_add(expr* e1, expr* e2, expr_ref& result);
-	
+
     expr * get_cached(expr * n) const;
     bool is_cached(expr * n) const {  return get_cached(n) != 0; }
     void cache_result(expr * n, expr * r);
diff --git a/src/ast/rewriter/bv_bounds.h b/src/ast/rewriter/bv_bounds.h
index 3d8ec9ebb..4a7226fa7 100644
--- a/src/ast/rewriter/bv_bounds.h
+++ b/src/ast/rewriter/bv_bounds.h
@@ -38,7 +38,7 @@ public:
     bv_bounds(ast_manager& m) : m_m(m), m_bv_util(m), m_okay(true) {};
     ~bv_bounds();
 public: // bounds addition methods
-	br_status rewrite(unsigned limit, func_decl * f, unsigned num, expr * const * args, expr_ref& result);
+    br_status rewrite(unsigned limit, func_decl * f, unsigned num, expr * const * args, expr_ref& result);
 
     /** \brief Add a constraint to the system.
 
@@ -82,7 +82,7 @@ protected:
     bv_util                   m_bv_util;
     bool                      m_okay;
     bool                      is_sat(app * v);
-	bool                      is_sat_core(app * v);
+bool                      is_sat_core(app * v);
     inline bool               in_range(app *v, numeral l);
     inline bool               is_constant_add(unsigned bv_sz, expr * e, app*& v, numeral& val);
     void                      record_singleton(app * v,  numeral& singleton_value);
@@ -94,7 +94,7 @@ protected:
 inline bool bv_bounds::is_okay() { return m_okay; }
 
 inline bool bv_bounds::to_bound(const expr * e) const {
-	return is_app(e) && m_bv_util.is_bv(e)
+    return is_app(e) && m_bv_util.is_bv(e)
        && !m_bv_util.is_bv_add(e)
        && !m_bv_util.is_numeral(e);
 }
diff --git a/src/duality/duality.h b/src/duality/duality.h
index 0ef6be30e..657fa18b4 100644
--- a/src/duality/duality.h
+++ b/src/duality/duality.h
@@ -21,6 +21,7 @@
 #pragma once
 
 #include "duality/duality_wrapper.h"
+#include <vector>
 #include <list>
 #include <map>
 
@@ -41,9 +42,9 @@ namespace Duality {
         typedef expr Term;
 
     Z3User(context &_ctx) : ctx(_ctx){}
-  
+
         const char *string_of_int(int n);
-      
+
         Term conjoin(const std::vector<Term> &args);
 
         Term sum(const std::vector<Term> &args);
@@ -130,58 +131,58 @@ namespace Duality {
 
     /** This class represents a relation post-fixed point (RPFP) problem as
      *  a "problem graph". The graph consists of Nodes and hyper-edges.
-     * 
+     *
      * A node consists of
      * - Annotation, a symbolic relation
      * - Bound, a symbolic relation giving an upper bound on Annotation
-     * 
+     *
      *
      * A hyper-edge consists of:
      *  - Children, a sequence of children Nodes,
      *  - F, a symbolic relational transformer,
      *  - Parent, a single parent Node.
-     *  
+     *
      * The graph is "solved" when:
      * - For every Node n, n.Annotation subseteq n.Bound
      * - For every hyperedge e, e.F(e.Children.Annotation) subseteq e.Parent.Annotation
-     * 
+     *
      * where, if x is a sequence of Nodes, x.Annotation is the sequences
      * of Annotations of the nodes in the sequence.
-     * 
+     *
      * A symbolic Transformer consists of
      * - RelParams, a sequence of relational symbols
      * - IndParams, a sequence of individual symbols
      * - Formula, a formula over RelParams and IndParams
-     * 
+     *
      * A Transformer t represents a function that takes sequence R of relations
      * and yields the relation lambda (t.Indparams). Formula(R/RelParams).
-     * 
+     *
      * As a special case, a nullary Transformer (where RelParams is the empty sequence)
      * represents a fixed relation.
-     * 
+     *
      * An RPFP consists of
      * - Nodes, a set of Nodes
      * - Edges, a set of hyper-edges
      * - Context, a prover context that contains formula AST's
-     *  
+     *
      * Multiple RPFP's can use the same Context, but you should be careful
-     * that only one RPFP asserts constraints in the context at any time. 
-     * 
+     * that only one RPFP asserts constraints in the context at any time.
+     *
      *  */
     class RPFP : public Z3User
     {
     public:
-      
+
         class Edge;
         class Node;
         bool HornClauses;
 
-      
+
         /** Interface class for interpolating solver. */
 
         class LogicSolver {
         public:
-           
+
             context *ctx;   /** Z3 context for formulas */
             solver *slvr;   /** Z3 solver */
             bool need_goals; /** Can the solver use the goal tree to optimize interpolants? */
@@ -191,7 +192,7 @@ namespace Duality {
                 "assumptions" are currently asserted in the solver. The return
                 value indicates whether the assertions are satisfiable. In the
                 UNSAT case, a tree interpolant is returned in "interpolants".
-                In the SAT case, a model is returned. 
+                In the SAT case, a model is returned.
             */
 
             virtual
@@ -201,7 +202,7 @@ namespace Duality {
                                        TermTree *goals = 0,
                                        bool weak = false
                                        ) = 0;
-           
+
             /** Declare a constant in the background theory. */
             virtual void declare_constant(const func_decl &f) = 0;
 
@@ -319,7 +320,7 @@ namespace Duality {
             virtual void declare_constant(const func_decl &f){
                 bckg.insert(f);
             }
-	
+
             /** Is this a background constant? */
             virtual bool is_constant(const func_decl &f){
                 return bckg.find(f) != bckg.end();
@@ -344,9 +345,9 @@ namespace Duality {
         static iZ3LogicSolver *CreateLogicSolver(config &_config){
             return new iZ3LogicSolver(_config);
         }
-#endif      
+#endif
 
-        /** Create a logic solver from a low-level Z3 context. 
+        /** Create a logic solver from a low-level Z3 context.
             Only use this if you know what you're doing. */
         static iZ3LogicSolver *CreateLogicSolver(context c){
             return new iZ3LogicSolver(c);
@@ -357,7 +358,7 @@ namespace Duality {
     protected:
         int nodeCount;
         int edgeCount;
-      
+
         class stack_entry
         {
         public:
@@ -365,8 +366,8 @@ namespace Duality {
             std::list<Node *> nodes;
             std::list<std::pair<Edge *,Term> > constraints;
         };
-      
-      
+
+
     public:
         model dualModel;
     protected:
@@ -375,14 +376,14 @@ namespace Duality {
         std::vector<Term> axioms; // only saved here for printing purposes
         solver &aux_solver;
         hash_set<ast> *proof_core;
-      
+
     public:
 
         /** Construct an RPFP graph with a given interpolating prover context. It is allowed to
             have multiple RPFP's use the same context, but you should never have teo RPFP's
             with the same conext asserting nodes or edges at the same time. Note, if you create
             axioms in one RPFP, them create a second RPFP with the same context, the second will
-            inherit the axioms. 
+            inherit the axioms.
         */
 
     RPFP(LogicSolver *_ls) : Z3User(*(_ls->ctx)), dualModel(*(_ls->ctx)), aux_solver(_ls->aux_solver)
@@ -396,7 +397,7 @@ namespace Duality {
             }
 
         virtual ~RPFP();
-      
+
         /** Symbolic representation of a relational transformer */
         class Transformer
         {
@@ -406,12 +407,12 @@ namespace Duality {
             Term Formula;
             RPFP *owner;
             hash_map<std::string,Term> labels;
-	
+
             Transformer *Clone()
             {
                 return new Transformer(*this);
             }
-	
+
             void SetEmpty(){
                 Formula = owner->ctx.bool_val(false);
             }
@@ -451,7 +452,7 @@ namespace Duality {
             void Complement(){
                 Formula = !Formula;
             }
-	
+
             void Simplify(){
                 Formula = Formula.simplify();
             }
@@ -459,7 +460,7 @@ namespace Duality {
         Transformer(const std::vector<FuncDecl> &_RelParams, const std::vector<Term> &_IndParams, const Term &_Formula, RPFP *_owner)
             : RelParams(_RelParams), IndParams(_IndParams), Formula(_Formula) {owner = _owner;}
         };
-      
+
         /** Create a symbolic transformer. */
         Transformer CreateTransformer(const std::vector<FuncDecl> &_RelParams, const std::vector<Term> &_IndParams, const Term &_Formula)
         {
@@ -469,13 +470,13 @@ namespace Duality {
             // t.labels = foo.Item2;
             return Transformer(_RelParams,_IndParams,_Formula,this);
         }
-      
+
         /** Create a relation (nullary relational transformer) */
         Transformer CreateRelation(const std::vector<Term> &_IndParams, const Term &_Formula)
         {
             return CreateTransformer(std::vector<FuncDecl>(), _IndParams, _Formula);
         }
-      
+
         /** A node in the RPFP graph */
         class Node
         {
@@ -491,17 +492,17 @@ namespace Duality {
             Term dual;
             Node *map;
             unsigned recursion_bound;
-	
+
         Node(const FuncDecl &_Name, const Transformer &_Annotation, const Transformer &_Bound, const Transformer &_Underapprox, const Term &_dual, RPFP *_owner, int _number)
             : Name(_Name), Annotation(_Annotation), Bound(_Bound), Underapprox(_Underapprox), dual(_dual) {owner = _owner; number = _number; Outgoing = 0; recursion_bound = UINT_MAX;}
         };
-      
+
         /** Create a node in the graph. The input is a term R(v_1...v_n)
          *  where R is an arbitrary relational symbol and v_1...v_n are
          *  arbitary distinct variables. The names are only of mnemonic value,
          *  however, the number and type of arguments determine the type
          *  of the relation at this node. */
-      
+
         Node *CreateNode(const Term &t)
         {
             std::vector<Term> _IndParams;
@@ -517,9 +518,9 @@ namespace Duality {
             nodes.push_back(n);
             return n;
         }
-      
+
         /** Clone a node (can be from another graph).  */
-      
+
         Node *CloneNode(Node *old)
         {
             Node *n = new Node(old->Name,
@@ -534,7 +535,7 @@ namespace Duality {
             n->map = old;
             return n;
         }
-      
+
         /** Delete a node. You can only do this if not connected to any edges.*/
         void DeleteNode(Node *node){
             if(node->Outgoing || !node->Incoming.empty())
@@ -549,7 +550,7 @@ namespace Duality {
         }
 
         /** This class represents a hyper-edge in the RPFP graph */
-      
+
         class Edge
         {
         public:
@@ -565,15 +566,15 @@ namespace Duality {
             Edge *map;
             Term labeled;
             std::vector<Term> constraints;
-	
+
         Edge(Node *_Parent, const Transformer &_F, const std::vector<Node *> &_Children, RPFP *_owner, int _number)
             : F(_F), Parent(_Parent), Children(_Children), dual(expr(_owner->ctx)) {
                 owner = _owner;
                 number = _number;
             }
         };
-      
-        
+
+
         /** Create a hyper-edge. */
         Edge *CreateEdge(Node *_Parent, const Transformer &_F, const std::vector<Node *> &_Children)
         {
@@ -584,8 +585,8 @@ namespace Duality {
             edges.push_back(e);
             return e;
         }
-      
-      
+
+
         /** Delete a hyper-edge and unlink it from any nodes. */
         void DeleteEdge(Edge *edge){
             if(edge->Parent)
@@ -607,19 +608,19 @@ namespace Duality {
             }
             delete edge;
         }
-      
+
         /** Create an edge that lower-bounds its parent. */
         Edge *CreateLowerBoundEdge(Node *_Parent)
         {
             return CreateEdge(_Parent, _Parent->Annotation, std::vector<Node *>());
         }
-      
+
 
         /** For incremental solving, asserts the constraint associated
          * with this edge in the SMT context. If this edge is removed,
          * you must pop the context accordingly. The second argument is
          * the number of pushes we are inside. */
-      
+
         virtual void AssertEdge(Edge *e, int persist = 0, bool with_children = false, bool underapprox = false);
 
         /* Constrain an edge by the annotation of one of its children. */
@@ -629,19 +630,19 @@ namespace Duality {
         /** For incremental solving, asserts the negation of the upper bound associated
          * with a node.
          * */
-      
+
         void AssertNode(Node *n);
 
-        /** Assert a constraint on an edge in the SMT context. 
+        /** Assert a constraint on an edge in the SMT context.
          */
         void ConstrainEdge(Edge *e, const Term &t);
-      
+
         /** Fix the truth values of atomic propositions in the given
             edge to their values in the current assignment. */
         void FixCurrentState(Edge *root);
-    
+
         void FixCurrentStateFull(Edge *edge, const expr &extra);
-      
+
         void FixCurrentStateFull(Edge *edge, const std::vector<expr> &assumps, const hash_map<ast,expr> &renaming);
 
         /** Declare a constant in the background theory. */
@@ -660,78 +661,78 @@ namespace Duality {
 
 #if 0
         /** Do not call this. */
-      
+
         void RemoveAxiom(const Term &t);
 #endif
 
         /** Solve an RPFP graph. This means either strengthen the annotation
          *  so that the bound at the given root node is satisfied, or
-         *  show that this cannot be done by giving a dual solution 
-         *  (i.e., a counterexample). 
-         *  
+         *  show that this cannot be done by giving a dual solution
+         *  (i.e., a counterexample).
+         *
          * In the current implementation, this only works for graphs that
          * are:
          * - tree-like
-         * 
+         *
          * - closed.
-         * 
+         *
          * In a tree-like graph, every nod has out most one incoming and one out-going edge,
          * and there are no cycles. In a closed graph, every node has exactly one out-going
          * edge. This means that the leaves of the tree are all hyper-edges with no
          * children. Such an edge represents a relation (nullary transformer) and thus
          * a lower bound on its parent. The parameter root must be the root of this tree.
-         * 
+         *
          * If Solve returns LBool.False, this indicates success. The annotation of the tree
-         * has been updated to satisfy the upper bound at the root. 
-         * 
+         * has been updated to satisfy the upper bound at the root.
+         *
          * If Solve returns LBool.True, this indicates a counterexample. For each edge,
          * you can then call Eval to determine the values of symbols in the transformer formula.
          * You can also call Empty on a node to determine if its value in the counterexample
          * is the empty relation.
-         * 
+         *
          *    \param root The root of the tree
-         *    \param persist Number of context pops through which result should persist 
-         * 
-         * 
+         *    \param persist Number of context pops through which result should persist
+         *
+         *
          */
 
         lbool Solve(Node *root, int persist);
-      
+
         /** Same as Solve, but annotates only a single node. */
 
         lbool SolveSingleNode(Node *root, Node *node);
 
         /** Get the constraint tree (but don't solve it) */
-      
+
         TermTree *GetConstraintTree(Node *root, Node *skip_descendant = 0);
-  
+
         /** Dispose of the dual model (counterexample) if there is one. */
-      
+
         void DisposeDualModel();
 
         /** Check satisfiability of asserted edges and nodes. Same functionality as
-         * Solve, except no primal solution (interpolant) is generated in the unsat case. */ 
-      
-        check_result Check(Node *root, std::vector<Node *> underapproxes = std::vector<Node *>(), 
+         * Solve, except no primal solution (interpolant) is generated in the unsat case. */
+
+        check_result Check(Node *root, std::vector<Node *> underapproxes = std::vector<Node *>(),
                            std::vector<Node *> *underapprox_core = 0);
 
         /** Update the model, attempting to make the propositional literals in assumps true. If possible,
             return sat, else return unsat and keep the old model. */
-      
+
         check_result CheckUpdateModel(Node *root, std::vector<expr> assumps);
 
         /** Determines the value in the counterexample of a symbol occuring in the transformer formula of
          *  a given edge. */
-      
+
         Term Eval(Edge *e, Term t);
-	
+
         /** Return the fact derived at node p in a counterexample. */
 
         Term EvalNode(Node *p);
-    
+
         /** Returns true if the given node is empty in the primal solution. For proecudure summaries,
             this means that the procedure is not called in the current counter-model. */
-      
+
         bool Empty(Node *p);
 
         /** Compute an underapproximation of every node in a tree rooted at "root",
@@ -747,11 +748,11 @@ namespace Duality {
         void InterpolateByCases(Node *root, Node *node);
 
         /** Push a scope. Assertions made after Push can be undone by Pop. */
-      
+
         void Push();
 
         /** Exception thrown when bad clause is encountered */
-      
+
         struct bad_clause {
             std::string msg;
             int i;
@@ -777,7 +778,7 @@ namespace Duality {
         // thrown on internal error
         struct Bad {
         };
-      
+
         // thrown on more serious internal error
         struct ReallyBad {
         };
@@ -786,56 +787,56 @@ namespace Duality {
         struct greedy_reduce_failed {};
 
         /** Pop a scope (see Push). Note, you cannot pop axioms. */
-      
+
         void Pop(int num_scopes);
-      
+
         /** Erase the proof by performing a Pop, Push and re-assertion of
             all the popped constraints */
         void PopPush();
 
         /** Return true if the given edge is used in the proof of unsat.
             Can be called only after Solve or Check returns an unsat result. */
-      
+
         bool EdgeUsedInProof(Edge *edge);
 
 
         /** Convert a collection of clauses to Nodes and Edges in the RPFP.
-	  
+
             Predicate unknowns are uninterpreted predicates not
             occurring in the background theory.
-          
-            Clauses are of the form 
-          
+
+            Clauses are of the form
+
             B => P(t_1,...,t_k)
-	  
+
             where P is a predicate unknown and predicate unknowns
             occur only positivey in H and only under existential
             quantifiers in prenex form.
-	  
+
             Each predicate unknown maps to a node. Each clause maps to
             an edge. Let C be a clause B => P(t_1,...,t_k) where the
             sequence of predicate unknowns occurring in B (in order
             of occurrence) is P_1..P_n. The clause maps to a transformer
             T where:
-	  
+
             T.Relparams = P_1..P_n
             T.Indparams = x_1...x+k
             T.Formula = B /\ t_1 = x_1 /\ ... /\ t_k = x_k
-	  
+
             Throws exception bad_clause(msg,i) if a clause i is
             in the wrong form.
-	  
+
         */
-      
+
         struct label_struct {
             symbol name;
             expr value;
             bool pos;
-	label_struct(const symbol &s, const expr &e, bool b)
-	: name(s), value(e), pos(b) {}
+            label_struct(const symbol &s, const expr &e, bool b)
+                : name(s), value(e), pos(b) {}
         };
 
-      
+
 #ifdef _WINDOWS
         __declspec(dllexport)
 #endif
@@ -847,7 +848,7 @@ namespace Duality {
 
         void WriteCounterexample(std::ostream &s, Node *node);
 
-        enum FileFormat {DualityFormat, SMT2Format, HornFormat}; 
+        enum FileFormat {DualityFormat, SMT2Format, HornFormat};
 
         /** Write the RPFP to a file (currently in SMTLIB 1.2 format) */
         void WriteProblemToFile(std::string filename, FileFormat format = DualityFormat);
@@ -870,9 +871,9 @@ namespace Duality {
         /** Fuse a vector of transformers. If the total number of inputs of the transformers
             is N, then the result is an N-ary transfomer whose output is the union of
             the outputs of the given transformers. The is, suppose we have a vetor of transfoermers
-            {T_i(r_i1,...,r_iN(i) : i=1..M}. The the result is a transformer 
-	       
-            F(r_11,...,r_iN(1),...,r_M1,...,r_MN(M)) = 
+            {T_i(r_i1,...,r_iN(i) : i=1..M}. The the result is a transformer
+
+            F(r_11,...,r_iN(1),...,r_M1,...,r_MN(M)) =
             T_1(r_11,...,r_iN(1)) U ... U T_M(r_M1,...,r_MN(M))
         */
 
@@ -921,7 +922,7 @@ namespace Duality {
         }
 
     protected:
-      
+
         void ClearProofCore(){
             if(proof_core)
                 delete proof_core;
@@ -929,7 +930,7 @@ namespace Duality {
         }
 
         Term SuffixVariable(const Term &t, int n);
-      
+
         Term HideVariable(const Term &t, int n);
 
         void RedVars(Node *node, Term &b, std::vector<Term> &v);
@@ -958,16 +959,16 @@ namespace Duality {
 
 #if 0
         void WriteInterps(System.IO.StreamWriter f, TermTree t);
-#endif    
+#endif
 
         void WriteEdgeVars(Edge *e,  hash_map<ast,int> &memo, const Term &t, std::ostream &s);
 
         void WriteEdgeAssignment(std::ostream &s, Edge *e);
 
-    
+
         // Scan the clause body for occurrences of the predicate unknowns
-  
-        Term ScanBody(hash_map<ast,Term> &memo, 
+
+        Term ScanBody(hash_map<ast,Term> &memo,
                       const Term &t,
                       hash_map<func_decl,Node *> &pmap,
                       std::vector<func_decl> &res,
@@ -1035,7 +1036,7 @@ namespace Duality {
         void ConstrainEdgeLocalized(Edge *e, const Term &t);
 
         void GreedyReduce(solver &s, std::vector<expr> &conjuncts);
-      
+
         void NegateLits(std::vector<expr> &lits);
 
         expr SimplifyOr(std::vector<expr> &lits);
@@ -1053,7 +1054,7 @@ namespace Duality {
         void GetGroundLitsUnderQuants(hash_set<ast> *memo, const Term &f, std::vector<Term> &res, int under);
 
         Term StrengthenFormulaByCaseSplitting(const Term &f, std::vector<expr> &case_lits);
-    
+
         expr NegateLit(const expr &f);
 
         expr GetEdgeFormula(Edge *e, int persist, bool with_children, bool underapprox);
@@ -1065,7 +1066,7 @@ namespace Duality {
         expr UnhoistPullRec(hash_map<ast,expr> & memo, const expr &w, hash_map<ast,expr> & init_defs, hash_map<ast,expr> & const_params, hash_map<ast,expr> &const_params_inv, std::vector<expr> &new_params);
 
         void AddParamsToTransformer(Transformer &trans, const std::vector<expr> &params);
- 
+
         expr AddParamsToApp(const expr &app, const func_decl &new_decl, const std::vector<expr> &params);
 
         expr GetRelRec(hash_set<ast> &memo, const expr &t, const func_decl &rel);
@@ -1081,7 +1082,7 @@ namespace Duality {
         void UnhoistLoop(Edge *loop_edge, Edge *init_edge);
 
         void Unhoist();
-      
+
         Term ElimIteRec(hash_map<ast,expr> &memo, const Term &t, std::vector<expr> &cnsts);
 
         Term ElimIte(const Term &t);
@@ -1089,11 +1090,11 @@ namespace Duality {
         void MarkLiveNodes(hash_map<Node *,std::vector<Edge *> > &outgoing, hash_set<Node *> &live_nodes, Node *node);
 
         virtual void slvr_add(const expr &e);
-      
+
         virtual void slvr_pop(int i);
 
         virtual void slvr_push();
-      
+
         virtual check_result slvr_check(unsigned n = 0, expr * const assumptions = 0, unsigned *core_size = 0, expr *core = 0);
 
         virtual lbool ls_interpolate_tree(TermTree *assumptions,
@@ -1105,14 +1106,14 @@ namespace Duality {
         virtual bool proof_core_contains(const expr &e);
 
     };
-    
+
 
     /** RPFP solver base class. */
 
     class Solver {
-      
+
     public:
-      
+
         class Counterexample {
         private:
             RPFP *tree;
@@ -1148,18 +1149,18 @@ namespace Duality {
             Counterexample &operator=(const Counterexample &);
             Counterexample(const Counterexample &);
         };
-      
+
         /** Solve the problem. You can optionally give an old
             counterexample to use as a guide. This is chiefly useful for
             abstraction refinement metholdologies, and is only used as a
             heuristic. */
-      
+
         virtual bool Solve() = 0;
-      
+
         virtual Counterexample &GetCounterexample() = 0;
-      
+
         virtual bool SetOption(const std::string &option, const std::string &value) = 0;
-      
+
         /** Learn heuristic information from another solver. This
             is chiefly useful for abstraction refinement, when we want to
             solve a series of similar problems. */
@@ -1184,7 +1185,7 @@ namespace Duality {
 
         /** Object thrown on cancellation */
         struct Canceled {};
-      
+
         /** Object thrown on incompleteness */
         struct Incompleteness {};
     };
@@ -1235,16 +1236,16 @@ namespace Duality {
     public:
 
         /** appends assumption literals for edge to lits. if with_children is true,
-            includes that annotation of the edge's children. 
-        */ 
+            includes that annotation of the edge's children.
+        */
         void AssertEdgeCache(Edge *e, std::vector<Term> &lits, bool with_children = false);
-      
+
         /** appends assumption literals for node to lits */
         void AssertNodeCache(Node *, std::vector<Term> lits);
 
         /** check assumption lits, and return core */
         check_result CheckCore(const std::vector<Term> &assumps, std::vector<Term> &core);
-      
+
         /** Clone another RPFP into this one, keeping a map */
         void Clone(RPFP *other);
 
@@ -1287,7 +1288,7 @@ namespace Duality {
             uptr<solver> slvr;
         };
         hash_map<Edge *, edge_solver > edge_solvers;
-      
+
 #ifdef LIMIT_STACK_WEIGHT
         struct weight_counter {
             int val;
@@ -1296,7 +1297,7 @@ namespace Duality {
                 std::swap(val,other.val);
             }
         };
-      
+
         struct big_stack_entry {
             weight_counter weight_added;
             std::vector<expr> new_alits;
@@ -1319,11 +1320,11 @@ namespace Duality {
         void ConstrainEdgeLocalizedCache(Edge *e, const Term &tl, std::vector<expr> &lits);
 
         virtual void slvr_add(const expr &e);
-      
+
         virtual void slvr_pop(int i);
 
         virtual void slvr_push();
-      
+
         virtual check_result slvr_check(unsigned n = 0, expr * const assumptions = 0, unsigned *core_size = 0, expr *core = 0);
 
         virtual lbool ls_interpolate_tree(TermTree *assumptions,
@@ -1348,7 +1349,7 @@ namespace Duality {
             scoped_solver_for_edge(RPFP_caching *_rpfp, Edge *edge, bool models = false, bool axioms = false){
                 rpfp = _rpfp;
                 orig_slvr = rpfp->ls->slvr;
-                es = &(rpfp->SolverForEdge(edge,models,axioms)); 
+                es = &(rpfp->SolverForEdge(edge,models,axioms));
                 rpfp->ls->slvr = es->slvr.get();
                 rpfp->AssumptionLits.swap(es->AssumptionLits);
             }
diff --git a/src/duality/duality_wrapper.h b/src/duality/duality_wrapper.h
index 8ea8017a2..96c49b36b 100644
--- a/src/duality/duality_wrapper.h
+++ b/src/duality/duality_wrapper.h
@@ -176,7 +176,7 @@ namespace Duality {
             m_datalog_fid = m().mk_family_id("datalog_relation");
         }
         ~context() { }
-      
+
         ast_manager &m() const {return *(ast_manager *)&mgr;}
 
         void set(char const * param, char const * value) { m_config.set(param,value); }
@@ -186,13 +186,13 @@ namespace Duality {
 
         symbol str_symbol(char const * s);
         symbol int_symbol(int n);
-      
+
         sort bool_sort();
         sort int_sort();
         sort real_sort();
         sort bv_sort(unsigned sz);
         sort array_sort(sort d, sort r);
-      
+
         func_decl function(symbol const & name, unsigned arity, sort const * domain, sort const & range);
         func_decl function(char const * name, unsigned arity, sort const * domain, sort const & range);
         func_decl function(char const * name, sort const & domain, sort const & range);
@@ -210,22 +210,22 @@ namespace Duality {
         expr int_const(char const * name);
         expr real_const(char const * name);
         expr bv_const(char const * name, unsigned sz);
-      
+
         expr bool_val(bool b);
-      
+
         expr int_val(int n);
         expr int_val(unsigned n);
         expr int_val(char const * n);
-      
+
         expr real_val(int n, int d);
         expr real_val(int n);
         expr real_val(unsigned n);
         expr real_val(char const * n);
-      
+
         expr bv_val(int n, unsigned sz);
         expr bv_val(unsigned n, unsigned sz);
         expr bv_val(char const * n, unsigned sz);
-      
+
         expr num_val(int n, sort const & s);
 
         expr mki(family_id fid, ::decl_kind dk, int n, ::expr **args);
@@ -281,17 +281,17 @@ namespace Duality {
     object(object const & s):m_ctx(s.m_ctx) {}
         context & ctx() const { return *m_ctx; }
         friend void check_context(object const & a, object const & b) { assert(a.m_ctx == b.m_ctx); }
-	ast_manager &m() const {return m_ctx->m();}
+        ast_manager &m() const {return m_ctx->m();}
     };
 
     class symbol : public object {
         ::symbol m_sym;
     public:
-    symbol(context & c, ::symbol s):object(c), m_sym(s) {}
-    symbol(symbol const & s):object(s), m_sym(s.m_sym) {}
+        symbol(context & c, ::symbol s):object(c), m_sym(s) {}
+        symbol(symbol const & s):object(s), m_sym(s.m_sym) {}
         symbol & operator=(symbol const & s) { m_ctx = s.m_ctx; m_sym = s.m_sym; return *this; }
-	operator ::symbol() const {return m_sym;} 
-	std::string str() const {
+        operator ::symbol() const {return m_sym;}
+        std::string str() const {
             if (m_sym.is_numerical()) {
                 std::ostringstream buffer;
                 buffer << m_sym.get_num();
@@ -300,13 +300,13 @@ namespace Duality {
             else {
                 return m_sym.bare_str();
             }
-	}
-        friend std::ostream & operator<<(std::ostream & out, symbol const & s){
+        }
+        friend std::ostream & operator<<(std::ostream & out, symbol const & s) {
             return out << s.str();
-	}
-	friend bool operator==(const symbol &x, const symbol &y){
+        }
+        friend bool operator==(const symbol &x, const symbol &y) {
             return x.m_sym == y.m_sym;
-	}
+        }
     };
 
     class params : public config {};
@@ -318,7 +318,7 @@ namespace Duality {
     public:
         ::ast * const &raw() const {return _ast;}
     ast_i(context & c, ::ast *a = 0) : object(c) {_ast = a;}
-      
+
         ast_i(){_ast = 0;}
         bool eq(const ast_i &other) const {
             return _ast == other._ast;
@@ -345,19 +345,19 @@ namespace Duality {
         operator ::ast*() const { return raw(); }
         friend bool eq(ast const & a, ast const & b) { return a.raw() == b.raw(); }
 
-      
+
     ast(context &c, ::ast *a = 0) : ast_i(c,a) {
             if(_ast)
                 m().inc_ref(a);
         }
-      
+
         ast() {}
-      
+
     ast(const ast &other) : ast_i(other) {
             if(_ast)
                 m().inc_ref(_ast);
         }
-      
+
         ast &operator=(const ast &other) {
             if(_ast)
                 m().dec_ref(_ast);
@@ -367,7 +367,7 @@ namespace Duality {
                 m().inc_ref(_ast);
             return *this;
         }
-      
+
         ~ast(){
             if(_ast)
                 m().dec_ref(_ast);
@@ -386,15 +386,15 @@ namespace Duality {
         sort & operator=(sort const & s) { return static_cast<sort&>(ast::operator=(s)); }
 
         bool is_bool() const { return m().is_bool(*this); }
-        bool is_int() const { return ctx().get_sort_kind(*this) == IntSort; } 
-        bool is_real() const { return ctx().get_sort_kind(*this) == RealSort; } 
+        bool is_int() const { return ctx().get_sort_kind(*this) == IntSort; }
+        bool is_real() const { return ctx().get_sort_kind(*this) == RealSort; }
         bool is_arith() const;
-        bool is_array() const { return ctx().get_sort_kind(*this) == ArraySort; } 
-        bool is_datatype() const; 
-        bool is_relation() const; 
-        bool is_finite_domain() const; 
+        bool is_array() const { return ctx().get_sort_kind(*this) == ArraySort; }
+        bool is_datatype() const;
+        bool is_relation() const;
+        bool is_finite_domain() const;
+
 
-      
         sort array_domain() const;
         sort array_range() const;
 
@@ -404,7 +404,7 @@ namespace Duality {
         }
     };
 
-    
+
     class func_decl : public ast {
     public:
     func_decl() : ast() {}
@@ -413,7 +413,7 @@ namespace Duality {
     func_decl(func_decl const & s):ast(s) {}
         operator ::func_decl*() const { return to_func_decl(*this); }
         func_decl & operator=(func_decl const & s) { return static_cast<func_decl&>(ast::operator=(s)); }
-        
+
         unsigned arity() const;
         sort domain(unsigned i) const;
         sort range() const;
@@ -434,9 +434,9 @@ namespace Duality {
         expr operator()(expr const & a1, expr const & a2, expr const & a3, expr const & a4) const;
         expr operator()(expr const & a1, expr const & a2, expr const & a3, expr const & a4, expr const & a5) const;
 
-	func_decl get_func_decl_parameter(unsigned idx){
+        func_decl get_func_decl_parameter(unsigned idx){
             return func_decl(ctx(),to_func_decl(to_func_decl(raw())->get_parameters()[idx].get_ast()));
-	}
+        }
 
     };
 
@@ -447,8 +447,8 @@ namespace Duality {
     expr(context & c, ::ast *n):ast(c, n) {}
     expr(expr const & n):ast(n) {}
         expr & operator=(expr const & n) { return static_cast<expr&>(ast::operator=(n)); }
-	operator ::expr*() const { return to_expr(raw()); }
-	unsigned get_id() const {return to_expr(raw())->get_id();}
+        operator ::expr*() const { return to_expr(raw()); }
+        unsigned get_id() const {return to_expr(raw())->get_id();}
 
         sort get_sort() const { return sort(ctx(),m().get_sort(to_expr(raw()))); }
 
@@ -460,27 +460,27 @@ namespace Duality {
         bool is_datatype() const { return get_sort().is_datatype(); }
         bool is_relation() const { return get_sort().is_relation(); }
         bool is_finite_domain() const { return get_sort().is_finite_domain(); }
-	bool is_true() const {return is_app() && decl().get_decl_kind() == True; }
+        bool is_true() const {return is_app() && decl().get_decl_kind() == True; }
 
         bool is_numeral() const {
             return is_app() && decl().get_decl_kind() == OtherArith && m().is_unique_value(to_expr(raw()));
-	}
-	bool is_app() const {return raw()->get_kind() == AST_APP;}
+        }
+        bool is_app() const {return raw()->get_kind() == AST_APP;}
         bool is_quantifier() const {return raw()->get_kind() == AST_QUANTIFIER;}
         bool is_var() const {return raw()->get_kind() == AST_VAR;}
-	bool is_label (bool &pos,std::vector<symbol> &names) const ;
-	bool is_ground() const {return to_app(raw())->is_ground();}
-	bool has_quantifiers() const {return to_app(raw())->has_quantifiers();}
-	bool has_free(int idx) const {
+        bool is_label (bool &pos,std::vector<symbol> &names) const ;
+        bool is_ground() const {return to_app(raw())->is_ground();}
+        bool has_quantifiers() const {return to_app(raw())->has_quantifiers();}
+        bool has_free(int idx) const {
             used_vars proc;
             proc.process(to_expr(raw()));
             return proc.contains(idx);
-	}
-	unsigned get_max_var_idx_plus_1() const {
+        }
+        unsigned get_max_var_idx_plus_1() const {
             used_vars proc;
             proc.process(to_expr(raw()));
             return proc.get_max_found_var_idx_plus_1();
-	}
+        }
 
         // operator Z3_app() const { assert(is_app()); return reinterpret_cast<Z3_app>(m_ast); }
         func_decl decl() const {return func_decl(ctx(),to_app(raw())->get_decl());}
@@ -493,11 +493,11 @@ namespace Duality {
                 return 1;
             case AST_VAR:
                 return 0;
-            default:;    
+            default:;
             }
             SASSERT(0);
             return 0;
-	}
+        }
         expr arg(unsigned i) const {
             ast_kind dk = raw()->get_kind();
             switch(dk){
@@ -509,25 +509,25 @@ namespace Duality {
             }
             assert(0);
             return expr();
-	}
+        }
 
         expr body() const {
             return ctx().cook(to_quantifier(raw())->get_expr());
-	}
+        }
 
         friend expr operator!(expr const & a) {
             // ::expr *e = a;
             return expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_NOT,a));
-	}
+        }
 
         friend expr operator&&(expr const & a, expr const & b) {
             return expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_AND,a,b));
-	}
+        }
 
         friend expr operator||(expr const & a, expr const & b) {
             return expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_OR,a,b));
         }
-        
+
         friend expr implies(expr const & a, expr const & b) {
             return expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_IMPLIES,a,b));
         }
@@ -546,12 +546,12 @@ namespace Duality {
 
         friend expr operator*(expr const & a, expr const & b) {
             return a.ctx().make(Times,a,b); // expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_MUL,a,b));
-	}
+        }
 
         friend expr operator/(expr const & a, expr const & b) {
             return a.ctx().make(Div,a,b); //  expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_DIV,a,b));
         }
-	
+
         friend expr operator-(expr const & a) {
             return a.ctx().make(Uminus,a); // expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_UMINUS,a));
         }
@@ -562,71 +562,71 @@ namespace Duality {
 
         friend expr operator<=(expr const & a, expr const & b) {
             return a.ctx().make(Leq,a,b); // expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_LE,a,b));
-	}
+        }
 
         friend expr operator>=(expr const & a, expr const & b) {
             return a.ctx().make(Geq,a,b); //expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_GE,a,b));
         }
-	
+
         friend expr operator<(expr const & a, expr const & b) {
             return a.ctx().make(Lt,a,b); expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_LT,a,b));
         }
-        
+
         friend expr operator>(expr const & a, expr const & b) {
             return a.ctx().make(Gt,a,b); expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_GT,a,b));
-	}
+        }
 
         expr simplify() const;
 
         expr simplify(params const & p) const;
-	
+
         expr qe_lite() const;
 
-	expr qe_lite(const std::set<int> &idxs, bool index_of_bound) const;
+        expr qe_lite(const std::set<int> &idxs, bool index_of_bound) const;
 
-	friend expr clone_quantifier(const expr &, const expr &);
+        friend expr clone_quantifier(const expr &, const expr &);
 
         friend expr clone_quantifier(const expr &q, const expr &b, const std::vector<expr> &patterns);
 
-	friend expr clone_quantifier(decl_kind, const expr &, const expr &);
+        friend expr clone_quantifier(decl_kind, const expr &, const expr &);
 
         friend std::ostream & operator<<(std::ostream & out, expr const & m){
             m.ctx().print_expr(out,m);
             return out;
-	}
+        }
 
-	void get_patterns(std::vector<expr> &pats) const ;
+        void get_patterns(std::vector<expr> &pats) const ;
 
-	unsigned get_quantifier_num_bound() const {
+        unsigned get_quantifier_num_bound() const {
             return to_quantifier(raw())->get_num_decls();
-	}
+        }
 
-	unsigned get_index_value() const {
+        unsigned get_index_value() const {
             var* va = to_var(raw());
             return va->get_idx();
-	}
+        }
 
         bool is_quantifier_forall() const {
             return to_quantifier(raw())->is_forall();
-	}
+        }
 
-	sort get_quantifier_bound_sort(unsigned n) const {
+        sort get_quantifier_bound_sort(unsigned n) const {
             return sort(ctx(),to_quantifier(raw())->get_decl_sort(n));
-	}
+        }
 
-	symbol get_quantifier_bound_name(unsigned n) const {
+        symbol get_quantifier_bound_name(unsigned n) const {
             return symbol(ctx(),to_quantifier(raw())->get_decl_names()[n]);
-	}
+        }
 
-	friend expr forall(const std::vector<expr> &quants, const expr &body);
+        friend expr forall(const std::vector<expr> &quants, const expr &body);
 
-	friend expr exists(const std::vector<expr> &quants, const expr &body);
+        friend expr exists(const std::vector<expr> &quants, const expr &body);
 
     };
-    
+
 
     typedef ::decl_kind pfrule;
-    
+
     class proof : public ast {
     public:
     proof(context & c):ast(c) {}
@@ -643,15 +643,15 @@ namespace Duality {
         unsigned num_prems() const {
             return to_app(raw())->get_num_args() - 1;
         }
-      
+
         expr conc() const {
             return ctx().cook(to_app(raw())->get_arg(num_prems()));
         }
-      
+
         proof prem(unsigned i) const {
             return proof(ctx(),to_app(to_app(raw())->get_arg(i)));
         }
-      
+
         void get_assumptions(std::vector<expr> &assumps);
     };
 
@@ -675,12 +675,12 @@ namespace Duality {
         T back() const { return operator[](size() - 1); }
         void pop_back() { assert(size() > 0); resize(size() - 1); }
         bool empty() const { return size() == 0; }
-        ast_vector_tpl & operator=(ast_vector_tpl const & s) { 
-            Z3_ast_vector_inc_ref(s.ctx(), s.m_vector); 
+        ast_vector_tpl & operator=(ast_vector_tpl const & s) {
+            Z3_ast_vector_inc_ref(s.ctx(), s.m_vector);
             // Z3_ast_vector_dec_ref(ctx(), m_vector);
-            m_ctx = s.m_ctx; 
+            m_ctx = s.m_ctx;
             m_vector = s.m_vector;
-            return *this; 
+            return *this;
         }
         friend std::ostream & operator<<(std::ostream & out, ast_vector_tpl const & v) { out << Z3_ast_vector_to_string(v.ctx(), v); return out; }
     };
@@ -705,9 +705,9 @@ namespace Duality {
         ~func_interp() { }
         operator ::func_interp *() const { return m_interp; }
         func_interp & operator=(func_interp const & s) {
-            m_ctx = s.m_ctx; 
+            m_ctx = s.m_ctx;
             m_interp = s.m_interp;
-            return *this; 
+            return *this;
         }
         unsigned num_entries() const { return m_interp->num_entries(); }
         expr get_arg(unsigned ent, unsigned arg) const {
@@ -729,32 +729,32 @@ namespace Duality {
             m_model = m;
         }
     public:
-    model(context & c, ::model * m = 0):object(c), m_model(m) { }
-    model(model const & s):object(s), m_model(s.m_model) { }
-	~model() { }
+        model(context & c, ::model * m = 0):object(c), m_model(m) { }
+        model(model const & s):object(s), m_model(s.m_model) { }
+        ~model() { }
         operator ::model *() const { return m_model.get(); }
         model & operator=(model const & s) {
             // ::model *_inc_ref(s.ctx(), s.m_model);
             // ::model *_dec_ref(ctx(), m_model);
-            m_ctx = s.m_ctx; 
+            m_ctx = s.m_ctx;
             m_model = s.m_model.get();
-            return *this; 
+            return *this;
         }
         model & operator=(::model *s) {
-  	    m_model = s;
-            return *this; 
+            m_model = s;
+            return *this;
         }
-	bool null() const {return !m_model;}
-        
+        bool null() const {return !m_model;}
+
         expr eval(expr const & n, bool model_completion=true) const {
             ::model * _m = m_model.get();
             expr_ref result(ctx().m());
             _m->eval(n, result, model_completion);
             return expr(ctx(), result);
         }
-        
+
         void show() const;
-	void show_hash() const;
+        void show_hash() const;
 
         unsigned num_consts() const {return m_model.get()->get_num_constants();}
         unsigned num_funcs() const {return m_model.get()->get_num_functions();}
@@ -765,11 +765,11 @@ namespace Duality {
 
         expr get_const_interp(func_decl f) const {
             return ctx().cook(m_model->get_const_interp(to_func_decl(f.raw())));
-	}
+        }
 
         func_interp get_func_interp(func_decl f) const {
             return func_interp(ctx(),m_model->get_func_interp(to_func_decl(f.raw())));
-	} 
+        }
 
 #if 0
         friend std::ostream & operator<<(std::ostream & out, model const & m) { out << Z3_model_to_string(m.ctx(), m); return out; }
@@ -792,9 +792,9 @@ namespace Duality {
         stats & operator=(stats const & s) {
             Z3_stats_inc_ref(s.ctx(), s.m_stats);
             if (m_stats) Z3_stats_dec_ref(ctx(), m_stats);
-            m_ctx = s.m_ctx; 
+            m_ctx = s.m_ctx;
             m_stats = s.m_stats;
-            return *this; 
+            return *this;
         }
         unsigned size() const { return Z3_stats_size(ctx(), m_stats); }
         std::string key(unsigned i) const { Z3_string s = Z3_stats_get_key(ctx(), m_stats, i); check_error(); return s; }
@@ -820,7 +820,7 @@ namespace Duality {
         void assert_cnst(const expr &cnst);
     };
 
-    inline std::ostream & operator<<(std::ostream & out, check_result r) { 
+    inline std::ostream & operator<<(std::ostream & out, check_result r) {
         if (r == unsat) out << "unsat";
         else if (r == sat) out << "sat";
         else out << "unknown";
@@ -837,54 +837,54 @@ namespace Duality {
     protected:
         ::solver *m_solver;
         model the_model;
-	bool canceled;
-	proof_gen_mode m_mode;
-	bool extensional;
+        bool canceled;
+        proof_gen_mode m_mode;
+        bool extensional;
     public:
         solver(context & c, bool extensional = false, bool models = true);
-    solver(context & c, ::solver *s):object(c),the_model(c) { m_solver = s; canceled = false;}
-    solver(solver const & s):object(s), the_model(s.the_model) { m_solver = s.m_solver; canceled = false;}
+        solver(context & c, ::solver *s):object(c),the_model(c) { m_solver = s; canceled = false;}
+        solver(solver const & s):object(s), the_model(s.the_model) { m_solver = s.m_solver; canceled = false;}
         ~solver() {
             if(m_solver)
                 dealloc(m_solver);
-	}
-	operator ::solver*() const { return m_solver; }
-        solver & operator=(solver const & s) {
-            m_ctx = s.m_ctx; 
-            m_solver = s.m_solver;
-	    the_model = s.the_model;
-	    m_mode = s.m_mode;
-            return *this; 
         }
-	struct cancel_exception {};
-	void checkpoint(){
+        operator ::solver*() const { return m_solver; }
+        solver & operator=(solver const & s) {
+            m_ctx = s.m_ctx;
+            m_solver = s.m_solver;
+            the_model = s.the_model;
+            m_mode = s.m_mode;
+            return *this;
+        }
+        struct cancel_exception {};
+        void checkpoint(){
             if(canceled)
                 throw(cancel_exception());
-	}
+        }
         // void set(params const & p) { Z3_solver_set_params(ctx(), m_solver, p); check_error(); }
         void push() { scoped_proof_mode spm(m(),m_mode); m_solver->push(); }
         void pop(unsigned n = 1) { scoped_proof_mode spm(m(),m_mode); m_solver->pop(n); }
         // void reset() { Z3_solver_reset(ctx(), m_solver); check_error(); }
         void add(expr const & e) { scoped_proof_mode spm(m(),m_mode); m_solver->assert_expr(e); }
-        check_result check() { 
-            scoped_proof_mode spm(m(),m_mode); 
+        check_result check() {
+            scoped_proof_mode spm(m(),m_mode);
             checkpoint();
             lbool r = m_solver->check_sat(0,0);
             model_ref m;
             m_solver->get_model(m);
             the_model = m.get();
             return to_check_result(r);
-	}
-        check_result check_keep_model(unsigned n, expr * const assumptions, unsigned *core_size = 0, expr *core = 0) { 
-            scoped_proof_mode spm(m(),m_mode); 
+        }
+        check_result check_keep_model(unsigned n, expr * const assumptions, unsigned *core_size = 0, expr *core = 0) {
+            scoped_proof_mode spm(m(),m_mode);
             model old_model(the_model);
             check_result res = check(n,assumptions,core_size,core);
             if(the_model == 0)
                 the_model = old_model;
             return res;
-	}
+        }
         check_result check(unsigned n, expr * const assumptions, unsigned *core_size = 0, expr *core = 0) {
-            scoped_proof_mode spm(m(),m_mode); 
+            scoped_proof_mode spm(m(),m_mode);
             checkpoint();
             std::vector< ::expr *> _assumptions(n);
             for (unsigned i = 0; i < n; i++) {
@@ -892,7 +892,7 @@ namespace Duality {
             }
             the_model = 0;
             lbool r = m_solver->check_sat(n, VEC2PTR(_assumptions));
-	  
+
             if(core_size && core){
                 ptr_vector< ::expr> _core;
                 m_solver->get_unsat_core(_core);
@@ -905,20 +905,20 @@ namespace Duality {
             m_solver->get_model(m);
             the_model = m.get();
 
-            return to_check_result(r); 
+            return to_check_result(r);
         }
 #if 0
-        check_result check(expr_vector assumptions) { 
-            scoped_proof_mode spm(m(),m_mode); 
+        check_result check(expr_vector assumptions) {
+            scoped_proof_mode spm(m(),m_mode);
             unsigned n = assumptions.size();
             z3array<Z3_ast> _assumptions(n);
             for (unsigned i = 0; i < n; i++) {
                 check_context(*this, assumptions[i]);
                 _assumptions[i] = assumptions[i];
             }
-            Z3_lbool r = Z3_check_assumptions(ctx(), m_solver, n, _assumptions.ptr()); 
-            check_error(); 
-            return to_check_result(r); 
+            Z3_lbool r = Z3_check_assumptions(ctx(), m_solver, n, _assumptions.ptr());
+            check_error();
+            return to_check_result(r);
         }
 #endif
         model get_model() const { return model(ctx(), the_model); }
@@ -930,27 +930,26 @@ namespace Duality {
 #endif
         // expr proof() const { Z3_ast r = Z3_solver_proof(ctx(), m_solver); check_error(); return expr(ctx(), r); }
         // friend std::ostream & operator<<(std::ostream & out, solver const & s) { out << Z3_solver_to_string(s.ctx(), s); return out; }
-	
-	int get_num_decisions(); 
+        int get_num_decisions();
 
-	void cancel(){
-            scoped_proof_mode spm(m(),m_mode); 
+        void cancel(){
+            scoped_proof_mode spm(m(),m_mode);
             canceled = true;
             m().limit().cancel();
-	}
+        }
 
-	unsigned get_scope_level(){ scoped_proof_mode spm(m(),m_mode); return m_solver->get_scope_level();}
+        unsigned get_scope_level(){ scoped_proof_mode spm(m(),m_mode); return m_solver->get_scope_level();}
 
-	void show();
-	void print(const char *filename);
-	void show_assertion_ids();
+        void show();
+        void print(const char *filename);
+        void show_assertion_ids();
 
-	proof get_proof(){
-            scoped_proof_mode spm(m(),m_mode); 
+        proof get_proof(){
+            scoped_proof_mode spm(m(),m_mode);
             return proof(ctx(),m_solver->get_proof());
-	}
+        }
 
-	bool extensional_array_theory() {return extensional;}
+        bool extensional_array_theory() {return extensional;}
     };
 
 #if 0
@@ -969,20 +968,20 @@ namespace Duality {
         goal & operator=(goal const & s) {
             Z3_goal_inc_ref(s.ctx(), s.m_goal);
             Z3_goal_dec_ref(ctx(), m_goal);
-            m_ctx = s.m_ctx; 
+            m_ctx = s.m_ctx;
             m_goal = s.m_goal;
-            return *this; 
+            return *this;
         }
         void add(expr const & f) { check_context(*this, f); Z3_goal_assert(ctx(), m_goal, f); check_error(); }
         unsigned size() const { return Z3_goal_size(ctx(), m_goal); }
         expr operator[](unsigned i) const { Z3_ast r = Z3_goal_formula(ctx(), m_goal, i); check_error(); return expr(ctx(), r); }
         Z3_goal_prec precision() const { return Z3_goal_precision(ctx(), m_goal); }
         bool inconsistent() const { return Z3_goal_inconsistent(ctx(), m_goal) != 0; }
-        unsigned depth() const { return Z3_goal_depth(ctx(), m_goal); } 
+        unsigned depth() const { return Z3_goal_depth(ctx(), m_goal); }
         void reset() { Z3_goal_reset(ctx(), m_goal); }
         unsigned num_exprs() const { Z3_goal_num_exprs(ctx(), m_goal); }
-        bool is_decided_sat() const { return Z3_goal_is_decided_sat(ctx(), m_goal) != 0; }        
-        bool is_decided_unsat() const { return Z3_goal_is_decided_unsat(ctx(), m_goal) != 0; }        
+        bool is_decided_sat() const { return Z3_goal_is_decided_sat(ctx(), m_goal) != 0; }
+        bool is_decided_unsat() const { return Z3_goal_is_decided_unsat(ctx(), m_goal) != 0; }
         friend std::ostream & operator<<(std::ostream & out, goal const & g) { out << Z3_goal_to_string(g.ctx(), g); return out; }
     };
 
@@ -1000,15 +999,15 @@ namespace Duality {
         apply_result & operator=(apply_result const & s) {
             Z3_apply_result_inc_ref(s.ctx(), s.m_apply_result);
             Z3_apply_result_dec_ref(ctx(), m_apply_result);
-            m_ctx = s.m_ctx; 
+            m_ctx = s.m_ctx;
             m_apply_result = s.m_apply_result;
-            return *this; 
+            return *this;
         }
         unsigned size() const { return Z3_apply_result_get_num_subgoals(ctx(), m_apply_result); }
         goal operator[](unsigned i) const { Z3_goal r = Z3_apply_result_get_subgoal(ctx(), m_apply_result, i); check_error(); return goal(ctx(), r); }
         goal operator[](int i) const { assert(i >= 0); return this->operator[](static_cast<unsigned>(i)); }
-        model convert_model(model const & m, unsigned i = 0) const { 
-            check_context(*this, m); 
+        model convert_model(model const & m, unsigned i = 0) const {
+            check_context(*this, m);
             Z3_model new_m = Z3_apply_result_convert_model(ctx(), m_apply_result, i, m);
             check_error();
             return model(ctx(), new_m);
@@ -1031,16 +1030,16 @@ namespace Duality {
         tactic & operator=(tactic const & s) {
             Z3_tactic_inc_ref(s.ctx(), s.m_tactic);
             Z3_tactic_dec_ref(ctx(), m_tactic);
-            m_ctx = s.m_ctx; 
+            m_ctx = s.m_ctx;
             m_tactic = s.m_tactic;
-            return *this; 
+            return *this;
         }
         solver mk_solver() const { Z3_solver r = Z3_mk_solver_from_tactic(ctx(), m_tactic); check_error(); return solver(ctx(), r);  }
-        apply_result apply(goal const & g) const { 
+        apply_result apply(goal const & g) const {
             check_context(*this, g);
-            Z3_apply_result r = Z3_tactic_apply(ctx(), m_tactic, g); 
-            check_error(); 
-            return apply_result(ctx(), r); 
+            Z3_apply_result r = Z3_tactic_apply(ctx(), m_tactic, g);
+            check_error();
+            return apply_result(ctx(), r);
         }
         apply_result operator()(goal const & g) const {
             return apply(g);
@@ -1091,45 +1090,45 @@ namespace Duality {
         probe & operator=(probe const & s) {
             Z3_probe_inc_ref(s.ctx(), s.m_probe);
             Z3_probe_dec_ref(ctx(), m_probe);
-            m_ctx = s.m_ctx; 
+            m_ctx = s.m_ctx;
             m_probe = s.m_probe;
-            return *this; 
+            return *this;
         }
         double apply(goal const & g) const { double r = Z3_probe_apply(ctx(), m_probe, g); check_error(); return r; }
         double operator()(goal const & g) const { return apply(g); }
-        friend probe operator<=(probe const & p1, probe const & p2) { 
-            check_context(p1, p2); Z3_probe r = Z3_probe_le(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r); 
+        friend probe operator<=(probe const & p1, probe const & p2) {
+            check_context(p1, p2); Z3_probe r = Z3_probe_le(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
         }
         friend probe operator<=(probe const & p1, double p2) { return p1 <= probe(p1.ctx(), p2); }
         friend probe operator<=(double p1, probe const & p2) { return probe(p2.ctx(), p1) <= p2; }
-        friend probe operator>=(probe const & p1, probe const & p2) { 
-            check_context(p1, p2); Z3_probe r = Z3_probe_ge(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r); 
+        friend probe operator>=(probe const & p1, probe const & p2) {
+            check_context(p1, p2); Z3_probe r = Z3_probe_ge(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
         }
         friend probe operator>=(probe const & p1, double p2) { return p1 >= probe(p1.ctx(), p2); }
         friend probe operator>=(double p1, probe const & p2) { return probe(p2.ctx(), p1) >= p2; }
-        friend probe operator<(probe const & p1, probe const & p2) { 
-            check_context(p1, p2); Z3_probe r = Z3_probe_lt(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r); 
+        friend probe operator<(probe const & p1, probe const & p2) {
+            check_context(p1, p2); Z3_probe r = Z3_probe_lt(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
         }
         friend probe operator<(probe const & p1, double p2) { return p1 < probe(p1.ctx(), p2); }
         friend probe operator<(double p1, probe const & p2) { return probe(p2.ctx(), p1) < p2; }
-        friend probe operator>(probe const & p1, probe const & p2) { 
-            check_context(p1, p2); Z3_probe r = Z3_probe_gt(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r); 
+        friend probe operator>(probe const & p1, probe const & p2) {
+            check_context(p1, p2); Z3_probe r = Z3_probe_gt(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
         }
         friend probe operator>(probe const & p1, double p2) { return p1 > probe(p1.ctx(), p2); }
         friend probe operator>(double p1, probe const & p2) { return probe(p2.ctx(), p1) > p2; }
-        friend probe operator==(probe const & p1, probe const & p2) { 
-            check_context(p1, p2); Z3_probe r = Z3_probe_eq(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r); 
+        friend probe operator==(probe const & p1, probe const & p2) {
+            check_context(p1, p2); Z3_probe r = Z3_probe_eq(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
         }
         friend probe operator==(probe const & p1, double p2) { return p1 == probe(p1.ctx(), p2); }
         friend probe operator==(double p1, probe const & p2) { return probe(p2.ctx(), p1) == p2; }
-        friend probe operator&&(probe const & p1, probe const & p2) { 
-            check_context(p1, p2); Z3_probe r = Z3_probe_and(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r); 
+        friend probe operator&&(probe const & p1, probe const & p2) {
+            check_context(p1, p2); Z3_probe r = Z3_probe_and(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
         }
-        friend probe operator||(probe const & p1, probe const & p2) { 
-            check_context(p1, p2); Z3_probe r = Z3_probe_or(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r); 
+        friend probe operator||(probe const & p1, probe const & p2) {
+            check_context(p1, p2); Z3_probe r = Z3_probe_or(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
         }
         friend probe operator!(probe const & p) {
-            Z3_probe r = Z3_probe_not(p.ctx(), p); p.check_error(); return probe(p.ctx(), r); 
+            Z3_probe r = Z3_probe_not(p.ctx(), p); p.check_error(); return probe(p.ctx(), r);
         }
     };
 
@@ -1159,15 +1158,15 @@ namespace Duality {
     inline symbol context::int_symbol(int n) { ::symbol r = ::symbol(n); return symbol(*this, r); }
 
     inline sort context::bool_sort() {
-        ::sort *s = m().mk_sort(m_basic_fid, BOOL_SORT); 
+        ::sort *s = m().mk_sort(m_basic_fid, BOOL_SORT);
         return sort(*this, s);
     }
     inline sort context::int_sort()  {
-        ::sort *s = m().mk_sort(m_arith_fid, INT_SORT); 
+        ::sort *s = m().mk_sort(m_arith_fid, INT_SORT);
         return sort(*this, s);
     }
     inline sort context::real_sort()  {
-        ::sort *s = m().mk_sort(m_arith_fid, REAL_SORT); 
+        ::sort *s = m().mk_sort(m_arith_fid, REAL_SORT);
         return sort(*this, s);
     }
     inline sort context::array_sort(sort d, sort r) {
@@ -1188,7 +1187,7 @@ namespace Duality {
     inline func_decl context::function(char const * name, unsigned arity, sort const * domain, sort const & range) {
         return function(str_symbol(name), arity, domain, range);
     }
-    
+
     inline func_decl context::function(char const * name, sort const & domain, sort const & range) {
         sort args[1] = { domain };
         return function(name, 1, args, range);
@@ -1196,7 +1195,7 @@ namespace Duality {
 
     inline func_decl context::function(char const * name, sort const & d1, sort const & d2, sort const & range) {
         sort args[2] = { d1, d2 };
-	return function(name, 2, args, range);
+        return function(name, 2, args, range);
     }
 
     inline func_decl context::function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & range) {
@@ -1208,7 +1207,7 @@ namespace Duality {
         sort args[4] = { d1, d2, d3, d4 };
         return function(name, 4, args, range);
     }
-    
+
     inline func_decl context::function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & d4, sort const & d5, sort const & range) {
         sort args[5] = { d1, d2, d3, d4, d5 };
         return function(name, 5, args, range);
@@ -1217,7 +1216,7 @@ namespace Duality {
 
     inline expr context::constant(symbol const & name, sort const & s) {
         ::expr *r = m().mk_const(m().mk_const_decl(name, s));
-        return expr(*this, r); 
+        return expr(*this, r);
     }
     inline expr context::constant(char const * name, sort const & s) { return constant(str_symbol(name), s); }
     inline expr context::bool_const(char const * name) { return constant(name, bool_sort()); }
@@ -1250,11 +1249,11 @@ namespace Duality {
         expr args[5] = {a1,a2,a3,a4,a5};
         return operator()(5,args);
     }
-    
-    
+
+
     inline expr select(expr const & a, expr const & i) { return a.ctx().make(Select,a,i); }
     inline expr store(expr const & a, expr const & i, expr const & v) { return a.ctx().make(Store,a,i,v); }
-    
+
     inline expr forall(const std::vector<expr> &quants, const expr &body){
         return body.ctx().make_quant(Forall,quants,body);
     }
@@ -1304,7 +1303,7 @@ namespace Duality {
         }
 
         inline void setTerm(expr t){term = t;}
-      
+
         inline void addTerm(expr t){terms.push_back(t);}
 
         inline void setChildren(const std::vector<TermTree *> & _children){
@@ -1326,7 +1325,7 @@ namespace Duality {
         std::vector<TermTree *> children;
         int num;
     };
-    
+
     typedef context interpolating_context;
 
     class interpolating_solver : public solver {
@@ -1336,7 +1335,7 @@ namespace Duality {
             {
                 weak_mode = false;
             }
-      
+
     public:
         lbool interpolate(const std::vector<expr> &assumptions,
                           std::vector<expr> &interpolants,
@@ -1344,41 +1343,41 @@ namespace Duality {
                           literals &lits,
                           bool incremental
                           );
-      
+
         lbool interpolate_tree(TermTree *assumptions,
                                TermTree *&interpolants,
                                model &_model,
                                literals &lits,
                                bool incremental
                                );
-      
+
         bool read_interpolation_problem(const std::string &file_name,
                                         std::vector<expr> &assumptions,
                                         std::vector<expr> &theory,
                                         std::string &error_message
                                         );
-      
+
         void write_interpolation_problem(const std::string &file_name,
                                          const std::vector<expr> &assumptions,
                                          const std::vector<expr> &theory
                                          );
-      
+
         void AssertInterpolationAxiom(const expr &expr);
         void RemoveInterpolationAxiom(const expr &expr);
-      
+
         void SetWeakInterpolants(bool weak);
         void SetPrintToFile(const std::string &file_name);
-      
+
         const std::vector<expr> &GetInterpolationAxioms() {return theory;}
         const char *profile();
-      
+
     private:
         bool weak_mode;
         std::string print_filename;
         std::vector<expr> theory;
     };
-    
-    
+
+
     inline expr context::cook(::expr *a) {return expr(*this,a);}
 
     inline std::vector<expr> context::cook(ptr_vector< ::expr> v) {
diff --git a/src/interp/iz3base.h b/src/interp/iz3base.h
index ac171aa9e..15f613730 100755
--- a/src/interp/iz3base.h
+++ b/src/interp/iz3base.h
@@ -66,35 +66,35 @@ class iz3base : public iz3mgr, public scopes {
 
     /** Constructor */
 
- iz3base(ast_manager &_m_manager,
-	 const std::vector<ast> &_cnsts,
-	 const std::vector<int> &_parents,
-	 const std::vector<ast> &_theory)
-     : iz3mgr(_m_manager), scopes(_parents)  {
+    iz3base(ast_manager &_m_manager,
+            const std::vector<ast> &_cnsts,
+            const std::vector<int> &_parents,
+            const std::vector<ast> &_theory)
+        : iz3mgr(_m_manager), scopes(_parents)  {
         initialize(_cnsts,_parents,_theory);
         weak = false;
     }
 
- iz3base(const iz3mgr& other,
-	 const std::vector<ast> &_cnsts,
-	 const std::vector<int> &_parents,
-	 const std::vector<ast> &_theory)
-     : iz3mgr(other), scopes(_parents)  {
+    iz3base(const iz3mgr& other,
+            const std::vector<ast> &_cnsts,
+            const std::vector<int> &_parents,
+            const std::vector<ast> &_theory)
+        : iz3mgr(other), scopes(_parents)  {
         initialize(_cnsts,_parents,_theory);
         weak = false;
     }
 
- iz3base(const iz3mgr& other,
-         const std::vector<std::vector<ast> > &_cnsts,
-	 const std::vector<int> &_parents,
-	 const std::vector<ast> &_theory)
-     : iz3mgr(other), scopes(_parents)  {
+    iz3base(const iz3mgr& other,
+            const std::vector<std::vector<ast> > &_cnsts,
+            const std::vector<int> &_parents,
+            const std::vector<ast> &_theory)
+        : iz3mgr(other), scopes(_parents)  {
         initialize(_cnsts,_parents,_theory);
         weak = false;
     }
 
- iz3base(const iz3mgr& other)
-     : iz3mgr(other), scopes()  {
+    iz3base(const iz3mgr& other)
+        : iz3mgr(other), scopes()  {
         weak = false;
     }
 
diff --git a/src/interp/iz3checker.h b/src/interp/iz3checker.h
index 175b5a43a..d89db3011 100644
--- a/src/interp/iz3checker.h
+++ b/src/interp/iz3checker.h
@@ -24,26 +24,26 @@
 #include "solver/solver.h"
 
 bool iz3check(ast_manager &_m_manager,
-	      solver *s,
-	      std::ostream &err,
-	      const ptr_vector<ast> &cnsts,
-	      const ::vector<int> &parents,
-	      const ptr_vector<ast> &interps,
-	      const ptr_vector<ast> &theory);
+              solver *s,
+              std::ostream &err,
+              const ptr_vector<ast> &cnsts,
+              const ::vector<int> &parents,
+              const ptr_vector<ast> &interps,
+              const ptr_vector<ast> &theory);
 
 bool iz3check(ast_manager &_m_manager,
-	      solver *s,
-	      std::ostream &err,
-	      const ptr_vector<ast> &cnsts,
-	      ast *tree,
-	      const ptr_vector<ast> &interps);
+              solver *s,
+              std::ostream &err,
+              const ptr_vector<ast> &cnsts,
+              ast *tree,
+              const ptr_vector<ast> &interps);
 
 bool iz3check(iz3mgr &mgr,
-	      solver *s,
-	      std::ostream &err,
-	      const std::vector<iz3mgr::ast> &cnsts,
-	      const std::vector<int> &parents,
-	      const std::vector<iz3mgr::ast> &interps,
-	      const ptr_vector<iz3mgr::ast> &theory);
+              solver *s,
+              std::ostream &err,
+              const std::vector<iz3mgr::ast> &cnsts,
+              const std::vector<int> &parents,
+              const std::vector<iz3mgr::ast> &interps,
+              const ptr_vector<iz3mgr::ast> &theory);
 
 #endif
diff --git a/src/interp/iz3hash.h b/src/interp/iz3hash.h
index 483c7ca49..c796a247b 100644
--- a/src/interp/iz3hash.h
+++ b/src/interp/iz3hash.h
@@ -468,10 +468,10 @@ namespace hash_space {
     : hashtable<std::pair<Key,Value>,Key,HashFun,proj1<Key,Value>,EqFun>(7) {}
 
     Value &operator[](const Key& key) {
-	std::pair<Key,Value> kvp(key,Value());
-	return 
-	hashtable<std::pair<Key,Value>,Key,HashFun,proj1<Key,Value>,EqFun>::
-        lookup(kvp,true)->val.second;
+        std::pair<Key,Value> kvp(key,Value());
+        return 
+            hashtable<std::pair<Key,Value>,Key,HashFun,proj1<Key,Value>,EqFun>::
+            lookup(kvp,true)->val.second;
     }
     };
 
diff --git a/src/interp/iz3interp.h b/src/interp/iz3interp.h
index 9763208f1..a4e1024a9 100644
--- a/src/interp/iz3interp.h
+++ b/src/interp/iz3interp.h
@@ -73,22 +73,22 @@ typedef interpolation_options_struct *interpolation_options;
    representation, for compatibility with the old API. */
 
 void iz3interpolate(ast_manager &_m_manager,
-		    ast *proof,
-		    const ptr_vector<ast> &cnsts,
-		    const ::vector<int> &parents,
-		    ptr_vector<ast> &interps,
-		    const ptr_vector<ast> &theory,
-		    interpolation_options_struct * options = 0);
+                    ast *proof,
+                    const ptr_vector<ast> &cnsts,
+                    const ::vector<int> &parents,
+                    ptr_vector<ast> &interps,
+                    const ptr_vector<ast> &theory,
+                    interpolation_options_struct * options = 0);
 
 /* Same as above, but each constraint is a vector of formulas. */
 
 void iz3interpolate(ast_manager &_m_manager,
-		    ast *proof,
-		    const vector<ptr_vector<ast> > &cnsts,
-		    const ::vector<int> &parents,
-		    ptr_vector<ast> &interps,
-		    const ptr_vector<ast> &theory,
-		    interpolation_options_struct * options = 0);
+                    ast *proof,
+                    const vector<ptr_vector<ast> > &cnsts,
+                    const ::vector<int> &parents,
+                    ptr_vector<ast> &interps,
+                    const ptr_vector<ast> &theory,
+                    interpolation_options_struct * options = 0);
 
 /* Compute an interpolant from a proof. This version uses the ast
    representation, for compatibility with the new API. Here, cnsts is
@@ -98,11 +98,11 @@ void iz3interpolate(ast_manager &_m_manager,
    proof, so it can be considered a hint.  */
 
 void iz3interpolate(ast_manager &_m_manager,
-		    ast *proof,
-		    const ptr_vector<ast> &cnsts,
-		    ast *tree,
-		    ptr_vector<ast> &interps,
-		    interpolation_options_struct * options);
+                    ast *proof,
+                    const ptr_vector<ast> &cnsts,
+                    ast *tree,
+                    ptr_vector<ast> &interps,
+                    interpolation_options_struct * options);
 
 
 /* Compute an interpolant from an ast representing an interpolation
@@ -112,12 +112,12 @@ void iz3interpolate(ast_manager &_m_manager,
 */
 
 lbool iz3interpolate(ast_manager &_m_manager,
-		     solver &s,
-		     ast *tree,
-		     ptr_vector<ast> &cnsts,
-		     ptr_vector<ast> &interps,
-		     model_ref &m,
-		     interpolation_options_struct * options);
+                     solver &s,
+                     ast *tree,
+                     ptr_vector<ast> &cnsts,
+                     ptr_vector<ast> &interps,
+                     model_ref &m,
+                     interpolation_options_struct * options);
 
 
 #endif
diff --git a/src/interp/iz3pp.h b/src/interp/iz3pp.h
index eec88d35e..7b3405f9b 100644
--- a/src/interp/iz3pp.h
+++ b/src/interp/iz3pp.h
@@ -30,7 +30,7 @@ struct iz3pp_bad_tree: public iz3_exception {
 };
 
 void iz3pp(ast_manager &m,
-	   const ptr_vector<expr> &cnsts_vec,
-	   expr *tree,
-	   std::ostream& out);
+           const ptr_vector<expr> &cnsts_vec,
+           expr *tree,
+           std::ostream& out);
 #endif
diff --git a/src/interp/iz3scopes.h b/src/interp/iz3scopes.h
index 745256e57..ece30dc25 100755
--- a/src/interp/iz3scopes.h
+++ b/src/interp/iz3scopes.h
@@ -105,7 +105,7 @@ class scopes {
 
     void range_add(int i, range &n){
 #if 0
-	if(i < n.lo) n.lo = i;
+        if(i < n.lo) n.lo = i;
         if(i > n.hi) n.hi = i;
 #else
         range rng; rng.lo = i; rng.hi = i;
@@ -119,7 +119,7 @@ class scopes {
         int thing = tree_lca(rng1.lo,rng2.hi);
         if(thing == rng1.lo) frame = rng1.lo;
         else frame = tree_gcd(thing,rng1.hi);
-	return frame;
+        return frame;
     }
 #else
 
diff --git a/src/interp/iz3translate.h b/src/interp/iz3translate.h
index 3430d11b3..519a252e0 100755
--- a/src/interp/iz3translate.h
+++ b/src/interp/iz3translate.h
@@ -47,9 +47,9 @@ class iz3translation : public iz3base {
 
  protected:
  iz3translation(iz3mgr &mgr,
-		const std::vector<std::vector<ast> > &_cnsts,
-		const std::vector<int> &_parents,
-		const std::vector<ast> &_theory)
+                const std::vector<std::vector<ast> > &_cnsts,
+                const std::vector<int> &_parents,
+                const std::vector<ast> &_theory)
      : iz3base(mgr,_cnsts,_parents,_theory)  {}
 };
 
diff --git a/src/math/automata/automaton.h b/src/math/automata/automaton.h
index 07d6d31ec..41fc19907 100644
--- a/src/math/automata/automaton.h
+++ b/src/math/automata/automaton.h
@@ -478,7 +478,7 @@ public:
     unsigned out_degree(unsigned state) const { return m_delta[state].size(); }
     move const& get_move_from(unsigned state) const { SASSERT(m_delta[state].size() == 1); return m_delta[state][0]; }
     move const& get_move_to(unsigned state) const { SASSERT(m_delta_inv[state].size() == 1); return m_delta_inv[state][0]; }
-    moves const& get_moves_from(unsigned state) const { return m_delta[state]; }	
+    moves const& get_moves_from(unsigned state) const { return m_delta[state]; }
     moves const& get_moves_to(unsigned state) const { return m_delta_inv[state]; }
     bool initial_state_is_source() const { return m_delta_inv[m_init].empty(); }
     bool is_final_state(unsigned s) const { return m_final_set.contains(s); }
diff --git a/src/math/automata/boolean_algebra.h b/src/math/automata/boolean_algebra.h
index e49d414c4..d54ff5d1a 100644
--- a/src/math/automata/boolean_algebra.h
+++ b/src/math/automata/boolean_algebra.h
@@ -40,9 +40,7 @@ template<class T>
 class boolean_algebra : public positive_boolean_algebra<T> {
 public:
     virtual ~boolean_algebra() {}
-    virtual T mk_not(T x) = 0;	
-    //virtual lbool are_equivalent(T x, T y) = 0;
-    //virtual T simplify(T x) = 0;    
+    virtual T mk_not(T x) = 0;
 };
 
 #endif
diff --git a/src/math/polynomial/polynomial.h b/src/math/polynomial/polynomial.h
index 138331ef3..43b3c1138 100644
--- a/src/math/polynomial/polynomial.h
+++ b/src/math/polynomial/polynomial.h
@@ -63,8 +63,8 @@ namespace polynomial {
     public:
         void set_degree(var x, unsigned d) { m_var2degree.setx(x, d, 0); }
         unsigned degree(var x) const { return m_var2degree.get(x, 0); }
-		void display(std::ostream & out) const;
-		friend std::ostream & operator<<(std::ostream & out, var2degree const & ideal) { ideal.display(out); return out; }
+        void display(std::ostream & out) const;
+        friend std::ostream & operator<<(std::ostream & out, var2degree const & ideal) { ideal.display(out); return out; }
     };
 
     template<typename ValManager, typename Value = typename ValManager::numeral>
diff --git a/src/math/polynomial/upolynomial.h b/src/math/polynomial/upolynomial.h
index e0df0dd31..f8efae465 100644
--- a/src/math/polynomial/upolynomial.h
+++ b/src/math/polynomial/upolynomial.h
@@ -434,11 +434,11 @@ namespace upolynomial {
                 m().reset(r[i]);
             }
             for (unsigned i = 0; i < sz; i++) {
-				typename polynomial::monomial * mon = pm.get_monomial(p, i);
-				if (pm.size(mon) == 0) {
+                typename polynomial::monomial * mon = pm.get_monomial(p, i);
+                if (pm.size(mon) == 0) {
                     m().set(r[0], pm.coeff(p, i));
-				} else if (pm.size(mon) == 1 && pm.get_var(mon, 0) == x) {
-					unsigned m_deg_x = pm.degree(mon, 0);
+                } else if (pm.size(mon) == 1 && pm.get_var(mon, 0) == x) {
+                    unsigned m_deg_x = pm.degree(mon, 0);
                     m().set(r[m_deg_x], pm.coeff(p, i));
                 }
             }
diff --git a/src/model/model_core.cpp b/src/model/model_core.cpp
index 2fd2d8746..f94558097 100644
--- a/src/model/model_core.cpp
+++ b/src/model/model_core.cpp
@@ -86,13 +86,13 @@ void model_core::register_decl(func_decl * d, func_interp * fi) {
 void model_core::unregister_decl(func_decl * d) {
     decl2expr::obj_map_entry * ec = m_interp.find_core(d);
     if (ec && ec->get_data().m_value != 0) {
-		m_manager.dec_ref(ec->get_data().m_key);
-		m_manager.dec_ref(ec->get_data().m_value);
+        m_manager.dec_ref(ec->get_data().m_key);
+        m_manager.dec_ref(ec->get_data().m_value);
         m_interp.remove(d);
         m_const_decls.erase(d);
         return;
     }
-    
+
     decl2finterp::obj_map_entry * ef = m_finterp.find_core(d);
     if (ef && ef->get_data().m_value != 0) {
         m_manager.dec_ref(ef->get_data().m_key);
diff --git a/src/muz/base/dl_context.h b/src/muz/base/dl_context.h
index 738c2559e..129277514 100644
--- a/src/muz/base/dl_context.h
+++ b/src/muz/base/dl_context.h
@@ -54,7 +54,7 @@ namespace datalog {
         MEMOUT,
         INPUT_ERROR,
         APPROX,
-	BOUNDED,
+        BOUNDED,
         CANCELED
     };
 
@@ -318,7 +318,7 @@ namespace datalog {
            \brief Retrieve predicates
         */
         func_decl_set const& get_predicates() const { return m_preds; }
-	ast_ref_vector const &get_pinned() const {return m_pinned; }
+        ast_ref_vector const &get_pinned() const {return m_pinned; }
 
         bool is_predicate(func_decl* pred) const { return m_preds.contains(pred); }
         bool is_predicate(expr * e) const { return is_app(e) && is_predicate(to_app(e)->get_decl()); }
@@ -534,7 +534,7 @@ namespace datalog {
            \brief retrieve proof from derivation of the query.
            
            \pre engine == 'pdr'  || engine == 'duality'- this option is only supported
-	   for PDR mode and Duality mode.
+           for PDR mode and Duality mode.
          */
         proof_ref get_proof();
 
diff --git a/src/muz/base/dl_engine_base.h b/src/muz/base/dl_engine_base.h
index 9c20c712d..576ed7f6b 100644
--- a/src/muz/base/dl_engine_base.h
+++ b/src/muz/base/dl_engine_base.h
@@ -32,7 +32,7 @@ namespace datalog {
         QBMC_ENGINE,
         TAB_ENGINE,
         CLP_ENGINE,
-	DUALITY_ENGINE,
+        DUALITY_ENGINE,
         DDNF_ENGINE,
         LAST_ENGINE
     };
diff --git a/src/muz/duality/duality_dl_interface.h b/src/muz/duality/duality_dl_interface.h
index 21291a45b..506642217 100644
--- a/src/muz/duality/duality_dl_interface.h
+++ b/src/muz/duality/duality_dl_interface.h
@@ -37,7 +37,7 @@ namespace Duality {
 
     class dl_interface : public datalog::engine_base {
         duality_data *_d;
-	datalog::context &m_ctx;
+        datalog::context &m_ctx;
 
     public:
         dl_interface(datalog::context& ctx); 
@@ -69,7 +69,7 @@ namespace Duality {
 
         proof_ref get_proof();
         
-	duality_data *dd(){return _d;}
+        duality_data *dd(){return _d;}
 
     private:
         void display_certificate_non_const(std::ostream& out);
diff --git a/src/muz/pdr/pdr_generalizers.h b/src/muz/pdr/pdr_generalizers.h
index 3d0fe6ccd..e0feda310 100644
--- a/src/muz/pdr/pdr_generalizers.h
+++ b/src/muz/pdr/pdr_generalizers.h
@@ -88,7 +88,7 @@ namespace pdr {
         virtual ~core_convex_hull_generalizer() {}
         virtual void operator()(model_node& n, expr_ref_vector const& core, bool uses_level, cores& new_cores);
         virtual void operator()(model_node& n, expr_ref_vector& core, bool& uses_level);
-    };	
+    };
 
     class core_multi_generalizer : public core_generalizer {
         core_bool_inductive_generalizer m_gen;
diff --git a/src/muz/rel/dl_mk_similarity_compressor.h b/src/muz/rel/dl_mk_similarity_compressor.h
index 68410831c..096305c59 100644
--- a/src/muz/rel/dl_mk_similarity_compressor.h
+++ b/src/muz/rel/dl_mk_similarity_compressor.h
@@ -53,7 +53,7 @@ namespace datalog {
     */
     class mk_similarity_compressor : public rule_transformer::plugin {
 
-        context &			m_context;
+        context &           m_context;
         ast_manager &       m_manager;
         /** number of similar rules necessary for a group to be introduced */
         unsigned            m_threshold_count;
diff --git a/src/muz/rel/dl_mk_simple_joins.h b/src/muz/rel/dl_mk_simple_joins.h
index 4d422e651..cf4522c22 100644
--- a/src/muz/rel/dl_mk_simple_joins.h
+++ b/src/muz/rel/dl_mk_simple_joins.h
@@ -49,7 +49,7 @@ namespace datalog {
        We say that a rule containing C_i's is a rule with a "big tail".
     */
     class mk_simple_joins : public rule_transformer::plugin {
-        context & 	    m_context;
+        context &           m_context;
         rule_manager &      rm;
     public:
         mk_simple_joins(context & ctx);
diff --git a/src/muz/spacer/spacer_qe_project.cpp b/src/muz/spacer/spacer_qe_project.cpp
index 8dbf87ca5..dd6472224 100644
--- a/src/muz/spacer/spacer_qe_project.cpp
+++ b/src/muz/spacer/spacer_qe_project.cpp
@@ -1209,7 +1209,7 @@ namespace qe {
 
         void operator()(model& mdl, app_ref_vector& vars, expr_ref& fml) {
           expr_map map (m);
-        	operator()(mdl, vars, fml, map);
+            operator()(mdl, vars, fml, map);
         }
 
         void operator()(model& mdl, app_ref_vector& vars, expr_ref& fml, expr_map& map) {
diff --git a/src/muz/transforms/dl_mk_magic_sets.h b/src/muz/transforms/dl_mk_magic_sets.h
index eef40fd71..73b5e94f6 100644
--- a/src/muz/transforms/dl_mk_magic_sets.h
+++ b/src/muz/transforms/dl_mk_magic_sets.h
@@ -93,7 +93,7 @@ namespace datalog {
         typedef obj_map<func_decl, adornment> pred_adornment_map;
         typedef obj_map<func_decl, func_decl *> pred2pred;
 
-        context &	       m_context;
+        context &              m_context;
         ast_manager &          m;
         rule_manager&          rm;
         ast_ref_vector         m_pinned;
diff --git a/src/muz/transforms/dl_mk_unbound_compressor.h b/src/muz/transforms/dl_mk_unbound_compressor.h
index febb4bd46..6f53e0707 100644
--- a/src/muz/transforms/dl_mk_unbound_compressor.h
+++ b/src/muz/transforms/dl_mk_unbound_compressor.h
@@ -50,7 +50,7 @@ namespace datalog {
         typedef hashtable<c_info, c_info_hash, default_eq<c_info> > in_progress_table;
         typedef svector<c_info> todo_stack;
 
-        context &	    m_context;
+        context &           m_context;
         ast_manager &       m;
         rule_manager &      rm;
         rule_ref_vector     m_rules;
diff --git a/src/smt/diff_logic.h b/src/smt/diff_logic.h
index 67d1f045d..44e858219 100644
--- a/src/smt/diff_logic.h
+++ b/src/smt/diff_logic.h
@@ -956,8 +956,8 @@ public:
     }
 
     void get_neighbours_undirected(dl_var current, svector<dl_var> & neighbours) {
-	    neighbours.reset();
-	    edge_id_vector & out_edges = m_out_edges[current];
+        neighbours.reset();
+        edge_id_vector & out_edges = m_out_edges[current];
         typename edge_id_vector::iterator it = out_edges.begin(), end = out_edges.end();
         for (; it != end; ++it) {
             edge_id e_id = *it;
@@ -968,7 +968,7 @@ public:
         }
         edge_id_vector & in_edges = m_in_edges[current];
         typename edge_id_vector::iterator it2 = in_edges.begin(), end2 = in_edges.end();
-	    for (; it2 != end2; ++it2) {
+        for (; it2 != end2; ++it2) {
             edge_id e_id = *it2;
             edge & e     = m_edges[e_id];
             SASSERT(e.get_target() == current);
@@ -980,19 +980,19 @@ public:
     void dfs_undirected(dl_var start, svector<dl_var> & threads) {
         threads.reset();
         threads.resize(get_num_nodes());
-	    uint_set discovered, explored;
-	    svector<dl_var> nodes;
+        uint_set discovered, explored;
+        svector<dl_var> nodes;
         discovered.insert(start);
-	    nodes.push_back(start);
-	    dl_var prev = start;
-	    while(!nodes.empty()) {
-		    dl_var current = nodes.back();
+        nodes.push_back(start);
+        dl_var prev = start;
+        while(!nodes.empty()) {
+            dl_var current = nodes.back();
             SASSERT(discovered.contains(current) && !explored.contains(current));
-		    svector<dl_var> neighbours;
-		    get_neighbours_undirected(current, neighbours);
+            svector<dl_var> neighbours;
+            get_neighbours_undirected(current, neighbours);
             SASSERT(!neighbours.empty());
             bool found = false;
-		    for (unsigned i = 0; i < neighbours.size(); ++i) {
+            for (unsigned i = 0; i < neighbours.size(); ++i) {
                 dl_var next = neighbours[i];
                 DEBUG_CODE(
                 edge_id id;
@@ -1002,18 +1002,18 @@ public:
                     threads[prev] = next;
                     prev = next;
                     discovered.insert(next);
-	                nodes.push_back(next);
+                    nodes.push_back(next);
                     found = true;
                     break;
                 }
-		    }            
+            }            
             SASSERT(!nodes.empty());
             if (!found) {
                 explored.insert(current);
                 nodes.pop_back();
             }
-	    }
-	    threads[prev] = start;
+        }
+        threads[prev] = start;
     }
 
     void bfs_undirected(dl_var start, svector<dl_var> & parents, svector<dl_var> & depths) {
@@ -1022,31 +1022,31 @@ public:
         parents[start] = -1;
         depths.reset();
         depths.resize(get_num_nodes());
-	    uint_set visited;
-	    std::deque<dl_var> nodes;
-	    visited.insert(start);
-	    nodes.push_front(start);
-	    while(!nodes.empty()) {
+        uint_set visited;
+        std::deque<dl_var> nodes;
+        visited.insert(start);
+        nodes.push_front(start);
+        while(!nodes.empty()) {
             dl_var current = nodes.back();
             nodes.pop_back();
-		    SASSERT(visited.contains(current));
+            SASSERT(visited.contains(current));
             svector<dl_var> neighbours;
-		    get_neighbours_undirected(current, neighbours);
+            get_neighbours_undirected(current, neighbours);
             SASSERT(!neighbours.empty());
-		    for (unsigned i = 0; i < neighbours.size(); ++i) {
-			    dl_var next = neighbours[i];
+            for (unsigned i = 0; i < neighbours.size(); ++i) {
+                dl_var next = neighbours[i];
                 DEBUG_CODE(
                 edge_id id;
                 SASSERT(get_edge_id(current, next, id) || get_edge_id(next, current, id)););
                 if (!visited.contains(next)) {
                     TRACE("diff_logic", tout << "parents[" << next << "] --> " << current << std::endl;);
-	                parents[next] = current;
-	                depths[next] = depths[current] + 1;
-	                visited.insert(next);
-	                nodes.push_front(next);
+                    parents[next] = current;
+                    depths[next] = depths[current] + 1;
+                    visited.insert(next);
+                    nodes.push_front(next);
                 }
-		    }
-	    }
+            }
+        }
     }
 
     template<typename Functor>
diff --git a/src/smt/smt_enode.h b/src/smt/smt_enode.h
index 4b3a64d90..f471314fa 100644
--- a/src/smt/smt_enode.h
+++ b/src/smt/smt_enode.h
@@ -40,10 +40,10 @@ namespace smt {
 
     /** \ brief Use sparse maps in SMT solver.
 
-	Define this to use hash maps rather than vectors over ast
-	nodes. This is useful in the case there are many solvers, each
-	referencing few nodes from a large ast manager. There is some
-	unknown performance penalty for this. */
+    Define this to use hash maps rather than vectors over ast
+    nodes. This is useful in the case there are many solvers, each
+    referencing few nodes from a large ast manager. There is some
+    unknown performance penalty for this. */
 
     // #define SPARSE_MAP
 
diff --git a/src/smt/smt_quantifier.h b/src/smt/smt_quantifier.h
index a55c895e6..d89f3f6a4 100644
--- a/src/smt/smt_quantifier.h
+++ b/src/smt/smt_quantifier.h
@@ -149,7 +149,7 @@ namespace smt {
         /**
            \brief Is "model based" instantiate allowed to instantiate this quantifier?
          */
-    	virtual bool mbqi_enabled(quantifier *q) const {return true;}
+        virtual bool mbqi_enabled(quantifier *q) const {return true;}
 
         /**
            \brief Give a change to the plugin to adjust the interpretation of unintepreted functions.
diff --git a/src/smt/smt_theory.h b/src/smt/smt_theory.h
index 71eedc1a7..2ee0db322 100644
--- a/src/smt/smt_theory.h
+++ b/src/smt/smt_theory.h
@@ -192,7 +192,7 @@ namespace smt {
         virtual lbool validate_unsat_core(expr_ref_vector & unsat_core) {
             return l_false;
         }
-	
+
         /**
            \brief This method is invoked before the search starts.
         */
diff --git a/src/smt/theory_seq.h b/src/smt/theory_seq.h
index 1f97697c2..2ad257fd7 100644
--- a/src/smt/theory_seq.h
+++ b/src/smt/theory_seq.h
@@ -45,7 +45,7 @@ namespace smt {
         typedef trail_stack<theory_seq> th_trail_stack;
         typedef std::pair<expr*, dependency*> expr_dep;
         typedef obj_map<expr, expr_dep> eqdep_map_t; 
-	typedef union_find<theory_seq> th_union_find;
+        typedef union_find<theory_seq> th_union_find;
 
         class seq_value_proc;
 
@@ -298,8 +298,8 @@ namespace smt {
         scoped_vector<eq>          m_eqs;        // set of current equations.
         scoped_vector<ne>          m_nqs;        // set of current disequalities.
         scoped_vector<nc>          m_ncs;        // set of non-contains constraints.
-        unsigned                   m_eq_id;	
-	th_union_find              m_find;
+        unsigned                   m_eq_id;
+        th_union_find              m_find;
 
         seq_factory*               m_factory;    // value factory
         exclusion_table            m_exclude;    // set of asserted disequalities.
@@ -584,7 +584,7 @@ namespace smt {
         // model building
         app* mk_value(app* a);
 
-	th_trail_stack& get_trail_stack() { return m_trail_stack; }
+        th_trail_stack& get_trail_stack() { return m_trail_stack; }
         void merge_eh(theory_var, theory_var, theory_var v1, theory_var v2) {}
         void after_merge_eh(theory_var r1, theory_var r2, theory_var v1, theory_var v2) { }
         void unmerge_eh(theory_var v1, theory_var v2) {}
diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp
index 88b044a90..8a141665c 100644
--- a/src/smt/theory_str.cpp
+++ b/src/smt/theory_str.cpp
@@ -4748,11 +4748,11 @@ namespace smt {
         context& ctx = get_context();
         ast_manager & m = get_manager();
 
-	// safety
-	if (!ctx.e_internalized(e)) {
+    // safety
+    if (!ctx.e_internalized(e)) {
             return false;
-	}
-	
+    }
+    
         // if an integer constant exists in the eqc, it should be the root
         enode * en_e = ctx.get_enode(e);
         enode * root_e = en_e->get_root();
@@ -7028,7 +7028,7 @@ namespace smt {
         ast_manager & m = get_manager();
         if (lenTester_fvar_map.contains(lenTester)) {
             expr * fVar = lenTester_fvar_map[lenTester];
-			expr_ref toAssert(gen_len_val_options_for_free_var(fVar, lenTester, lenTesterValue), m);
+            expr_ref toAssert(gen_len_val_options_for_free_var(fVar, lenTester, lenTesterValue), m);
             TRACE("str", tout << "asserting more length tests for free variable " << mk_ismt2_pp(fVar, m) << std::endl;);
             if (toAssert) {
                 assert_axiom(toAssert);
diff --git a/src/smt/watch_list.cpp b/src/smt/watch_list.cpp
index 2ff75c418..edd6923d7 100644
--- a/src/smt/watch_list.cpp
+++ b/src/smt/watch_list.cpp
@@ -36,10 +36,10 @@ namespace smt {
     
     void watch_list::expand() {
         if (m_data == 0) {
-	    unsigned size       = DEFAULT_WATCH_LIST_SIZE + HEADER_SIZE;
+        unsigned size       = DEFAULT_WATCH_LIST_SIZE + HEADER_SIZE;
             unsigned * mem      = reinterpret_cast<unsigned*>(alloc_svect(char, size));
 #ifdef _AMD64_
-	    ++mem;  // make sure data is aligned in 64 bit machines
+        ++mem;  // make sure data is aligned in 64 bit machines
 #endif
             *mem                = 0;
             ++mem;
@@ -62,9 +62,9 @@ namespace smt {
             unsigned * mem          = reinterpret_cast<unsigned*>(alloc_svect(char, new_capacity + HEADER_SIZE));
             unsigned curr_end_cls   = end_cls_core();
 #ifdef _AMD64_
-	    ++mem;  // make sure data is aligned in 64 bit machines
+        ++mem;  // make sure data is aligned in 64 bit machines
 #endif
-	    *mem                    = curr_end_cls;
+        *mem                    = curr_end_cls;
             ++mem;
             SASSERT(bin_bytes <= new_capacity);
             unsigned new_begin_bin  = new_capacity - bin_bytes;
diff --git a/src/tactic/sls/sls_tracker.h b/src/tactic/sls/sls_tracker.h
index 651e4ef14..4ad5c65f4 100644
--- a/src/tactic/sls/sls_tracker.h
+++ b/src/tactic/sls/sls_tracker.h
@@ -68,7 +68,7 @@ private:
     typedef obj_map<expr, value_score> scores_type;    
     typedef obj_map<expr, ptr_vector<expr> > uplinks_type;    
     typedef obj_map<expr, ptr_vector<func_decl> > occ_type;
-    obj_hashtable<expr>	  m_top_expr;
+    obj_hashtable<expr>      m_top_expr;
     scores_type           m_scores;
     uplinks_type          m_uplinks;
     entry_point_type      m_entry_points;
@@ -85,11 +85,11 @@ private:
     unsigned              m_touched;
     double                m_scale_unsat;
     unsigned              m_paws_init;
-    obj_map<expr, unsigned>	m_where_false;
-    expr**					m_list_false;
+    obj_map<expr, unsigned>    m_where_false;
+    expr**                    m_list_false;
     unsigned              m_track_unsat;
     obj_map<expr, unsigned> m_weights;
-    double				  m_top_sum;
+    double                  m_top_sum;
     obj_hashtable<expr>   m_temp_seen;
 
 public:    
@@ -450,7 +450,7 @@ public:
             m_list_false = new expr*[sz];
             for (unsigned i = 0; i < sz; i++)
             {
-        	    if (m_mpz_manager.eq(get_value(as[i]), m_zero))
+                if (m_mpz_manager.eq(get_value(as[i]), m_zero))
                     break_assertion(as[i]);
             }
         }
@@ -462,7 +462,7 @@ public:
 
             // initialize weights
             if (!m_weights.contains(e))
-        		m_weights.insert(e, m_paws_init);
+                m_weights.insert(e, m_paws_init);
 
             // positive/negative occurrences used for early pruning
             setup_occs(as[i]);
@@ -1075,7 +1075,7 @@ public:
 
             unsigned cnt_unsat = 0;
             for (unsigned i = 0; i < sz; i++)
-                if (m_mpz_manager.neq(get_value(as[i]), m_one) && (get_random_uint(16) % ++cnt_unsat == 0)) pos = i;	
+                if (m_mpz_manager.neq(get_value(as[i]), m_one) && (get_random_uint(16) % ++cnt_unsat == 0)) pos = i;    
             if (pos == static_cast<unsigned>(-1))
                 return 0;
         }
@@ -1092,7 +1092,7 @@ public:
         
         unsigned cnt_unsat = 0, pos = -1;
         for (unsigned i = 0; i < sz; i++)
-            if ((i != m_last_pos) && m_mpz_manager.neq(get_value(as[i]), m_one) && (get_random_uint(16) % ++cnt_unsat == 0)) pos = i;	
+            if ((i != m_last_pos) && m_mpz_manager.neq(get_value(as[i]), m_one) && (get_random_uint(16) % ++cnt_unsat == 0)) pos = i;
 
         if (pos == static_cast<unsigned>(-1))
             return 0;
diff --git a/src/test/bit_vector.cpp b/src/test/bit_vector.cpp
index e920fadee..487f6cdd0 100644
--- a/src/test/bit_vector.cpp
+++ b/src/test/bit_vector.cpp
@@ -27,36 +27,36 @@ static void tst1() {
     unsigned n = rand()%10000;
     for (unsigned i = 0; i < n; i++) {
         int op = rand()%6;
-	if (op <= 1) {
-	    bool val = (rand()%2) != 0;
-	    v1.push_back(val);
-	    v2.push_back(val);
-	    ENSURE(v1.size() == v2.size());
-	}
-	else if (op <= 3) {
-	    ENSURE(v1.size() == v2.size());
-	    if (v1.size() > 0) {
-		bool val = (rand()%2) != 0;
-		unsigned idx = rand()%v1.size();
-		ENSURE(v1.get(idx) == v2[idx]);
-		v1.set(idx, val);
-		v2[idx] = val;
-		ENSURE(v1.get(idx) == v2[idx]);
-	    }
-	}
-	else if (op <= 4) {
-	    ENSURE(v1.size() == v2.size());
-	    if (v1.size() > 0) {
-		unsigned idx = rand()%v1.size();
-		VERIFY(v1.get(idx) == v2[idx]);
-	    }
-	}
-	else if (op <= 5) {
-	    ENSURE(v1.size() == v2.size());
-	    for (unsigned j = 0; j < v1.size(); j++) {
-		ENSURE(v1.get(j) == v2[j]);
-	    }
-	}
+    if (op <= 1) {
+        bool val = (rand()%2) != 0;
+        v1.push_back(val);
+        v2.push_back(val);
+        ENSURE(v1.size() == v2.size());
+    }
+    else if (op <= 3) {
+        ENSURE(v1.size() == v2.size());
+        if (v1.size() > 0) {
+        bool val = (rand()%2) != 0;
+        unsigned idx = rand()%v1.size();
+        ENSURE(v1.get(idx) == v2[idx]);
+        v1.set(idx, val);
+        v2[idx] = val;
+        ENSURE(v1.get(idx) == v2[idx]);
+        }
+    }
+    else if (op <= 4) {
+        ENSURE(v1.size() == v2.size());
+        if (v1.size() > 0) {
+        unsigned idx = rand()%v1.size();
+        VERIFY(v1.get(idx) == v2[idx]);
+        }
+    }
+    else if (op <= 5) {
+        ENSURE(v1.size() == v2.size());
+        for (unsigned j = 0; j < v1.size(); j++) {
+        ENSURE(v1.get(j) == v2[j]);
+        }
+    }
     }
 }
 
@@ -309,6 +309,6 @@ void tst_bit_vector() {
     tst2();
     for (unsigned i = 0; i < 20; i++) {
         std::cerr << i << std::endl;
-	tst1();
+    tst1();
     }
 }
diff --git a/src/test/diff_logic.cpp b/src/test/diff_logic.cpp
index e79c93cf2..0564fbfbe 100644
--- a/src/test/diff_logic.cpp
+++ b/src/test/diff_logic.cpp
@@ -33,7 +33,7 @@ template class dl_graph<diff_logic_ext>;
 typedef dl_graph<diff_logic_ext> dlg;
 
 struct tst_dl_functor {
-	smt::literal_vector m_literals;
+    smt::literal_vector m_literals;
     void operator()(smt::literal l) {
         m_literals.push_back(l);
     }
diff --git a/src/test/expr_rand.cpp b/src/test/expr_rand.cpp
index 388a178f4..f1b20ba8e 100644
--- a/src/test/expr_rand.cpp
+++ b/src/test/expr_rand.cpp
@@ -98,8 +98,8 @@ void tst_expr_rand(char** argv, int argc, int& i) {
         i += 1;
         if (i + 1 < argc && 0 == strncmp(argv[i+1],"/rs:",3)) {
             rand_seed = atol(argv[i+1]+4);
-			std::cout << "random seed:" << rand_seed << "\n";
-			i += 1;
+            std::cout << "random seed:" << rand_seed << "\n";
+            i += 1;
         }
 
         if (i + 1 < argc && 0 == strcmp(argv[i+1],"/arith")) {
diff --git a/src/test/main.cpp b/src/test/main.cpp
index 2c51df601..d0d0aac5b 100644
--- a/src/test/main.cpp
+++ b/src/test/main.cpp
@@ -16,20 +16,20 @@
 // and print "PASS" to indicate success.
 // 
 
-#define TST(MODULE) {				\
-    std::string s("test ");			\
-    s += #MODULE;				\
-    void tst_##MODULE();			\
+#define TST(MODULE) {                \
+    std::string s("test ");            \
+    s += #MODULE;                \
+    void tst_##MODULE();            \
     if (do_display_usage)                       \
         std::cout << #MODULE << "\n";           \
-    for (int i = 0; i < argc; i++) 		\
-	if (test_all || strcmp(argv[i], #MODULE) == 0) {	\
+    for (int i = 0; i < argc; i++)         \
+    if (test_all || strcmp(argv[i], #MODULE) == 0) {    \
             enable_trace(#MODULE);              \
-	    enable_debug(#MODULE);		\
-	    timeit timeit(true, s.c_str());     \
-	    tst_##MODULE();			\
+        enable_debug(#MODULE);        \
+        timeit timeit(true, s.c_str());     \
+        tst_##MODULE();            \
             std::cout << "PASS" << std::endl;   \
-	}					\
+    }                    \
 }
 
 #define TST_ARGV(MODULE) {                              \
@@ -39,13 +39,13 @@
     if (do_display_usage)                               \
         std::cout << #MODULE << "\n";                   \
     for (int i = 0; i < argc; i++)                      \
-	if (strcmp(argv[i], #MODULE) == 0) {            \
+    if (strcmp(argv[i], #MODULE) == 0) {            \
             enable_trace(#MODULE);                      \
-	    enable_debug(#MODULE);                      \
-	    timeit timeit(true, s.c_str());             \
-	    tst_##MODULE(argv, argc, i);                \
+        enable_debug(#MODULE);                      \
+        timeit timeit(true, s.c_str());             \
+        tst_##MODULE(argv, argc, i);                \
             std::cout << "PASS" << std::endl;           \
-	}                                               \
+    }                                               \
 }
 
 void error(const char * msg) {
@@ -76,49 +76,49 @@ void display_usage() {
 void parse_cmd_line_args(int argc, char ** argv, bool& do_display_usage, bool& test_all) {
     int i = 1;
     while (i < argc) {
-	char * arg = argv[i], *eq_pos = 0;
+    char * arg = argv[i], *eq_pos = 0;
 
-	if (arg[0] == '-' || arg[0] == '/') {
-	    char * opt_name = arg + 1;
-	    char * opt_arg  = 0;
-	    char * colon    = strchr(arg, ':');
-	    if (colon) {
-		opt_arg = colon + 1;
-		*colon  = 0;
-	    }
-	    if (strcmp(opt_name, "h") == 0 ||
+    if (arg[0] == '-' || arg[0] == '/') {
+        char * opt_name = arg + 1;
+        char * opt_arg  = 0;
+        char * colon    = strchr(arg, ':');
+        if (colon) {
+        opt_arg = colon + 1;
+        *colon  = 0;
+        }
+        if (strcmp(opt_name, "h") == 0 ||
                 strcmp(opt_name, "?") == 0) {
-		display_usage();
+        display_usage();
                 do_display_usage = true;
                 return;
-	    }
-	    else if (strcmp(opt_name, "v") == 0) {
-		if (!opt_arg)
-		    error("option argument (/v:level) is missing.");
-		long lvl = strtol(opt_arg, 0, 10);
-		set_verbosity_level(lvl);
-	    }
-	    else if (strcmp(opt_name, "w") == 0) {
+        }
+        else if (strcmp(opt_name, "v") == 0) {
+        if (!opt_arg)
+            error("option argument (/v:level) is missing.");
+        long lvl = strtol(opt_arg, 0, 10);
+        set_verbosity_level(lvl);
+        }
+        else if (strcmp(opt_name, "w") == 0) {
                 enable_warning_messages(true);
-	    }
-	    else if (strcmp(opt_name, "a") == 0) {
+        }
+        else if (strcmp(opt_name, "a") == 0) {
                 test_all = true;
-	    }
+        }
 #ifdef _TRACE
-	    else if (strcmp(opt_name, "tr") == 0) {
-		if (!opt_arg)
-		    error("option argument (/tr:tag) is missing.");
-		enable_trace(opt_arg);
-	    }
+        else if (strcmp(opt_name, "tr") == 0) {
+        if (!opt_arg)
+            error("option argument (/tr:tag) is missing.");
+        enable_trace(opt_arg);
+        }
 #endif
 #ifdef Z3DEBUG
-	    else if (strcmp(opt_name, "dbg") == 0) {
-		if (!opt_arg)
-		    error("option argument (/dbg:tag) is missing.");
-		enable_debug(opt_arg);
-	    }
+        else if (strcmp(opt_name, "dbg") == 0) {
+        if (!opt_arg)
+            error("option argument (/dbg:tag) is missing.");
+        enable_debug(opt_arg);
+        }
 #endif
-	}
+    }
         else if (arg[0] != '"' && (eq_pos = strchr(arg, '='))) {
             char * key   = arg;
             *eq_pos      = 0;
@@ -130,7 +130,7 @@ void parse_cmd_line_args(int argc, char ** argv, bool& do_display_usage, bool& t
                 std::cerr << ex.msg() << "\n";
             }
         }            
-	i++;
+    i++;
     }
 }
 
diff --git a/src/test/model_based_opt.cpp b/src/test/model_based_opt.cpp
index 2f8cf9941..7b3b95afd 100644
--- a/src/test/model_based_opt.cpp
+++ b/src/test/model_based_opt.cpp
@@ -54,7 +54,7 @@ static void add_random_ineq(opt::model_based_opt& mbo,
             continue;
         }
         unsigned sign = r(2);
-		coeff = sign == 0 ? coeff : -coeff;
+        coeff = sign == 0 ? coeff : -coeff;
         vars.push_back(var(x, rational(coeff)));
         value += coeff*values[x];
     }
diff --git a/src/test/optional.cpp b/src/test/optional.cpp
index 2ef922444..d698f7289 100644
--- a/src/test/optional.cpp
+++ b/src/test/optional.cpp
@@ -36,11 +36,11 @@ struct OptFoo {
     int m_y;
 
     OptFoo(int x, int y):m_x(x), m_y(y) {
-	TRACE("optional", tout << "OptFoo created: " << m_x << " : " << m_y << "\n";);
+    TRACE("optional", tout << "OptFoo created: " << m_x << " : " << m_y << "\n";);
     }
 
     ~OptFoo() {
-	TRACE("optional", tout << "OptFoo deleted: " << m_x << " : " << m_y << "\n";);
+    TRACE("optional", tout << "OptFoo deleted: " << m_x << " : " << m_y << "\n";);
     }
 };
 
diff --git a/src/util/dependency.h b/src/util/dependency.h
index d6df6d7bf..5055399bc 100644
--- a/src/util/dependency.h
+++ b/src/util/dependency.h
@@ -201,7 +201,7 @@ public:
             m_todo.push_back(d);
             unsigned qhead = 0;
             while (qhead < m_todo.size()) {
-	        d = m_todo[qhead];
+                d = m_todo[qhead];
                 qhead++;
                 if (d->is_leaf()) {
                     vs.push_back(to_leaf(d)->m_value);
diff --git a/src/util/hash.h b/src/util/hash.h
index 7fce04ca8..bc6117cac 100644
--- a/src/util/hash.h
+++ b/src/util/hash.h
@@ -236,7 +236,7 @@ template<typename T>
 struct ptr_hash {
     typedef T * data;
     unsigned operator()(T * ptr) const { 
-	return get_ptr_hash(ptr);
+        return get_ptr_hash(ptr);
     }
 };
 
diff --git a/src/util/inf_eps_rational.h b/src/util/inf_eps_rational.h
index 72212d33c..c184623ca 100644
--- a/src/util/inf_eps_rational.h
+++ b/src/util/inf_eps_rational.h
@@ -119,12 +119,12 @@ class inf_eps_rational {
     bool is_rational() const { return m_infty.is_zero() && m_r.is_rational(); }
 
     int64 get_int64() const {
-	SASSERT(is_int64());
+        SASSERT(is_int64());
         return m_r.get_int64();
     }
 
     uint64 get_uint64() const {
-	SASSERT(is_uint64());
+        SASSERT(is_uint64());
         return m_r.get_uint64();
     }
 
@@ -168,45 +168,45 @@ class inf_eps_rational {
     inf_eps_rational & operator=(const inf_eps_rational & r) {
         m_infty = r.m_infty;
         m_r = r.m_r;
-	return *this;
+        return *this;
     }
 
     inf_eps_rational & operator=(const Numeral & r) {
         m_infty.reset();
         m_r = r;
-	return *this;
+        return *this;
     }
 
     inf_eps_rational & operator+=(const inf_eps_rational & r) { 
         m_infty  += r.m_infty;
         m_r      += r.m_r;
-	return *this; 
+        return *this; 
     }
 
     inf_eps_rational & operator-=(const inf_eps_rational & r) { 
         m_infty  -= r.m_infty;
         m_r      -= r.m_r;
-	return *this; 
+        return *this; 
     }
 
     inf_eps_rational & operator-=(const inf_rational & r) { 
         m_r      -= r;
-	return *this; 
+        return *this; 
     }
 
     inf_eps_rational & operator+=(const inf_rational & r) { 
         m_r      += r;
-	return *this; 
+        return *this; 
     }
 
     inf_eps_rational & operator+=(const rational & r) { 
         m_r  += r;
-	return *this; 
+        return *this; 
     }
 
     inf_eps_rational & operator-=(const rational & r) { 
         m_r  -= r;
-	return *this; 
+        return *this; 
     }
 
     inf_eps_rational & operator*=(const rational & r1) {
diff --git a/src/util/inf_int_rational.h b/src/util/inf_int_rational.h
index ce871b0d5..c9c82052e 100644
--- a/src/util/inf_int_rational.h
+++ b/src/util/inf_int_rational.h
@@ -110,12 +110,12 @@ class inf_int_rational {
     bool is_rational() const { return m_second == 0; }
 
     int64 get_int64() const {
-	SASSERT(is_int64());
+        SASSERT(is_int64());
         return m_first.get_int64();
     }
 
     uint64 get_uint64() const {
-	SASSERT(is_uint64());
+        SASSERT(is_uint64());
         return m_first.get_uint64();
     }
 
@@ -132,7 +132,7 @@ class inf_int_rational {
     inf_int_rational & operator=(const inf_int_rational & r) {
         m_first = r.m_first;
         m_second = r.m_second;
-	return *this;
+        return *this;
     }
 
     inf_int_rational & operator=(const rational & r) {
@@ -154,7 +154,7 @@ class inf_int_rational {
     inf_int_rational & operator+=(const inf_int_rational & r) { 
         m_first  += r.m_first;
         m_second += r.m_second;
-	return *this; 
+        return *this; 
     }
 
     inf_int_rational & operator*=(const rational & r) { 
@@ -163,7 +163,7 @@ class inf_int_rational {
         }
         m_first  *= r;
         m_second *= r.get_int32();
-	return *this; 
+        return *this; 
     }
 
 
@@ -171,17 +171,17 @@ class inf_int_rational {
     inf_int_rational & operator-=(const inf_int_rational & r) { 
         m_first  -= r.m_first;
         m_second -= r.m_second;
-	return *this; 
+        return *this; 
     }
 
     inf_int_rational & operator+=(const rational & r) { 
         m_first  += r;
-	return *this; 
+        return *this; 
     }
 
     inf_int_rational & operator-=(const rational & r) { 
         m_first  -= r;
-	return *this; 
+        return *this; 
     }
 
     inf_int_rational & operator++() {
diff --git a/src/util/inf_rational.h b/src/util/inf_rational.h
index c17c4312b..d49e45f50 100644
--- a/src/util/inf_rational.h
+++ b/src/util/inf_rational.h
@@ -123,12 +123,12 @@ class inf_rational {
     bool is_rational() const { return m_second.is_zero(); }
 
     int64 get_int64() const {
-	SASSERT(is_int64());
+        SASSERT(is_int64());
         return m_first.get_int64();
     }
 
     uint64 get_uint64() const {
-	SASSERT(is_uint64());
+        SASSERT(is_uint64());
         return m_first.get_uint64();
     }
 
@@ -145,7 +145,7 @@ class inf_rational {
     inf_rational & operator=(const inf_rational & r) {
         m_first = r.m_first;
         m_second = r.m_second;
-	return *this;
+        return *this;
     }
 
     inf_rational & operator=(const rational & r) {
@@ -167,23 +167,23 @@ class inf_rational {
     inf_rational & operator+=(const inf_rational & r) { 
         m_first  += r.m_first;
         m_second += r.m_second;
-	return *this; 
+        return *this; 
     }
 
     inf_rational & operator-=(const inf_rational & r) { 
         m_first  -= r.m_first;
         m_second -= r.m_second;
-	return *this; 
+        return *this; 
     }
 
     inf_rational & operator+=(const rational & r) { 
         m_first  += r;
-	return *this; 
+        return *this; 
     }
 
     inf_rational & operator-=(const rational & r) { 
         m_first  -= r;
-	return *this; 
+        return *this; 
     }
 
     inf_rational & operator*=(const rational & r1) {
diff --git a/src/util/inf_s_integer.h b/src/util/inf_s_integer.h
index 6cf1d4225..067000202 100644
--- a/src/util/inf_s_integer.h
+++ b/src/util/inf_s_integer.h
@@ -67,7 +67,7 @@ class inf_s_integer {
     inf_s_integer & operator=(const inf_s_integer & r) { 
         m_first = r.m_first;
         m_second = r.m_second;
-	return *this;
+        return *this;
     }
     inf_s_integer & operator=(const rational & r) {
         m_first = static_cast<int>(r.get_int64());
@@ -90,20 +90,20 @@ class inf_s_integer {
     inf_s_integer & operator+=(const inf_s_integer & r) { 
         m_first  += r.m_first;
         m_second += r.m_second;
-	return *this; 
+        return *this; 
     }
     inf_s_integer & operator-=(const inf_s_integer & r) { 
         m_first  -= r.m_first;
         m_second -= r.m_second;
-	return *this; 
+        return *this; 
     }
     inf_s_integer & operator+=(const s_integer & r) { 
         m_first  += r.get_int();
-	return *this; 
+        return *this; 
     }
     inf_s_integer & operator-=(const s_integer & r) { 
         m_first  -= r.get_int();
-	return *this; 
+        return *this; 
     }
     inf_s_integer & operator*=(const s_integer & r1) {
         m_first  *= r1.get_int();
diff --git a/src/util/lp/bound_analyzer_on_row.h b/src/util/lp/bound_analyzer_on_row.h
index 4c6c43464..914835a3c 100644
--- a/src/util/lp/bound_analyzer_on_row.h
+++ b/src/util/lp/bound_analyzer_on_row.h
@@ -114,22 +114,22 @@ public :
         }
         return a * lb(j).x;
     }
-	mpq monoid_max(const mpq & a, unsigned j, bool & strict) const {
-		if (is_pos(a)) {
-			strict = !is_zero(ub(j).y);
-			return a * ub(j).x;
-		}
-		strict = !is_zero(lb(j).y);
-		return a * lb(j).x;
-	}
-	const mpq & monoid_min_no_mult(bool a_is_pos, unsigned j, bool & strict) const {
-		if (!a_is_pos) {
-			strict = !is_zero(ub(j).y);
-			return ub(j).x;
-		}
-		strict = !is_zero(lb(j).y);
-		return lb(j).x;
-	}
+    mpq monoid_max(const mpq & a, unsigned j, bool & strict) const {
+        if (is_pos(a)) {
+            strict = !is_zero(ub(j).y);
+            return a * ub(j).x;
+        }
+        strict = !is_zero(lb(j).y);
+        return a * lb(j).x;
+    }
+    const mpq & monoid_min_no_mult(bool a_is_pos, unsigned j, bool & strict) const {
+        if (!a_is_pos) {
+            strict = !is_zero(ub(j).y);
+            return ub(j).x;
+        }
+        strict = !is_zero(lb(j).y);
+        return lb(j).x;
+    }
 
     mpq monoid_min(const mpq & a, unsigned j, bool& strict) const {
         if (is_neg(a)) {
@@ -166,7 +166,7 @@ public :
         m_it.reset();
         while (m_it.next(a, j)) {
             bool str;
-			bool a_is_pos = is_pos(a);
+            bool a_is_pos = is_pos(a);
             mpq bound = total / a + monoid_min_no_mult(a_is_pos, j, str);
             if (a_is_pos) {
                 limit_j(j, bound, true, false, strict - static_cast<int>(str) > 0);
@@ -192,8 +192,8 @@ public :
         m_it.reset();
         while (m_it.next(a, j)) {
             bool str;
-			bool a_is_pos = is_pos(a);
-			mpq bound = total / a + monoid_max_no_mult(a_is_pos, j, str);
+            bool a_is_pos = is_pos(a);
+            mpq bound = total / a + monoid_max_no_mult(a_is_pos, j, str);
             bool astrict = strict - static_cast<int>(str) > 0;
             if (a_is_pos) {
                 limit_j(j, bound, true, true, astrict);
diff --git a/src/util/lp/init_lar_solver.h b/src/util/lp/init_lar_solver.h
index 3fc29f25b..db5a6ed4c 100644
--- a/src/util/lp/init_lar_solver.h
+++ b/src/util/lp/init_lar_solver.h
@@ -123,7 +123,7 @@ void add_row_for_term(const lar_term * term, unsigned term_ext_index) {
 void add_row_from_term_no_constraint(const lar_term * term, unsigned term_ext_index) {
     register_new_ext_var_index(term_ext_index);
     // j will be a new variable
-	unsigned j = A_r().column_count();
+    unsigned j = A_r().column_count();
     ul_pair ul(j);
     m_vars_to_ul_pairs.push_back(ul);
     add_basic_var_to_core_fields();
@@ -152,7 +152,7 @@ void add_basic_var_to_core_fields() {
 }
 
 constraint_index add_var_bound(var_index j, lconstraint_kind kind, const mpq & right_side)  {
-	constraint_index ci = m_constraints.size();
+    constraint_index ci = m_constraints.size();
     if (!is_term(j)) { // j is a var
         auto vc = new lar_var_constraint(j, kind, right_side);
         m_constraints.push_back(vc);
@@ -212,8 +212,8 @@ void add_constraint_from_term_and_create_new_column_row(unsigned term_j, const l
 }
 
 void decide_on_strategy_and_adjust_initial_state() {
-	lean_assert(strategy_is_undecided());
-	if (m_vars_to_ul_pairs.size() > m_settings.column_number_threshold_for_using_lu_in_lar_solver) {
+    lean_assert(strategy_is_undecided());
+    if (m_vars_to_ul_pairs.size() > m_settings.column_number_threshold_for_using_lu_in_lar_solver) {
         m_settings.simplex_strategy() = simplex_strategy_enum::lu;
     } else {
         m_settings.simplex_strategy() = simplex_strategy_enum::tableau_rows; // todo: when to switch to tableau_costs?
@@ -239,14 +239,14 @@ void adjust_initial_state() {
 
 void adjust_initial_state_for_lu() {
     copy_from_mpq_matrix(A_d());
-	unsigned n = A_d().column_count();
-	m_mpq_lar_core_solver.m_d_x.resize(n);
-	m_mpq_lar_core_solver.m_d_low_bounds.resize(n);
-	m_mpq_lar_core_solver.m_d_upper_bounds.resize(n);
-	m_mpq_lar_core_solver.m_d_heading = m_mpq_lar_core_solver.m_r_heading;
-	m_mpq_lar_core_solver.m_d_basis = m_mpq_lar_core_solver.m_r_basis;
+    unsigned n = A_d().column_count();
+    m_mpq_lar_core_solver.m_d_x.resize(n);
+    m_mpq_lar_core_solver.m_d_low_bounds.resize(n);
+    m_mpq_lar_core_solver.m_d_upper_bounds.resize(n);
+    m_mpq_lar_core_solver.m_d_heading = m_mpq_lar_core_solver.m_r_heading;
+    m_mpq_lar_core_solver.m_d_basis = m_mpq_lar_core_solver.m_r_basis;
 
-	/*
+    /*
     unsigned j = A_d().column_count();
     A_d().add_column();
     lean_assert(m_mpq_lar_core_solver.m_d_x.size() == j);
diff --git a/src/util/lp/lar_core_solver.h b/src/util/lp/lar_core_solver.h
index 71d69c3a4..7e402d726 100644
--- a/src/util/lp/lar_core_solver.h
+++ b/src/util/lp/lar_core_solver.h
@@ -550,7 +550,7 @@ public:
             lean_assert(m_r_solver.m_basis_heading[leaving] >= 0);
             m_r_solver.change_basis_unconditionally(entering, leaving);
             if(!m_r_solver.pivot_column_tableau(entering, m_r_solver.m_basis_heading[entering])) {
-				// unroll the last step
+                // unroll the last step
                 m_r_solver.change_basis_unconditionally(leaving, entering);
 #ifdef LEAN_DEBUG
                 bool t =
diff --git a/src/util/lp/lar_solver.h b/src/util/lp/lar_solver.h
index c8048a550..d4b591154 100644
--- a/src/util/lp/lar_solver.h
+++ b/src/util/lp/lar_solver.h
@@ -380,8 +380,8 @@ public:
 
 
     bool term_is_used_as_row(unsigned term) const {
-		lean_assert(is_term(term));
-		return contains(m_ext_vars_to_columns, term);
+        lean_assert(is_term(term));
+        return contains(m_ext_vars_to_columns, term);
     }
 
     void propagate_bounds_on_terms(lp_bound_propagator & bp) {
@@ -484,16 +484,16 @@ public:
 
     void pop(unsigned k) {
         int n_was = static_cast<int>(m_ext_vars_to_columns.size());
-		m_status.pop(k);
-		m_infeasible_column_index.pop(k);
+        m_status.pop(k);
+        m_infeasible_column_index.pop(k);
         unsigned n = m_vars_to_ul_pairs.peek_size(k);
-		for (unsigned j = n_was; j-- > n;)
-			m_ext_vars_to_columns.erase(m_columns_to_ext_vars_or_term_indices[j]);
-		m_columns_to_ext_vars_or_term_indices.resize(n);
-		if (m_settings.use_tableau()) {
+        for (unsigned j = n_was; j-- > n;)
+            m_ext_vars_to_columns.erase(m_columns_to_ext_vars_or_term_indices[j]);
+        m_columns_to_ext_vars_or_term_indices.resize(n);
+        if (m_settings.use_tableau()) {
             pop_tableau();
         }
-		m_vars_to_ul_pairs.pop(k);
+        m_vars_to_ul_pairs.pop(k);
 
         m_mpq_lar_core_solver.pop(k);
         clean_large_elements_after_pop(n, m_columns_with_changed_bound);
@@ -501,7 +501,7 @@ public:
         clean_large_elements_after_pop(m, m_rows_with_changed_bounds);
         clean_inf_set_of_r_solver_after_pop();
         lean_assert(m_settings.simplex_strategy() == simplex_strategy_enum::undecided ||
-			(!use_tableau()) || m_mpq_lar_core_solver.m_r_solver.reduced_costs_are_correct_tableau());
+            (!use_tableau()) || m_mpq_lar_core_solver.m_r_solver.reduced_costs_are_correct_tableau());
 
 
         lean_assert(ax_is_correct());
@@ -518,9 +518,9 @@ public:
         }
         m_terms.resize(m_term_count);
         m_orig_terms.resize(m_term_count);
-		m_simplex_strategy.pop(k);
-		m_settings.simplex_strategy() = m_simplex_strategy;
-		lean_assert(sizes_are_correct());
+        m_simplex_strategy.pop(k);
+        m_settings.simplex_strategy() = m_simplex_strategy;
+        lean_assert(sizes_are_correct());
         lean_assert((!m_settings.use_tableau()) || m_mpq_lar_core_solver.m_r_solver.reduced_costs_are_correct_tableau());
     }
 
@@ -967,8 +967,8 @@ public:
 
     template <typename U, typename V>
     void copy_from_mpq_matrix(static_matrix<U, V> & matr) {
-		matr.m_rows.resize(A_r().row_count());
-		matr.m_columns.resize(A_r().column_count());
+        matr.m_rows.resize(A_r().row_count());
+        matr.m_columns.resize(A_r().column_count());
         for (unsigned i = 0; i < matr.row_count(); i++) {
             for (auto & it : A_r().m_rows[i]) {
                 matr.set(i, it.m_j,  convert_struct<U, mpq>::convert(it.get_val()));
diff --git a/src/util/lp/lp_bound_propagator.cpp b/src/util/lp/lp_bound_propagator.cpp
index 8b42f24a0..506ba138b 100644
--- a/src/util/lp/lp_bound_propagator.cpp
+++ b/src/util/lp/lp_bound_propagator.cpp
@@ -17,11 +17,11 @@ const impq & lp_bound_propagator::get_upper_bound(unsigned j) const {
 }
 void lp_bound_propagator::try_add_bound(const mpq & v, unsigned j, bool is_low, bool coeff_before_j_is_pos, unsigned row_or_term_index, bool strict) {
     unsigned term_j = m_lar_solver.adjust_column_index_to_term_index(j);
-	mpq w = v;
-	if (term_j != j) {
-		j = term_j;
-		w += m_lar_solver.get_term(term_j).m_v; // when terms are turned into the columns they "lose" the right side, at this moment they aquire it back
-	}
+    mpq w = v;
+    if (term_j != j) {
+        j = term_j;
+        w += m_lar_solver.get_term(term_j).m_v; // when terms are turned into the columns they "lose" the right side, at this moment they aquire it back
+    }
     lconstraint_kind kind = is_low? GE : LE;
     if (strict)
         kind = static_cast<lconstraint_kind>(kind / 2);
diff --git a/src/util/lp/lp_settings.h b/src/util/lp/lp_settings.h
index aac3692f9..ad40ad69d 100644
--- a/src/util/lp/lp_settings.h
+++ b/src/util/lp/lp_settings.h
@@ -278,13 +278,13 @@ public:
         return m_simplex_strategy;
     }
 
-	bool use_lu() const {
-		return m_simplex_strategy == simplex_strategy_enum::lu;
-	}
+    bool use_lu() const {
+        return m_simplex_strategy == simplex_strategy_enum::lu;
+    }
 
     bool use_tableau() const {
-		return m_simplex_strategy == simplex_strategy_enum::tableau_rows ||
-			m_simplex_strategy == simplex_strategy_enum::tableau_costs;
+        return m_simplex_strategy == simplex_strategy_enum::tableau_rows ||
+            m_simplex_strategy == simplex_strategy_enum::tableau_costs;
     }
 
     bool use_tableau_rows() const {
diff --git a/src/util/lp/lp_utils.h b/src/util/lp/lp_utils.h
index 2be15d79a..34cf4f6b9 100644
--- a/src/util/lp/lp_utils.h
+++ b/src/util/lp/lp_utils.h
@@ -18,7 +18,7 @@ bool try_get_val(const std::unordered_map<A,B> & map, const A& key, B & val) {
 
 template <typename A, typename B>
 bool contains(const std::unordered_map<A, B> & map, const A& key) {
-	return map.find(key) != map.end();
+    return map.find(key) != map.end();
 }
 
 #ifdef lp_for_z3
diff --git a/src/util/lp/stacked_vector.h b/src/util/lp/stacked_vector.h
index 3f39dd346..21202b7b8 100644
--- a/src/util/lp/stacked_vector.h
+++ b/src/util/lp/stacked_vector.h
@@ -51,10 +51,10 @@ public:
 
 private:
     void emplace_replace(unsigned i,const B & b) {
-		if (m_vector[i] != b) {
-			m_changes.push_back(std::make_pair(i, m_vector[i]));
-			m_vector[i] = b;
-		}
+        if (m_vector[i] != b) {
+            m_changes.push_back(std::make_pair(i, m_vector[i]));
+            m_vector[i] = b;
+        }
     }
 public:
 
@@ -87,14 +87,14 @@ public:
     }
 
     template <typename T>  
-	void pop_tail(vector<T> & v, unsigned k) {
-		lean_assert(v.size() >= k);
-		v.resize(v.size() - k);
-	}
+    void pop_tail(vector<T> & v, unsigned k) {
+        lean_assert(v.size() >= k);
+        v.resize(v.size() - k);
+    }
 
     template <typename T>  
     void resize(vector<T> & v, unsigned new_size) {
-		v.resize(new_size);
+        v.resize(new_size);
     }
     
     void pop(unsigned k) {
@@ -156,10 +156,10 @@ public:
         m_vector.resize(m_vector.size() + 1);
     }
 
-	unsigned peek_size(unsigned k) const {
-		lean_assert(k > 0 && k <= m_stack_of_vector_sizes.size());
-		return m_stack_of_vector_sizes[m_stack_of_vector_sizes.size() - k];
-	}
+    unsigned peek_size(unsigned k) const {
+        lean_assert(k > 0 && k <= m_stack_of_vector_sizes.size());
+        return m_stack_of_vector_sizes[m_stack_of_vector_sizes.size() - k];
+    }
 
     const vector<B>& operator()() const { return m_vector; }
 };
diff --git a/src/util/lp/static_matrix.h b/src/util/lp/static_matrix.h
index 5ef4b449f..d027c105f 100644
--- a/src/util/lp/static_matrix.h
+++ b/src/util/lp/static_matrix.h
@@ -47,7 +47,7 @@ class static_matrix
         dim(unsigned m, unsigned n) :m_m(m), m_n(n) {}
     };
     std::stack<dim> m_stack;
-	vector<unsigned> m_became_zeros; // the row indices that became zeroes during the pivoting
+    vector<unsigned> m_became_zeros; // the row indices that became zeroes during the pivoting
 public:
     typedef vector<row_cell<T>> row_strip;
     typedef vector<column_cell> column_strip;
diff --git a/src/util/lp/ul_pair.h b/src/util/lp/ul_pair.h
index 2e77a7db0..6331d17b5 100644
--- a/src/util/lp/ul_pair.h
+++ b/src/util/lp/ul_pair.h
@@ -49,8 +49,8 @@ public:
             && m_upper_bound_witness == p.m_upper_bound_witness &&
             m_i == p.m_i;
     }
-	// empty constructor
-	ul_pair() :
+    // empty constructor
+    ul_pair() :
         m_low_bound_witness(static_cast<constraint_index>(-1)),
         m_upper_bound_witness(static_cast<constraint_index>(-1)),
         m_i(static_cast<row_index>(-1))
diff --git a/src/util/map.h b/src/util/map.h
index 0d2acf11b..3a59c8975 100644
--- a/src/util/map.h
+++ b/src/util/map.h
@@ -135,7 +135,7 @@ public:
     value const& get(key const& k, value const& default_value) const {
         entry* e = find_core(k);
         if (e) {
-	  return e->get_data().m_value;
+            return e->get_data().m_value;
         }
         else {
             return default_value;
diff --git a/src/util/max_cliques.h b/src/util/max_cliques.h
index 09e40dee1..340d3fee7 100644
--- a/src/util/max_cliques.h
+++ b/src/util/max_cliques.h
@@ -92,7 +92,7 @@ public:
         m_next.reserve(std::max(src, dst) + 1);
         m_next.reserve(std::max(negate(src), negate(dst)) + 1);
         m_next[src].push_back(dst);
-		m_next[dst].push_back(src);
+        m_next[dst].push_back(src);
     }
 
     void cliques(unsigned_vector const& ps, vector<unsigned_vector>& cliques) {     
@@ -104,7 +104,7 @@ public:
             max = std::max(max, std::max(np, p) + 1);
         }
         m_next.reserve(max);
-		m_tc.reserve(m_next.size());
+        m_tc.reserve(m_next.size());
         unsigned_vector clique;
         uint_set vars;
         for (unsigned i = 0; i < num_ps; ++i) {
diff --git a/src/util/rational.h b/src/util/rational.h
index ca294e234..803c562ad 100644
--- a/src/util/rational.h
+++ b/src/util/rational.h
@@ -422,7 +422,7 @@ inline bool operator>(rational const & r1, rational const & r2) {
 }
 
 inline bool operator<(rational const & r1, int r2) {
-	return r1 < rational(r2);
+    return r1 < rational(r2);
 }
 
 inline bool operator<=(rational const & r1, rational const & r2) { 
@@ -450,11 +450,11 @@ inline rational operator+(rational const & r1, rational const & r2) {
 }
 
 inline rational operator+(int r1, rational const & r2) {
-	return rational(r1) + r2;
+    return rational(r1) + r2;
 }
 
 inline rational operator+(rational const & r1, int r2) {
-	return r1 + rational(r2);
+    return r1 + rational(r2);
 }
 
 
@@ -463,11 +463,11 @@ inline rational operator-(rational const & r1, rational const & r2) {
 }
 
 inline rational operator-(rational const & r1, int r2) {
-	return r1 - rational(r2);
+    return r1 - rational(r2);
 }
 
 inline rational operator-(int r1, rational const & r2) {
-	return rational(r1) - r2;
+    return rational(r1) - r2;
 }
 
 inline rational operator-(rational const & r) { 
@@ -492,11 +492,11 @@ inline rational operator/(rational const & r1, rational const & r2) {
 }
 
 inline rational operator/(rational const & r1, int r2) {
-	return r1 / rational(r2);
+    return r1 / rational(r2);
 }
 
-inline rational operator/(int r1, rational const &	r2) {
-	return rational(r1) / r2;
+inline rational operator/(int r1, rational const &    r2) {
+    return rational(r1) / r2;
 }
 
 inline rational power(rational const & r, unsigned p) {
diff --git a/src/util/stopwatch.h b/src/util/stopwatch.h
index 7a9066030..7f2ed3245 100644
--- a/src/util/stopwatch.h
+++ b/src/util/stopwatch.h
@@ -110,7 +110,7 @@ public:
             mach_timespec_t _stop;
             clock_get_time(m_host_clock, &_stop);
             m_time += (_stop.tv_sec - m_start.tv_sec) * 1000000000ull;
-	    m_time += (_stop.tv_nsec - m_start.tv_nsec);
+            m_time += (_stop.tv_nsec - m_start.tv_nsec);
             m_running = false;
         }
     }
@@ -163,8 +163,8 @@ public:
             struct timespec _stop;
             clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &_stop);
             m_time += (_stop.tv_sec - m_start.tv_sec) * 1000000000ull;
-	    if (m_time != 0 || _stop.tv_nsec >= m_start.tv_nsec)
-	      m_time += (_stop.tv_nsec - m_start.tv_nsec);
+            if (m_time != 0 || _stop.tv_nsec >= m_start.tv_nsec)
+                m_time += (_stop.tv_nsec - m_start.tv_nsec);
             m_running = false;
         }
     }
diff --git a/src/util/util.h b/src/util/util.h
index 440877619..23c2c1657 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -153,13 +153,13 @@ template<class T, size_t N> char (*ArraySizer(T (&)[N]))[N];
 template<typename IT>
 void display(std::ostream & out, const IT & begin, const IT & end, const char * sep, bool & first) {
     for(IT it = begin; it != end; ++it) {
-	if (first) {
-	    first = false;
-	}
-	else {
-	    out << sep;
-	}
-	out << *it;
+    if (first) {
+        first = false;
+    }
+    else {
+        out << sep;
+    }
+    out << *it;
     }
 }
 
@@ -172,9 +172,9 @@ void display(std::ostream & out, const IT & begin, const IT & end, const char *
 template<typename T>
 struct delete_proc {
     void operator()(T * ptr) { 
-	if (ptr) {
-	    dealloc(ptr);
-	}
+    if (ptr) {
+        dealloc(ptr);
+    }
     }
 };
 

From d61b722b68e5260f5a37c5dcb788fc2abe972d74 Mon Sep 17 00:00:00 2001
From: "Christoph M. Wintersteiger" <cwinter@microsoft.com>
Date: Sun, 17 Sep 2017 16:00:06 +0100
Subject: [PATCH 03/10] Partial cleanup of util/lp/*

---
 src/shell/lp_frontend.cpp                     |  22 +-
 src/smt/theory_lra.cpp                        | 318 +++++++++---------
 src/util/lp/binary_heap_priority_queue.h      |  31 +-
 src/util/lp/binary_heap_priority_queue.hpp    |  48 ++-
 .../binary_heap_priority_queue_instances.cpp  |  29 +-
 src/util/lp/binary_heap_upair_queue.h         |  27 +-
 src/util/lp/binary_heap_upair_queue.hpp       |  33 +-
 .../lp/binary_heap_upair_queue_instances.cpp  |  25 +-
 src/util/lp/bound_analyzer_on_row.h           |  35 +-
 src/util/lp/breakpoint.h                      |  25 +-
 src/util/lp/column_info.h                     |  31 +-
 src/util/lp/column_namer.h                    |  25 +-
 src/util/lp/conversion_helper.h               |   2 +-
 src/util/lp/core_solver_pretty_printer.h      |  25 +-
 src/util/lp/core_solver_pretty_printer.hpp    |  31 +-
 .../core_solver_pretty_printer_instances.cpp  |  41 ++-
 src/util/lp/dense_matrix.h                    |  29 +-
 src/util/lp/dense_matrix.hpp                  |  29 +-
 src/util/lp/dense_matrix_instances.cpp        |  57 ++--
 src/util/lp/eta_matrix.h                      |  35 +-
 src/util/lp/eta_matrix.hpp                    |  47 ++-
 src/util/lp/eta_matrix_instances.cpp          |  61 ++--
 src/util/lp/hash_helper.h                     |  27 +-
 src/util/lp/implied_bound.h                   |  25 +-
 src/util/lp/indexed_value.h                   |  27 +-
 src/util/lp/indexed_vector.h                  |  29 +-
 src/util/lp/indexed_vector.hpp                |  31 +-
 src/util/lp/indexed_vector_instances.cpp      |  51 ++-
 src/util/lp/init_lar_solver.h                 | 109 +++---
 src/util/lp/int_set.h                         |  27 +-
 src/util/lp/iterator_on_column.h              |  25 +-
 src/util/lp/iterator_on_indexed_vector.h      |  25 +-
 src/util/lp/iterator_on_pivot_row.h           |  25 +-
 src/util/lp/iterator_on_row.h                 |  25 +-
 src/util/lp/iterator_on_term_with_basis_var.h |  25 +-
 src/util/lp/lar_constraints.h                 |  29 +-
 src/util/lp/lar_core_solver.h                 | 113 ++++---
 src/util/lp/lar_core_solver.hpp               |  86 +++--
 src/util/lp/lar_core_solver_instances.cpp     |  23 +-
 src/util/lp/lar_solution_signature.h          |  25 +-
 src/util/lp/lar_solver.h                      | 213 ++++++------
 src/util/lp/lar_term.h                        |  25 +-
 src/util/lp/linear_combination_iterator.h     |  25 +-
 src/util/lp/lp_bound_propagator.cpp           |  25 +-
 src/util/lp/lp_bound_propagator.h             |  27 +-
 src/util/lp/lp_core_solver_base.h             |  53 +--
 src/util/lp/lp_core_solver_base.hpp           |  93 ++---
 src/util/lp/lp_core_solver_base_instances.cpp | 245 +++++++-------
 src/util/lp/lp_dual_core_solver.h             |  25 +-
 src/util/lp/lp_dual_core_solver.hpp           |  85 +++--
 src/util/lp/lp_dual_core_solver_instances.cpp |  45 ++-
 src/util/lp/lp_dual_simplex.h                 |  25 +-
 src/util/lp/lp_dual_simplex.hpp               |  53 +--
 src/util/lp/lp_dual_simplex_instances.cpp     |  31 +-
 src/util/lp/lp_primal_core_solver.h           | 105 +++---
 src/util/lp/lp_primal_core_solver.hpp         | 157 +++++----
 .../lp/lp_primal_core_solver_instances.cpp    |  37 +-
 ...au.hpp => lp_primal_core_solver_tableau.h} |  75 +++--
 src/util/lp/lp_primal_simplex.h               |  25 +-
 src/util/lp/lp_primal_simplex.hpp             |  45 ++-
 src/util/lp/lp_primal_simplex_instances.cpp   |  43 ++-
 src/util/lp/lp_settings.h                     |  31 +-
 src/util/lp/lp_settings.hpp                   |  33 +-
 src/util/lp/lp_settings_instances.cpp         |  27 +-
 src/util/lp/lp_solver.h                       |  25 +-
 src/util/lp/lp_solver.hpp                     |  53 +--
 src/util/lp/lp_solver_instances.cpp           |  91 ++---
 src/util/lp/lp_utils.cpp                      |  29 +-
 src/util/lp/lp_utils.h                        |  99 ++----
 src/util/lp/lu.h                              |  53 +--
 src/util/lp/lu.hpp                            | 137 ++++----
 src/util/lp/lu_instances.cpp                  | 123 ++++---
 src/util/lp/matrix.h                          |  25 +-
 src/util/lp/matrix.hpp                        |  25 +-
 src/util/lp/matrix_instances.cpp              |  37 +-
 src/util/lp/mps_reader.h                      |  41 ++-
 src/util/lp/numeric_pair.h                    |  80 ++---
 src/util/lp/permutation_matrix.h              |  33 +-
 src/util/lp/permutation_matrix.hpp            |  83 +++--
 src/util/lp/permutation_matrix_instances.cpp  | 115 ++++---
 src/util/lp/quick_xplain.cpp                  |  47 ++-
 src/util/lp/quick_xplain.h                    |   2 +-
 src/util/lp/random_updater.h                  |   2 +-
 src/util/lp/random_updater.hpp                |  61 ++--
 src/util/lp/random_updater_instances.cpp      |  23 +-
 src/util/lp/row_eta_matrix.h                  |  35 +-
 src/util/lp/row_eta_matrix.hpp                |  57 ++--
 src/util/lp/row_eta_matrix_instances.cpp      |  27 +-
 src/util/lp/scaler.h                          |  27 +-
 src/util/lp/scaler.hpp                        |  31 +-
 src/util/lp/scaler_instances.cpp              |  27 +-
 src/util/lp/signature_bound_evidence.h        |  25 +-
 src/util/lp/sparse_matrix.h                   |  51 ++-
 src/util/lp/sparse_matrix.hpp                 | 135 ++++----
 src/util/lp/sparse_matrix_instances.cpp       |  77 +++--
 src/util/lp/sparse_vector.h                   |  29 +-
 src/util/lp/square_dense_submatrix.h          |  45 ++-
 src/util/lp/square_dense_submatrix.hpp        |  71 ++--
 .../lp/square_dense_submatrix_instances.cpp   |  71 ++--
 src/util/lp/stacked_map.h                     |  37 +-
 src/util/lp/stacked_unordered_set.h           |  27 +-
 src/util/lp/stacked_value.h                   |  25 +-
 src/util/lp/stacked_vector.h                  |  22 +-
 src/util/lp/static_matrix.h                   |  57 ++--
 src/util/lp/static_matrix.hpp                 |  63 ++--
 src/util/lp/static_matrix_instances.cpp       |  41 ++-
 src/util/lp/tail_matrix.h                     |  27 +-
 src/util/lp/test_bound_analyzer.h             |  29 +-
 src/util/lp/ul_pair.h                         |  25 +-
 109 files changed, 3503 insertions(+), 2023 deletions(-)
 rename src/util/lp/{lp_primal_core_solver_tableau.hpp => lp_primal_core_solver_tableau.h} (90%)

diff --git a/src/shell/lp_frontend.cpp b/src/shell/lp_frontend.cpp
index 61015c860..95f9e1eb3 100644
--- a/src/shell/lp_frontend.cpp
+++ b/src/shell/lp_frontend.cpp
@@ -1,7 +1,7 @@
 /*++
 Copyright (c) 2016 Microsoft Corporation
 
-Author: 
+Author:
 
     Lev Nachmanson 2016-10-27
 
@@ -17,7 +17,7 @@ Author:
 #include "util/gparams.h"
 #include <signal.h>
 
-static lean::lp_solver<double, double>* g_solver = 0;
+static lp::lp_solver<double, double>* g_solver = 0;
 
 static void display_statistics() {
     if (g_solver && g_solver->settings().print_statistics) {
@@ -42,7 +42,7 @@ static void on_timeout() {
     }
 }
 
-struct front_end_resource_limit : public lean::lp_resource_limit {
+struct front_end_resource_limit : public lp::lp_resource_limit {
     reslimit& m_reslim;
 
     front_end_resource_limit(reslimit& lim):
@@ -54,7 +54,7 @@ struct front_end_resource_limit : public lean::lp_resource_limit {
 
 void run_solver(lp_params & params, char const * mps_file_name) {
 
-    reslimit rlim;    
+    reslimit rlim;
     unsigned timeout = gparams::get().get_uint("timeout", 0);
     unsigned rlimit  = gparams::get().get_uint("rlimit", 0);
     front_end_resource_limit lp_limit(rlim);
@@ -64,14 +64,14 @@ void run_solver(lp_params & params, char const * mps_file_name) {
     scoped_timer timer(timeout, &eh);
 
     std::string fn(mps_file_name);
-    lean::mps_reader<double, double> reader(fn);
+    lp::mps_reader<double, double> reader(fn);
     reader.set_message_stream(&std::cout); // can be redirected
     reader.read();
     if (!reader.is_ok()) {
         std::cerr << "cannot process " << mps_file_name << std::endl;
         return;
     }
-    lean::lp_solver<double, double> * solver =  reader.create_solver(false);  // false - to create the primal solver
+    lp::lp_solver<double, double> * solver =  reader.create_solver(false);  // false - to create the primal solver
     solver->settings().set_resource_limit(lp_limit);
     g_solver = solver;
     if (params.min()) {
@@ -80,20 +80,20 @@ void run_solver(lp_params & params, char const * mps_file_name) {
     solver->settings().set_message_ostream(&std::cout);
     solver->settings().report_frequency = params.rep_freq();
     solver->settings().print_statistics = params.print_stats();
-    solver->settings().simplex_strategy() = lean:: simplex_strategy_enum::lu;
-    
+    solver->settings().simplex_strategy() = lp:: simplex_strategy_enum::lu;
+
     solver->find_maximal_solution();
 
     *(solver->settings().get_message_ostream()) << "status is " << lp_status_to_string(solver->get_status()) << std::endl;
-    if (solver->get_status() == lean::OPTIMAL) {
+    if (solver->get_status() == lp::OPTIMAL) {
         if (params.min()) {
             solver->flip_costs();
         }
         solver->print_model(std::cout);
     }
-    
+
 //    #pragma omp critical (g_display_stats)
-    {    
+    {
         display_statistics();
         register_on_timeout_proc(0);
         g_solver = 0;
diff --git a/src/smt/theory_lra.cpp b/src/smt/theory_lra.cpp
index a09005b7e..bd8572d73 100644
--- a/src/smt/theory_lra.cpp
+++ b/src/smt/theory_lra.cpp
@@ -38,7 +38,7 @@ Revision History:
 #include "util/nat_set.h"
 #include "tactic/filter_model_converter.h"
 
-namespace lp {
+namespace lra_lp {
     enum bound_kind { lower_t, upper_t };
 
     std::ostream& operator<<(std::ostream& out, bound_kind const& k) {
@@ -50,7 +50,7 @@ namespace lp {
     }
 
     class bound {
-        smt::bool_var     m_bv;
+        smt::bool_var    m_bv;
         smt::theory_var  m_var;
         rational         m_value;
         bound_kind       m_bound_kind;
@@ -111,7 +111,7 @@ namespace lp {
 
 namespace smt {
 
-    typedef ptr_vector<lp::bound> lp_bounds;
+    typedef ptr_vector<lra_lp::bound> lp_bounds;
 
     class theory_lra::imp {
 
@@ -133,7 +133,7 @@ namespace smt {
             delayed_atom(unsigned b, bool t): m_bv(b), m_is_true(t) {}
         };
 
-        class resource_limit : public lean::lp_resource_limit {
+        class resource_limit : public lp::lp_resource_limit {
             imp& m_imp;
         public:
             resource_limit(imp& i): m_imp(i) { }
@@ -198,7 +198,7 @@ namespace smt {
             }
         };
 
-        typedef vector<std::pair<rational, lean::var_index>> var_coeffs;
+        typedef vector<std::pair<rational, lp::var_index>> var_coeffs;
         struct delayed_def {
             vector<rational>    m_coeffs;
             svector<theory_var> m_vars;
@@ -208,11 +208,11 @@ namespace smt {
                 m_coeffs(coeffs), m_vars(vars), m_coeff(r), m_var(v) {}
         };
 
-        svector<lean::var_index> m_theory_var2var_index;   // translate from theory variables to lar vars
+        svector<lp::var_index> m_theory_var2var_index;   // translate from theory variables to lar vars
         svector<theory_var>      m_var_index2theory_var;   // reverse map from lp_solver variables to theory variables
         svector<theory_var>      m_term_index2theory_var;   // reverse map from lp_solver variables to theory variables
         var_coeffs               m_left_side;              // constraint left side
-        mutable std::unordered_map<lean::var_index, rational> m_variable_values; // current model
+        mutable std::unordered_map<lp::var_index, rational> m_variable_values; // current model
 
         enum constraint_source {
             inequality_source,
@@ -233,10 +233,10 @@ namespace smt {
         expr*                  m_not_handled;
         ptr_vector<app>        m_underspecified;
         unsigned_vector        m_var_trail;
-        vector<ptr_vector<lp::bound> > m_use_list;        // bounds where variables are used.
+        vector<ptr_vector<lra_lp::bound> > m_use_list;        // bounds where variables are used.
 
         // attributes for incremental version:
-        u_map<lp::bound*>      m_bool_var2bound;
+        u_map<lra_lp::bound*>      m_bool_var2bound;
         vector<lp_bounds>      m_bounds;
         unsigned_vector        m_unassigned_bounds;
         unsigned_vector        m_bounds_trail;
@@ -258,15 +258,15 @@ namespace smt {
         struct var_value_hash {
             imp & m_th;
             var_value_hash(imp & th):m_th(th) {}
-            unsigned operator()(theory_var v) const { return (unsigned)std::hash<lean::impq>()(m_th.get_ivalue(v)); }
+            unsigned operator()(theory_var v) const { return (unsigned)std::hash<lp::impq>()(m_th.get_ivalue(v)); }
         };
         int_hashtable<var_value_hash, var_value_eq>   m_model_eqs;
 
 
         svector<scope>         m_scopes;
-        lp::stats              m_stats;
+        lra_lp::stats              m_stats;
         arith_factory*         m_factory;
-        scoped_ptr<lean::lar_solver> m_solver;
+        scoped_ptr<lp::lar_solver> m_solver;
         resource_limit         m_resource_limit;
         lp_bounds              m_new_bounds;
 
@@ -282,10 +282,10 @@ namespace smt {
         void init_solver() {
             if (m_solver) return;
             lp_params lp(ctx().get_params());
-            m_solver = alloc(lean::lar_solver);
+            m_solver = alloc(lp::lar_solver);
             m_theory_var2var_index.reset();
             m_solver->settings().set_resource_limit(m_resource_limit);
-            m_solver->settings().simplex_strategy() = static_cast<lean::simplex_strategy_enum>(lp.simplex_strategy());
+            m_solver->settings().simplex_strategy() = static_cast<lp::simplex_strategy_enum>(lp.simplex_strategy());
             reset_variable_values();
             m_solver->settings().bound_propagation() = BP_NONE != propagation_mode();
             m_solver->set_propagate_bounds_on_pivoted_rows_mode(lp.bprop_on_pivoted_rows());
@@ -487,8 +487,8 @@ namespace smt {
             return v;
         }
 
-        lean::var_index get_var_index(theory_var v) {
-            lean::var_index result = UINT_MAX;
+        lp::var_index get_var_index(theory_var v) {
+            lp::var_index result = UINT_MAX;
             if (m_theory_var2var_index.size() > static_cast<unsigned>(v)) {
                 result = m_theory_var2var_index[v];
             }
@@ -537,20 +537,20 @@ namespace smt {
             return true;
         }
 
-        void add_eq_constraint(lean::constraint_index index, enode* n1, enode* n2) {
+        void add_eq_constraint(lp::constraint_index index, enode* n1, enode* n2) {
             m_constraint_sources.setx(index, equality_source, null_source);
             m_equalities.setx(index, enode_pair(n1, n2), enode_pair(0, 0));
             ++m_stats.m_add_rows;
         }
 
-        void add_ineq_constraint(lean::constraint_index index, literal lit) {
+        void add_ineq_constraint(lp::constraint_index index, literal lit) {
             m_constraint_sources.setx(index, inequality_source, null_source);
             m_inequalities.setx(index, lit, null_literal);
             ++m_stats.m_add_rows;
             TRACE("arith", m_solver->print_constraint(index, tout); tout << "\n";);
         }
 
-        void add_def_constraint(lean::constraint_index index, theory_var v) {
+        void add_def_constraint(lp::constraint_index index, theory_var v) {
             m_constraint_sources.setx(index, definition_source, null_source);
             m_definitions.setx(index, v, null_theory_var);
             ++m_stats.m_add_rows;
@@ -561,7 +561,7 @@ namespace smt {
             st.vars().append(d.m_vars);
             st.coeffs().append(d.m_coeffs);
             init_left_side(st);
-            add_def_constraint(m_solver->add_constraint(m_left_side, lean::EQ, -d.m_coeff), d.m_var);
+            add_def_constraint(m_solver->add_constraint(m_left_side, lp::EQ, -d.m_coeff), d.m_var);
         }
 
         void internalize_eq(theory_var v1, theory_var v2) {
@@ -573,7 +573,7 @@ namespace smt {
             st.coeffs().push_back(rational::one());
             st.coeffs().push_back(rational::minus_one());
             init_left_side(st);
-            add_eq_constraint(m_solver->add_constraint(m_left_side, lean::EQ, rational::zero()), n1, n2);
+            add_eq_constraint(m_solver->add_constraint(m_left_side, lp::EQ, rational::zero()), n1, n2);
             TRACE("arith",
                   tout << "v" << v1 << " = " << "v" << v2 << ": "
                   << mk_pp(n1->get_owner(), m) << " = " << mk_pp(n2->get_owner(), m) << "\n";);
@@ -583,7 +583,7 @@ namespace smt {
             for (unsigned i = m_bounds_trail.size(); i > old_size; ) {
                 --i;
                 unsigned v = m_bounds_trail[i];
-                lp::bound* b = m_bounds[v].back();
+                lra_lp::bound* b = m_bounds[v].back();
                 // del_use_lists(b);
                 dealloc(b);
                 m_bounds[v].pop_back();
@@ -626,7 +626,7 @@ namespace smt {
             else {
                 init_left_side(st);
                 theory_var v = mk_var(term);
-                lean::var_index vi = m_theory_var2var_index.get(v, UINT_MAX);
+                lp::var_index vi = m_theory_var2var_index.get(v, UINT_MAX);
                 if (vi == UINT_MAX) {
                     vi = m_solver->add_term(m_left_side, st.coeff());
                     m_theory_var2var_index.setx(v, vi, UINT_MAX);
@@ -691,22 +691,22 @@ namespace smt {
             ctx().set_var_theory(bv, get_id());
             expr* n1, *n2;
             rational r;
-            lp::bound_kind k;
+            lra_lp::bound_kind k;
             theory_var v = null_theory_var;
             if (a.is_le(atom, n1, n2) && is_numeral(n2, r) && is_app(n1)) {
                 v = internalize_def(to_app(n1));
-                k = lp::upper_t;
+                k = lra_lp::upper_t;
             }
             else if (a.is_ge(atom, n1, n2) && is_numeral(n2, r) && is_app(n1)) {
                 v = internalize_def(to_app(n1));
-                k = lp::lower_t;
+                k = lra_lp::lower_t;
             }
             else {
                 TRACE("arith", tout << "Could not internalize " << mk_pp(atom, m) << "\n";);
                 found_not_handled(atom);
                 return true;
             }
-            lp::bound* b = alloc(lp::bound, bv, v, r, k);
+            lra_lp::bound* b = alloc(lra_lp::bound, bv, v, r, k);
             m_bounds[v].push_back(b);
             updt_unassigned_bounds(v, +1);
             m_bounds_trail.push_back(v);
@@ -723,23 +723,23 @@ namespace smt {
             ctx().set_var_theory(bv, get_id());
             expr* n1, *n2;
             rational r;
-            lp::bound_kind k;
+            lra_lp::bound_kind k;
             theory_var v = null_theory_var;
             scoped_internalize_state st(*this);
             if (a.is_le(atom, n1, n2) && is_numeral(n2, r) && is_app(n1)) {
                 v = internalize_def(to_app(n1), st);
-                k = lp::upper_t;
+                k = lra_lp::upper_t;
             }
             else if (a.is_ge(atom, n1, n2) && is_numeral(n2, r) && is_app(n1)) {
                 v = internalize_def(to_app(n1), st);
-                k = lp::lower_t;
+                k = lra_lp::lower_t;
             }
             else {
                 TRACE("arith", tout << "Could not internalize " << mk_pp(atom, m) << "\n";);
                 found_not_handled(atom);
                 return true;
             }
-            lp::bound* b = alloc(lp::bound, bv, v, r, k);
+            lra_lp::bound* b = alloc(lra_lp::bound, bv, v, r, k);
             m_bounds[v].push_back(b);
             updt_unassigned_bounds(v, +1);
             m_bounds_trail.push_back(v);
@@ -830,7 +830,7 @@ namespace smt {
             unsigned old_size = m_scopes.size() - num_scopes;
             del_bounds(m_scopes[old_size].m_bounds_lim);
             for (unsigned i = m_scopes[old_size].m_var_trail_lim; i < m_var_trail.size(); ++i) {
-                lean::var_index vi = m_theory_var2var_index[m_var_trail[i]];
+                lp::var_index vi = m_theory_var2var_index[m_var_trail[i]];
                 if (m_solver->is_term(vi)) {
                     unsigned ti = m_solver->adjust_term_index(vi);
                     m_term_index2theory_var[ti] = UINT_MAX;
@@ -1023,14 +1023,14 @@ namespace smt {
             return m_solver->var_is_registered(m_theory_var2var_index[v]);
         }
 
-        lean::impq get_ivalue(theory_var v) const {
-            lean_assert(can_get_ivalue(v));
-            lean::var_index vi = m_theory_var2var_index[v];
+        lp::impq get_ivalue(theory_var v) const {
+            SASSERT(can_get_ivalue(v));
+            lp::var_index vi = m_theory_var2var_index[v];
             if (!m_solver->is_term(vi))
                 return m_solver->get_value(vi);
 
-            const lean::lar_term& term = m_solver->get_term(vi);
-            lean::impq result(term.m_v);
+            const lp::lar_term& term = m_solver->get_term(vi);
+            lp::impq result(term.m_v);
             for (const auto & i:  term.m_coeffs) {
                 result += m_solver->get_value(i.first) * i.second;
             }
@@ -1040,12 +1040,12 @@ namespace smt {
 
         rational get_value(theory_var v) const {
             if (!can_get_value(v)) return rational::zero();
-            lean::var_index vi = m_theory_var2var_index[v];
+            lp::var_index vi = m_theory_var2var_index[v];
             if (m_variable_values.count(vi) > 0) {
                 return m_variable_values[vi];
             }
             if (m_solver->is_term(vi)) {
-                const lean::lar_term& term = m_solver->get_term(vi);
+                const lp::lar_term& term = m_solver->get_term(vi);
                 rational result = term.m_v;
                 for (auto i = term.m_coeffs.begin();  i != term.m_coeffs.end(); ++i) {
                     result += m_variable_values[i->first] * i->second;
@@ -1068,7 +1068,7 @@ namespace smt {
         }
 
         bool assume_eqs() {
-            svector<lean::var_index> vars;
+            svector<lp::var_index> vars;
             theory_var sz = static_cast<theory_var>(th.get_num_vars());
             for (theory_var v = 0; v < sz; ++v) {
                 if (th.is_relevant_and_shared(get_enode(v))) {
@@ -1169,7 +1169,7 @@ namespace smt {
                 }
                 is_sat = make_feasible();
             }
-            else if (m_solver->get_status() != lean::lp_status::OPTIMAL) {
+            else if (m_solver->get_status() != lp::lp_status::OPTIMAL) {
                 is_sat = make_feasible();
             }
             switch (is_sat) {
@@ -1266,7 +1266,7 @@ namespace smt {
                 propagate_bound(bv, is_true, b);
 #endif
                 if (!m_delay_constraints) {
-                    lp::bound& b = *m_bool_var2bound.find(bv);
+                    lra_lp::bound& b = *m_bool_var2bound.find(bv);
                     assert_bound(bv, is_true, b);
                 }
 
@@ -1279,7 +1279,7 @@ namespace smt {
             /*for (; qhead < m_asserted_atoms.size() && !ctx().inconsistent(); ++qhead) {
                 bool_var bv  = m_asserted_atoms[qhead].m_bv;
                 bool is_true = m_asserted_atoms[qhead].m_is_true;
-                lp::bound& b = *m_bool_var2bound.find(bv);
+                lra_lp::bound& b = *m_bool_var2bound.find(bv);
                 propagate_bound_compound(bv, is_true, b);
             }*/
 
@@ -1314,7 +1314,7 @@ namespace smt {
             int new_num_of_p = m_solver->settings().st().m_num_of_implied_bounds;
             (void)new_num_of_p;
             CTRACE("arith", new_num_of_p > num_of_p, tout << "found " << new_num_of_p << " implied bounds\n";);
-            if (m_solver->get_status() == lean::lp_status::INFEASIBLE) {
+            if (m_solver->get_status() == lp::lp_status::INFEASIBLE) {
                 set_conflict();
             }
             else {
@@ -1324,7 +1324,7 @@ namespace smt {
             }
         }
 
-        bool bound_is_interesting(unsigned vi, lean::lconstraint_kind kind, const rational & bval) const {
+        bool bound_is_interesting(unsigned vi, lp::lconstraint_kind kind, const rational & bval) const {
             theory_var v;
             if (m_solver->is_term(vi)) {
                 v = m_term_index2theory_var.get(m_solver->adjust_term_index(vi), null_theory_var);
@@ -1341,7 +1341,7 @@ namespace smt {
             }
             lp_bounds const& bounds = m_bounds[v];
             for (unsigned i = 0; i < bounds.size(); ++i) {
-                lp::bound* b = bounds[i];
+                lra_lp::bound* b = bounds[i];
                 if (ctx().get_assignment(b->get_bv()) != l_undef) {
                     continue;
                 }
@@ -1354,11 +1354,11 @@ namespace smt {
             return false;
         }
 
-        struct local_bound_propagator: public lean::lp_bound_propagator {
+        struct local_bound_propagator: public lp::lp_bound_propagator {
             imp & m_imp;
             local_bound_propagator(imp& i) : lp_bound_propagator(*i.m_solver), m_imp(i) {}
 
-            bool bound_is_interesting(unsigned j, lean::lconstraint_kind kind, const rational & v) {
+            bool bound_is_interesting(unsigned j, lp::lconstraint_kind kind, const rational & v) {
                 return m_imp.bound_is_interesting(j, kind, v);
             }
 
@@ -1368,10 +1368,10 @@ namespace smt {
         };
 
 
-        void propagate_lp_solver_bound(lean::implied_bound& be) {
+        void propagate_lp_solver_bound(lp::implied_bound& be) {
 
             theory_var v;
-            lean::var_index vi = be.m_j;
+            lp::var_index vi = be.m_j;
             if (m_solver->is_term(vi)) {
                 v = m_term_index2theory_var.get(m_solver->adjust_term_index(vi), null_theory_var);
             }
@@ -1392,7 +1392,7 @@ namespace smt {
             lp_bounds const& bounds = m_bounds[v];
             bool first = true;
             for (unsigned i = 0; i < bounds.size(); ++i) {
-                lp::bound* b = bounds[i];
+                lra_lp::bound* b = bounds[i];
                 if (ctx().get_assignment(b->get_bv()) != l_undef) {
                     continue;
                 }
@@ -1455,28 +1455,28 @@ namespace smt {
             }
         }
 
-        literal is_bound_implied(lean::lconstraint_kind k, rational const& value, lp::bound const& b) const {
-            if ((k == lean::LE || k == lean::LT) && b.get_bound_kind() == lp::upper_t && value <= b.get_value()) {
+        literal is_bound_implied(lp::lconstraint_kind k, rational const& value, lra_lp::bound const& b) const {
+            if ((k == lp::LE || k == lp::LT) && b.get_bound_kind() == lra_lp::upper_t && value <= b.get_value()) {
                 // v <= value <= b.get_value() => v <= b.get_value()
                 return literal(b.get_bv(), false);
             }
-            if ((k == lean::GE || k == lean::GT) && b.get_bound_kind() == lp::lower_t && b.get_value() <= value) {
+            if ((k == lp::GE || k == lp::GT) && b.get_bound_kind() == lra_lp::lower_t && b.get_value() <= value) {
                 // b.get_value() <= value <= v => b.get_value() <= v
                 return literal(b.get_bv(), false);
             }
-            if (k == lean::LE && b.get_bound_kind() == lp::lower_t && value < b.get_value()) {
+            if (k == lp::LE && b.get_bound_kind() == lra_lp::lower_t && value < b.get_value()) {
                 // v <= value < b.get_value() => v < b.get_value()
                 return literal(b.get_bv(), true);
             }
-            if (k == lean::LT && b.get_bound_kind() == lp::lower_t && value <= b.get_value()) {
+            if (k == lp::LT && b.get_bound_kind() == lra_lp::lower_t && value <= b.get_value()) {
                 // v < value <= b.get_value() => v < b.get_value()
                 return literal(b.get_bv(), true);
             }
-            if (k == lean::GE && b.get_bound_kind() == lp::upper_t && b.get_value() < value) {
+            if (k == lp::GE && b.get_bound_kind() == lra_lp::upper_t && b.get_value() < value) {
                 // b.get_value() < value <= v => b.get_value() < v
                 return literal(b.get_bv(), true);
             }
-            if (k == lean::GT && b.get_bound_kind() == lp::upper_t && b.get_value() <= value) {
+            if (k == lp::GT && b.get_bound_kind() == lra_lp::upper_t && b.get_value() <= value) {
                 // b.get_value() <= value < v => b.get_value() < v
                 return literal(b.get_bv(), true);
             }
@@ -1484,7 +1484,7 @@ namespace smt {
             return null_literal;
         }
 
-        void mk_bound_axioms(lp::bound& b) {
+        void mk_bound_axioms(lra_lp::bound& b) {
             if (!ctx().is_searching()) {
                 //
                 // NB. We make an assumption that user push calls propagation
@@ -1495,19 +1495,19 @@ namespace smt {
                 return;
             }
             theory_var v = b.get_var();
-            lp::bound_kind kind1 = b.get_bound_kind();
+            lra_lp::bound_kind kind1 = b.get_bound_kind();
             rational const& k1 = b.get_value();
             lp_bounds & bounds = m_bounds[v];
 
-            lp::bound* end = 0;
-            lp::bound* lo_inf = end, *lo_sup = end;
-            lp::bound* hi_inf = end, *hi_sup = end;
+            lra_lp::bound* end = 0;
+            lra_lp::bound* lo_inf = end, *lo_sup = end;
+            lra_lp::bound* hi_inf = end, *hi_sup = end;
 
             for (unsigned i = 0; i < bounds.size(); ++i) {
-                lp::bound& other = *bounds[i];
+                lra_lp::bound& other = *bounds[i];
                 if (&other == &b) continue;
                 if (b.get_bv() == other.get_bv()) continue;
-                lp::bound_kind kind2 = other.get_bound_kind();
+                lra_lp::bound_kind kind2 = other.get_bound_kind();
                 rational const& k2 = other.get_value();
                 if (k1 == k2 && kind1 == kind2) {
                     // the bounds are equivalent.
@@ -1515,7 +1515,7 @@ namespace smt {
                 }
 
                 SASSERT(k1 != k2 || kind1 != kind2);
-                if (kind2 == lp::lower_t) {
+                if (kind2 == lra_lp::lower_t) {
                     if (k2 < k1) {
                         if (lo_inf == end || k2 > lo_inf->get_value()) {
                             lo_inf = &other;
@@ -1541,14 +1541,14 @@ namespace smt {
         }
 
 
-        void mk_bound_axiom(lp::bound& b1, lp::bound& b2) {
+        void mk_bound_axiom(lra_lp::bound& b1, lra_lp::bound& b2) {
             theory_var v = b1.get_var();
             literal   l1(b1.get_bv());
             literal   l2(b2.get_bv());
             rational const& k1 = b1.get_value();
             rational const& k2 = b2.get_value();
-            lp::bound_kind kind1 = b1.get_bound_kind();
-            lp::bound_kind kind2 = b2.get_bound_kind();
+            lra_lp::bound_kind kind1 = b1.get_bound_kind();
+            lra_lp::bound_kind kind2 = b2.get_bound_kind();
             bool v_is_int = is_int(v);
             SASSERT(v == b2.get_var());
             if (k1 == k2 && kind1 == kind2) return;
@@ -1556,8 +1556,8 @@ namespace smt {
             parameter coeffs[3] = { parameter(symbol("farkas")),
                                     parameter(rational(1)), parameter(rational(1)) };
 
-            if (kind1 == lp::lower_t) {
-                if (kind2 == lp::lower_t) {
+            if (kind1 == lra_lp::lower_t) {
+                if (kind2 == lra_lp::lower_t) {
                     if (k2 <= k1) {
                         mk_clause(~l1, l2, 3, coeffs);
                     }
@@ -1578,7 +1578,7 @@ namespace smt {
                     }
                 }
             }
-            else if (kind2 == lp::lower_t) {
+            else if (kind2 == lra_lp::lower_t) {
                 if (k1 >= k2) {
                     // k1 >= lo_inf, k1 >= x or lo_inf <= x
                     mk_clause(l1, l2, 3, coeffs);
@@ -1636,21 +1636,21 @@ namespace smt {
                 iterator begin1 = occs.begin();
                 iterator begin2 = occs.begin();
                 iterator end = occs.end();
-                begin1 = first(lp::lower_t, begin1, end);
-                begin2 = first(lp::upper_t, begin2, end);
+                begin1 = first(lra_lp::lower_t, begin1, end);
+                begin2 = first(lra_lp::upper_t, begin2, end);
 
                 iterator lo_inf = begin1, lo_sup = begin1;
                 iterator hi_inf = begin2, hi_sup = begin2;
                 iterator lo_inf1 = begin1, lo_sup1 = begin1;
                 iterator hi_inf1 = begin2, hi_sup1 = begin2;
                 bool flo_inf, fhi_inf, flo_sup, fhi_sup;
-                ptr_addr_hashtable<lp::bound> visited;
+                ptr_addr_hashtable<lra_lp::bound> visited;
                 for (unsigned i = 0; i < atoms.size(); ++i) {
-                    lp::bound* a1 = atoms[i];
-                    lo_inf1 = next_inf(a1, lp::lower_t, lo_inf, end, flo_inf);
-                    hi_inf1 = next_inf(a1, lp::upper_t, hi_inf, end, fhi_inf);
-                    lo_sup1 = next_sup(a1, lp::lower_t, lo_sup, end, flo_sup);
-                    hi_sup1 = next_sup(a1, lp::upper_t, hi_sup, end, fhi_sup);
+                    lra_lp::bound* a1 = atoms[i];
+                    lo_inf1 = next_inf(a1, lra_lp::lower_t, lo_inf, end, flo_inf);
+                    hi_inf1 = next_inf(a1, lra_lp::upper_t, hi_inf, end, fhi_inf);
+                    lo_sup1 = next_sup(a1, lra_lp::lower_t, lo_sup, end, flo_sup);
+                    hi_sup1 = next_sup(a1, lra_lp::upper_t, hi_sup, end, fhi_sup);
                     if (lo_inf1 != end) lo_inf = lo_inf1;
                     if (lo_sup1 != end) lo_sup = lo_sup1;
                     if (hi_inf1 != end) hi_inf = hi_inf1;
@@ -1669,24 +1669,24 @@ namespace smt {
         }
 
         struct compare_bounds {
-            bool operator()(lp::bound* a1, lp::bound* a2) const { return a1->get_value() < a2->get_value(); }
+            bool operator()(lra_lp::bound* a1, lra_lp::bound* a2) const { return a1->get_value() < a2->get_value(); }
         };
 
 
         lp_bounds::iterator first(
-            lp::bound_kind kind,
+            lra_lp::bound_kind kind,
             iterator it,
             iterator end) {
             for (; it != end; ++it) {
-                lp::bound* a = *it;
+                lra_lp::bound* a = *it;
                 if (a->get_bound_kind() == kind) return it;
             }
             return end;
         }
 
         lp_bounds::iterator next_inf(
-            lp::bound* a1,
-            lp::bound_kind kind,
+            lra_lp::bound* a1,
+            lra_lp::bound_kind kind,
             iterator it,
             iterator end,
             bool& found_compatible) {
@@ -1694,7 +1694,7 @@ namespace smt {
             iterator result = end;
             found_compatible = false;
             for (; it != end; ++it) {
-                lp::bound * a2 = *it;
+                lra_lp::bound * a2 = *it;
                 if (a1 == a2) continue;
                 if (a2->get_bound_kind() != kind) continue;
                 rational const & k2(a2->get_value());
@@ -1710,15 +1710,15 @@ namespace smt {
         }
 
         lp_bounds::iterator next_sup(
-            lp::bound* a1,
-            lp::bound_kind kind,
+            lra_lp::bound* a1,
+            lra_lp::bound_kind kind,
             iterator it,
             iterator end,
             bool& found_compatible) {
             rational const & k1(a1->get_value());
             found_compatible = false;
             for (; it != end; ++it) {
-                lp::bound * a2 = *it;
+                lra_lp::bound * a2 = *it;
                 if (a1 == a2) continue;
                 if (a2->get_bound_kind() != kind) continue;
                 rational const & k2(a2->get_value());
@@ -1732,7 +1732,7 @@ namespace smt {
 
         void propagate_basic_bounds() {
             for (auto const& bv : m_to_check) {
-                lp::bound& b = *m_bool_var2bound.find(bv);
+                lra_lp::bound& b = *m_bool_var2bound.find(bv);
                 propagate_bound(bv, ctx().get_assignment(bv) == l_true, b);
                 if (ctx().inconsistent()) break;
 
@@ -1747,11 +1747,11 @@ namespace smt {
         //   x <= hi -> x <= hi'
         //   x <= hi -> ~(x >= hi')
 
-        void propagate_bound(bool_var bv, bool is_true, lp::bound& b) {
+        void propagate_bound(bool_var bv, bool is_true, lra_lp::bound& b) {
             if (BP_NONE == propagation_mode()) {
                 return;
             }
-            lp::bound_kind k = b.get_bound_kind();
+            lra_lp::bound_kind k = b.get_bound_kind();
             theory_var v = b.get_var();
             inf_rational val = b.get_value(is_true);
             lp_bounds const& bounds = m_bounds[v];
@@ -1761,12 +1761,12 @@ namespace smt {
 
             literal lit1(bv, !is_true);
             literal lit2 = null_literal;
-            bool find_glb = (is_true == (k == lp::lower_t));
+            bool find_glb = (is_true == (k == lra_lp::lower_t));
             if (find_glb) {
                 rational glb;
-                lp::bound* lb = 0;
+                lra_lp::bound* lb = 0;
                 for (unsigned i = 0; i < bounds.size(); ++i) {
-                    lp::bound* b2 = bounds[i];
+                    lra_lp::bound* b2 = bounds[i];
                     if (b2 == &b) continue;
                     rational const& val2 = b2->get_value();
                     if ((is_true ? val2 < val : val2 <= val) && (!lb || glb < val2)) {
@@ -1775,14 +1775,14 @@ namespace smt {
                     }
                 }
                 if (!lb) return;
-                bool sign = lb->get_bound_kind() != lp::lower_t;
+                bool sign = lb->get_bound_kind() != lra_lp::lower_t;
                 lit2 = literal(lb->get_bv(), sign);
             }
             else {
                 rational lub;
-                lp::bound* ub = 0;
+                lra_lp::bound* ub = 0;
                 for (unsigned i = 0; i < bounds.size(); ++i) {
-                    lp::bound* b2 = bounds[i];
+                    lra_lp::bound* b2 = bounds[i];
                     if (b2 == &b) continue;
                     rational const& val2 = b2->get_value();
                     if ((is_true ? val < val2 : val <= val2) && (!ub || val2 < lub)) {
@@ -1791,7 +1791,7 @@ namespace smt {
                     }
                 }
                 if (!ub) return;
-                bool sign = ub->get_bound_kind() != lp::upper_t;
+                bool sign = ub->get_bound_kind() != lra_lp::upper_t;
                 lit2 = literal(ub->get_bv(), sign);
             }
             TRACE("arith",
@@ -1811,27 +1811,27 @@ namespace smt {
             ++m_stats.m_bounds_propagations;
         }
 
-        void add_use_lists(lp::bound* b) {
+        void add_use_lists(lra_lp::bound* b) {
             theory_var v = b->get_var();
-            lean::var_index vi = get_var_index(v);
+            lp::var_index vi = get_var_index(v);
             if (m_solver->is_term(vi)) {
-                lean::lar_term const& term = m_solver->get_term(vi);
+                lp::lar_term const& term = m_solver->get_term(vi);
                 for (auto i = term.m_coeffs.begin(); i != term.m_coeffs.end(); ++i) {
-                    lean::var_index wi = i->first;
+                    lp::var_index wi = i->first;
                     unsigned w = m_var_index2theory_var[wi];
-                    m_use_list.reserve(w + 1, ptr_vector<lp::bound>());
+                    m_use_list.reserve(w + 1, ptr_vector<lra_lp::bound>());
                     m_use_list[w].push_back(b);
                 }
             }
         }
 
-        void del_use_lists(lp::bound* b) {
+        void del_use_lists(lra_lp::bound* b) {
             theory_var v = b->get_var();
-            lean::var_index vi = m_theory_var2var_index[v];
+            lp::var_index vi = m_theory_var2var_index[v];
             if (m_solver->is_term(vi)) {
-                lean::lar_term const& term = m_solver->get_term(vi);
+                lp::lar_term const& term = m_solver->get_term(vi);
                 for (auto i = term.m_coeffs.begin(); i != term.m_coeffs.end(); ++i) {
-                    lean::var_index wi = i->first;
+                    lp::var_index wi = i->first;
                     unsigned w = m_var_index2theory_var[wi];
                     SASSERT(m_use_list[w].back() == b);
                     m_use_list[w].pop_back();
@@ -1845,7 +1845,7 @@ namespace smt {
         // have been assigned we may know the truth value of the inequality by using simple
         // bounds propagation.
         //
-        void propagate_bound_compound(bool_var bv, bool is_true, lp::bound& b) {
+        void propagate_bound_compound(bool_var bv, bool is_true, lra_lp::bound& b) {
             theory_var v = b.get_var();
             TRACE("arith", tout << mk_pp(get_owner(v), m) << "\n";);
             if (static_cast<unsigned>(v) >= m_use_list.size()) {
@@ -1861,7 +1861,7 @@ namespace smt {
                 // x >= 0, y >= 1 -> x + y >= 1
                 // x <= 0, y <= 2 -> x + y <= 2
                 literal lit = null_literal;
-                if (lp::lower_t == vb->get_bound_kind()) {
+                if (lra_lp::lower_t == vb->get_bound_kind()) {
                     if (get_glb(*vb, r) && r >= vb->get_value()) {        // vb is assigned true
                         lit = literal(vb->get_bv(), false);
                     }
@@ -1895,30 +1895,30 @@ namespace smt {
             }
         }
 
-        bool get_lub(lp::bound const& b, inf_rational& lub) {
+        bool get_lub(lra_lp::bound const& b, inf_rational& lub) {
             return get_bound(b, lub, true);
         }
 
-        bool get_glb(lp::bound const& b, inf_rational& glb) {
+        bool get_glb(lra_lp::bound const& b, inf_rational& glb) {
             return get_bound(b, glb, false);
         }
 
-        std::ostream& display_bound(std::ostream& out, lp::bound const& b) {
+        std::ostream& display_bound(std::ostream& out, lra_lp::bound const& b) {
             return out << mk_pp(ctx().bool_var2expr(b.get_bv()), m);
         }
 
-        bool get_bound(lp::bound const& b, inf_rational& r, bool is_lub) {
+        bool get_bound(lra_lp::bound const& b, inf_rational& r, bool is_lub) {
             m_core.reset();
             m_eqs.reset();
             m_params.reset();
             r.reset();
             theory_var v = b.get_var();
-            lean::var_index vi = m_theory_var2var_index[v];
+            lp::var_index vi = m_theory_var2var_index[v];
             SASSERT(m_solver->is_term(vi));
-            lean::lar_term const& term = m_solver->get_term(vi);
+            lp::lar_term const& term = m_solver->get_term(vi);
             for (auto const coeff : term.m_coeffs) {
-                lean::var_index wi = coeff.first;
-                lean::constraint_index ci;
+                lp::var_index wi = coeff.first;
+                lp::constraint_index ci;
                 rational value;
                 bool is_strict;
                 if (coeff.second.is_neg() == is_lub) {
@@ -1945,24 +1945,24 @@ namespace smt {
             return true;
         }
 
-        void assert_bound(bool_var bv, bool is_true, lp::bound& b) {
-            if (m_solver->get_status() == lean::lp_status::INFEASIBLE) {
+        void assert_bound(bool_var bv, bool is_true, lra_lp::bound& b) {
+            if (m_solver->get_status() == lp::lp_status::INFEASIBLE) {
                 return;
             }
             scoped_internalize_state st(*this);
             st.vars().push_back(b.get_var());
             st.coeffs().push_back(rational::one());
             init_left_side(st);
-            lean::lconstraint_kind k = lean::EQ;
+            lp::lconstraint_kind k = lp::EQ;
             switch (b.get_bound_kind()) {
-            case lp::lower_t:
-                k = is_true ? lean::GE : lean::LT;
+            case lra_lp::lower_t:
+                k = is_true ? lp::GE : lp::LT;
                 break;
-            case lp::upper_t:
-                k = is_true ? lean::LE : lean::GT;
+            case lra_lp::upper_t:
+                k = is_true ? lp::LE : lp::GT;
                 break;
             }
-            if (k == lean::LT || k == lean::LE) {
+            if (k == lp::LT || k == lp::LE) {
                 ++m_stats.m_assert_lower;
             }
             else {
@@ -1983,7 +1983,7 @@ namespace smt {
         // Then the equality v1 == v2 is propagated to the core.
         //
 
-        typedef std::pair<lean::constraint_index, rational> constraint_bound;
+        typedef std::pair<lp::constraint_index, rational> constraint_bound;
         vector<constraint_bound>        m_lower_terms;
         vector<constraint_bound>        m_upper_terms;
         typedef std::pair<rational, bool> value_sort_pair;
@@ -1991,16 +1991,16 @@ namespace smt {
         typedef map<value_sort_pair, theory_var, value_sort_pair_hash, default_eq<value_sort_pair> > value2var;
         value2var               m_fixed_var_table;
 
-        void propagate_eqs(lean::var_index vi, lean::constraint_index ci, lean::lconstraint_kind k, lp::bound& b) {
+        void propagate_eqs(lp::var_index vi, lp::constraint_index ci, lp::lconstraint_kind k, lra_lp::bound& b) {
             if (propagate_eqs()) {
                 rational const& value = b.get_value();
-                if (k == lean::GE) {
+                if (k == lp::GE) {
                     set_lower_bound(vi, ci, value);
                     if (has_upper_bound(vi, ci, value)) {
                         fixed_var_eh(b.get_var(), value);
                     }
                 }
-                else if (k == lean::LE) {
+                else if (k == lp::LE) {
                     set_upper_bound(vi, ci, value);
                     if (has_lower_bound(vi, ci, value)) {
                         fixed_var_eh(b.get_var(), value);
@@ -2021,16 +2021,16 @@ namespace smt {
 
         bool use_tableau() const { return lp_params(ctx().get_params()).simplex_strategy() < 2; }
 
-        void set_upper_bound(lean::var_index vi, lean::constraint_index ci, rational const& v) { set_bound(vi, ci, v, false);  }
+        void set_upper_bound(lp::var_index vi, lp::constraint_index ci, rational const& v) { set_bound(vi, ci, v, false);  }
 
-        void set_lower_bound(lean::var_index vi, lean::constraint_index ci, rational const& v) { set_bound(vi, ci, v, true);   }
+        void set_lower_bound(lp::var_index vi, lp::constraint_index ci, rational const& v) { set_bound(vi, ci, v, true);   }
 
-        void set_bound(lean::var_index vi, lean::constraint_index ci, rational const& v, bool is_lower) {
+        void set_bound(lp::var_index vi, lp::constraint_index ci, rational const& v, bool is_lower) {
             if (!m_solver->is_term(vi)) {
                 // m_solver already tracks bounds on proper variables, but not on terms.
                 return;
             }
-            lean::var_index ti = m_solver->adjust_term_index(vi);
+            lp::var_index ti = m_solver->adjust_term_index(vi);
             auto& vec = is_lower ? m_lower_terms : m_upper_terms;
             if (vec.size() <= ti) {
                 vec.resize(ti + 1, constraint_bound(UINT_MAX, rational()));
@@ -2043,15 +2043,15 @@ namespace smt {
             }
         }
 
-        bool has_upper_bound(lean::var_index vi, lean::constraint_index& ci, rational const& bound) { return has_bound(vi, ci, bound, false); }
+        bool has_upper_bound(lp::var_index vi, lp::constraint_index& ci, rational const& bound) { return has_bound(vi, ci, bound, false); }
 
-        bool has_lower_bound(lean::var_index vi, lean::constraint_index& ci, rational const& bound) { return has_bound(vi, ci, bound, true); }
+        bool has_lower_bound(lp::var_index vi, lp::constraint_index& ci, rational const& bound) { return has_bound(vi, ci, bound, true); }
 
-        bool has_bound(lean::var_index vi, lean::constraint_index& ci, rational const& bound, bool is_lower) {
+        bool has_bound(lp::var_index vi, lp::constraint_index& ci, rational const& bound, bool is_lower) {
 
             if (m_solver->is_term(vi)) {
 
-                lean::var_index ti = m_solver->adjust_term_index(vi);
+                lp::var_index ti = m_solver->adjust_term_index(vi);
                 theory_var v = m_term_index2theory_var.get(ti, null_theory_var);
                 rational val;
                 TRACE("arith", tout << vi << " " << v << "\n";);
@@ -2094,7 +2094,7 @@ namespace smt {
                 if (static_cast<unsigned>(v2) < th.get_num_vars() && !is_equal(v1, v2)) {
                     auto vi1 = get_var_index(v1);
                     auto vi2 = get_var_index(v2);
-                    lean::constraint_index ci1, ci2, ci3, ci4;
+                    lp::constraint_index ci1, ci2, ci3, ci4;
                     TRACE("arith", tout << "fixed: " << mk_pp(get_owner(v1), m) << " " << mk_pp(get_owner(v2), m) << " " << bound << " " << has_lower_bound(vi2, ci3, bound) << "\n";);
                     if (has_lower_bound(vi2, ci3, bound) && has_upper_bound(vi2, ci4, bound)) {
                         VERIFY (has_lower_bound(vi1, ci1, bound));
@@ -2148,19 +2148,19 @@ namespace smt {
             if (m_solver->A_r().row_count() > m_stats.m_max_rows)
                 m_stats.m_max_rows = m_solver->A_r().row_count();
             TRACE("arith_verbose", display(tout););
-            lean::lp_status status = m_solver->find_feasible_solution();
+            lp::lp_status status = m_solver->find_feasible_solution();
             m_stats.m_num_iterations = m_solver->settings().st().m_total_iterations;
             m_stats.m_num_factorizations = m_solver->settings().st().m_num_factorizations;
             m_stats.m_need_to_solve_inf = m_solver->settings().st().m_need_to_solve_inf;
 
             switch (status) {
-            case lean::lp_status::INFEASIBLE:
+            case lp::lp_status::INFEASIBLE:
                 return l_false;
-            case lean::lp_status::FEASIBLE:
-            case lean::lp_status::OPTIMAL:
+            case lp::lp_status::FEASIBLE:
+            case lp::lp_status::OPTIMAL:
                 //                SASSERT(m_solver->all_constraints_hold());
                 return l_true;
-            case lean::lp_status::TIME_EXHAUSTED:
+            case lp::lp_status::TIME_EXHAUSTED:
 
             default:
                 TRACE("arith", tout << "status treated as inconclusive: " << status << "\n";);
@@ -2170,14 +2170,14 @@ namespace smt {
             }
         }
 
-        vector<std::pair<rational, lean::constraint_index>> m_explanation;
+        vector<std::pair<rational, lp::constraint_index>> m_explanation;
         literal_vector      m_core;
         svector<enode_pair> m_eqs;
         vector<parameter>   m_params;
 
-        // lean::constraint_index const null_constraint_index = UINT_MAX; // not sure what a correct fix is
+        // lp::constraint_index const null_constraint_index = UINT_MAX; // not sure what a correct fix is
 
-        void set_evidence(lean::constraint_index idx) {
+        void set_evidence(lp::constraint_index idx) {
             if (idx == UINT_MAX) {
                 return;
             }
@@ -2327,16 +2327,16 @@ namespace smt {
         }
 
         theory_lra::inf_eps value(theory_var v) {
-            lean::impq ival = get_ivalue(v);
+            lp::impq ival = get_ivalue(v);
             return inf_eps(0, inf_rational(ival.x, ival.y));
         }
 
         theory_lra::inf_eps maximize(theory_var v, expr_ref& blocker, bool& has_shared) {
-            lean::var_index vi = m_theory_var2var_index.get(v, UINT_MAX);
-            vector<std::pair<rational, lean::var_index> > coeffs;
+            lp::var_index vi = m_theory_var2var_index.get(v, UINT_MAX);
+            vector<std::pair<rational, lp::var_index> > coeffs;
             rational coeff;
             if (m_solver->is_term(vi)) {
-                const lean::lar_term& term = m_solver->get_term(vi);
+                const lp::lar_term& term = m_solver->get_term(vi);
                 for (auto & ti : term.m_coeffs) {
                     coeffs.push_back(std::make_pair(ti.second, ti.first));
                 }
@@ -2346,7 +2346,7 @@ namespace smt {
                 coeffs.push_back(std::make_pair(rational::one(), vi));
                 coeff = rational::zero();
             }
-            lean::impq term_max;
+            lp::impq term_max;
             if (m_solver->maximize_term(coeffs, term_max)) {
                 blocker = mk_gt(v);
                 inf_rational val(term_max.x + coeff, term_max.y);
@@ -2361,7 +2361,7 @@ namespace smt {
         }
 
         expr_ref mk_gt(theory_var v) {
-            lean::impq val = get_ivalue(v);
+            lp::impq val = get_ivalue(v);
             expr* obj = get_enode(v)->get_owner();
             rational r = val.x;
             expr_ref e(m);
@@ -2393,11 +2393,11 @@ namespace smt {
         }
 
         app_ref mk_obj(theory_var v) {
-            lean::var_index vi = m_theory_var2var_index[v];
+            lp::var_index vi = m_theory_var2var_index[v];
             bool is_int = a.is_int(get_enode(v)->get_owner());
             if (m_solver->is_term(vi)) {
                 expr_ref_vector args(m);
-                const lean::lar_term& term = m_solver->get_term(vi);
+                const lp::lar_term& term = m_solver->get_term(vi);
                 for (auto & ti : term.m_coeffs) {
                     theory_var w = m_var_index2theory_var[ti.first];
                     expr* o = get_enode(w)->get_owner();
@@ -2428,9 +2428,9 @@ namespace smt {
                 bool_var bv = ctx().mk_bool_var(b);
                 ctx().set_var_theory(bv, get_id());
                 // ctx().set_enode_flag(bv, true);
-                lp::bound_kind bkind = lp::bound_kind::lower_t;
-                if (is_strict) bkind = lp::bound_kind::upper_t;
-                lp::bound* a = alloc(lp::bound, bv, v, r, bkind);
+                lra_lp::bound_kind bkind = lra_lp::bound_kind::lower_t;
+                if (is_strict) bkind = lra_lp::bound_kind::upper_t;
+                lra_lp::bound* a = alloc(lra_lp::bound, bv, v, r, bkind);
                 mk_bound_axioms(*a);
                 updt_unassigned_bounds(v, +1);
                 m_bounds[v].push_back(a);
@@ -2462,7 +2462,7 @@ namespace smt {
             }
         }
 
-        void display_evidence(std::ostream& out, vector<std::pair<rational, lean::constraint_index>> const& evidence) {
+        void display_evidence(std::ostream& out, vector<std::pair<rational, lp::constraint_index>> const& evidence) {
             for (auto const& ev : evidence) {
                 expr_ref e(m);
                 SASSERT(!ev.first.is_zero());
diff --git a/src/util/lp/binary_heap_priority_queue.h b/src/util/lp/binary_heap_priority_queue.h
index a6206948c..8282ece9c 100644
--- a/src/util/lp/binary_heap_priority_queue.h
+++ b/src/util/lp/binary_heap_priority_queue.h
@@ -1,13 +1,28 @@
 
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include "util/vector.h"
 #include "util/debug.h"
 #include "util/lp/lp_utils.h"
-namespace lean {
+namespace lp {
 // the elements with the smallest priority are dequeued first
 template <typename T>
 class binary_heap_priority_queue {
@@ -22,7 +37,7 @@ class binary_heap_priority_queue {
     void put_at(unsigned i, unsigned h);
     void decrease_priority(unsigned o, T newPriority);
 public:
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     bool is_consistent() const;
 #endif
 public:
@@ -60,10 +75,10 @@ public:
     /// return the first element of the queue and removes it from the queue
     unsigned dequeue();
     unsigned peek() const {
-        lean_assert(m_heap_size > 0);
+        SASSERT(m_heap_size > 0);
         return m_heap[1];
     }
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     void print(std::ostream & out);
 #endif
 };
diff --git a/src/util/lp/binary_heap_priority_queue.hpp b/src/util/lp/binary_heap_priority_queue.hpp
index 440b45b02..e7378309d 100644
--- a/src/util/lp/binary_heap_priority_queue.hpp
+++ b/src/util/lp/binary_heap_priority_queue.hpp
@@ -1,11 +1,26 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include "util/vector.h"
 #include "util/lp/binary_heap_priority_queue.h"
-namespace lean {
-// is is the child place in heap
+namespace lp {
+// this is the child place in the heap
 template <typename T> void binary_heap_priority_queue<T>::swap_with_parent(unsigned i) {
     unsigned parent = m_heap[i >> 1];
     put_at(i >> 1, m_heap[i]);
@@ -29,12 +44,12 @@ template <typename T> void binary_heap_priority_queue<T>::decrease_priority(unsi
     }
 }
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template <typename T> bool binary_heap_priority_queue<T>::is_consistent() const {
     for (int i = 0; i < m_heap_inverse.size(); i++) {
         int i_index = m_heap_inverse[i];
-        lean_assert(i_index <= static_cast<int>(m_heap_size));
-        lean_assert(i_index == -1 || m_heap[i_index] == i);
+        SASSERT(i_index <= static_cast<int>(m_heap_size));
+        SASSERT(i_index == -1 || m_heap[i_index] == i);
     }
     for (unsigned i = 1; i < m_heap_size; i++) {
         unsigned ch = i << 1;
@@ -49,13 +64,14 @@ template <typename T> bool binary_heap_priority_queue<T>::is_consistent() const
     return true;
 }
 #endif
+
 template <typename T> void binary_heap_priority_queue<T>::remove(unsigned o) {
     T priority_of_o = m_priorities[o];
     int o_in_heap = m_heap_inverse[o];
     if (o_in_heap == -1)  {
         return;  // nothing to do
     }
-    lean_assert(static_cast<unsigned>(o_in_heap) <= m_heap_size);
+    SASSERT(static_cast<unsigned>(o_in_heap) <= m_heap_size);
     if (static_cast<unsigned>(o_in_heap) < m_heap_size) {
         put_at(o_in_heap, m_heap[m_heap_size--]);
         if (m_priorities[m_heap[o_in_heap]] > priority_of_o) {
@@ -72,11 +88,11 @@ template <typename T> void binary_heap_priority_queue<T>::remove(unsigned o) {
             }
         }
     } else {
-        lean_assert(static_cast<unsigned>(o_in_heap) == m_heap_size);
+        SASSERT(static_cast<unsigned>(o_in_heap) == m_heap_size);
         m_heap_size--;
     }
     m_heap_inverse[o] = -1;
-    // lean_assert(is_consistent());
+    // SASSERT(is_consistent());
 }
 // n is the initial queue capacity.
 // The capacity will be enlarged two times automatically if needed
@@ -102,7 +118,7 @@ template <typename T> void binary_heap_priority_queue<T>::put_to_heap(unsigned i
 template <typename T> void binary_heap_priority_queue<T>::enqueue_new(unsigned o, const T& priority) {
     m_heap_size++;
     int i = m_heap_size;
-    lean_assert(o < m_priorities.size());
+    SASSERT(o < m_priorities.size());
     m_priorities[o] = priority;
     put_at(i, o);
     while (i > 1 && m_priorities[m_heap[i >> 1]] > priority) {
@@ -134,7 +150,7 @@ template <typename T> void binary_heap_priority_queue<T>::change_priority_for_ex
 
 /// return the first element of the queue and removes it from the queue
 template <typename T> unsigned binary_heap_priority_queue<T>::dequeue_and_get_priority(T & priority) {
-    lean_assert(m_heap_size != 0);
+    SASSERT(m_heap_size != 0);
     int ret = m_heap[1];
     priority = m_priorities[ret];
     put_the_last_at_the_top_and_fix_the_heap();
@@ -168,13 +184,13 @@ template <typename T> void binary_heap_priority_queue<T>::put_the_last_at_the_to
 }
 /// return the first element of the queue and removes it from the queue
 template <typename T> unsigned binary_heap_priority_queue<T>::dequeue() {
-    lean_assert(m_heap_size > 0);
+    SASSERT(m_heap_size > 0);
     int ret = m_heap[1];
     put_the_last_at_the_top_and_fix_the_heap();
     m_heap_inverse[ret] = -1;
     return ret;
 }
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template <typename T> void binary_heap_priority_queue<T>::print(std::ostream & out) {
     vector<int> index;
     vector<T> prs;
diff --git a/src/util/lp/binary_heap_priority_queue_instances.cpp b/src/util/lp/binary_heap_priority_queue_instances.cpp
index 567494d6f..fca826a6b 100644
--- a/src/util/lp/binary_heap_priority_queue_instances.cpp
+++ b/src/util/lp/binary_heap_priority_queue_instances.cpp
@@ -1,10 +1,25 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include "util/lp/numeric_pair.h"
 #include "util/lp/binary_heap_priority_queue.hpp"
-namespace lean {
+namespace lp {
 template binary_heap_priority_queue<int>::binary_heap_priority_queue(unsigned int);
 template unsigned binary_heap_priority_queue<int>::dequeue();
 template void binary_heap_priority_queue<int>::enqueue(unsigned int, int const&);
@@ -16,11 +31,11 @@ template unsigned binary_heap_priority_queue<double>::dequeue();
 template unsigned binary_heap_priority_queue<mpq>::dequeue();
 template void binary_heap_priority_queue<numeric_pair<mpq> >::enqueue(unsigned int, numeric_pair<mpq> const&);
 template void binary_heap_priority_queue<numeric_pair<mpq> >::resize(unsigned int);
-template void lean::binary_heap_priority_queue<double>::resize(unsigned int);
+template void lp::binary_heap_priority_queue<double>::resize(unsigned int);
 template binary_heap_priority_queue<unsigned int>::binary_heap_priority_queue(unsigned int);
 template void binary_heap_priority_queue<unsigned>::resize(unsigned int);
 template unsigned binary_heap_priority_queue<unsigned int>::dequeue();
 template void binary_heap_priority_queue<unsigned int>::enqueue(unsigned int, unsigned int const&);
 template void binary_heap_priority_queue<unsigned int>::remove(unsigned int);
-template void lean::binary_heap_priority_queue<mpq>::resize(unsigned int);
+template void lp::binary_heap_priority_queue<mpq>::resize(unsigned int);
 }
diff --git a/src/util/lp/binary_heap_upair_queue.h b/src/util/lp/binary_heap_upair_queue.h
index 26cfd5532..640c4bb81 100644
--- a/src/util/lp/binary_heap_upair_queue.h
+++ b/src/util/lp/binary_heap_upair_queue.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 #include <unordered_set>
@@ -15,7 +30,7 @@
 
 typedef std::pair<unsigned, unsigned> upair;
 
-namespace lean {
+namespace lp {
 template <typename  T>
 class binary_heap_upair_queue {
     binary_heap_priority_queue<T> m_q;
@@ -38,7 +53,7 @@ public:
     void enqueue(unsigned i, unsigned j, const T & priority);
     void dequeue(unsigned & i, unsigned &j);
     T get_priority(unsigned i, unsigned j) const;
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     bool pair_to_index_is_a_bijection() const;
     bool available_spots_are_correct() const;
     bool is_correct() const {
diff --git a/src/util/lp/binary_heap_upair_queue.hpp b/src/util/lp/binary_heap_upair_queue.hpp
index a48bdb5b7..d12be9707 100644
--- a/src/util/lp/binary_heap_upair_queue.hpp
+++ b/src/util/lp/binary_heap_upair_queue.hpp
@@ -1,12 +1,27 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #include <set>
 #include "util/lp/lp_utils.h"
 #include "util/lp/binary_heap_upair_queue.h"
-namespace lean {
+namespace lp {
 template <typename T> binary_heap_upair_queue<T>::binary_heap_upair_queue(unsigned size) : m_q(size), m_pairs(size) {
     for (unsigned i = 0; i < size; i++)
         m_available_spots.push_back(i);
@@ -14,7 +29,7 @@ template <typename T> binary_heap_upair_queue<T>::binary_heap_upair_queue(unsign
 
 template <typename T> unsigned
 binary_heap_upair_queue<T>::dequeue_available_spot() {
-    lean_assert(m_available_spots.empty() == false);
+    SASSERT(m_available_spots.empty() == false);
     unsigned ret = m_available_spots.back();
     m_available_spots.pop_back();
     return ret;
@@ -54,7 +69,7 @@ template <typename T> void binary_heap_upair_queue<T>::enqueue(unsigned i, unsig
             m_pairs.resize(new_size);
         }
         ij_index = dequeue_available_spot();
-        // lean_assert(ij_index<m_pairs.size() && ij_index_is_new(ij_index));
+        // SASSERT(ij_index<m_pairs.size() && ij_index_is_new(ij_index));
         m_pairs[ij_index] = p;
         m_pairs_to_index[p] = ij_index;
     } else {
@@ -64,7 +79,7 @@ template <typename T> void binary_heap_upair_queue<T>::enqueue(unsigned i, unsig
 }
 
 template <typename T> void binary_heap_upair_queue<T>::dequeue(unsigned & i, unsigned &j) {
-    lean_assert(!m_q.is_empty());
+    SASSERT(!m_q.is_empty());
     unsigned ij_index = m_q.dequeue();
     upair & p = m_pairs[ij_index];
     i = p.first;
@@ -81,7 +96,7 @@ template <typename T> T binary_heap_upair_queue<T>::get_priority(unsigned i, uns
     return m_q.get_priority(it->second);
 }
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template <typename T> bool binary_heap_upair_queue<T>::pair_to_index_is_a_bijection() const {
     std::set<int> tmp;
     for (auto p : m_pairs_to_index) {
diff --git a/src/util/lp/binary_heap_upair_queue_instances.cpp b/src/util/lp/binary_heap_upair_queue_instances.cpp
index 4c4603110..6d093b175 100644
--- a/src/util/lp/binary_heap_upair_queue_instances.cpp
+++ b/src/util/lp/binary_heap_upair_queue_instances.cpp
@@ -1,9 +1,24 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include "util/lp/binary_heap_upair_queue.hpp"
-namespace lean {
+namespace lp {
 template binary_heap_upair_queue<int>::binary_heap_upair_queue(unsigned int);
 template binary_heap_upair_queue<unsigned int>::binary_heap_upair_queue(unsigned int);
 template unsigned binary_heap_upair_queue<int>::dequeue_available_spot();
diff --git a/src/util/lp/bound_analyzer_on_row.h b/src/util/lp/bound_analyzer_on_row.h
index 914835a3c..52b8ece64 100644
--- a/src/util/lp/bound_analyzer_on_row.h
+++ b/src/util/lp/bound_analyzer_on_row.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include "util/vector.h"
 #include "util/lp/linear_combination_iterator.h"
@@ -13,7 +28,7 @@
 // We try to pin a var by pushing the total by using the variable bounds
 // In a loop we drive the partial sum down, denoting the variables of this process by _u.
 // In the same loop trying to pin variables by pushing the partial sum up, denoting the variable related to it by _l
-namespace lean {
+namespace lp {
 
 class bound_analyzer_on_row {
 
@@ -91,11 +106,11 @@ public :
     }
 
     const impq & ub(unsigned j) const {
-        lean_assert(upper_bound_is_available(j));
+        SASSERT(upper_bound_is_available(j));
         return m_bp.get_upper_bound(j);
     }
     const impq & lb(unsigned j) const {
-        lean_assert(low_bound_is_available(j));
+        SASSERT(low_bound_is_available(j));
         return m_bp.get_low_bound(j);
     }
 
@@ -153,7 +168,7 @@ public :
     void limit_all_monoids_from_above() {
         int strict = 0;
         mpq total;
-        lean_assert(is_zero(total));
+        SASSERT(is_zero(total));
         m_it.reset();
         mpq a; unsigned j;
         while (m_it.next(a, j)) {
@@ -180,7 +195,7 @@ public :
     void limit_all_monoids_from_below() {
         int strict = 0;
         mpq total;
-        lean_assert(is_zero(total));
+        SASSERT(is_zero(total));
         m_it.reset();
         mpq a; unsigned j;
         while (m_it.next(a, j)) {
@@ -272,7 +287,7 @@ public :
     //     mpq a; unsigned j;
     //     while (it->next(a, j)) {
     //         if (be.m_j == j) continue;
-    //         lean_assert(bound_is_available(j, is_neg(a) ? low_bound : !low_bound));
+    //         SASSERT(bound_is_available(j, is_neg(a) ? low_bound : !low_bound));
     //         be.m_vector_of_bound_signatures.emplace_back(a, j, numeric_traits<impq>::
     //                                                      is_neg(a)? low_bound: !low_bound);
     //     }
diff --git a/src/util/lp/breakpoint.h b/src/util/lp/breakpoint.h
index e5454db0e..40fab293f 100644
--- a/src/util/lp/breakpoint.h
+++ b/src/util/lp/breakpoint.h
@@ -1,11 +1,26 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 
-namespace lean {
+namespace lp {
 enum breakpoint_type {
     low_break, upper_break, fixed_break
 };
diff --git a/src/util/lp/column_info.h b/src/util/lp/column_info.h
index 56e75a1fb..e4b449bbf 100644
--- a/src/util/lp/column_info.h
+++ b/src/util/lp/column_info.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 #include "util/vector.h"
@@ -9,7 +24,7 @@
 #include <string>
 #include <algorithm>
 #include "util/lp/lp_settings.h"
-namespace lean {
+namespace lp {
 inline bool is_valid(unsigned j) { return static_cast<int>(j) >= 0;}
 
 template <typename T>
@@ -100,11 +115,11 @@ public:
     }
 
     T get_low_bound() const {
-        lean_assert(m_low_bound_is_set);
+        SASSERT(m_low_bound_is_set);
         return m_low_bound;
     }
     T get_upper_bound() const {
-        lean_assert(m_upper_bound_is_set);
+        SASSERT(m_upper_bound_is_set);
         return m_upper_bound;
     }
 
@@ -156,7 +171,7 @@ public:
     }
 
     T get_fixed_value() const {
-        lean_assert(m_is_fixed);
+        SASSERT(m_is_fixed);
         return m_fixed_value;
     }
 
diff --git a/src/util/lp/column_namer.h b/src/util/lp/column_namer.h
index a3fe05dd0..97d371f48 100644
--- a/src/util/lp/column_namer.h
+++ b/src/util/lp/column_namer.h
@@ -1,11 +1,26 @@
 #pragma once
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <string>
 #include "util/lp/linear_combination_iterator.h"
-namespace lean {
+namespace lp {
 class column_namer {
 public:
     virtual std::string get_column_name(unsigned j) const = 0;
diff --git a/src/util/lp/conversion_helper.h b/src/util/lp/conversion_helper.h
index bff2ad563..cd8577483 100644
--- a/src/util/lp/conversion_helper.h
+++ b/src/util/lp/conversion_helper.h
@@ -4,7 +4,7 @@
   Author: Lev Nachmanson
 */
 #pragma once
-namespace lean {
+namespace lp {
 template <typename V>
 struct conversion_helper {
     static V get_low_bound(const column_info<mpq> & ci) {
diff --git a/src/util/lp/core_solver_pretty_printer.h b/src/util/lp/core_solver_pretty_printer.h
index 2a3a14b31..20b2c1cbe 100644
--- a/src/util/lp/core_solver_pretty_printer.h
+++ b/src/util/lp/core_solver_pretty_printer.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include <limits>
 #include <string>
@@ -10,7 +25,7 @@
 #include <ostream>
 #include "util/lp/lp_settings.h"
 #include "util/lp/indexed_vector.h"
-namespace lean {
+namespace lp {
 template <typename T, typename X> class lp_core_solver_base; // forward definition
 
 template <typename T, typename X>
diff --git a/src/util/lp/core_solver_pretty_printer.hpp b/src/util/lp/core_solver_pretty_printer.hpp
index 786b8b3a1..4ae49a550 100644
--- a/src/util/lp/core_solver_pretty_printer.hpp
+++ b/src/util/lp/core_solver_pretty_printer.hpp
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <limits>
 #include <string>
 #include <algorithm>
@@ -9,7 +24,7 @@
 #include "util/lp/lp_core_solver_base.h"
 #include "util/lp/core_solver_pretty_printer.h"
 #include "util/lp/numeric_pair.h"
-namespace lean {
+namespace lp {
 
 
 template <typename T, typename X>
@@ -148,7 +163,7 @@ template <typename T, typename X> void core_solver_pretty_printer<T, X>::adjust_
     case column_type::free_column:
         break;
     default:
-        lean_assert(false);
+        SASSERT(false);
         break;
     }
 }
@@ -357,7 +372,7 @@ template <typename T, typename X> void core_solver_pretty_printer<T, X>::print_g
         unsigned width = m_column_widths[col];
         string s = row[col];
         int number_of_blanks = width - static_cast<unsigned>(s.size());
-        lean_assert(number_of_blanks >= 0);
+        SASSERT(number_of_blanks >= 0);
         print_blanks(number_of_blanks, m_out);
         m_out << s << ' ';
         if (col < row.size() - 1) {
@@ -368,7 +383,7 @@ template <typename T, typename X> void core_solver_pretty_printer<T, X>::print_g
 
     string rs = T_to_string(rst);
     int nb = m_rs_width - static_cast<int>(rs.size());
-    lean_assert(nb >= 0);
+    SASSERT(nb >= 0);
     print_blanks(nb + 1, m_out);
     m_out << rs << std::endl;
 }
diff --git a/src/util/lp/core_solver_pretty_printer_instances.cpp b/src/util/lp/core_solver_pretty_printer_instances.cpp
index cfa72f725..0bd7f5559 100644
--- a/src/util/lp/core_solver_pretty_printer_instances.cpp
+++ b/src/util/lp/core_solver_pretty_printer_instances.cpp
@@ -1,15 +1,30 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include "util/lp/numeric_pair.h"
 #include "util/lp/core_solver_pretty_printer.hpp"
-template lean::core_solver_pretty_printer<double, double>::core_solver_pretty_printer(lean::lp_core_solver_base<double, double> &, std::ostream & out);
-template void lean::core_solver_pretty_printer<double, double>::print();
-template lean::core_solver_pretty_printer<double, double>::~core_solver_pretty_printer();
-template lean::core_solver_pretty_printer<lean::mpq, lean::mpq>::core_solver_pretty_printer(lean::lp_core_solver_base<lean::mpq, lean::mpq> &, std::ostream & out);
-template void lean::core_solver_pretty_printer<lean::mpq, lean::mpq>::print();
-template lean::core_solver_pretty_printer<lean::mpq, lean::mpq>::~core_solver_pretty_printer();
-template lean::core_solver_pretty_printer<lean::mpq, lean::numeric_pair<lean::mpq> >::core_solver_pretty_printer(lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> > &, std::ostream & out);
-template lean::core_solver_pretty_printer<lean::mpq, lean::numeric_pair<lean::mpq> >::~core_solver_pretty_printer();
-template void lean::core_solver_pretty_printer<lean::mpq, lean::numeric_pair<lean::mpq> >::print();
+template lp::core_solver_pretty_printer<double, double>::core_solver_pretty_printer(lp::lp_core_solver_base<double, double> &, std::ostream & out);
+template void lp::core_solver_pretty_printer<double, double>::print();
+template lp::core_solver_pretty_printer<double, double>::~core_solver_pretty_printer();
+template lp::core_solver_pretty_printer<lp::mpq, lp::mpq>::core_solver_pretty_printer(lp::lp_core_solver_base<lp::mpq, lp::mpq> &, std::ostream & out);
+template void lp::core_solver_pretty_printer<lp::mpq, lp::mpq>::print();
+template lp::core_solver_pretty_printer<lp::mpq, lp::mpq>::~core_solver_pretty_printer();
+template lp::core_solver_pretty_printer<lp::mpq, lp::numeric_pair<lp::mpq> >::core_solver_pretty_printer(lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> > &, std::ostream & out);
+template lp::core_solver_pretty_printer<lp::mpq, lp::numeric_pair<lp::mpq> >::~core_solver_pretty_printer();
+template void lp::core_solver_pretty_printer<lp::mpq, lp::numeric_pair<lp::mpq> >::print();
diff --git a/src/util/lp/dense_matrix.h b/src/util/lp/dense_matrix.h
index 233f74016..6b157ffd4 100644
--- a/src/util/lp/dense_matrix.h
+++ b/src/util/lp/dense_matrix.h
@@ -1,12 +1,27 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 #include "util/vector.h"
 #include "util/lp/matrix.h"
-namespace lean {
+namespace lp {
 // used for debugging purposes only
 template <typename T, typename X>
 class dense_matrix: public matrix<T, X> {
@@ -31,7 +46,7 @@ public:
     dense_matrix(unsigned m, unsigned n);
 
     dense_matrix operator*=(matrix<T, X> const & a) {
-        lean_assert(column_count() == a.row_count());
+        SASSERT(column_count() == a.row_count());
         dense_matrix c(row_count(), a.column_count());
         for (unsigned i = 0; i < row_count(); i++) {
             for (unsigned j = 0; j < a.column_count(); j++) {
diff --git a/src/util/lp/dense_matrix.hpp b/src/util/lp/dense_matrix.hpp
index e42d9e3a4..a1f815109 100644
--- a/src/util/lp/dense_matrix.hpp
+++ b/src/util/lp/dense_matrix.hpp
@@ -1,13 +1,28 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include "util/lp/lp_settings.h"
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 #include "util/vector.h"
 #include "util/lp/numeric_pair.h"
 #include "util/lp/dense_matrix.h"
-namespace lean {
+namespace lp {
 template <typename T> void print_vector(const vector<T> & t, std::ostream & out);
 template <typename T, typename X> dense_matrix<T, X>::dense_matrix(unsigned m, unsigned n) : m_m(m), m_n(n), m_values(m * n, numeric_traits<T>::zero()) {
 }
@@ -170,7 +185,7 @@ template <typename T, typename X> void dense_matrix<T, X>::multiply_row_by_const
 
 template <typename T, typename X>
 dense_matrix<T, X> operator* (matrix<T, X> & a, matrix<T, X> & b){
-    lean_assert(a.column_count() == b.row_count());
+    SASSERT(a.column_count() == b.row_count());
     dense_matrix<T, X> ret(a.row_count(), b.column_count());
     for (unsigned i = 0; i < ret.m_m; i++)
         for (unsigned j = 0; j< ret.m_n; j++) {
diff --git a/src/util/lp/dense_matrix_instances.cpp b/src/util/lp/dense_matrix_instances.cpp
index 95ba01801..54b0d15d6 100644
--- a/src/util/lp/dense_matrix_instances.cpp
+++ b/src/util/lp/dense_matrix_instances.cpp
@@ -1,25 +1,40 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include "util/lp/lp_settings.h"
 #include "util/lp/dense_matrix.hpp"
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 #include "util/vector.h"
-template lean::dense_matrix<double, double> lean::operator*<double, double>(lean::matrix<double, double>&, lean::matrix<double, double>&);
-template void lean::dense_matrix<double, double>::apply_from_left(vector<double> &);
-template lean::dense_matrix<double, double>::dense_matrix(lean::matrix<double, double> const*);
-template lean::dense_matrix<double, double>::dense_matrix(unsigned int, unsigned int);
-template lean::dense_matrix<double, double>& lean::dense_matrix<double, double>::operator=(lean::dense_matrix<double, double> const&);
-template lean::dense_matrix<lean::mpq, lean::mpq>::dense_matrix(unsigned int, unsigned int);
-template lean::dense_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::dense_matrix(lean::matrix<lean::mpq, lean::numeric_pair<lean::mpq> > const*);
-template void lean::dense_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::apply_from_left(vector<lean::mpq>&);
-template lean::dense_matrix<lean::mpq, lean::mpq> lean::operator*<lean::mpq, lean::mpq>(lean::matrix<lean::mpq, lean::mpq>&, lean::matrix<lean::mpq, lean::mpq>&);
-template lean::dense_matrix<lean::mpq, lean::mpq> & lean::dense_matrix<lean::mpq, lean::mpq>::operator=(lean::dense_matrix<lean::mpq, lean::mpq> const&);
-template lean::dense_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::dense_matrix(unsigned int, unsigned int);
-template lean::dense_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >& lean::dense_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::operator=(lean::dense_matrix<lean::mpq, lean::numeric_pair<lean::mpq> > const&);
-template lean::dense_matrix<lean::mpq, lean::numeric_pair<lean::mpq> > lean::operator*<lean::mpq, lean::numeric_pair<lean::mpq> >(lean::matrix<lean::mpq, lean::numeric_pair<lean::mpq> >&, lean::matrix<lean::mpq, lean::numeric_pair<lean::mpq> >&);
-template void lean::dense_matrix<lean::mpq, lean::numeric_pair< lean::mpq> >::apply_from_right( vector< lean::mpq> &);
-template void lean::dense_matrix<double,double>::apply_from_right(class vector<double> &);
-template void lean::dense_matrix<lean::mpq, lean::mpq>::apply_from_left(vector<lean::mpq>&);
+template lp::dense_matrix<double, double> lp::operator*<double, double>(lp::matrix<double, double>&, lp::matrix<double, double>&);
+template void lp::dense_matrix<double, double>::apply_from_left(vector<double> &);
+template lp::dense_matrix<double, double>::dense_matrix(lp::matrix<double, double> const*);
+template lp::dense_matrix<double, double>::dense_matrix(unsigned int, unsigned int);
+template lp::dense_matrix<double, double>& lp::dense_matrix<double, double>::operator=(lp::dense_matrix<double, double> const&);
+template lp::dense_matrix<lp::mpq, lp::mpq>::dense_matrix(unsigned int, unsigned int);
+template lp::dense_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::dense_matrix(lp::matrix<lp::mpq, lp::numeric_pair<lp::mpq> > const*);
+template void lp::dense_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::apply_from_left(vector<lp::mpq>&);
+template lp::dense_matrix<lp::mpq, lp::mpq> lp::operator*<lp::mpq, lp::mpq>(lp::matrix<lp::mpq, lp::mpq>&, lp::matrix<lp::mpq, lp::mpq>&);
+template lp::dense_matrix<lp::mpq, lp::mpq> & lp::dense_matrix<lp::mpq, lp::mpq>::operator=(lp::dense_matrix<lp::mpq, lp::mpq> const&);
+template lp::dense_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::dense_matrix(unsigned int, unsigned int);
+template lp::dense_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >& lp::dense_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::operator=(lp::dense_matrix<lp::mpq, lp::numeric_pair<lp::mpq> > const&);
+template lp::dense_matrix<lp::mpq, lp::numeric_pair<lp::mpq> > lp::operator*<lp::mpq, lp::numeric_pair<lp::mpq> >(lp::matrix<lp::mpq, lp::numeric_pair<lp::mpq> >&, lp::matrix<lp::mpq, lp::numeric_pair<lp::mpq> >&);
+template void lp::dense_matrix<lp::mpq, lp::numeric_pair< lp::mpq> >::apply_from_right( vector< lp::mpq> &);
+template void lp::dense_matrix<double,double>::apply_from_right(class vector<double> &);
+template void lp::dense_matrix<lp::mpq, lp::mpq>::apply_from_left(vector<lp::mpq>&);
 #endif
diff --git a/src/util/lp/eta_matrix.h b/src/util/lp/eta_matrix.h
index 51b015066..6c30e2146 100644
--- a/src/util/lp/eta_matrix.h
+++ b/src/util/lp/eta_matrix.h
@@ -1,32 +1,47 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 #include "util/vector.h"
 #include "util/lp/tail_matrix.h"
 #include "util/lp/permutation_matrix.h"
-namespace lean {
+namespace lp {
 
 // This is the sum of a unit matrix and a one-column matrix
 template <typename T, typename X>
 class eta_matrix
     : public tail_matrix<T, X> {
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     unsigned m_length;
 #endif
     unsigned m_column_index;
 public:
     sparse_vector<T> m_column_vector;
     T m_diagonal_element;
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     eta_matrix(unsigned column_index, unsigned length):
 #else
         eta_matrix(unsigned column_index):
 #endif
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
         m_length(length),
 #endif
         m_column_index(column_index) {}
@@ -61,7 +76,7 @@ public:
 
 
     void push_back(unsigned row_index, T val ) {
-        lean_assert(row_index != m_column_index);
+        SASSERT(row_index != m_column_index);
         m_column_vector.push_back(row_index, val);
     }
 
@@ -69,7 +84,7 @@ public:
     void apply_from_right(indexed_vector<T> & w);
 
     T get_elem(unsigned i, unsigned j) const;
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     unsigned row_count() const { return m_length; }
     unsigned column_count() const { return m_length; }
     void set_number_of_rows(unsigned m) { m_length = m; }
diff --git a/src/util/lp/eta_matrix.hpp b/src/util/lp/eta_matrix.hpp
index 142a408d1..ae4ed712e 100644
--- a/src/util/lp/eta_matrix.hpp
+++ b/src/util/lp/eta_matrix.hpp
@@ -1,12 +1,27 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 #include "util/vector.h"
 #include "util/lp/eta_matrix.h"
-namespace lean {
+namespace lp {
 
 // This is the sum of a unit matrix and a one-column matrix
 template <typename T, typename X>
@@ -49,7 +64,7 @@ apply_from_left_local(indexed_vector<L> & w, lp_settings & settings) {
 }
 template <typename T, typename X>
 void eta_matrix<T, X>::apply_from_right(vector<T> & w) {
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     // dense_matrix<T, X> deb(*this);
     // auto clone_w = clone_vector<T>(w, get_number_of_rows());
     // deb.apply_from_right(clone_w);
@@ -59,8 +74,8 @@ void eta_matrix<T, X>::apply_from_right(vector<T> & w) {
         t += w[it.first] * it.second;
     }
     w[m_column_index] = t;
-#ifdef LEAN_DEBUG
-    // lean_assert(vectors_are_equal<T>(clone_w, w, get_number_of_rows()));
+#ifdef Z3DEBUG
+    // SASSERT(vectors_are_equal<T>(clone_w, w, get_number_of_rows()));
     // delete clone_w;
 #endif
 }
@@ -68,7 +83,7 @@ template <typename T, typename X>
 void eta_matrix<T, X>::apply_from_right(indexed_vector<T> & w) {
     if (w.m_index.size() == 0)
         return;
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     // vector<T> wcopy(w.m_data);
     // apply_from_right(wcopy);
 #endif
@@ -99,12 +114,12 @@ void eta_matrix<T, X>::apply_from_right(indexed_vector<T> & w) {
         }
     }
     
-#ifdef LEAN_DEBUG
-    // lean_assert(w.is_OK());
-    // lean_assert(vectors_are_equal<T>(wcopy, w.m_data));
+#ifdef Z3DEBUG
+    // SASSERT(w.is_OK());
+    // SASSERT(vectors_are_equal<T>(wcopy, w.m_data));
 #endif
 }
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template <typename T, typename X>
 T eta_matrix<T, X>::get_elem(unsigned i, unsigned j) const {
     if (j == m_column_index){
@@ -120,7 +135,7 @@ T eta_matrix<T, X>::get_elem(unsigned i, unsigned j) const {
 template <typename T, typename X>
 void eta_matrix<T, X>::conjugate_by_permutation(permutation_matrix<T, X> & p) {
     // this = p * this * p(-1)
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     // auto rev = p.get_reverse();
     // auto deb = ((*this) * rev);
     // deb = p * deb;
@@ -129,8 +144,8 @@ void eta_matrix<T, X>::conjugate_by_permutation(permutation_matrix<T, X> & p) {
     for (auto & pair : m_column_vector.m_data) {
         pair.first = p.get_rev(pair.first);
     }
-#ifdef LEAN_DEBUG
-    // lean_assert(deb == *this);
+#ifdef Z3DEBUG
+    // SASSERT(deb == *this);
 #endif
 }
 }
diff --git a/src/util/lp/eta_matrix_instances.cpp b/src/util/lp/eta_matrix_instances.cpp
index d57d43fed..87e12c913 100644
--- a/src/util/lp/eta_matrix_instances.cpp
+++ b/src/util/lp/eta_matrix_instances.cpp
@@ -1,28 +1,43 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <memory>
 #include "util/vector.h"
 #include "util/lp/numeric_pair.h"
 #include "util/lp/eta_matrix.hpp"
-#ifdef LEAN_DEBUG
-template double lean::eta_matrix<double, double>::get_elem(unsigned int, unsigned int) const;
-template lean::mpq lean::eta_matrix<lean::mpq, lean::mpq>::get_elem(unsigned int, unsigned int) const;
-template lean::mpq lean::eta_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::get_elem(unsigned int, unsigned int) const;
+#ifdef Z3DEBUG
+template double lp::eta_matrix<double, double>::get_elem(unsigned int, unsigned int) const;
+template lp::mpq lp::eta_matrix<lp::mpq, lp::mpq>::get_elem(unsigned int, unsigned int) const;
+template lp::mpq lp::eta_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::get_elem(unsigned int, unsigned int) const;
 #endif
-template void lean::eta_matrix<double, double>::apply_from_left(vector<double>&, lean::lp_settings&);
-template void lean::eta_matrix<double, double>::apply_from_right(vector<double>&);
-template void lean::eta_matrix<double, double>::conjugate_by_permutation(lean::permutation_matrix<double, double>&);
-template void lean::eta_matrix<lean::mpq, lean::mpq>::apply_from_left(vector<lean::mpq>&, lean::lp_settings&);
-template void lean::eta_matrix<lean::mpq, lean::mpq>::apply_from_right(vector<lean::mpq>&);
-template void lean::eta_matrix<lean::mpq, lean::mpq>::conjugate_by_permutation(lean::permutation_matrix<lean::mpq, lean::mpq>&);
-template void lean::eta_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::apply_from_left(vector<lean::numeric_pair<lean::mpq> >&, lean::lp_settings&);
-template void lean::eta_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::apply_from_right(vector<lean::mpq>&);
-template void lean::eta_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::conjugate_by_permutation(lean::permutation_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >&);
-template void lean::eta_matrix<double, double>::apply_from_left_local<double>(lean::indexed_vector<double>&, lean::lp_settings&);
-template void lean::eta_matrix<lean::mpq, lean::mpq>::apply_from_left_local<lean::mpq>(lean::indexed_vector<lean::mpq>&, lean::lp_settings&);
-template void lean::eta_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::apply_from_left_local<lean::mpq>(lean::indexed_vector<lean::mpq>&, lean::lp_settings&);
-template void lean::eta_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::apply_from_right(lean::indexed_vector<lean::mpq>&);
-template void lean::eta_matrix<lean::mpq, lean::mpq>::apply_from_right(lean::indexed_vector<lean::mpq>&);
-template void lean::eta_matrix<double, double>::apply_from_right(lean::indexed_vector<double>&);
+template void lp::eta_matrix<double, double>::apply_from_left(vector<double>&, lp::lp_settings&);
+template void lp::eta_matrix<double, double>::apply_from_right(vector<double>&);
+template void lp::eta_matrix<double, double>::conjugate_by_permutation(lp::permutation_matrix<double, double>&);
+template void lp::eta_matrix<lp::mpq, lp::mpq>::apply_from_left(vector<lp::mpq>&, lp::lp_settings&);
+template void lp::eta_matrix<lp::mpq, lp::mpq>::apply_from_right(vector<lp::mpq>&);
+template void lp::eta_matrix<lp::mpq, lp::mpq>::conjugate_by_permutation(lp::permutation_matrix<lp::mpq, lp::mpq>&);
+template void lp::eta_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::apply_from_left(vector<lp::numeric_pair<lp::mpq> >&, lp::lp_settings&);
+template void lp::eta_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::apply_from_right(vector<lp::mpq>&);
+template void lp::eta_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::conjugate_by_permutation(lp::permutation_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >&);
+template void lp::eta_matrix<double, double>::apply_from_left_local<double>(lp::indexed_vector<double>&, lp::lp_settings&);
+template void lp::eta_matrix<lp::mpq, lp::mpq>::apply_from_left_local<lp::mpq>(lp::indexed_vector<lp::mpq>&, lp::lp_settings&);
+template void lp::eta_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::apply_from_left_local<lp::mpq>(lp::indexed_vector<lp::mpq>&, lp::lp_settings&);
+template void lp::eta_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::apply_from_right(lp::indexed_vector<lp::mpq>&);
+template void lp::eta_matrix<lp::mpq, lp::mpq>::apply_from_right(lp::indexed_vector<lp::mpq>&);
+template void lp::eta_matrix<double, double>::apply_from_right(lp::indexed_vector<double>&);
diff --git a/src/util/lp/hash_helper.h b/src/util/lp/hash_helper.h
index 6fe31d5cd..ab5fa844b 100644
--- a/src/util/lp/hash_helper.h
+++ b/src/util/lp/hash_helper.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include <utility>
 #include <functional>
@@ -12,8 +27,8 @@
 #endif
 namespace std {
 template<>
-struct hash<lean::mpq> {
-    inline size_t operator()(const lean::mpq & v) const {
+struct hash<lp::mpq> {
+    inline size_t operator()(const lp::mpq & v) const {
         return v.hash();
     }
 };
diff --git a/src/util/lp/implied_bound.h b/src/util/lp/implied_bound.h
index 9583e3cd8..f1c711ffa 100644
--- a/src/util/lp/implied_bound.h
+++ b/src/util/lp/implied_bound.h
@@ -1,11 +1,26 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include "util/lp/lp_settings.h"
 #include "util/lp/lar_constraints.h"
-namespace lean {
+namespace lp {
 struct implied_bound {
     mpq m_bound;
     unsigned m_j; // the column for which the bound has been found
diff --git a/src/util/lp/indexed_value.h b/src/util/lp/indexed_value.h
index 7963dfdf9..216a6f953 100644
--- a/src/util/lp/indexed_value.h
+++ b/src/util/lp/indexed_value.h
@@ -1,10 +1,25 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 
-namespace lean {
+namespace lp {
 template <typename T>
 class indexed_value {
 public:
@@ -41,7 +56,7 @@ public:
         m_value = val;
     }
 };
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template <typename X>
 bool check_vector_for_small_values(indexed_vector<X> & w, lp_settings & settings) {
     for (unsigned i : w.m_index) {
diff --git a/src/util/lp/indexed_vector.h b/src/util/lp/indexed_vector.h
index 6e6a6009b..3b1258ed7 100644
--- a/src/util/lp/indexed_vector.h
+++ b/src/util/lp/indexed_vector.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 #include "util/vector.h"
@@ -11,7 +26,7 @@
 #include "util/lp/lp_utils.h"
 #include "util/lp/lp_settings.h"
 #include <unordered_set>
-namespace lean {
+namespace lp {
 
 template <typename T> void print_vector(const vector<T> & t, std::ostream & out);
 template <typename T> void print_vector(const buffer<T> & t, std::ostream & out);
@@ -76,7 +91,7 @@ public:
 
     void set_value(const T& value, unsigned index);
     void set_value_as_in_dictionary(unsigned index) {
-        lean_assert(index < m_data.size());
+        SASSERT(index < m_data.size());
         T & loc = m_data[index];
         if (is_zero(loc)) {
             m_index.push_back(index);
@@ -161,7 +176,7 @@ public:
         }
     }
     
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     bool is_OK() const;
     void print(std::ostream & out);
 #endif
diff --git a/src/util/lp/indexed_vector.hpp b/src/util/lp/indexed_vector.hpp
index 64e329adc..73055d6da 100644
--- a/src/util/lp/indexed_vector.hpp
+++ b/src/util/lp/indexed_vector.hpp
@@ -1,11 +1,26 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include "util/vector.h"
 #include "util/lp/indexed_vector.h"
 #include "util/lp/lp_settings.h"
-namespace lean {
+namespace lp {
 
 template <typename T>
 void print_vector(const vector<T> & t, std::ostream & out) {
@@ -41,13 +56,13 @@ template <typename T>
 void indexed_vector<T>::resize(unsigned data_size) {
     clear();
     m_data.resize(data_size, numeric_traits<T>::zero());
-    lean_assert(is_OK());
+    SASSERT(is_OK());
 }
 
 template <typename T>
 void indexed_vector<T>::set_value(const T& value, unsigned index) {
     m_data[index] = value;
-    lean_assert(std::find(m_index.begin(), m_index.end(), index) == m_index.end());
+    SASSERT(std::find(m_index.begin(), m_index.end(), index) == m_index.end());
     m_index.push_back(index);
 }
 
@@ -70,7 +85,7 @@ void indexed_vector<T>::erase_from_index(unsigned j) {
         m_index.erase(it);
 }
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template <typename T>
 bool indexed_vector<T>::is_OK() const {
     return true;
diff --git a/src/util/lp/indexed_vector_instances.cpp b/src/util/lp/indexed_vector_instances.cpp
index 6f17a894f..ee078f021 100644
--- a/src/util/lp/indexed_vector_instances.cpp
+++ b/src/util/lp/indexed_vector_instances.cpp
@@ -1,10 +1,25 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include "util/vector.h"
 #include "util/lp/indexed_vector.hpp"
-namespace lean {
+namespace lp {
 template void indexed_vector<double>::clear();
 template void indexed_vector<double>::clear_all();
 template void indexed_vector<double>::erase_from_index(unsigned int);
@@ -17,20 +32,20 @@ template void indexed_vector<mpq>::resize(unsigned int);
 template void indexed_vector<unsigned>::resize(unsigned int);
 template void indexed_vector<mpq>::set_value(const mpq&, unsigned int);
 template void indexed_vector<unsigned>::set_value(const unsigned&, unsigned int);
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template bool indexed_vector<double>::is_OK() const;
 template bool indexed_vector<mpq>::is_OK() const;
-template bool indexed_vector<lean::numeric_pair<mpq> >::is_OK() const;
-template void lean::indexed_vector< lean::mpq>::print(std::basic_ostream<char,struct std::char_traits<char> > &);
-template void lean::indexed_vector<double>::print(std::basic_ostream<char,struct std::char_traits<char> > &);
-template void lean::indexed_vector<lean::numeric_pair<lean::mpq> >::print(std::ostream&);
+template bool indexed_vector<lp::numeric_pair<mpq> >::is_OK() const;
+template void lp::indexed_vector< lp::mpq>::print(std::basic_ostream<char,struct std::char_traits<char> > &);
+template void lp::indexed_vector<double>::print(std::basic_ostream<char,struct std::char_traits<char> > &);
+template void lp::indexed_vector<lp::numeric_pair<lp::mpq> >::print(std::ostream&);
 #endif
 }
-template void lean::print_vector<double>(vector<double> const&, std::ostream&);
-template void lean::print_vector<unsigned int>(vector<unsigned int> const&, std::ostream&);
-template void lean::print_vector<std::string>(vector<std::string> const&, std::ostream&);
-template void lean::print_vector<lean::numeric_pair<lean::mpq> >(vector<lean::numeric_pair<lean::mpq>> const&, std::ostream&);
-template void lean::indexed_vector<double>::resize(unsigned int);
-template void lean::print_vector< lean::mpq>(vector< lean::mpq> const &, std::basic_ostream<char, std::char_traits<char> > &);
-template void lean::print_vector<std::pair<lean::mpq, unsigned int> >(vector<std::pair<lean::mpq, unsigned int>> const&, std::ostream&);
-template void lean::indexed_vector<lean::numeric_pair<lean::mpq> >::erase_from_index(unsigned int);
+template void lp::print_vector<double>(vector<double> const&, std::ostream&);
+template void lp::print_vector<unsigned int>(vector<unsigned int> const&, std::ostream&);
+template void lp::print_vector<std::string>(vector<std::string> const&, std::ostream&);
+template void lp::print_vector<lp::numeric_pair<lp::mpq> >(vector<lp::numeric_pair<lp::mpq>> const&, std::ostream&);
+template void lp::indexed_vector<double>::resize(unsigned int);
+template void lp::print_vector< lp::mpq>(vector< lp::mpq> const &, std::basic_ostream<char, std::char_traits<char> > &);
+template void lp::print_vector<std::pair<lp::mpq, unsigned int> >(vector<std::pair<lp::mpq, unsigned int>> const&, std::ostream&);
+template void lp::indexed_vector<lp::numeric_pair<lp::mpq> >::erase_from_index(unsigned int);
diff --git a/src/util/lp/init_lar_solver.h b/src/util/lp/init_lar_solver.h
index db5a6ed4c..5d78c3ba7 100644
--- a/src/util/lp/init_lar_solver.h
+++ b/src/util/lp/init_lar_solver.h
@@ -1,9 +1,24 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
 
-// here we are inside lean::lar_solver class
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
+
+// here we are inside lp::lar_solver class
 
 bool strategy_is_undecided() const {
     return m_settings.simplex_strategy() == simplex_strategy_enum::undecided;
@@ -11,7 +26,7 @@ bool strategy_is_undecided() const {
 
 var_index add_var(unsigned ext_j) {
     var_index i;
-    lean_assert (ext_j < m_terms_start_index); 
+    SASSERT (ext_j < m_terms_start_index); 
 
     if (ext_j >= m_terms_start_index)
         throw 0; // todo : what is the right way to exit?
@@ -19,19 +34,19 @@ var_index add_var(unsigned ext_j) {
     if (try_get_val(m_ext_vars_to_columns, ext_j, i)) {
         return i;
     }
-    lean_assert(m_vars_to_ul_pairs.size() == A_r().column_count());
+    SASSERT(m_vars_to_ul_pairs.size() == A_r().column_count());
     i = A_r().column_count();
     m_vars_to_ul_pairs.push_back (ul_pair(static_cast<unsigned>(-1)));
     add_non_basic_var_to_core_fields(ext_j);
-    lean_assert(sizes_are_correct());
+    SASSERT(sizes_are_correct());
     return i;
 }
 
 void register_new_ext_var_index(unsigned ext_v) {
-    lean_assert(!contains(m_ext_vars_to_columns, ext_v));
+    SASSERT(!contains(m_ext_vars_to_columns, ext_v));
     unsigned j = static_cast<unsigned>(m_ext_vars_to_columns.size());
     m_ext_vars_to_columns[ext_v] = j;
-    lean_assert(m_columns_to_ext_vars_or_term_indices.size() == j);
+    SASSERT(m_columns_to_ext_vars_or_term_indices.size() == j);
     m_columns_to_ext_vars_or_term_indices.push_back(ext_v);
 }
 
@@ -47,12 +62,12 @@ void add_non_basic_var_to_core_fields(unsigned ext_j) {
 void add_new_var_to_core_fields_for_doubles(bool register_in_basis) {
     unsigned j = A_d().column_count();
     A_d().add_column();
-    lean_assert(m_mpq_lar_core_solver.m_d_x.size() == j);
-    //        lean_assert(m_mpq_lar_core_solver.m_d_low_bounds.size() == j && m_mpq_lar_core_solver.m_d_upper_bounds.size() == j);  // restore later
+    SASSERT(m_mpq_lar_core_solver.m_d_x.size() == j);
+    //        SASSERT(m_mpq_lar_core_solver.m_d_low_bounds.size() == j && m_mpq_lar_core_solver.m_d_upper_bounds.size() == j);  // restore later
     m_mpq_lar_core_solver.m_d_x.resize(j + 1 ); 
     m_mpq_lar_core_solver.m_d_low_bounds.resize(j + 1);
     m_mpq_lar_core_solver.m_d_upper_bounds.resize(j + 1);
-    lean_assert(m_mpq_lar_core_solver.m_d_heading.size() == j); // as A().column_count() on the entry to the method
+    SASSERT(m_mpq_lar_core_solver.m_d_heading.size() == j); // as A().column_count() on the entry to the method
     if (register_in_basis) {
         A_d().add_row();
         m_mpq_lar_core_solver.m_d_heading.push_back(m_mpq_lar_core_solver.m_d_basis.size());
@@ -66,15 +81,15 @@ void add_new_var_to_core_fields_for_doubles(bool register_in_basis) {
 void add_new_var_to_core_fields_for_mpq(bool register_in_basis) {
     unsigned j = A_r().column_count();
     A_r().add_column();
-    lean_assert(m_mpq_lar_core_solver.m_r_x.size() == j);
-    //        lean_assert(m_mpq_lar_core_solver.m_r_low_bounds.size() == j && m_mpq_lar_core_solver.m_r_upper_bounds.size() == j);  // restore later
+    SASSERT(m_mpq_lar_core_solver.m_r_x.size() == j);
+    //        SASSERT(m_mpq_lar_core_solver.m_r_low_bounds.size() == j && m_mpq_lar_core_solver.m_r_upper_bounds.size() == j);  // restore later
     m_mpq_lar_core_solver.m_r_x.resize(j + 1);
     m_mpq_lar_core_solver.m_r_low_bounds.increase_size_by_one();
     m_mpq_lar_core_solver.m_r_upper_bounds.increase_size_by_one();
     m_mpq_lar_core_solver.m_r_solver.m_inf_set.increase_size_by_one();
     m_mpq_lar_core_solver.m_r_solver.m_costs.resize(j + 1);
     m_mpq_lar_core_solver.m_r_solver.m_d.resize(j + 1);
-    lean_assert(m_mpq_lar_core_solver.m_r_heading.size() == j); // as A().column_count() on the entry to the method
+    SASSERT(m_mpq_lar_core_solver.m_r_heading.size() == j); // as A().column_count() on the entry to the method
     if (register_in_basis) {
         A_r().add_row();
         m_mpq_lar_core_solver.m_r_heading.push_back(m_mpq_lar_core_solver.m_r_basis.size());
@@ -110,14 +125,14 @@ var_index add_term(const vector<std::pair<mpq, var_index>> & coeffs,
         if (m_settings.bound_propagation())
             m_rows_with_changed_bounds.insert(A_r().row_count() - 1);
     } 
-    lean_assert(m_ext_vars_to_columns.size() == A_r().column_count());
+    SASSERT(m_ext_vars_to_columns.size() == A_r().column_count());
     return ret;
 }
 
 void add_row_for_term(const lar_term * term, unsigned term_ext_index) {
-    lean_assert(sizes_are_correct());
+    SASSERT(sizes_are_correct());
     add_row_from_term_no_constraint(term, term_ext_index);
-    lean_assert(sizes_are_correct());
+    SASSERT(sizes_are_correct());
 }
 
 void add_row_from_term_no_constraint(const lar_term * term, unsigned term_ext_index) {
@@ -142,7 +157,7 @@ void add_row_from_term_no_constraint(const lar_term * term, unsigned term_ext_in
 
 void add_basic_var_to_core_fields() {
     bool use_lu = m_mpq_lar_core_solver.need_to_presolve_with_double_solver();
-    lean_assert(!use_lu || A_r().column_count() == A_d().column_count());
+    SASSERT(!use_lu || A_r().column_count() == A_d().column_count());
     m_mpq_lar_core_solver.m_column_types.push_back(column_type::free_column);
     m_columns_with_changed_bound.increase_size_by_one();
     m_rows_with_changed_bounds.increase_size_by_one();
@@ -160,7 +175,7 @@ constraint_index add_var_bound(var_index j, lconstraint_kind kind, const mpq & r
     } else {
         add_var_bound_on_constraint_for_term(j, kind, right_side, ci);
     }
-    lean_assert(sizes_are_correct());
+    SASSERT(sizes_are_correct());
     return ci;
 }
 
@@ -182,12 +197,12 @@ void update_column_type_and_bound(var_index j, lconstraint_kind kind, const mpq
         update_fixed_column_type_and_bound(j, kind, right_side, constr_index);
         break;
     default:
-        lean_assert(false); // cannot be here
+        SASSERT(false); // cannot be here
     }
 }
 
 void add_var_bound_on_constraint_for_term(var_index j, lconstraint_kind kind, const mpq & right_side, constraint_index ci) {
-    lean_assert(is_term(j));
+    SASSERT(is_term(j));
     unsigned adjusted_term_index = adjust_term_index(j);
     unsigned term_j;
     if (try_get_val(m_ext_vars_to_columns, j, term_j)) {
@@ -208,11 +223,11 @@ void add_constraint_from_term_and_create_new_column_row(unsigned term_j, const l
     unsigned j = A_r().column_count() - 1;
     update_column_type_and_bound(j, kind, right_side - term->m_v, m_constraints.size());
     m_constraints.push_back(new lar_term_constraint(term, kind, right_side));
-    lean_assert(A_r().column_count() == m_mpq_lar_core_solver.m_r_solver.m_costs.size());
+    SASSERT(A_r().column_count() == m_mpq_lar_core_solver.m_r_solver.m_costs.size());
 }
 
 void decide_on_strategy_and_adjust_initial_state() {
-    lean_assert(strategy_is_undecided());
+    SASSERT(strategy_is_undecided());
     if (m_vars_to_ul_pairs.size() > m_settings.column_number_threshold_for_using_lu_in_lar_solver) {
         m_settings.simplex_strategy() = simplex_strategy_enum::lu;
     } else {
@@ -230,7 +245,7 @@ void adjust_initial_state() {
         adjust_initial_state_for_tableau_rows();
         break;
     case simplex_strategy_enum::tableau_costs:
-        lean_assert(false); // not implemented
+        SASSERT(false); // not implemented
     case simplex_strategy_enum::undecided:
         adjust_initial_state_for_tableau_rows();
         break;
@@ -249,12 +264,12 @@ void adjust_initial_state_for_lu() {
     /*
     unsigned j = A_d().column_count();
     A_d().add_column();
-    lean_assert(m_mpq_lar_core_solver.m_d_x.size() == j);
-    //        lean_assert(m_mpq_lar_core_solver.m_d_low_bounds.size() == j && m_mpq_lar_core_solver.m_d_upper_bounds.size() == j);  // restore later
+    SASSERT(m_mpq_lar_core_solver.m_d_x.size() == j);
+    //        SASSERT(m_mpq_lar_core_solver.m_d_low_bounds.size() == j && m_mpq_lar_core_solver.m_d_upper_bounds.size() == j);  // restore later
     m_mpq_lar_core_solver.m_d_x.resize(j + 1 ); 
     m_mpq_lar_core_solver.m_d_low_bounds.resize(j + 1);
     m_mpq_lar_core_solver.m_d_upper_bounds.resize(j + 1);
-    lean_assert(m_mpq_lar_core_solver.m_d_heading.size() == j); // as A().column_count() on the entry to the method
+    SASSERT(m_mpq_lar_core_solver.m_d_heading.size() == j); // as A().column_count() on the entry to the method
     if (register_in_basis) {
         A_d().add_row();
         m_mpq_lar_core_solver.m_d_heading.push_back(m_mpq_lar_core_solver.m_d_basis.size());
@@ -275,13 +290,13 @@ void adjust_initial_state_for_tableau_rows() {
 
 // this fills the last row of A_d and sets the basis column: -1 in the last column of the row
 void fill_last_row_of_A_d(static_matrix<double, double> & A, const lar_term* ls) {
-    lean_assert(A.row_count() > 0);
-    lean_assert(A.column_count() > 0);
+    SASSERT(A.row_count() > 0);
+    SASSERT(A.column_count() > 0);
     unsigned last_row = A.row_count() - 1;
-    lean_assert(A.m_rows[last_row].empty());
+    SASSERT(A.m_rows[last_row].empty());
 
     for (auto & t : ls->m_coeffs) {
-        lean_assert(!is_zero(t.second));
+        SASSERT(!is_zero(t.second));
         var_index j = t.first;
         A.set(last_row, j, - t.second.get_double());
     }
@@ -297,8 +312,8 @@ void update_free_column_type_and_bound(var_index j, lconstraint_kind kind, const
         y_of_bound = -1;
     case LE:
         m_mpq_lar_core_solver.m_column_types[j] = column_type::upper_bound;
-        lean_assert(m_mpq_lar_core_solver.m_column_types()[j] == column_type::upper_bound);
-        lean_assert(m_mpq_lar_core_solver.m_r_upper_bounds.size() > j);
+        SASSERT(m_mpq_lar_core_solver.m_column_types()[j] == column_type::upper_bound);
+        SASSERT(m_mpq_lar_core_solver.m_r_upper_bounds.size() > j);
         {
             auto up = numeric_pair<mpq>(right_side, y_of_bound);
             m_mpq_lar_core_solver.m_r_upper_bounds[j] = up;
@@ -309,7 +324,7 @@ void update_free_column_type_and_bound(var_index j, lconstraint_kind kind, const
         y_of_bound = 1;
     case GE:
         m_mpq_lar_core_solver.m_column_types[j] = column_type::low_bound;
-        lean_assert(m_mpq_lar_core_solver.m_r_upper_bounds.size() > j);
+        SASSERT(m_mpq_lar_core_solver.m_r_upper_bounds.size() > j);
         {
             auto low = numeric_pair<mpq>(right_side, y_of_bound);
             m_mpq_lar_core_solver.m_r_low_bounds[j] = low;
@@ -324,14 +339,14 @@ void update_free_column_type_and_bound(var_index j, lconstraint_kind kind, const
         break;
 
     default:
-        lean_unreachable();
+        SASSERT(false);
                 
     }
     m_columns_with_changed_bound.insert(j);
 }
 
 void update_upper_bound_column_type_and_bound(var_index j, lconstraint_kind kind, const mpq & right_side, constraint_index ci) {
-    lean_assert(m_mpq_lar_core_solver.m_column_types()[j] == column_type::upper_bound);
+    SASSERT(m_mpq_lar_core_solver.m_column_types()[j] == column_type::upper_bound);
     mpq y_of_bound(0);
     switch (kind) {
     case LT:
@@ -382,13 +397,13 @@ void update_upper_bound_column_type_and_bound(var_index j, lconstraint_kind kind
         break;
 
     default:
-        lean_unreachable();
+        SASSERT(false);
                 
     }
 }
     
 void update_boxed_column_type_and_bound(var_index j, lconstraint_kind kind, const mpq & right_side, constraint_index ci) {
-    lean_assert(m_status == INFEASIBLE || (m_mpq_lar_core_solver.m_column_types()[j] == column_type::boxed && m_mpq_lar_core_solver.m_r_low_bounds()[j] < m_mpq_lar_core_solver.m_r_upper_bounds()[j]));
+    SASSERT(m_status == INFEASIBLE || (m_mpq_lar_core_solver.m_column_types()[j] == column_type::boxed && m_mpq_lar_core_solver.m_r_low_bounds()[j] < m_mpq_lar_core_solver.m_r_upper_bounds()[j]));
     mpq y_of_bound(0);
     switch (kind) {
     case LT:
@@ -404,7 +419,7 @@ void update_boxed_column_type_and_bound(var_index j, lconstraint_kind kind, cons
 
             if (up < m_mpq_lar_core_solver.m_r_low_bounds[j]) {
                 m_status = INFEASIBLE;
-                lean_assert(false);
+                SASSERT(false);
                 m_infeasible_column_index = j;
             } else {
                 if (m_mpq_lar_core_solver.m_r_low_bounds()[j] == m_mpq_lar_core_solver.m_r_upper_bounds()[j])
@@ -453,12 +468,12 @@ void update_boxed_column_type_and_bound(var_index j, lconstraint_kind kind, cons
         }
 
     default:
-        lean_unreachable();
+        SASSERT(false);
                 
     }
 }
 void update_low_bound_column_type_and_bound(var_index j, lconstraint_kind kind, const mpq & right_side, constraint_index ci) {
-    lean_assert(m_mpq_lar_core_solver.m_column_types()[j] == column_type::low_bound);
+    SASSERT(m_mpq_lar_core_solver.m_column_types()[j] == column_type::low_bound);
     mpq y_of_bound(0);
     switch (kind) {
     case LT:
@@ -508,14 +523,14 @@ void update_low_bound_column_type_and_bound(var_index j, lconstraint_kind kind,
         }
 
     default:
-        lean_unreachable();
+        SASSERT(false);
                 
     }
 }
 
 void update_fixed_column_type_and_bound(var_index j, lconstraint_kind kind, const mpq & right_side, constraint_index ci) {
-    lean_assert(m_status == INFEASIBLE || (m_mpq_lar_core_solver.m_column_types()[j] == column_type::fixed && m_mpq_lar_core_solver.m_r_low_bounds()[j] == m_mpq_lar_core_solver.m_r_upper_bounds()[j]));
-    lean_assert(m_status == INFEASIBLE || (m_mpq_lar_core_solver.m_r_low_bounds()[j].y.is_zero() && m_mpq_lar_core_solver.m_r_upper_bounds()[j].y.is_zero()));
+    SASSERT(m_status == INFEASIBLE || (m_mpq_lar_core_solver.m_column_types()[j] == column_type::fixed && m_mpq_lar_core_solver.m_r_low_bounds()[j] == m_mpq_lar_core_solver.m_r_upper_bounds()[j]));
+    SASSERT(m_status == INFEASIBLE || (m_mpq_lar_core_solver.m_r_low_bounds()[j].y.is_zero() && m_mpq_lar_core_solver.m_r_upper_bounds()[j].y.is_zero()));
     auto v = numeric_pair<mpq>(right_side, mpq(0));
         
     mpq y_of_bound(0);
@@ -569,7 +584,7 @@ void update_fixed_column_type_and_bound(var_index j, lconstraint_kind kind, cons
         }
 
     default:
-        lean_unreachable();
+        SASSERT(false);
                 
     }
 }
diff --git a/src/util/lp/int_set.h b/src/util/lp/int_set.h
index 0619facd8..698b8bc49 100644
--- a/src/util/lp/int_set.h
+++ b/src/util/lp/int_set.h
@@ -1,12 +1,27 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include "util/vector.h"
 #include "util/lp/indexed_vector.h"
 #include <ostream>
-namespace lean {
+namespace lp {
 // serves at a set of non-negative integers smaller than the set size
 class int_set {
     vector<int> m_data;
@@ -20,7 +35,7 @@ public:
         return m_data[j] >= 0;
     }
     void insert(unsigned j) {
-        lean_assert(j < m_data.size());
+        SASSERT(j < m_data.size());
         if (contains(j)) return;
         m_data[j] = m_index.size();
         m_index.push_back(j);
diff --git a/src/util/lp/iterator_on_column.h b/src/util/lp/iterator_on_column.h
index 215514b39..5bb43f4c6 100644
--- a/src/util/lp/iterator_on_column.h
+++ b/src/util/lp/iterator_on_column.h
@@ -1,12 +1,27 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include "util/lp/linear_combination_iterator.h"
 #include "util/lp/static_matrix.h"
 #include "util/lp/lar_term.h"
-namespace lean {
+namespace lp {
 template <typename T, typename X>
 struct iterator_on_column:linear_combination_iterator<T> {
     const vector<column_cell>& m_column; // the offset in term coeffs
diff --git a/src/util/lp/iterator_on_indexed_vector.h b/src/util/lp/iterator_on_indexed_vector.h
index 532b62617..2c8daf83b 100644
--- a/src/util/lp/iterator_on_indexed_vector.h
+++ b/src/util/lp/iterator_on_indexed_vector.h
@@ -1,10 +1,25 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include "util/lp/linear_combination_iterator.h"
-namespace lean {
+namespace lp {
 template <typename T>
 struct iterator_on_indexed_vector:linear_combination_iterator<T> {
     const indexed_vector<T> & m_v;
diff --git a/src/util/lp/iterator_on_pivot_row.h b/src/util/lp/iterator_on_pivot_row.h
index 1a9381a70..8aa498477 100644
--- a/src/util/lp/iterator_on_pivot_row.h
+++ b/src/util/lp/iterator_on_pivot_row.h
@@ -1,10 +1,25 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include "util/lp/iterator_on_indexed_vector.h"
-namespace lean {
+namespace lp {
 template <typename T>
 struct iterator_on_pivot_row:linear_combination_iterator<T> {
     bool m_basis_returned;
diff --git a/src/util/lp/iterator_on_row.h b/src/util/lp/iterator_on_row.h
index 96a1a8cf3..1ac5b66bc 100644
--- a/src/util/lp/iterator_on_row.h
+++ b/src/util/lp/iterator_on_row.h
@@ -1,10 +1,25 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include "util/lp/linear_combination_iterator.h"
-namespace lean {
+namespace lp {
 template <typename T>
 struct iterator_on_row:linear_combination_iterator<T> {
     const vector<row_cell<T>> & m_row;
diff --git a/src/util/lp/iterator_on_term_with_basis_var.h b/src/util/lp/iterator_on_term_with_basis_var.h
index 3dd217103..e566b92b5 100644
--- a/src/util/lp/iterator_on_term_with_basis_var.h
+++ b/src/util/lp/iterator_on_term_with_basis_var.h
@@ -1,12 +1,27 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include "util/lp/linear_combination_iterator.h"
 #include "util/lp/numeric_pair.h"
 #include "util/lp/lar_term.h"
-namespace lean {
+namespace lp {
 struct iterator_on_term_with_basis_var:linear_combination_iterator<mpq> {
     const lar_term & m_term;
     std::unordered_map<unsigned, mpq>::const_iterator m_i; // the offset in term coeffs
diff --git a/src/util/lp/lar_constraints.h b/src/util/lp/lar_constraints.h
index ee0864a4e..7b573bab7 100644
--- a/src/util/lp/lar_constraints.h
+++ b/src/util/lp/lar_constraints.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 #include "util/vector.h"
@@ -12,7 +27,7 @@
 #include "util/lp/lp_utils.h"
 #include "util/lp/ul_pair.h"
 #include "util/lp/lar_term.h"
-namespace lean {
+namespace lp {
 inline lconstraint_kind flip_kind(lconstraint_kind t) {
     return static_cast<lconstraint_kind>( - static_cast<int>(t));
 }
@@ -25,7 +40,7 @@ inline std::string lconstraint_kind_string(lconstraint_kind t) {
     case GT: return std::string(">");
     case EQ: return std::string("=");
     }
-    lean_unreachable();
+    SASSERT(false);
     return std::string(); // it is unreachable
 }
 
@@ -74,7 +89,7 @@ public:
         :  lar_base_constraint(kind, right_side), m_coeffs(left_side) {}
     
     lar_constraint(const lar_base_constraint & c) {
-        lean_assert(false); // should not be called : todo!
+        SASSERT(false); // should not be called : todo!
     }
 
     unsigned size() const {
diff --git a/src/util/lp/lar_core_solver.h b/src/util/lp/lar_core_solver.h
index 7e402d726..61b0d9b38 100644
--- a/src/util/lp/lar_core_solver.h
+++ b/src/util/lp/lar_core_solver.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include "util/vector.h"
 #include <string>
@@ -18,7 +33,7 @@
 #include "util/lp/iterator_on_column.h"
 #include "util/lp/iterator_on_indexed_vector.h"
 #include "util/lp/stacked_value.h"
-namespace lean {
+namespace lp {
 
 class lar_core_solver  {
     // m_sign_of_entering is set to 1 if the entering variable needs
@@ -168,9 +183,9 @@ public:
     }
 
     void push() {
-        lean_assert(m_r_solver.basis_heading_is_correct());
-        lean_assert(!need_to_presolve_with_double_solver() || m_d_solver.basis_heading_is_correct());
-        lean_assert(m_column_types.size() == m_r_A.column_count());
+        SASSERT(m_r_solver.basis_heading_is_correct());
+        SASSERT(!need_to_presolve_with_double_solver() || m_d_solver.basis_heading_is_correct());
+        SASSERT(m_column_types.size() == m_r_A.column_count());
         m_stacked_simplex_strategy = settings().simplex_strategy();
         m_stacked_simplex_strategy.push();
         m_column_types.push();
@@ -192,7 +207,7 @@ public:
 
     template <typename K> 
     void push_vector(stacked_vector<K> & pushed_vector, const vector<K> & vector) {
-        lean_assert(pushed_vector.size() <= vector.size());
+        SASSERT(pushed_vector.size() <= vector.size());
         for (unsigned i = 0; i < vector.size();i++) {
             if (i == pushed_vector.size()) {
                 pushed_vector.push_back(vector[i]);
@@ -242,8 +257,8 @@ public:
         pop_basis(k);
         m_stacked_simplex_strategy.pop(k);
         settings().simplex_strategy() = m_stacked_simplex_strategy;
-        lean_assert(m_r_solver.basis_heading_is_correct());
-        lean_assert(!need_to_presolve_with_double_solver() || m_d_solver.basis_heading_is_correct());
+        SASSERT(m_r_solver.basis_heading_is_correct());
+        SASSERT(!need_to_presolve_with_double_solver() || m_d_solver.basis_heading_is_correct());
     }
 
     bool need_to_presolve_with_double_solver() const {
@@ -304,11 +319,11 @@ public:
                 break;
 
             default:
-                lean_assert(false);
+                SASSERT(false);
             }
             break;
         default:
-            lean_unreachable();
+            SASSERT(false);
         }
         m_r_solver.remove_column_from_inf_set(j);
         return true;
@@ -317,7 +332,7 @@ public:
     
     
     void prepare_solver_x_with_signature_tableau(const lar_solution_signature & signature) {
-        lean_assert(m_r_solver.inf_set_is_correct());
+        SASSERT(m_r_solver.inf_set_is_correct());
         for (auto &t : signature) {
             unsigned j = t.first;
             if (m_r_heading[j] >= 0)
@@ -332,9 +347,9 @@ public:
                 m_r_solver.m_x[jb] -= delta * m_r_solver.m_A.get_val(cc);
                 m_r_solver.update_column_in_inf_set(jb);
             }
-            lean_assert(m_r_solver.A_mult_x_is_off() == false);
+            SASSERT(m_r_solver.A_mult_x_is_off() == false);
         }
-        lean_assert(m_r_solver.inf_set_is_correct());
+        SASSERT(m_r_solver.inf_set_is_correct());
     }
 
     
@@ -342,7 +357,7 @@ public:
     void prepare_solver_x_with_signature(const lar_solution_signature & signature, lp_primal_core_solver<L,K> & s) {
         for (auto &t : signature) {
             unsigned j = t.first;
-            lean_assert(m_r_heading[j] < 0);
+            SASSERT(m_r_heading[j] < 0);
             auto pos_type = t.second;
             switch (pos_type) {
             case at_low_bound:
@@ -359,7 +374,7 @@ public:
             case not_at_bound:
                   switch (m_column_types[j]) {
                   case column_type::free_column:
-                      lean_assert(false); // unreachable
+                      SASSERT(false); // unreachable
                   case column_type::upper_bound:
                       s.m_x[j] = s.m_upper_bounds[j];
                       break;
@@ -377,15 +392,15 @@ public:
                       s.m_x[j] = s.m_low_bounds[j];
                       break;
                   default:
-                      lean_assert(false);
+                      SASSERT(false);
                   }
                   break;
             default:
-                lean_unreachable();
+                SASSERT(false);
             }
         }
 
-        lean_assert(is_zero_vector(s.m_b));
+        SASSERT(is_zero_vector(s.m_b));
         s.solve_Ax_eq_b();
     }
 
@@ -418,7 +433,7 @@ public:
             // the queues of delayed indices
             std::queue<unsigned> entr_q, leav_q;
             auto * l = cs.m_factorization;
-            lean_assert(l->get_status() == LU_status::OK);
+            SASSERT(l->get_status() == LU_status::OK);
             for (unsigned i = 0; i < trace_of_basis_change.size(); i+= 2) {
                 unsigned entering = trace_of_basis_change[i];
                 unsigned leaving = trace_of_basis_change[i+1];
@@ -446,8 +461,8 @@ public:
                         continue;
                     }
                 }
-                lean_assert(cs.m_basis_heading[entering] < 0);
-                lean_assert(cs.m_basis_heading[leaving] >= 0);
+                SASSERT(cs.m_basis_heading[entering] < 0);
+                SASSERT(cs.m_basis_heading[leaving] >= 0);
                 if (l->get_status() == LU_status::OK) {
                     l->prepare_entering(entering, w); // to init vector w
                     l->replace_column(zero_of_type<L>(), w, cs.m_basis_heading[leaving]);
@@ -471,7 +486,7 @@ public:
 
     void solve_on_signature_tableau(const lar_solution_signature & signature, const vector<unsigned> & changes_of_basis) {
         r_basis_is_OK();
-        lean_assert(settings().use_tableau());
+        SASSERT(settings().use_tableau());
         bool r = catch_up_in_lu_tableau(changes_of_basis, m_d_solver.m_basis_heading);
 
         if (!r) { // it is the case where m_d_solver gives a degenerated basis
@@ -490,10 +505,10 @@ public:
                 return;
             m_r_solver.stop_tracing_basis_changes();
             // and now catch up in the double solver
-            lean_assert(m_r_solver.total_iterations() >= m_r_solver.m_trace_of_basis_change_vector.size() /2);
+            SASSERT(m_r_solver.total_iterations() >= m_r_solver.m_trace_of_basis_change_vector.size() /2);
             catch_up_in_lu(m_r_solver.m_trace_of_basis_change_vector, m_r_solver.m_basis_heading, m_d_solver);
         }
-        lean_assert(r_basis_is_OK());
+        SASSERT(r_basis_is_OK());
     }
 
     bool adjust_x_of_column(unsigned j) {
@@ -507,16 +522,16 @@ public:
         }
 
         m_r_solver.snap_column_to_bound_tableau(j);
-        lean_assert(m_r_solver.column_is_feasible(j));
+        SASSERT(m_r_solver.column_is_feasible(j));
         m_r_solver.m_inf_set.erase(j);
         */
-        lean_assert(false);
+        SASSERT(false);
         return true;
     }
 
     
     bool catch_up_in_lu_tableau(const vector<unsigned> & trace_of_basis_change, const vector<int> & basis_heading) {
-        lean_assert(r_basis_is_OK());
+        SASSERT(r_basis_is_OK());
         // the queues of delayed indices
         std::queue<unsigned> entr_q, leav_q;
         for (unsigned i = 0; i < trace_of_basis_change.size(); i+= 2) {
@@ -546,47 +561,47 @@ public:
                     continue;
                 }
             }
-            lean_assert(m_r_solver.m_basis_heading[entering] < 0);
-            lean_assert(m_r_solver.m_basis_heading[leaving] >= 0);
+            SASSERT(m_r_solver.m_basis_heading[entering] < 0);
+            SASSERT(m_r_solver.m_basis_heading[leaving] >= 0);
             m_r_solver.change_basis_unconditionally(entering, leaving);
             if(!m_r_solver.pivot_column_tableau(entering, m_r_solver.m_basis_heading[entering])) {
                 // unroll the last step
                 m_r_solver.change_basis_unconditionally(leaving, entering);
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
                 bool t =
 #endif
                     m_r_solver.pivot_column_tableau(leaving, m_r_solver.m_basis_heading[leaving]);
-#ifdef LEAN_DEBUG
-                lean_assert(t);
+#ifdef Z3DEBUG
+                SASSERT(t);
 #endif 
                 return false;
             }
         }
-        lean_assert(r_basis_is_OK());
+        SASSERT(r_basis_is_OK());
         return true;
     }
 
 
     bool r_basis_is_OK() const {
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
         if (!m_r_solver.m_settings.use_tableau())
             return true;
         for (unsigned j : m_r_solver.m_basis) {
-            lean_assert(m_r_solver.m_A.m_columns[j].size() == 1);
-            lean_assert(m_r_solver.m_A.get_val(m_r_solver.m_A.m_columns[j][0]) == one_of_type<mpq>());
+            SASSERT(m_r_solver.m_A.m_columns[j].size() == 1);
+            SASSERT(m_r_solver.m_A.get_val(m_r_solver.m_A.m_columns[j][0]) == one_of_type<mpq>());
         }
         for (unsigned j =0; j < m_r_solver.m_basis_heading.size(); j++) {
             if (m_r_solver.m_basis_heading[j] >= 0) continue;
             if (m_r_solver.m_column_types[j] == column_type::fixed) continue;
-            lean_assert(static_cast<unsigned>(- m_r_solver.m_basis_heading[j] - 1) < m_r_solver.m_column_types.size());
-            lean_assert( m_r_solver.m_basis_heading[j] <= -1);
+            SASSERT(static_cast<unsigned>(- m_r_solver.m_basis_heading[j] - 1) < m_r_solver.m_column_types.size());
+            SASSERT( m_r_solver.m_basis_heading[j] <= -1);
         }
 #endif
         return true;
     }
     
     void solve_on_signature(const lar_solution_signature & signature, const vector<unsigned> & changes_of_basis) {
-        lean_assert(!settings().use_tableau());
+        SASSERT(!settings().use_tableau());
         if (m_r_solver.m_factorization == nullptr) {
             for (unsigned j = 0; j < changes_of_basis.size(); j+=2) {
                 unsigned entering = changes_of_basis[j];
@@ -615,7 +630,7 @@ public:
                 return;
             m_r_solver.stop_tracing_basis_changes();
             // and now catch up in the double solver
-            lean_assert(m_r_solver.total_iterations() >= m_r_solver.m_trace_of_basis_change_vector.size() /2);
+            SASSERT(m_r_solver.total_iterations() >= m_r_solver.m_trace_of_basis_change_vector.size() /2);
             catch_up_in_lu(m_r_solver.m_trace_of_basis_change_vector, m_r_solver.m_basis_heading, m_d_solver);
         }
     }
@@ -641,7 +656,7 @@ public:
     template <typename L, typename K>
     void extract_signature_from_lp_core_solver(const lp_primal_core_solver<L, K> & solver, lar_solution_signature & signature) {
         signature.clear();
-        lean_assert(signature.size() == 0);
+        SASSERT(signature.size() == 0);
         for (unsigned j = 0; j < solver.m_basis_heading.size(); j++) {
             if (solver.m_basis_heading[j] < 0) {
                 signature[j] = solver.get_non_basic_column_value_position(j);
@@ -664,7 +679,7 @@ public:
             if (upper_bound_is_set(j)) {
                 const auto & ub = m_r_solver.m_upper_bounds[j];
                 m_d_upper_bounds[j] = ub.x.get_double() + delta * ub.y.get_double();
-                lean_assert(!low_bound_is_set(j) || (m_d_upper_bounds[j] >= m_d_low_bounds[j]));
+                SASSERT(!low_bound_is_set(j) || (m_d_upper_bounds[j] >= m_d_low_bounds[j]));
             }
         }
     }
@@ -729,7 +744,7 @@ public:
         case column_type::fixed:
             return true;
         default:
-            lean_assert(false);
+            SASSERT(false);
         }
         return false;
     }
@@ -744,20 +759,20 @@ public:
         case column_type::fixed:
             return true;
         default:
-            lean_assert(false);
+            SASSERT(false);
         }
         return false;
     }
 
     void update_delta(mpq& delta, numeric_pair<mpq> const& l, numeric_pair<mpq> const& u) const {
-        lean_assert(l <= u);
+        SASSERT(l <= u);
         if (l.x < u.x && l.y > u.y) {
             mpq delta1 = (u.x - l.x) / (l.y - u.y);
             if (delta1 < delta) {
                 delta = delta1;
             }
         }
-        lean_assert(l.x + delta * l.y <= u.x + delta * u.y);
+        SASSERT(l.x + delta * l.y <= u.x + delta * u.y);
     }
 
 
diff --git a/src/util/lp/lar_core_solver.hpp b/src/util/lp/lar_core_solver.hpp
index a6dd7e3e0..62a5c7887 100644
--- a/src/util/lp/lar_core_solver.hpp
+++ b/src/util/lp/lar_core_solver.hpp
@@ -1,16 +1,46 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <string>
 #include "util/vector.h"
 #include "util/lp/lar_core_solver.h"
 #include "util/lp/lar_solution_signature.h"
-namespace lean {
+namespace lp {
 lar_core_solver::lar_core_solver(
                                  lp_settings & settings,
                                  const column_namer & column_names
@@ -42,9 +72,9 @@ lar_core_solver::lar_core_solver(
                     column_names){}
 
 void lar_core_solver::init_costs(bool first_time) {
-    lean_assert(false); // should not be called
-    // lean_assert(this->m_x.size() >= this->m_n());
-    // lean_assert(this->m_column_types.size() >= this->m_n());
+    SASSERT(false); // should not be called
+    // SASSERT(this->m_x.size() >= this->m_n());
+    // SASSERT(this->m_column_types.size() >= this->m_n());
     // if (first_time)
     //     this->m_costs.resize(this->m_n());
     // X inf = this->m_infeasibility;
@@ -54,7 +84,7 @@ void lar_core_solver::init_costs(bool first_time) {
     // if (!(first_time || inf >= this->m_infeasibility)) {
     //     LP_OUT(this->m_settings, "iter = " << this->total_iterations() << std::endl);
     //     LP_OUT(this->m_settings, "inf was " << T_to_string(inf) << " and now " << T_to_string(this->m_infeasibility) << std::endl);
-    //     lean_assert(false);
+    //     SASSERT(false);
     // }
     // if (inf == this->m_infeasibility)
     //     this->m_iters_with_no_cost_growing++;
@@ -105,7 +135,7 @@ void lar_core_solver::init_cost_for_column(unsigned j) {
         this->m_costs[j] = numeric_traits<T>::zero();
         break;
     default:
-        lean_assert(false);
+        SASSERT(false);
         break;
         }*/
 }
@@ -138,15 +168,15 @@ int lar_core_solver::column_is_out_of_bounds(unsigned j) {
         return 0;
         break;
         }*/
-    lean_assert(false);
+    SASSERT(false);
     return true;
 }
 
 
 
 void lar_core_solver::calculate_pivot_row(unsigned i) {
-    lean_assert(!m_r_solver.use_tableau());
-    lean_assert(m_r_solver.m_pivot_row.is_OK());
+    SASSERT(!m_r_solver.use_tableau());
+    SASSERT(m_r_solver.m_pivot_row.is_OK());
     m_r_solver.m_pivot_row_of_B_1.clear();
     m_r_solver.m_pivot_row_of_B_1.resize(m_r_solver.m_m());
     m_r_solver.m_pivot_row.clear();
@@ -208,7 +238,7 @@ void lar_core_solver::calculate_pivot_row(unsigned i) {
 }
 
 void lar_core_solver::fill_not_improvable_zero_sum_from_inf_row() {
-    lean_assert(m_r_solver.A_mult_x_is_off() == false);
+    SASSERT(m_r_solver.A_mult_x_is_off() == false);
     unsigned bj = m_r_basis[m_r_solver.m_inf_row_index_for_tableau];
     m_infeasible_sum_sign =  m_r_solver.inf_sign_of_column(bj);
     m_infeasible_linear_combination.clear();
@@ -243,15 +273,15 @@ void lar_core_solver::fill_not_improvable_zero_sum() {
 
 
 void lar_core_solver::solve() {
-    lean_assert(m_r_solver.non_basic_columns_are_set_correctly());
-    lean_assert(m_r_solver.inf_set_is_correct());
+    SASSERT(m_r_solver.non_basic_columns_are_set_correctly());
+    SASSERT(m_r_solver.inf_set_is_correct());
     if (m_r_solver.current_x_is_feasible() && m_r_solver.m_look_for_feasible_solution_only) {
         m_r_solver.set_status(OPTIMAL);
         return;
     }
     ++settings().st().m_need_to_solve_inf;
-    lean_assert(!m_r_solver.A_mult_x_is_off());
-    lean_assert((!settings().use_tableau()) || r_basis_is_OK());
+    SASSERT(!m_r_solver.A_mult_x_is_off());
+    SASSERT((!settings().use_tableau()) || r_basis_is_OK());
     if (need_to_presolve_with_double_solver()) {
         prefix_d();
         lar_solution_signature solution_signature;
@@ -264,11 +294,11 @@ void lar_core_solver::solve() {
             solve_on_signature_tableau(solution_signature, changes_of_basis);
         else 
             solve_on_signature(solution_signature, changes_of_basis);
-        lean_assert(!settings().use_tableau() || r_basis_is_OK());
+        SASSERT(!settings().use_tableau() || r_basis_is_OK());
     } else {
         if (!settings().use_tableau()) {
             bool snapped = m_r_solver.snap_non_basic_x_to_bound();   
-            lean_assert(m_r_solver.non_basic_columns_are_set_correctly());
+            SASSERT(m_r_solver.non_basic_columns_are_set_correctly());
             if (snapped)
                 m_r_solver.solve_Ax_eq_b();
         }
@@ -276,16 +306,16 @@ void lar_core_solver::solve() {
             m_r_solver.find_feasible_solution();
         else
             m_r_solver.solve();
-        lean_assert(!settings().use_tableau() || r_basis_is_OK());
+        SASSERT(!settings().use_tableau() || r_basis_is_OK());
     }
     if (m_r_solver.get_status() == INFEASIBLE) {
         fill_not_improvable_zero_sum();
     } else if (m_r_solver.get_status() != UNBOUNDED) {
         m_r_solver.set_status(OPTIMAL);
     }
-    lean_assert(r_basis_is_OK());
-    lean_assert(m_r_solver.non_basic_columns_are_set_correctly());
-    lean_assert(m_r_solver.inf_set_is_correct());
+    SASSERT(r_basis_is_OK());
+    SASSERT(m_r_solver.non_basic_columns_are_set_correctly());
+    SASSERT(m_r_solver.inf_set_is_correct());
 }
 
 
diff --git a/src/util/lp/lar_core_solver_instances.cpp b/src/util/lp/lar_core_solver_instances.cpp
index 432d1a939..a6a4048e5 100644
--- a/src/util/lp/lar_core_solver_instances.cpp
+++ b/src/util/lp/lar_core_solver_instances.cpp
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <utility>
 #include <memory>
 #include <string>
diff --git a/src/util/lp/lar_solution_signature.h b/src/util/lp/lar_solution_signature.h
index 2c4169c81..08551a2d0 100644
--- a/src/util/lp/lar_solution_signature.h
+++ b/src/util/lp/lar_solution_signature.h
@@ -1,13 +1,28 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 #include "util/vector.h"
 #include "util/debug.h"
 #include "util/lp/lp_settings.h"
 #include <unordered_map>
-namespace lean {
+namespace lp {
 typedef std::unordered_map<unsigned, non_basic_column_value_position> lar_solution_signature;
 }
diff --git a/src/util/lp/lar_solver.h b/src/util/lp/lar_solver.h
index d4b591154..1ed30bd70 100644
--- a/src/util/lp/lar_solver.h
+++ b/src/util/lp/lar_solver.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include "util/vector.h"
 #include <utility>
@@ -30,7 +45,7 @@
 #include "util/lp/iterator_on_row.h"
 #include "util/lp/quick_xplain.h"
 #include "util/lp/conversion_helper.h"
-namespace lean {
+namespace lp {
 
 class lar_solver : public column_namer {
     //////////////////// fields //////////////////////////
@@ -75,7 +90,7 @@ public:
 
     lp_settings const & settings() const { return m_settings;}
 
-    void clear() {lean_assert(false); // not implemented
+    void clear() {SASSERT(false); // not implemented
     }
 
 
@@ -107,7 +122,7 @@ public:
     }
 
     unsigned adjust_term_index(unsigned j) const {
-        lean_assert(is_term(j));
+        SASSERT(is_term(j));
         return j - m_terms_start_index;
     }
 
@@ -115,10 +130,10 @@ public:
     bool use_lu() const { return m_settings.simplex_strategy() == simplex_strategy_enum::lu; }
 
     bool sizes_are_correct() const {
-        lean_assert(strategy_is_undecided() || !m_mpq_lar_core_solver.need_to_presolve_with_double_solver() || A_r().column_count() == A_d().column_count());
-        lean_assert(A_r().column_count() == m_mpq_lar_core_solver.m_r_solver.m_column_types.size());
-        lean_assert(A_r().column_count() == m_mpq_lar_core_solver.m_r_solver.m_costs.size());
-        lean_assert(A_r().column_count() == m_mpq_lar_core_solver.m_r_x.size());
+        SASSERT(strategy_is_undecided() || !m_mpq_lar_core_solver.need_to_presolve_with_double_solver() || A_r().column_count() == A_d().column_count());
+        SASSERT(A_r().column_count() == m_mpq_lar_core_solver.m_r_solver.m_column_types.size());
+        SASSERT(A_r().column_count() == m_mpq_lar_core_solver.m_r_solver.m_costs.size());
+        SASSERT(A_r().column_count() == m_mpq_lar_core_solver.m_r_x.size());
         return true;
     }
 
@@ -160,7 +175,7 @@ public:
             else if (kind == LE || kind == LT) n_of_L++;
             rs_of_evidence += coeff*constr.m_right_side;
         }
-        lean_assert(n_of_G == 0 || n_of_L == 0);
+        SASSERT(n_of_G == 0 || n_of_L == 0);
         lconstraint_kind kind = n_of_G ? GE : (n_of_L ? LE : EQ);
         if (strict)
             kind = static_cast<lconstraint_kind>((static_cast<int>(kind) / 2));
@@ -204,7 +219,7 @@ public:
     void analyze_new_bounds_on_row(
                                    unsigned row_index,
                                    lp_bound_propagator & bp) {
-        lean_assert(!use_tableau());
+        SASSERT(!use_tableau());
         iterator_on_pivot_row<mpq> it(m_mpq_lar_core_solver.get_pivot_row(), m_mpq_lar_core_solver.m_r_basis[row_index]);
 
         bound_analyzer_on_row ra_pos(it,
@@ -223,7 +238,7 @@ public:
         if (A_r().m_rows[row_index].size() > settings().max_row_length_for_bound_propagation)
             return;
         iterator_on_row<mpq> it(A_r().m_rows[row_index]);
-        lean_assert(use_tableau());
+        SASSERT(use_tableau());
         bound_analyzer_on_row::analyze_row(it,
                                            zero_of_type<numeric_pair<mpq>>(),
                                            row_index,
@@ -271,7 +286,7 @@ public:
       }
 
       void fill_bound_evidence_on_term(implied_bound & ie, implied_bound& be) {
-      lean_assert(false);
+      SASSERT(false);
       }
       void fill_implied_bound_on_row(implied_bound & ie, implied_bound& be) {
       iterator_on_row<mpq> it(A_r().m_rows[ie.m_row_or_term_index]);
@@ -285,7 +300,7 @@ public:
 
       if (is_neg(a)) { // so the monoid has a positive coeff on the right side
       constraint_index witness = toggle ? ul.m_low_bound_witness : ul.m_upper_bound_witness;
-      lean_assert(is_valid(witness));
+      SASSERT(is_valid(witness));
       be.m_explanation.emplace_back(a, witness);
       }
       }
@@ -304,7 +319,7 @@ public:
       }
 
       implied_bound fill_implied_bound_for_upper_bound(implied_bound& implied_evidence) {
-      lean_assert(false);
+      SASSERT(false);
 
       be.m_j = implied_evidence.m_j;
       be.m_bound = implied_evidence.m_bound.x;
@@ -312,7 +327,7 @@ public:
       for (auto t : implied_evidence.m_vector_of_bound_signatures) {
       const ul_pair & ul = m_vars_to_ul_pairs[t.m_column_index];
       constraint_index witness = t.m_low_bound ? ul.m_low_bound_witness : ul.m_upper_bound_witness;
-      lean_assert(is_valid(witness));
+      SASSERT(is_valid(witness));
       be.m_explanation.emplace_back(t.m_coeff, witness);
       }
 
@@ -338,7 +353,7 @@ public:
     //    implied_bound * get_existing_
 
     linear_combination_iterator<mpq> * create_new_iter_from_term(unsigned term_index) const {
-        lean_assert(false); // not implemented
+        SASSERT(false); // not implemented
         return nullptr;
         //        new linear_combination_iterator_on_vector<mpq>(m_terms[adjust_term_index(term_index)]->coeffs_as_vector());
     }
@@ -349,7 +364,7 @@ public:
     }
 
     void propagate_bounds_on_a_term(const lar_term& t, lp_bound_propagator & bp, unsigned term_offset) {
-        lean_assert(false); // not implemented
+        SASSERT(false); // not implemented
     }
 
 
@@ -372,15 +387,15 @@ public:
             int sign = j_sign * a_sign;
             const ul_pair & ul =  m_vars_to_ul_pairs[j];
             auto witness = sign > 0? ul.upper_bound_witness(): ul.low_bound_witness();
-            lean_assert(is_valid(witness));
+            SASSERT(is_valid(witness));
             bp.consume(a, witness);
         }
-        // lean_assert(implied_bound_is_correctly_explained(ib, explanation));
+        // SASSERT(implied_bound_is_correctly_explained(ib, explanation));
     }
 
 
     bool term_is_used_as_row(unsigned term) const {
-        lean_assert(is_term(term));
+        SASSERT(is_term(term));
         return contains(m_ext_vars_to_columns, term);
     }
 
@@ -500,12 +515,12 @@ public:
         unsigned m = A_r().row_count();
         clean_large_elements_after_pop(m, m_rows_with_changed_bounds);
         clean_inf_set_of_r_solver_after_pop();
-        lean_assert(m_settings.simplex_strategy() == simplex_strategy_enum::undecided ||
+        SASSERT(m_settings.simplex_strategy() == simplex_strategy_enum::undecided ||
             (!use_tableau()) || m_mpq_lar_core_solver.m_r_solver.reduced_costs_are_correct_tableau());
 
 
-        lean_assert(ax_is_correct());
-        lean_assert(m_mpq_lar_core_solver.m_r_solver.inf_set_is_correct());
+        SASSERT(ax_is_correct());
+        SASSERT(m_mpq_lar_core_solver.m_r_solver.inf_set_is_correct());
         m_constraint_count.pop(k);
         for (unsigned i = m_constraint_count; i < m_constraints.size(); i++)
             delete m_constraints[i];
@@ -520,8 +535,8 @@ public:
         m_orig_terms.resize(m_term_count);
         m_simplex_strategy.pop(k);
         m_settings.simplex_strategy() = m_simplex_strategy;
-        lean_assert(sizes_are_correct());
-        lean_assert((!m_settings.use_tableau()) || m_mpq_lar_core_solver.m_r_solver.reduced_costs_are_correct_tableau());
+        SASSERT(sizes_are_correct());
+        SASSERT((!m_settings.use_tableau()) || m_mpq_lar_core_solver.m_r_solver.reduced_costs_are_correct_tableau());
     }
 
     vector<constraint_index> get_all_constraint_indices() const {
@@ -550,13 +565,13 @@ public:
 
     bool costs_are_zeros_for_r_solver() const {
         for (unsigned j = 0; j < m_mpq_lar_core_solver.m_r_solver.m_costs.size(); j++) {
-            lean_assert(is_zero(m_mpq_lar_core_solver.m_r_solver.m_costs[j]));
+            SASSERT(is_zero(m_mpq_lar_core_solver.m_r_solver.m_costs[j]));
         }
         return true;
     }
     bool reduced_costs_are_zeroes_for_r_solver() const {
         for (unsigned j = 0; j < m_mpq_lar_core_solver.m_r_solver.m_d.size(); j++) {
-            lean_assert(is_zero(m_mpq_lar_core_solver.m_r_solver.m_d[j]));
+            SASSERT(is_zero(m_mpq_lar_core_solver.m_r_solver.m_d[j]));
         }
         return true;
     }
@@ -564,7 +579,7 @@ public:
     void set_costs_to_zero(const vector<std::pair<mpq, var_index>> & term) {
         auto & rslv = m_mpq_lar_core_solver.m_r_solver;
         auto & jset = m_mpq_lar_core_solver.m_r_solver.m_inf_set; // hijack this set that should be empty right now
-        lean_assert(jset.m_index.size()==0);
+        SASSERT(jset.m_index.size()==0);
 
         for (auto & p : term) {
             unsigned j = p.second;
@@ -583,16 +598,16 @@ public:
 
         jset.clear();
 
-        lean_assert(reduced_costs_are_zeroes_for_r_solver());
-        lean_assert(costs_are_zeros_for_r_solver());
+        SASSERT(reduced_costs_are_zeroes_for_r_solver());
+        SASSERT(costs_are_zeros_for_r_solver());
     }
 
     void prepare_costs_for_r_solver(const vector<std::pair<mpq, var_index>> & term) {
 
         auto & rslv = m_mpq_lar_core_solver.m_r_solver;
         rslv.m_using_infeas_costs = false;
-        lean_assert(costs_are_zeros_for_r_solver());
-        lean_assert(reduced_costs_are_zeroes_for_r_solver());
+        SASSERT(costs_are_zeros_for_r_solver());
+        SASSERT(reduced_costs_are_zeroes_for_r_solver());
         rslv.m_costs.resize(A_r().column_count(), zero_of_type<mpq>());
         for (auto & p : term) {
             unsigned j = p.second;
@@ -602,7 +617,7 @@ public:
             else
                 rslv.update_reduced_cost_for_basic_column_cost_change(- p.first, j);
         }
-        lean_assert(rslv.reduced_costs_are_correct_tableau());
+        SASSERT(rslv.reduced_costs_are_correct_tableau());
     }
 
     bool maximize_term_on_corrected_r_solver(const vector<std::pair<mpq, var_index>> & term,
@@ -629,10 +644,10 @@ public:
             }
 
         case simplex_strategy_enum::lu:
-            lean_assert(false); // not implemented
+            SASSERT(false); // not implemented
             return false;
         default:
-            lean_unreachable(); // wrong mode
+            SASSERT(false); // wrong mode
         }
         return false;
     }
@@ -640,7 +655,7 @@ public:
     // return true if found and false if unbounded
     bool maximize_term(const vector<std::pair<mpq, var_index>> & term,
                        impq &term_max) {
-        lean_assert(m_mpq_lar_core_solver.m_r_solver.current_x_is_feasible());
+        SASSERT(m_mpq_lar_core_solver.m_r_solver.current_x_is_feasible());
         m_mpq_lar_core_solver.m_r_solver.m_look_for_feasible_solution_only = false;
         return maximize_term_on_corrected_r_solver(term, term_max);
     }
@@ -648,7 +663,7 @@ public:
 
 
     const lar_term &  get_term(unsigned j) const {
-        lean_assert(j >= m_terms_start_index);
+        SASSERT(j >= m_terms_start_index);
         return *m_terms[j - m_terms_start_index];
     }
 
@@ -680,7 +695,7 @@ public:
                           vector<std::pair<mpq, var_index>> &left_side, mpq & right_side) const {
         for (auto & t : left_side_with_terms) {
             if (t.second < m_terms_start_index) {
-                lean_assert(t.second < A_r().column_count());
+                SASSERT(t.second < A_r().column_count());
                 left_side.push_back(std::pair<mpq, var_index>(mult * t.first, t.second));
             } else {
                 const lar_term & term = * m_terms[adjust_term_index(t.second)];
@@ -696,7 +711,7 @@ public:
             m_column_buffer.resize(A_r().row_count());
         else
             m_column_buffer.clear();
-        lean_assert(m_column_buffer.size() == 0 && m_column_buffer.is_OK());
+        SASSERT(m_column_buffer.size() == 0 && m_column_buffer.is_OK());
 
         m_mpq_lar_core_solver.m_r_solver.solve_Bd(j, m_column_buffer);
         for (unsigned i : m_column_buffer.m_index)
@@ -730,7 +745,7 @@ public:
     }
 
     void adjust_x_of_column(unsigned j) {
-        lean_assert(false);
+        SASSERT(false);
     }
 
     bool row_is_correct(unsigned i) const {
@@ -819,14 +834,14 @@ public:
     }
 
     void update_x_and_inf_costs_for_columns_with_changed_bounds_tableau() {
-        lean_assert(ax_is_correct());
+        SASSERT(ax_is_correct());
         for (auto j : m_columns_with_changed_bound.m_index)
             update_x_and_inf_costs_for_column_with_changed_bounds(j);
 
         if (tableau_with_costs()) {
             for (unsigned j : m_basic_columns_with_changed_cost.m_index)
                 m_mpq_lar_core_solver.m_r_solver.update_inf_cost_for_column_tableau(j);
-            lean_assert(m_mpq_lar_core_solver.m_r_solver.reduced_costs_are_correct_tableau());
+            SASSERT(m_mpq_lar_core_solver.m_r_solver.reduced_costs_are_correct_tableau());
         }
     }
 
@@ -848,7 +863,7 @@ public:
             update_x_and_inf_costs_for_columns_with_changed_bounds();
         m_mpq_lar_core_solver.solve();
         set_status(m_mpq_lar_core_solver.m_r_solver.get_status());
-        lean_assert(m_status != OPTIMAL || all_constraints_hold());
+        SASSERT(m_status != OPTIMAL || all_constraints_hold());
     }
 
 
@@ -875,7 +890,7 @@ public:
         numeric_pair<mpq> r = zero_of_type<numeric_pair<mpq>>();
         m_mpq_lar_core_solver.calculate_pivot_row(i);
         for (unsigned j : m_mpq_lar_core_solver.m_r_solver.m_pivot_row.m_index) {
-            lean_assert(m_mpq_lar_core_solver.m_r_solver.m_basis_heading[j] < 0);
+            SASSERT(m_mpq_lar_core_solver.m_r_solver.m_basis_heading[j] < 0);
             r -= m_mpq_lar_core_solver.m_r_solver.m_pivot_row.m_data[j] * m_mpq_lar_core_solver.m_r_x[j];
         }
         return r;
@@ -939,12 +954,12 @@ public:
     }
 
     void fill_last_row_of_A_r(static_matrix<mpq, numeric_pair<mpq>> & A, const lar_term * ls) {
-        lean_assert(A.row_count() > 0);
-        lean_assert(A.column_count() > 0);
+        SASSERT(A.row_count() > 0);
+        SASSERT(A.column_count() > 0);
         unsigned last_row = A.row_count() - 1;
-        lean_assert(A.m_rows[last_row].size() == 0);
+        SASSERT(A.m_rows[last_row].size() == 0);
         for (auto & t : ls->m_coeffs) {
-            lean_assert(!is_zero(t.second));
+            SASSERT(!is_zero(t.second));
             var_index j = t.first;
             A.set(last_row, j, - t.second);
         }
@@ -954,7 +969,7 @@ public:
 
     template <typename U, typename V>
     void create_matrix_A(static_matrix<U, V> & matr) {
-        lean_assert(false); // not implemented
+        SASSERT(false); // not implemented
         /*
           unsigned m = number_or_nontrivial_left_sides();
           unsigned n = m_vec_of_canonic_left_sides.size();
@@ -1016,8 +1031,8 @@ public:
           mpq rs = right_side_parm;
           vector<std::pair<mpq, var_index>> left_side;
           substitute_terms(one_of_type<mpq>(), left_side_with_terms, left_side, rs);
-          lean_assert(left_side.size() > 0);
-          lean_assert(all_constrained_variables_are_registered(left_side));
+          SASSERT(left_side.size() > 0);
+          SASSERT(all_constrained_variables_are_registered(left_side));
           lar_constraint original_constr(left_side, kind_par, rs);
           unsigned j; // j is the index of the basic variables corresponding to the left side
           canonic_left_side ls = create_or_fetch_canonic_left_side(left_side, j);
@@ -1030,7 +1045,7 @@ public:
           update_column_type_and_bound(j, kind, rs, constr_ind);
           return constr_ind;
         */
-        lean_assert(false); // not implemented
+        SASSERT(false); // not implemented
         return 0;
     }
 
@@ -1058,7 +1073,7 @@ public:
         case GT: return left_side_val > constr.m_right_side;
         case EQ: return left_side_val == constr.m_right_side;
         default:
-            lean_unreachable();
+            SASSERT(false);
         }
         return false; // it is unreachable
     }
@@ -1108,7 +1123,7 @@ public:
         for (auto & it : evidence) {
             mpq coeff = it.first;
             constraint_index con_ind = it.second;
-            lean_assert(con_ind < m_constraints.size());
+            SASSERT(con_ind < m_constraints.size());
             register_in_map(coeff_map, *m_constraints[con_ind], coeff);
         }
 
@@ -1131,7 +1146,7 @@ public:
         for (auto & it : evidence) {
             mpq coeff = it.first;
             constraint_index con_ind = it.second;
-            lean_assert(con_ind < m_constraints.size());
+            SASSERT(con_ind < m_constraints.size());
             const lar_constraint & constr = *m_constraints[con_ind];
             ret += constr.m_right_side * coeff;
         }
@@ -1139,24 +1154,24 @@ public:
     }
 
     bool explanation_is_correct(const vector<std::pair<mpq, unsigned>>& explanation) const {
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
         lconstraint_kind kind;
-        lean_assert(the_relations_are_of_same_type(explanation, kind));
-        lean_assert(the_left_sides_sum_to_zero(explanation));
+        SASSERT(the_relations_are_of_same_type(explanation, kind));
+        SASSERT(the_left_sides_sum_to_zero(explanation));
         mpq rs = sum_of_right_sides_of_explanation(explanation);
         switch (kind) {
-        case LE: lean_assert(rs < zero_of_type<mpq>());
+        case LE: SASSERT(rs < zero_of_type<mpq>());
             break;
-        case LT: lean_assert(rs <= zero_of_type<mpq>());
+        case LT: SASSERT(rs <= zero_of_type<mpq>());
             break;
-        case GE: lean_assert(rs > zero_of_type<mpq>());
+        case GE: SASSERT(rs > zero_of_type<mpq>());
             break;
-        case GT: lean_assert(rs >= zero_of_type<mpq>());
+        case GT: SASSERT(rs >= zero_of_type<mpq>());
             break;
-        case EQ: lean_assert(rs != zero_of_type<mpq>());
+        case EQ: SASSERT(rs != zero_of_type<mpq>());
             break;
         default:
-            lean_assert(false);
+            SASSERT(false);
             return false;
         }
 #endif
@@ -1164,7 +1179,7 @@ public:
     }
 
     bool inf_explanation_is_correct() const {
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
         vector<std::pair<mpq, unsigned>> explanation;
         get_infeasibility_explanation(explanation);
         return explanation_is_correct(explanation);
@@ -1177,7 +1192,7 @@ public:
         for (auto & it : explanation) {
             mpq coeff = it.first;
             constraint_index con_ind = it.second;
-            lean_assert(con_ind < m_constraints.size());
+            SASSERT(con_ind < m_constraints.size());
             ret += (m_constraints[con_ind]->m_right_side - m_constraints[con_ind]->get_free_coeff_of_left_side()) * coeff;
         }
         return ret;
@@ -1235,7 +1250,7 @@ public:
         int inf_sign;
         auto inf_row = m_mpq_lar_core_solver.get_infeasibility_info(inf_sign);
         get_infeasibility_explanation_for_inf_sign(explanation, inf_row, inf_sign);
-        lean_assert(explanation_is_correct(explanation));
+        SASSERT(explanation_is_correct(explanation));
     }
 
     void get_infeasibility_explanation_for_inf_sign(
@@ -1251,7 +1266,7 @@ public:
             const ul_pair & ul = m_vars_to_ul_pairs[j];
 
             constraint_index bound_constr_i = adj_sign < 0 ? ul.upper_bound_witness() : ul.low_bound_witness();
-            lean_assert(bound_constr_i < m_constraints.size());
+            SASSERT(bound_constr_i < m_constraints.size());
             explanation.push_back(std::make_pair(coeff, bound_constr_i));
         }
     }
@@ -1260,7 +1275,7 @@ public:
 
     void get_model(std::unordered_map<var_index, mpq> & variable_values) const {
         mpq delta = m_mpq_lar_core_solver.find_delta_for_strict_bounds(mpq(1, 2)); // start from 0.5 to have less clashes
-        lean_assert(m_status == OPTIMAL);
+        SASSERT(m_status == OPTIMAL);
         unsigned i;
         do {
 
@@ -1332,7 +1347,7 @@ public:
         for (auto & it : cns.get_left_side_coefficients()) {
             var_index j = it.second;
             auto vi = var_map.find(j);
-            lean_assert(vi != var_map.end());
+            SASSERT(vi != var_map.end());
             ret += it.first * vi->second;
         }
         return ret;
@@ -1379,7 +1394,7 @@ public:
 
     void make_sure_that_the_bottom_right_elem_not_zero_in_tableau(unsigned i, unsigned j) {
         // i, j - is the indices of the bottom-right element of the tableau
-        lean_assert(A_r().row_count() == i + 1 && A_r().column_count() == j + 1);
+        SASSERT(A_r().row_count() == i + 1 && A_r().column_count() == j + 1);
         auto & last_column = A_r().m_columns[j];
         int non_zero_column_cell_index = -1;
         for (unsigned k = last_column.size(); k-- > 0;){
@@ -1389,13 +1404,13 @@ public:
             non_zero_column_cell_index = k;
         }
 
-        lean_assert(non_zero_column_cell_index != -1);
-        lean_assert(static_cast<unsigned>(non_zero_column_cell_index) != i);
+        SASSERT(non_zero_column_cell_index != -1);
+        SASSERT(static_cast<unsigned>(non_zero_column_cell_index) != i);
         m_mpq_lar_core_solver.m_r_solver.transpose_rows_tableau(last_column[non_zero_column_cell_index].m_i, i);
     }
 
     void remove_last_row_and_column_from_tableau(unsigned j) {
-        lean_assert(A_r().column_count() == m_mpq_lar_core_solver.m_r_solver.m_costs.size());
+        SASSERT(A_r().column_count() == m_mpq_lar_core_solver.m_r_solver.m_costs.size());
         auto & slv = m_mpq_lar_core_solver.m_r_solver;
         unsigned i = A_r().row_count() - 1; //last row index
         make_sure_that_the_bottom_right_elem_not_zero_in_tableau(i, j);
@@ -1414,17 +1429,17 @@ public:
 
             A_r().remove_element(last_row, rc);
         }
-        lean_assert(last_row.size() == 0);
-        lean_assert(A_r().m_columns[j].size() == 0);
+        SASSERT(last_row.size() == 0);
+        SASSERT(A_r().m_columns[j].size() == 0);
         A_r().m_rows.pop_back();
         A_r().m_columns.pop_back();
         slv.m_b.pop_back();
     }
 
     void remove_last_column_from_tableau(unsigned j) {
-        lean_assert(j == A_r().column_count() - 1);
+        SASSERT(j == A_r().column_count() - 1);
         // the last column has to be empty
-        lean_assert(A_r().m_columns[j].size() == 0);
+        SASSERT(A_r().m_columns[j].size() == 0);
         A_r().m_columns.pop_back();
     }
 
@@ -1433,7 +1448,7 @@ public:
         int i = rslv.m_basis_heading[j];
         if (i >= 0) { // j is a basic var
             int last_pos = static_cast<int>(rslv.m_basis.size()) - 1;
-            lean_assert(last_pos >= 0);
+            SASSERT(last_pos >= 0);
             if (i != last_pos) {
                 unsigned j_at_last_pos = rslv.m_basis[last_pos];
                 rslv.m_basis[i] = j_at_last_pos;
@@ -1442,7 +1457,7 @@ public:
             rslv.m_basis.pop_back(); // remove j from the basis
         } else {
             int last_pos = static_cast<int>(rslv.m_nbasis.size()) - 1;
-            lean_assert(last_pos >= 0);
+            SASSERT(last_pos >= 0);
             i = - 1 - i;
             if (i != last_pos) {
                 unsigned j_at_last_pos = rslv.m_nbasis[last_pos];
@@ -1452,14 +1467,14 @@ public:
             rslv.m_nbasis.pop_back(); // remove j from the basis
         }
         rslv.m_basis_heading.pop_back();
-        lean_assert(rslv.m_basis.size() == A_r().row_count());
-        lean_assert(rslv.basis_heading_is_correct());
+        SASSERT(rslv.m_basis.size() == A_r().row_count());
+        SASSERT(rslv.basis_heading_is_correct());
     }
 
     void remove_column_from_tableau(unsigned j) {
         auto& rslv = m_mpq_lar_core_solver.m_r_solver;
-        lean_assert(j == A_r().column_count() - 1);
-        lean_assert(A_r().column_count() == m_mpq_lar_core_solver.m_r_solver.m_costs.size());
+        SASSERT(j == A_r().column_count() - 1);
+        SASSERT(A_r().column_count() == m_mpq_lar_core_solver.m_r_solver.m_costs.size());
         if (column_represents_row_in_tableau(j)) {
             remove_last_row_and_column_from_tableau(j);
             if (rslv.m_basis_heading[j] < 0)
@@ -1473,23 +1488,23 @@ public:
         rslv.m_costs.pop_back();
 
         remove_last_column_from_basis_tableau(j);
-        lean_assert(m_mpq_lar_core_solver.r_basis_is_OK());
-        lean_assert(A_r().column_count() == m_mpq_lar_core_solver.m_r_solver.m_costs.size());
+        SASSERT(m_mpq_lar_core_solver.r_basis_is_OK());
+        SASSERT(A_r().column_count() == m_mpq_lar_core_solver.m_r_solver.m_costs.size());
     }
 
 
     void pop_tableau() {
-        lean_assert(m_mpq_lar_core_solver.m_r_solver.m_costs.size() == A_r().column_count());
+        SASSERT(m_mpq_lar_core_solver.m_r_solver.m_costs.size() == A_r().column_count());
 
-        lean_assert(m_mpq_lar_core_solver.m_r_solver.m_basis.size() == A_r().row_count());
-        lean_assert(m_mpq_lar_core_solver.m_r_solver.basis_heading_is_correct());
+        SASSERT(m_mpq_lar_core_solver.m_r_solver.m_basis.size() == A_r().row_count());
+        SASSERT(m_mpq_lar_core_solver.m_r_solver.basis_heading_is_correct());
         // We remove last variables starting from m_column_names.size() to m_vec_of_canonic_left_sides.size().
         // At this moment m_column_names is already popped
         for (unsigned j = A_r().column_count(); j-- > m_columns_to_ext_vars_or_term_indices.size();)
             remove_column_from_tableau(j);
-        lean_assert(m_mpq_lar_core_solver.m_r_solver.m_costs.size() == A_r().column_count());
-        lean_assert(m_mpq_lar_core_solver.m_r_solver.m_basis.size() == A_r().row_count());
-        lean_assert(m_mpq_lar_core_solver.m_r_solver.basis_heading_is_correct());
+        SASSERT(m_mpq_lar_core_solver.m_r_solver.m_costs.size() == A_r().column_count());
+        SASSERT(m_mpq_lar_core_solver.m_r_solver.m_basis.size() == A_r().row_count());
+        SASSERT(m_mpq_lar_core_solver.m_r_solver.basis_heading_is_correct());
     }
 
 
@@ -1512,14 +1527,14 @@ public:
         }
 
         for (unsigned j : became_feas) {
-            lean_assert(m_mpq_lar_core_solver.m_r_solver.m_basis_heading[j] < 0);
+            SASSERT(m_mpq_lar_core_solver.m_r_solver.m_basis_heading[j] < 0);
             m_mpq_lar_core_solver.m_r_solver.m_d[j] -= m_mpq_lar_core_solver.m_r_solver.m_costs[j];
             m_mpq_lar_core_solver.m_r_solver.m_costs[j] = zero_of_type<mpq>();
             m_mpq_lar_core_solver.m_r_solver.m_inf_set.erase(j);
         }
         became_feas.clear();
         for (unsigned j : m_mpq_lar_core_solver.m_r_solver.m_inf_set.m_index) {
-            lean_assert(m_mpq_lar_core_solver.m_r_heading[j] >= 0);
+            SASSERT(m_mpq_lar_core_solver.m_r_heading[j] >= 0);
             if (m_mpq_lar_core_solver.m_r_solver.column_is_feasible(j))
                 became_feas.push_back(j);
         }
@@ -1532,7 +1547,7 @@ public:
                 m_mpq_lar_core_solver.m_r_solver.update_inf_cost_for_column_tableau(j);
             for (unsigned j : basic_columns_with_changed_cost)
                 m_mpq_lar_core_solver.m_r_solver.update_inf_cost_for_column_tableau(j);
-            lean_assert(m_mpq_lar_core_solver.m_r_solver.reduced_costs_are_correct_tableau());
+            SASSERT(m_mpq_lar_core_solver.m_r_solver.reduced_costs_are_correct_tableau());
         }
     }
 
@@ -1540,7 +1555,7 @@ public:
     void shrink_explanation_to_minimum(vector<std::pair<mpq, constraint_index>> & explanation) const {
         // implementing quickXplain
         quick_xplain::run(explanation, *this);
-        lean_assert(this->explanation_is_correct(explanation));
+        SASSERT(this->explanation_is_correct(explanation));
     }
 };
 }
diff --git a/src/util/lp/lar_term.h b/src/util/lp/lar_term.h
index 0e715ad0b..16b5a938d 100644
--- a/src/util/lp/lar_term.h
+++ b/src/util/lp/lar_term.h
@@ -1,10 +1,25 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include "util/lp/indexed_vector.h"
-namespace lean {
+namespace lp {
 struct lar_term {
     // the term evaluates to sum of m_coeffs + m_v
     std::unordered_map<unsigned, mpq> m_coeffs;
diff --git a/src/util/lp/linear_combination_iterator.h b/src/util/lp/linear_combination_iterator.h
index 634accfd4..417bdcf82 100644
--- a/src/util/lp/linear_combination_iterator.h
+++ b/src/util/lp/linear_combination_iterator.h
@@ -1,9 +1,24 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
-namespace lean {
+namespace lp {
 template <typename T>
 struct linear_combination_iterator {
     virtual bool next(T & a, unsigned & i) = 0;
diff --git a/src/util/lp/lp_bound_propagator.cpp b/src/util/lp/lp_bound_propagator.cpp
index 506ba138b..53218fced 100644
--- a/src/util/lp/lp_bound_propagator.cpp
+++ b/src/util/lp/lp_bound_propagator.cpp
@@ -1,9 +1,24 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include "util/lp/lar_solver.h"
-namespace lean {
+namespace lp {
     lp_bound_propagator::lp_bound_propagator(lar_solver & ls):
     m_lar_solver(ls) {}
 column_type lp_bound_propagator::get_column_type(unsigned j) const {
diff --git a/src/util/lp/lp_bound_propagator.h b/src/util/lp/lp_bound_propagator.h
index f1e0d486e..76870f457 100644
--- a/src/util/lp/lp_bound_propagator.h
+++ b/src/util/lp/lp_bound_propagator.h
@@ -1,10 +1,25 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include "util/lp/lp_settings.h"
-namespace lean {
+namespace lp {
 class lar_solver;
 class lp_bound_propagator {
     std::unordered_map<unsigned, unsigned> m_improved_low_bounds; // these maps map a column index to the corresponding index in ibounds
@@ -19,7 +34,7 @@ public:
     const impq & get_upper_bound(unsigned) const;
     void try_add_bound(const mpq & v, unsigned j, bool is_low, bool coeff_before_j_is_pos, unsigned row_or_term_index, bool strict);
     virtual bool bound_is_interesting(unsigned vi,
-                                      lean::lconstraint_kind kind,
+                                      lp::lconstraint_kind kind,
                                       const rational & bval) {return true;}
     unsigned number_of_found_bounds() const { return m_ibounds.size(); }
     virtual void consume(mpq const& v, unsigned j) { std::cout << "doh\n"; }
diff --git a/src/util/lp/lp_core_solver_base.h b/src/util/lp/lp_core_solver_base.h
index a12b7b5d2..fd115669c 100644
--- a/src/util/lp/lp_core_solver_base.h
+++ b/src/util/lp/lp_core_solver_base.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include <set>
 #include "util/vector.h"
@@ -13,7 +28,7 @@
 #include "util/lp/lu.h"
 #include "util/lp/permutation_matrix.h"
 #include "util/lp/column_namer.h"
-namespace lean {
+namespace lp {
 
 template <typename T, typename X> // X represents the type of the x variable and the bounds
 class lp_core_solver_base {    
@@ -182,11 +197,11 @@ public:
 
 
     bool need_to_pivot_to_basis_tableau() const {
-        lean_assert(m_A.is_correct());
+        SASSERT(m_A.is_correct());
         unsigned m = m_A.row_count();
         for (unsigned i = 0; i < m; i++) {
             unsigned bj = m_basis[i];
-            lean_assert(m_A.m_columns[bj].size() > 0);
+            SASSERT(m_A.m_columns[bj].size() > 0);
             if (m_A.m_columns[bj].size() > 1 || m_A.get_val(m_A.m_columns[bj][0]) != one_of_type<mpq>()) return true;
         }
         return false;
@@ -195,7 +210,7 @@ public:
     bool reduced_costs_are_correct_tableau() const {
         if (m_settings.simplex_strategy() == simplex_strategy_enum::tableau_rows)
             return true;
-        lean_assert(m_A.is_correct());
+        SASSERT(m_A.is_correct());
         if (m_using_infeas_costs) {
             if (infeasibility_costs_are_correct() == false) {
                 std::cout << "infeasibility_costs_are_correct() does not hold" << std::endl;
@@ -370,11 +385,11 @@ public:
     }
 
     bool make_column_feasible(unsigned j, numeric_pair<mpq> & delta) {
-        lean_assert(m_basis_heading[j] < 0);
+        SASSERT(m_basis_heading[j] < 0);
         auto & x = m_x[j];
         switch (m_column_types[j]) {
         case column_type::fixed:
-            lean_assert(m_low_bounds[j] == m_upper_bounds[j]);
+            SASSERT(m_low_bounds[j] == m_upper_bounds[j]);
             if (x != m_low_bounds[j]) {
                 delta = m_low_bounds[j] - x;
                 x = m_low_bounds[j];
@@ -410,7 +425,7 @@ public:
         case column_type::free_column:
             break;
         default:
-            lean_assert(false);
+            SASSERT(false);
             break;
         }
         return false;
@@ -458,7 +473,7 @@ public:
     }
 
     void change_basis_unconditionally(unsigned entering, unsigned leaving) {
-        lean_assert(m_basis_heading[entering] < 0);
+        SASSERT(m_basis_heading[entering] < 0);
         int place_in_non_basis = -1 - m_basis_heading[entering];
         if (static_cast<unsigned>(place_in_non_basis) >= m_nbasis.size()) {
               // entering variable in not in m_nbasis, we need to put it back;
@@ -477,7 +492,7 @@ public:
     }
     
     void change_basis(unsigned entering, unsigned leaving) {
-        lean_assert(m_basis_heading[entering] < 0);
+        SASSERT(m_basis_heading[entering] < 0);
         
         int place_in_basis =  m_basis_heading[leaving];
         int place_in_non_basis = - m_basis_heading[entering] - 1;
@@ -518,7 +533,7 @@ public:
         case column_type::free_column:
             break;
         default:
-            lean_assert(false);
+            SASSERT(false);
             break;
         }
         return true;
@@ -566,7 +581,7 @@ public:
         case column_type::free_column:
             break;
         default:
-            lean_assert(false);
+            SASSERT(false);
         }
         std::cout << "basis heading = " << m_basis_heading[j] << std::endl;
         std::cout << "x = " << m_x[j] << std::endl;
@@ -665,17 +680,17 @@ public:
     }
     void insert_column_into_inf_set(unsigned j) {
         m_inf_set.insert(j);
-        lean_assert(!column_is_feasible(j));
+        SASSERT(!column_is_feasible(j));
     }
     void remove_column_from_inf_set(unsigned j) {
         m_inf_set.erase(j);
-        lean_assert(column_is_feasible(j));
+        SASSERT(column_is_feasible(j));
     }
     bool costs_on_nbasis_are_zeros() const {
-        lean_assert(this->basis_heading_is_correct());
+        SASSERT(this->basis_heading_is_correct());
         for (unsigned j = 0; j < this->m_n(); j++) {
             if (this->m_basis_heading[j] < 0)
-                lean_assert(is_zero(this->m_costs[j]));
+                SASSERT(is_zero(this->m_costs[j]));
         }
         return true;
     }
diff --git a/src/util/lp/lp_core_solver_base.hpp b/src/util/lp/lp_core_solver_base.hpp
index a0dba9de7..fa1c95850 100644
--- a/src/util/lp/lp_core_solver_base.hpp
+++ b/src/util/lp/lp_core_solver_base.hpp
@@ -1,13 +1,28 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <set>
 #include <string>
 #include "util/vector.h"
 #include "util/lp/lp_utils.h"
 #include "util/lp/lp_core_solver_base.h"
-namespace lean {
+namespace lp {
 
 template <typename T, typename X> lp_core_solver_base<T, X>::
 lp_core_solver_base(static_matrix<T, X> & A,
@@ -53,7 +68,7 @@ lp_core_solver_base(static_matrix<T, X> & A,
     m_tracing_basis_changes(false),
     m_pivoted_rows(nullptr),
     m_look_for_feasible_solution_only(false) {
-    lean_assert(bounds_for_boxed_are_set_correctly());    
+    SASSERT(bounds_for_boxed_are_set_correctly());    
     init();
     init_basis_heading_and_non_basic_columns_vector();
 }
@@ -61,7 +76,7 @@ lp_core_solver_base(static_matrix<T, X> & A,
 template <typename T, typename X> void lp_core_solver_base<T, X>::
 allocate_basis_heading() { // the rest of initilization will be handled by the factorization class
     init_basis_heading_and_non_basic_columns_vector();
-    lean_assert(basis_heading_is_correct());
+    SASSERT(basis_heading_is_correct());
 }
 template <typename T, typename X> void lp_core_solver_base<T, X>::
 init() {    
@@ -127,7 +142,7 @@ solve_yB(vector<T> & y) {
 //     }
 // }
 template <typename T, typename X> void lp_core_solver_base<T, X>::solve_Bd(unsigned entering, indexed_vector<T> & column) {
-    lean_assert(!m_settings.use_tableau());
+    SASSERT(!m_settings.use_tableau());
     if (m_factorization == nullptr) {
         init_factorization(m_factorization, m_A, m_basis, m_settings);
     }
@@ -137,19 +152,19 @@ template <typename T, typename X> void lp_core_solver_base<T, X>::solve_Bd(unsig
 
 template <typename T, typename X> void lp_core_solver_base<T, X>::
 solve_Bd(unsigned entering) {
-    lean_assert(m_ed.is_OK());
+    SASSERT(m_ed.is_OK());
     m_factorization->solve_Bd(entering, m_ed, m_w);
     if (this->precise())
         m_columns_nz[entering] = m_ed.m_index.size();
-    lean_assert(m_ed.is_OK());
-    lean_assert(m_w.is_OK());
-#ifdef LEAN_DEBUG
+    SASSERT(m_ed.is_OK());
+    SASSERT(m_w.is_OK());
+#ifdef Z3DEBUG
     // auto B = get_B(*m_factorization, m_basis);
     // vector<T>  a(m_m());
     // m_A.copy_column_to_vector(entering, a);
     // vector<T> cd(m_ed.m_data);
     // B.apply_from_left(cd, m_settings);
-    // lean_assert(vectors_are_equal(cd , a));
+    // SASSERT(vectors_are_equal(cd , a));
 #endif
 }
 
@@ -208,7 +223,7 @@ restore_m_ed(T * buffer) {
 
 template <typename T, typename X> bool lp_core_solver_base<T, X>::
 A_mult_x_is_off() const {
-    lean_assert(m_x.size() == m_A.column_count());
+    SASSERT(m_x.size() == m_A.column_count());
     if (numeric_traits<T>::precise()) {
         for (unsigned i = 0; i < m_m(); i++) {
             X delta = m_b[i] - m_A.dot_product_with_row(i, m_x);
@@ -244,7 +259,7 @@ A_mult_x_is_off() const {
 }
 template <typename T, typename X> bool lp_core_solver_base<T, X>::
 A_mult_x_is_off_on_index(const vector<unsigned> & index) const {
-    lean_assert(m_x.size() == m_A.column_count());
+    SASSERT(m_x.size() == m_A.column_count());
     if (numeric_traits<T>::precise()) return false;
 #if RUN_A_MULT_X_IS_OFF_FOR_PRECESE
     for (unsigned i : index) {
@@ -284,13 +299,13 @@ A_mult_x_is_off_on_index(const vector<unsigned> & index) const {
 // from page 182 of Istvan Maros's book
 template <typename T, typename X> void lp_core_solver_base<T, X>::
 calculate_pivot_row_of_B_1(unsigned pivot_row) {
-    lean_assert(! use_tableau());
-    lean_assert(m_pivot_row_of_B_1.is_OK());
+    SASSERT(! use_tableau());
+    SASSERT(m_pivot_row_of_B_1.is_OK());
     m_pivot_row_of_B_1.clear();
     m_pivot_row_of_B_1.set_value(numeric_traits<T>::one(), pivot_row);
-    lean_assert(m_pivot_row_of_B_1.is_OK());
+    SASSERT(m_pivot_row_of_B_1.is_OK());
     m_factorization->solve_yB_with_error_check_indexed(m_pivot_row_of_B_1, m_basis_heading, m_basis, m_settings);
-    lean_assert(m_pivot_row_of_B_1.is_OK());
+    SASSERT(m_pivot_row_of_B_1.is_OK());
 }
 
 
@@ -380,11 +395,11 @@ set_non_basic_x_to_correct_bounds() {
             break;
         case column_type::low_bound:
             m_x[j] = m_low_bounds[j];
-            lean_assert(column_is_dual_feasible(j));
+            SASSERT(column_is_dual_feasible(j));
             break;
         case column_type::upper_bound:
             m_x[j] = m_upper_bounds[j];
-            lean_assert(column_is_dual_feasible(j));
+            SASSERT(column_is_dual_feasible(j));
             break;
         default:
             break;
@@ -402,15 +417,15 @@ column_is_dual_feasible(unsigned j) const {
         return x_is_at_low_bound(j) && d_is_not_negative(j);
     case column_type::upper_bound:
         LP_OUT(m_settings,  "upper_bound type should be switched to low_bound" << std::endl);
-        lean_assert(false); // impossible case
+        SASSERT(false); // impossible case
     case column_type::free_column:
         return numeric_traits<X>::is_zero(m_d[j]);
     default:
         LP_OUT(m_settings,  "column = " << j << std::endl);
         LP_OUT(m_settings,  "unexpected column type = " << column_type_to_string(m_column_types[j]) << std::endl);
-        lean_unreachable();
+        SASSERT(false);
     }
-    lean_unreachable();
+    SASSERT(false);
     return false;
 }
 template <typename T, typename X> bool lp_core_solver_base<T, X>::
@@ -493,7 +508,7 @@ template <typename T, typename X> bool lp_core_solver_base<T, X>::column_is_feas
         return true;
         break;
     default:
-        lean_unreachable();
+        SASSERT(false);
     }
     return false; // it is unreachable
 }
@@ -575,7 +590,7 @@ update_basis_and_x(int entering, int leaving, X const & tt) {
         restore_x_and_refactor(entering, leaving, tt);
         if (m_status == FLOATING_POINT_ERROR)
             return false;
-        lean_assert(!A_mult_x_is_off());
+        SASSERT(!A_mult_x_is_off());
         m_iters_with_no_cost_growing++;
         //        LP_OUT(m_settings, "rolled back after failing of init_factorization()" << std::endl);
         m_status = UNSTABLE;
@@ -587,7 +602,7 @@ update_basis_and_x(int entering, int leaving, X const & tt) {
 
 template <typename T, typename X> bool lp_core_solver_base<T, X>::
 divide_row_by_pivot(unsigned pivot_row, unsigned pivot_col) {
-    lean_assert(numeric_traits<T>::precise());
+    SASSERT(numeric_traits<T>::precise());
     int pivot_index = -1;
     auto & row = m_A.m_rows[pivot_row];
     unsigned size = row.size();
@@ -628,7 +643,7 @@ pivot_column_tableau(unsigned j, unsigned piv_row_index) {
         return false;
         
     if (pivot_col_cell_index != 0) {
-        lean_assert(column.size() > 1);
+        SASSERT(column.size() > 1);
         // swap the pivot column cell with the head cell
         auto c = column[0];
         column[0]  = column[pivot_col_cell_index];
@@ -639,7 +654,7 @@ pivot_column_tableau(unsigned j, unsigned piv_row_index) {
     }
     while (column.size() > 1) {
         auto & c = column.back();
-        lean_assert(c.m_i != piv_row_index);
+        SASSERT(c.m_i != piv_row_index);
         if(! m_A.pivot_row_to_row_given_cell(piv_row_index, c, j)) {
             return false;
         }
@@ -687,7 +702,7 @@ non_basis_is_correctly_represented_in_heading() const {
     }
     for (unsigned j = 0; j < m_A.column_count(); j++) {
         if (m_basis_heading[j] >= 0) {
-            lean_assert(static_cast<unsigned>(m_basis_heading[j]) < m_A.row_count() && m_basis[m_basis_heading[j]] == j);
+            SASSERT(static_cast<unsigned>(m_basis_heading[j]) < m_A.row_count() && m_basis[m_basis_heading[j]] == j);
         }
     }
     return true;
@@ -695,9 +710,9 @@ non_basis_is_correctly_represented_in_heading() const {
 
 template <typename T, typename X> bool lp_core_solver_base<T, X>::
     basis_heading_is_correct() const {
-    lean_assert(m_basis_heading.size() == m_A.column_count());
-    lean_assert(m_basis.size() == m_A.row_count());
-    lean_assert(m_nbasis.size() <= m_A.column_count() - m_A.row_count()); // for the dual the size of non basis can be smaller
+    SASSERT(m_basis_heading.size() == m_A.column_count());
+    SASSERT(m_basis.size() == m_A.row_count());
+    SASSERT(m_nbasis.size() <= m_A.column_count() - m_A.row_count()); // for the dual the size of non basis can be smaller
     if (!basis_has_no_doubles()) {
         //        std::cout << "basis_has_no_doubles" << std::endl;
         return false;
@@ -841,7 +856,7 @@ solve_Ax_eq_b() {
 template <typename T, typename X> void lp_core_solver_base<T, X>::
 snap_non_basic_x_to_bound_and_free_to_zeroes() {
     for (unsigned j : non_basis()) {
-        lean_assert(j < m_x.size());
+        SASSERT(j < m_x.size());
         switch (m_column_types[j]) {
         case column_type::fixed:
         case column_type::boxed:
@@ -892,9 +907,9 @@ get_non_basic_column_value_position(unsigned j) const {
     case column_type::upper_bound:
         return x_is_at_upper_bound(j)? at_upper_bound : not_at_bound;
     default:
-        lean_unreachable();
+        SASSERT(false);
     }
-    lean_unreachable();
+    SASSERT(false);
     return at_low_bound;
 }
 
@@ -958,7 +973,7 @@ template <typename T, typename X>  void lp_core_solver_base<T, X>::pivot_fixed_v
                 break;
             }
         }
-        lean_assert(m_factorization->get_status()== LU_status::OK);
+        SASSERT(m_factorization->get_status()== LU_status::OK);
     }
 }
 
@@ -966,7 +981,7 @@ template <typename T, typename X> bool
 lp_core_solver_base<T, X>::infeasibility_costs_are_correct() const {
     if (! this->m_using_infeas_costs)
         return true;
-    lean_assert(costs_on_nbasis_are_zeros());
+    SASSERT(costs_on_nbasis_are_zeros());
     for (unsigned j :this->m_basis) {
         if (!infeasibility_cost_is_correct_for_column(j)) {
             std::cout << "infeasibility_cost_is_correct_for_column does not hold\n";
@@ -1011,7 +1026,7 @@ lp_core_solver_base<T, X>::infeasibility_cost_is_correct_for_column(unsigned j)
     case column_type::free_column:
         return is_zero(this->m_costs[j]);
     default:
-        lean_assert(false);
+        SASSERT(false);
         return true;
     }
 }
diff --git a/src/util/lp/lp_core_solver_base_instances.cpp b/src/util/lp/lp_core_solver_base_instances.cpp
index 17dcb87db..f5853eecf 100644
--- a/src/util/lp/lp_core_solver_base_instances.cpp
+++ b/src/util/lp/lp_core_solver_base_instances.cpp
@@ -1,131 +1,146 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <utility>
 #include <memory>
 #include <string>
 #include "util/vector.h"
 #include <functional>
 #include "util/lp/lp_core_solver_base.hpp"
-template bool lean::lp_core_solver_base<double, double>::A_mult_x_is_off() const;
-template bool lean::lp_core_solver_base<double, double>::A_mult_x_is_off_on_index(const vector<unsigned> &) const;
-template bool lean::lp_core_solver_base<double, double>::basis_heading_is_correct() const;
-template void lean::lp_core_solver_base<double, double>::calculate_pivot_row_of_B_1(unsigned int);
-template void lean::lp_core_solver_base<double, double>::calculate_pivot_row_when_pivot_row_of_B1_is_ready(unsigned);
-template bool lean::lp_core_solver_base<double, double>::column_is_dual_feasible(unsigned int) const;
-template void lean::lp_core_solver_base<double, double>::fill_reduced_costs_from_m_y_by_rows();
-template bool lean::lp_core_solver_base<double, double>::find_x_by_solving();
-template lean::non_basic_column_value_position lean::lp_core_solver_base<double, double>::get_non_basic_column_value_position(unsigned int) const;
-template lean::non_basic_column_value_position lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::get_non_basic_column_value_position(unsigned int) const;
-template lean::non_basic_column_value_position lean::lp_core_solver_base<lean::mpq, lean::mpq>::get_non_basic_column_value_position(unsigned int) const;
-template void lean::lp_core_solver_base<double, double>::init_reduced_costs_for_one_iteration();
-template lean::lp_core_solver_base<double, double>::lp_core_solver_base(
-    lean::static_matrix<double, double>&, vector<double>&, 
+template bool lp::lp_core_solver_base<double, double>::A_mult_x_is_off() const;
+template bool lp::lp_core_solver_base<double, double>::A_mult_x_is_off_on_index(const vector<unsigned> &) const;
+template bool lp::lp_core_solver_base<double, double>::basis_heading_is_correct() const;
+template void lp::lp_core_solver_base<double, double>::calculate_pivot_row_of_B_1(unsigned int);
+template void lp::lp_core_solver_base<double, double>::calculate_pivot_row_when_pivot_row_of_B1_is_ready(unsigned);
+template bool lp::lp_core_solver_base<double, double>::column_is_dual_feasible(unsigned int) const;
+template void lp::lp_core_solver_base<double, double>::fill_reduced_costs_from_m_y_by_rows();
+template bool lp::lp_core_solver_base<double, double>::find_x_by_solving();
+template lp::non_basic_column_value_position lp::lp_core_solver_base<double, double>::get_non_basic_column_value_position(unsigned int) const;
+template lp::non_basic_column_value_position lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::get_non_basic_column_value_position(unsigned int) const;
+template lp::non_basic_column_value_position lp::lp_core_solver_base<lp::mpq, lp::mpq>::get_non_basic_column_value_position(unsigned int) const;
+template void lp::lp_core_solver_base<double, double>::init_reduced_costs_for_one_iteration();
+template lp::lp_core_solver_base<double, double>::lp_core_solver_base(
+    lp::static_matrix<double, double>&, vector<double>&, 
     vector<unsigned int >&,
     vector<unsigned> &, vector<int> &,
     vector<double >&, 
     vector<double >&, 
-    lean::lp_settings&, const column_namer&, const vector<lean::column_type >&,
+    lp::lp_settings&, const column_namer&, const vector<lp::column_type >&,
     const vector<double >&,
     const vector<double >&);
 
-template bool lean::lp_core_solver_base<double, double>::print_statistics_with_iterations_and_nonzeroes_and_cost_and_check_that_the_time_is_over(char const*, std::ostream &);
-template bool lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::print_statistics_with_iterations_and_nonzeroes_and_cost_and_check_that_the_time_is_over(char const*, std::ostream &);
-template void lean::lp_core_solver_base<double, double>::restore_x(unsigned int, double const&);
-template void lean::lp_core_solver_base<double, double>::set_non_basic_x_to_correct_bounds();
-template void lean::lp_core_solver_base<double, double>::snap_xN_to_bounds_and_free_columns_to_zeroes();
-template void lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::snap_xN_to_bounds_and_free_columns_to_zeroes();
-template void lean::lp_core_solver_base<double, double>::solve_Ax_eq_b();
-template void lean::lp_core_solver_base<double, double>::solve_Bd(unsigned int);
-template void lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq>>::solve_Bd(unsigned int, indexed_vector<lean::mpq>&);
-template void lean::lp_core_solver_base<double, double>::solve_yB(vector<double >&);
-template bool lean::lp_core_solver_base<double, double>::update_basis_and_x(int, int, double const&);
-template void lean::lp_core_solver_base<double, double>::update_x(unsigned int, const double&);
-template bool lean::lp_core_solver_base<lean::mpq, lean::mpq>::A_mult_x_is_off() const;
-template bool lean::lp_core_solver_base<lean::mpq, lean::mpq>::A_mult_x_is_off_on_index(const vector<unsigned> &) const;
-template bool lean::lp_core_solver_base<lean::mpq, lean::mpq>::basis_heading_is_correct() const ;
-template void lean::lp_core_solver_base<lean::mpq, lean::mpq>::calculate_pivot_row_of_B_1(unsigned int);
-template void lean::lp_core_solver_base<lean::mpq, lean::mpq>::calculate_pivot_row_when_pivot_row_of_B1_is_ready(unsigned);
-template bool lean::lp_core_solver_base<lean::mpq, lean::mpq>::column_is_dual_feasible(unsigned int) const;
-template void lean::lp_core_solver_base<lean::mpq, lean::mpq>::fill_reduced_costs_from_m_y_by_rows();
-template bool lean::lp_core_solver_base<lean::mpq, lean::mpq>::find_x_by_solving();
-template void lean::lp_core_solver_base<lean::mpq, lean::mpq>::init_reduced_costs_for_one_iteration();
-template bool lean::lp_core_solver_base<lean::mpq, lean::mpq>::print_statistics_with_iterations_and_nonzeroes_and_cost_and_check_that_the_time_is_over(char const*, std::ostream &);
-template void lean::lp_core_solver_base<lean::mpq, lean::mpq>::restore_x(unsigned int, lean::mpq const&);
-template void lean::lp_core_solver_base<lean::mpq, lean::mpq>::set_non_basic_x_to_correct_bounds();
-template void lean::lp_core_solver_base<lean::mpq, lean::mpq>::solve_Ax_eq_b();
-template void lean::lp_core_solver_base<lean::mpq, lean::mpq>::solve_Bd(unsigned int);
-template void lean::lp_core_solver_base<lean::mpq, lean::mpq>::solve_yB(vector<lean::mpq>&);
-template bool lean::lp_core_solver_base<lean::mpq, lean::mpq>::update_basis_and_x(int, int, lean::mpq const&);
-template void lean::lp_core_solver_base<lean::mpq, lean::mpq>::update_x(unsigned int, const lean::mpq&);
-template void lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::calculate_pivot_row_of_B_1(unsigned int);
-template void lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::calculate_pivot_row_when_pivot_row_of_B1_is_ready(unsigned);
-template void lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::init();
-template void lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::init_basis_heading_and_non_basic_columns_vector();
-template void lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::init_reduced_costs_for_one_iteration();
-template lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::lp_core_solver_base(lean::static_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >&, vector<lean::numeric_pair<lean::mpq> >&, vector<unsigned int >&, vector<unsigned> &, vector<int> &, vector<lean::numeric_pair<lean::mpq> >&, vector<lean::mpq>&, lean::lp_settings&, const column_namer&, const vector<lean::column_type >&,
-                                                                                                   const vector<lean::numeric_pair<lean::mpq> >&,
-                                                                                                   const vector<lean::numeric_pair<lean::mpq> >&);
-template bool lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::print_statistics_with_cost_and_check_that_the_time_is_over(lean::numeric_pair<lean::mpq>, std::ostream&);
-template void lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::snap_xN_to_bounds_and_fill_xB();
-template void lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::solve_Bd(unsigned int);
-template bool lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::update_basis_and_x(int, int, lean::numeric_pair<lean::mpq> const&);
-template void lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::update_x(unsigned int, const lean::numeric_pair<lean::mpq>&);
-template lean::lp_core_solver_base<lean::mpq, lean::mpq>::lp_core_solver_base(
-                                                                              lean::static_matrix<lean::mpq, lean::mpq>&,
-                                                                              vector<lean::mpq>&,
+template bool lp::lp_core_solver_base<double, double>::print_statistics_with_iterations_and_nonzeroes_and_cost_and_check_that_the_time_is_over(char const*, std::ostream &);
+template bool lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::print_statistics_with_iterations_and_nonzeroes_and_cost_and_check_that_the_time_is_over(char const*, std::ostream &);
+template void lp::lp_core_solver_base<double, double>::restore_x(unsigned int, double const&);
+template void lp::lp_core_solver_base<double, double>::set_non_basic_x_to_correct_bounds();
+template void lp::lp_core_solver_base<double, double>::snap_xN_to_bounds_and_free_columns_to_zeroes();
+template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::snap_xN_to_bounds_and_free_columns_to_zeroes();
+template void lp::lp_core_solver_base<double, double>::solve_Ax_eq_b();
+template void lp::lp_core_solver_base<double, double>::solve_Bd(unsigned int);
+template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq>>::solve_Bd(unsigned int, indexed_vector<lp::mpq>&);
+template void lp::lp_core_solver_base<double, double>::solve_yB(vector<double >&);
+template bool lp::lp_core_solver_base<double, double>::update_basis_and_x(int, int, double const&);
+template void lp::lp_core_solver_base<double, double>::update_x(unsigned int, const double&);
+template bool lp::lp_core_solver_base<lp::mpq, lp::mpq>::A_mult_x_is_off() const;
+template bool lp::lp_core_solver_base<lp::mpq, lp::mpq>::A_mult_x_is_off_on_index(const vector<unsigned> &) const;
+template bool lp::lp_core_solver_base<lp::mpq, lp::mpq>::basis_heading_is_correct() const ;
+template void lp::lp_core_solver_base<lp::mpq, lp::mpq>::calculate_pivot_row_of_B_1(unsigned int);
+template void lp::lp_core_solver_base<lp::mpq, lp::mpq>::calculate_pivot_row_when_pivot_row_of_B1_is_ready(unsigned);
+template bool lp::lp_core_solver_base<lp::mpq, lp::mpq>::column_is_dual_feasible(unsigned int) const;
+template void lp::lp_core_solver_base<lp::mpq, lp::mpq>::fill_reduced_costs_from_m_y_by_rows();
+template bool lp::lp_core_solver_base<lp::mpq, lp::mpq>::find_x_by_solving();
+template void lp::lp_core_solver_base<lp::mpq, lp::mpq>::init_reduced_costs_for_one_iteration();
+template bool lp::lp_core_solver_base<lp::mpq, lp::mpq>::print_statistics_with_iterations_and_nonzeroes_and_cost_and_check_that_the_time_is_over(char const*, std::ostream &);
+template void lp::lp_core_solver_base<lp::mpq, lp::mpq>::restore_x(unsigned int, lp::mpq const&);
+template void lp::lp_core_solver_base<lp::mpq, lp::mpq>::set_non_basic_x_to_correct_bounds();
+template void lp::lp_core_solver_base<lp::mpq, lp::mpq>::solve_Ax_eq_b();
+template void lp::lp_core_solver_base<lp::mpq, lp::mpq>::solve_Bd(unsigned int);
+template void lp::lp_core_solver_base<lp::mpq, lp::mpq>::solve_yB(vector<lp::mpq>&);
+template bool lp::lp_core_solver_base<lp::mpq, lp::mpq>::update_basis_and_x(int, int, lp::mpq const&);
+template void lp::lp_core_solver_base<lp::mpq, lp::mpq>::update_x(unsigned int, const lp::mpq&);
+template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::calculate_pivot_row_of_B_1(unsigned int);
+template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::calculate_pivot_row_when_pivot_row_of_B1_is_ready(unsigned);
+template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::init();
+template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::init_basis_heading_and_non_basic_columns_vector();
+template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::init_reduced_costs_for_one_iteration();
+template lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::lp_core_solver_base(lp::static_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >&, vector<lp::numeric_pair<lp::mpq> >&, vector<unsigned int >&, vector<unsigned> &, vector<int> &, vector<lp::numeric_pair<lp::mpq> >&, vector<lp::mpq>&, lp::lp_settings&, const column_namer&, const vector<lp::column_type >&,
+                                                                                                   const vector<lp::numeric_pair<lp::mpq> >&,
+                                                                                                   const vector<lp::numeric_pair<lp::mpq> >&);
+template bool lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::print_statistics_with_cost_and_check_that_the_time_is_over(lp::numeric_pair<lp::mpq>, std::ostream&);
+template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::snap_xN_to_bounds_and_fill_xB();
+template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::solve_Bd(unsigned int);
+template bool lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::update_basis_and_x(int, int, lp::numeric_pair<lp::mpq> const&);
+template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::update_x(unsigned int, const lp::numeric_pair<lp::mpq>&);
+template lp::lp_core_solver_base<lp::mpq, lp::mpq>::lp_core_solver_base(
+                                                                              lp::static_matrix<lp::mpq, lp::mpq>&,
+                                                                              vector<lp::mpq>&,
                                                                               vector<unsigned int >&,
                                                                               vector<unsigned> &, vector<int> &,
-                                                                              vector<lean::mpq>&,
-                                                                              vector<lean::mpq>&,
-                                                                              lean::lp_settings&,
+                                                                              vector<lp::mpq>&,
+                                                                              vector<lp::mpq>&,
+                                                                              lp::lp_settings&,
                                                                               const column_namer&,
-                                                                              const vector<lean::column_type >&,
-                                                                              const vector<lean::mpq>&,
-                                                                              const vector<lean::mpq>&);
-template bool lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::print_statistics_with_iterations_and_check_that_the_time_is_over(std::ostream &);
-template std::string lean::lp_core_solver_base<double, double>::column_name(unsigned int) const;
-template void lean::lp_core_solver_base<double, double>::pretty_print(std::ostream & out);
-template void lean::lp_core_solver_base<double, double>::restore_state(double*, double*);
-template void lean::lp_core_solver_base<double, double>::save_state(double*, double*);
-template std::string lean::lp_core_solver_base<lean::mpq, lean::mpq>::column_name(unsigned int) const;
-template void lean::lp_core_solver_base<lean::mpq, lean::mpq>::pretty_print(std::ostream & out);
-template void lean::lp_core_solver_base<lean::mpq, lean::mpq>::restore_state(lean::mpq*, lean::mpq*);
-template void lean::lp_core_solver_base<lean::mpq, lean::mpq>::save_state(lean::mpq*, lean::mpq*);
-template std::string lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::column_name(unsigned int) const;
-template void lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::pretty_print(std::ostream & out);
-template void lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::restore_state(lean::mpq*, lean::mpq*);
-template void lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::save_state(lean::mpq*, lean::mpq*);
-template void lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::solve_yB(vector<lean::mpq>&);
-template void lean::lp_core_solver_base<double, double>::init_lu();
-template void lean::lp_core_solver_base<lean::mpq, lean::mpq>::init_lu();
-template int lean::lp_core_solver_base<double, double>::pivots_in_column_and_row_are_different(int, int) const;
-template int lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::pivots_in_column_and_row_are_different(int, int) const;
-template int lean::lp_core_solver_base<lean::mpq, lean::mpq>::pivots_in_column_and_row_are_different(int, int) const;
-template bool lean::lp_core_solver_base<double, double>::calc_current_x_is_feasible_include_non_basis(void)const;
-template bool lean::lp_core_solver_base<lean::mpq, lean::mpq>::calc_current_x_is_feasible_include_non_basis(void)const;
-template bool lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::calc_current_x_is_feasible_include_non_basis() const;
-template void  lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::pivot_fixed_vars_from_basis();
-template bool lean::lp_core_solver_base<double, double>::column_is_feasible(unsigned int) const;
-template bool lean::lp_core_solver_base<lean::mpq, lean::mpq>::column_is_feasible(unsigned int) const;
-// template void lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::print_linear_combination_of_column_indices(vector<std::pair<lean::mpq, unsigned int>, std::allocator<std::pair<lean::mpq, unsigned int> > > const&, std::ostream&) const;
-template bool lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::column_is_feasible(unsigned int) const;
-template bool lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::snap_non_basic_x_to_bound();
-template void lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::init_lu();
-template bool lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::A_mult_x_is_off_on_index(vector<unsigned int> const&) const;
-template bool lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::find_x_by_solving();
-template void lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::restore_x(unsigned int, lean::numeric_pair<lean::mpq> const&);
-template bool lean::lp_core_solver_base<double, double>::pivot_for_tableau_on_basis();
-template bool lean::lp_core_solver_base<lean::mpq, lean::mpq>::pivot_for_tableau_on_basis();
-template bool lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq>>::pivot_for_tableau_on_basis();
-template bool lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq>>::pivot_column_tableau(unsigned int, unsigned int);
-template bool lean::lp_core_solver_base<double, double>::pivot_column_tableau(unsigned int, unsigned int);
-template bool lean::lp_core_solver_base<lean::mpq, lean::mpq>::pivot_column_tableau(unsigned int, unsigned int);
-template void lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::transpose_rows_tableau(unsigned int, unsigned int);
-template bool lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::inf_set_is_correct() const;
-template bool lean::lp_core_solver_base<double, double>::inf_set_is_correct() const;
-template bool lean::lp_core_solver_base<lean::mpq, lean::mpq>::inf_set_is_correct() const;
-template bool lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> >::infeasibility_costs_are_correct() const;
-template bool lean::lp_core_solver_base<lean::mpq, lean::mpq >::infeasibility_costs_are_correct() const;
-template bool lean::lp_core_solver_base<double, double >::infeasibility_costs_are_correct() const;
+                                                                              const vector<lp::column_type >&,
+                                                                              const vector<lp::mpq>&,
+                                                                              const vector<lp::mpq>&);
+template bool lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::print_statistics_with_iterations_and_check_that_the_time_is_over(std::ostream &);
+template std::string lp::lp_core_solver_base<double, double>::column_name(unsigned int) const;
+template void lp::lp_core_solver_base<double, double>::pretty_print(std::ostream & out);
+template void lp::lp_core_solver_base<double, double>::restore_state(double*, double*);
+template void lp::lp_core_solver_base<double, double>::save_state(double*, double*);
+template std::string lp::lp_core_solver_base<lp::mpq, lp::mpq>::column_name(unsigned int) const;
+template void lp::lp_core_solver_base<lp::mpq, lp::mpq>::pretty_print(std::ostream & out);
+template void lp::lp_core_solver_base<lp::mpq, lp::mpq>::restore_state(lp::mpq*, lp::mpq*);
+template void lp::lp_core_solver_base<lp::mpq, lp::mpq>::save_state(lp::mpq*, lp::mpq*);
+template std::string lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::column_name(unsigned int) const;
+template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::pretty_print(std::ostream & out);
+template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::restore_state(lp::mpq*, lp::mpq*);
+template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::save_state(lp::mpq*, lp::mpq*);
+template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::solve_yB(vector<lp::mpq>&);
+template void lp::lp_core_solver_base<double, double>::init_lu();
+template void lp::lp_core_solver_base<lp::mpq, lp::mpq>::init_lu();
+template int lp::lp_core_solver_base<double, double>::pivots_in_column_and_row_are_different(int, int) const;
+template int lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::pivots_in_column_and_row_are_different(int, int) const;
+template int lp::lp_core_solver_base<lp::mpq, lp::mpq>::pivots_in_column_and_row_are_different(int, int) const;
+template bool lp::lp_core_solver_base<double, double>::calc_current_x_is_feasible_include_non_basis(void)const;
+template bool lp::lp_core_solver_base<lp::mpq, lp::mpq>::calc_current_x_is_feasible_include_non_basis(void)const;
+template bool lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::calc_current_x_is_feasible_include_non_basis() const;
+template void  lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::pivot_fixed_vars_from_basis();
+template bool lp::lp_core_solver_base<double, double>::column_is_feasible(unsigned int) const;
+template bool lp::lp_core_solver_base<lp::mpq, lp::mpq>::column_is_feasible(unsigned int) const;
+// template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::print_linear_combination_of_column_indices(vector<std::pair<lp::mpq, unsigned int>, std::allocator<std::pair<lp::mpq, unsigned int> > > const&, std::ostream&) const;
+template bool lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::column_is_feasible(unsigned int) const;
+template bool lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::snap_non_basic_x_to_bound();
+template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::init_lu();
+template bool lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::A_mult_x_is_off_on_index(vector<unsigned int> const&) const;
+template bool lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::find_x_by_solving();
+template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::restore_x(unsigned int, lp::numeric_pair<lp::mpq> const&);
+template bool lp::lp_core_solver_base<double, double>::pivot_for_tableau_on_basis();
+template bool lp::lp_core_solver_base<lp::mpq, lp::mpq>::pivot_for_tableau_on_basis();
+template bool lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq>>::pivot_for_tableau_on_basis();
+template bool lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq>>::pivot_column_tableau(unsigned int, unsigned int);
+template bool lp::lp_core_solver_base<double, double>::pivot_column_tableau(unsigned int, unsigned int);
+template bool lp::lp_core_solver_base<lp::mpq, lp::mpq>::pivot_column_tableau(unsigned int, unsigned int);
+template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::transpose_rows_tableau(unsigned int, unsigned int);
+template bool lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::inf_set_is_correct() const;
+template bool lp::lp_core_solver_base<double, double>::inf_set_is_correct() const;
+template bool lp::lp_core_solver_base<lp::mpq, lp::mpq>::inf_set_is_correct() const;
+template bool lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::infeasibility_costs_are_correct() const;
+template bool lp::lp_core_solver_base<lp::mpq, lp::mpq >::infeasibility_costs_are_correct() const;
+template bool lp::lp_core_solver_base<double, double >::infeasibility_costs_are_correct() const;
diff --git a/src/util/lp/lp_dual_core_solver.h b/src/util/lp/lp_dual_core_solver.h
index b873cb711..ba4be494f 100644
--- a/src/util/lp/lp_dual_core_solver.h
+++ b/src/util/lp/lp_dual_core_solver.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include "util/lp/static_matrix.h"
 #include "util/lp/lp_core_solver_base.h"
@@ -11,7 +26,7 @@
 #include <algorithm>
 #include "util/vector.h"
 
-namespace lean {
+namespace lp {
 template <typename T, typename X>
 class lp_dual_core_solver:public lp_core_solver_base<T, X> {
 public:
diff --git a/src/util/lp/lp_dual_core_solver.hpp b/src/util/lp/lp_dual_core_solver.hpp
index 6565331b3..5d48fe24d 100644
--- a/src/util/lp/lp_dual_core_solver.hpp
+++ b/src/util/lp/lp_dual_core_solver.hpp
@@ -1,13 +1,28 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <algorithm>
 #include <string>
 #include "util/vector.h"
 #include "util/lp/lp_dual_core_solver.h"
 
-namespace lean {
+namespace lp {
 
 template <typename T, typename X> void lp_dual_core_solver<T, X>::init_a_wave_by_zeros() {
     unsigned j = this->m_m();
@@ -23,7 +38,7 @@ template <typename T, typename X> void lp_dual_core_solver<T, X>::restore_non_ba
     while (j--) {
         if (this->m_basis_heading[j] >= 0 ) continue;
         if (m_can_enter_basis[j]) {
-            lean_assert(std::find(nb.begin(), nb.end(), j) == nb.end());
+            SASSERT(std::find(nb.begin(), nb.end(), j) == nb.end());
             nb.push_back(j);
             this->m_basis_heading[j] = - static_cast<int>(nb.size());
         }
@@ -93,14 +108,14 @@ template <typename T, typename X> bool lp_dual_core_solver<T, X>::done() {
 }
 
 template <typename T, typename X> T lp_dual_core_solver<T, X>::get_edge_steepness_for_low_bound(unsigned p) {
-    lean_assert(this->m_basis_heading[p] >= 0 && static_cast<unsigned>(this->m_basis_heading[p]) < this->m_m());
+    SASSERT(this->m_basis_heading[p] >= 0 && static_cast<unsigned>(this->m_basis_heading[p]) < this->m_m());
     T del = this->m_x[p] - this->m_low_bounds[p];
     del *= del;
     return del / this->m_betas[this->m_basis_heading[p]];
 }
 
 template <typename T, typename X> T lp_dual_core_solver<T, X>::get_edge_steepness_for_upper_bound(unsigned p) {
-    lean_assert(this->m_basis_heading[p] >= 0 && static_cast<unsigned>(this->m_basis_heading[p]) < this->m_m());
+    SASSERT(this->m_basis_heading[p] >= 0 && static_cast<unsigned>(this->m_basis_heading[p]) < this->m_m());
     T del = this->m_x[p] - this->m_upper_bounds[p];
     del *= del;
     return del / this->m_betas[this->m_basis_heading[p]];
@@ -135,12 +150,12 @@ template <typename T, typename X> T lp_dual_core_solver<T, X>::pricing_for_row(u
         return numeric_traits<T>::zero();
         break;
     case column_type::free_column:
-        lean_assert(numeric_traits<T>::is_zero(this->m_d[p]));
+        SASSERT(numeric_traits<T>::is_zero(this->m_d[p]));
         return numeric_traits<T>::zero();
     default:
-        lean_unreachable();
+        SASSERT(false);
     }
-    lean_unreachable();
+    SASSERT(false);
     return numeric_traits<T>::zero();
 }
 
@@ -209,9 +224,9 @@ template <typename T, typename X> bool lp_dual_core_solver<T, X>::advance_on_kno
     int pivot_compare_result = this->pivots_in_column_and_row_are_different(m_q, m_p);
     if (!pivot_compare_result){;}
     else if (pivot_compare_result == 2) { // the sign is changed, cannot continue
-        lean_unreachable(); // not implemented yet
+        SASSERT(false); // not implemented yet
     } else {
-        lean_assert(pivot_compare_result == 1);
+        SASSERT(pivot_compare_result == 1);
         this->init_lu();
     }
     DSE_FTran();
@@ -228,21 +243,21 @@ template <typename T, typename X> int lp_dual_core_solver<T, X>::define_sign_of_
         if (this->x_above_upper_bound(m_p)) {
             return 1;
         }
-        lean_unreachable();
+        SASSERT(false);
     case column_type::low_bound:
         if (this->x_below_low_bound(m_p)) {
             return -1;
         }
-        lean_unreachable();
+        SASSERT(false);
     case column_type::upper_bound:
         if (this->x_above_upper_bound(m_p)) {
             return 1;
         }
-        lean_unreachable();
+        SASSERT(false);
     default:
-        lean_unreachable();
+        SASSERT(false);
     }
-    lean_unreachable();
+    SASSERT(false);
     return 0;
 }
 
@@ -250,10 +265,10 @@ template <typename T, typename X> bool lp_dual_core_solver<T, X>::can_be_breakpo
     if (this->pivot_row_element_is_too_small_for_ratio_test(j)) return false;
     switch (this->m_column_types[j]) {
     case column_type::low_bound:
-        lean_assert(this->m_settings.abs_val_is_smaller_than_harris_tolerance(this->m_x[j] - this->m_low_bounds[j]));
+        SASSERT(this->m_settings.abs_val_is_smaller_than_harris_tolerance(this->m_x[j] - this->m_low_bounds[j]));
         return m_sign_of_alpha_r * this->m_pivot_row[j]  > 0;
     case column_type::upper_bound:
-        lean_assert(this->m_settings.abs_val_is_smaller_than_harris_tolerance(this->m_x[j] - this->m_upper_bounds[j]));
+        SASSERT(this->m_settings.abs_val_is_smaller_than_harris_tolerance(this->m_x[j] - this->m_upper_bounds[j]));
         return m_sign_of_alpha_r * this->m_pivot_row[j] < 0;
     case column_type::boxed:
         {
@@ -292,23 +307,23 @@ template <typename T, typename X> T lp_dual_core_solver<T, X>::get_delta() {
         if (this->x_above_upper_bound(m_p)) {
             return this->m_x[m_p] - this->m_upper_bounds[m_p];
         }
-        lean_unreachable();
+        SASSERT(false);
     case column_type::low_bound:
         if (this->x_below_low_bound(m_p)) {
             return this->m_x[m_p] - this->m_low_bounds[m_p];
         }
-        lean_unreachable();
+        SASSERT(false);
     case column_type::upper_bound:
         if (this->x_above_upper_bound(m_p)) {
             return get_edge_steepness_for_upper_bound(m_p);
         }
-        lean_unreachable();
+        SASSERT(false);
     case column_type::fixed:
         return this->m_x[m_p] - this->m_upper_bounds[m_p];
     default:
-        lean_unreachable();
+        SASSERT(false);
     }
-    lean_unreachable();
+    SASSERT(false);
     return zero_of_type<T>();
 }
 
@@ -355,7 +370,7 @@ template <typename T, typename X> void lp_dual_core_solver<T, X>::update_betas()
 
 template <typename T, typename X> void lp_dual_core_solver<T, X>::apply_flips() {
     for (unsigned j : m_flipped_boxed) {
-        lean_assert(this->x_is_at_bound(j));
+        SASSERT(this->x_is_at_bound(j));
         if (this->x_is_at_low_bound(j)) {
             this->m_x[j] = this->m_upper_bounds[j];
         } else {
@@ -385,7 +400,7 @@ template <typename T, typename X> void lp_dual_core_solver<T, X>::snap_xN_column
     case column_type::free_column:
         break;
     default:
-        lean_unreachable();
+        SASSERT(false);
     }
 }
 
@@ -441,7 +456,7 @@ template <typename T, typename X> bool lp_dual_core_solver<T, X>::basis_change_a
         return false;
     }
 
-    lean_assert(d_is_correct());
+    SASSERT(d_is_correct());
     return true;
 }
 
@@ -457,7 +472,7 @@ template <typename T, typename X> void lp_dual_core_solver<T, X>::recover_leavin
     case free_of_bounds:
         this->m_x[m_q] = zero_of_type<X>();
     default:
-        lean_unreachable();
+        SASSERT(false);
     }
 }
 
@@ -584,7 +599,7 @@ template <typename T, typename X> bool lp_dual_core_solver<T, X>::tight_breakpoi
 template <typename T, typename X> T lp_dual_core_solver<T, X>::calculate_harris_delta_on_breakpoint_set() {
     bool first_time = true;
     T ret = zero_of_type<T>();
-    lean_assert(m_breakpoint_set.size() > 0);
+    SASSERT(m_breakpoint_set.size() > 0);
     for (auto j : m_breakpoint_set) {
         T t;
         if (this->x_is_at_low_bound(j)) {
@@ -633,7 +648,7 @@ template <typename T, typename X> void lp_dual_core_solver<T, X>::find_q_on_tigh
         }
     }
     m_tight_set.erase(m_q);
-    lean_assert(m_q != -1);
+    SASSERT(m_q != -1);
 }
 
 template <typename T, typename X> void lp_dual_core_solver<T, X>::find_q_and_tight_set() {
@@ -722,13 +737,13 @@ template <typename T, typename X> void lp_dual_core_solver<T, X>::one_iteration(
         this->set_status(FEASIBLE);
     }
     pricing_loop(number_of_rows_to_try, offset_in_rows);
-    lean_assert(problem_is_dual_feasible());
+    SASSERT(problem_is_dual_feasible());
 }
 
 template <typename T, typename X> void lp_dual_core_solver<T, X>::solve() { // see the page 35
-    lean_assert(d_is_correct());
-    lean_assert(problem_is_dual_feasible());
-    lean_assert(this->basis_heading_is_correct());
+    SASSERT(d_is_correct());
+    SASSERT(problem_is_dual_feasible());
+    SASSERT(this->basis_heading_is_correct());
     this->set_total_iterations(0);
     this->iters_with_no_cost_growing() = 0;
     do {
diff --git a/src/util/lp/lp_dual_core_solver_instances.cpp b/src/util/lp/lp_dual_core_solver_instances.cpp
index 8016088f8..db68bda65 100644
--- a/src/util/lp/lp_dual_core_solver_instances.cpp
+++ b/src/util/lp/lp_dual_core_solver_instances.cpp
@@ -1,29 +1,44 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <utility>
 #include <memory>
 #include <string>
 #include "util/vector.h"
 #include <functional>
 #include "util/lp/lp_dual_core_solver.hpp"
-template void lean::lp_dual_core_solver<lean::mpq, lean::mpq>::start_with_initial_basis_and_make_it_dual_feasible();
-template void lean::lp_dual_core_solver<lean::mpq, lean::mpq>::solve();
-template lean::lp_dual_core_solver<double, double>::lp_dual_core_solver(lean::static_matrix<double, double>&, vector<bool>&,
+template void lp::lp_dual_core_solver<lp::mpq, lp::mpq>::start_with_initial_basis_and_make_it_dual_feasible();
+template void lp::lp_dual_core_solver<lp::mpq, lp::mpq>::solve();
+template lp::lp_dual_core_solver<double, double>::lp_dual_core_solver(lp::static_matrix<double, double>&, vector<bool>&,
                                                                         vector<double>&,
                                                                         vector<double>&,
                                                                         vector<unsigned int>&,
                                                                         vector<unsigned> &,
                                                                         vector<int> &,
                                                                         vector<double>&,
-                                                                        vector<lean::column_type>&,
+                                                                        vector<lp::column_type>&,
                                                                         vector<double>&,
                                                                         vector<double>&,
-                                                                        lean::lp_settings&, const lean::column_namer&);
-template void lean::lp_dual_core_solver<double, double>::start_with_initial_basis_and_make_it_dual_feasible();
-template void lean::lp_dual_core_solver<double, double>::solve();
-template void lean::lp_dual_core_solver<lean::mpq, lean::mpq>::restore_non_basis();
-template void lean::lp_dual_core_solver<double, double>::restore_non_basis();
-template void lean::lp_dual_core_solver<double, double>::revert_to_previous_basis();
-template void lean::lp_dual_core_solver<lean::mpq, lean::mpq>::revert_to_previous_basis();
+                                                                        lp::lp_settings&, const lp::column_namer&);
+template void lp::lp_dual_core_solver<double, double>::start_with_initial_basis_and_make_it_dual_feasible();
+template void lp::lp_dual_core_solver<double, double>::solve();
+template void lp::lp_dual_core_solver<lp::mpq, lp::mpq>::restore_non_basis();
+template void lp::lp_dual_core_solver<double, double>::restore_non_basis();
+template void lp::lp_dual_core_solver<double, double>::revert_to_previous_basis();
+template void lp::lp_dual_core_solver<lp::mpq, lp::mpq>::revert_to_previous_basis();
diff --git a/src/util/lp/lp_dual_simplex.h b/src/util/lp/lp_dual_simplex.h
index 4dff2a4f1..c17a9e99e 100644
--- a/src/util/lp/lp_dual_simplex.h
+++ b/src/util/lp/lp_dual_simplex.h
@@ -1,13 +1,28 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include "util/vector.h"
 #include "util/lp/lp_utils.h"
 #include "util/lp/lp_solver.h"
 #include "util/lp/lp_dual_core_solver.h"
-namespace lean {
+namespace lp {
 
 template <typename T, typename X>
 class lp_dual_simplex: public lp_solver<T, X> {
diff --git a/src/util/lp/lp_dual_simplex.hpp b/src/util/lp/lp_dual_simplex.hpp
index 5047e117f..248dff448 100644
--- a/src/util/lp/lp_dual_simplex.hpp
+++ b/src/util/lp/lp_dual_simplex.hpp
@@ -1,9 +1,24 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include "util/lp/lp_dual_simplex.h"
-namespace lean{
+namespace lp{
 
 template <typename T, typename X> void lp_dual_simplex<T, X>::decide_on_status_after_stage1() {
     switch (m_core_solver->get_status()) {
@@ -15,7 +30,7 @@ template <typename T, typename X> void lp_dual_simplex<T, X>::decide_on_status_a
         }
         break;
     case DUAL_UNBOUNDED:
-        lean_unreachable();
+        SASSERT(false);
     case ITERATIONS_EXHAUSTED:
         this->m_status = ITERATIONS_EXHAUSTED;
         break;
@@ -26,12 +41,12 @@ template <typename T, typename X> void lp_dual_simplex<T, X>::decide_on_status_a
         this->m_status = FLOATING_POINT_ERROR;
         break;
     default:
-        lean_unreachable();
+        SASSERT(false);
     }
 }
 
 template <typename T, typename X> void lp_dual_simplex<T, X>::fix_logical_for_stage2(unsigned j) {
-    lean_assert(j >= this->number_of_core_structurals());
+    SASSERT(j >= this->number_of_core_structurals());
     switch (m_column_types_of_logicals[j - this->number_of_core_structurals()]) {
     case column_type::low_bound:
         m_low_bounds[j] = numeric_traits<T>::zero();
@@ -44,7 +59,7 @@ template <typename T, typename X> void lp_dual_simplex<T, X>::fix_logical_for_st
         m_can_enter_basis[j] = false;
         break;
     default:
-        lean_unreachable();
+        SASSERT(false);
     }
 }
 
@@ -58,7 +73,7 @@ template <typename T, typename X> void lp_dual_simplex<T, X>::fix_structural_for
         break;
     case column_type::fixed:
     case column_type::upper_bound:
-        lean_unreachable();
+        SASSERT(false);
     case column_type::boxed:
         this->m_upper_bounds[j] = ci->get_adjusted_upper_bound() / this->m_column_scale[j];
         m_low_bounds[j] = numeric_traits<T>::zero();
@@ -70,7 +85,7 @@ template <typename T, typename X> void lp_dual_simplex<T, X>::fix_structural_for
         m_column_types_of_core_solver[j] = column_type::free_column;
         break;
     default:
-        lean_unreachable();
+        SASSERT(false);
     }
     //    T cost_was = this->m_costs[j];
     this->set_scaled_cost(j);
@@ -115,7 +130,7 @@ template <typename T, typename X> void lp_dual_simplex<T, X>::solve_for_stage2()
         this->m_status = FLOATING_POINT_ERROR;
         break;
     default:
-        lean_unreachable();
+        SASSERT(false);
     }
     this->m_second_stage_iterations = m_core_solver->total_iterations();
     this->m_total_iterations = (this->m_first_stage_iterations + this->m_second_stage_iterations);
@@ -129,7 +144,7 @@ template <typename T, typename X> void lp_dual_simplex<T, X>::fill_x_with_zeros(
 }
 
 template <typename T, typename X> void lp_dual_simplex<T, X>::stage1() {
-    lean_assert(m_core_solver == nullptr);
+    SASSERT(m_core_solver == nullptr);
     this->m_x.resize(this->m_A->column_count(), numeric_traits<T>::zero());
     if (this->m_settings.get_message_ostream() != nullptr)
         this->print_statistics_on_A(*this->m_settings.get_message_ostream());
@@ -177,7 +192,7 @@ template <typename T, typename X> void lp_dual_simplex<T, X>::fill_first_stage_s
 }
 
 template <typename T, typename X> column_type lp_dual_simplex<T, X>::get_column_type(unsigned j) {
-    lean_assert(j < this->m_A->column_count());
+    SASSERT(j < this->m_A->column_count());
     if (j >= this->number_of_core_structurals()) {
         return m_column_types_of_logicals[j - this->number_of_core_structurals()];
     }
@@ -186,12 +201,12 @@ template <typename T, typename X> column_type lp_dual_simplex<T, X>::get_column_
 
 template <typename T, typename X> void lp_dual_simplex<T, X>::fill_costs_bounds_types_and_can_enter_basis_for_the_first_stage_solver_structural_column(unsigned j) {
     // see 4.7 in the dissertation of Achim Koberstein
-    lean_assert(this->m_core_solver_columns_to_external_columns.find(j) !=
+    SASSERT(this->m_core_solver_columns_to_external_columns.find(j) !=
                 this->m_core_solver_columns_to_external_columns.end());
 
     T free_bound = T(1e4); // see 4.8
     unsigned jj = this->m_core_solver_columns_to_external_columns[j];
-    lean_assert(this->m_map_from_var_index_to_column_info.find(jj) != this->m_map_from_var_index_to_column_info.end());
+    SASSERT(this->m_map_from_var_index_to_column_info.find(jj) != this->m_map_from_var_index_to_column_info.end());
     column_info<T> * ci = this->m_map_from_var_index_to_column_info[jj];
     switch (ci->get_column_type()) {
     case column_type::upper_bound: {
@@ -221,14 +236,14 @@ template <typename T, typename X> void lp_dual_simplex<T, X>::fill_costs_bounds_
         this->m_upper_bounds[j] = this->m_low_bounds[j] =  numeric_traits<T>::zero(); // is it needed?
         break;
     default:
-        lean_unreachable();
+        SASSERT(false);
     }
     m_column_types_of_core_solver[j] = column_type::boxed;
 }
 
 template <typename T, typename X> void lp_dual_simplex<T, X>::fill_costs_bounds_types_and_can_enter_basis_for_the_first_stage_solver_logical_column(unsigned j) {
     this->m_costs[j] = 0;
-    lean_assert(get_column_type(j) != column_type::upper_bound);
+    SASSERT(get_column_type(j) != column_type::upper_bound);
     if ((m_can_enter_basis[j] = (get_column_type(j) == column_type::low_bound))) {
         m_column_types_of_core_solver[j] = column_type::boxed;
         this->m_low_bounds[j] = numeric_traits<T>::zero();
@@ -254,7 +269,7 @@ template <typename T, typename X> void lp_dual_simplex<T, X>::fill_costs_and_bou
 template <typename T, typename X> void lp_dual_simplex<T, X>::fill_first_stage_solver_fields_for_row_slack_and_artificial(unsigned row,
                                                                                                                           unsigned & slack_var,
                                                                                                                           unsigned & artificial) {
-    lean_assert(row < this->row_count());
+    SASSERT(row < this->row_count());
     auto & constraint = this->m_constraints[this->m_core_solver_rows_to_external_rows[row]];
     // we need to bring the program to the form Ax = b
     T rs = this->m_b[row];
diff --git a/src/util/lp/lp_dual_simplex_instances.cpp b/src/util/lp/lp_dual_simplex_instances.cpp
index 6610814d8..9e45849de 100644
--- a/src/util/lp/lp_dual_simplex_instances.cpp
+++ b/src/util/lp/lp_dual_simplex_instances.cpp
@@ -1,9 +1,24 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include "util/lp/lp_dual_simplex.hpp"
-template lean::mpq lean::lp_dual_simplex<lean::mpq, lean::mpq>::get_current_cost() const;
-template void lean::lp_dual_simplex<lean::mpq, lean::mpq>::find_maximal_solution();
-template double lean::lp_dual_simplex<double, double>::get_current_cost() const;
-template void lean::lp_dual_simplex<double, double>::find_maximal_solution();
+template lp::mpq lp::lp_dual_simplex<lp::mpq, lp::mpq>::get_current_cost() const;
+template void lp::lp_dual_simplex<lp::mpq, lp::mpq>::find_maximal_solution();
+template double lp::lp_dual_simplex<double, double>::get_current_cost() const;
+template void lp::lp_dual_simplex<double, double>::find_maximal_solution();
diff --git a/src/util/lp/lp_primal_core_solver.h b/src/util/lp/lp_primal_core_solver.h
index f77aae6eb..a7614862b 100644
--- a/src/util/lp/lp_primal_core_solver.h
+++ b/src/util/lp/lp_primal_core_solver.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 #include <list>
@@ -23,7 +38,7 @@
 #include "util/lp/binary_heap_priority_queue.h"
 #include "util/lp/int_set.h"
 #include "util/lp/iterator_on_row.h"
-namespace lean {
+namespace lp {
 
 // This core solver solves (Ax=b, low_bound_values \leq x \leq upper_bound_values, maximize costs*x )
 // The right side b is given implicitly by x and the basis
@@ -70,7 +85,7 @@ public:
     //     unsigned len = 100000000; 
     //     for (unsigned j : this->m_inf_set.m_index) {
     //         int i = this->m_basis_heading[j];
-    //         lean_assert(i >= 0);
+    //         SASSERT(i >= 0);
     //         unsigned row_len = this->m_A.m_rows[i].size();
     //         if (row_len < len) {
     //             choices.clear();
@@ -98,8 +113,8 @@ public:
     bool column_is_benefitial_for_entering_basis_on_sign_row_strategy(unsigned j, int sign) const {
         // sign = 1 means the x of the basis column of the row has to grow to become feasible, when the coeff before j is neg, or x - has to diminish when the coeff is pos
         // we have xbj = -aj * xj
-        lean_assert(this->m_basis_heading[j] < 0);
-        lean_assert(this->column_is_feasible(j));
+        SASSERT(this->m_basis_heading[j] < 0);
+        SASSERT(this->column_is_feasible(j));
         switch (this->m_column_types[j]) {
         case column_type::free_column: return true;
         case column_type::fixed: return false;
@@ -117,13 +132,13 @@ public:
             return !this->x_is_at_upper_bound(j);
         }
 
-        lean_assert(false); // cannot be here
+        SASSERT(false); // cannot be here
         return false;
     }
     
 
     bool needs_to_grow(unsigned bj) const {
-        lean_assert(!this->column_is_feasible(bj));
+        SASSERT(!this->column_is_feasible(bj));
         switch(this->m_column_types[bj]) {
         case column_type::free_column:
             return false;
@@ -134,12 +149,12 @@ public:
         default:
             return false;
         }
-        lean_assert(false); // unreachable
+        SASSERT(false); // unreachable
         return false;
     }
 
     int inf_sign_of_column(unsigned bj) const {
-        lean_assert(!this->column_is_feasible(bj));
+        SASSERT(!this->column_is_feasible(bj));
         switch(this->m_column_types[bj]) {
         case column_type::free_column:
             return 0;
@@ -151,7 +166,7 @@ public:
         default:
             return -1;
         }
-        lean_assert(false); // unreachable
+        SASSERT(false); // unreachable
         return 0;
         
     }
@@ -159,7 +174,7 @@ public:
 
     bool monoid_can_decrease(const row_cell<T> & rc) const {
         unsigned j = rc.m_j;
-        lean_assert(this->column_is_feasible(j));
+        SASSERT(this->column_is_feasible(j));
         switch (this->m_column_types[j]) {
         case column_type::free_column:
             return true;
@@ -186,13 +201,13 @@ public:
         default:
             return false;
         }
-        lean_assert(false); // unreachable
+        SASSERT(false); // unreachable
         return false;
     }
 
     bool monoid_can_increase(const row_cell<T> & rc) const {
         unsigned j = rc.m_j;
-        lean_assert(this->column_is_feasible(j));
+        SASSERT(this->column_is_feasible(j));
         switch (this->m_column_types[j]) {
         case column_type::free_column:
             return true;
@@ -219,7 +234,7 @@ public:
         default:
             return false;
         }
-        lean_assert(false); // unreachable
+        SASSERT(false); // unreachable
         return false;
     }
 
@@ -329,24 +344,24 @@ public:
     }
 
     void limit_theta_on_basis_column_for_inf_case_m_neg_upper_bound(unsigned j, const T & m, X & theta, bool & unlimited) {
-        lean_assert(m < 0 && this->m_column_types[j] == column_type::upper_bound);
+        SASSERT(m < 0 && this->m_column_types[j] == column_type::upper_bound);
         limit_inf_on_upper_bound_m_neg(m, this->m_x[j], this->m_upper_bounds[j], theta, unlimited);
     }
 
 
     void limit_theta_on_basis_column_for_inf_case_m_neg_low_bound(unsigned j, const T & m, X & theta, bool & unlimited) {
-        lean_assert(m < 0 && this->m_column_types[j] == column_type::low_bound);
+        SASSERT(m < 0 && this->m_column_types[j] == column_type::low_bound);
         limit_inf_on_bound_m_neg(m, this->m_x[j], this->m_low_bounds[j], theta, unlimited);
     }
 
 
     void limit_theta_on_basis_column_for_inf_case_m_pos_low_bound(unsigned j, const T & m, X & theta, bool & unlimited) {
-        lean_assert(m > 0 && this->m_column_types[j] == column_type::low_bound);
+        SASSERT(m > 0 && this->m_column_types[j] == column_type::low_bound);
         limit_inf_on_low_bound_m_pos(m, this->m_x[j], this->m_low_bounds[j], theta, unlimited);
     }
 
     void limit_theta_on_basis_column_for_inf_case_m_pos_upper_bound(unsigned j, const T & m, X & theta, bool & unlimited) {
-        lean_assert(m > 0 && this->m_column_types[j] == column_type::upper_bound);
+        SASSERT(m > 0 && this->m_column_types[j] == column_type::upper_bound);
         limit_inf_on_bound_m_pos(m, this->m_x[j], this->m_upper_bounds[j], theta, unlimited);
     };
 
@@ -359,7 +374,7 @@ public:
 
     X get_max_bound(vector<X> & b);
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     void check_Ax_equal_b();
     void check_the_bounds();
     void check_bound(unsigned i);
@@ -388,7 +403,7 @@ public:
     bool need_to_switch_costs() const {
         if (this->m_settings.simplex_strategy() == simplex_strategy_enum::tableau_rows)
             return false;
-        //        lean_assert(calc_current_x_is_feasible() == current_x_is_feasible());
+        //        SASSERT(calc_current_x_is_feasible() == current_x_is_feasible());
         return this->current_x_is_feasible() == this->m_using_infeas_costs;
     }
 
@@ -443,7 +458,7 @@ public:
         if (j == -1)
             return -1;
 
-        lean_assert(!this->column_is_feasible(j));
+        SASSERT(!this->column_is_feasible(j));
         switch (this->m_column_types[j]) {
         case column_type::fixed:
         case column_type::upper_bound:
@@ -459,7 +474,7 @@ public:
                 new_val_for_leaving = this->m_low_bounds[j];
             break;
         default:
-            lean_assert(false);
+            SASSERT(false);
             new_val_for_leaving = numeric_traits<T>::zero(); // does not matter
         }
         return j;
@@ -490,7 +505,7 @@ public:
         }
         X theta = (this->m_x[leaving] - new_val_for_leaving) / a_ent;
         advance_on_entering_and_leaving_tableau_rows(entering, leaving, theta );
-        lean_assert(this->m_x[leaving] == new_val_for_leaving);
+        SASSERT(this->m_x[leaving] == new_val_for_leaving);
         if (this->current_x_is_feasible())
             this->set_status(OPTIMAL);
     }
@@ -507,13 +522,13 @@ public:
     void update_basis_and_x_with_comparison(unsigned entering, unsigned leaving, X delta);
 
     void decide_on_status_when_cannot_find_entering() {
-        lean_assert(!need_to_switch_costs());
+        SASSERT(!need_to_switch_costs());
         this->set_status(this->current_x_is_feasible()? OPTIMAL: INFEASIBLE);
     }
 
     // void limit_theta_on_basis_column_for_feas_case_m_neg(unsigned j, const T & m, X & theta) {
-    //     lean_assert(m < 0);
-    //     lean_assert(this->m_column_type[j] == low_bound || this->m_column_type[j] == boxed);
+    //     SASSERT(m < 0);
+    //     SASSERT(this->m_column_type[j] == low_bound || this->m_column_type[j] == boxed);
     //     const X & eps = harris_eps_for_bound(this->m_low_bounds[j]);
     //     if (this->above_bound(this->m_x[j], this->m_low_bounds[j])) {
     //         theta = std::min((this->m_low_bounds[j] -this->m_x[j] - eps) / m, theta);
@@ -522,7 +537,7 @@ public:
     // }
 
     void limit_theta_on_basis_column_for_feas_case_m_neg_no_check(unsigned j, const T & m, X & theta, bool & unlimited) {
-        lean_assert(m < 0);
+        SASSERT(m < 0);
         const X& eps = harris_eps_for_bound(this->m_low_bounds[j]);
         limit_theta((this->m_low_bounds[j] - this->m_x[j] - eps) / m, theta, unlimited);
         if (theta < zero_of_type<X>()) theta = zero_of_type<X>();
@@ -530,7 +545,7 @@ public:
 
     bool limit_inf_on_bound_m_neg(const T & m, const X & x, const X & bound, X & theta, bool & unlimited) {
         // x gets smaller
-        lean_assert(m < 0);
+        SASSERT(m < 0);
         if (numeric_traits<T>::precise()) {
             if (this->below_bound(x, bound)) return false;
             if (this->above_bound(x, bound)) {
@@ -554,7 +569,7 @@ public:
 
     bool limit_inf_on_bound_m_pos(const T & m, const X & x, const X & bound, X & theta, bool & unlimited) {
         // x gets larger
-        lean_assert(m > 0);
+        SASSERT(m > 0);
         if (numeric_traits<T>::precise()) {
             if (this->above_bound(x, bound)) return false;
             if (this->below_bound(x, bound)) {
@@ -579,14 +594,14 @@ public:
     void limit_inf_on_low_bound_m_pos(const T & m, const X & x, const X & bound, X & theta, bool & unlimited) {
         if (numeric_traits<T>::precise()) {
             // x gets larger
-            lean_assert(m > 0);
+            SASSERT(m > 0);
             if (this->below_bound(x, bound)) {
                 limit_theta((bound - x) / m, theta, unlimited);
             }
         }
         else {
             // x gets larger
-            lean_assert(m > 0);
+            SASSERT(m > 0);
             const X& eps = harris_eps_for_bound(bound);
             if (this->below_bound(x, bound)) {
                 limit_theta((bound - x + eps) / m, theta, unlimited);
@@ -596,7 +611,7 @@ public:
 
     void limit_inf_on_upper_bound_m_neg(const T & m, const X & x, const X & bound, X & theta, bool & unlimited) {
         // x gets smaller
-        lean_assert(m < 0);
+        SASSERT(m < 0);
         const X& eps = harris_eps_for_bound(bound);
         if (this->above_bound(x, bound)) {
             limit_theta((bound - x - eps) / m, theta, unlimited);
@@ -604,7 +619,7 @@ public:
     }
 
     void limit_theta_on_basis_column_for_inf_case_m_pos_boxed(unsigned j, const T & m, X & theta, bool & unlimited) {
-        //        lean_assert(m > 0 && this->m_column_type[j] == column_type::boxed);
+        //        SASSERT(m > 0 && this->m_column_type[j] == column_type::boxed);
         const X & x = this->m_x[j];
         const X & lbound = this->m_low_bounds[j];
 
@@ -624,7 +639,7 @@ public:
     }
 
     void limit_theta_on_basis_column_for_inf_case_m_neg_boxed(unsigned j, const T & m, X & theta, bool & unlimited) {
-        //  lean_assert(m < 0 && this->m_column_type[j] == column_type::boxed);
+        //  SASSERT(m < 0 && this->m_column_type[j] == column_type::boxed);
         const X & x = this->m_x[j];
         const X & ubound = this->m_upper_bounds[j];
         if (this->above_bound(x, ubound)) {
@@ -642,7 +657,7 @@ public:
         }
     }
     void limit_theta_on_basis_column_for_feas_case_m_pos(unsigned j, const T & m, X & theta, bool & unlimited) {
-        lean_assert(m > 0);
+        SASSERT(m > 0);
         const T& eps = harris_eps_for_bound(this->m_upper_bounds[j]);
         if (this->below_bound(this->m_x[j], this->m_upper_bounds[j])) {
             limit_theta((this->m_upper_bounds[j] - this->m_x[j] + eps) / m, theta, unlimited);
@@ -654,7 +669,7 @@ public:
     }
 
     void limit_theta_on_basis_column_for_feas_case_m_pos_no_check(unsigned j, const T & m, X & theta, bool & unlimited ) {
-        lean_assert(m > 0);
+        SASSERT(m > 0);
         const X& eps = harris_eps_for_bound(this->m_upper_bounds[j]);
         limit_theta( (this->m_upper_bounds[j] - this->m_x[j] + eps) / m, theta, unlimited);
         if (theta < zero_of_type<X>()) {
@@ -720,7 +735,7 @@ public:
 
             break;
         default:
-            lean_unreachable();
+            SASSERT(false);
         }
         if (!unlimited && theta < zero_of_type<X>()) {
             theta = zero_of_type<X>();
@@ -803,7 +818,7 @@ public:
         case column_type::free_column:
             return 0;
         default:
-            lean_assert(false);
+            SASSERT(false);
         }
         return 0;
     }
@@ -838,7 +853,7 @@ public:
             return -1;
             break;
         default:
-            lean_assert(false);
+            SASSERT(false);
         }
         return 0;
 
@@ -864,7 +879,7 @@ public:
 
 // the delta is between the old and the new cost (old - new)
     void update_reduced_cost_for_basic_column_cost_change(const T & delta, unsigned j) {
-        lean_assert(this->m_basis_heading[j] >= 0);
+        SASSERT(this->m_basis_heading[j] >= 0);
         unsigned i = static_cast<unsigned>(this->m_basis_heading[j]);
         for (const row_cell<T> & rc : this->m_A.m_rows[i]) {
             unsigned k = rc.m_j;
@@ -943,10 +958,10 @@ public:
                                   upper_bound_values),
         m_beta(A.row_count()),
         m_converted_harris_eps(convert_struct<T, double>::convert(this->m_settings.harris_feasibility_tolerance)) {
-        lean_assert(initial_x_is_correct());
+        SASSERT(initial_x_is_correct());
         m_low_bounds_dummy.resize(A.column_count(), zero_of_type<T>());
         m_enter_price_eps = numeric_traits<T>::precise() ? numeric_traits<T>::zero() : T(1e-5);
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
         // check_correctness();
 #endif
     }
diff --git a/src/util/lp/lp_primal_core_solver.hpp b/src/util/lp/lp_primal_core_solver.hpp
index 969d56812..5f81def51 100644
--- a/src/util/lp/lp_primal_core_solver.hpp
+++ b/src/util/lp/lp_primal_core_solver.hpp
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <list>
 #include "util/vector.h"
 #include <fstream>
@@ -9,13 +24,13 @@
 #include <set>
 #include <string>
 #include "util/lp/lp_primal_core_solver.h"
-namespace lean {
+namespace lp {
 // This core solver solves (Ax=b, low_bound_values \leq x \leq upper_bound_values, maximize costs*x )
 // The right side b is given implicitly by x and the basis
 
 template <typename T, typename X>
 void lp_primal_core_solver<T, X>::sort_non_basis_rational() {
-    lean_assert(numeric_traits<T>::precise());
+    SASSERT(numeric_traits<T>::precise());
     if (this->m_settings.use_tableau()) {
         std::sort(this->m_nbasis.begin(), this->m_nbasis.end(), [this](unsigned a, unsigned b) {
                 unsigned ca = this->m_A.number_of_non_zeroes_in_column(a);
@@ -70,11 +85,11 @@ bool lp_primal_core_solver<T, X>::column_is_benefitial_for_entering_on_breakpoin
     const T & d = this->m_d[j];
     switch (this->m_column_types[j]) {
     case column_type::low_bound:
-        lean_assert(this->x_is_at_low_bound(j));
+        SASSERT(this->x_is_at_low_bound(j));
         ret = d < -m_epsilon_of_reduced_cost;
         break;
     case column_type::upper_bound:
-        lean_assert(this->x_is_at_upper_bound(j));
+        SASSERT(this->x_is_at_upper_bound(j));
         ret = d > m_epsilon_of_reduced_cost;
         break;
     case column_type::fixed:
@@ -83,7 +98,7 @@ bool lp_primal_core_solver<T, X>::column_is_benefitial_for_entering_on_breakpoin
     case column_type::boxed:
         {
             bool low_bound = this->x_is_at_low_bound(j);
-            lean_assert(low_bound || this->x_is_at_upper_bound(j));
+            SASSERT(low_bound || this->x_is_at_upper_bound(j));
             ret = (low_bound && d < -m_epsilon_of_reduced_cost) || ((!low_bound) && d > m_epsilon_of_reduced_cost);
         }
         break;
@@ -91,7 +106,7 @@ bool lp_primal_core_solver<T, X>::column_is_benefitial_for_entering_on_breakpoin
         ret = d > m_epsilon_of_reduced_cost || d < - m_epsilon_of_reduced_cost;
         break;
     default:
-        lean_unreachable();
+        SASSERT(false);
         ret = false;
         break;
     }
@@ -127,14 +142,14 @@ bool lp_primal_core_solver<T, X>::column_is_benefitial_for_entering_basis(unsign
         }
         break;
     default:
-        lean_unreachable();
+        SASSERT(false);
         break;
     }
     return false;
 }
 template <typename T, typename X>
 bool lp_primal_core_solver<T, X>::column_is_benefitial_for_entering_basis_precise(unsigned j) const {
-    lean_assert (numeric_traits<T>::precise());
+    SASSERT (numeric_traits<T>::precise());
     if (this->m_using_infeas_costs && this->m_settings.use_breakpoints_in_feasibility_search)
         return column_is_benefitial_for_entering_on_breakpoints(j);
     const T& dj = this->m_d[j];
@@ -167,7 +182,7 @@ bool lp_primal_core_solver<T, X>::column_is_benefitial_for_entering_basis_precis
         }
         break;
     default:
-        lean_unreachable();
+        SASSERT(false);
         break;
     }
     return false;
@@ -175,7 +190,7 @@ bool lp_primal_core_solver<T, X>::column_is_benefitial_for_entering_basis_precis
 
 template <typename T, typename X>
 int lp_primal_core_solver<T, X>::choose_entering_column_presize(unsigned number_of_benefitial_columns_to_go_over) { // at this moment m_y = cB * B(-1)
-    lean_assert(numeric_traits<T>::precise());
+    SASSERT(numeric_traits<T>::precise());
     if (number_of_benefitial_columns_to_go_over == 0)
         return -1;
     if (this->m_basis_sort_counter == 0) {
@@ -259,7 +274,7 @@ int lp_primal_core_solver<T, X>::choose_entering_column(unsigned number_of_benef
 template <typename T, typename X> int lp_primal_core_solver<T, X>::advance_on_sorted_breakpoints(unsigned entering, X &t) {
     T slope_at_entering = this->m_d[entering];
     breakpoint<X> * last_bp = nullptr;
-    lean_assert(m_breakpoint_indices_queue.is_empty()==false);
+    SASSERT(m_breakpoint_indices_queue.is_empty()==false);
     while (m_breakpoint_indices_queue.is_empty() == false) {
         unsigned bi = m_breakpoint_indices_queue.dequeue();
         breakpoint<X> *b = &m_breakpoints[bi];
@@ -274,7 +289,7 @@ template <typename T, typename X> int lp_primal_core_solver<T, X>::advance_on_so
             }
         }        
     }
-    lean_assert (last_bp != nullptr);
+    SASSERT (last_bp != nullptr);
     t = last_bp->m_delta;
     return last_bp->m_j;
 }
@@ -282,13 +297,13 @@ template <typename T, typename X> int lp_primal_core_solver<T, X>::advance_on_so
 
 template <typename T, typename X> int
 lp_primal_core_solver<T, X>::find_leaving_and_t_with_breakpoints(unsigned entering, X & t){
-    lean_assert(this->precise() == false);
+    SASSERT(this->precise() == false);
     fill_breakpoints_array(entering);
     return advance_on_sorted_breakpoints(entering, t);
 }
 
 template <typename T, typename X> bool lp_primal_core_solver<T, X>::get_harris_theta(X & theta) {
-    lean_assert(this->m_ed.is_OK());
+    SASSERT(this->m_ed.is_OK());
     bool unlimited = true;
     for (unsigned i : this->m_ed.m_index) {
         if (this->m_settings.abs_val_is_smaller_than_pivot_tolerance(this->m_ed[i])) continue;
@@ -345,13 +360,13 @@ template <typename T, typename X> bool lp_primal_core_solver<T, X>::try_jump_to_
             if (m_sign_of_entering_delta > 0) {
                 t = this->m_upper_bounds[entering] - this->m_x[entering];
                 if (unlimited || t <= theta){
-                    lean_assert(t >= zero_of_type<X>());
+                    SASSERT(t >= zero_of_type<X>());
                     return true;
                 }
             } else { // m_sign_of_entering_delta == -1
                 t = this->m_x[entering] - this->m_low_bounds[entering];
                 if (unlimited || t <= theta) {
-                    lean_assert(t >= zero_of_type<X>());
+                    SASSERT(t >= zero_of_type<X>());
                     return true;
                 }
             }
@@ -360,7 +375,7 @@ template <typename T, typename X> bool lp_primal_core_solver<T, X>::try_jump_to_
         if (m_sign_of_entering_delta > 0) {
             t = this->m_upper_bounds[entering] - this->m_x[entering];
             if (unlimited || t <= theta){
-                lean_assert(t >= zero_of_type<X>());
+                SASSERT(t >= zero_of_type<X>());
                 return true;
             }
         }
@@ -369,7 +384,7 @@ template <typename T, typename X> bool lp_primal_core_solver<T, X>::try_jump_to_
         if (m_sign_of_entering_delta < 0) {
                 t = this->m_x[entering] - this->m_low_bounds[entering];
                 if (unlimited || t <= theta) {
-                    lean_assert(t >= zero_of_type<X>());
+                    SASSERT(t >= zero_of_type<X>());
                     return true;
                 }
         }
@@ -405,7 +420,7 @@ template <typename T, typename X> int lp_primal_core_solver<T, X>::find_leaving_
     do {
         unsigned i = this->m_ed.m_index[k];
         const T & ed = this->m_ed[i];
-        lean_assert(!numeric_traits<T>::is_zero(ed));
+        SASSERT(!numeric_traits<T>::is_zero(ed));
         unsigned j = this->m_basis[i];
         limit_theta_on_basis_column(j, - ed * m_sign_of_entering_delta, t, unlimited);
         if (!unlimited) {
@@ -424,7 +439,7 @@ template <typename T, typename X> int lp_primal_core_solver<T, X>::find_leaving_
     while (k != initial_k) {
         unsigned i = this->m_ed.m_index[k];
         const T & ed = this->m_ed[i];
-        lean_assert(!numeric_traits<T>::is_zero(ed));
+        SASSERT(!numeric_traits<T>::is_zero(ed));
         unsigned j = this->m_basis[i];
         unlimited = true;
         limit_theta_on_basis_column(j, -ed * m_sign_of_entering_delta, ratio, unlimited);
@@ -464,7 +479,7 @@ template <typename T, typename X>    int lp_primal_core_solver<T, X>::find_leavi
         return find_leaving_and_t_with_breakpoints(entering, t);
     X theta;
     bool unlimited = get_harris_theta(theta);
-    lean_assert(unlimited || theta >= zero_of_type<X>());
+    SASSERT(unlimited || theta >= zero_of_type<X>());
     if (try_jump_to_another_bound_on_entering(entering, theta, t, unlimited)) return entering;
     if (unlimited)
         return -1;
@@ -529,11 +544,11 @@ template <typename T, typename X>    X lp_primal_core_solver<T, X>::get_max_boun
     return ret;
 }
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template <typename T, typename X>   void lp_primal_core_solver<T, X>::check_Ax_equal_b() {
     dense_matrix<T, X> d(this->m_A);
     T * ls = d.apply_from_left_with_different_dims(this->m_x);
-    lean_assert(vectors_are_equal<T>(ls, this->m_b, this->m_m()));
+    SASSERT(vectors_are_equal<T>(ls, this->m_b, this->m_m()));
     delete [] ls;
 }
 template <typename T, typename X>    void lp_primal_core_solver<T, X>::check_the_bounds() {
@@ -543,8 +558,8 @@ template <typename T, typename X>    void lp_primal_core_solver<T, X>::check_the
 }
 
 template <typename T, typename X>    void lp_primal_core_solver<T, X>::check_bound(unsigned i) {
-    lean_assert (!(this->column_has_low_bound(i) && (numeric_traits<T>::zero() > this->m_x[i])));
-    lean_assert (!(this->column_has_upper_bound(i) && (this->m_upper_bounds[i] < this->m_x[i])));
+    SASSERT (!(this->column_has_low_bound(i) && (numeric_traits<T>::zero() > this->m_x[i])));
+    SASSERT (!(this->column_has_upper_bound(i) && (this->m_upper_bounds[i] < this->m_x[i])));
 }
 
 template <typename T, typename X>    void lp_primal_core_solver<T, X>::check_correctness() {
@@ -558,10 +573,10 @@ template <typename T, typename X>    void lp_primal_core_solver<T, X>::check_cor
 template <typename T, typename X>
 void lp_primal_core_solver<T, X>::update_reduced_costs_from_pivot_row(unsigned entering, unsigned leaving) {
     // the basis heading has changed already
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     auto & basis_heading = this->m_basis_heading;
-    lean_assert(basis_heading[entering] >= 0 && static_cast<unsigned>(basis_heading[entering]) < this->m_m());
-    lean_assert(basis_heading[leaving] < 0);
+    SASSERT(basis_heading[entering] >= 0 && static_cast<unsigned>(basis_heading[entering]) < this->m_m());
+    SASSERT(basis_heading[leaving] < 0);
 #endif
     T pivot = this->m_pivot_row[entering];
     T dq = this->m_d[entering]/pivot;
@@ -584,7 +599,7 @@ void lp_primal_core_solver<T, X>::update_reduced_costs_from_pivot_row(unsigned e
 template <typename T, typename X>    int lp_primal_core_solver<T, X>::refresh_reduced_cost_at_entering_and_check_that_it_is_off(unsigned entering) {
     if (numeric_traits<T>::precise()) return 0;
     T reduced_at_entering_was = this->m_d[entering];  // can benefit from going over non-zeros of m_ed
-    lean_assert(abs(reduced_at_entering_was) > m_epsilon_of_reduced_cost);
+    SASSERT(abs(reduced_at_entering_was) > m_epsilon_of_reduced_cost);
     T refreshed_cost = this->m_costs[entering];
     unsigned i = this->m_m();
     while (i--) refreshed_cost -= this->m_costs[this->m_basis[i]] * this->m_ed[i];
@@ -619,7 +634,7 @@ template <typename T, typename X>    void lp_primal_core_solver<T, X>::backup_an
         m_costs_backup = this->m_costs;
     } else {
         T cost_max = std::max(max_abs_in_vector(this->m_costs), T(1));
-        lean_assert(m_costs_backup.size() == 0);
+        SASSERT(m_costs_backup.size() == 0);
         for (unsigned j = 0; j < this->m_costs.size(); j++)
             m_costs_backup.push_back(this->m_costs[j] /= cost_max);
     }
@@ -649,16 +664,16 @@ template <typename T, typename X>    void lp_primal_core_solver<T, X>::init_run(
 
 
 template <typename T, typename X>    void lp_primal_core_solver<T, X>::calc_working_vector_beta_for_column_norms(){
-    lean_assert(numeric_traits<T>::precise() == false);
-    lean_assert(this->m_ed.is_OK());
-    lean_assert(m_beta.is_OK());
+    SASSERT(numeric_traits<T>::precise() == false);
+    SASSERT(this->m_ed.is_OK());
+    SASSERT(m_beta.is_OK());
     m_beta = this->m_ed;
     this->m_factorization->solve_yB_with_error_check_indexed(m_beta, this->m_basis_heading, this->m_basis, this->m_settings);
 }
 
 template <typename T, typename X>
 void lp_primal_core_solver<T, X>::advance_on_entering_equal_leaving(int entering, X & t) {
-    lean_assert(!this->A_mult_x_is_off() );
+    SASSERT(!this->A_mult_x_is_off() );
     this->update_x(entering, t * m_sign_of_entering_delta);
     if (this->A_mult_x_is_off_on_index(this->m_ed.m_index) && !this->find_x_by_solving()) {
         this->init_lu();
@@ -670,7 +685,7 @@ void lp_primal_core_solver<T, X>::advance_on_entering_equal_leaving(int entering
         }
     }
     if (this->m_using_infeas_costs) {
-        lean_assert(is_zero(this->m_costs[entering])); 
+        SASSERT(is_zero(this->m_costs[entering])); 
         init_infeasibility_costs_for_changed_basis_only();
     }
     if (this->m_look_for_feasible_solution_only && this->current_x_is_feasible())
@@ -683,10 +698,10 @@ void lp_primal_core_solver<T, X>::advance_on_entering_equal_leaving(int entering
 }
 
 template <typename T, typename X>void lp_primal_core_solver<T, X>::advance_on_entering_and_leaving(int entering, int leaving, X & t) {
-    lean_assert(entering >= 0 && m_non_basis_list.back() == static_cast<unsigned>(entering));
-    lean_assert(this->m_using_infeas_costs || t >= zero_of_type<X>());
-    lean_assert(leaving >= 0 && entering >= 0);
-    lean_assert(entering != leaving || !is_zero(t)); // otherwise nothing changes
+    SASSERT(entering >= 0 && m_non_basis_list.back() == static_cast<unsigned>(entering));
+    SASSERT(this->m_using_infeas_costs || t >= zero_of_type<X>());
+    SASSERT(leaving >= 0 && entering >= 0);
+    SASSERT(entering != leaving || !is_zero(t)); // otherwise nothing changes
     if (entering == leaving) {
         advance_on_entering_equal_leaving(entering, t);
         return;
@@ -702,7 +717,7 @@ template <typename T, typename X>void lp_primal_core_solver<T, X>::advance_on_en
         this->iters_with_no_cost_growing()++;
         return;
     } else {
-        lean_assert(pivot_compare_result == 1);
+        SASSERT(pivot_compare_result == 1);
         this->init_lu();
         if (this->m_factorization == nullptr || this->m_factorization->get_status() != LU_status::OK) {
             this->set_status(UNSTABLE);
@@ -746,7 +761,7 @@ template <typename T, typename X>void lp_primal_core_solver<T, X>::advance_on_en
     }  else {
         update_reduced_costs_from_pivot_row(entering, leaving);
     }
-    lean_assert(!need_to_switch_costs());
+    SASSERT(!need_to_switch_costs());
     std::list<unsigned>::iterator it = m_non_basis_list.end();
     it--;
     * it = static_cast<unsigned>(leaving);
@@ -754,8 +769,8 @@ template <typename T, typename X>void lp_primal_core_solver<T, X>::advance_on_en
 
 
 template <typename T, typename X> void lp_primal_core_solver<T, X>::advance_on_entering_precise(int entering) {
-    lean_assert(numeric_traits<T>::precise());
-    lean_assert(entering > -1);
+    SASSERT(numeric_traits<T>::precise());
+    SASSERT(entering > -1);
     this->solve_Bd(entering);
     X t;
     int leaving = find_leaving_and_t_precise(entering, t);
@@ -771,7 +786,7 @@ template <typename T, typename X> void lp_primal_core_solver<T, X>::advance_on_e
         advance_on_entering_precise(entering);
         return;
     }
-    lean_assert(entering > -1);
+    SASSERT(entering > -1);
     this->solve_Bd(entering);
     int refresh_result = refresh_reduced_cost_at_entering_and_check_that_it_is_off(entering);
     if (refresh_result) {
@@ -791,7 +806,7 @@ template <typename T, typename X> void lp_primal_core_solver<T, X>::advance_on_e
     int leaving = find_leaving_and_t(entering, t);
     if (leaving == -1){
         if (!this->current_x_is_feasible()) {
-            lean_assert(!numeric_traits<T>::precise()); // we cannot have unbounded with inf costs
+            SASSERT(!numeric_traits<T>::precise()); // we cannot have unbounded with inf costs
                
             // if (m_look_for_feasible_solution_only) {
             //     this->m_status = INFEASIBLE;
@@ -865,7 +880,7 @@ template <typename T, typename X> unsigned lp_primal_core_solver<T, X>::solve()
             return this->total_iterations();
         }
         one_iteration();
-        lean_assert(!this->m_using_infeas_costs || this->costs_on_nbasis_are_zeros());
+        SASSERT(!this->m_using_infeas_costs || this->costs_on_nbasis_are_zeros());
         switch (this->get_status()) {
         case OPTIMAL:  // double check that we are at optimum
         case INFEASIBLE:
@@ -914,7 +929,7 @@ template <typename T, typename X> unsigned lp_primal_core_solver<T, X>::solve()
             break;
 
         case UNSTABLE:
-            lean_assert(! (numeric_traits<T>::precise()));
+            SASSERT(! (numeric_traits<T>::precise()));
             this->init_lu();
             if (this->m_factorization->get_status() != LU_status::OK) {
                 this->set_status(FLOATING_POINT_ERROR);
@@ -940,7 +955,7 @@ template <typename T, typename X> unsigned lp_primal_core_solver<T, X>::solve()
              &&
              !(this->current_x_is_feasible() && this->m_look_for_feasible_solution_only));
 
-    lean_assert(this->get_status() == FLOATING_POINT_ERROR
+    SASSERT(this->get_status() == FLOATING_POINT_ERROR
                 ||
                 this->current_x_is_feasible() == false
                 ||
@@ -957,7 +972,7 @@ template <typename T, typename X>    void lp_primal_core_solver<T, X>::delete_fa
 
 // according to Swietanowski, " A new steepest edge approximation for the simplex method for linear programming"
 template <typename T, typename X> void lp_primal_core_solver<T, X>::init_column_norms() {
-    lean_assert(numeric_traits<T>::precise() == false);
+    SASSERT(numeric_traits<T>::precise() == false);
     for (unsigned j = 0; j < this->m_n(); j++) {
         this->m_column_norms[j] = T(static_cast<int>(this->m_A.m_columns[j].size() + 1)) 
             
@@ -967,7 +982,7 @@ template <typename T, typename X> void lp_primal_core_solver<T, X>::init_column_
 
 // debug only
 template <typename T, typename X> T lp_primal_core_solver<T, X>::calculate_column_norm_exactly(unsigned j) {
-    lean_assert(numeric_traits<T>::precise() == false);
+    SASSERT(numeric_traits<T>::precise() == false);
     indexed_vector<T> w(this->m_m());
     this->m_A.copy_column_to_vector(j, w);
     vector<T> d(this->m_m());
@@ -979,8 +994,8 @@ template <typename T, typename X> T lp_primal_core_solver<T, X>::calculate_colum
 }
 
 template <typename T, typename X>    void lp_primal_core_solver<T, X>::update_or_init_column_norms(unsigned entering, unsigned leaving) {
-    lean_assert(numeric_traits<T>::precise() == false);
-    lean_assert(m_column_norm_update_counter <= this->m_settings.column_norms_update_frequency);
+    SASSERT(numeric_traits<T>::precise() == false);
+    SASSERT(m_column_norm_update_counter <= this->m_settings.column_norms_update_frequency);
     if (m_column_norm_update_counter == this->m_settings.column_norms_update_frequency) {
         m_column_norm_update_counter = 0;
         init_column_norms();
@@ -992,7 +1007,7 @@ template <typename T, typename X>    void lp_primal_core_solver<T, X>::update_or
 
 // following Swietanowski - A new steepest ...
 template <typename T, typename X>    void lp_primal_core_solver<T, X>::update_column_norms(unsigned entering, unsigned leaving) {
-    lean_assert(numeric_traits<T>::precise() == false);
+    SASSERT(numeric_traits<T>::precise() == false);
     T pivot = this->m_pivot_row[entering];
     T g_ent = calculate_norm_of_entering_exactly() / pivot / pivot;
     if (!numeric_traits<T>::precise()) {
@@ -1027,7 +1042,7 @@ template <typename T, typename X>    T lp_primal_core_solver<T, X>::calculate_no
 // calling it stage1 is too cryptic
 template <typename T, typename X>    void lp_primal_core_solver<T, X>::find_feasible_solution() {
     this->m_look_for_feasible_solution_only = true;
-    lean_assert(this->non_basic_columns_are_set_correctly());
+    SASSERT(this->non_basic_columns_are_set_correctly());
     this->set_status(UNKNOWN);
     solve();
 }
@@ -1095,8 +1110,8 @@ void lp_primal_core_solver<T, X>::init_infeasibility_costs_for_changed_basis_onl
 
 template <typename T, typename X>
 void lp_primal_core_solver<T, X>::init_infeasibility_costs() {
-    lean_assert(this->m_x.size() >= this->m_n());
-    lean_assert(this->m_column_types.size() >= this->m_n());
+    SASSERT(this->m_x.size() >= this->m_n());
+    SASSERT(this->m_column_types.size() >= this->m_n());
     for (unsigned j = this->m_n(); j--;)
         init_infeasibility_cost_for_column(j);
     this->m_using_infeas_costs = true;
@@ -1138,7 +1153,7 @@ lp_primal_core_solver<T, X>::get_infeasibility_cost_for_column(unsigned j) const
         ret = numeric_traits<T>::zero();
         break;
     default:
-        lean_assert(false);
+        SASSERT(false);
         ret = numeric_traits<T>::zero(); // does not matter
         break;
     }
@@ -1192,7 +1207,7 @@ lp_primal_core_solver<T, X>::init_infeasibility_cost_for_column(unsigned j) {
         this->m_costs[j] = numeric_traits<T>::zero();
         break;
     default:
-        lean_assert(false);
+        SASSERT(false);
         break;
     }
     
@@ -1223,7 +1238,7 @@ template <typename T, typename X> void lp_primal_core_solver<T, X>::print_column
     case column_type::free_column:
         out << "( _" << this->m_x[j] << "_)" << std::endl;
     default:
-        lean_unreachable();
+        SASSERT(false);
     }
 }
 
@@ -1262,7 +1277,7 @@ template <typename T, typename X> std::string lp_primal_core_solver<T, X>::break
     case upper_break: return "upper_break";
     case fixed_break: return "fixed_break";
     default:
-        lean_assert(false);
+        SASSERT(false);
         break;
     }
     return "type is not found";
@@ -1275,7 +1290,7 @@ template <typename T, typename X> void lp_primal_core_solver<T, X>::print_breakp
 
 template <typename T, typename X>
 void lp_primal_core_solver<T, X>::init_reduced_costs() {
-    lean_assert(!this->use_tableau());
+    SASSERT(!this->use_tableau());
     if (this->current_x_is_infeasible() && !this->m_using_infeas_costs) {
         init_infeasibility_costs();
     } else if (this->current_x_is_feasible() && this->m_using_infeas_costs) {
@@ -1290,12 +1305,12 @@ void lp_primal_core_solver<T, X>::init_reduced_costs() {
 
 template <typename T, typename X>    void lp_primal_core_solver<T, X>::change_slope_on_breakpoint(unsigned entering, breakpoint<X> * b, T & slope_at_entering) {
     if (b->m_j == entering) {
-        lean_assert(b->m_type != fixed_break && (!is_zero(b->m_delta)));
+        SASSERT(b->m_type != fixed_break && (!is_zero(b->m_delta)));
         slope_at_entering += m_sign_of_entering_delta;
         return;
     }
 
-    lean_assert(this->m_basis_heading[b->m_j] >= 0);
+    SASSERT(this->m_basis_heading[b->m_j] >= 0);
     unsigned i_row = this->m_basis_heading[b->m_j];
     const T & d = - this->m_ed[i_row];
     if (numeric_traits<T>::is_zero(d)) return;
@@ -1314,13 +1329,13 @@ template <typename T, typename X>    void lp_primal_core_solver<T, X>::change_sl
         slope_at_entering += delta;
         break;
     default:
-        lean_assert(false);
+        SASSERT(false);
     }
 }
 
 
 template <typename T, typename X>    void lp_primal_core_solver<T, X>::try_add_breakpoint_in_row(unsigned i) {
-    lean_assert(i < this->m_m());
+    SASSERT(i < this->m_m());
     const T & d = this->m_ed[i]; // the coefficient before m_entering in the i-th row
     if (d == 0) return; // the change of x[m_entering] will not change the corresponding basis x
     unsigned j = this->m_basis[i];
@@ -1342,7 +1357,7 @@ template <typename T, typename X>    void lp_primal_core_solver<T, X>::try_add_b
     case column_type::free_column:
         break;
     default:
-        lean_assert(false);
+        SASSERT(false);
         break;
     }
 }
@@ -1366,7 +1381,7 @@ template <typename T, typename X> void lp_primal_core_solver<T, X>::print_bound_
         out << "inf, inf" << std::endl;
         break;
     default:
-        lean_assert(false);
+        SASSERT(false);
         break;
     }
 }
diff --git a/src/util/lp/lp_primal_core_solver_instances.cpp b/src/util/lp/lp_primal_core_solver_instances.cpp
index ca231fd34..fd5f42d67 100644
--- a/src/util/lp/lp_primal_core_solver_instances.cpp
+++ b/src/util/lp/lp_primal_core_solver_instances.cpp
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <utility>
 #include <memory>
 #include <string>
@@ -9,19 +24,19 @@
 #include <functional>
 #include "util/lp/lar_solver.h"
 #include "util/lp/lp_primal_core_solver.hpp"
-#include "util/lp/lp_primal_core_solver_tableau.hpp"
-namespace lean {
+#include "util/lp/lp_primal_core_solver_tableau.h"
+namespace lp {
 
 template void lp_primal_core_solver<double, double>::find_feasible_solution();
-template void lean::lp_primal_core_solver<lean::mpq, lean::numeric_pair<lean::mpq> >::find_feasible_solution();
+template void lp::lp_primal_core_solver<lp::mpq, lp::numeric_pair<lp::mpq> >::find_feasible_solution();
 
 template unsigned lp_primal_core_solver<double, double>::solve();
 template unsigned lp_primal_core_solver<double, double>::solve_with_tableau();
 template unsigned lp_primal_core_solver<mpq, mpq>::solve();
 template unsigned lp_primal_core_solver<mpq, numeric_pair<mpq> >::solve();
-template void lean::lp_primal_core_solver<double, double>::clear_breakpoints();
-template bool lean::lp_primal_core_solver<lean::mpq, lean::mpq>::update_basis_and_x_tableau(int, int, lean::mpq const&);
-template bool lean::lp_primal_core_solver<double, double>::update_basis_and_x_tableau(int, int, double const&);
-template bool lean::lp_primal_core_solver<lean::mpq, lean::numeric_pair<lean::mpq> >::update_basis_and_x_tableau(int, int, lean::numeric_pair<lean::mpq> const&);
+template void lp::lp_primal_core_solver<double, double>::clear_breakpoints();
+template bool lp::lp_primal_core_solver<lp::mpq, lp::mpq>::update_basis_and_x_tableau(int, int, lp::mpq const&);
+template bool lp::lp_primal_core_solver<double, double>::update_basis_and_x_tableau(int, int, double const&);
+template bool lp::lp_primal_core_solver<lp::mpq, lp::numeric_pair<lp::mpq> >::update_basis_and_x_tableau(int, int, lp::numeric_pair<lp::mpq> const&);
 
 }
diff --git a/src/util/lp/lp_primal_core_solver_tableau.hpp b/src/util/lp/lp_primal_core_solver_tableau.h
similarity index 90%
rename from src/util/lp/lp_primal_core_solver_tableau.hpp
rename to src/util/lp/lp_primal_core_solver_tableau.h
index 0c09c22c9..97fa2f9da 100644
--- a/src/util/lp/lp_primal_core_solver_tableau.hpp
+++ b/src/util/lp/lp_primal_core_solver_tableau.h
@@ -1,10 +1,25 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 // this is a part of lp_primal_core_solver that deals with the tableau
 #include "util/lp/lp_primal_core_solver.h"
-namespace lean {
+namespace lp {
 template <typename T, typename X> void lp_primal_core_solver<T, X>::one_iteration_tableau() {
     int entering = choose_entering_column_tableau();
     if (entering == -1) {
@@ -13,7 +28,7 @@ template <typename T, typename X> void lp_primal_core_solver<T, X>::one_iteratio
     else {
         advance_on_entering_tableau(entering);
     }
-    lean_assert(this->inf_set_is_correct());
+    SASSERT(this->inf_set_is_correct());
 }
 
 template <typename T, typename X> void lp_primal_core_solver<T, X>::advance_on_entering_tableau(int entering) {
@@ -37,7 +52,7 @@ template <typename T, typename X> int lp_primal_core_solver<T, X>::choose_enteri
     //this moment m_y = cB * B(-1)
     unsigned number_of_benefitial_columns_to_go_over =  get_number_of_non_basic_column_to_try_for_enter();
     
-    lean_assert(numeric_traits<T>::precise());
+    SASSERT(numeric_traits<T>::precise());
     if (number_of_benefitial_columns_to_go_over == 0)
         return -1;
     if (this->m_basis_sort_counter == 0) {
@@ -149,7 +164,7 @@ unsigned lp_primal_core_solver<T, X>::solve_with_tableau() {
             break;
 
         case UNSTABLE:
-            lean_assert(! (numeric_traits<T>::precise()));
+            SASSERT(! (numeric_traits<T>::precise()));
             this->init_lu();
             if (this->m_factorization->get_status() != LU_status::OK) {
                 this->set_status(FLOATING_POINT_ERROR);
@@ -175,7 +190,7 @@ unsigned lp_primal_core_solver<T, X>::solve_with_tableau() {
              &&
              !(this->current_x_is_feasible() && this->m_look_for_feasible_solution_only));
 
-    lean_assert(this->get_status() == FLOATING_POINT_ERROR
+    SASSERT(this->get_status() == FLOATING_POINT_ERROR
                 ||
                 this->current_x_is_feasible() == false
                 ||
@@ -184,13 +199,13 @@ unsigned lp_primal_core_solver<T, X>::solve_with_tableau() {
 
 }
 template <typename T, typename X>void lp_primal_core_solver<T, X>::advance_on_entering_and_leaving_tableau(int entering, int leaving, X & t) {
-    lean_assert(this->A_mult_x_is_off() == false);
-    lean_assert(leaving >= 0 && entering >= 0);
-    lean_assert((this->m_settings.simplex_strategy() ==
+    SASSERT(this->A_mult_x_is_off() == false);
+    SASSERT(leaving >= 0 && entering >= 0);
+    SASSERT((this->m_settings.simplex_strategy() ==
                 simplex_strategy_enum::tableau_rows) ||
                 m_non_basis_list.back() == static_cast<unsigned>(entering));
-    lean_assert(this->m_using_infeas_costs || !is_neg(t));
-    lean_assert(entering != leaving || !is_zero(t)); // otherwise nothing changes
+    SASSERT(this->m_using_infeas_costs || !is_neg(t));
+    SASSERT(entering != leaving || !is_zero(t)); // otherwise nothing changes
     if (entering == leaving) {
         advance_on_entering_equal_leaving_tableau(entering, t);
         return;
@@ -201,7 +216,7 @@ template <typename T, typename X>void lp_primal_core_solver<T, X>::advance_on_en
                 t = -t;
         }
         this->update_basis_and_x_tableau(entering, leaving, t);
-        lean_assert(this->A_mult_x_is_off() == false);
+        SASSERT(this->A_mult_x_is_off() == false);
         this->iters_with_no_cost_growing() = 0;
     } else {
         this->pivot_column_tableau(entering, this->m_basis_heading[leaving]);
@@ -216,7 +231,7 @@ template <typename T, typename X>void lp_primal_core_solver<T, X>::advance_on_en
             this->init_reduced_costs_tableau();
         }
         
-        lean_assert(!need_to_switch_costs());
+        SASSERT(!need_to_switch_costs());
         std::list<unsigned>::iterator it = m_non_basis_list.end();
         it--;
         * it = static_cast<unsigned>(leaving);
@@ -225,7 +240,7 @@ template <typename T, typename X>void lp_primal_core_solver<T, X>::advance_on_en
 
 template <typename T, typename X>
 void lp_primal_core_solver<T, X>::advance_on_entering_equal_leaving_tableau(int entering, X & t) {
-    lean_assert(!this->A_mult_x_is_off() );
+    SASSERT(!this->A_mult_x_is_off() );
     this->update_x_tableau(entering, t * m_sign_of_entering_delta); 
     if (this->m_look_for_feasible_solution_only && this->current_x_is_feasible())
         return;
@@ -246,7 +261,7 @@ template <typename T, typename X> int lp_primal_core_solver<T, X>::find_leaving_
         const column_cell & c = col[k];
         unsigned i = c.m_i;
         const T & ed = this->m_A.get_val(c);
-        lean_assert(!numeric_traits<T>::is_zero(ed));
+        SASSERT(!numeric_traits<T>::is_zero(ed));
         unsigned j = this->m_basis[i];
         limit_theta_on_basis_column(j, - ed * m_sign_of_entering_delta, t, unlimited);
         if (!unlimited) {
@@ -265,7 +280,7 @@ template <typename T, typename X> int lp_primal_core_solver<T, X>::find_leaving_
         const column_cell & c = col[k];
         unsigned i = c.m_i;
         const T & ed = this->m_A.get_val(c);
-         lean_assert(!numeric_traits<T>::is_zero(ed));
+         SASSERT(!numeric_traits<T>::is_zero(ed));
         unsigned j = this->m_basis[i];
         unlimited = true;
         limit_theta_on_basis_column(j, -ed * m_sign_of_entering_delta, ratio, unlimited);
@@ -298,12 +313,12 @@ template <typename T, typename X> int lp_primal_core_solver<T, X>::find_leaving_
 }
 template <typename T, typename X> void lp_primal_core_solver<T, X>::init_run_tableau() {
         //        print_matrix(&(this->m_A), std::cout);
-        lean_assert(this->A_mult_x_is_off() == false);
-        lean_assert(basis_columns_are_set_correctly());
+        SASSERT(this->A_mult_x_is_off() == false);
+        SASSERT(basis_columns_are_set_correctly());
         this->m_basis_sort_counter = 0; // to initiate the sort of the basis
         this->set_total_iterations(0);
         this->iters_with_no_cost_growing() = 0;
-		lean_assert(this->inf_set_is_correct());
+		SASSERT(this->inf_set_is_correct());
         if (this->current_x_is_feasible() && this->m_look_for_feasible_solution_only)
             return;
         if (this->m_settings.backup_costs)
@@ -317,13 +332,13 @@ template <typename T, typename X> void lp_primal_core_solver<T, X>::init_run_tab
         }
         if (this->m_settings.simplex_strategy() == simplex_strategy_enum::tableau_rows)
             init_tableau_rows();
-        lean_assert(this->reduced_costs_are_correct_tableau());
-        lean_assert(!this->need_to_pivot_to_basis_tableau());
+        SASSERT(this->reduced_costs_are_correct_tableau());
+        SASSERT(!this->need_to_pivot_to_basis_tableau());
 }
 
 template <typename T, typename X> bool lp_primal_core_solver<T, X>::
 update_basis_and_x_tableau(int entering, int leaving, X const & tt) {
-    lean_assert(this->use_tableau());
+    SASSERT(this->use_tableau());
     update_x_tableau(entering, tt);
     this->pivot_column_tableau(entering, this->m_basis_heading[leaving]);
     this->change_basis(entering, leaving);
@@ -340,8 +355,8 @@ update_x_tableau(unsigned entering, const X& delta) {
         }
     } else { // m_using_infeas_costs == true
         this->m_x[entering] += delta;
-        lean_assert(this->column_is_feasible(entering));
-        lean_assert(this->m_costs[entering] == zero_of_type<T>());
+        SASSERT(this->column_is_feasible(entering));
+        SASSERT(this->m_costs[entering] == zero_of_type<T>());
         // m_d[entering] can change because of the cost change for basic columns.
         for (const auto & c : this->m_A.m_columns[entering]) {
             unsigned i = c.m_i;
@@ -354,13 +369,13 @@ update_x_tableau(unsigned entering, const X& delta) {
                 this->m_inf_set.insert(j);
         }
     }
-    lean_assert(this->A_mult_x_is_off() == false);
+    SASSERT(this->A_mult_x_is_off() == false);
 }
 
 template <typename T, typename X> void lp_primal_core_solver<T, X>::
 update_inf_cost_for_column_tableau(unsigned j) {
-    lean_assert(this->m_settings.simplex_strategy() != simplex_strategy_enum::tableau_rows);
-    lean_assert(this->m_using_infeas_costs);
+    SASSERT(this->m_settings.simplex_strategy() != simplex_strategy_enum::tableau_rows);
+    SASSERT(this->m_using_infeas_costs);
     T new_cost = get_infeasibility_cost_for_column(j);
     T delta = this->m_costs[j] - new_cost;
     if (is_zero(delta))
diff --git a/src/util/lp/lp_primal_simplex.h b/src/util/lp/lp_primal_simplex.h
index 715d76408..d8fd114e4 100644
--- a/src/util/lp/lp_primal_simplex.h
+++ b/src/util/lp/lp_primal_simplex.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include "util/vector.h"
 #include <unordered_map>
@@ -12,7 +27,7 @@
 #include "util/lp/lp_primal_core_solver.h"
 #include "util/lp/lp_solver.h"
 #include "util/lp/iterator_on_row.h"
-namespace lean {
+namespace lp {
 template <typename T, typename X>
 class lp_primal_simplex: public lp_solver<T, X> {
     lp_primal_core_solver<T, X> * m_core_solver;
diff --git a/src/util/lp/lp_primal_simplex.hpp b/src/util/lp/lp_primal_simplex.hpp
index b6b6006e5..fd717ec7f 100644
--- a/src/util/lp/lp_primal_simplex.hpp
+++ b/src/util/lp/lp_primal_simplex.hpp
@@ -1,12 +1,27 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <string>
 #include "util/vector.h"
 #include "util/lp/lp_primal_simplex.h"
 
-namespace lean {
+namespace lp {
 template <typename T, typename X> void lp_primal_simplex<T, X>::fill_costs_and_x_for_first_stage_solver(unsigned original_number_of_columns) {
     unsigned slack_var = original_number_of_columns;
     unsigned artificial = original_number_of_columns + this->m_slacks;
@@ -61,7 +76,7 @@ template <typename T, typename X> void lp_primal_simplex<T, X>::fill_costs_and_x
                                                                                                                 int row,
                                                                                                                 unsigned & slack_var,
                                                                                                                 unsigned & artificial) {
-    lean_assert(row >= 0 && row < this->row_count());
+    SASSERT(row >= 0 && row < this->row_count());
     auto & constraint = this->m_constraints[this->m_core_solver_rows_to_external_rows[row]];
     // we need to bring the program to the form Ax = b
     T rs = this->m_b[row];
@@ -86,7 +101,7 @@ template <typename T, typename X> void lp_primal_simplex<T, X>::fill_costs_and_x
         (*this->m_A)(row, slack_var) = - numeric_traits<T>::one();
 
         if (rs > 0) {
-            lean_assert(numeric_traits<T>::is_zero(this->m_x[slack_var]));
+            SASSERT(numeric_traits<T>::is_zero(this->m_x[slack_var]));
             // adding one artificial
             this->m_column_types[artificial] = column_type::low_bound;
             (*this->m_A)(row, artificial) = numeric_traits<T>::one();
@@ -108,7 +123,7 @@ template <typename T, typename X> void lp_primal_simplex<T, X>::fill_costs_and_x
 
         if (rs < 0) {
             // adding one artificial
-            lean_assert(numeric_traits<T>::is_zero(this->m_x[slack_var]));
+            SASSERT(numeric_traits<T>::is_zero(this->m_x[slack_var]));
             this->m_column_types[artificial] = column_type::low_bound;
             (*this->m_A)(row, artificial) = - numeric_traits<T>::one();
             this->m_costs[artificial] = artificial_cost;
@@ -177,12 +192,12 @@ template <typename T, typename X> void lp_primal_simplex<T, X>::fill_A_x_and_bas
 }
 
 template <typename T, typename X> void lp_primal_simplex<T, X>::fill_A_x_and_basis_for_stage_one_total_inf_for_row(unsigned row) {
-    lean_assert(row < this->row_count());
+    SASSERT(row < this->row_count());
     auto ext_row_it = this->m_core_solver_rows_to_external_rows.find(row);
-    lean_assert(ext_row_it != this->m_core_solver_rows_to_external_rows.end());
+    SASSERT(ext_row_it != this->m_core_solver_rows_to_external_rows.end());
     unsigned ext_row = ext_row_it->second;
     auto constr_it = this->m_constraints.find(ext_row);
-    lean_assert(constr_it != this->m_constraints.end());
+    SASSERT(constr_it != this->m_constraints.end());
     auto & constraint = constr_it->second;
     unsigned j = this->m_A->column_count(); // j is a slack variable
     this->m_A->add_column();
@@ -209,7 +224,7 @@ template <typename T, typename X> void lp_primal_simplex<T, X>::fill_A_x_and_bas
         this->m_upper_bounds[j] = m_low_bounds[j] = zero_of_type<X>();
         break;
     default:
-        lean_unreachable();
+        SASSERT(false);
     }
 }
 
@@ -281,10 +296,10 @@ template <typename T, typename X> T lp_primal_simplex<T, X>::get_row_value(unsig
     T ret = numeric_traits<T>::zero();
     for (auto & pair : it->second) {
         auto cit = this->m_map_from_var_index_to_column_info.find(pair.first);
-        lean_assert(cit != this->m_map_from_var_index_to_column_info.end());
+        SASSERT(cit != this->m_map_from_var_index_to_column_info.end());
         column_info<T> * ci = cit->second;
         auto sol_it = solution.find(ci->get_name());
-        lean_assert(sol_it != solution.end());
+        SASSERT(sol_it != solution.end());
         T column_val = sol_it->second;
         if (out != nullptr) {
             (*out) << pair.second << "(" << ci->get_name() << "=" << column_val << ") ";
@@ -329,7 +344,7 @@ template <typename T, typename X> bool lp_primal_simplex<T, X>::row_constraint_h
         }
         return true;;
     }
-    lean_unreachable();
+    SASSERT(false);
     return false; // it is unreachable
 }
 
diff --git a/src/util/lp/lp_primal_simplex_instances.cpp b/src/util/lp/lp_primal_simplex_instances.cpp
index 37b639489..92e3a77ff 100644
--- a/src/util/lp/lp_primal_simplex_instances.cpp
+++ b/src/util/lp/lp_primal_simplex_instances.cpp
@@ -1,20 +1,35 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <utility>
 #include <memory>
 #include <string>
 #include "util/vector.h"
 #include <functional>
 #include "util/lp/lp_primal_simplex.hpp"
-template bool lean::lp_primal_simplex<double, double>::bounds_hold(std::unordered_map<std::string, double, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, double> > > const&);
-template bool lean::lp_primal_simplex<double, double>::row_constraints_hold(std::unordered_map<std::string, double, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, double> > > const&);
-template double lean::lp_primal_simplex<double, double>::get_current_cost() const;
-template double lean::lp_primal_simplex<double, double>::get_column_value(unsigned int) const;
-template lean::lp_primal_simplex<double, double>::~lp_primal_simplex();
-template lean::lp_primal_simplex<lean::mpq, lean::mpq>::~lp_primal_simplex();
-template lean::mpq lean::lp_primal_simplex<lean::mpq, lean::mpq>::get_current_cost() const;
-template lean::mpq lean::lp_primal_simplex<lean::mpq, lean::mpq>::get_column_value(unsigned int) const;
-template void lean::lp_primal_simplex<double, double>::find_maximal_solution();
-template void lean::lp_primal_simplex<lean::mpq, lean::mpq>::find_maximal_solution();
+template bool lp::lp_primal_simplex<double, double>::bounds_hold(std::unordered_map<std::string, double, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, double> > > const&);
+template bool lp::lp_primal_simplex<double, double>::row_constraints_hold(std::unordered_map<std::string, double, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, double> > > const&);
+template double lp::lp_primal_simplex<double, double>::get_current_cost() const;
+template double lp::lp_primal_simplex<double, double>::get_column_value(unsigned int) const;
+template lp::lp_primal_simplex<double, double>::~lp_primal_simplex();
+template lp::lp_primal_simplex<lp::mpq, lp::mpq>::~lp_primal_simplex();
+template lp::mpq lp::lp_primal_simplex<lp::mpq, lp::mpq>::get_current_cost() const;
+template lp::mpq lp::lp_primal_simplex<lp::mpq, lp::mpq>::get_column_value(unsigned int) const;
+template void lp::lp_primal_simplex<double, double>::find_maximal_solution();
+template void lp::lp_primal_simplex<lp::mpq, lp::mpq>::find_maximal_solution();
diff --git a/src/util/lp/lp_settings.h b/src/util/lp/lp_settings.h
index ad40ad69d..70a9f1504 100644
--- a/src/util/lp/lp_settings.h
+++ b/src/util/lp/lp_settings.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 #include "util/vector.h"
@@ -12,7 +27,7 @@
 #include "util/lp/lp_utils.h"
 #include "util/stopwatch.h"
 
-namespace lean {
+namespace lp {
 typedef unsigned var_index;
 typedef unsigned constraint_index;
 typedef unsigned row_index;
@@ -296,7 +311,7 @@ public:
     unsigned column_norms_update_frequency;
     bool scale_with_ratio;
     double density_threshold; // need to tune it up, todo
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     static unsigned ddd; // used for debugging    
 #endif
     bool use_breakpoints_in_feasibility_search;
@@ -366,7 +381,7 @@ inline void print_blanks(int n, std::ostream & out) {
 // after a push of the last element we ensure that the vector increases
 // we also suppose that before the last push the vector was increasing
 inline void ensure_increasing(vector<unsigned> & v) {
-    lean_assert(v.size() > 0);
+    SASSERT(v.size() > 0);
     unsigned j = v.size() - 1;
     for (; j > 0; j-- )
         if (v[j] <= v[j - 1]) {
@@ -381,7 +396,7 @@ inline void ensure_increasing(vector<unsigned> & v) {
 
 
 
-#if LEAN_DEBUG
+#if Z3DEBUG
 bool D();
 #endif
 }
diff --git a/src/util/lp/lp_settings.hpp b/src/util/lp/lp_settings.hpp
index b27d837e0..659d47c62 100644
--- a/src/util/lp/lp_settings.hpp
+++ b/src/util/lp/lp_settings.hpp
@@ -1,12 +1,27 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <cmath>
 #include <string>
 #include "util/vector.h"
 #include "util/lp/lp_settings.h"
-namespace lean {
+namespace lp {
 std::string column_type_to_string(column_type t) {
     switch (t) {
     case column_type::fixed:       return "fixed";
@@ -14,7 +29,7 @@ std::string column_type_to_string(column_type t) {
     case column_type::low_bound:   return "low_bound";
     case column_type::upper_bound: return "upper_bound";
     case column_type::free_column: return "free_column";
-    default:  lean_unreachable();
+    default:  SASSERT(false);
     }
     return "unknown"; // it is unreachable
 }
@@ -34,7 +49,7 @@ const char* lp_status_to_string(lp_status status) {
     case EMPTY: return "EMPTY";
     case UNSTABLE: return "UNSTABLE";
     default:
-        lean_unreachable();
+        SASSERT(false);
     }
     return "UNKNOWN";  // it is unreachable
 }
@@ -49,7 +64,7 @@ lp_status lp_status_from_string(std::string status) {
     if (status == "TIME_EXHAUSTED") return lp_status::TIME_EXHAUSTED;
     if (status == "ITERATIONS_EXHAUSTED") return lp_status::ITERATIONS_EXHAUSTED;
     if (status == "EMPTY") return lp_status::EMPTY;
-    lean_unreachable();
+    SASSERT(false);
     return lp_status::UNKNOWN; // it is unreachable
 }
 
@@ -104,7 +119,7 @@ bool vectors_are_equal(const vector<T> & a, const vector<T>  &b) {
     }
     return true;
 }
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 unsigned lp_settings::ddd = 0;
 #endif
 }
diff --git a/src/util/lp/lp_settings_instances.cpp b/src/util/lp/lp_settings_instances.cpp
index ac2ed4b51..bd5a1515f 100644
--- a/src/util/lp/lp_settings_instances.cpp
+++ b/src/util/lp/lp_settings_instances.cpp
@@ -1,10 +1,25 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <memory>
 #include "util/vector.h"
 #include "util/lp/lp_settings.hpp"
-template bool lean::vectors_are_equal<double>(vector<double> const&, vector<double> const&);
-template bool lean::vectors_are_equal<lean::mpq>(vector<lean::mpq > const&, vector<lean::mpq> const&);
+template bool lp::vectors_are_equal<double>(vector<double> const&, vector<double> const&);
+template bool lp::vectors_are_equal<lp::mpq>(vector<lp::mpq > const&, vector<lp::mpq> const&);
 
diff --git a/src/util/lp/lp_solver.h b/src/util/lp/lp_solver.h
index 1bfe7dcdc..c447b1870 100644
--- a/src/util/lp/lp_solver.h
+++ b/src/util/lp/lp_solver.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 #include <string>
@@ -15,7 +30,7 @@
 #include "util/lp/scaler.h"
 #include "util/lp/linear_combination_iterator.h"
 #include "util/lp/bound_analyzer_on_row.h"
-namespace lean {
+namespace lp {
 enum lp_relation  {
     Less_or_equal,
     Equal,
diff --git a/src/util/lp/lp_solver.hpp b/src/util/lp/lp_solver.hpp
index 135616a69..3bc83b316 100644
--- a/src/util/lp/lp_solver.hpp
+++ b/src/util/lp/lp_solver.hpp
@@ -1,12 +1,27 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <string>
 #include <algorithm>
 #include "util/vector.h"
 #include "util/lp/lp_solver.h"
-namespace lean {
+namespace lp {
 template <typename T, typename X> column_info<T> * lp_solver<T, X>::get_or_create_column_info(unsigned column) {
     auto it = m_map_from_var_index_to_column_info.find(column);
     return (it == m_map_from_var_index_to_column_info.end())? (m_map_from_var_index_to_column_info[column] = new column_info<T>(static_cast<unsigned>(-1))) : it->second;
@@ -32,7 +47,7 @@ template <typename T, typename X> T lp_solver<T, X>::get_column_cost_value(unsig
     return ci->get_cost() * get_column_value(j);
 }
 template <typename T, typename X> void lp_solver<T, X>::add_constraint(lp_relation relation, T  right_side, unsigned row_index) {
-    lean_assert(m_constraints.find(row_index) == m_constraints.end());
+    SASSERT(m_constraints.find(row_index) == m_constraints.end());
     lp_constraint<T, X> cs(right_side, relation);
     m_constraints[row_index] = cs;
 }
@@ -158,10 +173,10 @@ template <typename T, typename X> void lp_solver<T, X>::pin_vars_on_row_with_sig
         column_info<T> * ci = m_map_from_var_index_to_column_info[j];
         T a = t.second;
         if (a * sign > numeric_traits<T>::zero()) {
-            lean_assert(ci->upper_bound_is_set());
+            SASSERT(ci->upper_bound_is_set());
             ci->set_fixed_value(ci->get_upper_bound());
         } else {
-            lean_assert(ci->low_bound_is_set());
+            SASSERT(ci->low_bound_is_set());
             ci->set_fixed_value(ci->get_low_bound());
         }
     }
@@ -328,7 +343,7 @@ template <typename T, typename X>    bool lp_solver<T, X>::row_is_obsolete(std::
     case lp_relation::Less_or_equal:
         return row_le_is_obsolete(row, row_index);
     }
-    lean_unreachable();
+    SASSERT(false);
     return false; // it is unreachable
 }
 
@@ -343,7 +358,7 @@ template <typename T, typename X> void lp_solver<T, X>::remove_fixed_or_zero_col
     vector<unsigned> removed;
     for (auto & col : row) {
         unsigned j = col.first;
-        lean_assert(m_map_from_var_index_to_column_info.find(j) != m_map_from_var_index_to_column_info.end());
+        SASSERT(m_map_from_var_index_to_column_info.find(j) != m_map_from_var_index_to_column_info.end());
         column_info<T> * ci = m_map_from_var_index_to_column_info[j];
         if (ci->is_fixed()) {
             removed.push_back(j);
@@ -412,7 +427,7 @@ template <typename T, typename X> void lp_solver<T, X>::map_external_columns_to_
             }
             unsigned j = col.first;
             auto column_info_it = m_map_from_var_index_to_column_info.find(j);
-            lean_assert(column_info_it != m_map_from_var_index_to_column_info.end());
+            SASSERT(column_info_it != m_map_from_var_index_to_column_info.end());
 
             auto j_column = column_info_it->second->get_column_index();
             if (!is_valid(j_column)) { // j is a newcomer
@@ -435,14 +450,14 @@ template <typename T, typename X> void lp_solver<T, X>::fill_A_from_A_values() {
     m_A = new static_matrix<T, X>(static_cast<unsigned>(m_A_values.size()), number_of_core_structurals());
     for (auto & t : m_A_values) {
         auto row_it = m_external_rows_to_core_solver_rows.find(t.first);
-        lean_assert(row_it != m_external_rows_to_core_solver_rows.end());
+        SASSERT(row_it != m_external_rows_to_core_solver_rows.end());
         unsigned row =  row_it->second;
         for (auto k : t.second) {
             auto column_info_it = m_map_from_var_index_to_column_info.find(k.first);
-            lean_assert(column_info_it != m_map_from_var_index_to_column_info.end());
+            SASSERT(column_info_it != m_map_from_var_index_to_column_info.end());
             column_info<T> *ci = column_info_it->second;
             unsigned col = ci->get_column_index();
-            lean_assert(is_valid(col));
+            SASSERT(is_valid(col));
             bool col_is_flipped = m_map_from_var_index_to_column_info[k.first]->is_flipped();
             if (!col_is_flipped) {
                 (*m_A)(row, col) = k.second;
@@ -456,7 +471,7 @@ template <typename T, typename X> void lp_solver<T, X>::fill_A_from_A_values() {
 template <typename T, typename X> void lp_solver<T, X>::fill_matrix_A_and_init_right_side() {
     map_external_rows_to_core_solver_rows();
     map_external_columns_to_core_solver_columns();
-    lean_assert(m_A == nullptr);
+    SASSERT(m_A == nullptr);
     fill_A_from_A_values();
     m_b.resize(m_A->row_count());
 }
@@ -468,7 +483,7 @@ template <typename T, typename X> void lp_solver<T, X>::count_slacks_and_artific
 }
 
 template <typename T, typename X> void lp_solver<T, X>::count_slacks_and_artificials_for_row(unsigned i) {
-    lean_assert(this->m_constraints.find(this->m_core_solver_rows_to_external_rows[i]) != this->m_constraints.end());
+    SASSERT(this->m_constraints.find(this->m_core_solver_rows_to_external_rows[i]) != this->m_constraints.end());
     auto & constraint = this->m_constraints[this->m_core_solver_rows_to_external_rows[i]];
     switch (constraint.m_relation) {
     case Equal:
@@ -504,7 +519,7 @@ template <typename T, typename X>    T lp_solver<T, X>::low_bound_shift_for_row(
 
 template <typename T, typename X> void lp_solver<T, X>::fill_m_b() {
     for (int i = this->row_count() - 1; i >= 0; i--) {
-        lean_assert(this->m_constraints.find(this->m_core_solver_rows_to_external_rows[i]) != this->m_constraints.end());
+        SASSERT(this->m_constraints.find(this->m_core_solver_rows_to_external_rows[i]) != this->m_constraints.end());
         unsigned external_i = this->m_core_solver_rows_to_external_rows[i];
         auto & constraint = this->m_constraints[external_i];
         this->m_b[i] = constraint.m_rs - low_bound_shift_for_row(external_i);
@@ -542,13 +557,13 @@ template <typename T, typename X> T lp_solver<T, X>::get_column_value_with_core_
 
 template <typename T, typename X> void lp_solver<T, X>::set_scaled_cost(unsigned j) {
     // grab original costs but modify it with the column scales
-    lean_assert(j < this->m_column_scale.size());
+    SASSERT(j < this->m_column_scale.size());
     column_info<T> * ci = this->m_map_from_var_index_to_column_info[this->m_core_solver_columns_to_external_columns[j]];
     T cost = ci->get_cost();
     if (ci->is_flipped()){
         cost *= -1;
     }
-    lean_assert(ci->is_fixed() == false);
+    SASSERT(ci->is_fixed() == false);
     this->m_costs[j] = cost * this->m_column_scale[j];
 }
 }
diff --git a/src/util/lp/lp_solver_instances.cpp b/src/util/lp/lp_solver_instances.cpp
index 5df490cae..4fe04c05f 100644
--- a/src/util/lp/lp_solver_instances.cpp
+++ b/src/util/lp/lp_solver_instances.cpp
@@ -1,40 +1,55 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <string>
 #include "util/lp/lp_solver.hpp"
-template void lean::lp_solver<double, double>::add_constraint(lean::lp_relation, double, unsigned int);
-template void lean::lp_solver<double, double>::cleanup();
-template void lean::lp_solver<double, double>::count_slacks_and_artificials();
-template void lean::lp_solver<double, double>::fill_m_b();
-template void lean::lp_solver<double, double>::fill_matrix_A_and_init_right_side();
-template void lean::lp_solver<double, double>::flip_costs();
-template double lean::lp_solver<double, double>::get_column_cost_value(unsigned int, lean::column_info<double>*) const;
-template int lean::lp_solver<double, double>::get_column_index_by_name(std::string) const;
-template double lean::lp_solver<double, double>::get_column_value_with_core_solver(unsigned int, lean::lp_core_solver_base<double, double>*) const;
-template lean::column_info<double>* lean::lp_solver<double, double>::get_or_create_column_info(unsigned int);
-template void lean::lp_solver<double, double>::give_symbolic_name_to_column(std::string, unsigned int);
-template void lean::lp_solver<double, double>::print_statistics_on_A(std::ostream & out);
-template bool lean::lp_solver<double, double>::problem_is_empty();
-template void lean::lp_solver<double, double>::scale();
-template void lean::lp_solver<double, double>::set_scaled_cost(unsigned int);
-template lean::lp_solver<double, double>::~lp_solver();
-template void lean::lp_solver<lean::mpq, lean::mpq>::add_constraint(lean::lp_relation, lean::mpq, unsigned int);
-template void lean::lp_solver<lean::mpq, lean::mpq>::cleanup();
-template void lean::lp_solver<lean::mpq, lean::mpq>::count_slacks_and_artificials();
-template void lean::lp_solver<lean::mpq, lean::mpq>::fill_m_b();
-template void lean::lp_solver<lean::mpq, lean::mpq>::fill_matrix_A_and_init_right_side();
-template void lean::lp_solver<lean::mpq, lean::mpq>::flip_costs();
-template lean::mpq lean::lp_solver<lean::mpq, lean::mpq>::get_column_cost_value(unsigned int, lean::column_info<lean::mpq>*) const;
-template int lean::lp_solver<lean::mpq, lean::mpq>::get_column_index_by_name(std::string) const;
-template lean::mpq lean::lp_solver<lean::mpq, lean::mpq>::get_column_value_by_name(std::string) const;
-template lean::mpq lean::lp_solver<lean::mpq, lean::mpq>::get_column_value_with_core_solver(unsigned int, lean::lp_core_solver_base<lean::mpq, lean::mpq>*) const;
-template lean::column_info<lean::mpq>* lean::lp_solver<lean::mpq, lean::mpq>::get_or_create_column_info(unsigned int);
-template void lean::lp_solver<lean::mpq, lean::mpq>::give_symbolic_name_to_column(std::string, unsigned int);
-template void lean::lp_solver<lean::mpq, lean::mpq>::print_statistics_on_A(std::ostream & out);
-template bool lean::lp_solver<lean::mpq, lean::mpq>::problem_is_empty();
-template void lean::lp_solver<lean::mpq, lean::mpq>::scale();
-template void lean::lp_solver<lean::mpq, lean::mpq>::set_scaled_cost(unsigned int);
-template lean::lp_solver<lean::mpq, lean::mpq>::~lp_solver();
-template double lean::lp_solver<double, double>::get_column_value_by_name(std::string) const;
+template void lp::lp_solver<double, double>::add_constraint(lp::lp_relation, double, unsigned int);
+template void lp::lp_solver<double, double>::cleanup();
+template void lp::lp_solver<double, double>::count_slacks_and_artificials();
+template void lp::lp_solver<double, double>::fill_m_b();
+template void lp::lp_solver<double, double>::fill_matrix_A_and_init_right_side();
+template void lp::lp_solver<double, double>::flip_costs();
+template double lp::lp_solver<double, double>::get_column_cost_value(unsigned int, lp::column_info<double>*) const;
+template int lp::lp_solver<double, double>::get_column_index_by_name(std::string) const;
+template double lp::lp_solver<double, double>::get_column_value_with_core_solver(unsigned int, lp::lp_core_solver_base<double, double>*) const;
+template lp::column_info<double>* lp::lp_solver<double, double>::get_or_create_column_info(unsigned int);
+template void lp::lp_solver<double, double>::give_symbolic_name_to_column(std::string, unsigned int);
+template void lp::lp_solver<double, double>::print_statistics_on_A(std::ostream & out);
+template bool lp::lp_solver<double, double>::problem_is_empty();
+template void lp::lp_solver<double, double>::scale();
+template void lp::lp_solver<double, double>::set_scaled_cost(unsigned int);
+template lp::lp_solver<double, double>::~lp_solver();
+template void lp::lp_solver<lp::mpq, lp::mpq>::add_constraint(lp::lp_relation, lp::mpq, unsigned int);
+template void lp::lp_solver<lp::mpq, lp::mpq>::cleanup();
+template void lp::lp_solver<lp::mpq, lp::mpq>::count_slacks_and_artificials();
+template void lp::lp_solver<lp::mpq, lp::mpq>::fill_m_b();
+template void lp::lp_solver<lp::mpq, lp::mpq>::fill_matrix_A_and_init_right_side();
+template void lp::lp_solver<lp::mpq, lp::mpq>::flip_costs();
+template lp::mpq lp::lp_solver<lp::mpq, lp::mpq>::get_column_cost_value(unsigned int, lp::column_info<lp::mpq>*) const;
+template int lp::lp_solver<lp::mpq, lp::mpq>::get_column_index_by_name(std::string) const;
+template lp::mpq lp::lp_solver<lp::mpq, lp::mpq>::get_column_value_by_name(std::string) const;
+template lp::mpq lp::lp_solver<lp::mpq, lp::mpq>::get_column_value_with_core_solver(unsigned int, lp::lp_core_solver_base<lp::mpq, lp::mpq>*) const;
+template lp::column_info<lp::mpq>* lp::lp_solver<lp::mpq, lp::mpq>::get_or_create_column_info(unsigned int);
+template void lp::lp_solver<lp::mpq, lp::mpq>::give_symbolic_name_to_column(std::string, unsigned int);
+template void lp::lp_solver<lp::mpq, lp::mpq>::print_statistics_on_A(std::ostream & out);
+template bool lp::lp_solver<lp::mpq, lp::mpq>::problem_is_empty();
+template void lp::lp_solver<lp::mpq, lp::mpq>::scale();
+template void lp::lp_solver<lp::mpq, lp::mpq>::set_scaled_cost(unsigned int);
+template lp::lp_solver<lp::mpq, lp::mpq>::~lp_solver();
+template double lp::lp_solver<double, double>::get_column_value_by_name(std::string) const;
diff --git a/src/util/lp/lp_utils.cpp b/src/util/lp/lp_utils.cpp
index 8cb98974e..46a82e9ec 100644
--- a/src/util/lp/lp_utils.cpp
+++ b/src/util/lp/lp_utils.cpp
@@ -1,11 +1,26 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include "util/lp/lp_utils.h"
-#ifdef lp_for_z3
-namespace lean {
+
+namespace lp {
 double numeric_traits<double>::g_zero = 0.0;
 double numeric_traits<double>::g_one = 1.0;
 }
-#endif
+
diff --git a/src/util/lp/lp_utils.h b/src/util/lp/lp_utils.h
index 34cf4f6b9..fce9f4d02 100644
--- a/src/util/lp/lp_utils.h
+++ b/src/util/lp/lp_utils.h
@@ -1,8 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-  This file should be present in z3 and in Lean.
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include <string>
 #include "util/lp/numeric_pair.h"
@@ -21,20 +35,12 @@ bool contains(const std::unordered_map<A, B> & map, const A& key) {
     return map.find(key) != map.end();
 }
 
-#ifdef lp_for_z3
-
-#ifdef Z3DEBUG
-#define LEAN_DEBUG 1
-#endif
-
-namespace lean {
+namespace lp {
     inline void throw_exception(const std::string & str) {
         throw default_exception(str);
     }
     typedef z3_exception exception;
 
-#define lean_assert(_x_) { SASSERT(_x_); }
-    inline void lean_unreachable() { lean_assert(false); }
     template <typename X> inline X zero_of_type() { return numeric_traits<X>::zero(); }
     template <typename X> inline X one_of_type() { return numeric_traits<X>::one(); }
     template <typename X> inline bool is_zero(const X & v) { return numeric_traits<X>::is_zero(v); }
@@ -68,8 +74,8 @@ template<typename S, typename T> struct hash<pair<S, T>> {
 };
 
 template<>
-struct hash<lean::numeric_pair<lean::mpq>> {
-    inline size_t operator()(const lean::numeric_pair<lean::mpq> & v) const {
+struct hash<lp::numeric_pair<lp::mpq>> {
+    inline size_t operator()(const lp::numeric_pair<lp::mpq> & v) const {
         size_t seed = 0;
         hash_combine(seed, v.x);
         hash_combine(seed, v.y);
@@ -78,64 +84,3 @@ struct hash<lean::numeric_pair<lean::mpq>> {
 };
 
 }
-#else // else  of #if  lp_for_z3
-#include <utility>
-#include <functional>
-//include "util/numerics/mpq.h"
-//include "util/numerics/numeric_traits.h"
-//include "util/numerics/double.h"
-
-#ifdef __CLANG__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wmismatched-tags"
-#endif
-namespace std {
-template<>
-struct hash<lean::mpq> {
-    inline size_t operator()(const lean::mpq & v) const {
-        return v.hash();
-    }
-};
-}
-namespace lean {
-template <typename X> inline bool  precise() { return numeric_traits<X>::precise();}
-template <typename X> inline X one_of_type() { return numeric_traits<X>::one(); }
-template <typename X> inline bool is_zero(const X & v) { return numeric_traits<X>::is_zero(v); }
-template <typename X> inline double  get_double(const X & v) { return numeric_traits<X>::get_double(v); }
-template <typename T> inline T zero_of_type() {return numeric_traits<T>::zero();}
-inline void throw_exception(std::string str) { throw exception(str); }
-template <typename T> inline T from_string(std::string const & ) { lean_unreachable();}
-template <> double inline from_string<double>(std::string const & str) { return atof(str.c_str());}
-template <> mpq inline from_string<mpq>(std::string const & str) {
-    return mpq(atof(str.c_str()));
-}
-
-} // closing lean
-template <class T>
-inline void hash_combine(std::size_t & seed, const T & v) {
-    seed ^= std::hash<T>()(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
-}
-
-namespace std {
-template<typename S, typename T> struct hash<pair<S, T>> {
-    inline size_t operator()(const pair<S, T> & v) const {
-        size_t seed = 0;
-        hash_combine(seed, v.first);
-        hash_combine(seed, v.second);
-        return seed;
-    }
-};
-template<>
-struct hash<lean::numeric_pair<lean::mpq>> {
-    inline size_t operator()(const lean::numeric_pair<lean::mpq> & v) const {
-        size_t seed = 0;
-        hash_combine(seed, v.x);
-        hash_combine(seed, v.y);
-        return seed;
-    }
-};
-} // std
-#ifdef __CLANG__
-#pragma clang diagnostic pop
-#endif
-#endif
diff --git a/src/util/lp/lu.h b/src/util/lp/lu.h
index 0d8163a14..5498a1849 100644
--- a/src/util/lp/lu.h
+++ b/src/util/lp/lu.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 
@@ -18,8 +33,8 @@
 #include "util/lp/row_eta_matrix.h"
 #include "util/lp/square_dense_submatrix.h"
 #include "util/lp/dense_matrix.h"
-namespace lean {
-#ifdef LEAN_DEBUG
+namespace lp {
+#ifdef Z3DEBUG
 template <typename T, typename X> // print the nr x nc submatrix at the top left corner
 void print_submatrix(sparse_matrix<T, X> & m, unsigned mr, unsigned nc);
 
@@ -32,7 +47,7 @@ void print_matrix(sparse_matrix<T, X>& m, std::ostream & out);
 
 template <typename T, typename X>
 X dot_product(const vector<T> & a, const vector<X> & b) {
-    lean_assert(a.size() == b.size());
+    SASSERT(a.size() == b.size());
     auto r = zero_of_type<X>();
     for (unsigned i = 0; i < a.size(); i++) {
         r += a[i] * b[i];
@@ -47,7 +62,7 @@ class one_elem_on_diag: public tail_matrix<T, X> {
     T m_val;
 public:
     one_elem_on_diag(unsigned i, T val) : m_i(i), m_val(val) {
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
         m_one_over_val = numeric_traits<T>::one() / m_val;
 #endif
     }
@@ -56,7 +71,7 @@ public:
 
     one_elem_on_diag(const one_elem_on_diag & o);
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     unsigned m_m;
     unsigned m_n;
     virtual void set_number_of_rows(unsigned m) { m_m = m; m_n = m; }
@@ -91,15 +106,15 @@ public:
 
     void conjugate_by_permutation(permutation_matrix<T, X> & p) {
         // this = p * this * p(-1)
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
         // auto rev = p.get_reverse();
         // auto deb = ((*this) * rev);
         // deb = p * deb;
 #endif
         m_i = p.apply_reverse(m_i);
 
-#ifdef LEAN_DEBUG
-        // lean_assert(*this == deb);
+#ifdef Z3DEBUG
+        // SASSERT(*this == deb);
 #endif
     }
 }; // end of one_elem_on_diag
@@ -212,7 +227,7 @@ public:
     // see page 407 of Chvatal
     unsigned transform_U_to_V_by_replacing_column(indexed_vector<T> & w, unsigned leaving_column_of_U);
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     void check_vector_w(unsigned entering);
 
     void check_apply_matrix_to_vector(matrix<T, X> *lp, T *w);
@@ -248,7 +263,7 @@ public:
     bool is_correct(const vector<unsigned>& basis);
 
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     dense_matrix<T, X> tail_product();
     dense_matrix<T, X>  get_left_side(const vector<unsigned>& basis);
 
@@ -291,7 +306,7 @@ public:
     bool need_to_refactor() { return m_refactor_counter >= 200; }
     
     void adjust_dimension_with_matrix_A() {
-        lean_assert(m_A.row_count() >= m_dim);
+        SASSERT(m_A.row_count() >= m_dim);
         m_dim = m_A.row_count();
         m_U.resize(m_dim);
         m_Q.resize(m_dim);
@@ -305,7 +320,7 @@ public:
         unsigned m = m_A.row_count();
         unsigned m_prev = m_U.dimension();
 
-        lean_assert(m_A.column_count() == heading.size());
+        SASSERT(m_A.column_count() == heading.size());
 
         for (unsigned i = m_prev; i < m; i++) {
             for (const row_cell<T> & c : m_A.m_rows[i]) {
@@ -321,14 +336,14 @@ public:
     
     void add_last_rows_to_B(const vector<int> & heading, const std::unordered_set<unsigned> & columns_to_replace) {
         unsigned m = m_A.row_count();
-        lean_assert(m_A.column_count() == heading.size());
+        SASSERT(m_A.column_count() == heading.size());
         adjust_dimension_with_matrix_A();
         m_w_for_extension.resize(m);
         // At this moment the LU is correct      
         // for B extended by only by ones at the diagonal in the lower right corner
 
         for (unsigned j :columns_to_replace) {
-            lean_assert(heading[j] >= 0);
+            SASSERT(heading[j] >= 0);
             replace_column_with_only_change_at_last_rows(j, heading[j]);
             if (get_status() == LU_status::Degenerated)
                 break;
@@ -352,7 +367,7 @@ public:
 template <typename T, typename X>
 void init_factorization(lu<T, X>* & factorization, static_matrix<T, X> & m_A, vector<unsigned> & m_basis, lp_settings &m_settings);
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template <typename T, typename X>
 dense_matrix<T, X>  get_B(lu<T, X>& f, const vector<unsigned>& basis);
 #endif
diff --git a/src/util/lp/lu.hpp b/src/util/lp/lu.hpp
index 2d2c7c7c4..9d1532ac9 100644
--- a/src/util/lp/lu.hpp
+++ b/src/util/lp/lu.hpp
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <string>
 #include <algorithm>
 #include <set>
@@ -9,8 +24,8 @@
 #include <utility>
 #include "util/debug.h"
 #include "util/lp/lu.h"
-namespace lean {
-#ifdef LEAN_DEBUG
+namespace lp {
+#ifdef Z3DEBUG
 template <typename T, typename X> // print the nr x nc submatrix at the top left corner
 void print_submatrix(sparse_matrix<T, X> & m, unsigned mr, unsigned nc, std::ostream & out) {
     vector<vector<std::string>> A;
@@ -72,13 +87,13 @@ template <typename T, typename X>
 one_elem_on_diag<T, X>::one_elem_on_diag(const one_elem_on_diag & o) {
     m_i = o.m_i;
     m_val = o.m_val;
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     m_m = m_n = o.m_m;
     m_one_over_val = numeric_traits<T>::one() / o.m_val;
 #endif
 }
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template <typename T, typename X>
 T one_elem_on_diag<T, X>::get_elem(unsigned i, unsigned j) const {
     if (i == j){
@@ -122,29 +137,29 @@ lu<T, X>::lu(static_matrix<T, X> const & A,
     m_failure(false),
     m_row_eta_work_vector(A.row_count()),
     m_refactor_counter(0) {
-    lean_assert(!(numeric_traits<T>::precise() && settings.use_tableau()));
-#ifdef LEAN_DEBUG
+    SASSERT(!(numeric_traits<T>::precise() && settings.use_tableau()));
+#ifdef Z3DEBUG
     debug_test_of_basis(A, basis);
 #endif
     ++m_settings.st().m_num_factorizations;
     create_initial_factorization();
-#ifdef LEAN_DEBUG
-    // lean_assert(check_correctness());
+#ifdef Z3DEBUG
+    // SASSERT(check_correctness());
 #endif
 }
 template <typename T, typename X>
 void lu<T, X>::debug_test_of_basis(static_matrix<T, X> const & A, vector<unsigned> & basis) {
     std::set<unsigned> set;
     for (unsigned i = 0; i < A.row_count(); i++) {
-        lean_assert(basis[i]< A.column_count());
+        SASSERT(basis[i]< A.column_count());
         set.insert(basis[i]);
     }
-    lean_assert(set.size() == A.row_count());
+    SASSERT(set.size() == A.row_count());
 }
 
  template <typename T, typename X>
  void lu<T, X>::solve_By(indexed_vector<X> & y) {
-     lean_assert(false); // not implemented
+     SASSERT(false); // not implemented
      // init_vector_y(y);
      // solve_By_when_y_is_ready(y);
  }
@@ -268,7 +283,7 @@ void lu<T, X>::solve_yB(vector<T>& y) {
     m_U.solve_y_U(y); // got y*U=cb*R(-1)
     m_Q.apply_reverse_from_right_to_T(y); //
     for (auto e = m_tail.rbegin(); e != m_tail.rend(); ++e) {
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
         (*e)->set_number_of_columns(m_dim);
 #endif
         (*e)->apply_from_right(y);
@@ -277,20 +292,20 @@ void lu<T, X>::solve_yB(vector<T>& y) {
 
 template <typename T, typename X>
 void lu<T, X>::solve_yB_indexed(indexed_vector<T>& y) {
-    lean_assert(y.is_OK());
+    SASSERT(y.is_OK());
     // first solve yU = cb*R(-1)
     m_R.apply_reverse_from_right_to_T(y); // got y = cb*R(-1)
-    lean_assert(y.is_OK());
+    SASSERT(y.is_OK());
     m_U.solve_y_U_indexed(y, m_settings); // got y*U=cb*R(-1)
-    lean_assert(y.is_OK());
+    SASSERT(y.is_OK());
     m_Q.apply_reverse_from_right_to_T(y);
-    lean_assert(y.is_OK());
+    SASSERT(y.is_OK());
     for (auto e = m_tail.rbegin(); e != m_tail.rend(); ++e) {
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
         (*e)->set_number_of_columns(m_dim);
 #endif
         (*e)->apply_from_right(y);
-        lean_assert(y.is_OK());
+        SASSERT(y.is_OK());
     }
 }
 
@@ -304,8 +319,8 @@ void lu<T, X>::add_delta_to_solution(const vector<T>& yc, vector<T>& y){
 template <typename T, typename X>
 void lu<T, X>::add_delta_to_solution_indexed(indexed_vector<T>& y) {
     // the delta sits in m_y_copy, put result into y
-    lean_assert(y.is_OK());
-    lean_assert(m_y_copy.is_OK());
+    SASSERT(y.is_OK());
+    SASSERT(m_y_copy.is_OK());
     m_ii.clear();
     m_ii.resize(y.data_size());
     for (unsigned i : y.m_index)
@@ -315,7 +330,7 @@ void lu<T, X>::add_delta_to_solution_indexed(indexed_vector<T>& y) {
         if (m_ii[i] == 0)
             m_ii.set_value(1, i);
     }
-    lean_assert(m_ii.is_OK());
+    SASSERT(m_ii.is_OK());
     y.m_index.clear();
 
     for (unsigned i : m_ii.m_index) {
@@ -326,7 +341,7 @@ void lu<T, X>::add_delta_to_solution_indexed(indexed_vector<T>& y) {
             v = zero_of_type<T>();
     }
         
-    lean_assert(y.is_OK());
+    SASSERT(y.is_OK());
 }
 
 template <typename T, typename X>
@@ -343,7 +358,7 @@ void lu<T, X>::find_error_of_yB_indexed(const indexed_vector<T>& y, const vector
     // it is a non efficient version
     indexed_vector<T> yc = m_y_copy;
     yc.m_index.clear();
-    lean_assert(!numeric_traits<T>::precise());
+    SASSERT(!numeric_traits<T>::precise());
     {
 
         vector<unsigned> d_basis(y.m_data.size());
@@ -364,10 +379,10 @@ void lu<T, X>::find_error_of_yB_indexed(const indexed_vector<T>& y, const vector
         }
     }
 #endif
-    lean_assert(m_ii.is_OK());
+    SASSERT(m_ii.is_OK());
     m_ii.clear();
     m_ii.resize(y.data_size());
-    lean_assert(m_y_copy.is_OK());
+    SASSERT(m_y_copy.is_OK());
     // put the error into m_y_copy
     for (auto k : y.m_index) {
         auto & row = m_A.m_rows[k];
@@ -399,7 +414,7 @@ void lu<T, X>::find_error_of_yB_indexed(const indexed_vector<T>& y, const vector
             m_y_copy.set_value(v, k);
         }
     }
-    lean_assert(m_y_copy.is_OK());
+    SASSERT(m_y_copy.is_OK());
 
 }
 
@@ -419,12 +434,12 @@ void lu<T, X>::solve_yB_with_error_check_indexed(indexed_vector<T> & y, const ve
         }
         return;
     }
-    lean_assert(m_y_copy.is_OK());
-    lean_assert(y.is_OK());
+    SASSERT(m_y_copy.is_OK());
+    SASSERT(y.is_OK());
     if (y.m_index.size() * ratio_of_index_size_to_all_size<T>() < m_A.column_count()) {
         m_y_copy = y;
         solve_yB_indexed(y);
-        lean_assert(y.is_OK());
+        SASSERT(y.is_OK());
         if (y.m_index.size() * ratio_of_index_size_to_all_size<T>() >= m_A.column_count()) {
             find_error_of_yB(m_y_copy.m_data, y.m_data, basis);
             solve_yB(m_y_copy.m_data);
@@ -436,7 +451,7 @@ void lu<T, X>::solve_yB_with_error_check_indexed(indexed_vector<T> & y, const ve
             solve_yB_indexed(m_y_copy);
             add_delta_to_solution_indexed(y);
         }
-        lean_assert(m_y_copy.is_OK());
+        SASSERT(m_y_copy.is_OK());
     } else {
         solve_yB_with_error_check(y.m_data, basis);
         y.restore_index_and_clean_from_data();
@@ -489,7 +504,7 @@ template <typename T, typename X>
 void lu<T, X>::perform_transformations_on_w(indexed_vector<T>& w) {
     apply_lp_list_to_w(w);
     m_Q.apply_reverse_from_left(w);
-    // TBD does not compile: lean_assert(numeric_traits<T>::precise() || check_vector_for_small_values(w, m_settings));
+    // TBD does not compile: SASSERT(numeric_traits<T>::precise() || check_vector_for_small_values(w, m_settings));
 }
 
 // see Chvatal 24.3
@@ -503,7 +518,7 @@ template <typename T, typename X>
 void lu<T, X>::apply_lp_list_to_w(indexed_vector<T> & w) {
     for (unsigned i = 0; i < m_tail.size(); i++) {
         m_tail[i]->apply_from_left_to_T(w, m_settings);
-        // TBD does not compile: lean_assert(check_vector_for_small_values(w, m_settings));
+        // TBD does not compile: SASSERT(check_vector_for_small_values(w, m_settings));
     }
 }
 template <typename T, typename X>
@@ -570,7 +585,7 @@ unsigned lu<T, X>::transform_U_to_V_by_replacing_column(indexed_vector<T> & w,
     return column_to_replace;
 }
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template <typename T, typename X>
 void lu<T, X>::check_vector_w(unsigned entering) {
     T * w = new T[m_dim];
@@ -595,7 +610,7 @@ void lu<T, X>::check_apply_lp_lists_to_w(T * w) {
     permutation_matrix<T, X> qr = m_Q.get_reverse();
     apply_to_vector(qr, w);
     for (int i = m_dim - 1; i >= 0; i--) {
-        lean_assert(abs(w[i] - w[i]) < 0.0000001);
+        SASSERT(abs(w[i] - w[i]) < 0.0000001);
     }
 }
 
@@ -624,7 +639,7 @@ void lu<T, X>::process_column(int j) {
 }
 template <typename T, typename X>
 bool lu<T, X>::is_correct(const vector<unsigned>& basis) {
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     if (get_status() != LU_status::OK) {
         return false;
     }
@@ -637,10 +652,10 @@ bool lu<T, X>::is_correct(const vector<unsigned>& basis) {
 }
 
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template <typename T, typename X>
 dense_matrix<T, X> lu<T, X>::tail_product() {
-    lean_assert(tail_size() > 0);
+    SASSERT(tail_size() > 0);
     dense_matrix<T, X> left_side = permutation_matrix<T, X>(m_dim);
     for (unsigned i = 0; i < tail_size(); i++) {
         matrix<T, X>* lp =  get_lp_matrix(i);
@@ -690,8 +705,8 @@ template <typename T, typename X>
 bool lu<T, X>::all_columns_and_rows_are_active() {
     unsigned i = m_dim;
     while (i--) {
-        lean_assert(m_U.col_is_active(i));
-        lean_assert(m_U.row_is_active(i));
+        SASSERT(m_U.col_is_active(i));
+        SASSERT(m_U.row_is_active(i));
     }
     return true;
 }
@@ -733,9 +748,9 @@ void lu<T, X>::create_initial_factorization(){
         }
     }
     if (j == m_dim) {
-        // TBD does not compile: lean_assert(m_U.is_upper_triangular_and_maximums_are_set_correctly_in_rows(m_settings));
-        //        lean_assert(is_correct());
-        // lean_assert(m_U.is_upper_triangular_and_maximums_are_set_correctly_in_rows(m_settings));
+        // TBD does not compile: SASSERT(m_U.is_upper_triangular_and_maximums_are_set_correctly_in_rows(m_settings));
+        //        SASSERT(is_correct());
+        // SASSERT(m_U.is_upper_triangular_and_maximums_are_set_correctly_in_rows(m_settings));
         return;
     }
     j++;
@@ -748,12 +763,12 @@ void lu<T, X>::create_initial_factorization(){
         }
     }
     m_dense_LU->update_parent_matrix(m_settings);
-    lean_assert(m_dense_LU->is_L_matrix());
+    SASSERT(m_dense_LU->is_L_matrix());
     m_dense_LU->conjugate_by_permutation(m_Q);
     push_matrix_to_tail(m_dense_LU);
     m_refactor_counter = 0;
-    // lean_assert(is_correct());
-    // lean_assert(m_U.is_upper_triangular_and_maximums_are_set_correctly_in_rows(m_settings));
+    // SASSERT(is_correct());
+    // SASSERT(m_U.is_upper_triangular_and_maximums_are_set_correctly_in_rows(m_settings));
 }
 
 template <typename T, typename X>
@@ -780,7 +795,7 @@ void lu<T, X>::scan_last_row_to_work_vector(unsigned lowest_row_of_the_bump) {
     vector<indexed_value<T>> & last_row_vec = m_U.get_row_values(m_U.adjust_row(lowest_row_of_the_bump));
     for (auto & iv : last_row_vec) {
         if (is_zero(iv.m_value)) continue;
-        lean_assert(!m_settings.abs_val_is_smaller_than_drop_tolerance(iv.m_value));
+        SASSERT(!m_settings.abs_val_is_smaller_than_drop_tolerance(iv.m_value));
         unsigned adjusted_col = m_U.adjust_column_inverse(iv.m_index);
         if (adjusted_col < lowest_row_of_the_bump) {
             m_row_eta_work_vector.set_value(-iv.m_value, adjusted_col);
@@ -801,14 +816,14 @@ void lu<T, X>::pivot_and_solve_the_system(unsigned replaced_column, unsigned low
         vector<indexed_value<T>> & row = m_U.get_row_values(aj);
         for (auto & iv : row) {
             unsigned col = m_U.adjust_column_inverse(iv.m_index);
-            lean_assert(col >= j || numeric_traits<T>::is_zero(iv.m_value));
+            SASSERT(col >= j || numeric_traits<T>::is_zero(iv.m_value));
             if (col == j) continue;
             if (numeric_traits<T>::is_zero(iv.m_value)) {
                 continue;
             }
             // the -v is for solving the system ( to zero the last row), and +v is for pivoting
             T delta = col < lowest_row_of_the_bump? -v * iv.m_value: v * iv.m_value;
-            lean_assert(numeric_traits<T>::is_zero(delta) == false);
+            SASSERT(numeric_traits<T>::is_zero(delta) == false);
 
 
             
@@ -845,7 +860,7 @@ row_eta_matrix<T, X> *lu<T, X>::get_row_eta_matrix_and_set_row_vector(unsigned r
             return nullptr;
         }
     }
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     auto ret = new row_eta_matrix<T, X>(replaced_column, lowest_row_of_the_bump, m_dim);
 #else
     auto ret = new row_eta_matrix<T, X>(replaced_column, lowest_row_of_the_bump);
@@ -885,15 +900,15 @@ void lu<T, X>::replace_column(T pivot_elem_for_checking, indexed_vector<T> & w,
         push_matrix_to_tail(row_eta);
     }
     calculate_Lwave_Pwave_for_bump(replaced_column, lowest_row_of_the_bump);
-    // lean_assert(m_U.is_upper_triangular_and_maximums_are_set_correctly_in_rows(m_settings));
-    // lean_assert(w.is_OK() && m_row_eta_work_vector.is_OK());
+    // SASSERT(m_U.is_upper_triangular_and_maximums_are_set_correctly_in_rows(m_settings));
+    // SASSERT(w.is_OK() && m_row_eta_work_vector.is_OK());
 }
 template <typename T, typename X>
 void lu<T, X>::calculate_Lwave_Pwave_for_bump(unsigned replaced_column, unsigned lowest_row_of_the_bump){
     T diagonal_elem;
     if (replaced_column < lowest_row_of_the_bump) {
         diagonal_elem = m_row_eta_work_vector[lowest_row_of_the_bump];
-        //          lean_assert(m_row_eta_work_vector.is_OK());
+        //          SASSERT(m_row_eta_work_vector.is_OK());
         m_U.set_row_from_work_vector_and_clean_work_vector_not_adjusted(m_U.adjust_row(lowest_row_of_the_bump), m_row_eta_work_vector, m_settings);
     } else {
         diagonal_elem = m_U(lowest_row_of_the_bump, lowest_row_of_the_bump); // todo - get it more efficiently
@@ -904,13 +919,13 @@ void lu<T, X>::calculate_Lwave_Pwave_for_bump(unsigned replaced_column, unsigned
     }
 
     calculate_Lwave_Pwave_for_last_row(lowest_row_of_the_bump, diagonal_elem);
-    //         lean_assert(m_U.is_upper_triangular_and_maximums_are_set_correctly_in_rows(m_settings));
+    //         SASSERT(m_U.is_upper_triangular_and_maximums_are_set_correctly_in_rows(m_settings));
 }
 
 template <typename T, typename X>
 void lu<T, X>::calculate_Lwave_Pwave_for_last_row(unsigned lowest_row_of_the_bump, T diagonal_element) {
     auto l = new one_elem_on_diag<T, X>(lowest_row_of_the_bump, diagonal_element);
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     l->set_number_of_columns(m_dim);
 #endif
     push_matrix_to_tail(l);
@@ -927,11 +942,11 @@ void init_factorization(lu<T, X>* & factorization, static_matrix<T, X> & m_A, ve
     //     LP_OUT(m_settings, "failing in init_factorization" << std::endl);
 }
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template <typename T, typename X>
 dense_matrix<T, X>  get_B(lu<T, X>& f, const vector<unsigned>& basis) {
-    lean_assert(basis.size() == f.dimension());
-    lean_assert(basis.size() == f.m_U.dimension());
+    SASSERT(basis.size() == f.dimension());
+    SASSERT(basis.size() == f.m_U.dimension());
     dense_matrix<T, X>  B(f.dimension(), f.dimension());
     for (unsigned i = 0; i < f.dimension(); i++)
         for (unsigned j = 0; j < f.dimension(); j++)
diff --git a/src/util/lp/lu_instances.cpp b/src/util/lp/lu_instances.cpp
index c8ff7b2f4..057895068 100644
--- a/src/util/lp/lu_instances.cpp
+++ b/src/util/lp/lu_instances.cpp
@@ -1,63 +1,78 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <utility>
 #include <memory>
 #include <string>
 #include "util/vector.h"
 #include "util/debug.h"
 #include "util/lp/lu.hpp"
-template double lean::dot_product<double, double>(vector<double> const&, vector<double> const&);
-template lean::lu<double, double>::lu(lean::static_matrix<double, double> const&, vector<unsigned int>&, lean::lp_settings&);
-template void lean::lu<double, double>::push_matrix_to_tail(lean::tail_matrix<double, double>*);
-template void lean::lu<double, double>::replace_column(double, lean::indexed_vector<double>&, unsigned);
-template void lean::lu<double, double>::solve_Bd(unsigned int, lean::indexed_vector<double>&, lean::indexed_vector<double>&);
-template lean::lu<double, double>::~lu();
-template void lean::lu<lean::mpq, lean::mpq>::push_matrix_to_tail(lean::tail_matrix<lean::mpq, lean::mpq>*);
-template void lean::lu<lean::mpq, lean::mpq>::solve_Bd(unsigned int, lean::indexed_vector<lean::mpq>&, lean::indexed_vector<lean::mpq>&);
-template lean::lu<lean::mpq, lean::mpq>::~lu();
-template void lean::lu<lean::mpq, lean::numeric_pair<lean::mpq> >::push_matrix_to_tail(lean::tail_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >*);
-template void lean::lu<lean::mpq, lean::numeric_pair<lean::mpq> >::solve_Bd(unsigned int, lean::indexed_vector<lean::mpq>&, lean::indexed_vector<lean::mpq>&);
-template lean::lu<lean::mpq, lean::numeric_pair<lean::mpq> >::~lu();
-template lean::mpq lean::dot_product<lean::mpq, lean::mpq>(vector<lean::mpq > const&, vector<lean::mpq > const&);
-template void lean::init_factorization<double, double>(lean::lu<double, double>*&, lean::static_matrix<double, double>&, vector<unsigned int>&, lean::lp_settings&);
-template void lean::init_factorization<lean::mpq, lean::mpq>(lean::lu<lean::mpq, lean::mpq>*&, lean::static_matrix<lean::mpq, lean::mpq>&, vector<unsigned int>&, lean::lp_settings&);
-template void lean::init_factorization<lean::mpq, lean::numeric_pair<lean::mpq> >(lean::lu<lean::mpq, lean::numeric_pair<lean::mpq> >*&, lean::static_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >&, vector<unsigned int>&, lean::lp_settings&);
-#ifdef LEAN_DEBUG
-template void lean::print_matrix<double, double>(lean::sparse_matrix<double, double>&, std::ostream & out);
-template void lean::print_matrix<lean::mpq, lean::mpq>(lean::static_matrix<lean::mpq, lean::mpq>&, std::ostream&);
-template void lean::print_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >(lean::static_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >&, std::ostream&);
-template void lean::print_matrix<double, double>(lean::static_matrix<double, double>&, std::ostream & out);
-template bool lean::lu<double, double>::is_correct(const vector<unsigned>& basis);
-template bool lean::lu<lean::mpq, lean::numeric_pair<lean::mpq> >::is_correct( vector<unsigned int> const &);
-template lean::dense_matrix<double, double> lean::get_B<double, double>(lean::lu<double, double>&, const vector<unsigned>& basis);
-template lean::dense_matrix<lean::mpq, lean::mpq> lean::get_B<lean::mpq, lean::mpq>(lean::lu<lean::mpq, lean::mpq>&, vector<unsigned int> const&);
+template double lp::dot_product<double, double>(vector<double> const&, vector<double> const&);
+template lp::lu<double, double>::lu(lp::static_matrix<double, double> const&, vector<unsigned int>&, lp::lp_settings&);
+template void lp::lu<double, double>::push_matrix_to_tail(lp::tail_matrix<double, double>*);
+template void lp::lu<double, double>::replace_column(double, lp::indexed_vector<double>&, unsigned);
+template void lp::lu<double, double>::solve_Bd(unsigned int, lp::indexed_vector<double>&, lp::indexed_vector<double>&);
+template lp::lu<double, double>::~lu();
+template void lp::lu<lp::mpq, lp::mpq>::push_matrix_to_tail(lp::tail_matrix<lp::mpq, lp::mpq>*);
+template void lp::lu<lp::mpq, lp::mpq>::solve_Bd(unsigned int, lp::indexed_vector<lp::mpq>&, lp::indexed_vector<lp::mpq>&);
+template lp::lu<lp::mpq, lp::mpq>::~lu();
+template void lp::lu<lp::mpq, lp::numeric_pair<lp::mpq> >::push_matrix_to_tail(lp::tail_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >*);
+template void lp::lu<lp::mpq, lp::numeric_pair<lp::mpq> >::solve_Bd(unsigned int, lp::indexed_vector<lp::mpq>&, lp::indexed_vector<lp::mpq>&);
+template lp::lu<lp::mpq, lp::numeric_pair<lp::mpq> >::~lu();
+template lp::mpq lp::dot_product<lp::mpq, lp::mpq>(vector<lp::mpq > const&, vector<lp::mpq > const&);
+template void lp::init_factorization<double, double>(lp::lu<double, double>*&, lp::static_matrix<double, double>&, vector<unsigned int>&, lp::lp_settings&);
+template void lp::init_factorization<lp::mpq, lp::mpq>(lp::lu<lp::mpq, lp::mpq>*&, lp::static_matrix<lp::mpq, lp::mpq>&, vector<unsigned int>&, lp::lp_settings&);
+template void lp::init_factorization<lp::mpq, lp::numeric_pair<lp::mpq> >(lp::lu<lp::mpq, lp::numeric_pair<lp::mpq> >*&, lp::static_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >&, vector<unsigned int>&, lp::lp_settings&);
+#ifdef Z3DEBUG
+template void lp::print_matrix<double, double>(lp::sparse_matrix<double, double>&, std::ostream & out);
+template void lp::print_matrix<lp::mpq, lp::mpq>(lp::static_matrix<lp::mpq, lp::mpq>&, std::ostream&);
+template void lp::print_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >(lp::static_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >&, std::ostream&);
+template void lp::print_matrix<double, double>(lp::static_matrix<double, double>&, std::ostream & out);
+template bool lp::lu<double, double>::is_correct(const vector<unsigned>& basis);
+template bool lp::lu<lp::mpq, lp::numeric_pair<lp::mpq> >::is_correct( vector<unsigned int> const &);
+template lp::dense_matrix<double, double> lp::get_B<double, double>(lp::lu<double, double>&, const vector<unsigned>& basis);
+template lp::dense_matrix<lp::mpq, lp::mpq> lp::get_B<lp::mpq, lp::mpq>(lp::lu<lp::mpq, lp::mpq>&, vector<unsigned int> const&);
 
 #endif
 
-template bool lean::lu<double, double>::pivot_the_row(int); // NOLINT
-template void lean::lu<double, double>::init_vector_w(unsigned int, lean::indexed_vector<double>&);
-template void lean::lu<double, double>::solve_By(vector<double>&);
-template void lean::lu<double, double>::solve_By_when_y_is_ready_for_X(vector<double>&);
-template void lean::lu<double, double>::solve_yB_with_error_check(vector<double>&, const vector<unsigned>& basis);
-template void lean::lu<double, double>::solve_yB_with_error_check_indexed(lean::indexed_vector<double>&, vector<int> const&,  const vector<unsigned> & basis, const lp_settings&);
-template void lean::lu<lean::mpq, lean::mpq>::replace_column(lean::mpq, lean::indexed_vector<lean::mpq>&, unsigned);
-template void lean::lu<lean::mpq, lean::mpq>::solve_By(vector<lean::mpq >&);
-template void lean::lu<lean::mpq, lean::mpq>::solve_By_when_y_is_ready_for_X(vector<lean::mpq >&);
-template void lean::lu<lean::mpq, lean::mpq>::solve_yB_with_error_check(vector<lean::mpq >&, const vector<unsigned>& basis);
-template void lean::lu<lean::mpq, lean::mpq>::solve_yB_with_error_check_indexed(lean::indexed_vector<lean::mpq>&, vector< int > const&,  const vector<unsigned> & basis, const lp_settings&);
-template void lean::lu<lean::mpq, lean::numeric_pair<lean::mpq> >::solve_yB_with_error_check_indexed(lean::indexed_vector<lean::mpq>&, vector< int > const&,  const vector<unsigned> & basis, const lp_settings&);
-template void lean::lu<lean::mpq, lean::numeric_pair<lean::mpq> >::init_vector_w(unsigned int, lean::indexed_vector<lean::mpq>&);
-template void lean::lu<lean::mpq, lean::numeric_pair<lean::mpq> >::replace_column(lean::mpq, lean::indexed_vector<lean::mpq>&, unsigned);
-template void lean::lu<lean::mpq, lean::numeric_pair<lean::mpq> >::solve_Bd_faster(unsigned int, lean::indexed_vector<lean::mpq>&);
-template void lean::lu<lean::mpq, lean::numeric_pair<lean::mpq> >::solve_By(vector<lean::numeric_pair<lean::mpq> >&);
-template void lean::lu<lean::mpq, lean::numeric_pair<lean::mpq> >::solve_By_when_y_is_ready_for_X(vector<lean::numeric_pair<lean::mpq> >&);
-template void lean::lu<lean::mpq, lean::numeric_pair<lean::mpq> >::solve_yB_with_error_check(vector<lean::mpq >&, const vector<unsigned>& basis);
-template void lean::lu<lean::mpq, lean::mpq>::solve_By(lean::indexed_vector<lean::mpq>&);
-template void lean::lu<double, double>::solve_By(lean::indexed_vector<double>&);
-template void lean::lu<double, double>::solve_yB_indexed(lean::indexed_vector<double>&);
-template void lean::lu<lean::mpq, lean::mpq>::solve_yB_indexed(lean::indexed_vector<lean::mpq>&);
-template void lean::lu<lean::mpq, lean::numeric_pair<lean::mpq> >::solve_yB_indexed(lean::indexed_vector<lean::mpq>&);
-template void lean::lu<lean::mpq, lean::mpq>::solve_By_for_T_indexed_only(lean::indexed_vector<lean::mpq>&, lean::lp_settings const&);
-template void lean::lu<double, double>::solve_By_for_T_indexed_only(lean::indexed_vector<double>&, lean::lp_settings const&);
+template bool lp::lu<double, double>::pivot_the_row(int); // NOLINT
+template void lp::lu<double, double>::init_vector_w(unsigned int, lp::indexed_vector<double>&);
+template void lp::lu<double, double>::solve_By(vector<double>&);
+template void lp::lu<double, double>::solve_By_when_y_is_ready_for_X(vector<double>&);
+template void lp::lu<double, double>::solve_yB_with_error_check(vector<double>&, const vector<unsigned>& basis);
+template void lp::lu<double, double>::solve_yB_with_error_check_indexed(lp::indexed_vector<double>&, vector<int> const&,  const vector<unsigned> & basis, const lp_settings&);
+template void lp::lu<lp::mpq, lp::mpq>::replace_column(lp::mpq, lp::indexed_vector<lp::mpq>&, unsigned);
+template void lp::lu<lp::mpq, lp::mpq>::solve_By(vector<lp::mpq >&);
+template void lp::lu<lp::mpq, lp::mpq>::solve_By_when_y_is_ready_for_X(vector<lp::mpq >&);
+template void lp::lu<lp::mpq, lp::mpq>::solve_yB_with_error_check(vector<lp::mpq >&, const vector<unsigned>& basis);
+template void lp::lu<lp::mpq, lp::mpq>::solve_yB_with_error_check_indexed(lp::indexed_vector<lp::mpq>&, vector< int > const&,  const vector<unsigned> & basis, const lp_settings&);
+template void lp::lu<lp::mpq, lp::numeric_pair<lp::mpq> >::solve_yB_with_error_check_indexed(lp::indexed_vector<lp::mpq>&, vector< int > const&,  const vector<unsigned> & basis, const lp_settings&);
+template void lp::lu<lp::mpq, lp::numeric_pair<lp::mpq> >::init_vector_w(unsigned int, lp::indexed_vector<lp::mpq>&);
+template void lp::lu<lp::mpq, lp::numeric_pair<lp::mpq> >::replace_column(lp::mpq, lp::indexed_vector<lp::mpq>&, unsigned);
+template void lp::lu<lp::mpq, lp::numeric_pair<lp::mpq> >::solve_Bd_faster(unsigned int, lp::indexed_vector<lp::mpq>&);
+template void lp::lu<lp::mpq, lp::numeric_pair<lp::mpq> >::solve_By(vector<lp::numeric_pair<lp::mpq> >&);
+template void lp::lu<lp::mpq, lp::numeric_pair<lp::mpq> >::solve_By_when_y_is_ready_for_X(vector<lp::numeric_pair<lp::mpq> >&);
+template void lp::lu<lp::mpq, lp::numeric_pair<lp::mpq> >::solve_yB_with_error_check(vector<lp::mpq >&, const vector<unsigned>& basis);
+template void lp::lu<lp::mpq, lp::mpq>::solve_By(lp::indexed_vector<lp::mpq>&);
+template void lp::lu<double, double>::solve_By(lp::indexed_vector<double>&);
+template void lp::lu<double, double>::solve_yB_indexed(lp::indexed_vector<double>&);
+template void lp::lu<lp::mpq, lp::mpq>::solve_yB_indexed(lp::indexed_vector<lp::mpq>&);
+template void lp::lu<lp::mpq, lp::numeric_pair<lp::mpq> >::solve_yB_indexed(lp::indexed_vector<lp::mpq>&);
+template void lp::lu<lp::mpq, lp::mpq>::solve_By_for_T_indexed_only(lp::indexed_vector<lp::mpq>&, lp::lp_settings const&);
+template void lp::lu<double, double>::solve_By_for_T_indexed_only(lp::indexed_vector<double>&, lp::lp_settings const&);
diff --git a/src/util/lp/matrix.h b/src/util/lp/matrix.h
index 63fd5c01e..f6374756f 100644
--- a/src/util/lp/matrix.h
+++ b/src/util/lp/matrix.h
@@ -1,14 +1,29 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #ifdef Z3DEBUG
 #pragma once
 #include "util/lp/numeric_pair.h"
 #include "util/vector.h"
 #include <string>
 #include "util/lp/lp_settings.h"
-namespace lean {
+namespace lp {
 // used for debugging purposes only
 template <typename T, typename X>
 class matrix {
diff --git a/src/util/lp/matrix.hpp b/src/util/lp/matrix.hpp
index d032cab8c..6eb82a9cc 100644
--- a/src/util/lp/matrix.hpp
+++ b/src/util/lp/matrix.hpp
@@ -1,13 +1,28 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #ifdef Z3DEBUG
 #include <cmath>
 #include <string>
 #include "util/lp/matrix.h"
-namespace lean {
+namespace lp {
 template <typename T, typename X>
 bool matrix<T, X>::is_equal(const matrix<T, X>& other) {
     if (other.row_count() != row_count() || other.column_count() != column_count())
diff --git a/src/util/lp/matrix_instances.cpp b/src/util/lp/matrix_instances.cpp
index aeee62786..8271a4d8a 100644
--- a/src/util/lp/matrix_instances.cpp
+++ b/src/util/lp/matrix_instances.cpp
@@ -1,16 +1,31 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include "util/lp/lp_settings.h"
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 #include "util/lp/matrix.hpp"
 #include "util/lp/static_matrix.h"
 #include <string>
-template void lean::print_matrix<double, double>(lean::matrix<double, double> const*, std::ostream & out);
-template bool lean::matrix<double, double>::is_equal(lean::matrix<double, double> const&);
-template void lean::print_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >(lean::matrix<lean::mpq, lean::numeric_pair<lean::mpq> > const *, std::basic_ostream<char, std::char_traits<char> > &);
-template void lean::print_matrix<lean::mpq, lean::mpq>(lean::matrix<lean::mpq, lean::mpq> const*, std::ostream&);
-template bool lean::matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::is_equal(lean::matrix<lean::mpq, lean::numeric_pair<lean::mpq> > const&);
-template bool lean::matrix<lean::mpq, lean::mpq>::is_equal(lean::matrix<lean::mpq, lean::mpq> const&);
+template void lp::print_matrix<double, double>(lp::matrix<double, double> const*, std::ostream & out);
+template bool lp::matrix<double, double>::is_equal(lp::matrix<double, double> const&);
+template void lp::print_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >(lp::matrix<lp::mpq, lp::numeric_pair<lp::mpq> > const *, std::basic_ostream<char, std::char_traits<char> > &);
+template void lp::print_matrix<lp::mpq, lp::mpq>(lp::matrix<lp::mpq, lp::mpq> const*, std::ostream&);
+template bool lp::matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::is_equal(lp::matrix<lp::mpq, lp::numeric_pair<lp::mpq> > const&);
+template bool lp::matrix<lp::mpq, lp::mpq>::is_equal(lp::matrix<lp::mpq, lp::mpq> const&);
 #endif
diff --git a/src/util/lp/mps_reader.h b/src/util/lp/mps_reader.h
index 4c793d56e..1b020407d 100644
--- a/src/util/lp/mps_reader.h
+++ b/src/util/lp/mps_reader.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 
@@ -19,7 +34,7 @@
 #include "util/lp/lar_solver.h"
 #include "util/lp/lp_utils.h"
 #include "util/lp/lp_solver.h"
-namespace lean {
+namespace lp {
 inline bool my_white_space(const char & a) {
     return a == ' ' || a == '\t';
 }
@@ -160,9 +175,9 @@ class mps_reader {
             if (m_line[i] == ' ')
                 break;
         }
-        lean_assert(m_line.size() >= offset);
-        lean_assert(m_line.size() >> i);
-        lean_assert(i >= offset);
+        SASSERT(m_line.size() >= offset);
+        SASSERT(m_line.size() >> i);
+        SASSERT(i >= offset);
         return m_line.substr(offset, i - offset);
     }
 
@@ -497,7 +512,7 @@ class mps_reader {
 
     void create_or_update_bound() {
         const unsigned name_offset = 14;
-        lean_assert(m_line.size() >= 14);
+        SASSERT(m_line.size() >= 14);
         vector<std::string> bound_string = split_and_trim(m_line.substr(name_offset, m_line.size()));
 
         if (bound_string.size() == 0) {
@@ -603,7 +618,7 @@ class mps_reader {
         }
 
         for (auto s : row_with_range->m_row_columns) {
-            lean_assert(m_columns.find(s.first) != m_columns.end());
+            SASSERT(m_columns.find(s.first) != m_columns.end());
             other_bound_range_row->m_row_columns[s.first] = s.second;
         }
     }
@@ -679,7 +694,7 @@ class mps_reader {
         if (row->m_name != m_cost_row_name) {
             solver->add_constraint(get_relation_from_row(row->m_type), row->m_right_side, row->m_index);
             for (auto s : row->m_row_columns) {
-                lean_assert(m_columns.find(s.first) != m_columns.end());
+                SASSERT(m_columns.find(s.first) != m_columns.end());
                 solver->set_row_column_coefficient(row->m_index, m_columns[s.first]->m_index, s.second);
             }
         } else {
@@ -714,7 +729,7 @@ class mps_reader {
     void set_solver_cost(row * row, lp_solver<T, X> *solver) {
         for (auto s : row->m_row_columns) {
             std::string name = s.first;
-            lean_assert(m_columns.find(name) != m_columns.end());
+            SASSERT(m_columns.find(name) != m_columns.end());
             mps_reader::column * col = m_columns[name];
             solver->set_cost_for_column(col->m_index, s.second);
         }
@@ -723,7 +738,7 @@ class mps_reader {
 public:
 
     void set_message_stream(std::ostream * o) {
-        lean_assert(o != nullptr);
+        SASSERT(o != nullptr);
         m_message_stream = o;
     }
     vector<std::string> column_names() {
diff --git a/src/util/lp/numeric_pair.h b/src/util/lp/numeric_pair.h
index 84c99b3b1..4ebe63613 100644
--- a/src/util/lp/numeric_pair.h
+++ b/src/util/lp/numeric_pair.h
@@ -1,33 +1,38 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-  The idea is that it is only one different file in Lean and z3 source inside of LP
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
-#define lp_for_z3
+
 #include <string>
 #include <cmath>
 #include <algorithm>
-#ifdef lp_for_z3
 #include "../rational.h"
 #include "../sstream.h"
 #include "../z3_exception.h"
 
-#else
- // include "util/numerics/mpq.h"
- // include "util/numerics/numeric_traits.h"
-#endif
-namespace lean {
-#ifdef lp_for_z3 // rename rationals
-    typedef rational mpq;
-#else
-    typedef lean::mpq mpq;
-#endif
+namespace lp {
+    typedef rational mpq; // rename rationals
 
 
 template <typename T>
 std::string T_to_string(const T & t); // forward definition
-#ifdef lp_for_z3
+
 template <typename T> class numeric_traits {};
 
 template <>  class numeric_traits<unsigned> {
@@ -67,14 +72,13 @@ template <>  class numeric_traits<double> {
         static bool is_pos(const rational & d) {return d.is_pos();}
         static bool is_neg(const rational & d) {return d.is_neg();}
     };
-#endif
 
 template <typename X, typename Y>
 struct convert_struct {
     static X convert(const Y & y){ return X(y);}
     static bool is_epsilon_small(const X & x,  const double & y) { return std::abs(numeric_traits<X>::get_double(x)) < y; }
-    static bool below_bound_numeric(const X &, const X &, const Y &) { /*lean_unreachable();*/ return false;}
-    static bool above_bound_numeric(const X &, const X &, const Y &) { /*lean_unreachable();*/ return false; }
+    static bool below_bound_numeric(const X &, const X &, const Y &) { /*SASSERT(false);*/ return false;}
+    static bool above_bound_numeric(const X &, const X &, const Y &) { /*SASSERT(false);*/ return false; }
 };
 
 
@@ -104,9 +108,9 @@ struct numeric_pair {
     template <typename X>
     numeric_pair(const X & n) : x(n), y(0) {
     }
-    
+
     numeric_pair(const numeric_pair<T> & n) : x(n.x), y(n.y) {}
-    
+
     template <typename X, typename Y>
     numeric_pair(X xp, Y yp) : x(convert_struct<T, X>::convert(xp)), y(convert_struct<T, Y>::convert(yp)) {}
 
@@ -144,16 +148,16 @@ struct numeric_pair {
     }
 
     numeric_pair operator/(const numeric_pair &) const {
-        // lean_unreachable();
+        // SASSERT(false);
     }
-    
-    
+
+
     numeric_pair operator+(const numeric_pair & a) const  {
         return numeric_pair(a.x + x, a.y + y);
     }
 
     numeric_pair operator*(const numeric_pair & /*a*/) const  {
-        // lean_unreachable();
+        // SASSERT(false);
     }
 
     numeric_pair&  operator+=(const numeric_pair & a) {
@@ -188,14 +192,14 @@ struct numeric_pair {
         return numeric_pair(-x, -y);
     }
 
-    static bool precize() { return lean::numeric_traits<T>::precize();}
+    static bool precize() { return lp::numeric_traits<T>::precize();}
 
     bool is_zero() const { return x.is_zero() && y.is_zero(); }
 
     bool is_pos() const { return x.is_pos() || (x.is_zero() && y.is_pos());}
 
     bool is_neg() const { return x.is_neg() || (x.is_zero() && y.is_neg());}
-    
+
     std::string to_string() const {
         return std::string("(") + T_to_string(x) + ", "  + T_to_string(y) + ")";
     }
@@ -225,15 +229,15 @@ numeric_pair<T> operator/(const numeric_pair<T> & r, const X & a) {
 }
 
 // template <numeric_pair, typename T>  bool precise() { return numeric_traits<T>::precise();}
-template <typename T> double get_double(const lean::numeric_pair<T> & ) { /* lean_unreachable(); */ return 0;}
+template <typename T> double get_double(const lp::numeric_pair<T> & ) { /* SASSERT(false); */ return 0;}
 template <typename T>
-class numeric_traits<lean::numeric_pair<T>> {
+class numeric_traits<lp::numeric_pair<T>> {
   public:
     static bool precise() { return numeric_traits<T>::precise();}
-    static lean::numeric_pair<T> zero() { return lean::numeric_pair<T>(numeric_traits<T>::zero(), numeric_traits<T>::zero()); }
-    static bool is_zero(const lean::numeric_pair<T> & v) { return numeric_traits<T>::is_zero(v.x) && numeric_traits<T>::is_zero(v.y); }
-    static double get_double(const lean::numeric_pair<T> & v){ return numeric_traits<T>::get_double(v.x); } // just return the double of the first coordinate
-    static double one() { /*lean_unreachable();*/ return 0;}
+    static lp::numeric_pair<T> zero() { return lp::numeric_pair<T>(numeric_traits<T>::zero(), numeric_traits<T>::zero()); }
+    static bool is_zero(const lp::numeric_pair<T> & v) { return numeric_traits<T>::is_zero(v.x) && numeric_traits<T>::is_zero(v.y); }
+    static double get_double(const lp::numeric_pair<T> & v){ return numeric_traits<T>::get_double(v.x); } // just return the double of the first coordinate
+    static double one() { /*SASSERT(false);*/ return 0;}
     static bool is_pos(const numeric_pair<T> &p) {
         return numeric_traits<T>::is_pos(p.x) ||
             (numeric_traits<T>::is_zero(p.x) && numeric_traits<T>::is_pos(p.y));
@@ -242,7 +246,7 @@ class numeric_traits<lean::numeric_pair<T>> {
         return numeric_traits<T>::is_neg(p.x) ||
             (numeric_traits<T>::is_zero(p.x) && numeric_traits<T>::is_neg(p.y));
     }
-            
+
 };
 
 template <>
@@ -263,11 +267,11 @@ struct convert_struct<numeric_pair<T>, double> {
         return convert_struct<T, double>::is_epsilon_small(p.x, eps) && convert_struct<T, double>::is_epsilon_small(p.y, eps);
     }
     static bool below_bound_numeric(const numeric_pair<T> &, const numeric_pair<T> &, const double &) {
-        // lean_unreachable();
+        // SASSERT(false);
         return false;
     }
     static bool above_bound_numeric(const numeric_pair<T> &, const numeric_pair<T> &, const double &) {
-        // lean_unreachable();
+        // SASSERT(false);
         return false;
     }
 };
diff --git a/src/util/lp/permutation_matrix.h b/src/util/lp/permutation_matrix.h
index 4bdd57f25..7cf64a5c7 100644
--- a/src/util/lp/permutation_matrix.h
+++ b/src/util/lp/permutation_matrix.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include "util/vector.h"
 #include <algorithm>
@@ -12,8 +27,8 @@
 #include "util/lp/lp_settings.h"
 #include "util/lp/matrix.h"
 #include "util/lp/tail_matrix.h"
-namespace lean {
-#ifdef LEAN_DEBUG
+namespace lp {
+#ifdef Z3DEBUG
     inline bool is_even(int k) {  return (k/2)*2 == k; }
 #endif
 
@@ -50,7 +65,7 @@ class permutation_matrix : public tail_matrix<T, X> {
         void init(unsigned length);
         unsigned get_rev(unsigned i) { return m_rev[i]; }
         bool is_dense() const { return false; }
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
         permutation_matrix get_inverse() const {
             return permutation_matrix(size(), m_rev);
         }
@@ -86,14 +101,14 @@ class permutation_matrix : public tail_matrix<T, X> {
         void apply_reverse_from_right_to_X(vector<X> & w);
 
         void set_val(unsigned i, unsigned pi) {
-            lean_assert(i < size() && pi < size());  m_permutation[i] = pi;  m_rev[pi] = i;  }
+            SASSERT(i < size() && pi < size());  m_permutation[i] = pi;  m_rev[pi] = i;  }
 
         void transpose_from_left(unsigned i, unsigned j);
 
         unsigned apply_reverse(unsigned i) const { return m_rev[i];  }
 
         void transpose_from_right(unsigned i, unsigned j);
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
         T get_elem(unsigned i, unsigned j) const{
             return m_permutation[i] == j? numeric_traits<T>::one() : numeric_traits<T>::zero();
         }
diff --git a/src/util/lp/permutation_matrix.hpp b/src/util/lp/permutation_matrix.hpp
index ec9af5a50..be96ca99f 100644
--- a/src/util/lp/permutation_matrix.hpp
+++ b/src/util/lp/permutation_matrix.hpp
@@ -1,10 +1,25 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include "util/vector.h"
 #include "util/lp/permutation_matrix.h"
-namespace lean {
+namespace lp {
 template <typename T, typename X> permutation_matrix<T, X>::permutation_matrix(unsigned length): m_permutation(length), m_rev(length), m_T_buffer(length), m_X_buffer(length)  {
     for (unsigned i = 0; i < length; i++) { // do not change the direction of the loop because of the vectorization bug in clang3.3
         m_permutation[i] = m_rev[i] = i;
@@ -27,7 +42,7 @@ template <typename T, typename X> void permutation_matrix<T, X>::init(unsigned l
     }
 }
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template <typename T, typename X> void permutation_matrix<T, X>::print(std::ostream & out) const {
     out << "[";
     for (unsigned i = 0; i < size(); i++) {
@@ -44,13 +59,13 @@ template <typename T, typename X> void permutation_matrix<T, X>::print(std::ostr
 
 template <typename T, typename X>
 void permutation_matrix<T, X>::apply_from_left(vector<X> & w, lp_settings & ) {
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     // dense_matrix<L, X> deb(*this);
     // L * deb_w = clone_vector<L>(w, row_count());
     // deb.apply_from_left(deb_w);
 #endif
     // std::cout << " apply_from_left " << std::endl;
-    lean_assert(m_X_buffer.size() == w.size());
+    SASSERT(m_X_buffer.size() == w.size());
     unsigned i = size();
     while (i-- > 0) {
         m_X_buffer[i] = w[m_permutation[i]];
@@ -59,8 +74,8 @@ void permutation_matrix<T, X>::apply_from_left(vector<X> & w, lp_settings & ) {
     while (i-- > 0) {
         w[i] = m_X_buffer[i];
     }
-#ifdef LEAN_DEBUG
-    // lean_assert(vectors_are_equal<L>(deb_w, w, row_count()));
+#ifdef Z3DEBUG
+    // SASSERT(vectors_are_equal<L>(deb_w, w, row_count()));
     // delete [] deb_w;
 #endif
 }
@@ -81,12 +96,12 @@ void permutation_matrix<T, X>::apply_from_left_to_T(indexed_vector<T> & w, lp_se
 }
 
 template <typename T, typename X> void permutation_matrix<T, X>::apply_from_right(vector<T> & w) {
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     // dense_matrix<T, X> deb(*this);
     // T * deb_w = clone_vector<T>(w, row_count());
     // deb.apply_from_right(deb_w);
 #endif
-    lean_assert(m_T_buffer.size() == w.size());
+    SASSERT(m_T_buffer.size() == w.size());
     for (unsigned i = 0; i < size(); i++) {
         m_T_buffer[i] = w[m_rev[i]];
     }
@@ -94,14 +109,14 @@ template <typename T, typename X> void permutation_matrix<T, X>::apply_from_righ
     for (unsigned i = 0; i < size(); i++) {
         w[i] = m_T_buffer[i];
     }
-#ifdef LEAN_DEBUG
-    // lean_assert(vectors_are_equal<T>(deb_w, w, row_count()));
+#ifdef Z3DEBUG
+    // SASSERT(vectors_are_equal<T>(deb_w, w, row_count()));
     // delete [] deb_w;
 #endif
 }
 
 template <typename T, typename X> void permutation_matrix<T, X>::apply_from_right(indexed_vector<T> & w) {
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     vector<T> wcopy(w.m_data);
     apply_from_right(wcopy);
 #endif
@@ -117,9 +132,9 @@ template <typename T, typename X> void permutation_matrix<T, X>::apply_from_righ
         unsigned pj = m_permutation[j];
         w.set_value(buffer[i], pj);
     }
-    lean_assert(w.is_OK());
-#ifdef LEAN_DEBUG
-    lean_assert(vectors_are_equal(wcopy, w.m_data));
+    SASSERT(w.is_OK());
+#ifdef Z3DEBUG
+    SASSERT(vectors_are_equal(wcopy, w.m_data));
 #endif
 }
 
@@ -147,7 +162,7 @@ void permutation_matrix<T, X>::clear_data(indexed_vector<L> & w) {
 template <typename T, typename X>template <typename L>
 void permutation_matrix<T, X>::apply_reverse_from_left(indexed_vector<L> & w) {
     // the result will be w = p(-1) * w
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     // dense_matrix<L, X> deb(get_reverse());
     // L * deb_w = clone_vector<L>(w.m_data, row_count());
     // deb.apply_from_left(deb_w);
@@ -165,8 +180,8 @@ void permutation_matrix<T, X>::apply_reverse_from_left(indexed_vector<L> & w) {
         w[j] = t[i];
         w.m_index[i] = j;
     }
-#ifdef LEAN_DEBUG
-    // lean_assert(vectors_are_equal<L>(deb_w, w.m_data, row_count()));
+#ifdef Z3DEBUG
+    // SASSERT(vectors_are_equal<L>(deb_w, w.m_data, row_count()));
     // delete [] deb_w;
 #endif
 }
@@ -174,7 +189,7 @@ void permutation_matrix<T, X>::apply_reverse_from_left(indexed_vector<L> & w) {
 template <typename T, typename X>
 void permutation_matrix<T, X>::apply_reverse_from_left_to_T(vector<T> & w) {
     // the result will be w = p(-1) * w
-    lean_assert(m_T_buffer.size() == w.size());
+    SASSERT(m_T_buffer.size() == w.size());
     unsigned i = size();
     while (i-- > 0) {
         m_T_buffer[m_permutation[i]] = w[i];
@@ -187,7 +202,7 @@ void permutation_matrix<T, X>::apply_reverse_from_left_to_T(vector<T> & w) {
 template <typename T, typename X>
 void permutation_matrix<T, X>::apply_reverse_from_left_to_X(vector<X> & w) {
     // the result will be w = p(-1) * w
-    lean_assert(m_X_buffer.size() == w.size());
+    SASSERT(m_X_buffer.size() == w.size());
     unsigned i = size();
     while (i-- > 0) {
         m_X_buffer[m_permutation[i]] = w[i];
@@ -201,7 +216,7 @@ void permutation_matrix<T, X>::apply_reverse_from_left_to_X(vector<X> & w) {
 template <typename T, typename X>
 void permutation_matrix<T, X>::apply_reverse_from_right_to_T(vector<T> & w) {
     // the result will be w = w * p(-1)
-    lean_assert(m_T_buffer.size() == w.size());
+    SASSERT(m_T_buffer.size() == w.size());
     unsigned i = size();
     while (i-- > 0) {
         m_T_buffer[i] = w[m_permutation[i]];
@@ -215,11 +230,11 @@ void permutation_matrix<T, X>::apply_reverse_from_right_to_T(vector<T> & w) {
 template <typename T, typename X>
 void permutation_matrix<T, X>::apply_reverse_from_right_to_T(indexed_vector<T> & w) {
     // the result will be w = w * p(-1)
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     // vector<T> wcopy(w.m_data);
     // apply_reverse_from_right_to_T(wcopy);
 #endif
-    lean_assert(w.is_OK());
+    SASSERT(w.is_OK());
     vector<T> tmp;
     vector<unsigned> tmp_index(w.m_index);
     for (auto i : w.m_index) {
@@ -232,15 +247,15 @@ void permutation_matrix<T, X>::apply_reverse_from_right_to_T(indexed_vector<T> &
         w.set_value(tmp[k], m_rev[j]);
     }
 
-    // lean_assert(w.is_OK());    
-    // lean_assert(vectors_are_equal(w.m_data, wcopy));
+    // SASSERT(w.is_OK());    
+    // SASSERT(vectors_are_equal(w.m_data, wcopy));
 }
 
 
 template <typename T, typename X>
 void permutation_matrix<T, X>::apply_reverse_from_right_to_X(vector<X> & w) {
     // the result will be w = w * p(-1)
-    lean_assert(m_X_buffer.size() == w.size());
+    SASSERT(m_X_buffer.size() == w.size());
     unsigned i = size();
     while (i-- > 0) {
         m_X_buffer[i] = w[m_permutation[i]];
@@ -253,7 +268,7 @@ void permutation_matrix<T, X>::apply_reverse_from_right_to_X(vector<X> & w) {
 
 template <typename T, typename X> void permutation_matrix<T, X>::transpose_from_left(unsigned i, unsigned j) {
     // the result will be this = (i,j)*this
-    lean_assert(i < size() && j < size() && i != j);
+    SASSERT(i < size() && j < size() && i != j);
     auto pi = m_rev[i];
     auto pj = m_rev[j];
     set_val(pi, j);
@@ -262,7 +277,7 @@ template <typename T, typename X> void permutation_matrix<T, X>::transpose_from_
 
 template <typename T, typename X> void permutation_matrix<T, X>::transpose_from_right(unsigned i, unsigned j) {
     // the result will be this = this * (i,j)
-    lean_assert(i < size() && j < size() && i != j);
+    SASSERT(i < size() && j < size() && i != j);
     auto pi = m_permutation[i];
     auto pj = m_permutation[j];
     set_val(i, pj);
@@ -271,7 +286,7 @@ template <typename T, typename X> void permutation_matrix<T, X>::transpose_from_
 
 template <typename T, typename X> void permutation_matrix<T, X>::multiply_by_permutation_from_left(permutation_matrix<T, X> & p) {
     m_work_array = m_permutation;
-    lean_assert(p.size() == size());
+    SASSERT(p.size() == size());
     unsigned i = size();
     while (i-- > 0) {
         set_val(i, m_work_array[p[i]]); // we have m(P)*m(Q) = m(QP), where m is the matrix of the permutation
@@ -281,7 +296,7 @@ template <typename T, typename X> void permutation_matrix<T, X>::multiply_by_per
 // this is multiplication in the matrix sense
 template <typename T, typename X> void permutation_matrix<T, X>::multiply_by_permutation_from_right(permutation_matrix<T, X> & p) {
     m_work_array = m_permutation;
-    lean_assert(p.size() == size());
+    SASSERT(p.size() == size());
     unsigned i = size();
     while (i-- > 0)
         set_val(i, p[m_work_array[i]]); // we have m(P)*m(Q) = m(QP), where m is the matrix of the permutation
@@ -289,7 +304,7 @@ template <typename T, typename X> void permutation_matrix<T, X>::multiply_by_per
 }
 
 template <typename T, typename X> void permutation_matrix<T, X>::multiply_by_reverse_from_right(permutation_matrix<T, X> & q){ // todo : condensed permutations ?
-    lean_assert(q.size() == size());
+    SASSERT(q.size() == size());
     m_work_array = m_permutation;
     // the result is this = this*q(-1)
     unsigned i = size();
diff --git a/src/util/lp/permutation_matrix_instances.cpp b/src/util/lp/permutation_matrix_instances.cpp
index 91473fabc..692d32337 100644
--- a/src/util/lp/permutation_matrix_instances.cpp
+++ b/src/util/lp/permutation_matrix_instances.cpp
@@ -1,55 +1,70 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <memory>
 #include "util/vector.h"
 #include "util/lp/permutation_matrix.hpp"
 #include "util/lp/numeric_pair.h"
-template void lean::permutation_matrix<double, double>::apply_from_right(vector<double>&);
-template void lean::permutation_matrix<double, double>::init(unsigned int);
-template void lean::permutation_matrix<lean::mpq, lean::mpq>::init(unsigned int);
-template void lean::permutation_matrix<lean::mpq, lean::numeric_pair<lean::mpq>>::init(unsigned int);
-template bool lean::permutation_matrix<double, double>::is_identity() const;
-template void lean::permutation_matrix<double, double>::multiply_by_permutation_from_left(lean::permutation_matrix<double, double>&);
-template void lean::permutation_matrix<double, double>::multiply_by_permutation_reverse_from_left(lean::permutation_matrix<double, double>&);
-template void lean::permutation_matrix<double, double>::multiply_by_reverse_from_right(lean::permutation_matrix<double, double>&);
-template lean::permutation_matrix<double, double>::permutation_matrix(unsigned int, vector<unsigned int> const&);
-template void lean::permutation_matrix<double, double>::transpose_from_left(unsigned int, unsigned int);
+template void lp::permutation_matrix<double, double>::apply_from_right(vector<double>&);
+template void lp::permutation_matrix<double, double>::init(unsigned int);
+template void lp::permutation_matrix<lp::mpq, lp::mpq>::init(unsigned int);
+template void lp::permutation_matrix<lp::mpq, lp::numeric_pair<lp::mpq>>::init(unsigned int);
+template bool lp::permutation_matrix<double, double>::is_identity() const;
+template void lp::permutation_matrix<double, double>::multiply_by_permutation_from_left(lp::permutation_matrix<double, double>&);
+template void lp::permutation_matrix<double, double>::multiply_by_permutation_reverse_from_left(lp::permutation_matrix<double, double>&);
+template void lp::permutation_matrix<double, double>::multiply_by_reverse_from_right(lp::permutation_matrix<double, double>&);
+template lp::permutation_matrix<double, double>::permutation_matrix(unsigned int, vector<unsigned int> const&);
+template void lp::permutation_matrix<double, double>::transpose_from_left(unsigned int, unsigned int);
 
-template void lean::permutation_matrix<lean::mpq, lean::mpq>::apply_from_right(vector<lean::mpq>&);
-template bool lean::permutation_matrix<lean::mpq, lean::mpq>::is_identity() const;
-template void lean::permutation_matrix<lean::mpq, lean::mpq>::multiply_by_permutation_from_left(lean::permutation_matrix<lean::mpq, lean::mpq>&);
-template void lean::permutation_matrix<lean::mpq, lean::mpq>::multiply_by_permutation_from_right(lean::permutation_matrix<lean::mpq, lean::mpq>&);
-template void lean::permutation_matrix<lean::mpq, lean::mpq>::multiply_by_permutation_reverse_from_left(lean::permutation_matrix<lean::mpq, lean::mpq>&);
-template void lean::permutation_matrix<lean::mpq, lean::mpq>::multiply_by_reverse_from_right(lean::permutation_matrix<lean::mpq, lean::mpq>&);
-template lean::permutation_matrix<lean::mpq, lean::mpq>::permutation_matrix(unsigned int);
-template void lean::permutation_matrix<lean::mpq, lean::mpq>::transpose_from_left(unsigned int, unsigned int);
-template void lean::permutation_matrix<lean::mpq, lean::mpq>::transpose_from_right(unsigned int, unsigned int);
-template void lean::permutation_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::apply_from_right(vector<lean::mpq>&);
-template bool lean::permutation_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::is_identity() const;
-template void lean::permutation_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::multiply_by_permutation_from_left(lean::permutation_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >&);
-template void lean::permutation_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::multiply_by_permutation_from_right(lean::permutation_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >&);
-template void lean::permutation_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::multiply_by_permutation_reverse_from_left(lean::permutation_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >&);
-template void lean::permutation_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::multiply_by_reverse_from_right(lean::permutation_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >&);
-template lean::permutation_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::permutation_matrix(unsigned int);
-template void lean::permutation_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::transpose_from_left(unsigned int, unsigned int);
-template void lean::permutation_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::transpose_from_right(unsigned int, unsigned int);
-template void lean::permutation_matrix<double, double>::apply_reverse_from_left<double>(lean::indexed_vector<double>&);
-template void lean::permutation_matrix<double, double>::apply_reverse_from_left_to_T(vector<double>&);
-template void lean::permutation_matrix<double, double>::apply_reverse_from_right_to_T(vector<double>&);
-template void lean::permutation_matrix<double, double>::transpose_from_right(unsigned int, unsigned int);
-template void lean::permutation_matrix<lean::mpq, lean::mpq>::apply_reverse_from_left<lean::mpq>(lean::indexed_vector<lean::mpq>&);
-template void lean::permutation_matrix<lean::mpq, lean::mpq>::apply_reverse_from_left_to_T(vector<lean::mpq>&);
-template void lean::permutation_matrix<lean::mpq, lean::mpq>::apply_reverse_from_right_to_T(vector<lean::mpq>&);
-template void lean::permutation_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::apply_reverse_from_left<lean::mpq>(lean::indexed_vector<lean::mpq>&);
-template void lean::permutation_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::apply_reverse_from_left_to_T(vector<lean::mpq>&);
-template void lean::permutation_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::apply_reverse_from_right_to_T(vector<lean::mpq >&);
-template void lean::permutation_matrix<double, double>::multiply_by_permutation_from_right(lean::permutation_matrix<double, double>&);
-template lean::permutation_matrix<double, double>::permutation_matrix(unsigned int);
-template void lean::permutation_matrix<double, double>::apply_reverse_from_left_to_X(vector<double> &);
-template void  lean::permutation_matrix< lean::mpq, lean::mpq>::apply_reverse_from_left_to_X(vector<lean::mpq> &);
-template void lean::permutation_matrix< lean::mpq, lean::numeric_pair< lean::mpq> >::apply_reverse_from_left_to_X(vector<lean::numeric_pair< lean::mpq>> &);
-template void lean::permutation_matrix<double, double>::apply_reverse_from_right_to_T(lean::indexed_vector<double>&);
-template void lean::permutation_matrix<lean::mpq, lean::mpq>::apply_reverse_from_right_to_T(lean::indexed_vector<lean::mpq>&);
-template void lean::permutation_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::apply_reverse_from_right_to_T(lean::indexed_vector<lean::mpq>&);
+template void lp::permutation_matrix<lp::mpq, lp::mpq>::apply_from_right(vector<lp::mpq>&);
+template bool lp::permutation_matrix<lp::mpq, lp::mpq>::is_identity() const;
+template void lp::permutation_matrix<lp::mpq, lp::mpq>::multiply_by_permutation_from_left(lp::permutation_matrix<lp::mpq, lp::mpq>&);
+template void lp::permutation_matrix<lp::mpq, lp::mpq>::multiply_by_permutation_from_right(lp::permutation_matrix<lp::mpq, lp::mpq>&);
+template void lp::permutation_matrix<lp::mpq, lp::mpq>::multiply_by_permutation_reverse_from_left(lp::permutation_matrix<lp::mpq, lp::mpq>&);
+template void lp::permutation_matrix<lp::mpq, lp::mpq>::multiply_by_reverse_from_right(lp::permutation_matrix<lp::mpq, lp::mpq>&);
+template lp::permutation_matrix<lp::mpq, lp::mpq>::permutation_matrix(unsigned int);
+template void lp::permutation_matrix<lp::mpq, lp::mpq>::transpose_from_left(unsigned int, unsigned int);
+template void lp::permutation_matrix<lp::mpq, lp::mpq>::transpose_from_right(unsigned int, unsigned int);
+template void lp::permutation_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::apply_from_right(vector<lp::mpq>&);
+template bool lp::permutation_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::is_identity() const;
+template void lp::permutation_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::multiply_by_permutation_from_left(lp::permutation_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >&);
+template void lp::permutation_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::multiply_by_permutation_from_right(lp::permutation_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >&);
+template void lp::permutation_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::multiply_by_permutation_reverse_from_left(lp::permutation_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >&);
+template void lp::permutation_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::multiply_by_reverse_from_right(lp::permutation_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >&);
+template lp::permutation_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::permutation_matrix(unsigned int);
+template void lp::permutation_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::transpose_from_left(unsigned int, unsigned int);
+template void lp::permutation_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::transpose_from_right(unsigned int, unsigned int);
+template void lp::permutation_matrix<double, double>::apply_reverse_from_left<double>(lp::indexed_vector<double>&);
+template void lp::permutation_matrix<double, double>::apply_reverse_from_left_to_T(vector<double>&);
+template void lp::permutation_matrix<double, double>::apply_reverse_from_right_to_T(vector<double>&);
+template void lp::permutation_matrix<double, double>::transpose_from_right(unsigned int, unsigned int);
+template void lp::permutation_matrix<lp::mpq, lp::mpq>::apply_reverse_from_left<lp::mpq>(lp::indexed_vector<lp::mpq>&);
+template void lp::permutation_matrix<lp::mpq, lp::mpq>::apply_reverse_from_left_to_T(vector<lp::mpq>&);
+template void lp::permutation_matrix<lp::mpq, lp::mpq>::apply_reverse_from_right_to_T(vector<lp::mpq>&);
+template void lp::permutation_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::apply_reverse_from_left<lp::mpq>(lp::indexed_vector<lp::mpq>&);
+template void lp::permutation_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::apply_reverse_from_left_to_T(vector<lp::mpq>&);
+template void lp::permutation_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::apply_reverse_from_right_to_T(vector<lp::mpq >&);
+template void lp::permutation_matrix<double, double>::multiply_by_permutation_from_right(lp::permutation_matrix<double, double>&);
+template lp::permutation_matrix<double, double>::permutation_matrix(unsigned int);
+template void lp::permutation_matrix<double, double>::apply_reverse_from_left_to_X(vector<double> &);
+template void  lp::permutation_matrix< lp::mpq, lp::mpq>::apply_reverse_from_left_to_X(vector<lp::mpq> &);
+template void lp::permutation_matrix< lp::mpq, lp::numeric_pair< lp::mpq> >::apply_reverse_from_left_to_X(vector<lp::numeric_pair< lp::mpq>> &);
+template void lp::permutation_matrix<double, double>::apply_reverse_from_right_to_T(lp::indexed_vector<double>&);
+template void lp::permutation_matrix<lp::mpq, lp::mpq>::apply_reverse_from_right_to_T(lp::indexed_vector<lp::mpq>&);
+template void lp::permutation_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::apply_reverse_from_right_to_T(lp::indexed_vector<lp::mpq>&);
diff --git a/src/util/lp/quick_xplain.cpp b/src/util/lp/quick_xplain.cpp
index a4b6fb0e6..f9506c056 100644
--- a/src/util/lp/quick_xplain.cpp
+++ b/src/util/lp/quick_xplain.cpp
@@ -1,9 +1,24 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include "util/lp/lar_solver.h"
-namespace lean {
+namespace lp {
 quick_xplain::quick_xplain(vector<std::pair<mpq, constraint_index>> & explanation, const lar_solver & ls, lar_solver & qsol) :
     m_explanation(explanation),
     m_parent_solver(ls),
@@ -15,7 +30,7 @@ void quick_xplain::add_constraint_to_qsol(unsigned j) {
     auto ci = m_qsol.add_constraint(ls, lar_c.m_kind, lar_c.m_right_side);
     m_local_ci_to_constraint_offsets[ci] = j;
 }
-    
+
 void quick_xplain::copy_constraint_and_add_constraint_vars(const lar_constraint& lar_c) {
     vector < std::pair<mpq, unsigned>> ls;
     for (auto & p : lar_c.get_left_side_coefficients()) {
@@ -56,9 +71,9 @@ void quick_xplain::minimize(const vector<unsigned>& u) {
         }
     }
     if (m > 0) {
-        lean_assert(m_qsol.constraint_stack_size() >= initial_stack_size);
+        SASSERT(m_qsol.constraint_stack_size() >= initial_stack_size);
         m_qsol.pop(m_qsol.constraint_stack_size() - initial_stack_size);
-        for (auto j : m_x) 
+        for (auto j : m_x)
             add_constraint_to_qsol(j);
         if (!infeasible()) {
             vector<unsigned> un;
@@ -69,11 +84,11 @@ void quick_xplain::minimize(const vector<unsigned>& u) {
     }
 }
 
-    
+
 void quick_xplain::run(vector<std::pair<mpq, constraint_index>> & explanation, const lar_solver & ls){
     if (explanation.size() <= 2) return;
     lar_solver qsol;
-    lean_assert(ls.explanation_is_correct(explanation));
+    SASSERT(ls.explanation_is_correct(explanation));
     quick_xplain q(explanation, ls, qsol);
     q.solve();
 }
@@ -109,7 +124,7 @@ bool quick_xplain::x_is_minimal() const {
         x.push_back(j);
 
     for (unsigned k = 0; k < x.size(); k++) {
-        lean_assert(is_feasible(x, x[k]));
+        SASSERT(is_feasible(x, x[k]));
     }
     return true;
 }
@@ -117,8 +132,8 @@ bool quick_xplain::x_is_minimal() const {
 void quick_xplain::solve() {
     copy_constraints_to_local_constraints();
     m_qsol.push();
-    lean_assert(m_qsol.constraint_count() == 0)
-        vector<unsigned> u;
+    SASSERT(m_qsol.constraint_count() == 0);
+    vector<unsigned> u;
     for (unsigned k = 0; k < m_constraints_in_local_vars.size(); k++)
         u.push_back(k);
     minimize(u);
@@ -127,10 +142,10 @@ void quick_xplain::solve() {
     for (unsigned i : m_x)
         add_constraint_to_qsol(i);
     m_qsol.solve();
-    lean_assert(m_qsol.get_status() == INFEASIBLE);
+    SASSERT(m_qsol.get_status() == INFEASIBLE);
     m_qsol.get_infeasibility_explanation(m_explanation);
-    lean_assert(m_qsol.explanation_is_correct(m_explanation));
-    lean_assert(x_is_minimal());
+    SASSERT(m_qsol.explanation_is_correct(m_explanation));
+    SASSERT(x_is_minimal());
     for (auto & p : m_explanation) {
         p.second = this->m_local_constraint_offset_to_external_ci[m_local_ci_to_constraint_offsets[p.second]];
     }
diff --git a/src/util/lp/quick_xplain.h b/src/util/lp/quick_xplain.h
index 9faa5f41c..952199f85 100644
--- a/src/util/lp/quick_xplain.h
+++ b/src/util/lp/quick_xplain.h
@@ -7,7 +7,7 @@ Author: Lev Nachmanson
 #include "util/vector.h"
 #include <unordered_set>
 
-namespace lean {
+namespace lp {
     class lar_solver; // forward definition
    
     class quick_xplain {
diff --git a/src/util/lp/random_updater.h b/src/util/lp/random_updater.h
index 8cb9740ea..68b14c971 100644
--- a/src/util/lp/random_updater.h
+++ b/src/util/lp/random_updater.h
@@ -12,7 +12,7 @@ Author: Lev Nachmanson
 #include "util/lp/linear_combination_iterator.h"
 // see http://research.microsoft.com/projects/z3/smt07.pdf
 // The class searches for a feasible solution with as many different values of variables as it can find
-namespace lean {
+namespace lp {
 template <typename T> struct numeric_pair; // forward definition
 class lar_core_solver; // forward definition
 class random_updater {
diff --git a/src/util/lp/random_updater.hpp b/src/util/lp/random_updater.hpp
index 7c6a0539f..5bbcdf27c 100644
--- a/src/util/lp/random_updater.hpp
+++ b/src/util/lp/random_updater.hpp
@@ -1,12 +1,27 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include "util/lp/random_updater.h"
 #include "util/lp/static_matrix.h"
 #include "util/lp/lar_solver.h"
 #include "util/vector.h"
-namespace lean {
+namespace lp {
 
 
 
@@ -36,7 +51,7 @@ random_updater::interval random_updater::get_interval_of_non_basic_var(unsigned
         ret.set_upper_bound(m_core_solver.m_r_upper_bounds[j]);
         break;
     default:
-        lean_assert(false);
+        SASSERT(false);
     }
     return ret;
 }
@@ -44,15 +59,15 @@ random_updater::interval random_updater::get_interval_of_non_basic_var(unsigned
 void random_updater::diminish_interval_for_basic_var(numeric_pair<mpq>& nb_x, unsigned j,
                                                      mpq & a,
                                                      interval & r) {
-    lean_assert(m_core_solver.m_r_heading[j] >= 0);
+    SASSERT(m_core_solver.m_r_heading[j] >= 0);
     numeric_pair<mpq> delta;
-    lean_assert(a != zero_of_type<mpq>());
+    SASSERT(a != zero_of_type<mpq>());
     switch (m_core_solver.get_column_type(j)) {
     case column_type::free_column:
         break;
     case column_type::low_bound:
         delta = m_core_solver.m_r_x[j] - m_core_solver.m_r_low_bounds[j];
-        lean_assert(delta >= zero_of_type<numeric_pair<mpq>>());
+        SASSERT(delta >= zero_of_type<numeric_pair<mpq>>());
         if (a > 0) {
             r.set_upper_bound(nb_x + delta / a);
         } else {
@@ -61,7 +76,7 @@ void random_updater::diminish_interval_for_basic_var(numeric_pair<mpq>& nb_x, un
         break;
     case column_type::upper_bound:
         delta = m_core_solver.m_r_upper_bounds()[j] - m_core_solver.m_r_x[j];
-        lean_assert(delta >= zero_of_type<numeric_pair<mpq>>());
+        SASSERT(delta >= zero_of_type<numeric_pair<mpq>>());
         if (a > 0) {
             r.set_low_bound(nb_x - delta / a);
         } else {
@@ -71,17 +86,17 @@ void random_updater::diminish_interval_for_basic_var(numeric_pair<mpq>& nb_x, un
     case column_type::boxed:
         if (a > 0) {
             delta = m_core_solver.m_r_x[j] - m_core_solver.m_r_low_bounds[j];
-            lean_assert(delta >= zero_of_type<numeric_pair<mpq>>());
+            SASSERT(delta >= zero_of_type<numeric_pair<mpq>>());
             r.set_upper_bound(nb_x + delta / a);
             delta = m_core_solver.m_r_upper_bounds()[j] - m_core_solver.m_r_x[j];
-            lean_assert(delta >= zero_of_type<numeric_pair<mpq>>());
+            SASSERT(delta >= zero_of_type<numeric_pair<mpq>>());
             r.set_low_bound(nb_x - delta / a);
         } else { // a < 0
             delta = m_core_solver.m_r_upper_bounds()[j] - m_core_solver.m_r_x[j];
-            lean_assert(delta >= zero_of_type<numeric_pair<mpq>>());
+            SASSERT(delta >= zero_of_type<numeric_pair<mpq>>());
             r.set_upper_bound(nb_x - delta / a);
             delta = m_core_solver.m_r_x[j] - m_core_solver.m_r_low_bounds[j];
-            lean_assert(delta >= zero_of_type<numeric_pair<mpq>>());
+            SASSERT(delta >= zero_of_type<numeric_pair<mpq>>());
             r.set_low_bound(nb_x + delta / a);
         }
         break;
@@ -90,7 +105,7 @@ void random_updater::diminish_interval_for_basic_var(numeric_pair<mpq>& nb_x, un
           r.set_upper_bound(nb_x);
           break;
     default:
-        lean_assert(false);
+        SASSERT(false);
     }
 }
 
@@ -113,15 +128,15 @@ random_updater::interval random_updater::find_shift_interval(unsigned j) {
 }
 
 void random_updater::shift_var(unsigned j, interval & r) {
-    lean_assert(r.contains(m_core_solver.m_r_x[j]));
-    lean_assert(m_core_solver.m_r_solver.column_is_feasible(j));
+    SASSERT(r.contains(m_core_solver.m_r_x[j]));
+    SASSERT(m_core_solver.m_r_solver.column_is_feasible(j));
     auto old_x = m_core_solver.m_r_x[j];
     remove_value(old_x);
     auto new_val = m_core_solver.m_r_x[j] = get_random_from_interval(r);
     add_value(new_val);
 
-    lean_assert(r.contains(m_core_solver.m_r_x[j]));
-    lean_assert(m_core_solver.m_r_solver.column_is_feasible(j));
+    SASSERT(r.contains(m_core_solver.m_r_x[j]));
+    SASSERT(m_core_solver.m_r_solver.column_is_feasible(j));
     auto delta = m_core_solver.m_r_x[j] - old_x;
    
     unsigned i;
@@ -130,9 +145,9 @@ void random_updater::shift_var(unsigned j, interval & r) {
     while(m_column_j->next(a, i)) {
         unsigned bj = m_core_solver.m_r_basis[i];
         m_core_solver.m_r_x[bj] -= a * delta;
-        lean_assert(m_core_solver.m_r_solver.column_is_feasible(bj));
+        SASSERT(m_core_solver.m_r_solver.column_is_feasible(bj));
     }
-    lean_assert(m_core_solver.m_r_solver.A_mult_x_is_off() == false);
+    SASSERT(m_core_solver.m_r_solver.A_mult_x_is_off() == false);
 }
 
 numeric_pair<mpq> random_updater::get_random_from_interval(interval & r) {
@@ -143,7 +158,7 @@ numeric_pair<mpq> random_updater::get_random_from_interval(interval & r) {
         return r.low_bound + numeric_pair<mpq>(rand % range, 0);
     if ((!r.low_bound_is_set) && r.upper_bound_is_set)
         return r.upper_bound - numeric_pair<mpq>(rand % range, 0);
-    lean_assert(r.low_bound_is_set && r.upper_bound_is_set);
+    SASSERT(r.low_bound_is_set && r.upper_bound_is_set);
     return r.low_bound + (rand % range) * (r.upper_bound - r.low_bound)/ range;
 }
 
@@ -183,7 +198,7 @@ void random_updater::add_value(numeric_pair<mpq>& v) {
 
 void random_updater::remove_value(numeric_pair<mpq>& v) {
     std::unordered_map<numeric_pair<mpq>, unsigned>::iterator it = m_values.find(v);
-    lean_assert(it != m_values.end());
+    SASSERT(it != m_values.end());
     it->second--;
     if (it->second == 0)
         m_values.erase((std::unordered_map<numeric_pair<mpq>, unsigned>::const_iterator)it);
diff --git a/src/util/lp/random_updater_instances.cpp b/src/util/lp/random_updater_instances.cpp
index 5b4c89bd5..4f9b880c0 100644
--- a/src/util/lp/random_updater_instances.cpp
+++ b/src/util/lp/random_updater_instances.cpp
@@ -1,5 +1,20 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include "util/lp/random_updater.hpp"
diff --git a/src/util/lp/row_eta_matrix.h b/src/util/lp/row_eta_matrix.h
index 90acb89f3..c287e263a 100644
--- a/src/util/lp/row_eta_matrix.h
+++ b/src/util/lp/row_eta_matrix.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 #include "util/vector.h"
@@ -10,26 +25,26 @@
 #include "util/lp/sparse_vector.h"
 #include "util/lp/indexed_vector.h"
 #include "util/lp/permutation_matrix.h"
-namespace lean {
+namespace lp {
     // This is the sum of a unit matrix and a lower triangular matrix
     // with non-zero elements only in one row
 template <typename T, typename X>
 class row_eta_matrix
         : public tail_matrix<T, X> {
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     unsigned m_dimension;
 #endif
     unsigned m_row_start;
     unsigned m_row;
     sparse_vector<T> m_row_vector;
 public:
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     row_eta_matrix(unsigned row_start, unsigned row, unsigned dim):
 #else
     row_eta_matrix(unsigned row_start, unsigned row):
 #endif
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     m_dimension(dim),
 #endif
     m_row_start(row_start), m_row(row) {
@@ -55,7 +70,7 @@ public:
     }
 
     void push_back(unsigned row_index, T val ) {
-        lean_assert(row_index != m_row);
+        SASSERT(row_index != m_row);
         m_row_vector.push_back(row_index, val);
     }
 
@@ -63,7 +78,7 @@ public:
     void apply_from_right(indexed_vector<T> & w);
 
     void conjugate_by_permutation(permutation_matrix<T, X> & p);
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     T get_elem(unsigned row, unsigned col) const;
     unsigned row_count() const { return m_dimension; }
     unsigned column_count() const { return m_dimension; }
diff --git a/src/util/lp/row_eta_matrix.hpp b/src/util/lp/row_eta_matrix.hpp
index 5758abeb8..969b4af7d 100644
--- a/src/util/lp/row_eta_matrix.hpp
+++ b/src/util/lp/row_eta_matrix.hpp
@@ -1,13 +1,28 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include "util/vector.h"
 #include "util/lp/row_eta_matrix.h"
-namespace lean {
+namespace lp {
 template <typename T, typename X>
 void row_eta_matrix<T, X>::apply_from_left(vector<X> & w, lp_settings &) {
-    // #ifdef LEAN_DEBUG
+    // #ifdef Z3DEBUG
     //         dense_matrix<T> deb(*this);
     //         auto clone_w = clone_vector<T>(w, m_dimension);
     //         deb.apply_from_left(clone_w, settings);
@@ -18,8 +33,8 @@ void row_eta_matrix<T, X>::apply_from_left(vector<X> & w, lp_settings &) {
         w_at_row += w[it.first] * it.second;
     }
     // w[m_row] = w_at_row;
-    // #ifdef LEAN_DEBUG
-    //         lean_assert(vectors_are_equal<T>(clone_w, w, m_dimension));
+    // #ifdef Z3DEBUG
+    //         SASSERT(vectors_are_equal<T>(clone_w, w, m_dimension));
     //         delete [] clone_w;
     // #endif
 }
@@ -43,7 +58,7 @@ void row_eta_matrix<T, X>::apply_from_left_local_to_T(indexed_vector<T> & w, lp_
         auto it = std::find(w.m_index.begin(), w.m_index.end(), m_row);
         w.m_index.erase(it);
     }
-    // TBD: lean_assert(check_vector_for_small_values(w, settings));
+    // TBD: SASSERT(check_vector_for_small_values(w, settings));
 }
 
 template <typename T, typename X>
@@ -65,14 +80,14 @@ void row_eta_matrix<T, X>::apply_from_left_local_to_X(indexed_vector<X> & w, lp_
         auto it = std::find(w.m_index.begin(), w.m_index.end(), m_row);
         w.m_index.erase(it);
     }
-    // TBD: does not compile lean_assert(check_vector_for_small_values(w, settings));
+    // TBD: does not compile SASSERT(check_vector_for_small_values(w, settings));
 }
 
 template <typename T, typename X>
 void row_eta_matrix<T, X>::apply_from_right(vector<T> & w) {
     const T & w_row = w[m_row];
     if (numeric_traits<T>::is_zero(w_row)) return;
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     // dense_matrix<T> deb(*this);
     // auto clone_w = clone_vector<T>(w, m_dimension);
     // deb.apply_from_right(clone_w);
@@ -80,18 +95,18 @@ void row_eta_matrix<T, X>::apply_from_right(vector<T> & w) {
     for (auto & it : m_row_vector.m_data) {
         w[it.first] += w_row * it.second;
     }
-#ifdef LEAN_DEBUG
-    // lean_assert(vectors_are_equal<T>(clone_w, w, m_dimension));
+#ifdef Z3DEBUG
+    // SASSERT(vectors_are_equal<T>(clone_w, w, m_dimension));
     // delete clone_w;
 #endif
 }
 
 template <typename T, typename X>
 void row_eta_matrix<T, X>::apply_from_right(indexed_vector<T> & w) {
-    lean_assert(w.is_OK());
+    SASSERT(w.is_OK());
     const T & w_row = w[m_row];
     if (numeric_traits<T>::is_zero(w_row)) return;
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     // vector<T> wcopy(w.m_data);
     // apply_from_right(wcopy);
 #endif
@@ -129,8 +144,8 @@ void row_eta_matrix<T, X>::apply_from_right(indexed_vector<T> & w) {
             }
         }
     }
-#ifdef LEAN_DEBUG
-    // lean_assert(vectors_are_equal(wcopy, w.m_data));
+#ifdef Z3DEBUG
+    // SASSERT(vectors_are_equal(wcopy, w.m_data));
 
 #endif
 }
@@ -138,7 +153,7 @@ void row_eta_matrix<T, X>::apply_from_right(indexed_vector<T> & w) {
 template <typename T, typename X>
 void row_eta_matrix<T, X>::conjugate_by_permutation(permutation_matrix<T, X> & p) {
     // this = p * this * p(-1)
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     // auto rev = p.get_reverse();
     // auto deb = ((*this) * rev);
     // deb = p * deb;
@@ -150,11 +165,11 @@ void row_eta_matrix<T, X>::conjugate_by_permutation(permutation_matrix<T, X> & p
         columns.push_back(it.first);
     for (unsigned i = static_cast<unsigned>(columns.size()); i-- > 0;)
         m_row_vector.m_data[i].first = p.get_rev(columns[i]);
-#ifdef LEAN_DEBUG
-    // lean_assert(deb == *this);
+#ifdef Z3DEBUG
+    // SASSERT(deb == *this);
 #endif
 }
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template <typename T, typename X>
 T row_eta_matrix<T, X>::get_elem(unsigned row, unsigned col) const {
     if (row == m_row){
diff --git a/src/util/lp/row_eta_matrix_instances.cpp b/src/util/lp/row_eta_matrix_instances.cpp
index c172eda11..3c4ab9bed 100644
--- a/src/util/lp/row_eta_matrix_instances.cpp
+++ b/src/util/lp/row_eta_matrix_instances.cpp
@@ -1,16 +1,31 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <memory>
 #include "util/vector.h"
 #include "util/lp/row_eta_matrix.hpp"
 #include "util/lp/lu.h"
-namespace lean {
+namespace lp {
 template void row_eta_matrix<double, double>::conjugate_by_permutation(permutation_matrix<double, double>&);
 template void row_eta_matrix<mpq, numeric_pair<mpq> >::conjugate_by_permutation(permutation_matrix<mpq, numeric_pair<mpq> >&);
 template void row_eta_matrix<mpq, mpq>::conjugate_by_permutation(permutation_matrix<mpq, mpq>&);
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template mpq row_eta_matrix<mpq, mpq>::get_elem(unsigned int, unsigned int) const;
 template mpq row_eta_matrix<mpq, numeric_pair<mpq> >::get_elem(unsigned int, unsigned int) const;
 template double row_eta_matrix<double, double>::get_elem(unsigned int, unsigned int) const;
diff --git a/src/util/lp/scaler.h b/src/util/lp/scaler.h
index 33c5a6cc4..509671528 100644
--- a/src/util/lp/scaler.h
+++ b/src/util/lp/scaler.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 #include "util/vector.h"
@@ -11,7 +26,7 @@
 #include <stdlib.h>     /* exit, EXIT_FAILURE */
 #include "util/lp/lp_utils.h"
 #include "util/lp/static_matrix.h"
-namespace lean {
+namespace lp {
 // for scaling an LP
 template <typename T, typename X>
 class scaler {
@@ -31,7 +46,7 @@ public:
         m_scaling_maximum(scaling_maximum),
         m_column_scale(column_scale),
         m_settings(settings) {
-        lean_assert(m_column_scale.size() == 0);
+        SASSERT(m_column_scale.size() == 0);
         m_column_scale.resize(m_A.column_count(), numeric_traits<T>::one());
     }
 
diff --git a/src/util/lp/scaler.hpp b/src/util/lp/scaler.hpp
index 69427eea0..ea8dc98c4 100644
--- a/src/util/lp/scaler.hpp
+++ b/src/util/lp/scaler.hpp
@@ -1,11 +1,26 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <algorithm>
 #include "util/lp/scaler.h"
 #include "util/lp/numeric_pair.h"
-namespace lean {
+namespace lp {
 // for scaling an LP
 template <typename T, typename X> T scaler<T, X>::right_side_balance() {
     T ret = zero_of_type<T>();
@@ -41,7 +56,7 @@ template <typename T, typename X>    T scaler<T, X>::A_max() const {
 template <typename T, typename X>    T scaler<T, X>::get_A_ratio() const {
     T min = A_min();
     T max = A_max();
-    lean_assert(!m_settings.abs_val_is_smaller_than_zero_tolerance(min));
+    SASSERT(!m_settings.abs_val_is_smaller_than_zero_tolerance(min));
     T ratio = max / min;
     return ratio;
 }
@@ -51,7 +66,7 @@ template <typename T, typename X>    T scaler<T, X>::get_max_ratio_on_rows() con
     unsigned i = m_A.row_count();
     while (i--) {
         T den = m_A.get_min_abs_in_row(i);
-        lean_assert(!m_settings.abs_val_is_smaller_than_zero_tolerance(den));
+        SASSERT(!m_settings.abs_val_is_smaller_than_zero_tolerance(den));
         T t = m_A.get_max_abs_in_row(i)/ den;
         if (t > ret)
             ret = t;
@@ -78,7 +93,7 @@ template <typename T, typename X>    void scaler<T, X>::scale_rows_with_geometri
     while (i--) {
         T max = m_A.get_max_abs_in_row(i);
         T min = m_A.get_min_abs_in_row(i);
-        lean_assert(max > zero_of_type<T>() && min > zero_of_type<T>());
+        SASSERT(max > zero_of_type<T>() && min > zero_of_type<T>());
         if (is_zero(max) || is_zero(min))
             continue;
         T gm = T(sqrt(numeric_traits<T>::get_double(max*min)));
diff --git a/src/util/lp/scaler_instances.cpp b/src/util/lp/scaler_instances.cpp
index f97e8098f..ba02321ea 100644
--- a/src/util/lp/scaler_instances.cpp
+++ b/src/util/lp/scaler_instances.cpp
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include "util/lp/scaler.hpp"
-template bool lean::scaler<double, double>::scale();
-template bool lean::scaler<lean::mpq, lean::mpq>::scale();
+template bool lp::scaler<double, double>::scale();
+template bool lp::scaler<lp::mpq, lp::mpq>::scale();
diff --git a/src/util/lp/signature_bound_evidence.h b/src/util/lp/signature_bound_evidence.h
index a22c188b4..e4eeb328d 100644
--- a/src/util/lp/signature_bound_evidence.h
+++ b/src/util/lp/signature_bound_evidence.h
@@ -1,11 +1,26 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include "util/lp/lp_settings.h"
 #include "util/lp/lar_constraints.h"
-namespace lean {
+namespace lp {
 struct bound_signature {
     unsigned m_i;
     bool m_at_low;
diff --git a/src/util/lp/sparse_matrix.h b/src/util/lp/sparse_matrix.h
index 7256004da..400f2bfc0 100644
--- a/src/util/lp/sparse_matrix.h
+++ b/src/util/lp/sparse_matrix.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 #include "util/vector.h"
@@ -21,11 +36,11 @@
 #include "util/lp/binary_heap_upair_queue.h"
 #include "util/lp/numeric_pair.h"
 #include "util/lp/int_set.h"
-namespace lean {
+namespace lp {
 // it is a square matrix
 template <typename T, typename X>
 class sparse_matrix
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     : public matrix<T, X>
 #endif
 {
@@ -57,7 +72,7 @@ public:
     vector<bool>                      m_processed;
     unsigned get_n_of_active_elems() const { return m_n_of_active_elems; }
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     // dense_matrix<T> m_dense;
 #endif
     /*
@@ -146,7 +161,7 @@ public:
 
     unsigned dimension() const {return static_cast<unsigned>(m_row_permutation.size());}
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     unsigned row_count() const {return dimension();}
     unsigned column_count() const {return dimension();}
 #endif
@@ -206,19 +221,19 @@ public:
     void multiply_from_right(permutation_matrix<T, X>& p) {
         //            m_dense = m_dense * p;
         m_column_permutation.multiply_by_permutation_from_right(p);
-        //            lean_assert(*this == m_dense);
+        //            SASSERT(*this == m_dense);
     }
 
     void multiply_from_left(permutation_matrix<T, X>& p) {
         //            m_dense = p * m_dense;
         m_row_permutation.multiply_by_permutation_from_left(p);
-        //            lean_assert(*this == m_dense);
+        //            SASSERT(*this == m_dense);
     }
 
     void multiply_from_left_with_reverse(permutation_matrix<T, X>& p) {
         //            m_dense = p * m_dense;
         m_row_permutation.multiply_by_permutation_reverse_from_left(p);
-        //            lean_assert(*this == m_dense);
+        //            SASSERT(*this == m_dense);
     }
 
     // adding delta columns at the end of the matrix
@@ -231,13 +246,13 @@ public:
         // dense_matrix<T, X> d(*this);
         m_column_permutation.transpose_from_left(a, b);
         // d.swap_columns(a, b);
-        // lean_assert(*this == d);
+        // SASSERT(*this == d);
     }
 
     void swap_rows(unsigned a, unsigned b) {
         m_row_permutation.transpose_from_right(a, b);
         //            m_dense.swap_rows(a, b);
-        //            lean_assert(*this == m_dense);
+        //            SASSERT(*this == m_dense);
     }
 
     void divide_row_by_constant(unsigned i, const T & t, lp_settings & settings);
@@ -286,7 +301,7 @@ public:
     template <typename L>
     void solve_U_y_indexed_only(indexed_vector<L> & y, const lp_settings&, vector<unsigned> & sorted_active_rows );
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     T get_elem(unsigned i, unsigned j) const { return get(i, j); }
     unsigned get_number_of_rows() const { return dimension(); }
     unsigned get_number_of_columns() const { return dimension(); }
@@ -341,7 +356,7 @@ public:
     bool shorten_active_matrix(unsigned row, eta_matrix<T, X> *eta_matrix);
 
     unsigned pivot_score_without_shortened_counters(unsigned i, unsigned j, unsigned k);
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     bool can_improve_score_for_row(unsigned row, unsigned score, T const & c_partial_pivoting, unsigned k);
     bool really_best_pivot(unsigned i, unsigned j, T const & c_partial_pivoting, unsigned k);
     void print_active_matrix(unsigned k, std::ostream & out);
@@ -373,7 +388,7 @@ public:
     }
 
     bool fill_eta_matrix(unsigned j, eta_matrix<T, X> ** eta);
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     bool is_upper_triangular_and_maximums_are_set_correctly_in_rows(lp_settings & settings) const;
 
     bool is_upper_triangular_until(unsigned k) const;
@@ -393,7 +408,7 @@ public:
     void process_index_recursively_for_y_U(unsigned j, vector<unsigned>  & sorted_rows);
     void resize(unsigned new_dim) {
         unsigned old_dim = dimension();
-        lean_assert(new_dim >= old_dim);
+        SASSERT(new_dim >= old_dim);
         for (unsigned j = old_dim; j < new_dim; j++) {
             m_rows.push_back(vector<indexed_value<T>>());
             m_columns.push_back(col_header());
@@ -407,7 +422,7 @@ public:
             add_new_element(j, j, numeric_traits<T>::one());
         }
     }
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 vector<T> get_full_row(unsigned i) const;
 #endif
     unsigned pivot_queue_size() const { return m_pivot_queue.size(); }
diff --git a/src/util/lp/sparse_matrix.hpp b/src/util/lp/sparse_matrix.hpp
index 32bb8ed4e..d2040d313 100644
--- a/src/util/lp/sparse_matrix.hpp
+++ b/src/util/lp/sparse_matrix.hpp
@@ -1,13 +1,28 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #include "util/vector.h"
 #include "util/lp/sparse_matrix.h"
 #include <set>
 #include <queue>
-namespace lean {
+namespace lp {
 template <typename T, typename X>
 void sparse_matrix<T, X>::copy_column_from_static_matrix(unsigned col, static_matrix<T, X> const &A, unsigned col_index_in_the_new_matrix) {
     vector<column_cell> const & A_col_vector = A.m_columns[col];
@@ -82,12 +97,12 @@ void sparse_matrix<T, X>::set_with_no_adjusting(unsigned row, unsigned col, T va
 
 template <typename T, typename X>
 void sparse_matrix<T, X>::set(unsigned row, unsigned col, T val) { // should not be used in efficient code
-    lean_assert(row < dimension() && col < dimension());
+    SASSERT(row < dimension() && col < dimension());
     //            m_dense.set_elem(row, col, val);
     row = adjust_row(row);
     col = adjust_column(col);
     set_with_no_adjusting(row, col, val);
-    //            lean_assert(*this == m_dense);
+    //            SASSERT(*this == m_dense);
 }
 
 template <typename T, typename X>
@@ -243,7 +258,7 @@ void sparse_matrix<T, X>::scan_row_to_work_vector_and_remove_pivot_column(unsign
     }
 }
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template <typename T, typename X>
 vector<T> sparse_matrix<T, X>::get_full_row(unsigned i) const {
     vector<T> r;
@@ -261,8 +276,8 @@ vector<T> sparse_matrix<T, X>::get_full_row(unsigned i) const {
 // Returns false if the resulting row is all zeroes, and true otherwise
 template <typename T, typename X>
 bool sparse_matrix<T, X>::pivot_row_to_row(unsigned i, const T& alpha, unsigned i0, lp_settings & settings ) {
-    lean_assert(i < dimension() && i0 < dimension());
-    lean_assert(i != i0);
+    SASSERT(i < dimension() && i0 < dimension());
+    SASSERT(i != i0);
     unsigned pivot_col = adjust_column(i);
     i = adjust_row(i);
     i0 = adjust_row(i0);
@@ -327,7 +342,7 @@ bool sparse_matrix<T, X>::set_row_from_work_vector_and_clean_work_vector_not_adj
         if (numeric_traits<T>::is_zero(work_vec[j])) {
             continue;
         }
-        lean_assert(!settings.abs_val_is_smaller_than_drop_tolerance(work_vec[j]));
+        SASSERT(!settings.abs_val_is_smaller_than_drop_tolerance(work_vec[j]));
         add_new_element(i0, adjust_column(j), work_vec[j]);
         work_vec[j] = numeric_traits<T>::zero();
     }
@@ -372,7 +387,7 @@ void sparse_matrix<T, X>::remove_zero_elements_and_set_data_on_existing_elements
         T val = work_vec[rj];
         if (settings.abs_val_is_smaller_than_drop_tolerance(val)) {
             remove_element(row_vals, row_el_iv);
-            lean_assert(numeric_traits<T>::is_zero(val));
+            SASSERT(numeric_traits<T>::is_zero(val));
         } else {
             m_columns[j].m_values[row_el_iv.m_other].set_value(row_el_iv.m_value = val);
             work_vec[rj] = numeric_traits<T>::zero();
@@ -393,7 +408,7 @@ void sparse_matrix<T, X>::add_columns_at_the_end(unsigned delta) {
 
 template <typename T, typename X>
 void sparse_matrix<T, X>::delete_column(int i) {
-    lean_assert(i < dimension());
+    SASSERT(i < dimension());
     for (auto cell = m_columns[i].m_head; cell != nullptr;) {
         auto next_cell = cell->m_down;
         kill_cell(cell);
@@ -403,7 +418,7 @@ void sparse_matrix<T, X>::delete_column(int i) {
 
 template <typename T, typename X>
 void sparse_matrix<T, X>::divide_row_by_constant(unsigned i, const T & t, lp_settings & settings) {
-    lean_assert(!settings.abs_val_is_smaller_than_zero_tolerance(t));
+    SASSERT(!settings.abs_val_is_smaller_than_zero_tolerance(t));
     i = adjust_row(i);
     for (auto & iv : m_rows[i]) {
         T &v = iv.m_value;
@@ -420,7 +435,7 @@ void sparse_matrix<T, X>::divide_row_by_constant(unsigned i, const T & t, lp_set
 // the matrix here has to be upper triangular
 template <typename T, typename X>
 void sparse_matrix<T, X>::solve_y_U(vector<T> & y) const { // works by rows
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     // T * rs = clone_vector<T>(y, dimension());
 #endif
     unsigned end = dimension();
@@ -436,11 +451,11 @@ void sparse_matrix<T, X>::solve_y_U(vector<T> & y) const { // works by rows
             }
         }
     }
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     // dense_matrix<T> deb(*this);
     // T * clone_y = clone_vector<T>(y, dimension());
     // deb.apply_from_right(clone_y);
-    // lean_assert(vectors_are_equal(rs, clone_y, dimension()));
+    // SASSERT(vectors_are_equal(rs, clone_y, dimension()));
     // delete [] clone_y;
     // delete [] rs;
 #endif
@@ -450,7 +465,7 @@ void sparse_matrix<T, X>::solve_y_U(vector<T> & y) const { // works by rows
 // the matrix here has to be upper triangular
 template <typename T, typename X>
 void sparse_matrix<T, X>::solve_y_U_indexed(indexed_vector<T> & y, const lp_settings & settings) {
-#if 0 && LEAN_DEBUG
+#if 0 && Z3DEBUG
     vector<T> ycopy(y.m_data);
     if (numeric_traits<T>::precise() == false)
         solve_y_U(ycopy);
@@ -474,10 +489,10 @@ void sparse_matrix<T, X>::solve_y_U_indexed(indexed_vector<T> & y, const lp_sett
             y.m_data[j] = zero_of_type<T>();
     }
 
-    lean_assert(y.is_OK());
-#if 0 && LEAN_DEBUG
+    SASSERT(y.is_OK());
+#if 0 && Z3DEBUG
     if (numeric_traits<T>::precise() == false)
-        lean_assert(vectors_are_equal(ycopy, y.m_data));
+        SASSERT(vectors_are_equal(ycopy, y.m_data));
 #endif
 }
 
@@ -537,8 +552,8 @@ void sparse_matrix<T, X>::add_delta_to_solution(const vector<L>& del, vector<L>
 template <typename T, typename X>
 template <typename L>
 void sparse_matrix<T, X>::add_delta_to_solution(const indexed_vector<L>& del, indexed_vector<L> & y) {
-//    lean_assert(del.is_OK());
- //   lean_assert(y.is_OK());
+//    SASSERT(del.is_OK());
+ //   SASSERT(y.is_OK());
     for (auto i : del.m_index) {
         y.add_value_at_index(i, del[i]);
     }
@@ -546,11 +561,11 @@ void sparse_matrix<T, X>::add_delta_to_solution(const indexed_vector<L>& del, in
 template <typename T, typename X>
 template <typename L>
 void sparse_matrix<T, X>::double_solve_U_y(indexed_vector<L>& y, const lp_settings & settings){
-    lean_assert(y.is_OK());
+    SASSERT(y.is_OK());
     indexed_vector<L> y_orig(y); // copy y aside
     vector<unsigned> active_rows;
     solve_U_y_indexed_only(y, settings, active_rows);
-    lean_assert(y.is_OK());
+    SASSERT(y.is_OK());
     find_error_in_solution_U_y_indexed(y_orig, y, active_rows);
     // y_orig contains the error now
     if (y_orig.m_index.size() * ratio_of_index_size_to_all_size<T>() < 32 * dimension()) {
@@ -563,7 +578,7 @@ void sparse_matrix<T, X>::double_solve_U_y(indexed_vector<L>& y, const lp_settin
         add_delta_to_solution(y_orig.m_data, y.m_data);
         y.restore_index_and_clean_from_data();
     }
-    lean_assert(y.is_OK());
+    SASSERT(y.is_OK());
 }
 template <typename T, typename X>
 template <typename L>
@@ -581,7 +596,7 @@ void sparse_matrix<T, X>::double_solve_U_y(vector<L>& y){
 template <typename T, typename X>
 template <typename L>
 void sparse_matrix<T, X>::solve_U_y(vector<L> & y) { // it is a column wise version
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     // T * rs = clone_vector<T>(y, dimension());
 #endif
 
@@ -595,16 +610,16 @@ void sparse_matrix<T, X>::solve_U_y(vector<L> & y) { // it is a column wise vers
             }
         }
     }
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     // dense_matrix<T> deb(*this);
     // T * clone_y = clone_vector<T>(y, dimension());
     // deb.apply_from_left(clone_y);
-    // lean_assert(vectors_are_equal(rs, clone_y, dimension()));
+    // SASSERT(vectors_are_equal(rs, clone_y, dimension()));
 #endif
 }
 template <typename T, typename X>
 void sparse_matrix<T, X>::process_index_recursively_for_y_U(unsigned j, vector<unsigned> & sorted_active_rows) {
-    lean_assert(m_processed[j] == false);
+    SASSERT(m_processed[j] == false);
     m_processed[j]=true;
     auto & row = m_rows[adjust_row(j)];
     for (auto & c : row) {
@@ -619,7 +634,7 @@ void sparse_matrix<T, X>::process_index_recursively_for_y_U(unsigned j, vector<u
 
 template <typename T, typename X>
 void sparse_matrix<T, X>::process_column_recursively(unsigned j, vector<unsigned> & sorted_active_rows) {
-    lean_assert(m_processed[j] == false);
+    SASSERT(m_processed[j] == false);
     auto & mc = m_columns[adjust_column(j)].m_values;
     for (auto & iv : mc) {
         unsigned i = adjust_row_inverse(iv.m_index);
@@ -684,12 +699,12 @@ void sparse_matrix<T, X>::solve_U_y_indexed_only(indexed_vector<L> & y, const lp
             y[j] = zero_of_type<L>();
     }
 
-    lean_assert(y.is_OK());
-#ifdef LEAN_DEBUG
+    SASSERT(y.is_OK());
+#ifdef Z3DEBUG
      // dense_matrix<T,X> deb(this);
      // vector<T> clone_y(y.m_data);
      // deb.apply_from_left(clone_y);
-     // lean_assert(vectors_are_equal(rs, clone_y));
+     // SASSERT(vectors_are_equal(rs, clone_y));
 #endif
 }
 
@@ -802,7 +817,7 @@ void sparse_matrix<T, X>::add_new_elements_of_w_and_clear_w(unsigned column_to_r
             unsigned ai = adjust_row(i);
             add_new_element(ai, column_to_replace, w_at_i);
             auto & row_chunk = m_rows[ai];
-            lean_assert(row_chunk.size() > 0);
+            SASSERT(row_chunk.size() > 0);
             if (abs(w_at_i) > abs(row_chunk[0].m_value))
                 put_max_index_to_0(row_chunk, static_cast<unsigned>(row_chunk.size()) - 1);
         }
@@ -833,7 +848,7 @@ unsigned sparse_matrix<T, X>::pivot_score(unsigned i, unsigned j) {
 
 template <typename T, typename X>
 void sparse_matrix<T, X>::enqueue_domain_into_pivot_queue() {
-    lean_assert(m_pivot_queue.size() == 0);
+    SASSERT(m_pivot_queue.size() == 0);
     for (unsigned i = 0; i < dimension(); i++) {
         auto & rh = m_rows[i];
         unsigned rnz = static_cast<unsigned>(rh.size());
@@ -919,7 +934,7 @@ void sparse_matrix<T, X>::update_active_pivots(unsigned row) {
     for (const auto & iv : m_rows[arow]) {
         col_header & ch = m_columns[iv.m_index];
         int cols = static_cast<int>(ch.m_values.size()) - ch.m_shortened_markovitz - 1;
-        lean_assert(cols >= 0);
+        SASSERT(cols >= 0);
         for (const auto &ivc : ch.m_values) {
             unsigned i = ivc.m_index;
             if (adjust_row_inverse(i) <= row) continue; // the i is not an active row
@@ -945,7 +960,7 @@ bool sparse_matrix<T, X>::shorten_active_matrix(unsigned row, eta_matrix<T, X> *
         for (auto & iv : row_values) {
             const col_header& ch = m_columns[iv.m_index];
             int cnz = static_cast<int>(ch.m_values.size()) - ch.m_shortened_markovitz - 1;
-            lean_assert(cnz >= 0);
+            SASSERT(cnz >= 0);
             m_pivot_queue.enqueue(row, iv.m_index, rnz * cnz);
         }
     }
@@ -961,25 +976,25 @@ unsigned sparse_matrix<T, X>::pivot_score_without_shortened_counters(unsigned i,
         if (adjust_row_inverse(iv.m_index) < k)
             cnz--;
     }
-    lean_assert(cnz > 0);
+    SASSERT(cnz > 0);
     return m_rows[i].m_values.size() * (cnz - 1);
 }
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template <typename T, typename X>
 bool sparse_matrix<T, X>::can_improve_score_for_row(unsigned row, unsigned score, T const & c_partial_pivoting, unsigned k) {
     unsigned arow = adjust_row(row);
     auto & row_vals = m_rows[arow].m_values;
     auto & begin_iv = row_vals[0];
     T row_max = abs(begin_iv.m_value);
-    lean_assert(adjust_column_inverse(begin_iv.m_index) >= k);
+    SASSERT(adjust_column_inverse(begin_iv.m_index) >= k);
     if (pivot_score_without_shortened_counters(arow, begin_iv.m_index, k) < score) {
         print_active_matrix(k);
         return true;
     }
     for (unsigned jj = 1; jj < row_vals.size(); jj++) {
         auto & iv = row_vals[jj];
-        lean_assert(adjust_column_inverse(iv.m_index) >= k);
-        lean_assert(abs(iv.m_value) <= row_max);
+        SASSERT(adjust_column_inverse(iv.m_index) >= k);
+        SASSERT(abs(iv.m_value) <= row_max);
         if (c_partial_pivoting * abs(iv.m_value) < row_max) continue;
         if (pivot_score_without_shortened_counters(arow, iv.m_index, k) < score) {
             print_active_matrix(k);
@@ -993,7 +1008,7 @@ template <typename T, typename X>
 bool sparse_matrix<T, X>::really_best_pivot(unsigned i, unsigned j, T const & c_partial_pivoting, unsigned k) {
     unsigned queue_pivot_score = pivot_score_without_shortened_counters(i, j, k);
     for (unsigned ii = k; ii < dimension(); ii++) {
-        lean_assert(!can_improve_score_for_row(ii, queue_pivot_score, c_partial_pivoting, k));
+        SASSERT(!can_improve_score_for_row(ii, queue_pivot_score, c_partial_pivoting, k));
     }
     return true;
 }
@@ -1026,7 +1041,7 @@ template <typename T, typename X>
 bool sparse_matrix<T, X>::pivot_queue_is_correct_for_row(unsigned i, unsigned k) {
     unsigned arow = adjust_row(i);
     for (auto & iv : m_rows[arow].m_values) {
-        lean_assert(pivot_score_without_shortened_counters(arow, iv.m_index, k + 1) ==
+        SASSERT(pivot_score_without_shortened_counters(arow, iv.m_index, k + 1) ==
                     m_pivot_queue.get_priority(arow, iv.m_index));
     }
     return true;
@@ -1035,8 +1050,8 @@ bool sparse_matrix<T, X>::pivot_queue_is_correct_for_row(unsigned i, unsigned k)
 template <typename T, typename X>
 bool sparse_matrix<T, X>::pivot_queue_is_correct_after_pivoting(int k) {
     for (unsigned i = k + 1; i < dimension(); i++ )
-        lean_assert(pivot_queue_is_correct_for_row(i, k));
-    lean_assert(m_pivot_queue.is_correct());
+        SASSERT(pivot_queue_is_correct_for_row(i, k));
+    SASSERT(m_pivot_queue.is_correct());
     return true;
 }
 #endif
@@ -1052,10 +1067,10 @@ bool sparse_matrix<T, X>::get_pivot_for_column(unsigned &i, unsigned &j, int c_p
         if (j_inv < k) continue;
         int _small = elem_is_too_small(i, j, c_partial_pivoting);
         if (!_small) {
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
             // if (!really_best_pivot(i, j, c_partial_pivoting, k)) {
             //     print_active_matrix(k);
-            //     lean_assert(false);
+            //     SASSERT(false);
             //  }
 #endif
             recover_pivot_queue(pivots_candidates_that_are_too_small);
@@ -1088,7 +1103,7 @@ bool sparse_matrix<T, X>::shorten_columns_by_pivot_row(unsigned i, unsigned pivo
     for (indexed_value<T> & iv : row_chunk) {
         unsigned j = iv.m_index;
         if (j == pivot_column) {
-            lean_assert(!col_is_active(j));
+            SASSERT(!col_is_active(j));
             continue;
         }
         m_columns[j].shorten_markovich_by_one();
@@ -1121,7 +1136,7 @@ bool sparse_matrix<T, X>::fill_eta_matrix(unsigned j, eta_matrix<T, X> ** eta) {
         return true;
     }
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     *eta = new eta_matrix<T, X>(j, dimension());
 #else
     *eta = new eta_matrix<T, X>(j);
@@ -1146,16 +1161,16 @@ bool sparse_matrix<T, X>::fill_eta_matrix(unsigned j, eta_matrix<T, X> ** eta) {
     (*eta)->divide_by_diagonal_element();
     return true;
 }
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template <typename T, typename X>
 bool sparse_matrix<T, X>::is_upper_triangular_and_maximums_are_set_correctly_in_rows(lp_settings & settings) const {
     for (unsigned i = 0; i < dimension(); i++) {
         vector<indexed_value<T>> const & row_chunk = get_row_values(i);
-        lean_assert(row_chunk.size());
+        SASSERT(row_chunk.size());
         T const & max = abs(row_chunk[0].m_value);
         unsigned ai = adjust_row_inverse(i);
         for (auto & iv : row_chunk) {
-            lean_assert(abs(iv.m_value) <= max);
+            SASSERT(abs(iv.m_value) <= max);
             unsigned aj = adjust_column_inverse(iv.m_index);
             if (!(ai <= aj || numeric_traits<T>::is_zero(iv.m_value)))
                 return false;
@@ -1193,18 +1208,18 @@ void sparse_matrix<T, X>::check_column_vs_rows(unsigned col) {
         indexed_value<T> & row_iv = column_iv_other(column_iv);
         if (row_iv.m_index != col) {
             //            std::cout << "m_other in row does not belong to column " << col << ", but to column  " << row_iv.m_index << std::endl;
-            lean_assert(false);
+            SASSERT(false);
         }
 
         if (& row_iv_other(row_iv) != &column_iv) {
             // std::cout << "row and col do not point to each other" << std::endl;
-            lean_assert(false);
+            SASSERT(false);
         }
 
         if (row_iv.m_value != column_iv.m_value) {
             // std::cout << "the data from col " << col << " for row " << column_iv.m_index << " is different in the column " << std::endl;
             // std::cout << "in the col it is " << column_iv.m_value << ", but in the row it is " << row_iv.m_value << std::endl;
-            lean_assert(false);
+            SASSERT(false);
         }
     }
 }
@@ -1217,18 +1232,18 @@ void sparse_matrix<T, X>::check_row_vs_columns(unsigned row) {
 
         if (column_iv.m_index != row) {
             // std::cout << "col_iv does not point to correct row " << row << " but to " << column_iv.m_index << std::endl;
-            lean_assert(false);
+            SASSERT(false);
         }
 
         if (& row_iv != & column_iv_other(column_iv)) {
             // std::cout << "row and col do not point to each other" << std::endl;
-            lean_assert(false);
+            SASSERT(false);
         }
 
         if (row_iv.m_value != column_iv.m_value) {
             // std::cout << "the data from col " << column_iv.m_index << " for row " << row << " is different in the column " << std::endl;
             // std::cout << "in the col it is " << column_iv.m_value << ", but in the row it is " << row_iv.m_value << std::endl;
-            lean_assert(false);
+            SASSERT(false);
         }
     }
 }
diff --git a/src/util/lp/sparse_matrix_instances.cpp b/src/util/lp/sparse_matrix_instances.cpp
index c06fcbf05..64a555bb2 100644
--- a/src/util/lp/sparse_matrix_instances.cpp
+++ b/src/util/lp/sparse_matrix_instances.cpp
@@ -1,14 +1,29 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <memory>
 #include "util/vector.h"
 #include "util/lp/lp_settings.h"
 #include "util/lp/lu.h"
 #include "util/lp/sparse_matrix.hpp"
 #include "util/lp/dense_matrix.h"
-namespace lean {
+namespace lp {
 template double sparse_matrix<double, double>::dot_product_with_row<double>(unsigned int, vector<double> const&) const;
 template void sparse_matrix<double, double>::add_new_element(unsigned int, unsigned int, const double&);
 template void sparse_matrix<double, double>::divide_row_by_constant(unsigned int, const double&, lp_settings&);
@@ -65,37 +80,37 @@ template void sparse_matrix<double, double>::double_solve_U_y<double>(indexed_ve
 template void sparse_matrix<mpq, mpq>::double_solve_U_y<mpq>(indexed_vector<mpq>&, const lp_settings&);
 template void sparse_matrix<mpq, numeric_pair<mpq>>::double_solve_U_y<mpq>(indexed_vector<mpq>&, const lp_settings&);
 template void sparse_matrix<mpq, numeric_pair<mpq> >::double_solve_U_y<numeric_pair<mpq> >(indexed_vector<numeric_pair<mpq>>&, const lp_settings&);
-template void lean::sparse_matrix<double, double>::solve_U_y_indexed_only<double>(lean::indexed_vector<double>&, const lp_settings&, vector<unsigned> &);
-template void lean::sparse_matrix<lean::mpq, lean::mpq>::solve_U_y_indexed_only<lean::mpq>(lean::indexed_vector<lean::mpq>&, const lp_settings &, vector<unsigned> &);
-#ifdef LEAN_DEBUG
+template void lp::sparse_matrix<double, double>::solve_U_y_indexed_only<double>(lp::indexed_vector<double>&, const lp_settings&, vector<unsigned> &);
+template void lp::sparse_matrix<lp::mpq, lp::mpq>::solve_U_y_indexed_only<lp::mpq>(lp::indexed_vector<lp::mpq>&, const lp_settings &, vector<unsigned> &);
+#ifdef Z3DEBUG
 template bool sparse_matrix<double, double>::is_upper_triangular_and_maximums_are_set_correctly_in_rows(lp_settings&) const;
 template bool sparse_matrix<mpq, mpq>::is_upper_triangular_and_maximums_are_set_correctly_in_rows(lp_settings&) const;
 template bool sparse_matrix<mpq, numeric_pair<mpq> >::is_upper_triangular_and_maximums_are_set_correctly_in_rows(lp_settings&) const;
 #endif
 }
-template void lean::sparse_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::solve_U_y_indexed_only<lean::mpq>(lean::indexed_vector<lean::mpq>&, const lp_settings &, vector<unsigned> &);
-template void lean::sparse_matrix<lean::mpq, lean::mpq>::solve_U_y<lean::mpq>(vector<lean::mpq>&);
-template void lean::sparse_matrix<lean::mpq, lean::mpq>::double_solve_U_y<lean::mpq>(vector<lean::mpq >&);
-template void lean::sparse_matrix<double, double>::solve_U_y<double>(vector<double>&);
-template void lean::sparse_matrix<double, double>::double_solve_U_y<double>(vector<double>&);
-template void lean::sparse_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::solve_U_y<lean::numeric_pair<lean::mpq> >(vector<lean::numeric_pair<lean::mpq> >&);
-template void lean::sparse_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::double_solve_U_y<lean::numeric_pair<lean::mpq> >(vector<lean::numeric_pair<lean::mpq> >&);
-template void lean::sparse_matrix<double, double>::find_error_in_solution_U_y_indexed<double>(lean::indexed_vector<double>&, lean::indexed_vector<double>&, const vector<unsigned> &);
-template double lean::sparse_matrix<double, double>::dot_product_with_row<double>(unsigned int, lean::indexed_vector<double> const&) const;
-template void lean::sparse_matrix<lean::mpq, lean::mpq>::find_error_in_solution_U_y_indexed<lean::mpq>(lean::indexed_vector<lean::mpq>&, lean::indexed_vector<lean::mpq>&, const vector<unsigned> &);
-template lean::mpq lean::sparse_matrix<lean::mpq, lean::mpq>::dot_product_with_row<lean::mpq>(unsigned int, lean::indexed_vector<lean::mpq> const&) const;
-template void lean::sparse_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::find_error_in_solution_U_y_indexed<lean::mpq>(lean::indexed_vector<lean::mpq>&, lean::indexed_vector<lean::mpq>&, const vector<unsigned> &);
-template lean::mpq lean::sparse_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::dot_product_with_row<lean::mpq>(unsigned int, lean::indexed_vector<lean::mpq> const&) const;
-template void lean::sparse_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::find_error_in_solution_U_y_indexed<lean::numeric_pair<lean::mpq> >(lean::indexed_vector<lean::numeric_pair<lean::mpq> >&, lean::indexed_vector<lean::numeric_pair<lean::mpq> >&, const vector<unsigned> &);
-template lean::numeric_pair<lean::mpq> lean::sparse_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::dot_product_with_row<lean::numeric_pair<lean::mpq> >(unsigned int, lean::indexed_vector<lean::numeric_pair<lean::mpq> > const&) const;
-template void lean::sparse_matrix<lean::mpq, lean::mpq>::extend_and_sort_active_rows(vector<unsigned int> const&, vector<unsigned int>&);
+template void lp::sparse_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::solve_U_y_indexed_only<lp::mpq>(lp::indexed_vector<lp::mpq>&, const lp_settings &, vector<unsigned> &);
+template void lp::sparse_matrix<lp::mpq, lp::mpq>::solve_U_y<lp::mpq>(vector<lp::mpq>&);
+template void lp::sparse_matrix<lp::mpq, lp::mpq>::double_solve_U_y<lp::mpq>(vector<lp::mpq >&);
+template void lp::sparse_matrix<double, double>::solve_U_y<double>(vector<double>&);
+template void lp::sparse_matrix<double, double>::double_solve_U_y<double>(vector<double>&);
+template void lp::sparse_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::solve_U_y<lp::numeric_pair<lp::mpq> >(vector<lp::numeric_pair<lp::mpq> >&);
+template void lp::sparse_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::double_solve_U_y<lp::numeric_pair<lp::mpq> >(vector<lp::numeric_pair<lp::mpq> >&);
+template void lp::sparse_matrix<double, double>::find_error_in_solution_U_y_indexed<double>(lp::indexed_vector<double>&, lp::indexed_vector<double>&, const vector<unsigned> &);
+template double lp::sparse_matrix<double, double>::dot_product_with_row<double>(unsigned int, lp::indexed_vector<double> const&) const;
+template void lp::sparse_matrix<lp::mpq, lp::mpq>::find_error_in_solution_U_y_indexed<lp::mpq>(lp::indexed_vector<lp::mpq>&, lp::indexed_vector<lp::mpq>&, const vector<unsigned> &);
+template lp::mpq lp::sparse_matrix<lp::mpq, lp::mpq>::dot_product_with_row<lp::mpq>(unsigned int, lp::indexed_vector<lp::mpq> const&) const;
+template void lp::sparse_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::find_error_in_solution_U_y_indexed<lp::mpq>(lp::indexed_vector<lp::mpq>&, lp::indexed_vector<lp::mpq>&, const vector<unsigned> &);
+template lp::mpq lp::sparse_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::dot_product_with_row<lp::mpq>(unsigned int, lp::indexed_vector<lp::mpq> const&) const;
+template void lp::sparse_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::find_error_in_solution_U_y_indexed<lp::numeric_pair<lp::mpq> >(lp::indexed_vector<lp::numeric_pair<lp::mpq> >&, lp::indexed_vector<lp::numeric_pair<lp::mpq> >&, const vector<unsigned> &);
+template lp::numeric_pair<lp::mpq> lp::sparse_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::dot_product_with_row<lp::numeric_pair<lp::mpq> >(unsigned int, lp::indexed_vector<lp::numeric_pair<lp::mpq> > const&) const;
+template void lp::sparse_matrix<lp::mpq, lp::mpq>::extend_and_sort_active_rows(vector<unsigned int> const&, vector<unsigned int>&);
 
-template void lean::sparse_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::extend_and_sort_active_rows(vector<unsigned int> const&, vector<unsigned int>&);
+template void lp::sparse_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::extend_and_sort_active_rows(vector<unsigned int> const&, vector<unsigned int>&);
 
-template void lean::sparse_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::solve_U_y<lean::mpq>(vector<lean::mpq >&);
-template void lean::sparse_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::double_solve_U_y<lean::mpq>(vector<lean::mpq >&);
-template void lean::sparse_matrix< lean::mpq,lean::numeric_pair< lean::mpq> >::set(unsigned int,unsigned int, lean::mpq);
-template void lean::sparse_matrix<double, double>::solve_y_U_indexed(lean::indexed_vector<double>&, const lp_settings & );
-template void lean::sparse_matrix<lean::mpq, lean::mpq>::solve_y_U_indexed(lean::indexed_vector<lean::mpq>&, const lp_settings &);
-template void lean::sparse_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::solve_y_U_indexed(lean::indexed_vector<lean::mpq>&, const lp_settings &);
+template void lp::sparse_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::solve_U_y<lp::mpq>(vector<lp::mpq >&);
+template void lp::sparse_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::double_solve_U_y<lp::mpq>(vector<lp::mpq >&);
+template void lp::sparse_matrix< lp::mpq,lp::numeric_pair< lp::mpq> >::set(unsigned int,unsigned int, lp::mpq);
+template void lp::sparse_matrix<double, double>::solve_y_U_indexed(lp::indexed_vector<double>&, const lp_settings & );
+template void lp::sparse_matrix<lp::mpq, lp::mpq>::solve_y_U_indexed(lp::indexed_vector<lp::mpq>&, const lp_settings &);
+template void lp::sparse_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::solve_y_U_indexed(lp::indexed_vector<lp::mpq>&, const lp_settings &);
 
diff --git a/src/util/lp/sparse_vector.h b/src/util/lp/sparse_vector.h
index 975cb7f28..51639674c 100644
--- a/src/util/lp/sparse_vector.h
+++ b/src/util/lp/sparse_vector.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 #include "util/vector.h"
@@ -9,7 +24,7 @@
 #include "util/debug.h"
 #include "util/lp/lp_utils.h"
 #include "util/lp/lp_settings.h"
-namespace lean {
+namespace lp {
 
 template <typename T>
 class sparse_vector {
@@ -18,7 +33,7 @@ public:
     void push_back(unsigned index, T val) {
         m_data.push_back(std::make_pair(index, val));
     }
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     T operator[] (unsigned i) const {
         for (auto &t : m_data) {
             if (t.first == i) return t.second;
@@ -27,7 +42,7 @@ public:
     }
 #endif
     void divide(T const & a) {
-        lean_assert(!lp_settings::is_eps_small_general(a, 1e-12));
+        SASSERT(!lp_settings::is_eps_small_general(a, 1e-12));
         for (auto & t : m_data) {  t.second /= a; }
     }
 
diff --git a/src/util/lp/square_dense_submatrix.h b/src/util/lp/square_dense_submatrix.h
index 019497aa5..3e88e8114 100644
--- a/src/util/lp/square_dense_submatrix.h
+++ b/src/util/lp/square_dense_submatrix.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 #include "util/vector.h"
@@ -20,7 +35,7 @@
 #include "util/lp/eta_matrix.h"
 #include "util/lp/binary_heap_upair_queue.h"
 #include "util/lp/sparse_matrix.h"
-namespace lean {
+namespace lp {
 template <typename T, typename X>
 class square_dense_submatrix : public tail_matrix<T, X> {
     // the submatrix uses the permutations of the parent matrix to access the elements
@@ -30,11 +45,11 @@ class square_dense_submatrix : public tail_matrix<T, X> {
         ref(unsigned i, square_dense_submatrix & s) :
             m_i_offset((i - s.m_index_start) * s.m_dim), m_s(s){}
         T & operator[] (unsigned j) {
-            lean_assert(j >= m_s.m_index_start);
+            SASSERT(j >= m_s.m_index_start);
             return m_s.m_v[m_i_offset + m_s.adjust_column(j) - m_s.m_index_start];
         }
         const T & operator[] (unsigned j) const {
-            lean_assert(j >= m_s.m_index_start);
+            SASSERT(j >= m_s.m_index_start);
             return m_s.m_v[m_i_offset + m_s.adjust_column(j) - m_s.m_index_start];
         }
     };
@@ -58,8 +73,8 @@ public:
     bool is_dense() const { return true; }
     
     ref operator[] (unsigned i) {
-        lean_assert(i >= m_index_start);
-        lean_assert(i < m_parent->dimension());
+        SASSERT(i >= m_index_start);
+        SASSERT(i < m_parent->dimension());
         return ref(i, *this);
     }
 
@@ -148,7 +163,7 @@ public:
                 }
             }
         }
-        lean_assert(wcopy.is_OK());
+        SASSERT(wcopy.is_OK());
         apply_from_right(w.m_data);
         w.m_index.clear();
         if (numeric_traits<T>::precise()) {
@@ -167,11 +182,11 @@ public:
             }
         }
 #else
-        lean_assert(w.is_OK());
-        lean_assert(m_work_vector.is_OK());
+        SASSERT(w.is_OK());
+        SASSERT(m_work_vector.is_OK());
         m_work_vector.resize(w.data_size());
         m_work_vector.clear();
-        lean_assert(m_work_vector.is_OK());
+        SASSERT(m_work_vector.is_OK());
         unsigned end = m_index_start + m_dim;
         for (unsigned k : w.m_index) {
             // find j such that k = adjust_row_inverse(j)
@@ -188,7 +203,7 @@ public:
             }
         }
         m_work_vector.clean_up();
-        lean_assert(m_work_vector.is_OK());
+        SASSERT(m_work_vector.is_OK());
         w = m_work_vector;
 #endif
     }
@@ -198,7 +213,7 @@ public:
 
     void apply_from_right(vector<T> & w);
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     T get_elem (unsigned i, unsigned j) const;
     unsigned row_count() const { return m_parent->row_count();}
     unsigned column_count() const { return row_count();}
diff --git a/src/util/lp/square_dense_submatrix.hpp b/src/util/lp/square_dense_submatrix.hpp
index 365c9d7f0..cbf69c5dd 100644
--- a/src/util/lp/square_dense_submatrix.hpp
+++ b/src/util/lp/square_dense_submatrix.hpp
@@ -1,10 +1,25 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include "util/vector.h"
 #include "util/lp/square_dense_submatrix.h"
-namespace lean {
+namespace lp {
 template <typename T, typename X>
 square_dense_submatrix<T, X>::square_dense_submatrix (sparse_matrix<T, X> *parent_matrix, unsigned index_start) :
     m_index_start(index_start),
@@ -18,7 +33,7 @@ square_dense_submatrix<T, X>::square_dense_submatrix (sparse_matrix<T, X> *paren
         unsigned row = parent_matrix->adjust_row(i);
         for (auto & iv : parent_matrix->get_row_values(row)) {
             unsigned j = parent_matrix->adjust_column_inverse(iv.m_index);
-            lean_assert(j>= m_index_start);
+            SASSERT(j>= m_index_start);
             m_v[row_offset + j] = iv.m_value;
         }
         row_offset += m_dim;
@@ -43,7 +58,7 @@ template <typename T, typename X> void square_dense_submatrix<T, X>::init(sparse
 template <typename T, typename X>    int square_dense_submatrix<T, X>::find_pivot_column_in_row(unsigned i) const {
     int j = -1;
     T max = zero_of_type<T>();
-    lean_assert(i >= m_index_start);
+    SASSERT(i >= m_index_start);
     unsigned row_start = (i - m_index_start) * m_dim;
     for (unsigned k = i; k < m_parent->dimension(); k++) {
         unsigned col = adjust_column(k); // this is where the column is in the row
@@ -64,14 +79,14 @@ template <typename T, typename X>    void square_dense_submatrix<T, X>::pivot(un
 }
 
 template <typename T, typename X>    void square_dense_submatrix<T, X>::pivot_row_to_row(unsigned i, unsigned row, lp_settings & settings) {
-    lean_assert(i < row);
+    SASSERT(i < row);
     unsigned pj = adjust_column(i); // the pivot column
     unsigned pjd = pj - m_index_start;
     unsigned pivot_row_offset = (i-m_index_start)*m_dim;
     T pivot = m_v[pivot_row_offset + pjd];
     unsigned row_offset= (row-m_index_start)*m_dim;
     T m = m_v[row_offset + pjd];
-    lean_assert(!is_zero(pivot));
+    SASSERT(!is_zero(pivot));
     m_v[row_offset + pjd] = -m * pivot; // creating L matrix
     for (unsigned j = m_index_start; j < m_parent->dimension(); j++) {
         if (j == pj) {
@@ -94,7 +109,7 @@ template <typename T, typename X>    void square_dense_submatrix<T, X>::divide_r
     unsigned pj = adjust_column(i); // the pivot column
     unsigned irow_offset = (i - m_index_start) * m_dim;
     T pivot = m_v[irow_offset + pj - m_index_start];
-    lean_assert(!is_zero(pivot));
+    SASSERT(!is_zero(pivot));
     for (unsigned k = m_index_start; k < m_parent->dimension(); k++) {
         if (k == pj){
             m_v[irow_offset++] = one_of_type<T>() / pivot; // creating the L matrix diagonal
@@ -158,7 +173,7 @@ template <typename T, typename X>    void square_dense_submatrix<T, X>::push_new
 template <typename T, typename X>
 template <typename L>
 L square_dense_submatrix<T, X>::row_by_vector_product(unsigned i, const vector<L> & v) {
-    lean_assert(i >= m_index_start);
+    SASSERT(i >= m_index_start);
 
     unsigned row_in_subm = i - m_index_start;
     unsigned row_offset = row_in_subm * m_dim;
@@ -171,7 +186,7 @@ L square_dense_submatrix<T, X>::row_by_vector_product(unsigned i, const vector<L
 template <typename T, typename X>
 template <typename L>
 L square_dense_submatrix<T, X>::column_by_vector_product(unsigned j, const vector<L> & v) {
-    lean_assert(j >= m_index_start);
+    SASSERT(j >= m_index_start);
 
     unsigned offset = j - m_index_start;
     L r = zero_of_type<L>();
@@ -182,7 +197,7 @@ L square_dense_submatrix<T, X>::column_by_vector_product(unsigned j, const vecto
 template <typename T, typename X>
 template <typename L>
 L square_dense_submatrix<T, X>::row_by_indexed_vector_product(unsigned i, const indexed_vector<L> & v) {
-    lean_assert(i >= m_index_start);
+    SASSERT(i >= m_index_start);
 
     unsigned row_in_subm = i - m_index_start;
     unsigned row_offset = row_in_subm * m_dim;
@@ -194,7 +209,7 @@ L square_dense_submatrix<T, X>::row_by_indexed_vector_product(unsigned i, const
 template <typename T, typename X>
 template <typename L>
 void square_dense_submatrix<T, X>::apply_from_left_local(indexed_vector<L> & w, lp_settings & settings) {
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     // dense_matrix<T, X> deb(*this);
     // vector<L>  deb_w(w.m_data.size());
     // for (unsigned i = 0; i < w.m_data.size(); i++)
@@ -246,11 +261,11 @@ void square_dense_submatrix<T, X>::apply_from_left_local(indexed_vector<L> & w,
         w.m_data[i] = v;
     }
 #endif
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     // cout << "w final" << endl;
     // print_vector(w.m_data);
-    //        lean_assert(vectors_are_equal<T>(deb_w, w.m_data));
-    // lean_assert(w.is_OK());
+    //        SASSERT(vectors_are_equal<T>(deb_w, w.m_data));
+    // SASSERT(w.is_OK());
 #endif
 }
 
@@ -277,19 +292,19 @@ void square_dense_submatrix<T, X>::apply_from_left_to_vector(vector<L> & w) {
     for (unsigned i = 0; i < m_parent->dimension(); i++) {
         w[i] = t[i];
     }
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     // cout << "w final" << endl;
     // print_vector(w.m_data);
-    //  lean_assert(vectors_are_equal<L>(deb_w, w));
+    //  SASSERT(vectors_are_equal<L>(deb_w, w));
 #endif
 }
 
 template <typename T, typename X>    bool square_dense_submatrix<T, X>::is_L_matrix() const {
-#ifdef LEAN_DEBUG
-    lean_assert(m_row_permutation.is_identity());
+#ifdef Z3DEBUG
+    SASSERT(m_row_permutation.is_identity());
     for (unsigned i = 0; i < m_parent->dimension(); i++) {
         if (i < m_index_start) {
-            lean_assert(m_column_permutation[i] == i);
+            SASSERT(m_column_permutation[i] == i);
             continue;
         }
         unsigned row_offs = (i-m_index_start)*m_dim;
@@ -297,9 +312,9 @@ template <typename T, typename X>    bool square_dense_submatrix<T, X>::is_L_mat
             unsigned j = m_index_start + k;
             unsigned jex = adjust_column_inverse(j);
             if (jex > i) {
-                lean_assert(is_zero(m_v[row_offs + k]));
+                SASSERT(is_zero(m_v[row_offs + k]));
             } else if (jex == i) {
-                lean_assert(!is_zero(m_v[row_offs + k]));
+                SASSERT(!is_zero(m_v[row_offs + k]));
             }
         }
     }
@@ -308,7 +323,7 @@ template <typename T, typename X>    bool square_dense_submatrix<T, X>::is_L_mat
 }
 
 template <typename T, typename X> void square_dense_submatrix<T, X>::apply_from_right(vector<T> & w) {
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     // dense_matrix<T, X> deb(*this);
     // vector<T>  deb_w(w);
     // deb.apply_from_right(deb_w);
@@ -326,15 +341,15 @@ template <typename T, typename X> void square_dense_submatrix<T, X>::apply_from_
         t[adjust_column_inverse(j)] = column_by_vector_product(j, w);
     }
     w = t;
-#ifdef LEAN_DEBUG
-    //  lean_assert(vector_are_equal<T>(deb_w, w));
+#ifdef Z3DEBUG
+    //  SASSERT(vector_are_equal<T>(deb_w, w));
 #endif
 }
 
 
 
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 
 template <typename T, typename X>    T square_dense_submatrix<T, X>::get_elem (unsigned i, unsigned j) const {
     i = adjust_row(i);
diff --git a/src/util/lp/square_dense_submatrix_instances.cpp b/src/util/lp/square_dense_submatrix_instances.cpp
index 7d45aaaa1..e1df0036e 100644
--- a/src/util/lp/square_dense_submatrix_instances.cpp
+++ b/src/util/lp/square_dense_submatrix_instances.cpp
@@ -1,33 +1,48 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <memory>
 #include "util/vector.h"
 #include "util/lp/square_dense_submatrix.hpp"
-template void lean::square_dense_submatrix<double, double>::init(lean::sparse_matrix<double, double>*, unsigned int);
-template lean::square_dense_submatrix<double, double>::square_dense_submatrix(lean::sparse_matrix<double, double>*, unsigned int);
-template void lean::square_dense_submatrix<double, double>::update_parent_matrix(lean::lp_settings&);
-template bool lean::square_dense_submatrix<double, double>::is_L_matrix() const;
-template void lean::square_dense_submatrix<double, double>::conjugate_by_permutation(lean::permutation_matrix<double, double>&);
-template int lean::square_dense_submatrix<double, double>::find_pivot_column_in_row(unsigned int) const;
-template void lean::square_dense_submatrix<double, double>::pivot(unsigned int, lean::lp_settings&);
-template lean::square_dense_submatrix<lean::mpq, lean::numeric_pair<lean::mpq> >::square_dense_submatrix(lean::sparse_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >*, unsigned int);
-template void lean::square_dense_submatrix<lean::mpq, lean::numeric_pair<lean::mpq> >::update_parent_matrix(lean::lp_settings&);
-template bool lean::square_dense_submatrix<lean::mpq, lean::numeric_pair<lean::mpq> >::is_L_matrix() const;
-template void lean::square_dense_submatrix<lean::mpq, lean::numeric_pair<lean::mpq> >::conjugate_by_permutation(lean::permutation_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >&);
-template int lean::square_dense_submatrix<lean::mpq, lean::numeric_pair<lean::mpq> >::find_pivot_column_in_row(unsigned int) const;
-template void lean::square_dense_submatrix<lean::mpq, lean::numeric_pair<lean::mpq> >::pivot(unsigned int, lean::lp_settings&);
-#ifdef LEAN_DEBUG
-template double lean::square_dense_submatrix<double, double>::get_elem(unsigned int, unsigned int) const;
+template void lp::square_dense_submatrix<double, double>::init(lp::sparse_matrix<double, double>*, unsigned int);
+template lp::square_dense_submatrix<double, double>::square_dense_submatrix(lp::sparse_matrix<double, double>*, unsigned int);
+template void lp::square_dense_submatrix<double, double>::update_parent_matrix(lp::lp_settings&);
+template bool lp::square_dense_submatrix<double, double>::is_L_matrix() const;
+template void lp::square_dense_submatrix<double, double>::conjugate_by_permutation(lp::permutation_matrix<double, double>&);
+template int lp::square_dense_submatrix<double, double>::find_pivot_column_in_row(unsigned int) const;
+template void lp::square_dense_submatrix<double, double>::pivot(unsigned int, lp::lp_settings&);
+template lp::square_dense_submatrix<lp::mpq, lp::numeric_pair<lp::mpq> >::square_dense_submatrix(lp::sparse_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >*, unsigned int);
+template void lp::square_dense_submatrix<lp::mpq, lp::numeric_pair<lp::mpq> >::update_parent_matrix(lp::lp_settings&);
+template bool lp::square_dense_submatrix<lp::mpq, lp::numeric_pair<lp::mpq> >::is_L_matrix() const;
+template void lp::square_dense_submatrix<lp::mpq, lp::numeric_pair<lp::mpq> >::conjugate_by_permutation(lp::permutation_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >&);
+template int lp::square_dense_submatrix<lp::mpq, lp::numeric_pair<lp::mpq> >::find_pivot_column_in_row(unsigned int) const;
+template void lp::square_dense_submatrix<lp::mpq, lp::numeric_pair<lp::mpq> >::pivot(unsigned int, lp::lp_settings&);
+#ifdef Z3DEBUG
+template double lp::square_dense_submatrix<double, double>::get_elem(unsigned int, unsigned int) const;
 #endif
-template void lean::square_dense_submatrix<double, double>::apply_from_right(vector<double>&);
+template void lp::square_dense_submatrix<double, double>::apply_from_right(vector<double>&);
    
-template void  lean::square_dense_submatrix<double, double>::apply_from_left_local<double>(lean::indexed_vector<double>&, lean::lp_settings&);
-template void  lean::square_dense_submatrix<double, double>::apply_from_left_to_vector<double>(vector<double>&);
-template lean::square_dense_submatrix<lean::mpq, lean::mpq>::square_dense_submatrix(lean::sparse_matrix<lean::mpq, lean::mpq>*, unsigned int);
-template void lean::square_dense_submatrix<lean::mpq, lean::mpq>::update_parent_matrix(lean::lp_settings&);
-template bool lean::square_dense_submatrix<lean::mpq, lean::mpq>::is_L_matrix() const;
-template void lean::square_dense_submatrix<lean::mpq, lean::mpq>::conjugate_by_permutation(lean::permutation_matrix<lean::mpq, lean::mpq>&);
-template int lean::square_dense_submatrix<lean::mpq, lean::mpq>::find_pivot_column_in_row(unsigned int) const;
-template void lean::square_dense_submatrix<lean::mpq, lean::mpq>::pivot(unsigned int, lean::lp_settings&);
+template void  lp::square_dense_submatrix<double, double>::apply_from_left_local<double>(lp::indexed_vector<double>&, lp::lp_settings&);
+template void  lp::square_dense_submatrix<double, double>::apply_from_left_to_vector<double>(vector<double>&);
+template lp::square_dense_submatrix<lp::mpq, lp::mpq>::square_dense_submatrix(lp::sparse_matrix<lp::mpq, lp::mpq>*, unsigned int);
+template void lp::square_dense_submatrix<lp::mpq, lp::mpq>::update_parent_matrix(lp::lp_settings&);
+template bool lp::square_dense_submatrix<lp::mpq, lp::mpq>::is_L_matrix() const;
+template void lp::square_dense_submatrix<lp::mpq, lp::mpq>::conjugate_by_permutation(lp::permutation_matrix<lp::mpq, lp::mpq>&);
+template int lp::square_dense_submatrix<lp::mpq, lp::mpq>::find_pivot_column_in_row(unsigned int) const;
+template void lp::square_dense_submatrix<lp::mpq, lp::mpq>::pivot(unsigned int, lp::lp_settings&);
diff --git a/src/util/lp/stacked_map.h b/src/util/lp/stacked_map.h
index 4692540dd..1bcad5649 100644
--- a/src/util/lp/stacked_map.h
+++ b/src/util/lp/stacked_map.h
@@ -1,14 +1,29 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 // this class implements a map with some stack functionality
 #include <unordered_map>
 #include <set>
 #include <stack>
-namespace lean {
+namespace lp {
 
 
 template <typename A, typename B,
@@ -33,10 +48,10 @@ public:
             m_map.emplace_replace(m_key, b);
             return *this;
         }
-        ref & operator=(const ref & b) { lean_assert(false); return *this; }
+        ref & operator=(const ref & b) { SASSERT(false); return *this; }
         operator const B&() const {
             auto it = m_map.m_map.find(m_key);
-            lean_assert(it != m_map.m_map.end());
+            SASSERT(it != m_map.m_map.end());
             return it->second;
         }
     };
@@ -73,7 +88,7 @@ public:
     const B & operator[]( const A & a) const {
         auto it = m_map.find(a);
         if (it == m_map.end()) {
-            lean_assert(false);
+            SASSERT(false);
         }
 
         return it->second;
@@ -128,7 +143,7 @@ public:
             for (auto & t: d.m_original_changed) {
                 m_map[t.first] = t.second;
             }
-            //            lean_assert(d.m_deb_copy == m_map);
+            //            SASSERT(d.m_deb_copy == m_map);
             m_stack.pop();
         }
     }
@@ -142,7 +157,7 @@ public:
         delta & d = m_stack.top();
         auto it = m_map.find(key);
         if (it == m_map.end()) {
-            lean_assert(d.m_new.find(key) == d.m_new.end());
+            SASSERT(d.m_new.find(key) == d.m_new.end());
             return;
         }
         auto &orig_changed = d.m_original_changed;
@@ -151,7 +166,7 @@ public:
             if (orig_changed.find(key) == orig_changed.end())
                 orig_changed.emplace(it->first, it->second); // need to restore
         } else { // k is new
-            lean_assert(orig_changed.find(key) == orig_changed.end());
+            SASSERT(orig_changed.find(key) == orig_changed.end());
             d.m_new.erase(nit);
         }
 
diff --git a/src/util/lp/stacked_unordered_set.h b/src/util/lp/stacked_unordered_set.h
index 69c4cf03b..6e313e6c0 100644
--- a/src/util/lp/stacked_unordered_set.h
+++ b/src/util/lp/stacked_unordered_set.h
@@ -1,14 +1,29 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 // this class implements an unordered_set with some stack functionality
 #include <unordered_set>
 #include <set>
 #include <stack>
-namespace lean {
+namespace lp {
 
 template <typename A, 
           typename Hash = std::hash<A>,
@@ -81,7 +96,7 @@ public:
             for (auto & t : d.m_erased) {
                 m_set.insert(t);
             }
-            lean_assert(d.m_deb_copy == m_set);
+            SASSERT(d.m_deb_copy == m_set);
             m_stack.pop();
         }
     }
diff --git a/src/util/lp/stacked_value.h b/src/util/lp/stacked_value.h
index 2a1e85be7..5ef7ea0c8 100644
--- a/src/util/lp/stacked_value.h
+++ b/src/util/lp/stacked_value.h
@@ -1,12 +1,27 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 // add to value the stack semantics
 #include <stack>
-namespace lean {
+namespace lp {
 template <typename T> class stacked_value {
     T m_value;    
     std::stack<T> m_stack;
diff --git a/src/util/lp/stacked_vector.h b/src/util/lp/stacked_vector.h
index 21202b7b8..0f66e93f3 100644
--- a/src/util/lp/stacked_vector.h
+++ b/src/util/lp/stacked_vector.h
@@ -7,7 +7,7 @@ Author: Lev Nachmanson
 #include <set>
 #include <stack>
 #include "util/vector.h"
-namespace lean {
+namespace lp {
 template < typename B> class stacked_vector {
     vector<unsigned> m_stack_of_vector_sizes;
     vector<unsigned> m_stack_of_change_sizes;
@@ -19,7 +19,7 @@ public:
         unsigned m_i;
     public:
         ref(stacked_vector<B> &m, unsigned key) :m_vec(m), m_i(key) {
-            lean_assert(key < m.size());
+            SASSERT(key < m.size());
         }
         ref & operator=(const B & b) {
             m_vec.emplace_replace(m_i, b);
@@ -40,7 +40,7 @@ public:
         unsigned m_i;
     public:
         ref_const(const stacked_vector<B> &m, unsigned key) :m_vec(m), m_i(key) {
-            lean_assert(key < m.size());
+            SASSERT(key < m.size());
         }
  
         operator const B&() const {
@@ -68,7 +68,7 @@ public:
 
     /*
     const B & operator[](unsigned a) const {
-        lean_assert(a < m_vector.size());
+        SASSERT(a < m_vector.size());
         return m_vector[a];
     }
     */    
@@ -88,7 +88,7 @@ public:
 
     template <typename T>  
     void pop_tail(vector<T> & v, unsigned k) {
-        lean_assert(v.size() >= k);
+        SASSERT(v.size() >= k);
         v.resize(v.size() - k);
     }
 
@@ -98,8 +98,8 @@ public:
     }
     
     void pop(unsigned k) {
-        lean_assert(m_stack_of_vector_sizes.size() >= k);
-        lean_assert(k > 0);
+        SASSERT(m_stack_of_vector_sizes.size() >= k);
+        SASSERT(k > 0);
         resize(m_vector, m_stack_of_vector_sizes[m_stack_of_vector_sizes.size() - k]);
         pop_tail(m_stack_of_vector_sizes, k);
         unsigned first_change = m_stack_of_change_sizes[m_stack_of_change_sizes.size() - k];
@@ -119,15 +119,15 @@ public:
                 return;
             
             delta & d = m_stack.back();
-            lean_assert(m_vector.size() >= d.m_size);
+            SASSERT(m_vector.size() >= d.m_size);
             while (m_vector.size() > d.m_size)
                 m_vector.pop_back();
             
             for (auto & t : d.m_original_changed) {
-                lean_assert(t.first < m_vector.size());
+                SASSERT(t.first < m_vector.size());
                 m_vector[t.first] = t.second;
             }
-            //            lean_assert(d.m_deb_copy == m_vector);
+            //            SASSERT(d.m_deb_copy == m_vector);
             m_stack.pop_back();*/
     }   
 
@@ -157,7 +157,7 @@ public:
     }
 
     unsigned peek_size(unsigned k) const {
-        lean_assert(k > 0 && k <= m_stack_of_vector_sizes.size());
+        SASSERT(k > 0 && k <= m_stack_of_vector_sizes.size());
         return m_stack_of_vector_sizes[m_stack_of_vector_sizes.size() - k];
     }
 
diff --git a/src/util/lp/static_matrix.h b/src/util/lp/static_matrix.h
index d027c105f..29b7ed646 100644
--- a/src/util/lp/static_matrix.h
+++ b/src/util/lp/static_matrix.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 #include "util/vector.h"
@@ -13,7 +28,7 @@
 #include "util/lp/permutation_matrix.h"
 #include "util/lp/linear_combination_iterator.h"
 #include <stack>
-namespace lean {
+namespace lp {
 
 struct column_cell {
     unsigned m_i; // points to the row
@@ -37,7 +52,7 @@ struct row_cell {
 // each assignment for this matrix should be issued only once!!!
 template <typename T, typename X>
 class static_matrix
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     : public matrix<T, X>
 #endif
 {
@@ -130,7 +145,7 @@ public:
     }
     
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     void regen_domain();
 #endif
 
@@ -163,7 +178,7 @@ public:
 
     T get_min_abs_in_column(unsigned column) const;
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     void check_consistency();
 #endif
 
@@ -196,14 +211,14 @@ public:
     void clean_row_work_vector(unsigned i);
 
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     unsigned get_number_of_rows() const { return row_count(); }
     unsigned get_number_of_columns() const { return column_count(); }
     virtual void set_number_of_rows(unsigned /*m*/) { }
     virtual void set_number_of_columns(unsigned /*n*/) { }
 #endif
 
-    T get_max_val_in_row(unsigned /* i */) const { lean_unreachable();   }
+    T get_max_val_in_row(unsigned /* i */) const { SASSERT(false);   }
 
     T get_balance() const;
 
@@ -219,7 +234,7 @@ public:
         for (auto & c : row) {
             unsigned j = c.m_j;
             auto & col = m_columns[j];
-            lean_assert(col[col.size() - 1].m_i == m_rows.size() -1 ); // todo : start here!!!!
+            SASSERT(col[col.size() - 1].m_i == m_rows.size() -1 ); // todo : start here!!!!
             col.pop_back();
         }
     }
@@ -227,7 +242,7 @@ public:
     
     
     void pop(unsigned k) {
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
         std::set<std::pair<unsigned, unsigned>> pairs_to_remove_from_domain;
 #endif
         
@@ -246,7 +261,7 @@ public:
                 m_columns.pop_back(); // delete the last column
             m_stack.pop();
         }
-        lean_assert(is_correct());
+        SASSERT(is_correct());
     }
 
     void multiply_row(unsigned row, T const & alpha) {
@@ -262,7 +277,7 @@ public:
     }
     
     T dot_product_with_column(const vector<T> & y, unsigned j) const {
-        lean_assert(j < column_count());
+        SASSERT(j < column_count());
         T ret = numeric_traits<T>::zero();
         for (auto & it : m_columns[j]) {
             ret += y[it.m_i] * get_val(it); // get_value_of_column_cell(it);
@@ -281,20 +296,20 @@ public:
         // now fix the columns
         for (auto & rc : m_rows[i]) {
             column_cell & cc = m_columns[rc.m_j][rc.m_offset];
-            lean_assert(cc.m_i == ii);
+            SASSERT(cc.m_i == ii);
             cc.m_i = i;
         }
         for (auto & rc : m_rows[ii]) {
             column_cell & cc = m_columns[rc.m_j][rc.m_offset];
-            lean_assert(cc.m_i == i);
+            SASSERT(cc.m_i == i);
             cc.m_i = ii;
         }
     
     }
 
     void fill_last_row_with_pivoting(linear_combination_iterator<T> & it, const vector<int> & basis_heading) {
-        lean_assert(numeric_traits<T>::precise());
-        lean_assert(row_count() > 0);
+        SASSERT(numeric_traits<T>::precise());
+        SASSERT(row_count() > 0);
         m_work_vector.resize(column_count());
         T a;
         unsigned j;
@@ -332,13 +347,13 @@ public:
             alpha = zero_of_type<T>();
             m_work_vector.erase_from_index(j);
         }
-        lean_assert(m_work_vector.is_OK());
+        SASSERT(m_work_vector.is_OK());
         unsigned last_row = row_count() - 1;
     
         for (unsigned j : m_work_vector.m_index) {
             set (last_row, j, m_work_vector.m_data[j]);
         }
-        lean_assert(column_count() > 0);
+        SASSERT(column_count() > 0);
         set(last_row, column_count() - 1, one_of_type<T>());
     }
 
@@ -354,7 +369,7 @@ public:
     template <typename L>
     L dot_product_with_row(unsigned row, const vector<L> & w) const {
         L ret = zero_of_type<L>();
-        lean_assert(row < m_rows.size());
+        SASSERT(row < m_rows.size());
         for (auto & it : m_rows[row]) {
             ret += w[it.m_j] * it.get_val();
         }
diff --git a/src/util/lp/static_matrix.hpp b/src/util/lp/static_matrix.hpp
index fb12da8c4..d8681ff93 100644
--- a/src/util/lp/static_matrix.hpp
+++ b/src/util/lp/static_matrix.hpp
@@ -1,16 +1,31 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include "util/vector.h"
 #include <utility>
 #include <set>
 #include "util/lp/static_matrix.h"
-namespace lean {
+namespace lp {
 // each assignment for this matrix should be issued only once!!!
 template <typename T, typename X>
 void  static_matrix<T, X>::init_row_columns(unsigned m, unsigned n) {
-    lean_assert(m_rows.size() == 0 && m_columns.size() == 0);
+    SASSERT(m_rows.size() == 0 && m_columns.size() == 0);
     for (unsigned i = 0; i < m; i++){
         m_rows.push_back(row_strip());
     }
@@ -30,23 +45,23 @@ template <typename T, typename X> void static_matrix<T, X>::scan_row_ii_to_offse
 
 template <typename T, typename X> bool static_matrix<T, X>::pivot_row_to_row_given_cell(unsigned i, column_cell & c, unsigned pivot_col) {
     unsigned ii = c.m_i;
-    lean_assert(i < row_count() && ii < column_count());
-    lean_assert(i != ii);
+    SASSERT(i < row_count() && ii < column_count());
+    SASSERT(i != ii);
     
 	m_became_zeros.reset();
     T alpha = -get_val(c);
-	lean_assert(!is_zero(alpha));
+	SASSERT(!is_zero(alpha));
     auto & ii_row_vals = m_rows[ii];
     remove_element(ii_row_vals, ii_row_vals[c.m_offset]);
     scan_row_ii_to_offset_vector(ii);
-    lean_assert(!is_zero(alpha));
+    SASSERT(!is_zero(alpha));
     unsigned prev_size_ii = ii_row_vals.size();
     // run over the pivot row and update row ii
     for (const auto & iv : m_rows[i]) {
         unsigned j = iv.m_j;
         if (j == pivot_col) continue;
         T alv = alpha * iv.m_value;
-		lean_assert(!is_zero(iv.m_value));
+		SASSERT(!is_zero(iv.m_value));
         int j_offs = m_vector_of_row_offsets[j];
         if (j_offs == -1) { // it is a new element
             add_new_element(ii, j, alv);
@@ -104,9 +119,9 @@ template <typename T, typename X>    void static_matrix<T, X>::init_empty_matrix
 }
 
 template <typename T, typename X>    unsigned static_matrix<T, X>::lowest_row_in_column(unsigned col) {
-    lean_assert(col < column_count());
+    SASSERT(col < column_count());
     column_strip & colstrip = m_columns[col];
-    lean_assert(colstrip.size() > 0);
+    SASSERT(colstrip.size() > 0);
     unsigned ret = 0;
     for (auto & t : colstrip) {
         if (t.m_i > ret) {
@@ -122,7 +137,7 @@ template <typename T, typename X>    void static_matrix<T, X>::add_columns_at_th
 }
 
 template <typename T, typename X>    void static_matrix<T, X>::forget_last_columns(unsigned how_many_to_forget) {
-    lean_assert(m_columns.size() >= how_many_to_forget);
+    SASSERT(m_columns.size() >= how_many_to_forget);
     unsigned j = column_count() - 1;
     for (; how_many_to_forget > 0; how_many_to_forget--) {
         remove_last_column(j --);
@@ -151,7 +166,7 @@ template <typename T, typename X> void static_matrix<T, X>::remove_last_column(u
 
 template <typename T, typename X>    void static_matrix<T, X>::set(unsigned row, unsigned col, T const & val) {
     if (numeric_traits<T>::is_zero(val)) return;
-    lean_assert(row < row_count() && col < column_count());
+    SASSERT(row < row_count() && col < column_count());
     auto & r = m_rows[row];
     unsigned offs_in_cols = static_cast<unsigned>(m_columns[col].size());
     m_columns[col].push_back(make_column_cell(row, static_cast<unsigned>(r.size())));
@@ -171,7 +186,7 @@ std::set<std::pair<unsigned, unsigned>>  static_matrix<T, X>::get_domain() {
 
 
 template <typename T, typename X>    void static_matrix<T, X>::copy_column_to_indexed_vector (unsigned j, indexed_vector<T> & v) const {
-    lean_assert(j < m_columns.size());
+    SASSERT(j < m_columns.size());
     for (auto & it : m_columns[j]) {
         const T& val = get_val(it);
         if (!is_zero(val))
@@ -234,13 +249,13 @@ template <typename T, typename X>     T static_matrix<T, X>::get_min_abs_in_colu
     return ret;
 }
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template <typename T, typename X>    void static_matrix<T, X>::check_consistency() {
     std::unordered_map<std::pair<unsigned, unsigned>, T> by_rows;
     for (int i = 0; i < m_rows.size(); i++){
         for (auto & t : m_rows[i]) {
             std::pair<unsigned, unsigned> p(i, t.m_j);
-            lean_assert(by_rows.find(p) == by_rows.end());
+            SASSERT(by_rows.find(p) == by_rows.end());
             by_rows[p] = t.get_val();
         }
     }
@@ -248,11 +263,11 @@ template <typename T, typename X>    void static_matrix<T, X>::check_consistency
     for (int i = 0; i < m_columns.size(); i++){
         for (auto & t : m_columns[i]) {
             std::pair<unsigned, unsigned> p(t.m_i, i);
-            lean_assert(by_cols.find(p) == by_cols.end());
+            SASSERT(by_cols.find(p) == by_cols.end());
             by_cols[p] = get_val(t);
         }
     }
-    lean_assert(by_rows.size() == by_cols.size());
+    SASSERT(by_rows.size() == by_cols.size());
 
     for (auto & t : by_rows) {
         auto ic = by_cols.find(t.first);
@@ -260,21 +275,21 @@ template <typename T, typename X>    void static_matrix<T, X>::check_consistency
             //std::cout << "rows have pair (" << t.first.first <<"," << t.first.second
             //         << "), but columns don't " << std::endl;
         }
-        lean_assert(ic != by_cols.end());
-        lean_assert(t.second == ic->second);
+        SASSERT(ic != by_cols.end());
+        SASSERT(t.second == ic->second);
     }
 }
 #endif
 
 
 template <typename T, typename X>    void static_matrix<T, X>::cross_out_row(unsigned k) {
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     check_consistency();
 #endif
     cross_out_row_from_columns(k, m_rows[k]);
     fix_row_indices_in_each_column_for_crossed_row(k);
     m_rows.erase(m_rows.begin() + k);
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     regen_domain();
     check_consistency();
 #endif
diff --git a/src/util/lp/static_matrix_instances.cpp b/src/util/lp/static_matrix_instances.cpp
index ef4374a50..c57f31177 100644
--- a/src/util/lp/static_matrix_instances.cpp
+++ b/src/util/lp/static_matrix_instances.cpp
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #include <memory>
 #include <set>
 #include <utility>
@@ -13,18 +28,18 @@
 #include "util/lp/lp_primal_core_solver.h"
 #include "util/lp/scaler.h"
 #include "util/lp/lar_solver.h"
-namespace lean {
+namespace lp {
 template void static_matrix<double, double>::add_columns_at_the_end(unsigned int);
 template void static_matrix<double, double>::clear();
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template bool static_matrix<double, double>::is_correct() const;
 #endif
 template void static_matrix<double, double>::copy_column_to_indexed_vector(unsigned int, indexed_vector<double>&) const;
 
 template double static_matrix<double, double>::get_balance() const;
 template std::set<std::pair<unsigned, unsigned>> static_matrix<double, double>::get_domain();
-template std::set<std::pair<unsigned, unsigned>> lean::static_matrix<lean::mpq, lean::mpq>::get_domain();
-template std::set<std::pair<unsigned, unsigned>> lean::static_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::get_domain();
+template std::set<std::pair<unsigned, unsigned>> lp::static_matrix<lp::mpq, lp::mpq>::get_domain();
+template std::set<std::pair<unsigned, unsigned>> lp::static_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::get_domain();
 template double static_matrix<double, double>::get_elem(unsigned int, unsigned int) const;
 template double static_matrix<double, double>::get_max_abs_in_column(unsigned int) const;
 template double static_matrix<double, double>::get_min_abs_in_column(unsigned int) const;
@@ -51,7 +66,7 @@ template static_matrix<mpq, mpq>::ref& static_matrix<mpq, mpq>::ref::operator=(m
 template void static_matrix<mpq, mpq>::set(unsigned int, unsigned int, mpq const&);
 
 template static_matrix<mpq, mpq>::static_matrix(unsigned int, unsigned int);
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template bool static_matrix<mpq, numeric_pair<mpq> >::is_correct() const;
 #endif
 template void static_matrix<mpq, numeric_pair<mpq> >::copy_column_to_indexed_vector(unsigned int, indexed_vector<mpq>&) const;
@@ -60,10 +75,10 @@ template void static_matrix<mpq, numeric_pair<mpq> >::init_empty_matrix(unsigned
 template void static_matrix<mpq, numeric_pair<mpq> >::set(unsigned int, unsigned int, mpq const&);
 
 
-template bool lean::static_matrix<double, double>::pivot_row_to_row_given_cell(unsigned int, column_cell &, unsigned int);
-template bool lean::static_matrix<lean::mpq, lean::mpq>::pivot_row_to_row_given_cell(unsigned int, column_cell& , unsigned int);
-template bool lean::static_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::pivot_row_to_row_given_cell(unsigned int, column_cell&, unsigned int);
-template void lean::static_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::remove_element(vector<lean::row_cell<lean::mpq>, true, unsigned int>&, lean::row_cell<lean::mpq>&);
+template bool lp::static_matrix<double, double>::pivot_row_to_row_given_cell(unsigned int, column_cell &, unsigned int);
+template bool lp::static_matrix<lp::mpq, lp::mpq>::pivot_row_to_row_given_cell(unsigned int, column_cell& , unsigned int);
+template bool lp::static_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::pivot_row_to_row_given_cell(unsigned int, column_cell&, unsigned int);
+template void lp::static_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::remove_element(vector<lp::row_cell<lp::mpq>, true, unsigned int>&, lp::row_cell<lp::mpq>&);
 
 }
 
diff --git a/src/util/lp/tail_matrix.h b/src/util/lp/tail_matrix.h
index c337b0933..37b217205 100644
--- a/src/util/lp/tail_matrix.h
+++ b/src/util/lp/tail_matrix.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 #include "util/vector.h"
@@ -10,10 +25,10 @@
 #include "util/lp/lp_settings.h"
 // These matrices appear at the end of the list
 
-namespace lean {
+namespace lp {
 template <typename T, typename X>
 class tail_matrix
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     : public matrix<T, X>
 #endif
 {
diff --git a/src/util/lp/test_bound_analyzer.h b/src/util/lp/test_bound_analyzer.h
index 262c610c7..30f2dd16a 100644
--- a/src/util/lp/test_bound_analyzer.h
+++ b/src/util/lp/test_bound_analyzer.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 #pragma once
 #include "util/vector.h"
 #include "util/lp/linear_combination_iterator.h"
@@ -16,7 +31,7 @@
 // In the same loop trying to pin variables by pushing the partial sum up, denoting the variable related to it by _l
 
 // here in addition we assume that all coefficient in the row are positive
-namespace lean {
+namespace lp {
 
 class test_bound_analyzer {
     linear_combination_iterator<mpq> & m_it;
@@ -74,7 +89,7 @@ public :
     void analyze_i_for_upper(unsigned i) {
         mpq l;
         bool strict = false;
-        lean_assert(is_zero(l));
+        SASSERT(is_zero(l));
         for (unsigned k = 0; k < m_index.size(); k++) {
             if (k == i)
                 continue;
@@ -165,7 +180,7 @@ public :
 
     void analyze_i_for_lower(unsigned i) {
         mpq l;
-        lean_assert(is_zero(l));
+        SASSERT(is_zero(l));
         bool strict = false;
         for (unsigned k = 0; k < m_index.size(); k++) {
             if (k == i)
diff --git a/src/util/lp/ul_pair.h b/src/util/lp/ul_pair.h
index 6331d17b5..cbf511d90 100644
--- a/src/util/lp/ul_pair.h
+++ b/src/util/lp/ul_pair.h
@@ -1,7 +1,22 @@
-/*
-  Copyright (c) 2017 Microsoft Corporation
-  Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 #include "util/vector.h"
@@ -10,7 +25,7 @@
 #include <utility>
 #include "util/lp/column_info.h"
 
-namespace lean {
+namespace lp {
 
     enum lconstraint_kind {
         LE = -2, LT = -1 , GE = 2, GT = 1, EQ = 0

From 6d51265d9de9324330a87ea5323a78e76981192b Mon Sep 17 00:00:00 2001
From: "Christoph M. Wintersteiger" <cwinter@microsoft.com>
Date: Sun, 17 Sep 2017 17:14:30 +0100
Subject: [PATCH 04/10] Cleaned up LP test code.

---
 src/test/argument_parser.h  |  25 ++-
 src/test/lp.cpp             | 297 +++++++++++++++++++-----------------
 src/test/smt_reader.h       |  53 ++++---
 src/test/test_file_reader.h |  26 +++-
 4 files changed, 229 insertions(+), 172 deletions(-)

diff --git a/src/test/argument_parser.h b/src/test/argument_parser.h
index 706167f49..c8566ce34 100644
--- a/src/test/argument_parser.h
+++ b/src/test/argument_parser.h
@@ -1,9 +1,22 @@
-/*
-Copyright (c) 2013 Microsoft Corporation. All rights reserved.
-Released under Apache 2.0 license as described in the file LICENSE.
+/*++
+Copyright (c) 2017 Microsoft Corporation
 
-Author: Lev Nachmanson
-*/
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #include <unordered_map>
 #include <vector>
@@ -11,7 +24,7 @@ Author: Lev Nachmanson
 #include <set>
 #include <iostream>
 
-namespace lean {
+namespace lp {
 class argument_parser {
     std::unordered_map<std::string, std::string> m_options;
     std::unordered_map<std::string, std::string> m_options_with_after_string;
diff --git a/src/test/lp.cpp b/src/test/lp.cpp
index 695a31cf4..0f4186252 100644
--- a/src/test/lp.cpp
+++ b/src/test/lp.cpp
@@ -1,7 +1,23 @@
-/*
-Copyright (c) 2017 Microsoft Corporation. All rights reserved.
-Author: Lev Nachmanson
-*/
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
+
 #include <limits>
 #if _LINUX_
 #include <dirent.h>
@@ -31,8 +47,9 @@ Author: Lev Nachmanson
 #include "util/lp/stacked_unordered_set.h"
 #include "util/lp/int_set.h"
 #include "util/stopwatch.h"
-namespace lean {
-unsigned seed = 1;
+
+namespace lp {
+    unsigned seed = 1;
 
     random_gen g_rand;
     static unsigned my_random() {
@@ -78,7 +95,7 @@ void test_matrix(sparse_matrix<T, X> & a) {
 
     a.set(i, j, t);
 
-    lean_assert(a.get(i, j) == t);
+    SASSERT(a.get(i, j) == t);
 
     unsigned j1;
     if (j < m - 1) {
@@ -155,7 +172,7 @@ void tst1() {
 
     test_matrix(m10by9);
     std::cout <<"zeroing m10by9\n";
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     for (unsigned int i = 0; i < m10by9.dimension(); i++)
         for (unsigned int j = 0; j < m10by9.column_count(); j++)
             m10by9.set(i, j, 0);
@@ -170,7 +187,7 @@ vector<int> allocate_basis_heading(unsigned count) { // the rest of initilizatio
 
 
 void init_basic_part_of_basis_heading(vector<unsigned> & basis, vector<int> & basis_heading) {
-    lean_assert(basis_heading.size() >= basis.size());
+    SASSERT(basis_heading.size() >= basis.size());
     unsigned m = basis.size();
     for (unsigned i = 0; i < m; i++) {
         unsigned column = basis[i];
@@ -205,7 +222,7 @@ void change_basis(unsigned entering, unsigned leaving, vector<unsigned>& basis,
 }
 
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 void test_small_lu(lp_settings & settings) {
     std::cout << " test_small_lu" << std::endl;
     static_matrix<double, double> m(3, 6);
@@ -218,61 +235,61 @@ void test_small_lu(lp_settings & settings) {
     m(1, 1) = 4; m(1, 4) = 7;
     m(2, 0) = 1.8; m(2, 2) = 5; m(2, 4) = 2; m(2, 5) = 8;
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     print_matrix(m, std::cout);
 #endif
     vector<int> heading = allocate_basis_heading(m.column_count());
     vector<unsigned> non_basic_columns;
     init_basis_heading_and_non_basic_columns_vector(basis, heading, non_basic_columns);
     lu<double, double> l(m, basis, settings);
-    lean_assert(l.is_correct(basis));
+    SASSERT(l.is_correct(basis));
     indexed_vector<double> w(m.row_count());
     std::cout << "entering 2, leaving 0" << std::endl;
     l.prepare_entering(2, w); // to init vector w
     l.replace_column(0, w, heading[0]);
     change_basis(2, 0, basis, non_basic_columns, heading);
-    // #ifdef LEAN_DEBUG
+    // #ifdef Z3DEBUG
     // std::cout << "we were factoring " << std::endl;
     // print_matrix(get_B(l));
     // #endif
-    lean_assert(l.is_correct(basis));
+    SASSERT(l.is_correct(basis));
     std::cout << "entering 4, leaving 3" << std::endl;
     l.prepare_entering(4, w); // to init vector w
     l.replace_column(0, w, heading[3]);
     change_basis(4, 3, basis, non_basic_columns, heading);
     std::cout << "we were factoring " << std::endl;
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     {
         auto bl = get_B(l, basis);
         print_matrix(&bl, std::cout);
     }
 #endif
-    lean_assert(l.is_correct(basis));
+    SASSERT(l.is_correct(basis));
 
     std::cout << "entering 5, leaving 1" << std::endl;
     l.prepare_entering(5, w); // to init vector w
     l.replace_column(0, w, heading[1]);
     change_basis(5, 1, basis, non_basic_columns, heading);
     std::cout << "we were factoring " << std::endl;
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     {
         auto bl = get_B(l, basis);
         print_matrix(&bl, std::cout);
     }
 #endif
-    lean_assert(l.is_correct(basis));
+    SASSERT(l.is_correct(basis));
     std::cout << "entering 3, leaving 2" << std::endl;
     l.prepare_entering(3, w); // to init vector w
     l.replace_column(0, w, heading[2]);
     change_basis(3, 2, basis, non_basic_columns, heading);
     std::cout << "we were factoring " << std::endl;
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     {
         auto bl = get_B(l, basis);
         print_matrix(&bl, std::cout);
     }
 #endif
-    lean_assert(l.is_correct(basis));
+    SASSERT(l.is_correct(basis));
 
     m.add_row();
     m.add_column();
@@ -291,7 +308,7 @@ void test_small_lu(lp_settings & settings) {
     auto columns_to_replace = l.get_set_of_columns_to_replace_for_add_last_rows(heading);
     l.add_last_rows_to_B(heading, columns_to_replace);
     std::cout << "here" << std::endl;
-    lean_assert(l.is_correct(basis));
+    SASSERT(l.is_correct(basis));
 }
 
 #endif
@@ -351,7 +368,7 @@ void fill_larger_sparse_matrix(static_matrix<double, double> & m){
 
 int perm_id = 0;
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 void test_larger_lu_exp(lp_settings & settings) {
     std::cout << " test_larger_lu_exp" << std::endl;
     static_matrix<double, double> m(6, 12);
@@ -373,7 +390,7 @@ void test_larger_lu_exp(lp_settings & settings) {
 
     dense_matrix<double, double> left_side = l.get_left_side(basis);
     dense_matrix<double, double> right_side = l.get_right_side();
-    lean_assert(left_side == right_side);
+    SASSERT(left_side == right_side);
     int leaving = 3;
     int entering = 8;
     for (unsigned i = 0; i < m.row_count(); i++) {
@@ -385,12 +402,12 @@ void test_larger_lu_exp(lp_settings & settings) {
     l.prepare_entering(entering, w);
     l.replace_column(0, w, heading[leaving]);
     change_basis(entering, leaving, basis, non_basic_columns, heading);
-    lean_assert(l.is_correct(basis));
+    SASSERT(l.is_correct(basis));
 
     l.prepare_entering(11, w); // to init vector w
     l.replace_column(0, w, heading[0]);
     change_basis(11, 0, basis, non_basic_columns, heading);
-    lean_assert(l.is_correct(basis));
+    SASSERT(l.is_correct(basis));
 }
 
 void test_larger_lu_with_holes(lp_settings & settings) {
@@ -432,7 +449,7 @@ void test_larger_lu_with_holes(lp_settings & settings) {
     l.prepare_entering(8, w); // to init vector w
     l.replace_column(0, w, heading[0]);
     change_basis(8, 0, basis, non_basic_columns, heading);
-    lean_assert(l.is_correct(basis));
+    SASSERT(l.is_correct(basis));
 }
 
 
@@ -479,7 +496,7 @@ void test_larger_lu(lp_settings& settings) {
     l.prepare_entering(9, w); // to init vector w
     l.replace_column(0, w, heading[0]);
     change_basis(9, 0, basis, non_basic_columns, heading);
-    lean_assert(l.is_correct(basis));
+    SASSERT(l.is_correct(basis));
 }
 
 
@@ -550,7 +567,7 @@ void test_lp_1() {
     m(1, 0) = -1;                m(1, 2) = 3;  m(1, 4) = 1;
     m(2, 0) =  2;  m(2, 1) = -1; m(2, 2) = 2;  m(2, 5) = 1;
     m(3, 0) =  2;  m(3, 1) =  3; m(3, 2) = -1; m(3, 6) = 1;
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     print_matrix(m, std::cout);
 #endif
     vector<double> x_star(7);
@@ -604,7 +621,7 @@ void test_lp_primal_core_solver() {
 }
 
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template <typename T, typename X>
 void test_swap_rows_with_permutation(sparse_matrix<T, X>& m){
     std::cout << "testing swaps" << std::endl;
@@ -612,7 +629,7 @@ void test_swap_rows_with_permutation(sparse_matrix<T, X>& m){
     dense_matrix<double, double> original(&m);
     permutation_matrix<double, double> q(dim);
     print_matrix(m, std::cout);
-    lean_assert(original == q * m);
+    SASSERT(original == q * m);
     for (int i = 0; i < 100; i++) {
         unsigned row1 = my_random() % dim;
         unsigned row2 = my_random() % dim;
@@ -620,7 +637,7 @@ void test_swap_rows_with_permutation(sparse_matrix<T, X>& m){
         std::cout << "swap " << row1 << " " << row2 << std::endl;
         m.swap_rows(row1, row2);
         q.transpose_from_left(row1, row2);
-        lean_assert(original == q * m);
+        SASSERT(original == q * m);
         print_matrix(m, std::cout);
         std::cout << std::endl;
     }
@@ -628,7 +645,7 @@ void test_swap_rows_with_permutation(sparse_matrix<T, X>& m){
 #endif
 template <typename T, typename X>
 void fill_matrix(sparse_matrix<T, X>& m); // forward definition
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 template <typename T, typename X>
 void test_swap_cols_with_permutation(sparse_matrix<T, X>& m){
     std::cout << "testing swaps" << std::endl;
@@ -636,7 +653,7 @@ void test_swap_cols_with_permutation(sparse_matrix<T, X>& m){
     dense_matrix<double, double> original(&m);
     permutation_matrix<double, double> q(dim);
     print_matrix(m, std::cout);
-    lean_assert(original == q * m);
+    SASSERT(original == q * m);
     for (int i = 0; i < 100; i++) {
         unsigned row1 = my_random() % dim;
         unsigned row2 = my_random() % dim;
@@ -644,7 +661,7 @@ void test_swap_cols_with_permutation(sparse_matrix<T, X>& m){
         std::cout << "swap " << row1 << " " << row2 << std::endl;
         m.swap_rows(row1, row2);
         q.transpose_from_right(row1, row2);
-        lean_assert(original == q * m);
+        SASSERT(original == q * m);
         print_matrix(m, std::cout);
         std::cout << std::endl;
     }
@@ -663,8 +680,8 @@ void test_swap_rows(sparse_matrix<T, X>& m, unsigned i0, unsigned i1){
     m.swap_rows(i0, i1);
 
     for (unsigned j = 0; j < m.dimension(); j++) {
-        lean_assert(mcopy(i0, j) == m(i1, j));
-        lean_assert(mcopy(i1, j) == m(i0, j));
+        SASSERT(mcopy(i0, j) == m(i1, j));
+        SASSERT(mcopy(i1, j) == m(i0, j));
     }
 }
 template <typename T, typename X>
@@ -678,15 +695,15 @@ void test_swap_columns(sparse_matrix<T, X>& m, unsigned i0, unsigned i1){
     m.swap_columns(i0, i1);
 
     for (unsigned j = 0; j < m.dimension(); j++) {
-        lean_assert(mcopy(j, i0) == m(j, i1));
-        lean_assert(mcopy(j, i1) == m(j, i0));
+        SASSERT(mcopy(j, i0) == m(j, i1));
+        SASSERT(mcopy(j, i1) == m(j, i0));
     }
 
     for (unsigned i = 0; i  < m.dimension(); i++) {
         if (i == i0 || i == i1)
             continue;
         for (unsigned j = 0; j < m.dimension(); j++) {
-            lean_assert(mcopy(j, i)== m(j, i));
+            SASSERT(mcopy(j, i)== m(j, i));
         }
     }
 }
@@ -731,7 +748,7 @@ void test_pivot_like_swaps_and_pivot(){
     m(target_row, 3) = 0;
     m(target_row, 5) = 0;
     m(pivot_row, 6) = 0;
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     print_matrix(m, std::cout);
 #endif
 
@@ -748,11 +765,11 @@ void test_pivot_like_swaps_and_pivot(){
     m.pivot_row_to_row(pivot_row_0, beta, target_row, settings);
     //  print_matrix(m);
     for (unsigned j = 0; j < m.dimension(); j++) {
-        lean_assert(abs(row[j] - m(target_row, j)) < 0.00000001);
+        SASSERT(abs(row[j] - m(target_row, j)) < 0.00000001);
     }
 }
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
 void test_swap_rows() {
     sparse_matrix<double, double> m(10);
     fill_matrix(m);
@@ -853,57 +870,57 @@ void sparse_matrix_with_permutaions_test() {
     m.multiply_from_left(q0);
     for (unsigned i = 0; i < dim; i++) {
         for (unsigned j = 0; j < dim; j++) {
-            lean_assert(m(i, j) == dm0.get_elem(q0[i], j));
+            SASSERT(m(i, j) == dm0.get_elem(q0[i], j));
         }
     }
 
     auto q0_dm = q0 * dm;
-    lean_assert(m == q0_dm);
+    SASSERT(m == q0_dm);
 
     m.multiply_from_left(q1);
     for (unsigned i = 0; i < dim; i++) {
         for (unsigned j = 0; j < dim; j++) {
-            lean_assert(m(i, j) == dm0.get_elem(q0[q1[i]], j));
+            SASSERT(m(i, j) == dm0.get_elem(q0[q1[i]], j));
         }
     }
 
 
     auto q1_q0_dm = q1 * q0_dm;
 
-    lean_assert(m == q1_q0_dm);
+    SASSERT(m == q1_q0_dm);
 
     m.multiply_from_right(p0);
 
     for (unsigned i = 0; i < dim; i++) {
         for (unsigned j = 0; j < dim; j++) {
-            lean_assert(m(i, j) == dm0.get_elem(q0[q1[i]], p0[j]));
+            SASSERT(m(i, j) == dm0.get_elem(q0[q1[i]], p0[j]));
         }
     }
 
     auto q1_q0_dm_p0 = q1_q0_dm * p0;
 
-    lean_assert(m == q1_q0_dm_p0);
+    SASSERT(m == q1_q0_dm_p0);
 
     m.multiply_from_right(p1);
 
     for (unsigned i = 0; i < dim; i++) {
         for (unsigned j = 0; j < dim; j++) {
-            lean_assert(m(i, j) == dm0.get_elem(q0[q1[i]], p1[p0[j]]));
+            SASSERT(m(i, j) == dm0.get_elem(q0[q1[i]], p1[p0[j]]));
         }
     }
 
     auto q1_q0_dm_p0_p1 = q1_q0_dm_p0 * p1;
-    lean_assert(m == q1_q0_dm_p0_p1);
+    SASSERT(m == q1_q0_dm_p0_p1);
 
     m.multiply_from_right(p1);
     for (unsigned i = 0; i < dim; i++) {
         for (unsigned j = 0; j < dim; j++) {
-            lean_assert(m(i, j) == dm0.get_elem(q0[q1[i]], p1[p1[p0[j]]]));
+            SASSERT(m(i, j) == dm0.get_elem(q0[q1[i]], p1[p1[p0[j]]]));
         }
     }
     auto q1_q0_dm_p0_p1_p1 = q1_q0_dm_p0_p1 * p1;
 
-    lean_assert(m == q1_q0_dm_p0_p1_p1);
+    SASSERT(m == q1_q0_dm_p0_p1_p1);
 }
 
 void test_swap_columns() {
@@ -1021,10 +1038,10 @@ void test_apply_reverse_from_right_to_perm(permutation_matrix<double, double> &
     pclone[4] = 1;
 
     p.multiply_by_reverse_from_right(l);
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     auto rev = l.get_inverse();
     auto rs = pclone * rev;
-    lean_assert(p == rs)
+    SASSERT(p == rs);
 #endif
 }
 
@@ -1051,8 +1068,8 @@ void test_permutations() {
 
     p.apply_reverse_from_right_to_T(v);
     p.apply_reverse_from_right_to_T(vi);
-    lean_assert(vectors_are_equal(v, vi.m_data));
-    lean_assert(vi.is_OK());
+    SASSERT(vectors_are_equal(v, vi.m_data));
+    SASSERT(vi.is_OK());
 }
 
 void lp_solver_test() {
@@ -1200,7 +1217,7 @@ void solve_mps_double(std::string file_name, bool look_for_min, unsigned max_ite
                     compare_solutions(reader, primal_solver, solver);
                     print_x(reader, primal_solver);
                     std::cout << "dual cost is " << cost << ", but primal cost is " << primal_cost << std::endl;
-                    lean_assert(false);
+                    SASSERT(false);
                 }
             }
         }
@@ -1210,7 +1227,7 @@ void solve_mps_double(std::string file_name, bool look_for_min, unsigned max_ite
 }
 
 void solve_mps_rational(std::string file_name, bool look_for_min, unsigned max_iterations, unsigned time_limit, bool dual, argument_parser & args_parser) {
-    mps_reader<lean::mpq, lean::mpq> reader(file_name);
+    mps_reader<lp::mpq, lp::mpq> reader(file_name);
     reader.read();
     if (reader.is_ok()) {
         auto * solver =  reader.create_solver(dual);
@@ -1224,7 +1241,7 @@ void solve_mps_rational(std::string file_name, bool look_for_min, unsigned max_i
             // for (auto name: reader.column_names()) {
             //  std::cout << name << "=" << solver->get_column_value_by_name(name) << ' ';
             // }
-            lean::mpq cost = solver->get_current_cost();
+            lp::mpq cost = solver->get_current_cost();
             if (look_for_min) {
                 cost = -cost;
             }
@@ -1262,7 +1279,7 @@ void solve_mps(std::string file_name, argument_parser & args_parser) {
 void solve_mps_in_rational(std::string file_name, bool dual, argument_parser & /*args_parser*/) {
     std::cout << "solving " << file_name << std::endl;
 
-    mps_reader<lean::mpq, lean::mpq> reader(file_name);
+    mps_reader<lp::mpq, lp::mpq> reader(file_name);
     reader.read();
     if (reader.is_ok()) {
         auto * solver =  reader.create_solver(dual);
@@ -1274,7 +1291,7 @@ void solve_mps_in_rational(std::string file_name, bool dual, argument_parser & /
                     std::cout << name << "=" << solver->get_column_value_by_name(name).get_double() << ' ';
                 }
             }
-            std::cout << std::endl << "cost = " << numeric_traits<lean::mpq>::get_double(solver->get_current_cost()) << std::endl;
+            std::cout << std::endl << "cost = " << numeric_traits<lp::mpq>::get_double(solver->get_current_cost()) << std::endl;
         }
         delete solver;
     } else {
@@ -1318,7 +1335,7 @@ void test_binary_priority_queue() {
 
     for (unsigned i = 0; i < 10; i++) {
         unsigned de = q.dequeue();
-        lean_assert(i == de);
+        SASSERT(i == de);
         std::cout << de << std::endl;
     }
     q.enqueue(2, 2);
@@ -1337,11 +1354,11 @@ void test_binary_priority_queue() {
     q.dequeue();
     q.remove(33);
     q.enqueue(0, 0);
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     unsigned t = 0;
     while (q.size() > 0) {
         unsigned d =q.dequeue();
-        lean_assert(t++ == d);
+        SASSERT(t++ == d);
         std::cout << d << std::endl;
     }
 #endif
@@ -1370,7 +1387,7 @@ void solve_mps_with_known_solution(std::string file_name, std::unordered_map<std
         std::cout << "status is " << lp_status_to_string(solver->get_status()) << std::endl;
         if (status != solver->get_status()){
             std::cout << "status should be " << lp_status_to_string(status) << std::endl;
-            lean_assert(status == solver->get_status());
+            SASSERT(status == solver->get_status());
             throw "status is wrong";
         }
         if (solver->get_status() == lp_status::OPTIMAL) {
@@ -1381,7 +1398,7 @@ void solve_mps_with_known_solution(std::string file_name, std::unordered_map<std
                         std::cout << "expected:" << it.first << "=" <<
                             it.second <<", got " << solver->get_column_value_by_name(it.first) << std::endl;
                     }
-                    lean_assert(fabs(it.second - solver->get_column_value_by_name(it.first)) < 0.000001);
+                    SASSERT(fabs(it.second - solver->get_column_value_by_name(it.first)) < 0.000001);
                 }
             }
             if (reader.column_names().size() < 20) {
@@ -1706,48 +1723,48 @@ void solve_some_mps(argument_parser & args_parser) {
 #endif
 
 void solve_rational() {
-    lp_primal_simplex<lean::mpq, lean::mpq> solver;
-    solver.add_constraint(lp_relation::Equal, lean::mpq(7), 0);
-    solver.add_constraint(lp_relation::Equal, lean::mpq(-3), 1);
+    lp_primal_simplex<lp::mpq, lp::mpq> solver;
+    solver.add_constraint(lp_relation::Equal, lp::mpq(7), 0);
+    solver.add_constraint(lp_relation::Equal, lp::mpq(-3), 1);
 
     // setting the cost
     int cost[] = {-3, -1, -1, 2, -1, 1, 1, -4};
     std::string var_names[8] = {"x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8"};
 
     for (unsigned i = 0; i < 8; i++) {
-        solver.set_cost_for_column(i, lean::mpq(cost[i]));
+        solver.set_cost_for_column(i, lp::mpq(cost[i]));
         solver.give_symbolic_name_to_column(var_names[i], i);
     }
 
     int row0[] = {1, 0, 3, 1, -5, -2 , 4, -6};
     for (unsigned i = 0; i < 8; i++) {
-        solver.set_row_column_coefficient(0, i, lean::mpq(row0[i]));
+        solver.set_row_column_coefficient(0, i, lp::mpq(row0[i]));
     }
 
     int row1[] = {0, 1, -2, -1, 4, 1, -3, 5};
     for (unsigned i = 0; i < 8; i++) {
-        solver.set_row_column_coefficient(1, i, lean::mpq(row1[i]));
+        solver.set_row_column_coefficient(1, i, lp::mpq(row1[i]));
     }
 
     int bounds[] = {8, 6, 4, 15, 2, 10, 10, 3};
     for (unsigned i = 0; i < 8; i++) {
-        solver.set_low_bound(i, lean::mpq(0));
-        solver.set_upper_bound(i, lean::mpq(bounds[i]));
+        solver.set_low_bound(i, lp::mpq(0));
+        solver.set_upper_bound(i, lp::mpq(bounds[i]));
     }
 
-    std::unordered_map<std::string, lean::mpq>  expected_sol;
-    expected_sol["x1"] = lean::mpq(0);
-    expected_sol["x2"] = lean::mpq(6);
-    expected_sol["x3"] = lean::mpq(0);
-    expected_sol["x4"] = lean::mpq(15);
-    expected_sol["x5"] = lean::mpq(2);
-    expected_sol["x6"] = lean::mpq(1);
-    expected_sol["x7"] = lean::mpq(1);
-    expected_sol["x8"] = lean::mpq(0);
+    std::unordered_map<std::string, lp::mpq>  expected_sol;
+    expected_sol["x1"] = lp::mpq(0);
+    expected_sol["x2"] = lp::mpq(6);
+    expected_sol["x3"] = lp::mpq(0);
+    expected_sol["x4"] = lp::mpq(15);
+    expected_sol["x5"] = lp::mpq(2);
+    expected_sol["x6"] = lp::mpq(1);
+    expected_sol["x7"] = lp::mpq(1);
+    expected_sol["x8"] = lp::mpq(0);
     solver.find_maximal_solution();
-    lean_assert(solver.get_status() == OPTIMAL);
+    SASSERT(solver.get_status() == OPTIMAL);
     for (auto it : expected_sol) {
-        lean_assert(it.second == solver.get_column_value_by_name(it.first));
+        SASSERT(it.second == solver.get_column_value_by_name(it.first));
     }
 }
 
@@ -1805,7 +1822,7 @@ std::unordered_map<std::string, double> * get_solution_from_glpsol_output(std::s
            return ret;
         }
 
-        lean_assert(split.size() > 3);
+        SASSERT(split.size() > 3);
         (*ret)[split[1]] = atof(split[3].c_str());
     } while (true);
 }
@@ -1817,7 +1834,7 @@ void test_init_U() {
     m(0, 0) = 10; m(0, 1) = 11; m(0, 2) = 12; m(0, 3) = 13; m(0, 4) = 14;
     m(1, 0) = 20; m(1, 1) = 21; m(1, 2) = 22; m(1, 3) = 23; m(1, 5) = 24;
     m(2, 0) = 30; m(2, 1) = 31; m(2, 2) = 32; m(2, 3) = 33; m(2, 6) = 34;
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     print_matrix(m, std::cout);
 #endif
     vector<unsigned> basis(3);
@@ -1829,7 +1846,7 @@ void test_init_U() {
 
     for (unsigned i = 0; i < 3; i++) {
         for (unsigned j = 0; j < 3; j ++) {
-            lean_assert(m(i, basis[j]) == u(i, j));
+            SASSERT(m(i, basis[j]) == u(i, j));
         }
     }
 
@@ -1857,7 +1874,7 @@ void test_replace_column() {
     for (unsigned column_to_replace = 0;  column_to_replace < m.dimension(); column_to_replace ++) {
         m.replace_column(column_to_replace, w, settings);
         for (unsigned i = 0; i < m.dimension(); i++) {
-            lean_assert(abs(w[i] - m(i, column_to_replace)) < 0.00000001);
+            SASSERT(abs(w[i] - m(i, column_to_replace)) < 0.00000001);
         }
     }
 }
@@ -1961,7 +1978,7 @@ void test_stacked_unsigned() {
     v = 3;
     v = 4;
     v.pop();
-    lean_assert(v == 2);
+    SASSERT(v == 2);
     v ++;
     v++;
     std::cout << "before push v=" << v << std::endl;
@@ -1971,7 +1988,7 @@ void test_stacked_unsigned() {
     v+=1;
     std::cout << "v = " << v << std::endl;
     v.pop(2);
-    lean_assert(v == 4);
+    SASSERT(v == 4);
     const unsigned & rr = v;
     std::cout << rr << std:: endl;
     
@@ -2010,7 +2027,7 @@ void test_stacked_vector() {
 }
 
 void test_stacked_set() {
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     std::cout << "test_stacked_set" << std::endl;
     stacked_unordered_set<int> s;
     s.insert(1);
@@ -2020,7 +2037,7 @@ void test_stacked_set() {
     s.push();
     s.insert(4);
     s.pop();
-    lean_assert(s() == scopy);
+    SASSERT(s() == scopy);
     s.push();
     s.push();
     s.insert(4);
@@ -2028,7 +2045,7 @@ void test_stacked_set() {
     s.push();
     s.insert(4);
     s.pop(3);
-    lean_assert(s() == scopy);
+    SASSERT(s() == scopy);
 #endif
 }
 
@@ -2397,15 +2414,15 @@ void test_files_from_directory(std::string test_file_dir, argument_parser & args
 }
 
 
-std::unordered_map<std::string, lean::mpq> get_solution_map(lp_solver<lean::mpq, lean::mpq> * lps, mps_reader<lean::mpq, lean::mpq> & reader) {
-    std::unordered_map<std::string, lean::mpq> ret;
+std::unordered_map<std::string, lp::mpq> get_solution_map(lp_solver<lp::mpq, lp::mpq> * lps, mps_reader<lp::mpq, lp::mpq> & reader) {
+    std::unordered_map<std::string, lp::mpq> ret;
     for (auto it : reader.column_names()) {
         ret[it] = lps->get_column_value_by_name(it);
     }
     return ret;
 }
 
-void run_lar_solver(argument_parser & args_parser, lar_solver * solver, mps_reader<lean::mpq, lean::mpq> * reader) {
+void run_lar_solver(argument_parser & args_parser, lar_solver * solver, mps_reader<lp::mpq, lp::mpq> * reader) {
     std::string maxng = args_parser.get_option_value("--maxng");
     if (maxng.size() > 0) {
         solver->settings().max_number_of_iterations_with_no_improvements = atoi(maxng.c_str());
@@ -2425,7 +2442,7 @@ void run_lar_solver(argument_parser & args_parser, lar_solver * solver, mps_read
         }
         auto * lps = reader->create_solver(false);
         lps->find_maximal_solution();
-        std::unordered_map<std::string, lean::mpq> sol = get_solution_map(lps, *reader);
+        std::unordered_map<std::string, lp::mpq> sol = get_solution_map(lps, *reader);
         std::cout << "status = " << lp_status_to_string(solver->get_status()) <<  std::endl;
         return;
     }
@@ -2434,7 +2451,7 @@ void run_lar_solver(argument_parser & args_parser, lar_solver * solver, mps_read
     lp_status status = solver->solve();
     std::cout << "status is " <<  lp_status_to_string(status) << ", processed for " << sw.get_current_seconds() <<" seconds, and " << solver->get_total_iterations() << " iterations" << std::endl;
     if (solver->get_status() == INFEASIBLE) {
-        vector<std::pair<lean::mpq, constraint_index>> evidence;
+        vector<std::pair<lp::mpq, constraint_index>> evidence;
         solver->get_infeasibility_explanation(evidence);
     }
     if (args_parser.option_is_used("--randomize_lar")) {
@@ -2467,7 +2484,7 @@ lar_solver * create_lar_solver_from_file(std::string file_name, argument_parser
         }
         return reader.create_lar_solver();
     }
-    mps_reader<lean::mpq, lean::mpq> reader(file_name);
+    mps_reader<lp::mpq, lp::mpq> reader(file_name);
     reader.read();
     if (!reader.is_ok()) {
         std::cout << "cannot process " << file_name << std::endl;
@@ -2478,8 +2495,8 @@ lar_solver * create_lar_solver_from_file(std::string file_name, argument_parser
 
 void test_lar_on_file(std::string file_name, argument_parser & args_parser) {
     lar_solver * solver = create_lar_solver_from_file(file_name, args_parser);
-    mps_reader<lean::mpq, lean::mpq> reader(file_name);
-    mps_reader<lean::mpq, lean::mpq> * mps_reader = nullptr;
+    mps_reader<lp::mpq, lp::mpq> reader(file_name);
+    mps_reader<lp::mpq, lp::mpq> * mps_reader = nullptr;
     reader.read();
     if (reader.is_ok()) {
         mps_reader = & reader;
@@ -2524,28 +2541,28 @@ void test_lar_solver(argument_parser & args_parser) {
 }
 
 void test_numeric_pair() {
-    numeric_pair<lean::mpq> a;
-    numeric_pair<lean::mpq> b(2, lean::mpq(6, 2));
+    numeric_pair<lp::mpq> a;
+    numeric_pair<lp::mpq> b(2, lp::mpq(6, 2));
     a = b;
-    numeric_pair<lean::mpq> c(0.1, 0.5);
+    numeric_pair<lp::mpq> c(0.1, 0.5);
     a += 2*c;
     a -= c;
-    lean_assert (a == b + c);
-    numeric_pair<lean::mpq> d = a * 2;
+    SASSERT (a == b + c);
+    numeric_pair<lp::mpq> d = a * 2;
     std::cout << a  << std::endl;
-    lean_assert(b == b);
-    lean_assert(b < a);
-    lean_assert(b <= a);
-    lean_assert(a > b);
-    lean_assert(a != b);
-    lean_assert(a >= b);
-    lean_assert(-a < b);
-    lean_assert(a < 2 * b);
-    lean_assert(b + b > a);
-    lean_assert(lean::mpq(2.1) * b + b > a);
-    lean_assert(-b * lean::mpq(2.1) - b < lean::mpq(0.99)  * a);
-    std::cout << - b * lean::mpq(2.1) - b << std::endl;
-    lean_assert(-b *(lean::mpq(2.1) + 1) == - b * lean::mpq(2.1) - b);
+    SASSERT(b == b);
+    SASSERT(b < a);
+    SASSERT(b <= a);
+    SASSERT(a > b);
+    SASSERT(a != b);
+    SASSERT(a >= b);
+    SASSERT(-a < b);
+    SASSERT(a < 2 * b);
+    SASSERT(b + b > a);
+    SASSERT(lp::mpq(2.1) * b + b > a);
+    SASSERT(-b * lp::mpq(2.1) - b < lp::mpq(0.99)  * a);
+    std::cout << - b * lp::mpq(2.1) - b << std::endl;
+    SASSERT(-b *(lp::mpq(2.1) + 1) == - b * lp::mpq(2.1) - b);
 }
 
 void get_matrix_dimensions(std::ifstream & f, unsigned & m, unsigned & n) {
@@ -2566,7 +2583,7 @@ void read_row_cols(unsigned i, static_matrix<double, double>& A, std::ifstream &
         if (line== "row_end")
             break;
         auto r = split_and_trim(line);
-        lean_assert(r.size() == 4);
+        SASSERT(r.size() == 4);
         unsigned j = atoi(r[1].c_str());
         double v = atof(r[3].c_str());
         A.set(i, j, v);
@@ -2594,7 +2611,7 @@ void read_basis(vector<unsigned> & basis, std::ifstream & f) {
     std::cout << "reading basis" << std::endl;
     std::string line;
     getline(f, line);
-    lean_assert(line == "basis_start");
+    SASSERT(line == "basis_start");
     do {
         getline(f, line);
         if (line == "basis_end")
@@ -2607,7 +2624,7 @@ void read_basis(vector<unsigned> & basis, std::ifstream & f) {
 void read_indexed_vector(indexed_vector<double> & v, std::ifstream & f) {
     std::string line;
     getline(f, line);
-    lean_assert(line == "vector_start");
+    SASSERT(line == "vector_start");
     do {
         getline(f, line);
         if (line == "vector_end") break;
@@ -2641,13 +2658,13 @@ void check_lu_from_file(std::string lufile_name) {
      indexed_vector<double>  d(A.row_count());
     unsigned entering = 26;
     lsuhl.solve_Bd(entering, d, v);
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     auto B = get_B(lsuhl, basis);
     vector<double>  a(m);
     A.copy_column_to_vector(entering, a);
     indexed_vector<double> cd(d);
     B.apply_from_left(cd.m_data, settings);
-    lean_assert(vectors_are_equal(cd.m_data , a));
+    SASSERT(vectors_are_equal(cd.m_data , a));
 #endif
 }
 
@@ -2662,7 +2679,7 @@ void test_square_dense_submatrix() {
     for (unsigned i = index_start; i < parent_dim; i++)
         for (unsigned j = index_start; j < parent_dim; j++)
             d[i][j] = i*3+j*2;
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     unsigned dim = parent_dim - index_start;
     dense_matrix<double, double> m(dim, dim);
     for (unsigned i = index_start; i < parent_dim; i++)
@@ -2673,7 +2690,7 @@ void test_square_dense_submatrix() {
     for (unsigned i = index_start; i < parent_dim; i++)
         for (unsigned j = index_start; j < parent_dim; j++)
             d[i][j] = d[j][i];
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     for (unsigned i = index_start; i < parent_dim; i++)
         for (unsigned j = index_start; j < parent_dim; j++)
             m[i-index_start][j-index_start] = d[i][j];
@@ -2738,7 +2755,7 @@ void test_evidence_for_total_inf_simple(argument_parser & args_parser) {
     auto status = solver.solve();
     std::cout << lp_status_to_string(status) << std::endl;
     std::unordered_map<var_index, mpq> model;
-    lean_assert(solver.get_status() == INFEASIBLE);
+    SASSERT(solver.get_status() == INFEASIBLE);
 }
 void test_bound_propagation_one_small_sample1() {
     /*
@@ -2934,8 +2951,8 @@ void test_total_case_l(){
     ls.solve();
     lp_bound_propagator bp(ls);
     ls.propagate_bounds_for_touched_rows(bp);
-    lean_assert(ev.size() == 4);
-    lean_assert(contains_j_kind(x, GE, - one_of_type<mpq>(), ev));
+    SASSERT(ev.size() == 4);
+    SASSERT(contains_j_kind(x, GE, - one_of_type<mpq>(), ev));
 }
 void test_bound_propagation() {
     test_total_case_u();
@@ -2955,17 +2972,17 @@ void test_int_set() {
     s.insert(1);
     s.insert(2);
     s.print(std::cout);
-    lean_assert(s.contains(2));
-    lean_assert(s.size() == 2);
+    SASSERT(s.contains(2));
+    SASSERT(s.size() == 2);
     s.erase(2);
-    lean_assert(s.size() == 1);
+    SASSERT(s.size() == 1);
     s.erase(2);
-    lean_assert(s.size() == 1);
+    SASSERT(s.size() == 1);
     s.print(std::cout);
     s.insert(3);
     s.insert(2);
     s.clear();
-    lean_assert(s.size() == 0);
+    SASSERT(s.size() == 0);
     
     
 }
@@ -3112,7 +3129,7 @@ void test_lp_local(int argn, char**argv) {
         return finalize(0);
     }
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     if (args_parser.option_is_used("--test_swaps")) {
         sparse_matrix<double, double> m(10);
         fill_matrix(m);
@@ -3142,7 +3159,7 @@ void test_lp_local(int argn, char**argv) {
         return finalize(ret);
     }
 
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     lp_settings settings;
     update_settings(args_parser, settings);
     if (args_parser.option_is_used("--test_lu")) {
@@ -3219,11 +3236,11 @@ void test_lp_local(int argn, char**argv) {
         ret = 0;
         return finalize(ret);
     }
-    //  lean::ccc = 0;
+    //  lp::ccc = 0;
     return finalize(0);
     test_init_U();
     test_replace_column();
-#ifdef LEAN_DEBUG
+#ifdef Z3DEBUG
     sparse_matrix_with_permutaions_test();
     test_dense_matrix();
     test_swap_operations();
@@ -3236,5 +3253,5 @@ void test_lp_local(int argn, char**argv) {
 }
 }
 void tst_lp(char ** argv, int argc, int& i) {
-    lean::test_lp_local(argc - 2, argv + 2);
+    lp::test_lp_local(argc - 2, argv + 2);
 }
diff --git a/src/test/smt_reader.h b/src/test/smt_reader.h
index 38e3f4157..437cb7a6b 100644
--- a/src/test/smt_reader.h
+++ b/src/test/smt_reader.h
@@ -1,9 +1,22 @@
-/*
-  Copyright (c) 2013 Microsoft Corporation. All rights reserved.
-  Released under Apache 2.0 license as described in the file LICENSE.
+/*++
+Copyright (c) 2017 Microsoft Corporation
 
-  Author: Lev Nachmanson
-*/
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 
@@ -23,7 +36,7 @@
 #include "util/lp/lar_constraints.h"
 #include <sstream>
 #include <cstdlib>
-namespace lean {
+namespace lp {
 
     template<typename T>
     T from_string(const std::string& str) {
@@ -108,13 +121,13 @@ namespace lean {
 
         void fill_simple_elem(lisp_elem & lm) {
             int separator = first_separator();
-            lean_assert(-1 != separator && separator != 0);
+            SASSERT(-1 != separator && separator != 0);
             lm.m_head = m_line.substr(0, separator);
             m_line = m_line.substr(separator);
         }
 
         void fill_nested_elem(lisp_elem & lm) {
-            lean_assert(m_line[0] == '(');
+            SASSERT(m_line[0] == '(');
             m_line = m_line.substr(1);
             int separator = first_separator();
             lm.m_head = m_line.substr(0, separator);
@@ -181,11 +194,11 @@ namespace lean {
         }
 
         void adjust_rigth_side(formula_constraint & /* c*/, lisp_elem & /*el*/) {
-            // lean_assert(el.m_head == "0"); // do nothing for the time being
+            // SASSERT(el.m_head == "0"); // do nothing for the time being
         }
 
         void set_constraint_coeffs(formula_constraint & c, lisp_elem & el) {
-            lean_assert(el.m_elems.size() == 2);
+            SASSERT(el.m_elems.size() == 2);
             set_constraint_coeffs_on_coeff_element(c, el.m_elems[0]);
             adjust_rigth_side(c, el.m_elems[1]);
         }
@@ -201,7 +214,7 @@ namespace lean {
                 add_mult_elem(c, el.m_elems);
             } else if (el.m_head == "~") {
                 lisp_elem & minel = el.m_elems[0];
-                lean_assert(minel.is_simple());
+                SASSERT(minel.is_simple());
                 c.m_right_side += mpq(str_to_int(minel.m_head));
             } else {
                 std::cout << "unexpected input " << el.m_head << std::endl;
@@ -211,14 +224,14 @@ namespace lean {
         }
 
         std::string get_name(lisp_elem & name) {
-            lean_assert(name.is_simple());
-            lean_assert(!is_integer(name.m_head));
+            SASSERT(name.is_simple());
+            SASSERT(!is_integer(name.m_head));
             return name.m_head;
         }
 
 
         void add_mult_elem(formula_constraint & c, std::vector<lisp_elem> & els) {
-            lean_assert(els.size() == 2);
+            SASSERT(els.size() == 2);
             mpq coeff = get_coeff(els[0]);
             std::string col_name = get_name(els[1]);
             c.add_pair(coeff, col_name);
@@ -228,16 +241,16 @@ namespace lean {
             if (le.is_simple()) {
                 return mpq(str_to_int(le.m_head));
             } else {
-                lean_assert(le.m_head == "~");
-                lean_assert(le.size() == 1);
+                SASSERT(le.m_head == "~");
+                SASSERT(le.size() == 1);
                 lisp_elem & el = le.m_elems[0];
-                lean_assert(el.is_simple());
+                SASSERT(el.is_simple());
                 return -mpq(str_to_int(el.m_head));
             }
         }
 
         int str_to_int(std::string & s) {
-            lean_assert(is_integer(s));
+            SASSERT(is_integer(s));
             return atoi(s.c_str());
         }
 
@@ -245,7 +258,7 @@ namespace lean {
             if (el.size()) {
                 add_complex_sum_elem(c, el);
             } else {
-                lean_assert(is_integer(el.m_head));
+                SASSERT(is_integer(el.m_head));
                 int v = atoi(el.m_head.c_str());
                 mpq vr(v);
                 c.m_right_side -= vr;
@@ -263,7 +276,7 @@ namespace lean {
             } else if (el.m_head == "+") {
                 add_sum(c, el.m_elems);
             } else {
-                lean_assert(false); // unexpected input
+                SASSERT(false); // unexpected input
             }
         }
 
diff --git a/src/test/test_file_reader.h b/src/test/test_file_reader.h
index c7a9e3b8b..74dad419b 100644
--- a/src/test/test_file_reader.h
+++ b/src/test/test_file_reader.h
@@ -1,9 +1,23 @@
-/*
-Copyright (c) 2013 Microsoft Corporation. All rights reserved.
-Released under Apache 2.0 license as described in the file LICENSE.
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
-Author: Lev Nachmanson
-*/
 #pragma once
 
 // reads a text file
@@ -15,7 +29,7 @@ Author: Lev Nachmanson
 #include "util/lp/lp_utils.h"
 #include "util/lp/lp_solver.h"
 
-namespace lean {
+namespace lp {
 
 template <typename T>
 struct test_result {

From 56e20da3cea4688186d94a5b6daa098afd749d08 Mon Sep 17 00:00:00 2001
From: "Christoph M. Wintersteiger" <cwinter@microsoft.com>
Date: Sun, 17 Sep 2017 17:33:42 +0100
Subject: [PATCH 05/10] Copyright messages

---
 src/util/lp/conversion_helper.h | 23 +++++++++++++++++++----
 src/util/lp/quick_xplain.h      | 21 ++++++++++++++++++---
 src/util/lp/random_updater.h    | 22 +++++++++++++++++++---
 src/util/lp/stacked_vector.h    | 22 +++++++++++++++++++---
 4 files changed, 75 insertions(+), 13 deletions(-)

diff --git a/src/util/lp/conversion_helper.h b/src/util/lp/conversion_helper.h
index cd8577483..f80b1c2c6 100644
--- a/src/util/lp/conversion_helper.h
+++ b/src/util/lp/conversion_helper.h
@@ -1,8 +1,23 @@
-/*
-  Copyright (c) 2013 Microsoft Corporation. All rights reserved.
+/*++
+Copyright (c) 2017 Microsoft Corporation
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
-  Author: Lev Nachmanson
-*/
 #pragma once
 namespace lp {
 template <typename V>
diff --git a/src/util/lp/quick_xplain.h b/src/util/lp/quick_xplain.h
index 952199f85..902fa08cd 100644
--- a/src/util/lp/quick_xplain.h
+++ b/src/util/lp/quick_xplain.h
@@ -1,7 +1,22 @@
-/*
+/*++
 Copyright (c) 2017 Microsoft Corporation
-Author: Lev Nachmanson
-*/
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
 
 #pragma once
 #include "util/vector.h"
diff --git a/src/util/lp/random_updater.h b/src/util/lp/random_updater.h
index 68b14c971..6b03ad941 100644
--- a/src/util/lp/random_updater.h
+++ b/src/util/lp/random_updater.h
@@ -1,7 +1,23 @@
-/*
+/*++
 Copyright (c) 2017 Microsoft Corporation
-Author: Lev Nachmanson
-*/
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
+
 #pragma once
 #include <set>
 #include "util/vector.h"
diff --git a/src/util/lp/stacked_vector.h b/src/util/lp/stacked_vector.h
index 0f66e93f3..e8234d1e4 100644
--- a/src/util/lp/stacked_vector.h
+++ b/src/util/lp/stacked_vector.h
@@ -1,7 +1,23 @@
-/*
+/*++
 Copyright (c) 2017 Microsoft Corporation
-Author: Lev Nachmanson
-*/
+
+Module Name:
+
+    <name>
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Lev Nachmanson (levnach)
+
+Revision History:
+
+
+--*/
+
 #pragma once
 #include <unordered_map>
 #include <set>

From db398eca7a45dd3f3f7cd747e83befb52a6dc68b Mon Sep 17 00:00:00 2001
From: "Christoph M. Wintersteiger" <cwinter@microsoft.com>
Date: Sun, 17 Sep 2017 17:50:05 +0100
Subject: [PATCH 06/10] Tabs, formatting.

---
 src/api/dotnet/CMakeLists.txt                 | 144 +++++++++---------
 src/api/dotnet/Context.cs                     |   6 +-
 src/api/dotnet/Expr.cs                        |  18 +--
 src/api/dotnet/Optimize.cs                    |  36 ++---
 .../dotnet/dotnet35/Microsoft.Z3.NET35.sln    |  74 ++++-----
 src/api/java/ASTVector.java                   |   2 +-
 src/api/java/AlgebraicNum.java                |  92 +++++------
 src/api/java/Context.java                     | 120 +++++++--------
 src/api/java/EnumSort.java                    |   2 +-
 src/api/java/Expr.java                        |   2 +-
 src/api/java/Model.java                       |   2 +-
 src/api/java/Optimize.java                    |   9 +-
 src/api/java/ParamDescrs.java                 |   2 +-
 src/api/java/Solver.java                      |   2 +-
 src/api/java/Sort.java                        |   8 +-
 src/api/ml/z3native_stubs.c.pre               |  38 ++---
 src/ast/rewriter/array_rewriter_params.pyg    |   2 +-
 src/ast/rewriter/fpa_rewriter_params.pyg      |   2 +-
 src/muz/base/fixedpoint_params.pyg            |  44 +++---
 src/opt/opt_params.pyg                        |   2 +-
 src/tactic/sls/.#sls_params.pyg               |   1 +
 src/tactic/sls/sls_params.pyg                 |  44 +++---
 src/util/lp/CMakeLists.txt                    |   2 +-
 src/util/lp/lp_core_solver_base.hpp           |   4 +-
 src/util/lp/lp_primal_core_solver_tableau.h   |   2 +-
 src/util/lp/static_matrix.hpp                 |   6 +-
 26 files changed, 331 insertions(+), 335 deletions(-)
 create mode 100644 src/tactic/sls/.#sls_params.pyg

diff --git a/src/api/dotnet/CMakeLists.txt b/src/api/dotnet/CMakeLists.txt
index 93f5929d9..add1b0ded 100644
--- a/src/api/dotnet/CMakeLists.txt
+++ b/src/api/dotnet/CMakeLists.txt
@@ -43,78 +43,78 @@ add_custom_command(OUTPUT "${Z3_DOTNET_CONST_FILE}"
 )
 
 set(Z3_DOTNET_ASSEMBLY_SOURCES_IN_SRC_TREE
-	AlgebraicNum.cs
-	ApplyResult.cs
-	ArithExpr.cs
-	ArithSort.cs
-	ArrayExpr.cs
-	ArraySort.cs
-	AST.cs
-	ASTMap.cs
-	ASTVector.cs
-	BitVecExpr.cs
-	BitVecNum.cs
-	BitVecSort.cs
-	BoolExpr.cs
-	BoolSort.cs
-	Constructor.cs
-	ConstructorList.cs
-	Context.cs
-	DatatypeExpr.cs
-	DatatypeSort.cs
-	Deprecated.cs
-	EnumSort.cs
-	Expr.cs
-	FiniteDomainExpr.cs
-	FiniteDomainNum.cs
-	FiniteDomainSort.cs
-	Fixedpoint.cs
-	FPExpr.cs
-	FPNum.cs
-	FPRMExpr.cs
-	FPRMNum.cs
-	FPRMSort.cs
-	FPSort.cs
-	FuncDecl.cs
-	FuncInterp.cs
-	Global.cs
-	Goal.cs
-	IDecRefQueue.cs
-	InterpolationContext.cs
-	IntExpr.cs
-	IntNum.cs
-	IntSort.cs
-	IntSymbol.cs
-	ListSort.cs
-	Log.cs
-	Model.cs
-	Optimize.cs
-	ParamDescrs.cs
-	Params.cs
-	Pattern.cs
-	Probe.cs
-	Quantifier.cs
-	RatNum.cs
-	RealExpr.cs
-	RealSort.cs
-	ReExpr.cs
-	RelationSort.cs
-	ReSort.cs
-	SeqExpr.cs
-	SeqSort.cs
-	SetSort.cs
-	Solver.cs
-	Sort.cs
-	Statistics.cs
-	Status.cs
-	StringSymbol.cs
-	Symbol.cs
-	Tactic.cs
-	TupleSort.cs
-	UninterpretedSort.cs
-	Version.cs
-	Z3Exception.cs
-	Z3Object.cs
+    AlgebraicNum.cs
+    ApplyResult.cs
+    ArithExpr.cs
+    ArithSort.cs
+    ArrayExpr.cs
+    ArraySort.cs
+    AST.cs
+    ASTMap.cs
+    ASTVector.cs
+    BitVecExpr.cs
+    BitVecNum.cs
+    BitVecSort.cs
+    BoolExpr.cs
+    BoolSort.cs
+    Constructor.cs
+    ConstructorList.cs
+    Context.cs
+    DatatypeExpr.cs
+    DatatypeSort.cs
+    Deprecated.cs
+    EnumSort.cs
+    Expr.cs
+    FiniteDomainExpr.cs
+    FiniteDomainNum.cs
+    FiniteDomainSort.cs
+    Fixedpoint.cs
+    FPExpr.cs
+    FPNum.cs
+    FPRMExpr.cs
+    FPRMNum.cs
+    FPRMSort.cs
+    FPSort.cs
+    FuncDecl.cs
+    FuncInterp.cs
+    Global.cs
+    Goal.cs
+    IDecRefQueue.cs
+    InterpolationContext.cs
+    IntExpr.cs
+    IntNum.cs
+    IntSort.cs
+    IntSymbol.cs
+    ListSort.cs
+    Log.cs
+    Model.cs
+    Optimize.cs
+    ParamDescrs.cs
+    Params.cs
+    Pattern.cs
+    Probe.cs
+    Quantifier.cs
+    RatNum.cs
+    RealExpr.cs
+    RealSort.cs
+    ReExpr.cs
+    RelationSort.cs
+    ReSort.cs
+    SeqExpr.cs
+    SeqSort.cs
+    SetSort.cs
+    Solver.cs
+    Sort.cs
+    Statistics.cs
+    Status.cs
+    StringSymbol.cs
+    Symbol.cs
+    Tactic.cs
+    TupleSort.cs
+    UninterpretedSort.cs
+    Version.cs
+    Z3Exception.cs
+    Z3Object.cs
 )
 
 set(Z3_DOTNET_ASSEMBLY_SOURCES "")
diff --git a/src/api/dotnet/Context.cs b/src/api/dotnet/Context.cs
index a656be3eb..d7699c961 100644
--- a/src/api/dotnet/Context.cs
+++ b/src/api/dotnet/Context.cs
@@ -126,7 +126,7 @@ namespace Microsoft.Z3
         private BoolSort m_boolSort = null;
         private IntSort m_intSort = null;
         private RealSort m_realSort = null;
-	private SeqSort m_stringSort = null;
+        private SeqSort m_stringSort = null;
 
         /// <summary>
         /// Retrieves the Boolean sort of the context.
@@ -2426,7 +2426,7 @@ namespace Microsoft.Z3
         public SeqExpr IntToString(Expr e) 
         {
             Contract.Requires(e != null);
-	    Contract.Requires(e is ArithExpr);
+            Contract.Requires(e is ArithExpr);
             Contract.Ensures(Contract.Result<SeqExpr>() != null);
             return new SeqExpr(this, Native.Z3_mk_int_to_str(nCtx, e.NativeObject));
         }
@@ -2690,7 +2690,7 @@ namespace Microsoft.Z3
         /// <summary>
         /// Create a range expression.
         /// </summary>
-	public ReExpr MkRange(SeqExpr lo, SeqExpr hi) 
+        public ReExpr MkRange(SeqExpr lo, SeqExpr hi) 
         {
             Contract.Requires(lo != null);
             Contract.Requires(hi != null);
diff --git a/src/api/dotnet/Expr.cs b/src/api/dotnet/Expr.cs
index 6c52b83c8..4fd306052 100644
--- a/src/api/dotnet/Expr.cs
+++ b/src/api/dotnet/Expr.cs
@@ -809,55 +809,55 @@ namespace Microsoft.Z3
         /// Check whether expression is a concatentation.
         /// </summary>
         /// <returns>a Boolean</returns>
-	public bool IsConcat { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_CONCAT; } }
+        public bool IsConcat { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_CONCAT; } }
 
         /// <summary>
         /// Check whether expression is a prefix.
         /// </summary>
         /// <returns>a Boolean</returns>
-	public bool IsPrefix { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_PREFIX; } }
+        public bool IsPrefix { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_PREFIX; } }
 
         /// <summary>
         /// Check whether expression is a suffix.
         /// </summary>
         /// <returns>a Boolean</returns>
-	public bool IsSuffix { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_SUFFIX; } }
+        public bool IsSuffix { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_SUFFIX; } }
 
         /// <summary>
         /// Check whether expression is a contains.
         /// </summary>
         /// <returns>a Boolean</returns>
-	public bool IsContains { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_CONTAINS; } }
+        public bool IsContains { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_CONTAINS; } }
 
         /// <summary>
         /// Check whether expression is an extract.
         /// </summary>
         /// <returns>a Boolean</returns>
-	public bool IsExtract { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_EXTRACT; } }
+        public bool IsExtract { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_EXTRACT; } }
 
         /// <summary>
         /// Check whether expression is a replace.
         /// </summary>
         /// <returns>a Boolean</returns>
-	public bool IsReplace { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_REPLACE; } }
+        public bool IsReplace { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_REPLACE; } }
 
         /// <summary>
         /// Check whether expression is an at.
         /// </summary>
         /// <returns>a Boolean</returns>
-	public bool IsAt { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_AT; } }
+        public bool IsAt { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_AT; } }
 
         /// <summary>
         /// Check whether expression is a sequence length.
         /// </summary>
         /// <returns>a Boolean</returns>
-	public bool IsLength { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_LENGTH; } }
+        public bool IsLength { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_LENGTH; } }
 
         /// <summary>
         /// Check whether expression is a sequence index.
         /// </summary>
         /// <returns>a Boolean</returns>
-	public bool IsIndex { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_INDEX; } }
+        public bool IsIndex { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_INDEX; } }
 
 
         #endregion
diff --git a/src/api/dotnet/Optimize.cs b/src/api/dotnet/Optimize.cs
index 99dd9aac0..9d0636425 100644
--- a/src/api/dotnet/Optimize.cs
+++ b/src/api/dotnet/Optimize.cs
@@ -123,7 +123,7 @@ namespace Microsoft.Z3
 
             /// <summary>
             /// Retrieve a lower bound for the objective handle.
-            /// </summary>        	   	
+            /// </summary>                   
             public ArithExpr Lower
             {
                 get { return opt.GetLower(handle); }
@@ -131,7 +131,7 @@ namespace Microsoft.Z3
 
             /// <summary>
             /// Retrieve an upper bound for the objective handle.
-            /// </summary>        	   	
+            /// </summary>                   
             public ArithExpr Upper
             {
                 get { return opt.GetUpper(handle); }
@@ -139,7 +139,7 @@ namespace Microsoft.Z3
 
             /// <summary>
             /// Retrieve the value of an objective.
-            /// </summary>        	   	
+            /// </summary>                   
             public ArithExpr Value
             {
                 get { return Lower; }
@@ -147,7 +147,7 @@ namespace Microsoft.Z3
 
             /// <summary>
             /// Retrieve a lower bound for the objective handle.
-            /// </summary>        	   	
+            /// </summary>                   
             public ArithExpr[] LowerAsVector
             {
                 get { return opt.GetLowerAsVector(handle); }
@@ -155,7 +155,7 @@ namespace Microsoft.Z3
 
             /// <summary>
             /// Retrieve an upper bound for the objective handle.
-            /// </summary>        	   	
+            /// </summary>                   
             public ArithExpr[] UpperAsVector
             {
                 get { return opt.GetUpperAsVector(handle); }
@@ -240,7 +240,7 @@ namespace Microsoft.Z3
         /// Declare an arithmetical maximization objective.
         /// Return a handle to the objective. The handle is used as
         /// to retrieve the values of objectives after calling Check.
-        /// </summary>        	
+        /// </summary>            
         public Handle MkMaximize(ArithExpr e)
         {
             return new Handle(this, Native.Z3_optimize_maximize(Context.nCtx, NativeObject, e.NativeObject));
@@ -249,7 +249,7 @@ namespace Microsoft.Z3
         /// <summary>
         /// Declare an arithmetical minimization objective. 
         /// Similar to MkMaximize.
-        /// </summary>        	
+        /// </summary>            
         public Handle MkMinimize(ArithExpr e)
         {
             return new Handle(this, Native.Z3_optimize_minimize(Context.nCtx, NativeObject, e.NativeObject));
@@ -257,7 +257,7 @@ namespace Microsoft.Z3
 
         /// <summary>
         /// Retrieve a lower bound for the objective handle.
-        /// </summary>        	
+        /// </summary>            
         private ArithExpr GetLower(uint index)
         {
             return (ArithExpr)Expr.Create(Context, Native.Z3_optimize_get_lower(Context.nCtx, NativeObject, index));
@@ -266,7 +266,7 @@ namespace Microsoft.Z3
 
         /// <summary>
         /// Retrieve an upper bound for the objective handle.
-        /// </summary>        	
+        /// </summary>            
         private ArithExpr GetUpper(uint index)
         {
             return (ArithExpr)Expr.Create(Context, Native.Z3_optimize_get_upper(Context.nCtx, NativeObject, index));
@@ -274,7 +274,7 @@ namespace Microsoft.Z3
 
         /// <summary>
         /// Retrieve a lower bound for the objective handle.
-        /// </summary>        	
+        /// </summary>            
         private ArithExpr[] GetLowerAsVector(uint index)
         {
             ASTVector v = new ASTVector(Context, Native.Z3_optimize_get_lower_as_vector(Context.nCtx, NativeObject, index));
@@ -284,29 +284,29 @@ namespace Microsoft.Z3
 
         /// <summary>
         /// Retrieve an upper bound for the objective handle.
-        /// </summary>        	
+        /// </summary>            
         private ArithExpr[] GetUpperAsVector(uint index)
         {
             ASTVector v = new ASTVector(Context, Native.Z3_optimize_get_upper_as_vector(Context.nCtx, NativeObject, index));
             return v.ToArithExprArray();
         }
 
-	/// <summary>
-	/// Return a string the describes why the last to check returned unknown
-	/// </summary>	
-    	public String ReasonUnknown
-    	{
+    /// <summary>
+    /// Return a string the describes why the last to check returned unknown
+    /// </summary>    
+        public String ReasonUnknown
+        {
             get 
             {
                 Contract.Ensures(Contract.Result<string>() != null);
                 return Native.Z3_optimize_get_reason_unknown(Context.nCtx, NativeObject);
             }
-    	}
+        }
 
 
         /// <summary>
         /// Print the context to a string (SMT-LIB parseable benchmark).
-        /// </summary>        	
+        /// </summary>            
         public override string ToString()
         {
             return Native.Z3_optimize_to_string(Context.nCtx, NativeObject);
diff --git a/src/api/dotnet/dotnet35/Microsoft.Z3.NET35.sln b/src/api/dotnet/dotnet35/Microsoft.Z3.NET35.sln
index b6e252684..1e33f136e 100644
--- a/src/api/dotnet/dotnet35/Microsoft.Z3.NET35.sln
+++ b/src/api/dotnet/dotnet35/Microsoft.Z3.NET35.sln
@@ -8,41 +8,41 @@ EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example", "Example\Example.csproj", "{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}"
 EndProject
 Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Any CPU = Debug|Any CPU
-		Debug|x64 = Debug|x64
-		Debug|x86 = Debug|x86
-		Release|Any CPU = Release|Any CPU
-		Release|x64 = Release|x64
-		Release|x86 = Release|x86
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|x64.ActiveCfg = Debug|Any CPU
-		{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|x64.Build.0 = Debug|Any CPU
-		{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|x86.Build.0 = Debug|Any CPU
-		{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|Any CPU.Build.0 = Release|Any CPU
-		{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|x64.ActiveCfg = Release|x64
-		{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|x64.Build.0 = Release|x64
-		{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|x86.ActiveCfg = Release|Any CPU
-		{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|x86.Build.0 = Release|Any CPU
-		{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|x64.ActiveCfg = Debug|Any CPU
-		{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|x64.Build.0 = Debug|Any CPU
-		{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|x86.Build.0 = Debug|Any CPU
-		{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|Any CPU.Build.0 = Release|Any CPU
-		{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|x64.ActiveCfg = Release|x64
-		{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|x64.Build.0 = Release|x64
-		{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|x86.ActiveCfg = Release|Any CPU
-		{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|x86.Build.0 = Release|Any CPU
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
+    GlobalSection(SolutionConfigurationPlatforms) = preSolution
+        Debug|Any CPU = Debug|Any CPU
+        Debug|x64 = Debug|x64
+        Debug|x86 = Debug|x86
+        Release|Any CPU = Release|Any CPU
+        Release|x64 = Release|x64
+        Release|x86 = Release|x86
+    EndGlobalSection
+    GlobalSection(ProjectConfigurationPlatforms) = postSolution
+        {EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+        {EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+        {EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|x64.ActiveCfg = Debug|Any CPU
+        {EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|x64.Build.0 = Debug|Any CPU
+        {EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|x86.ActiveCfg = Debug|Any CPU
+        {EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|x86.Build.0 = Debug|Any CPU
+        {EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+        {EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|Any CPU.Build.0 = Release|Any CPU
+        {EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|x64.ActiveCfg = Release|x64
+        {EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|x64.Build.0 = Release|x64
+        {EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|x86.ActiveCfg = Release|Any CPU
+        {EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|x86.Build.0 = Release|Any CPU
+        {2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+        {2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|Any CPU.Build.0 = Debug|Any CPU
+        {2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|x64.ActiveCfg = Debug|Any CPU
+        {2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|x64.Build.0 = Debug|Any CPU
+        {2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|x86.ActiveCfg = Debug|Any CPU
+        {2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|x86.Build.0 = Debug|Any CPU
+        {2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|Any CPU.ActiveCfg = Release|Any CPU
+        {2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|Any CPU.Build.0 = Release|Any CPU
+        {2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|x64.ActiveCfg = Release|x64
+        {2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|x64.Build.0 = Release|x64
+        {2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|x86.ActiveCfg = Release|Any CPU
+        {2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|x86.Build.0 = Release|Any CPU
+    EndGlobalSection
+    GlobalSection(SolutionProperties) = preSolution
+        HideSolutionNode = FALSE
+    EndGlobalSection
 EndGlobal
diff --git a/src/api/java/ASTVector.java b/src/api/java/ASTVector.java
index 4d9ab291a..b78f714b2 100644
--- a/src/api/java/ASTVector.java
+++ b/src/api/java/ASTVector.java
@@ -131,7 +131,7 @@ public class ASTVector extends Z3Object {
         Expr[] res = new Expr[n];
         for (int i = 0; i < n; i++)
             res[i] = Expr.create(getContext(), get(i).getNativeObject());
-        return res;	
+        return res;    
     }
 
     /**
diff --git a/src/api/java/AlgebraicNum.java b/src/api/java/AlgebraicNum.java
index 6725d3937..7369e06e3 100644
--- a/src/api/java/AlgebraicNum.java
+++ b/src/api/java/AlgebraicNum.java
@@ -22,57 +22,57 @@ package com.microsoft.z3;
  **/
 public class AlgebraicNum extends ArithExpr
 {
-	/**
-	 * Return a upper bound for a given real algebraic number. The interval
-	 * isolating the number is smaller than 1/10^{@code precision}.
-	 * 
-	 * @see Expr#isAlgebraicNumber
-	 * @param precision the precision of the result
-	 * 
-	 * @return A numeral Expr of sort Real
-	 * @throws Z3Exception on error
-	 **/
-	public RatNum toUpper(int precision)
-	{
+    /**
+     * Return a upper bound for a given real algebraic number. The interval
+     * isolating the number is smaller than 1/10^{@code precision}.
+     * 
+     * @see Expr#isAlgebraicNumber
+     * @param precision the precision of the result
+     * 
+     * @return A numeral Expr of sort Real
+     * @throws Z3Exception on error
+     **/
+    public RatNum toUpper(int precision)
+    {
 
-		return new RatNum(getContext(), Native.getAlgebraicNumberUpper(getContext()
-				.nCtx(), getNativeObject(), precision));
-	}
+        return new RatNum(getContext(), Native.getAlgebraicNumberUpper(getContext()
+                .nCtx(), getNativeObject(), precision));
+    }
 
-	/**
-	 * Return a lower bound for the given real algebraic number. The interval
-	 * isolating the number is smaller than 1/10^{@code precision}.
-	 * 
-	 * @see Expr#isAlgebraicNumber
-	 * @param precision precision
-	 * 
-	 * @return A numeral Expr of sort Real
-	 * @throws Z3Exception on error
-	 **/
-	public RatNum toLower(int precision)
-	{
+    /**
+     * Return a lower bound for the given real algebraic number. The interval
+     * isolating the number is smaller than 1/10^{@code precision}.
+     * 
+     * @see Expr#isAlgebraicNumber
+     * @param precision precision
+     * 
+     * @return A numeral Expr of sort Real
+     * @throws Z3Exception on error
+     **/
+    public RatNum toLower(int precision)
+    {
 
-		return new RatNum(getContext(), Native.getAlgebraicNumberLower(getContext()
-				.nCtx(), getNativeObject(), precision));
-	}
+        return new RatNum(getContext(), Native.getAlgebraicNumberLower(getContext()
+                .nCtx(), getNativeObject(), precision));
+    }
 
-	/**
-	 * Returns a string representation in decimal notation.
-	 * Remarks: The result has at most {@code precision} decimal places.
-	 * @param precision precision
-	 * @return String
-	 * @throws Z3Exception on error
-	 **/
-	public String toDecimal(int precision)
-	{
+    /**
+     * Returns a string representation in decimal notation.
+     * Remarks: The result has at most {@code precision} decimal places.
+     * @param precision precision
+     * @return String
+     * @throws Z3Exception on error
+     **/
+    public String toDecimal(int precision)
+    {
 
-		return Native.getNumeralDecimalString(getContext().nCtx(), getNativeObject(),
-				precision);
-	}
+        return Native.getNumeralDecimalString(getContext().nCtx(), getNativeObject(),
+                precision);
+    }
 
-	AlgebraicNum(Context ctx, long obj)
-	{
-		super(ctx, obj);
+    AlgebraicNum(Context ctx, long obj)
+    {
+        super(ctx, obj);
 
-	}
+    }
 }
diff --git a/src/api/java/Context.java b/src/api/java/Context.java
index 2609dbb29..986736fb6 100644
--- a/src/api/java/Context.java
+++ b/src/api/java/Context.java
@@ -1898,8 +1898,8 @@ public class Context implements AutoCloseable {
     */
     public SeqExpr mkEmptySeq(Sort s) 
     {
-	checkContextMatch(s);
-	return (SeqExpr) Expr.create(this, Native.mkSeqEmpty(nCtx(), s.getNativeObject()));
+        checkContextMatch(s);
+        return (SeqExpr) Expr.create(this, Native.mkSeqEmpty(nCtx(), s.getNativeObject()));
     }
 
     /**
@@ -1907,8 +1907,8 @@ public class Context implements AutoCloseable {
      */
     public SeqExpr mkUnit(Expr elem) 
     {
-	checkContextMatch(elem);
-	return (SeqExpr) Expr.create(this, Native.mkSeqUnit(nCtx(), elem.getNativeObject()));
+        checkContextMatch(elem);
+        return (SeqExpr) Expr.create(this, Native.mkSeqUnit(nCtx(), elem.getNativeObject()));
     }
     
     /**
@@ -1916,7 +1916,7 @@ public class Context implements AutoCloseable {
      */
     public SeqExpr mkString(String s) 
     {
-	return (SeqExpr) Expr.create(this, Native.mkString(nCtx(), s));
+        return (SeqExpr) Expr.create(this, Native.mkString(nCtx(), s));
     }
     
     /**
@@ -1924,8 +1924,8 @@ public class Context implements AutoCloseable {
      */
     public SeqExpr mkConcat(SeqExpr... t)
     {
-	checkContextMatch(t);
-	return (SeqExpr) Expr.create(this, Native.mkSeqConcat(nCtx(), t.length, AST.arrayToNative(t)));
+        checkContextMatch(t);
+        return (SeqExpr) Expr.create(this, Native.mkSeqConcat(nCtx(), t.length, AST.arrayToNative(t)));
     }
     
     
@@ -1934,8 +1934,8 @@ public class Context implements AutoCloseable {
      */
     public IntExpr mkLength(SeqExpr s)
     {
-	checkContextMatch(s);
-	return (IntExpr) Expr.create(this, Native.mkSeqLength(nCtx(), s.getNativeObject()));
+        checkContextMatch(s);
+        return (IntExpr) Expr.create(this, Native.mkSeqLength(nCtx(), s.getNativeObject()));
     }
     
     /**
@@ -1943,8 +1943,8 @@ public class Context implements AutoCloseable {
      */
     public BoolExpr mkPrefixOf(SeqExpr s1, SeqExpr s2) 
     {
-	checkContextMatch(s1, s2);
-	return (BoolExpr) Expr.create(this, Native.mkSeqPrefix(nCtx(), s1.getNativeObject(), s2.getNativeObject()));
+        checkContextMatch(s1, s2);
+        return (BoolExpr) Expr.create(this, Native.mkSeqPrefix(nCtx(), s1.getNativeObject(), s2.getNativeObject()));
     }
     
     /**
@@ -1952,8 +1952,8 @@ public class Context implements AutoCloseable {
      */
     public BoolExpr mkSuffixOf(SeqExpr s1, SeqExpr s2) 
     {
-	checkContextMatch(s1, s2);
-	return (BoolExpr)Expr.create(this, Native.mkSeqSuffix(nCtx(), s1.getNativeObject(), s2.getNativeObject()));
+        checkContextMatch(s1, s2);
+        return (BoolExpr)Expr.create(this, Native.mkSeqSuffix(nCtx(), s1.getNativeObject(), s2.getNativeObject()));
     }
     
     /**
@@ -1961,8 +1961,8 @@ public class Context implements AutoCloseable {
      */
     public BoolExpr mkContains(SeqExpr s1, SeqExpr s2) 
     {
-	checkContextMatch(s1, s2);
-	return (BoolExpr) Expr.create(this, Native.mkSeqContains(nCtx(), s1.getNativeObject(), s2.getNativeObject()));
+        checkContextMatch(s1, s2);
+        return (BoolExpr) Expr.create(this, Native.mkSeqContains(nCtx(), s1.getNativeObject(), s2.getNativeObject()));
     }
     
     /**
@@ -1970,8 +1970,8 @@ public class Context implements AutoCloseable {
      */
     public SeqExpr mkAt(SeqExpr s, IntExpr index)
     {
-	checkContextMatch(s, index);
-	return (SeqExpr) Expr.create(this, Native.mkSeqAt(nCtx(), s.getNativeObject(), index.getNativeObject()));
+        checkContextMatch(s, index);
+        return (SeqExpr) Expr.create(this, Native.mkSeqAt(nCtx(), s.getNativeObject(), index.getNativeObject()));
     }
     
     /**
@@ -1979,8 +1979,8 @@ public class Context implements AutoCloseable {
      */
     public SeqExpr mkExtract(SeqExpr s, IntExpr offset, IntExpr length)
     {
-	checkContextMatch(s, offset, length);
-	return (SeqExpr) Expr.create(this, Native.mkSeqExtract(nCtx(), s.getNativeObject(), offset.getNativeObject(), length.getNativeObject()));
+        checkContextMatch(s, offset, length);
+        return (SeqExpr) Expr.create(this, Native.mkSeqExtract(nCtx(), s.getNativeObject(), offset.getNativeObject(), length.getNativeObject()));
     }
     
     /**
@@ -1988,8 +1988,8 @@ public class Context implements AutoCloseable {
      */
     public IntExpr mkIndexOf(SeqExpr s, SeqExpr substr, ArithExpr offset)
     {
-	checkContextMatch(s, substr, offset);
-	return (IntExpr)Expr.create(this, Native.mkSeqIndex(nCtx(), s.getNativeObject(), substr.getNativeObject(), offset.getNativeObject()));
+        checkContextMatch(s, substr, offset);
+        return (IntExpr)Expr.create(this, Native.mkSeqIndex(nCtx(), s.getNativeObject(), substr.getNativeObject(), offset.getNativeObject()));
     }
     
     /**
@@ -1997,8 +1997,8 @@ public class Context implements AutoCloseable {
      */
     public SeqExpr mkReplace(SeqExpr s, SeqExpr src, SeqExpr dst)
     {
-	checkContextMatch(s, src, dst);
-	return (SeqExpr) Expr.create(this, Native.mkSeqReplace(nCtx(), s.getNativeObject(), src.getNativeObject(), dst.getNativeObject()));
+        checkContextMatch(s, src, dst);
+        return (SeqExpr) Expr.create(this, Native.mkSeqReplace(nCtx(), s.getNativeObject(), src.getNativeObject(), dst.getNativeObject()));
     }
     
     /**
@@ -2006,8 +2006,8 @@ public class Context implements AutoCloseable {
      */
     public ReExpr mkToRe(SeqExpr s) 
     {
-	checkContextMatch(s);
-	return (ReExpr) Expr.create(this, Native.mkSeqToRe(nCtx(), s.getNativeObject()));            
+        checkContextMatch(s);
+        return (ReExpr) Expr.create(this, Native.mkSeqToRe(nCtx(), s.getNativeObject()));            
     }
     
     
@@ -2016,8 +2016,8 @@ public class Context implements AutoCloseable {
      */
     public BoolExpr mkInRe(SeqExpr s, ReExpr re)
     {
-	checkContextMatch(s, re);
-	return (BoolExpr) Expr.create(this, Native.mkSeqInRe(nCtx(), s.getNativeObject(), re.getNativeObject()));            
+        checkContextMatch(s, re);
+        return (BoolExpr) Expr.create(this, Native.mkSeqInRe(nCtx(), s.getNativeObject(), re.getNativeObject()));            
     }
     
     /**
@@ -2025,8 +2025,8 @@ public class Context implements AutoCloseable {
      */
     public ReExpr mkStar(ReExpr re)
     {
-	checkContextMatch(re);
-	return (ReExpr) Expr.create(this, Native.mkReStar(nCtx(), re.getNativeObject()));            
+        checkContextMatch(re);
+        return (ReExpr) Expr.create(this, Native.mkReStar(nCtx(), re.getNativeObject()));            
     }
 
     /**
@@ -2034,7 +2034,7 @@ public class Context implements AutoCloseable {
      */
     public ReExpr mkLoop(ReExpr re, int lo, int hi)
     {
-	return (ReExpr) Expr.create(this, Native.mkReLoop(nCtx(), re.getNativeObject(), lo, hi));            
+        return (ReExpr) Expr.create(this, Native.mkReLoop(nCtx(), re.getNativeObject(), lo, hi));            
     }
 
     /**
@@ -2042,7 +2042,7 @@ public class Context implements AutoCloseable {
      */
     public ReExpr mkLoop(ReExpr re, int lo)
     {
-	return (ReExpr) Expr.create(this, Native.mkReLoop(nCtx(), re.getNativeObject(), lo, 0));            
+        return (ReExpr) Expr.create(this, Native.mkReLoop(nCtx(), re.getNativeObject(), lo, 0));            
     }
 
     
@@ -2051,8 +2051,8 @@ public class Context implements AutoCloseable {
      */
     public ReExpr mkPlus(ReExpr re)
     {
-	checkContextMatch(re);
-	return (ReExpr) Expr.create(this, Native.mkRePlus(nCtx(), re.getNativeObject()));            
+        checkContextMatch(re);
+        return (ReExpr) Expr.create(this, Native.mkRePlus(nCtx(), re.getNativeObject()));            
     }
     
     /**
@@ -2060,8 +2060,8 @@ public class Context implements AutoCloseable {
      */
     public ReExpr mkOption(ReExpr re)
     {
-	checkContextMatch(re);
-	return (ReExpr) Expr.create(this, Native.mkReOption(nCtx(), re.getNativeObject()));            
+        checkContextMatch(re);
+        return (ReExpr) Expr.create(this, Native.mkReOption(nCtx(), re.getNativeObject()));            
     }
 
     
@@ -2070,8 +2070,8 @@ public class Context implements AutoCloseable {
      */
     public ReExpr mkComplement(ReExpr re)
     {
-	checkContextMatch(re);
-	return (ReExpr) Expr.create(this, Native.mkReComplement(nCtx(), re.getNativeObject()));            
+        checkContextMatchb(re);
+        return (ReExpr) Expr.create(this, Native.mkReComplement(nCtx(), re.getNativeObject()));            
     }    
 
     /**
@@ -2079,8 +2079,8 @@ public class Context implements AutoCloseable {
      */
     public ReExpr mkConcat(ReExpr... t)
     {
-	checkContextMatch(t);
-	return (ReExpr) Expr.create(this, Native.mkReConcat(nCtx(), t.length, AST.arrayToNative(t)));
+        checkContextMatch(t);
+        return (ReExpr) Expr.create(this, Native.mkReConcat(nCtx(), t.length, AST.arrayToNative(t)));
     }
     
     /**
@@ -2088,8 +2088,8 @@ public class Context implements AutoCloseable {
      */
     public ReExpr mkUnion(ReExpr... t)
     {
-	checkContextMatch(t);
-	return (ReExpr) Expr.create(this, Native.mkReUnion(nCtx(), t.length, AST.arrayToNative(t)));
+        checkContextMatch(t);
+        return (ReExpr) Expr.create(this, Native.mkReUnion(nCtx(), t.length, AST.arrayToNative(t)));
     }
 
     /**
@@ -2097,8 +2097,8 @@ public class Context implements AutoCloseable {
      */
     public ReExpr mkIntersect(ReExpr... t)
     {
-	checkContextMatch(t);
-	return (ReExpr) Expr.create(this, Native.mkReIntersect(nCtx(), t.length, AST.arrayToNative(t)));
+        checkContextMatch(t);
+        return (ReExpr) Expr.create(this, Native.mkReIntersect(nCtx(), t.length, AST.arrayToNative(t)));
     }    
     
     /**
@@ -2106,8 +2106,8 @@ public class Context implements AutoCloseable {
      */
     public ReExpr MkRange(SeqExpr lo, SeqExpr hi) 
     {
-	checkContextMatch(lo, hi);
-	return (ReExpr) Expr.create(this, Native.mkReRange(nCtx(), lo.getNativeObject(), hi.getNativeObject()));
+        checkContextMatch(lo, hi);
+        return (ReExpr) Expr.create(this, Native.mkReRange(nCtx(), lo.getNativeObject(), hi.getNativeObject()));
     }
 
 
@@ -2116,8 +2116,8 @@ public class Context implements AutoCloseable {
      */
     public BoolExpr mkAtMost(BoolExpr[] args, int k)
     {
-	checkContextMatch(args);
-	return (BoolExpr) Expr.create(this, Native.mkAtmost(nCtx(), args.length, AST.arrayToNative(args), k));
+        checkContextMatch(args);
+        return (BoolExpr) Expr.create(this, Native.mkAtmost(nCtx(), args.length, AST.arrayToNative(args), k));
     }
 
     /**
@@ -2125,8 +2125,8 @@ public class Context implements AutoCloseable {
      */
     public BoolExpr mkAtLeast(BoolExpr[] args, int k)
     {
-	checkContextMatch(args);
-	return (BoolExpr) Expr.create(this, Native.mkAtleast(nCtx(), args.length, AST.arrayToNative(args), k));
+        checkContextMatch(args);
+        return (BoolExpr) Expr.create(this, Native.mkAtleast(nCtx(), args.length, AST.arrayToNative(args), k));
     }
 
     /**
@@ -2134,8 +2134,8 @@ public class Context implements AutoCloseable {
      */
     public BoolExpr mkPBLe(int[] coeffs, BoolExpr[] args, int k)
     {
-	checkContextMatch(args);
-	return (BoolExpr) Expr.create(this, Native.mkPble(nCtx(), args.length, AST.arrayToNative(args), coeffs, k));
+        checkContextMatch(args);
+        return (BoolExpr) Expr.create(this, Native.mkPble(nCtx(), args.length, AST.arrayToNative(args), coeffs, k));
     }
 
     /**
@@ -2143,8 +2143,8 @@ public class Context implements AutoCloseable {
      */
     public BoolExpr mkPBGe(int[] coeffs, BoolExpr[] args, int k)
     {
-	checkContextMatch(args);
-	return (BoolExpr) Expr.create(this, Native.mkPbge(nCtx(), args.length, AST.arrayToNative(args), coeffs, k));
+        checkContextMatch(args);
+        return (BoolExpr) Expr.create(this, Native.mkPbge(nCtx(), args.length, AST.arrayToNative(args), coeffs, k));
     }
 
     /**
@@ -2152,8 +2152,8 @@ public class Context implements AutoCloseable {
      */
     public BoolExpr mkPBEq(int[] coeffs, BoolExpr[] args, int k)
     {
-	checkContextMatch(args);
-	return (BoolExpr) Expr.create(this, Native.mkPbeq(nCtx(), args.length, AST.arrayToNative(args), coeffs, k));
+        checkContextMatch(args);
+        return (BoolExpr) Expr.create(this, Native.mkPbeq(nCtx(), args.length, AST.arrayToNative(args), coeffs, k));
     }
 
 
@@ -3988,15 +3988,15 @@ public class Context implements AutoCloseable {
 
     void checkContextMatch(Z3Object other1, Z3Object other2)
     {
-	checkContextMatch(other1);
-	checkContextMatch(other2);
+        checkContextMatch(other1);
+        checkContextMatch(other2);
     }
 
     void checkContextMatch(Z3Object other1, Z3Object other2, Z3Object other3)
     {
-	checkContextMatch(other1);
-	checkContextMatch(other2);
-	checkContextMatch(other3);
+        checkContextMatch(other1);
+        checkContextMatch(other2);
+        checkContextMatch(other3);
     }
 
     void checkContextMatch(Z3Object[] arr)
diff --git a/src/api/java/EnumSort.java b/src/api/java/EnumSort.java
index ce2f8d578..e0bd0f617 100644
--- a/src/api/java/EnumSort.java
+++ b/src/api/java/EnumSort.java
@@ -65,7 +65,7 @@ public class EnumSort extends Sort
      **/
     public Expr getConst(int inx)
     {        
-    	return getContext().mkApp(getConstDecl(inx));
+        return getContext().mkApp(getConstDecl(inx));
     }
 
     /**
diff --git a/src/api/java/Expr.java b/src/api/java/Expr.java
index 6cabbb1b8..d3793a24b 100644
--- a/src/api/java/Expr.java
+++ b/src/api/java/Expr.java
@@ -1287,7 +1287,7 @@ public class Expr extends AST
      */
     public String getString()
     {
-	return Native.getString(getContext().nCtx(), getNativeObject());
+        return Native.getString(getContext().nCtx(), getNativeObject());
     }
 
     /**
diff --git a/src/api/java/Model.java b/src/api/java/Model.java
index 60abb001d..9c7013aca 100644
--- a/src/api/java/Model.java
+++ b/src/api/java/Model.java
@@ -200,7 +200,7 @@ public class Model extends Z3Object {
      * Remarks:  This function may fail if {@code t} contains
      * quantifiers, is partial (MODEL_PARTIAL enabled), or if {@code t} is not well-sorted. In this case a
      * {@code ModelEvaluationFailedException} is thrown.  
-	 * @param t the expression to evaluate
+     * @param t the expression to evaluate
      * @param completion An expression {@code completion} When this flag
      * is enabled, a model value will be assigned to any constant or function
      * that does not have an interpretation in the model.
diff --git a/src/api/java/Optimize.java b/src/api/java/Optimize.java
index bc2232888..3edbff73e 100644
--- a/src/api/java/Optimize.java
+++ b/src/api/java/Optimize.java
@@ -213,7 +213,7 @@ public class Optimize extends Z3Object {
      *  Declare an arithmetical maximization objective.
      *  Return a handle to the objective. The handle is used as
      *  to retrieve the values of objectives after calling Check.
-     **/        	
+     **/            
     public Handle MkMaximize(ArithExpr e)
     {
         return new Handle(this, Native.optimizeMaximize(getContext().nCtx(), getNativeObject(), e.getNativeObject()));
@@ -285,8 +285,7 @@ public class Optimize extends Z3Object {
      **/
     public String getReasonUnknown()
     {
-        return Native.optimizeGetReasonUnknown(getContext().nCtx(),
-                getNativeObject());	
+        return Native.optimizeGetReasonUnknown(getContext().nCtx(), getNativeObject());
     }
 
     /**
@@ -304,7 +303,7 @@ public class Optimize extends Z3Object {
      */
     public void fromFile(String file)
     {
-	Native.optimizeFromFile(getContext().nCtx(), getNativeObject(), file);
+        Native.optimizeFromFile(getContext().nCtx(), getNativeObject(), file);
     }
 
     /**
@@ -312,7 +311,7 @@ public class Optimize extends Z3Object {
      */
     public void fromString(String s)
     {
-	Native.optimizeFromString(getContext().nCtx(), getNativeObject(), s);
+        Native.optimizeFromString(getContext().nCtx(), getNativeObject(), s);
     }
 
 
diff --git a/src/api/java/ParamDescrs.java b/src/api/java/ParamDescrs.java
index 0008515e3..fdaf29647 100644
--- a/src/api/java/ParamDescrs.java
+++ b/src/api/java/ParamDescrs.java
@@ -49,7 +49,7 @@ public class ParamDescrs extends Z3Object {
 
      public String getDocumentation(Symbol name)
      {
-	 return Native.paramDescrsGetDocumentation(getContext().nCtx(), getNativeObject(), name.getNativeObject());
+         return Native.paramDescrsGetDocumentation(getContext().nCtx(), getNativeObject(), name.getNativeObject());
      }
 
     /**
diff --git a/src/api/java/Solver.java b/src/api/java/Solver.java
index a98fcbf94..19f3b01da 100644
--- a/src/api/java/Solver.java
+++ b/src/api/java/Solver.java
@@ -302,7 +302,7 @@ public class Solver extends Z3Object {
      */
     public Solver translate(Context ctx) 
     {
-	return new Solver(ctx, Native.solverTranslate(getContext().nCtx(), getNativeObject(), ctx.nCtx()));
+        return new Solver(ctx, Native.solverTranslate(getContext().nCtx(), getNativeObject(), ctx.nCtx()));
     }
 
     /**
diff --git a/src/api/java/Sort.java b/src/api/java/Sort.java
index e7a186ad2..a89417059 100644
--- a/src/api/java/Sort.java
+++ b/src/api/java/Sort.java
@@ -35,12 +35,8 @@ public class Sort extends AST
         if (!(o instanceof Sort)) return false;
         Sort other = (Sort) o;
 
-	return  (getContext().nCtx() == other.getContext().nCtx()) &&
-	    (Native.isEqSort(
-            getContext().nCtx(),
-            getNativeObject(),
-            other.getNativeObject()
-        ));
+        return (getContext().nCtx() == other.getContext().nCtx()) &&
+            (Native.isEqSort(getContext().nCtx(), getNativeObject(), other.getNativeObject()));
     }
 
     /**
diff --git a/src/api/ml/z3native_stubs.c.pre b/src/api/ml/z3native_stubs.c.pre
index 1b1ea3fde..c1c772c85 100644
--- a/src/api/ml/z3native_stubs.c.pre
+++ b/src/api/ml/z3native_stubs.c.pre
@@ -25,34 +25,34 @@ extern "C" {
 #include <z3native_stubs.h>
 
 #define CAMLlocal6(X1,X2,X3,X4,X5,X6)                                   \
-  CAMLlocal5(X1,X2,X3,X4,X5);                                       	\
+  CAMLlocal5(X1,X2,X3,X4,X5);                                           \
   CAMLlocal1(X6)
-#define CAMLlocal7(X1,X2,X3,X4,X5,X6,X7)				\
-  CAMLlocal5(X1,X2,X3,X4,X5);                                       	\
+#define CAMLlocal7(X1,X2,X3,X4,X5,X6,X7)                                \
+  CAMLlocal5(X1,X2,X3,X4,X5);                                           \
   CAMLlocal2(X6,X7)
-#define CAMLlocal8(X1,X2,X3,X4,X5,X6,X7,X8)				\
-  CAMLlocal5(X1,X2,X3,X4,X5);                                       	\
+#define CAMLlocal8(X1,X2,X3,X4,X5,X6,X7,X8)                             \
+  CAMLlocal5(X1,X2,X3,X4,X5);                                           \
   CAMLlocal3(X6,X7,X8)
 
-#define CAMLparam6(X1,X2,X3,X4,X5,X6)                   \
-  CAMLparam5(X1,X2,X3,X4,X5);                                       	\
+#define CAMLparam6(X1,X2,X3,X4,X5,X6)                                   \
+  CAMLparam5(X1,X2,X3,X4,X5);                                           \
   CAMLxparam1(X6)
-#define CAMLparam7(X1,X2,X3,X4,X5,X6,X7)				\
-  CAMLparam5(X1,X2,X3,X4,X5);                                       	\
+#define CAMLparam7(X1,X2,X3,X4,X5,X6,X7)                                \
+  CAMLparam5(X1,X2,X3,X4,X5);                                           \
   CAMLxparam2(X6,X7)
-#define CAMLparam8(X1,X2,X3,X4,X5,X6,X7,X8)				\
-  CAMLparam5(X1,X2,X3,X4,X5);                                       	\
+#define CAMLparam8(X1,X2,X3,X4,X5,X6,X7,X8)                             \
+  CAMLparam5(X1,X2,X3,X4,X5);                                           \
   CAMLxparam3(X6,X7,X8)
-#define CAMLparam9(X1,X2,X3,X4,X5,X6,X7,X8,X9)				\
-  CAMLparam5(X1,X2,X3,X4,X5);                                       	\
+#define CAMLparam9(X1,X2,X3,X4,X5,X6,X7,X8,X9)                          \
+  CAMLparam5(X1,X2,X3,X4,X5);                                           \
   CAMLxparam4(X6,X7,X8,X9)
-#define CAMLparam12(X1,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12)		\
-  CAMLparam5(X1,X2,X3,X4,X5);                                   	\
-  CAMLxparam5(X6,X7,X8,X9,X10);                                 	\
+#define CAMLparam12(X1,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12)             \
+  CAMLparam5(X1,X2,X3,X4,X5);                                           \
+  CAMLxparam5(X6,X7,X8,X9,X10);                                         \
   CAMLxparam2(X11,X12)
-#define CAMLparam13(X1,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,X13)		\
-  CAMLparam5(X1,X2,X3,X4,X5);                                   	\
-  CAMLxparam5(X6,X7,X8,X9,X10);                                 	\
+#define CAMLparam13(X1,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,X13)        \
+  CAMLparam5(X1,X2,X3,X4,X5);                                          \
+  CAMLxparam5(X6,X7,X8,X9,X10);                                        \
   CAMLxparam3(X11,X12,X13)
 
 
diff --git a/src/ast/rewriter/array_rewriter_params.pyg b/src/ast/rewriter/array_rewriter_params.pyg
index a43fadecf..3b4af7fb7 100644
--- a/src/ast/rewriter/array_rewriter_params.pyg
+++ b/src/ast/rewriter/array_rewriter_params.pyg
@@ -2,5 +2,5 @@ def_module_params(module_name='rewriter',
                   class_name='array_rewriter_params',
                   export=True,
                   params=(("expand_select_store", BOOL, False, "replace a (select (store ...) ...) term by an if-then-else term"),
-			  ("expand_store_eq", BOOL, False, "reduce (store ...) = (store ...) with a common base into selects"),
+                          ("expand_store_eq", BOOL, False, "reduce (store ...) = (store ...) with a common base into selects"),
                           ("sort_store", BOOL, False, "sort nested stores when the indices are known to be different")))
diff --git a/src/ast/rewriter/fpa_rewriter_params.pyg b/src/ast/rewriter/fpa_rewriter_params.pyg
index f0cfbdf55..487c50a85 100644
--- a/src/ast/rewriter/fpa_rewriter_params.pyg
+++ b/src/ast/rewriter/fpa_rewriter_params.pyg
@@ -1,5 +1,5 @@
 def_module_params(module_name='rewriter',
                   class_name='fpa_rewriter_params',
                   export=True,
-				  params=(("hi_fp_unspecified", BOOL, False, "use the 'hardware interpretation' for unspecified values in fp.to_ubv, fp.to_sbv, fp.to_real, and fp.to_ieee_bv"),
+                  params=(("hi_fp_unspecified", BOOL, False, "use the 'hardware interpretation' for unspecified values in fp.to_ubv, fp.to_sbv, fp.to_real, and fp.to_ieee_bv"),
 ))
diff --git a/src/muz/base/fixedpoint_params.pyg b/src/muz/base/fixedpoint_params.pyg
index 110f081b0..0c2f03460 100644
--- a/src/muz/base/fixedpoint_params.pyg
+++ b/src/muz/base/fixedpoint_params.pyg
@@ -4,7 +4,7 @@ def_module_params('fixedpoint',
                   params=(('timeout', UINT, UINT_MAX, 'set timeout'),
                           ('engine', SYMBOL, 'auto-config', 
                            'Select: auto-config, datalog, duality, pdr, bmc, spacer'),
-			  ('datalog.default_table', SYMBOL, 'sparse', 
+                          ('datalog.default_table', SYMBOL, 'sparse', 
                            'default table implementation: sparse, hashtable, bitvector, interval'),
                           ('datalog.default_relation', SYMBOL, 'pentagon', 
                            'default relation implementation: external_relation, pentagon'),
@@ -56,18 +56,18 @@ def_module_params('fixedpoint',
                            "table columns, if it would have been empty otherwise"),
                           ('datalog.subsumption', BOOL, True,
                            "if true, removes/filters predicates with total transitions"),
-	                  ('duality.full_expand', BOOL, False, 'Fully expand derivation trees'),
-	                  ('duality.no_conj', BOOL, False, 'No forced covering (conjectures)'),
-	                  ('duality.feasible_edges', BOOL, True, 
+                          ('duality.full_expand', BOOL, False, 'Fully expand derivation trees'),
+                          ('duality.no_conj', BOOL, False, 'No forced covering (conjectures)'),
+                          ('duality.feasible_edges', BOOL, True, 
                            'Don\'t expand definitley infeasible edges'),
-	                  ('duality.use_underapprox', BOOL, False, 'Use underapproximations'),
-			  ('duality.stratified_inlining', BOOL, False, 'Use stratified inlining'),
-			  ('duality.recursion_bound', UINT, UINT_MAX, 
+                          ('duality.use_underapprox', BOOL, False, 'Use underapproximations'),
+                          ('duality.stratified_inlining', BOOL, False, 'Use stratified inlining'),
+                          ('duality.recursion_bound', UINT, UINT_MAX, 
                            'Recursion bound for stratified inlining'),
-			  ('duality.profile', BOOL, False, 'profile run time'),
-			  ('duality.mbqi', BOOL, True, 'use model-based quantifier instantiation'),
-			  ('duality.batch_expand', BOOL, False, 'use batch expansion'),
-			  ('duality.conjecture_file', STRING, '', 'save conjectures to file'),
+                          ('duality.profile', BOOL, False, 'profile run time'),
+                          ('duality.mbqi', BOOL, True, 'use model-based quantifier instantiation'),
+                          ('duality.batch_expand', BOOL, False, 'use batch expansion'),
+                          ('duality.conjecture_file', STRING, '', 'save conjectures to file'),
                           ('pdr.bfs_model_search', BOOL, True, 
                            "use BFS strategy for expanding model search"),    
                           ('pdr.farkas', BOOL, True, 
@@ -92,9 +92,9 @@ def_module_params('fixedpoint',
                            "generalize lemmas using induction strengthening"),
                           ('pdr.use_arith_inductive_generalizer', BOOL, False, 
                            "generalize lemmas using arithmetic heuristics for induction strengthening"),
-	                  ('pdr.use_convex_closure_generalizer', BOOL, False, 
+                          ('pdr.use_convex_closure_generalizer', BOOL, False, 
                            "generalize using convex closures of lemmas"),
-	                  ('pdr.use_convex_interior_generalizer', BOOL, False, 
+                          ('pdr.use_convex_interior_generalizer', BOOL, False, 
                            "generalize using convex interiors of lemmas"),
                           ('pdr.cache_mode', UINT, 0, "use no (0), symbolic (1) or explicit " + 
                            "cache (2) for model search"),
@@ -104,7 +104,7 @@ def_module_params('fixedpoint',
                           ('pdr.max_num_contexts', UINT, 500, "maximal number of contexts to create"),
                           ('pdr.try_minimize_core', BOOL, False, 
                            "try to reduce core size (before inductive minimization)"),
-			  ('pdr.utvpi', BOOL, True, 'Enable UTVPI strategy'),
+                          ('pdr.utvpi', BOOL, True, 'Enable UTVPI strategy'),
                           ('print_fixedpoint_extensions', BOOL, True, 
                            "use SMT-LIB2 fixedpoint extensions, instead of pure SMT2, " + 
                            "when printing rules"),
@@ -123,7 +123,7 @@ def_module_params('fixedpoint',
                           ('print_statistics',  BOOL, False, 'print statistics'),
                           ('print_aig', SYMBOL, '', 
                            'Dump clauses in AIG text format (AAG) to the given file name'),
-	                  ('tab.selection', SYMBOL, 'weight',
+                          ('tab.selection', SYMBOL, 'weight',
                            'selection method for tabular strategy: weight (default), first, var-use'),
                           ('xform.bit_blast', BOOL, False, 
                            'bit-blast bit-vectors'),
@@ -140,7 +140,7 @@ def_module_params('fixedpoint',
                           ('xform.unfold_rules', UINT, 0, 
                            "unfold rules statically using iterative squarring"),
                           ('xform.slice', BOOL, True, "simplify clause set using slicing"),
-	                  ('xform.karr',  BOOL, False, 
+                          ('xform.karr',  BOOL, False, 
                            "Add linear invariants to clauses using Karr's method"),
                           ('spacer.use_eqclass', BOOL, False, "Generalizes equalities to equivalence classes"),
                           ('xform.transform_arrays',  BOOL, False, 
@@ -153,24 +153,24 @@ def_module_params('fixedpoint',
                            "Gives the number of quantifiers per array"),
                           ('xform.instantiate_arrays.slice_technique',  SYMBOL, "no-slicing", 
                            "<no-slicing>=> GetId(i) = i, <smash> => GetId(i) = true"),
-	                  ('xform.quantify_arrays', BOOL, False, 
+                          ('xform.quantify_arrays', BOOL, False, 
                            "create quantified Horn clauses from clauses with arrays"),
-	                  ('xform.instantiate_quantifiers', BOOL, False, 
+                          ('xform.instantiate_quantifiers', BOOL, False, 
                            "instantiate quantified Horn clauses using E-matching heuristic"),
                           ('xform.coalesce_rules', BOOL, False, "coalesce rules"),
                           ('xform.tail_simplifier_pve', BOOL, True, "propagate_variable_equivalences"),
                           ('xform.subsumption_checker', BOOL, True, "Enable subsumption checker (no support for model conversion)"),
-                          ('xform.coi', BOOL, True, "use cone of influence simplificaiton"),
-			  ('duality.enable_restarts', BOOL, False, 'DUALITY: enable restarts'),
+                          ('xform.coi', BOOL, True, "use cone of influence simplification"),
+                          ('duality.enable_restarts', BOOL, False, 'DUALITY: enable restarts'),
                           ('spacer.order_children', UINT, 0, 'SPACER: order of enqueuing children in non-linear rules : 0 (original), 1 (reverse)'),
                           ('spacer.eager_reach_check', BOOL, True, 'SPACER: eagerly check if a query is reachable using reachability facts of predecessors'),
                           ('spacer.use_lemma_as_cti', BOOL, False, 'SPACER: use a lemma instead of a CTI in flexible_trace'),
                           ('spacer.reset_obligation_queue', BOOL, True, 'SPACER: reset obligation queue when entering a new level'),
                           ('spacer.init_reach_facts', BOOL, True, 'SPACER: initialize reachability facts with false'),
                           ('spacer.use_array_eq_generalizer', BOOL, True, 'SPACER: attempt to generalize lemmas with array equalities'),
-                          ('spacer.use_derivations', BOOL, True, 'SPACER: using derivation mechanism to cache intermediate results for non-linear rules'),	
+                          ('spacer.use_derivations', BOOL, True, 'SPACER: using derivation mechanism to cache intermediate results for non-linear rules'),    
                           ('xform.array_blast', BOOL, False, "try to eliminate local array terms using Ackermannization -- some array terms may remain"), 
-	                  ('xform.array_blast_full', BOOL, False, "eliminate all local array variables by QE"),
+                          ('xform.array_blast_full', BOOL, False, "eliminate all local array variables by QE"),
                           ('spacer.skip_propagate', BOOL, False, "Skip propagate/pushing phase. Turns PDR into a BMC that returns either reachable or unknown"),
                           ('spacer.max_level', UINT, UINT_MAX, "Maximum level to explore"),
                           ('spacer.elim_aux', BOOL, True, "Eliminate auxiliary variables in reachability facts"),
diff --git a/src/opt/opt_params.pyg b/src/opt/opt_params.pyg
index 13bf51313..cfcc5e47e 100644
--- a/src/opt/opt_params.pyg
+++ b/src/opt/opt_params.pyg
@@ -2,7 +2,7 @@ def_module_params('opt',
                   description='optimization parameters',
                   export=True,
                   params=(('optsmt_engine', SYMBOL, 'basic', "select optimization engine: 'basic', 'farkas', 'symba'"),
-	                  ('maxsat_engine', SYMBOL, 'maxres', "select engine for maxsat: 'core_maxsat', 'wmax', 'maxres', 'pd-maxres'"),
+                          ('maxsat_engine', SYMBOL, 'maxres', "select engine for maxsat: 'core_maxsat', 'wmax', 'maxres', 'pd-maxres'"),
                           ('priority', SYMBOL, 'lex', "select how to priortize objectives: 'lex' (lexicographic), 'pareto', or 'box'"),
                           ('dump_benchmarks', BOOL, False, 'dump benchmarks for profiling'),
                           ('timeout', UINT, UINT_MAX, 'timeout (in milliseconds) (UINT_MAX and 0 mean no timeout)'),
diff --git a/src/tactic/sls/.#sls_params.pyg b/src/tactic/sls/.#sls_params.pyg
new file mode 100644
index 000000000..50991f6f4
--- /dev/null
+++ b/src/tactic/sls/.#sls_params.pyg
@@ -0,0 +1 @@
+winte@WINTERMUTE.13536:1505663874
\ No newline at end of file
diff --git a/src/tactic/sls/sls_params.pyg b/src/tactic/sls/sls_params.pyg
index bf5bd181a..05405ef24 100644
--- a/src/tactic/sls/sls_params.pyg
+++ b/src/tactic/sls/sls_params.pyg
@@ -2,25 +2,25 @@ def_module_params('sls',
                   export=True,
                   description='Experimental Stochastic Local Search Solver (for QFBV only).',
                   params=(max_memory_param(),
-						('max_restarts', UINT, UINT_MAX, 'maximum number of restarts'),
-						('walksat', BOOL, 1, 'use walksat assertion selection (instead of gsat)'),
-						('walksat_ucb', BOOL, 1, 'use bandit heuristic for walksat assertion selection (instead of random)'),
-						('walksat_ucb_constant', DOUBLE, 20.0, 'the ucb constant c in the term score + c * f(touched)'),
-						('walksat_ucb_init', BOOL, 0, 'initialize total ucb touched to formula size'),
-						('walksat_ucb_forget', DOUBLE, 1.0, 'scale touched by this factor every base restart interval'),
-						('walksat_ucb_noise', DOUBLE, 0.0002, 'add noise 0 <= 256 * ucb_noise to ucb score for assertion selection'),
-						('walksat_repick', BOOL, 1, 'repick assertion if randomizing in local minima'),
-						('scale_unsat', DOUBLE, 0.5, 'scale score of unsat expressions by this factor'),
-						('paws_init', UINT, 40, 'initial/minimum assertion weights'),
-						('paws_sp', UINT, 52, 'smooth assertion weights with probability paws_sp / 1024'),
-						('wp', UINT, 100, 'random walk with probability wp / 1024'),
-						('vns_mc', UINT, 0, 'in local minima, try Monte Carlo sampling vns_mc many 2-bit-flips per bit'),
-						('vns_repick', BOOL, 0, 'in local minima, try picking a different assertion (only for walksat)'),
-						('restart_base', UINT, 100, 'base restart interval given by moves per run'),
-						('restart_init', BOOL, 0, 'initialize to 0 or random value (= 1) after restart'),
-						('early_prune', BOOL, 1, 'use early pruning for score prediction'),
-						('random_offset', BOOL, 1, 'use random offset for candidate evaluation'),
-						('rescore', BOOL, 1, 'rescore/normalize top-level score every base restart interval'),
-						('track_unsat', BOOL, 0, 'keep a list of unsat assertions as done in SAT - currently disabled internally'),
-						('random_seed', UINT, 0, 'random seed')
-			  ))
+                        ('max_restarts', UINT, UINT_MAX, 'maximum number of restarts'),
+                        ('walksat', BOOL, 1, 'use walksat assertion selection (instead of gsat)'),
+                        ('walksat_ucb', BOOL, 1, 'use bandit heuristic for walksat assertion selection (instead of random)'),
+                        ('walksat_ucb_constant', DOUBLE, 20.0, 'the ucb constant c in the term score + c * f(touched)'),
+                        ('walksat_ucb_init', BOOL, 0, 'initialize total ucb touched to formula size'),
+                        ('walksat_ucb_forget', DOUBLE, 1.0, 'scale touched by this factor every base restart interval'),
+                        ('walksat_ucb_noise', DOUBLE, 0.0002, 'add noise 0 <= 256 * ucb_noise to ucb score for assertion selection'),
+                        ('walksat_repick', BOOL, 1, 'repick assertion if randomizing in local minima'),
+                        ('scale_unsat', DOUBLE, 0.5, 'scale score of unsat expressions by this factor'),
+                        ('paws_init', UINT, 40, 'initial/minimum assertion weights'),
+                        ('paws_sp', UINT, 52, 'smooth assertion weights with probability paws_sp / 1024'),
+                        ('wp', UINT, 100, 'random walk with probability wp / 1024'),
+                        ('vns_mc', UINT, 0, 'in local minima, try Monte Carlo sampling vns_mc many 2-bit-flips per bit'),
+                        ('vns_repick', BOOL, 0, 'in local minima, try picking a different assertion (only for walksat)'),
+                        ('restart_base', UINT, 100, 'base restart interval given by moves per run'),
+                        ('restart_init', BOOL, 0, 'initialize to 0 or random value (= 1) after restart'),
+                        ('early_prune', BOOL, 1, 'use early pruning for score prediction'),
+                        ('random_offset', BOOL, 1, 'use random offset for candidate evaluation'),
+                        ('rescore', BOOL, 1, 'rescore/normalize top-level score every base restart interval'),
+                        ('track_unsat', BOOL, 0, 'keep a list of unsat assertions as done in SAT - currently disabled internally'),
+                        ('random_seed', UINT, 0, 'random seed')
+              ))
diff --git a/src/util/lp/CMakeLists.txt b/src/util/lp/CMakeLists.txt
index ca8683434..70c5f9e3b 100644
--- a/src/util/lp/CMakeLists.txt
+++ b/src/util/lp/CMakeLists.txt
@@ -19,7 +19,7 @@ z3_add_component(lp
     lu_instances.cpp
     matrix_instances.cpp
     permutation_matrix_instances.cpp
-	quick_xplain.cpp
+    quick_xplain.cpp
     row_eta_matrix_instances.cpp
     scaler_instances.cpp
     sparse_matrix_instances.cpp
diff --git a/src/util/lp/lp_core_solver_base.hpp b/src/util/lp/lp_core_solver_base.hpp
index fa1c95850..b49dd0638 100644
--- a/src/util/lp/lp_core_solver_base.hpp
+++ b/src/util/lp/lp_core_solver_base.hpp
@@ -98,8 +98,8 @@ pivot_for_tableau_on_basis() {
 // i is the pivot row, and j is the pivot column
 template <typename T, typename X> void lp_core_solver_base<T, X>::
 pivot_to_reduced_costs_tableau(unsigned i, unsigned j) {
-	if (j >= m_d.size())
-		return;
+    if (j >= m_d.size())
+        return;
     T &a = m_d[j];
     if (is_zero(a))
         return;
diff --git a/src/util/lp/lp_primal_core_solver_tableau.h b/src/util/lp/lp_primal_core_solver_tableau.h
index 97fa2f9da..5c7d4d2c2 100644
--- a/src/util/lp/lp_primal_core_solver_tableau.h
+++ b/src/util/lp/lp_primal_core_solver_tableau.h
@@ -318,7 +318,7 @@ template <typename T, typename X> void lp_primal_core_solver<T, X>::init_run_tab
         this->m_basis_sort_counter = 0; // to initiate the sort of the basis
         this->set_total_iterations(0);
         this->iters_with_no_cost_growing() = 0;
-		SASSERT(this->inf_set_is_correct());
+        SASSERT(this->inf_set_is_correct());
         if (this->current_x_is_feasible() && this->m_look_for_feasible_solution_only)
             return;
         if (this->m_settings.backup_costs)
diff --git a/src/util/lp/static_matrix.hpp b/src/util/lp/static_matrix.hpp
index d8681ff93..846c2a19f 100644
--- a/src/util/lp/static_matrix.hpp
+++ b/src/util/lp/static_matrix.hpp
@@ -48,9 +48,9 @@ template <typename T, typename X> bool static_matrix<T, X>::pivot_row_to_row_giv
     SASSERT(i < row_count() && ii < column_count());
     SASSERT(i != ii);
     
-	m_became_zeros.reset();
+    m_became_zeros.reset();
     T alpha = -get_val(c);
-	SASSERT(!is_zero(alpha));
+    SASSERT(!is_zero(alpha));
     auto & ii_row_vals = m_rows[ii];
     remove_element(ii_row_vals, ii_row_vals[c.m_offset]);
     scan_row_ii_to_offset_vector(ii);
@@ -61,7 +61,7 @@ template <typename T, typename X> bool static_matrix<T, X>::pivot_row_to_row_giv
         unsigned j = iv.m_j;
         if (j == pivot_col) continue;
         T alv = alpha * iv.m_value;
-		SASSERT(!is_zero(iv.m_value));
+        SASSERT(!is_zero(iv.m_value));
         int j_offs = m_vector_of_row_offsets[j];
         if (j_offs == -1) { // it is a new element
             add_new_element(ii, j, alv);

From 085df4a0a01e5ed1ae507ea49eb9c8a8af4e2cbc Mon Sep 17 00:00:00 2001
From: "Christoph M. Wintersteiger" <cwinter@microsoft.com>
Date: Sun, 17 Sep 2017 17:52:31 +0100
Subject: [PATCH 07/10] removed temp file

---
 src/tactic/sls/.#sls_params.pyg | 1 -
 1 file changed, 1 deletion(-)
 delete mode 100644 src/tactic/sls/.#sls_params.pyg

diff --git a/src/tactic/sls/.#sls_params.pyg b/src/tactic/sls/.#sls_params.pyg
deleted file mode 100644
index 50991f6f4..000000000
--- a/src/tactic/sls/.#sls_params.pyg
+++ /dev/null
@@ -1 +0,0 @@
-winte@WINTERMUTE.13536:1505663874
\ No newline at end of file

From 60c6249912a1fc8183a5f561f32ec455edfc2d10 Mon Sep 17 00:00:00 2001
From: "Christoph M. Wintersteiger" <cwinter@microsoft.com>
Date: Sun, 17 Sep 2017 18:09:10 +0100
Subject: [PATCH 08/10] Removed unused variable

---
 src/ast/rewriter/fpa_rewriter.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/ast/rewriter/fpa_rewriter.cpp b/src/ast/rewriter/fpa_rewriter.cpp
index 09307cbf2..6420dd968 100644
--- a/src/ast/rewriter/fpa_rewriter.cpp
+++ b/src/ast/rewriter/fpa_rewriter.cpp
@@ -772,7 +772,6 @@ br_status fpa_rewriter::mk_to_bv(func_decl * f, expr * arg1, expr * arg2, bool i
 
     if (m_util.is_rm_numeral(arg1, rmv) &&
         m_util.is_numeral(arg2, v)) {
-        const mpf & x = v.get();
 
         if (m_fm.is_nan(v) || m_fm.is_inf(v))
             return mk_to_bv_unspecified(f, result);

From b9494fe3c01f445d9523975763b1736c882c1689 Mon Sep 17 00:00:00 2001
From: "Christoph M. Wintersteiger" <cwinter@microsoft.com>
Date: Sun, 17 Sep 2017 18:09:43 +0100
Subject: [PATCH 09/10] Tabs, whitespace

---
 src/smt/database.smt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/smt/database.smt b/src/smt/database.smt
index 2f5e5e1c9..27955badf 100644
--- a/src/smt/database.smt
+++ b/src/smt/database.smt
@@ -11,7 +11,7 @@
    :formula (forall (a Int) (i Int) (e Int)  
                     (= (?select (?store a i e) i) e)
                     :pats { (?store a i e) }
-		    :weight { 0 })
+                    :weight { 0 })
 
    :formula (forall (a Int) (i Int) (j Int) (e Int)  
                     (or (= i j) (= (?select (?store a i e) j) (?select a j)))

From c275d4ddca7f09c78f4e6f8a55c1f03fde42c9f3 Mon Sep 17 00:00:00 2001
From: "Christoph M. Wintersteiger" <cwinter@microsoft.com>
Date: Sun, 17 Sep 2017 18:33:40 +0100
Subject: [PATCH 10/10] typo

---
 src/api/java/Context.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/api/java/Context.java b/src/api/java/Context.java
index 986736fb6..72866a0ba 100644
--- a/src/api/java/Context.java
+++ b/src/api/java/Context.java
@@ -2070,7 +2070,7 @@ public class Context implements AutoCloseable {
      */
     public ReExpr mkComplement(ReExpr re)
     {
-        checkContextMatchb(re);
+        checkContextMatch(re);
         return (ReExpr) Expr.create(this, Native.mkReComplement(nCtx(), re.getNativeObject()));            
     }