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

Adding FP Library of the SMTLIB #28

Closed
bobot opened this issue Apr 10, 2020 · 10 comments
Closed

Adding FP Library of the SMTLIB #28

bobot opened this issue Apr 10, 2020 · 10 comments

Comments

@bobot
Copy link
Contributor

bobot commented Apr 10, 2020

I'm proposing to do it, but I prefer to check that someone else is not doing it. I think I will take inspiration from the BV theory which also a family of types indexed by integers, but is there any other advice?

PS: Dolmen is really really great! I still don't understand why builtins are not exported in Dolmen.Expr, how should we match the different ids when going through the typed expressions?

@c-cube
Copy link
Collaborator

c-cube commented Apr 10, 2020

I think it's safe to say @Gbury isn't working on it 🙂
Are you writing SMT solvers in OCaml, still, @bobot ?

@Gbury
Copy link
Owner

Gbury commented Apr 10, 2020

I can confirm that I'm not working on it, so if you have the time and motivation, that's great !

For writing the theory, I would give the following advices:

  • get inspiration from the other theories written for smtlib
  • add together with the theory implementation the reference description of the theory from smtlib (i.e. the fp.smt2 file describing the theory). It helps having it directly next to the implementation and when/if it changes, diffing the new version will help upgrading the theory.
  • but most of all, give attention to the error cases, as can be seen in other theories, the code handling the error cases takes quite a lot of place (and time to write), but it is very important, hence why there are quite a lot of helper functions in the base.ml file that you can probably re-use as much as possible (for checking arity, dealing with associative and/or chainable operations, etc...).

The fact that builtins are not exported in Dolmen.Expr is clearly a mistake. As you say, the goal is indeed to match on these builtins as much as possible (rather than testing equality of declared symbols). I'll try and fix it asap, ^^

@bobot
Copy link
Contributor Author

bobot commented Apr 10, 2020

It is for COLIBRI, we have an OCaml to Prolog bridge, so since our previous prolog parser was flaky, using dolmen is more than a bliss.

Thanks for the advices @Gbury!

@c-cube
Copy link
Collaborator

c-cube commented Apr 10, 2020

Good to hear. Is colibri amenable to be re-written in OCaml, or is it too big a stretch? :p

@bobot
Copy link
Contributor Author

bobot commented Apr 10, 2020

Not in OCaml too easy, in Why3 it is better 😉

@Gbury
Copy link
Owner

Gbury commented Apr 11, 2020

@bobot I just pushed bbbe607 which exports and documents the builtins in Dolmen.Expr. Don't hesitate to make any remarks about it, ^^

@Gbury
Copy link
Owner

Gbury commented Apr 11, 2020

Additionally, do you think dolmen should to export the following function (It basically tries and match the type of a term with a bitvector type and if successful extracts the length of the bitvector), or do you think it is simple enough that users can re-implement their variant of it (returning an option, or some other error) ?

dolmen/src/standard/expr.ml

Lines 2109 to 2112 in bbbe607

let match_bitv_type t =
match ty t with
| { descr = App ({ builtin = Bitv i; _ }, _); _ } -> i
| _ -> raise (Wrong_type (t, Ty.bitv 0))

@bobot
Copy link
Contributor Author

bobot commented Apr 14, 2020

I think it is not necessary, because I think in most use cases one will match on all the possible builtin at the same time.

@bobot
Copy link
Contributor Author

bobot commented Apr 14, 2020

The MR #31 should implement the theory.

@bobot
Copy link
Contributor Author

bobot commented Apr 28, 2020

I have some small fixes that I will MR in bulk once when COLIBRI+dolmen works fully.

@Gbury Gbury closed this as completed in cc25652 May 15, 2020
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

No branches or pull requests

3 participants