-
Notifications
You must be signed in to change notification settings - Fork 33
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
Fix issue 1099 #1102
Conversation
a55dcc8
to
1be1c40
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I think its worth adding a test with |
Dolmen should indeed aggregate together consecutive quantifications (assuming that there are no trigger annotations in the middle). |
I'll check, thanks ;) |
Dismissing approval due to changes to the PR and regressions
The new fix has been tested. We got +19-0. I believe that we lost these tests with Dolmen only. I did a mistake in the previous patch because I thought that So if you call
Dolmen generated the above term for the axiom I believe we should never get a non-toplevel forall binder with type variable. I added an assertion to enforce this invariant. I will run a last test on |
I don't think this should happen in smtlibv3 (but it's been a long time since I looked at its specification). However, one of the reasons that dolmen does not enforce type quantification at top-level is that there are a few cases where solvers might be able to / want to handle a type quantification that is not at top-level (or at least, that depends on the definition of top-level). For instance:
All in all, I think it's probably better to leave to solvers the task of defining which type quantifications they can handle ? But I'm open to suggestions, ^^ |
I agree. We should clarify what is supposed to be a top level formula in Alt-Ergo. I think we should test this PR on psmt2 files. |
The `D_cnf` module didn't use the flag `toplevel` as it was done in `Cnf`. This flag is important because the `Expr` AST doesn't store quantified type variables with binders as it does for the term variable. Instead, we use a `prenex polymorphism` approach, which means the quantified type variables are at the top level only. I believe this PR fixes the issue OCamlPro#1099.
Alt-Ergo only supports prenex polymorphism. This commit adds a failwith clause in `D_cnf` to enforce this property.
To clarify the meaning of
I also tested if we can quantify types in inner formula with the psmt format. We cannot! For instance, the following assertion (set-logic ALL)
(declare-sort t 1)
(declare-fun P (Int) Bool)
(assert (forall ((x Int))
(=> (P x)
(par (a) (forall ((x (t a)) (y (t a))) (= x y))))))
(check-sat) So the assertion I added in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor remarks.
It is worth running benchmarks again, just to be sure.
src/lib/structures/expr.mli
Outdated
An {e asserted formula} is a formula introduced by {e (assert ...)} or | ||
generated by a function definition with {e (define-fun ...)}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not familiar with the formatting {e ...}
for documentation, not sure what it does. Afaik brackets [...]
or [|...|]
are usually used for code.
cf: https://ocamlverse.net/content/documentation_guidelines.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{e ...}
emphasizes the text. I'm used to use brackets for OCaml code only but I haven't strong opinions on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use the bracket syntax in the last commit.
src/lib/structures/expr.mli
Outdated
By {e top level}, we mean that the quantified formula is not | ||
contained in another quantified formula, but the formula can be a | ||
subformula. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is confusing. Isn't a formula contained in another formula a subformula? Maybe we can use some clearer wording?
For example:
By {e top level}, we mean that the quantified formula is not | |
contained in another quantified formula, but the formula can be a | |
subformula. | |
By {e top level}, we mean that the quantified formula is not | |
a subformula of another quantified formula. |
Should suffice IMO.
The
D_cnf
module didn't use the flagtoplevel
as it was done inCnf
. This flag is important because theExpr
AST doesn't store quantified type variables with binders as it does for the term variable. Instead, we use aprenex polymorphism
approach, which means the quantified type variables are at the top level only.I believe this PR fixes the issue #1099. I'll check it on Marvin.
NB: I think this bug didn't make Alt-Ergo unsound.