-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(translator): Strip type constraints before generating rank axioms (…
- Loading branch information
1 parent
856f17b
commit f3aabc6
Showing
4 changed files
with
89 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// RUN: %dafny /compile:0 "%s" > "%t" | ||
// RUN: %diff "%s.expect" "%t" | ||
|
||
/// This file checks whether sufficient axioms are generated to compare | ||
/// datatypes constructed using subset types over sequences. | ||
|
||
module Datatype { | ||
datatype Box_<T> = Box(t: T) | ||
type Box<T> = b: Box_<T> | true witness * | ||
|
||
datatype List<T> = Nil | Cons(t: T, Box<List<T>>) | ||
|
||
function Length<T>(l: List<T>): int { | ||
match l { | ||
case Nil => 0 | ||
case Cons(t, q) => 1 + Length(q.t) | ||
} | ||
} | ||
} | ||
|
||
module Seq { | ||
type Box_<T> = seq<T> | ||
type Box<T> = b: Box_<T> | |b| == 1 witness * | ||
|
||
datatype List<T> = Nil | Cons(t: T, Box<List<T>>) | ||
|
||
function Length<T>(l: List<T>): int { | ||
match l { | ||
case Nil => 0 | ||
case Cons(t, q) => | ||
assert q[0] in q; | ||
var l :| l in q; | ||
Length(l) | ||
} | ||
} | ||
} | ||
|
||
module Set { | ||
type Box_<T> = set<T> | ||
type Box<T> = b: Box_<T> | |b| == 1 witness * | ||
|
||
datatype List<T(==)> = Nil | Cons(t: T, Box<List<T>>) | ||
|
||
function Length<T>(l: List<T>): int { | ||
match l { | ||
case Nil => 0 | ||
case Cons(t, q) => | ||
var l :| l in q; | ||
Length(l) | ||
} | ||
} | ||
} | ||
|
||
module Multiset { | ||
type Box_<T> = multiset<T> | ||
type Box<T> = b: Box_<T> | |b| == 1 witness * | ||
|
||
datatype List<T(==)> = Nil | Cons(t: T, Box<List<T>>) | ||
|
||
function Length<T>(l: List<T>): int { | ||
match l { | ||
case Nil => 0 | ||
case Cons(t, q) => | ||
var l :| l in q; | ||
Length(l) | ||
} | ||
} | ||
} | ||
|
||
module Map { | ||
type Box_<T> = map<T, bool> | ||
type Box<T> = b: Box_<T> | |b| == 1 witness * | ||
|
||
datatype List<T(==)> = Nil | Cons(t: T, Box<List<T>>) | ||
|
||
function Length<T>(l: List<T>): int { | ||
match l { | ||
case Nil => 0 | ||
case Cons(t, q) => | ||
var l :| l in q.Keys; | ||
Length(l) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
Dafny program verifier finished with 5 verified, 0 errors |