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 a mode to sercomp to get rid of all notations #196

Closed
vsiles opened this issue Mar 4, 2020 · 14 comments
Closed

Adding a mode to sercomp to get rid of all notations #196

vsiles opened this issue Mar 4, 2020 · 14 comments

Comments

@vsiles
Copy link

vsiles commented Mar 4, 2020

Hi !
Do you know how complex it would be to extend sercomp with a mode that strips a vernacular expression of all notations ? The end goal here is to train an algorithm without having to deal/depend on user notations, feeding it only notation free expressions.

To my knowledge there is currently no option to do that (and coqc -beautify is quite broken). I'm not familiar with Coq plugin development, but if you think that's not a huge task, I might be able to help implementing it.

Just asking :)

Best,
V.

@ejgallego
Copy link
Collaborator

Hi @vsiles ,

that's a tricky question; indeed it may be doable but there are several approaches:

@vsiles
Copy link
Author

vsiles commented Mar 5, 2020

It looks like the discussion hit a dead end last year. Do you think with some external use cases we could get new traction on that direction ? It looks like a promising step towards ejgallego/coq-lsp#331 . In the meantime, I'll get a bit more familiar with 2020's Coq internals, see if I can provide more than just a use case :)

@vsiles
Copy link
Author

vsiles commented Mar 5, 2020

By the way, it really looks like ejgallego/coq-lsp#331, so feel free to close and move the discussion there

@vsiles
Copy link
Author

vsiles commented Mar 5, 2020

Since it's still open, I'm taking the opportunity to ask an implementation question: in vsiles@e456953 I quickly hacked what I think could be the "notation erasure" function.

As you can see there's a message when I run the new binary:

[sertop] Critical Dynlink error implementation mismatch on
Serlib__Ser_names

Does that ring any bell ?

Also, do you think that's the way to go ?

@ejgallego
Copy link
Collaborator

The main blocker for ejgallego/coq-lsp#331 was actually designing a flexible protocol so "internalization" [the part of the elaboration that deals with notations] would be available in some contexts.

A really big problem with exposing internalization for vernaculars is that they don't really have an internalized form in the syntax, as of today internalization of commands happens internally so we don't have a VernacDefinition ready in Coq that would allow us to modify the output format as a parameter. We can try some things in this regard, but maybe the solution in the CEP is the right one [but quite costly to implement].

@ejgallego
Copy link
Collaborator

Does that ring any bell ?

Umm, it seems you are using an incomplete build? Does it work if you do dune build before?

@ejgallego
Copy link
Collaborator

ejgallego commented Mar 5, 2020

Also, I recommend you place the functions in a separate module from the beginning.

@vsiles
Copy link
Author

vsiles commented Mar 6, 2020

Does that ring any bell ?

Umm, it seems you are using an incomplete build? Does it work if you do dune build before?
So I move the code into its own module and tried again, still got this dll message:

$ eval $(opam env)
$ dune build
$ ./_build/default/sertop/sercomp.exe -Q ..,Temp --input=vernac --mode=print --omit_loc ../toto.v
[sertop] Critical Dynlink error error loading shared library: Dynlink.Error (Dynlink.Cannot_open_dll "(Failure\n   \"dlopen(/Users/vsiles/.opam/coq/lib/coq-serapi/serlib/ground_plugin/serlib_firstorder.cmxs, 10): Symbol not found: _camlSerlib__Ser_loc__fun_1223\\\n  \\n  Referenced from: /Users/vsiles/.opam/coq/lib/coq-serapi/serlib/ground_plugin/serlib_firstorder.cmxs\\\n  \\n  Expected in: flat namespace\\\n  \\n in /Users/vsiles/.opam/coq/lib/coq-serapi/serlib/ground_plugin/serlib_firstorder.cmxs\")")
Inductive foo :=
  | X : _
  | Y : _.
Notation "'A'" := X.
Definition X0 := X.
Definition X1 := X.
$ coqc --version
The Coq Proof Assistant, version 8.11.0 (March 2020)
compiled on Mar 5 2020 8:39:08 with OCaml 4.08.1
$ dune --version
2.3.1
$ ocamlc --version
4.08.1

It seems to run ok... I was usually building using make. I have the same results with make and dune build directly.

EDIT: I have serapi installed in my opam switch too. Maybe it's getting confused between the local version I'm building and the one in opam ? I'll try to remove it

EDIT2: I removed serapi from my opam switch, now it doesn't run at all:

$ make clean
$ make
$ ./_build/default/sertop/sercomp.exe -Q ..,Temp --input=vernac --mode=print --omit_loc ../toto.v
Error:
       Cannot link ml-object ground_plugin.cmxs to Coq code (Fl_package_base.No_such_package("coq-serapi.serlib.ground_plugin", "")).

@ejgallego
Copy link
Collaborator

@ejgallego
Copy link
Collaborator

Installing into the opam switch will make the default paths work, however plugins will become out of date the moment you rebuild and the interface changes [so you need to reinstall again]

@vsiles
Copy link
Author

vsiles commented Mar 6, 2020

got it running fine with dune, thanks !

@vsiles
Copy link
Author

vsiles commented Apr 6, 2020

@ejgallego Ok, my attempt seems to work "kind of"... but there's some cases where it doesn't work at all (involving inductive types e.g., not sure what's wrong).

What would be the best way to contact Coq devs and see what they think of it ? Coq-club, an issue on github ?

@ejgallego
Copy link
Collaborator

For these kind of questions Gitter may be the perfect spot.

@ejgallego
Copy link
Collaborator

Duplicate of ejgallego/coq-lsp#331

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

2 participants