From f33e5329fc935e1d3ef3c1ef53bb4c09c96b1e23 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 19 Oct 2011 23:40:36 +0530 Subject: Added a push+pop+unsat-core interface to SMTLib (for stratified inlining only) --- Source/Provers/SMTLib/TypeDeclCollector.cs | 79 +++++++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 6 deletions(-) (limited to 'Source/Provers/SMTLib/TypeDeclCollector.cs') diff --git a/Source/Provers/SMTLib/TypeDeclCollector.cs b/Source/Provers/SMTLib/TypeDeclCollector.cs index 23475242..0bc41c2a 100644 --- a/Source/Provers/SMTLib/TypeDeclCollector.cs +++ b/Source/Provers/SMTLib/TypeDeclCollector.cs @@ -36,6 +36,7 @@ void ObjectInvariant() Contract.Requires(namer != null); this.Namer = namer; this.Options = opts; + InitializeKnownDecls(); } // not used @@ -47,13 +48,79 @@ void ObjectInvariant() private readonly List!*/> AllDecls = new List (); private readonly List!*/> IncDecls = new List (); - private readonly HashSet/*!*/ KnownFunctions = new HashSet(); - private readonly HashSet/*!*/ KnownVariables = new HashSet(); + // In order to support push/pop interface of the theorem prover, the "known" declarations + // must be kept in a stack - private readonly HashSet/*!*/ KnownTypes = new HashSet(); - private readonly HashSet/*!*/ KnownStoreFunctions = new HashSet(); - private readonly HashSet/*!*/ KnownSelectFunctions = new HashSet(); - private readonly HashSet KnownLBL = new HashSet(); + private HashSet/*!*/ KnownFunctions + { + get { return _KnownFunctions.Peek(); } + } + + private HashSet/*!*/ KnownVariables + { + get { return _KnownVariables.Peek(); } + } + + private HashSet/*!*/ KnownTypes + { + get { return _KnownTypes.Peek(); } + } + + private HashSet/*!*/ KnownStoreFunctions + { + get { return _KnownStoreFunctions.Peek(); } + } + + private HashSet/*!*/ KnownSelectFunctions + { + get { return _KnownSelectFunctions.Peek(); } + } + + private HashSet KnownLBL + { + get { return _KnownLBL.Peek(); } + } + + // ------ + private readonly Stack/*!*/> _KnownFunctions = new Stack>(); + private readonly Stack/*!*/> _KnownVariables = new Stack>(); + + private readonly Stack/*!*/> _KnownTypes = new Stack>(); + private readonly Stack/*!*/> _KnownStoreFunctions = new Stack>(); + private readonly Stack/*!*/> _KnownSelectFunctions = new Stack>(); + private readonly Stack> _KnownLBL = new Stack>(); + + private void InitializeKnownDecls() + { + _KnownFunctions.Push(new HashSet()); + _KnownVariables.Push(new HashSet()); + _KnownTypes.Push(new HashSet()); + _KnownStoreFunctions.Push(new HashSet()); + _KnownSelectFunctions.Push(new HashSet()); + _KnownLBL.Push(new HashSet()); + } + + public void Push() + { + Contract.Assert(_KnownFunctions.Count > 0); + _KnownFunctions.Push(new HashSet(_KnownFunctions.Peek())); + _KnownVariables.Push(new HashSet(_KnownVariables.Peek())); + _KnownTypes.Push(new HashSet(_KnownTypes.Peek())); + _KnownStoreFunctions.Push(new HashSet(_KnownStoreFunctions.Peek())); + _KnownSelectFunctions.Push(new HashSet(_KnownSelectFunctions.Peek())); + _KnownLBL.Push(new HashSet(_KnownLBL.Peek())); + } + + public void Pop() + { + Contract.Assert(_KnownFunctions.Count > 1); + _KnownFunctions.Pop(); + _KnownVariables.Pop(); + _KnownTypes.Pop(); + _KnownStoreFunctions.Pop(); + _KnownSelectFunctions.Pop(); + _KnownLBL.Pop(); + } public List!*/> AllDeclarations { get { Contract.Ensures(cce.NonNullElements(Contract.Result>() )); -- cgit v1.2.3