This is an overview of a theorem proving project in Haskell, carried out by Pritam Choudhury (pritam) and Yao Li (liyao) as part of the coursework for CIS 552.
The following libraries are needed for running the programs.
cabal install pretty-tree
cabal install singletons
This project develops a theorem proving framework for intuitionistic and classical propositional logics in Haskell. For formalising these logics, we used the sequent style approach, meaning the theorems are sequents where the antecedent of the sequent is the list of hypotheses and the succedent of the sequent is the thesis. There are two well-known methods that formalises logical theorems as sequents. One of them is the Natural Deduction style, the other is the Gentzen style. We implemented both of them.
For formalising in either style, we first need to encode the rules of inference. The rules of inference can be encoded as partial functions on sequents or as constructors of an inductive data structure.
The implementation using functions is carried out in FunImpl. This folder has
three files:
- The file
NDed.hscontains the rules of inference represented as partial functions. - The file
NDedTheorems.hscontains some theorems proved using the rules of inference exported fromNDed.hs. - The file
NDedTests.hscontains unit tests checking the output of the functions (representing theorems) developed inNDedTheorems.hs.
The functional implementation is a bit verbose and less expressive. We can overcome these problems by encoding the rules of inference as constructors of an inductive data structure. We explore two ways in which this can be acheived.
In the first approach, we construct a new kind, Formula, the type of all
formulas. With this, we can construct an inductive data structure that contains
all the rules of inference. So the language is now more expressive, and the proofs
are shorter.
This is implemented in FmlKind. This folder has five files:
- The file
Basic.hscontains the basic definitions for this approach. - The file
GentzenCPL.hscontains the Gentzen style rules for classical propositional logic. - The file
GentzenCPLTheorems.hscontains some theorems proved using the rules specified inGentzenCPL.hs. - The file
GentzenIPL.hscontains the Gentzen style rules for intuitionistic propositional logic. - The file
GentzenIPLTheorems.hscontains some theorems proved using the rules specified inGentzenIPL.hs.
To support printing for the proof-trees we generate, we have Printing.
FunImpl and FmlKind use this folder. This folder contains two files:
- The file
ProofTree.hsbuilds upon thepretty-treeprinting library for printing the proof trees. - The file
Proof.hsdefines some higher-order functions that transform rules of inference into combinators for proof-trees.
By creating ProofTree as another layer of abstraction, our FunImpl approach
and FmlKind approach can share the same proof-tree printing utility.
In the Formula as Kind approach, we can't populate the individual formulas
with terms. So we explore a second approach that enables us to do so. In this
approach, Formula is a type constructor of kind * -> * . The individual
formulas are Haskell types and as such, we can populate them with terms. So
we can have derivations (using just the rules of inference) and evidence (by
looking inside the types or formulas) in the same setting.
This is implemented in FmlTypeConstr. This folder has seven files:
- The file
Basic.hscontains the basic definitions for this approach. - The file
NDedInt.hsandNDedCl.hscontain the natural deduction style rules for intuitionistic logic and classical logic respectively, along with some example theorems. - The file
GStyleInt.hsandGStyleCl.hscontain the Gentzen style rules for intuitionistic logic and classical logic respectively, along with some example theorems. - The file
ProofObjects.hscontains the intuitionistic natural deduction rules along with the corresponding proof-objects and some example theorems. - The file
Provability.hsimplements evidence based proving of intuitionistic theorems.
The Main.hs file implements an interactive program that shows some sample
results.