Skip to content
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

Start to move PVerifier so that its ready to be merged into P3.0 #805

Merged
merged 19 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
0b6c4b5
Prototype Support For Verification (#762)
FedericoAureliano Aug 21, 2024
f28f1ce
add install instructions for amazon linux
FedericoAureliano Aug 27, 2024
45e4b29
[Feature] `prove * using *` command for incremental proof constructio…
AD1024 Oct 11, 2024
8d40993
add support for foreign functions with contracts and update one tutor…
FedericoAureliano Oct 30, 2024
21ea906
allow duplicate invariant names in different groups using group name …
FedericoAureliano Oct 30, 2024
4f68d8c
add caching using liteDB and md5 hash of uclid files
FedericoAureliano Oct 31, 2024
97b0570
fix bug in caching by simplifying process checklist
FedericoAureliano Oct 31, 2024
479ed18
fix bug in global procedures: always prepend self reference
FedericoAureliano Nov 1, 2024
d62226d
add default that captures P's proof obligations
FedericoAureliano Nov 2, 2024
92a01ed
fix bug in file names
FedericoAureliano Nov 2, 2024
45f5269
cleanup example for tutorial
FedericoAureliano Nov 4, 2024
be3227b
add 2pc verification tutorial
FedericoAureliano Nov 23, 2024
80eed8b
pverifier backend and reorganize verification tutorials
FedericoAureliano Nov 28, 2024
c12d6a7
init keyword -> init-condition keyword
FedericoAureliano Nov 28, 2024
c26fc9b
add error message when trying to use pverifier syntax for other backends
FedericoAureliano Nov 28, 2024
446859b
move install instructions to docs and update link in 2pc verification…
FedericoAureliano Nov 28, 2024
d01c547
rename uclid5 backend to pverifier
FedericoAureliano Dec 5, 2024
0a92d4c
remove unnecessary imports
FedericoAureliano Dec 5, 2024
07f2a06
add iff symbol
FedericoAureliano Dec 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions Docs/docs/advanced/install-verification-backend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Install Instructions for Amazon Linux

## Get Java 11
```sh
sudo rpm --import https://yum.corretto.aws/corretto.key
sudo curl -L-o /etc/yum.repos.d/corretto.repo https://yum.corretto.aws/corretto.repo
sudo yum install java-11-amazon-corretto-devel
```

## Get SBT
```sh
sudo rm -f /etc/yum.repos.d/bintray-rpm.repo || true
curl -L https://www.scala-sbt.org/sbt-rpm.repo > sbt-rpm.repo
sudo mv sbt-rpm.repo /etc/yum.repos.d/
sudo yum install sbt
```

## Get Z3
```sh
cd ~
git clone https://github.com/Z3Prover/z3.git
cd z3
python scripts/mk_make.py --java
cd build; make
```
Then add `export PATH=$PATH:$HOME/z3/build/` and `export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/z3/build/` to your .zshrc and run
`source ~/.zshrc`.

## Get UCLID5
```sh
cd ~
git clone https://github.com/uclid-org/uclid.git
cd uclid
sbt update clean compile "set fork:=true" test # should fail some tests that use cvc5 and delphi
sbt universal:packageBin
unzip target/universal/uclid-0.9.5.zip
```
Then add `export PATH=$PATH:$HOME/uclid/uclid-0.9.5/bin/` to your .zshrc and run `source ~/.zshrc`.

## Get PVerifier
```sh
cd ~
git clone https://github.com/FedericoAureliano/P.git
cd P
# follow regular P install instructions
root=$(pwd)
cd $root/Bld
./build.sh
dotnet tool uninstall --global P
cd $root/Src/PCompiler/PCommandLine
dotnet pack PCommandLine.csproj --configuration Release --output ./publish -p:PackAsTool=true -p:ToolCommandName=P -p:Version=2.1.3
dotnet tool install P --global --add-source ./publish
```
388 changes: 388 additions & 0 deletions Docs/docs/tutorial/advanced/twophasecommitverification.md

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Src/PCompiler/CompilerCore/Backend/Debugging/IrToPseudoP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ private void WriteTree(IPAST tree)
WriteStmt("assert ", assertStmt.Assertion, ", \"", assertStmt.Message, "\";");
break;

case AssumeStmt assumeStmt:
WriteStmt("assume ", assumeStmt.Assumption, ", \"", assumeStmt.Message, "\";");
break;

case AssignStmt assignStmt:
WriteStmt(assignStmt.Location, " = ", assignStmt.Value, ";");
break;
Expand Down
17 changes: 16 additions & 1 deletion Src/PCompiler/CompilerCore/Backend/IRTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,22 @@ private List<IPStmt> SimplifyStatement(IPStmt statement)
}).ToList()));
return assertDeps.Concat(new List<IPStmt>{ifStmtForAssert})
.ToList();

case AssumeStmt assumeStmt:
(var assumeExpr, var assumeDeps) = SimplifyExpression(assumeStmt.Assumption);
(var amessageExpr, var amessageDeps) = SimplifyExpression(assumeStmt.Message);
if (assumeExpr is BoolLiteralExpr)
{
return assumeDeps.Concat(amessageDeps).Concat(new []{new AssumeStmt(location, assumeExpr, amessageExpr)}).ToList();
}

var aifStmtForAssert = new IfStmt(location, assumeExpr, new NoStmt(location), new CompoundStmt(
location, amessageDeps.Concat(new[]
{
new AssumeStmt(location, assumeExpr, amessageExpr)
}).ToList()));
return assumeDeps.Concat(new List<IPStmt>{aifStmtForAssert})
.ToList();

case AssignStmt assignStmt:
(var assignLV, var assignLVDeps) = SimplifyLvalue(assignStmt.Location);
Expand Down Expand Up @@ -434,7 +450,6 @@ private List<IPStmt> SimplifyStatement(IPStmt statement)
new CompoundStmt(ifStmt.ElseBranch.SourceLocation, elseBranch))
})
.ToList();

case AddStmt addStmt:
var (addVar, addVarDeps) = SimplifyLvalue(addStmt.Variable);
var (addVal, addValDeps) = SimplifyArgPack(new[] { addStmt.Value });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ static private IPStmt ReplaceVars(IPStmt stmt, Dictionary<Variable,Variable> var
return new AnnounceStmt(announceStmt.SourceLocation, ReplaceVars(announceStmt.Event, varMap), ReplaceVars(announceStmt.Payload, varMap));
case AssertStmt assertStmt:
return new AssertStmt(assertStmt.SourceLocation, ReplaceVars(assertStmt.Assertion, varMap), ReplaceVars(assertStmt.Message, varMap));
case AssumeStmt assumeStmt:
return new AssumeStmt(assumeStmt.SourceLocation, ReplaceVars(assumeStmt.Assumption, varMap), ReplaceVars(assumeStmt.Message, varMap));
case AssignStmt assignStmt:
return new AssignStmt(assignStmt.SourceLocation, ReplaceVars(assignStmt.Location, varMap), ReplaceVars(assignStmt.Value, varMap));
case CompoundStmt compoundStmt:
Expand Down
2 changes: 2 additions & 0 deletions Src/PCompiler/CompilerCore/Backend/TargetLanguage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Plang.Compiler.Backend.Java;
using Plang.Compiler.Backend.Stately;
using Plang.Compiler.Backend.Symbolic;
using Plang.Compiler.Backend.Uclid5;

namespace Plang.Compiler.Backend
{
Expand All @@ -17,6 +18,7 @@ static TargetLanguage()
RegisterCodeGenerator(CompilerOutput.Java, new JavaCompiler());
RegisterCodeGenerator(CompilerOutput.Symbolic, new SymbolicCodeGenerator());
RegisterCodeGenerator(CompilerOutput.Stately, new StatelyCodeGenerator());
RegisterCodeGenerator(CompilerOutput.Uclid5, new Uclid5CodeGenerator());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets rename this to PVerifier instead of UCLID5

}

private static void RegisterCodeGenerator(CompilerOutput name, ICodeGenerator generator)
Expand Down
11 changes: 11 additions & 0 deletions Src/PCompiler/CompilerCore/Backend/Uclid5/CompilationContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Plang.Compiler.Backend.Uclid5;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please rename the entire folder Backend/Uclid5 to Backend/PVerifier


internal class CompilationContext : CompilationContextBase
{
public CompilationContext(ICompilerConfiguration job) : base(job)
{
FileName = $"{ProjectName}.ucl";
}

public string FileName { get; set; }
}
Loading
Loading