summaryrefslogtreecommitdiff
path: root/src/theory/sep
diff options
context:
space:
mode:
authorAina Niemetz <aina.niemetz@gmail.com>2021-04-20 15:55:56 -0700
committerGitHub <noreply@github.com>2021-04-20 22:55:56 +0000
commit10a4e43ad9a56a3a72878b24ec24c2e4fbccea57 (patch)
tree2c306afc9f9c8f9b2ff3eac4e6fd195e8cfa16e4 /src/theory/sep
parent9cb7212d58d42cf1433dc086d305f1a202c3771b (diff)
Sep: Move implementation of type rules to cpp. (#6402)
Diffstat (limited to 'src/theory/sep')
-rw-r--r--src/theory/sep/theory_sep_type_rules.cpp120
-rw-r--r--src/theory/sep/theory_sep_type_rules.h104
2 files changed, 147 insertions, 77 deletions
diff --git a/src/theory/sep/theory_sep_type_rules.cpp b/src/theory/sep/theory_sep_type_rules.cpp
new file mode 100644
index 000000000..28dfa5c40
--- /dev/null
+++ b/src/theory/sep/theory_sep_type_rules.cpp
@@ -0,0 +1,120 @@
+/******************************************************************************
+ * Top contributors (to current version):
+ * Andrew Reynolds, Tim King, Mathias Preiner
+ *
+ * This file is part of the cvc5 project.
+ *
+ * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
+ * in the top-level source directory and their institutional affiliations.
+ * All rights reserved. See the file COPYING in the top-level source
+ * directory for licensing information.
+ * ****************************************************************************
+ *
+ * Typing and cardinality rules for the theory of sep.
+ */
+
+#include "theory/sep/theory_sep_type_rules.h"
+
+namespace cvc5 {
+namespace theory {
+namespace sep {
+
+TypeNode SepEmpTypeRule::computeType(NodeManager* nodeManager,
+ TNode n,
+ bool check)
+{
+ Assert(n.getKind() == kind::SEP_EMP);
+ return nodeManager->booleanType();
+}
+
+TypeNode SepPtoTypeRule::computeType(NodeManager* nodeManager,
+ TNode n,
+ bool check)
+{
+ Assert(n.getKind() == kind::SEP_PTO);
+ if (check)
+ {
+ TypeNode refType = n[0].getType(check);
+ TypeNode ptType = n[1].getType(check);
+ }
+ return nodeManager->booleanType();
+}
+
+TypeNode SepStarTypeRule::computeType(NodeManager* nodeManager,
+ TNode n,
+ bool check)
+{
+ TypeNode btype = nodeManager->booleanType();
+ Assert(n.getKind() == kind::SEP_STAR);
+ if (check)
+ {
+ for (unsigned i = 0; i < n.getNumChildren(); i++)
+ {
+ TypeNode ctype = n[i].getType(check);
+ if (ctype != btype)
+ {
+ throw TypeCheckingExceptionPrivate(n,
+ "child of sep star is not Boolean");
+ }
+ }
+ }
+ return btype;
+}
+
+TypeNode SepWandTypeRule::computeType(NodeManager* nodeManager,
+ TNode n,
+ bool check)
+{
+ TypeNode btype = nodeManager->booleanType();
+ Assert(n.getKind() == kind::SEP_WAND);
+ if (check)
+ {
+ for (unsigned i = 0; i < n.getNumChildren(); i++)
+ {
+ TypeNode ctype = n[i].getType(check);
+ if (ctype != btype)
+ {
+ throw TypeCheckingExceptionPrivate(
+ n, "child of sep magic wand is not Boolean");
+ }
+ }
+ }
+ return btype;
+}
+
+TypeNode SepLabelTypeRule::computeType(NodeManager* nodeManager,
+ TNode n,
+ bool check)
+{
+ TypeNode btype = nodeManager->booleanType();
+ Assert(n.getKind() == kind::SEP_LABEL);
+ if (check)
+ {
+ TypeNode ctype = n[0].getType(check);
+ if (ctype != btype)
+ {
+ throw TypeCheckingExceptionPrivate(n,
+ "child of sep label is not Boolean");
+ }
+ TypeNode stype = n[1].getType(check);
+ if (!stype.isSet())
+ {
+ throw TypeCheckingExceptionPrivate(n, "label of sep label is not a set");
+ }
+ }
+ return btype;
+}
+
+TypeNode SepNilTypeRule::computeType(NodeManager* nodeManager,
+ TNode n,
+ bool check)
+{
+ Assert(n.getKind() == kind::SEP_NIL);
+ Assert(check);
+ TypeNode type = n.getType();
+ return type;
+}
+
+} // namespace sep
+} // namespace theory
+} // namespace cvc5
diff --git a/src/theory/sep/theory_sep_type_rules.h b/src/theory/sep/theory_sep_type_rules.h
index 676cb8d9d..f437ba2d7 100644
--- a/src/theory/sep/theory_sep_type_rules.h
+++ b/src/theory/sep/theory_sep_type_rules.h
@@ -18,93 +18,43 @@
#ifndef CVC5__THEORY__SEP__THEORY_SEP_TYPE_RULES_H
#define CVC5__THEORY__SEP__THEORY_SEP_TYPE_RULES_H
+#include "expr/node.h"
+#include "expr/type_node.h"
+
namespace cvc5 {
namespace theory {
namespace sep {
-class SepEmpTypeRule {
-public:
- inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check)
- {
- Assert(n.getKind() == kind::SEP_EMP);
- return nodeManager->booleanType();
- }
+class SepEmpTypeRule
+{
+ public:
+ static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
};
-struct SepPtoTypeRule {
- inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check)
- {
- Assert(n.getKind() == kind::SEP_PTO);
- if( check ) {
- TypeNode refType = n[0].getType(check);
- TypeNode ptType = n[1].getType(check);
- }
- return nodeManager->booleanType();
- }
-};/* struct SepSelectTypeRule */
+struct SepPtoTypeRule
+{
+ static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
+};
-struct SepStarTypeRule {
- inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check)
- {
- TypeNode btype = nodeManager->booleanType();
- Assert(n.getKind() == kind::SEP_STAR);
- if( check ){
- for( unsigned i=0; i<n.getNumChildren(); i++ ){
- TypeNode ctype = n[i].getType( check );
- if( ctype!=btype ){
- throw TypeCheckingExceptionPrivate(n, "child of sep star is not Boolean");
- }
- }
- }
- return btype;
- }
-};/* struct SepStarTypeRule */
+struct SepStarTypeRule
+{
+ static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
+};
-struct SepWandTypeRule {
- inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check)
- {
- TypeNode btype = nodeManager->booleanType();
- Assert(n.getKind() == kind::SEP_WAND);
- if( check ){
- for( unsigned i=0; i<n.getNumChildren(); i++ ){
- TypeNode ctype = n[i].getType( check );
- if( ctype!=btype ){
- throw TypeCheckingExceptionPrivate(n, "child of sep magic wand is not Boolean");
- }
- }
- }
- return btype;
- }
-};/* struct SepWandTypeRule */
+struct SepWandTypeRule
+{
+ static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
+};
-struct SepLabelTypeRule {
- inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check)
- {
- TypeNode btype = nodeManager->booleanType();
- Assert(n.getKind() == kind::SEP_LABEL);
- if( check ){
- TypeNode ctype = n[0].getType( check );
- if( ctype!=btype ){
- throw TypeCheckingExceptionPrivate(n, "child of sep label is not Boolean");
- }
- TypeNode stype = n[1].getType( check );
- if( !stype.isSet() ){
- throw TypeCheckingExceptionPrivate(n, "label of sep label is not a set");
- }
- }
- return btype;
- }
-};/* struct SepLabelTypeRule */
+struct SepLabelTypeRule
+{
+ static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
+};
-struct SepNilTypeRule {
- inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check)
- {
- Assert(n.getKind() == kind::SEP_NIL);
- Assert(check);
- TypeNode type = n.getType();
- return type;
- }
-};/* struct SepLabelTypeRule */
+struct SepNilTypeRule
+{
+ static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
+};
} // namespace sep
} // namespace theory
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback