diff options
Diffstat (limited to 'src/theory')
431 files changed, 4387 insertions, 2906 deletions
diff --git a/src/theory/arith/approx_simplex.cpp b/src/theory/arith/approx_simplex.cpp index bc7efdaf7..e621131d5 100644 --- a/src/theory/arith/approx_simplex.cpp +++ b/src/theory/arith/approx_simplex.cpp @@ -2,9 +2,9 @@ /*! \file approx_simplex.cpp ** \verbatim ** Top contributors (to current version): - ** Tim King, Andres Noetzli, Morgan Deters + ** Tim King, Morgan Deters, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/approx_simplex.h b/src/theory/arith/approx_simplex.h index a0982169d..2914c2da8 100644 --- a/src/theory/arith/approx_simplex.h +++ b/src/theory/arith/approx_simplex.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/arith_ite_utils.cpp b/src/theory/arith/arith_ite_utils.cpp index 5b51e162d..3980b41b8 100644 --- a/src/theory/arith/arith_ite_utils.cpp +++ b/src/theory/arith/arith_ite_utils.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Aina Niemetz, Kshitij Bansal ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/arith_ite_utils.h b/src/theory/arith/arith_ite_utils.h index 2c6a30758..a9e7aa92c 100644 --- a/src/theory/arith/arith_ite_utils.h +++ b/src/theory/arith/arith_ite_utils.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Aina Niemetz ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -19,8 +19,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__ARITH__ARITH_ITE_UTILS_H -#define __CVC4__THEORY__ARITH__ARITH_ITE_UTILS_H +#ifndef CVC4__THEORY__ARITH__ARITH_ITE_UTILS_H +#define CVC4__THEORY__ARITH__ARITH_ITE_UTILS_H #include <unordered_map> @@ -115,4 +115,4 @@ private: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__ARITH__ARITH_ITE_UTILS_H */ +#endif /* CVC4__THEORY__ARITH__ARITH_ITE_UTILS_H */ diff --git a/src/theory/arith/arith_msum.cpp b/src/theory/arith/arith_msum.cpp index f08b4c0ba..7f13ce07d 100644 --- a/src/theory/arith/arith_msum.cpp +++ b/src/theory/arith/arith_msum.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/arith_msum.h b/src/theory/arith/arith_msum.h index 195db38c9..8a9dbf791 100644 --- a/src/theory/arith/arith_msum.h +++ b/src/theory/arith/arith_msum.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__ARITH__MSUM_H -#define __CVC4__THEORY__ARITH__MSUM_H +#ifndef CVC4__THEORY__ARITH__MSUM_H +#define CVC4__THEORY__ARITH__MSUM_H #include <map> @@ -185,4 +185,4 @@ class ArithMSum } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__ARITH__MSUM_H */ +#endif /* CVC4__THEORY__ARITH__MSUM_H */ diff --git a/src/theory/arith/arith_rewriter.cpp b/src/theory/arith/arith_rewriter.cpp index c3327e620..267fcc383 100644 --- a/src/theory/arith/arith_rewriter.cpp +++ b/src/theory/arith/arith_rewriter.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Andrew Reynolds, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/arith_rewriter.h b/src/theory/arith/arith_rewriter.h index 7d137bdfd..de6b3f228 100644 --- a/src/theory/arith/arith_rewriter.h +++ b/src/theory/arith/arith_rewriter.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Dejan Jovanovic, Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -17,8 +17,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__ARITH__ARITH_REWRITER_H -#define __CVC4__THEORY__ARITH__ARITH_REWRITER_H +#ifndef CVC4__THEORY__ARITH__ARITH_REWRITER_H +#define CVC4__THEORY__ARITH__ARITH_REWRITER_H #include "theory/theory.h" #include "theory/rewriter.h" @@ -76,4 +76,4 @@ private: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__ARITH__ARITH_REWRITER_H */ +#endif /* CVC4__THEORY__ARITH__ARITH_REWRITER_H */ diff --git a/src/theory/arith/arith_static_learner.cpp b/src/theory/arith/arith_static_learner.cpp index 4bfc1a4f9..2138b513e 100644 --- a/src/theory/arith/arith_static_learner.cpp +++ b/src/theory/arith/arith_static_learner.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Dejan Jovanovic, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/arith_static_learner.h b/src/theory/arith/arith_static_learner.h index a6b57411b..bc77f8ec0 100644 --- a/src/theory/arith/arith_static_learner.h +++ b/src/theory/arith/arith_static_learner.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Dejan Jovanovic, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -17,8 +17,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__ARITH__ARITH_STATIC_LEARNER_H -#define __CVC4__THEORY__ARITH__ARITH_STATIC_LEARNER_H +#ifndef CVC4__THEORY__ARITH__ARITH_STATIC_LEARNER_H +#define CVC4__THEORY__ARITH__ARITH_STATIC_LEARNER_H #include <set> @@ -72,4 +72,4 @@ private: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__ARITH__ARITH_STATIC_LEARNER_H */ +#endif /* CVC4__THEORY__ARITH__ARITH_STATIC_LEARNER_H */ diff --git a/src/theory/arith/arith_utilities.h b/src/theory/arith/arith_utilities.h index 14c7fcefe..c8e92dfd3 100644 --- a/src/theory/arith/arith_utilities.h +++ b/src/theory/arith/arith_utilities.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Andrew Reynolds, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__ARITH__ARITH_UTILITIES_H -#define __CVC4__THEORY__ARITH__ARITH_UTILITIES_H +#ifndef CVC4__THEORY__ARITH__ARITH_UTILITIES_H +#define CVC4__THEORY__ARITH__ARITH_UTILITIES_H #include <unordered_map> #include <unordered_set> @@ -307,4 +307,4 @@ inline Node mkPi() }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__ARITH__ARITH_UTILITIES_H */ +#endif /* CVC4__THEORY__ARITH__ARITH_UTILITIES_H */ diff --git a/src/theory/arith/arithvar.cpp b/src/theory/arith/arithvar.cpp index 8ac72276d..2eb349984 100644 --- a/src/theory/arith/arithvar.cpp +++ b/src/theory/arith/arithvar.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/arithvar.h b/src/theory/arith/arithvar.h index cb1fb7b5f..9ab452947 100644 --- a/src/theory/arith/arithvar.h +++ b/src/theory/arith/arithvar.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/arithvar_node_map.h b/src/theory/arith/arithvar_node_map.h index 0606eb65d..03b061504 100644 --- a/src/theory/arith/arithvar_node_map.h +++ b/src/theory/arith/arithvar_node_map.h @@ -2,9 +2,9 @@ /*! \file arithvar_node_map.h ** \verbatim ** Top contributors (to current version): - ** Tim King, Morgan Deters, Dejan Jovanovic + ** Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -17,8 +17,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__ARITH__ARITHVAR_NODE_MAP_H -#define __CVC4__THEORY__ARITH__ARITHVAR_NODE_MAP_H +#ifndef CVC4__THEORY__ARITH__ARITHVAR_NODE_MAP_H +#define CVC4__THEORY__ARITH__ARITHVAR_NODE_MAP_H #include "theory/arith/arithvar.h" @@ -92,4 +92,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__ARITH__ARITHVAR_NODE_MAP_H */ +#endif /* CVC4__THEORY__ARITH__ARITHVAR_NODE_MAP_H */ diff --git a/src/theory/arith/attempt_solution_simplex.cpp b/src/theory/arith/attempt_solution_simplex.cpp index 025571650..f269847de 100644 --- a/src/theory/arith/attempt_solution_simplex.cpp +++ b/src/theory/arith/attempt_solution_simplex.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/attempt_solution_simplex.h b/src/theory/arith/attempt_solution_simplex.h index 7e5b41936..1fd8ee146 100644 --- a/src/theory/arith/attempt_solution_simplex.h +++ b/src/theory/arith/attempt_solution_simplex.h @@ -2,9 +2,9 @@ /*! \file attempt_solution_simplex.h ** \verbatim ** Top contributors (to current version): - ** Tim King, Mathias Preiner + ** Tim King, Morgan Deters, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/bound_counts.h b/src/theory/arith/bound_counts.h index 7debbad13..7bd69190e 100644 --- a/src/theory/arith/bound_counts.h +++ b/src/theory/arith/bound_counts.h @@ -2,9 +2,9 @@ /*! \file bound_counts.h ** \verbatim ** Top contributors (to current version): - ** Tim King, Morgan Deters, Clark Barrett + ** Tim King, Clark Barrett ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/callbacks.cpp b/src/theory/arith/callbacks.cpp index 86240b949..a11dd729b 100644 --- a/src/theory/arith/callbacks.cpp +++ b/src/theory/arith/callbacks.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/callbacks.h b/src/theory/arith/callbacks.h index 8b79ff659..ee39c76f9 100644 --- a/src/theory/arith/callbacks.h +++ b/src/theory/arith/callbacks.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Mathias Preiner, Clark Barrett ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/congruence_manager.cpp b/src/theory/arith/congruence_manager.cpp index bf251660d..ce45141ef 100644 --- a/src/theory/arith/congruence_manager.cpp +++ b/src/theory/arith/congruence_manager.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Paul Meng, Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/congruence_manager.h b/src/theory/arith/congruence_manager.h index 11c229399..bccd2e943 100644 --- a/src/theory/arith/congruence_manager.h +++ b/src/theory/arith/congruence_manager.h @@ -2,9 +2,9 @@ /*! \file congruence_manager.h ** \verbatim ** Top contributors (to current version): - ** Tim King, Paul Meng, Mathias Preiner + ** Tim King, Mathias Preiner, Paul Meng ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/constraint.cpp b/src/theory/arith/constraint.cpp index 297e3de37..c7251d4c4 100644 --- a/src/theory/arith/constraint.cpp +++ b/src/theory/arith/constraint.cpp @@ -2,9 +2,9 @@ /*! \file constraint.cpp ** \verbatim ** Top contributors (to current version): - ** Tim King, Morgan Deters + ** Tim King, Alex Ozdemir, Aina Niemetz ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/constraint.h b/src/theory/arith/constraint.h index 51575bb2f..f2c0c4b02 100644 --- a/src/theory/arith/constraint.h +++ b/src/theory/arith/constraint.h @@ -2,9 +2,9 @@ /*! \file constraint.h ** \verbatim ** Top contributors (to current version): - ** Tim King, Morgan Deters + ** Tim King, Alex Ozdemir, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -72,8 +72,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__ARITH__CONSTRAINT_H -#define __CVC4__THEORY__ARITH__CONSTRAINT_H +#ifndef CVC4__THEORY__ARITH__CONSTRAINT_H +#define CVC4__THEORY__ARITH__CONSTRAINT_H #include <unordered_map> #include <list> @@ -1209,4 +1209,4 @@ private: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__ARITH__CONSTRAINT_H */ +#endif /* CVC4__THEORY__ARITH__CONSTRAINT_H */ diff --git a/src/theory/arith/constraint_forward.h b/src/theory/arith/constraint_forward.h index b08b572be..5f3f2251d 100644 --- a/src/theory/arith/constraint_forward.h +++ b/src/theory/arith/constraint_forward.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ ** minimize interaction between header files. **/ -#ifndef __CVC4__THEORY__ARITH__CONSTRAINT_FORWARD_H -#define __CVC4__THEORY__ARITH__CONSTRAINT_FORWARD_H +#ifndef CVC4__THEORY__ARITH__CONSTRAINT_FORWARD_H +#define CVC4__THEORY__ARITH__CONSTRAINT_FORWARD_H #include "cvc4_private.h" #include <vector> @@ -46,4 +46,4 @@ static const RationalVectorP RationalVectorPSentinel = NULL; }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__ARITH__CONSTRAINT_FORWARD_H */ +#endif /* CVC4__THEORY__ARITH__CONSTRAINT_FORWARD_H */ diff --git a/src/theory/arith/cut_log.cpp b/src/theory/arith/cut_log.cpp index dcdadd76f..e9df7559d 100644 --- a/src/theory/arith/cut_log.cpp +++ b/src/theory/arith/cut_log.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/cut_log.h b/src/theory/arith/cut_log.h index 5fd585588..44553a15b 100644 --- a/src/theory/arith/cut_log.h +++ b/src/theory/arith/cut_log.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Morgan Deters, Kshitij Bansal ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/delta_rational.cpp b/src/theory/arith/delta_rational.cpp index 758f8af4a..35640ac1a 100644 --- a/src/theory/arith/delta_rational.cpp +++ b/src/theory/arith/delta_rational.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/delta_rational.h b/src/theory/arith/delta_rational.h index 9a8e4586e..831c631f8 100644 --- a/src/theory/arith/delta_rational.h +++ b/src/theory/arith/delta_rational.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Dejan Jovanovic, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/dio_solver.cpp b/src/theory/arith/dio_solver.cpp index 718034f62..b30dc515b 100644 --- a/src/theory/arith/dio_solver.cpp +++ b/src/theory/arith/dio_solver.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Morgan Deters, Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/dio_solver.h b/src/theory/arith/dio_solver.h index aeb82a82b..0c26f9c55 100644 --- a/src/theory/arith/dio_solver.h +++ b/src/theory/arith/dio_solver.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -17,8 +17,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__ARITH__DIO_SOLVER_H -#define __CVC4__THEORY__ARITH__DIO_SOLVER_H +#ifndef CVC4__THEORY__ARITH__DIO_SOLVER_H +#define CVC4__THEORY__ARITH__DIO_SOLVER_H #include <unordered_map> #include <utility> @@ -423,4 +423,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__ARITH__DIO_SOLVER_H */ +#endif /* CVC4__THEORY__ARITH__DIO_SOLVER_H */ diff --git a/src/theory/arith/dual_simplex.cpp b/src/theory/arith/dual_simplex.cpp index c2b95890a..47a196353 100644 --- a/src/theory/arith/dual_simplex.cpp +++ b/src/theory/arith/dual_simplex.cpp @@ -2,9 +2,9 @@ /*! \file dual_simplex.cpp ** \verbatim ** Top contributors (to current version): - ** Tim King, Andres Noetzli + ** Tim King, Morgan Deters, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/dual_simplex.h b/src/theory/arith/dual_simplex.h index 56eaf9a50..ab04bc616 100644 --- a/src/theory/arith/dual_simplex.h +++ b/src/theory/arith/dual_simplex.h @@ -2,9 +2,9 @@ /*! \file dual_simplex.h ** \verbatim ** Top contributors (to current version): - ** Tim King, Mathias Preiner + ** Tim King, Mathias Preiner, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/error_set.cpp b/src/theory/arith/error_set.cpp index d5b86143d..80c1e03ec 100644 --- a/src/theory/arith/error_set.cpp +++ b/src/theory/arith/error_set.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/error_set.h b/src/theory/arith/error_set.h index 2eb2b60d2..8839739a2 100644 --- a/src/theory/arith/error_set.h +++ b/src/theory/arith/error_set.h @@ -2,9 +2,9 @@ /*! \file error_set.h ** \verbatim ** Top contributors (to current version): - ** Tim King + ** Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/fc_simplex.cpp b/src/theory/arith/fc_simplex.cpp index 07c6b1691..827323302 100644 --- a/src/theory/arith/fc_simplex.cpp +++ b/src/theory/arith/fc_simplex.cpp @@ -2,9 +2,9 @@ /*! \file fc_simplex.cpp ** \verbatim ** Top contributors (to current version): - ** Tim King, Andres Noetzli + ** Tim King, Morgan Deters, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/fc_simplex.h b/src/theory/arith/fc_simplex.h index 0fc646151..cfeef1d26 100644 --- a/src/theory/arith/fc_simplex.h +++ b/src/theory/arith/fc_simplex.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Morgan Deters, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/infer_bounds.cpp b/src/theory/arith/infer_bounds.cpp index 501b3507c..5ce617061 100644 --- a/src/theory/arith/infer_bounds.cpp +++ b/src/theory/arith/infer_bounds.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/infer_bounds.h b/src/theory/arith/infer_bounds.h index 8a48cb8bc..bce9a07db 100644 --- a/src/theory/arith/infer_bounds.h +++ b/src/theory/arith/infer_bounds.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/linear_equality.cpp b/src/theory/arith/linear_equality.cpp index e424c714e..7f729751b 100644 --- a/src/theory/arith/linear_equality.cpp +++ b/src/theory/arith/linear_equality.cpp @@ -2,9 +2,9 @@ /*! \file linear_equality.cpp ** \verbatim ** Top contributors (to current version): - ** Tim King + ** Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/linear_equality.h b/src/theory/arith/linear_equality.h index 531b52c3a..1f5bb9ea4 100644 --- a/src/theory/arith/linear_equality.h +++ b/src/theory/arith/linear_equality.h @@ -2,9 +2,9 @@ /*! \file linear_equality.h ** \verbatim ** Top contributors (to current version): - ** Tim King, Mathias Preiner, Clark Barrett + ** Tim King, Mathias Preiner, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/matrix.cpp b/src/theory/arith/matrix.cpp index 5da2ab2f6..c6332fd23 100644 --- a/src/theory/arith/matrix.cpp +++ b/src/theory/arith/matrix.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/matrix.h b/src/theory/arith/matrix.h index ef045ea37..02b8dc194 100644 --- a/src/theory/arith/matrix.h +++ b/src/theory/arith/matrix.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Mathias Preiner, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/nonlinear_extension.cpp b/src/theory/arith/nonlinear_extension.cpp index 929c7808d..29b1cf2fc 100644 --- a/src/theory/arith/nonlinear_extension.cpp +++ b/src/theory/arith/nonlinear_extension.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Tim King, Aina Niemetz ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -2621,8 +2621,10 @@ void NonlinearExtension::mkPi(){ d_pi_neg = Rewriter::rewrite(NodeManager::currentNM()->mkNode( MULT, d_pi, NodeManager::currentNM()->mkConst(Rational(-1)))); //initialize bounds - d_pi_bound[0] = NodeManager::currentNM()->mkConst( Rational(333)/Rational(106) ); - d_pi_bound[1] = NodeManager::currentNM()->mkConst( Rational(355)/Rational(113) ); + d_pi_bound[0] = + NodeManager::currentNM()->mkConst(Rational(103993) / Rational(33102)); + d_pi_bound[1] = + NodeManager::currentNM()->mkConst(Rational(104348) / Rational(33215)); } } @@ -4358,31 +4360,21 @@ bool NonlinearExtension::checkTfTangentPlanesFun(Node tf, { // compute tangent plane // Figure 3: T( x ) - Node tplane; - Node poly_approx_deriv = getDerivative(poly_approx, d_taylor_real_fv); - Assert(!poly_approx_deriv.isNull()); - poly_approx_deriv = Rewriter::rewrite(poly_approx_deriv); - Trace("nl-ext-tftp-debug2") << "...derivative of " << poly_approx << " is " - << poly_approx_deriv << std::endl; - std::vector<Node> taylor_subs; - taylor_subs.push_back(c); - Assert(taylor_vars.size() == taylor_subs.size()); - Node poly_approx_c_deriv = poly_approx_deriv.substitute(taylor_vars.begin(), - taylor_vars.end(), - taylor_subs.begin(), - taylor_subs.end()); - tplane = nm->mkNode( - PLUS, - poly_approx_c, - nm->mkNode(MULT, poly_approx_c_deriv, nm->mkNode(MINUS, tf[0], c))); + // We use zero slope tangent planes, since the concavity of the Taylor + // approximation cannot be easily established. + Node tplane = poly_approx_c; Node lem = nm->mkNode(concavity == 1 ? GEQ : LEQ, tf, tplane); std::vector<Node> antec; + int mdir = regionToMonotonicityDir(k, region); for (unsigned i = 0; i < 2; i++) { - if (!bounds[i].isNull()) + // Tangent plane is valid in the interval [c,u) if the slope of the + // function matches its concavity, and is valid in (l, c] otherwise. + Node use_bound = (mdir == concavity) == (i == 0) ? c : bounds[i]; + if (!use_bound.isNull()) { - Node ant = nm->mkNode(i == 0 ? GEQ : LEQ, tf[0], bounds[i]); + Node ant = nm->mkNode(i == 0 ? GEQ : LEQ, tf[0], use_bound); antec.push_back(ant); } } diff --git a/src/theory/arith/nonlinear_extension.h b/src/theory/arith/nonlinear_extension.h index cb74502d6..7452e322b 100644 --- a/src/theory/arith/nonlinear_extension.h +++ b/src/theory/arith/nonlinear_extension.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -15,8 +15,8 @@ ** multiplication via axiom instantiations. **/ -#ifndef __CVC4__THEORY__ARITH__NONLINEAR_EXTENSION_H -#define __CVC4__THEORY__ARITH__NONLINEAR_EXTENSION_H +#ifndef CVC4__THEORY__ARITH__NONLINEAR_EXTENSION_H +#define CVC4__THEORY__ARITH__NONLINEAR_EXTENSION_H #include <stdint.h> @@ -1013,4 +1013,4 @@ class NonlinearExtension { } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__ARITH__NONLINEAR_EXTENSION_H */ +#endif /* CVC4__THEORY__ARITH__NONLINEAR_EXTENSION_H */ diff --git a/src/theory/arith/normal_form.cpp b/src/theory/arith/normal_form.cpp index 12bf90f2e..ee298bc66 100644 --- a/src/theory/arith/normal_form.cpp +++ b/src/theory/arith/normal_form.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Andrew Reynolds, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/normal_form.h b/src/theory/arith/normal_form.h index b4d9e9f13..a3d173cc7 100644 --- a/src/theory/arith/normal_form.h +++ b/src/theory/arith/normal_form.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Morgan Deters, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -17,8 +17,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__ARITH__NORMAL_FORM_H -#define __CVC4__THEORY__ARITH__NORMAL_FORM_H +#ifndef CVC4__THEORY__ARITH__NORMAL_FORM_H +#define CVC4__THEORY__ARITH__NORMAL_FORM_H #include <algorithm> #include <list> @@ -1393,4 +1393,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__ARITH__NORMAL_FORM_H */ +#endif /* CVC4__THEORY__ARITH__NORMAL_FORM_H */ diff --git a/src/theory/arith/partial_model.cpp b/src/theory/arith/partial_model.cpp index 4364b730a..855b673c5 100644 --- a/src/theory/arith/partial_model.cpp +++ b/src/theory/arith/partial_model.cpp @@ -2,9 +2,9 @@ /*! \file partial_model.cpp ** \verbatim ** Top contributors (to current version): - ** Tim King, Morgan Deters + ** Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/partial_model.h b/src/theory/arith/partial_model.h index 9e8a51b9f..5006c6a9c 100644 --- a/src/theory/arith/partial_model.h +++ b/src/theory/arith/partial_model.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -18,8 +18,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__ARITH__PARTIAL_MODEL_H -#define __CVC4__THEORY__ARITH__PARTIAL_MODEL_H +#ifndef CVC4__THEORY__ARITH__PARTIAL_MODEL_H +#define CVC4__THEORY__ARITH__PARTIAL_MODEL_H #include <list> #include <vector> @@ -416,4 +416,4 @@ private: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__ARITH__PARTIAL_MODEL_H */ +#endif /* CVC4__THEORY__ARITH__PARTIAL_MODEL_H */ diff --git a/src/theory/arith/simplex.cpp b/src/theory/arith/simplex.cpp index 4ee613f4c..77872fb55 100644 --- a/src/theory/arith/simplex.cpp +++ b/src/theory/arith/simplex.cpp @@ -2,9 +2,9 @@ /*! \file simplex.cpp ** \verbatim ** Top contributors (to current version): - ** Tim King, Andres Noetzli, Morgan Deters + ** Tim King, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/simplex.h b/src/theory/arith/simplex.h index 477e0c1fe..56a9bc95f 100644 --- a/src/theory/arith/simplex.h +++ b/src/theory/arith/simplex.h @@ -2,9 +2,9 @@ /*! \file simplex.h ** \verbatim ** Top contributors (to current version): - ** Tim King, Morgan Deters, Clark Barrett + ** Tim King, Clark Barrett ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/simplex_update.cpp b/src/theory/arith/simplex_update.cpp index 634d17a55..011e07143 100644 --- a/src/theory/arith/simplex_update.cpp +++ b/src/theory/arith/simplex_update.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/simplex_update.h b/src/theory/arith/simplex_update.h index f823be36c..cfd00ac30 100644 --- a/src/theory/arith/simplex_update.h +++ b/src/theory/arith/simplex_update.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/soi_simplex.cpp b/src/theory/arith/soi_simplex.cpp index 31301df61..e23273a09 100644 --- a/src/theory/arith/soi_simplex.cpp +++ b/src/theory/arith/soi_simplex.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Morgan Deters, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/soi_simplex.h b/src/theory/arith/soi_simplex.h index 68af680d0..6fd8cf7c1 100644 --- a/src/theory/arith/soi_simplex.h +++ b/src/theory/arith/soi_simplex.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Morgan Deters, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/tableau.cpp b/src/theory/arith/tableau.cpp index e0f5fc9e3..aa4c3d454 100644 --- a/src/theory/arith/tableau.cpp +++ b/src/theory/arith/tableau.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/tableau.h b/src/theory/arith/tableau.h index 338baea7f..3f3bf883a 100644 --- a/src/theory/arith/tableau.h +++ b/src/theory/arith/tableau.h @@ -2,9 +2,9 @@ /*! \file tableau.h ** \verbatim ** Top contributors (to current version): - ** Tim King + ** Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/tableau_sizes.cpp b/src/theory/arith/tableau_sizes.cpp index d7434529e..aec7b0384 100644 --- a/src/theory/arith/tableau_sizes.cpp +++ b/src/theory/arith/tableau_sizes.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/tableau_sizes.h b/src/theory/arith/tableau_sizes.h index 228ce06b8..95820dc93 100644 --- a/src/theory/arith/tableau_sizes.h +++ b/src/theory/arith/tableau_sizes.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/theory_arith.cpp b/src/theory/arith/theory_arith.cpp index 9902121d0..6943c5546 100644 --- a/src/theory/arith/theory_arith.cpp +++ b/src/theory/arith/theory_arith.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Dejan Jovanovic, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/theory_arith.h b/src/theory/arith/theory_arith.h index e4b1c5b26..b39ab961f 100644 --- a/src/theory/arith/theory_arith.h +++ b/src/theory/arith/theory_arith.h @@ -2,9 +2,9 @@ /*! \file theory_arith.h ** \verbatim ** Top contributors (to current version): - ** Tim King, Morgan Deters, Dejan Jovanovic + ** Tim King, Alex Ozdemir, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/theory_arith_private.cpp b/src/theory/arith/theory_arith_private.cpp index 48d1b0188..c775a2611 100644 --- a/src/theory/arith/theory_arith_private.cpp +++ b/src/theory/arith/theory_arith_private.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Andrew Reynolds, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/theory_arith_private.h b/src/theory/arith/theory_arith_private.h index 2d8d61736..03cb81785 100644 --- a/src/theory/arith/theory_arith_private.h +++ b/src/theory/arith/theory_arith_private.h @@ -2,9 +2,9 @@ /*! \file theory_arith_private.h ** \verbatim ** Top contributors (to current version): - ** Tim King, Andrew Reynolds, Martin Brain + ** Tim King, Andrew Reynolds, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/theory_arith_private_forward.h b/src/theory/arith/theory_arith_private_forward.h index 4bd242037..84dea1b4e 100644 --- a/src/theory/arith/theory_arith_private_forward.h +++ b/src/theory/arith/theory_arith_private_forward.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arith/theory_arith_type_rules.h b/src/theory/arith/theory_arith_type_rules.h index bde1730a2..c32b612e2 100644 --- a/src/theory/arith/theory_arith_type_rules.h +++ b/src/theory/arith/theory_arith_type_rules.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Dejan Jovanovic, Morgan Deters, Christopher L. Conway ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__ARITH__THEORY_ARITH_TYPE_RULES_H -#define __CVC4__THEORY__ARITH__THEORY_ARITH_TYPE_RULES_H +#ifndef CVC4__THEORY__ARITH__THEORY_ARITH_TYPE_RULES_H +#define CVC4__THEORY__ARITH__THEORY_ARITH_TYPE_RULES_H namespace CVC4 { namespace theory { @@ -185,4 +185,4 @@ class DivisibleOpTypeRule }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__ARITH__THEORY_ARITH_TYPE_RULES_H */ +#endif /* CVC4__THEORY__ARITH__THEORY_ARITH_TYPE_RULES_H */ diff --git a/src/theory/arith/type_enumerator.h b/src/theory/arith/type_enumerator.h index ab0dff020..5c6bf63ce 100644 --- a/src/theory/arith/type_enumerator.h +++ b/src/theory/arith/type_enumerator.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__ARITH__TYPE_ENUMERATOR_H -#define __CVC4__THEORY__ARITH__TYPE_ENUMERATOR_H +#ifndef CVC4__THEORY__ARITH__TYPE_ENUMERATOR_H +#define CVC4__THEORY__ARITH__TYPE_ENUMERATOR_H #include "expr/kind.h" #include "expr/type_node.h" @@ -104,4 +104,4 @@ class IntegerEnumerator : public TypeEnumeratorBase<IntegerEnumerator> { }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__ARITH__TYPE_ENUMERATOR_H */ +#endif /* CVC4__THEORY__ARITH__TYPE_ENUMERATOR_H */ diff --git a/src/theory/arrays/array_info.cpp b/src/theory/arrays/array_info.cpp index 406ae5329..e92947c7f 100644 --- a/src/theory/arrays/array_info.cpp +++ b/src/theory/arrays/array_info.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters, Clark Barrett, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arrays/array_info.h b/src/theory/arrays/array_info.h index ed8594ca7..7e18f9ed2 100644 --- a/src/theory/arrays/array_info.h +++ b/src/theory/arrays/array_info.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters, Clark Barrett, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -15,8 +15,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__ARRAYS__ARRAY_INFO_H -#define __CVC4__THEORY__ARRAYS__ARRAY_INFO_H +#ifndef CVC4__THEORY__ARRAYS__ARRAY_INFO_H +#define CVC4__THEORY__ARRAYS__ARRAY_INFO_H #include <iostream> #include <map> @@ -211,4 +211,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__ARRAYS__ARRAY_INFO_H */ +#endif /* CVC4__THEORY__ARRAYS__ARRAY_INFO_H */ diff --git a/src/theory/arrays/array_proof_reconstruction.cpp b/src/theory/arrays/array_proof_reconstruction.cpp index e0f3b03be..c25ce1aba 100644 --- a/src/theory/arrays/array_proof_reconstruction.cpp +++ b/src/theory/arrays/array_proof_reconstruction.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Guy Katz, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arrays/array_proof_reconstruction.h b/src/theory/arrays/array_proof_reconstruction.h index 7132b2f3e..37b014d35 100644 --- a/src/theory/arrays/array_proof_reconstruction.h +++ b/src/theory/arrays/array_proof_reconstruction.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Paul Meng, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -15,8 +15,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__ARRAYS__ARRAY_PROOF_RECONSTRUCTION_H -#define __CVC4__THEORY__ARRAYS__ARRAY_PROOF_RECONSTRUCTION_H +#ifndef CVC4__THEORY__ARRAYS__ARRAY_PROOF_RECONSTRUCTION_H +#define CVC4__THEORY__ARRAYS__ARRAY_PROOF_RECONSTRUCTION_H #include "theory/uf/equality_engine.h" @@ -56,4 +56,4 @@ private: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__ARRAYS__ARRAY_PROOF_RECONSTRUCTION_H */ +#endif /* CVC4__THEORY__ARRAYS__ARRAY_PROOF_RECONSTRUCTION_H */ diff --git a/src/theory/arrays/static_fact_manager.cpp b/src/theory/arrays/static_fact_manager.cpp index d7758d00c..63dfae173 100644 --- a/src/theory/arrays/static_fact_manager.cpp +++ b/src/theory/arrays/static_fact_manager.cpp @@ -2,9 +2,9 @@ /*! \file static_fact_manager.cpp ** \verbatim ** Top contributors (to current version): - ** Clark Barrett, Tim King + ** Clark Barrett ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arrays/static_fact_manager.h b/src/theory/arrays/static_fact_manager.h index 1f3c3d1df..6b68edf26 100644 --- a/src/theory/arrays/static_fact_manager.h +++ b/src/theory/arrays/static_fact_manager.h @@ -2,9 +2,9 @@ /*! \file static_fact_manager.h ** \verbatim ** Top contributors (to current version): - ** Clark Barrett, Tim King, Morgan Deters + ** Clark Barrett, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -18,8 +18,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__ARRAYS__STATIC_FACT_MANAGER_H -#define __CVC4__THEORY__ARRAYS__STATIC_FACT_MANAGER_H +#ifndef CVC4__THEORY__ARRAYS__STATIC_FACT_MANAGER_H +#define CVC4__THEORY__ARRAYS__STATIC_FACT_MANAGER_H #include <utility> #include <vector> @@ -113,4 +113,4 @@ inline void StaticFactManager::setCanon(TNode n, TNode newParent) { }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /*__CVC4__THEORY__ARRAYS__STATIC_FACT_MANAGER_H */ +#endif /*CVC4__THEORY__ARRAYS__STATIC_FACT_MANAGER_H */ diff --git a/src/theory/arrays/theory_arrays.cpp b/src/theory/arrays/theory_arrays.cpp index c21fda430..9f06950bd 100644 --- a/src/theory/arrays/theory_arrays.cpp +++ b/src/theory/arrays/theory_arrays.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Clark Barrett, Morgan Deters, Guy Katz ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arrays/theory_arrays.h b/src/theory/arrays/theory_arrays.h index e0f187e33..be80a081d 100644 --- a/src/theory/arrays/theory_arrays.h +++ b/src/theory/arrays/theory_arrays.h @@ -2,9 +2,9 @@ /*! \file theory_arrays.h ** \verbatim ** Top contributors (to current version): - ** Morgan Deters, Clark Barrett, Tim King + ** Morgan Deters, Clark Barrett, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__ARRAYS__THEORY_ARRAYS_H -#define __CVC4__THEORY__ARRAYS__THEORY_ARRAYS_H +#ifndef CVC4__THEORY__ARRAYS__THEORY_ARRAYS_H +#define CVC4__THEORY__ARRAYS__THEORY_ARRAYS_H #include <tuple> #include <unordered_map> @@ -491,4 +491,4 @@ class TheoryArrays : public Theory { }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__ARRAYS__THEORY_ARRAYS_H */ +#endif /* CVC4__THEORY__ARRAYS__THEORY_ARRAYS_H */ diff --git a/src/theory/arrays/theory_arrays_rewriter.cpp b/src/theory/arrays/theory_arrays_rewriter.cpp index eaf7b5ff9..43c6153c7 100644 --- a/src/theory/arrays/theory_arrays_rewriter.cpp +++ b/src/theory/arrays/theory_arrays_rewriter.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arrays/theory_arrays_rewriter.h b/src/theory/arrays/theory_arrays_rewriter.h index d17c4d4ab..5f3fcf48d 100644 --- a/src/theory/arrays/theory_arrays_rewriter.h +++ b/src/theory/arrays/theory_arrays_rewriter.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Clark Barrett, Morgan Deters, Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -17,8 +17,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__ARRAYS__THEORY_ARRAYS_REWRITER_H -#define __CVC4__THEORY__ARRAYS__THEORY_ARRAYS_REWRITER_H +#ifndef CVC4__THEORY__ARRAYS__THEORY_ARRAYS_REWRITER_H +#define CVC4__THEORY__ARRAYS__THEORY_ARRAYS_REWRITER_H #include <unordered_map> #include <unordered_set> @@ -509,4 +509,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__ARRAYS__THEORY_ARRAYS_REWRITER_H */ +#endif /* CVC4__THEORY__ARRAYS__THEORY_ARRAYS_REWRITER_H */ diff --git a/src/theory/arrays/theory_arrays_type_rules.h b/src/theory/arrays/theory_arrays_type_rules.h index 171a03555..78756176d 100644 --- a/src/theory/arrays/theory_arrays_type_rules.h +++ b/src/theory/arrays/theory_arrays_type_rules.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters, Clark Barrett, Christopher L. Conway ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__ARRAYS__THEORY_ARRAYS_TYPE_RULES_H -#define __CVC4__THEORY__ARRAYS__THEORY_ARRAYS_TYPE_RULES_H +#ifndef CVC4__THEORY__ARRAYS__THEORY_ARRAYS_TYPE_RULES_H +#define CVC4__THEORY__ARRAYS__THEORY_ARRAYS_TYPE_RULES_H #include "theory/arrays/theory_arrays_rewriter.h" // for array-constant attributes #include "theory/type_enumerator.h" @@ -227,4 +227,4 @@ struct ArrayPartialSelectTypeRule { }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__ARRAYS__THEORY_ARRAYS_TYPE_RULES_H */ +#endif /* CVC4__THEORY__ARRAYS__THEORY_ARRAYS_TYPE_RULES_H */ diff --git a/src/theory/arrays/type_enumerator.h b/src/theory/arrays/type_enumerator.h index f9a88f2ae..5ca156b2e 100644 --- a/src/theory/arrays/type_enumerator.h +++ b/src/theory/arrays/type_enumerator.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Clark Barrett, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__ARRAYS__TYPE_ENUMERATOR_H -#define __CVC4__THEORY__ARRAYS__TYPE_ENUMERATOR_H +#ifndef CVC4__THEORY__ARRAYS__TYPE_ENUMERATOR_H +#define CVC4__THEORY__ARRAYS__TYPE_ENUMERATOR_H #include "theory/type_enumerator.h" #include "expr/type_node.h" @@ -158,4 +158,4 @@ class ArrayEnumerator : public TypeEnumeratorBase<ArrayEnumerator> { }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__ARRAYS__TYPE_ENUMERATOR_H */ +#endif /* CVC4__THEORY__ARRAYS__TYPE_ENUMERATOR_H */ diff --git a/src/theory/arrays/union_find.cpp b/src/theory/arrays/union_find.cpp index f919f9260..af2cf3c3f 100644 --- a/src/theory/arrays/union_find.cpp +++ b/src/theory/arrays/union_find.cpp @@ -2,9 +2,9 @@ /*! \file union_find.cpp ** \verbatim ** Top contributors (to current version): - ** Morgan Deters, Tim King + ** Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/arrays/union_find.h b/src/theory/arrays/union_find.h index 617c9a1ba..1f38f1280 100644 --- a/src/theory/arrays/union_find.h +++ b/src/theory/arrays/union_find.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -18,8 +18,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__ARRAYS__UNION_FIND_H -#define __CVC4__THEORY__ARRAYS__UNION_FIND_H +#ifndef CVC4__THEORY__ARRAYS__UNION_FIND_H +#define CVC4__THEORY__ARRAYS__UNION_FIND_H #include <utility> #include <vector> @@ -139,4 +139,4 @@ inline void UnionFind<NodeType, NodeHash>::setCanon(TNode n, TNode newParent) { }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /*__CVC4__THEORY__ARRAYS__UNION_FIND_H */ +#endif /*CVC4__THEORY__ARRAYS__UNION_FIND_H */ diff --git a/src/theory/assertion.cpp b/src/theory/assertion.cpp index bef29131e..4f428e85c 100644 --- a/src/theory/assertion.cpp +++ b/src/theory/assertion.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/assertion.h b/src/theory/assertion.h index c9748f8c8..863a7e893 100644 --- a/src/theory/assertion.h +++ b/src/theory/assertion.h @@ -2,9 +2,9 @@ /*! \file assertion.h ** \verbatim ** Top contributors (to current version): - ** Tim King + ** Tim King, Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -17,8 +17,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__ASSERTION_H -#define __CVC4__THEORY__ASSERTION_H +#ifndef CVC4__THEORY__ASSERTION_H +#define CVC4__THEORY__ASSERTION_H #include "expr/node.h" @@ -49,4 +49,4 @@ std::ostream& operator<<(std::ostream& out, const Assertion& a); }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__ASSERTION_H */ +#endif /* CVC4__THEORY__ASSERTION_H */ diff --git a/src/theory/atom_requests.cpp b/src/theory/atom_requests.cpp index 85c7907bb..6054ac603 100644 --- a/src/theory/atom_requests.cpp +++ b/src/theory/atom_requests.cpp @@ -2,9 +2,9 @@ /*! \file atom_requests.cpp ** \verbatim ** Top contributors (to current version): - ** Dejan Jovanovic, Morgan Deters + ** Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/atom_requests.h b/src/theory/atom_requests.h index 678a0f3f0..6a3ffe5e9 100644 --- a/src/theory/atom_requests.h +++ b/src/theory/atom_requests.h @@ -2,9 +2,9 @@ /*! \file atom_requests.h ** \verbatim ** Top contributors (to current version): - ** Dejan Jovanovic, Morgan Deters + ** Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/booleans/circuit_propagator.cpp b/src/theory/booleans/circuit_propagator.cpp index 2548cf5c3..150403b67 100644 --- a/src/theory/booleans/circuit_propagator.cpp +++ b/src/theory/booleans/circuit_propagator.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Dejan Jovanovic, Morgan Deters, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/booleans/circuit_propagator.h b/src/theory/booleans/circuit_propagator.h index 077a019fd..9c4798898 100644 --- a/src/theory/booleans/circuit_propagator.h +++ b/src/theory/booleans/circuit_propagator.h @@ -2,9 +2,9 @@ /*! \file circuit_propagator.h ** \verbatim ** Top contributors (to current version): - ** Morgan Deters, Dejan Jovanovic, Clark Barrett + ** Aina Niemetz, Morgan Deters, Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__BOOLEANS__CIRCUIT_PROPAGATOR_H -#define __CVC4__THEORY__BOOLEANS__CIRCUIT_PROPAGATOR_H +#ifndef CVC4__THEORY__BOOLEANS__CIRCUIT_PROPAGATOR_H +#define CVC4__THEORY__BOOLEANS__CIRCUIT_PROPAGATOR_H #include <functional> #include <unordered_map> @@ -313,4 +313,4 @@ class CircuitPropagator } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__BOOLEANS__CIRCUIT_PROPAGATOR_H */ +#endif /* CVC4__THEORY__BOOLEANS__CIRCUIT_PROPAGATOR_H */ diff --git a/src/theory/booleans/theory_bool.cpp b/src/theory/booleans/theory_bool.cpp index d025c4966..8fbe83951 100644 --- a/src/theory/booleans/theory_bool.cpp +++ b/src/theory/booleans/theory_bool.cpp @@ -2,9 +2,9 @@ /*! \file theory_bool.cpp ** \verbatim ** Top contributors (to current version): - ** Morgan Deters, Andrew Reynolds, Dejan Jovanovic + ** Andrew Reynolds, Dejan Jovanovic, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/booleans/theory_bool.h b/src/theory/booleans/theory_bool.h index b81ed50f1..abe024282 100644 --- a/src/theory/booleans/theory_bool.h +++ b/src/theory/booleans/theory_bool.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters, Tim King, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__BOOLEANS__THEORY_BOOL_H -#define __CVC4__THEORY__BOOLEANS__THEORY_BOOL_H +#ifndef CVC4__THEORY__BOOLEANS__THEORY_BOOL_H +#define CVC4__THEORY__BOOLEANS__THEORY_BOOL_H #include "theory/theory.h" #include "context/context.h" @@ -44,4 +44,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__BOOLEANS__THEORY_BOOL_H */ +#endif /* CVC4__THEORY__BOOLEANS__THEORY_BOOL_H */ diff --git a/src/theory/booleans/theory_bool_rewriter.cpp b/src/theory/booleans/theory_bool_rewriter.cpp index 28f86da7a..02267cf2c 100644 --- a/src/theory/booleans/theory_bool_rewriter.cpp +++ b/src/theory/booleans/theory_bool_rewriter.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tim King, Dejan Jovanovic, Kshitij Bansal ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -77,7 +77,7 @@ RewriteResponse flattenNode(TNode n, TNode trivialNode, TNode skipNode) /* Trickery to stay under number of children possible in a node */ NodeManager* nodeManager = NodeManager::currentNM(); - static const unsigned MAX_CHILDREN = (1u << __CVC4__EXPR__NODE_VALUE__NBITS__NCHILDREN ) - 1; + static const unsigned MAX_CHILDREN = (1u << CVC4__EXPR__NODE_VALUE__NBITS__NCHILDREN ) - 1; if (childList.size() < MAX_CHILDREN) { Node retNode = nodeManager->mkNode(k, childList); return RewriteResponse(REWRITE_DONE, retNode); diff --git a/src/theory/booleans/theory_bool_rewriter.h b/src/theory/booleans/theory_bool_rewriter.h index 11c7b16a2..250f36efa 100644 --- a/src/theory/booleans/theory_bool_rewriter.h +++ b/src/theory/booleans/theory_bool_rewriter.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Dejan Jovanovic, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -17,8 +17,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__BOOLEANS__THEORY_BOOL_REWRITER_H -#define __CVC4__THEORY__BOOLEANS__THEORY_BOOL_REWRITER_H +#ifndef CVC4__THEORY__BOOLEANS__THEORY_BOOL_REWRITER_H +#define CVC4__THEORY__BOOLEANS__THEORY_BOOL_REWRITER_H #include "theory/rewriter.h" @@ -42,4 +42,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__BOOLEANS__THEORY_BOOL_REWRITER_H */ +#endif /* CVC4__THEORY__BOOLEANS__THEORY_BOOL_REWRITER_H */ diff --git a/src/theory/booleans/theory_bool_type_rules.h b/src/theory/booleans/theory_bool_type_rules.h index 7498b7de4..18329b8b9 100644 --- a/src/theory/booleans/theory_bool_type_rules.h +++ b/src/theory/booleans/theory_bool_type_rules.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Dejan Jovanovic, Morgan Deters, Christopher L. Conway ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY_BOOL_TYPE_RULES_H -#define __CVC4__THEORY_BOOL_TYPE_RULES_H +#ifndef CVC4__THEORY_BOOL_TYPE_RULES_H +#define CVC4__THEORY_BOOL_TYPE_RULES_H namespace CVC4 { namespace theory { @@ -74,4 +74,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY_BOOL_TYPE_RULES_H */ +#endif /* CVC4__THEORY_BOOL_TYPE_RULES_H */ diff --git a/src/theory/booleans/type_enumerator.h b/src/theory/booleans/type_enumerator.h index 2e00f22ce..361216b10 100644 --- a/src/theory/booleans/type_enumerator.h +++ b/src/theory/booleans/type_enumerator.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__BOOLEANS__TYPE_ENUMERATOR_H -#define __CVC4__THEORY__BOOLEANS__TYPE_ENUMERATOR_H +#ifndef CVC4__THEORY__BOOLEANS__TYPE_ENUMERATOR_H +#define CVC4__THEORY__BOOLEANS__TYPE_ENUMERATOR_H #include "theory/type_enumerator.h" #include "expr/type_node.h" @@ -67,4 +67,4 @@ class BooleanEnumerator : public TypeEnumeratorBase<BooleanEnumerator> { }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__BOOLEANS__TYPE_ENUMERATOR_H */ +#endif /* CVC4__THEORY__BOOLEANS__TYPE_ENUMERATOR_H */ diff --git a/src/theory/builtin/kinds b/src/theory/builtin/kinds index 3313a684f..15891dfad 100644 --- a/src/theory/builtin/kinds +++ b/src/theory/builtin/kinds @@ -289,9 +289,6 @@ constant BUILTIN \ "expr/kind.h" \ "the kind of expressions representing built-in operators" -variable FUNCTION "a defined function" -parameterized APPLY FUNCTION 0: "application of a defined function" - operator EQUAL 2 "equality (two parameters only, sorts must match)" operator DISTINCT 2: "disequality (N-ary, sorts must match)" variable VARIABLE "a variable (not permitted in bindings)" @@ -332,7 +329,6 @@ well-founded SEXPR_TYPE \ "::CVC4::theory::builtin::SExprProperties::mkGroundTerm(%TYPE%)" \ "theory/builtin/theory_builtin_type_rules.h" -typerule APPLY ::CVC4::theory::builtin::ApplyTypeRule typerule EQUAL ::CVC4::theory::builtin::EqualityTypeRule typerule DISTINCT ::CVC4::theory::builtin::DistinctTypeRule typerule SEXPR ::CVC4::theory::builtin::SExprTypeRule diff --git a/src/theory/builtin/theory_builtin.cpp b/src/theory/builtin/theory_builtin.cpp index ec22eb3f6..b819b883d 100644 --- a/src/theory/builtin/theory_builtin.cpp +++ b/src/theory/builtin/theory_builtin.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/builtin/theory_builtin.h b/src/theory/builtin/theory_builtin.h index c987941f6..8a7d1bf7b 100644 --- a/src/theory/builtin/theory_builtin.h +++ b/src/theory/builtin/theory_builtin.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters, Tim King, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__BUILTIN__THEORY_BUILTIN_H -#define __CVC4__THEORY__BUILTIN__THEORY_BUILTIN_H +#ifndef CVC4__THEORY__BUILTIN__THEORY_BUILTIN_H +#define CVC4__THEORY__BUILTIN__THEORY_BUILTIN_H #include "theory/theory.h" @@ -38,4 +38,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__BUILTIN__THEORY_BUILTIN_H */ +#endif /* CVC4__THEORY__BUILTIN__THEORY_BUILTIN_H */ diff --git a/src/theory/builtin/theory_builtin_rewriter.cpp b/src/theory/builtin/theory_builtin_rewriter.cpp index 4c14ec177..5b893ffc6 100644 --- a/src/theory/builtin/theory_builtin_rewriter.cpp +++ b/src/theory/builtin/theory_builtin_rewriter.cpp @@ -2,9 +2,9 @@ /*! \file theory_builtin_rewriter.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Dejan Jovanovic, Morgan Deters + ** Andrew Reynolds, Morgan Deters, Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/builtin/theory_builtin_rewriter.h b/src/theory/builtin/theory_builtin_rewriter.h index 8f45cc0fd..5f703fa00 100644 --- a/src/theory/builtin/theory_builtin_rewriter.h +++ b/src/theory/builtin/theory_builtin_rewriter.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Dejan Jovanovic, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -17,8 +17,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__BUILTIN__THEORY_BUILTIN_REWRITER_H -#define __CVC4__THEORY__BUILTIN__THEORY_BUILTIN_REWRITER_H +#ifndef CVC4__THEORY__BUILTIN__THEORY_BUILTIN_REWRITER_H +#define CVC4__THEORY__BUILTIN__THEORY_BUILTIN_REWRITER_H #include "theory/rewriter.h" #include "theory/theory.h" @@ -130,4 +130,4 @@ private: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__BUILTIN__THEORY_BUILTIN_REWRITER_H */ +#endif /* CVC4__THEORY__BUILTIN__THEORY_BUILTIN_REWRITER_H */ diff --git a/src/theory/builtin/theory_builtin_type_rules.h b/src/theory/builtin/theory_builtin_type_rules.h index c471caf86..db427d21e 100644 --- a/src/theory/builtin/theory_builtin_type_rules.h +++ b/src/theory/builtin/theory_builtin_type_rules.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters, Andrew Reynolds, Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__BUILTIN__THEORY_BUILTIN_TYPE_RULES_H -#define __CVC4__THEORY__BUILTIN__THEORY_BUILTIN_TYPE_RULES_H +#ifndef CVC4__THEORY__BUILTIN__THEORY_BUILTIN_TYPE_RULES_H +#define CVC4__THEORY__BUILTIN__THEORY_BUILTIN_TYPE_RULES_H #include "expr/node.h" #include "expr/type_node.h" @@ -31,44 +31,6 @@ namespace CVC4 { namespace theory { namespace builtin { -class ApplyTypeRule { - public: - inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check) - { - TNode f = n.getOperator(); - TypeNode fType = f.getType(check); - if( !fType.isFunction() && n.getNumChildren() > 0 ) { - throw TypeCheckingExceptionPrivate(n, "operator does not have function type"); - } - if( check ) { - if(fType.isFunction()) { - if(n.getNumChildren() != fType.getNumChildren() - 1) { - throw TypeCheckingExceptionPrivate(n, "number of arguments does not match the function type"); - } - TNode::iterator argument_it = n.begin(); - TNode::iterator argument_it_end = n.end(); - TypeNode::iterator argument_type_it = fType.begin(); - for(; argument_it != argument_it_end; ++argument_it, ++argument_type_it) { - if(!(*argument_it).getType().isComparableTo(*argument_type_it)) { - std::stringstream ss; - ss << "argument types do not match the function type:\n" - << "argument: " << *argument_it << "\n" - << "has type: " << (*argument_it).getType() << "\n" - << "not equal: " << *argument_type_it; - throw TypeCheckingExceptionPrivate(n, ss.str()); - } - } - } else { - if( n.getNumChildren() > 0 ) { - throw TypeCheckingExceptionPrivate(n, "number of arguments does not match the function type"); - } - } - } - return fType.isFunction() ? fType.getRangeType() : fType; - } -};/* class ApplyTypeRule */ - - class EqualityTypeRule { public: inline static TypeNode computeType(NodeManager* nodeManager, @@ -375,4 +337,4 @@ class SExprProperties { }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__BUILTIN__THEORY_BUILTIN_TYPE_RULES_H */ +#endif /* CVC4__THEORY__BUILTIN__THEORY_BUILTIN_TYPE_RULES_H */ diff --git a/src/theory/builtin/type_enumerator.cpp b/src/theory/builtin/type_enumerator.cpp index 7a088bd8d..10c6d16dc 100644 --- a/src/theory/builtin/type_enumerator.cpp +++ b/src/theory/builtin/type_enumerator.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/builtin/type_enumerator.h b/src/theory/builtin/type_enumerator.h index bea3b7c18..8ce17306f 100644 --- a/src/theory/builtin/type_enumerator.h +++ b/src/theory/builtin/type_enumerator.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__BUILTIN__TYPE_ENUMERATOR_H -#define __CVC4__THEORY__BUILTIN__TYPE_ENUMERATOR_H +#ifndef CVC4__THEORY__BUILTIN__TYPE_ENUMERATOR_H +#define CVC4__THEORY__BUILTIN__TYPE_ENUMERATOR_H #include "expr/kind.h" #include "expr/type_node.h" @@ -108,4 +108,4 @@ class FunctionEnumerator : public TypeEnumeratorBase<FunctionEnumerator> }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__BUILTIN_TYPE_ENUMERATOR_H */ +#endif /* CVC4__THEORY__BUILTIN_TYPE_ENUMERATOR_H */ diff --git a/src/theory/bv/abstraction.cpp b/src/theory/bv/abstraction.cpp index 081590810..16f77f925 100644 --- a/src/theory/bv/abstraction.cpp +++ b/src/theory/bv/abstraction.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Liana Hadarean, Aina Niemetz, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/abstraction.h b/src/theory/bv/abstraction.h index a6bc5f12f..5472aa5a2 100644 --- a/src/theory/bv/abstraction.h +++ b/src/theory/bv/abstraction.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Liana Hadarean, Tim King, Guy Katz ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__BV__ABSTRACTION_H -#define __CVC4__THEORY__BV__ABSTRACTION_H +#ifndef CVC4__THEORY__BV__ABSTRACTION_H +#define CVC4__THEORY__BV__ABSTRACTION_H #include <unordered_map> #include <unordered_set> diff --git a/src/theory/bv/bitblast/aig_bitblaster.cpp b/src/theory/bv/bitblast/aig_bitblaster.cpp index b69704dfb..3ed926f84 100644 --- a/src/theory/bv/bitblast/aig_bitblaster.cpp +++ b/src/theory/bv/bitblast/aig_bitblaster.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Liana Hadarean, Mathias Preiner, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/bitblast/aig_bitblaster.h b/src/theory/bv/bitblast/aig_bitblaster.h index 3b48928ca..8b63a9aa6 100644 --- a/src/theory/bv/bitblast/aig_bitblaster.h +++ b/src/theory/bv/bitblast/aig_bitblaster.h @@ -2,9 +2,9 @@ /*! \file aig_bitblaster.h ** \verbatim ** Top contributors (to current version): - ** Mathias Preiner + ** Liana Hadarean, Mathias Preiner, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__BV__BITBLAST__AIG_BITBLASTER_H -#define __CVC4__THEORY__BV__BITBLAST__AIG_BITBLASTER_H +#ifndef CVC4__THEORY__BV__BITBLAST__AIG_BITBLASTER_H +#define CVC4__THEORY__BV__BITBLAST__AIG_BITBLASTER_H #include "theory/bv/bitblast/bitblaster.h" #include "prop/sat_solver.h" @@ -111,4 +111,4 @@ class AigBitblaster : public TBitblaster<Abc_Obj_t*> } // namespace bv } // namespace theory } // namespace CVC4 -#endif // __CVC4__THEORY__BV__BITBLAST__AIG_BITBLASTER_H +#endif // CVC4__THEORY__BV__BITBLAST__AIG_BITBLASTER_H diff --git a/src/theory/bv/bitblast/bitblast_strategies_template.h b/src/theory/bv/bitblast/bitblast_strategies_template.h index c081b87cf..9e668e258 100644 --- a/src/theory/bv/bitblast/bitblast_strategies_template.h +++ b/src/theory/bv/bitblast/bitblast_strategies_template.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Liana Hadarean, Aina Niemetz, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__BV__BITBLAST__BITBLAST_STRATEGIES_TEMPLATE_H -#define __CVC4__THEORY__BV__BITBLAST__BITBLAST_STRATEGIES_TEMPLATE_H +#ifndef CVC4__THEORY__BV__BITBLAST__BITBLAST_STRATEGIES_TEMPLATE_H +#define CVC4__THEORY__BV__BITBLAST__BITBLAST_STRATEGIES_TEMPLATE_H #include <cmath> #include <ostream> diff --git a/src/theory/bv/bitblast/bitblast_utils.h b/src/theory/bv/bitblast/bitblast_utils.h index 731ffb3dd..f2bee22e5 100644 --- a/src/theory/bv/bitblast/bitblast_utils.h +++ b/src/theory/bv/bitblast/bitblast_utils.h @@ -2,9 +2,9 @@ /*! \file bitblast_utils.h ** \verbatim ** Top contributors (to current version): - ** Liana Hadarean, Mathias Preiner, Andrew Reynolds + ** Liana Hadarean, Dejan Jovanovic, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__BV__BITBLAST__BITBLAST_UTILS_H -#define __CVC4__THEORY__BV__BITBLAST__BITBLAST_UTILS_H +#ifndef CVC4__THEORY__BV__BITBLAST__BITBLAST_UTILS_H +#define CVC4__THEORY__BV__BITBLAST__BITBLAST_UTILS_H #include <ostream> @@ -269,4 +269,4 @@ T inline sLessThanBB(const std::vector<T>&a, const std::vector<T>& b, bool orEqu } // namespace theory } // namespace CVC4 -#endif // __CVC4__THEORY__BV__BITBLAST__BITBLAST_UTILS_H +#endif // CVC4__THEORY__BV__BITBLAST__BITBLAST_UTILS_H diff --git a/src/theory/bv/bitblast/bitblaster.h b/src/theory/bv/bitblast/bitblaster.h index b28ff3e2a..df7cc4f11 100644 --- a/src/theory/bv/bitblast/bitblaster.h +++ b/src/theory/bv/bitblast/bitblaster.h @@ -2,9 +2,9 @@ /*! \file bitblaster.h ** \verbatim ** Top contributors (to current version): - ** Mathias Preiner + ** Liana Hadarean, Mathias Preiner, Alex Ozdemir ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__BV__BITBLAST__BITBLASTER_H -#define __CVC4__THEORY__BV__BITBLAST__BITBLASTER_H +#ifndef CVC4__THEORY__BV__BITBLAST__BITBLASTER_H +#define CVC4__THEORY__BV__BITBLAST__BITBLASTER_H #include <unordered_map> #include <unordered_set> @@ -286,4 +286,4 @@ Node TBitblaster<T>::getTermModel(TNode node, bool fullModel) } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__BV__BITBLAST__BITBLASTER_H */ +#endif /* CVC4__THEORY__BV__BITBLAST__BITBLASTER_H */ diff --git a/src/theory/bv/bitblast/eager_bitblaster.cpp b/src/theory/bv/bitblast/eager_bitblaster.cpp index 1e557bb64..77ff6f885 100644 --- a/src/theory/bv/bitblast/eager_bitblaster.cpp +++ b/src/theory/bv/bitblast/eager_bitblaster.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Liana Hadarean, Mathias Preiner, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/bitblast/eager_bitblaster.h b/src/theory/bv/bitblast/eager_bitblaster.h index 1c183b509..d407b8131 100644 --- a/src/theory/bv/bitblast/eager_bitblaster.h +++ b/src/theory/bv/bitblast/eager_bitblaster.h @@ -2,9 +2,9 @@ /*! \file eager_bitblaster.h ** \verbatim ** Top contributors (to current version): - ** Mathias Preiner, Andres Noetzli + ** Mathias Preiner, Liana Hadarean, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__BV__BITBLAST__EAGER_BITBLASTER_H -#define __CVC4__THEORY__BV__BITBLAST__EAGER_BITBLASTER_H +#ifndef CVC4__THEORY__BV__BITBLAST__EAGER_BITBLASTER_H +#define CVC4__THEORY__BV__BITBLAST__EAGER_BITBLASTER_H #include <unordered_set> @@ -88,4 +88,4 @@ class BitblastingRegistrar : public prop::Registrar } // namespace bv } // namespace theory } // namespace CVC4 -#endif // __CVC4__THEORY__BV__BITBLAST__EAGER_BITBLASTER_H +#endif // CVC4__THEORY__BV__BITBLAST__EAGER_BITBLASTER_H diff --git a/src/theory/bv/bitblast/lazy_bitblaster.cpp b/src/theory/bv/bitblast/lazy_bitblaster.cpp index 3b44bfddf..845fd399e 100644 --- a/src/theory/bv/bitblast/lazy_bitblaster.cpp +++ b/src/theory/bv/bitblast/lazy_bitblaster.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Liana Hadarean, Aina Niemetz, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/bitblast/lazy_bitblaster.h b/src/theory/bv/bitblast/lazy_bitblaster.h index 8dbf7807d..ac5cd5c7f 100644 --- a/src/theory/bv/bitblast/lazy_bitblaster.h +++ b/src/theory/bv/bitblast/lazy_bitblaster.h @@ -2,9 +2,9 @@ /*! \file lazy_bitblaster.h ** \verbatim ** Top contributors (to current version): - ** Mathias Preiner + ** Liana Hadarean, Mathias Preiner, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__BV__BITBLAST__LAZY_BITBLASTER_H -#define __CVC4__THEORY__BV__BITBLAST__LAZY_BITBLASTER_H +#ifndef CVC4__THEORY__BV__BITBLAST__LAZY_BITBLASTER_H +#define CVC4__THEORY__BV__BITBLAST__LAZY_BITBLASTER_H #include "proof/resolution_bitvector_proof.h" #include "theory/bv/bitblast/bitblaster.h" @@ -176,4 +176,4 @@ class TLazyBitblaster : public TBitblaster<Node> } // namespace bv } // namespace theory } // namespace CVC4 -#endif // __CVC4__THEORY__BV__BITBLAST__LAZY_BITBLASTER_H +#endif // CVC4__THEORY__BV__BITBLAST__LAZY_BITBLASTER_H diff --git a/src/theory/bv/bv_eager_solver.cpp b/src/theory/bv/bv_eager_solver.cpp index 336529dfd..dd0458a70 100644 --- a/src/theory/bv/bv_eager_solver.cpp +++ b/src/theory/bv/bv_eager_solver.cpp @@ -2,9 +2,9 @@ /*! \file bv_eager_solver.cpp ** \verbatim ** Top contributors (to current version): - ** Liana Hadarean, Mathias Preiner, Tim King + ** Mathias Preiner, Liana Hadarean, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/bv_eager_solver.h b/src/theory/bv/bv_eager_solver.h index 0b518ca4a..8e42d5cab 100644 --- a/src/theory/bv/bv_eager_solver.h +++ b/src/theory/bv/bv_eager_solver.h @@ -2,9 +2,9 @@ /*! \file bv_eager_solver.h ** \verbatim ** Top contributors (to current version): - ** Liana Hadarean, Tim King, Mathias Preiner + ** Liana Hadarean, Mathias Preiner, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__BV__BV_EAGER_SOLVER_H -#define __CVC4__THEORY__BV__BV_EAGER_SOLVER_H +#ifndef CVC4__THEORY__BV__BV_EAGER_SOLVER_H +#define CVC4__THEORY__BV__BV_EAGER_SOLVER_H #include <unordered_set> #include <vector> @@ -68,4 +68,4 @@ class EagerBitblastSolver { } // namespace theory } // namespace CVC4 -#endif // __CVC4__THEORY__BV__BV_EAGER_SOLVER_H +#endif // CVC4__THEORY__BV__BV_EAGER_SOLVER_H diff --git a/src/theory/bv/bv_inequality_graph.cpp b/src/theory/bv/bv_inequality_graph.cpp index 3d1ce4f27..89d5e1883 100644 --- a/src/theory/bv/bv_inequality_graph.cpp +++ b/src/theory/bv/bv_inequality_graph.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Liana Hadarean, Aina Niemetz, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/bv_inequality_graph.h b/src/theory/bv/bv_inequality_graph.h index e1f2fbf7c..07facf4af 100644 --- a/src/theory/bv/bv_inequality_graph.h +++ b/src/theory/bv/bv_inequality_graph.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Liana Hadarean, Tim King, Clark Barrett ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__BV__BV_INEQUALITY__GRAPH_H -#define __CVC4__THEORY__BV__BV_INEQUALITY__GRAPH_H +#ifndef CVC4__THEORY__BV__BV_INEQUALITY__GRAPH_H +#define CVC4__THEORY__BV__BV_INEQUALITY__GRAPH_H #include <list> #include <queue> @@ -282,4 +282,4 @@ public: } } -#endif /* __CVC4__THEORY__BV__BV_INEQUALITY__GRAPH_H */ +#endif /* CVC4__THEORY__BV__BV_INEQUALITY__GRAPH_H */ diff --git a/src/theory/bv/bv_quick_check.cpp b/src/theory/bv/bv_quick_check.cpp index d81300b84..0183dd6e7 100644 --- a/src/theory/bv/bv_quick_check.cpp +++ b/src/theory/bv/bv_quick_check.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Liana Hadarean, Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/bv_quick_check.h b/src/theory/bv/bv_quick_check.h index b2c31edcb..75f39b6e0 100644 --- a/src/theory/bv/bv_quick_check.h +++ b/src/theory/bv/bv_quick_check.h @@ -2,9 +2,9 @@ /*! \file bv_quick_check.h ** \verbatim ** Top contributors (to current version): - ** Liana Hadarean, Morgan Deters, Tim King + ** Liana Hadarean, Morgan Deters, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__BV_QUICK_CHECK_H -#define __CVC4__BV_QUICK_CHECK_H +#ifndef CVC4__BV_QUICK_CHECK_H +#define CVC4__BV_QUICK_CHECK_H #include <vector> #include <unordered_set> @@ -172,4 +172,4 @@ public: } /* theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__BV_QUICK_CHECK_H */ +#endif /* CVC4__BV_QUICK_CHECK_H */ diff --git a/src/theory/bv/bv_subtheory.h b/src/theory/bv/bv_subtheory.h index e2b649841..60660eda9 100644 --- a/src/theory/bv/bv_subtheory.h +++ b/src/theory/bv/bv_subtheory.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Liana Hadarean, Tim King, Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ ** Interface for bit-vectors sub-solvers. **/ -#ifndef __CVC4__THEORY__BV__BV_SUBTHEORY_H -#define __CVC4__THEORY__BV__BV_SUBTHEORY_H +#ifndef CVC4__THEORY__BV__BV_SUBTHEORY_H +#define CVC4__THEORY__BV__BV_SUBTHEORY_H #include "cvc4_private.h" #include "context/context.h" @@ -117,4 +117,4 @@ class SubtheorySolver { } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__BV__BV_SUBTHEORY_H */ +#endif /* CVC4__THEORY__BV__BV_SUBTHEORY_H */ diff --git a/src/theory/bv/bv_subtheory_algebraic.cpp b/src/theory/bv/bv_subtheory_algebraic.cpp index df7ba29b5..1f4aef42d 100644 --- a/src/theory/bv/bv_subtheory_algebraic.cpp +++ b/src/theory/bv/bv_subtheory_algebraic.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Liana Hadarean, Aina Niemetz, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/bv_subtheory_algebraic.h b/src/theory/bv/bv_subtheory_algebraic.h index 42f5faa7c..7f38b1563 100644 --- a/src/theory/bv/bv_subtheory_algebraic.h +++ b/src/theory/bv/bv_subtheory_algebraic.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Liana Hadarean, Mathias Preiner, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/bv_subtheory_bitblast.cpp b/src/theory/bv/bv_subtheory_bitblast.cpp index ceb02af40..94dfdee14 100644 --- a/src/theory/bv/bv_subtheory_bitblast.cpp +++ b/src/theory/bv/bv_subtheory_bitblast.cpp @@ -2,9 +2,9 @@ /*! \file bv_subtheory_bitblast.cpp ** \verbatim ** Top contributors (to current version): - ** Liana Hadarean, Dejan Jovanovic, Aina Niemetz + ** Liana Hadarean, Aina Niemetz, Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/bv_subtheory_bitblast.h b/src/theory/bv/bv_subtheory_bitblast.h index e028dbbdc..0b0a9521b 100644 --- a/src/theory/bv/bv_subtheory_bitblast.h +++ b/src/theory/bv/bv_subtheory_bitblast.h @@ -2,9 +2,9 @@ /*! \file bv_subtheory_bitblast.h ** \verbatim ** Top contributors (to current version): - ** Liana Hadarean, Dejan Jovanovic, Mathias Preiner + ** Liana Hadarean, Mathias Preiner, Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/bv_subtheory_core.cpp b/src/theory/bv/bv_subtheory_core.cpp index 9285141a0..f809c38c0 100644 --- a/src/theory/bv/bv_subtheory_core.cpp +++ b/src/theory/bv/bv_subtheory_core.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Liana Hadarean, Aina Niemetz, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/bv_subtheory_core.h b/src/theory/bv/bv_subtheory_core.h index ce570d531..e2026d4a5 100644 --- a/src/theory/bv/bv_subtheory_core.h +++ b/src/theory/bv/bv_subtheory_core.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Liana Hadarean, Mathias Preiner, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/bv_subtheory_inequality.cpp b/src/theory/bv/bv_subtheory_inequality.cpp index 6fc167793..b527eada4 100644 --- a/src/theory/bv/bv_subtheory_inequality.cpp +++ b/src/theory/bv/bv_subtheory_inequality.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Liana Hadarean, Aina Niemetz, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/bv_subtheory_inequality.h b/src/theory/bv/bv_subtheory_inequality.h index 1bdec8386..e18c886df 100644 --- a/src/theory/bv/bv_subtheory_inequality.h +++ b/src/theory/bv/bv_subtheory_inequality.h @@ -2,9 +2,9 @@ /*! \file bv_subtheory_inequality.h ** \verbatim ** Top contributors (to current version): - ** Liana Hadarean, Morgan Deters, Mathias Preiner + ** Liana Hadarean, Mathias Preiner, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__BV__BV_SUBTHEORY__INEQUALITY_H -#define __CVC4__THEORY__BV__BV_SUBTHEORY__INEQUALITY_H +#ifndef CVC4__THEORY__BV__BV_SUBTHEORY__INEQUALITY_H +#define CVC4__THEORY__BV__BV_SUBTHEORY__INEQUALITY_H #include <unordered_set> @@ -83,4 +83,4 @@ public: } } -#endif /* __CVC4__THEORY__BV__BV_SUBTHEORY__INEQUALITY_H */ +#endif /* CVC4__THEORY__BV__BV_SUBTHEORY__INEQUALITY_H */ diff --git a/src/theory/bv/slicer.cpp b/src/theory/bv/slicer.cpp index 4c4b7c723..e633792d8 100644 --- a/src/theory/bv/slicer.cpp +++ b/src/theory/bv/slicer.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Liana Hadarean, Aina Niemetz, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/slicer.h b/src/theory/bv/slicer.h index e6ddfb93c..3ddbcaf36 100644 --- a/src/theory/bv/slicer.h +++ b/src/theory/bv/slicer.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Liana Hadarean, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -28,8 +28,8 @@ #include "util/index.h" #include "util/statistics_registry.h" -#ifndef __CVC4__THEORY__BV__SLICER_BV_H -#define __CVC4__THEORY__BV__SLICER_BV_H +#ifndef CVC4__THEORY__BV__SLICER_BV_H +#define CVC4__THEORY__BV__SLICER_BV_H namespace CVC4 { @@ -251,4 +251,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__BV__SLICER_BV_H */ +#endif /* CVC4__THEORY__BV__SLICER_BV_H */ diff --git a/src/theory/bv/theory_bv.cpp b/src/theory/bv/theory_bv.cpp index 04a6cf52c..b7e52205f 100644 --- a/src/theory/bv/theory_bv.cpp +++ b/src/theory/bv/theory_bv.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Liana Hadarean, Andrew Reynolds, Aina Niemetz ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/theory_bv.h b/src/theory/bv/theory_bv.h index 3d151cfb1..7ca98f2ea 100644 --- a/src/theory/bv/theory_bv.h +++ b/src/theory/bv/theory_bv.h @@ -2,9 +2,9 @@ /*! \file theory_bv.h ** \verbatim ** Top contributors (to current version): - ** Liana Hadarean, Morgan Deters, Tim King + ** Liana Hadarean, Tim King, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__BV__THEORY_BV_H -#define __CVC4__THEORY__BV__THEORY_BV_H +#ifndef CVC4__THEORY__BV__THEORY_BV_H +#define CVC4__THEORY__BV__THEORY_BV_H #include <unordered_map> #include <unordered_set> @@ -273,4 +273,4 @@ public: }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__BV__THEORY_BV_H */ +#endif /* CVC4__THEORY__BV__THEORY_BV_H */ diff --git a/src/theory/bv/theory_bv_rewrite_rules.h b/src/theory/bv/theory_bv_rewrite_rules.h index c6cd9eb1c..eefda524e 100644 --- a/src/theory/bv/theory_bv_rewrite_rules.h +++ b/src/theory/bv/theory_bv_rewrite_rules.h @@ -2,9 +2,9 @@ /*! \file theory_bv_rewrite_rules.h ** \verbatim ** Top contributors (to current version): - ** Liana Hadarean, Dejan Jovanovic, Clark Barrett + ** Liana Hadarean, Dejan Jovanovic, Aina Niemetz ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/theory_bv_rewrite_rules_constant_evaluation.h b/src/theory/bv/theory_bv_rewrite_rules_constant_evaluation.h index 1eb813116..22a12cc10 100644 --- a/src/theory/bv/theory_bv_rewrite_rules_constant_evaluation.h +++ b/src/theory/bv/theory_bv_rewrite_rules_constant_evaluation.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Liana Hadarean, Clark Barrett, Aina Niemetz ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/theory_bv_rewrite_rules_core.h b/src/theory/bv/theory_bv_rewrite_rules_core.h index 42bf09d92..4a66aa847 100644 --- a/src/theory/bv/theory_bv_rewrite_rules_core.h +++ b/src/theory/bv/theory_bv_rewrite_rules_core.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Dejan Jovanovic, Liana Hadarean, Clark Barrett ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/theory_bv_rewrite_rules_normalization.h b/src/theory/bv/theory_bv_rewrite_rules_normalization.h index 1293f8311..cada3d30c 100644 --- a/src/theory/bv/theory_bv_rewrite_rules_normalization.h +++ b/src/theory/bv/theory_bv_rewrite_rules_normalization.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Liana Hadarean, Aina Niemetz, Clark Barrett ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/theory_bv_rewrite_rules_operator_elimination.h b/src/theory/bv/theory_bv_rewrite_rules_operator_elimination.h index 575a40aff..80974b2a5 100644 --- a/src/theory/bv/theory_bv_rewrite_rules_operator_elimination.h +++ b/src/theory/bv/theory_bv_rewrite_rules_operator_elimination.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Liana Hadarean, Aina Niemetz, Clark Barrett ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/theory_bv_rewrite_rules_simplification.h b/src/theory/bv/theory_bv_rewrite_rules_simplification.h index c58d69f6f..0e42886b5 100644 --- a/src/theory/bv/theory_bv_rewrite_rules_simplification.h +++ b/src/theory/bv/theory_bv_rewrite_rules_simplification.h @@ -2,9 +2,9 @@ /*! \file theory_bv_rewrite_rules_simplification.h ** \verbatim ** Top contributors (to current version): - ** Liana Hadarean, Mathias Preiner, Aina Niemetz + ** Liana Hadarean, Aina Niemetz, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/theory_bv_rewriter.cpp b/src/theory/bv/theory_bv_rewriter.cpp index 0c6f1d37a..0f7629c5f 100644 --- a/src/theory/bv/theory_bv_rewriter.cpp +++ b/src/theory/bv/theory_bv_rewriter.cpp @@ -2,9 +2,9 @@ /*! \file theory_bv_rewriter.cpp ** \verbatim ** Top contributors (to current version): - ** Liana Hadarean, Dejan Jovanovic, Morgan Deters + ** Liana Hadarean, Aina Niemetz, Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -173,12 +173,19 @@ RewriteResponse TheoryBVRewriter::RewriteITEBv(TNode node, bool prerewrite) RewriteRule<BvIteConstCond>, RewriteRule<BvIteEqualChildren>, RewriteRule<BvIteConstChildren>, - RewriteRule<BvIteEqualCond>, - RewriteRule<BvIteMergeThenIf>, + RewriteRule<BvIteEqualCond>>::apply(node); + if (resultNode != node) + { + return RewriteResponse(REWRITE_AGAIN, resultNode); + } + + resultNode = + LinearRewriteStrategy<RewriteRule<BvIteMergeThenIf>, RewriteRule<BvIteMergeElseIf>, RewriteRule<BvIteMergeThenElse>, RewriteRule<BvIteMergeElseElse>>::apply(node); - return RewriteResponse(REWRITE_DONE, resultNode); + return RewriteResponse(resultNode == node ? REWRITE_DONE : REWRITE_AGAIN_FULL, + resultNode); } RewriteResponse TheoryBVRewriter::RewriteNot(TNode node, bool prerewrite){ diff --git a/src/theory/bv/theory_bv_rewriter.h b/src/theory/bv/theory_bv_rewriter.h index aa771fc94..bf707c268 100644 --- a/src/theory/bv/theory_bv_rewriter.h +++ b/src/theory/bv/theory_bv_rewriter.h @@ -2,9 +2,9 @@ /*! \file theory_bv_rewriter.h ** \verbatim ** Top contributors (to current version): - ** Liana Hadarean, Dejan Jovanovic, Morgan Deters + ** Liana Hadarean, Morgan Deters, Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -17,8 +17,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__BV__THEORY_BV_REWRITER_H -#define __CVC4__THEORY__BV__THEORY_BV_REWRITER_H +#ifndef CVC4__THEORY__BV__THEORY_BV_REWRITER_H +#define CVC4__THEORY__BV__THEORY_BV_REWRITER_H #include "theory/rewriter.h" #include "util/statistics_registry.h" @@ -109,4 +109,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__BV__THEORY_BV_REWRITER_H */ +#endif /* CVC4__THEORY__BV__THEORY_BV_REWRITER_H */ diff --git a/src/theory/bv/theory_bv_type_rules.h b/src/theory/bv/theory_bv_type_rules.h index 616a03f6b..64d04a37e 100644 --- a/src/theory/bv/theory_bv_type_rules.h +++ b/src/theory/bv/theory_bv_type_rules.h @@ -2,9 +2,9 @@ /*! \file theory_bv_type_rules.h ** \verbatim ** Top contributors (to current version): - ** Aina Niemetz, Dejan Jovanovic, Morgan Deters + ** Aina Niemetz, Andrew Reynolds, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -18,8 +18,8 @@ #include <algorithm> -#ifndef __CVC4__THEORY__BV__THEORY_BV_TYPE_RULES_H -#define __CVC4__THEORY__BV__THEORY_BV_TYPE_RULES_H +#ifndef CVC4__THEORY__BV__THEORY_BV_TYPE_RULES_H +#define CVC4__THEORY__BV__THEORY_BV_TYPE_RULES_H namespace CVC4 { namespace theory { @@ -348,7 +348,7 @@ class BitVectorRotateLeftOpTypeRule TNode n, bool check) { - Assert(n.getKind() == kind::BITVECTOR_ROTATE_LEFT); + Assert(n.getKind() == kind::BITVECTOR_ROTATE_LEFT_OP); return nodeManager->builtinOperatorType(); } }; /* class BitVectorRotateLeftOpTypeRule */ @@ -360,7 +360,7 @@ class BitVectorRotateRightOpTypeRule TNode n, bool check) { - Assert(n.getKind() == kind::BITVECTOR_ROTATE_RIGHT); + Assert(n.getKind() == kind::BITVECTOR_ROTATE_RIGHT_OP); return nodeManager->builtinOperatorType(); } }; /* class BitVectorRotateRightOpTypeRule */ @@ -525,4 +525,4 @@ class BitVectorAckermanizationUremTypeRule } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__BV__THEORY_BV_TYPE_RULES_H */ +#endif /* CVC4__THEORY__BV__THEORY_BV_TYPE_RULES_H */ diff --git a/src/theory/bv/theory_bv_utils.cpp b/src/theory/bv/theory_bv_utils.cpp index 9ccaa58e9..f1cb197ab 100644 --- a/src/theory/bv/theory_bv_utils.cpp +++ b/src/theory/bv/theory_bv_utils.cpp @@ -2,9 +2,9 @@ /*! \file theory_bv_utils.cpp ** \verbatim ** Top contributors (to current version): - ** Aina Niemetz, Tim King, Mathias Preiner + ** Aina Niemetz, Liana Hadarean, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/theory_bv_utils.h b/src/theory/bv/theory_bv_utils.h index 2ece472e4..975796719 100644 --- a/src/theory/bv/theory_bv_utils.h +++ b/src/theory/bv/theory_bv_utils.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Aina Niemetz, Dejan Jovanovic, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/bv/type_enumerator.h b/src/theory/bv/type_enumerator.h index fdf7dfbd3..90aae339b 100644 --- a/src/theory/bv/type_enumerator.h +++ b/src/theory/bv/type_enumerator.h @@ -2,9 +2,9 @@ /*! \file type_enumerator.h ** \verbatim ** Top contributors (to current version): - ** Morgan Deters, Tim King, Mathias Preiner + ** Morgan Deters, Mathias Preiner, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__BV__TYPE_ENUMERATOR_H -#define __CVC4__THEORY__BV__TYPE_ENUMERATOR_H +#ifndef CVC4__THEORY__BV__TYPE_ENUMERATOR_H +#define CVC4__THEORY__BV__TYPE_ENUMERATOR_H #include "expr/kind.h" #include "expr/type_node.h" @@ -63,4 +63,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__BV__TYPE_ENUMERATOR_H */ +#endif /* CVC4__THEORY__BV__TYPE_ENUMERATOR_H */ diff --git a/src/theory/care_graph.h b/src/theory/care_graph.h index d81cd8389..55851c1a4 100644 --- a/src/theory/care_graph.h +++ b/src/theory/care_graph.h @@ -2,9 +2,9 @@ /*! \file care_graph.h ** \verbatim ** Top contributors (to current version): - ** Tim King + ** Dejan Jovanovic, Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__CARE_GRAPH_H -#define __CVC4__THEORY__CARE_GRAPH_H +#ifndef CVC4__THEORY__CARE_GRAPH_H +#define CVC4__THEORY__CARE_GRAPH_H #include <set> @@ -59,4 +59,4 @@ typedef std::set<CarePair> CareGraph; } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__CARE_GRAPH_H */ +#endif /* CVC4__THEORY__CARE_GRAPH_H */ diff --git a/src/theory/datatypes/datatypes_rewriter.cpp b/src/theory/datatypes/datatypes_rewriter.cpp index a2458e2eb..be87b7e8d 100644 --- a/src/theory/datatypes/datatypes_rewriter.cpp +++ b/src/theory/datatypes/datatypes_rewriter.cpp @@ -2,9 +2,9 @@ /*! \file datatypes_rewriter.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Morgan Deters, Paul Meng ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -32,7 +32,7 @@ RewriteResponse DatatypesRewriter::postRewrite(TNode in) { return rewriteConstructor(in); } - else if (k == kind::APPLY_SELECTOR_TOTAL) + else if (k == kind::APPLY_SELECTOR_TOTAL || k == kind::APPLY_SELECTOR) { return rewriteSelector(in); } @@ -191,8 +191,6 @@ Kind DatatypesRewriter::getOperatorKindForSygusBuiltin(Node op) Assert(op.getKind() != BUILTIN); if (op.getKind() == LAMBDA) { - // we use APPLY_UF instead of APPLY, since the rewriter for APPLY_UF - // does beta-reduction but does not for APPLY return APPLY_UF; } TypeNode tn = op.getType(); @@ -247,7 +245,16 @@ Node DatatypesRewriter::mkSygusTerm(const Datatype& dt, Kind ok = NodeManager::operatorToKind(op); if (ok != UNDEFINED_KIND) { - ret = NodeManager::currentNM()->mkNode(ok, schildren); + if (ok == APPLY_UF && schildren.size() == 1) + { + // This case is triggered for defined constant symbols. In this case, + // we return the operator itself instead of an APPLY_UF node. + ret = schildren[0]; + } + else + { + ret = NodeManager::currentNM()->mkNode(ok, schildren); + } Trace("dt-sygus-util") << "...return (op) " << ret << std::endl; return ret; } @@ -331,6 +338,7 @@ RewriteResponse DatatypesRewriter::rewriteConstructor(TNode in) RewriteResponse DatatypesRewriter::rewriteSelector(TNode in) { + Kind k = in.getKind(); if (in[0].getKind() == kind::APPLY_CONSTRUCTOR) { // Have to be careful not to rewrite well-typed expressions @@ -338,17 +346,41 @@ RewriteResponse DatatypesRewriter::rewriteSelector(TNode in) // e.g. "pred(zero)". TypeNode tn = in.getType(); TypeNode argType = in[0].getType(); - TNode selector = in.getOperator(); + Expr selector = in.getOperator().toExpr(); TNode constructor = in[0].getOperator(); size_t constructorIndex = indexOf(constructor); - const Datatype& dt = Datatype::datatypeOf(selector.toExpr()); + const Datatype& dt = Datatype::datatypeOf(selector); const DatatypeConstructor& c = dt[constructorIndex]; Trace("datatypes-rewrite-debug") << "Rewriting collapsable selector : " << in; Trace("datatypes-rewrite-debug") << ", cindex = " << constructorIndex << ", selector is " << selector << std::endl; - int selectorIndex = c.getSelectorIndexInternal(selector.toExpr()); + // The argument that the selector extracts, or -1 if the selector is + // is wrongly applied. + int selectorIndex = -1; + if (k == kind::APPLY_SELECTOR_TOTAL) + { + // The argument index of internal selectors is obtained by + // getSelectorIndexInternal. + selectorIndex = c.getSelectorIndexInternal(selector); + } + else + { + // The argument index of external selectors (applications of + // APPLY_SELECTOR) is given by an attribute and obtained via indexOf below + // The argument is only valid if it is the proper constructor. + selectorIndex = Datatype::indexOf(selector); + if (selectorIndex < 0 + || selectorIndex >= static_cast<int>(c.getNumArgs())) + { + selectorIndex = -1; + } + else if (c[selectorIndex].getSelector() != selector) + { + selectorIndex = -1; + } + } Trace("datatypes-rewrite-debug") << "Internal selector index is " << selectorIndex << std::endl; if (selectorIndex >= 0) @@ -374,7 +406,7 @@ RewriteResponse DatatypesRewriter::rewriteSelector(TNode in) return RewriteResponse(REWRITE_DONE, in[0][selectorIndex]); } } - else + else if (k == kind::APPLY_SELECTOR_TOTAL) { Node gt; bool useTe = true; diff --git a/src/theory/datatypes/datatypes_rewriter.h b/src/theory/datatypes/datatypes_rewriter.h index 2eeecbb0e..6c1d64e5b 100644 --- a/src/theory/datatypes/datatypes_rewriter.h +++ b/src/theory/datatypes/datatypes_rewriter.h @@ -2,9 +2,9 @@ /*! \file datatypes_rewriter.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Morgan Deters, Tim King + ** Andrew Reynolds, Morgan Deters, Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__DATATYPES__DATATYPES_REWRITER_H -#define __CVC4__THEORY__DATATYPES__DATATYPES_REWRITER_H +#ifndef CVC4__THEORY__DATATYPES__DATATYPES_REWRITER_H +#define CVC4__THEORY__DATATYPES__DATATYPES_REWRITER_H #include "expr/node_manager_attributes.h" #include "options/datatypes_options.h" @@ -258,4 +258,4 @@ private: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__DATATYPES__DATATYPES_REWRITER_H */ +#endif /* CVC4__THEORY__DATATYPES__DATATYPES_REWRITER_H */ diff --git a/src/theory/datatypes/datatypes_sygus.cpp b/src/theory/datatypes/datatypes_sygus.cpp index cb2968bd5..ea3bb5f72 100644 --- a/src/theory/datatypes/datatypes_sygus.cpp +++ b/src/theory/datatypes/datatypes_sygus.cpp @@ -2,9 +2,9 @@ /*! \file datatypes_sygus.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King + ** Andrew Reynolds, Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/datatypes/datatypes_sygus.h b/src/theory/datatypes/datatypes_sygus.h index 6cf1d7d37..95c259f2b 100644 --- a/src/theory/datatypes/datatypes_sygus.h +++ b/src/theory/datatypes/datatypes_sygus.h @@ -2,9 +2,9 @@ /*! \file datatypes_sygus.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Andres Noetzli + ** Andrew Reynolds, Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__DATATYPES__DATATYPES_SYGUS_NEW_H -#define __CVC4__THEORY__DATATYPES__DATATYPES_SYGUS_NEW_H +#ifndef CVC4__THEORY__DATATYPES__DATATYPES_SYGUS_NEW_H +#define CVC4__THEORY__DATATYPES__DATATYPES_SYGUS_NEW_H #include <iostream> #include <map> diff --git a/src/theory/datatypes/sygus_simple_sym.cpp b/src/theory/datatypes/sygus_simple_sym.cpp index a35ab2a03..fb8bd7515 100644 --- a/src/theory/datatypes/sygus_simple_sym.cpp +++ b/src/theory/datatypes/sygus_simple_sym.cpp @@ -2,9 +2,9 @@ /*! \file sygus_simple_sym.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Haniel Barbosa ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/datatypes/sygus_simple_sym.h b/src/theory/datatypes/sygus_simple_sym.h index 7fb7f4653..815466d00 100644 --- a/src/theory/datatypes/sygus_simple_sym.h +++ b/src/theory/datatypes/sygus_simple_sym.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__DATATYPES__SIMPLE_SYM_BREAK_H -#define __CVC4__THEORY__DATATYPES__SIMPLE_SYM_BREAK_H +#ifndef CVC4__THEORY__DATATYPES__SIMPLE_SYM_BREAK_H +#define CVC4__THEORY__DATATYPES__SIMPLE_SYM_BREAK_H #include <map> #include "theory/quantifiers/sygus/term_database_sygus.h" @@ -104,4 +104,4 @@ class SygusSimpleSymBreak } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__DATATYPES__SIMPLE_SYM_BREAK_H */ +#endif /* CVC4__THEORY__DATATYPES__SIMPLE_SYM_BREAK_H */ diff --git a/src/theory/datatypes/theory_datatypes.cpp b/src/theory/datatypes/theory_datatypes.cpp index 5ed623190..609cdaf6e 100644 --- a/src/theory/datatypes/theory_datatypes.cpp +++ b/src/theory/datatypes/theory_datatypes.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -552,100 +552,130 @@ void TheoryDatatypes::finishInit() { } Node TheoryDatatypes::expandDefinition(LogicRequest &logicRequest, Node n) { - switch( n.getKind() ){ - case kind::APPLY_SELECTOR: { - Trace("dt-expand") << "Dt Expand definition : " << n << std::endl; - Node selector = n.getOperator(); - Expr selectorExpr = selector.toExpr(); - // APPLY_SELECTOR always applies to an external selector, cindexOf is legal here - size_t cindex = Datatype::cindexOf(selectorExpr); - const Datatype& dt = Datatype::datatypeOf(selectorExpr); - const DatatypeConstructor& c = dt[cindex]; - Node selector_use; - TypeNode ndt = n[0].getType(); - if( options::dtSharedSelectors() ){ - size_t selectorIndex = DatatypesRewriter::indexOf(selector); - Trace("dt-expand") << "...selector index = " << selectorIndex << std::endl; - Assert( selectorIndex<c.getNumArgs() ); - selector_use = Node::fromExpr( c.getSelectorInternal( ndt.toType(), selectorIndex ) ); - }else{ - selector_use = selector; - } - Node sel = NodeManager::currentNM()->mkNode( kind::APPLY_SELECTOR_TOTAL, selector_use, n[0] ); - if( options::dtRewriteErrorSel() ){ - return sel; - }else{ - Expr tester = c.getTester(); - Node tst = NodeManager::currentNM()->mkNode( kind::APPLY_TESTER, Node::fromExpr( tester ), n[0] ); - tst = Rewriter::rewrite( tst ); - Node n_ret; - if( tst==d_true ){ - n_ret = sel; + NodeManager* nm = NodeManager::currentNM(); + switch (n.getKind()) + { + case kind::APPLY_SELECTOR: + { + Trace("dt-expand") << "Dt Expand definition : " << n << std::endl; + Node selector = n.getOperator(); + Expr selectorExpr = selector.toExpr(); + // APPLY_SELECTOR always applies to an external selector, cindexOf is + // legal here + size_t cindex = Datatype::cindexOf(selectorExpr); + const Datatype& dt = Datatype::datatypeOf(selectorExpr); + const DatatypeConstructor& c = dt[cindex]; + Node selector_use; + TypeNode ndt = n[0].getType(); + if (options::dtSharedSelectors()) + { + size_t selectorIndex = DatatypesRewriter::indexOf(selector); + Trace("dt-expand") << "...selector index = " << selectorIndex + << std::endl; + Assert(selectorIndex < c.getNumArgs()); + selector_use = + Node::fromExpr(c.getSelectorInternal(ndt.toType(), selectorIndex)); }else{ - mkExpDefSkolem( selector, ndt, n.getType() ); - Node sk = NodeManager::currentNM()->mkNode( kind::APPLY_UF, d_exp_def_skolem[ndt][ selector ], n[0] ); - if( tst==NodeManager::currentNM()->mkConst( false ) ){ - n_ret = sk; + selector_use = selector; + } + Node sel = nm->mkNode(kind::APPLY_SELECTOR_TOTAL, selector_use, n[0]); + if (options::dtRewriteErrorSel()) + { + return sel; + } + else + { + Expr tester = c.getTester(); + Node tst = nm->mkNode(kind::APPLY_TESTER, Node::fromExpr(tester), n[0]); + tst = Rewriter::rewrite(tst); + Node n_ret; + if (tst == d_true) + { + n_ret = sel; }else{ - n_ret = NodeManager::currentNM()->mkNode( kind::ITE, tst, sel, sk ); + mkExpDefSkolem(selector, ndt, n.getType()); + Node sk = + nm->mkNode(kind::APPLY_UF, d_exp_def_skolem[ndt][selector], n[0]); + if (tst == nm->mkConst(false)) + { + n_ret = sk; + } + else + { + n_ret = nm->mkNode(kind::ITE, tst, sel, sk); + } } + // n_ret = Rewriter::rewrite( n_ret ); + Trace("dt-expand") << "Expand def : " << n << " to " << n_ret + << std::endl; + return n_ret; } - //n_ret = Rewriter::rewrite( n_ret ); - Trace("dt-expand") << "Expand def : " << n << " to " << n_ret << std::endl; - return n_ret; } - } break; - default: - return n; + case TUPLE_UPDATE: + case RECORD_UPDATE: + { + TypeNode t = n.getType(); + Assert(t.isDatatype()); + const Datatype& dt = DatatypeType(t.toType()).getDatatype(); + NodeBuilder<> b(APPLY_CONSTRUCTOR); + b << Node::fromExpr(dt[0].getConstructor()); + size_t size, updateIndex; + if (n.getKind() == TUPLE_UPDATE) + { + Assert(t.isTuple()); + size = t.getTupleLength(); + updateIndex = n.getOperator().getConst<TupleUpdate>().getIndex(); + } + else + { + Assert(t.isRecord()); + const Record& record = t.getRecord(); + size = record.getNumFields(); + updateIndex = record.getIndex( + n.getOperator().getConst<RecordUpdate>().getField()); + } + Debug("tuprec") << "expr is " << n << std::endl; + Debug("tuprec") << "updateIndex is " << updateIndex << std::endl; + Debug("tuprec") << "t is " << t << std::endl; + Debug("tuprec") << "t has arity " << size << std::endl; + for (size_t i = 0; i < size; ++i) + { + if (i == updateIndex) + { + b << n[1]; + Debug("tuprec") << "arg " << i << " gets updated to " << n[1] + << std::endl; + } + else + { + b << nm->mkNode( + APPLY_SELECTOR_TOTAL, + Node::fromExpr(dt[0].getSelectorInternal(t.toType(), i)), + n[0]); + Debug("tuprec") << "arg " << i << " copies " + << b[b.getNumChildren() - 1] << std::endl; + } + } + Node n_ret = b; + Debug("tuprec") << "return " << n_ret << std::endl; + return n_ret; + } break; + default: return n; break; } Unreachable(); } -void TheoryDatatypes::presolve() { +void TheoryDatatypes::presolve() +{ Debug("datatypes") << "TheoryDatatypes::presolve()" << endl; } -Node TheoryDatatypes::ppRewrite(TNode in) { +Node TheoryDatatypes::ppRewrite(TNode in) +{ Debug("tuprec") << "TheoryDatatypes::ppRewrite(" << in << ")" << endl; - TypeNode t = in.getType(); - - if(in.getKind() == kind::TUPLE_UPDATE || in.getKind() == kind::RECORD_UPDATE) { - Assert( t.isDatatype() ); - const Datatype& dt = DatatypeType(t.toType()).getDatatype(); - NodeBuilder<> b(kind::APPLY_CONSTRUCTOR); - b << Node::fromExpr(dt[0].getConstructor()); - size_t size, updateIndex; - if(in.getKind() == kind::TUPLE_UPDATE) { - Assert( t.isTuple() ); - size = t.getTupleLength(); - updateIndex = in.getOperator().getConst<TupleUpdate>().getIndex(); - } else { // kind::RECORD_UPDATE - Assert( t.isRecord() ); - const Record& record = t.getRecord(); - size = record.getNumFields(); - updateIndex = record.getIndex(in.getOperator().getConst<RecordUpdate>().getField()); - } - Debug("tuprec") << "expr is " << in << std::endl; - Debug("tuprec") << "updateIndex is " << updateIndex << std::endl; - Debug("tuprec") << "t is " << t << std::endl; - Debug("tuprec") << "t has arity " << size << std::endl; - for(size_t i = 0; i < size; ++i) { - if(i == updateIndex) { - b << in[1]; - Debug("tuprec") << "arg " << i << " gets updated to " << in[1] << std::endl; - } else { - b << NodeManager::currentNM()->mkNode(kind::APPLY_SELECTOR_TOTAL, Node::fromExpr(dt[0].getSelectorInternal( t.toType(), i )), in[0]); - Debug("tuprec") << "arg " << i << " copies " << b[b.getNumChildren() - 1] << std::endl; - } - } - Debug("tuprec") << "builder says " << b << std::endl; - Node n = b; - return n; - } - if( in.getKind()==EQUAL ){ Node nn; std::vector< Node > rew; diff --git a/src/theory/datatypes/theory_datatypes.h b/src/theory/datatypes/theory_datatypes.h index a7b40e282..b4803e69a 100644 --- a/src/theory/datatypes/theory_datatypes.h +++ b/src/theory/datatypes/theory_datatypes.h @@ -2,9 +2,9 @@ /*! \file theory_datatypes.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Morgan Deters + ** Andrew Reynolds, Tim King, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__DATATYPES__THEORY_DATATYPES_H -#define __CVC4__THEORY__DATATYPES__THEORY_DATATYPES_H +#ifndef CVC4__THEORY__DATATYPES__THEORY_DATATYPES_H +#define CVC4__THEORY__DATATYPES__THEORY_DATATYPES_H #include <iostream> #include <map> @@ -370,4 +370,4 @@ private: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__DATATYPES__THEORY_DATATYPES_H */ +#endif /* CVC4__THEORY__DATATYPES__THEORY_DATATYPES_H */ diff --git a/src/theory/datatypes/theory_datatypes_type_rules.h b/src/theory/datatypes/theory_datatypes_type_rules.h index 8a5849010..22ac074f0 100644 --- a/src/theory/datatypes/theory_datatypes_type_rules.h +++ b/src/theory/datatypes/theory_datatypes_type_rules.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__DATATYPES__THEORY_DATATYPES_TYPE_RULES_H -#define __CVC4__THEORY__DATATYPES__THEORY_DATATYPES_TYPE_RULES_H +#ifndef CVC4__THEORY__DATATYPES__THEORY_DATATYPES_TYPE_RULES_H +#define CVC4__THEORY__DATATYPES__THEORY_DATATYPES_TYPE_RULES_H #include "expr/matcher.h" //#include "expr/attribute.h" @@ -433,4 +433,4 @@ class DtSyguEvalTypeRule } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__DATATYPES__THEORY_DATATYPES_TYPE_RULES_H */ +#endif /* CVC4__THEORY__DATATYPES__THEORY_DATATYPES_TYPE_RULES_H */ diff --git a/src/theory/datatypes/type_enumerator.cpp b/src/theory/datatypes/type_enumerator.cpp index afe6e182f..609106b46 100644 --- a/src/theory/datatypes/type_enumerator.cpp +++ b/src/theory/datatypes/type_enumerator.cpp @@ -2,9 +2,9 @@ /*! \file type_enumerator.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/datatypes/type_enumerator.h b/src/theory/datatypes/type_enumerator.h index 13d590508..a294324fa 100644 --- a/src/theory/datatypes/type_enumerator.h +++ b/src/theory/datatypes/type_enumerator.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__DATATYPES__TYPE_ENUMERATOR_H -#define __CVC4__THEORY__DATATYPES__TYPE_ENUMERATOR_H +#ifndef CVC4__THEORY__DATATYPES__TYPE_ENUMERATOR_H +#define CVC4__THEORY__DATATYPES__TYPE_ENUMERATOR_H #include "theory/type_enumerator.h" #include "expr/type_node.h" @@ -185,4 +185,4 @@ class DatatypesEnumerator : public TypeEnumeratorBase<DatatypesEnumerator> { }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__DATATYPES__TYPE_ENUMERATOR_H */ +#endif /* CVC4__THEORY__DATATYPES__TYPE_ENUMERATOR_H */ diff --git a/src/theory/decision_manager.cpp b/src/theory/decision_manager.cpp index 5c43e6159..3eda45b00 100644 --- a/src/theory/decision_manager.cpp +++ b/src/theory/decision_manager.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/decision_manager.h b/src/theory/decision_manager.h index fbc0e2cd6..6825c1cf4 100644 --- a/src/theory/decision_manager.h +++ b/src/theory/decision_manager.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -15,8 +15,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__DECISION_MANAGER__H -#define __CVC4__THEORY__DECISION_MANAGER__H +#ifndef CVC4__THEORY__DECISION_MANAGER__H +#define CVC4__THEORY__DECISION_MANAGER__H #include <map> #include "theory/decision_strategy.h" @@ -116,4 +116,4 @@ class DecisionManager } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__DECISION_MANAGER__H */ +#endif /* CVC4__THEORY__DECISION_MANAGER__H */ diff --git a/src/theory/decision_strategy.cpp b/src/theory/decision_strategy.cpp index fcd11f6ba..b14936ee9 100644 --- a/src/theory/decision_strategy.cpp +++ b/src/theory/decision_strategy.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/decision_strategy.h b/src/theory/decision_strategy.h index 04788f515..65b80b7f6 100644 --- a/src/theory/decision_strategy.h +++ b/src/theory/decision_strategy.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -15,8 +15,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__DECISION_STRATEGY__H -#define __CVC4__THEORY__DECISION_STRATEGY__H +#ifndef CVC4__THEORY__DECISION_STRATEGY__H +#define CVC4__THEORY__DECISION_STRATEGY__H #include <map> #include "context/cdo.h" @@ -143,4 +143,4 @@ class DecisionStrategySingleton : public DecisionStrategyFmf } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__DECISION_STRATEGY__H */ +#endif /* CVC4__THEORY__DECISION_STRATEGY__H */ diff --git a/src/theory/evaluator.cpp b/src/theory/evaluator.cpp index 0a0176f25..818f40e8c 100644 --- a/src/theory/evaluator.cpp +++ b/src/theory/evaluator.cpp @@ -2,9 +2,9 @@ /*! \file evaluator.cpp ** \verbatim ** Top contributors (to current version): - ** Andres Noetzli + ** Andres Noetzli, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/evaluator.h b/src/theory/evaluator.h index 0d7ddbec8..5c0e9b944 100644 --- a/src/theory/evaluator.h +++ b/src/theory/evaluator.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -17,8 +17,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__EVALUATOR_H -#define __CVC4__THEORY__EVALUATOR_H +#ifndef CVC4__THEORY__EVALUATOR_H +#define CVC4__THEORY__EVALUATOR_H #include <utility> #include <vector> @@ -110,4 +110,4 @@ class Evaluator } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__EVALUATOR_H */ +#endif /* CVC4__THEORY__EVALUATOR_H */ diff --git a/src/theory/example/ecdata.cpp b/src/theory/example/ecdata.cpp index 4089ad45d..6a66f5491 100644 --- a/src/theory/example/ecdata.cpp +++ b/src/theory/example/ecdata.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/example/ecdata.h b/src/theory/example/ecdata.h index 7c62f9833..c646725e8 100644 --- a/src/theory/example/ecdata.h +++ b/src/theory/example/ecdata.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -17,8 +17,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__UF__TIM__ECDATA_H -#define __CVC4__THEORY__UF__TIM__ECDATA_H +#ifndef CVC4__THEORY__UF__TIM__ECDATA_H +#define CVC4__THEORY__UF__TIM__ECDATA_H #include "expr/node.h" #include "context/context.h" @@ -255,4 +255,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__UF__TIM__ECDATA_H */ +#endif /* CVC4__THEORY__UF__TIM__ECDATA_H */ diff --git a/src/theory/example/theory_uf_tim.cpp b/src/theory/example/theory_uf_tim.cpp index fa329f1d5..54d2e3209 100644 --- a/src/theory/example/theory_uf_tim.cpp +++ b/src/theory/example/theory_uf_tim.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/example/theory_uf_tim.h b/src/theory/example/theory_uf_tim.h index ccdab9d35..20fd6bcfb 100644 --- a/src/theory/example/theory_uf_tim.h +++ b/src/theory/example/theory_uf_tim.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -22,8 +22,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__UF__TIM__THEORY_UF_TIM_H -#define __CVC4__THEORY__UF__TIM__THEORY_UF_TIM_H +#ifndef CVC4__THEORY__UF__TIM__THEORY_UF_TIM_H +#define CVC4__THEORY__UF__TIM__THEORY_UF_TIM_H #include "expr/node.h" #include "expr/attribute.h" @@ -210,4 +210,4 @@ typedef expr::Attribute<ECAttrTag, ECData*, ECCleanupStrategy> ECAttr; }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__UF__TIM__THEORY_UF_TIM_H */ +#endif /* CVC4__THEORY__UF__TIM__THEORY_UF_TIM_H */ diff --git a/src/theory/ext_theory.cpp b/src/theory/ext_theory.cpp index c1e7c971f..5a37889a2 100644 --- a/src/theory/ext_theory.cpp +++ b/src/theory/ext_theory.cpp @@ -2,9 +2,9 @@ /*! \file ext_theory.cpp ** \verbatim ** Top contributors (to current version): - ** Tim King, Andrew Reynolds, Dejan Jovanovic + ** Andrew Reynolds, Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2017 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/ext_theory.h b/src/theory/ext_theory.h index 8657d0fb8..7ac79a4d6 100644 --- a/src/theory/ext_theory.h +++ b/src/theory/ext_theory.h @@ -2,9 +2,9 @@ /*! \file ext_theory.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2017 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -30,8 +30,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__EXT_THEORY_H -#define __CVC4__THEORY__EXT_THEORY_H +#ifndef CVC4__THEORY__EXT_THEORY_H +#define CVC4__THEORY__EXT_THEORY_H #include <map> #include <set> @@ -247,4 +247,4 @@ class ExtTheory } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__EXT_THEORY_H */ +#endif /* CVC4__THEORY__EXT_THEORY_H */ diff --git a/src/theory/fp/fp_converter.cpp b/src/theory/fp/fp_converter.cpp index dc6c001c9..a69cf8c96 100644 --- a/src/theory/fp/fp_converter.cpp +++ b/src/theory/fp/fp_converter.cpp @@ -2,9 +2,9 @@ /*! \file fp_converter.cpp ** \verbatim ** Top contributors (to current version): - ** Martin Brain + ** Martin Brain, Andres Noetzli, Aina Niemetz ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/fp/fp_converter.h b/src/theory/fp/fp_converter.h index 018f3ee66..753030408 100644 --- a/src/theory/fp/fp_converter.h +++ b/src/theory/fp/fp_converter.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Martin Brain ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -18,8 +18,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__FP__FP_CONVERTER_H -#define __CVC4__THEORY__FP__FP_CONVERTER_H +#ifndef CVC4__THEORY__FP__FP_CONVERTER_H +#define CVC4__THEORY__FP__FP_CONVERTER_H #include "base/cvc4_assert.h" #include "context/cdhashmap.h" @@ -355,4 +355,4 @@ class FpConverter } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__FP__THEORY_FP_H */ +#endif /* CVC4__THEORY__FP__THEORY_FP_H */ diff --git a/src/theory/fp/theory_fp.cpp b/src/theory/fp/theory_fp.cpp index 364df3890..2c93553fe 100644 --- a/src/theory/fp/theory_fp.cpp +++ b/src/theory/fp/theory_fp.cpp @@ -2,9 +2,9 @@ /*! \file theory_fp.cpp ** \verbatim ** Top contributors (to current version): - ** Martin Brain, Andrew Reynolds, Tim King + ** Martin Brain, Andres Noetzli, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -15,9 +15,12 @@ ** \todo document this file **/ -#include "theory/fp/theory_fp.h" + +#include "options/fp_options.h" #include "theory/rewriter.h" #include "theory/theory_model.h" +#include "theory/fp/theory_fp.h" + #include <set> #include <stack> @@ -306,7 +309,7 @@ Node TheoryFp::toRealUF(Node node) { std::vector<TypeNode> args(1); args[0] = t; fun = nm->mkSkolem("floatingpoint_to_real_infinity_and_NaN_case", - nm->mkFunctionType(args, nm->realType()), + nm->mkFunctionType(args, nm->realType()), "floatingpoint_to_real_infinity_and_NaN_case", NodeManager::SKOLEM_EXACT_NAME); d_toRealMap.insert(t, fun); @@ -876,7 +879,27 @@ bool TheoryFp::isRegistered(TNode node) { return !(d_registeredTerms.find(node) == d_registeredTerms.end()); } -void TheoryFp::preRegisterTerm(TNode node) { +void TheoryFp::preRegisterTerm(TNode node) +{ + if (Configuration::isBuiltWithSymFPU() && !options::fpExp()) + { + TypeNode tn = node.getType(); + if (tn.isFloatingPoint()) + { + unsigned exp_sz = tn.getFloatingPointExponentSize(); + unsigned sig_sz = tn.getFloatingPointSignificandSize(); + if (!((exp_sz == 8 && sig_sz == 24) || (exp_sz == 11 && sig_sz == 53))) + { + std::stringstream ss; + ss << "FP term " << node << " with type whose size is " << exp_sz << "/" + << sig_sz + << " is not supported, only Float32 (8/24) or Float64 (11/53) types " + "are supported in default mode. Try the experimental solver via " + "--fp-exp"; + throw LogicException(ss.str()); + } + } + } Trace("fp-preRegisterTerm") << "TheoryFp::preRegisterTerm(): " << node << std::endl; registerTerm(node); @@ -1084,6 +1107,41 @@ bool TheoryFp::collectModelInfo(TheoryModel *m) { return false; } + + if (Configuration::isAssertionBuild() && isLeaf(node) && !node.isConst() + && node.getType().isFloatingPoint()) + { + // Check that the equality engine has asssigned values to all the + // components of `node` except `(sign node)` (the sign component is + // assignable, meaning that the model builder can pick an arbitrary value + // for it if it hasn't been assigned in the equality engine). + NodeManager* nm = NodeManager::currentNM(); + Node compNaN = nm->mkNode(kind::FLOATINGPOINT_COMPONENT_NAN, node); + Node compInf = nm->mkNode(kind::FLOATINGPOINT_COMPONENT_INF, node); + Node compZero = nm->mkNode(kind::FLOATINGPOINT_COMPONENT_ZERO, node); + Node compExponent = + nm->mkNode(kind::FLOATINGPOINT_COMPONENT_EXPONENT, node); + Node compSignificand = + nm->mkNode(kind::FLOATINGPOINT_COMPONENT_SIGNIFICAND, node); + + eq::EqualityEngine* ee = m->getEqualityEngine(); + Assert(ee->hasTerm(compNaN) && ee->getRepresentative(compNaN).isConst()); + Assert(ee->hasTerm(compInf) && ee->getRepresentative(compInf).isConst()); + Assert(ee->hasTerm(compZero) + && ee->getRepresentative(compZero).isConst()); + Assert(ee->hasTerm(compExponent) + && ee->getRepresentative(compExponent).isConst()); + Assert(ee->hasTerm(compSignificand)); + Assert(ee->getRepresentative(compSignificand).isConst()); + + // At most one of the flags (NaN, inf, zero) can be set + Node one = nm->mkConst(BitVector(1U, 1U)); + size_t numFlags = 0; + numFlags += ee->getRepresentative(compNaN) == one ? 1 : 0; + numFlags += ee->getRepresentative(compInf) == one ? 1 : 0; + numFlags += ee->getRepresentative(compZero) == one ? 1 : 0; + Assert(numFlags <= 1); + } } return true; diff --git a/src/theory/fp/theory_fp.h b/src/theory/fp/theory_fp.h index 3d13cc63f..ad093f924 100644 --- a/src/theory/fp/theory_fp.h +++ b/src/theory/fp/theory_fp.h @@ -2,9 +2,9 @@ /*! \file theory_fp.h ** \verbatim ** Top contributors (to current version): - ** Martin Brain, Mathias Preiner, Tim King + ** Martin Brain, Tim King, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -17,8 +17,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__FP__THEORY_FP_H -#define __CVC4__THEORY__FP__THEORY_FP_H +#ifndef CVC4__THEORY__FP__THEORY_FP_H +#define CVC4__THEORY__FP__THEORY_FP_H #include <string> #include <utility> @@ -148,4 +148,4 @@ class TheoryFp : public Theory { } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__FP__THEORY_FP_H */ +#endif /* CVC4__THEORY__FP__THEORY_FP_H */ diff --git a/src/theory/fp/theory_fp_rewriter.cpp b/src/theory/fp/theory_fp_rewriter.cpp index 875471ded..68ea01eb8 100644 --- a/src/theory/fp/theory_fp_rewriter.cpp +++ b/src/theory/fp/theory_fp_rewriter.cpp @@ -2,10 +2,10 @@ /*! \file theory_fp_rewriter.cpp ** \verbatim ** Top contributors (to current version): - ** Martin Brain, Clark Barrett, Andrew Reynolds + ** Martin Brain, Martin Brain, Andrew Reynolds ** Copyright (c) 2013 University of Oxford ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/fp/theory_fp_rewriter.h b/src/theory/fp/theory_fp_rewriter.h index e39a95615..fef97afea 100644 --- a/src/theory/fp/theory_fp_rewriter.h +++ b/src/theory/fp/theory_fp_rewriter.h @@ -2,9 +2,9 @@ /*! \file theory_fp_rewriter.h ** \verbatim ** Top contributors (to current version): - ** Martin Brain, Paul Meng + ** Martin Brain ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -17,8 +17,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__FP__THEORY_FP_REWRITER_H -#define __CVC4__THEORY__FP__THEORY_FP_REWRITER_H +#ifndef CVC4__THEORY__FP__THEORY_FP_REWRITER_H +#define CVC4__THEORY__FP__THEORY_FP_REWRITER_H #include "theory/rewriter.h" @@ -64,4 +64,4 @@ class TheoryFpRewriter { }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__FP__THEORY_FP_REWRITER_H */ +#endif /* CVC4__THEORY__FP__THEORY_FP_REWRITER_H */ diff --git a/src/theory/fp/theory_fp_type_rules.h b/src/theory/fp/theory_fp_type_rules.h index 94ce476bf..4022cc278 100644 --- a/src/theory/fp/theory_fp_type_rules.h +++ b/src/theory/fp/theory_fp_type_rules.h @@ -2,9 +2,9 @@ /*! \file theory_fp_type_rules.h ** \verbatim ** Top contributors (to current version): - ** Martin Brain, Tim King + ** Martin Brain, Tim King, Martin Brain ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -20,8 +20,8 @@ // This is only needed for checking that components are only applied to leaves. #include "theory/theory.h" -#ifndef __CVC4__THEORY__FP__THEORY_FP_TYPE_RULES_H -#define __CVC4__THEORY__FP__THEORY_FP_TYPE_RULES_H +#ifndef CVC4__THEORY__FP__THEORY_FP_TYPE_RULES_H +#define CVC4__THEORY__FP__THEORY_FP_TYPE_RULES_H namespace CVC4 { namespace theory { @@ -806,4 +806,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__FP__THEORY_FP_TYPE_RULES_H */ +#endif /* CVC4__THEORY__FP__THEORY_FP_TYPE_RULES_H */ diff --git a/src/theory/fp/type_enumerator.h b/src/theory/fp/type_enumerator.h index eeb1ac4f8..4494fd40f 100644 --- a/src/theory/fp/type_enumerator.h +++ b/src/theory/fp/type_enumerator.h @@ -2,10 +2,10 @@ /*! \file type_enumerator.h ** \verbatim ** Top contributors (to current version): - ** Tim King, Martin Brain + ** Tim King, Martin Brain, Andrew Reynolds ** Copyright (c) 2009-2015 New York University and The University of Iowa ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -17,8 +17,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__FP__TYPE_ENUMERATOR_H -#define __CVC4__THEORY__FP__TYPE_ENUMERATOR_H +#ifndef CVC4__THEORY__FP__TYPE_ENUMERATOR_H +#define CVC4__THEORY__FP__TYPE_ENUMERATOR_H #include "expr/kind.h" #include "expr/type_node.h" @@ -132,4 +132,4 @@ class RoundingModeEnumerator } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__FP__TYPE_ENUMERATOR_H */ +#endif /* CVC4__THEORY__FP__TYPE_ENUMERATOR_H */ diff --git a/src/theory/idl/idl_assertion.cpp b/src/theory/idl/idl_assertion.cpp index 8b5758f5a..1e3905537 100644 --- a/src/theory/idl/idl_assertion.cpp +++ b/src/theory/idl/idl_assertion.cpp @@ -2,9 +2,9 @@ /*! \file idl_assertion.cpp ** \verbatim ** Top contributors (to current version): - ** Dejan Jovanovic, Morgan Deters + ** Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/idl/idl_assertion.h b/src/theory/idl/idl_assertion.h index 6804945f3..e24fbfc67 100644 --- a/src/theory/idl/idl_assertion.h +++ b/src/theory/idl/idl_assertion.h @@ -2,9 +2,9 @@ /*! \file idl_assertion.h ** \verbatim ** Top contributors (to current version): - ** Dejan Jovanovic, Morgan Deters + ** Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/idl/idl_assertion_db.cpp b/src/theory/idl/idl_assertion_db.cpp index 150d0814a..865d8b4f5 100644 --- a/src/theory/idl/idl_assertion_db.cpp +++ b/src/theory/idl/idl_assertion_db.cpp @@ -2,9 +2,9 @@ /*! \file idl_assertion_db.cpp ** \verbatim ** Top contributors (to current version): - ** Dejan Jovanovic, Morgan Deters + ** Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/idl/idl_assertion_db.h b/src/theory/idl/idl_assertion_db.h index 8d7edc87c..ac87282d9 100644 --- a/src/theory/idl/idl_assertion_db.h +++ b/src/theory/idl/idl_assertion_db.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Dejan Jovanovic, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/idl/idl_model.cpp b/src/theory/idl/idl_model.cpp index 98a7ed7c2..729a18ee4 100644 --- a/src/theory/idl/idl_model.cpp +++ b/src/theory/idl/idl_model.cpp @@ -2,9 +2,9 @@ /*! \file idl_model.cpp ** \verbatim ** Top contributors (to current version): - ** Dejan Jovanovic, Morgan Deters + ** Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/idl/idl_model.h b/src/theory/idl/idl_model.h index a58c2d79c..87e67edea 100644 --- a/src/theory/idl/idl_model.h +++ b/src/theory/idl/idl_model.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Dejan Jovanovic, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/idl/theory_idl.cpp b/src/theory/idl/theory_idl.cpp index ab87cb1a9..12ac1e802 100644 --- a/src/theory/idl/theory_idl.cpp +++ b/src/theory/idl/theory_idl.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Dejan Jovanovic, Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/idl/theory_idl.h b/src/theory/idl/theory_idl.h index 17f19ca4a..1d48d0785 100644 --- a/src/theory/idl/theory_idl.h +++ b/src/theory/idl/theory_idl.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Dejan Jovanovic, Mathias Preiner, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/interrupted.h b/src/theory/interrupted.h index 8ab6f0ba7..905a98689 100644 --- a/src/theory/interrupted.h +++ b/src/theory/interrupted.h @@ -2,9 +2,9 @@ /*! \file interrupted.h ** \verbatim ** Top contributors (to current version): - ** Morgan Deters, Tim King + ** Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -26,8 +26,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__INTERRUPTED_H -#define __CVC4__THEORY__INTERRUPTED_H +#ifndef CVC4__THEORY__INTERRUPTED_H +#define CVC4__THEORY__INTERRUPTED_H #include "base/exception.h" @@ -40,4 +40,4 @@ class Interrupted : public CVC4::Exception { }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__INTERRUPTED_H */ +#endif /* CVC4__THEORY__INTERRUPTED_H */ diff --git a/src/theory/logic_info.cpp b/src/theory/logic_info.cpp index 7d41ff5e6..1712bb30a 100644 --- a/src/theory/logic_info.cpp +++ b/src/theory/logic_info.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters, Tim King, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/logic_info.h b/src/theory/logic_info.h index 2edc049c6..a765472dd 100644 --- a/src/theory/logic_info.h +++ b/src/theory/logic_info.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters, Andrew Reynolds, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -18,8 +18,8 @@ #include "cvc4_public.h" -#ifndef __CVC4__LOGIC_INFO_H -#define __CVC4__LOGIC_INFO_H +#ifndef CVC4__LOGIC_INFO_H +#define CVC4__LOGIC_INFO_H #include <string> #include <vector> @@ -279,4 +279,4 @@ std::ostream& operator<<(std::ostream& out, const LogicInfo& logic) CVC4_PUBLIC; }/* CVC4 namespace */ -#endif /* __CVC4__LOGIC_INFO_H */ +#endif /* CVC4__LOGIC_INFO_H */ diff --git a/src/theory/output_channel.h b/src/theory/output_channel.h index bb8103891..347177b93 100644 --- a/src/theory/output_channel.h +++ b/src/theory/output_channel.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters, Tim King, Liana Hadarean ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__OUTPUT_CHANNEL_H -#define __CVC4__THEORY__OUTPUT_CHANNEL_H +#ifndef CVC4__THEORY__OUTPUT_CHANNEL_H +#define CVC4__THEORY__OUTPUT_CHANNEL_H #include <memory> @@ -194,4 +194,4 @@ class OutputChannel { } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__OUTPUT_CHANNEL_H */ +#endif /* CVC4__THEORY__OUTPUT_CHANNEL_H */ diff --git a/src/theory/quantifiers/alpha_equivalence.cpp b/src/theory/quantifiers/alpha_equivalence.cpp index 577b2c31f..bb0cdde83 100644 --- a/src/theory/quantifiers/alpha_equivalence.cpp +++ b/src/theory/quantifiers/alpha_equivalence.cpp @@ -2,9 +2,9 @@ /*! \file alpha_equivalence.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/alpha_equivalence.h b/src/theory/quantifiers/alpha_equivalence.h index 4ab45b015..b5d68f233 100644 --- a/src/theory/quantifiers/alpha_equivalence.h +++ b/src/theory/quantifiers/alpha_equivalence.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Paul Meng ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__ALPHA_EQUIVALENCE_H -#define __CVC4__ALPHA_EQUIVALENCE_H +#ifndef CVC4__ALPHA_EQUIVALENCE_H +#define CVC4__ALPHA_EQUIVALENCE_H #include "theory/quantifiers_engine.h" diff --git a/src/theory/quantifiers/anti_skolem.cpp b/src/theory/quantifiers/anti_skolem.cpp index 08e215d72..5d1967bb4 100644 --- a/src/theory/quantifiers/anti_skolem.cpp +++ b/src/theory/quantifiers/anti_skolem.cpp @@ -2,9 +2,9 @@ /*! \file anti_skolem.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King + ** Andrew Reynolds, Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/anti_skolem.h b/src/theory/quantifiers/anti_skolem.h index 162140ff1..3a7dc2da8 100644 --- a/src/theory/quantifiers/anti_skolem.h +++ b/src/theory/quantifiers/anti_skolem.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Tim King, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANT_ANTI_SKOLEM_H -#define __CVC4__THEORY__QUANT_ANTI_SKOLEM_H +#ifndef CVC4__THEORY__QUANT_ANTI_SKOLEM_H +#define CVC4__THEORY__QUANT_ANTI_SKOLEM_H #include <map> #include <vector> diff --git a/src/theory/quantifiers/bv_inverter.cpp b/src/theory/quantifiers/bv_inverter.cpp index 2525f5d18..24e3a85b5 100644 --- a/src/theory/quantifiers/bv_inverter.cpp +++ b/src/theory/quantifiers/bv_inverter.cpp @@ -2,9 +2,9 @@ /*! \file bv_inverter.cpp ** \verbatim ** Top contributors (to current version): - ** Aina Niemetz, Mathias Preiner, Andrew Reynolds + ** Aina Niemetz, Andrew Reynolds, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/bv_inverter.h b/src/theory/quantifiers/bv_inverter.h index ad16a2ed9..746bfba9a 100644 --- a/src/theory/quantifiers/bv_inverter.h +++ b/src/theory/quantifiers/bv_inverter.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Mathias Preiner, Aina Niemetz ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__BV_INVERTER_H -#define __CVC4__BV_INVERTER_H +#ifndef CVC4__BV_INVERTER_H +#define CVC4__BV_INVERTER_H #include <map> #include <unordered_map> @@ -130,4 +130,4 @@ class BvInverter } // namespace theory } // namespace CVC4 -#endif /* __CVC4__BV_INVERTER_H */ +#endif /* CVC4__BV_INVERTER_H */ diff --git a/src/theory/quantifiers/bv_inverter_utils.cpp b/src/theory/quantifiers/bv_inverter_utils.cpp index 8ad26a422..e01af3f38 100644 --- a/src/theory/quantifiers/bv_inverter_utils.cpp +++ b/src/theory/quantifiers/bv_inverter_utils.cpp @@ -1,10 +1,10 @@ /********************* */ -/*! \file bv_inverter.cpp +/*! \file bv_inverter_utils.cpp ** \verbatim ** Top contributors (to current version): ** Aina Niemetz, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/bv_inverter_utils.h b/src/theory/quantifiers/bv_inverter_utils.h index 0fec00579..264b42ef5 100644 --- a/src/theory/quantifiers/bv_inverter_utils.h +++ b/src/theory/quantifiers/bv_inverter_utils.h @@ -1,10 +1,10 @@ /********************* */ -/*! \file bv_inverter.cpp +/*! \file bv_inverter_utils.h ** \verbatim ** Top contributors (to current version): - ** Aina Niemetz, Mathias Preiner + ** Aina Niemetz ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__BV_INVERTER_UTILS_H -#define __CVC4__BV_INVERTER_UTILS_H +#ifndef CVC4__BV_INVERTER_UTILS_H +#define CVC4__BV_INVERTER_UTILS_H #include "expr/node.h" diff --git a/src/theory/quantifiers/candidate_rewrite_database.cpp b/src/theory/quantifiers/candidate_rewrite_database.cpp index 2d2e9ce30..e00bc957f 100644 --- a/src/theory/quantifiers/candidate_rewrite_database.cpp +++ b/src/theory/quantifiers/candidate_rewrite_database.cpp @@ -2,9 +2,9 @@ /*! \file candidate_rewrite_database.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -69,9 +69,29 @@ void CandidateRewriteDatabase::initializeSygus(const std::vector<Node>& vars, } bool CandidateRewriteDatabase::addTerm(Node sol, + bool rec, std::ostream& out, bool& rew_print) { + // have we added this term before? + std::unordered_map<Node, bool, NodeHashFunction>::iterator itac = + d_add_term_cache.find(sol); + if (itac != d_add_term_cache.end()) + { + return itac->second; + } + + if (rec) + { + // if recursive, we first add all subterms + for (const Node& solc : sol) + { + // whether a candidate rewrite is printed for any subterm is irrelevant + bool rew_printc = false; + addTerm(solc, rec, out, rew_printc); + } + } + // register the term bool is_unique_term = true; Node eq_sol = d_sampler->registerTerm(sol); // eq_sol is a candidate solution that is equivalent to sol @@ -117,9 +137,9 @@ bool CandidateRewriteDatabase::addTerm(Node sol, // options as the SmtEngine we belong to, where we ensure that // produce-models is set. bool needExport = false; - ExprManagerMapCollection varMap; ExprManager em(nm->getOptions()); std::unique_ptr<SmtEngine> rrChecker; + ExprManagerMapCollection varMap; initializeChecker(rrChecker, em, varMap, crr, needExport); Result r = rrChecker->checkSat(); Trace("rr-check") << "...result : " << r << std::endl; @@ -252,13 +272,18 @@ bool CandidateRewriteDatabase::addTerm(Node sol, // it discards it as a redundant candidate rewrite rule before // checking its correctness. } + d_add_term_cache[sol] = is_unique_term; return is_unique_term; } -bool CandidateRewriteDatabase::addTerm(Node sol, std::ostream& out) +bool CandidateRewriteDatabase::addTerm(Node sol, bool rec, std::ostream& out) { bool rew_print = false; - return addTerm(sol, out, rew_print); + return addTerm(sol, rec, out, rew_print); +} +bool CandidateRewriteDatabase::addTerm(Node sol, std::ostream& out) +{ + return addTerm(sol, false, out); } void CandidateRewriteDatabase::setSilent(bool flag) { d_silent = flag; } @@ -298,7 +323,7 @@ bool CandidateRewriteDatabaseGen::addTerm(Node n, std::ostream& out) Trace("synth-rr-dbg") << "...finish." << std::endl; } Trace("synth-rr-dbg") << "Add term " << nr << " for " << tn << std::endl; - return itc->second.addTerm(nr, out); + return itc->second.addTerm(nr, false, out); } } /* CVC4::theory::quantifiers namespace */ diff --git a/src/theory/quantifiers/candidate_rewrite_database.h b/src/theory/quantifiers/candidate_rewrite_database.h index 5b8ffbd94..b68b20998 100644 --- a/src/theory/quantifiers/candidate_rewrite_database.h +++ b/src/theory/quantifiers/candidate_rewrite_database.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__CANDIDATE_REWRITE_DATABASE_H -#define __CVC4__THEORY__QUANTIFIERS__CANDIDATE_REWRITE_DATABASE_H +#ifndef CVC4__THEORY__QUANTIFIERS__CANDIDATE_REWRITE_DATABASE_H +#define CVC4__THEORY__QUANTIFIERS__CANDIDATE_REWRITE_DATABASE_H #include <map> #include <memory> @@ -71,9 +71,13 @@ class CandidateRewriteDatabase : public ExprMiner * cause a candidate-rewrite to be printed on the output stream out. * We return true if the term sol is distinct (up to equivalence) with * all previous terms added to this class. The argument rew_print is set to - * true if this class printed a rewrite. + * true if this class printed a rewrite involving sol. + * + * If the flag rec is true, then we also recursively add all subterms of sol + * to this class as well. */ - bool addTerm(Node sol, std::ostream& out, bool& rew_print); + bool addTerm(Node sol, bool rec, std::ostream& out, bool& rew_print); + bool addTerm(Node sol, bool rec, std::ostream& out); bool addTerm(Node sol, std::ostream& out) override; /** sets whether this class should output candidate rewrites it finds */ void setSilent(bool flag); @@ -93,6 +97,8 @@ class CandidateRewriteDatabase : public ExprMiner bool d_using_sygus; /** candidate rewrite filter */ CandidateRewriteFilter d_crewrite_filter; + /** the cache for results of addTerm */ + std::unordered_map<Node, bool, NodeHashFunction> d_add_term_cache; /** if true, we silence the output of candidate rewrites */ bool d_silent; }; @@ -115,7 +121,8 @@ class CandidateRewriteDatabaseGen * This registers term n with this class. We generate the candidate rewrite * database of the appropriate type (if not allocated already), and register * n with this database. This may result in "candidate-rewrite" being - * printed on the output stream out. + * printed on the output stream out. We return true if the term sol is + * distinct (up to equivalence) with all previous terms added to this class. */ bool addTerm(Node n, std::ostream& out); @@ -138,4 +145,4 @@ class CandidateRewriteDatabaseGen } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__CANDIDATE_REWRITE_DATABASE_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__CANDIDATE_REWRITE_DATABASE_H */ diff --git a/src/theory/quantifiers/candidate_rewrite_filter.cpp b/src/theory/quantifiers/candidate_rewrite_filter.cpp index 0d3878149..53c40464f 100644 --- a/src/theory/quantifiers/candidate_rewrite_filter.cpp +++ b/src/theory/quantifiers/candidate_rewrite_filter.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -290,6 +290,12 @@ bool CandidateRewriteFilter::filterPair(Node n, Node eq_n) // ----- check rewriting redundancy if (keep && options::sygusRewSynthFilterCong()) { + // When using sygus types, this filtering applies to the builtin versions + // of n and eq_n. This means that we may filter out a rewrite rule for one + // sygus type based on another, e.g. we won't report x=x+0 for both A and B + // in: + // A -> x | 0 | A+A + // B -> x | 0 | B+B Trace("cr-filter-debug") << "Check equal rewrite pair..." << std::endl; if (d_drewrite->areEqual(bn, beq_n)) { @@ -309,7 +315,9 @@ bool CandidateRewriteFilter::filterPair(Node n, Node eq_n) Node bni = d_drewrite->toInternal(bn); if (!bni.isNull()) { - if (!d_match_trie.getMatches(bni, &d_ssenm)) + // as with congruence filtering, we cache based on the builtin type + TypeNode tn = bn.getType(); + if (!d_match_trie[tn].getMatches(bni, &d_ssenm)) { keep = false; Trace("cr-filter") << "...redundant (matchable)" << std::endl; @@ -357,6 +365,8 @@ void CandidateRewriteFilter::registerRelevantPair(Node n, Node eq_n) } if (options::sygusRewSynthFilterMatch()) { + // cache based on the builtin type + TypeNode tn = bn.getType(); // add to match information for (unsigned r = 0; r < 2; r++) { @@ -369,7 +379,7 @@ void CandidateRewriteFilter::registerRelevantPair(Node n, Node eq_n) Node ti = d_drewrite->toInternal(t); if (!ti.isNull()) { - d_match_trie.addTerm(ti); + d_match_trie[tn].addTerm(ti); } } d_pairs[t].insert(to); diff --git a/src/theory/quantifiers/candidate_rewrite_filter.h b/src/theory/quantifiers/candidate_rewrite_filter.h index ca071faa4..af9ac6d87 100644 --- a/src/theory/quantifiers/candidate_rewrite_filter.h +++ b/src/theory/quantifiers/candidate_rewrite_filter.h @@ -2,9 +2,9 @@ /*! \file candidate_rewrite_filter.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__CANDIDATE_REWRITE_FILTER_H -#define __CVC4__THEORY__QUANTIFIERS__CANDIDATE_REWRITE_FILTER_H +#ifndef CVC4__THEORY__QUANTIFIERS__CANDIDATE_REWRITE_FILTER_H +#define CVC4__THEORY__QUANTIFIERS__CANDIDATE_REWRITE_FILTER_H #include <map> #include "theory/quantifiers/dynamic_rewrite.h" @@ -165,14 +165,16 @@ class CandidateRewriteFilter * detail, if (t,s) is a relevant pair, then t in d_pairs[s]. */ std::map<Node, std::unordered_set<Node, NodeHashFunction> > d_pairs; - /** Match trie storing all terms in the domain of d_pairs. + /** + * For each (builtin) type, a match trie storing all terms in the domain of + * d_pairs. * * Notice that we store d_drewrite->toInternal(t) instead of t, for each * term t, so that polymorphism is handled properly. In particular, this * prevents matches between terms select( x, y ) and select( z, y ) where * the type of x and z are different. */ - MatchTrie d_match_trie; + std::map<TypeNode, MatchTrie> d_match_trie; /** Notify class */ class CandidateRewriteFilterNotifyMatch : public NotifyMatch { @@ -221,4 +223,4 @@ class CandidateRewriteFilter } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__QUANTIFIERS__CANDIDATE_REWRITE_FILTER_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__CANDIDATE_REWRITE_FILTER_H */ diff --git a/src/theory/quantifiers/cegqi/ceg_arith_instantiator.cpp b/src/theory/quantifiers/cegqi/ceg_arith_instantiator.cpp index 4ea006d54..fa02c6d09 100644 --- a/src/theory/quantifiers/cegqi/ceg_arith_instantiator.cpp +++ b/src/theory/quantifiers/cegqi/ceg_arith_instantiator.cpp @@ -2,9 +2,9 @@ /*! \file ceg_arith_instantiator.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King + ** Andrew Reynolds, Morgan Deters, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/cegqi/ceg_arith_instantiator.h b/src/theory/quantifiers/cegqi/ceg_arith_instantiator.h index b6e22329d..8799ce1cd 100644 --- a/src/theory/quantifiers/cegqi/ceg_arith_instantiator.h +++ b/src/theory/quantifiers/cegqi/ceg_arith_instantiator.h @@ -2,9 +2,9 @@ /*! \file ceg_arith_instantiator.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King + ** Andrew Reynolds, Tim King, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__CEG_ARITH_INSTANTIATOR_H -#define __CVC4__THEORY__QUANTIFIERS__CEG_ARITH_INSTANTIATOR_H +#ifndef CVC4__THEORY__QUANTIFIERS__CEG_ARITH_INSTANTIATOR_H +#define CVC4__THEORY__QUANTIFIERS__CEG_ARITH_INSTANTIATOR_H #include <vector> #include "expr/node.h" @@ -203,4 +203,4 @@ class ArithInstantiator : public Instantiator } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__QUANTIFIERS__CEG_ARITH_INSTANTIATOR_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__CEG_ARITH_INSTANTIATOR_H */ diff --git a/src/theory/quantifiers/cegqi/ceg_bv_instantiator.cpp b/src/theory/quantifiers/cegqi/ceg_bv_instantiator.cpp index 272914c25..28a24d884 100644 --- a/src/theory/quantifiers/cegqi/ceg_bv_instantiator.cpp +++ b/src/theory/quantifiers/cegqi/ceg_bv_instantiator.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Mathias Preiner, Aina Niemetz ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/cegqi/ceg_bv_instantiator.h b/src/theory/quantifiers/cegqi/ceg_bv_instantiator.h index 35bc6c042..466eba6a2 100644 --- a/src/theory/quantifiers/cegqi/ceg_bv_instantiator.h +++ b/src/theory/quantifiers/cegqi/ceg_bv_instantiator.h @@ -2,9 +2,9 @@ /*! \file ceg_bv_instantiator.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Mathias Preiner, Aina Niemetz + ** Andrew Reynolds, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__CEG_BV_INSTANTIATOR_H -#define __CVC4__THEORY__QUANTIFIERS__CEG_BV_INSTANTIATOR_H +#ifndef CVC4__THEORY__QUANTIFIERS__CEG_BV_INSTANTIATOR_H +#define CVC4__THEORY__QUANTIFIERS__CEG_BV_INSTANTIATOR_H #include <unordered_map> #include "theory/quantifiers/bv_inverter.h" @@ -211,4 +211,4 @@ class BvInstantiatorPreprocess : public InstantiatorPreprocess } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__QUANTIFIERS__CEG_BV_INSTANTIATOR_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__CEG_BV_INSTANTIATOR_H */ diff --git a/src/theory/quantifiers/cegqi/ceg_bv_instantiator_utils.cpp b/src/theory/quantifiers/cegqi/ceg_bv_instantiator_utils.cpp index b74d358ac..b351dc83c 100644 --- a/src/theory/quantifiers/cegqi/ceg_bv_instantiator_utils.cpp +++ b/src/theory/quantifiers/cegqi/ceg_bv_instantiator_utils.cpp @@ -1,10 +1,10 @@ /********************* */ -/*! \file ceg_bv_instantiator.cpp +/*! \file ceg_bv_instantiator_utils.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Mathias Preiner, Aina Niemetz + ** Mathias Preiner, Aina Niemetz, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/cegqi/ceg_bv_instantiator_utils.h b/src/theory/quantifiers/cegqi/ceg_bv_instantiator_utils.h index 551ce08e0..7c72a29f2 100644 --- a/src/theory/quantifiers/cegqi/ceg_bv_instantiator_utils.h +++ b/src/theory/quantifiers/cegqi/ceg_bv_instantiator_utils.h @@ -1,10 +1,10 @@ /********************* */ -/*! \file ceg_bv_instantiator.cpp +/*! \file ceg_bv_instantiator_utils.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Mathias Preiner, Aina Niemetz + ** Mathias Preiner, Aina Niemetz, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__BV_INSTANTIATOR_UTILS_H -#define __CVC4__BV_INSTANTIATOR_UTILS_H +#ifndef CVC4__BV_INSTANTIATOR_UTILS_H +#define CVC4__BV_INSTANTIATOR_UTILS_H #include "expr/attribute.h" #include "expr/node.h" diff --git a/src/theory/quantifiers/cegqi/ceg_dt_instantiator.cpp b/src/theory/quantifiers/cegqi/ceg_dt_instantiator.cpp index e56d5f5db..0bdcbe0d7 100644 --- a/src/theory/quantifiers/cegqi/ceg_dt_instantiator.cpp +++ b/src/theory/quantifiers/cegqi/ceg_dt_instantiator.cpp @@ -2,9 +2,9 @@ /*! \file ceg_dt_instantiator.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Morgan Deters, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/cegqi/ceg_dt_instantiator.h b/src/theory/quantifiers/cegqi/ceg_dt_instantiator.h index 6cf3bdf42..cf9736abe 100644 --- a/src/theory/quantifiers/cegqi/ceg_dt_instantiator.h +++ b/src/theory/quantifiers/cegqi/ceg_dt_instantiator.h @@ -2,9 +2,9 @@ /*! \file ceg_dt_instantiator.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Mathias Preiner, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__CEG_DT_INSTANTIATOR_H -#define __CVC4__THEORY__QUANTIFIERS__CEG_DT_INSTANTIATOR_H +#ifndef CVC4__THEORY__QUANTIFIERS__CEG_DT_INSTANTIATOR_H +#define CVC4__THEORY__QUANTIFIERS__CEG_DT_INSTANTIATOR_H #include "expr/node.h" #include "theory/quantifiers/cegqi/ceg_instantiator.h" @@ -93,4 +93,4 @@ class DtInstantiator : public Instantiator } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__QUANTIFIERS__CEG_DT_INSTANTIATOR_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__CEG_DT_INSTANTIATOR_H */ diff --git a/src/theory/quantifiers/cegqi/ceg_epr_instantiator.cpp b/src/theory/quantifiers/cegqi/ceg_epr_instantiator.cpp index df6690273..f0ea7ab7b 100644 --- a/src/theory/quantifiers/cegqi/ceg_epr_instantiator.cpp +++ b/src/theory/quantifiers/cegqi/ceg_epr_instantiator.cpp @@ -2,9 +2,9 @@ /*! \file ceg_epr_instantiator.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Morgan Deters, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/cegqi/ceg_epr_instantiator.h b/src/theory/quantifiers/cegqi/ceg_epr_instantiator.h index f5057ad86..05932de7e 100644 --- a/src/theory/quantifiers/cegqi/ceg_epr_instantiator.h +++ b/src/theory/quantifiers/cegqi/ceg_epr_instantiator.h @@ -2,9 +2,9 @@ /*! \file ceg_epr_instantiator.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Mathias Preiner, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__CEG_EPR_INSTANTIATOR_H -#define __CVC4__THEORY__QUANTIFIERS__CEG_EPR_INSTANTIATOR_H +#ifndef CVC4__THEORY__QUANTIFIERS__CEG_EPR_INSTANTIATOR_H +#define CVC4__THEORY__QUANTIFIERS__CEG_EPR_INSTANTIATOR_H #include <map> #include <vector> @@ -106,4 +106,4 @@ class EprInstantiator : public Instantiator } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__QUANTIFIERS__CEG_EPR_INSTANTIATOR_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__CEG_EPR_INSTANTIATOR_H */ diff --git a/src/theory/quantifiers/cegqi/ceg_instantiator.cpp b/src/theory/quantifiers/cegqi/ceg_instantiator.cpp index 46649154e..b11358543 100644 --- a/src/theory/quantifiers/cegqi/ceg_instantiator.cpp +++ b/src/theory/quantifiers/cegqi/ceg_instantiator.cpp @@ -2,9 +2,9 @@ /*! \file ceg_instantiator.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King + ** Andrew Reynolds, Morgan Deters, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/cegqi/ceg_instantiator.h b/src/theory/quantifiers/cegqi/ceg_instantiator.h index ae191cf91..0a09f39c7 100644 --- a/src/theory/quantifiers/cegqi/ceg_instantiator.h +++ b/src/theory/quantifiers/cegqi/ceg_instantiator.h @@ -2,9 +2,9 @@ /*! \file ceg_instantiator.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Mathias Preiner + ** Andrew Reynolds, Mathias Preiner, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -15,8 +15,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__CEG_INSTANTIATOR_H -#define __CVC4__THEORY__QUANTIFIERS__CEG_INSTANTIATOR_H +#ifndef CVC4__THEORY__QUANTIFIERS__CEG_INSTANTIATOR_H +#define CVC4__THEORY__QUANTIFIERS__CEG_INSTANTIATOR_H #include "theory/quantifiers_engine.h" #include "util/statistics_registry.h" diff --git a/src/theory/quantifiers/cegqi/inst_strategy_cegqi.cpp b/src/theory/quantifiers/cegqi/inst_strategy_cegqi.cpp index 3ea3e72e4..7cfda5ba1 100644 --- a/src/theory/quantifiers/cegqi/inst_strategy_cegqi.cpp +++ b/src/theory/quantifiers/cegqi/inst_strategy_cegqi.cpp @@ -2,9 +2,9 @@ /*! \file inst_strategy_cegqi.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Morgan Deters + ** Andrew Reynolds, Morgan Deters, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/cegqi/inst_strategy_cegqi.h b/src/theory/quantifiers/cegqi/inst_strategy_cegqi.h index 0a19727b8..ebebb808d 100644 --- a/src/theory/quantifiers/cegqi/inst_strategy_cegqi.h +++ b/src/theory/quantifiers/cegqi/inst_strategy_cegqi.h @@ -2,9 +2,9 @@ /*! \file inst_strategy_cegqi.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Mathias Preiner + ** Andrew Reynolds, Mathias Preiner, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -15,8 +15,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__INST_STRATEGY_CEGQI_H -#define __CVC4__THEORY__QUANTIFIERS__INST_STRATEGY_CEGQI_H +#ifndef CVC4__THEORY__QUANTIFIERS__INST_STRATEGY_CEGQI_H +#define CVC4__THEORY__QUANTIFIERS__INST_STRATEGY_CEGQI_H #include "theory/decision_manager.h" #include "theory/quantifiers/cegqi/ceg_instantiator.h" diff --git a/src/theory/quantifiers/conjecture_generator.cpp b/src/theory/quantifiers/conjecture_generator.cpp index 7408678e7..1d9ed1639 100644 --- a/src/theory/quantifiers/conjecture_generator.cpp +++ b/src/theory/quantifiers/conjecture_generator.cpp @@ -2,9 +2,9 @@ /*! \file conjecture_generator.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Dejan Jovanovic + ** Andrew Reynolds, Aina Niemetz, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/conjecture_generator.h b/src/theory/quantifiers/conjecture_generator.h index 8fff7eafe..236c08138 100644 --- a/src/theory/quantifiers/conjecture_generator.h +++ b/src/theory/quantifiers/conjecture_generator.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Mathias Preiner, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/dynamic_rewrite.cpp b/src/theory/quantifiers/dynamic_rewrite.cpp index f48f73aee..cd73ffe33 100644 --- a/src/theory/quantifiers/dynamic_rewrite.cpp +++ b/src/theory/quantifiers/dynamic_rewrite.cpp @@ -2,9 +2,9 @@ /*! \file dynamic_rewrite.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Andres Noetzli + ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/dynamic_rewrite.h b/src/theory/quantifiers/dynamic_rewrite.h index 50bae0268..969b6bf93 100644 --- a/src/theory/quantifiers/dynamic_rewrite.h +++ b/src/theory/quantifiers/dynamic_rewrite.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__DYNAMIC_REWRITER_H -#define __CVC4__THEORY__QUANTIFIERS__DYNAMIC_REWRITER_H +#ifndef CVC4__THEORY__QUANTIFIERS__DYNAMIC_REWRITER_H +#define CVC4__THEORY__QUANTIFIERS__DYNAMIC_REWRITER_H #include <map> @@ -121,4 +121,4 @@ class DynamicRewriter } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__DYNAMIC_REWRITER_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__DYNAMIC_REWRITER_H */ diff --git a/src/theory/quantifiers/ematching/candidate_generator.cpp b/src/theory/quantifiers/ematching/candidate_generator.cpp index 612a1938a..cb0fcaf50 100644 --- a/src/theory/quantifiers/ematching/candidate_generator.cpp +++ b/src/theory/quantifiers/ematching/candidate_generator.cpp @@ -2,9 +2,9 @@ /*! \file candidate_generator.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Morgan Deters + ** Andrew Reynolds, Morgan Deters, Francois Bobot ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/ematching/candidate_generator.h b/src/theory/quantifiers/ematching/candidate_generator.h index da4ec2d83..8cff12477 100644 --- a/src/theory/quantifiers/ematching/candidate_generator.h +++ b/src/theory/quantifiers/ematching/candidate_generator.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__CANDIDATE_GENERATOR_H -#define __CVC4__THEORY__QUANTIFIERS__CANDIDATE_GENERATOR_H +#ifndef CVC4__THEORY__QUANTIFIERS__CANDIDATE_GENERATOR_H +#define CVC4__THEORY__QUANTIFIERS__CANDIDATE_GENERATOR_H #include "theory/theory.h" #include "theory/uf/equality_engine.h" @@ -212,4 +212,4 @@ class CandidateGeneratorConsExpand : public CandidateGeneratorQE }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__CANDIDATE_GENERATOR_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__CANDIDATE_GENERATOR_H */ diff --git a/src/theory/quantifiers/ematching/ho_trigger.cpp b/src/theory/quantifiers/ematching/ho_trigger.cpp index 2fcfa19d9..7598e6fdc 100644 --- a/src/theory/quantifiers/ematching/ho_trigger.cpp +++ b/src/theory/quantifiers/ematching/ho_trigger.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -270,6 +270,11 @@ bool HigherOrderTrigger::sendInstantiation(InstMatch& m) // Assert( f==value ); for (unsigned k = 0, size = args.size(); k < size; k++) { + // must now subsitute back, to handle cases like + // (@ x y) matching (@ t (@ t s)) + // where the above substitution would produce (@ x (@ x s)), + // but the argument should be (@ t s). + args[k] = args[k].substitute(var, value); Node val = args[k]; std::map<unsigned, Node>::iterator itf = fixed_vals.find(k); if (itf == fixed_vals.end()) diff --git a/src/theory/quantifiers/ematching/ho_trigger.h b/src/theory/quantifiers/ematching/ho_trigger.h index 8840c949f..6f0ff0635 100644 --- a/src/theory/quantifiers/ematching/ho_trigger.h +++ b/src/theory/quantifiers/ematching/ho_trigger.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Tim King, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__HO_TRIGGER_H -#define __CVC4__THEORY__QUANTIFIERS__HO_TRIGGER_H +#ifndef CVC4__THEORY__QUANTIFIERS__HO_TRIGGER_H +#define CVC4__THEORY__QUANTIFIERS__HO_TRIGGER_H #include <map> #include <unordered_set> @@ -275,4 +275,4 @@ class HigherOrderTrigger : public Trigger } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__HO_TRIGGER_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__HO_TRIGGER_H */ diff --git a/src/theory/quantifiers/ematching/inst_match_generator.cpp b/src/theory/quantifiers/ematching/inst_match_generator.cpp index f26df5b79..0a4386db9 100644 --- a/src/theory/quantifiers/ematching/inst_match_generator.cpp +++ b/src/theory/quantifiers/ematching/inst_match_generator.cpp @@ -2,9 +2,9 @@ /*! \file inst_match_generator.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King + ** Andrew Reynolds, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/ematching/inst_match_generator.h b/src/theory/quantifiers/ematching/inst_match_generator.h index 83d4ce82e..3995c67b4 100644 --- a/src/theory/quantifiers/ematching/inst_match_generator.h +++ b/src/theory/quantifiers/ematching/inst_match_generator.h @@ -2,9 +2,9 @@ /*! \file inst_match_generator.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Clark Barrett + ** Andrew Reynolds, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__INST_MATCH_GENERATOR_H -#define __CVC4__THEORY__QUANTIFIERS__INST_MATCH_GENERATOR_H +#ifndef CVC4__THEORY__QUANTIFIERS__INST_MATCH_GENERATOR_H +#define CVC4__THEORY__QUANTIFIERS__INST_MATCH_GENERATOR_H #include <map> #include "expr/node_trie.h" diff --git a/src/theory/quantifiers/ematching/inst_strategy_e_matching.cpp b/src/theory/quantifiers/ematching/inst_strategy_e_matching.cpp index 6784fb8e3..8f671fb55 100644 --- a/src/theory/quantifiers/ematching/inst_strategy_e_matching.cpp +++ b/src/theory/quantifiers/ematching/inst_strategy_e_matching.cpp @@ -2,9 +2,9 @@ /*! \file inst_strategy_e_matching.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Morgan Deters + ** Andrew Reynolds, Morgan Deters, Aina Niemetz ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/ematching/inst_strategy_e_matching.h b/src/theory/quantifiers/ematching/inst_strategy_e_matching.h index a8d53cf4b..5eb992368 100644 --- a/src/theory/quantifiers/ematching/inst_strategy_e_matching.h +++ b/src/theory/quantifiers/ematching/inst_strategy_e_matching.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters, Andrew Reynolds, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__INST_STRATEGY_E_MATCHING_H -#define __CVC4__INST_STRATEGY_E_MATCHING_H +#ifndef CVC4__INST_STRATEGY_E_MATCHING_H +#define CVC4__INST_STRATEGY_E_MATCHING_H #include "context/context.h" #include "context/context_mm.h" diff --git a/src/theory/quantifiers/ematching/instantiation_engine.cpp b/src/theory/quantifiers/ematching/instantiation_engine.cpp index 2aa8af53d..d2650f01f 100644 --- a/src/theory/quantifiers/ematching/instantiation_engine.cpp +++ b/src/theory/quantifiers/ematching/instantiation_engine.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/ematching/instantiation_engine.h b/src/theory/quantifiers/ematching/instantiation_engine.h index c94320b74..139adcb04 100644 --- a/src/theory/quantifiers/ematching/instantiation_engine.h +++ b/src/theory/quantifiers/ematching/instantiation_engine.h @@ -2,9 +2,9 @@ /*! \file instantiation_engine.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Morgan Deters, Tim King + ** Andrew Reynolds, Morgan Deters, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__INSTANTIATION_ENGINE_H -#define __CVC4__THEORY__QUANTIFIERS__INSTANTIATION_ENGINE_H +#ifndef CVC4__THEORY__QUANTIFIERS__INSTANTIATION_ENGINE_H +#define CVC4__THEORY__QUANTIFIERS__INSTANTIATION_ENGINE_H #include <memory> @@ -95,4 +95,4 @@ class InstantiationEngine : public QuantifiersModule { }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__INSTANTIATION_ENGINE_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__INSTANTIATION_ENGINE_H */ diff --git a/src/theory/quantifiers/ematching/trigger.cpp b/src/theory/quantifiers/ematching/trigger.cpp index b50deea11..31bd1aa96 100644 --- a/src/theory/quantifiers/ematching/trigger.cpp +++ b/src/theory/quantifiers/ematching/trigger.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/ematching/trigger.h b/src/theory/quantifiers/ematching/trigger.h index bbd7c386b..f276585d6 100644 --- a/src/theory/quantifiers/ematching/trigger.h +++ b/src/theory/quantifiers/ematching/trigger.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__TRIGGER_H -#define __CVC4__THEORY__QUANTIFIERS__TRIGGER_H +#ifndef CVC4__THEORY__QUANTIFIERS__TRIGGER_H +#define CVC4__THEORY__QUANTIFIERS__TRIGGER_H #include <map> @@ -464,4 +464,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__TRIGGER_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__TRIGGER_H */ diff --git a/src/theory/quantifiers/equality_infer.cpp b/src/theory/quantifiers/equality_infer.cpp index f4a4a34a7..ef80af5f5 100644 --- a/src/theory/quantifiers/equality_infer.cpp +++ b/src/theory/quantifiers/equality_infer.cpp @@ -2,9 +2,9 @@ /*! \file equality_infer.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Morgan Deters, Tianyi Liang ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/equality_infer.h b/src/theory/quantifiers/equality_infer.h index 49d208d99..69cd12a70 100644 --- a/src/theory/quantifiers/equality_infer.h +++ b/src/theory/quantifiers/equality_infer.h @@ -2,9 +2,9 @@ /*! \file equality_infer.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Andres Noetzli + ** Andrew Reynolds, Morgan Deters, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__EQUALITY_INFER_H -#define __CVC4__THEORY__QUANTIFIERS__EQUALITY_INFER_H +#ifndef CVC4__THEORY__QUANTIFIERS__EQUALITY_INFER_H +#define CVC4__THEORY__QUANTIFIERS__EQUALITY_INFER_H #include <iostream> #include <map> diff --git a/src/theory/quantifiers/equality_query.cpp b/src/theory/quantifiers/equality_query.cpp index ae560c5e5..030b0dccb 100644 --- a/src/theory/quantifiers/equality_query.cpp +++ b/src/theory/quantifiers/equality_query.cpp @@ -2,9 +2,9 @@ /*! \file equality_query.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/equality_query.h b/src/theory/quantifiers/equality_query.h index 8f836f9c6..e4eeeffa7 100644 --- a/src/theory/quantifiers/equality_query.h +++ b/src/theory/quantifiers/equality_query.h @@ -2,9 +2,9 @@ /*! \file equality_query.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Mathias Preiner + ** Andrew Reynolds, Mathias Preiner, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS_EQUALITY_QUERY_H -#define __CVC4__THEORY__QUANTIFIERS_EQUALITY_QUERY_H +#ifndef CVC4__THEORY__QUANTIFIERS_EQUALITY_QUERY_H +#define CVC4__THEORY__QUANTIFIERS_EQUALITY_QUERY_H #include "context/cdo.h" #include "context/context.h" @@ -120,4 +120,4 @@ class EqualityQueryQuantifiersEngine : public EqualityQuery }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS_EQUALITY_QUERY_H */ +#endif /* CVC4__THEORY__QUANTIFIERS_EQUALITY_QUERY_H */ diff --git a/src/theory/quantifiers/expr_miner.cpp b/src/theory/quantifiers/expr_miner.cpp index b65d1c522..98d07fdea 100644 --- a/src/theory/quantifiers/expr_miner.cpp +++ b/src/theory/quantifiers/expr_miner.cpp @@ -2,9 +2,9 @@ /*! \file expr_miner.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -87,9 +87,11 @@ void ExprMiner::initializeChecker(std::unique_ptr<SmtEngine>& checker, try { checker.reset(new SmtEngine(&em)); + checker->setIsInternalSubsolver(); checker->setTimeLimit(options::sygusExprMinerCheckTimeout(), true); checker->setLogic(smt::currentSmtEngine()->getLogicInfo()); checker->setOption("sygus-rr-synth-input", false); + checker->setOption("sygus-abduct", false); checker->setOption("input-language", "smt2"); Expr equery = squery.toExpr().exportTo(&em, varMap); checker->assertFormula(equery); @@ -129,9 +131,9 @@ Result ExprMiner::doCheck(Node query) } NodeManager* nm = NodeManager::currentNM(); bool needExport = false; - ExprManagerMapCollection varMap; ExprManager em(nm->getOptions()); std::unique_ptr<SmtEngine> smte; + ExprManagerMapCollection varMap; initializeChecker(smte, em, varMap, queryr, needExport); return smte->checkSat(); } diff --git a/src/theory/quantifiers/expr_miner.h b/src/theory/quantifiers/expr_miner.h index 59d9989c5..233ef39f7 100644 --- a/src/theory/quantifiers/expr_miner.h +++ b/src/theory/quantifiers/expr_miner.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__EXPRESSION_MINER_H -#define __CVC4__THEORY__QUANTIFIERS__EXPRESSION_MINER_H +#ifndef CVC4__THEORY__QUANTIFIERS__EXPRESSION_MINER_H +#define CVC4__THEORY__QUANTIFIERS__EXPRESSION_MINER_H #include <map> #include <memory> @@ -106,4 +106,4 @@ class ExprMiner } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__QUANTIFIERS__EXPRESSION_MINER_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__EXPRESSION_MINER_H */ diff --git a/src/theory/quantifiers/expr_miner_manager.cpp b/src/theory/quantifiers/expr_miner_manager.cpp index a808d386c..3db0e14ab 100644 --- a/src/theory/quantifiers/expr_miner_manager.cpp +++ b/src/theory/quantifiers/expr_miner_manager.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -15,6 +15,8 @@ #include "theory/quantifiers/expr_miner_manager.h" #include "theory/quantifiers_engine.h" +#include "options/quantifiers_options.h" + namespace CVC4 { namespace theory { namespace quantifiers { @@ -140,7 +142,7 @@ bool ExpressionMinerManager::addTerm(Node sol, bool ret = true; if (d_doRewSynth) { - ret = d_crd.addTerm(sol, out, rew_print); + ret = d_crd.addTerm(sol, options::sygusRewSynthRec(), out, rew_print); } // a unique term, let's try the query generator diff --git a/src/theory/quantifiers/expr_miner_manager.h b/src/theory/quantifiers/expr_miner_manager.h index d817d3775..1c8aab826 100644 --- a/src/theory/quantifiers/expr_miner_manager.h +++ b/src/theory/quantifiers/expr_miner_manager.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__EXPR_MINER_MANAGER_H -#define __CVC4__THEORY__QUANTIFIERS__EXPR_MINER_MANAGER_H +#ifndef CVC4__THEORY__QUANTIFIERS__EXPR_MINER_MANAGER_H +#define CVC4__THEORY__QUANTIFIERS__EXPR_MINER_MANAGER_H #include "expr/node.h" #include "theory/quantifiers/candidate_rewrite_database.h" @@ -120,4 +120,4 @@ class ExpressionMinerManager } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__QUANTIFIERS__EXPR_MINER_MANAGER_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__EXPR_MINER_MANAGER_H */ diff --git a/src/theory/quantifiers/extended_rewrite.cpp b/src/theory/quantifiers/extended_rewrite.cpp index 46dcb7151..0fbd971fd 100644 --- a/src/theory/quantifiers/extended_rewrite.cpp +++ b/src/theory/quantifiers/extended_rewrite.cpp @@ -2,9 +2,9 @@ /*! \file extended_rewrite.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/extended_rewrite.h b/src/theory/quantifiers/extended_rewrite.h index da77bda51..836e15b7b 100644 --- a/src/theory/quantifiers/extended_rewrite.h +++ b/src/theory/quantifiers/extended_rewrite.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__EXTENDED_REWRITE_H -#define __CVC4__THEORY__QUANTIFIERS__EXTENDED_REWRITE_H +#ifndef CVC4__THEORY__QUANTIFIERS__EXTENDED_REWRITE_H +#define CVC4__THEORY__QUANTIFIERS__EXTENDED_REWRITE_H #include <unordered_map> @@ -250,4 +250,4 @@ class ExtendedRewriter } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__EXTENDED_REWRITE_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__EXTENDED_REWRITE_H */ diff --git a/src/theory/quantifiers/first_order_model.cpp b/src/theory/quantifiers/first_order_model.cpp index 5eb65ed21..5428d9f1a 100644 --- a/src/theory/quantifiers/first_order_model.cpp +++ b/src/theory/quantifiers/first_order_model.cpp @@ -2,9 +2,9 @@ /*! \file first_order_model.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Morgan Deters + ** Andrew Reynolds, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/first_order_model.h b/src/theory/quantifiers/first_order_model.h index b96b42dc2..bdf1d7c15 100644 --- a/src/theory/quantifiers/first_order_model.h +++ b/src/theory/quantifiers/first_order_model.h @@ -2,9 +2,9 @@ /*! \file first_order_model.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Paul Meng + ** Andrew Reynolds, Paul Meng, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__FIRST_ORDER_MODEL_H -#define __CVC4__FIRST_ORDER_MODEL_H +#ifndef CVC4__FIRST_ORDER_MODEL_H +#define CVC4__FIRST_ORDER_MODEL_H #include "theory/theory_model.h" #include "theory/uf/theory_uf_model.h" @@ -218,4 +218,4 @@ class FirstOrderModelFmc : public FirstOrderModel }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__FIRST_ORDER_MODEL_H */ +#endif /* CVC4__FIRST_ORDER_MODEL_H */ diff --git a/src/theory/quantifiers/fmf/bounded_integers.cpp b/src/theory/quantifiers/fmf/bounded_integers.cpp index cafa4a749..e15fc85bb 100644 --- a/src/theory/quantifiers/fmf/bounded_integers.cpp +++ b/src/theory/quantifiers/fmf/bounded_integers.cpp @@ -2,9 +2,9 @@ /*! \file bounded_integers.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Morgan Deters, Tim King + ** Andrew Reynolds, Andres Noetzli, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/fmf/bounded_integers.h b/src/theory/quantifiers/fmf/bounded_integers.h index b3132a4a7..55ed5bdd2 100644 --- a/src/theory/quantifiers/fmf/bounded_integers.h +++ b/src/theory/quantifiers/fmf/bounded_integers.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -15,8 +15,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__BOUNDED_INTEGERS_H -#define __CVC4__BOUNDED_INTEGERS_H +#ifndef CVC4__BOUNDED_INTEGERS_H +#define CVC4__BOUNDED_INTEGERS_H #include "theory/quantifiers_engine.h" diff --git a/src/theory/quantifiers/fmf/full_model_check.cpp b/src/theory/quantifiers/fmf/full_model_check.cpp index 481048105..ace5c2b26 100644 --- a/src/theory/quantifiers/fmf/full_model_check.cpp +++ b/src/theory/quantifiers/fmf/full_model_check.cpp @@ -2,9 +2,9 @@ /*! \file full_model_check.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Kshitij Bansal + ** Andrew Reynolds, Morgan Deters, Francois Bobot ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/fmf/full_model_check.h b/src/theory/quantifiers/fmf/full_model_check.h index f0f9a1798..7dd1991f5 100644 --- a/src/theory/quantifiers/fmf/full_model_check.h +++ b/src/theory/quantifiers/fmf/full_model_check.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Morgan Deters, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__FULL_MODEL_CHECK_H -#define __CVC4__THEORY__QUANTIFIERS__FULL_MODEL_CHECK_H +#ifndef CVC4__THEORY__QUANTIFIERS__FULL_MODEL_CHECK_H +#define CVC4__THEORY__QUANTIFIERS__FULL_MODEL_CHECK_H #include "theory/quantifiers/fmf/model_builder.h" #include "theory/quantifiers/first_order_model.h" @@ -162,4 +162,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__FULL_MODEL_CHECK_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__FULL_MODEL_CHECK_H */ diff --git a/src/theory/quantifiers/fmf/model_builder.cpp b/src/theory/quantifiers/fmf/model_builder.cpp index 8ef30fc4d..51cd8481f 100644 --- a/src/theory/quantifiers/fmf/model_builder.cpp +++ b/src/theory/quantifiers/fmf/model_builder.cpp @@ -2,9 +2,9 @@ /*! \file model_builder.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Morgan Deters + ** Andrew Reynolds, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/fmf/model_builder.h b/src/theory/quantifiers/fmf/model_builder.h index b73716169..1b4d24779 100644 --- a/src/theory/quantifiers/fmf/model_builder.h +++ b/src/theory/quantifiers/fmf/model_builder.h @@ -2,9 +2,9 @@ /*! \file model_builder.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Mathias Preiner + ** Andrew Reynolds, Morgan Deters, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__MODEL_BUILDER_H -#define __CVC4__THEORY__QUANTIFIERS__MODEL_BUILDER_H +#ifndef CVC4__THEORY__QUANTIFIERS__MODEL_BUILDER_H +#define CVC4__THEORY__QUANTIFIERS__MODEL_BUILDER_H #include "theory/quantifiers_engine.h" #include "theory/theory_model_builder.h" @@ -60,4 +60,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__MODEL_BUILDER_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__MODEL_BUILDER_H */ diff --git a/src/theory/quantifiers/fmf/model_engine.cpp b/src/theory/quantifiers/fmf/model_engine.cpp index d2579b4ee..5609cade6 100644 --- a/src/theory/quantifiers/fmf/model_engine.cpp +++ b/src/theory/quantifiers/fmf/model_engine.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Morgan Deters, Kshitij Bansal ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -266,7 +266,8 @@ void ModelEngine::exhaustiveInstantiate( Node f, int effort ){ } d_triedLemmas += mb->getNumTriedLemmas()-prev_tlem; d_addedLemmas += mb->getNumAddedLemmas()-prev_alem; - d_quantEngine->d_statistics.d_instantiations_fmf_mbqi += mb->getNumAddedLemmas(); + d_quantEngine->d_statistics.d_instantiations_fmf_mbqi += + (mb->getNumAddedLemmas() - prev_alem); }else{ if( Trace.isOn("fmf-exh-inst-debug") ){ Trace("fmf-exh-inst-debug") << " Instantiation Constants: "; diff --git a/src/theory/quantifiers/fmf/model_engine.h b/src/theory/quantifiers/fmf/model_engine.h index a11115f33..41bc312e7 100644 --- a/src/theory/quantifiers/fmf/model_engine.h +++ b/src/theory/quantifiers/fmf/model_engine.h @@ -2,9 +2,9 @@ /*! \file model_engine.h ** \verbatim ** Top contributors (to current version): - ** Morgan Deters, Andrew Reynolds, Mathias Preiner + ** Andrew Reynolds, Morgan Deters, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__MODEL_ENGINE_H -#define __CVC4__THEORY__QUANTIFIERS__MODEL_ENGINE_H +#ifndef CVC4__THEORY__QUANTIFIERS__MODEL_ENGINE_H +#define CVC4__THEORY__QUANTIFIERS__MODEL_ENGINE_H #include "theory/quantifiers_engine.h" #include "theory/quantifiers/fmf/model_builder.h" @@ -67,4 +67,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__MODEL_ENGINE_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__MODEL_ENGINE_H */ diff --git a/src/theory/quantifiers/fun_def_process.cpp b/src/theory/quantifiers/fun_def_process.cpp index 1671fa1a0..185a349c0 100644 --- a/src/theory/quantifiers/fun_def_process.cpp +++ b/src/theory/quantifiers/fun_def_process.cpp @@ -2,9 +2,9 @@ /*! \file fun_def_process.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/fun_def_process.h b/src/theory/quantifiers/fun_def_process.h index 78adc710c..0282f0e40 100644 --- a/src/theory/quantifiers/fun_def_process.h +++ b/src/theory/quantifiers/fun_def_process.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__QUANTIFIERS_FUN_DEF_PROCESS_H -#define __CVC4__QUANTIFIERS_FUN_DEF_PROCESS_H +#ifndef CVC4__QUANTIFIERS_FUN_DEF_PROCESS_H +#define CVC4__QUANTIFIERS_FUN_DEF_PROCESS_H #include <iostream> #include <string> diff --git a/src/theory/quantifiers/inst_match.cpp b/src/theory/quantifiers/inst_match.cpp index a16e03420..069d5b888 100644 --- a/src/theory/quantifiers/inst_match.cpp +++ b/src/theory/quantifiers/inst_match.cpp @@ -2,9 +2,9 @@ /*! \file inst_match.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Morgan Deters, Clark Barrett + ** Andrew Reynolds, Morgan Deters, Francois Bobot ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/inst_match.h b/src/theory/quantifiers/inst_match.h index 5695d1294..d298c43a8 100644 --- a/src/theory/quantifiers/inst_match.h +++ b/src/theory/quantifiers/inst_match.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Morgan Deters, Francois Bobot ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__INST_MATCH_H -#define __CVC4__THEORY__QUANTIFIERS__INST_MATCH_H +#ifndef CVC4__THEORY__QUANTIFIERS__INST_MATCH_H +#define CVC4__THEORY__QUANTIFIERS__INST_MATCH_H #include <vector> @@ -102,4 +102,4 @@ typedef CVC4::theory::inst::InstMatch InstMatch; }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__INST_MATCH_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__INST_MATCH_H */ diff --git a/src/theory/quantifiers/inst_match_trie.cpp b/src/theory/quantifiers/inst_match_trie.cpp index aba4a3b5e..8b8689835 100644 --- a/src/theory/quantifiers/inst_match_trie.cpp +++ b/src/theory/quantifiers/inst_match_trie.cpp @@ -2,9 +2,9 @@ /*! \file inst_match_trie.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/inst_match_trie.h b/src/theory/quantifiers/inst_match_trie.h index 50df50786..4854616db 100644 --- a/src/theory/quantifiers/inst_match_trie.h +++ b/src/theory/quantifiers/inst_match_trie.h @@ -2,9 +2,9 @@ /*! \file inst_match_trie.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__INST_MATCH_TRIE_H -#define __CVC4__THEORY__QUANTIFIERS__INST_MATCH_TRIE_H +#ifndef CVC4__THEORY__QUANTIFIERS__INST_MATCH_TRIE_H +#define CVC4__THEORY__QUANTIFIERS__INST_MATCH_TRIE_H #include <map> @@ -436,4 +436,4 @@ class InstMatchTrieOrdered } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__INST_MATCH_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__INST_MATCH_H */ diff --git a/src/theory/quantifiers/inst_propagator.cpp b/src/theory/quantifiers/inst_propagator.cpp index 15dd35c26..56be1506c 100644 --- a/src/theory/quantifiers/inst_propagator.cpp +++ b/src/theory/quantifiers/inst_propagator.cpp @@ -2,9 +2,9 @@ /*! \file inst_propagator.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King + ** Andrew Reynolds, Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/inst_propagator.h b/src/theory/quantifiers/inst_propagator.h index 1ba359228..d45b078ce 100644 --- a/src/theory/quantifiers/inst_propagator.h +++ b/src/theory/quantifiers/inst_propagator.h @@ -2,9 +2,9 @@ /*! \file inst_propagator.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Mathias Preiner + ** Andrew Reynolds, Mathias Preiner, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__QUANTIFIERS_INST_PROPAGATOR_H -#define __CVC4__QUANTIFIERS_INST_PROPAGATOR_H +#ifndef CVC4__QUANTIFIERS_INST_PROPAGATOR_H +#define CVC4__QUANTIFIERS_INST_PROPAGATOR_H #include <iostream> #include <map> diff --git a/src/theory/quantifiers/inst_strategy_enumerative.cpp b/src/theory/quantifiers/inst_strategy_enumerative.cpp index 9d70d0d4b..7a2f62864 100644 --- a/src/theory/quantifiers/inst_strategy_enumerative.cpp +++ b/src/theory/quantifiers/inst_strategy_enumerative.cpp @@ -2,9 +2,9 @@ /*! \file inst_strategy_enumerative.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -70,46 +70,89 @@ void InstStrategyEnum::check(Theory::Effort e, QEffort quant_e) doCheck = quant_e == QEFFORT_LAST_CALL; fullEffort = !d_quantEngine->hasAddedLemma(); } - if (doCheck) + if (!doCheck) { - double clSet = 0; - if (Trace.isOn("fs-engine")) - { - clSet = double(clock()) / double(CLOCKS_PER_SEC); - Trace("fs-engine") << "---Full Saturation Round, effort = " << e << "---" - << std::endl; - } - int addedLemmas = 0; - for (unsigned i = 0; - i < d_quantEngine->getModel()->getNumAssertedQuantifiers(); - i++) + return; + } + double clSet = 0; + if (Trace.isOn("fs-engine")) + { + clSet = double(clock()) / double(CLOCKS_PER_SEC); + Trace("fs-engine") << "---Full Saturation Round, effort = " << e << "---" + << std::endl; + } + unsigned rstart = options::fullSaturateQuantRd() ? 0 : 1; + unsigned rend = fullEffort ? 1 : rstart; + unsigned addedLemmas = 0; + // First try in relevant domain of all quantified formulas, if no + // instantiations exist, try arbitrary ground terms. + // Notice that this stratification of effort levels makes it so that some + // quantified formulas may not be instantiated (if they have no instances + // at effort level r=0 but another quantified formula does). We prefer + // this stratification since effort level r=1 may be highly expensive in the + // case where we have a quantified formula with many entailed instances. + FirstOrderModel* fm = d_quantEngine->getModel(); + RelevantDomain* rd = d_quantEngine->getRelevantDomain(); + unsigned nquant = fm->getNumAssertedQuantifiers(); + std::map<Node, bool> alreadyProc; + for (unsigned r = rstart; r <= rend; r++) + { + if (rd || r > 0) { - Node q = d_quantEngine->getModel()->getAssertedQuantifier(i, true); - if (d_quantEngine->hasOwnership(q, this) - && d_quantEngine->getModel()->isQuantifierActive(q)) + if (r == 0) + { + Trace("inst-alg") << "-> Relevant domain instantiate..." << std::endl; + Trace("inst-alg-debug") << "Compute relevant domain..." << std::endl; + rd->compute(); + Trace("inst-alg-debug") << "...finished" << std::endl; + } + else + { + Trace("inst-alg") << "-> Ground term instantiate..." << std::endl; + } + for (unsigned i = 0; i < nquant; i++) { - if (process(q, fullEffort)) + Node q = fm->getAssertedQuantifier(i, true); + bool doProcess = d_quantEngine->hasOwnership(q, this) + && fm->isQuantifierActive(q) + && alreadyProc.find(q) == alreadyProc.end(); + if (doProcess) { - // added lemma - addedLemmas++; - if (d_quantEngine->inConflict()) + if (process(q, fullEffort, r == 0)) { - break; + // don't need to mark this if we are not stratifying + if (!options::fullSaturateStratify()) + { + alreadyProc[q] = true; + } + // added lemma + addedLemmas++; + if (d_quantEngine->inConflict()) + { + break; + } } } } + if (d_quantEngine->inConflict() + || (addedLemmas > 0 && options::fullSaturateStratify())) + { + // we break if we are in conflict, or if we added any lemma at this + // effort level and we stratify effort levels. + break; + } } - if (Trace.isOn("fs-engine")) - { - Trace("fs-engine") << "Added lemmas = " << addedLemmas << std::endl; - double clSet2 = double(clock()) / double(CLOCKS_PER_SEC); - Trace("fs-engine") << "Finished full saturation engine, time = " - << (clSet2 - clSet) << std::endl; - } + } + if (Trace.isOn("fs-engine")) + { + Trace("fs-engine") << "Added lemmas = " << addedLemmas << std::endl; + double clSet2 = double(clock()) / double(CLOCKS_PER_SEC); + Trace("fs-engine") << "Finished full saturation engine, time = " + << (clSet2 - clSet) << std::endl; } } -bool InstStrategyEnum::process(Node f, bool fullEffort) +bool InstStrategyEnum::process(Node f, bool fullEffort, bool isRd) { // ignore if constant true (rare case of non-standard quantifier whose body is // rewritten to true) @@ -117,178 +160,156 @@ bool InstStrategyEnum::process(Node f, bool fullEffort) { return false; } - // first, try from relevant domain RelevantDomain* rd = d_quantEngine->getRelevantDomain(); - unsigned rstart = options::fullSaturateQuantRd() ? 0 : 1; - unsigned rend = fullEffort ? 1 : rstart; - for (unsigned r = rstart; r <= rend; r++) + unsigned final_max_i = 0; + std::vector<unsigned> maxs; + std::vector<bool> max_zero; + bool has_zero = false; + std::map<TypeNode, std::vector<Node> > term_db_list; + std::vector<TypeNode> ftypes; + TermDb* tdb = d_quantEngine->getTermDatabase(); + EqualityQuery* qy = d_quantEngine->getEqualityQuery(); + // iterate over substitutions for variables + for (unsigned i = 0; i < f[0].getNumChildren(); i++) { - if (rd || r > 0) + TypeNode tn = f[0][i].getType(); + ftypes.push_back(tn); + unsigned ts; + if (isRd) { - if (r == 0) + ts = rd->getRDomain(f, i)->d_terms.size(); + } + else + { + ts = tdb->getNumTypeGroundTerms(tn); + std::map<TypeNode, std::vector<Node> >::iterator ittd = + term_db_list.find(tn); + if (ittd == term_db_list.end()) { - Trace("inst-alg") << "-> Relevant domain instantiate " << f << "..." - << std::endl; - Trace("inst-alg-debug") << "Compute relevant domain..." << std::endl; - rd->compute(); - Trace("inst-alg-debug") << "...finished" << std::endl; + std::map<Node, Node> reps_found; + for (unsigned j = 0; j < ts; j++) + { + Node gt = tdb->getTypeGroundTerm(ftypes[i], j); + if (!options::cbqi() || !quantifiers::TermUtil::hasInstConstAttr(gt)) + { + Node rep = qy->getRepresentative(gt); + if (reps_found.find(rep) == reps_found.end()) + { + reps_found[rep] = gt; + term_db_list[tn].push_back(gt); + } + } + } + ts = term_db_list[tn].size(); } else { - Trace("inst-alg") << "-> Ground term instantiate " << f << "..." - << std::endl; + ts = ittd->second.size(); } - unsigned final_max_i = 0; - std::vector<unsigned> maxs; - std::vector<bool> max_zero; - bool has_zero = false; - std::map<TypeNode, std::vector<Node> > term_db_list; - std::vector<TypeNode> ftypes; - // iterate over substitutions for variables - for (unsigned i = 0; i < f[0].getNumChildren(); i++) + } + // consider a default value if at full effort + max_zero.push_back(fullEffort && ts == 0); + ts = (fullEffort && ts == 0) ? 1 : ts; + Trace("inst-alg-rd") << "Variable " << i << " has " << ts + << " in relevant domain." << std::endl; + if (ts == 0) + { + has_zero = true; + break; + } + maxs.push_back(ts); + if (ts > final_max_i) + { + final_max_i = ts; + } + } + if (!has_zero) + { + Trace("inst-alg-rd") << "Will do " << final_max_i + << " stages of instantiation." << std::endl; + unsigned max_i = 0; + bool success; + Instantiate* ie = d_quantEngine->getInstantiate(); + while (max_i <= final_max_i) + { + Trace("inst-alg-rd") << "Try stage " << max_i << "..." << std::endl; + std::vector<unsigned> childIndex; + int index = 0; + do { - TypeNode tn = f[0][i].getType(); - ftypes.push_back(tn); - unsigned ts; - if (r == 0) - { - ts = rd->getRDomain(f, i)->d_terms.size(); - } - else + while (index >= 0 && index < (int)f[0].getNumChildren()) { - ts = d_quantEngine->getTermDatabase()->getNumTypeGroundTerms(tn); - std::map<TypeNode, std::vector<Node> >::iterator ittd = - term_db_list.find(tn); - if (ittd == term_db_list.end()) + if (index == static_cast<int>(childIndex.size())) { - std::map<Node, Node> reps_found; - for (unsigned j = 0; j < ts; j++) - { - Node gt = d_quantEngine->getTermDatabase()->getTypeGroundTerm( - ftypes[i], j); - if (!options::cbqi() - || !quantifiers::TermUtil::hasInstConstAttr(gt)) - { - Node rep = - d_quantEngine->getEqualityQuery()->getRepresentative(gt); - if (reps_found.find(rep) == reps_found.end()) - { - reps_found[rep] = gt; - term_db_list[tn].push_back(gt); - } - } - } - ts = term_db_list[tn].size(); + childIndex.push_back(-1); } else { - ts = ittd->second.size(); + Assert(index == static_cast<int>(childIndex.size()) - 1); + unsigned nv = childIndex[index] + 1; + if (nv < maxs[index] && nv <= max_i) + { + childIndex[index] = nv; + index++; + } + else + { + childIndex.pop_back(); + index--; + } } } - // consider a default value if at full effort - max_zero.push_back(fullEffort && ts == 0); - ts = (fullEffort && ts == 0) ? 1 : ts; - Trace("inst-alg-rd") << "Variable " << i << " has " << ts - << " in relevant domain." << std::endl; - if (ts == 0) + success = index >= 0; + if (success) { - has_zero = true; - break; - } - else - { - maxs.push_back(ts); - if (ts > final_max_i) + if (Trace.isOn("inst-alg-rd")) { - final_max_i = ts; + Trace("inst-alg-rd") << "Try instantiation { "; + for (unsigned i : childIndex) + { + Trace("inst-alg-rd") << i << " "; + } + Trace("inst-alg-rd") << "}" << std::endl; } - } - } - if (!has_zero) - { - Trace("inst-alg-rd") << "Will do " << final_max_i - << " stages of instantiation." << std::endl; - unsigned max_i = 0; - bool success; - while (max_i <= final_max_i) - { - Trace("inst-alg-rd") << "Try stage " << max_i << "..." << std::endl; - std::vector<unsigned> childIndex; - int index = 0; - do + // try instantiation + std::vector<Node> terms; + for (unsigned i = 0, nchild = f[0].getNumChildren(); i < nchild; i++) { - while (index >= 0 && index < (int)f[0].getNumChildren()) + if (max_zero[i]) { - if (index == (int)childIndex.size()) - { - childIndex.push_back(-1); - } - else - { - Assert(index == (int)(childIndex.size()) - 1); - unsigned nv = childIndex[index] + 1; - if (nv < maxs[index] && nv <= max_i) - { - childIndex[index] = nv; - index++; - } - else - { - childIndex.pop_back(); - index--; - } - } + // no terms available, will report incomplete instantiation + terms.push_back(Node::null()); + Trace("inst-alg-rd") << " null" << std::endl; } - success = index >= 0; - if (success) + else if (isRd) { - Trace("inst-alg-rd") << "Try instantiation { "; - for (unsigned j = 0; j < childIndex.size(); j++) - { - Trace("inst-alg-rd") << childIndex[j] << " "; - } - Trace("inst-alg-rd") << "}" << std::endl; - // try instantiation - std::vector<Node> terms; - for (unsigned i = 0; i < f[0].getNumChildren(); i++) - { - if (max_zero[i]) - { - // no terms available, will report incomplete instantiation - terms.push_back(Node::null()); - Trace("inst-alg-rd") << " null" << std::endl; - } - else if (r == 0) - { - terms.push_back(rd->getRDomain(f, i)->d_terms[childIndex[i]]); - Trace("inst-alg-rd") - << " " << rd->getRDomain(f, i)->d_terms[childIndex[i]] - << std::endl; - } - else - { - Assert(childIndex[i] < term_db_list[ftypes[i]].size()); - terms.push_back(term_db_list[ftypes[i]][childIndex[i]]); - Trace("inst-alg-rd") << " " - << term_db_list[ftypes[i]][childIndex[i]] - << std::endl; - } - } - if (d_quantEngine->getInstantiate()->addInstantiation(f, terms)) - { - Trace("inst-alg-rd") << "Success!" << std::endl; - ++(d_quantEngine->d_statistics.d_instantiations_guess); - return true; - } - else - { - index--; - } + terms.push_back(rd->getRDomain(f, i)->d_terms[childIndex[i]]); + Trace("inst-alg-rd") + << " " << rd->getRDomain(f, i)->d_terms[childIndex[i]] + << std::endl; } - } while (success); - max_i++; + else + { + Assert(childIndex[i] < term_db_list[ftypes[i]].size()); + terms.push_back(term_db_list[ftypes[i]][childIndex[i]]); + Trace("inst-alg-rd") + << " " << term_db_list[ftypes[i]][childIndex[i]] + << std::endl; + } + } + if (ie->addInstantiation(f, terms)) + { + Trace("inst-alg-rd") << "Success!" << std::endl; + ++(d_quantEngine->d_statistics.d_instantiations_guess); + return true; + } + else + { + index--; + } } - } + } while (success); + max_i++; } } // TODO : term enumerator instantiation? diff --git a/src/theory/quantifiers/inst_strategy_enumerative.h b/src/theory/quantifiers/inst_strategy_enumerative.h index be0f452e4..920e643bc 100644 --- a/src/theory/quantifiers/inst_strategy_enumerative.h +++ b/src/theory/quantifiers/inst_strategy_enumerative.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__INST_STRATEGY_ENUMERATIVE_H -#define __CVC4__INST_STRATEGY_ENUMERATIVE_H +#ifndef CVC4__INST_STRATEGY_ENUMERATIVE_H +#define CVC4__INST_STRATEGY_ENUMERATIVE_H #include "context/context.h" #include "context/context_mm.h" @@ -92,8 +92,12 @@ class InstStrategyEnum : public QuantifiersModule * well-typed term *not* occurring in the current context. * This handles corner cases where there are no well-typed * ground terms in the current context to instantiate with. + * + * The flag isRd indicates whether we are trying relevant domain + * instantiations. If this flag is false, we are trying arbitrary ground + * term instantiations. */ - bool process(Node q, bool fullEffort); + bool process(Node q, bool fullEffort, bool isRd); }; /* class InstStrategyEnum */ } /* CVC4::theory::quantifiers namespace */ diff --git a/src/theory/quantifiers/instantiate.cpp b/src/theory/quantifiers/instantiate.cpp index 96a28cde6..623db032a 100644 --- a/src/theory/quantifiers/instantiate.cpp +++ b/src/theory/quantifiers/instantiate.cpp @@ -2,9 +2,9 @@ /*! \file instantiate.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/instantiate.h b/src/theory/quantifiers/instantiate.h index 62e0ddb55..2fdb494e9 100644 --- a/src/theory/quantifiers/instantiate.h +++ b/src/theory/quantifiers/instantiate.h @@ -2,9 +2,9 @@ /*! \file instantiate.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Mathias Preiner + ** Andrew Reynolds, Mathias Preiner, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__INSTANTIATE_H -#define __CVC4__THEORY__QUANTIFIERS__INSTANTIATE_H +#ifndef CVC4__THEORY__QUANTIFIERS__INSTANTIATE_H +#define CVC4__THEORY__QUANTIFIERS__INSTANTIATE_H #include <map> @@ -374,4 +374,4 @@ class Instantiate : public QuantifiersUtil } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__INSTANTIATE_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__INSTANTIATE_H */ diff --git a/src/theory/quantifiers/lazy_trie.cpp b/src/theory/quantifiers/lazy_trie.cpp index 35049b8ba..a50352df5 100644 --- a/src/theory/quantifiers/lazy_trie.cpp +++ b/src/theory/quantifiers/lazy_trie.cpp @@ -2,9 +2,9 @@ /*! \file lazy_trie.cpp ** \verbatim ** Top contributors (to current version): - ** Haniel Barbosa + ** Haniel Barbosa, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/lazy_trie.h b/src/theory/quantifiers/lazy_trie.h index 156f1abde..8f822fcc0 100644 --- a/src/theory/quantifiers/lazy_trie.h +++ b/src/theory/quantifiers/lazy_trie.h @@ -2,9 +2,9 @@ /*! \file lazy_trie.h ** \verbatim ** Top contributors (to current version): - ** Haniel Barbosa + ** Haniel Barbosa, Andrew Reynolds, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -12,8 +12,8 @@ ** \brief lazy trie **/ -#ifndef __CVC4__THEORY__QUANTIFIERS__LAZY_TRIE_H -#define __CVC4__THEORY__QUANTIFIERS__LAZY_TRIE_H +#ifndef CVC4__THEORY__QUANTIFIERS__LAZY_TRIE_H +#define CVC4__THEORY__QUANTIFIERS__LAZY_TRIE_H #include "expr/node.h" @@ -170,4 +170,4 @@ class LazyTrieMulti } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__LAZY_TRIE_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__LAZY_TRIE_H */ diff --git a/src/theory/quantifiers/local_theory_ext.cpp b/src/theory/quantifiers/local_theory_ext.cpp index 752d61489..520088328 100644 --- a/src/theory/quantifiers/local_theory_ext.cpp +++ b/src/theory/quantifiers/local_theory_ext.cpp @@ -2,9 +2,9 @@ /*! \file local_theory_ext.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Paul Meng + ** Andrew Reynolds, Morgan Deters, Paul Meng ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/local_theory_ext.h b/src/theory/quantifiers/local_theory_ext.h index b8b0e34fa..9793ea0a7 100644 --- a/src/theory/quantifiers/local_theory_ext.h +++ b/src/theory/quantifiers/local_theory_ext.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__LOCAL_THEORY_EXT_H -#define __CVC4__THEORY__LOCAL_THEORY_EXT_H +#ifndef CVC4__THEORY__LOCAL_THEORY_EXT_H +#define CVC4__THEORY__LOCAL_THEORY_EXT_H #include "context/cdo.h" #include "expr/node_trie.h" diff --git a/src/theory/quantifiers/quant_conflict_find.cpp b/src/theory/quantifiers/quant_conflict_find.cpp index 5b57af14c..dc18a2005 100644 --- a/src/theory/quantifiers/quant_conflict_find.cpp +++ b/src/theory/quantifiers/quant_conflict_find.cpp @@ -2,9 +2,9 @@ /*! \file quant_conflict_find.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Morgan Deters + ** Andrew Reynolds, Tim King, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -583,7 +583,9 @@ bool QuantInfo::isTConstraintSpurious( QuantConflictFind * p, std::vector< Node }else{ Node inst = p->d_quantEngine->getInstantiate()->getInstantiation(d_q, terms); - Node inst_eval = p->getTermDatabase()->evaluateTerm( inst, NULL, options::qcfTConstraint() ); + inst = Rewriter::rewrite(inst); + Node inst_eval = p->getTermDatabase()->evaluateTerm( + inst, nullptr, options::qcfTConstraint(), true); if( Trace.isOn("qcf-instance-check") ){ Trace("qcf-instance-check") << "Possible propagating instance for " << d_q << " : " << std::endl; for( unsigned i=0; i<terms.size(); i++ ){ @@ -591,10 +593,13 @@ bool QuantInfo::isTConstraintSpurious( QuantConflictFind * p, std::vector< Node } Trace("qcf-instance-check") << "...evaluates to " << inst_eval << std::endl; } - if( inst_eval.isNull() || inst_eval==p->getTermUtil()->d_true || !isPropagatingInstance( p, inst_eval ) ){ + if (inst_eval.isNull() + || (inst_eval.isConst() && inst_eval.getConst<bool>())) + { Trace("qcf-instance-check") << "...spurious." << std::endl; return true; }else{ + Assert(p->isPropagatingInstance(inst_eval)); Trace("qcf-instance-check") << "...not spurious." << std::endl; } } @@ -615,27 +620,6 @@ bool QuantInfo::isTConstraintSpurious( QuantConflictFind * p, std::vector< Node return p->d_quantEngine->inConflict(); } -bool QuantInfo::isPropagatingInstance( QuantConflictFind * p, Node n ) { - if( n.getKind()==FORALL ){ - //TODO? - return true; - }else if( n.getKind()==NOT || n.getKind()==AND || n.getKind()==OR || n.getKind()==EQUAL || n.getKind()==ITE || - ( n.getKind()==EQUAL && n[0].getType().isBoolean() ) ){ - for( unsigned i=0; i<n.getNumChildren(); i++ ){ - if( !isPropagatingInstance( p, n[i] ) ){ - return false; - } - } - return true; - }else{ - if( p->getEqualityEngine()->hasTerm( n ) || isGroundSubterm( n ) ){ - return true; - } - } - Trace("qcf-instance-check-debug") << "...not propagating instance because of " << n << std::endl; - return false; -} - bool QuantInfo::entailmentTest( QuantConflictFind * p, Node lit, bool chEnt ) { Trace("qcf-tconstraint-debug") << "Check : " << lit << std::endl; Node rew = Rewriter::rewrite( lit ); @@ -1047,7 +1031,6 @@ MatchGen::MatchGen( QuantInfo * qi, Node n, bool isVar ) else { d_qni_gterm[i] = d_n[i]; - qi->setGroundSubterm(d_n[i]); } } d_type = d_n.getKind() == EQUAL ? typ_eq : typ_tconstraint; @@ -1058,7 +1041,6 @@ MatchGen::MatchGen( QuantInfo * qi, Node n, bool isVar ) //we will just evaluate d_n = n; d_type = typ_ground; - qi->setGroundSubterm( d_n ); } } Trace("qcf-qregister-debug") << "Done make match gen " << n << ", type = "; @@ -2211,6 +2193,42 @@ std::ostream& operator<<(std::ostream& os, const QuantConflictFind::Effort& e) { return os; } +bool QuantConflictFind::isPropagatingInstance(Node n) const +{ + std::unordered_set<TNode, TNodeHashFunction> visited; + std::vector<TNode> visit; + TNode cur; + visit.push_back(n); + do + { + cur = visit.back(); + visit.pop_back(); + if (visited.find(cur) == visited.end()) + { + visited.insert(cur); + Kind ck = cur.getKind(); + if (ck == FORALL) + { + // do nothing + } + else if (TermUtil::isBoolConnective(ck)) + { + for (TNode cc : cur) + { + visit.push_back(cc); + } + } + else if (!getEqualityEngine()->hasTerm(cur)) + { + Trace("qcf-instance-check-debug") + << "...not propagating instance because of " << n << std::endl; + return false; + } + } + } while (!visit.empty()); + return true; +} + } /* namespace CVC4::theory::quantifiers */ } /* namespace CVC4::theory */ } /* namespace CVC4 */ diff --git a/src/theory/quantifiers/quant_conflict_find.h b/src/theory/quantifiers/quant_conflict_find.h index 9fa37a96c..f22910191 100644 --- a/src/theory/quantifiers/quant_conflict_find.h +++ b/src/theory/quantifiers/quant_conflict_find.h @@ -2,9 +2,9 @@ /*! \file quant_conflict_find.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Mathias Preiner + ** Andrew Reynolds, Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -126,13 +126,9 @@ private: //for completing match void getPropagateVars( QuantConflictFind * p, std::vector< TNode >& vars, TNode n, bool pol, std::map< TNode, bool >& visited ); //optimization: number of variables set, to track when we can stop std::map< int, bool > d_vars_set; - std::map< Node, bool > d_ground_terms; std::vector< Node > d_extra_var; public: - void setGroundSubterm( Node t ) { d_ground_terms[t] = true; } - bool isGroundSubterm( Node t ) { return d_ground_terms.find( t )!=d_ground_terms.end(); } bool isBaseMatchComplete(); - bool isPropagatingInstance( QuantConflictFind * p, Node n ); public: QuantInfo(); ~QuantInfo(); @@ -272,6 +268,22 @@ public: Statistics d_statistics; /** Identify this module */ std::string identify() const override { return "QcfEngine"; } + /** is n a propagating instance? + * + * A propagating instance is any formula that consists of Boolean connectives, + * equality, quantified formulas, and terms that exist in the current + * context (those in the master equality engine). + * + * Notice the distinction that quantified formulas that do not appear in the + * current context are considered to be legal in propagating instances. This + * choice is significant for TPTP, where a net of ~200 benchmarks are gained + * due to this decision. + * + * Propagating instances are the second most useful kind of instantiation + * after conflicting instances and are used as a second effort in the + * algorithm performed by this class. + */ + bool isPropagatingInstance(Node n) const; }; std::ostream& operator<<(std::ostream& os, const QuantConflictFind::Effort& e); diff --git a/src/theory/quantifiers/quant_epr.cpp b/src/theory/quantifiers/quant_epr.cpp index eedea6767..e03a2c120 100644 --- a/src/theory/quantifiers/quant_epr.cpp +++ b/src/theory/quantifiers/quant_epr.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/quant_epr.h b/src/theory/quantifiers/quant_epr.h index 07569a09b..1284dde33 100644 --- a/src/theory/quantifiers/quant_epr.h +++ b/src/theory/quantifiers/quant_epr.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANT_EPR_H -#define __CVC4__THEORY__QUANT_EPR_H +#ifndef CVC4__THEORY__QUANT_EPR_H +#define CVC4__THEORY__QUANT_EPR_H #include <map> @@ -101,4 +101,4 @@ class QuantEPR } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANT_EPR_H */ +#endif /* CVC4__THEORY__QUANT_EPR_H */ diff --git a/src/theory/quantifiers/quant_relevance.cpp b/src/theory/quantifiers/quant_relevance.cpp index a05388d17..de54fa05f 100644 --- a/src/theory/quantifiers/quant_relevance.cpp +++ b/src/theory/quantifiers/quant_relevance.cpp @@ -2,9 +2,9 @@ /*! \file quant_relevance.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/quant_relevance.h b/src/theory/quantifiers/quant_relevance.h index 21017e783..26a4630cd 100644 --- a/src/theory/quantifiers/quant_relevance.h +++ b/src/theory/quantifiers/quant_relevance.h @@ -2,9 +2,9 @@ /*! \file quant_relevance.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Mathias Preiner + ** Andrew Reynolds, Morgan Deters, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANT_RELEVANCE_H -#define __CVC4__THEORY__QUANT_RELEVANCE_H +#ifndef CVC4__THEORY__QUANT_RELEVANCE_H +#define CVC4__THEORY__QUANT_RELEVANCE_H #include <map> @@ -68,4 +68,4 @@ class QuantRelevance : public QuantifiersUtil } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANT_RELEVANCE_H */ +#endif /* CVC4__THEORY__QUANT_RELEVANCE_H */ diff --git a/src/theory/quantifiers/quant_split.cpp b/src/theory/quantifiers/quant_split.cpp index fb5492eb3..808c6006f 100644 --- a/src/theory/quantifiers/quant_split.cpp +++ b/src/theory/quantifiers/quant_split.cpp @@ -2,9 +2,9 @@ /*! \file quant_split.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/quant_split.h b/src/theory/quantifiers/quant_split.h index 6a752fe3f..1a2aaa6cf 100644 --- a/src/theory/quantifiers/quant_split.h +++ b/src/theory/quantifiers/quant_split.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANT_SPLIT_H -#define __CVC4__THEORY__QUANT_SPLIT_H +#ifndef CVC4__THEORY__QUANT_SPLIT_H +#define CVC4__THEORY__QUANT_SPLIT_H #include "theory/quantifiers_engine.h" #include "context/cdo.h" diff --git a/src/theory/quantifiers/quant_util.cpp b/src/theory/quantifiers/quant_util.cpp index b1b34fb98..01f362d25 100644 --- a/src/theory/quantifiers/quant_util.cpp +++ b/src/theory/quantifiers/quant_util.cpp @@ -2,9 +2,9 @@ /*! \file quant_util.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -30,27 +30,38 @@ QuantifiersModule::QEffort QuantifiersModule::needsModel(Theory::Effort e) return QEFFORT_NONE; } -eq::EqualityEngine * QuantifiersModule::getEqualityEngine() { +eq::EqualityEngine* QuantifiersModule::getEqualityEngine() const +{ return d_quantEngine->getActiveEqualityEngine(); } -bool QuantifiersModule::areEqual( TNode n1, TNode n2 ) { +bool QuantifiersModule::areEqual(TNode n1, TNode n2) const +{ return d_quantEngine->getEqualityQuery()->areEqual( n1, n2 ); } -bool QuantifiersModule::areDisequal( TNode n1, TNode n2 ) { +bool QuantifiersModule::areDisequal(TNode n1, TNode n2) const +{ return d_quantEngine->getEqualityQuery()->areDisequal( n1, n2 ); } -TNode QuantifiersModule::getRepresentative( TNode n ) { +TNode QuantifiersModule::getRepresentative(TNode n) const +{ return d_quantEngine->getEqualityQuery()->getRepresentative( n ); } -quantifiers::TermDb * QuantifiersModule::getTermDatabase() { +QuantifiersEngine* QuantifiersModule::getQuantifiersEngine() const +{ + return d_quantEngine; +} + +quantifiers::TermDb* QuantifiersModule::getTermDatabase() const +{ return d_quantEngine->getTermDatabase(); } -quantifiers::TermUtil * QuantifiersModule::getTermUtil() { +quantifiers::TermUtil* QuantifiersModule::getTermUtil() const +{ return d_quantEngine->getTermUtil(); } diff --git a/src/theory/quantifiers/quant_util.h b/src/theory/quantifiers/quant_util.h index e324bc36f..43861d6e9 100644 --- a/src/theory/quantifiers/quant_util.h +++ b/src/theory/quantifiers/quant_util.h @@ -2,9 +2,9 @@ /*! \file quant_util.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANT_UTIL_H -#define __CVC4__THEORY__QUANT_UTIL_H +#ifndef CVC4__THEORY__QUANT_UTIL_H +#define CVC4__THEORY__QUANT_UTIL_H #include <iostream> #include <map> @@ -138,19 +138,19 @@ class QuantifiersModule { virtual std::string identify() const = 0; //----------------------------general queries /** get currently used the equality engine */ - eq::EqualityEngine * getEqualityEngine(); + eq::EqualityEngine* getEqualityEngine() const; /** are n1 and n2 equal in the current used equality engine? */ - bool areEqual( TNode n1, TNode n2 ); + bool areEqual(TNode n1, TNode n2) const; /** are n1 and n2 disequal in the current used equality engine? */ - bool areDisequal(TNode n1, TNode n2); + bool areDisequal(TNode n1, TNode n2) const; /** get the representative of n in the current used equality engine */ - TNode getRepresentative( TNode n ); + TNode getRepresentative(TNode n) const; /** get quantifiers engine that owns this module */ - QuantifiersEngine* getQuantifiersEngine() { return d_quantEngine; } + QuantifiersEngine* getQuantifiersEngine() const; /** get currently used term database */ - quantifiers::TermDb * getTermDatabase(); + quantifiers::TermDb* getTermDatabase() const; /** get currently used term utility object */ - quantifiers::TermUtil * getTermUtil(); + quantifiers::TermUtil* getTermUtil() const; //----------------------------end general queries protected: /** pointer to the quantifiers engine that owns this module */ @@ -237,4 +237,4 @@ public: } } -#endif /* __CVC4__THEORY__QUANT_UTIL_H */ +#endif /* CVC4__THEORY__QUANT_UTIL_H */ diff --git a/src/theory/quantifiers/quantifiers_attributes.cpp b/src/theory/quantifiers/quantifiers_attributes.cpp index e3463df0d..d93de6a54 100644 --- a/src/theory/quantifiers/quantifiers_attributes.cpp +++ b/src/theory/quantifiers/quantifiers_attributes.cpp @@ -2,9 +2,9 @@ /*! \file quantifiers_attributes.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Paul Meng, Tim King + ** Andrew Reynolds, Paul Meng, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/quantifiers_attributes.h b/src/theory/quantifiers/quantifiers_attributes.h index d3acc9434..329f9d08a 100644 --- a/src/theory/quantifiers/quantifiers_attributes.h +++ b/src/theory/quantifiers/quantifiers_attributes.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__QUANTIFIERS_ATTRIBUTES_H -#define __CVC4__THEORY__QUANTIFIERS__QUANTIFIERS_ATTRIBUTES_H +#ifndef CVC4__THEORY__QUANTIFIERS__QUANTIFIERS_ATTRIBUTES_H +#define CVC4__THEORY__QUANTIFIERS__QUANTIFIERS_ATTRIBUTES_H #include "expr/attribute.h" #include "expr/node.h" diff --git a/src/theory/quantifiers/quantifiers_rewriter.cpp b/src/theory/quantifiers/quantifiers_rewriter.cpp index e2a26f6e6..015bf9c5a 100644 --- a/src/theory/quantifiers/quantifiers_rewriter.cpp +++ b/src/theory/quantifiers/quantifiers_rewriter.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/quantifiers_rewriter.h b/src/theory/quantifiers/quantifiers_rewriter.h index a1d6d25c3..09f26b65b 100644 --- a/src/theory/quantifiers/quantifiers_rewriter.h +++ b/src/theory/quantifiers/quantifiers_rewriter.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__QUANTIFIERS_REWRITER_H -#define __CVC4__THEORY__QUANTIFIERS__QUANTIFIERS_REWRITER_H +#ifndef CVC4__THEORY__QUANTIFIERS__QUANTIFIERS_REWRITER_H +#define CVC4__THEORY__QUANTIFIERS__QUANTIFIERS_REWRITER_H #include "theory/rewriter.h" #include "theory/quantifiers_engine.h" @@ -188,6 +188,6 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__QUANTIFIERS_REWRITER_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__QUANTIFIERS_REWRITER_H */ diff --git a/src/theory/quantifiers/query_generator.cpp b/src/theory/quantifiers/query_generator.cpp index e62f3513c..bc7538c1f 100644 --- a/src/theory/quantifiers/query_generator.cpp +++ b/src/theory/quantifiers/query_generator.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -185,9 +185,9 @@ void QueryGenerator::checkQuery(Node qy, unsigned spIndex) NodeManager* nm = NodeManager::currentNM(); // make the satisfiability query bool needExport = false; - ExprManagerMapCollection varMap; ExprManager em(nm->getOptions()); std::unique_ptr<SmtEngine> queryChecker; + ExprManagerMapCollection varMap; initializeChecker(queryChecker, em, varMap, qy, needExport); Result r = queryChecker->checkSat(); Trace("sygus-qgen-check") << " query: ...got : " << r << std::endl; diff --git a/src/theory/quantifiers/query_generator.h b/src/theory/quantifiers/query_generator.h index f0b3fa565..749c78c85 100644 --- a/src/theory/quantifiers/query_generator.h +++ b/src/theory/quantifiers/query_generator.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -15,8 +15,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__QUERY_GENERATOR_H -#define __CVC4__THEORY__QUANTIFIERS__QUERY_GENERATOR_H +#ifndef CVC4__THEORY__QUANTIFIERS__QUERY_GENERATOR_H +#define CVC4__THEORY__QUANTIFIERS__QUERY_GENERATOR_H #include <map> #include <unordered_set> @@ -113,4 +113,4 @@ class QueryGenerator : public ExprMiner } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__QUANTIFIERS___H */ +#endif /* CVC4__THEORY__QUANTIFIERS___H */ diff --git a/src/theory/quantifiers/relevant_domain.cpp b/src/theory/quantifiers/relevant_domain.cpp index 849e73822..071bd7933 100644 --- a/src/theory/quantifiers/relevant_domain.cpp +++ b/src/theory/quantifiers/relevant_domain.cpp @@ -2,9 +2,9 @@ /*! \file relevant_domain.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -169,7 +169,9 @@ void RelevantDomain::computeRelevantDomain( Node q, Node n, bool hasPol, bool po computeRelevantDomainOpCh( rf, n[i] ); } } - if( n[i].getKind()!=FORALL ){ + // do not recurse under nested closures + if (!n[i].isClosure()) + { bool newHasPol; bool newPol; QuantPhaseReq::getPolarity( n, i, hasPol, pol, newHasPol, newPol ); diff --git a/src/theory/quantifiers/relevant_domain.h b/src/theory/quantifiers/relevant_domain.h index 78fe23890..8f348b471 100644 --- a/src/theory/quantifiers/relevant_domain.h +++ b/src/theory/quantifiers/relevant_domain.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__RELEVANT_DOMAIN_H -#define __CVC4__THEORY__QUANTIFIERS__RELEVANT_DOMAIN_H +#ifndef CVC4__THEORY__QUANTIFIERS__RELEVANT_DOMAIN_H +#define CVC4__THEORY__QUANTIFIERS__RELEVANT_DOMAIN_H #include "theory/quantifiers/first_order_model.h" #include "theory/quantifiers/quant_util.h" @@ -163,4 +163,4 @@ class RelevantDomain : public QuantifiersUtil }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__RELEVANT_DOMAIN_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__RELEVANT_DOMAIN_H */ diff --git a/src/theory/quantifiers/rewrite_engine.cpp b/src/theory/quantifiers/rewrite_engine.cpp index ed9666d80..ff42a9c89 100644 --- a/src/theory/quantifiers/rewrite_engine.cpp +++ b/src/theory/quantifiers/rewrite_engine.cpp @@ -2,9 +2,9 @@ /*! \file rewrite_engine.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King + ** Andrew Reynolds, Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/rewrite_engine.h b/src/theory/quantifiers/rewrite_engine.h index febcc0126..bbd6a1534 100644 --- a/src/theory/quantifiers/rewrite_engine.h +++ b/src/theory/quantifiers/rewrite_engine.h @@ -2,9 +2,9 @@ /*! \file rewrite_engine.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Mathias Preiner, Tim King + ** Andrew Reynolds, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -15,8 +15,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__REWRITE_ENGINE_H -#define __CVC4__REWRITE_ENGINE_H +#ifndef CVC4__REWRITE_ENGINE_H +#define CVC4__REWRITE_ENGINE_H #include "context/context.h" #include "context/context_mm.h" diff --git a/src/theory/quantifiers/single_inv_partition.cpp b/src/theory/quantifiers/single_inv_partition.cpp index 851204a84..153ab71cc 100644 --- a/src/theory/quantifiers/single_inv_partition.cpp +++ b/src/theory/quantifiers/single_inv_partition.cpp @@ -2,9 +2,9 @@ /*! \file single_inv_partition.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/single_inv_partition.h b/src/theory/quantifiers/single_inv_partition.h index 199ab29d4..0a4af3185 100644 --- a/src/theory/quantifiers/single_inv_partition.h +++ b/src/theory/quantifiers/single_inv_partition.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SINGLE_INV_PARTITION_H -#define __CVC4__THEORY__QUANTIFIERS__SINGLE_INV_PARTITION_H +#ifndef CVC4__THEORY__QUANTIFIERS__SINGLE_INV_PARTITION_H +#define CVC4__THEORY__QUANTIFIERS__SINGLE_INV_PARTITION_H #include <map> #include <vector> @@ -294,4 +294,4 @@ class SingleInvocationPartition } /* namespace CVC4::theory */ } /* namespace CVC4 */ -#endif /* __CVC4__THEORY__QUANTIFIERS__SINGLE_INV_PARTITION_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__SINGLE_INV_PARTITION_H */ diff --git a/src/theory/quantifiers/skolemize.cpp b/src/theory/quantifiers/skolemize.cpp index 2f12c000c..1d2b869c4 100644 --- a/src/theory/quantifiers/skolemize.cpp +++ b/src/theory/quantifiers/skolemize.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/skolemize.h b/src/theory/quantifiers/skolemize.h index 5605c8c5f..f07bbdfd3 100644 --- a/src/theory/quantifiers/skolemize.h +++ b/src/theory/quantifiers/skolemize.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SKOLEMIZE_H -#define __CVC4__THEORY__QUANTIFIERS__SKOLEMIZE_H +#ifndef CVC4__THEORY__QUANTIFIERS__SKOLEMIZE_H +#define CVC4__THEORY__QUANTIFIERS__SKOLEMIZE_H #include <unordered_map> #include <unordered_set> @@ -143,4 +143,4 @@ class Skolemize } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__SKOLEMIZE_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__SKOLEMIZE_H */ diff --git a/src/theory/quantifiers/solution_filter.cpp b/src/theory/quantifiers/solution_filter.cpp index 19d39e997..2c6186372 100644 --- a/src/theory/quantifiers/solution_filter.cpp +++ b/src/theory/quantifiers/solution_filter.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/solution_filter.h b/src/theory/quantifiers/solution_filter.h index d162f41f0..bd4c62a09 100644 --- a/src/theory/quantifiers/solution_filter.h +++ b/src/theory/quantifiers/solution_filter.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SOLUTION_FILTER_H -#define __CVC4__THEORY__QUANTIFIERS__SOLUTION_FILTER_H +#ifndef CVC4__THEORY__QUANTIFIERS__SOLUTION_FILTER_H +#define CVC4__THEORY__QUANTIFIERS__SOLUTION_FILTER_H #include <map> #include <unordered_set> @@ -72,4 +72,4 @@ class SolutionFilterStrength : public ExprMiner } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__QUANTIFIERS__SOLUTION_FILTER_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__SOLUTION_FILTER_H */ diff --git a/src/theory/quantifiers/sygus/ce_guided_single_inv.cpp b/src/theory/quantifiers/sygus/ce_guided_single_inv.cpp index aa20c1f76..00d040af5 100644 --- a/src/theory/quantifiers/sygus/ce_guided_single_inv.cpp +++ b/src/theory/quantifiers/sygus/ce_guided_single_inv.cpp @@ -2,9 +2,9 @@ /*! \file ce_guided_single_inv.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King + ** Andrew Reynolds, Andres Noetzli, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/sygus/ce_guided_single_inv.h b/src/theory/quantifiers/sygus/ce_guided_single_inv.h index 0de7b4290..4b24cbb1c 100644 --- a/src/theory/quantifiers/sygus/ce_guided_single_inv.h +++ b/src/theory/quantifiers/sygus/ce_guided_single_inv.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Tim King, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__CE_GUIDED_SINGLE_INV_H -#define __CVC4__THEORY__QUANTIFIERS__CE_GUIDED_SINGLE_INV_H +#ifndef CVC4__THEORY__QUANTIFIERS__CE_GUIDED_SINGLE_INV_H +#define CVC4__THEORY__QUANTIFIERS__CE_GUIDED_SINGLE_INV_H #include "context/cdlist.h" #include "theory/quantifiers/sygus/ce_guided_single_inv_sol.h" diff --git a/src/theory/quantifiers/sygus/ce_guided_single_inv_sol.cpp b/src/theory/quantifiers/sygus/ce_guided_single_inv_sol.cpp index 7f7c56f84..074971622 100644 --- a/src/theory/quantifiers/sygus/ce_guided_single_inv_sol.cpp +++ b/src/theory/quantifiers/sygus/ce_guided_single_inv_sol.cpp @@ -2,9 +2,9 @@ /*! \file ce_guided_single_inv_sol.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King + ** Andrew Reynolds, Tim King, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/sygus/ce_guided_single_inv_sol.h b/src/theory/quantifiers/sygus/ce_guided_single_inv_sol.h index fb0862413..40117af6c 100644 --- a/src/theory/quantifiers/sygus/ce_guided_single_inv_sol.h +++ b/src/theory/quantifiers/sygus/ce_guided_single_inv_sol.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__CE_GUIDED_SINGLE_INV_SOL_H -#define __CVC4__THEORY__QUANTIFIERS__CE_GUIDED_SINGLE_INV_SOL_H +#ifndef CVC4__THEORY__QUANTIFIERS__CE_GUIDED_SINGLE_INV_SOL_H +#define CVC4__THEORY__QUANTIFIERS__CE_GUIDED_SINGLE_INV_SOL_H #include "context/cdhashmap.h" #include "theory/quantifiers_engine.h" diff --git a/src/theory/quantifiers/sygus/cegis.cpp b/src/theory/quantifiers/sygus/cegis.cpp index 6aca71ca3..314b43711 100644 --- a/src/theory/quantifiers/sygus/cegis.cpp +++ b/src/theory/quantifiers/sygus/cegis.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Haniel Barbosa ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/sygus/cegis.h b/src/theory/quantifiers/sygus/cegis.h index 849a39639..a295f6a40 100644 --- a/src/theory/quantifiers/sygus/cegis.h +++ b/src/theory/quantifiers/sygus/cegis.h @@ -2,9 +2,9 @@ /*! \file cegis.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Haniel Barbosa, Andres Noetzli + ** Andrew Reynolds, Haniel Barbosa, FabianWolff ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__CEGIS_H -#define __CVC4__THEORY__QUANTIFIERS__CEGIS_H +#ifndef CVC4__THEORY__QUANTIFIERS__CEGIS_H +#define CVC4__THEORY__QUANTIFIERS__CEGIS_H #include <map> #include "theory/quantifiers/sygus/sygus_module.h" @@ -209,4 +209,4 @@ class Cegis : public SygusModule } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__CEGIS_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__CEGIS_H */ diff --git a/src/theory/quantifiers/sygus/cegis_unif.cpp b/src/theory/quantifiers/sygus/cegis_unif.cpp index 18e313bf0..e34669425 100644 --- a/src/theory/quantifiers/sygus/cegis_unif.cpp +++ b/src/theory/quantifiers/sygus/cegis_unif.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Haniel Barbosa ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/sygus/cegis_unif.h b/src/theory/quantifiers/sygus/cegis_unif.h index 972d07af7..a2e7be1c1 100644 --- a/src/theory/quantifiers/sygus/cegis_unif.h +++ b/src/theory/quantifiers/sygus/cegis_unif.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Haniel Barbosa, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -13,8 +13,8 @@ **/ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SYGUS__CEGIS_UNIF_H -#define __CVC4__THEORY__QUANTIFIERS__SYGUS__CEGIS_UNIF_H +#ifndef CVC4__THEORY__QUANTIFIERS__SYGUS__CEGIS_UNIF_H +#define CVC4__THEORY__QUANTIFIERS__SYGUS__CEGIS_UNIF_H #include <map> #include <vector> diff --git a/src/theory/quantifiers/sygus/enum_stream_substitution.cpp b/src/theory/quantifiers/sygus/enum_stream_substitution.cpp index e8daa4256..b568b8f53 100644 --- a/src/theory/quantifiers/sygus/enum_stream_substitution.cpp +++ b/src/theory/quantifiers/sygus/enum_stream_substitution.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Haniel Barbosa, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/sygus/enum_stream_substitution.h b/src/theory/quantifiers/sygus/enum_stream_substitution.h index 476a364ea..687641e60 100644 --- a/src/theory/quantifiers/sygus/enum_stream_substitution.h +++ b/src/theory/quantifiers/sygus/enum_stream_substitution.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Haniel Barbosa, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ **/ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SYGUS__ENUM_STREAM_SUBSTITUTION_H -#define __CVC4__THEORY__QUANTIFIERS__SYGUS__ENUM_STREAM_SUBSTITUTION_H +#ifndef CVC4__THEORY__QUANTIFIERS__SYGUS__ENUM_STREAM_SUBSTITUTION_H +#define CVC4__THEORY__QUANTIFIERS__SYGUS__ENUM_STREAM_SUBSTITUTION_H #include "expr/node.h" #include "theory/quantifiers/sygus/synth_conjecture.h" diff --git a/src/theory/quantifiers/sygus/sygus_enumerator.cpp b/src/theory/quantifiers/sygus/sygus_enumerator.cpp index 9981b5141..bd85ea496 100644 --- a/src/theory/quantifiers/sygus/sygus_enumerator.cpp +++ b/src/theory/quantifiers/sygus/sygus_enumerator.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -476,6 +476,13 @@ bool SygusEnumerator::TermEnumSlave::validateIndex() { Assert(d_index == tc.getNumTerms()); Trace("sygus-enum-debug2") << "slave(" << d_tn << ") : force master...\n"; + // if the size of the master is larger than the size limit, then + // there is no use continuing, since there are no more terms that this + // slave enumerator can return. + if (d_master->getCurrentSize() > d_sizeLim) + { + return false; + } // must push the master index if (!d_master->increment()) { @@ -655,9 +662,14 @@ bool SygusEnumerator::TermEnumMaster::increment() { return false; } + Trace("sygus-enum-summary") << "SygusEnumerator::TermEnumMaster: increment " + << d_tn << "..." << std::endl; d_isIncrementing = true; bool ret = incrementInternal(); d_isIncrementing = false; + Trace("sygus-enum-summary") + << "SygusEnumerator::TermEnumMaster: finished increment " << d_tn + << std::endl; return ret; } @@ -789,7 +801,15 @@ bool SygusEnumerator::TermEnumMaster::incrementInternal() // restart with constructor class one (skip nullary constructors) d_consClassNum = 1; - return incrementInternal(); + + // We break for a round: return the null term when we cross a size + // boundary. This ensures that the necessary breaks are taken, e.g. + // in slave enumerators who may instead want to abandon this call to + // increment master when the size of the master makes their increment + // infeasible. + d_currTermSet = true; + d_currTerm = Node::null(); + return true; } bool incSuccess = false; @@ -819,6 +839,8 @@ bool SygusEnumerator::TermEnumMaster::incrementInternal() // the term was not unique based on rewriting Trace("sygus-enum-debug2") << "master(" << d_tn << "): failed addTerm\n"; + // we will return null (d_currTermSet is true at this point) + Assert(d_currTermSet); d_currTerm = Node::null(); } } diff --git a/src/theory/quantifiers/sygus/sygus_enumerator.h b/src/theory/quantifiers/sygus/sygus_enumerator.h index 716a047d2..d4c466b03 100644 --- a/src/theory/quantifiers/sygus/sygus_enumerator.h +++ b/src/theory/quantifiers/sygus/sygus_enumerator.h @@ -1,10 +1,10 @@ -/******************** */ +/********************* */ /*! \file sygus_enumerator.h ** \verbatim ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SYGUS_ENUMERATOR_H -#define __CVC4__THEORY__QUANTIFIERS__SYGUS_ENUMERATOR_H +#ifndef CVC4__THEORY__QUANTIFIERS__SYGUS_ENUMERATOR_H +#define CVC4__THEORY__QUANTIFIERS__SYGUS_ENUMERATOR_H #include <map> #include <unordered_set> @@ -454,4 +454,4 @@ class SygusEnumerator : public EnumValGenerator } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__QUANTIFIERS__SYGUS_ENUMERATOR_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__SYGUS_ENUMERATOR_H */ diff --git a/src/theory/quantifiers/sygus/sygus_eval_unfold.cpp b/src/theory/quantifiers/sygus/sygus_eval_unfold.cpp index ac7467c00..e44b604d0 100644 --- a/src/theory/quantifiers/sygus/sygus_eval_unfold.cpp +++ b/src/theory/quantifiers/sygus/sygus_eval_unfold.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/sygus/sygus_eval_unfold.h b/src/theory/quantifiers/sygus/sygus_eval_unfold.h index 94f37c845..adc54c6a7 100644 --- a/src/theory/quantifiers/sygus/sygus_eval_unfold.h +++ b/src/theory/quantifiers/sygus/sygus_eval_unfold.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SYGUS_EVAL_UNFOLD_H -#define __CVC4__THEORY__QUANTIFIERS__SYGUS_EVAL_UNFOLD_H +#ifndef CVC4__THEORY__QUANTIFIERS__SYGUS_EVAL_UNFOLD_H +#define CVC4__THEORY__QUANTIFIERS__SYGUS_EVAL_UNFOLD_H #include <map> #include "expr/node.h" @@ -113,4 +113,4 @@ class SygusEvalUnfold } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__QUANTIFIERS__SYGUS_EVAL_UNFOLD_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__SYGUS_EVAL_UNFOLD_H */ diff --git a/src/theory/quantifiers/sygus/sygus_explain.cpp b/src/theory/quantifiers/sygus/sygus_explain.cpp index ddf52001e..f55ce2097 100644 --- a/src/theory/quantifiers/sygus/sygus_explain.cpp +++ b/src/theory/quantifiers/sygus/sygus_explain.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/sygus/sygus_explain.h b/src/theory/quantifiers/sygus/sygus_explain.h index 3f18a65d6..ec29ab2a1 100644 --- a/src/theory/quantifiers/sygus/sygus_explain.h +++ b/src/theory/quantifiers/sygus/sygus_explain.h @@ -2,9 +2,9 @@ /*! \file sygus_explain.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, FabianWolff ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SYGUS_EXPLAIN_H -#define __CVC4__THEORY__QUANTIFIERS__SYGUS_EXPLAIN_H +#ifndef CVC4__THEORY__QUANTIFIERS__SYGUS_EXPLAIN_H +#define CVC4__THEORY__QUANTIFIERS__SYGUS_EXPLAIN_H #include <vector> @@ -241,4 +241,4 @@ class SygusExplain } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__SYGUS_EXPLAIN_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__SYGUS_EXPLAIN_H */ diff --git a/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp b/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp index 67fa1398e..48da8e8e8 100644 --- a/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp +++ b/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Haniel Barbosa ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/sygus/sygus_grammar_cons.h b/src/theory/quantifiers/sygus/sygus_grammar_cons.h index bf377bd33..7dfa9b478 100644 --- a/src/theory/quantifiers/sygus/sygus_grammar_cons.h +++ b/src/theory/quantifiers/sygus/sygus_grammar_cons.h @@ -2,9 +2,9 @@ /*! \file sygus_grammar_cons.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Haniel Barbosa ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -15,8 +15,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SYGUS_GRAMMAR_CONS_H -#define __CVC4__THEORY__QUANTIFIERS__SYGUS_GRAMMAR_CONS_H +#ifndef CVC4__THEORY__QUANTIFIERS__SYGUS_GRAMMAR_CONS_H +#define CVC4__THEORY__QUANTIFIERS__SYGUS_GRAMMAR_CONS_H #include "theory/quantifiers_engine.h" diff --git a/src/theory/quantifiers/sygus/sygus_grammar_norm.cpp b/src/theory/quantifiers/sygus/sygus_grammar_norm.cpp index 8e41b6b07..fb6b23132 100644 --- a/src/theory/quantifiers/sygus/sygus_grammar_norm.cpp +++ b/src/theory/quantifiers/sygus/sygus_grammar_norm.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Haniel Barbosa, Andrew Reynolds, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/sygus/sygus_grammar_norm.h b/src/theory/quantifiers/sygus/sygus_grammar_norm.h index 993d41668..ae701113c 100644 --- a/src/theory/quantifiers/sygus/sygus_grammar_norm.h +++ b/src/theory/quantifiers/sygus/sygus_grammar_norm.h @@ -2,9 +2,9 @@ /*! \file sygus_grammar_norm.h ** \verbatim ** Top contributors (to current version): - ** Haniel Barbosa, Tim King, Andrew Reynolds + ** Haniel Barbosa, Andrew Reynolds, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ **/ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SYGUS_GRAMMAR_NORM_H -#define __CVC4__THEORY__QUANTIFIERS__SYGUS_GRAMMAR_NORM_H +#ifndef CVC4__THEORY__QUANTIFIERS__SYGUS_GRAMMAR_NORM_H +#define CVC4__THEORY__QUANTIFIERS__SYGUS_GRAMMAR_NORM_H #include <map> #include <memory> diff --git a/src/theory/quantifiers/sygus/sygus_grammar_red.cpp b/src/theory/quantifiers/sygus/sygus_grammar_red.cpp index 24aa74c9e..6ad590f28 100644 --- a/src/theory/quantifiers/sygus/sygus_grammar_red.cpp +++ b/src/theory/quantifiers/sygus/sygus_grammar_red.cpp @@ -2,9 +2,9 @@ /*! \file sygus_grammar_red.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Haniel Barbosa ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/sygus/sygus_grammar_red.h b/src/theory/quantifiers/sygus/sygus_grammar_red.h index ce83402c9..8ed080a30 100644 --- a/src/theory/quantifiers/sygus/sygus_grammar_red.h +++ b/src/theory/quantifiers/sygus/sygus_grammar_red.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SYGUS_GRAMMAR_RED_H -#define __CVC4__THEORY__QUANTIFIERS__SYGUS_GRAMMAR_RED_H +#ifndef CVC4__THEORY__QUANTIFIERS__SYGUS_GRAMMAR_RED_H +#define CVC4__THEORY__QUANTIFIERS__SYGUS_GRAMMAR_RED_H #include <map> #include "theory/quantifiers_engine.h" @@ -116,4 +116,4 @@ class SygusRedundantCons } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__SYGUS_GRAMMAR_RED_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__SYGUS_GRAMMAR_RED_H */ diff --git a/src/theory/quantifiers/sygus/sygus_invariance.cpp b/src/theory/quantifiers/sygus/sygus_invariance.cpp index 5ea01ef57..b494e085e 100644 --- a/src/theory/quantifiers/sygus/sygus_invariance.cpp +++ b/src/theory/quantifiers/sygus/sygus_invariance.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/sygus/sygus_invariance.h b/src/theory/quantifiers/sygus/sygus_invariance.h index 02c249411..feb2d3313 100644 --- a/src/theory/quantifiers/sygus/sygus_invariance.h +++ b/src/theory/quantifiers/sygus/sygus_invariance.h @@ -2,9 +2,9 @@ /*! \file sygus_invariance.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Mathias Preiner + ** Andrew Reynolds, Mathias Preiner, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SYGUS_INVARIANCE_H -#define __CVC4__THEORY__QUANTIFIERS__SYGUS_INVARIANCE_H +#ifndef CVC4__THEORY__QUANTIFIERS__SYGUS_INVARIANCE_H +#define CVC4__THEORY__QUANTIFIERS__SYGUS_INVARIANCE_H #include <unordered_map> #include <vector> @@ -300,4 +300,4 @@ class NegContainsSygusInvarianceTest : public SygusInvarianceTest } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__SYGUS_INVARIANCE_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__SYGUS_INVARIANCE_H */ diff --git a/src/theory/quantifiers/sygus/sygus_module.cpp b/src/theory/quantifiers/sygus/sygus_module.cpp index 3471472fa..42a125ae5 100644 --- a/src/theory/quantifiers/sygus/sygus_module.cpp +++ b/src/theory/quantifiers/sygus/sygus_module.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/sygus/sygus_module.h b/src/theory/quantifiers/sygus/sygus_module.h index fef24e9bb..d5e1de3fc 100644 --- a/src/theory/quantifiers/sygus/sygus_module.h +++ b/src/theory/quantifiers/sygus/sygus_module.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SYGUS_MODULE_H -#define __CVC4__THEORY__QUANTIFIERS__SYGUS_MODULE_H +#ifndef CVC4__THEORY__QUANTIFIERS__SYGUS_MODULE_H +#define CVC4__THEORY__QUANTIFIERS__SYGUS_MODULE_H #include <map> #include "expr/node.h" @@ -148,4 +148,4 @@ class SygusModule } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__SYGUS_MODULE_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__SYGUS_MODULE_H */ diff --git a/src/theory/quantifiers/sygus/sygus_pbe.cpp b/src/theory/quantifiers/sygus/sygus_pbe.cpp index 7891814be..2ab51f1fb 100644 --- a/src/theory/quantifiers/sygus/sygus_pbe.cpp +++ b/src/theory/quantifiers/sygus/sygus_pbe.cpp @@ -2,9 +2,9 @@ /*! \file sygus_pbe.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Haniel Barbosa, Aina Niemetz + ** Andrew Reynolds, Haniel Barbosa, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/sygus/sygus_pbe.h b/src/theory/quantifiers/sygus/sygus_pbe.h index dc7f1cc51..e82ce01da 100644 --- a/src/theory/quantifiers/sygus/sygus_pbe.h +++ b/src/theory/quantifiers/sygus/sygus_pbe.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Haniel Barbosa ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SYGUS_PBE_H -#define __CVC4__THEORY__QUANTIFIERS__SYGUS_PBE_H +#ifndef CVC4__THEORY__QUANTIFIERS__SYGUS_PBE_H +#define CVC4__THEORY__QUANTIFIERS__SYGUS_PBE_H #include "context/cdhashmap.h" #include "theory/quantifiers/sygus/sygus_module.h" diff --git a/src/theory/quantifiers/sygus/sygus_process_conj.cpp b/src/theory/quantifiers/sygus/sygus_process_conj.cpp index a2454758a..2b9592d4d 100644 --- a/src/theory/quantifiers/sygus/sygus_process_conj.cpp +++ b/src/theory/quantifiers/sygus/sygus_process_conj.cpp @@ -2,9 +2,9 @@ /*! \file sygus_process_conj.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King + ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/sygus/sygus_process_conj.h b/src/theory/quantifiers/sygus/sygus_process_conj.h index 199619699..e9ee340f4 100644 --- a/src/theory/quantifiers/sygus/sygus_process_conj.h +++ b/src/theory/quantifiers/sygus/sygus_process_conj.h @@ -2,9 +2,9 @@ /*! \file sygus_process_conj.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King + ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -15,8 +15,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SYGUS_PROCESS_CONJ_H -#define __CVC4__THEORY__QUANTIFIERS__SYGUS_PROCESS_CONJ_H +#ifndef CVC4__THEORY__QUANTIFIERS__SYGUS_PROCESS_CONJ_H +#define CVC4__THEORY__QUANTIFIERS__SYGUS_PROCESS_CONJ_H #include <map> #include <unordered_map> diff --git a/src/theory/quantifiers/sygus/sygus_repair_const.cpp b/src/theory/quantifiers/sygus/sygus_repair_const.cpp index 09525712f..85a0a4bf8 100644 --- a/src/theory/quantifiers/sygus/sygus_repair_const.cpp +++ b/src/theory/quantifiers/sygus/sygus_repair_const.cpp @@ -2,9 +2,9 @@ /*! \file sygus_repair_const.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Haniel Barbosa, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -115,6 +115,7 @@ void SygusRepairConst::initializeChecker(std::unique_ptr<SmtEngine>& checker, try { checker.reset(new SmtEngine(&em)); + checker->setIsInternalSubsolver(); checker->setTimeLimit(options::sygusRepairConstTimeout(), true); checker->setLogic(smt::currentSmtEngine()->getLogicInfo()); // renable options disabled by sygus diff --git a/src/theory/quantifiers/sygus/sygus_repair_const.h b/src/theory/quantifiers/sygus/sygus_repair_const.h index c6bfd2806..bc3a58f9e 100644 --- a/src/theory/quantifiers/sygus/sygus_repair_const.h +++ b/src/theory/quantifiers/sygus/sygus_repair_const.h @@ -2,9 +2,9 @@ /*! \file sygus_repair_const.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Haniel Barbosa ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SYGUS_REPAIR_CONST_H -#define __CVC4__THEORY__QUANTIFIERS__SYGUS_REPAIR_CONST_H +#ifndef CVC4__THEORY__QUANTIFIERS__SYGUS_REPAIR_CONST_H +#define CVC4__THEORY__QUANTIFIERS__SYGUS_REPAIR_CONST_H #include <unordered_set> #include "expr/node.h" @@ -215,4 +215,4 @@ class SygusRepairConst } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__SYGUS_REPAIR_CONST_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__SYGUS_REPAIR_CONST_H */ diff --git a/src/theory/quantifiers/sygus/sygus_unif.cpp b/src/theory/quantifiers/sygus/sygus_unif.cpp index 5d7017a1c..2eb508fde 100644 --- a/src/theory/quantifiers/sygus/sygus_unif.cpp +++ b/src/theory/quantifiers/sygus/sygus_unif.cpp @@ -2,9 +2,9 @@ /*! \file sygus_unif.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Haniel Barbosa + ** Andrew Reynolds, Aina Niemetz, Haniel Barbosa ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/sygus/sygus_unif.h b/src/theory/quantifiers/sygus/sygus_unif.h index 0784644f8..a5215628c 100644 --- a/src/theory/quantifiers/sygus/sygus_unif.h +++ b/src/theory/quantifiers/sygus/sygus_unif.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Haniel Barbosa ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_H -#define __CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_H +#ifndef CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_H +#define CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_H #include <map> #include "expr/node.h" @@ -196,4 +196,4 @@ class SygusUnif } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_H */ diff --git a/src/theory/quantifiers/sygus/sygus_unif_io.cpp b/src/theory/quantifiers/sygus/sygus_unif_io.cpp index c9db62735..207aa4c8e 100644 --- a/src/theory/quantifiers/sygus/sygus_unif_io.cpp +++ b/src/theory/quantifiers/sygus/sygus_unif_io.cpp @@ -2,9 +2,9 @@ /*! \file sygus_unif_io.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Haniel Barbosa + ** Andrew Reynolds, Haniel Barbosa, Aina Niemetz ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -161,7 +161,12 @@ bool UnifContextIo::getStringIncrement(SygusUnifIo* sui, if (d_vals[j] == sui->d_true) { // example is active in this context - Assert(vals[j].isConst()); + if (!vals[j].isConst()) + { + // the value is unknown, thus we cannot use it to increment the strings + // position + return false; + } String mystr = vals[j].getConst<String>(); ival = mystr.size(); if (mystr.size() <= ex_vals[j].size()) @@ -199,7 +204,11 @@ bool UnifContextIo::isStringSolved(SygusUnifIo* sui, if (d_vals[j] == sui->d_true) { // example is active in this context - Assert(vals[j].isConst()); + if (!vals[j].isConst()) + { + // value is unknown, thus it does not solve + return false; + } String mystr = vals[j].getConst<String>(); if (ex_vals[j] != mystr) { @@ -448,12 +457,23 @@ void SubsumeTrie::getLeavesInternal(const std::vector<Node>& vals, ++it) { int new_status = status; - // if the current value is true + bool success = true; + // If the current value is true, then this is a relevant point. + // We must consider the value of this child. if (curr_val_true) { - if (status != 0) + if (it->first.isNull()) { - Assert(it->first.isConst() && it->first.getType().isBoolean()); + // The value of this child is unknown on this point, hence we + // do not recurse + success = false; + } + else if (status != 0) + { + // if the status is not zero (indicating that we have a mix of T/F), + // then we must compute the new status. + Assert(it->first.getType().isBoolean()); + Assert(it->first.isConst()); new_status = (it->first.getConst<bool>() ? 1 : -1); if (status != -2 && new_status != status) { @@ -461,7 +481,10 @@ void SubsumeTrie::getLeavesInternal(const std::vector<Node>& vals, } } } - it->second.getLeavesInternal(vals, pol, v, index + 1, new_status); + if (success) + { + it->second.getLeavesInternal(vals, pol, v, index + 1, new_status); + } } } } @@ -641,23 +664,41 @@ void SygusUnifIo::notifyEnumeration(Node e, Node v, std::vector<Node>& lemmas) for (unsigned j = 0, size = itsr->second.size(); j < size; j++) { Node res = itsr->second[j]; - Assert(res.isConst()); + // The value of this term for this example, or the truth value of + // the I/O pair if the role of this enumerator is enum_io. Node resb; if (eiv.getRole() == enum_io) { Node out = d_examples_out[j]; Assert(out.isConst()); - resb = res == out ? d_true : d_false; + // If the result is not constant, then we assume that it does + // not satisfy the example. This is a safe underapproximation + // of the good behavior of the current term, that is, we only + // produce solutions whose values are fully evaluatable on all input + // points. Notice that terms may be used as leaves of decision + // trees that are fully evaluatable on points in that branch, but + // are not evaluatable on others, e.g. (head x) in the solution: + // (ite ((_ is cons) x) (head x) 5) + resb = (res.isConst() && res == out) ? d_true : d_false; } else { - resb = res; + // We only set resb if it is constant, otherwise it remains null. + // This indicates its value cannot be determined. + if (res.isConst()) + { + resb = res; + } } cond_vals[resb] = true; results.push_back(resb); if (Trace.isOn("sygus-sui-enum")) { - if (resb.getType().isBoolean()) + if (resb.isNull()) + { + Trace("sygus-sui-enum") << "_"; + } + else if (resb.getType().isBoolean()) { Trace("sygus-sui-enum") << (resb == d_true ? "1" : "0"); } @@ -677,6 +718,7 @@ void SygusUnifIo::notifyEnumeration(Node e, Node v, std::vector<Node>& lemmas) std::vector<Node> subsume; if (cond_vals.find(d_false) == cond_vals.end()) { + Assert(cond_vals.size() == 1); // it is the entire solution, we are done Trace("sygus-sui-enum") << " ...success, full solution added to PBE pool : " @@ -917,23 +959,27 @@ bool SygusUnifIo::getExplanationForEnumeratorExclude( std::vector<unsigned> cmp_indices; for (unsigned i = 0, size = results.size(); i < size; i++) { - Assert(results[i].isConst()); - Assert(d_examples_out[i].isConst()); - Trace("sygus-sui-cterm-debug") - << " " << results[i] << " <> " << d_examples_out[i]; - Node cont = nm->mkNode(STRING_STRCTN, d_examples_out[i], results[i]); - Node contr = Rewriter::rewrite(cont); - if (contr == d_false) - { - cmp_indices.push_back(i); - Trace("sygus-sui-cterm-debug") << "...not contained." << std::endl; - } - else + // If the result is not constant, then it is worthless. It does not + // impact whether the term is excluded. + if (results[i].isConst()) { - Trace("sygus-sui-cterm-debug") << "...contained." << std::endl; - if (isConditional) + Assert(d_examples_out[i].isConst()); + Trace("sygus-sui-cterm-debug") + << " " << results[i] << " <> " << d_examples_out[i]; + Node cont = nm->mkNode(STRING_STRCTN, d_examples_out[i], results[i]); + Node contr = Rewriter::rewrite(cont); + if (contr == d_false) { - return false; + cmp_indices.push_back(i); + Trace("sygus-sui-cterm-debug") << "...not contained." << std::endl; + } + else + { + Trace("sygus-sui-cterm-debug") << "...contained." << std::endl; + if (isConditional) + { + return false; + } } } } diff --git a/src/theory/quantifiers/sygus/sygus_unif_io.h b/src/theory/quantifiers/sygus/sygus_unif_io.h index 7f48645bf..7e9c5abd2 100644 --- a/src/theory/quantifiers/sygus/sygus_unif_io.h +++ b/src/theory/quantifiers/sygus/sygus_unif_io.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Haniel Barbosa ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_IO_H -#define __CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_IO_H +#ifndef CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_IO_H +#define CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_IO_H #include <map> #include "theory/quantifiers/sygus/sygus_unif.h" @@ -218,7 +218,24 @@ class SubsumeTrie int status, bool checkExistsOnly, bool checkSubsume); - /** helper function for above functions */ + /** helper function for above functions + * + * This adds to v[-1], v[0], v[1] the children of the trie that occur + * along paths that contain only false (v[-1]), a mix of true/false (v[0]), + * and only true (v[1]) values for respectively for relevant points. + * + * vals/pol is used to determine the relevant points, which impacts which + * paths of the trie to traverse on this call. + * In particular, all points such that (pol ? vals[index] : !vals[index]) + * are relevant. + * + * Paths that contain an unknown value for any relevant point are not + * traversed. In the larger picture, this ensures that terms are not used in a + * way such that their unknown value is relevant to the overall behavior of + * a synthesis solution. + * + * status holds the current value of v (0,1,-1) that we will be adding to. + */ void getLeavesInternal(const std::vector<Node>& vals, bool pol, std::map<int, std::vector<Node>>& v, @@ -472,4 +489,4 @@ class SygusUnifIo : public SygusUnif } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_IO_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_IO_H */ diff --git a/src/theory/quantifiers/sygus/sygus_unif_rl.cpp b/src/theory/quantifiers/sygus/sygus_unif_rl.cpp index ee07efdfe..3514ccbeb 100644 --- a/src/theory/quantifiers/sygus/sygus_unif_rl.cpp +++ b/src/theory/quantifiers/sygus/sygus_unif_rl.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Haniel Barbosa, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/sygus/sygus_unif_rl.h b/src/theory/quantifiers/sygus/sygus_unif_rl.h index 179a5ac16..ada99dbaf 100644 --- a/src/theory/quantifiers/sygus/sygus_unif_rl.h +++ b/src/theory/quantifiers/sygus/sygus_unif_rl.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Haniel Barbosa, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_RL_H -#define __CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_RL_H +#ifndef CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_RL_H +#define CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_RL_H #include <map> #include "options/main_options.h" @@ -434,4 +434,4 @@ class SygusUnifRl : public SygusUnif } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_RL_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_RL_H */ diff --git a/src/theory/quantifiers/sygus/sygus_unif_strat.cpp b/src/theory/quantifiers/sygus/sygus_unif_strat.cpp index 3cbac1eaa..acf5a2d7f 100644 --- a/src/theory/quantifiers/sygus/sygus_unif_strat.cpp +++ b/src/theory/quantifiers/sygus/sygus_unif_strat.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Haniel Barbosa ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/sygus/sygus_unif_strat.h b/src/theory/quantifiers/sygus/sygus_unif_strat.h index 41923f7a1..1c691bd84 100644 --- a/src/theory/quantifiers/sygus/sygus_unif_strat.h +++ b/src/theory/quantifiers/sygus/sygus_unif_strat.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Haniel Barbosa, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_STRAT_H -#define __CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_STRAT_H +#ifndef CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_STRAT_H +#define CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_STRAT_H #include <map> #include "expr/node.h" @@ -429,4 +429,4 @@ class SygusUnifStrategy } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__SYGUS_UNIF_H */ diff --git a/src/theory/quantifiers/sygus/synth_conjecture.cpp b/src/theory/quantifiers/sygus/synth_conjecture.cpp index e25e8a225..756e1f791 100644 --- a/src/theory/quantifiers/sygus/synth_conjecture.cpp +++ b/src/theory/quantifiers/sygus/synth_conjecture.cpp @@ -2,9 +2,9 @@ /*! \file synth_conjecture.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Haniel Barbosa + ** Andrew Reynolds, Haniel Barbosa, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -540,6 +540,7 @@ bool SynthConjecture::doCheck(std::vector<Node>& lems) Trace("cegqi-engine") << "Check side condition..." << std::endl; Trace("cegqi-debug") << "Check side condition : " << sc << std::endl; SmtEngine scSmt(nm->toExprManager()); + scSmt.setIsInternalSubsolver(); scSmt.setLogic(smt::currentSmtEngine()->getLogicInfo()); scSmt.assertFormula(sc.toExpr()); Result r = scSmt.checkSat(); @@ -572,6 +573,7 @@ bool SynthConjecture::doCheck(std::vector<Node>& lems) { Trace("cegqi-engine") << " *** Verify with subcall..." << std::endl; SmtEngine verifySmt(nm->toExprManager()); + verifySmt.setIsInternalSubsolver(); verifySmt.setLogic(smt::currentSmtEngine()->getLogicInfo()); verifySmt.assertFormula(query.toExpr()); Result r = verifySmt.checkSat(); diff --git a/src/theory/quantifiers/sygus/synth_conjecture.h b/src/theory/quantifiers/sygus/synth_conjecture.h index cf6178fdb..83a7eaa45 100644 --- a/src/theory/quantifiers/sygus/synth_conjecture.h +++ b/src/theory/quantifiers/sygus/synth_conjecture.h @@ -2,9 +2,9 @@ /*! \file synth_conjecture.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Haniel Barbosa + ** Andrew Reynolds, Haniel Barbosa, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -15,8 +15,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SYNTH_CONJECTURE_H -#define __CVC4__THEORY__QUANTIFIERS__SYNTH_CONJECTURE_H +#ifndef CVC4__THEORY__QUANTIFIERS__SYNTH_CONJECTURE_H +#define CVC4__THEORY__QUANTIFIERS__SYNTH_CONJECTURE_H #include <memory> diff --git a/src/theory/quantifiers/sygus/synth_engine.cpp b/src/theory/quantifiers/sygus/synth_engine.cpp index d3eff1750..fc1ed938d 100644 --- a/src/theory/quantifiers/sygus/synth_engine.cpp +++ b/src/theory/quantifiers/sygus/synth_engine.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -159,6 +159,7 @@ void SynthEngine::assignConjecture(Node q) { // create new smt engine to do quantifier elimination SmtEngine smt_qe(nm->toExprManager()); + smt_qe.setIsInternalSubsolver(); smt_qe.setLogic(smt::currentSmtEngine()->getLogicInfo()); Trace("cegqi-qep") << "Property is non-ground single invocation, run " "QE to obtain single invocation." diff --git a/src/theory/quantifiers/sygus/synth_engine.h b/src/theory/quantifiers/sygus/synth_engine.h index a7346b888..d5337e5d1 100644 --- a/src/theory/quantifiers/sygus/synth_engine.h +++ b/src/theory/quantifiers/sygus/synth_engine.h @@ -2,9 +2,9 @@ /*! \file synth_engine.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Mathias Preiner, Tim King + ** Andrew Reynolds, Mathias Preiner, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -15,8 +15,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SYNTH_ENGINE_H -#define __CVC4__THEORY__QUANTIFIERS__SYNTH_ENGINE_H +#ifndef CVC4__THEORY__QUANTIFIERS__SYNTH_ENGINE_H +#define CVC4__THEORY__QUANTIFIERS__SYNTH_ENGINE_H #include "context/cdhashmap.h" #include "theory/quantifiers/sygus/synth_conjecture.h" diff --git a/src/theory/quantifiers/sygus/term_database_sygus.cpp b/src/theory/quantifiers/sygus/term_database_sygus.cpp index 9198f7e56..af820b0fc 100644 --- a/src/theory/quantifiers/sygus/term_database_sygus.cpp +++ b/src/theory/quantifiers/sygus/term_database_sygus.cpp @@ -2,9 +2,9 @@ /*! \file term_database_sygus.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Haniel Barbosa, Aina Niemetz + ** Andrew Reynolds, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -1633,6 +1633,33 @@ Node TermDbSygus::evaluateWithUnfolding( while (ret.getKind() == DT_SYGUS_EVAL && ret[0].getKind() == APPLY_CONSTRUCTOR) { + if (ret == n && ret[0].isConst()) + { + Trace("dt-eval-unfold-debug") + << "Optimize: evaluate constant head " << ret << std::endl; + // can just do direct evaluation here + std::vector<Node> args; + bool success = true; + for (unsigned i = 1, nchild = ret.getNumChildren(); i < nchild; i++) + { + if (!ret[i].isConst()) + { + success = false; + break; + } + args.push_back(ret[i]); + } + if (success) + { + TypeNode rt = ret[0].getType(); + Node bret = sygusToBuiltin(ret[0], rt); + Node rete = evaluateBuiltin(rt, bret, args); + visited[n] = rete; + Trace("dt-eval-unfold-debug") + << "Return " << rete << " for " << n << std::endl; + return rete; + } + } ret = unfold( ret ); } if( ret.getNumChildren()>0 ){ diff --git a/src/theory/quantifiers/sygus/term_database_sygus.h b/src/theory/quantifiers/sygus/term_database_sygus.h index 7a522ded6..0f3d650d3 100644 --- a/src/theory/quantifiers/sygus/term_database_sygus.h +++ b/src/theory/quantifiers/sygus/term_database_sygus.h @@ -2,9 +2,9 @@ /*! \file term_database_sygus.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Andres Noetzli, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__TERM_DATABASE_SYGUS_H -#define __CVC4__THEORY__QUANTIFIERS__TERM_DATABASE_SYGUS_H +#ifndef CVC4__THEORY__QUANTIFIERS__TERM_DATABASE_SYGUS_H +#define CVC4__THEORY__QUANTIFIERS__TERM_DATABASE_SYGUS_H #include <unordered_set> @@ -599,4 +599,4 @@ class TermDbSygus { }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__TERM_DATABASE_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__TERM_DATABASE_H */ diff --git a/src/theory/quantifiers/sygus_sampler.cpp b/src/theory/quantifiers/sygus_sampler.cpp index f1908fc19..10d7ef6ab 100644 --- a/src/theory/quantifiers/sygus_sampler.cpp +++ b/src/theory/quantifiers/sygus_sampler.cpp @@ -2,9 +2,9 @@ /*! \file sygus_sampler.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Haniel Barbosa + ** Andrew Reynolds, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -40,7 +40,6 @@ void SygusSampler::initialize(TypeNode tn, d_tds = nullptr; d_use_sygus_type = false; d_is_valid = true; - d_tn = tn; d_ftn = TypeNode::null(); d_type_vars.clear(); d_vars.clear(); @@ -95,7 +94,6 @@ void SygusSampler::initializeSygus(TermDbSygus* tds, Assert(d_ftn.isDatatype()); const Datatype& dt = static_cast<DatatypeType>(d_ftn.toType()).getDatatype(); Assert(dt.isSygus()); - d_tn = TypeNode::fromType(dt.getSygusType()); Trace("sygus-sample") << "Register sampler for " << f << std::endl; @@ -264,28 +262,30 @@ bool SygusSampler::PtTrie::add(std::vector<Node>& pt) Node SygusSampler::registerTerm(Node n, bool forceKeep) { - if (d_is_valid) + if (!d_is_valid) { - Node bn = n; - // if this is a sygus type, get its builtin analog - if (d_use_sygus_type) - { - Assert(!d_ftn.isNull()); - bn = d_tds->sygusToBuiltin(n); - Assert(d_builtin_to_sygus.find(bn) == d_builtin_to_sygus.end() - || d_builtin_to_sygus[bn] == n); - d_builtin_to_sygus[bn] = n; - } - Assert(bn.getType() == d_tn); - Node res = d_trie.add(bn, this, 0, d_samples.size(), forceKeep); - if (d_use_sygus_type) - { - Assert(d_builtin_to_sygus.find(res) != d_builtin_to_sygus.end()); - res = res != bn ? d_builtin_to_sygus[res] : n; - } - return res; + // do nothing + return n; + } + Node bn = n; + TypeNode tn = n.getType(); + // If we are using sygus types, get the builtin analog of n. + if (d_use_sygus_type) + { + bn = d_tds->sygusToBuiltin(n); + d_builtin_to_sygus[tn][bn] = n; + } + // cache based on the (original) type of n + Node res = d_trie[tn].add(bn, this, 0, d_samples.size(), forceKeep); + // If we are using sygus types, map back to an original. + // Notice that d_builtin_to_sygus is not necessarily bijective. + if (d_use_sygus_type) + { + std::map<Node, Node>& bts = d_builtin_to_sygus[tn]; + Assert(bts.find(res) != bts.end()); + res = res != bn ? bts[res] : n; } - return n; + return res; } bool SygusSampler::isContiguous(Node n) diff --git a/src/theory/quantifiers/sygus_sampler.h b/src/theory/quantifiers/sygus_sampler.h index 28f715b34..429b6f511 100644 --- a/src/theory/quantifiers/sygus_sampler.h +++ b/src/theory/quantifiers/sygus_sampler.h @@ -2,9 +2,9 @@ /*! \file sygus_sampler.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Mathias Preiner + ** Andrew Reynolds, FabianWolff, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__SYGUS_SAMPLER_H -#define __CVC4__THEORY__QUANTIFIERS__SYGUS_SAMPLER_H +#ifndef CVC4__THEORY__QUANTIFIERS__SYGUS_SAMPLER_H +#define CVC4__THEORY__QUANTIFIERS__SYGUS_SAMPLER_H #include <map> #include "theory/evaluator.h" @@ -194,14 +194,15 @@ class SygusSampler : public LazyTrieEvaluator }; /** a trie for samples */ PtTrie d_samples_trie; - /** type of nodes we will be registering with this class */ - TypeNode d_tn; /** the sygus type for this sampler (if applicable). */ TypeNode d_ftn; - /** whether we are registering terms of type d_ftn */ + /** whether we are registering terms of sygus types with this sampler */ bool d_use_sygus_type; - /** map from builtin terms to the sygus term they correspond to */ - std::map<Node, Node> d_builtin_to_sygus; + /** + * For each (sygus) type, a map from builtin terms to the sygus term they + * correspond to. + */ + std::map<TypeNode, std::map<Node, Node> > d_builtin_to_sygus; /** all variables we are sampling values for */ std::vector<Node> d_vars; /** type variables @@ -235,8 +236,22 @@ class SygusSampler : public LazyTrieEvaluator * that type. */ std::map<TypeNode, std::vector<Node> > d_type_consts; - /** the lazy trie */ - LazyTrie d_trie; + /** a lazy trie for each type + * + * This stores the evaluation of all terms registered to this class. + * + * Notice if we are registering sygus terms with this class, then terms + * are grouped into this trie according to their sygus type, and not their + * builtin type. For example, for grammar: + * A -> x | B+1 + * B -> x | 0 | 1 | B+B + * If we register C^B_+( C^B_x(), C^B_0() ) and C^A_x() with this class, + * then x+0 is registered to d_trie[B] and x is registered to d_trie[A], + * and no rewrite rule is reported. The reason for this is that otherwise + * we would end up reporting many useless rewrites since the same builtin + * term can be generated by multiple sygus types (e.g. C^B_x() and C^A_x()). + */ + std::map<TypeNode, LazyTrie> d_trie; /** is this sampler valid? * * A sampler can be invalid if sample points cannot be generated for a type @@ -307,4 +322,4 @@ class SygusSampler : public LazyTrieEvaluator } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__SYGUS_SAMPLER_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__SYGUS_SAMPLER_H */ diff --git a/src/theory/quantifiers/term_canonize.cpp b/src/theory/quantifiers/term_canonize.cpp index d257198d9..9817da5a1 100644 --- a/src/theory/quantifiers/term_canonize.cpp +++ b/src/theory/quantifiers/term_canonize.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/term_canonize.h b/src/theory/quantifiers/term_canonize.h index e23627271..8f7b8722e 100644 --- a/src/theory/quantifiers/term_canonize.h +++ b/src/theory/quantifiers/term_canonize.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__TERM_CANONIZE_H -#define __CVC4__THEORY__QUANTIFIERS__TERM_CANONIZE_H +#ifndef CVC4__THEORY__QUANTIFIERS__TERM_CANONIZE_H +#define CVC4__THEORY__QUANTIFIERS__TERM_CANONIZE_H #include <map> #include "expr/node.h" @@ -89,4 +89,4 @@ class TermCanonize } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__QUANTIFIERS__TERM_CANONIZE_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__TERM_CANONIZE_H */ diff --git a/src/theory/quantifiers/term_database.cpp b/src/theory/quantifiers/term_database.cpp index 44c5586c3..abb84ccd7 100644 --- a/src/theory/quantifiers/term_database.cpp +++ b/src/theory/quantifiers/term_database.cpp @@ -2,9 +2,9 @@ /*! \file term_database.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Francois Bobot + ** Andrew Reynolds, Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -228,7 +228,7 @@ void TermDb::addTerm(Node n, d_iclosure_processed.insert(n); rec = true; } - if (rec && n.getKind() != FORALL) + if (rec && !n.isClosure()) { for (const Node& nc : n) { @@ -509,88 +509,196 @@ bool TermDb::inRelevantDomain( TNode f, unsigned i, TNode r ) { } } -//return a term n' equivalent to n -// maximal subterms of n' are representatives in the equality engine qy -Node TermDb::evaluateTerm2( TNode n, std::map< TNode, Node >& visited, EqualityQuery * qy, bool useEntailmentTests ) { +Node TermDb::evaluateTerm2(TNode n, + std::map<TNode, Node>& visited, + std::vector<Node>& exp, + EqualityQuery* qy, + bool useEntailmentTests, + bool computeExp, + bool reqHasTerm) +{ std::map< TNode, Node >::iterator itv = visited.find( n ); if( itv != visited.end() ){ return itv->second; } + size_t prevSize = exp.size(); Trace("term-db-eval") << "evaluate term : " << n << std::endl; Node ret = n; if( n.getKind()==FORALL || n.getKind()==BOUND_VARIABLE ){ //do nothing - }else if( !qy->hasTerm( n ) ){ - //term is not known to be equal to a representative in equality engine, evaluate it - if( n.hasOperator() ){ - TNode f = getMatchOperator( n ); - std::vector< TNode > args; - bool ret_set = false; - for( unsigned i=0; i<n.getNumChildren(); i++ ){ - TNode c = evaluateTerm2( n[i], visited, qy, useEntailmentTests ); - if( c.isNull() ){ - ret = Node::null(); + } + else if (qy->hasTerm(n)) + { + Trace("term-db-eval") << "...exists in ee, return rep" << std::endl; + ret = qy->getRepresentative(n); + if (computeExp) + { + if (n != ret) + { + exp.push_back(n.eqNode(ret)); + } + } + reqHasTerm = false; + } + else if (n.hasOperator()) + { + std::vector<TNode> args; + bool ret_set = false; + Kind k = n.getKind(); + std::vector<Node> tempExp; + for (unsigned i = 0, nchild = n.getNumChildren(); i < nchild; i++) + { + TNode c = evaluateTerm2(n[i], + visited, + tempExp, + qy, + useEntailmentTests, + computeExp, + reqHasTerm); + if (c.isNull()) + { + ret = Node::null(); + ret_set = true; + break; + } + else if (c == d_true || c == d_false) + { + // short-circuiting + if ((k == AND && c == d_false) || (k == OR && c == d_true)) + { + ret = c; + ret_set = true; + reqHasTerm = false; + break; + } + else if (k == ITE && i == 0) + { + ret = evaluateTerm2(n[c == d_true ? 1 : 2], + visited, + tempExp, + qy, + useEntailmentTests, + computeExp, + reqHasTerm); ret_set = true; + reqHasTerm = false; break; - }else if( c==d_true || c==d_false ){ - //short-circuiting - if( ( n.getKind()==kind::AND && c==d_false ) || ( n.getKind()==kind::OR && c==d_true ) ){ - ret = c; - ret_set = true; - break; - }else if( n.getKind()==kind::ITE && i==0 ){ - ret = evaluateTerm2( n[ c==d_true ? 1 : 2], visited, qy, useEntailmentTests ); - ret_set = true; - break; + } + } + if (computeExp) + { + exp.insert(exp.end(), tempExp.begin(), tempExp.end()); + } + Trace("term-db-eval") << " child " << i << " : " << c << std::endl; + args.push_back(c); + } + if (ret_set) + { + // if we short circuited + if (computeExp) + { + exp.clear(); + exp.insert(exp.end(), tempExp.begin(), tempExp.end()); + } + } + else + { + // get the (indexed) operator of n, if it exists + TNode f = getMatchOperator(n); + // if it is an indexed term, return the congruent term + if (!f.isNull()) + { + // if f is congruent to a term indexed by this class + TNode nn = qy->getCongruentTerm(f, args); + Trace("term-db-eval") << " got congruent term " << nn + << " from DB for " << n << std::endl; + if (!nn.isNull()) + { + if (computeExp) + { + Assert(nn.getNumChildren() == n.getNumChildren()); + for (unsigned i = 0, nchild = nn.getNumChildren(); i < nchild; i++) + { + if (nn[i] != n[i]) + { + exp.push_back(nn[i].eqNode(n[i])); + } + } + } + ret = qy->getRepresentative(nn); + Trace("term-db-eval") << "return rep" << std::endl; + ret_set = true; + reqHasTerm = false; + Assert(!ret.isNull()); + if (computeExp) + { + if (n != ret) + { + exp.push_back(nn.eqNode(ret)); + } } } - Trace("term-db-eval") << " child " << i << " : " << c << std::endl; - args.push_back( c ); } if( !ret_set ){ - //if it is an indexed term, return the congruent term - if( !f.isNull() ){ - TNode nn = qy->getCongruentTerm( f, args ); - Trace("term-db-eval") << " got congruent term " << nn << " from DB for " << n << std::endl; - if( !nn.isNull() ){ - ret = qy->getRepresentative( nn ); - Trace("term-db-eval") << "return rep" << std::endl; - ret_set = true; - Assert( !ret.isNull() ); - } + Trace("term-db-eval") << "return rewrite" << std::endl; + // a theory symbol or a new UF term + if (n.getMetaKind() == metakind::PARAMETERIZED) + { + args.insert(args.begin(), n.getOperator()); } - if( !ret_set ){ - Trace("term-db-eval") << "return rewrite" << std::endl; - //a theory symbol or a new UF term - if( n.getMetaKind() == kind::metakind::PARAMETERIZED ){ - args.insert( args.begin(), n.getOperator() ); - } - ret = NodeManager::currentNM()->mkNode( n.getKind(), args ); - ret = Rewriter::rewrite( ret ); - if( ret.getKind()==kind::EQUAL ){ - if( qy->areDisequal( ret[0], ret[1] ) ){ - ret = d_false; - } + ret = NodeManager::currentNM()->mkNode(n.getKind(), args); + ret = Rewriter::rewrite(ret); + if (ret.getKind() == EQUAL) + { + if (qy->areDisequal(ret[0], ret[1])) + { + ret = d_false; } - if( useEntailmentTests ){ - if( ret.getKind()==kind::EQUAL || ret.getKind()==kind::GEQ ){ - for( unsigned j=0; j<2; j++ ){ - std::pair<bool, Node> et = d_quantEngine->getTheoryEngine()->entailmentCheck(THEORY_OF_TYPE_BASED, j==0 ? ret : ret.negate() ); - if( et.first ){ - ret = j==0 ? d_true : d_false; - break; + } + if (useEntailmentTests) + { + if (ret.getKind() == EQUAL || ret.getKind() == GEQ) + { + TheoryEngine* te = d_quantEngine->getTheoryEngine(); + for (unsigned j = 0; j < 2; j++) + { + std::pair<bool, Node> et = te->entailmentCheck( + THEORY_OF_TYPE_BASED, j == 0 ? ret : ret.negate()); + if (et.first) + { + ret = j == 0 ? d_true : d_false; + if (computeExp) + { + exp.push_back(et.second); } + break; } } } } } } - }else{ - Trace("term-db-eval") << "...exists in ee, return rep" << std::endl; - ret = qy->getRepresentative( n ); } - Trace("term-db-eval") << "evaluated term : " << n << ", got : " << ret << std::endl; + // must have the term + if (reqHasTerm && !ret.isNull()) + { + Kind k = ret.getKind(); + if (k != OR && k != AND && k != EQUAL && k != ITE && k != NOT + && k != FORALL) + { + if (!qy->hasTerm(ret)) + { + ret = Node::null(); + } + } + } + Trace("term-db-eval") << "evaluated term : " << n << ", got : " << ret + << ", reqHasTerm = " << reqHasTerm << std::endl; + // clear the explanation if failed + if (computeExp && ret.isNull()) + { + exp.resize(prevSize); + } visited[n] = ret; return ret; } @@ -645,12 +753,33 @@ TNode TermDb::getEntailedTerm2( TNode n, std::map< TNode, TNode >& subs, bool su return TNode::null(); } -Node TermDb::evaluateTerm( TNode n, EqualityQuery * qy, bool useEntailmentTests ) { +Node TermDb::evaluateTerm(TNode n, + EqualityQuery* qy, + bool useEntailmentTests, + bool reqHasTerm) +{ if( qy==NULL ){ qy = d_quantEngine->getEqualityQuery(); } std::map< TNode, Node > visited; - return evaluateTerm2( n, visited, qy, useEntailmentTests ); + std::vector<Node> exp; + return evaluateTerm2( + n, visited, exp, qy, useEntailmentTests, false, reqHasTerm); +} + +Node TermDb::evaluateTerm(TNode n, + std::vector<Node>& exp, + EqualityQuery* qy, + bool useEntailmentTests, + bool reqHasTerm) +{ + if (qy == NULL) + { + qy = d_quantEngine->getEqualityQuery(); + } + std::map<TNode, Node> visited; + return evaluateTerm2( + n, visited, exp, qy, useEntailmentTests, true, reqHasTerm); } TNode TermDb::getEntailedTerm( TNode n, std::map< TNode, TNode >& subs, bool subsRep, EqualityQuery * qy ) { diff --git a/src/theory/quantifiers/term_database.h b/src/theory/quantifiers/term_database.h index cc9a24d08..148a18958 100644 --- a/src/theory/quantifiers/term_database.h +++ b/src/theory/quantifiers/term_database.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__TERM_DATABASE_H -#define __CVC4__THEORY__QUANTIFIERS__TERM_DATABASE_H +#ifndef CVC4__THEORY__QUANTIFIERS__TERM_DATABASE_H +#define CVC4__THEORY__QUANTIFIERS__TERM_DATABASE_H #include <map> #include <unordered_set> @@ -178,17 +178,37 @@ class TermDb : public QuantifiersUtil { bool inRelevantDomain(TNode f, unsigned i, TNode r); /** evaluate term * - * Returns a term n' such that n = n' is entailed based on the equality - * information qy. This function may generate new terms. In particular, - * we typically rewrite maximal - * subterms of n to terms that exist in the equality engine specified by qy. - * - * useEntailmentTests is whether to use the theory engine's entailmentCheck - * call, for increased precision. This is not frequently used. - */ + * Returns a term n' such that n = n' is entailed based on the equality + * information qy. This function may generate new terms. In particular, + * we typically rewrite subterms of n of maximal size to terms that exist in + * the equality engine specified by qy. + * + * useEntailmentTests is whether to call the theory engine's entailmentTest + * on literals n for which this call fails to find a term n' that is + * equivalent to n, for increased precision. This is not frequently used. + * + * The vector exp stores the explanation for why n evaluates to that term, + * that is, if this call returns a non-null node n', then: + * exp => n = n' + * + * If reqHasTerm, then we require that the returned term is a Boolean + * combination of terms that exist in the equality engine used by this call. + * If no such term is constructable, this call returns null. The motivation + * for setting this to true is to "fail fast" if we require the return value + * of this function to only involve existing terms. This is used e.g. in + * the "propagating instances" portion of conflict-based instantiation + * (quant_conflict_find.h). + */ + Node evaluateTerm(TNode n, + std::vector<Node>& exp, + EqualityQuery* qy = NULL, + bool useEntailmentTests = false, + bool reqHasTerm = false); + /** same as above, without exp */ Node evaluateTerm(TNode n, EqualityQuery* qy = NULL, - bool useEntailmentTests = false); + bool useEntailmentTests = false, + bool reqHasTerm = false); /** get entailed term * * If possible, returns a term n' such that: @@ -307,7 +327,13 @@ class TermDb : public QuantifiersUtil { /** set has term */ void setHasTerm( Node n ); /** helper for evaluate term */ - Node evaluateTerm2( TNode n, std::map< TNode, Node >& visited, EqualityQuery * qy, bool useEntailmentTests ); + Node evaluateTerm2(TNode n, + std::map<TNode, Node>& visited, + std::vector<Node>& exp, + EqualityQuery* qy, + bool useEntailmentTests, + bool computeExp, + bool reqHasTerm); /** helper for get entailed term */ TNode getEntailedTerm2( TNode n, std::map< TNode, TNode >& subs, bool subsRep, bool hasSubs, EqualityQuery * qy ); /** helper for is entailed */ @@ -383,4 +409,4 @@ class TermDb : public QuantifiersUtil { }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__TERM_DATABASE_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__TERM_DATABASE_H */ diff --git a/src/theory/quantifiers/term_enumeration.cpp b/src/theory/quantifiers/term_enumeration.cpp index 8e3219768..0336700ad 100644 --- a/src/theory/quantifiers/term_enumeration.cpp +++ b/src/theory/quantifiers/term_enumeration.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -87,6 +87,26 @@ bool TermEnumeration::mayComplete(TypeNode tn, unsigned maxCard) return mc; } +bool TermEnumeration::getDomain(TypeNode tn, std::vector<Node>& dom) +{ + if (!mayComplete(tn)) + { + return false; + } + Node curre; + unsigned counter = 0; + do + { + curre = getEnumerateTerm(tn, counter); + counter++; + if (!curre.isNull()) + { + dom.push_back(curre); + } + } while (!curre.isNull()); + return true; +} + } /* CVC4::theory::quantifiers namespace */ } /* CVC4::theory namespace */ } /* CVC4 namespace */ diff --git a/src/theory/quantifiers/term_enumeration.h b/src/theory/quantifiers/term_enumeration.h index cf25335f4..279680b1f 100644 --- a/src/theory/quantifiers/term_enumeration.h +++ b/src/theory/quantifiers/term_enumeration.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__TERM_ENUMERATION_H -#define __CVC4__THEORY__QUANTIFIERS__TERM_ENUMERATION_H +#ifndef CVC4__THEORY__QUANTIFIERS__TERM_ENUMERATION_H +#define CVC4__THEORY__QUANTIFIERS__TERM_ENUMERATION_H #include <unordered_map> #include <vector> @@ -56,6 +56,14 @@ class TermEnumeration */ static bool mayComplete(TypeNode tn, unsigned cardMax); + /** get domain + * + * If tn is a type such that mayComplete(tn) returns true, this method + * adds all domain elements of tn to dom and returns true. Otherwise, this + * method returns false. + */ + bool getDomain(TypeNode tn, std::vector<Node>& dom); + private: /** ground terms enumerated for types */ std::unordered_map<TypeNode, std::vector<Node>, TypeNodeHashFunction> @@ -74,4 +82,4 @@ class TermEnumeration } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__TERM_ENUMERATION_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__TERM_ENUMERATION_H */ diff --git a/src/theory/quantifiers/term_util.cpp b/src/theory/quantifiers/term_util.cpp index 4c9cf2c8d..065096607 100644 --- a/src/theory/quantifiers/term_util.cpp +++ b/src/theory/quantifiers/term_util.cpp @@ -2,9 +2,9 @@ /*! \file term_util.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Paul Meng, Yoni Zohar + ** Andrew Reynolds, Morgan Deters, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers/term_util.h b/src/theory/quantifiers/term_util.h index 820821991..1f2eea1c5 100644 --- a/src/theory/quantifiers/term_util.h +++ b/src/theory/quantifiers/term_util.h @@ -2,9 +2,9 @@ /*! \file term_util.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Mathias Preiner + ** Andrew Reynolds, Morgan Deters, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__TERM_UTIL_H -#define __CVC4__THEORY__QUANTIFIERS__TERM_UTIL_H +#ifndef CVC4__THEORY__QUANTIFIERS__TERM_UTIL_H +#define CVC4__THEORY__QUANTIFIERS__TERM_UTIL_H #include <map> #include <unordered_set> @@ -379,4 +379,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__TERM_UTIL_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__TERM_UTIL_H */ diff --git a/src/theory/quantifiers/theory_quantifiers.cpp b/src/theory/quantifiers/theory_quantifiers.cpp index 6f647aeb1..f24a4bb2b 100644 --- a/src/theory/quantifiers/theory_quantifiers.cpp +++ b/src/theory/quantifiers/theory_quantifiers.cpp @@ -2,9 +2,9 @@ /*! \file theory_quantifiers.cpp ** \verbatim ** Top contributors (to current version): - ** Morgan Deters, Andrew Reynolds, Tim King + ** Andrew Reynolds, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -38,8 +38,6 @@ using namespace CVC4::theory::quantifiers; TheoryQuantifiers::TheoryQuantifiers(Context* c, context::UserContext* u, OutputChannel& out, Valuation valuation, const LogicInfo& logicInfo) : Theory(THEORY_QUANTIFIERS, c, u, out, valuation, logicInfo) { - d_numInstantiations = 0; - d_baseDecLevel = -1; out.handleUserAttribute( "axiom", this ); out.handleUserAttribute( "conjecture", this ); out.handleUserAttribute( "fun-def", this ); @@ -71,13 +69,6 @@ void TheoryQuantifiers::preRegisterTerm(TNode n) { return; } Debug("quantifiers-prereg") << "TheoryQuantifiers::preRegisterTerm() " << n << endl; - if (options::cbqi() && !options::recurseCbqi() - && TermUtil::hasInstConstAttr(n)) - { - Debug("quantifiers-prereg") - << "TheoryQuantifiers::preRegisterTerm() done, unused " << n << endl; - return; - } // Preregister the quantified formula. // This initializes the modules used for handling n in this user context. getQuantifiersEngine()->preRegisterQuantifier(n); @@ -135,7 +126,7 @@ void TheoryQuantifiers::check(Effort e) { Trace("quantifiers-assert") << "quantifiers::assert(): " << assertion << std::endl; switch(assertion.getKind()) { case kind::FORALL: - assertUniversal( assertion ); + getQuantifiersEngine()->assertQuantifier(assertion, true); break; case kind::INST_CLOSURE: getQuantifiersEngine()->addTermToDatabase( assertion[0], false, true ); @@ -150,7 +141,7 @@ void TheoryQuantifiers::check(Effort e) { { switch( assertion[0].getKind()) { case kind::FORALL: - assertExistential( assertion ); + getQuantifiersEngine()->assertQuantifier(assertion[0], false); break; case kind::EQUAL: //do nothing @@ -171,20 +162,6 @@ void TheoryQuantifiers::check(Effort e) { getQuantifiersEngine()->check( e ); } -void TheoryQuantifiers::assertUniversal( Node n ){ - Assert( n.getKind()==FORALL ); - if( !options::cbqi() || options::recurseCbqi() || !TermUtil::hasInstConstAttr(n) ){ - getQuantifiersEngine()->assertQuantifier( n, true ); - } -} - -void TheoryQuantifiers::assertExistential( Node n ){ - Assert( n.getKind()== NOT && n[0].getKind()==FORALL ); - if( !options::cbqi() || options::recurseCbqi() || !TermUtil::hasInstConstAttr(n[0]) ){ - getQuantifiersEngine()->assertQuantifier( n[0], false ); - } -} - void TheoryQuantifiers::setUserAttribute(const std::string& attr, Node n, std::vector<Node> node_values, std::string str_value){ QuantAttributes::setUserAttribute( attr, n, node_values, str_value ); } diff --git a/src/theory/quantifiers/theory_quantifiers.h b/src/theory/quantifiers/theory_quantifiers.h index 55047fe2b..b5b07f2e6 100644 --- a/src/theory/quantifiers/theory_quantifiers.h +++ b/src/theory/quantifiers/theory_quantifiers.h @@ -2,9 +2,9 @@ /*! \file theory_quantifiers.h ** \verbatim ** Top contributors (to current version): - ** Morgan Deters, Tim King, Andrew Reynolds + ** Tim King, Morgan Deters, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__THEORY_QUANTIFIERS_H -#define __CVC4__THEORY__QUANTIFIERS__THEORY_QUANTIFIERS_H +#ifndef CVC4__THEORY__QUANTIFIERS__THEORY_QUANTIFIERS_H +#define CVC4__THEORY__QUANTIFIERS__THEORY_QUANTIFIERS_H #include "context/cdhashmap.h" #include "context/context.h" @@ -56,17 +56,10 @@ class TheoryQuantifiers : public Theory { std::vector<Node> node_values, std::string str_value) override; - private: - void assertUniversal( Node n ); - void assertExistential( Node n ); - /** number of instantiations */ - int d_numInstantiations; - int d_baseDecLevel; - };/* class TheoryQuantifiers */ }/* CVC4::theory::quantifiers namespace */ }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__THEORY_QUANTIFIERS_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__THEORY_QUANTIFIERS_H */ diff --git a/src/theory/quantifiers/theory_quantifiers_type_rules.h b/src/theory/quantifiers/theory_quantifiers_type_rules.h index bac3ca58f..ad1c4c69b 100644 --- a/src/theory/quantifiers/theory_quantifiers_type_rules.h +++ b/src/theory/quantifiers/theory_quantifiers_type_rules.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters, Andrew Reynolds, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__THEORY_QUANTIFIERS_TYPE_RULES_H -#define __CVC4__THEORY__QUANTIFIERS__THEORY_QUANTIFIERS_TYPE_RULES_H +#ifndef CVC4__THEORY__QUANTIFIERS__THEORY_QUANTIFIERS_TYPE_RULES_H +#define CVC4__THEORY__QUANTIFIERS__THEORY_QUANTIFIERS_TYPE_RULES_H #include "expr/matcher.h" @@ -229,4 +229,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__THEORY_QUANTIFIERS_TYPE_RULES_H */ +#endif /* CVC4__THEORY__QUANTIFIERS__THEORY_QUANTIFIERS_TYPE_RULES_H */ diff --git a/src/theory/quantifiers_engine.cpp b/src/theory/quantifiers_engine.cpp index 433621d31..f86d82874 100644 --- a/src/theory/quantifiers_engine.cpp +++ b/src/theory/quantifiers_engine.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/quantifiers_engine.h b/src/theory/quantifiers_engine.h index 512f0c651..61e9053f5 100644 --- a/src/theory/quantifiers_engine.h +++ b/src/theory/quantifiers_engine.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Morgan Deters, Haniel Barbosa ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__QUANTIFIERS_ENGINE_H -#define __CVC4__THEORY__QUANTIFIERS_ENGINE_H +#ifndef CVC4__THEORY__QUANTIFIERS_ENGINE_H +#define CVC4__THEORY__QUANTIFIERS_ENGINE_H #include <iostream> #include <map> @@ -431,4 +431,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS_ENGINE_H */ +#endif /* CVC4__THEORY__QUANTIFIERS_ENGINE_H */ diff --git a/src/theory/rep_set.cpp b/src/theory/rep_set.cpp index dcd90c236..0530e7889 100644 --- a/src/theory/rep_set.cpp +++ b/src/theory/rep_set.cpp @@ -2,9 +2,9 @@ /*! \file rep_set.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King + ** Andrew Reynolds, Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/rep_set.h b/src/theory/rep_set.h index d5de1e520..d972a7a84 100644 --- a/src/theory/rep_set.h +++ b/src/theory/rep_set.h @@ -2,9 +2,9 @@ /*! \file rep_set.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Morgan Deters + ** Andrew Reynolds, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__REP_SET_H -#define __CVC4__THEORY__REP_SET_H +#ifndef CVC4__THEORY__REP_SET_H +#define CVC4__THEORY__REP_SET_H #include <map> #include <vector> @@ -313,4 +313,4 @@ class RepBoundExt }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__REP_SET_H */ +#endif /* CVC4__THEORY__REP_SET_H */ diff --git a/src/theory/rewriter.cpp b/src/theory/rewriter.cpp index 58f4832c0..3f9405785 100644 --- a/src/theory/rewriter.cpp +++ b/src/theory/rewriter.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Dejan Jovanovic, Liana Hadarean, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/rewriter.h b/src/theory/rewriter.h index cc948ae7c..5a15d15fb 100644 --- a/src/theory/rewriter.h +++ b/src/theory/rewriter.h @@ -2,9 +2,9 @@ /*! \file rewriter.h ** \verbatim ** Top contributors (to current version): - ** Dejan Jovanovic, Morgan Deters, Liana Hadarean + ** Morgan Deters, Dejan Jovanovic, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/rewriter_attributes.h b/src/theory/rewriter_attributes.h index 7fb6dbfaa..93120735e 100644 --- a/src/theory/rewriter_attributes.h +++ b/src/theory/rewriter_attributes.h @@ -2,9 +2,9 @@ /*! \file rewriter_attributes.h ** \verbatim ** Top contributors (to current version): - ** Dejan Jovanovic, Morgan Deters, Tim King + ** Dejan Jovanovic, Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/rewriter_tables_template.h b/src/theory/rewriter_tables_template.h index f34972781..531b62a49 100644 --- a/src/theory/rewriter_tables_template.h +++ b/src/theory/rewriter_tables_template.h @@ -2,9 +2,9 @@ /*! \file rewriter_tables_template.h ** \verbatim ** Top contributors (to current version): - ** Dejan Jovanovic, Tim King, Morgan Deters + ** Dejan Jovanovic, Tim King, Liana Hadarean ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/sep/theory_sep.cpp b/src/theory/sep/theory_sep.cpp index d1ba65dd8..b787cd94f 100644 --- a/src/theory/sep/theory_sep.cpp +++ b/src/theory/sep/theory_sep.cpp @@ -2,9 +2,9 @@ /*! \file theory_sep.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Mathias Preiner + ** Andrew Reynolds, Dejan Jovanovic, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/sep/theory_sep.h b/src/theory/sep/theory_sep.h index f8bb58784..ae044f6d7 100644 --- a/src/theory/sep/theory_sep.h +++ b/src/theory/sep/theory_sep.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Tim King, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__SEP__THEORY_SEP_H -#define __CVC4__THEORY__SEP__THEORY_SEP_H +#ifndef CVC4__THEORY__SEP__THEORY_SEP_H +#define CVC4__THEORY__SEP__THEORY_SEP_H #include "context/cdhashmap.h" #include "context/cdhashset.h" @@ -331,4 +331,4 @@ class TheorySep : public Theory { }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__SEP__THEORY_SEP_H */ +#endif /* CVC4__THEORY__SEP__THEORY_SEP_H */ diff --git a/src/theory/sep/theory_sep_rewriter.cpp b/src/theory/sep/theory_sep_rewriter.cpp index 614d4f7c4..92e7db7aa 100644 --- a/src/theory/sep/theory_sep_rewriter.cpp +++ b/src/theory/sep/theory_sep_rewriter.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/sep/theory_sep_rewriter.h b/src/theory/sep/theory_sep_rewriter.h index 8ed8c3de2..f4639efa3 100644 --- a/src/theory/sep/theory_sep_rewriter.h +++ b/src/theory/sep/theory_sep_rewriter.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -17,8 +17,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__SEP__THEORY_SEP_REWRITER_H -#define __CVC4__THEORY__SEP__THEORY_SEP_REWRITER_H +#ifndef CVC4__THEORY__SEP__THEORY_SEP_REWRITER_H +#define CVC4__THEORY__SEP__THEORY_SEP_REWRITER_H #include "theory/rewriter.h" #include "theory/type_enumerator.h" @@ -49,4 +49,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__SEP__THEORY_SEP_REWRITER_H */ +#endif /* CVC4__THEORY__SEP__THEORY_SEP_REWRITER_H */ diff --git a/src/theory/sep/theory_sep_type_rules.h b/src/theory/sep/theory_sep_type_rules.h index f5a59c41c..29adeda5a 100644 --- a/src/theory/sep/theory_sep_type_rules.h +++ b/src/theory/sep/theory_sep_type_rules.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__SEP__THEORY_SEP_TYPE_RULES_H -#define __CVC4__THEORY__SEP__THEORY_SEP_TYPE_RULES_H +#ifndef CVC4__THEORY__SEP__THEORY_SEP_TYPE_RULES_H +#define CVC4__THEORY__SEP__THEORY_SEP_TYPE_RULES_H namespace CVC4 { namespace theory { @@ -112,4 +112,4 @@ struct SepNilTypeRule { }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__SEP__THEORY_SEP_TYPE_RULES_H */ +#endif /* CVC4__THEORY__SEP__THEORY_SEP_TYPE_RULES_H */ diff --git a/src/theory/sets/normal_form.h b/src/theory/sets/normal_form.h index 16a32d989..d7c68a574 100644 --- a/src/theory/sets/normal_form.h +++ b/src/theory/sets/normal_form.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Kshitij Bansal, Andrew Reynolds, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__SETS__NORMAL_FORM_H -#define __CVC4__THEORY__SETS__NORMAL_FORM_H +#ifndef CVC4__THEORY__SETS__NORMAL_FORM_H +#define CVC4__THEORY__SETS__NORMAL_FORM_H namespace CVC4 { namespace theory { diff --git a/src/theory/sets/rels_utils.h b/src/theory/sets/rels_utils.h index 39175bf0f..1bbbb359b 100644 --- a/src/theory/sets/rels_utils.h +++ b/src/theory/sets/rels_utils.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/sets/theory_sets.cpp b/src/theory/sets/theory_sets.cpp index 188523a10..563a981b1 100644 --- a/src/theory/sets/theory_sets.cpp +++ b/src/theory/sets/theory_sets.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Kshitij Bansal, Andrew Reynolds, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/sets/theory_sets.h b/src/theory/sets/theory_sets.h index e679d33c3..414ba4b28 100644 --- a/src/theory/sets/theory_sets.h +++ b/src/theory/sets/theory_sets.h @@ -2,9 +2,9 @@ /*! \file theory_sets.h ** \verbatim ** Top contributors (to current version): - ** Kshitij Bansal, Tim King, Andrew Reynolds + ** Tim King, Kshitij Bansal, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__SETS__THEORY_SETS_H -#define __CVC4__THEORY__SETS__THEORY_SETS_H +#ifndef CVC4__THEORY__SETS__THEORY_SETS_H +#define CVC4__THEORY__SETS__THEORY_SETS_H #include <memory> @@ -71,4 +71,4 @@ class TheorySets : public Theory }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__SETS__THEORY_SETS_H */ +#endif /* CVC4__THEORY__SETS__THEORY_SETS_H */ diff --git a/src/theory/sets/theory_sets_private.cpp b/src/theory/sets/theory_sets_private.cpp index 1c302573e..a62a235c3 100644 --- a/src/theory/sets/theory_sets_private.cpp +++ b/src/theory/sets/theory_sets_private.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Kshitij Bansal, Paul Meng ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -700,9 +700,11 @@ void TheorySetsPrivate::fullEffortCheck(){ checkUpwardsClosure( lemmas ); flushLemmas( lemmas ); if( !hasProcessed() ){ - std::vector< Node > intro_sets; - //for cardinality - if( d_card_enabled ){ + checkDisequalities(lemmas); + flushLemmas(lemmas); + if (!hasProcessed() && d_card_enabled) + { + // for cardinality checkCardBuildGraph( lemmas ); flushLemmas( lemmas ); if( !hasProcessed() ){ @@ -712,28 +714,24 @@ void TheorySetsPrivate::fullEffortCheck(){ checkCardCycles( lemmas ); flushLemmas( lemmas ); if( !hasProcessed() ){ + std::vector<Node> intro_sets; checkNormalForms( lemmas, intro_sets ); flushLemmas( lemmas ); + if (!hasProcessed() && !intro_sets.empty()) + { + Assert(intro_sets.size() == 1); + Trace("sets-intro") + << "Introduce term : " << intro_sets[0] << std::endl; + Trace("sets-intro") << " Actual Intro : "; + debugPrintSet(intro_sets[0], "sets-nf"); + Trace("sets-nf") << std::endl; + Node k = getProxy(intro_sets[0]); + d_sentLemma = true; + } } } } } - if( !hasProcessed() ){ - checkDisequalities( lemmas ); - flushLemmas( lemmas ); - if( !hasProcessed() ){ - //introduce splitting on venn regions (absolute last resort) - if( d_card_enabled && !hasProcessed() && !intro_sets.empty() ){ - Assert( intro_sets.size()==1 ); - Trace("sets-intro") << "Introduce term : " << intro_sets[0] << std::endl; - Trace("sets-intro") << " Actual Intro : "; - debugPrintSet( intro_sets[0], "sets-nf" ); - Trace("sets-nf") << std::endl; - Node k = getProxy( intro_sets[0] ); - d_sentLemma = true; - } - } - } } } } @@ -1380,8 +1378,8 @@ void TheorySetsPrivate::checkNormalForm( Node eqc, std::vector< Node >& intro_se Assert( d_nf.find( eqc )==d_nf.end() ); bool success = true; + Node emp_set = getEmptySet(tn); if( !base.isNull() ){ - Node emp_set = getEmptySet( tn ); for( unsigned j=0; j<comps.size(); j++ ){ //compare if equal std::vector< Node > c; @@ -1491,12 +1489,24 @@ void TheorySetsPrivate::checkNormalForm( Node eqc, std::vector< Node >& intro_se Trace("sets-nf") << "----> N " << eqc << " => F " << base << std::endl; }else{ Trace("sets-nf") << "failed to build N " << eqc << std::endl; - Assert( false ); } }else{ - //normal form is this equivalence class - d_nf[eqc].push_back( eqc ); - Trace("sets-nf") << "----> N " << eqc << " => { " << eqc << " }" << std::endl; + // must ensure disequal from empty + if (!eqc.isConst() && !ee_areDisequal(eqc, emp_set) + && (d_pol_mems[0].find(eqc) == d_pol_mems[0].end() + || d_pol_mems[0][eqc].empty())) + { + Trace("sets-nf-debug") << "Split on leaf " << eqc << std::endl; + split(eqc.eqNode(emp_set)); + success = false; + } + else + { + // normal form is this equivalence class + d_nf[eqc].push_back(eqc); + Trace("sets-nf") << "----> N " << eqc << " => { " << eqc << " }" + << std::endl; + } } if( success ){ //send to parents diff --git a/src/theory/sets/theory_sets_private.h b/src/theory/sets/theory_sets_private.h index 447ac33a1..3014b2f2a 100644 --- a/src/theory/sets/theory_sets_private.h +++ b/src/theory/sets/theory_sets_private.h @@ -2,9 +2,9 @@ /*! \file theory_sets_private.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Kshitij Bansal, Mathias Preiner + ** Andrew Reynolds, Kshitij Bansal, Paul Meng ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__SETS__THEORY_SETS_PRIVATE_H -#define __CVC4__THEORY__SETS__THEORY_SETS_PRIVATE_H +#ifndef CVC4__THEORY__SETS__THEORY_SETS_PRIVATE_H +#define CVC4__THEORY__SETS__THEORY_SETS_PRIVATE_H #include "context/cdhashset.h" #include "context/cdqueue.h" @@ -334,4 +334,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__SETS__THEORY_SETS_PRIVATE_H */ +#endif /* CVC4__THEORY__SETS__THEORY_SETS_PRIVATE_H */ diff --git a/src/theory/sets/theory_sets_rels.cpp b/src/theory/sets/theory_sets_rels.cpp index ebfa6f8bb..74d0e5bd8 100644 --- a/src/theory/sets/theory_sets_rels.cpp +++ b/src/theory/sets/theory_sets_rels.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Paul Meng, Andrew Reynolds, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/sets/theory_sets_rels.h b/src/theory/sets/theory_sets_rels.h index 161b5195e..7cad0f18d 100644 --- a/src/theory/sets/theory_sets_rels.h +++ b/src/theory/sets/theory_sets_rels.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Paul Meng, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/sets/theory_sets_rewriter.cpp b/src/theory/sets/theory_sets_rewriter.cpp index 2a2015319..15cec0856 100644 --- a/src/theory/sets/theory_sets_rewriter.cpp +++ b/src/theory/sets/theory_sets_rewriter.cpp @@ -2,9 +2,9 @@ /*! \file theory_sets_rewriter.cpp ** \verbatim ** Top contributors (to current version): - ** Kshitij Bansal, Andrew Reynolds, Paul Meng + ** Andrew Reynolds, Kshitij Bansal, Paul Meng ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/sets/theory_sets_rewriter.h b/src/theory/sets/theory_sets_rewriter.h index c506f19a5..463d02d6d 100644 --- a/src/theory/sets/theory_sets_rewriter.h +++ b/src/theory/sets/theory_sets_rewriter.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Kshitij Bansal ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__SETS__THEORY_SETS_REWRITER_H -#define __CVC4__THEORY__SETS__THEORY_SETS_REWRITER_H +#ifndef CVC4__THEORY__SETS__THEORY_SETS_REWRITER_H +#define CVC4__THEORY__SETS__THEORY_SETS_REWRITER_H #include "theory/rewriter.h" @@ -89,4 +89,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__SETS__THEORY_SETS_REWRITER_H */ +#endif /* CVC4__THEORY__SETS__THEORY_SETS_REWRITER_H */ diff --git a/src/theory/sets/theory_sets_type_enumerator.h b/src/theory/sets/theory_sets_type_enumerator.h index 65a614f9a..5a6745367 100644 --- a/src/theory/sets/theory_sets_type_enumerator.h +++ b/src/theory/sets/theory_sets_type_enumerator.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Kshitij Bansal, Tim King, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -18,8 +18,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__SETS__TYPE_ENUMERATOR_H -#define __CVC4__THEORY__SETS__TYPE_ENUMERATOR_H +#ifndef CVC4__THEORY__SETS__TYPE_ENUMERATOR_H +#define CVC4__THEORY__SETS__TYPE_ENUMERATOR_H #include "theory/type_enumerator.h" #include "expr/type_node.h" @@ -183,4 +183,4 @@ class SetEnumerator : public TypeEnumeratorBase<SetEnumerator> { }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__SETS__TYPE_ENUMERATOR_H */ +#endif /* CVC4__THEORY__SETS__TYPE_ENUMERATOR_H */ diff --git a/src/theory/sets/theory_sets_type_rules.h b/src/theory/sets/theory_sets_type_rules.h index 8cbb62883..7e6038423 100644 --- a/src/theory/sets/theory_sets_type_rules.h +++ b/src/theory/sets/theory_sets_type_rules.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Kshitij Bansal, Andrew Reynolds, Paul Meng ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__SETS__THEORY_SETS_TYPE_RULES_H -#define __CVC4__THEORY__SETS__THEORY_SETS_TYPE_RULES_H +#ifndef CVC4__THEORY__SETS__THEORY_SETS_TYPE_RULES_H +#define CVC4__THEORY__SETS__THEORY_SETS_TYPE_RULES_H #include "theory/sets/normal_form.h" @@ -428,4 +428,4 @@ struct SetsProperties { }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__SETS__THEORY_SETS_TYPE_RULES_H */ +#endif /* CVC4__THEORY__SETS__THEORY_SETS_TYPE_RULES_H */ diff --git a/src/theory/shared_terms_database.cpp b/src/theory/shared_terms_database.cpp index ca10314e8..a13ac207a 100644 --- a/src/theory/shared_terms_database.cpp +++ b/src/theory/shared_terms_database.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Dejan Jovanovic, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/shared_terms_database.h b/src/theory/shared_terms_database.h index 5389c021f..0c73195c5 100644 --- a/src/theory/shared_terms_database.h +++ b/src/theory/shared_terms_database.h @@ -2,9 +2,9 @@ /*! \file shared_terms_database.h ** \verbatim ** Top contributors (to current version): - ** Dejan Jovanovic, Morgan Deters, Mathias Preiner + ** Dejan Jovanovic, Mathias Preiner, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/sort_inference.cpp b/src/theory/sort_inference.cpp index 74f2e4803..6c141cf2a 100644 --- a/src/theory/sort_inference.cpp +++ b/src/theory/sort_inference.cpp @@ -2,9 +2,9 @@ /*! \file sort_inference.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Paul Meng, Tim King + ** Andrew Reynolds, Paul Meng, Kshitij Bansal ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/sort_inference.h b/src/theory/sort_inference.h index b93d5531c..5b28f669d 100644 --- a/src/theory/sort_inference.h +++ b/src/theory/sort_inference.h @@ -2,9 +2,9 @@ /*! \file sort_inference.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Paul Meng, Tim King + ** Andrew Reynolds, Paul Meng ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__SORT_INFERENCE_H -#define __CVC4__SORT_INFERENCE_H +#ifndef CVC4__SORT_INFERENCE_H +#define CVC4__SORT_INFERENCE_H #include <iostream> #include <string> diff --git a/src/theory/strings/normal_form.cpp b/src/theory/strings/normal_form.cpp new file mode 100644 index 000000000..c70845d64 --- /dev/null +++ b/src/theory/strings/normal_form.cpp @@ -0,0 +1,163 @@ +/********************* */ +/*! \file normal_form.cpp + ** \verbatim + ** Top contributors (to current version): + ** Andrew Reynolds + ** This file is part of the CVC4 project. + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS + ** in the top-level source directory) and their institutional affiliations. + ** All rights reserved. See the file COPYING in the top-level source + ** directory for licensing information.\endverbatim + ** + ** \brief Implementation of normal form data structure for the theory of + ** strings. + **/ + +#include "theory/strings/normal_form.h" + +#include "options/strings_options.h" +#include "theory/rewriter.h" + +using namespace std; +using namespace CVC4::kind; + +namespace CVC4 { +namespace theory { +namespace strings { + +void NormalForm::init(Node base) +{ + Assert(base.getType().isString()); + Assert(base.getKind() != STRING_CONCAT); + d_base = base; + d_nf.clear(); + d_isRev = false; + d_exp.clear(); + d_expDep.clear(); + + // add to normal form + if (!base.isConst() || !base.getConst<String>().isEmptyString()) + { + d_nf.push_back(base); + } +} + +void NormalForm::reverse() +{ + std::reverse(d_nf.begin(), d_nf.end()); + d_isRev = !d_isRev; +} + +void NormalForm::splitConstant(unsigned index, Node c1, Node c2) +{ + Assert(Rewriter::rewrite(NodeManager::currentNM()->mkNode( + STRING_CONCAT, d_isRev ? c2 : c1, d_isRev ? c1 : c2)) + == d_nf[index]); + d_nf.insert(d_nf.begin() + index + 1, c2); + d_nf[index] = c1; + // update the dependency indices + // notice this is not critical for soundness: not doing the below incrementing + // will only lead to overapproximating when antecedants are required in + // explanations + for (const std::pair<Node, std::map<bool, unsigned> >& pe : d_expDep) + { + for (const std::pair<bool, unsigned>& pep : pe.second) + { + // See if this can be incremented: it can if this literal is not relevant + // to the current index, and hence it is not relevant for both c1 and c2. + Assert(pep.second >= 0 && pep.second <= d_nf.size()); + bool increment = (pep.first == d_isRev) + ? pep.second > index + : (d_nf.size() - 1 - pep.second) < index; + if (increment) + { + d_expDep[pe.first][pep.first] = pep.second + 1; + } + } + } +} + +void NormalForm::addToExplanation(Node exp, + unsigned new_val, + unsigned new_rev_val) +{ + if (std::find(d_exp.begin(), d_exp.end(), exp) == d_exp.end()) + { + d_exp.push_back(exp); + } + for (unsigned k = 0; k < 2; k++) + { + unsigned val = k == 0 ? new_val : new_rev_val; + std::map<bool, unsigned>::iterator itned = d_expDep[exp].find(k == 1); + if (itned == d_expDep[exp].end()) + { + Trace("strings-process-debug") + << "Deps : set dependency on " << exp << " to " << val + << " isRev=" << (k == 0) << std::endl; + d_expDep[exp][k == 1] = val; + } + else + { + Trace("strings-process-debug") + << "Deps : Multiple dependencies on " << exp << " : " << itned->second + << " " << val << " isRev=" << (k == 0) << std::endl; + // if we already have a dependency (in the case of non-linear string + // equalities), it is min/max + bool cmp = val > itned->second; + if (cmp == (k == 1)) + { + d_expDep[exp][k == 1] = val; + } + } + } +} + +void NormalForm::getExplanation(int index, std::vector<Node>& curr_exp) +{ + if (index == -1 || !options::stringMinPrefixExplain()) + { + curr_exp.insert(curr_exp.end(), d_exp.begin(), d_exp.end()); + return; + } + for (const Node& exp : d_exp) + { + int dep = static_cast<int>(d_expDep[exp][d_isRev]); + if (dep <= index) + { + curr_exp.push_back(exp); + Trace("strings-explain-prefix-debug") << " include : "; + } + else + { + Trace("strings-explain-prefix-debug") << " exclude : "; + } + Trace("strings-explain-prefix-debug") << exp << std::endl; + } +} + +void NormalForm::getExplanationForPrefixEq(NormalForm& nfi, + NormalForm& nfj, + int index_i, + int index_j, + std::vector<Node>& curr_exp) +{ + Assert(nfi.d_isRev == nfj.d_isRev); + Trace("strings-explain-prefix") + << "Get explanation for prefix " << index_i << ", " << index_j + << ", reverse = " << nfi.d_isRev << std::endl; + // get explanations + nfi.getExplanation(index_i, curr_exp); + nfj.getExplanation(index_j, curr_exp); + Trace("strings-explain-prefix") + << "Included " << curr_exp.size() << " / " + << (nfi.d_exp.size() + nfj.d_exp.size()) << std::endl; + if (nfi.d_base != nfj.d_base) + { + Node eq = nfi.d_base.eqNode(nfj.d_base); + curr_exp.push_back(eq); + } +} + +} // namespace strings +} // namespace theory +} // namespace CVC4 diff --git a/src/theory/strings/normal_form.h b/src/theory/strings/normal_form.h new file mode 100644 index 000000000..3d1326570 --- /dev/null +++ b/src/theory/strings/normal_form.h @@ -0,0 +1,159 @@ +/********************* */ +/*! \file normal_form.h + ** \verbatim + ** Top contributors (to current version): + ** Andrew Reynolds + ** This file is part of the CVC4 project. + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS + ** in the top-level source directory) and their institutional affiliations. + ** All rights reserved. See the file COPYING in the top-level source + ** directory for licensing information.\endverbatim + ** + ** \brief Normal form datastructure for the theory of strings. + **/ + +#include "cvc4_private.h" + +#ifndef CVC4__THEORY__STRINGS__NORMAL_FORM_H +#define CVC4__THEORY__STRINGS__NORMAL_FORM_H + +#include <map> +#include <vector> +#include "expr/node.h" + +namespace CVC4 { +namespace theory { +namespace strings { + +/** normal forms + * + * Stores information regarding the "normal form" of terms t in the current + * context. Normal forms can be associated with terms, or with string + * equivalence classes. For the latter, the normal form of an equivalence class + * exists if exactly one unique normal form is associated to a subset of its + * terms. + * + * In the following we use example where assertions are: + * { x = y, y = z, y = u ++ v, u = u1 ++ u2 } + * and equivalence class [x] = { x, y, z, u ++ v }, whose normal form is + * (u1, u2, v) + */ +class NormalForm +{ + public: + NormalForm() : d_isRev(false) {} + /** + * The "base" of the normal form. This is some term in the equivalence + * class of t that the normal form is based on. This is an arbitrary term + * which is used as the reference point for explanations. In the above + * running example, let us assume the base of [x] is y. + */ + Node d_base; + /** the normal form, (u1, u2, v), in the above example */ + std::vector<Node> d_nf; + /** is the normal form d_nf stored in reverse order? */ + bool d_isRev; + /** + * The explanation for the normal form, this is a set of literals such that + * d_exp => d_base = d_nf + * In the above example, this is the set of equalities + * { y = u ++ v, u = u1 ++ u2 } + * If u ++ v was chosen as the base, then the first literal could be omitted. + */ + std::vector<Node> d_exp; + /** + * Map from literals in the vector d_exp to integers indicating indices in + * d_nf for which that literal L is relevant for explaining d_base = d_nf. + * + * In particular: + * - false maps to an (ideally maximal) index relative to the start of d_nf + * such that L is required for explaining why d_base has a prefix that + * includes the term at that index, + * - true maps to an (ideally maximal) index relative to the end of d_nf + * such that L is required for explaining why d_base has a suffix that + * includes the term at that index. + * We call these the forward and backwards dependency indices. + * + * In the above example: + * y = u ++ v : false -> 0, true -> 0 + * u = u1 ++ u2 : false -> 0, true -> 1 + * When explaining y = u1 ++ u2 ++ v, the equality y = u ++ v is required + * for explaining any prefix/suffix of y and its normal form. More + * interestingly, the equality u = u1 ++ u2 is not required for explaining + * that v is a suffix of y, since its reverse index in this map is 1, + * indicating that "u2" is the first position in u1 ++ u2 ++ v that it is + * required for explaining. + * + * This information is used to minimize explanations when conflicts arise, + * thereby strengthening conflict clauses and lemmas. + * + * For example, say u ++ v = y = x = u ++ w and w and v are distinct + * constants, using this dependency information, we could construct a + * conflict: + * x = y ^ y = u ++ v ^ x = u ++ w + * that does not include u = u1 ++ u2, because the conflict only pertains + * to the last position in the normal form of y. + */ + std::map<Node, std::map<bool, unsigned> > d_expDep; + /** initialize + * + * Initialize the normal form with base node base. If base is not the empty + * string, then d_nf is set to the singleton list containing base, otherwise + * d_nf is empty. + */ + void init(Node base); + /** reverse the content of normal form d_nf + * + * This operation is done in contexts where the normal form is being scanned + * in reverse order. + */ + void reverse(); + /** split constant + * + * Splits the constant in d_nf at index to constants c1 and c2. + * + * Notice this function depends on whether the normal form has been reversed + * d_isRev, as this impacts how the dependency indices are updated. + */ + void splitConstant(unsigned index, Node c1, Node c2); + /** add to explanation + * + * This adds exp to the explanation vector d_exp with new forward and + * backwards dependency indices new_val and new_rev_val. + * + * If exp already has dependencies, we update the forward dependency + * index to the minimum of the previous value and the new value, and + * similarly update the backwards dependency index to the maximum. + */ + void addToExplanation(Node exp, unsigned new_val, unsigned new_rev_val); + /** get explanation + * + * This gets the explanation for the prefix (resp. suffix) of the normal + * form up to index when d_isRev is false (resp. true). In particular; + * + * If index is -1, then this method adds all literals in d_exp to curr_exp. + * + * If index>=0, this method adds all literals in d_exp to curr_exp whose + * forward (resp. backwards) dependency index is less than index + * when isRev is false (resp. true). + */ + void getExplanation(int index, std::vector<Node>& curr_exp); + /** get explanation for prefix equality + * + * This adds to curr_exp the reason why the prefix of nfi up to index index_i + * is equivalent to the prefix of nfj up to index_j. The values of + * nfi.d_isRev and nfj.d_isRev affect how dependency indices are updated + * during this call. + */ + static void getExplanationForPrefixEq(NormalForm& nfi, + NormalForm& nfj, + int index_i, + int index_j, + std::vector<Node>& curr_exp); +}; + +} // namespace strings +} // namespace theory +} // namespace CVC4 + +#endif /* CVC4__THEORY__STRINGS__NORMAL_FORM_H */ diff --git a/src/theory/strings/regexp_elim.cpp b/src/theory/strings/regexp_elim.cpp index 749816280..b6a997629 100644 --- a/src/theory/strings/regexp_elim.cpp +++ b/src/theory/strings/regexp_elim.cpp @@ -2,9 +2,9 @@ /*! \file regexp_elim.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Tianyi Liang ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -347,10 +347,10 @@ Node RegExpElimination::eliminateConcat(Node atom) for (unsigned r = 0; r < 2; r++) { unsigned index = r == 0 ? 0 : nchildren - 1; - Assert(children[index + (r == 0 ? 1 : -1)].getKind() != STRING_TO_REGEXP); Node c = children[index]; if (c.getKind() == STRING_TO_REGEXP) { + Assert(children[index + (r == 0 ? 1 : -1)].getKind() != STRING_TO_REGEXP); Node s = c[0]; Node lens = nm->mkNode(STRING_LENGTH, s); Node sss = r == 0 ? d_zero : nm->mkNode(MINUS, lenx, lens); @@ -375,9 +375,9 @@ Node RegExpElimination::eliminateConcat(Node atom) rexpElimChildren.push_back(c); } } - Assert(rexpElimChildren.size() + sConstraints.size() == nchildren); if (!sConstraints.empty()) { + Assert(rexpElimChildren.size() + sConstraints.size() == nchildren); Node ss = nm->mkNode(STRING_SUBSTR, x, sStartIndex, sLength); Assert(!rexpElimChildren.empty()); Node regElim = @@ -412,7 +412,7 @@ Node RegExpElimination::eliminateConcat(Node atom) Node bound = nm->mkNode(AND, nm->mkNode(LEQ, d_zero, k), - nm->mkNode(LT, k, nm->mkNode(MINUS, lenx, lens))); + nm->mkNode(LEQ, k, nm->mkNode(MINUS, lenx, lens))); echildren.push_back(bound); } Node substrEq = nm->mkNode(STRING_SUBSTR, x, k, lens).eqNode(s); diff --git a/src/theory/strings/regexp_elim.h b/src/theory/strings/regexp_elim.h index eddf33e71..dbd4102b6 100644 --- a/src/theory/strings/regexp_elim.h +++ b/src/theory/strings/regexp_elim.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ **/ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__STRINGS__REGEXP_ELIM_H -#define __CVC4__THEORY__STRINGS__REGEXP_ELIM_H +#ifndef CVC4__THEORY__STRINGS__REGEXP_ELIM_H +#define CVC4__THEORY__STRINGS__REGEXP_ELIM_H #include "expr/node.h" @@ -63,4 +63,4 @@ class RegExpElimination } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__STRINGS__REGEXP_ELIM_H */ +#endif /* CVC4__THEORY__STRINGS__REGEXP_ELIM_H */ diff --git a/src/theory/strings/regexp_operation.cpp b/src/theory/strings/regexp_operation.cpp index f53f82cc4..91beb1ab5 100644 --- a/src/theory/strings/regexp_operation.cpp +++ b/src/theory/strings/regexp_operation.cpp @@ -2,9 +2,9 @@ /*! \file regexp_operation.cpp ** \verbatim ** Top contributors (to current version): - ** Tianyi Liang, Tim King, Andrew Reynolds + ** Tianyi Liang, Andrew Reynolds, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/strings/regexp_operation.h b/src/theory/strings/regexp_operation.h index 57e68abfb..b2e3667fc 100644 --- a/src/theory/strings/regexp_operation.h +++ b/src/theory/strings/regexp_operation.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Tianyi Liang, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__STRINGS__REGEXP__OPERATION_H -#define __CVC4__THEORY__STRINGS__REGEXP__OPERATION_H +#ifndef CVC4__THEORY__STRINGS__REGEXP__OPERATION_H +#define CVC4__THEORY__STRINGS__REGEXP__OPERATION_H #include <vector> #include <set> @@ -100,4 +100,4 @@ class RegExpOpr { }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__STRINGS__REGEXP__OPERATION_H */ +#endif /* CVC4__THEORY__STRINGS__REGEXP__OPERATION_H */ diff --git a/src/theory/strings/regexp_solver.cpp b/src/theory/strings/regexp_solver.cpp new file mode 100644 index 000000000..f0e68890a --- /dev/null +++ b/src/theory/strings/regexp_solver.cpp @@ -0,0 +1,547 @@ +/********************* */ +/*! \file regexp_solver.cpp + ** \verbatim + ** Top contributors (to current version): + ** Andrew Reynolds, Tianyi Liang, Morgan Deters + ** This file is part of the CVC4 project. + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS + ** in the top-level source directory) and their institutional affiliations. + ** All rights reserved. See the file COPYING in the top-level source + ** directory for licensing information.\endverbatim + ** + ** \brief Implementation of the regular expression solver for the theory of + ** strings. + ** + **/ + +#include "theory/strings/regexp_solver.h" + +#include <cmath> + +#include "options/strings_options.h" +#include "theory/strings/theory_strings.h" +#include "theory/strings/theory_strings_rewriter.h" +#include "theory/theory_model.h" + +using namespace std; +using namespace CVC4::context; +using namespace CVC4::kind; + +namespace CVC4 { +namespace theory { +namespace strings { + +RegExpSolver::RegExpSolver(TheoryStrings& p, + context::Context* c, + context::UserContext* u) + : d_parent(p), + d_regexp_memberships(c), + d_regexp_ucached(u), + d_regexp_ccached(c), + d_pos_memberships(c), + d_neg_memberships(c), + d_inter_cache(c), + d_inter_index(c), + d_processed_memberships(c) +{ + d_emptyString = NodeManager::currentNM()->mkConst(::CVC4::String("")); + std::vector<Node> nvec; + d_emptyRegexp = NodeManager::currentNM()->mkNode(REGEXP_EMPTY, nvec); + d_true = NodeManager::currentNM()->mkConst(true); + d_false = NodeManager::currentNM()->mkConst(false); +} + +unsigned RegExpSolver::getNumMemberships(Node n, bool isPos) +{ + if (isPos) + { + NodeUIntMap::const_iterator it = d_pos_memberships.find(n); + if (it != d_pos_memberships.end()) + { + return (*it).second; + } + } + else + { + NodeUIntMap::const_iterator it = d_neg_memberships.find(n); + if (it != d_neg_memberships.end()) + { + return (*it).second; + } + } + return 0; +} + +Node RegExpSolver::getMembership(Node n, bool isPos, unsigned i) +{ + return isPos ? d_pos_memberships_data[n][i] : d_neg_memberships_data[n][i]; +} + +Node RegExpSolver::mkAnd(Node c1, Node c2) +{ + return NodeManager::currentNM()->mkNode(AND, c1, c2); +} + +void RegExpSolver::check() +{ + bool addedLemma = false; + bool changed = false; + std::vector<Node> processed; + std::vector<Node> cprocessed; + + Trace("regexp-debug") << "Checking Memberships ... " << std::endl; + for (NodeUIntMap::const_iterator itr_xr = d_pos_memberships.begin(); + itr_xr != d_pos_memberships.end(); + ++itr_xr) + { + bool spflag = false; + Node x = (*itr_xr).first; + Trace("regexp-debug") << "Checking Memberships for " << x << std::endl; + if (d_inter_index.find(x) == d_inter_index.end()) + { + d_inter_index[x] = 0; + } + int cur_inter_idx = d_inter_index[x]; + unsigned n_pmem = (*itr_xr).second; + Assert(getNumMemberships(x, true) == n_pmem); + if (cur_inter_idx != (int)n_pmem) + { + if (n_pmem == 1) + { + d_inter_cache[x] = getMembership(x, true, 0); + d_inter_index[x] = 1; + Trace("regexp-debug") << "... only one choice " << std::endl; + } + else if (n_pmem > 1) + { + Node r; + if (d_inter_cache.find(x) != d_inter_cache.end()) + { + r = d_inter_cache[x]; + } + if (r.isNull()) + { + r = getMembership(x, true, 0); + cur_inter_idx = 1; + } + + unsigned k_start = cur_inter_idx; + Trace("regexp-debug") << "... staring from : " << cur_inter_idx + << ", we have " << n_pmem << std::endl; + for (unsigned k = k_start; k < n_pmem; k++) + { + Node r2 = getMembership(x, true, k); + r = d_regexp_opr.intersect(r, r2, spflag); + if (spflag) + { + break; + } + else if (r == d_emptyRegexp) + { + std::vector<Node> vec_nodes; + for (unsigned kk = 0; kk <= k; kk++) + { + Node rr = getMembership(x, true, kk); + Node n = + NodeManager::currentNM()->mkNode(STRING_IN_REGEXP, x, rr); + vec_nodes.push_back(n); + } + Node conc; + d_parent.sendInference(vec_nodes, conc, "INTERSECT CONFLICT", true); + addedLemma = true; + break; + } + if (d_parent.inConflict()) + { + break; + } + } + // updates + if (!d_parent.inConflict() && !spflag) + { + d_inter_cache[x] = r; + d_inter_index[x] = (int)n_pmem; + } + } + } + } + + Trace("regexp-debug") + << "... No Intersect Conflict in Memberships, addedLemma: " << addedLemma + << std::endl; + if (!addedLemma) + { + NodeManager* nm = NodeManager::currentNM(); + for (unsigned i = 0; i < d_regexp_memberships.size(); i++) + { + // check regular expression membership + Node assertion = d_regexp_memberships[i]; + Trace("regexp-debug") + << "Check : " << assertion << " " + << (d_regexp_ucached.find(assertion) == d_regexp_ucached.end()) << " " + << (d_regexp_ccached.find(assertion) == d_regexp_ccached.end()) + << std::endl; + if (d_regexp_ucached.find(assertion) == d_regexp_ucached.end() + && d_regexp_ccached.find(assertion) == d_regexp_ccached.end()) + { + Trace("strings-regexp") + << "We have regular expression assertion : " << assertion + << std::endl; + Node atom = assertion.getKind() == NOT ? assertion[0] : assertion; + bool polarity = assertion.getKind() != NOT; + bool flag = true; + Node x = atom[0]; + Node r = atom[1]; + std::vector<Node> rnfexp; + + if (!x.isConst()) + { + x = d_parent.getNormalString(x, rnfexp); + changed = true; + } + if (!d_regexp_opr.checkConstRegExp(r)) + { + r = getNormalSymRegExp(r, rnfexp); + changed = true; + } + Trace("strings-regexp-nf") << "Term " << atom << " is normalized to " + << x << " IN " << r << std::endl; + if (changed) + { + Node tmp = Rewriter::rewrite(nm->mkNode(STRING_IN_REGEXP, x, r)); + if (!polarity) + { + tmp = tmp.negate(); + } + if (tmp == d_true) + { + d_regexp_ccached.insert(assertion); + continue; + } + else if (tmp == d_false) + { + std::vector<Node> exp_n; + exp_n.push_back(assertion); + Node conc = Node::null(); + d_parent.sendInference(rnfexp, exp_n, conc, "REGEXP NF Conflict"); + addedLemma = true; + break; + } + } + + if (polarity) + { + flag = checkPDerivative(x, r, atom, addedLemma, rnfexp); + } + else + { + if (!options::stringExp()) + { + throw LogicException( + "Strings Incomplete (due to Negative Membership) by default, " + "try --strings-exp option."); + } + } + if (flag) + { + // check if the term is atomic + Node xr = d_parent.getRepresentative(x); + Trace("strings-regexp") + << "Unroll/simplify membership of atomic term " << xr + << std::endl; + // if so, do simple unrolling + std::vector<Node> nvec; + if (nvec.empty()) + { + d_regexp_opr.simplify(atom, nvec, polarity); + } + std::vector<Node> exp_n; + exp_n.push_back(assertion); + Node conc = nvec.size() == 1 ? nvec[0] : nm->mkNode(AND, nvec); + conc = Rewriter::rewrite(conc); + d_parent.sendInference(rnfexp, exp_n, conc, "REGEXP_Unfold"); + addedLemma = true; + if (changed) + { + cprocessed.push_back(assertion); + } + else + { + processed.push_back(assertion); + } + } + } + if (d_parent.inConflict()) + { + break; + } + } + } + if (addedLemma) + { + if (!d_parent.inConflict()) + { + for (unsigned i = 0; i < processed.size(); i++) + { + Trace("strings-regexp") + << "...add " << processed[i] << " to u-cache." << std::endl; + d_regexp_ucached.insert(processed[i]); + } + for (unsigned i = 0; i < cprocessed.size(); i++) + { + Trace("strings-regexp") + << "...add " << cprocessed[i] << " to c-cache." << std::endl; + d_regexp_ccached.insert(cprocessed[i]); + } + } + } +} + +bool RegExpSolver::checkPDerivative( + Node x, Node r, Node atom, bool& addedLemma, std::vector<Node>& nf_exp) +{ + if (d_parent.areEqual(x, d_emptyString)) + { + Node exp; + switch (d_regexp_opr.delta(r, exp)) + { + case 0: + { + std::vector<Node> exp_n; + exp_n.push_back(atom); + exp_n.push_back(x.eqNode(d_emptyString)); + d_parent.sendInference(nf_exp, exp_n, exp, "RegExp Delta"); + addedLemma = true; + d_regexp_ccached.insert(atom); + return false; + } + case 1: + { + d_regexp_ccached.insert(atom); + break; + } + case 2: + { + std::vector<Node> exp_n; + exp_n.push_back(atom); + exp_n.push_back(x.eqNode(d_emptyString)); + Node conc; + d_parent.sendInference(nf_exp, exp_n, conc, "RegExp Delta CONFLICT"); + addedLemma = true; + d_regexp_ccached.insert(atom); + return false; + } + default: + // Impossible + break; + } + } + else + { + if (deriveRegExp(x, r, atom, nf_exp)) + { + addedLemma = true; + d_regexp_ccached.insert(atom); + return false; + } + } + return true; +} + +CVC4::String RegExpSolver::getHeadConst(Node x) +{ + if (x.isConst()) + { + return x.getConst<String>(); + } + else if (x.getKind() == STRING_CONCAT) + { + if (x[0].isConst()) + { + return x[0].getConst<String>(); + } + } + return d_emptyString.getConst<String>(); +} + +bool RegExpSolver::deriveRegExp(Node x, + Node r, + Node atom, + std::vector<Node>& ant) +{ + Assert(x != d_emptyString); + Trace("regexp-derive") << "RegExpSolver::deriveRegExp: x=" << x + << ", r= " << r << std::endl; + CVC4::String s = getHeadConst(x); + if (!s.isEmptyString() && d_regexp_opr.checkConstRegExp(r)) + { + Node conc = Node::null(); + Node dc = r; + bool flag = true; + for (unsigned i = 0; i < s.size(); ++i) + { + CVC4::String c = s.substr(i, 1); + Node dc2; + int rt = d_regexp_opr.derivativeS(dc, c, dc2); + dc = dc2; + if (rt == 2) + { + // CONFLICT + flag = false; + break; + } + } + // send lemma + if (flag) + { + if (x.isConst()) + { + Assert(false, + "Impossible: RegExpSolver::deriveRegExp: const string in const " + "regular expression."); + return false; + } + else + { + Assert(x.getKind() == STRING_CONCAT); + std::vector<Node> vec_nodes; + for (unsigned int i = 1; i < x.getNumChildren(); ++i) + { + vec_nodes.push_back(x[i]); + } + Node left = TheoryStringsRewriter::mkConcat(STRING_CONCAT, vec_nodes); + left = Rewriter::rewrite(left); + conc = NodeManager::currentNM()->mkNode(STRING_IN_REGEXP, left, dc); + } + } + std::vector<Node> exp_n; + exp_n.push_back(atom); + d_parent.sendInference(ant, exp_n, conc, "RegExp-Derive"); + return true; + } + return false; +} + +void RegExpSolver::addMembership(Node assertion) +{ + bool polarity = assertion.getKind() != NOT; + TNode atom = polarity ? assertion : assertion[0]; + Node x = atom[0]; + Node r = atom[1]; + if (polarity) + { + unsigned index = 0; + NodeUIntMap::const_iterator it = d_pos_memberships.find(x); + if (it != d_pos_memberships.end()) + { + index = (*it).second; + for (unsigned k = 0; k < index; k++) + { + if (k < d_pos_memberships_data[x].size()) + { + if (d_pos_memberships_data[x][k] == r) + { + return; + } + } + else + { + break; + } + } + } + d_pos_memberships[x] = index + 1; + if (index < d_pos_memberships_data[x].size()) + { + d_pos_memberships_data[x][index] = r; + } + else + { + d_pos_memberships_data[x].push_back(r); + } + } + else if (!options::stringIgnNegMembership()) + { + unsigned index = 0; + NodeUIntMap::const_iterator it = d_neg_memberships.find(x); + if (it != d_neg_memberships.end()) + { + index = (*it).second; + for (unsigned k = 0; k < index; k++) + { + if (k < d_neg_memberships_data[x].size()) + { + if (d_neg_memberships_data[x][k] == r) + { + return; + } + } + else + { + break; + } + } + } + d_neg_memberships[x] = index + 1; + if (index < d_neg_memberships_data[x].size()) + { + d_neg_memberships_data[x][index] = r; + } + else + { + d_neg_memberships_data[x].push_back(r); + } + } + // old + if (polarity || !options::stringIgnNegMembership()) + { + d_regexp_memberships.push_back(assertion); + } +} + +Node RegExpSolver::getNormalSymRegExp(Node r, std::vector<Node>& nf_exp) +{ + Node ret = r; + switch (r.getKind()) + { + case REGEXP_EMPTY: + case REGEXP_SIGMA: break; + case STRING_TO_REGEXP: + { + if (!r[0].isConst()) + { + Node tmp = d_parent.getNormalString(r[0], nf_exp); + if (tmp != r[0]) + { + ret = NodeManager::currentNM()->mkNode(STRING_TO_REGEXP, tmp); + } + } + break; + } + case REGEXP_CONCAT: + case REGEXP_UNION: + case REGEXP_INTER: + case REGEXP_STAR: + { + std::vector<Node> vec_nodes; + for (const Node& cr : r) + { + vec_nodes.push_back(getNormalSymRegExp(cr, nf_exp)); + } + ret = Rewriter::rewrite( + NodeManager::currentNM()->mkNode(r.getKind(), vec_nodes)); + break; + } + default: + { + Trace("strings-error") << "Unsupported term: " << r + << " in normalization SymRegExp." << std::endl; + Assert(false); + } + } + return ret; +} + +} // namespace strings +} // namespace theory +} // namespace CVC4 diff --git a/src/theory/strings/regexp_solver.h b/src/theory/strings/regexp_solver.h new file mode 100644 index 000000000..13b66557a --- /dev/null +++ b/src/theory/strings/regexp_solver.h @@ -0,0 +1,106 @@ +/********************* */ +/*! \file regexp_solver.h + ** \verbatim + ** Top contributors (to current version): + ** Andrew Reynolds, Tianyi Liang, Andres Noetzli + ** This file is part of the CVC4 project. + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS + ** in the top-level source directory) and their institutional affiliations. + ** All rights reserved. See the file COPYING in the top-level source + ** directory for licensing information.\endverbatim + ** + ** \brief Regular expression solver for the theory of strings. + ** + **/ + +#include "cvc4_private.h" + +#ifndef CVC4__THEORY__STRINGS__REGEXP_SOLVER_H +#define CVC4__THEORY__STRINGS__REGEXP_SOLVER_H + +#include <map> +#include "context/cdhashset.h" +#include "context/cdlist.h" +#include "context/context.h" +#include "expr/node.h" +#include "theory/strings/regexp_operation.h" +#include "util/regexp.h" + +namespace CVC4 { +namespace theory { +namespace strings { + +class TheoryStrings; + +class RegExpSolver +{ + typedef context::CDList<Node> NodeList; + typedef context::CDHashMap<Node, bool, NodeHashFunction> NodeBoolMap; + typedef context::CDHashMap<Node, int, NodeHashFunction> NodeIntMap; + typedef context::CDHashMap<Node, unsigned, NodeHashFunction> NodeUIntMap; + typedef context::CDHashMap<Node, Node, NodeHashFunction> NodeNodeMap; + typedef context::CDHashSet<Node, NodeHashFunction> NodeSet; + + public: + RegExpSolver(TheoryStrings& p, context::Context* c, context::UserContext* u); + ~RegExpSolver() {} + + /** add membership + * + * This informs this class that assertion is asserted in the current context. + * We expect that assertion is a (possibly negated) regular expression + * membership. + */ + void addMembership(Node assertion); + /** check + * + * Tells this solver to check whether the regular expressions asserted to it + * are consistent. If they are not, then this class will call the + * sendInference method of its parent TheoryString object, indicating that + * it requires a conflict or lemma to be processed. + */ + void check(); + + private: + // Constants + Node d_emptyString; + Node d_emptyRegexp; + Node d_true; + Node d_false; + /** the parent of this object */ + TheoryStrings& d_parent; + // check membership constraints + Node mkAnd(Node c1, Node c2); + bool checkPDerivative( + Node x, Node r, Node atom, bool& addedLemma, std::vector<Node>& nf_exp); + Node getMembership(Node n, bool isPos, unsigned i); + unsigned getNumMemberships(Node n, bool isPos); + CVC4::String getHeadConst(Node x); + bool deriveRegExp(Node x, Node r, Node atom, std::vector<Node>& ant); + Node getNormalSymRegExp(Node r, std::vector<Node>& nf_exp); + // regular expression memberships + NodeList d_regexp_memberships; + NodeSet d_regexp_ucached; + NodeSet d_regexp_ccached; + // stored assertions + NodeUIntMap d_pos_memberships; + std::map<Node, std::vector<Node> > d_pos_memberships_data; + NodeUIntMap d_neg_memberships; + std::map<Node, std::vector<Node> > d_neg_memberships_data; + // semi normal forms for symbolic expression + std::map<Node, Node> d_nf_regexps; + std::map<Node, std::vector<Node> > d_nf_regexps_exp; + // intersection + NodeNodeMap d_inter_cache; + NodeIntMap d_inter_index; + // processed memberships + NodeSet d_processed_memberships; + /** regular expression operation module */ + RegExpOpr d_regexp_opr; +}; /* class TheoryStrings */ + +} // namespace strings +} // namespace theory +} // namespace CVC4 + +#endif /* CVC4__THEORY__STRINGS__THEORY_STRINGS_H */ diff --git a/src/theory/strings/skolem_cache.cpp b/src/theory/strings/skolem_cache.cpp index 276cb70d6..669b424a4 100644 --- a/src/theory/strings/skolem_cache.cpp +++ b/src/theory/strings/skolem_cache.cpp @@ -2,9 +2,9 @@ /*! \file skolem_cache.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/strings/skolem_cache.h b/src/theory/strings/skolem_cache.h index a6e91a246..c1e3c7214 100644 --- a/src/theory/strings/skolem_cache.h +++ b/src/theory/strings/skolem_cache.h @@ -2,9 +2,9 @@ /*! \file skolem_cache.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__STRINGS__SKOLEM_CACHE_H -#define __CVC4__THEORY__STRINGS__SKOLEM_CACHE_H +#ifndef CVC4__THEORY__STRINGS__SKOLEM_CACHE_H +#define CVC4__THEORY__STRINGS__SKOLEM_CACHE_H #include <map> #include <tuple> @@ -168,4 +168,4 @@ class SkolemCache } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__STRINGS__SKOLEM_CACHE_H */ +#endif /* CVC4__THEORY__STRINGS__SKOLEM_CACHE_H */ diff --git a/src/theory/strings/theory_strings.cpp b/src/theory/strings/theory_strings.cpp index 23b818984..33fbbb174 100644 --- a/src/theory/strings/theory_strings.cpp +++ b/src/theory/strings/theory_strings.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Tianyi Liang, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -121,15 +121,7 @@ TheoryStrings::TheoryStrings(context::Context* c, d_functionsTerms(c), d_has_extf(c, false), d_has_str_code(false), - d_regexp_memberships(c), - d_regexp_ucached(u), - d_regexp_ccached(c), - d_pos_memberships(c), - d_neg_memberships(c), - d_inter_cache(c), - d_inter_index(c), - d_processed_memberships(c), - d_regexp_ant(c), + d_regexp_solver(*this, c, u), d_input_vars(u), d_input_var_lsum(u), d_cardinality_lits(u), @@ -169,8 +161,6 @@ TheoryStrings::TheoryStrings(context::Context* c, d_one = NodeManager::currentNM()->mkConst( Rational( 1 ) ); d_neg_one = NodeManager::currentNM()->mkConst(Rational(-1)); d_emptyString = NodeManager::currentNM()->mkConst( ::CVC4::String("") ); - std::vector< Node > nvec; - d_emptyRegexp = NodeManager::currentNM()->mkNode( kind::REGEXP_EMPTY, nvec ); d_true = NodeManager::currentNM()->mkConst( true ); d_false = NodeManager::currentNM()->mkConst( false ); @@ -258,6 +248,39 @@ Node TheoryStrings::getLength( Node t, std::vector< Node >& exp ) { return getLengthExp( t, exp, t ); } +Node TheoryStrings::getNormalString(Node x, std::vector<Node>& nf_exp) +{ + if (!x.isConst()) + { + Node xr = getRepresentative(x); + std::map<Node, NormalForm>::iterator it = d_normal_form.find(xr); + if (it != d_normal_form.end()) + { + NormalForm& nf = it->second; + Node ret = mkConcat(nf.d_nf); + nf_exp.insert(nf_exp.end(), nf.d_exp.begin(), nf.d_exp.end()); + addToExplanation(x, nf.d_base, nf_exp); + Trace("strings-debug") + << "Term: " << x << " has a normal form " << ret << std::endl; + return ret; + } + // if x does not have a normal form, then it should not occur in the + // equality engine and hence should be its own representative. + Assert(xr == x); + if (x.getKind() == kind::STRING_CONCAT) + { + std::vector<Node> vec_nodes; + for (unsigned i = 0; i < x.getNumChildren(); i++) + { + Node nc = getNormalString(x[i], nf_exp); + vec_nodes.push_back(nc); + } + return mkConcat(vec_nodes); + } + } + return x; +} + void TheoryStrings::setMasterEqualityEngine(eq::EqualityEngine* eq) { d_equalityEngine.setMasterEqualityEngine(eq); } @@ -377,11 +400,14 @@ bool TheoryStrings::getCurrentSubstitution( int effort, std::vector< Node >& var } }else if( effort>=1 && effort<3 && n.getType().isString() ){ //normal forms - Node ns = getNormalString( d_normal_forms_base[nr], exp[n] ); + NormalForm& nfnr = getNormalForm(nr); + Node ns = getNormalString(nfnr.d_base, exp[n]); subs.push_back( ns ); - Trace("strings-subs") << " normal eqc : " << ns << " " << d_normal_forms_base[nr] << " " << nr << std::endl; - if( !d_normal_forms_base[nr].isNull() ) { - addToExplanation( n, d_normal_forms_base[nr], exp[n] ); + Trace("strings-subs") << " normal eqc : " << ns << " " << nfnr.d_base + << " " << nr << std::endl; + if (!nfnr.d_base.isNull()) + { + addToExplanation(n, nfnr.d_base, exp[n]); } }else{ //representative? @@ -648,8 +674,8 @@ bool TheoryStrings::collectModelInfo(TheoryModel* m) //check if col[i][j] has only variables if (!eqc.isConst()) { - Assert(d_normal_forms.find(eqc) != d_normal_forms.end()); - if (d_normal_forms[eqc].size() == 1) + NormalForm& nfe = getNormalForm(eqc); + if (nfe.d_nf.size() == 1) { // does it have a code and the length of these equivalence classes are // one? @@ -772,20 +798,31 @@ bool TheoryStrings::collectModelInfo(TheoryModel* m) //step 4 : assign constants to all other equivalence classes for( unsigned i=0; i<nodes.size(); i++ ){ if( processed.find( nodes[i] )==processed.end() ){ - Assert( d_normal_forms.find( nodes[i] )!=d_normal_forms.end() ); - Trace("strings-model") << "Construct model for " << nodes[i] << " based on normal form "; - for( unsigned j=0; j<d_normal_forms[nodes[i]].size(); j++ ) { - if( j>0 ) Trace("strings-model") << " ++ "; - Trace("strings-model") << d_normal_forms[nodes[i]][j]; - Node r = getRepresentative( d_normal_forms[nodes[i]][j] ); - if( !r.isConst() && processed.find( r )==processed.end() ){ - Trace("strings-model") << "(UNPROCESSED)"; + NormalForm& nf = getNormalForm(nodes[i]); + if (Trace.isOn("strings-model")) + { + Trace("strings-model") + << "Construct model for " << nodes[i] << " based on normal form "; + for (unsigned j = 0, size = nf.d_nf.size(); j < size; j++) + { + Node n = nf.d_nf[j]; + if (j > 0) + { + Trace("strings-model") << " ++ "; + } + Trace("strings-model") << n; + Node r = getRepresentative(n); + if (!r.isConst() && processed.find(r) == processed.end()) + { + Trace("strings-model") << "(UNPROCESSED)"; + } } } Trace("strings-model") << std::endl; std::vector< Node > nc; - for( unsigned j=0; j<d_normal_forms[nodes[i]].size(); j++ ) { - Node r = getRepresentative( d_normal_forms[nodes[i]][j] ); + for (const Node& n : nf.d_nf) + { + Node r = getRepresentative(n); Assert( r.isConst() || processed.find( r )!=processed.end() ); nc.push_back(r.isConst() ? r : processed[r]); } @@ -885,8 +922,15 @@ void TheoryStrings::preRegisterTerm(TNode n) { // Function applications/predicates d_equalityEngine.addTerm(n); } - //concat terms do not contribute to theory combination? TODO: verify - if (n.hasOperator() && kindToTheoryId(k) == THEORY_STRINGS + // Set d_functionsTerms stores all function applications that are + // relevant to theory combination. Notice that this is a subset of + // the applications whose kinds are function kinds in the equality + // engine. This means it does not include applications of operators + // like re.++, which is not a function kind in the equality engine. + // Concatenation terms do not need to be considered here because + // their arguments have string type and do not introduce any shared + // terms. + if (n.hasOperator() && d_equalityEngine.isFunctionKind(k) && k != kind::STRING_CONCAT) { d_functionsTerms.push_back( n ); @@ -1023,6 +1067,30 @@ void TheoryStrings::checkExtfReductions( int effort ) { } } +void TheoryStrings::checkMemberships() +{ + // add the memberships + std::vector<Node> mems = getExtTheory()->getActive(kind::STRING_IN_REGEXP); + for (unsigned i = 0; i < mems.size(); i++) + { + Node n = mems[i]; + Assert(d_extf_info_tmp.find(n) != d_extf_info_tmp.end()); + if (!d_extf_info_tmp[n].d_const.isNull()) + { + bool pol = d_extf_info_tmp[n].d_const.getConst<bool>(); + Trace("strings-process-debug") + << " add membership : " << n << ", pol = " << pol << std::endl; + d_regexp_solver.addMembership(pol ? n : n.negate()); + } + else + { + Trace("strings-process-debug") + << " irrelevant (non-asserted) membership : " << n << std::endl; + } + } + d_regexp_solver.check(); +} + TheoryStrings::EqcInfo::EqcInfo(context::Context* c) : d_length_term(c), d_code_term(c), @@ -1572,7 +1640,6 @@ void TheoryStrings::checkExtfEval( int effort ) { einfo.d_exp.insert(einfo.d_exp.end(), exp[i].begin(), exp[i].end()); // inference is rewriting the substituted node Node nrc = Rewriter::rewrite( sn ); - Kind nrck = nrc.getKind(); //if rewrites to a constant, then do the inference and mark as reduced if( nrc.isConst() ){ if( effort<3 ){ @@ -1649,24 +1716,28 @@ void TheoryStrings::checkExtfEval( int effort ) { einfo.d_model_active = false; } } - //if it reduces to a conjunction, infer each and reduce } - else if ((nrck == OR && einfo.d_const == d_false) - || (nrck == AND && einfo.d_const == d_true)) + else { - Assert( effort<3 ); - getExtTheory()->markReduced( n ); - einfo.d_exp.push_back(einfo.d_const == d_false ? n.negate() : n); - Trace("strings-extf-debug") << " decomposable..." << std::endl; - Trace("strings-extf") << " resolve extf : " << sn << " -> " << nrc - << ", const = " << einfo.d_const << std::endl; - for (const Node& nrcc : nrc) + // if this was a predicate which changed after substitution + rewriting + if (!einfo.d_const.isNull() && nrc.getType().isBoolean() && nrc != n) { - sendInternalInference(einfo.d_exp, - einfo.d_const == d_false ? nrcc.negate() : nrcc, - effort == 0 ? "EXTF_d" : "EXTF_d-N"); + bool pol = einfo.d_const == d_true; + Node nrcAssert = pol ? nrc : nrc.negate(); + Node nAssert = pol ? n : n.negate(); + Assert(effort < 3); + einfo.d_exp.push_back(nAssert); + Trace("strings-extf-debug") << " decomposable..." << std::endl; + Trace("strings-extf") << " resolve extf : " << sn << " -> " << nrc + << ", const = " << einfo.d_const << std::endl; + // We send inferences internal here, which may help show unsat. + // However, we do not make a determination whether n can be marked + // reduced since this argument may be circular: we may infer than n + // can be reduced to something else, but that thing may argue that it + // can be reduced to n, in theory. + sendInternalInference( + einfo.d_exp, nrcAssert, effort == 0 ? "EXTF_d" : "EXTF_d-N"); } - }else{ to_reduce = nrc; } }else{ @@ -2418,8 +2489,7 @@ void TheoryStrings::checkNormalFormsEq() } // calculate normal forms for each equivalence class, possibly adding // splitting lemmas - d_normal_forms.clear(); - d_normal_forms_exp.clear(); + d_normal_form.clear(); std::map<Node, Node> nf_to_eqc; std::map<Node, Node> eqc_to_nf; std::map<Node, Node> eqc_to_exp; @@ -2433,16 +2503,17 @@ void TheoryStrings::checkNormalFormsEq() { return; } - Node nf_term = mkConcat(d_normal_forms[eqc]); + NormalForm& nfe = getNormalForm(eqc); + Node nf_term = mkConcat(nfe.d_nf); std::map<Node, Node>::iterator itn = nf_to_eqc.find(nf_term); if (itn != nf_to_eqc.end()) { + NormalForm& nfe_eq = getNormalForm(itn->second); // two equivalence classes have same normal form, merge std::vector<Node> nf_exp; - nf_exp.push_back(mkAnd(d_normal_forms_exp[eqc])); + nf_exp.push_back(mkAnd(nfe.d_exp)); nf_exp.push_back(eqc_to_exp[itn->second]); - Node eq = - d_normal_forms_base[eqc].eqNode(d_normal_forms_base[itn->second]); + Node eq = nfe.d_base.eqNode(nfe_eq.d_base); sendInference(nf_exp, eq, "Normal_Form"); if( hasProcessed() ){ return; @@ -2452,7 +2523,7 @@ void TheoryStrings::checkNormalFormsEq() { nf_to_eqc[nf_term] = eqc; eqc_to_nf[eqc] = nf_term; - eqc_to_exp[eqc] = mkAnd(d_normal_forms_exp[eqc]); + eqc_to_exp[eqc] = mkAnd(nfe.d_exp); } Trace("strings-process-debug") << "Done verifying normal forms are the same for " << eqc << std::endl; @@ -2464,8 +2535,8 @@ void TheoryStrings::checkNormalFormsEq() it != eqc_to_exp.end(); ++it) { - Trace("strings-nf") << " N[" << it->first << "] (base " - << d_normal_forms_base[it->first] + NormalForm& nf = getNormalForm(it->first); + Trace("strings-nf") << " N[" << it->first << "] (base " << nf.d_base << ") = " << eqc_to_nf[it->first] << std::endl; Trace("strings-nf") << " exp: " << it->second << std::endl; } @@ -2488,9 +2559,10 @@ void TheoryStrings::checkCodes() std::vector<Node> const_codes; for (const Node& eqc : d_strings_eqc) { - if (d_normal_forms[eqc].size() == 1 && d_normal_forms[eqc][0].isConst()) + NormalForm& nfe = getNormalForm(eqc); + if (nfe.d_nf.size() == 1 && nfe.d_nf[0].isConst()) { - Node c = d_normal_forms[eqc][0]; + Node c = nfe.d_nf[0]; Trace("strings-code-debug") << "Get proxy variable for " << c << std::endl; Node cc = nm->mkNode(kind::STRING_CODE, c); @@ -2559,83 +2631,65 @@ void TheoryStrings::normalizeEquivalenceClass( Node eqc ) { #endif //do nothing Trace("strings-process-debug") << "Return process equivalence class " << eqc << " : empty." << std::endl; - d_normal_forms_base[eqc] = d_emptyString; - d_normal_forms[eqc].clear(); - d_normal_forms_exp[eqc].clear(); + d_normal_form[eqc].init(d_emptyString); } else { - Assert( d_normal_forms.find(eqc)==d_normal_forms.end() ); - //phi => t = s1 * ... * sn - // normal form for each non-variable term in this eqc (s1...sn) - std::vector< std::vector< Node > > normal_forms; - // explanation for each normal form (phi) - std::vector< std::vector< Node > > normal_forms_exp; - // dependency information - std::vector< std::map< Node, std::map< bool, int > > > normal_forms_exp_depend; - // record terms for each normal form (t) - std::vector< Node > normal_form_src; - // get normal forms - getNormalForms(eqc, normal_forms, normal_form_src, normal_forms_exp, normal_forms_exp_depend); + // should not have computed the normal form of this equivalence class yet + Assert(d_normal_form.find(eqc) == d_normal_form.end()); + // Normal forms for the relevant terms in the equivalence class of eqc + std::vector<NormalForm> normal_forms; + // map each term to its index in the above vector + std::map<Node, unsigned> term_to_nf_index; + // get the normal forms + getNormalForms(eqc, normal_forms, term_to_nf_index); if( hasProcessed() ){ return; } // process the normal forms - processNEqc( normal_forms, normal_form_src, normal_forms_exp, normal_forms_exp_depend ); + processNEqc(normal_forms); if( hasProcessed() ){ return; } - //debugPrintNormalForms( "strings-solve", eqc, normal_forms, normal_form_src, normal_forms_exp, normal_forms_exp_depend ); - + // debugPrintNormalForms( "strings-solve", eqc, normal_forms ); + //construct the normal form Assert( !normal_forms.empty() ); - - int nf_index = 0; - std::vector< Node >::iterator itn = std::find( normal_form_src.begin(), normal_form_src.end(), eqc ); - if( itn!=normal_form_src.end() ){ - nf_index = itn - normal_form_src.begin(); - Trace("strings-solve-debug2") << "take normal form " << nf_index << std::endl; - Assert( normal_form_src[nf_index]==eqc ); - }else{ - //just take the first normal form - Trace("strings-solve-debug2") << "take the first normal form" << std::endl; - } - d_normal_forms[eqc].insert( d_normal_forms[eqc].end(), normal_forms[nf_index].begin(), normal_forms[nf_index].end() ); - d_normal_forms_exp[eqc].insert( d_normal_forms_exp[eqc].end(), normal_forms_exp[nf_index].begin(), normal_forms_exp[nf_index].end() ); - Trace("strings-solve-debug2") << "take normal form ... done" << std::endl; - d_normal_forms_base[eqc] = normal_form_src[nf_index]; - //track dependencies - for( unsigned i=0; i<normal_forms_exp[nf_index].size(); i++ ){ - Node exp = normal_forms_exp[nf_index][i]; - for( unsigned r=0; r<2; r++ ){ - d_normal_forms_exp_depend[eqc][exp][r==0] = normal_forms_exp_depend[nf_index][exp][r==0]; - } + unsigned nf_index = 0; + std::map<Node, unsigned>::iterator it = term_to_nf_index.find(eqc); + // we prefer taking the normal form whose base is the equivalence + // class representative, since this leads to shorter explanations in + // some cases. + if (it != term_to_nf_index.end()) + { + nf_index = it->second; } - Trace("strings-process-debug") << "Return process equivalence class " << eqc << " : returned, size = " << d_normal_forms[eqc].size() << std::endl; + d_normal_form[eqc] = normal_forms[nf_index]; + Trace("strings-process-debug") + << "Return process equivalence class " << eqc + << " : returned, size = " << d_normal_form[eqc].d_nf.size() + << std::endl; } } -void trackNfExpDependency( std::vector< Node >& nf_exp_n, std::map< Node, std::map< bool, int > >& nf_exp_depend_n, Node exp, int new_val, int new_rev_val ){ - if( std::find( nf_exp_n.begin(), nf_exp_n.end(), exp )==nf_exp_n.end() ){ - nf_exp_n.push_back( exp ); - } - for( unsigned k=0; k<2; k++ ){ - int val = k==0 ? new_val : new_rev_val; - std::map< bool, int >::iterator itned = nf_exp_depend_n[exp].find( k==1 ); - if( itned==nf_exp_depend_n[exp].end() ){ - Trace("strings-process-debug") << "Deps : set dependency on " << exp << " to " << val << " isRev=" << (k==0) << std::endl; - nf_exp_depend_n[exp][k==1] = val; - }else{ - Trace("strings-process-debug") << "Deps : Multiple dependencies on " << exp << " : " << itned->second << " " << val << " isRev=" << (k==0) << std::endl; - //if we already have a dependency (in the case of non-linear string equalities), it is min/max - bool cmp = val > itned->second; - if( cmp==(k==1) ){ - nf_exp_depend_n[exp][k==1] = val; - } - } +NormalForm& TheoryStrings::getNormalForm(Node n) +{ + std::map<Node, NormalForm>::iterator itn = d_normal_form.find(n); + if (itn == d_normal_form.end()) + { + Trace("strings-warn") << "WARNING: returning empty normal form for " << n + << std::endl; + // Shouln't ask for normal forms of strings that weren't computed. This + // likely means that n is not a representative or not a term in the current + // context. We simply return a default normal form here in this case. + Assert(false); + return d_normal_form[n]; } + return itn->second; } -void TheoryStrings::getNormalForms( Node &eqc, std::vector< std::vector< Node > > &normal_forms, std::vector< Node > &normal_form_src, - std::vector< std::vector< Node > > &normal_forms_exp, std::vector< std::map< Node, std::map< bool, int > > >& normal_forms_exp_depend ) { +void TheoryStrings::getNormalForms(Node eqc, + std::vector<NormalForm>& normal_forms, + std::map<Node, unsigned>& term_to_nf_index) +{ //constant for equivalence class Node eqc_non_c = eqc; Trace("strings-process-debug") << "Get normal forms " << eqc << std::endl; @@ -2643,79 +2697,115 @@ void TheoryStrings::getNormalForms( Node &eqc, std::vector< std::vector< Node > while( !eqc_i.isFinished() ){ Node n = (*eqc_i); if( d_congruent.find( n )==d_congruent.end() ){ - if( n.getKind() == kind::CONST_STRING || n.getKind() == kind::STRING_CONCAT ){ + if (n.getKind() == CONST_STRING || n.getKind() == STRING_CONCAT) + { Trace("strings-process-debug") << "Get Normal Form : Process term " << n << " in eqc " << eqc << std::endl; - std::vector< Node > nf_n; - std::vector< Node > nf_exp_n; - std::map< Node, std::map< bool, int > > nf_exp_depend_n; - if( n.getKind()==kind::CONST_STRING ){ - if( n!=d_emptyString ) { - nf_n.push_back( n ); - } - }else if( n.getKind()==kind::STRING_CONCAT ){ + NormalForm nf_curr; + if (n.getKind() == CONST_STRING) + { + nf_curr.init(n); + } + else if (n.getKind() == STRING_CONCAT) + { + // set the base to n, we construct the other portions of nf_curr in + // the following. + nf_curr.d_base = n; for( unsigned i=0; i<n.getNumChildren(); i++ ) { Node nr = d_equalityEngine.getRepresentative( n[i] ); + // get the normal form for the component + NormalForm& nfr = getNormalForm(nr); + std::vector<Node>& nfrv = nfr.d_nf; Trace("strings-process-debug") << "Normalizing subterm " << n[i] << " = " << nr << std::endl; - Assert( d_normal_forms.find( nr )!=d_normal_forms.end() ); - unsigned orig_size = nf_n.size(); - unsigned add_size = d_normal_forms[nr].size(); + unsigned orig_size = nf_curr.d_nf.size(); + unsigned add_size = nfrv.size(); //if not the empty string, add to current normal form - if( !d_normal_forms[nr].empty() ){ - for( unsigned r=0; r<d_normal_forms[nr].size(); r++ ) { - if( Trace.isOn("strings-error") ) { - if( d_normal_forms[nr][r].getKind()==kind::STRING_CONCAT ){ - Trace("strings-error") << "Strings::Error: From eqc = " << eqc << ", " << n << " index " << i << ", bad normal form : "; - for( unsigned rr=0; rr<d_normal_forms[nr].size(); rr++ ) { - Trace("strings-error") << d_normal_forms[nr][rr] << " "; + if (!nfrv.empty()) + { + // if in a build with assertions, we run the following block, + // which checks that normal forms do not have concat terms. + if (Configuration::isAssertionBuild()) + { + for (const Node& nn : nfrv) + { + if (Trace.isOn("strings-error")) + { + if (nn.getKind() == STRING_CONCAT) + { + Trace("strings-error") + << "Strings::Error: From eqc = " << eqc << ", " << n + << " index " << i << ", bad normal form : "; + for (unsigned rr = 0; rr < nfrv.size(); rr++) + { + Trace("strings-error") << nfrv[rr] << " "; + } + Trace("strings-error") << std::endl; } - Trace("strings-error") << std::endl; } + Assert(nn.getKind() != kind::STRING_CONCAT); } - Assert( d_normal_forms[nr][r].getKind()!=kind::STRING_CONCAT ); } - nf_n.insert( nf_n.end(), d_normal_forms[nr].begin(), d_normal_forms[nr].end() ); + nf_curr.d_nf.insert(nf_curr.d_nf.end(), nfrv.begin(), nfrv.end()); } - - for( unsigned j=0; j<d_normal_forms_exp[nr].size(); j++ ){ - Node exp = d_normal_forms_exp[nr][j]; - //track depends - trackNfExpDependency( nf_exp_n, nf_exp_depend_n, exp, - orig_size + d_normal_forms_exp_depend[nr][exp][false], - orig_size + ( add_size - d_normal_forms_exp_depend[nr][exp][true] ) ); + // Track explanation for the normal form. This is in two parts. + // First, we must carry the explanation of the normal form computed + // for the representative nr. + for (const Node& exp : nfr.d_exp) + { + // The explanation is only relevant for the subsegment it was + // previously relevant for, shifted now based on its relative + // placement in the normal form of n. + nf_curr.addToExplanation( + exp, + orig_size + nfr.d_expDep[exp][false], + orig_size + (add_size - nfr.d_expDep[exp][true])); } - if( d_normal_forms_base[nr]!=n[i] ){ - Assert( d_normal_forms_base.find( nr )!=d_normal_forms_base.end() ); - Node eq = n[i].eqNode( d_normal_forms_base[nr] ); - //track depends : entire current segment is dependent upon base equality - trackNfExpDependency( nf_exp_n, nf_exp_depend_n, eq, orig_size, orig_size + add_size ); + // Second, must explain that the component n[i] is equal to the + // base of the normal form for nr. + Node base = nfr.d_base; + if (base != n[i]) + { + Node eq = n[i].eqNode(base); + // The equality is relevant for the entire current segment + nf_curr.addToExplanation(eq, orig_size, orig_size + add_size); } } - //convert forward indices to reverse indices - int total_size = nf_n.size(); - for( std::map< Node, std::map< bool, int > >::iterator it = nf_exp_depend_n.begin(); it != nf_exp_depend_n.end(); ++it ){ - it->second[true] = total_size - it->second[true]; - Assert( it->second[true]>=0 ); + // Now that we are finished with the loop, we convert forward indices + // to reverse indices in the explanation dependency information + int total_size = nf_curr.d_nf.size(); + for (std::pair<const Node, std::map<bool, unsigned> >& ed : + nf_curr.d_expDep) + { + ed.second[true] = total_size - ed.second[true]; + Assert(ed.second[true] >= 0); } } //if not equal to self - if( nf_n.size()>1 || ( nf_n.size()==1 && nf_n[0].getKind()==kind::CONST_STRING ) ){ - if( nf_n.size()>1 ) { - for( unsigned i=0; i<nf_n.size(); i++ ){ - if( Trace.isOn("strings-error") ){ - Trace("strings-error") << "Cycle for normal form "; - printConcat(nf_n,"strings-error"); - Trace("strings-error") << "..." << nf_n[i] << std::endl; + std::vector<Node>& currv = nf_curr.d_nf; + if (currv.size() > 1 + || (currv.size() == 1 && currv[0].getKind() == CONST_STRING)) + { + // if in a build with assertions, check that normal form is acyclic + if (Configuration::isAssertionBuild()) + { + if (currv.size() > 1) + { + for (unsigned i = 0; i < currv.size(); i++) + { + if (Trace.isOn("strings-error")) + { + Trace("strings-error") << "Cycle for normal form "; + printConcat(currv, "strings-error"); + Trace("strings-error") << "..." << currv[i] << std::endl; + } + Assert(!areEqual(currv[i], n)); } - Assert( !areEqual( nf_n[i], n ) ); } } - normal_forms.push_back(nf_n); - normal_form_src.push_back(n); - normal_forms_exp.push_back(nf_exp_n); - normal_forms_exp_depend.push_back(nf_exp_depend_n); + term_to_nf_index[n] = normal_forms.size(); + normal_forms.push_back(nf_curr); }else{ //this was redundant: combination of self + empty string(s) - Node nn = nf_n.size()==0 ? d_emptyString : nf_n[0]; + Node nn = currv.size() == 0 ? d_emptyString : currv[0]; Assert( areEqual( nn, eqc ) ); } }else{ @@ -2727,41 +2817,56 @@ void TheoryStrings::getNormalForms( Node &eqc, std::vector< std::vector< Node > if( normal_forms.empty() ) { Trace("strings-solve-debug2") << "construct the normal form" << std::endl; - //do not choose a concat here use "eqc_non_c" (in this case they have non-trivial explanation why they normalize to self) - std::vector< Node > eqc_non_c_nf; - getConcatVec( eqc_non_c, eqc_non_c_nf ); - normal_forms.push_back( eqc_non_c_nf ); - normal_form_src.push_back( eqc_non_c ); - normal_forms_exp.push_back( std::vector< Node >() ); - normal_forms_exp_depend.push_back( std::map< Node, std::map< bool, int > >() ); + // This case happens when there are no non-trivial normal forms for this + // equivalence class. For example, given assertions: + // { x = y ++ z, x = y, z = "" } + // The equivalence class of { x, y, y ++ z } is such that the normal form + // of all terms is a variable (either x or y) in the equivalence class + // itself. Thus, the normal form of this equivalence class can be assigned + // to one of these variables. + // We use a non-concatenation term among the terms in this equivalence + // class, which is stored in eqc_non_c. The reason is this does not require + // an explanation, whereas e.g. y ++ z would require the explanation z = "" + // to justify its normal form is y. + Assert(eqc_non_c.getKind() != STRING_CONCAT); + NormalForm nf_triv; + nf_triv.init(eqc_non_c); + normal_forms.push_back(nf_triv); }else{ if(Trace.isOn("strings-solve")) { Trace("strings-solve") << "--- Normal forms for equivalance class " << eqc << " : " << std::endl; - for( unsigned i=0; i<normal_forms.size(); i++ ) { - Trace("strings-solve") << "#" << i << " (from " << normal_form_src[i] << ") : "; - for( unsigned j=0; j<normal_forms[i].size(); j++ ) { + for (unsigned i = 0, size = normal_forms.size(); i < size; i++) + { + NormalForm& nf = normal_forms[i]; + Trace("strings-solve") << "#" << i << " (from " << nf.d_base << ") : "; + for (unsigned j = 0, sizej = nf.d_nf.size(); j < sizej; j++) + { if(j>0) { Trace("strings-solve") << ", "; } - Trace("strings-solve") << normal_forms[i][j]; + Trace("strings-solve") << nf.d_nf[j]; } Trace("strings-solve") << std::endl; Trace("strings-solve") << " Explanation is : "; - if(normal_forms_exp[i].size() == 0) { + if (nf.d_exp.size() == 0) + { Trace("strings-solve") << "NONE"; } else { - for( unsigned j=0; j<normal_forms_exp[i].size(); j++ ) { + for (unsigned j = 0, sizej = nf.d_exp.size(); j < sizej; j++) + { if(j>0) { Trace("strings-solve") << " AND "; } - Trace("strings-solve") << normal_forms_exp[i][j]; + Trace("strings-solve") << nf.d_exp[j]; } Trace("strings-solve") << std::endl; Trace("strings-solve") << "WITH DEPENDENCIES : " << std::endl; - for( unsigned j=0; j<normal_forms_exp[i].size(); j++ ) { - Trace("strings-solve") << " " << normal_forms_exp[i][j] << " -> "; - Trace("strings-solve") << normal_forms_exp_depend[i][normal_forms_exp[i][j]][false] << ","; - Trace("strings-solve") << normal_forms_exp_depend[i][normal_forms_exp[i][j]][true] << std::endl; + for (unsigned j = 0, sizej = nf.d_exp.size(); j < sizej; j++) + { + Node exp = nf.d_exp[j]; + Trace("strings-solve") << " " << exp << " -> "; + Trace("strings-solve") << nf.d_expDep[exp][false] << ","; + Trace("strings-solve") << nf.d_expDep[exp][true] << std::endl; } } Trace("strings-solve") << std::endl; @@ -2775,10 +2880,14 @@ void TheoryStrings::getNormalForms( Node &eqc, std::vector< std::vector< Node > Node c = getConstantEqc( eqc ); if( !c.isNull() ){ Trace("strings-solve") << "Eqc is constant " << c << std::endl; - for( unsigned i=0; i<normal_forms.size(); i++ ) { + for (unsigned i = 0, size = normal_forms.size(); i < size; i++) + { + NormalForm& nf = normal_forms[i]; int firstc, lastc; - if( !TheoryStringsRewriter::canConstantContainList( c, normal_forms[i], firstc, lastc ) ){ - Node n = normal_form_src[i]; + if (!TheoryStringsRewriter::canConstantContainList( + c, nf.d_nf, firstc, lastc)) + { + Node n = nf.d_base; //conflict Trace("strings-solve") << "Normal form for " << n << " cannot be contained in constant " << c << std::endl; //conflict, explanation is n = base ^ base = c ^ relevant porition of ( n = N[n] ) @@ -2790,7 +2899,7 @@ void TheoryStrings::getNormalForms( Node &eqc, std::vector< std::vector< Node > exp.push_back( d_eqc_to_const_exp[eqc] ); } //TODO: this can be minimized based on firstc/lastc, normal_forms_exp_depend - exp.insert( exp.end(), normal_forms_exp[i].begin(), normal_forms_exp[i].end() ); + exp.insert(exp.end(), nf.d_exp.begin(), nf.d_exp.end()); Node conc = d_false; sendInference( exp, conc, "N_NCTN" ); } @@ -2799,52 +2908,29 @@ void TheoryStrings::getNormalForms( Node &eqc, std::vector< std::vector< Node > } } -void TheoryStrings::getExplanationVectorForPrefix( std::vector< std::vector< Node > > &normal_forms_exp, std::vector< std::map< Node, std::map< bool, int > > >& normal_forms_exp_depend, - unsigned i, int index, bool isRev, std::vector< Node >& curr_exp ) { - if( index==-1 || !options::stringMinPrefixExplain() ){ - curr_exp.insert(curr_exp.end(), normal_forms_exp[i].begin(), normal_forms_exp[i].end() ); - }else{ - for( unsigned k=0; k<normal_forms_exp[i].size(); k++ ){ - Node exp = normal_forms_exp[i][k]; - int dep = normal_forms_exp_depend[i][exp][isRev]; - if( dep<=index ){ - curr_exp.push_back( exp ); - Trace("strings-explain-prefix-debug") << " include : " << exp << std::endl; - }else{ - Trace("strings-explain-prefix-debug") << " exclude : " << exp << std::endl; - } - } - } -} - -void TheoryStrings::getExplanationVectorForPrefixEq( std::vector< std::vector< Node > > &normal_forms, std::vector< Node > &normal_form_src, - std::vector< std::vector< Node > > &normal_forms_exp, std::vector< std::map< Node, std::map< bool, int > > >& normal_forms_exp_depend, - unsigned i, unsigned j, int index_i, int index_j, bool isRev, std::vector< Node >& curr_exp ) { - Trace("strings-explain-prefix") << "Get explanation for prefix " << index_i << ", " << index_j << " of normal forms " << i << " and " << j << ", reverse = " << isRev << std::endl; - for( unsigned r=0; r<2; r++ ){ - getExplanationVectorForPrefix( normal_forms_exp, normal_forms_exp_depend, r==0 ? i : j, r==0 ? index_i : index_j, isRev, curr_exp ); - } - Trace("strings-explain-prefix") << "Included " << curr_exp.size() << " / " << ( normal_forms_exp[i].size() + normal_forms_exp[j].size() ) << std::endl; - addToExplanation( normal_form_src[i], normal_form_src[j], curr_exp ); -} - - -void TheoryStrings::processNEqc( std::vector< std::vector< Node > > &normal_forms, std::vector< Node > &normal_form_src, - std::vector< std::vector< Node > > &normal_forms_exp, std::vector< std::map< Node, std::map< bool, int > > >& normal_forms_exp_depend ){ +void TheoryStrings::processNEqc(std::vector<NormalForm>& normal_forms) +{ //the possible inferences std::vector< InferInfo > pinfer; // loop over all pairs for(unsigned i=0; i<normal_forms.size()-1; i++) { //unify each normalform[j] with normal_forms[i] for(unsigned j=i+1; j<normal_forms.size(); j++ ) { + NormalForm& nfi = normal_forms[i]; + NormalForm& nfj = normal_forms[j]; //ensure that normal_forms[i] and normal_forms[j] are the same modulo equality, add to pinfer if not Trace("strings-solve") << "Strings: Process normal form #" << i << " against #" << j << "..." << std::endl; - if( isNormalFormPair( normal_form_src[i], normal_form_src[j] ) ) { + if (isNormalFormPair(nfi.d_base, nfj.d_base)) + { Trace("strings-solve") << "Strings: Already cached." << std::endl; }else{ //process the reverse direction first (check for easy conflicts and inferences) unsigned rindex = 0; - processReverseNEq( normal_forms, normal_form_src, normal_forms_exp, normal_forms_exp_depend, i, j, rindex, 0, pinfer ); + nfi.reverse(); + nfj.reverse(); + processSimpleNEq(nfi, nfj, rindex, true, 0, pinfer); + nfi.reverse(); + nfj.reverse(); if( hasProcessed() ){ return; }else if( !pinfer.empty() && pinfer.back().d_id==1 ){ @@ -2854,7 +2940,7 @@ void TheoryStrings::processNEqc( std::vector< std::vector< Node > > &normal_form //rindex = 0; unsigned index = 0; - processSimpleNEq( normal_forms, normal_form_src, normal_forms_exp, normal_forms_exp_depend, i, j, index, false, rindex, pinfer ); + processSimpleNEq(nfi, nfj, index, false, rindex, pinfer); if( hasProcessed() ){ return; }else if( !pinfer.empty() && pinfer.back().d_id==1 ){ @@ -2920,86 +3006,92 @@ bool TheoryStrings::InferInfo::sendAsLemma() { return true; } -void TheoryStrings::processReverseNEq( std::vector< std::vector< Node > > &normal_forms, std::vector< Node > &normal_form_src, - std::vector< std::vector< Node > > &normal_forms_exp, std::vector< std::map< Node, std::map< bool, int > > >& normal_forms_exp_depend, - unsigned i, unsigned j, unsigned& index, unsigned rproc, std::vector< InferInfo >& pinfer ) { - //reverse normal form of i, j - std::reverse( normal_forms[i].begin(), normal_forms[i].end() ); - std::reverse( normal_forms[j].begin(), normal_forms[j].end() ); - - processSimpleNEq( normal_forms, normal_form_src, normal_forms_exp, normal_forms_exp_depend, i, j, index, true, rproc, pinfer ); - - //reverse normal form of i, j - std::reverse( normal_forms[i].begin(), normal_forms[i].end() ); - std::reverse( normal_forms[j].begin(), normal_forms[j].end() ); -} - -//rproc is the # is the size of suffix that is identical -void TheoryStrings::processSimpleNEq( std::vector< std::vector< Node > > &normal_forms, std::vector< Node > &normal_form_src, - std::vector< std::vector< Node > > &normal_forms_exp, std::vector< std::map< Node, std::map< bool, int > > >& normal_forms_exp_depend, - unsigned i, unsigned j, unsigned& index, bool isRev, unsigned rproc, std::vector< InferInfo >& pinfer ) { - Assert( rproc<=normal_forms[i].size() && rproc<=normal_forms[j].size() ); +void TheoryStrings::processSimpleNEq(NormalForm& nfi, + NormalForm& nfj, + unsigned& index, + bool isRev, + unsigned rproc, + std::vector<InferInfo>& pinfer) +{ + std::vector<Node>& nfiv = nfi.d_nf; + std::vector<Node>& nfjv = nfj.d_nf; + NodeManager* nm = NodeManager::currentNM(); + Assert(rproc <= nfiv.size() && rproc <= nfjv.size()); bool success; do { success = false; //if we are at the end - if( index==(normal_forms[i].size()-rproc) || index==(normal_forms[j].size()-rproc) ){ - if( index==(normal_forms[i].size()-rproc) && index==(normal_forms[j].size()-rproc) ){ + if (index == (nfiv.size() - rproc) || index == (nfjv.size() - rproc)) + { + if (index == (nfiv.size() - rproc) && index == (nfjv.size() - rproc)) + { //we're done }else{ //the remainder must be empty - unsigned k = index==(normal_forms[i].size()-rproc) ? j : i; + NormalForm& nfk = index == (nfiv.size() - rproc) ? nfj : nfi; + std::vector<Node>& nfkv = nfk.d_nf; unsigned index_k = index; //Node eq_exp = mkAnd( curr_exp ); std::vector< Node > curr_exp; - getExplanationVectorForPrefixEq( normal_forms, normal_form_src, normal_forms_exp, normal_forms_exp_depend, i, j, -1, -1, isRev, curr_exp ); - while( !d_conflict && index_k<(normal_forms[k].size()-rproc) ){ + NormalForm::getExplanationForPrefixEq(nfi, nfj, -1, -1, curr_exp); + while (!d_conflict && index_k < (nfkv.size() - rproc)) + { //can infer that this string must be empty - Node eq = normal_forms[k][index_k].eqNode( d_emptyString ); + Node eq = nfkv[index_k].eqNode(d_emptyString); //Trace("strings-lemma") << "Strings: Infer " << eq << " from " << eq_exp << std::endl; - Assert( !areEqual( d_emptyString, normal_forms[k][index_k] ) ); + Assert(!areEqual(d_emptyString, nfkv[index_k])); sendInference( curr_exp, eq, "N_EndpointEmp" ); index_k++; } } }else{ - Trace("strings-solve-debug") << "Process " << normal_forms[i][index] << " ... " << normal_forms[j][index] << std::endl; - if( normal_forms[i][index]==normal_forms[j][index] ){ + Trace("strings-solve-debug") + << "Process " << nfiv[index] << " ... " << nfjv[index] << std::endl; + if (nfiv[index] == nfjv[index]) + { Trace("strings-solve-debug") << "Simple Case 1 : strings are equal" << std::endl; index++; success = true; }else{ - Assert( !areEqual(normal_forms[i][index], normal_forms[j][index]) ); + Assert(!areEqual(nfiv[index], nfjv[index])); std::vector< Node > temp_exp; - Node length_term_i = getLength( normal_forms[i][index], temp_exp ); - Node length_term_j = getLength( normal_forms[j][index], temp_exp ); - //check length(normal_forms[i][index]) == length(normal_forms[j][index]) + Node length_term_i = getLength(nfiv[index], temp_exp); + Node length_term_j = getLength(nfjv[index], temp_exp); + // check length(nfiv[index]) == length(nfjv[index]) if( areEqual( length_term_i, length_term_j ) ){ Trace("strings-solve-debug") << "Simple Case 2 : string lengths are equal" << std::endl; - Node eq = normal_forms[i][index].eqNode( normal_forms[j][index] ); + Node eq = nfiv[index].eqNode(nfjv[index]); //eq = Rewriter::rewrite( eq ); Node length_eq = length_term_i.eqNode( length_term_j ); //temp_exp.insert(temp_exp.end(), curr_exp.begin(), curr_exp.end() ); - getExplanationVectorForPrefixEq( normal_forms, normal_form_src, normal_forms_exp, normal_forms_exp_depend, i, j, index, index, isRev, temp_exp ); + NormalForm::getExplanationForPrefixEq( + nfi, nfj, index, index, temp_exp); temp_exp.push_back(length_eq); sendInference( temp_exp, eq, "N_Unify" ); return; - }else if( ( normal_forms[i][index].getKind()!=kind::CONST_STRING && index==normal_forms[i].size()-rproc-1 ) || - ( normal_forms[j][index].getKind()!=kind::CONST_STRING && index==normal_forms[j].size()-rproc-1 ) ){ + } + else if ((nfiv[index].getKind() != CONST_STRING + && index == nfiv.size() - rproc - 1) + || (nfjv[index].getKind() != CONST_STRING + && index == nfjv.size() - rproc - 1)) + { Trace("strings-solve-debug") << "Simple Case 3 : at endpoint" << std::endl; std::vector< Node > antec; //antec.insert(antec.end(), curr_exp.begin(), curr_exp.end() ); - getExplanationVectorForPrefixEq( normal_forms, normal_form_src, normal_forms_exp, normal_forms_exp_depend, i, j, -1, -1, isRev, antec ); + NormalForm::getExplanationForPrefixEq(nfi, nfj, -1, -1, antec); std::vector< Node > eqn; for( unsigned r=0; r<2; r++ ) { - int index_k = index; - int k = r==0 ? i : j; + NormalForm& nfk = r == 0 ? nfi : nfj; + std::vector<Node>& nfkv = nfk.d_nf; std::vector< Node > eqnc; - for( unsigned index_l=index_k; index_l<(normal_forms[k].size()-rproc); index_l++ ) { + for (unsigned index_l = index, size = (nfkv.size() - rproc); + index_l < size; + index_l++) + { if(isRev) { - eqnc.insert(eqnc.begin(), normal_forms[k][index_l] ); + eqnc.insert(eqnc.begin(), nfkv[index_l]); } else { - eqnc.push_back( normal_forms[k][index_l] ); + eqnc.push_back(nfkv[index_l]); } } eqn.push_back( mkConcat( eqnc ) ); @@ -3008,49 +3100,46 @@ void TheoryStrings::processSimpleNEq( std::vector< std::vector< Node > > &normal sendInference( antec, eqn[0].eqNode( eqn[1] ), "N_EndpointEq", true ); return; }else{ - Assert( normal_forms[i].size()==normal_forms[j].size() ); - index = normal_forms[i].size()-rproc; + Assert(nfiv.size() == nfjv.size()); + index = nfiv.size() - rproc; } - }else if( normal_forms[i][index].isConst() && normal_forms[j][index].isConst() ){ - Node const_str = normal_forms[i][index]; - Node other_str = normal_forms[j][index]; + } + else if (nfiv[index].isConst() && nfjv[index].isConst()) + { + Node const_str = nfiv[index]; + Node other_str = nfjv[index]; Trace("strings-solve-debug") << "Simple Case 3 : Const Split : " << const_str << " vs " << other_str << " at index " << index << ", isRev = " << isRev << std::endl; unsigned len_short = const_str.getConst<String>().size() <= other_str.getConst<String>().size() ? const_str.getConst<String>().size() : other_str.getConst<String>().size(); bool isSameFix = isRev ? const_str.getConst<String>().rstrncmp(other_str.getConst<String>(), len_short): const_str.getConst<String>().strncmp(other_str.getConst<String>(), len_short); if( isSameFix ) { //same prefix/suffix + bool constCmp = const_str.getConst<String>().size() + < other_str.getConst<String>().size(); //k is the index of the string that is shorter - int k = const_str.getConst<String>().size()<other_str.getConst<String>().size() ? i : j; - int l = const_str.getConst<String>().size()<other_str.getConst<String>().size() ? j : i; - //update the nf exp dependencies - //notice this is not critical for soundness: not doing the below incrementing will only lead to overapproximating when antecedants are required in explanations - for( std::map< Node, std::map< bool, int > >::iterator itnd = normal_forms_exp_depend[l].begin(); itnd != normal_forms_exp_depend[l].end(); ++itnd ){ - for( std::map< bool, int >::iterator itnd2 = itnd->second.begin(); itnd2 != itnd->second.end(); ++itnd2 ){ - //see if this can be incremented: it can if it is not relevant to the current index - Assert( itnd2->second>=0 && itnd2->second<=(int)normal_forms[l].size() ); - bool increment = (itnd2->first==isRev) ? itnd2->second>(int)index : ( (int)normal_forms[l].size()-1-itnd2->second )<(int)index; - if( increment ){ - normal_forms_exp_depend[l][itnd->first][itnd2->first] = itnd2->second + 1; - } - } - } + NormalForm& nfk = constCmp ? nfi : nfj; + std::vector<Node>& nfkv = nfk.d_nf; + NormalForm& nfl = constCmp ? nfj : nfi; + std::vector<Node>& nflv = nfl.d_nf; + Node remainderStr; if( isRev ){ - int new_len = normal_forms[l][index].getConst<String>().size() - len_short; - Node remainderStr = NodeManager::currentNM()->mkConst( normal_forms[l][index].getConst<String>().substr(0, new_len) ); - Trace("strings-solve-debug-test") << "Break normal form of " << normal_forms[l][index] << " into " << normal_forms[k][index] << ", " << remainderStr << std::endl; - normal_forms[l].insert( normal_forms[l].begin()+index + 1, remainderStr ); + int new_len = nflv[index].getConst<String>().size() - len_short; + remainderStr = nm->mkConst( + nflv[index].getConst<String>().substr(0, new_len)); }else{ - Node remainderStr = NodeManager::currentNM()->mkConst(normal_forms[l][index].getConst<String>().substr(len_short)); - Trace("strings-solve-debug-test") << "Break normal form of " << normal_forms[l][index] << " into " << normal_forms[k][index] << ", " << remainderStr << std::endl; - normal_forms[l].insert( normal_forms[l].begin()+index + 1, remainderStr ); + remainderStr = + nm->mkConst(nflv[index].getConst<String>().substr(len_short)); } - normal_forms[l][index] = normal_forms[k][index]; + Trace("strings-solve-debug-test") + << "Break normal form of " << nflv[index] << " into " + << nfkv[index] << ", " << remainderStr << std::endl; + nfl.splitConstant(index, nfkv[index], remainderStr); index++; success = true; }else{ //conflict std::vector< Node > antec; - getExplanationVectorForPrefixEq( normal_forms, normal_form_src, normal_forms_exp, normal_forms_exp_depend, i, j, index, index, isRev, antec ); + NormalForm::getExplanationForPrefixEq( + nfi, nfj, index, index, antec); sendInference( antec, d_false, "N_Const", true ); return; } @@ -3059,17 +3148,19 @@ void TheoryStrings::processSimpleNEq( std::vector< std::vector< Node > > &normal InferInfo info; info.d_index = index; //for debugging - info.d_i = i; - info.d_j = j; + info.d_i = nfi.d_base; + info.d_j = nfj.d_base; info.d_rev = isRev; bool info_valid = false; - Assert( index<normal_forms[i].size()-rproc && index<normal_forms[j].size()-rproc ); + Assert(index < nfiv.size() - rproc && index < nfjv.size() - rproc); std::vector< Node > lexp; - Node length_term_i = getLength( normal_forms[i][index], lexp ); - Node length_term_j = getLength( normal_forms[j][index], lexp ); + Node length_term_i = getLength(nfiv[index], lexp); + Node length_term_j = getLength(nfjv[index], lexp); //split on equality between string lengths (note that splitting on equality between strings is worse since it is harder to process) - if( !areDisequal( length_term_i, length_term_j ) && !areEqual( length_term_i, length_term_j ) && - normal_forms[i][index].getKind()!=kind::CONST_STRING && normal_forms[j][index].getKind()!=kind::CONST_STRING ){ //AJR: remove the latter 2 conditions? + if (!areDisequal(length_term_i, length_term_j) + && !areEqual(length_term_i, length_term_j) + && !nfiv[index].isConst() && !nfjv[index].isConst()) + { // AJR: remove the latter 2 conditions? Trace("strings-solve-debug") << "Non-simple Case 1 : string lengths neither equal nor disequal" << std::endl; //try to make the lengths equal via splitting on demand Node length_eq = NodeManager::currentNM()->mkNode( kind::EQUAL, length_term_i, length_term_j ); @@ -3084,33 +3175,34 @@ void TheoryStrings::processSimpleNEq( std::vector< std::vector< Node > > &normal int loop_in_i = -1; int loop_in_j = -1; ProcessLoopResult plr = ProcessLoopResult::SKIPPED; - if( detectLoop( normal_forms, i, j, index, loop_in_i, loop_in_j, rproc ) ){ + if (detectLoop(nfi, nfj, index, loop_in_i, loop_in_j, rproc)) + { if( !isRev ){ //FIXME - getExplanationVectorForPrefixEq( normal_forms, normal_form_src, normal_forms_exp, normal_forms_exp_depend, i, j, -1, -1, isRev, info.d_ant ); - //set info - plr = processLoop(normal_forms, - normal_form_src, - i, - j, - loop_in_i != -1 ? i : j, - loop_in_i != -1 ? j : i, - loop_in_i != -1 ? loop_in_i : loop_in_j, - index, - info); - if (plr == ProcessLoopResult::INFERENCE) - { - info_valid = true; - } + NormalForm::getExplanationForPrefixEq( + nfi, nfj, -1, -1, info.d_ant); + // set info + plr = processLoop(loop_in_i != -1 ? nfi : nfj, + loop_in_i != -1 ? nfj : nfi, + loop_in_i != -1 ? loop_in_i : loop_in_j, + index, + info); + if (plr == ProcessLoopResult::INFERENCE) + { + info_valid = true; + } } } if (plr == ProcessLoopResult::SKIPPED) { //AJR: length entailment here? - if( normal_forms[i][index].getKind() == kind::CONST_STRING || normal_forms[j][index].getKind() == kind::CONST_STRING ){ - unsigned const_k = normal_forms[i][index].getKind() == kind::CONST_STRING ? i : j; - unsigned nconst_k = normal_forms[i][index].getKind() == kind::CONST_STRING ? j : i; - Node other_str = normal_forms[nconst_k][index]; + if (nfiv[index].isConst() || nfjv[index].isConst()) + { + NormalForm& nfc = nfiv[index].isConst() ? nfi : nfj; + std::vector<Node>& nfcv = nfc.d_nf; + NormalForm& nfnc = nfiv[index].isConst() ? nfj : nfi; + std::vector<Node>& nfncv = nfnc.d_nf; + Node other_str = nfncv[index]; Assert( other_str.getKind()!=kind::CONST_STRING, "Other string is not constant." ); Assert( other_str.getKind()!=kind::STRING_CONCAT, "Other string is not CONCAT." ); if( !d_equalityEngine.areDisequal( other_str, d_emptyString, true ) ){ @@ -3123,12 +3215,15 @@ void TheoryStrings::processSimpleNEq( std::vector< std::vector< Node > > &normal if( !isRev ){ //FIXME Node xnz = other_str.eqNode( d_emptyString ).negate(); unsigned index_nc_k = index+1; - //Node next_const_str = TheoryStringsRewriter::collectConstantStringAt( normal_forms[nconst_k], index_nc_k, false ); unsigned start_index_nc_k = index+1; - Node next_const_str = TheoryStringsRewriter::getNextConstantAt( normal_forms[nconst_k], start_index_nc_k, index_nc_k, false ); + Node next_const_str = + TheoryStringsRewriter::getNextConstantAt( + nfncv, start_index_nc_k, index_nc_k, false); if( !next_const_str.isNull() ) { unsigned index_c_k = index; - Node const_str = TheoryStringsRewriter::collectConstantStringAt( normal_forms[const_k], index_c_k, false ); + Node const_str = + TheoryStringsRewriter::collectConstantStringAt( + nfcv, index_c_k, false); Assert( !const_str.isNull() ); CVC4::String stra = const_str.getConst<String>(); CVC4::String strb = next_const_str.getConst<String>(); @@ -3151,9 +3246,9 @@ void TheoryStrings::processSimpleNEq( std::vector< std::vector< Node > > &normal } if( p>1 ){ if( start_index_nc_k==index+1 ){ - info.d_ant.push_back( xnz ); - getExplanationVectorForPrefixEq( normal_forms, normal_form_src, normal_forms_exp, normal_forms_exp_depend, - const_k, nconst_k, index_c_k, index_nc_k, isRev, info.d_ant ); + info.d_ant.push_back(xnz); + NormalForm::getExplanationForPrefixEq( + nfc, nfnc, index_c_k, index_nc_k, info.d_ant); Node prea = p==stra.size() ? const_str : NodeManager::currentNM()->mkConst( isRev ? stra.suffix( p ) : stra.prefix( p ) ); Node sk = d_sk_cache.mkSkolemCached( other_str, @@ -3168,24 +3263,13 @@ void TheoryStrings::processSimpleNEq( std::vector< std::vector< Node > > &normal info.d_id = INFER_SSPLIT_CST_PROP; info_valid = true; } - /* FIXME for isRev, speculative - else if( options::stringLenPropCsp() ){ - //propagate length constraint - std::vector< Node > cc; - for( unsigned i=index; i<start_index_nc_k; i++ ){ - cc.push_back( normal_forms[nconst_k][i] ); - } - Node lt = NodeManager::currentNM()->mkNode( kind::STRING_LENGTH, mkConcat( cc ) ); - conc = NodeManager::currentNM()->mkNode( kind::GEQ, lt, NodeManager::currentNM()->mkConst( Rational(p) ) ); - sendInference( ant, conc, "S-Split(CSP-P)-lprop", true ); - } - */ } } if( !info_valid ){ info.d_ant.push_back( xnz ); - Node const_str = normal_forms[const_k][index]; - getExplanationVectorForPrefixEq( normal_forms, normal_form_src, normal_forms_exp, normal_forms_exp_depend, i, j, index, index, isRev, info.d_ant ); + Node const_str = nfcv[index]; + NormalForm::getExplanationForPrefixEq( + nfi, nfj, index, index, info.d_ant); CVC4::String stra = const_str.getConst<String>(); if( options::stringBinaryCsp() && stra.size()>3 ){ //split string in half @@ -3227,7 +3311,7 @@ void TheoryStrings::processSimpleNEq( std::vector< std::vector< Node > > &normal if( options::stringCheckEntailLen() ){ //check entailment for( unsigned e=0; e<2; e++ ){ - Node t = e==0 ? normal_forms[i][index] : normal_forms[j][index]; + Node t = e == 0 ? nfiv[index] : nfjv[index]; //do not infer constants are larger than variables if( t.getKind()!=kind::CONST_STRING ){ Node lt1 = e==0 ? length_term_i : length_term_j; @@ -3244,11 +3328,12 @@ void TheoryStrings::processSimpleNEq( std::vector< std::vector< Node > > &normal } } } - - getExplanationVectorForPrefixEq( normal_forms, normal_form_src, normal_forms_exp, normal_forms_exp_depend, i, j, index, index, isRev, info.d_ant ); + + NormalForm::getExplanationForPrefixEq( + nfi, nfj, index, index, info.d_ant); //x!=e /\ y!=e for(unsigned xory=0; xory<2; xory++) { - Node x = xory==0 ? normal_forms[i][index] : normal_forms[j][index]; + Node x = xory == 0 ? nfiv[index] : nfjv[index]; Node xgtz = x.eqNode( d_emptyString ).negate(); if( d_equalityEngine.areDisequal( x, d_emptyString, true ) ) { info.d_ant.push_back( xgtz ); @@ -3257,15 +3342,19 @@ void TheoryStrings::processSimpleNEq( std::vector< std::vector< Node > > &normal } } Node sk = d_sk_cache.mkSkolemCached( - normal_forms[i][index], - normal_forms[j][index], + nfiv[index], + nfjv[index], isRev ? SkolemCache::SK_ID_V_SPT_REV : SkolemCache::SK_ID_V_SPT, "v_spt"); // must add length requirement info.d_new_skolem[LENGTH_GEQ_ONE].push_back(sk); - Node eq1 = normal_forms[i][index].eqNode( isRev ? mkConcat(sk, normal_forms[j][index]) : mkConcat(normal_forms[j][index], sk) ); - Node eq2 = normal_forms[j][index].eqNode( isRev ? mkConcat(sk, normal_forms[i][index]) : mkConcat(normal_forms[i][index], sk) ); + Node eq1 = + nfiv[index].eqNode(isRev ? mkConcat(sk, nfjv[index]) + : mkConcat(nfjv[index], sk)); + Node eq2 = + nfjv[index].eqNode(isRev ? mkConcat(sk, nfiv[index]) + : mkConcat(nfiv[index], sk)); if( lentTestSuccess!=-1 ){ info.d_antn.push_back( lentTestExp ); @@ -3297,15 +3386,26 @@ void TheoryStrings::processSimpleNEq( std::vector< std::vector< Node > > &normal }while( success ); } -bool TheoryStrings::detectLoop( std::vector< std::vector< Node > > &normal_forms, int i, int j, int index, int &loop_in_i, int &loop_in_j, unsigned rproc ){ +bool TheoryStrings::detectLoop(NormalForm& nfi, + NormalForm& nfj, + int index, + int& loop_in_i, + int& loop_in_j, + unsigned rproc) +{ int has_loop[2] = { -1, -1 }; if( options::stringLB() != 2 ) { for( unsigned r=0; r<2; r++ ) { - int n_index = (r==0 ? i : j); - int other_n_index = (r==0 ? j : i); - if( normal_forms[other_n_index][index].getKind() != kind::CONST_STRING ) { - for( unsigned lp = index+1; lp<normal_forms[n_index].size()-rproc; lp++ ){ - if( normal_forms[n_index][lp]==normal_forms[other_n_index][index] ){ + NormalForm& nf = r == 0 ? nfi : nfj; + NormalForm& nfo = r == 0 ? nfj : nfi; + std::vector<Node>& nfv = nf.d_nf; + std::vector<Node>& nfov = nfo.d_nf; + if (!nfov[index].isConst()) + { + for (unsigned lp = index + 1; lp < nfv.size() - rproc; lp++) + { + if (nfv[lp] == nfov[index]) + { has_loop[r] = lp; break; } @@ -3324,16 +3424,11 @@ bool TheoryStrings::detectLoop( std::vector< std::vector< Node > > &normal_forms } //xs(zy)=t(yz)xr -TheoryStrings::ProcessLoopResult TheoryStrings::processLoop( - const std::vector<std::vector<Node> >& normal_forms, - const std::vector<Node>& normal_form_src, - int i, - int j, - int loop_n_index, - int other_n_index, - int loop_index, - int index, - InferInfo& info) +TheoryStrings::ProcessLoopResult TheoryStrings::processLoop(NormalForm& nfi, + NormalForm& nfj, + int loop_index, + int index, + InferInfo& info) { if (options::stringProcessLoopMode() == ProcessLoopMode::ABORT) { @@ -3347,18 +3442,17 @@ TheoryStrings::ProcessLoopResult TheoryStrings::processLoop( NodeManager* nm = NodeManager::currentNM(); Node conc; - Trace("strings-loop") << "Detected possible loop for " - << normal_forms[loop_n_index][loop_index] << std::endl; - Trace("strings-loop") << " ... (X)= " << normal_forms[other_n_index][index] - << std::endl; + const std::vector<Node>& veci = nfi.d_nf; + const std::vector<Node>& vecoi = nfj.d_nf; + Trace("strings-loop") << "Detected possible loop for " << veci[loop_index] + << std::endl; + Trace("strings-loop") << " ... (X)= " << vecoi[index] << std::endl; Trace("strings-loop") << " ... T(Y.Z)= "; - const std::vector<Node>& veci = normal_forms[loop_n_index]; std::vector<Node> vec_t(veci.begin() + index, veci.begin() + loop_index); Node t_yz = mkConcat(vec_t); Trace("strings-loop") << " (" << t_yz << ")" << std::endl; Trace("strings-loop") << " ... S(Z.Y)= "; - const std::vector<Node>& vecoi = normal_forms[other_n_index]; std::vector<Node> vec_s(vecoi.begin() + index + 1, vecoi.end()); Node s_zy = mkConcat(vec_s); Trace("strings-loop") << s_zy << std::endl; @@ -3395,7 +3489,7 @@ TheoryStrings::ProcessLoopResult TheoryStrings::processLoop( Node split_eq; for (unsigned r = 0; r < 2; r++) { - Node t = r == 0 ? normal_forms[loop_n_index][loop_index] : t_yz; + Node t = r == 0 ? veci[loop_index] : t_yz; split_eq = t.eqNode(d_emptyString); Node split_eqr = Rewriter::rewrite(split_eq); // the equality could rewrite to false @@ -3428,16 +3522,14 @@ TheoryStrings::ProcessLoopResult TheoryStrings::processLoop( && s_zy.getConst<String>().isRepeated()) { Node rep_c = nm->mkConst(s_zy.getConst<String>().substr(0, 1)); - Trace("strings-loop") << "Special case (X)=" - << normal_forms[other_n_index][index] << " " + Trace("strings-loop") << "Special case (X)=" << vecoi[index] << " " << std::endl; Trace("strings-loop") << "... (C)=" << rep_c << " " << std::endl; // special case - str_in_re = - nm->mkNode(kind::STRING_IN_REGEXP, - normal_forms[other_n_index][index], - nm->mkNode(kind::REGEXP_STAR, - nm->mkNode(kind::STRING_TO_REGEXP, rep_c))); + str_in_re = nm->mkNode( + STRING_IN_REGEXP, + vecoi[index], + nm->mkNode(REGEXP_STAR, nm->mkNode(STRING_TO_REGEXP, rep_c))); conc = str_in_re; } else if (t_yz.isConst()) @@ -3470,14 +3562,13 @@ TheoryStrings::ProcessLoopResult TheoryStrings::processLoop( continue; } Node conc2 = nm->mkNode( - kind::STRING_IN_REGEXP, - normal_forms[other_n_index][index], - nm->mkNode(kind::REGEXP_CONCAT, - nm->mkNode(kind::STRING_TO_REGEXP, y), - nm->mkNode(kind::REGEXP_STAR, - nm->mkNode(kind::STRING_TO_REGEXP, restr)))); + STRING_IN_REGEXP, + vecoi[index], + nm->mkNode( + REGEXP_CONCAT, + nm->mkNode(STRING_TO_REGEXP, y), + nm->mkNode(REGEXP_STAR, nm->mkNode(STRING_TO_REGEXP, restr)))); cc = cc == d_true ? conc2 : nm->mkNode(kind::AND, cc, conc2); - d_regexp_ant[conc2] = ant; vconc.push_back(cc); } conc = vconc.size() == 0 ? Node::null() : vconc.size() == 1 @@ -3509,8 +3600,7 @@ TheoryStrings::ProcessLoopResult TheoryStrings::processLoop( vec_r.insert(vec_r.begin(), sk_y); vec_r.insert(vec_r.begin(), sk_z); Node conc2 = s_zy.eqNode(mkConcat(vec_r)); - Node conc3 = - normal_forms[other_n_index][index].eqNode(mkConcat(sk_y, sk_w)); + Node conc3 = vecoi[index].eqNode(mkConcat(sk_y, sk_w)); Node restr = r == d_emptyString ? s_zy : mkConcat(sk_z, sk_y); str_in_re = nm->mkNode(kind::STRING_IN_REGEXP, @@ -3527,27 +3617,25 @@ TheoryStrings::ProcessLoopResult TheoryStrings::processLoop( conc = nm->mkNode(kind::AND, vec_conc); } // normal case - // set its antecedant to ant, to say when it is relevant - if (!str_in_re.isNull()) - { - d_regexp_ant[str_in_re] = ant; - } // we will be done info.d_conc = conc; info.d_id = INFER_FLOOP; - info.d_nf_pair[0] = normal_form_src[i]; - info.d_nf_pair[1] = normal_form_src[j]; + info.d_nf_pair[0] = nfi.d_base; + info.d_nf_pair[1] = nfj.d_base; return ProcessLoopResult::INFERENCE; } //return true for lemma, false if we succeed void TheoryStrings::processDeq( Node ni, Node nj ) { //Assert( areDisequal( ni, nj ) ); - if( d_normal_forms[ni].size()>1 || d_normal_forms[nj].size()>1 ){ + NormalForm& nfni = getNormalForm(ni); + NormalForm& nfnj = getNormalForm(nj); + if (nfni.d_nf.size() > 1 || nfnj.d_nf.size() > 1) + { std::vector< Node > nfi; - nfi.insert( nfi.end(), d_normal_forms[ni].begin(), d_normal_forms[ni].end() ); + nfi.insert(nfi.end(), nfni.d_nf.begin(), nfni.d_nf.end()); std::vector< Node > nfj; - nfj.insert( nfj.end(), d_normal_forms[nj].begin(), d_normal_forms[nj].end() ); + nfj.insert(nfj.end(), nfnj.d_nf.begin(), nfnj.d_nf.end()); int revRet = processReverseDeq( nfi, nfj, ni, nj ); if( revRet!=0 ){ @@ -3555,9 +3643,9 @@ void TheoryStrings::processDeq( Node ni, Node nj ) { } nfi.clear(); - nfi.insert( nfi.end(), d_normal_forms[ni].begin(), d_normal_forms[ni].end() ); + nfi.insert(nfi.end(), nfni.d_nf.begin(), nfni.d_nf.end()); nfj.clear(); - nfj.insert( nfj.end(), d_normal_forms[nj].begin(), d_normal_forms[nj].end() ); + nfj.insert(nfj.end(), nfnj.d_nf.begin(), nfnj.d_nf.end()); unsigned index = 0; while( index<nfi.size() || index<nfj.size() ){ @@ -3612,8 +3700,10 @@ void TheoryStrings::processDeq( Node ni, Node nj ) { eq1 = Rewriter::rewrite( eq1 ); Node eq2 = nconst_k.eqNode( NodeManager::currentNM()->mkNode( kind::STRING_CONCAT, firstChar, skr ) ); std::vector< Node > antec; - antec.insert( antec.end(), d_normal_forms_exp[ni].begin(), d_normal_forms_exp[ni].end() ); - antec.insert( antec.end(), d_normal_forms_exp[nj].begin(), d_normal_forms_exp[nj].end() ); + antec.insert( + antec.end(), nfni.d_exp.begin(), nfni.d_exp.end()); + antec.insert( + antec.end(), nfnj.d_exp.begin(), nfnj.d_exp.end()); antec.push_back( nconst_k.eqNode( d_emptyString ).negate() ); sendInference( antec, NodeManager::currentNM()->mkNode( kind::OR, NodeManager::currentNM()->mkNode( kind::AND, eq1, sk.eqNode( firstChar ).negate() ), eq2 ), "D-DISL-CSplit" ); @@ -3626,8 +3716,8 @@ void TheoryStrings::processDeq( Node ni, Node nj ) { //must add lemma std::vector< Node > antec; std::vector< Node > antec_new_lits; - antec.insert( antec.end(), d_normal_forms_exp[ni].begin(), d_normal_forms_exp[ni].end() ); - antec.insert( antec.end(), d_normal_forms_exp[nj].begin(), d_normal_forms_exp[nj].end() ); + antec.insert(antec.end(), nfni.d_exp.begin(), nfni.d_exp.end()); + antec.insert(antec.end(), nfnj.d_exp.begin(), nfnj.d_exp.end()); //check disequal if( areDisequal( ni, nj ) ){ antec.push_back( ni.eqNode( nj ).negate() ); @@ -3714,16 +3804,18 @@ int TheoryStrings::processSimpleDeq( std::vector< Node >& nfi, std::vector< Node } } } + NormalForm& nfni = getNormalForm(ni); + NormalForm& nfnj = getNormalForm(nj); while( index<nfi.size() || index<nfj.size() ) { if( index>=nfi.size() || index>=nfj.size() ){ Trace("strings-solve-debug") << "Disequality normalize empty" << std::endl; std::vector< Node > ant; //we have a conflict : because the lengths are equal, the remainder needs to be empty, which will lead to a conflict - Node lni = getLengthExp( ni, ant, d_normal_forms_base[ni] ); - Node lnj = getLengthExp( nj, ant, d_normal_forms_base[nj] ); + Node lni = getLengthExp(ni, ant, nfni.d_base); + Node lnj = getLengthExp(nj, ant, nfnj.d_base); ant.push_back( lni.eqNode( lnj ) ); - ant.insert( ant.end(), d_normal_forms_exp[ni].begin(), d_normal_forms_exp[ni].end() ); - ant.insert( ant.end(), d_normal_forms_exp[nj].begin(), d_normal_forms_exp[nj].end() ); + ant.insert(ant.end(), nfni.d_exp.begin(), nfni.d_exp.end()); + ant.insert(ant.end(), nfnj.d_exp.begin(), nfnj.d_exp.end()); std::vector< Node > cc; std::vector< Node >& nfk = index>=nfi.size() ? nfj : nfi; for( unsigned index_k=index; index_k<nfk.size(); index_k++ ){ @@ -3924,36 +4016,24 @@ void TheoryStrings::registerTerm( Node n, int effort ) { Trace("strings-assert") << "(assert " << lem << ")" << std::endl; d_out->lemma(lem); } - else if (n.getKind() == STRING_STRIDOF) - { - Node lower = n[2]; - if (!TheoryStringsRewriter::checkEntailArith(lower)) { - lower = d_zero; - } - Node neg = Rewriter::rewrite(nm->mkNode(EQUAL, n, d_neg_one)); - Node geq = Rewriter::rewrite(nm->mkNode(GEQ, n, lower)); - Node lem = nm->mkNode(OR, neg, geq); - Trace("strings-lemma") << "Strings::Lemma STRIDOF : " << lem << std::endl; - Trace("strings-assert") << "(assert " << lem << ")" << std::endl; - //d_out->lemma(lem); - //d_out->requirePhase(neg, true); - - lem = Rewriter::rewrite(nm->mkNode(GT, nm->mkNode(STRING_LENGTH, n[0]), n)); - d_out->lemma(lem); - } } -void TheoryStrings::sendInternalInference(std::vector<Node>& exp, +bool TheoryStrings::sendInternalInference(std::vector<Node>& exp, Node conc, const char* c) { - if (conc.getKind() == AND) + if (conc.getKind() == AND + || (conc.getKind() == NOT && conc[0].getKind() == OR)) { - for (const Node& cc : conc) + Node conj = conc.getKind() == AND ? conc : conc[0]; + bool pol = conc.getKind() == AND; + bool ret = true; + for (const Node& cc : conj) { - sendInternalInference(exp, cc, c); + bool retc = sendInternalInference(exp, pol ? cc : cc.negate(), c); + ret = ret && retc; } - return; + return ret; } bool pol = conc.getKind() != NOT; Node lit = pol ? conc : conc[0]; @@ -3964,13 +4044,13 @@ void TheoryStrings::sendInternalInference(std::vector<Node>& exp, if (!lit[i].isConst() && !hasTerm(lit[i])) { // introduces a new non-constant term, do not infer - return; + return false; } } // does it already hold? if (pol ? areEqual(lit[0], lit[1]) : areDisequal(lit[0], lit[1])) { - return; + return true; } } else if (lit.isConst()) @@ -3979,20 +4059,21 @@ void TheoryStrings::sendInternalInference(std::vector<Node>& exp, { Assert(pol); // trivially holds - return; + return true; } } else if (!hasTerm(lit)) { // introduces a new non-constant term, do not infer - return; + return false; } else if (areEqual(lit, pol ? d_true : d_false)) { // already holds - return; + return true; } sendInference(exp, conc, c); + return true; } void TheoryStrings::sendInference( std::vector< Node >& exp, std::vector< Node >& exp_n, Node eq, const char * c, bool asLemma ) { @@ -4334,18 +4415,6 @@ Node TheoryStrings::mkAnd( std::vector< Node >& a ) { } } -void TheoryStrings::getConcatVec( Node n, std::vector< Node >& c ) { - if( n.getKind()==kind::STRING_CONCAT ) { - for( unsigned i=0; i<n.getNumChildren(); i++ ) { - if( !areEqual( n[i], d_emptyString ) ) { - c.push_back( n[i] ); - } - } - }else{ - c.push_back( n ); - } -} - void TheoryStrings::checkNormalFormsDeq() { std::vector< std::vector< Node > > cols; @@ -4380,20 +4449,28 @@ void TheoryStrings::checkNormalFormsDeq() separateByLength( d_strings_eqc, cols, lts ); for( unsigned i=0; i<cols.size(); i++ ){ if( cols[i].size()>1 && d_lemma_cache.empty() ){ - Trace("strings-solve") << "- Verify disequalities are processed for " << cols[i][0] << ", normal form : "; - printConcat( d_normal_forms[cols[i][0]], "strings-solve" ); - Trace("strings-solve") << "... #eql = " << cols[i].size() << std::endl; + if (Trace.isOn("strings-solve")) + { + Trace("strings-solve") << "- Verify disequalities are processed for " + << cols[i][0] << ", normal form : "; + printConcat(getNormalForm(cols[i][0]).d_nf, "strings-solve"); + Trace("strings-solve") + << "... #eql = " << cols[i].size() << std::endl; + } //must ensure that normal forms are disequal for( unsigned j=0; j<cols[i].size(); j++ ){ for( unsigned k=(j+1); k<cols[i].size(); k++ ){ //for strings that are disequal, but have the same length if( areDisequal( cols[i][j], cols[i][k] ) ){ Assert( !d_conflict ); - Trace("strings-solve") << "- Compare " << cols[i][j] << " "; - printConcat( d_normal_forms[cols[i][j]], "strings-solve" ); - Trace("strings-solve") << " against " << cols[i][k] << " "; - printConcat( d_normal_forms[cols[i][k]], "strings-solve" ); - Trace("strings-solve") << "..." << std::endl; + if (Trace.isOn("strings-solve")) + { + Trace("strings-solve") << "- Compare " << cols[i][j] << " "; + printConcat(getNormalForm(cols[i][j]).d_nf, "strings-solve"); + Trace("strings-solve") << " against " << cols[i][k] << " "; + printConcat(getNormalForm(cols[i][k]).d_nf, "strings-solve"); + Trace("strings-solve") << "..." << std::endl; + } processDeq( cols[i][j], cols[i][k] ); if( hasProcessed() ){ return; @@ -4409,7 +4486,7 @@ void TheoryStrings::checkNormalFormsDeq() void TheoryStrings::checkLengthsEqc() { if( options::stringLenNorm() ){ for( unsigned i=0; i<d_strings_eqc.size(); i++ ){ - //if( d_normal_forms[nodes[i]].size()>1 ) { + NormalForm& nfi = getNormalForm(d_strings_eqc[i]); Trace("strings-process-debug") << "Process length constraints for " << d_strings_eqc[i] << std::endl; //check if there is a length term for this equivalence class EqcInfo* ei = getOrMakeEqcInfo( d_strings_eqc[i], false ); @@ -4418,19 +4495,22 @@ void TheoryStrings::checkLengthsEqc() { Node llt = NodeManager::currentNM()->mkNode( kind::STRING_LENGTH, lt ); //now, check if length normalization has occurred if( ei->d_normalized_length.get().isNull() ) { - Node nf = mkConcat( d_normal_forms[d_strings_eqc[i]] ); + Node nf = mkConcat(nfi.d_nf); if( Trace.isOn("strings-process-debug") ){ - Trace("strings-process-debug") << " normal form is " << nf << " from base " << d_normal_forms_base[d_strings_eqc[i]] << std::endl; + Trace("strings-process-debug") + << " normal form is " << nf << " from base " << nfi.d_base + << std::endl; Trace("strings-process-debug") << " normal form exp is: " << std::endl; - for( unsigned j=0; j<d_normal_forms_exp[d_strings_eqc[i]].size(); j++ ){ - Trace("strings-process-debug") << " " << d_normal_forms_exp[d_strings_eqc[i]][j] << std::endl; + for (const Node& exp : nfi.d_exp) + { + Trace("strings-process-debug") << " " << exp << std::endl; } } //if not, add the lemma std::vector< Node > ant; - ant.insert( ant.end(), d_normal_forms_exp[d_strings_eqc[i]].begin(), d_normal_forms_exp[d_strings_eqc[i]].end() ); - ant.push_back( d_normal_forms_base[d_strings_eqc[i]].eqNode( lt ) ); + ant.insert(ant.end(), nfi.d_exp.begin(), nfi.d_exp.end()); + ant.push_back(nfi.d_base.eqNode(lt)); Node lc = NodeManager::currentNM()->mkNode( kind::STRING_LENGTH, nf ); Node lcr = Rewriter::rewrite( lc ); Trace("strings-process-debug") << "Rewrote length " << lc << " to " << lcr << std::endl; @@ -4443,7 +4523,7 @@ void TheoryStrings::checkLengthsEqc() { }else{ Trace("strings-process-debug") << "No length term for eqc " << d_strings_eqc[i] << " " << d_eqc_to_len_term[d_strings_eqc[i]] << std::endl; if( !options::stringEagerLen() ){ - Node c = mkConcat( d_normal_forms[d_strings_eqc[i]] ); + Node c = mkConcat(nfi.d_nf); registerTerm( c, 3 ); /* if( !c.isConst() ){ @@ -4712,525 +4792,6 @@ TheoryStrings::Statistics::~Statistics(){ smtStatisticsRegistry()->unregisterStat(&d_loop_lemmas); } - - - - - - - - - - - - - - - - - - - -//// Regular Expressions - - -unsigned TheoryStrings::getNumMemberships( Node n, bool isPos ) { - if( isPos ){ - NodeIntMap::const_iterator it = d_pos_memberships.find( n ); - if( it!=d_pos_memberships.end() ){ - return (*it).second; - } - }else{ - NodeIntMap::const_iterator it = d_neg_memberships.find( n ); - if( it!=d_neg_memberships.end() ){ - return (*it).second; - } - } - return 0; -} - -Node TheoryStrings::getMembership( Node n, bool isPos, unsigned i ) { - return isPos ? d_pos_memberships_data[n][i] : d_neg_memberships_data[n][i]; -} - -Node TheoryStrings::mkRegExpAntec(Node atom, Node ant) { - if(d_regexp_ant.find(atom) == d_regexp_ant.end()) { - return NodeManager::currentNM()->mkNode(kind::AND, ant, atom); - } else { - Node n = d_regexp_ant[atom]; - return NodeManager::currentNM()->mkNode(kind::AND, ant, n); - } -} - -void TheoryStrings::checkMemberships() { - //add the memberships - std::vector<Node> mems = getExtTheory()->getActive(kind::STRING_IN_REGEXP); - for (unsigned i = 0; i < mems.size(); i++) { - Node n = mems[i]; - Assert( d_extf_info_tmp.find( n )!=d_extf_info_tmp.end() ); - if (!d_extf_info_tmp[n].d_const.isNull()) - { - bool pol = d_extf_info_tmp[n].d_const.getConst<bool>(); - Trace("strings-process-debug") << " add membership : " << n << ", pol = " << pol << std::endl; - addMembership( pol ? n : n.negate() ); - }else{ - Trace("strings-process-debug") << " irrelevant (non-asserted) membership : " << n << std::endl; - } - } - - bool addedLemma = false; - bool changed = false; - std::vector< Node > processed; - std::vector< Node > cprocessed; - - Trace("regexp-debug") << "Checking Memberships ... " << std::endl; - //if(options::stringEIT()) { - //TODO: Opt for normal forms - for( NodeIntMap::const_iterator itr_xr = d_pos_memberships.begin(); itr_xr != d_pos_memberships.end(); ++itr_xr ){ - bool spflag = false; - Node x = (*itr_xr).first; - Trace("regexp-debug") << "Checking Memberships for " << x << std::endl; - if(d_inter_index.find(x) == d_inter_index.end()) { - d_inter_index[x] = 0; - } - int cur_inter_idx = d_inter_index[x]; - unsigned n_pmem = (*itr_xr).second; - Assert( getNumMemberships( x, true )==n_pmem ); - if( cur_inter_idx != (int)n_pmem ) { - if( n_pmem == 1) { - d_inter_cache[x] = getMembership( x, true, 0 ); - d_inter_index[x] = 1; - Trace("regexp-debug") << "... only one choice " << std::endl; - } else if(n_pmem > 1) { - Node r; - if(d_inter_cache.find(x) != d_inter_cache.end()) { - r = d_inter_cache[x]; - } - if(r.isNull()) { - r = getMembership( x, true, 0 ); - cur_inter_idx = 1; - } - - unsigned k_start = cur_inter_idx; - Trace("regexp-debug") << "... staring from : " << cur_inter_idx << ", we have " << n_pmem << std::endl; - for(unsigned k = k_start; k<n_pmem; k++) { - Node r2 = getMembership( x, true, k ); - r = d_regexp_opr.intersect(r, r2, spflag); - if(spflag) { - break; - } else if(r == d_emptyRegexp) { - std::vector< Node > vec_nodes; - for( unsigned kk=0; kk<=k; kk++ ){ - Node rr = getMembership( x, true, kk ); - Node n = NodeManager::currentNM()->mkNode(kind::STRING_IN_REGEXP, x, rr); - vec_nodes.push_back( n ); - } - Node conc; - sendInference(vec_nodes, conc, "INTERSECT CONFLICT", true); - addedLemma = true; - break; - } - if(d_conflict) { - break; - } - } - //updates - if(!d_conflict && !spflag) { - d_inter_cache[x] = r; - d_inter_index[x] = (int)n_pmem; - } - } - } - } - //} - - Trace("regexp-debug") << "... No Intersect Conflict in Memberships, addedLemma: " << addedLemma << std::endl; - if(!addedLemma) { - NodeManager* nm = NodeManager::currentNM(); - for( unsigned i=0; i<d_regexp_memberships.size(); i++ ) { - //check regular expression membership - Node assertion = d_regexp_memberships[i]; - Trace("regexp-debug") << "Check : " << assertion << " " << (d_regexp_ucached.find(assertion) == d_regexp_ucached.end()) << " " << (d_regexp_ccached.find(assertion) == d_regexp_ccached.end()) << std::endl; - if( d_regexp_ucached.find(assertion) == d_regexp_ucached.end() - && d_regexp_ccached.find(assertion) == d_regexp_ccached.end() ) { - Trace("strings-regexp") << "We have regular expression assertion : " << assertion << std::endl; - Node atom = assertion.getKind()==kind::NOT ? assertion[0] : assertion; - bool polarity = assertion.getKind()!=kind::NOT; - bool flag = true; - Node x = atom[0]; - Node r = atom[1]; - std::vector< Node > rnfexp; - - if (!x.isConst()) - { - x = getNormalString(x, rnfexp); - changed = true; - } - if (!d_regexp_opr.checkConstRegExp(r)) - { - r = getNormalSymRegExp(r, rnfexp); - changed = true; - } - Trace("strings-regexp-nf") << "Term " << atom << " is normalized to " - << x << " IN " << r << std::endl; - if (changed) - { - Node tmp = - Rewriter::rewrite(nm->mkNode(kind::STRING_IN_REGEXP, x, r)); - if (!polarity) - { - tmp = tmp.negate(); - } - if (tmp == d_true) - { - d_regexp_ccached.insert(assertion); - continue; - } - else if (tmp == d_false) - { - Node antec = mkRegExpAntec(assertion, mkExplain(rnfexp)); - Node conc = Node::null(); - sendLemma(antec, conc, "REGEXP NF Conflict"); - addedLemma = true; - break; - } - } - - if( polarity ) { - flag = checkPDerivative(x, r, atom, addedLemma, rnfexp); - } else { - if(! options::stringExp()) { - throw LogicException("Strings Incomplete (due to Negative Membership) by default, try --strings-exp option."); - } - } - if(flag) { - //check if the term is atomic - Node xr = getRepresentative( x ); - //Trace("strings-regexp") << xr << " is rep of " << x << std::endl; - //Assert( d_normal_forms.find( xr )!=d_normal_forms.end() ); - Trace("strings-regexp") - << "Unroll/simplify membership of atomic term " << xr - << std::endl; - // if so, do simple unrolling - std::vector<Node> nvec; - - if (nvec.empty()) - { - d_regexp_opr.simplify(atom, nvec, polarity); - } - Node antec = assertion; - if (d_regexp_ant.find(assertion) != d_regexp_ant.end()) - { - antec = d_regexp_ant[assertion]; - for (std::vector<Node>::const_iterator itr = nvec.begin(); - itr < nvec.end(); - itr++) - { - if (itr->getKind() == kind::STRING_IN_REGEXP) - { - if (d_regexp_ant.find(*itr) == d_regexp_ant.end()) - { - d_regexp_ant[*itr] = antec; - } - } - } - } - antec = NodeManager::currentNM()->mkNode( - kind::AND, antec, mkExplain(rnfexp)); - Node conc = nvec.size() == 1 - ? nvec[0] - : NodeManager::currentNM()->mkNode(kind::AND, nvec); - conc = Rewriter::rewrite(conc); - sendLemma(antec, conc, "REGEXP_Unfold"); - addedLemma = true; - if (changed) - { - cprocessed.push_back(assertion); - } - else - { - processed.push_back(assertion); - } - // d_regexp_ucached[assertion] = true; - } - } - if(d_conflict) { - break; - } - } - } - if( addedLemma ) { - if( !d_conflict ){ - for( unsigned i=0; i<processed.size(); i++ ) { - Trace("strings-regexp") << "...add " << processed[i] << " to u-cache." << std::endl; - d_regexp_ucached.insert(processed[i]); - } - for( unsigned i=0; i<cprocessed.size(); i++ ) { - Trace("strings-regexp") << "...add " << cprocessed[i] << " to c-cache." << std::endl; - d_regexp_ccached.insert(cprocessed[i]); - } - } - } -} - -bool TheoryStrings::checkPDerivative( Node x, Node r, Node atom, bool &addedLemma, std::vector< Node > &nf_exp ) { - - Node antnf = mkExplain(nf_exp); - - if(areEqual(x, d_emptyString)) { - Node exp; - switch(d_regexp_opr.delta(r, exp)) { - case 0: { - Node antec = mkRegExpAntec(atom, x.eqNode(d_emptyString)); - antec = NodeManager::currentNM()->mkNode(kind::AND, antec, antnf); - sendLemma(antec, exp, "RegExp Delta"); - addedLemma = true; - d_regexp_ccached.insert(atom); - return false; - } - case 1: { - d_regexp_ccached.insert(atom); - break; - } - case 2: { - Node antec = mkRegExpAntec(atom, x.eqNode(d_emptyString)); - antec = NodeManager::currentNM()->mkNode(kind::AND, antec, antnf); - Node conc = Node::null(); - sendLemma(antec, conc, "RegExp Delta CONFLICT"); - addedLemma = true; - d_regexp_ccached.insert(atom); - return false; - } - default: - //Impossible - break; - } - } else { - /*Node xr = getRepresentative( x ); - if(x != xr) { - Node n = NodeManager::currentNM()->mkNode(kind::STRING_IN_REGEXP, xr, r); - Node nn = Rewriter::rewrite( n ); - if(nn == d_true) { - d_regexp_ccached.insert(atom); - return false; - } else if(nn == d_false) { - Node antec = mkRegExpAntec(atom, x.eqNode(xr)); - Node conc = Node::null(); - sendLemma(antec, conc, "RegExp Delta CONFLICT"); - addedLemma = true; - d_regexp_ccached.insert(atom); - return false; - } - }*/ - Node sREant = mkRegExpAntec(atom, d_true); - sREant = NodeManager::currentNM()->mkNode(kind::AND, sREant, antnf); - if(deriveRegExp( x, r, sREant )) { - addedLemma = true; - d_regexp_ccached.insert(atom); - return false; - } - } - return true; -} - -CVC4::String TheoryStrings::getHeadConst( Node x ) { - if( x.isConst() ) { - return x.getConst< String >(); - } else if( x.getKind() == kind::STRING_CONCAT ) { - if( x[0].isConst() ) { - return x[0].getConst< String >(); - } else { - return d_emptyString.getConst< String >(); - } - } else { - return d_emptyString.getConst< String >(); - } -} - -bool TheoryStrings::deriveRegExp( Node x, Node r, Node ant ) { - // TODO cstr in vre - Assert(x != d_emptyString); - Trace("regexp-derive") << "TheoryStrings::deriveRegExp: x=" << x << ", r= " << r << std::endl; - //if(x.isConst()) { - // Node n = NodeManager::currentNM()->mkNode( kind::STRING_IN_REGEXP, x, r ); - // Node r = Rewriter::rewrite( n ); - // if(n != r) { - // sendLemma(ant, r, "REGEXP REWRITE"); - // return true; - // } - //} - CVC4::String s = getHeadConst( x ); - if( !s.isEmptyString() && d_regexp_opr.checkConstRegExp( r ) ) { - Node conc = Node::null(); - Node dc = r; - bool flag = true; - for(unsigned i=0; i<s.size(); ++i) { - CVC4::String c = s.substr(i, 1); - Node dc2; - int rt = d_regexp_opr.derivativeS(dc, c, dc2); - dc = dc2; - if(rt == 0) { - //TODO - } else if(rt == 2) { - // CONFLICT - flag = false; - break; - } - } - // send lemma - if(flag) { - if(x.isConst()) { - Assert(false, "Impossible: TheoryStrings::deriveRegExp: const string in const regular expression."); - return false; - } else { - Assert( x.getKind() == kind::STRING_CONCAT ); - std::vector< Node > vec_nodes; - for(unsigned int i=1; i<x.getNumChildren(); ++i ) { - vec_nodes.push_back( x[i] ); - } - Node left = mkConcat( vec_nodes ); - left = Rewriter::rewrite( left ); - conc = NodeManager::currentNM()->mkNode( kind::STRING_IN_REGEXP, left, dc ); - - /*std::vector< Node > sdc; - d_regexp_opr.simplify(conc, sdc, true); - if(sdc.size() == 1) { - conc = sdc[0]; - } else { - conc = Rewriter::rewrite(NodeManager::currentNM()->mkNode(kind::AND, conc)); - }*/ - } - } - sendLemma(ant, conc, "RegExp-Derive"); - return true; - } else { - return false; - } -} - -void TheoryStrings::addMembership(Node assertion) { - bool polarity = assertion.getKind() != kind::NOT; - TNode atom = polarity ? assertion : assertion[0]; - Node x = atom[0]; - Node r = atom[1]; - if(polarity) { - int index = 0; - NodeIntMap::const_iterator it = d_pos_memberships.find( x ); - if( it!=d_nf_pairs.end() ){ - index = (*it).second; - for( int k=0; k<index; k++ ){ - if( k<(int)d_pos_memberships_data[x].size() ){ - if( d_pos_memberships_data[x][k]==r ){ - return; - } - }else{ - break; - } - } - } - d_pos_memberships[x] = index + 1; - if( index<(int)d_pos_memberships_data[x].size() ){ - d_pos_memberships_data[x][index] = r; - }else{ - d_pos_memberships_data[x].push_back( r ); - } - } else if(!options::stringIgnNegMembership()) { - /*if(options::stringEIT() && d_regexp_opr.checkConstRegExp(r)) { - int rt; - Node r2 = d_regexp_opr.complement(r, rt); - Node a = NodeManager::currentNM()->mkNode(kind::STRING_IN_REGEXP, x, r2); - }*/ - int index = 0; - NodeIntMap::const_iterator it = d_neg_memberships.find( x ); - if( it!=d_nf_pairs.end() ){ - index = (*it).second; - for( int k=0; k<index; k++ ){ - if( k<(int)d_neg_memberships_data[x].size() ){ - if( d_neg_memberships_data[x][k]==r ){ - return; - } - }else{ - break; - } - } - } - d_neg_memberships[x] = index + 1; - if( index<(int)d_neg_memberships_data[x].size() ){ - d_neg_memberships_data[x][index] = r; - }else{ - d_neg_memberships_data[x].push_back( r ); - } - } - // old - if(polarity || !options::stringIgnNegMembership()) { - d_regexp_memberships.push_back( assertion ); - } -} - -Node TheoryStrings::getNormalString( Node x, std::vector< Node >& nf_exp ){ - if( !x.isConst() ){ - Node xr = getRepresentative( x ); - if( d_normal_forms.find( xr ) != d_normal_forms.end() ){ - Node ret = mkConcat( d_normal_forms[xr] ); - nf_exp.insert( nf_exp.end(), d_normal_forms_exp[xr].begin(), d_normal_forms_exp[xr].end() ); - addToExplanation( x, d_normal_forms_base[xr], nf_exp ); - Trace("strings-debug") << "Term: " << x << " has a normal form " << ret << std::endl; - return ret; - } else { - if(x.getKind() == kind::STRING_CONCAT) { - std::vector< Node > vec_nodes; - for(unsigned i=0; i<x.getNumChildren(); i++) { - Node nc = getNormalString( x[i], nf_exp ); - vec_nodes.push_back( nc ); - } - return mkConcat( vec_nodes ); - } - } - } - return x; -} - -Node TheoryStrings::getNormalSymRegExp(Node r, std::vector<Node> &nf_exp) { - Node ret = r; - switch( r.getKind() ) { - case kind::REGEXP_EMPTY: - case kind::REGEXP_SIGMA: - break; - case kind::STRING_TO_REGEXP: { - if(!r[0].isConst()) { - Node tmp = getNormalString( r[0], nf_exp ); - if(tmp != r[0]) { - ret = NodeManager::currentNM()->mkNode(kind::STRING_TO_REGEXP, tmp); - } - } - break; - } - case kind::REGEXP_CONCAT: - case kind::REGEXP_UNION: - case kind::REGEXP_INTER: - case kind::REGEXP_STAR: - { - std::vector< Node > vec_nodes; - for (const Node& cr : r) - { - vec_nodes.push_back(getNormalSymRegExp(cr, nf_exp)); - } - ret = Rewriter::rewrite( - NodeManager::currentNM()->mkNode(r.getKind(), vec_nodes)); - break; - } - //case kind::REGEXP_PLUS: - //case kind::REGEXP_OPT: - //case kind::REGEXP_RANGE: - default: { - Trace("strings-error") << "Unsupported term: " << r << " in normalization SymRegExp." << std::endl; - Assert( false ); - //return Node::null(); - } - } - return ret; -} - /** run the given inference step */ void TheoryStrings::runInferStep(InferStep s, int effort) { diff --git a/src/theory/strings/theory_strings.h b/src/theory/strings/theory_strings.h index 70e75db54..8371a27ea 100644 --- a/src/theory/strings/theory_strings.h +++ b/src/theory/strings/theory_strings.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Tianyi Liang, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,16 +16,18 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__STRINGS__THEORY_STRINGS_H -#define __CVC4__THEORY__STRINGS__THEORY_STRINGS_H +#ifndef CVC4__THEORY__STRINGS__THEORY_STRINGS_H +#define CVC4__THEORY__STRINGS__THEORY_STRINGS_H #include "context/cdhashset.h" #include "context/cdlist.h" #include "expr/attribute.h" #include "expr/node_trie.h" #include "theory/decision_manager.h" +#include "theory/strings/normal_form.h" #include "theory/strings/regexp_elim.h" #include "theory/strings/regexp_operation.h" +#include "theory/strings/regexp_solver.h" #include "theory/strings/skolem_cache.h" #include "theory/strings/theory_strings_preprocess.h" #include "theory/theory.h" @@ -235,27 +237,63 @@ class TheoryStrings : public Theory { } };/* class TheoryStrings::NotifyClass */ -private: + //--------------------------- equality engine + /** + * Get the representative of t in the equality engine of this class, or t + * itself if it is not registered as a term. + */ + Node getRepresentative(Node t); + /** Is t registered as a term in the equality engine of this class? */ + bool hasTerm(Node a); + /** + * Are a and b equal according to the equality engine of this class? Also + * returns true if a and b are identical. + */ + bool areEqual(Node a, Node b); + /** + * Are a and b disequal according to the equality engine of this class? Also + * returns true if the representative of a and b are distinct constants. + */ + bool areDisequal(Node a, Node b); + //--------------------------- end equality engine + + //--------------------------- helper functions + /** get length with explanation + * + * If possible, this returns an arithmetic term that exists in the current + * context that is equal to the length of te, or otherwise returns the + * length of t. It adds to exp literals that hold in the current context that + * explain why that term is equal to the length of t. For example, if + * we have assertions: + * len( x ) = 5 ^ z = x ^ x = y, + * then getLengthExp( z, exp, y ) returns len( x ) and adds { z = x } to + * exp. On the other hand, getLengthExp( z, exp, x ) returns len( x ) and + * adds nothing to exp. + */ + Node getLengthExp(Node t, std::vector<Node>& exp, Node te); + /** shorthand for getLengthExp(t, exp, t) */ + Node getLength(Node t, std::vector<Node>& exp); + /** get normal string + * + * This method returns the node that is equivalent to the normal form of x, + * and adds the corresponding explanation to nf_exp. + * + * For example, if x = y ++ z is an assertion in the current context, then + * this method returns the term y ++ z and adds x = y ++ z to nf_exp. + */ + Node getNormalString(Node x, std::vector<Node>& nf_exp); + //-------------------------- end helper functions + + private: // Constants Node d_emptyString; - Node d_emptyRegexp; Node d_true; Node d_false; Node d_zero; Node d_one; Node d_neg_one; + /** the cardinality of the alphabet */ unsigned d_card_size; - // Helper functions - Node getRepresentative( Node t ); - bool hasTerm( Node a ); - bool areEqual( Node a, Node b ); - bool areDisequal( Node a, Node b ); - bool areCareDisequal( TNode x, TNode y ); - // t is representative, te = t, add lt = te to explanation exp - Node getLengthExp( Node t, std::vector< Node >& exp, Node te ); - Node getLength( Node t, std::vector< Node >& exp ); - -private: /** The notify class */ NotifyClass d_notify; /** Equaltity engine */ @@ -270,11 +308,10 @@ private: /** inferences: maintained to ensure ref count for internally introduced nodes */ NodeList d_infer; NodeList d_infer_exp; - /** normal forms */ - std::map< Node, Node > d_normal_forms_base; - std::map< Node, std::vector< Node > > d_normal_forms; - std::map< Node, std::vector< Node > > d_normal_forms_exp; - std::map< Node, std::map< Node, std::map< bool, int > > > d_normal_forms_exp_depend; + /** map from terms to their normal forms */ + std::map<Node, NormalForm> d_normal_form; + /** get normal form */ + NormalForm& getNormalForm(Node n); //map of pairs of terms that have the same normal form NodeIntMap d_nf_pairs; std::map< Node, std::vector< Node > > d_nf_pairs_data; @@ -431,8 +468,14 @@ private: class InferInfo { public: - unsigned d_i; - unsigned d_j; + /** for debugging + * + * The base pair of strings d_i/d_j that led to the inference, and whether + * (d_rev) we were processing the normal forms of these strings in reverse + * direction. + */ + Node d_i; + Node d_j; bool d_rev; std::vector<Node> d_ant; std::vector<Node> d_antn; @@ -517,10 +560,77 @@ private: //--------------------------end for checkCycles //--------------------------for checkNormalFormsEq + /** normalize equivalence class + * + * This method attempts to build a "normal form" for the equivalence class + * of string term n (for more details on normal forms, see normal_form.h + * or see Liang et al CAV 2014). In particular, this method checks whether the + * current normal form for each term in this equivalence class is identical. + * If it is not, then we add an inference via sendInference and abort the + * call. + */ void normalizeEquivalenceClass( Node n ); - void getNormalForms( Node &eqc, std::vector< std::vector< Node > > &normal_forms, std::vector< Node > &normal_form_src, - std::vector< std::vector< Node > > &normal_forms_exp, std::vector< std::map< Node, std::map< bool, int > > >& normal_forms_exp_depend ); - bool detectLoop( std::vector< std::vector< Node > > &normal_forms, int i, int j, int index, int &loop_in_i, int &loop_in_j, unsigned rproc ); + /** + * For each term in the equivalence class of eqc, this adds data regarding its + * normal form to normal_forms. The map term_to_nf_index maps terms to the + * index in normal_forms where their normal form data is located. + */ + void getNormalForms(Node eqc, + std::vector<NormalForm>& normal_forms, + std::map<Node, unsigned>& term_to_nf_index); + /** process normalize equivalence class + * + * This is called when an equivalence class contains a set of terms that + * have normal forms given by the argument normal_forms. It either + * verifies that all normal forms in this vector are identical, or otherwise + * adds a conflict, lemma, or inference via the sendInference method. + * + * To prioritize one inference versus another, it builds a set of possible + * inferences, at most two for each pair of distinct normal forms, + * corresponding to processing the normal form pair in the (forward, reverse) + * directions. Once all possible inferences are recorded, it executes the + * one with highest priority based on the enumeration type Inference. + */ + void processNEqc(std::vector<NormalForm>& normal_forms); + /** process simple normal equality + * + * This method is called when two equal terms have normal forms nfi and nfj. + * It adds (typically at most one) possible inference to the vector pinfer. + * This inference is in the form of an InferInfo object, which stores the + * necessary information regarding how to process the inference. + * + * index: The index in the normal form vectors (nfi.d_nf and nfj.d_nf) that + * we are currently checking. This method will increment this index until + * it finds an index where these vectors differ, or until it reaches the + * end of these vectors. + * isRev: Whether we are processing the normal forms in reverse direction. + * Notice in this case the normal form vectors have been reversed, hence, + * many operations are identical to the forward case, e.g. index is + * incremented not decremented, while others require special care, e.g. + * constant strings "ABC" in the normal form vectors are not reversed to + * "CBA" and hence all operations should assume a flipped semantics for + * constants when isRev is true, + * rproc: the number of string components on the suffix of the normal form of + * nfi and nfj that were already processed. This is used when using + * fowards/backwards traversals of normal forms to ensure that duplicate + * inferences are not processed. + * pinfer: the set of possible inferences we add to. + */ + void processSimpleNEq(NormalForm& nfi, + NormalForm& nfj, + unsigned& index, + bool isRev, + unsigned rproc, + std::vector<InferInfo>& pinfer); + //--------------------------end for checkNormalFormsEq + + //--------------------------for checkNormalFormsEq with loops + bool detectLoop(NormalForm& nfi, + NormalForm& nfj, + int index, + int& loop_in_i, + int& loop_in_j, + unsigned rproc); /** * Result of processLoop() below. @@ -535,36 +645,17 @@ private: SKIPPED, }; - ProcessLoopResult processLoop( - const std::vector<std::vector<Node> >& normal_forms, - const std::vector<Node>& normal_form_src, - int i, - int j, - int loop_n_index, - int other_n_index, - int loop_index, - int index, - InferInfo& info); - - void processNEqc( std::vector< std::vector< Node > > &normal_forms, std::vector< Node > &normal_form_src, - std::vector< std::vector< Node > > &normal_forms_exp, std::vector< std::map< Node, std::map< bool, int > > >& normal_forms_exp_depend ); - void processReverseNEq( std::vector< std::vector< Node > > &normal_forms, std::vector< Node > &normal_form_src, - std::vector< std::vector< Node > > &normal_forms_exp, std::vector< std::map< Node, std::map< bool, int > > >& normal_forms_exp_depend, - unsigned i, unsigned j, unsigned& index, unsigned rproc, std::vector< InferInfo >& pinfer ); - void processSimpleNEq( std::vector< std::vector< Node > > &normal_forms, std::vector< Node > &normal_form_src, - std::vector< std::vector< Node > > &normal_forms_exp, std::vector< std::map< Node, std::map< bool, int > > >& normal_forms_exp_depend, - unsigned i, unsigned j, unsigned& index, bool isRev, unsigned rproc, std::vector< InferInfo >& pinfer ); - //--------------------------end for checkNormalFormsEq + ProcessLoopResult processLoop(NormalForm& nfi, + NormalForm& nfj, + int loop_index, + int index, + InferInfo& info); + //--------------------------end for checkNormalFormsEq with loops //--------------------------for checkNormalFormsDeq void processDeq( Node n1, Node n2 ); int processReverseDeq( std::vector< Node >& nfi, std::vector< Node >& nfj, Node ni, Node nj ); int processSimpleDeq( std::vector< Node >& nfi, std::vector< Node >& nfj, Node ni, Node nj, unsigned& index, bool isRev ); - void getExplanationVectorForPrefix( std::vector< std::vector< Node > > &normal_forms_exp, std::vector< std::map< Node, std::map< bool, int > > >& normal_forms_exp_depend, - unsigned i, int index, bool isRev, std::vector< Node >& curr_exp ); - void getExplanationVectorForPrefixEq( std::vector< std::vector< Node > > &normal_forms, std::vector< Node > &normal_form_src, - std::vector< std::vector< Node > > &normal_forms_exp, std::vector< std::map< Node, std::map< bool, int > > >& normal_forms_exp_depend, - unsigned i, unsigned j, int index_i, int index_j, bool isRev, std::vector< Node >& curr_exp ); //--------------------------end for checkNormalFormsDeq //--------------------------------for checkMemberships @@ -607,6 +698,11 @@ private: protected: /** compute care graph */ void computeCareGraph() override; + /** + * Are x and y shared terms that are not equal? This is used for constructing + * the care graph in the above function. + */ + bool areCareDisequal(TNode x, TNode y); // do pending merges void assertPendingFact(Node atom, bool polarity, Node exp); @@ -641,6 +737,7 @@ private: */ void registerTerm(Node n, int effort); //-------------------------------------send inferences + public: /** send internal inferences * * This is called when we have inferred exp => conc, where exp is a set @@ -652,21 +749,81 @@ private: * sendInference below in that it does not introduce any new non-constant * terms to the state. * - * The argument c is a string identifying the reason for the interference. + * The argument c is a string identifying the reason for the inference. * This string is used for debugging purposes. + * + * Return true if the inference is complete, in the sense that we infer + * inferences that are equivalent to conc. This returns false e.g. if conc + * (or one of its conjuncts if it is a conjunction) was not inferred due + * to the criteria mentioned above. + */ + bool sendInternalInference(std::vector<Node>& exp, Node conc, const char* c); + /** send inference + * + * This function should be called when ( exp ^ exp_n ) => eq. The set exp + * contains literals that are explainable by this class, i.e. those that + * hold in the equality engine of this class. On the other hand, the set + * exp_n ("explanations new") contain nodes that are not explainable by this + * class. This method may call sendInfer or sendLemma. Overall, the result + * of this method is one of the following: + * + * [1] (No-op) Do nothing if eq is true, + * + * [2] (Infer) Indicate that eq should be added to the equality engine of this + * class with explanation EXPLAIN(exp), where EXPLAIN returns the + * explanation of the node in exp in terms of the literals asserted to this + * class, + * + * [3] (Lemma) Indicate that the lemma ( EXPLAIN(exp) ^ exp_n ) => eq should + * be sent on the output channel of this class, or + * + * [4] (Conflict) Immediately report a conflict EXPLAIN(exp) on the output + * channel of this class. + * + * Determining which case to apply depends on the form of eq and whether + * exp_n is empty. In particular, lemmas must be used whenever exp_n is + * non-empty, conflicts are used when exp_n is empty and eq is false. + * + * The argument c is a string identifying the reason for inference, used for + * debugging. + * + * If the flag asLemma is true, then this method will send a lemma instead + * of an inference whenever applicable. */ - void sendInternalInference(std::vector<Node>& exp, Node conc, const char* c); - // send lemma void sendInference(std::vector<Node>& exp, std::vector<Node>& exp_n, Node eq, const char* c, bool asLemma = false); + /** same as above, but where exp_n is empty */ void sendInference(std::vector<Node>& exp, Node eq, const char* c, bool asLemma = false); + /** + * Are we in conflict? This returns true if this theory has called its output + * channel's conflict method in the current SAT context. + */ + bool inConflict() const { return d_conflict; } + + protected: + /** + * Indicates that ant => conc should be sent on the output channel of this + * class. This will either trigger an immediate call to the conflict + * method of the output channel of this class of conc is false, or adds the + * above lemma to the lemma cache d_lemma_cache, which may be flushed + * later within the current call to TheoryStrings::check. + * + * The argument c is a string identifying the reason for inference, used for + * debugging. + */ void sendLemma(Node ant, Node conc, const char* c); + /** + * Indicates that conc should be added to the equality engine of this class + * with explanation eq_exp. It must be the case that eq_exp is a (conjunction + * of) literals that each are explainable, i.e. they already hold in the + * equality engine of this class. + */ void sendInfer(Node eq_exp, Node eq, const char* c); bool sendSplit(Node a, Node b, const char* c, bool preq = true); //-------------------------------------end send inferences @@ -680,10 +837,10 @@ private: /** mkExplain **/ Node mkExplain(std::vector<Node>& a); Node mkExplain(std::vector<Node>& a, std::vector<Node>& an); + + protected: /** mkAnd **/ Node mkAnd(std::vector<Node>& a); - /** get concat vector */ - void getConcatVec(Node n, std::vector<Node>& c); /** get equivalence classes * @@ -711,39 +868,11 @@ private: // Symbolic Regular Expression private: - // regular expression memberships - NodeList d_regexp_memberships; - NodeSet d_regexp_ucached; - NodeSet d_regexp_ccached; - // stored assertions - NodeIntMap d_pos_memberships; - std::map< Node, std::vector< Node > > d_pos_memberships_data; - NodeIntMap d_neg_memberships; - std::map< Node, std::vector< Node > > d_neg_memberships_data; - unsigned getNumMemberships( Node n, bool isPos ); - Node getMembership( Node n, bool isPos, unsigned i ); - // semi normal forms for symbolic expression - std::map< Node, Node > d_nf_regexps; - std::map< Node, std::vector< Node > > d_nf_regexps_exp; - // intersection - NodeNodeMap d_inter_cache; - NodeIntMap d_inter_index; - // processed memberships - NodeSet d_processed_memberships; - // antecedant for why regexp membership must be true - NodeNodeMap d_regexp_ant; - /** regular expression operation module */ - RegExpOpr d_regexp_opr; + /** regular expression solver module */ + RegExpSolver d_regexp_solver; /** regular expression elimination module */ RegExpElimination d_regexp_elim; - CVC4::String getHeadConst( Node x ); - bool deriveRegExp( Node x, Node r, Node ant ); - void addMembership(Node assertion); - Node getNormalString(Node x, std::vector<Node> &nf_exp); - Node getNormalSymRegExp(Node r, std::vector<Node> &nf_exp); - - // Finite Model Finding private: NodeSet d_input_vars; @@ -1037,4 +1166,4 @@ private: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__STRINGS__THEORY_STRINGS_H */ +#endif /* CVC4__THEORY__STRINGS__THEORY_STRINGS_H */ diff --git a/src/theory/strings/theory_strings_preprocess.cpp b/src/theory/strings/theory_strings_preprocess.cpp index d095d6801..6ceeff6f2 100644 --- a/src/theory/strings/theory_strings_preprocess.cpp +++ b/src/theory/strings/theory_strings_preprocess.cpp @@ -2,9 +2,9 @@ /*! \file theory_strings_preprocess.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tianyi Liang, Tim King + ** Andrew Reynolds, Tianyi Liang ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/strings/theory_strings_preprocess.h b/src/theory/strings/theory_strings_preprocess.h index ff0195dc1..b96d619ef 100644 --- a/src/theory/strings/theory_strings_preprocess.h +++ b/src/theory/strings/theory_strings_preprocess.h @@ -2,9 +2,9 @@ /*! \file theory_strings_preprocess.h ** \verbatim ** Top contributors (to current version): - ** Tianyi Liang, Andrew Reynolds, Morgan Deters + ** Andrew Reynolds, Tianyi Liang ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__STRINGS__PREPROCESS_H -#define __CVC4__THEORY__STRINGS__PREPROCESS_H +#ifndef CVC4__THEORY__STRINGS__PREPROCESS_H +#define CVC4__THEORY__STRINGS__PREPROCESS_H #include <vector> #include "context/cdhashmap.h" @@ -86,4 +86,4 @@ private: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__STRINGS__PREPROCESS_H */ +#endif /* CVC4__THEORY__STRINGS__PREPROCESS_H */ diff --git a/src/theory/strings/theory_strings_rewriter.cpp b/src/theory/strings/theory_strings_rewriter.cpp index cbb298c5f..35e966b78 100644 --- a/src/theory/strings/theory_strings_rewriter.cpp +++ b/src/theory/strings/theory_strings_rewriter.cpp @@ -2,9 +2,9 @@ /*! \file theory_strings_rewriter.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Tianyi Liang, Andres Noetzli + ** Andrew Reynolds, Andres Noetzli, Tianyi Liang ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -592,6 +592,106 @@ Node TheoryStringsRewriter::rewriteStrEqualityExt(Node node) } } + if (node[0].getKind() == STRING_CONCAT && node[1].getKind() == STRING_CONCAT) + { + // (= (str.++ x_1 ... x_i x_{i + 1} ... x_n) + // (str.++ y_1 ... y_j y_{j + 1} ... y_m)) ---> + // (and (= (str.++ x_1 ... x_i) (str.++ y_1 ... y_j)) + // (= (str.++ x_{i + 1} ... x_n) (str.++ y_{j + 1} ... y_m))) + // + // if (str.len (str.++ x_1 ... x_i)) = (str.len (str.++ y_1 ... y_j)) + // + // This rewrite performs length-based equality splitting: If we can show + // that two prefixes have the same length, we can split an equality into + // two equalities, one over the prefixes and another over the suffixes. + std::vector<Node> v0, v1; + getConcat(node[0], v0); + getConcat(node[1], v1); + size_t startRhs = 0; + for (size_t i = 0, size0 = v0.size(); i <= size0; i++) + { + std::vector<Node> pfxv0(v0.begin(), v0.begin() + i); + Node pfx0 = mkConcat(STRING_CONCAT, pfxv0); + for (size_t j = startRhs, size1 = v1.size(); j <= size1; j++) + { + if (!(i == 0 && j == 0) && !(i == v0.size() && j == v1.size())) + { + std::vector<Node> pfxv1(v1.begin(), v1.begin() + j); + Node pfx1 = mkConcat(STRING_CONCAT, pfxv1); + Node lenPfx0 = nm->mkNode(STRING_LENGTH, pfx0); + Node lenPfx1 = nm->mkNode(STRING_LENGTH, pfx1); + + if (checkEntailArithEq(lenPfx0, lenPfx1)) + { + std::vector<Node> sfxv0(v0.begin() + i, v0.end()); + std::vector<Node> sfxv1(v1.begin() + j, v1.end()); + Node ret = nm->mkNode(kind::AND, + pfx0.eqNode(pfx1), + mkConcat(STRING_CONCAT, sfxv0) + .eqNode(mkConcat(STRING_CONCAT, sfxv1))); + return returnRewrite(node, ret, "split-eq"); + } + else if (checkEntailArith(lenPfx1, lenPfx0, true)) + { + // The prefix on the right-hand side is strictly longer than the + // prefix on the left-hand side, so we try to strip the right-hand + // prefix by the length of the left-hand prefix + // + // Example: + // (= (str.++ "A" x y) (str.++ x "AB" z)) ---> + // (and (= (str.++ "A" x) (str.++ x "A")) (= y (str.++ "B" z))) + std::vector<Node> rpfxv1; + if (stripSymbolicLength(pfxv1, rpfxv1, 1, lenPfx0)) + { + std::vector<Node> sfxv0(v0.begin() + i, v0.end()); + pfxv1.insert(pfxv1.end(), v1.begin() + j, v1.end()); + Node ret = + nm->mkNode(kind::AND, + pfx0.eqNode(mkConcat(STRING_CONCAT, rpfxv1)), + mkConcat(STRING_CONCAT, sfxv0) + .eqNode(mkConcat(STRING_CONCAT, pfxv1))); + return returnRewrite(node, ret, "split-eq-strip-r"); + } + + // If the prefix of the right-hand side is (strictly) longer than + // the prefix of the left-hand side, we can advance the left-hand + // side (since the length of the right-hand side is only increasing + // in the inner loop) + break; + } + else if (checkEntailArith(lenPfx0, lenPfx1, true)) + { + // The prefix on the left-hand side is strictly longer than the + // prefix on the right-hand side, so we try to strip the left-hand + // prefix by the length of the right-hand prefix + // + // Example: + // (= (str.++ x "AB" z) (str.++ "A" x y)) ---> + // (and (= (str.++ x "A") (str.++ "A" x)) (= (str.++ "B" z) y)) + std::vector<Node> rpfxv0; + if (stripSymbolicLength(pfxv0, rpfxv0, 1, lenPfx1)) + { + pfxv0.insert(pfxv0.end(), v0.begin() + i, v0.end()); + std::vector<Node> sfxv1(v1.begin() + j, v1.end()); + Node ret = + nm->mkNode(kind::AND, + mkConcat(STRING_CONCAT, rpfxv0).eqNode(pfx1), + mkConcat(STRING_CONCAT, pfxv0) + .eqNode(mkConcat(STRING_CONCAT, sfxv1))); + return returnRewrite(node, ret, "split-eq-strip-l"); + } + + // If the prefix of the left-hand side is (strictly) longer than + // the prefix of the right-hand side, then we don't need to check + // that right-hand prefix for future left-hand prefixes anymore + // (since they are increasing in length) + startRhs = j + 1; + } + } + } + } + } + return node; } @@ -599,31 +699,11 @@ Node TheoryStringsRewriter::rewriteArithEqualityExt(Node node) { Assert(node.getKind() == EQUAL && node[0].getType().isInteger()); - NodeManager* nm = NodeManager::currentNM(); - // cases where we can solve the equality - for (unsigned i = 0; i < 2; i++) - { - if (node[i].isConst()) - { - Node on = node[1 - i]; - Kind onk = on.getKind(); - if (onk == STRING_STOI) - { - Rational r = node[i].getConst<Rational>(); - int sgn = r.sgn(); - Node onEq; - std::stringstream ss; - if (sgn >= 0) - { - ss << r.getNumerator(); - } - Node new_ret = on[0].eqNode(nm->mkConst(String(ss.str()))); - return returnRewrite(node, new_ret, "stoi-solve"); - } - } - } + // notice we cannot rewrite str.to.int(x)=n to x="n" due to leading zeroes. + + NodeManager* nm = NodeManager::currentNM(); if (checkEntailArith(node[0], node[1], true) || checkEntailArith(node[1], node[0], true)) { @@ -1497,7 +1577,7 @@ RewriteResponse TheoryStringsRewriter::postRewrite(TNode node) { if(s.isNumber()) { retNode = nm->mkConst(s.toNumber()); } else { - retNode = nm->mkConst(::CVC4::Rational(-1)); + retNode = nm->mkConst(Rational(-1)); } } else if(node[0].getKind() == kind::STRING_CONCAT) { for(unsigned i=0; i<node[0].getNumChildren(); ++i) { @@ -2314,6 +2394,22 @@ Node TheoryStringsRewriter::rewriteIndexof( Node node ) { Node ret = nm->mkNode(kind::STRING_STRIDOF, nn, node[1], node[2]); return returnRewrite(node, ret, "idof-def-ctn"); } + + // Strip components from the beginning that are guaranteed not to match + if (stripConstantEndpoints(children0, children1, nb, ne, 1)) + { + // str.indexof(str.++("AB", x, "C"), "C", 0) ---> + // 2 + str.indexof(str.++(x, "C"), "C", 0) + Node ret = + nm->mkNode(kind::PLUS, + nm->mkNode(kind::STRING_LENGTH, + mkConcat(kind::STRING_CONCAT, nb)), + nm->mkNode(kind::STRING_STRIDOF, + mkConcat(kind::STRING_CONCAT, children0), + node[1], + node[2])); + return returnRewrite(node, ret, "idof-strip-cnst-endpts"); + } } // strip symbolic length @@ -3621,6 +3717,8 @@ bool TheoryStringsRewriter::stripConstantEndpoints(std::vector<Node>& n1, Assert(nb.empty()); Assert(ne.empty()); + + NodeManager* nm = NodeManager::currentNM(); bool changed = false; // for ( forwards, backwards ) direction for (unsigned r = 0; r < 2; r++) @@ -3670,6 +3768,14 @@ bool TheoryStringsRewriter::stripConstantEndpoints(std::vector<Node>& n1, // str.contains( str.++( "c", x ), str.++( "cd", y ) ) overlap = r == 0 ? s.overlap(t) : t.overlap(s); } + else + { + // if we are looking at a substring, we can remove the component + // if there is no overlap + // e.g. str.contains( str.++( str.substr( "c", i, j ), x), "a" ) + // --> str.contains( x, "a" ) + removeComponent = ((r == 0 ? s.overlap(t) : t.overlap(s)) == 0); + } } else if (sss.empty()) // only if not substr { @@ -3701,15 +3807,13 @@ bool TheoryStringsRewriter::stripConstantEndpoints(std::vector<Node>& n1, // component if (r == 0) { - nb.push_back( - NodeManager::currentNM()->mkConst(s.prefix(overlap))); - n1[index0] = NodeManager::currentNM()->mkConst(s.suffix(overlap)); + nb.push_back(nm->mkConst(s.prefix(s.size() - overlap))); + n1[index0] = nm->mkConst(s.suffix(overlap)); } else { - ne.push_back( - NodeManager::currentNM()->mkConst(s.suffix(overlap))); - n1[index0] = NodeManager::currentNM()->mkConst(s.prefix(overlap)); + ne.push_back(nm->mkConst(s.suffix(s.size() - overlap))); + n1[index0] = nm->mkConst(s.prefix(overlap)); } } } diff --git a/src/theory/strings/theory_strings_rewriter.h b/src/theory/strings/theory_strings_rewriter.h index 81bc29ad6..e8886d43b 100644 --- a/src/theory/strings/theory_strings_rewriter.h +++ b/src/theory/strings/theory_strings_rewriter.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Andres Noetzli, Tianyi Liang ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -15,8 +15,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__STRINGS__THEORY_STRINGS_REWRITER_H -#define __CVC4__THEORY__STRINGS__THEORY_STRINGS_REWRITER_H +#ifndef CVC4__THEORY__STRINGS__THEORY_STRINGS_REWRITER_H +#define CVC4__THEORY__STRINGS__THEORY_STRINGS_REWRITER_H #include <utility> #include <vector> @@ -751,4 +751,4 @@ class TheoryStringsRewriter { }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__STRINGS__THEORY_STRINGS_REWRITER_H */ +#endif /* CVC4__THEORY__STRINGS__THEORY_STRINGS_REWRITER_H */ diff --git a/src/theory/strings/theory_strings_type_rules.h b/src/theory/strings/theory_strings_type_rules.h index 9357a8f98..91de8ac01 100644 --- a/src/theory/strings/theory_strings_type_rules.h +++ b/src/theory/strings/theory_strings_type_rules.h @@ -2,9 +2,9 @@ /*! \file theory_strings_type_rules.h ** \verbatim ** Top contributors (to current version): - ** Tianyi Liang, Tim King, Andrew Reynolds + ** Tianyi Liang, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -17,8 +17,8 @@ #include "cvc4_private.h" #include "options/strings_options.h" -#ifndef __CVC4__THEORY__STRINGS__THEORY_STRINGS_TYPE_RULES_H -#define __CVC4__THEORY__STRINGS__THEORY_STRINGS_TYPE_RULES_H +#ifndef CVC4__THEORY__STRINGS__THEORY_STRINGS_TYPE_RULES_H +#define CVC4__THEORY__STRINGS__THEORY_STRINGS_TYPE_RULES_H namespace CVC4 { namespace theory { @@ -490,4 +490,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__STRINGS__THEORY_STRINGS_TYPE_RULES_H */ +#endif /* CVC4__THEORY__STRINGS__THEORY_STRINGS_TYPE_RULES_H */ diff --git a/src/theory/strings/type_enumerator.h b/src/theory/strings/type_enumerator.h index 108b1edc4..5ca0b624d 100644 --- a/src/theory/strings/type_enumerator.h +++ b/src/theory/strings/type_enumerator.h @@ -2,9 +2,9 @@ /*! \file type_enumerator.h ** \verbatim ** Top contributors (to current version): - ** Tianyi Liang, Tim King, Andres Noetzli + ** Tianyi Liang, Tim King, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__STRINGS__TYPE_ENUMERATOR_H -#define __CVC4__THEORY__STRINGS__TYPE_ENUMERATOR_H +#ifndef CVC4__THEORY__STRINGS__TYPE_ENUMERATOR_H +#define CVC4__THEORY__STRINGS__TYPE_ENUMERATOR_H #include <sstream> @@ -128,4 +128,4 @@ class StringEnumeratorLength { }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__STRINGS__TYPE_ENUMERATOR_H */ +#endif /* CVC4__THEORY__STRINGS__TYPE_ENUMERATOR_H */ diff --git a/src/theory/subs_minimize.cpp b/src/theory/subs_minimize.cpp index 58daf5c75..c16fab4a9 100644 --- a/src/theory/subs_minimize.cpp +++ b/src/theory/subs_minimize.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/subs_minimize.h b/src/theory/subs_minimize.h index bf6ccffae..3ffd588f1 100644 --- a/src/theory/subs_minimize.h +++ b/src/theory/subs_minimize.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__SUBS_MINIMIZE_H -#define __CVC4__THEORY__SUBS_MINIMIZE_H +#ifndef CVC4__THEORY__SUBS_MINIMIZE_H +#define CVC4__THEORY__SUBS_MINIMIZE_H #include <vector> @@ -97,4 +97,4 @@ class SubstitutionMinimize } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__SUBS_MINIMIZE_H */ +#endif /* CVC4__THEORY__SUBS_MINIMIZE_H */ diff --git a/src/theory/substitutions.cpp b/src/theory/substitutions.cpp index 036bb4ada..9007386c4 100644 --- a/src/theory/substitutions.cpp +++ b/src/theory/substitutions.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Dejan Jovanovic, Clark Barrett, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -57,8 +57,8 @@ Node SubstitutionMap::internalSubstitute(TNode t, NodeCache& cache) { continue; } - if (!d_substituteUnderQuantifiers && - (current.getKind() == kind::FORALL || current.getKind() == kind::EXISTS)) { + if (!d_substituteUnderQuantifiers && current.isClosure()) + { Debug("substitution::internal") << "--not substituting under quantifier" << endl; cache[current] = current; toVisit.pop_back(); diff --git a/src/theory/substitutions.h b/src/theory/substitutions.h index 6d6875ba3..c19fb12f6 100644 --- a/src/theory/substitutions.h +++ b/src/theory/substitutions.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters, Dejan Jovanovic, Clark Barrett ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__SUBSTITUTIONS_H -#define __CVC4__THEORY__SUBSTITUTIONS_H +#ifndef CVC4__THEORY__SUBSTITUTIONS_H +#define CVC4__THEORY__SUBSTITUTIONS_H //#include <algorithm> #include <utility> @@ -199,4 +199,4 @@ std::ostream& operator<<(std::ostream& out, const theory::SubstitutionMap::itera }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__SUBSTITUTIONS_H */ +#endif /* CVC4__THEORY__SUBSTITUTIONS_H */ diff --git a/src/theory/term_registration_visitor.cpp b/src/theory/term_registration_visitor.cpp index fdab93375..3b11d8e54 100644 --- a/src/theory/term_registration_visitor.cpp +++ b/src/theory/term_registration_visitor.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Dejan Jovanovic, Andrew Reynolds, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -35,10 +35,7 @@ bool PreRegisterVisitor::alreadyVisited(TNode current, TNode parent) { Debug("register::internal") << "PreRegisterVisitor::alreadyVisited(" << current << "," << parent << ")" << std::endl; - if ((parent.getKind() == kind::FORALL || parent.getKind() == kind::EXISTS - || parent.getKind() == kind::LAMBDA - || parent.getKind() == kind::CHOICE - || parent.getKind() == kind::REWRITE_RULE + if ((parent.isClosure() || parent.getKind() == kind::REWRITE_RULE || parent.getKind() == kind::SEP_STAR || parent.getKind() == kind::SEP_WAND || (parent.getKind() == kind::SEP_LABEL && current.getType().isBoolean()) @@ -181,10 +178,7 @@ bool SharedTermsVisitor::alreadyVisited(TNode current, TNode parent) const { Debug("register::internal") << "SharedTermsVisitor::alreadyVisited(" << current << "," << parent << ")" << std::endl; - if ((parent.getKind() == kind::FORALL || parent.getKind() == kind::EXISTS - || parent.getKind() == kind::LAMBDA - || parent.getKind() == kind::CHOICE - || parent.getKind() == kind::REWRITE_RULE + if ((parent.isClosure() || parent.getKind() == kind::REWRITE_RULE || parent.getKind() == kind::SEP_STAR || parent.getKind() == kind::SEP_WAND || (parent.getKind() == kind::SEP_LABEL && current.getType().isBoolean()) diff --git a/src/theory/term_registration_visitor.h b/src/theory/term_registration_visitor.h index b12cef064..cdb411c16 100644 --- a/src/theory/term_registration_visitor.h +++ b/src/theory/term_registration_visitor.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Dejan Jovanovic, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/theory.cpp b/src/theory/theory.cpp index a4e814e8c..5108e312a 100644 --- a/src/theory/theory.cpp +++ b/src/theory/theory.cpp @@ -2,9 +2,9 @@ /*! \file theory.cpp ** \verbatim ** Top contributors (to current version): - ** Tim King, Andrew Reynolds, Dejan Jovanovic + ** Tim King, Dejan Jovanovic, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/theory.h b/src/theory/theory.h index 8a0c87c9e..cabb17f48 100644 --- a/src/theory/theory.h +++ b/src/theory/theory.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters, Dejan Jovanovic, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__THEORY_H -#define __CVC4__THEORY__THEORY_H +#ifndef CVC4__THEORY__THEORY_H +#define CVC4__THEORY__THEORY_H #include <iosfwd> #include <map> @@ -915,4 +915,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__THEORY_H */ +#endif /* CVC4__THEORY__THEORY_H */ diff --git a/src/theory/theory_engine.cpp b/src/theory/theory_engine.cpp index fb4075d82..78db1718e 100644 --- a/src/theory/theory_engine.cpp +++ b/src/theory/theory_engine.cpp @@ -2,9 +2,9 @@ /*! \file theory_engine.cpp ** \verbatim ** Top contributors (to current version): - ** Dejan Jovanovic, Morgan Deters, Guy Katz + ** Dejan Jovanovic, Morgan Deters, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -1061,9 +1061,7 @@ Node TheoryEngine::ppTheoryRewrite(TNode term) { Node newTerm; // do not rewrite inside quantifiers - if (term.getKind() == kind::FORALL || term.getKind() == kind::EXISTS - || term.getKind() == kind::CHOICE - || term.getKind() == kind::LAMBDA) + if (term.isClosure()) { newTerm = Rewriter::rewrite(term); } diff --git a/src/theory/theory_engine.h b/src/theory/theory_engine.h index c3281c9ba..701d5cefb 100644 --- a/src/theory/theory_engine.h +++ b/src/theory/theory_engine.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Dejan Jovanovic, Morgan Deters, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY_ENGINE_H -#define __CVC4__THEORY_ENGINE_H +#ifndef CVC4__THEORY_ENGINE_H +#define CVC4__THEORY_ENGINE_H #include <deque> #include <memory> @@ -932,4 +932,4 @@ private: }/* CVC4 namespace */ -#endif /* __CVC4__THEORY_ENGINE_H */ +#endif /* CVC4__THEORY_ENGINE_H */ diff --git a/src/theory/theory_model.cpp b/src/theory/theory_model.cpp index 2ccc48a6a..8d6511854 100644 --- a/src/theory/theory_model.cpp +++ b/src/theory/theory_model.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Clark Barrett, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/theory_model.h b/src/theory/theory_model.h index 3ffd1e8c1..baf3a401c 100644 --- a/src/theory/theory_model.h +++ b/src/theory/theory_model.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Tim King, Clark Barrett ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__THEORY_MODEL_H -#define __CVC4__THEORY__THEORY_MODEL_H +#ifndef CVC4__THEORY__THEORY_MODEL_H +#define CVC4__THEORY__THEORY_MODEL_H #include <unordered_map> #include <unordered_set> @@ -351,4 +351,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__THEORY_MODEL_H */ +#endif /* CVC4__THEORY__THEORY_MODEL_H */ diff --git a/src/theory/theory_model_builder.cpp b/src/theory/theory_model_builder.cpp index a9742b2ba..b032dfec4 100644 --- a/src/theory/theory_model_builder.cpp +++ b/src/theory/theory_model_builder.cpp @@ -2,9 +2,9 @@ /*! \file theory_model_builder.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Clark Barrett, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -47,6 +47,14 @@ bool TheoryEngineModelBuilder::isAssignable(TNode n) return !n.getType().isFunction(); } } + else if (n.getKind() == kind::FLOATINGPOINT_COMPONENT_SIGN) + { + // Extracting the sign of a floating-point number acts similar to a + // selector on a datatype, i.e. if `(sign x)` wasn't assigned a value, we + // can pick an arbitrary one. Note that the other components of a + // floating-point number should always be assigned a value. + return true; + } else { // non-function variables, and fully applied functions @@ -72,7 +80,7 @@ void TheoryEngineModelBuilder::addAssignableSubterms(TNode n, TheoryModel* tm, NodeSet& cache) { - if (n.getKind() == FORALL || n.getKind() == EXISTS) + if (n.isClosure()) { return; } diff --git a/src/theory/theory_model_builder.h b/src/theory/theory_model_builder.h index bff230b5c..ce090b14d 100644 --- a/src/theory/theory_model_builder.h +++ b/src/theory/theory_model_builder.h @@ -2,9 +2,9 @@ /*! \file theory_model_builder.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Mathias Preiner + ** Andrew Reynolds, Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__THEORY_MODEL_BUILDER_H -#define __CVC4__THEORY__THEORY_MODEL_BUILDER_H +#ifndef CVC4__THEORY__THEORY_MODEL_BUILDER_H +#define CVC4__THEORY__THEORY_MODEL_BUILDER_H #include <unordered_map> #include <unordered_set> @@ -259,4 +259,4 @@ class TheoryEngineModelBuilder : public ModelBuilder } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__THEORY_MODEL_BUILDER_H */ +#endif /* CVC4__THEORY__THEORY_MODEL_BUILDER_H */ diff --git a/src/theory/theory_registrar.h b/src/theory/theory_registrar.h index 10b90e522..822ae086c 100644 --- a/src/theory/theory_registrar.h +++ b/src/theory/theory_registrar.h @@ -2,9 +2,9 @@ /*! \file theory_registrar.h ** \verbatim ** Top contributors (to current version): - ** Tim King, Liana Hadarean, Morgan Deters + ** Liana Hadarean, Tim King, Mathias Preiner ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -20,8 +20,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__THEORY_REGISTRAR_H -#define __CVC4__THEORY__THEORY_REGISTRAR_H +#ifndef CVC4__THEORY__THEORY_REGISTRAR_H +#define CVC4__THEORY__THEORY_REGISTRAR_H #include "prop/registrar.h" #include "theory/theory_engine.h" @@ -44,4 +44,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__THEORY_REGISTRAR_H */ +#endif /* CVC4__THEORY__THEORY_REGISTRAR_H */ diff --git a/src/theory/theory_test_utils.h b/src/theory/theory_test_utils.h index e0db2fdeb..ecda12dee 100644 --- a/src/theory/theory_test_utils.h +++ b/src/theory/theory_test_utils.h @@ -2,9 +2,9 @@ /*! \file theory_test_utils.h ** \verbatim ** Top contributors (to current version): - ** Tim King, Morgan Deters, Liana Hadarean + ** Tim King, Morgan Deters, Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_public.h" -#ifndef __CVC4__THEORY__THEORY_TEST_UTILS_H -#define __CVC4__THEORY__THEORY_TEST_UTILS_H +#ifndef CVC4__THEORY__THEORY_TEST_UTILS_H +#define CVC4__THEORY__THEORY_TEST_UTILS_H #include <iostream> #include <memory> @@ -124,4 +124,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__THEORY_TEST_UTILS_H */ +#endif /* CVC4__THEORY__THEORY_TEST_UTILS_H */ diff --git a/src/theory/theory_traits_template.h b/src/theory/theory_traits_template.h index e046da408..00ad7656d 100644 --- a/src/theory/theory_traits_template.h +++ b/src/theory/theory_traits_template.h @@ -2,9 +2,9 @@ /*! \file theory_traits_template.h ** \verbatim ** Top contributors (to current version): - ** Dejan Jovanovic, Morgan Deters, Tim King + ** Morgan Deters, Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/type_enumerator.h b/src/theory/type_enumerator.h index 58961646c..a92cfd2af 100644 --- a/src/theory/type_enumerator.h +++ b/src/theory/type_enumerator.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters, Tim King, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__TYPE_ENUMERATOR_H -#define __CVC4__THEORY__TYPE_ENUMERATOR_H +#ifndef CVC4__THEORY__TYPE_ENUMERATOR_H +#define CVC4__THEORY__TYPE_ENUMERATOR_H #include "base/exception.h" #include "base/cvc4_assert.h" @@ -185,4 +185,4 @@ class TypeEnumerator { }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__TYPE_ENUMERATOR_H */ +#endif /* CVC4__THEORY__TYPE_ENUMERATOR_H */ diff --git a/src/theory/type_enumerator_template.cpp b/src/theory/type_enumerator_template.cpp index 14f3e9e87..8ccf27302 100644 --- a/src/theory/type_enumerator_template.cpp +++ b/src/theory/type_enumerator_template.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters, Tim King, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/type_set.cpp b/src/theory/type_set.cpp index 95c672f69..616245e2b 100644 --- a/src/theory/type_set.cpp +++ b/src/theory/type_set.cpp @@ -2,9 +2,9 @@ /*! \file type_set.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds + ** Andrew Reynolds, Clark Barrett ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/type_set.h b/src/theory/type_set.h index 633c8b04d..aed7ad80c 100644 --- a/src/theory/type_set.h +++ b/src/theory/type_set.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__TYPE_SET_H -#define __CVC4__THEORY__TYPE_SET_H +#ifndef CVC4__THEORY__TYPE_SET_H +#define CVC4__THEORY__TYPE_SET_H #include <unordered_map> #include <unordered_set> @@ -87,4 +87,4 @@ class TypeSet } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__TYPE_SET_H */ +#endif /* CVC4__THEORY__TYPE_SET_H */ diff --git a/src/theory/uf/equality_engine.cpp b/src/theory/uf/equality_engine.cpp index bd2fe9f9f..3e321bf29 100644 --- a/src/theory/uf/equality_engine.cpp +++ b/src/theory/uf/equality_engine.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Dejan Jovanovic, Guy Katz, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -929,9 +929,9 @@ std::string EqualityEngine::edgesToString(EqualityEdgeId edgeId) const { void EqualityEngine::explainEquality(TNode t1, TNode t2, bool polarity, std::vector<TNode>& equalities, EqProof* eqp) const { - Debug("equality") << d_name << "::eq::explainEquality(" << t1 << ", " << t2 - << ", " << (polarity ? "true" : "false") << ")" - << ", proof = " << (eqp ? "ON" : "OFF") << std::endl; + Debug("pf::ee") << d_name << "::eq::explainEquality(" << t1 << ", " << t2 + << ", " << (polarity ? "true" : "false") << ")" + << ", proof = " << (eqp ? "ON" : "OFF") << std::endl; // The terms must be there already Assert(hasTerm(t1) && hasTerm(t2));; @@ -940,9 +940,10 @@ void EqualityEngine::explainEquality(TNode t1, TNode t2, bool polarity, EqualityNodeId t1Id = getNodeId(t1); EqualityNodeId t2Id = getNodeId(t2); + std::map<std::pair<EqualityNodeId, EqualityNodeId>, EqProof*> cache; if (polarity) { // Get the explanation - getExplanation(t1Id, t2Id, equalities, eqp); + getExplanation(t1Id, t2Id, equalities, cache, eqp); } else { if (eqp) { eqp->d_id = eq::MERGED_THROUGH_TRANS; @@ -964,12 +965,15 @@ void EqualityEngine::explainEquality(TNode t1, TNode t2, bool polarity, eqpc = std::make_shared<EqProof>(); } - getExplanation(toExplain.first, toExplain.second, equalities, eqpc.get()); + getExplanation( + toExplain.first, toExplain.second, equalities, cache, eqpc.get()); if (eqpc) { - Debug("pf::ee") << "Child proof is:" << std::endl; - eqpc->debug_print("pf::ee", 1); - + if (Debug.isOn("pf::ee")) + { + Debug("pf::ee") << "Child proof is:" << std::endl; + eqpc->debug_print("pf::ee", 1); + } if (eqpc->d_id == eq::MERGED_THROUGH_TRANS) { std::vector<std::shared_ptr<EqProof>> orderedChildren; bool nullCongruenceFound = false; @@ -987,8 +991,13 @@ void EqualityEngine::explainEquality(TNode t1, TNode t2, bool polarity, if (nullCongruenceFound) { eqpc->d_children = orderedChildren; - Debug("pf::ee") << "Child proof's children have been reordered. It is now:" << std::endl; - eqpc->debug_print("pf::ee", 1); + if (Debug.isOn("pf::ee")) + { + Debug("pf::ee") + << "Child proof's children have been reordered. It is now:" + << std::endl; + eqpc->debug_print("pf::ee", 1); + } } } @@ -1011,8 +1020,11 @@ void EqualityEngine::explainEquality(TNode t1, TNode t2, bool polarity, *eqp = *temp; } - Debug("pf::ee") << "Disequality explanation final proof: " << std::endl; - eqp->debug_print("pf::ee", 1); + if (Debug.isOn("pf::ee")) + { + Debug("pf::ee") << "Disequality explanation final proof: " << std::endl; + eqp->debug_print("pf::ee", 1); + } } } } @@ -1024,15 +1036,65 @@ void EqualityEngine::explainPredicate(TNode p, bool polarity, << std::endl; // Must have the term Assert(hasTerm(p)); + std::map<std::pair<EqualityNodeId, EqualityNodeId>, EqProof*> cache; // Get the explanation - getExplanation(getNodeId(p), polarity ? d_trueId : d_falseId, assertions, - eqp); + getExplanation( + getNodeId(p), polarity ? d_trueId : d_falseId, assertions, cache, eqp); } -void EqualityEngine::getExplanation(EqualityNodeId t1Id, EqualityNodeId t2Id, - std::vector<TNode>& equalities, - EqProof* eqp) const { - Debug("equality") << d_name << "::eq::getExplanation(" << d_nodes[t1Id] << "," << d_nodes[t2Id] << ")" << std::endl; +void EqualityEngine::getExplanation( + EqualityNodeId t1Id, + EqualityNodeId t2Id, + std::vector<TNode>& equalities, + std::map<std::pair<EqualityNodeId, EqualityNodeId>, EqProof*>& cache, + EqProof* eqp) const +{ + Trace("eq-exp") << d_name << "::eq::getExplanation(" << d_nodes[t1Id] << "," + << d_nodes[t2Id] << ") size = " << cache.size() << std::endl; + + // determine if we have already computed the explanation. + std::pair<EqualityNodeId, EqualityNodeId> cacheKey; + std::map<std::pair<EqualityNodeId, EqualityNodeId>, EqProof*>::iterator it; + if (!eqp) + { + // If proofs are disabled, we order the ids, since explaining t1 = t2 is the + // same as explaining t2 = t1. + cacheKey = std::minmax(t1Id, t2Id); + it = cache.find(cacheKey); + if (it != cache.end()) + { + return; + } + } + else + { + // If proofs are enabled, note that proofs are sensitive to the order of t1 + // and t2, so we don't sort the ids in this case. TODO: Depending on how + // issue #2965 is resolved, we may be able to revisit this, if it is the + // case that proof/uf_proof.h,cpp is robust to equality ordering. + cacheKey = std::pair<EqualityNodeId, EqualityNodeId>(t1Id, t2Id); + it = cache.find(cacheKey); + if (it != cache.end()) + { + if (it->second) + { + eqp->d_id = it->second->d_id; + eqp->d_children.insert(eqp->d_children.end(), + it->second->d_children.begin(), + it->second->d_children.end()); + eqp->d_node = it->second->d_node; + } + else + { + // We may have cached null in its place, create the trivial proof now. + Assert(d_nodes[t1Id] == d_nodes[t2Id]); + Assert(eqp->d_id == MERGED_THROUGH_REFLEXIVITY); + eqp->d_node = d_nodes[t1Id]; + } + return; + } + } + cache[cacheKey] = eqp; // We can only explain the nodes that got merged #ifdef CVC4_ASSERTIONS @@ -1136,11 +1198,11 @@ void EqualityEngine::getExplanation(EqualityNodeId t1Id, EqualityNodeId t2Id, Debug("equality") << "Explaining left hand side equalities" << std::endl; std::shared_ptr<EqProof> eqpc1 = eqpc ? std::make_shared<EqProof>() : nullptr; - getExplanation(f1.a, f2.a, equalities, eqpc1.get()); + getExplanation(f1.a, f2.a, equalities, cache, eqpc1.get()); Debug("equality") << "Explaining right hand side equalities" << std::endl; std::shared_ptr<EqProof> eqpc2 = eqpc ? std::make_shared<EqProof>() : nullptr; - getExplanation(f1.b, f2.b, equalities, eqpc2.get()); + getExplanation(f1.b, f2.b, equalities, cache, eqpc2.get()); if( eqpc ){ eqpc->d_children.push_back( eqpc1 ); eqpc->d_children.push_back( eqpc2 ); @@ -1185,7 +1247,7 @@ void EqualityEngine::getExplanation(EqualityNodeId t1Id, EqualityNodeId t2Id, Debug("equality") << push; std::shared_ptr<EqProof> eqpc1 = eqpc ? std::make_shared<EqProof>() : nullptr; - getExplanation(eq.a, eq.b, equalities, eqpc1.get()); + getExplanation(eq.a, eq.b, equalities, cache, eqpc1.get()); if( eqpc ){ eqpc->d_children.push_back( eqpc1 ); } @@ -1211,13 +1273,20 @@ void EqualityEngine::getExplanation(EqualityNodeId t1Id, EqualityNodeId t2Id, Assert(isConstant(childId)); std::shared_ptr<EqProof> eqpcc = eqpc ? std::make_shared<EqProof>() : nullptr; - getExplanation(childId, getEqualityNode(childId).getFind(), - equalities, eqpcc.get()); + getExplanation(childId, + getEqualityNode(childId).getFind(), + equalities, + cache, + eqpcc.get()); if( eqpc ) { eqpc->d_children.push_back( eqpcc ); - - Debug("pf::ee") << "MERGED_THROUGH_CONSTANTS. Dumping the child proof" << std::endl; - eqpc->debug_print("pf::ee", 1); + if (Debug.isOn("pf::ee")) + { + Debug("pf::ee") + << "MERGED_THROUGH_CONSTANTS. Dumping the child proof" + << std::endl; + eqpc->debug_print("pf::ee", 1); + } } } @@ -1255,7 +1324,6 @@ void EqualityEngine::getExplanation(EqualityNodeId t1Id, EqualityNodeId t2Id, } eqpc->d_id = reasonType; } - equalities.push_back(reason); break; } @@ -1288,8 +1356,10 @@ void EqualityEngine::getExplanation(EqualityNodeId t1Id, EqualityNodeId t2Id, eqp->d_children.insert( eqp->d_children.end(), eqp_trans.begin(), eqp_trans.end() ); eqp->d_node = NodeManager::currentNM()->mkNode(kind::EQUAL, d_nodes[t1Id], d_nodes[t2Id]); } - - eqp->debug_print("pf::ee", 1); + if (Debug.isOn("pf::ee")) + { + eqp->debug_print("pf::ee", 1); + } } // Done @@ -2236,27 +2306,48 @@ bool EqClassIterator::isFinished() const { } void EqProof::debug_print(const char* c, unsigned tb, PrettyPrinter* prettyPrinter) const { - for(unsigned i=0; i<tb; i++) { Debug( c ) << " "; } + std::stringstream ss; + debug_print(ss, tb, prettyPrinter); + Debug(c) << ss.str(); +} +void EqProof::debug_print(std::ostream& os, + unsigned tb, + PrettyPrinter* prettyPrinter) const +{ + for (unsigned i = 0; i < tb; i++) + { + os << " "; + } if (prettyPrinter) - Debug( c ) << prettyPrinter->printTag(d_id); + { + os << prettyPrinter->printTag(d_id); + } else - Debug( c ) << d_id; + { + os << d_id; + } - Debug( c ) << "("; + os << "("; if( !d_children.empty() || !d_node.isNull() ){ if( !d_node.isNull() ){ - Debug( c ) << std::endl; - for( unsigned i=0; i<tb+1; i++ ) { Debug( c ) << " "; } - Debug( c ) << d_node; + os << std::endl; + for (unsigned i = 0; i < tb + 1; i++) + { + os << " "; + } + os << d_node; } for( unsigned i=0; i<d_children.size(); i++ ){ - if( i>0 || !d_node.isNull() ) Debug( c ) << ","; - Debug( c ) << std::endl; - d_children[i]->debug_print( c, tb+1, prettyPrinter ); + if (i > 0 || !d_node.isNull()) + { + os << ","; + } + os << std::endl; + d_children[i]->debug_print(os, tb + 1, prettyPrinter); } } - Debug( c ) << ")" << std::endl; + os << ")" << std::endl; } } // Namespace uf diff --git a/src/theory/uf/equality_engine.h b/src/theory/uf/equality_engine.h index 15abf7251..73d8bd4e9 100644 --- a/src/theory/uf/equality_engine.h +++ b/src/theory/uf/equality_engine.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Dejan Jovanovic, Morgan Deters, Guy Katz ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -516,11 +516,24 @@ private: bool d_inPropagate; /** - * Get an explanation of the equality t1 = t2. Returns the asserted equalities that - * imply t1 = t2. Returns TNodes as the assertion equalities should be hashed somewhere - * else. + * Get an explanation of the equality t1 = t2. Returns the asserted equalities + * that imply t1 = t2. Returns TNodes as the assertion equalities should be + * hashed somewhere else. + * + * This call refers to terms t1 and t2 by their ids t1Id and t2Id. + * + * If eqp is non-null, then this method populates eqp's information and + * children such that it is a proof of t1 = t2. + * + * We cache results of this call in cache, where cache[t1Id][t2Id] stores + * a proof of t1 = t2. */ - void getExplanation(EqualityEdgeId t1Id, EqualityNodeId t2Id, std::vector<TNode>& equalities, EqProof* eqp) const; + void getExplanation( + EqualityEdgeId t1Id, + EqualityNodeId t2Id, + std::vector<TNode>& equalities, + std::map<std::pair<EqualityNodeId, EqualityNodeId>, EqProof*>& cache, + EqProof* eqp) const; /** * Print the equality graph. @@ -941,8 +954,19 @@ public: unsigned d_id; Node d_node; std::vector<std::shared_ptr<EqProof>> d_children; + /** + * Debug print this proof on debug trace c with tabulation tb and pretty + * printer prettyPrinter. + */ void debug_print(const char* c, unsigned tb = 0, PrettyPrinter* prettyPrinter = nullptr) const; + /** + * Debug print this proof on output stream os with tabulation tb and pretty + * printer prettyPrinter. + */ + void debug_print(std::ostream& os, + unsigned tb = 0, + PrettyPrinter* prettyPrinter = nullptr) const; };/* class EqProof */ } // Namespace eq diff --git a/src/theory/uf/equality_engine_types.h b/src/theory/uf/equality_engine_types.h index 724ab423c..3813bb697 100644 --- a/src/theory/uf/equality_engine_types.h +++ b/src/theory/uf/equality_engine_types.h @@ -2,9 +2,9 @@ /*! \file equality_engine_types.h ** \verbatim ** Top contributors (to current version): - ** Dejan Jovanovic, Andres Noetzli, Andrew Reynolds + ** Dejan Jovanovic, Andrew Reynolds, Andres Noetzli ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -17,8 +17,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__UF__EQUALITY_ENGINE_TYPES_H -#define __CVC4__THEORY__UF__EQUALITY_ENGINE_TYPES_H +#ifndef CVC4__THEORY__UF__EQUALITY_ENGINE_TYPES_H +#define CVC4__THEORY__UF__EQUALITY_ENGINE_TYPES_H #include <string> #include <iostream> @@ -360,4 +360,4 @@ struct TriggerInfo { } // namespace theory } // namespace CVC4 -#endif /* __CVC4__THEORY__UF__EQUALITY_ENGINE_TYPES_H */ +#endif /* CVC4__THEORY__UF__EQUALITY_ENGINE_TYPES_H */ diff --git a/src/theory/uf/symmetry_breaker.cpp b/src/theory/uf/symmetry_breaker.cpp index 0313fabab..9c1d4c2f1 100644 --- a/src/theory/uf/symmetry_breaker.cpp +++ b/src/theory/uf/symmetry_breaker.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters, Liana Hadarean, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/uf/symmetry_breaker.h b/src/theory/uf/symmetry_breaker.h index 434ddd93b..d528e948f 100644 --- a/src/theory/uf/symmetry_breaker.h +++ b/src/theory/uf/symmetry_breaker.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters, Liana Hadarean, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -41,8 +41,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__UF__SYMMETRY_BREAKER_H -#define __CVC4__THEORY__UF__SYMMETRY_BREAKER_H +#ifndef CVC4__THEORY__UF__SYMMETRY_BREAKER_H +#define CVC4__THEORY__UF__SYMMETRY_BREAKER_H #include <iostream> #include <list> @@ -176,4 +176,4 @@ std::ostream& operator<<(std::ostream& out, const ::CVC4::theory::uf::SymmetryBr }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__UF__SYMMETRY_BREAKER_H */ +#endif /* CVC4__THEORY__UF__SYMMETRY_BREAKER_H */ diff --git a/src/theory/uf/theory_uf.cpp b/src/theory/uf/theory_uf.cpp index 645e1f656..508bd5002 100644 --- a/src/theory/uf/theory_uf.cpp +++ b/src/theory/uf/theory_uf.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Morgan Deters, Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -19,17 +19,18 @@ #include <memory> +#include "expr/node_algorithm.h" #include "options/quantifiers_options.h" #include "options/smt_options.h" +#include "options/theory_options.h" #include "options/uf_options.h" #include "proof/proof_manager.h" #include "proof/theory_proof.h" #include "proof/uf_proof.h" #include "theory/theory_model.h" #include "theory/type_enumerator.h" -#include "theory/uf/theory_uf_strong_solver.h" -#include "options/theory_options.h" #include "theory/uf/theory_uf_rewriter.h" +#include "theory/uf/theory_uf_strong_solver.h" using namespace std; @@ -186,22 +187,67 @@ Node TheoryUF::getApplyUfForHoApply( Node node ) { std::vector< TNode > args; Node f = TheoryUfRewriter::decomposeHoApply( node, args, true ); Node new_f = f; + NodeManager* nm = NodeManager::currentNM(); if( !TheoryUfRewriter::canUseAsApplyUfOperator( f ) ){ NodeNodeMap::const_iterator itus = d_uf_std_skolem.find( f ); if( itus==d_uf_std_skolem.end() ){ - // introduce skolem to make a standard APPLY_UF - new_f = NodeManager::currentNM()->mkSkolem( "app_uf", f.getType() ); - Node lem = new_f.eqNode( f ); + std::unordered_set<Node, NodeHashFunction> fvs; + expr::getFreeVariables(f, fvs); + Node lem; + if (!fvs.empty()) + { + std::vector<TypeNode> newTypes; + std::vector<Node> vs; + std::vector<Node> nvs; + for (const Node& v : fvs) + { + TypeNode vt = v.getType(); + newTypes.push_back(vt); + Node nv = nm->mkBoundVar(vt); + vs.push_back(v); + nvs.push_back(nv); + } + TypeNode ft = f.getType(); + std::vector<TypeNode> argTypes = ft.getArgTypes(); + TypeNode rangeType = ft.getRangeType(); + + newTypes.insert(newTypes.end(), argTypes.begin(), argTypes.end()); + TypeNode nft = nm->mkFunctionType(newTypes, rangeType); + new_f = nm->mkSkolem("app_uf", nft); + for (const Node& v : vs) + { + new_f = nm->mkNode(kind::HO_APPLY, new_f, v); + } + Assert(new_f.getType() == f.getType()); + Node eq = new_f.eqNode(f); + Node seq = eq.substitute(vs.begin(), vs.end(), nvs.begin(), nvs.end()); + lem = nm->mkNode( + kind::FORALL, nm->mkNode(kind::BOUND_VAR_LIST, nvs), seq); + } + else + { + // introduce skolem to make a standard APPLY_UF + new_f = nm->mkSkolem("app_uf", f.getType()); + lem = new_f.eqNode(f); + } Trace("uf-ho-lemma") << "uf-ho-lemma : Skolem definition for apply-conversion : " << lem << std::endl; d_out->lemma( lem ); d_uf_std_skolem[f] = new_f; }else{ new_f = (*itus).second; } + // unroll the HO_APPLY, adding to the first argument position + // Note arguments in the vector args begin at position 1. + while (new_f.getKind() == kind::HO_APPLY) + { + args.insert(args.begin() + 1, new_f[1]); + new_f = new_f[0]; + } } Assert( TheoryUfRewriter::canUseAsApplyUfOperator( new_f ) ); args[0] = new_f; - Node ret = NodeManager::currentNM()->mkNode( kind::APPLY_UF, args ); + Node ret = nm->mkNode(kind::APPLY_UF, args); + Assert(ret.getType() == node.getType()); return ret; } @@ -409,7 +455,8 @@ void TheoryUF::ppStaticLearn(TNode n, NodeBuilder<>& learned) { while(!workList.empty()) { n = workList.back(); - if(n.getKind() == kind::FORALL || n.getKind() == kind::EXISTS) { + if (n.isClosure()) + { // unsafe to go under quantifiers; we might pull bound vars out of scope! processed.insert(n); workList.pop_back(); diff --git a/src/theory/uf/theory_uf.h b/src/theory/uf/theory_uf.h index a0380f73a..72dc04b10 100644 --- a/src/theory/uf/theory_uf.h +++ b/src/theory/uf/theory_uf.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Dejan Jovanovic, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -17,8 +17,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__UF__THEORY_UF_H -#define __CVC4__THEORY__UF__THEORY_UF_H +#ifndef CVC4__THEORY__UF__THEORY_UF_H +#define CVC4__THEORY__UF__THEORY_UF_H #include "context/cdhashset.h" #include "context/cdo.h" @@ -315,4 +315,4 @@ private: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__UF__THEORY_UF_H */ +#endif /* CVC4__THEORY__UF__THEORY_UF_H */ diff --git a/src/theory/uf/theory_uf_model.cpp b/src/theory/uf/theory_uf_model.cpp index 42847dfd4..f279aebaf 100644 --- a/src/theory/uf/theory_uf_model.cpp +++ b/src/theory/uf/theory_uf_model.cpp @@ -2,9 +2,9 @@ /*! \file theory_uf_model.cpp ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Morgan Deters, Tim King + ** Andrew Reynolds, Morgan Deters, Clark Barrett ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/uf/theory_uf_model.h b/src/theory/uf/theory_uf_model.h index ac57bde27..4454b7e8c 100644 --- a/src/theory/uf/theory_uf_model.h +++ b/src/theory/uf/theory_uf_model.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY_UF_MODEL_H -#define __CVC4__THEORY_UF_MODEL_H +#ifndef CVC4__THEORY_UF_MODEL_H +#define CVC4__THEORY_UF_MODEL_H #include "theory/theory_model.h" diff --git a/src/theory/uf/theory_uf_rewriter.h b/src/theory/uf/theory_uf_rewriter.h index 3eb59e5fc..bad4189d6 100644 --- a/src/theory/uf/theory_uf_rewriter.h +++ b/src/theory/uf/theory_uf_rewriter.h @@ -2,9 +2,9 @@ /*! \file theory_uf_rewriter.h ** \verbatim ** Top contributors (to current version): - ** Andrew Reynolds, Morgan Deters, Dejan Jovanovic + ** Andrew Reynolds, Haniel Barbosa, Dejan Jovanovic ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -17,11 +17,13 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__UF__THEORY_UF_REWRITER_H -#define __CVC4__THEORY__UF__THEORY_UF_REWRITER_H +#ifndef CVC4__THEORY__UF__THEORY_UF_REWRITER_H +#define CVC4__THEORY__UF__THEORY_UF_REWRITER_H +#include "expr/node_algorithm.h" #include "theory/rewriter.h" #include "theory/substitutions.h" +#include "options/uf_options.h" namespace CVC4 { namespace theory { @@ -46,19 +48,52 @@ public: } if(node.getKind() == kind::APPLY_UF) { if( node.getOperator().getKind() == kind::LAMBDA ){ + Trace("uf-ho-beta") + << "uf-ho-beta : beta-reducing all args of : " << node << "\n"; TNode lambda = node.getOperator(); - std::vector<TNode> vars; - std::vector<TNode> subs; - for (const TNode& v : lambda[0]) + Node ret; + // build capture-avoiding substitution since in HOL shadowing may have + // been introduced + if (options::ufHo()) { - vars.push_back(v); + std::vector<Node> vars; + std::vector<Node> subs; + for (const Node& v : lambda[0]) + { + vars.push_back(v); + } + for (const Node& s : node) + { + subs.push_back(s); + } + if (Trace.isOn("uf-ho-beta")) + { + Trace("uf-ho-beta") << "uf-ho-beta: ..sub of " << subs.size() + << " vars into " << subs.size() << " terms :\n"; + for (unsigned i = 0, size = subs.size(); i < size; ++i) + { + Trace("uf-ho-beta") << "uf-ho-beta: .... " << vars[i] << " |-> " + << subs[i] << "\n"; + } + } + ret = expr::substituteCaptureAvoiding(lambda[1], vars, subs); + Trace("uf-ho-beta") << "uf-ho-beta : ..result : " << ret << "\n"; } - for (const TNode& s : node) + else { - subs.push_back(s); + std::vector<TNode> vars; + std::vector<TNode> subs; + for (const TNode& v : lambda[0]) + { + vars.push_back(v); + } + for (const TNode& s : node) + { + subs.push_back(s); + } + ret = lambda[1].substitute( + vars.begin(), vars.end(), subs.begin(), subs.end()); } - Node ret = lambda[1].substitute( - vars.begin(), vars.end(), subs.begin(), subs.end()); return RewriteResponse(REWRITE_AGAIN_FULL, ret); }else if( !canUseAsApplyUfOperator( node.getOperator() ) ){ return RewriteResponse(REWRITE_AGAIN_FULL, getHoApplyForApplyUf(node)); @@ -66,9 +101,12 @@ public: }else if( node.getKind() == kind::HO_APPLY ){ if( node[0].getKind() == kind::LAMBDA ){ // resolve one argument of the lambda - TNode arg = Rewriter::rewrite( node[1] ); - TNode var = node[0][0][0]; - Node new_body = node[0][1].substitute( var, arg ); + Trace("uf-ho-beta") + << "uf-ho-beta : beta-reducing one argument of : " << node[0] + << " with " << node[1] << "\n"; + + // reconstruct the lambda first to avoid variable shadowing + Node new_body = node[0][1]; if( node[0][0].getNumChildren()>1 ){ std::vector< Node > new_vars; for( unsigned i=1; i<node[0][0].getNumChildren(); i++ ){ @@ -78,7 +116,26 @@ public: largs.push_back( NodeManager::currentNM()->mkNode( kind::BOUND_VAR_LIST, new_vars ) ); largs.push_back( new_body ); new_body = NodeManager::currentNM()->mkNode( kind::LAMBDA, largs ); + Trace("uf-ho-beta") + << "uf-ho-beta : ....new lambda : " << new_body << "\n"; + } + + // build capture-avoiding substitution since in HOL shadowing may have + // been introduced + if (options::ufHo()) + { + Node arg = Rewriter::rewrite(node[1]); + Node var = node[0][0][0]; + new_body = expr::substituteCaptureAvoiding(new_body, var, arg); + } + else + { + TNode arg = Rewriter::rewrite(node[1]); + TNode var = node[0][0][0]; + new_body = new_body.substitute(var, arg); } + Trace("uf-ho-beta") + << "uf-ho-beta : ..new body : " << new_body << "\n"; return RewriteResponse( REWRITE_AGAIN_FULL, new_body ); } } @@ -156,4 +213,4 @@ public: //conversion between HO_APPLY AND APPLY_UF }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__UF__THEORY_UF_REWRITER_H */ +#endif /* CVC4__THEORY__UF__THEORY_UF_REWRITER_H */ diff --git a/src/theory/uf/theory_uf_strong_solver.cpp b/src/theory/uf/theory_uf_strong_solver.cpp index a19298b64..a21edd8eb 100644 --- a/src/theory/uf/theory_uf_strong_solver.cpp +++ b/src/theory/uf/theory_uf_strong_solver.cpp @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/uf/theory_uf_strong_solver.h b/src/theory/uf/theory_uf_strong_solver.h index 286c7391a..5dac994aa 100644 --- a/src/theory/uf/theory_uf_strong_solver.h +++ b/src/theory/uf/theory_uf_strong_solver.h @@ -2,9 +2,9 @@ /*! \file theory_uf_strong_solver.h ** \verbatim ** Top contributors (to current version): - ** Morgan Deters, Andrew Reynolds, Tim King + ** Andrew Reynolds, Morgan Deters, Tim King ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -14,8 +14,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY_UF_STRONG_SOLVER_H -#define __CVC4__THEORY_UF_STRONG_SOLVER_H +#ifndef CVC4__THEORY_UF_STRONG_SOLVER_H +#define CVC4__THEORY_UF_STRONG_SOLVER_H #include "context/cdhashmap.h" #include "context/context.h" @@ -476,4 +476,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY_UF_STRONG_SOLVER_H */ +#endif /* CVC4__THEORY_UF_STRONG_SOLVER_H */ diff --git a/src/theory/uf/theory_uf_type_rules.h b/src/theory/uf/theory_uf_type_rules.h index 2dbfae388..cb373b535 100644 --- a/src/theory/uf/theory_uf_type_rules.h +++ b/src/theory/uf/theory_uf_type_rules.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Andrew Reynolds, Tim King, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -16,8 +16,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__UF__THEORY_UF_TYPE_RULES_H -#define __CVC4__THEORY__UF__THEORY_UF_TYPE_RULES_H +#ifndef CVC4__THEORY__UF__THEORY_UF_TYPE_RULES_H +#define CVC4__THEORY__UF__THEORY_UF_TYPE_RULES_H namespace CVC4 { namespace theory { @@ -178,4 +178,4 @@ class HoApplyTypeRule { } /* CVC4::theory namespace */ } /* CVC4 namespace */ -#endif /* __CVC4__THEORY__UF__THEORY_UF_TYPE_RULES_H */ +#endif /* CVC4__THEORY__UF__THEORY_UF_TYPE_RULES_H */ diff --git a/src/theory/valuation.cpp b/src/theory/valuation.cpp index 62b3fc196..83a7e3bff 100644 --- a/src/theory/valuation.cpp +++ b/src/theory/valuation.cpp @@ -2,9 +2,9 @@ /*! \file valuation.cpp ** \verbatim ** Top contributors (to current version): - ** Dejan Jovanovic, Morgan Deters, Andrew Reynolds + ** Dejan Jovanovic, Andrew Reynolds, Morgan Deters ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim diff --git a/src/theory/valuation.h b/src/theory/valuation.h index 93b33cfdf..89f286a5e 100644 --- a/src/theory/valuation.h +++ b/src/theory/valuation.h @@ -4,7 +4,7 @@ ** Top contributors (to current version): ** Morgan Deters, Dejan Jovanovic, Andrew Reynolds ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim @@ -18,8 +18,8 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__VALUATION_H -#define __CVC4__THEORY__VALUATION_H +#ifndef CVC4__THEORY__VALUATION_H +#define CVC4__THEORY__VALUATION_H #include "expr/node.h" #include "options/theoryof_mode.h" @@ -151,4 +151,4 @@ public: }/* CVC4::theory namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__VALUATION_H */ +#endif /* CVC4__THEORY__VALUATION_H */ |