OCamlPro / alt-ergo

OCamlPro public development repository for Alt-Ergo
https://alt-ergo.ocamlpro.com/
Other
130 stars 33 forks source link

feat(shostak): Transparent abstracted constants #1198

Open bclement-ocp opened 1 month ago

bclement-ocp commented 1 month ago

This patch introduces a new type of leaf in the Shostak module, called abstract leaves. Abstract leaves behave like constant terms, and are intended to replace the X.term_embed (E.fresh_name ty) pattern where possible.

An abstract leaf is created by calling X.abstract on an existing semantic value r. The abstract leaf X.abstract r is automatically defined to be equal to r when processed by the Uf and Ccx modules.

The benefits of abstract leaves over fresh term constants are twofold:

Abstract leaves are currently only used by the AC theory. In the future, it is intended to be used as a basis for implementing application of interpreted-but-not-solvable functions to semantic values (so that for instance we can denote bv2nat(r) where r is a semantic value). While it would be straightforward to adapt abstract leaves to be able to create terminal leaves for bv2nat(r) (without definitional equations), we want congruence closure and computation (so that bv2nat(x @ y) automatically becomes bv2nat(x) * 2^n + bv2nat(y)) to work for such leaves. This require additional adaptations to CC(X), and is expected to need abstract leaves to enforce an AC(X)-compatible ordering.

bclement-ocp commented 1 month ago

I expected this to have little to no impact but there seems to be some regressions on the internal dataset. I don't think we need it for 2.6.0 as the follow-up won't be complete by then, so I'm marking the PR as draft for now and will revisit in the next release cycle.

Halbaroth commented 1 month ago

Do you want my review? I was reviewing it yesterday.

bclement-ocp commented 1 month ago

Sure — I think it will be mostly identical once it is posted again, but I want to make sure I understand the regressions better. If needed we will keep fresh_ac_name for AC abstractions and use the new mechanism for new abstractions.