Skip to content

Commit 347ca27

Browse files
Updating imp.md, kore tests and kore-proof-trace to parse side condition events (#1032)
This PR fixes Pi-Squared-Inc/pi2#1348. This issue reports that `kore-proof-trace` doesn't generate any hints when a `requires` clause is used in an example. After investigating the issue, we realized that our regression tests didn't cover this case. Therefore, we updated the current `imp-*.kore` tests to contain it. We also updated `imp.md` to be compatible with K v7.0.15. To improve the reproducibility of our tests in the future, we made `imp.md` the source code of `imp.kore`, `imp-proof.kore`, and `imp-slow-proof.kore`. Then, we needed to update the Proof Hints version and the `kore-proof-trace` tool to include "side condition" events as arguments and parse them appropriately to hints for the `requires` clause and the rest of the test.
1 parent a485fe8 commit 347ca27

File tree

11 files changed

+8616
-10331
lines changed

11 files changed

+8616
-10331
lines changed

docs/proof-trace.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ event ::= hook
4040
argument ::= hook
4141
| function
4242
| rule
43+
| side_cond_entry
44+
| side_cond_exit
4345
| kore_term
4446
4547
name ::= string

include/kllvm/binary/ProofTraceParser.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ class llvm_rewrite_trace {
260260

261261
class proof_trace_parser {
262262
public:
263-
static constexpr uint32_t expected_version = 8U;
263+
static constexpr uint32_t expected_version = 9U;
264264

265265
private:
266266
bool verbose_;
@@ -631,6 +631,24 @@ class proof_trace_parser {
631631
return true;
632632
}
633633

634+
case side_condition_event_sentinel: {
635+
auto side_condition_event = parse_side_condition(ptr, end);
636+
if (!side_condition_event) {
637+
return false;
638+
}
639+
event.set_step_event(side_condition_event);
640+
return true;
641+
}
642+
643+
case side_condition_end_sentinel: {
644+
auto side_condition_end_event = parse_side_condition_end(ptr, end);
645+
if (!side_condition_end_event) {
646+
return false;
647+
}
648+
event.set_step_event(side_condition_end_event);
649+
return true;
650+
}
651+
634652
default: return false;
635653
}
636654
}

runtime/util/util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ block *construct_raw_term(void *subject, char const *sort, bool raw_value) {
3535
}
3636

3737
void print_proof_hint_header(FILE *file) {
38-
uint32_t version = 8;
38+
uint32_t version = 9;
3939
fmt::print(file, "HINT");
4040
fwrite(&version, sizeof(version), 1, file);
4141
}

test/defn/imp-proof.kore

Lines changed: 959 additions & 1120 deletions
Large diffs are not rendered by default.

test/defn/imp-slow-proof.kore

Lines changed: 959 additions & 1120 deletions
Large diffs are not rendered by default.

test/defn/imp.kore

Lines changed: 1229 additions & 1422 deletions
Large diffs are not rendered by default.

test/defn/k-files/imp.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ argument, because we want to give it a short-circuit semantics.
3333
| "(" AExp ")" [bracket]
3434
> AExp "+" AExp [left, strict, color(pink)]
3535
syntax BExp ::= Bool
36-
| AExp "<=" AExp [seqstrict, latex({#1}\leq{#2}), color(pink)]
36+
| AExp "<=" AExp [seqstrict, color(pink)]
3737
| "!" BExp [strict, color(pink)]
3838
| "(" BExp ")" [bracket]
3939
> BExp "&&" BExp [left, strict(1), color(pink)]
@@ -160,8 +160,8 @@ systems. You can make these rules computational (dropping the attribute
160160
`structural`) if you do want these to count as computational steps.
161161

162162
```k
163-
rule {} => . [structural]
164-
rule {S} => S [structural]
163+
rule {} => .K
164+
rule {S} => S
165165
```
166166

167167
### Assignment
@@ -170,7 +170,7 @@ to be declared, otherwise the semantics will get stuck. At the same time,
170170
the assignment is dissolved.
171171

172172
```k
173-
rule <k> X = I:Int; => . ...</k> <state>... X |-> (_ => I) ...</state>
173+
rule <k> X = I:Int; => .K ...</k> <state>... X |-> (_ => I) ...</state>
174174
```
175175

176176
### Sequential composition
@@ -185,7 +185,7 @@ transitions (i.e., hiding the structural rules as unobservable, or
185185
internal steps).
186186

187187
```k
188-
rule S1:Stmt S2:Stmt => S1 ~> S2 [structural]
188+
rule S1:Stmt S2:Stmt => S1 ~> S2
189189
```
190190

191191
### Conditional
@@ -205,7 +205,7 @@ We give the semantics of the `while` loop by unrolling.
205205
Note that we preferred to make the rule below structural.
206206

207207
```k
208-
rule while (B) S => if (B) {S while (B) S} else {} [structural]
208+
rule while (B) S => if (B) {S while (B) S} else {}
209209
```
210210

211211
### Programs
@@ -224,6 +224,6 @@ a computational step.
224224
```k
225225
rule <k> int (X,Xs => Xs);_ </k> <state> Rho:Map (.Map => X|->0) </state>
226226
requires notBool (X in keys(Rho))
227-
rule int .Ids; S => S [structural]
227+
rule int .Ids; S => S
228228
endmodule
229229
```

test/output/imp-proof/imp-proof.expanded.out.diff

Lines changed: 1357 additions & 1645 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)