Open jespercockx opened 1 year ago
For the purposes of integrating with agda2hs, we should consider Schmitty as two different projects:
Currently, Schmitty has tactics for Z3 and CVC4. Adding bindings for other SMTLIB-compatible solvers is very easy and can be done in only a few lines of code. It's only a matter of crafting the right command-line invocation—the rest is boilerplate. For an example, see Z3.agda.
Currently, Schmitty supports reasoning about naturals, integers, and reals.
Adding support for new theories is possible, but the amount of work will vary with the complexity of the theory. For a theory that is directly supported by SMITLIB, such as integers, you have to specify:
For a theory that uses some sort of encoding, such as the theory of naturals, you also have to specify that encoding.
Support algebraic datatypes should be fairly simple to add, as it was officially added to SMTLIB in version 2.5. This wouldn't be the same as adding a theory, since datatypes are declared by a declare-datatype
statement, which would mean extending the Script type. This should be relatively easy, but may involve some complications depending on how precise you want to be about enforcing that the script type is well-scoped by construction.
Schmitty is stable, but there is a pending refactoring to use composible languages following composable-semantics.
agda2hs
The major difficulties I foresee is that Schmitty relies on the standard library and agdarsec. I assume agda2hs
has its own standard library, which is presumably incompatible with the Agda standard library.
Schmitty's use of the standard library is fairly minimal, and it could probably be rewritten to only use Agda builtin modules.
I believe agdarsec
is very tightly coupled with the standard library, so for Schmitty to be portable across different standard libraries we would probably have to:
Why this would be different from regular Agda? I thought that most of such proofs would be erased anyway.
Yes, the proofs would indeed be erased. What does need to be done are the issues Wen lists above: the dependencies on stdlib and agdarsec, and the work of mapping the types and functions in the Agda2Hs prelude to the appropriate SMT theories.
@jespercockx Could not agda-stdlib
be mapped instead? I understand that is not in the paper, but I do not understand why. Like code base already has some lists for specific types translation, could not some pragma or typeclass be used to define new Agda -> Haskell translations for terms of well-known Agda libs?
@jespercockx Could not
agda-stdlib
be mapped instead? I understand that is not in the paper, but I do not understand why. Like code base already has some lists for specific types translation, could not some pragma or typeclass be used to define new Agda -> Haskell translations for terms of well-known Agda libs?
That'd work, but then you still can't use Schmitty with conventional agda2hs, right?
It would be very useful if one could use Z3 or another SMT solver to automatically dismiss proof obligations for obvious statements. There is already such an integration with Agda: Schmitty (https://github.com/wenkokke/schmitty/). We should check what is needed to integrate Schmitty into an Agda2Hs project and whether we can do anything to make it easier to use (e.g. provide predefined theories for types and functions from the Prelude).