refined_arith_theorem_producer.h

Go to the documentation of this file.
00001 /*****************************************************************************/
00002 /*!
00003  * \file refined_arith_theorem_producer.h
00004  * \brief TRUSTED implementation of arithmetic proof rules
00005  * 
00006  * Author: Sean McLaughlin
00007  * 
00008  * Created: Jan 23 00:00:00 GMT 2004
00009  *
00010  * <hr>
00011  * Copyright (C) 2003 by the Board of Trustees of Leland Stanford
00012  * Junior University and by New York University. 
00013  *
00014  * License to use, copy, modify, sell and/or distribute this software
00015  * and its documentation for any purpose is hereby granted without
00016  * royalty, subject to the terms and conditions defined in the \ref
00017  * LICENSE file provided with this distribution.  In particular:
00018  *
00019  * - The above copyright notice and this permission notice must appear
00020  * in all copies of the software and related documentation.
00021  *
00022  * - THE SOFTWARE IS PROVIDED "AS-IS", WITHOUT ANY WARRANTIES,
00023  * EXPRESSED OR IMPLIED.  USE IT AT YOUR OWN RISK.
00024  * 
00025  * <hr>
00026  * 
00027  */
00028 /*****************************************************************************/
00029 
00030 #ifndef _CVC_lite__refined_arith_theorem_producer_h_
00031 #define _CVC_lite__refined_arith_theorem_producer_h_
00032 
00033 #include "arith_proof_rules.h"
00034 #include "theory.h"
00035 #include "common_proof_rules.h"
00036 #include "arith_theorem_producer.h"
00037 #include "vcl.h"
00038 #include "type.h"
00039 #include "typecheck_exception.h"
00040 
00041 namespace CVCL {
00042 
00043 
00044   ////////////////////////
00045   //
00046   // This is a reimplimentation of the arithmetic rules going back to the 
00047   // axioms of the reals.  
00048   // 
00049   // 1) x + (y + z) = (x + y) + z         (Addition is associative) 
00050   // 2) x * (y * z) = (x * y) * z         (Multiplication is associative) 
00051   // 3) x + y = y + x                     (Addition is commutative) 
00052   // 4) x * y = y * x                     (Multiplication is commutative) 
00053   // 5) x * (y + z) = x * y + x * z       (Distributivity)
00054   // 6) 0 + x = x                         (Additive identity)
00055   // 7) 1 * x = x                         (Multiplicative identity)
00056   // 8) x + -x = 0                        (Additive inverse)
00057   // 9) x * 1/x = 1                       (Multiplicative inverse)
00058   // 10) x < y -> x + z < y + z           (Invariance of order)
00059   // 11) x < y -> y < z -> x < z          (Transitivity of order)
00060   // 12) x < y -> 0 < z -> xz < yz        (Scaling of order)
00061   // 14) arithmetic                       (rational number calculation)
00062 
00063   class RefinedArithTheoremProducer: public ArithTheoremProducer{
00064   private:
00065     // structures
00066     ExprManager* d_em;
00067     TheoryCore* core;
00068     VCL* vcl;
00069 
00070     // constants
00071     const Expr zero,one;
00072 
00073     // util 
00074     Rational eval(const Expr& rational_expr);
00075 
00076     // Axioms
00077     Theorem addAssoc(const Expr& x,const Expr& y,const Expr& z);
00078     Theorem multAssoc(const Expr& x,const Expr& y,const Expr& z);
00079     Theorem addSymm(const Expr& x,const Expr& y);
00080     Theorem multSymm(const Expr& x,const Expr& y);
00081     Theorem distribL(const Expr& x,const Expr& y,const Expr& z);
00082     Theorem addLID(const Expr& x);
00083     Theorem multLID(const Expr& x);
00084     Theorem addInvR(const Expr& x);
00085     Theorem multInvR(const Expr& x);public:
00086     Theorem ltAddR(const Expr& x,const Expr& y,const Expr& z);
00087     Theorem ltTrans(const Expr& x,const Expr& y,const Expr& z);
00088     Theorem ltScale(const Expr& x,const Expr& y,const Expr& z);
00089     Theorem arithmetic(const Expr& lhs,const Expr& rhs);
00090     Theorem minusDef(const Expr& x,const Expr& y);
00091     Theorem divideDef(const Expr& x,const Expr& y);
00092     
00093     // Derived Rules
00094     Theorem distribR(const Expr& x,const Expr& y,const Expr& z);
00095     Theorem addR(const Theorem& xEy,const Expr& z);
00096     Theorem addRID(const Expr& x);
00097     Theorem cancelR(const Expr& x,const Expr& y);
00098     Theorem addRCancel(const Theorem& t);
00099     Theorem multZeroL(const Expr& e);  
00100 
00101     // Core util
00102     Expr neg(const Expr& x);
00103     Expr inv(const Expr& x);
00104     Expr frac(const Expr& x,const Expr& y);
00105     Expr plus(const Expr& x,const Expr& y);
00106     Theorem trans(const Theorem& t1,const Theorem& t2);
00107     Theorem trans(const Expr& e);
00108     Theorem symm(const Theorem& t);
00109     Theorem subst(Op op,const Expr& x,const Theorem& t);
00110     Theorem subst(Op op,const Theorem& t,const Expr& x);
00111     Theorem subst(Op op,const Theorem& t1,const Theorem& t2);
00112 
00113   public:
00114 
00115     // Constructor
00116     RefinedArithTheoremProducer(VCL* vcl):
00117       ArithTheoremProducer(vcl),d_em(vcl->getEM()),zero(rat(0)),one(rat(1)),vcl(vcl) { 
00118       core = vcl->theoryCore();
00119     }
00120 
00121     // For convenience
00122     Expr rat(Rational r) { return Expr(d_em, r); }
00123 
00124     // Decision Prodedure Rules
00125     Theorem uMinusToMult(const Expr& e);
00126     Theorem minusToPlus(const Expr& x,const Expr& y);
00127 
00128 
00129     // test
00130     Theorem canonPlus(const Expr & e);
00131 
00132   };
00133   
00134    
00135 }
00136 #endif

Generated on Thu Apr 13 16:57:32 2006 for CVC Lite by  doxygen 1.4.4