Skip to content

Commit ed32fbc

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 2983a01 + efd2f19 commit ed32fbc

File tree

1 file changed

+82
-6
lines changed

1 file changed

+82
-6
lines changed

docs/proof-trace.md

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
# Proof Trace Format
22

33
This document describes the format for the binary proof trace that gets emitted
4-
when the `--proof-output` flag gets passed to the interpreter. In order for the trace
5-
to be emitted, an appropriate instrumentation flag should have been passed to `llvm-kompile`.
4+
when the `--proof-output` flag gets passed to the interpreter or `--proof-hint`
5+
is passed to `krun`. In order for the trace to be emitted, an appropriate instrumentation
6+
flag should have been passed to `kompile` or directly to `llvm-kompile`.
7+
68
We currently offer two modes of instrumentation: the default one is enabled with the flag
7-
`--proof-hint-instrumentation`, while a slower one that generates a longer trace is enabled with
8-
the flag `--proof-hint-instrumentation-slow`. Note that this trace
9-
format is in its early stages and will probably change quite a bit as development on it
10-
continues.
9+
`--proof-hint-instrumentation`, while a slower one that generates a longer trace with all
10+
intermediate configurations is enabled with the flag `--proof-hint-instrumentation-slow`.
11+
Note that this trace format is in its early stages and will probably change quite a bit as
12+
development on it continues. Watch for the version of the trace format in the header of
13+
the trace.
1114

1215
## Overview
1316

@@ -74,3 +77,76 @@ uint64 ::= <64-bit unsigned little endian integer>
7477
are related to configuration initialization.
7578
- The `relative_position` is a null terminated string of positive integers
7679
separated by `:` (ie. `0:1:1`)
80+
- The `arg*` in the `function` and `hook` event is a list of arguments that
81+
are either `hook`, `function`, `rule`, `side_cond_entry`, `side_cond_exit`, or `kore_term`.
82+
83+
84+
## Tools
85+
86+
As mentioned above, the proof trace is in binary format and can be generated using the
87+
appropriated flags to `kompile` and `krun `or directly to `llvm-kompile` and `llvm-krun`.
88+
We provide a tool to deserialize the binary trace to a human-readable format. The
89+
`kore-proof-trace` is located in the `tools` directory of the LLVM Backend repository
90+
and it takes two arguments: the path to the binary header and to the binary trace file.
91+
It can take 3 flags:
92+
- `--verbose` for verbose output,
93+
- `--expand-terms` for printing the KORE terms in the trace instead of their sizes and
94+
- `--streaming-parser` to use the streaming parser instead of the default one.
95+
96+
The tool will output the trace in a human-readable format to the standard output.
97+
98+
The binary header mentioned above is a file that contains data about the terms that
99+
might be serialized and the version of the binary KORE format used to
100+
serialize/deserialize the terms in the trace. The header is generated by the
101+
`kore-rich-header` tool located in the `tools` directory of the LLVM Backend repository.
102+
This tool takes a single argument, the path to the KORE definition file, and outputs
103+
the header to the standard output. The complete documentation for the header format and
104+
the new binary KORE format can be found in the [docs/binary-kore-2.md](./binary-kore-2.md) file.
105+
106+
## Example
107+
### Definition
108+
109+
```K
110+
module ADD-REWRITE-SYNTAX
111+
112+
syntax Nat ::= z()
113+
| s(Nat)
114+
syntax Nat ::= add(Nat, Nat)
115+
116+
syntax State ::= state(Nat, Nat)
117+
118+
endmodule
119+
120+
module ADD-REWRITE
121+
122+
imports ADD-REWRITE-SYNTAX
123+
124+
rule [add-zero] : add(z(), N:Nat) => N
125+
rule [add-succ] : add(s(N:Nat), M:Nat) => add(N, s(M))
126+
127+
rule [state-next] : state(s(N:Nat), M:Nat) => add(s(N), M) ~> state(N, M)
128+
129+
rule [state-succ] : s(M:Nat) ~> state(N:Nat, _:Nat) => state(N, s(M))
130+
rule [state-zero] : z() ~> state(N:Nat, _:Nat) => state(N, z())
131+
132+
endmodule
133+
```
134+
135+
### Input
136+
137+
```
138+
state(s(s(z())), z())
139+
```
140+
### Commands to generate the Proof Trace in binary format
141+
142+
```Bash
143+
kompile add-rewrite.k --llvm-proof-hint-instrumentation
144+
krun input.add-rewrite --proof-hint > input.add-rewrite.hints
145+
```
146+
147+
### Commands to print the Proof Trace in human-readable format
148+
149+
```Bash
150+
kore-rich-header add-rewrite-kompiled/definition.kore > add-rewrite.header
151+
kore-proof-trace add-rewrite.header input.add-rewrite.hints --expand-terms --verbose
152+
```

0 commit comments

Comments
 (0)