Basic file reading plugin infrastructure set up #13
Replies: 2 comments 5 replies
-
Maybe we should only do this with Coq and OCaml, because OCaml already has good bindings for LLVM, and thus we can verify our OCaml code (https://foobar-land.github.io/coq-of-ocaml/)? Also, I don't think that writing the Coq plugin is a good idea, I suppose that this is an overcomplication. Therefore, the solution from #10 is different from the plugin example. |
Beta Was this translation helpful? Give feedback.
-
I've been working on this. I have a tiny bit of rust that does both parsing from text to syntax trees and rendering from syntax trees to llvm. I have enough plumbing working to check the trees in coq, currently working on plumbing to add coq vernacular to trigger the rendering. Hopefully will have it in good enough shape to send a PR in a week or two. Here's my development branch: https://github.com/jeremyschlatter/magmide/tree/parser |
Beta Was this translation helpful? Give feedback.
-
Hello!
Today I managed to get a little proof of concept working, one that lays a simple foundation for the first intended phase of the project. The ocaml code in
plugins
creates a coq plugin that can read from source files and use the contents to create coq definitions. If you look attheory/test.v
you can see theMagmide
command being used, as it reads fromsomething.mg
and uses the contents to create a coq expression defined under the nameyo
, which you can then prove things about. Rundune build
to compile the project.The goal here is to allow magmide source code to be parsed from files and ingested into Coq to prove things about functions. The final version of the plugin will likely accept multiple identifiers after the
use
to ingest multiple functions from the same file, and of course all the parsing and transformation is completely undone.The next bit of plumbing work is figuring out a rust program that can accept the parsed syntax trees and emit llvm from them. Just figuring out the plumbing is all that we need, the llvm generated doesn't have to be interesting, but we do need the ability to inspect/walk the parsed ast. It might make sense to do the parsing with rust, but in general we should avoid transforming back and forth between different syntax trees, and since in order to prove things about the ast in Coq it has to be representable as ocaml values, then even if the parsing is done in rust it should produce ocaml values.
https://docs.rs/ocaml/latest/ocaml/
https://github.com/TheDan64/inkwell
Here are the guides I used to get my ocaml/opam/dune/coq environment set up. Watch out for opam switches, I wasted a lot of time reinstalling packages twice after accidentally switching to an old version of ocaml.
https://opam.ocaml.org/doc/Install.html
https://ocaml.org/docs/install.html
https://coq.inria.fr/opam-using.html
Beta Was this translation helpful? Give feedback.
All reactions