-
Notifications
You must be signed in to change notification settings - Fork 205
Add documentation for PEx #893
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,130 @@ | ||
| # PEx: Exhaustive Model Checking | ||
|
|
||
| PEx is an exhaustive model checker for P programs that performs a systematic search to verify correctness properties for small (finite) instances of the system. It explores all possible behaviors of the system by analyzing finite inputs and finite processes. | ||
|
|
||
| ## Architecture | ||
|
|
||
| PEx uses a multi-threaded, stateful search optimized to scale to billions of protocol states. The core architecture includes: | ||
|
|
||
| - **State Tracking**: Maintains record of all unexplored state transitions | ||
| - **Dynamic Prioritization**: Optimizes exploration order during search | ||
| - **State Caching**: Prevents redundant work by caching visited states | ||
| - **Parallel Execution**: Leverages thread-level parallelism for performance | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| PEx requires Java 17+ and Maven 3.7+ to be installed on your system. | ||
|
|
||
| === "MacOS" | ||
| ```shell | ||
| # Install Java 17 | ||
| brew install openjdk@17 | ||
|
|
||
| # Install Maven | ||
| brew install maven | ||
| ``` | ||
| Don't have Homebrew? Download [Java](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) and [Maven](https://maven.apache.org/install.html) directly. | ||
|
|
||
| === "Ubuntu" | ||
| ```shell | ||
| # Install Java 17 | ||
| sudo apt install openjdk-17-jdk | ||
|
|
||
| # Install Maven | ||
| sudo apt install maven | ||
| ``` | ||
|
|
||
| === "Windows" | ||
| - Download and install [Java 17](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) | ||
| - Follow the [Maven installation guide](https://maven.apache.org/install.html) | ||
|
|
||
| ??? hint "Verify installations" | ||
| ```shell | ||
| java -version # Should show version 17 or higher | ||
| mvn -version # Should show version 3.7 or higher | ||
| ``` | ||
|
|
||
| ### Building with PEx | ||
|
|
||
| To compile a P program for exhaustive model checking: | ||
|
|
||
| ```shell | ||
| p compile --mode pex | ||
| ``` | ||
|
|
||
| ### Running PEx | ||
|
|
||
| Basic usage to run PEx on a test case with a 60-second timeout on tutorial #1 Client Server: | ||
|
|
||
| ```shell | ||
| p check --mode pex -tc tcSingleClient --timeout 60 | ||
| ``` | ||
|
|
||
| ??? example "Expected Output" | ||
| ``` | ||
| .. Searching for a P compiled file locally in folder ./PGenerated/ | ||
| .. Found a P compiled file: ./PGenerated/PEx/target/ClientServer-jar-with-dependencies.jar | ||
| .. Checking ./PGenerated/PEx/target/ClientServer-jar-with-dependencies.jar | ||
| WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance. | ||
| .. Test case :: tcSingleClient | ||
| ... Checker is using 'random' strategy with 1 threads (seed:1754429957918) | ||
| -------------------- | ||
| Time Memory Tasks (run/fin/pen) Schedules Timelines States | ||
| 00:01:10 8.4 GB 1 / 0 / 0 1 1 17,491 | ||
|
|
||
| -------------------- | ||
| ... Checking statistics: | ||
| ..... Found 0 bugs. | ||
| ... Search statistics: | ||
| ..... Explored 17,491 distinct states over 1 timelines | ||
| ..... Explored 1 distinct schedules | ||
| ..... Finished 0 search tasks (0 pending) | ||
| ..... Number of steps explored: -1 (min), 0 (avg), -1 (max). | ||
| ... Elapsed 70 seconds and used 8.6 GB | ||
| .. Result: partially correct with 9 choices remaining | ||
| . Done | ||
| ... Checker timed out. | ||
| ~~ [PTool]: Thanks for using P! ~~ | ||
| ... Checker run terminated. | ||
| ``` | ||
|
|
||
| Understanding the output: | ||
|
|
||
| **States and Timelines**: | ||
| - Explored 17,491 distinct states in a single timeline/schedule | ||
|
|
||
| **Resource Usage**: | ||
| - Used 8.4 GB of memory during exploration | ||
| - Timed out after 70 seconds (hit the 60-second timeout plus overhead) | ||
|
|
||
| **Results**: | ||
| - Found no bugs in the explored state space | ||
| - "partially correct with 9 choices remaining" indicates there are still 9 unexplored choices when the checker timed out | ||
| - The negative values in "steps explored" indicate the checker was interrupted before completing its exploration | ||
|
|
||
| ### Advanced Options | ||
|
|
||
| ??? tip "Exploring PEx Runtime Options" | ||
| View available runtime options: | ||
| ```shell | ||
| # Print basic help menu | ||
| p check --mode pex --checker-args :--help | ||
|
|
||
| # Print expert help menu with advanced options | ||
| p check --mode pex --checker-args :--help-all | ||
| ``` | ||
|
|
||
| ### Parallel Execution | ||
|
|
||
| PEx supports parallel execution to speed up the verification process. To run with multiple cores on tutorial #1 Client Server: | ||
|
|
||
| ```shell | ||
| p check --mode pex -tc tcSingleClient --timeout 60 --checker-args :--nproc:32 | ||
| ``` | ||
|
|
||
| This example uses 32 cores for parallel exploration of the state space. | ||
|
|
||
| !!! note "Performance Tips" | ||
| - Start with a reasonable timeout value (e.g., 60 seconds) and adjust based on your system's complexity | ||
| - For large state spaces, use parallel execution with multiple cores | ||
| - Consider using abstractions to reduce the state space when possible | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revise run output without
--max-steps 100000