-
Notifications
You must be signed in to change notification settings - Fork 26
some trigger updates #25
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
base: master
Are you sure you want to change the base?
Changes from 4 commits
7fe04f3
85e585f
16c9e3d
b7ae16c
6937071
064984b
381bc75
9198630
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,15 +21,19 @@ module Maps { | |
| } | ||
|
|
||
| function method {:opaque} ToImap<X, Y>(m: map<X, Y>): (m': imap<X, Y>) | ||
| /* Dafny selected triggers: {m[x]}, {m'[x]}, {x in m'}, {x in m} */ | ||
| ensures forall x {:trigger m'[x]} :: x in m ==> x in m' && m'[x] == m[x] | ||
| /* Dafny selected triggers: {x in m}, {x in m'} */ | ||
| ensures forall x {:trigger x in m'} :: x in m' ==> x in m | ||
| { | ||
| imap x | x in m :: m[x] | ||
| } | ||
|
|
||
| /* Remove all key-value pairs corresponding to the set of keys provided. */ | ||
| function method {:opaque} RemoveKeys<X, Y>(m: map<X, Y>, xs: set<X>): (m': map<X, Y>) | ||
| /* Dafny selected triggers: {m[x]}, {m'[x]}, {x in m'}, {x in xs}, {x in m} */ | ||
| ensures forall x {:trigger m'[x]} :: x in m && x !in xs ==> x in m' && m'[x] == m[x] | ||
| /* Dafny selected triggers: {x in xs}, {x in m}, {x in m'} */ | ||
| ensures forall x {:trigger x in m'} :: x in m' ==> x in m && x !in xs | ||
|
Comment on lines
+36
to
37
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The trigger in the other direction (that is,
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the ensures is an implication, we might only want the |
||
| ensures m'.Keys == m.Keys - xs | ||
| { | ||
|
|
@@ -65,14 +69,16 @@ module Maps { | |
| predicate IsSubset<X, Y>(m: map<X, Y>, m': map<X, Y>) | ||
| { | ||
| && m.Keys <= m'.Keys | ||
| && forall x {:trigger EqualOnKey(m, m', x)}{:trigger x in m} :: x in m ==> EqualOnKey(m, m', x) | ||
| && forall x :: x in m ==> EqualOnKey(m, m', x) | ||
| } | ||
|
|
||
| /* Union of two maps. Does not require disjoint domains; on the intersection, | ||
| values from the second map are chosen. */ | ||
| function method {:opaque} Union<X, Y>(m: map<X, Y>, m': map<X, Y>): (r: map<X, Y>) | ||
| ensures r.Keys == m.Keys + m'.Keys | ||
| /* Dafny selected triggers: {m'[x]}, {r[x]}, {x in m'} */ | ||
| ensures forall x {:trigger r[x]} :: x in m' ==> r[x] == m'[x] | ||
| /* Dafny selected triggers: {m[x]}, {r[x]}, {x in m'}, {x in m} */ | ||
| ensures forall x {:trigger r[x]} :: x in m && x !in m' ==> r[x] == m[x] | ||
| { | ||
| m + m' | ||
|
|
@@ -91,6 +97,7 @@ module Maps { | |
| /* True iff a map is injective. */ | ||
| predicate {:opaque} Injective<X, Y>(m: map<X, Y>) | ||
| { | ||
| /* Dafny selected triggers: {m[x'], m[x]}, {m[x'], x in m}, {m[x], x' in m}, {x' in m, x in m} */ | ||
| forall x, x' {:trigger m[x], m[x']} :: x != x' && x in m && x' in m ==> m[x] != m[x'] | ||
| } | ||
|
|
||
|
|
@@ -112,19 +119,22 @@ module Maps { | |
| /* True iff a map contains all valid keys. */ | ||
| predicate {:opaque} Total<X(!new), Y>(m: map<X, Y>) | ||
| { | ||
| /* Dafny selected triggers: {i in m} */ | ||
| forall i {:trigger m[i]}{:trigger i in m} :: i in m | ||
| } | ||
|
|
||
| /* True iff a map is monotonic. */ | ||
| predicate {:opaque} Monotonic(m: map<int, int>) | ||
| { | ||
| /* Dafny selected triggers: {m[x'], m[x]}, {m[x'], x in m}, {m[x], x' in m}, {x' in m, x in m} */ | ||
| forall x, x' {:trigger m[x], m[x']} :: x in m && x' in m && x <= x' ==> m[x] <= m[x'] | ||
| } | ||
|
|
||
| /* True iff a map is monotonic. Only considers keys greater than or | ||
| equal to start. */ | ||
| predicate {:opaque} MonotonicFrom(m: map<int, int>, start: int) | ||
| { | ||
| /* Dafny selected triggers: {m[x'], m[x]}, {m[x'], x in m}, {m[x], x' in m}, {x' in m, x in m} */ | ||
| forall x, x' {:trigger m[x], m[x']} :: x in m && x' in m && start <= x <= x' ==> m[x] <= m[x'] | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.