-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extends CLI to support more complete SIF encoding supporting non-low …
…control flow
- Loading branch information
Showing
4 changed files
with
54 additions
and
6 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
40 changes: 40 additions & 0 deletions
40
src/test/resources/regressions/features/hyper_properties/commitment-extended.go
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,40 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
// ##(--hyperMode extended) | ||
|
||
package commitment | ||
|
||
// @ requires low(hash) | ||
// @ ensures res ==> low(value) | ||
func verify(hash int, value int) (res bool) { | ||
res = (hash == computeHash(value)) | ||
return | ||
} | ||
|
||
// @ requires low(hash) | ||
// @ ensures res ==> low(value) | ||
func verifyWithBranching(hash int, value int) (res bool) { | ||
// the following if statement succeeds because we enabled the extended | ||
// SIF encoding that allows branching on non-low conditions | ||
if hash != computeHash(value) { | ||
return false | ||
} | ||
return true | ||
} | ||
|
||
// the following postcondition specifies that the Go function `computeHash` behaves like the | ||
// pure (mathematical) function `hashFn` for which we assume injectivity (see domain below) | ||
// @ ensures res == hashFn(input) | ||
func computeHash(input int) (res int) | ||
|
||
/* @ | ||
type HashFunction domain { | ||
func hashFn(int) int | ||
func invFn(int) int | ||
axiom { // hashFn is injective | ||
forall v int :: { hashFn(v) } invFn(hashFn(v)) == v | ||
} | ||
} | ||
@ */ |
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 |
---|---|---|
|
@@ -38,4 +38,4 @@ type HashFunction domain { | |
forall v int :: { hashFn(v) } invFn(hashFn(v)) == v | ||
} | ||
} | ||
@ */ | ||
@ */ |