Module Proof


module Proof: sig .. end
The representation and checking of proofs

val checkProofs : bool Pervasives.ref
Whether to check the proofs
val printMagicProofWarning : bool Pervasives.ref
Whether to print warnings for Magic proofs

type parg =
| I of int
| S of string
| E of Logic.exp
| P of proof
| F of Logic.pred

type proof =
| Hyp of Util.symbol
| Truei
| Falsee of proof (*False elimination, if we have a proof of false*)
| Andi of proof list (*Proves Andp1; p2; ... *)
| Ande of int * proof (*Ande (i,pf) is a proof of p when pf is a proof of And ps, where List.nth ps i = p*)
| Alli of Logic.var * proof
| Alle of Logic.exp * proof
| Existe of Logic.var * proof
| Impi of Util.symbol * Logic.pred * proof
| Impe of proof * proof
| Contra of Util.symbol * Logic.pred * proof
| G of string * parg list
| Refl of Logic.exp
| Symm of proof (*Symm p proves e1=e2 if p:e2=e1*)
| Trans of Logic.exp * proof * proof (*Trans(et, p1t, p2t) proves e1=e2 if p1t:e1=et, pt2:et=e2*)
| Cong of Logic.exp * Logic.exp * proof list (*Cong [pf] proves Unop e1 = Unop e2 if pf proves e1 = e2; Cong [pf1; pf2] proves Binop (a1,b1) = Binop (a2,b2) if pf1 proves a1=a2 and pf2 proves b1=b2; Cong pfs proves Fun(f,as) = Fun(f,bs) if pfs.(n) proves as.(n) = bs.(n)

Note that each subproof of equality is really a proof of (Var 0)=(Var 1) in the context in which (Var 0) and (Var 1) are replaced with the two things in their appropriate contexts.

*)
| WithLemma of Util.symbol * Logic.exp list * proof list
| UnrollPDef of Logic.pred * proof
| UnrollEDef of Logic.pred * string * proof
| RollEDef of Logic.pred * string * proof
| Arith of Logic.exp * Logic.exp (*Check that e = e' by verifying that (e - e') mod32 = 0 using the rules of algebra.*)
| ArithNeq of int * Logic.exp * Logic.exp (*Check that e <> e' by verifiying that e - e' mod32 = i (i <> 0) using the rules of algebra*)
| ArithApart of int * Logic.exp * Logic.exp (*ArithApart(r, e1, e2) means that e1 - e2 = r and (-4 >= r or r >= 4).*)
| ArithGeq of int * Logic.exp * Logic.exp (*Check that e >= e', by verifying that e - e' = i and i >= 0. !!! This is unsound in presence of overflow. We'll have to clean this up.*)
| ArithGt of int * Logic.exp * Logic.exp (*Check that e >= e', by verifying that e - e' = i and i > 0. !!! This is unsound in presence of overflow. We'll have to clean this up.*)
| SelUpd0 of Logic.exp * Logic.exp * Logic.exp
| SelUpd1 of Logic.exp * Logic.exp * proof
| Magic of string * Logic.pred (*These are proofs that are allowed to go through the proof checker, with a warning. Pass a string to identify this magic*)
| MagicLemma of lemma (*A magic proof of a lemma*)
| Unimplemented of string

type lemma = {
   lname : Util.symbol;
   lvars : string list;
   lhyps : Logic.pred list;
   lconc : Logic.pred;
}
val infer : Logic.var list ->
(Util.symbol * Logic.pred) list -> proof -> Logic.pred
val check : Logic.var list ->
(Util.symbol * Logic.pred) list -> proof -> Logic.pred -> unit
val registerLemma : lemma -> proof -> unit
Register a lemma, along with its proof
val registeredLemmas : unit -> lemma list
val findRegisteredLemma : Util.symbol -> lemma
type edef = string * string list * Logic.exp 
Expression definitions. The name of the defined constructor (use a lowercase name), the list of formals, and the body, referring to the formals using deBruijn indices.
type pdef = string * string list * Logic.pred 
val registerEDef : edef -> unit
Register an expression definition
val registerPDef : pdef -> unit
Register a predicate definition
val mkContraProof : Util.symbol -> Logic.pred -> proof -> proof
Make a proof by contradiction
val d_prf : unit -> proof -> Pretty.doc
val dpa : parg -> Pretty.doc
val printer : Logic.logicPrinter Pervasives.ref
We can install a new printer for the Proof module
val allEDefs : (string, edef) Hashtbl.t
These are exported temporarily
val allPDefs : (string, pdef) Hashtbl.t
val allLemmas : lemma Inthash.t
val init : unit -> unit
Initialize the proof module
val snapshot : unit -> unit -> unit
Take a snapshot of the state of the proof module. The only state is the set of registered lemmas and constructors
val findLemma : lemma -> unit
val registeredLemmas : unit -> lemma list
val makeExistVar : string -> Logic.exp