Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
aa6a0db
refactored example structure
dominikgeissler Jan 2, 2025
138c61f
adjusted benchmark script to execute files with provided commands
dominikgeissler Jan 11, 2025
68b13eb
changed variable name
dominikgeissler Jan 15, 2025
6819f24
add comment
dominikgeissler Jan 15, 2025
74b3c6d
Runtime comparison only if more than 1 engine is selected
dominikgeissler Jan 22, 2025
ec7e572
more precise help text
dominikgeissler Jan 22, 2025
ae8b07f
fixed independent vars call
Jan 22, 2025
2e34b21
added first loop-free equiv example
Jan 22, 2025
f2dbd22
Runtime comparison only if more than 1 engine is selected
dominikgeissler Jan 22, 2025
d3a73f0
more precise help text
dominikgeissler Jan 22, 2025
0f0d367
fixed independent vars call
Jan 22, 2025
f6c0aea
added first loop-free equiv example
Jan 22, 2025
df17cdd
moved cov_phi, added check for variable difference
dominikgeissler Jan 23, 2025
b7fbec0
refactored equiv check
Jan 24, 2025
19640c1
deleted
Jan 24, 2025
4878983
fixed
Jan 24, 2025
28f0bfb
minor
Jan 24, 2025
fb40b98
minor
Jan 24, 2025
1e077df
small example
dominikgeissler Feb 4, 2025
e69fc2a
small example
dominikgeissler Feb 4, 2025
7b1eb64
added mockup test for new equality check
dominikgeissler Feb 5, 2025
b0bb58d
fixed broken equivalence tests
Feb 5, 2025
59b4de0
name change
Feb 5, 2025
63c23ca
optional type
Feb 6, 2025
41df41e
added automatic benchmark tests & doc regarding file structure + nami…
dominikgeissler Feb 7, 2025
81a390a
benchmark script should now be able to handle interactive programs
dominikgeissler Feb 7, 2025
b1902c5
Merge pull request #57 from LKlinke/feature/54/equality-checks
LKlinke Feb 7, 2025
4f5c926
remove duplicate
dominikgeissler Feb 7, 2025
de7383a
removed duplicates from solutions
dominikgeissler Jan 15, 2025
48e274e
todos in examples
dominikgeissler Jan 15, 2025
015f8e8
fixed execution instruction
Jan 22, 2025
592b6cf
fixed typo
dominikgeissler Feb 12, 2025
e9ec07c
fix skip_files
dominikgeissler Feb 12, 2025
5362f25
fixed parsing error in benchmark script
dominikgeissler Feb 12, 2025
f1e3ea9
added new benchmark
dominikgeissler Feb 9, 2025
b2429b3
better error message
Feb 12, 2025
c74744d
bug fix
Feb 12, 2025
ea14b1f
typo
Feb 12, 2025
9b36c04
added equivalence fail test
dominikgeissler Feb 12, 2025
a1ca1a9
fixed linting
dominikgeissler Mar 6, 2025
890c12d
mypy + tests
dominikgeissler Mar 6, 2025
fafed5b
temporarily disabled conflicting test
dominikgeissler Mar 9, 2025
00bb234
introduced test order to fix error #64
dominikgeissler Mar 9, 2025
6d45342
typo
dominikgeissler Mar 9, 2025
0bf3e43
Benchmark script can now handle multiple invariant files, removed tod…
dominikgeissler Mar 10, 2025
f58b348
#63 resolved the issue with bit_flip_conditioning
dominikgeissler Mar 10, 2025
a78f30c
changed compile -> parse
dominikgeissler Mar 15, 2025
020e287
resolved todo
dominikgeissler Mar 15, 2025
479ff03
ivars -> independent_vars_analysis
dominikgeissler Mar 15, 2025
90f1f69
investigation into failing tests
dominikgeissler Mar 15, 2025
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
362 changes: 259 additions & 103 deletions benchmark_comparison.py

Large diffs are not rendered by default.

44 changes: 37 additions & 7 deletions pgfexamples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,47 @@ pgfexamples/
├── comparison # Comparisons with other tools / paradigms
│   ├── ADDcomparison # Comparisons with Algebraic Decision Diagrams
│   └── psicomparison # Comparisons with Psi
│   ├── inference
│   ├── inference
│   └── psi_fails # Examples where Psi fails
├── evt_invariants # Synthesis of expected visiting time invariants
├── independence # Independent variables
├── equivalence # Equivalence of two programs
│   ├── loop_free # Programs without loops and their counterparts
│   └── loopy # Programs with loops
│   └── invariants # ... and their loop-free counterpart
├── independence # Checks for independent variables
├── inference # Calculation of posterior distribution
│   ├── loop_free # ... without while-loops
│   │   └── conditioning # ... with observe-statements
│   └── loopy # ... with while-loops
│   └── conditioning # ... with observe-statements
├── loop_equivalence # Equality of loopy and loop-free programs
│   └── invariants # Corresponding loop-free programs
├── invariant_synthesis # Synthesis of (expected visiting time) invariants
└── template_parameter_synthesis # Equality of loopy and loop-free programs with parameters
   └── invariants # Corresponding loop-free programs
```
└── invariants # Corresponding loop-free programs
```

## File structure

* Files have a comment in the first line indicating which arguments should be used in order to execute it

> ```bash
>python prodigy/cli.py METHOD FILE ARGS
>```
> results in
>```
># METHOD FILE ARGS
>```
> in the first line of the corresponding program or just
> ```
> # skip
> ```
> if the file should not be automatically tested.

* Naming convention:
* In `pgfexamples/equivalence/loop_free` the files are named `file_name.pgcl` for the first and
`file_name2.pgcl` for the second program
* In `pgfexamples/equivalence/loopy` and `pgfexamples/template_parameter_synthesis` the files are named
`file_name.pgcl` in the main folder and their corresponding invariants with `file_name_invariant.pgcl` in the
invariants folder
* If there are multiple invariant files for one program, e.g. for a nested loop, the invariants are to be marked
with numbers indicating the order they should be used (i.e. the invariant for the outer-most while loop has number
1 and so on)
* Invariants and second programs are to be marked with `skip`
4 changes: 4 additions & 0 deletions pgfexamples/equivalence/loop_free/bernoulli.pgcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# check_equality pgfexamples/equivalence/loop_free/bernoulli.pgcl pgfexamples/equivalence/loop_free/bernoulli2.pgcl
nat x;

{ x := 0 } [1/3] { x := 1 }
4 changes: 4 additions & 0 deletions pgfexamples/equivalence/loop_free/bernoulli2.pgcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# skip
nat x;

x := bernoulli(2/3);
9 changes: 9 additions & 0 deletions pgfexamples/equivalence/loop_free/dice_sampling.pgcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# check_equality pgfexamples/equivalence/loop_free/dice_sampling.pgcl pgfexamples/equivalence/loop_free/dice_sampling2.pgcl
nat dice;
nat tmp;

tmp := 0;

# Roll a dice
dice := unif(1,6);

11 changes: 11 additions & 0 deletions pgfexamples/equivalence/loop_free/dice_sampling2.pgcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# skip
nat dice;
nat tmp;

# Roll a three-sided dice
tmp := unif(1,3);

# Flip a coin, leave or increase by 3
{ dice := tmp; } [1/2] { dice := tmp + 3; }

tmp := 0;
4 changes: 4 additions & 0 deletions pgfexamples/equivalence/loop_free/uniform_sampling.pgcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# check_equality pgfexamples/equivalence/loop_free/uniform_sampling.pgcl pgfexamples/equivalence/loop_free/uniform_sampling2.pgcl
nat x

x := unif(1,6)
12 changes: 12 additions & 0 deletions pgfexamples/equivalence/loop_free/uniform_sampling2.pgcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# skip
nat x

{x:=1}[1/6]{
{x:=2}[1/5]{
{x:=3}[1/4]{
{x:=4}[1/3]{
{x:=5}[1/2]{x:=6}
}
}
}
}
11 changes: 11 additions & 0 deletions pgfexamples/equivalence/loopy/17_die_even.pgcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# check_equality pgfexamples/equivalence/loopy/17_die_even.pgcl pgfexamples/equivalence/loopy/invariants/17_die_even_invariant.pgcl
nat c
nat x
nat temp

while (x < 6) {
x := unif(1,6)
c := c + 1
observe(x % 2 = 0)
temp := 0
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# check_equality pgfexamples/equivalence/loopy/bit_flip_conditioning.pgcl pgfexamples/equivalence/loopy/invariants/bit_flip_conditioning_invariant.pgcl
bool b1
bool b2
bool b3
bool b4
nat i
nat temp

while (not ((b1 = 0) & (b2 = 0))) {
while (b1=1 || b2=1) {
b1 := bernoulli(1/2)
b2 := bernoulli(1/2)
observe( (b1 = 0 & b3 = 0) || (b1 = 1 & b3 = 1) || (b2 = 0 & b4 = 0) || (b2 = 1 & b4 = 1) )
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# skip
nat n;
nat m;

Expand Down
12 changes: 12 additions & 0 deletions pgfexamples/equivalence/loopy/dep_bern.pgcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# check_equality pgfexamples/equivalence/loopy/dep_bern.pgcl pgfexamples/equivalence/loopy/invariants/dep_bern_invariant.pgcl
nat c;
nat m;
nat n;
nat tmp;


while( c > 0 ){
{m := m+1} [1/2] {n:= n+1}
c := c-1
tmp := 0
}
7 changes: 7 additions & 0 deletions pgfexamples/equivalence/loopy/endless_conditioning.pgcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# check_equality pgfexamples/equivalence/loopy/endless_conditioning.pgcl pgfexamples/equivalence/loopy/invariants/endless_conditioning_invariant.pgcl
nat x;

while(x=1){
{x := 0}[1/2]{x:=1}
observe(x=1)
}
9 changes: 9 additions & 0 deletions pgfexamples/equivalence/loopy/geometric.pgcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# check_equality pgfexamples/equivalence/loopy/geometric.pgcl pgfexamples/equivalence/loopy/invariants/geometric_invariant.pgcl
nat x;
nat c;
nat temp;

while (x = 1){
{x := 0 } [1/2] {c := c+1}
temp :=0
}
11 changes: 11 additions & 0 deletions pgfexamples/equivalence/loopy/geometric_observe.pgcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# check_equality pgfexamples/equivalence/loopy/geometric_observe.pgcl pgfexamples/equivalence/loopy/invariants/geometric_observe_invariant.pgcl
nat y;
nat x;
nat tmp;

while ( y = 1){
{y := 0}[1/2]{y := 1};
x := x + 1;
observe( x < 3)
tmp := 0;
}
10 changes: 10 additions & 0 deletions pgfexamples/equivalence/loopy/geometric_shifted.pgcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# check_equality pgfexamples/equivalence/loopy/geometric_shifted.pgcl pgfexamples/equivalence/loopy/invariants/geometric_shifted_invariant.pgcl
nat x;
nat c;
nat temp;
rparam p;

while (x > 0){
{x := 0; c := c + 3 } [1/2] {c := c+1}
temp := 0
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# skip
nat c
nat x
nat temp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# skip
bool b1
bool b2
bool b3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# skip
nat n;
nat m;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# skip
nat c;
nat m;
nat n;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# skip
nat x;

if (x = 1){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# skip
nat x;
nat c;
nat temp;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# skip
nat y;
nat x;
nat tmp;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# skip
nat x;
nat c;
nat temp;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# skip
nat s;
nat die;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# skip
nat s;
nat die;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# skip
nat n;
nat c;
nat tmp;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# skip
nat x;
nat y;
nat c;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# skip
nat x;
nat y;
nat temp;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# skip
nat s;
nat c;
nat tmp;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# skip
nat c;

if(c%2=0){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# skip
nat x;
nat c;
nat tmp;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# skip
nat c;
nat m;
nat n;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# skip
nat m;
nat c;
nat tmp;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# skip
nat c;

if ( not (c%2=0)){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# skip
nat n;
nat m;
nat tmp;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# check_equality pgfexamples/equivalence/loopy/ky_die.pgcl pgfexamples/equivalence/loopy/invariants/ky_die_invariant.pgcl
nat s;
nat die;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# check_equality pgfexamples/equivalence/loopy/ky_die_2.pgcl pgfexamples/equivalence/loopy/invariants/ky_die_2_invariant.pgcl
nat s;
nat die;

Expand Down
9 changes: 9 additions & 0 deletions pgfexamples/equivalence/loopy/n_geometric.pgcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# check_equality pgfexamples/equivalence/loopy/n_geometric.pgcl pgfexamples/equivalence/loopy/invariants/n_geometric_invariant.pgcl
nat n;
nat c;
nat tmp;

while(n > 0){
{n := n - 1 } [1/2] {c := c + 1}
tmp := 0
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# check_equality pgfexamples/equivalence/loopy/nested_while.pgcl pgfexamples/equivalence/loopy/invariants/nested_while_invariant1.pgcl
nat x;
nat y;
nat c;
Expand Down
10 changes: 10 additions & 0 deletions pgfexamples/equivalence/loopy/random_walk.pgcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# check_equality pgfexamples/equivalence/loopy/random_walk.pgcl pgfexamples/equivalence/loopy/invariants/random_walk_invariant.pgcl
nat s;
nat c;
nat tmp;

while(s > 0){
{s := s+1} [1/2] {s := s-1}
c := c+1
tmp := 0
}
9 changes: 9 additions & 0 deletions pgfexamples/equivalence/loopy/running_paper_example.pgcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# check_equality pgfexamples/equivalence/loopy/running_paper_example.pgcl pgfexamples/equivalence/loopy/invariants/running_paper_example_invariant.pgcl
nat x;
nat c;
nat tmp;

while(x > 0) {
{ x := x-1 } [1/2] { c := c+1 }
tmp := 0;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# check_equality pgfexamples/equivalence/loopy/sequential_loops.pgcl pgfexamples/equivalence/loopy/invariants/sequential_loops_invariant1.pgcl
nat c;
nat m;
nat n;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# skip
nat c;

while (c%2=0){
Expand Down
12 changes: 12 additions & 0 deletions pgfexamples/equivalence/loopy/trivial_iid.pgcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# check_equality pgfexamples/equivalence/loopy/trivial_iid.pgcl pgfexamples/equivalence/loopy/invariants/trivial_iid_invariant.pgcl
nat n;
nat m;
nat tmp;

while (0 < n) {
tmp := unif(1,6);
m := m + tmp;
tmp := 0;
n := n-1
}

6 changes: 0 additions & 6 deletions pgfexamples/evt_invariants/faulty_decrement.pgcl

This file was deleted.

6 changes: 0 additions & 6 deletions pgfexamples/evt_invariants/geometric.pgcl

This file was deleted.

7 changes: 0 additions & 7 deletions pgfexamples/evt_invariants/geometric_counter.pgcl

This file was deleted.

Loading