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(Dolmen): Parse triggers from formula body #1051

Merged
merged 2 commits into from
Mar 14, 2024

Conversation

bclement-ocp
Copy link
Collaborator

@bclement-ocp bclement-ocp commented Mar 8, 2024

Triggers are annotated on the body of the quantifier, but Alt-Ergo looks them up on the quantifier itself. This used to be OK, because Dolmen used to copy tags from the body to the quantifier.

Since Gbury/dolmen#207 Dolmen no longer performs this copy, which means that we now ignore triggers (or rather, we use the triggers of the parent quantifier if it exists -- which is wrong).

This patch looks for trigger on the body instead, to be compatible with future Dolmen releases.

This patch also bumps the Dolmen version for obvious reasons.

See also: #1050

@bclement-ocp
Copy link
Collaborator Author

CI is failing due to #1052

| _ -> []
end
in
let trgs = root_trgs @ body_trgs in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To my understanding, root_trgs or body_trgs are disjoint? I understand you use the concatenation operator here because l @ [] and [] @ l are reduced immediately to l, but for sake of readability, I would prefer to match on the logic stored in the state of the typer as you did here:

let builtins =
  fun _st (lang : Typer.lang) ->
  match lang with
  | `Logic Alt_ergo -> ae_fpa_builtins
  | `Logic (Smtlib2 _) -> bv_builtins ++ smt_fpa_builtins
  | _ -> fun _ _ -> `Not_found

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to say that doing a concatenation this way is more robust to potential future Dolmen changes, but actually the code as written is buggy in the case of nested quantifiers in SMT (we pick up the pattern for both the outer and inner quantifier), good catch!

@bclement-ocp bclement-ocp force-pushed the dolmen-triggers-body branch 2 times, most recently from 41c4b0b to 0d54248 Compare March 13, 2024 11:10
@bclement-ocp
Copy link
Collaborator Author

Ready for round 2 - updated to dispatch trigger parsing depending on current language. This is a bit more involved because we needed to pass through the language information to the mk_expr function.

@bclement-ocp bclement-ocp requested a review from Halbaroth March 13, 2024 11:11
Halbaroth
Halbaroth previously approved these changes Mar 13, 2024
@Halbaroth
Copy link
Collaborator

It seems the CI still fails even after we have merged #1052. Do you know what's happening?

@bclement-ocp
Copy link
Collaborator Author

I think either the language attribute from Dolmen is wrong, or there are certain cases where Dolmen actually stores the annotations on the body of the trigger in AE format… looking into it.

@Halbaroth Halbaroth dismissed their stale review March 13, 2024 12:18

We have to check the CI.

@bclement-ocp
Copy link
Collaborator Author

bclement-ocp commented Mar 13, 2024

It seems the CI still fails even after we have merged #1052. Do you know what's happening?

Well it looks like what is happening is that the triggers are always on the body 😅

That's what I get for not double-checking this statement from a hallway conversation with @Gbury:

In the native format, triggers are annotated on the quantifier itself

(In hindsight, the fact that some AE tests were failing with our old code was suspicious)

Triggers are annotated on the body of the quantifier, but Alt-Ergo looks
them up on the quantifier itself. This used to be OK, because Dolmen
used to copy tags from the body to the quantifier.

Since Gbury/dolmen#207 Dolmen no longer performs
this copy, which means that we now ignore triggers (or rather, we use
the triggers of the parent quantifier if it exists -- which is wrong).

This patch looks for trigger on the body instead, to be compatible with
future Dolmen releases.

This patch also bumps the Dolmen version for obvious reasons.
@bclement-ocp bclement-ocp force-pushed the dolmen-triggers-body branch from c3b225c to c296019 Compare March 13, 2024 12:40
@bclement-ocp bclement-ocp changed the title fix(Dolmen): Parse triggers from formula body for SMT-LIB fix(Dolmen): Parse triggers from formula body Mar 13, 2024
@bclement-ocp
Copy link
Collaborator Author

Updated the patch to only look on the body for triggers and filters as per the AE parser in Dolmen. Also added more tests to cover success and failure cases in both formats.

@Gbury
Copy link
Collaborator

Gbury commented Mar 13, 2024

That's what I get for not double-checking this statement from a hallway conversation with @Gbury:

In the native format, triggers are annotated on the quantifier itself

Oops, sorry about that. Maybe I should try and add some documentation about that kind of things (but the question is then: where ?).

@bclement-ocp
Copy link
Collaborator Author

That's what I get for not double-checking this statement from a hallway conversation with @Gbury:

In the native format, triggers are annotated on the quantifier itself

Oops, sorry about that. Maybe I should try and add some documentation about that kind of things (but the question is then: where ?).

No worries; I think we were both confused between what Alt-Ergo does (it did check on the quantifier) and what the Dolmen parser for Alt-Ergo does (it annotates on the body).

We could probably add a note here; the SMT-LIB triggers is documented to be on the body but not the AE trigger.

(Both are used through here which mixes all these together even though they share many of the same fields)

Copy link
Collaborator

@Halbaroth Halbaroth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix and the clarification.

@bclement-ocp bclement-ocp merged commit 830917c into OCamlPro:next Mar 14, 2024
13 checks passed
@bclement-ocp bclement-ocp deleted the dolmen-triggers-body branch March 20, 2024 10:26
@bclement-ocp bclement-ocp added this to the 2.6.0 milestone Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants