-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #742 from viperproject/meilers_axiom_instantiation
Fixing Silicon issue #753
- Loading branch information
Showing
4 changed files
with
111 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
|
||
domain $domain$to_int { | ||
|
||
function to_int(to_int1: Perm): Int interpretation "to_int" | ||
} | ||
|
||
function round(x: Perm): Perm | ||
decreases | ||
ensures x == 3/1 ==> result == 3/2 | ||
//:: ExpectedOutput(postcondition.violated:assertion.false) | ||
ensures result == to_int(x) / 1 | ||
{ | ||
to_int(x) / 2 | ||
} |
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,88 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
|
||
domain Val {} | ||
|
||
domain WellFoundedOrder[T] { | ||
|
||
function decreasing(arg1: T, arg2: T): Bool | ||
|
||
function bounded(arg1: T): Bool | ||
} | ||
|
||
domain List[V] { | ||
|
||
function Nil(): List[V] | ||
|
||
function Cons(value: V, tail: List[V]): List[V] | ||
|
||
function get_List_value(t: List[V]): V | ||
|
||
function get_List_tail(t: List[V]): List[V] | ||
|
||
function List_tag(t: List[V]): Int | ||
|
||
axiom { | ||
(forall value: V, tail: List[V] :: | ||
{ (Cons(value, tail): List[V]) } | ||
value == (get_List_value((Cons(value, tail): List[V])): V)) | ||
} | ||
|
||
axiom { | ||
(forall value: V, tail: List[V] :: | ||
{ (Cons(value, tail): List[V]) } | ||
tail == (get_List_tail((Cons(value, tail): List[V])): List[V])) | ||
} | ||
|
||
axiom { | ||
(List_tag((Nil(): List[V])): Int) == 1 | ||
} | ||
|
||
axiom { | ||
(forall value: V, tail: List[V] :: | ||
{ (Cons(value, tail): List[V]) } | ||
(List_tag((Cons(value, tail): List[V])): Int) == 0) | ||
} | ||
|
||
axiom { | ||
(forall t: List[V] :: | ||
{ (List_tag(t): Int) } | ||
{ (get_List_value(t): V) } | ||
{ (get_List_tail(t): List[V]) } | ||
(List_tag(t) == 1 && t == (Nil(): List[V])) || | ||
(List_tag(t) == 0 && exists v: V, l: List[V] :: t == Cons(v, l)) | ||
//(t == (Cons((get_List_value(t): V), (get_List_tail(t): List[V])): List[V])) | ||
) | ||
} | ||
} | ||
|
||
domain ListWellFoundedOrder[V] { | ||
|
||
axiom { | ||
(bounded((Nil(): List[V])): Bool) | ||
} | ||
|
||
axiom { | ||
(forall value: V, tail: List[V] :: | ||
{ (Cons(value, tail): List[V]) } | ||
(bounded((Cons(value, tail): List[V])): Bool) && | ||
(decreasing(tail, (Cons(value, tail): List[V])): Bool)) | ||
} | ||
} | ||
|
||
// decreases l | ||
function len(l: List[Val]): Int | ||
ensures result >= 0 | ||
{ | ||
((List_tag(l): Int) == 1 ? 0 : 1 + len((get_List_tail(l): List[Val]))) | ||
} | ||
|
||
// decreases l | ||
method len_termination_proof(l: List[Val]) | ||
{ | ||
if ((List_tag(l): Int) == 1) { | ||
} else { | ||
assert (decreasing((get_List_tail(l): List[Val]), old(l)): Bool) && | ||
(bounded(old(l)): Bool)} | ||
} |
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