3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-06-13 20:35:39 +00:00

SMT2 front-end: accept HO_ALL and normalize curried expression-head applications (#9636)

The SMT2 front-end rejected valid higher-order inputs using `HO_ALL` and
failed on curried applications where the function position is itself an
expression (e.g., `((transfer top) 0)`).
This update adds `HO_ALL` support and makes curried parsing consistently
lower to implicit `select` chains.

- **Logic recognition**
  - Treat `HO_ALL` as an `ALL`-class logic in SMT logic classification.
- This unblocks `(set-logic HO_ALL)` in the standard SMT2 command path.

- **Curried application parsing**
- Extend application-frame handling to support parenthesized expression
heads, not only symbol heads.
- When the head is an expression, parse application arguments normally
and construct nested implicit selects:
    - `(f a b)` → `(select (select f a) b)`
- Preserve existing behavior for symbol-based applications, qualified
identifiers, and lambda-led forms.

- **Regression coverage**
- Add a focused parser/eval regression using the reported higher-order
case to lock in behavior.

```smt2
(set-logic HO_ALL)
(declare-fun transfer () (-> (-> Int Bool) (-> Int Bool)))
(assert (forall ((P (-> Int Bool))) (=> (P 0) ((transfer P) 0))))
(declare-fun top () (-> Int Bool))
(assert (forall ((x Int)) (top x)))
(assert (not ((transfer top) 0)))
(check-sat)
```

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
Copilot 2026-05-26 18:39:38 -07:00 committed by GitHub
parent 73151f1960
commit 316d249b3f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 84 additions and 22 deletions

View file

@ -160,6 +160,22 @@ void test_repeated_eval() {
Z3_del_context(ctx);
}
void test_ho_curried_application() {
char const* spec =
"(set-logic HO_ALL)\n"
"(declare-fun transfer () (-> (-> Int Bool) (-> Int Bool)))\n"
"(assert (forall ((P (-> Int Bool))) (=> (P 0) ((transfer P) 0))))\n"
"(declare-fun top () (-> Int Bool))\n"
"(assert (forall ((x Int)) (top x)))\n"
"(assert (not ((transfer top) 0)))\n"
"(check-sat)\n";
Z3_context ctx = Z3_mk_context(nullptr);
Z3_set_error_handler(ctx, setError);
test_eval(ctx, spec, false);
Z3_del_context(ctx);
}
void test_name(Z3_string spec, Z3_string expected_name) {
Z3_context ctx = Z3_mk_context(nullptr);
Z3_set_error_handler(ctx, setError);
@ -289,6 +305,7 @@ void tst_smt2print_parse() {
// Test ?
test_repeated_eval();
test_ho_curried_application();
test_symbol_escape();