return Expr(this, d_nodeManager->mkBoundVarPtr(*type.d_typeNode));
}
-Expr ExprManager::mkUniqueVar(Type type, Kind k){
+Expr ExprManager::mkNullaryOperator(Type type, Kind k){
NodeManagerScope nms(d_nodeManager);
- Node n = d_nodeManager->mkUniqueVar(*type.d_typeNode, k);
+ Node n = d_nodeManager->mkNullaryOperator(*type.d_typeNode, k);
return n.toExpr();
}
/**
* Create unique variable of type
*/
- Expr mkUniqueVar( Type type, Kind k);
+ Expr mkNullaryOperator( Type type, Kind k);
/** Get a reference to the statistics registry for this ExprManager */
Statistics getStatistics() const throw();
VARIABLE, /**< special node kinds: no operator */
OPERATOR, /**< operators that get "inlined" */
PARAMETERIZED, /**< parameterized ops (like APPLYs) that carry extra data */
- CONSTANT /**< constants */
+ CONSTANT, /**< constants */
+ NULLARY_OPERATOR /**< nullary operator */
};/* enum MetaKind_t */
}/* CVC4::kind::metakind namespace */
}/* CVC4::kind namespace */
-#line 342 "${template}"
+#line 343 "${template}"
namespace theory {
case $1: return to->mkConst(n.getConst< $2 >());"
}
+function nullaryoperator {
+ # nullaryoperator K ["comment"]
+ lineno=${BASH_LINENO[0]}
+ check_theory_seen
+}
+
function check_theory_seen {
if $seen_endtheory; then
echo "$kf:$lineno: error: command after \"endtheory\" declaration (endtheory has to be last)" >&2
register_kind "$1" 0 "$5"
}
+function nullaryoperator {
+ # nullaryoperator K ["comment"]
+
+ lineno=${BASH_LINENO[0]}
+
+ check_theory_seen
+ register_kind "$1" 0 "$2"
+}
+
function register_sort {
id=$1
cardinality=$2
"
}
+function nullaryoperator {
+ # nullaryoperator K ["comment"]
+
+ lineno=${BASH_LINENO[0]}
+
+ check_theory_seen
+ register_metakind NULLARY_OPERATOR "$1" 0
+}
+
function registerOperatorToKind {
operatorKind=$1
applyKind=$2
assertTNodeNotExpired();
return getMetaKind() == kind::metakind::VARIABLE;
}
- inline bool isUninterpretedVar() const {
- assertTNodeNotExpired();
- return getMetaKind() == kind::metakind::VARIABLE &&
- getKind() != kind::UNIVERSE_SET &&
- getKind() != kind::SEP_NIL;
- }
inline bool isClosure() const {
assertTNodeNotExpired();
case kind::metakind::CONSTANT:
IllegalArgument(*this, "getOperator() called on Node with CONSTANT-kinded kind");
+ case kind::metakind::NULLARY_OPERATOR:
+ IllegalArgument(*this, "getOperator() called on Node with NULLARY_OPERATOR-kinded kind");
+
default:
Unhandled(mk);
}
// file comments at the top of this file.
// Case 0: If a VARIABLE
- if(getMetaKind() == kind::metakind::VARIABLE) {
+ if(getMetaKind() == kind::metakind::VARIABLE || getMetaKind() == kind::metakind::NULLARY_OPERATOR) {
/* 0. If a VARIABLE, treat similarly to 1(b), except that we know
* there are no children (no reference counts to reason about),
* and we don't keep VARIABLE-kinded Nodes in the NodeManager
// file comments at the top of this file.
// Case 0: If a VARIABLE
- if(getMetaKind() == kind::metakind::VARIABLE) {
+ if(getMetaKind() == kind::metakind::VARIABLE || getMetaKind() == kind::metakind::NULLARY_OPERATOR) {
/* 0. If a VARIABLE, treat similarly to 1(b), except that we know
* there are no children (no reference counts to reason about),
* and we don't keep VARIABLE-kinded Nodes in the NodeManager
if( d_nm->getOptions()[options::earlyTypeChecking] ) {
kind::MetaKind mk = n.getMetaKind();
if( mk != kind::metakind::VARIABLE
+ && mk != kind::metakind::NULLARY_OPERATOR
&& mk != kind::metakind::CONSTANT ) {
d_nm->getType(n, true);
}
// remove from the pool
kind::MetaKind mk = nv->getMetaKind();
- if(mk != kind::metakind::VARIABLE) {
+ if(mk != kind::metakind::VARIABLE && mk != kind::metakind::NULLARY_OPERATOR) {
poolRemove(nv);
}
return n;
}
-Node NodeManager::mkUniqueVar(const TypeNode& type, Kind k) {
+Node NodeManager::mkNullaryOperator(const TypeNode& type, Kind k) {
std::map< TypeNode, Node >::iterator it = d_unique_vars[k].find( type );
if( it==d_unique_vars[k].end() ){
Node n = NodeBuilder<0>(this, k);
n.setAttribute(TypeAttr(), type);
- n.setAttribute(TypeCheckedAttr(), true);
+ //should type check it
+ //n.setAttribute(TypeCheckedAttr(), true);
d_unique_vars[k][type] = n;
- Assert( n.getMetaKind() == kind::metakind::VARIABLE );
+ Assert( n.getMetaKind() == kind::metakind::NULLARY_OPERATOR );
return n;
}else{
return it->second;
Node mkAbstractValue(const TypeNode& type);
/** make unique (per Type,Kind) variable. */
- Node mkUniqueVar(const TypeNode& type, Kind k);
+ Node mkNullaryOperator(const TypeNode& type, Kind k);
/**
* Create a constant of type T. It will have the appropriate
case kind::metakind::INVALID:
case kind::metakind::VARIABLE:
+ case kind::metakind::NULLARY_OPERATOR:
return false;
case kind::metakind::OPERATOR:
indent(out, ind);
out << '(';
out << getKind();
- if (getMetaKind() == kind::metakind::VARIABLE) {
+ if (getMetaKind() == kind::metakind::VARIABLE || getMetaKind() == kind::metakind::NULLARY_OPERATOR ) {
out << ' ' << getId();
} else if (getMetaKind() == kind::metakind::CONSTANT) {
out << ' ';
bool TypeChecker::computeIsConst(NodeManager* nodeManager, TNode n)
throw (AssertionException) {
- Assert(n.getMetaKind() == kind::metakind::OPERATOR || n.getMetaKind() == kind::metakind::PARAMETERIZED);
+ Assert(n.getMetaKind() == kind::metakind::OPERATOR || n.getMetaKind() == kind::metakind::PARAMETERIZED || n.getMetaKind() == kind::metakind::NULLARY_OPERATOR);
switch(n.getKind()) {
${construles}
bool TypeChecker::neverIsConst(NodeManager* nodeManager, TNode n)
throw (AssertionException) {
- Assert(n.getMetaKind() == kind::metakind::OPERATOR || n.getMetaKind() == kind::metakind::PARAMETERIZED);
+ Assert(n.getMetaKind() == kind::metakind::OPERATOR || n.getMetaKind() == kind::metakind::PARAMETERIZED || n.getMetaKind() == kind::metakind::NULLARY_OPERATOR);
switch(n.getKind()) {
${neverconstrules}
} else if(f.getKind() == CVC4::kind::EMPTYSET && t.isSet()) {
f = MK_CONST(CVC4::EmptySet(t));
} else if(f.getKind() == CVC4::kind::UNIVERSE_SET && t.isSet()) {
- f = EXPR_MANAGER->mkUniqueVar(t, kind::UNIVERSE_SET);
+ f = EXPR_MANAGER->mkNullaryOperator(t, kind::UNIVERSE_SET);
} else {
if(f.getType() != t) {
PARSER_STATE->parseError("Type ascription not satisfied.");
{ f = MK_CONST(EmptySet(Type())); }
| UNIVSET_TOK
{ //booleanType is placeholder
- f = EXPR_MANAGER->mkUniqueVar(EXPR_MANAGER->booleanType(), kind::UNIVERSE_SET);
+ f = EXPR_MANAGER->mkNullaryOperator(EXPR_MANAGER->booleanType(), kind::UNIVERSE_SET);
}
/* finite set literal */
<< f2 << " " << type << std::endl;
expr = MK_CONST( ::CVC4::EmptySet(type) );
} else if(f.getKind() == CVC4::kind::UNIVERSE_SET) {
- expr = EXPR_MANAGER->mkUniqueVar(type, kind::UNIVERSE_SET);
+ expr = EXPR_MANAGER->mkNullaryOperator(type, kind::UNIVERSE_SET);
} else if(f.getKind() == CVC4::kind::SEP_NIL) {
//We don't want the nil reference to be a constant: for instance, it
//could be of type Int but is not a const rational. However, the
//expression has 0 children. So we convert to a SEP_NIL variable.
- expr = EXPR_MANAGER->mkUniqueVar(type, kind::SEP_NIL);
+ expr = EXPR_MANAGER->mkNullaryOperator(type, kind::SEP_NIL);
} else {
if(f.getType() != type) {
PARSER_STATE->parseError("Type ascription not satisfied.");
| UNIVSET_TOK
{ //booleanType is placeholder here since we don't have type info without type annotation
- expr = EXPR_MANAGER->mkUniqueVar(EXPR_MANAGER->booleanType(), kind::UNIVERSE_SET); }
+ expr = EXPR_MANAGER->mkNullaryOperator(EXPR_MANAGER->booleanType(), kind::UNIVERSE_SET); }
| NILREF_TOK
{ //booleanType is placeholder here since we don't have type info without type annotation
- expr = EXPR_MANAGER->mkUniqueVar(EXPR_MANAGER->booleanType(), kind::SEP_NIL); }
+ expr = EXPR_MANAGER->mkNullaryOperator(EXPR_MANAGER->booleanType(), kind::SEP_NIL); }
// NOTE: Theory constants go here
;
Trace("rewriteApplyToConst") << "rewriteApplyToConst :: " << n << std::endl;
if(n.getMetaKind() == kind::metakind::CONSTANT ||
- n.getMetaKind() == kind::metakind::VARIABLE)
+ n.getMetaKind() == kind::metakind::VARIABLE ||
+ n.getMetaKind() == kind::metakind::NULLARY_OPERATOR)
{
return n;
}
rewriter ::CVC4::theory::sep::TheorySepRewriter "theory/sep/theory_sep_rewriter.h"
-variable SEP_NIL "separation nil"
+nullaryoperator SEP_NIL "separation nil"
operator SEP_EMP 2 "separation empty heap"
operator SEP_PTO 2 "points to relation"
typerule SEP_STAR ::CVC4::theory::sep::SepStarTypeRule
typerule SEP_WAND ::CVC4::theory::sep::SepWandTypeRule
typerule SEP_LABEL ::CVC4::theory::sep::SepLabelTypeRule
+typerule SEP_NIL ::CVC4::theory::sep::SepNilTypeRule
endtheory
Node TheorySep::getNilRef( TypeNode tn ) {
std::map< TypeNode, Node >::iterator it = d_nil_ref.find( tn );
if( it==d_nil_ref.end() ){
- Node nil = NodeManager::currentNM()->mkUniqueVar( tn, kind::SEP_NIL );
+ Node nil = NodeManager::currentNM()->mkNullaryOperator( tn, kind::SEP_NIL );
setNilRef( tn, nil );
return nil;
}else{
}
};/* struct SepLabelTypeRule */
+struct SepNilTypeRule {
+ inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check)
+ throw (TypeCheckingExceptionPrivate, AssertionException) {
+ Assert(n.getKind() == kind::SEP_NIL);
+ Assert(check);
+ TypeNode type = n.getType(false);
+ return type;
+ }
+};/* struct SepLabelTypeRule */
+
+
}/* CVC4::theory::sep namespace */
}/* CVC4::theory namespace */
}/* CVC4 namespace */
operator INSERT 2: "set obtained by inserting elements (first N-1 parameters) into a set (the last parameter)"
operator CARD 1 "set cardinality operator"
operator COMPLEMENT 1 "set COMPLEMENT (with respect to finite universe)"
+nullaryoperator UNIVERSE_SET "(finite) universe set, all set variables must be interpreted as subsets of it."
operator JOIN 2 "set join"
operator PRODUCT 2 "set cartesian product"
typerule INSERT ::CVC4::theory::sets::InsertTypeRule
typerule CARD ::CVC4::theory::sets::CardTypeRule
typerule COMPLEMENT ::CVC4::theory::sets::ComplementTypeRule
+typerule UNIVERSE_SET ::CVC4::theory::sets::UniverseSetTypeRule
typerule JOIN ::CVC4::theory::sets::RelBinaryOperatorTypeRule
typerule PRODUCT ::CVC4::theory::sets::RelBinaryOperatorTypeRule
typerule TRANSPOSE ::CVC4::theory::sets::RelTransposeTypeRule
typerule TCLOSURE ::CVC4::theory::sets::RelTransClosureTypeRule
-variable UNIVERSE_SET "(finite) universe set, all set variables must be interpreted as subsets of it."
-
construle UNION ::CVC4::theory::sets::SetsBinaryOperatorTypeRule
construle INTERSECTION ::CVC4::theory::sets::SetsBinaryOperatorTypeRule
construle SETMINUS ::CVC4::theory::sets::SetsBinaryOperatorTypeRule
Node TheorySetsPrivate::getUnivSet( TypeNode tn ) {
std::map< TypeNode, Node >::iterator it = d_univset.find( tn );
if( it==d_univset.end() ){
- Node n = NodeManager::currentNM()->mkUniqueVar(tn, kind::UNIVERSE_SET);
+ Node n = NodeManager::currentNM()->mkNullaryOperator(tn, kind::UNIVERSE_SET);
d_univset[tn] = n;
return n;
}else{
break;
}//kind::UNION
case kind::COMPLEMENT: {
- Node univ = NodeManager::currentNM()->mkUniqueVar( node[0].getType(), kind::UNIVERSE_SET );
+ Node univ = NodeManager::currentNM()->mkNullaryOperator( node[0].getType(), kind::UNIVERSE_SET );
return RewriteResponse( REWRITE_AGAIN, NodeManager::currentNM()->mkNode( kind::SETMINUS, univ, node[0] ) );
}
break;
}
};/* struct ComplementTypeRule */
-
+struct UniverseSetTypeRule {
+ inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check)
+ throw (TypeCheckingExceptionPrivate, AssertionException) {
+ Assert(n.getKind() == kind::UNIVERSE_SET);
+ // for nullary operators, we only computeType for check=true, since they are given TypeAttr() on creation
+ Assert(check);
+ TypeNode setType = n.getType(false);
+ if(!setType.isSet()) {
+ throw TypeCheckingExceptionPrivate(n, "COMPLEMENT operates on a set, non-set object found");
+ }
+ return setType;
+ }
+};/* struct ComplementTypeRule */
struct InsertTypeRule {
inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check)
// 1) x is a variable
// 2) x is not in the term t
// 3) x : T and t : S, then S <: T
- if (in[0].isUninterpretedVar() && !in[1].hasSubterm(in[0]) &&
+ if (in[0].isVar() && !in[1].hasSubterm(in[0]) &&
(in[1].getType()).isSubtypeOf(in[0].getType()) ){
outSubstitutions.addSubstitution(in[0], in[1]);
return PP_ASSERT_STATUS_SOLVED;
}
- if (in[1].isUninterpretedVar() && !in[0].hasSubterm(in[1]) &&
+ if (in[1].isVar() && !in[0].hasSubterm(in[1]) &&
(in[0].getType()).isSubtypeOf(in[1].getType())){
outSubstitutions.addSubstitution(in[1], in[0]);
return PP_ASSERT_STATUS_SOLVED;