Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Groebner extension #53

Open
wants to merge 613 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
613 commits
Select commit Hold shift + click to select a range
040c727
Add Docs/Linear directory with documentation on the linear type system
Chris-Hawblitzel Dec 11, 2020
4336f32
Fix some typos in Docs/Linear/TypingRules.md
Chris-Hawblitzel Dec 11, 2020
030cdaa
Minor reformatting in Docs/Linear/TypingRules.md
Chris-Hawblitzel Dec 11, 2020
0a4c475
Minor fixes
parno Dec 11, 2020
5bb1a8d
Add Docs/Linear/RelatedWork.md
Chris-Hawblitzel Dec 15, 2020
dfd9eac
Add Rust comparison to Docs/Linear/RelatedWork.md
Chris-Hawblitzel Dec 17, 2020
12a20d7
Minor fixes to Docs/Linear/RelatedWork.md
Chris-Hawblitzel Dec 17, 2020
ee03518
Minor formatting fixes to Docs/Linear/RelatedWork.md
Chris-Hawblitzel Dec 18, 2020
1e5f9b0
Minor bug fixes in Resolver/Linear
Chris-Hawblitzel Dec 18, 2020
dab22ed
Allow "linear var D() := ...;" to deconstruct empty linear datatype
Chris-Hawblitzel Dec 18, 2020
0b97e53
Add Docs/Linear/Library.md
Chris-Hawblitzel Dec 19, 2020
87c291b
Add Docs/Linear/Implementation.md
Chris-Hawblitzel Dec 20, 2020
7e7b8b0
Add Docs/Linear/PossibleChanges.md and Docs/Linear/README.md
Chris-Hawblitzel Dec 22, 2020
c03692e
Closes #15
parno Jan 5, 2021
5b3fc6f
Merge branch 'cpp' of github.com:secure-foundations/dafny into cpp
parno Jan 5, 2021
d3b9911
Merge branch 'master' into cpp
parno Jan 5, 2021
12992dc
Remove some outdated notes to simplify comparisons between branches
parno Jan 5, 2021
b5a6a82
Remove project files that are no longer needed
parno Jan 5, 2021
78f9a55
This LIMITATIONS file has been absorbed into Docs/Compilation/Cpp.md
parno Jan 5, 2021
d302369
Merge branch 'cpp' into inout
parno Jan 6, 2021
2b74270
Many fixes to restore everything to a state that compiles
parno Jan 6, 2021
157fe9a
Attempt to resolve a lookup in GetTypeOfFunction
parno Jan 7, 2021
390275f
Attmped fix to contract assertion failure. It looks like someone added
parno Jan 7, 2021
e375420
Fix a number of failing tests by eliminating bugs and/or making
parno Jan 7, 2021
6849c08
Fix another case in Linear.cs
parno Jan 7, 2021
82a06d4
Restore a portion of the parser that got lost in the merge
parno Jan 7, 2021
ae81dfb
Fix a problem with emitting default values. Addresses 6 test cases
parno Jan 7, 2021
8cb2a75
Fix another bad default to address 4 more test cases
parno Jan 7, 2021
1661d73
Remove redundant use of isGhost in favor of usage
parno Jan 8, 2021
279504d
Import a fix from master commit 5129ec34fa6f63
parno Jan 9, 2021
3f80c13
Fix #13, autogenerated syntax shouldn't be resolved early: dafny refi…
utaal Jan 13, 2021
1a76873
Partial fix for linearity failures in tests introduced by new auto gh…
utaal Jan 20, 2021
fe6c2f4
Fix linearity checking in VarDeclPattern after merge
Chris-Hawblitzel Jan 21, 2021
3a90deb
Small fixes so that Test/comp passes
Chris-Hawblitzel Jan 23, 2021
acf382c
Add a README test for inout
utaal Jan 23, 2021
031689a
When resolving operator overloading, don't splice ResolvedExpression …
Chris-Hawblitzel Jan 26, 2021
f01a9a5
Merge branch 'master' into inout-merge
parno Jan 31, 2021
f931a05
Resolve compilation errors
parno Feb 1, 2021
00418b3
Fix a parser bug
parno Feb 1, 2021
08ff66c
Remove some comments
parno Feb 2, 2021
fc49a78
After merge, fix usages passed to arrow type in Dafny.atg
Chris-Hawblitzel Feb 2, 2021
545b1bf
Minor post-merge fixes
Chris-Hawblitzel Feb 2, 2021
6dc9ea1
Minor post-merge fix for linear tuples
Chris-Hawblitzel Feb 2, 2021
02850f6
Restore some of Dafny.atg from before merge
Chris-Hawblitzel Feb 4, 2021
d566c39
Minor updates to linear documentation
Chris-Hawblitzel Feb 16, 2021
2002a5a
Remove linear-notes directory
Chris-Hawblitzel Feb 16, 2021
cb34a0b
Partially through merging Dafny official into betr
parno Mar 30, 2021
8917605
Resolve compilation errors in the merged code
parno Mar 30, 2021
e61278b
Fix some merge breakages in Resolver for linear checker
Chris-Hawblitzel Mar 30, 2021
012499a
Fix some merge breakages in Resolver for linear checker
Chris-Hawblitzel Mar 30, 2021
a087d4b
add inout regression test
utaal Mar 31, 2021
56abb22
Fix parsing when using explicit "linear" or "ghost" in pattern cases
Chris-Hawblitzel Mar 31, 2021
3464d3d
add inout regression test
utaal Mar 31, 2021
ab216bf
fixes #21: linear inout parameter causing crash in dafny
utaal Apr 13, 2021
37d5953
Merge branch 'betr-merge-master' into betr
parno Apr 13, 2021
dbecf84
Merge commit master commit '3b5de791712' into rebuild-attempt (branching
parno Apr 17, 2021
d4fa6a1
Resolve compilation errors in the merged code
parno Mar 30, 2021
bdfab95
Fix some merge breakages in Resolver for linear checker
Chris-Hawblitzel Mar 30, 2021
23d593b
add inout regression test
utaal Mar 31, 2021
a223c17
fixes #21: linear inout parameter causing crash in dafny
utaal Apr 13, 2021
247c461
Fix some merge breakages in Resolver for linear checker
Chris-Hawblitzel Mar 30, 2021
0ca8011
Fix parsing when using explicit "linear" or "ghost" in pattern cases
Chris-Hawblitzel Mar 31, 2021
c536e7b
Merge branch 'master' into betr
parno Apr 17, 2021
fcb3d6b
Modify the parser and AST to accept module's with functor applications.
parno Apr 18, 2021
1b7ef24
Add some additional fields to keep track of resolved data.
parno Apr 18, 2021
2ad2ed3
Better naming
parno Apr 19, 2021
77ca21e
Merge branch 'betr' into betr-merge-betr
parno Apr 19, 2021
a3f2437
Temporary work on Resolver. Some of it needs to be rolled back.
parno Apr 19, 2021
fd638bd
With some clean up, very simple functor definition test runs without
parno Apr 20, 2021
b1695fa
Extend dependency processing to handle imports and abstracts too,
parno Apr 20, 2021
2ecbfc9
Fill in the Root and expand test case
parno Apr 20, 2021
e78dd71
Added support for editing linear datatypes with multiple constructors
JackMenandCameron Apr 20, 2021
a89bd34
Updated datatypes.dfy.expect to reflect new tests
JackMenandCameron Apr 20, 2021
7abbc28
Fix some bit rot in our local C++ files
parno Apr 22, 2021
66f6b69
Fix compilation of templated datatype methods
parno Apr 22, 2021
37d7258
Don't emit an extra template argument for templated extern structs
parno Apr 22, 2021
c39a893
Fix: Special case the declaration of empty tuples
parno Apr 23, 2021
2b6ed30
Fix: Use compile name for get_default type parameter
parno Apr 23, 2021
6fdbc67
Fix tuple lit test
parno Apr 23, 2021
70315df
Fix: Tuple accessor was previously failing when used on tuples of
parno Apr 23, 2021
78d03e6
Special case the handling of empty tuple values
parno Apr 23, 2021
5454831
Fix: Don't emit type arguments for static method invocations
parno Apr 23, 2021
6d062ba
Fix: Filter typeArgs for functions as well. Turn off typeArgs even for
parno Apr 23, 2021
b06b685
Fix: Include module name when accessing constants
parno Apr 23, 2021
bfe96a0
Simple declaration of a functor and trivial application work (see
parno Apr 24, 2021
7eca3f4
Filled in a first approximation at Functor application in ResolveModu…
parno Apr 24, 2021
7e877eb
We have a reasonably credible functor application at this point,
parno Apr 24, 2021
058d6f5
Improve test and add some extra module definition resolution.
parno Apr 25, 2021
f829481
Current prefix of Simple.dfy verifies!
parno Apr 26, 2021
2f73de0
Fix a bug in ResolveModuleQualifiedId so that virtual module lookup sets
parno Apr 26, 2021
edbf72a
Basic refinement argument test passes
parno Apr 26, 2021
d1429dd
Working on improving module argument checking
parno Apr 26, 2021
bdbf946
Merge branch 'betr' into cpp-mult-const
JackMenandCameron Apr 26, 2021
7f67b5c
Fix positive and negative checks for passing the right kinds of module
parno Apr 26, 2021
d314d45
Merge pull request #28 from secure-foundations/cpp-mult-const
parno Apr 26, 2021
ca2868f
Rolling back visibility scope duplication works surprisingly well.
parno Apr 26, 2021
846f4ba
Fix what appears to be a bug in official Dafny. Now, all of Simple's
parno Apr 27, 2021
1a8821b
I think all of Simple's tests pass
parno Apr 27, 2021
119e45b
Split Simple into Good and Bad test cases. This facilitates testing the
parno Apr 27, 2021
76afcdb
Lit files
parno Apr 27, 2021
19a0815
Add lit files
parno Apr 27, 2021
dec0f63
Fix up ToString conversion for ModuleQualifiedId and FunctorApplication
parno Apr 27, 2021
1e04d5a
ModuleApplication works
parno Apr 27, 2021
f6ac115
Capture the next case to work on in SimpleGood
parno Apr 27, 2021
48dd550
Fix ToString for non-functors
parno Apr 27, 2021
0b89ac5
Still debugging the use of module formals in refines functor
parno Apr 27, 2021
15f75bd
Weaken filter for ModuleQualifiedId's in refinements.
parno Apr 27, 2021
118a7c7
Trying some variants of Resolve
parno Apr 27, 2021
1bbb315
Some experiments with Resolve2.dfy
parno Apr 27, 2021
57ba513
Another variant gives a different error
parno Apr 27, 2021
d2ede02
disable subsequence sharing optimisation
utaal May 4, 2021
6bbfb5d
Create a small test case of deep functor application (currently fails)
parno May 5, 2021
387e1ff
Start fleshing out deep functor app. Need to refactor functor app, so
parno May 5, 2021
60914f7
Partway through recursive application
parno May 5, 2021
9192246
Clean up and fixes so that recursive functor application works,
parno May 5, 2021
3127b71
Confirm the rest of the known tests still work
parno May 5, 2021
2d93223
Resolve2.dfy now works too!
parno May 5, 2021
61859c8
ResolveBadRefine also works.
parno May 5, 2021
43822b3
Add an expect file for Resolve2.dfy which is now passing
parno May 5, 2021
313da00
Some comments on what's being attempted here
parno May 5, 2021
d3849a5
Try to do more sophisticated refines checking, despite difficult
parno May 5, 2021
13b389c
SimpleGood example seems to verify. Resolve3 still doesn't
parno May 6, 2021
7f807da
Add an (unsuccessful) attempt at resolving B(C).D when used as a
parno May 6, 2021
aee1c3a
For now, we don't care about Resolve.dfy or Resolve3.dfy
parno May 6, 2021
5310828
Somewhat convoluted solution to refinements of functors. Leads a new
parno May 6, 2021
5d48637
Add new test cases
parno May 6, 2021
de7743e
Slight change in SystemTheorem signature is enough for FunctorParty to
parno May 7, 2021
89e7fdf
Use a more up-to-date version
parno May 7, 2021
6e412eb
enable inout translations on method members of opaque types
tjhance May 7, 2021
4c12de8
Implement functor output origin tracking and improve propagation of
parno May 7, 2021
0df426f
Created a small example of refinement type confusion
parno May 7, 2021
f014427
Deal with some of StateMachineRefinement's complaints about misnamed
parno May 8, 2021
6d317db
Make ComposeRefinements abstract
parno May 8, 2021
1ab216b
Add a hack to deduplicate translated types that may have been induced…
parno May 9, 2021
2cd2f5a
Confirm that lit tests still pass
parno May 10, 2021
4320af8
Fix some bugs in StateMachineRefinement.dfy. Uncomment to the point
parno May 9, 2021
aa92a5e
Implemented policy that output of abstract functor is abstract, and
parno May 10, 2021
0167d31
Working through abstract/concrete issues
parno May 11, 2021
1b7dfc2
Problematic example from Rob
parno May 16, 2021
46714c9
Fix timeLimitMultiplier by having it generate internal annotations,
parno May 18, 2021
2c810aa
Revert "disable subsequence sharing optimisation"
utaal May 18, 2021
2bd88bc
Disable multi-assignment to linear variables
Chris-Hawblitzel May 19, 2021
826620a
In linear/README.dfy, restrict peek to non-empty types
Chris-Hawblitzel May 19, 2021
f6a0d73
Look for timeLimitMultiplier in inductive datatypes too, not just in
parno May 24, 2021
4b9aa61
Manually clone the CompileSignature field, so that Rob's parser example
parno May 26, 2021
6b2c121
Add lit header and expect file
parno May 26, 2021
96802de
Try declaring that Functors are abstract for compilation purposes.
parno May 26, 2021
c9e9987
Exploring translation problem
parno May 27, 2021
5dc72ea
Allow callers to decide whether to preserve Functor status. Explicitly
parno May 28, 2021
0d397a3
All lit tests, including full SimpleGood, are passing.
parno May 28, 2021
73bede1
Resolve the issue with SimpleGood's abstract test. StateMachine still
parno May 28, 2021
3c720fd
Modify tests
parno May 28, 2021
91bec16
Track the fake AliasModuleDecls that we added, so that we only
parno May 29, 2021
fec34a2
StateMachineRefinement first half back in a working state
parno May 29, 2021
68ac238
More of StateMachineRefinement passes
parno May 29, 2021
40b6ad5
Final module in StateMachineRefinement still needs some work.
parno May 29, 2021
3e57ba3
Another failing case from Rob's parser
parno May 29, 2021
6070058
A version of Dafny that is successful on refine.dfy and parser.dfy.
parno May 31, 2021
b18fa88
Refactor refinement updates, so we can recurse if needed.
parno May 31, 2021
d2dc2b4
Minor changes
parno May 31, 2021
02e1c64
Improvements to UpdateRefinement, and a refactoring
parno Jun 1, 2021
50f206d
Fixes the recursion in UpdateRefinment, so that parser.dfy will pass,
parno Jun 1, 2021
03b28f8
Treat functor formals as a form of concrete module. A version
parno Jun 1, 2021
b521bde
Always generate _Compile versions of Functor modules,
parno Jun 2, 2021
93de589
Simplify parser example down to four modules
parno Jun 2, 2021
092a2c8
Fix the simplification
parno Jun 2, 2021
e56afdd
Create _Compile versions of everything. With this change,
parno Jun 2, 2021
23791e7
Full parser works too
parno Jun 2, 2021
c7794ad
Even fuller parser
parno Jun 2, 2021
ee6a104
Debugging SimpleGood case.
parno Jun 2, 2021
c9410b7
Refactored the code that handles _Compile modules into a separate
parno Jun 3, 2021
49d0730
Restore rest of SimpleGood
parno Jun 3, 2021
f4dc8d4
One more minor extra test
parno Jun 3, 2021
2a597fc
Full StateMachineRefinement passes!
parno Jun 3, 2021
4761981
PCM bugs reported by Travis
parno Jun 8, 2021
1e1c858
Try disabling translation of virtual modules
parno Jun 10, 2021
06384fb
Increase visibilityScopes
parno Jun 11, 2021
845ecf4
Try filtering _System out of scopes, so that we don't try to verify
parno Jun 15, 2021
f5f7199
Revert "Try filtering _System out of scopes, so that we don't try to …
parno Jun 15, 2021
cb0c91c
Revert "Increase visibilityScopes"
parno Jun 15, 2021
1396b29
Revert "Try disabling translation of virtual modules"
parno Jun 15, 2021
221f65b
Try alternate formulation of PCM1. That works. PCM2 still has issues.
parno Jun 15, 2021
99648c3
Simplify PCM2 some more
parno Jun 16, 2021
a81391b
Clone more resolution info and have the later portions of resolution
parno Jun 18, 2021
3945644
Add PCM files to lit
parno Jun 18, 2021
839d95b
Give Functor outputs unique names. This doesn't seem to break existing
parno Jun 18, 2021
34af35f
Bug report #33 from Travis
parno Jul 16, 2021
c68c26a
Small simplifications
parno Jul 16, 2021
a87c33e
Create a custom hasher and equality tester for FunctorApplication for
parno Jul 16, 2021
6f1d4db
Fixes SimpleGood, but FunctorParty still fails
parno Jul 16, 2021
c1e72ca
Refactor the .Origin field from Signature to LiteralModuleDecl.
parno Jul 20, 2021
316a48d
Add git issue 33 to lit
parno Jul 27, 2021
302a91c
Add an extra check for module parameters that are actually functors
parno Jul 27, 2021
bd8f3e7
Partial fix for the problem identified in Git issue #34.
parno Jul 27, 2021
ecacfab
When calling ApplyFunctor, always attempt to update any aliases that
parno Jul 27, 2021
821326f
Remove some tests we decided not to support
parno Jul 27, 2021
ba60b45
Remove another unused test
parno Jul 28, 2021
8cda8ad
Bug with abstract
parno Jul 30, 2021
dff789c
Add another condition where we won't worry about abstract modules.
parno Jul 30, 2021
a6f3195
New issues.
parno Aug 4, 2021
7359dca
Rename
parno Aug 4, 2021
3748f6c
Fix complaints about use of int
parno Aug 4, 2021
183116c
With some bug fixes, our first compilation test succeeds.
parno Aug 4, 2021
2fb97ad
Try to treat functor arguments as concrete too
parno Aug 4, 2021
b951f6f
Test case from git issue #37
parno Aug 5, 2021
349e0e7
Add a missing .expect file
parno Aug 6, 2021
809efcc
Revamp handling of module formal and actuals. We now explicitly keep
parno Aug 6, 2021
73b5dde
Example where more module info would be useful.
parno Aug 16, 2021
b78814e
Print more details about resolution errors when using /titrace
parno Aug 17, 2021
8a2d7a5
Add a lit test for issue 32
parno Aug 17, 2021
3b639cb
When updating a functor, follow all alias decls, updating functors along
parno Aug 18, 2021
7a2ec1f
Don't assume oldActual is a ModuleActualDecl
parno Aug 18, 2021
3af85d2
only generate operator== and hash for types that support equality
tjhance Sep 10, 2021
79bf73d
Fix some bit rot in our local C++ files
parno Apr 22, 2021
c0c6da9
Don't emit parentheses in module names. Closes #43
parno Sep 11, 2021
596bb92
Change directories
parno Sep 12, 2021
3da47d2
Turn off IsToBeCompiled for functor applications that make use of
parno Sep 12, 2021
bcbf073
Declare shared formals as C++ references.
parno Sep 12, 2021
15d05ab
Revert "only generate operator== and hash for types that support equa…
tjhance Sep 13, 2021
13747bc
add get_default for int types that were missing
tjhance Sep 14, 2021
9fdaf9f
Merge branch 'mod-params-bryan' into betr
parno Oct 3, 2021
166da2b
Restore the ability to import an export set
parno Oct 4, 2021
bd5acc1
Compute function fuel over virtual modules as well
parno Oct 7, 2021
2150693
Test case for opaque
parno Oct 7, 2021
a8826da
Alternate approach to generating compile names. Removes unique counter
parno Oct 16, 2021
d86e8ea
Don't compile modules that have arguments that are not going to be
parno Oct 18, 2021
63a234e
Part way through revamp of FunctorApplication, so we can use the fully
parno Oct 18, 2021
7302337
Consolidate the checking of whether something should be compiled,
parno Oct 19, 2021
a2de340
parser changes for gbassert
yizhou7 Feb 5, 2022
8793a19
a skeleton for SingularDriver in Translator
yizhou7 Feb 7, 2022
d3f239c
a very basic version
yizhou7 Feb 7, 2022
bbcc107
open a subprocess for Singular
yizhou7 Feb 7, 2022
a244118
cannot get WaitForExit with timeout working for whatever reason
yizhou7 Feb 7, 2022
3aab717
hardcode timeout in process start
yizhou7 Feb 7, 2022
fc17e5e
handle certain sub expressions as opaque
yizhou7 Feb 7, 2022
3960f0b
use separate files for queries
yizhou7 Feb 8, 2022
0b15020
add some use cases
yizhou7 Feb 8, 2022
c63e273
address some comments from @parno
yizhou7 Feb 8, 2022
ebb6341
fix missing variable
yizhou7 Feb 9, 2022
07cc617
handle more opaque expressions
yizhou7 Feb 9, 2022
4573075
add more support for opaque operations (binop)
yizhou7 Feb 9, 2022
c7e597d
emit null as empty string in opaque
yizhou7 Feb 9, 2022
87df8bc
bug fix for OpacifySubExpr (args for function calls were not encoded …
yizhou7 Feb 10, 2022
299f5ab
add groebner keyword for lemma call
yizhou7 Feb 11, 2022
b402d2a
retain support for gbassert
yizhou7 Feb 11, 2022
410403a
[groebner-extension]: close query file after writing
zhenkuny Mar 25, 2022
f5e1873
Merge pull request #54 from zhenkuny/patch-1
yizhou7 Mar 25, 2022
1adbb8d
Merge branch 'betr' into groebner-extension
yizhou7 Aug 28, 2022
c50e9ca
fix type errors
yizhou7 Aug 28, 2022
d865d2e
fix seq index access in gbassert
yizhou7 Jul 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Binaries/DafnyPrelude.bpl
Original file line number Diff line number Diff line change
Expand Up @@ -1461,3 +1461,23 @@ axiom (forall x, y, z: int ::
#endif

// -------------------------------------------------------------------------

// function declaration for _System._default.rank__is__less__than
function _System.__default.rank__is__less__than(A:Ty, B:Ty, a:Box, b:Box):bool;

axiom (forall A:Ty, B:Ty, a:Box, b:Box ::
{_System.__default.rank__is__less__than(A, B, a, b), BoxRank(a)}
{_System.__default.rank__is__less__than(A, B, a, b), BoxRank(b)}
_System.__default.rank__is__less__than(A, B, a, b) ==> BoxRank(a) < BoxRank(b));

axiom (forall A:Ty, B:Ty, a:Box, b:Seq Box ::
{_System.__default.rank__is__less__than(A, B, a, $Box(b)), BoxRank(a)}
{_System.__default.rank__is__less__than(A, B, a, $Box(b)), Seq#Rank(b)}
_System.__default.rank__is__less__than(A, B, a, $Box(b)) ==> BoxRank(a) < Seq#Rank(b));

axiom (forall A:Ty, B:Ty, a:Seq Box, b:Box ::
{_System.__default.rank__is__less__than(A, B, $Box(a), b), Seq#Rank(a)}
{_System.__default.rank__is__less__than(A, B, $Box(a), b), BoxRank(b)}
_System.__default.rank__is__less__than(A, B, $Box(a), b) ==> Seq#Rank(a) < BoxRank(b));

// -------------------------------------------------------------------------
32 changes: 32 additions & 0 deletions Binaries/DafnyRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <cstdint>
#include <variant>
#include <exception>
#include <smmintrin.h>
#include <immintrin.h>

typedef uint8_t uint8;
typedef uint16_t uint16;
Expand Down Expand Up @@ -97,11 +99,21 @@ struct get_default<unsigned int> {
static unsigned int call() { return 0; }
};

template<>
struct get_default<long> {
static long call() { return 0; }
};

template<>
struct get_default<unsigned long> {
static unsigned long call() { return 0; }
};

template<>
struct get_default<long long> {
static long long call() { return 0; }
};

template<>
struct get_default<unsigned long long> {
static unsigned long long call() { return 0; }
Expand All @@ -118,6 +130,8 @@ struct get_default<std::shared_ptr<U>> {
* TUPLES *
*********************************************************/

struct Tuple0 {};

template <typename... Types>
struct Tuple{
public:
Expand Down Expand Up @@ -287,6 +301,13 @@ struct DafnySequence {
std::copy(arr.begin(), arr.end(), start);
}

DafnySequence(std::vector<T> vec) {
len = vec.size();
sptr = std::shared_ptr<T> (new T[len], std::default_delete<T[]>());
start = &*sptr;
std::copy(vec.begin(), vec.end(), start);
}

DafnySequence(DafnyArray<T> arr, uint64 lo, uint64 hi) {
len = hi - lo;
sptr = std::shared_ptr<T> (new T[len], std::default_delete<T[]>());
Expand Down Expand Up @@ -465,6 +486,17 @@ struct std::hash<DafnyArray<U>> {
}
};

template<typename U>
struct std::hash<std::vector<U>> {
std::size_t operator()(const std:: vector<U>& x) const {
size_t seed = 0;
for (size_t i = 0; i < x.size(); i++) {
hash_combine<U>(seed, x[i]);
}
return seed;
}
};

/*********************************************************
* SETS *
*********************************************************/
Expand Down
93 changes: 60 additions & 33 deletions Source/Dafny/Cloner.cs

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions Source/Dafny/Compiler-Csharp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private void EmitTypeDescriptorMethod(TopLevelDecl enclosingTypeDecl, TargetWrit
Contract.Requires(wr != null);

var type = UserDefinedType.FromTopLevelDecl(enclosingTypeDecl.tok, enclosingTypeDecl);
var initializer = TypeInitializationValue(type, wr, enclosingTypeDecl.tok, false, true);
var initializer = TypeInitializationValue(type, wr, enclosingTypeDecl.tok, Usage.Ordinary, false, true);

var targetTypeName = TypeName(type, wr, enclosingTypeDecl.tok);
var typeDescriptorExpr = $"new {DafnyTypeDescriptor}<{targetTypeName}>({initializer})";
Expand Down Expand Up @@ -286,7 +286,7 @@ protected override BlockTargetWriter CreateIterator(IteratorDecl iter, TargetWri
foreach (var member in iter.Members) {
var f = member as Field;
if (f != null && !f.IsGhost) {
cw.DeclareField(IdName(f), iter, false, false, f.Type, f.tok, DefaultValue(f.Type, w, f.tok, true), f);
cw.DeclareField(IdName(f), iter, false, false, f.Type, f.tok, DefaultValue(f.Type, w, f.tok, Usage.Ordinary, true), f);
} else if (member is Constructor) {
Contract.Assert(ct == null); // we're expecting just one constructor
ct = (Constructor)member;
Expand Down Expand Up @@ -410,7 +410,7 @@ IClassWriter CompileDatatypeBase(DatatypeDecl dt, TargetWriter wr) {
wDefault.Write(DtCreateName(groundingCtor));
wDefault.Write("(");
var nonGhostFormals = groundingCtor.Formals.Where(f => !f.IsGhost);
wDefault.Write(Util.Comma(nonGhostFormals, f => DefaultValue(f.Type, wDefault, f.tok)));
wDefault.Write(Util.Comma(nonGhostFormals, f => DefaultValue(f.Type, wDefault, f.tok, f.Usage)));
wDefault.Write(")");

EmitTypeDescriptorMethod(dt, wr);
Expand Down Expand Up @@ -815,7 +815,7 @@ public BlockTargetWriter Writer(bool isStatic, bool createBody, MemberDecl/*?*/
public BlockTargetWriter/*?*/ CreateMethod(Method m, List<TypeArgumentInstantiation> typeArgs, bool createBody, bool forBodyInheritance, bool lookasideBody) {
return Compiler.CreateMethod(m, typeArgs, createBody, Writer(m.IsStatic, createBody, m), forBodyInheritance, lookasideBody);
}
public BlockTargetWriter/*?*/ CreateFunction(string name, List<TypeArgumentInstantiation> typeArgs, List<Formal> formals, Type resultType, Bpl.IToken tok, bool isStatic, bool createBody, MemberDecl member, bool forBodyInheritance, bool lookasideBody) {
public BlockTargetWriter/*?*/ CreateFunction(string name, List<TypeArgumentInstantiation> typeArgs, List<Formal> formals, Type resultType, Usage resultUsage, Bpl.IToken tok, bool isStatic, bool createBody, MemberDecl member, bool forBodyInheritance, bool lookasideBody) {
return Compiler.CreateFunction(name, typeArgs, formals, resultType, tok, isStatic, createBody, member, Writer(isStatic, createBody, member), forBodyInheritance, lookasideBody);
}
public BlockTargetWriter/*?*/ CreateGetter(string name, TopLevelDecl enclosingDecl, Type resultType, Bpl.IToken tok, bool isStatic, bool isConst, bool createBody, MemberDecl/*?*/ member, bool forBodyInheritance) {
Expand Down Expand Up @@ -866,7 +866,7 @@ public void Finish() { }
if (customReceiver) {
var nt = m.EnclosingClass;
var receiverType = UserDefinedType.FromTopLevelDecl(m.tok, nt);
DeclareFormal(sep, "_this", receiverType, m.tok, true, wr);
DeclareFormal(sep, "_this", receiverType, m.tok, Usage.Ordinary, true, false, wr);
nIns++;
sep = ", ";
}
Expand Down Expand Up @@ -907,7 +907,7 @@ public void Finish() { }
if (customReceiver) {
var nt = member.EnclosingClass;
var receiverType = UserDefinedType.FromTopLevelDecl(tok, nt);
DeclareFormal(sep, "_this", receiverType, tok, true, wr);
DeclareFormal(sep, "_this", receiverType, tok, Usage.Ordinary, true, false, wr);
sep = ", ";
}
WriteFormals(sep, formals, wr);
Expand Down Expand Up @@ -1102,7 +1102,7 @@ public string CommonTypeName(Type a, Type /*?*/ b, TextWriter wr, Bpl.IToken tok
return "object";
}

protected override string TypeInitializationValue(Type type, TextWriter wr, Bpl.IToken tok, bool usePlaceboValue, bool constructTypeParameterDefaultsFromTypeDescriptors) {
protected override string TypeInitializationValue(Type type, TextWriter wr, Bpl.IToken tok, Usage usage, bool usePlaceboValue, bool constructTypeParameterDefaultsFromTypeDescriptors) {
var xType = type.NormalizeExpandKeepConstraints();

if (usePlaceboValue) {
Expand Down Expand Up @@ -1141,7 +1141,7 @@ protected override string TypeInitializationValue(Type type, TextWriter wr, Bpl.
} else if (td.NativeType != null) {
return "0";
} else {
return TypeInitializationValue(td.BaseType, wr, tok, usePlaceboValue, constructTypeParameterDefaultsFromTypeDescriptors);
return TypeInitializationValue(td.BaseType, wr, tok, Usage.Ordinary, usePlaceboValue, constructTypeParameterDefaultsFromTypeDescriptors);
}
} else if (cl is SubsetTypeDecl) {
var td = (SubsetTypeDecl)cl;
Expand All @@ -1153,7 +1153,7 @@ protected override string TypeInitializationValue(Type type, TextWriter wr, Bpl.
if (ArrowType.IsPartialArrowTypeName(td.Name)) {
return string.Format("(({0})null)", TypeName(xType, wr, udt.tok));
} else if (ArrowType.IsTotalArrowTypeName(td.Name)) {
var rangeDefaultValue = TypeInitializationValue(udt.TypeArgs.Last(), wr, tok, usePlaceboValue, constructTypeParameterDefaultsFromTypeDescriptors);
var rangeDefaultValue = TypeInitializationValue(udt.TypeArgs.Last(), wr, tok, Usage.Ordinary, usePlaceboValue, constructTypeParameterDefaultsFromTypeDescriptors);
// return the lambda expression ((Ty0 x0, Ty1 x1, Ty2 x2) => rangeDefaultValue)
return string.Format("(({0}) => {1})",
Util.Comma(udt.TypeArgs.Count - 1, i => string.Format("{0} x{1}", TypeName(udt.TypeArgs[i], wr, udt.tok), i)),
Expand All @@ -1171,7 +1171,7 @@ protected override string TypeInitializationValue(Type type, TextWriter wr, Bpl.
return string.Format("default({0})", TypeName(xType, wr, udt.tok));
}
} else {
return TypeInitializationValue(td.RhsWithArgument(udt.TypeArgs), wr, tok, usePlaceboValue, constructTypeParameterDefaultsFromTypeDescriptors);
return TypeInitializationValue(td.RhsWithArgument(udt.TypeArgs), wr, tok, Usage.Ordinary, usePlaceboValue, constructTypeParameterDefaultsFromTypeDescriptors);
}
} else if (cl is ClassDecl) {
bool isHandle = true;
Expand All @@ -1186,7 +1186,7 @@ protected override string TypeInitializationValue(Type type, TextWriter wr, Bpl.
s += "<" + TypeNames(udt.TypeArgs, wr, udt.tok) + ">";
}
var relevantTypeArgs = UsedTypeParameters(dt, udt.TypeArgs);
return string.Format($"{s}.Default({Util.Comma(relevantTypeArgs, ta => DefaultValue(ta.Actual, wr, tok, constructTypeParameterDefaultsFromTypeDescriptors))})");
return string.Format($"{s}.Default({Util.Comma(relevantTypeArgs, ta => DefaultValue(ta.Actual, wr, tok, Usage.Ordinary, constructTypeParameterDefaultsFromTypeDescriptors))})");
} else {
Contract.Assert(false); throw new cce.UnreachableException(); // unexpected type
}
Expand Down Expand Up @@ -1366,12 +1366,12 @@ protected void DeclareField(string name, bool isPublic, bool isStatic, bool isCo
}
}

protected override bool DeclareFormal(string prefix, string name, Type type, Bpl.IToken tok, bool isInParam, TextWriter wr) {
protected override bool DeclareFormal(string prefix, string name, Type type, Bpl.IToken tok, Usage usage, bool isInParam, bool isInoutParam, TextWriter wr) {
wr.Write("{0}{1}{2} {3}", prefix, isInParam ? "" : "out ", TypeName(type, wr, tok), name);
return true;
}

protected override void DeclareLocalVar(string name, Type/*?*/ type, Bpl.IToken/*?*/ tok, bool leaveRoomForRhs, string/*?*/ rhs, TargetWriter wr) {
protected override void DeclareLocalVar(string name, Type/*?*/ type, Bpl.IToken/*?*/ tok, Usage usage, bool leaveRoomForRhs, string/*?*/ rhs, TargetWriter wr) {
wr.Write("{0} {1}", type != null ? TypeName(type, wr, tok) : "var", name);
if (leaveRoomForRhs) {
Contract.Assert(rhs == null); // follows from precondition
Expand All @@ -1382,7 +1382,7 @@ protected override void DeclareLocalVar(string name, Type/*?*/ type, Bpl.IToken/
}
}

protected override TargetWriter DeclareLocalVar(string name, Type/*?*/ type, Bpl.IToken/*?*/ tok, TargetWriter wr) {
protected override TargetWriter DeclareLocalVar(string name, Type/*?*/ type, Bpl.IToken/*?*/ tok, Usage usage, TargetWriter wr) {
wr.Write("{0} {1} = ", type != null ? TypeName(type, wr, tok) : "var", name);
var w = wr.Fork();
wr.WriteLine(";");
Expand All @@ -1393,9 +1393,9 @@ protected override void DeclareOutCollector(string collectorVarName, TargetWrite
wr.Write("var {0} = ", collectorVarName);
}

protected override void DeclareLocalOutVar(string name, Type type, Bpl.IToken tok, string rhs, bool useReturnStyleOuts, TargetWriter wr) {
protected override void DeclareLocalOutVar(string name, Type type, Bpl.IToken tok, Usage usage, string rhs, bool useReturnStyleOuts, TargetWriter wr) {
if (useReturnStyleOuts) {
DeclareLocalVar(name, type, tok, false, rhs, wr);
DeclareLocalVar(name, type, tok, usage, false, rhs, wr);
} else {
EmitAssignment(name, type, rhs, null, wr);
}
Expand Down Expand Up @@ -1545,7 +1545,7 @@ protected override void EmitNew(Type type, Bpl.IToken tok, CallStmt/*?*/ initCal
Formal p = ctor.Ins[i];
if (!p.IsGhost) {
wr.Write(sep);
TrExpr(initCall.Args[i], wr, false);
TrExpr(initCall.Args[i].Expr, wr, false);
sep = ", ";
}
}
Expand Down Expand Up @@ -1588,7 +1588,7 @@ private List<TargetWriter> EmitNewArray(Type elmtType, Bpl.IToken tok, int dimCo
} else {
wr.Write("Dafny.ArrayHelpers.InitNewArray{0}<{1}>", dimCount, TypeName(elmtType, wr, tok));
wr.Write("(");
wr.Write(DefaultValue(elmtType, wr, tok, true));
wr.Write(DefaultValue(elmtType, wr, tok, Usage.Ordinary,true));
for (var d = 0; d < dimCount; d++) {
wr.Write(", ");
var w = wr.Fork();
Expand Down Expand Up @@ -2248,7 +2248,7 @@ private void EmitSeqConstructionExprFromLambda(Expression lengthExpr, BoundVar b

var indexType = lengthExpr.Type;
var lengthVar = FreshId("dim");
DeclareLocalVar(lengthVar, indexType, lengthExpr.tok, lengthExpr, inLetExprBody, wrLamBody);
DeclareLocalVar(lengthVar, indexType, lengthExpr.tok, boundVar.Usage, lengthExpr, inLetExprBody, wrLamBody);
var arrVar = FreshId("arr");
wrLamBody.Write("var {0} = ", arrVar);
var wrDims = EmitNewArray(body.Type, body.tok, dimCount: 1, mustInitialize: false, wr: wrLamBody);
Expand Down Expand Up @@ -2699,12 +2699,12 @@ protected override void EmitMapDisplay(MapType mt, Bpl.IToken tok, List<Expressi
}

protected override void EmitSetBuilder_New(TargetWriter wr, SetComprehension e, string collectionName) {
var wrVarInit = DeclareLocalVar(collectionName, null, null, wr);
var wrVarInit = DeclareLocalVar(collectionName, null, null, Usage.Ordinary, wr);
wrVarInit.Write("new System.Collections.Generic.List<{0}>()", TypeName(e.Type.AsSetType.Arg, wrVarInit, e.tok));
}

protected override void EmitMapBuilder_New(TargetWriter wr, MapComprehension e, string collectionName) {
var wrVarInit = DeclareLocalVar(collectionName, null, null, wr);
var wrVarInit = DeclareLocalVar(collectionName, null, null, Usage.Ordinary, wr);
var mt = e.Type.AsMapType;
var domtypeName = TypeName(mt.Domain, wrVarInit, e.tok);
var rantypeName = TypeName(mt.Range, wrVarInit, e.tok);
Expand Down
Loading