-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tutorial Sections 2.1 and 2.2 Updates (#3387)
Update the tutorial, namely: - Update the [bounds checking and pointers example](https://model-checking.github.io/kani/tutorial-kinds-of-failure.html#bounds-checking-and-pointers). `cargo test` catches the UB in the current example, so this PR modifies the code slightly so that `cargo test` still misses the UB, as desired. - Rather than including larger sections on experimental features throughout the tutorial, create a separate experimental features section and include (briefer) references to them in the tutorial. - The old text recommended debugging by generating a trace with `--visualize`, with a briefer mention of `--concrete-playback`. Since `--visualize` is deprecated, revise the debugging exercises to recommend `--concrete-playback` instead. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses. --------- Co-authored-by: Jaisurya Nanduri <91620234+jaisnan@users.noreply.github.com>
- Loading branch information
1 parent
3bc4f0c
commit 695e6f7
Showing
12 changed files
with
81 additions
and
128 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
## Coverage | ||
|
||
Recall our `estimate_size` example from [First steps](../../tutorial-first-steps.md), | ||
where we wrote a proof harness constraining the range of inputs to integers less than 4096: | ||
|
||
```rust | ||
{{#include ../../tutorial/first-steps-v2/src/lib.rs:kani}} | ||
``` | ||
|
||
We must wonder if we've really fully tested our function. | ||
What if we revise the function, but forget to update the assumption in our proof harness to cover the new range of inputs? | ||
|
||
Fortunately, Kani is able to report a coverage metric for each proof harness. | ||
In the `first-steps-v2` directory, try running: | ||
|
||
``` | ||
cargo kani --coverage -Z line-coverage --harness verify_success | ||
``` | ||
|
||
which verifies the harness, then prints coverage information for each line. | ||
In this case, we see that each line of `estimate_size` is followed by `FULL`, indicating that our proof harness provides full coverage. | ||
|
||
Try changing the assumption in the proof harness to `x < 2048`. | ||
Now the harness won't be testing all possible cases. | ||
Rerun the command. | ||
You'll see this line: | ||
|
||
``` | ||
src/lib.rs, 24, NONE | ||
``` | ||
|
||
which indicates that the proof no longer covers line 24, which addresses the case where `x >= 2048`. |
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,5 @@ | ||
# Experimental Features | ||
|
||
We elaborate on some of the more commonly used experimental features in Kani. | ||
This is not an exhaustive list; to see all of Kani's experimental features, run `cargo kani --help`. | ||
To use an experimental feature, invoke Kani with the `--unstable` or `-Z` flag followed by the name of the feature. |
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