summaryrefslogtreecommitdiff
path: root/Source/Provers
diff options
context:
space:
mode:
authorGravatar qadeer <qadeer@microsoft.com>2012-03-18 07:10:44 -0700
committerGravatar qadeer <qadeer@microsoft.com>2012-03-18 07:10:44 -0700
commiteb702d50b002d07d40f94b1c8d2462ad0ec38838 (patch)
tree553387ad5394d41a1dd1b8e54020f2cc153f9edb /Source/Provers
parentf9fd0a289f17229e281ee5afc985ae7b479be677 (diff)
more type checking for datatypes
Diffstat (limited to 'Source/Provers')
-rw-r--r--Source/Provers/SMTLib/TypeDeclCollector.cs27
1 files changed, 10 insertions, 17 deletions
diff --git a/Source/Provers/SMTLib/TypeDeclCollector.cs b/Source/Provers/SMTLib/TypeDeclCollector.cs
index 40dc7cf6..05a6caf3 100644
--- a/Source/Provers/SMTLib/TypeDeclCollector.cs
+++ b/Source/Provers/SMTLib/TypeDeclCollector.cs
@@ -164,6 +164,7 @@ void ObjectInvariant()
return TypeToString(t);
}
+
public override bool Visit(VCExprNAry node, bool arg) {
Contract.Requires(node != null);
@@ -171,7 +172,9 @@ void ObjectInvariant()
else if (node.Op is VCExprSelectOp) RegisterSelect(node);
else {
VCExprBoogieFunctionOp op = node.Op as VCExprBoogieFunctionOp;
- if (op != null && !IsDatatypeFunction(op.Func) && !KnownFunctions.Contains(op.Func)) {
+ if (op != null &&
+ !(op.Func is DatatypeConstructor) && !(op.Func is DatatypeMembership) && !(op.Func is DatatypeSelector) &&
+ !KnownFunctions.Contains(op.Func)) {
Function f = op.Func;
Contract.Assert(f != null);
@@ -250,26 +253,16 @@ void ObjectInvariant()
if (type.IsBool || type.IsInt || type.IsBv)
return;
- if (CommandLineOptions.Clo.TypeEncodingMethod == CommandLineOptions.TypeEncoding.Monomorphic && !IsDatatype(type)) {
+ CtorType ctorType = type as CtorType;
+ if (ctorType != null && ctorType.IsDatatype())
+ return;
+
+ if (CommandLineOptions.Clo.TypeEncodingMethod == CommandLineOptions.TypeEncoding.Monomorphic) {
AddDeclaration("(declare-sort " + TypeToString(type) + " 0)");
KnownTypes.Add(type);
return;
}
- }
-
- public static bool IsDatatype(Type t) {
- CtorType ctorType = t.AsCtor;
- if (t == null)
- return false;
- return QKeyValue.FindBoolAttribute(ctorType.Decl.Attributes, "datatype");
- }
-
- public static bool IsDatatypeFunction(Function f) {
- return
- f is DatatypeConstructor ||
- f is DatatypeSelector ||
- f is DatatypeMembership;
- }
+ }
private void RegisterSelect(VCExprNAry node)
{