forked from noir-lang/noir
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fv): Add the implication operator
For writing more readable proofs we need the implication operator. With this commit we now add it. The user can write x ==> y where x and y are boolean statements. We are transforming the implication operator into !x | y which is logically equivalent to x ==> y. The implication operator can be used both in attributes and function's bodies. Added tests which showcase the new feature.
- Loading branch information
1 parent
a8f08d3
commit a73cd6a
Showing
16 changed files
with
93 additions
and
9 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
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
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
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
7 changes: 7 additions & 0 deletions
7
test_programs/formal_verify_failure/implication_operator/Nargo.toml
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,7 @@ | ||
[package] | ||
name = "implication_operator" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.35.0" | ||
|
||
[dependencies] |
9 changes: 9 additions & 0 deletions
9
test_programs/formal_verify_failure/implication_operator/src/main.nr
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,9 @@ | ||
// This test is expected to fail because if y is true, main returns x, not 0. | ||
#[ensures((y ==> result == 0))] | ||
fn main(x: u32, y: bool) -> pub u32 { | ||
if y { | ||
x | ||
} else { | ||
0 | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
test_programs/formal_verify_success/implication_operator_1/Nargo.toml
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,7 @@ | ||
[package] | ||
name = "implication_operator" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.35.0" | ||
|
||
[dependencies] |
8 changes: 8 additions & 0 deletions
8
test_programs/formal_verify_success/implication_operator_1/src/main.nr
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,8 @@ | ||
#[ensures((y ==> result == x) & (!y ==> result == 0))] | ||
fn main(x: u32, y: bool) -> pub u32 { | ||
if y { | ||
x | ||
} else { | ||
0 | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
test_programs/formal_verify_success/implication_operator_2/Nargo.toml
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,7 @@ | ||
[package] | ||
name = "implication_operator" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.35.0" | ||
|
||
[dependencies] |
6 changes: 6 additions & 0 deletions
6
test_programs/formal_verify_success/implication_operator_2/src/main.nr
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,6 @@ | ||
// This test shows that you can use the implication operator not | ||
// only in attributes but also in the function's body. | ||
#[requires(y ==> x > 5)] | ||
fn main(x: u32, y: bool) { | ||
assert(y ==> x > 5); | ||
} |