started work on metas
This commit is contained in:
parent
2c380ad564
commit
68a7cafd8e
|
@ -10,6 +10,11 @@ A "proof assistant" with holes and implicit arguments. Developed to learn about
|
|||
|
||||
# TODO
|
||||
|
||||
* Figure out representation of metas
|
||||
* Types needed for stuck values and typed conversion
|
||||
* Meta has value or other meta for type?
|
||||
* Where to put this file?
|
||||
|
||||
* Raw syntax
|
||||
* Parser (BNFC)
|
||||
|
||||
|
|
2
bin/dune
2
bin/dune
|
@ -1,4 +1,4 @@
|
|||
(executable
|
||||
(public_name implicitt)
|
||||
(name main)
|
||||
(libraries Core Raw Parse))
|
||||
(libraries Core Raw))
|
||||
|
|
10
lib/Core/Common.ml
Normal file
10
lib/Core/Common.ml
Normal file
|
@ -0,0 +1,10 @@
|
|||
(* number ; is-hole? *)
|
||||
type meta = Mv of int * bool
|
||||
|
||||
|
||||
let cMV : int ref = ref 0
|
||||
|
||||
let getCMV (_ : unit) =
|
||||
let c = ! cMV in
|
||||
cMV.contents <- c + 1;
|
||||
c
|
|
@ -9,6 +9,7 @@ let rec index (env : V.env) (i : int) =
|
|||
let rec eval (env : V.env) (tr : T.term) =
|
||||
match tr with
|
||||
| Var (Ix i) -> index env i
|
||||
| Mv m -> V.Stuck (V.Meta m, ?)
|
||||
| Type -> V.Type
|
||||
| T0 -> V.T0
|
||||
| Ind0 (B b, t) -> begin
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
module C = Common
|
||||
|
||||
type var = Ix of int
|
||||
|
||||
type 'a binder = B of 'a
|
||||
|
||||
type term
|
||||
= Var of var
|
||||
| Meta of C.meta
|
||||
|
||||
| Type
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
module T = Term
|
||||
module C = Common
|
||||
|
||||
type lvl = Lvl of int
|
||||
type lvl = Lvl of int
|
||||
|
||||
type closure = C of env * T.term
|
||||
and closure2 = C2 of env * T.term (* 2 variables missing *)
|
||||
|
@ -26,6 +27,7 @@ and value
|
|||
|
||||
and stuck
|
||||
= Var of lvl
|
||||
| Meta of C.meta
|
||||
| Ind0 of closure * stuck
|
||||
| IndN of closure * value * closure2 * stuck
|
||||
| IndB of closure * value * value * stuck
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
module P = AbsImplicitt
|
||||
module R = RawSyntax
|
||||
module C = Common
|
||||
|
||||
open R
|
||||
|
||||
|
@ -33,7 +34,17 @@ let rec proc (e : P.id list) (ex : P.exp) =
|
|||
| ExpPair (e1, e2) -> Pair (proc e e1, proc e e2)
|
||||
| ExpFst e1 -> Fst (proc e e1)
|
||||
| ExpSnd e1 -> Snd (proc e e1)
|
||||
| ExpHole -> failwith "hole not implemented"
|
||||
| ExpHole -> C.Mv (getCMV (), true)
|
||||
| ExpInd0 (Id i1, e1, e2) -> Ind0 (B (proc (i1 :: e)) e1) e2
|
||||
| ExpIndN (Id i1, e1, e2, Id i2, Id i3, e3, e4) ->
|
||||
IndN (B (proc (i1 :: e) e1)) (proc e e2)
|
||||
(B (B (proc (i3 :: i2 :: e) e3)))
|
||||
(proc e e4)
|
||||
| ExpIndB (Id i1, e1, e2, e3, e4) ->
|
||||
IndB (B (proc (i1 :: e) e1))
|
||||
(proc e e2)
|
||||
(proc e e3)
|
||||
(proc e e4)
|
||||
|
||||
and unwrapLambda (e : P.id list) (bs : P.bD list) (sc : P.exp) =
|
||||
match bs with
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
(library
|
||||
(name Raw)
|
||||
(libraries Core)
|
||||
(modules AbsImplicitt
|
||||
BNFC_Util
|
||||
LexImplicitt
|
||||
|
|
|
@ -19,6 +19,15 @@ ExpAppE. Exp1 ::= Exp1 Exp2;
|
|||
ExpFst. Exp1 ::= "pr₁" Exp2;
|
||||
ExpSnd. Exp1 ::= "pr₂" Exp2;
|
||||
ExpSuc. Exp1 ::= "S" Exp2;
|
||||
|
||||
ExpInd0. Exp1 ::= "⊥-elim" "⟦" Id "⇒" Exp "⟧" Exp2;
|
||||
ExpIndN. Exp1 ::= "ℕ-elim" "⟦" Id "⇒" Exp "⟧"
|
||||
"⟦" "0" "⇒" Exp
|
||||
"," "S" Id Id "⇒" Exp "⟧" Exp2;
|
||||
ExpIndB. Exp1 ::= "𝔹-elim" "⟦" Id "⇒" Exp "⟧"
|
||||
"⟦" "T" "⇒" Exp
|
||||
"," "F" "⇒" Exp "⟧" Exp2;
|
||||
|
||||
ExpVar. Exp2 ::= Id;
|
||||
ExpT0. Exp2 ::= "⊥";
|
||||
ExpT1. Exp2 ::= "⊤";
|
||||
|
@ -31,6 +40,7 @@ ExpFalse. Exp2 ::= "F";
|
|||
ExpPair. Exp2 ::= "⟨" Exp "," Exp "⟩";
|
||||
ExpHole. Exp2 ::= "?";
|
||||
|
||||
|
||||
coercions Exp 2 ;
|
||||
|
||||
VarDef. Def ::= "def" Id ":" Exp "≔" Exp;
|
||||
|
|
Loading…
Reference in New Issue
Block a user