|
1 | 1 | --- |
2 | | -sidebar_position: 5 |
| 2 | +sidebar_position: 1 |
3 | 3 | --- |
4 | 4 |
|
5 | 5 | # Debugging |
6 | 6 |
|
7 | | -TODO. |
| 7 | +Follow this guide if you are debugging verification with Caesar. |
| 8 | + |
| 9 | + |
| 10 | +## SMT Theories and Incompleteness {#incompleteness} |
| 11 | + |
| 12 | +[Expressions](../heyvl/expressions.md) are the main reason for *incompleteness* of Caesar, i.e. instances Caesar is unable to decide whether a given HeyVL program verifies or not. |
| 13 | +Caesar's incompleteness comes from incompleteness of the underlying SMT solver which is used to prove or disprove verification. |
| 14 | + |
| 15 | +At the moment, Caesar's translation of HeyVL verification problems is rather direct: most expressions are translated as one would intuitively expect. |
| 16 | +If operators have a direct correspondence in [SMT-LIB](https://smt-lib.org/), then we translate directly to those. |
| 17 | +Otherwise, usually only additional simple case distinctions are introduced. |
| 18 | +We have some more explanations in [Section 5 of our paper on HeyVL](https://arxiv.org/pdf/2309.07781#page=23). |
| 19 | + |
| 20 | +As a consequence, it is usually pretty simple to predict which [SMT-LIB theories](https://smt-lib.org/theories.shtml) will be used for the SMT query done by Caesar. |
| 21 | +[Caesar supports Z3 probes](#z3-probes) to help you check in which theory your problem falls. |
| 22 | +Also refer to the [Z3 documentation on arithmetic theories](https://microsoft.github.io/z3guide/docs/theories/Arithmetic/), since a lot of Caesar's reasoning will need arithmetic. |
| 23 | + |
| 24 | +Here are some rules of thumb for (in-)completeness: |
| 25 | + * Linear integer and real arithmetic (QF_LRA, QF_LIRA) is decidable. |
| 26 | + * Nonlinear integer arithmetic (QF_NIA) is undecidable. |
| 27 | + * Nonlinear real arithmetic (QF_NRA) is decidable for algebraic reals. |
| 28 | + * Quantifiers usually introduce undecidability, although there are [a bunch of strategies and fragments in Z3 that allow decidability](https://microsoft.github.io/z3guide/docs/logic/Quantifiers#model-based-quantifier-instantiation). |
| 29 | + * In particular, restrictive [quantifier triggers](../heyvl/expressions.md#triggers) can help e-matching prove many instances. |
| 30 | + * HeyVL's [quantitative quantifiers](../heyvl/expressions.md#quantifiers) (`inf` and `sup`) currently have a very naive default encoding that is problematic for Z3. If the quantitative quantifiers cannot be eliminated by Caesar's quantifier elimination (QE) procedure, then they are often a cause of nontermination of Caesar. |
| 31 | + * Quantitative quantifiers also come from the semantics of [`havoc` and `cohavoc`](../heyvl/statements.md#havoc). However, for e.g. the [induction-based proof rules](../proof-rules/induction.md), the HeyVL encodings fall into a fragment where Caesar's QE applies and the generated quantifiers are eliminated. |
| 32 | + * In practice, the SMT solver can often *prove* correctness, but it often has problems with *refutations* (i.e. providing counter-examples). |
| 33 | + |
| 34 | + |
| 35 | +### Z3 Probes |
| 36 | + |
| 37 | +Caesar supports the use of [Z3's *probes*](https://microsoft.github.io/z3guide/docs/strategies/probes/) to quickly help you determine performance-relevant properties about the SMT query, such as the presence of quantifiers or the theoretical complexity of the problem. |
| 38 | + |
| 39 | +Run Caesar with the `--probe` flag to enable probes. |
| 40 | +Caesar will print an output of the following form to standard error: |
| 41 | + |
| 42 | +``` |
| 43 | +Probe results for test.heyvl::test: |
| 44 | +Has quantifiers: false |
| 45 | +Detected theories: NIRA |
| 46 | + - complexity: Undecidable |
| 47 | + - rejected theories: LRA, LIA, LIRA, NRA, NIA |
| 48 | +Number of arithmetic constants: 1 |
| 49 | +Number of Boolean constants: 4 |
| 50 | +Number of bit-vector constants: 0 |
| 51 | +Number of constants: 1 |
| 52 | +Number of expressions: 71 |
| 53 | +``` |
| 54 | + |
| 55 | +The tool also tries to compute the complexity class of the problem to help you determine whether a problem is "easy". |
| 56 | + |
| 57 | +## Further Reading |
| 58 | + |
| 59 | + * [Dafny's guidelines for verification](https://dafny.org/dafny/DafnyRef/DafnyRef.html#sec-verification) can be helpful. |
| 60 | + Many of the ideas translate pretty much directly to Caesar. |
0 commit comments