# Creating a proof assistant for first order logic in Haskell

I am planning to implement a FOL proof assistant in Haskell. What are some useful libraries and implementations I should be looking at?

Here are some further details. I have a simple proof checker for propositional calculus implemented in Lean (see this and this). I am hoping to do the same for predicate logic. I then intend to create a proof assistant in Haskell and have the proofs created using it be exportable to a format that can be run through the Lean implementation of the checker. In this manner I hope to have a formal proof of the soundness of the trusted kernel, assuming that Lean is sound. The current state of this is here.

The issue at present is deciding if I should change to a different encoding for variables, for example locally nameless. The simplest to implement seems to be the substitution described here, but I am not certain if it has shortcomings that I have not seen yet.

• IMHO this question is slightly too broad for a good answer, can you be more specific? For instance, what background knowledge and/or familiar proof assistants you have, and what part (macroscopic design? specific implementation details?) you would like to know about.
– Trebor
Jun 18 at 4:42
• @Trebor Updated. Jun 18 at 5:16
• Do not write "EDIT" and stuff, just edit the question. Jun 18 at 10:24
• A "proof assistant" can mean many things. What mode of user interaction are you imagining? Would it be interactive, or would the proof assistant just process some files? Jun 18 at 10:32
• @AndrejBauer The proof checker in Lean would just process the files exported from the proof assistant as a final check. The proof assistant in Haskell would be interactive. Jun 18 at 16:02

Here's what uncle Google gave me:

It's difficult to give better advice since we do not know whether your project is just a hobby, a thesis, or a plan for world domination.

I am planning to implement a FOL proof assistant in Haskell. What are some useful libraries and implementations I should be looking at?

Does this do the Haskell part of what you need? I ask because as others have noted your question is seeking more of a compass direction than a destination.

Port of the Objective Caml code supporting John Harrison's logic textbook Handbook of Practical Logic and Automated Reasoning to Haskell. (GitHub)

The Code and resources for "Handbook of Practical Logic and Automated Reasoning" (link) has the original OCaml code used for the book.

• Thank you. That has actually been the primary reference for what I have so far. Jun 18 at 15:57
• What I have not been able to find in it is an algorithm for the substitution of predicates: proofassistants.stackexchange.com/questions/1487/… Jun 18 at 15:58
• I do have a copy that I bought. Jun 18 at 16:14
• Thank you for the link. I didn't realize there was also a port to Haskell. Jun 18 at 16:19
• Jun 18 at 16:21

So I think the biggest difference here from other questions is your implementation techniques don't necessarily have to be so restricted as implementation within proof assistants.

Consider the question How to deal with Binders? . In an implementation in Haskell you can use non strictly positive HOAS like

data Term :=
| Var String
| App Term Term
| Lam (Term -> Term)


Which is all sorts of weird from a formal semantics perspective.

Aside from not proving things I would say non strictly positive datatypes and general recursion are really the biggest simplifications from implementation within a theorem prover I guess. You can use mutable state and side effects to make some things faster but I'm not really sure they simplify things in the end.

You might also want to look into the trick GHC uses for lazily generating variable names by threading a lazy tree of variables through.

Also a tagless final style is a lot more useful in a language you don't have to prove things about (tagless final means you lose induction over things.)

Unfortunately I just personally don't have the practical experience to recommend specific libraries.