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

Add support for let .. in constructions in Z3 backend #434

Merged
merged 7 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions compiler/verification/z3backend.real.ml
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,14 @@ and translate_expr (ctx : context) (vc : typed expr) : context * Expr.expr =
args (ctx, [])
in
ctx, Expr.mk_app ctx.ctx_z3 fd z3_args
| EAbs { binder; _ } ->
let vars, _ = Bindlib.unmbind binder in
if Array.length vars != 1 || List.length args != 1 then
failwith "[Z3 encoding] EAbs not supported beyond let_in"
else
let arg = List.hd args in
let expr = Bindlib.msubst binder [| Marked.unmark arg |] in
R1kM marked this conversation as resolved.
Show resolved Hide resolved
translate_expr ctx expr
| _ ->
failwith
"[Z3 encoding] EApp node: Catala function calls should only include \
Expand Down
23 changes: 23 additions & 0 deletions tests/test_proof/bad/let_in_condition-empty.catala_en
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Test

```catala
declaration scope A:
context x content boolean

scope A:
definition x under condition
let y equals false in
y
consequence equals true
```

```catala-test-inline
$ catala Proof --disable_counterexamples
[ERROR] [A.x] This variable might return an empty error:
┌─⯈ tests/test_proof/bad/let_in_condition-empty.catala_en:5.10-11:
└─┐
5 │ context x content boolean
│ ‾
└─ Test
Counterexample generation is disabled so none was generated.
```
17 changes: 17 additions & 0 deletions tests/test_proof/good/let_in_condition.catala_en
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Test

```catala
declaration scope A:
context x content boolean

scope A:
definition x under condition
let y equals true in
y
consequence equals true
```

```catala-test-inline
$ catala Proof --disable_counterexamples
[RESULT] No errors found during the proof mode run.
```