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

Fix issue 1099 #1102

Merged
merged 6 commits into from
Jun 11, 2024
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
12 changes: 9 additions & 3 deletions src/lib/frontend/d_cnf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1472,8 +1472,14 @@ let rec mk_expr
) body binders

| Binder ((Forall (tyvl, tvl) | Exists (tyvl, tvl)) as e, body) ->
if tvl == []
then (Cache.store_tyvl tyvl; aux_mk_expr ~toplevel body)
if not toplevel && tyvl != [] then
Fmt.failwith "Non-prenex polymorphism in the term %a"
DE.Term.print term
else if tvl == []
then begin
Cache.store_tyvl tyvl;
aux_mk_expr ~toplevel:true body
end
else
let name =
if !name_tag = 0 then name_base
Expand Down Expand Up @@ -1518,7 +1524,7 @@ let rec mk_expr
end
in
let in_theory = decl_kind == E.Dtheory in
let f = aux_mk_expr ~toplevel body in
let f = aux_mk_expr ~toplevel:false body in
let qbody = E.purify_form f in
(* All the triggers that are encoutered at this level are assumed
to be user-defined. *)
Expand Down
19 changes: 18 additions & 1 deletion src/lib/structures/expr.mli
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,24 @@ and quantified = private {
(** The underlying formula. *)

toplevel : bool;
(** Determine if the quantified formula is at the top level.
(** Determine if the quantified formula is at the top level of an asserted
formula.

An {e asserted formula} is a formula introduced by [(assert ...)] or
generated by a function definition with [(define-fun ...)].

By {e top level}, we mean that the quantified formula is not
a subformula of another quantified formula.

For instance, the subformula ∀y:int. ¬G(y) of the asserted formula
¬(∀y:int. ¬G(y)) is also considered at the top level.

Notice that quantifiers of the same kind are packed as much as possible.
For instance, if we assert the formula:
∀α. ∀x:list α. ∃y:α. F(x, y)
Then the two universal quantifiers are packed in a same top level formula
but the subformula ∃y:α. F(x, y) is not at the top level.

This flag is important for the prenex polymorphism.
- If this flag is [true], all the free type variables of [main]
are implicitely considered as quantified.
Expand Down
272 changes: 271 additions & 1 deletion tests/dune.inc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions tests/issues/1099.ae
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type 'a t
logic p : 'a t, unit -> prop
logic f : 'a t -> prop
logic r : unit t

axiom a : forall s:'a t. exists n:unit. p(s, n)

goal g : f(r)
2 changes: 2 additions & 0 deletions tests/issues/1099.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

unknown
Loading