started work on metas

This commit is contained in:
Rachel Lambda Samuelsson 2023-01-31 19:51:46 +01:00
parent 2c380ad564
commit 68a7cafd8e
9 changed files with 46 additions and 3 deletions

View File

@ -10,6 +10,11 @@ A "proof assistant" with holes and implicit arguments. Developed to learn about
# TODO # 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 * Raw syntax
* Parser (BNFC) * Parser (BNFC)

View File

@ -1,4 +1,4 @@
(executable (executable
(public_name implicitt) (public_name implicitt)
(name main) (name main)
(libraries Core Raw Parse)) (libraries Core Raw))

10
lib/Core/Common.ml Normal file
View 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

View File

@ -9,6 +9,7 @@ let rec index (env : V.env) (i : int) =
let rec eval (env : V.env) (tr : T.term) = let rec eval (env : V.env) (tr : T.term) =
match tr with match tr with
| Var (Ix i) -> index env i | Var (Ix i) -> index env i
| Mv m -> V.Stuck (V.Meta m, ?)
| Type -> V.Type | Type -> V.Type
| T0 -> V.T0 | T0 -> V.T0
| Ind0 (B b, t) -> begin | Ind0 (B b, t) -> begin

View File

@ -1,9 +1,12 @@
module C = Common
type var = Ix of int type var = Ix of int
type 'a binder = B of 'a type 'a binder = B of 'a
type term type term
= Var of var = Var of var
| Meta of C.meta
| Type | Type

View File

@ -1,4 +1,5 @@
module T = Term module T = Term
module C = Common
type lvl = Lvl of int type lvl = Lvl of int
@ -26,6 +27,7 @@ and value
and stuck and stuck
= Var of lvl = Var of lvl
| Meta of C.meta
| Ind0 of closure * stuck | Ind0 of closure * stuck
| IndN of closure * value * closure2 * stuck | IndN of closure * value * closure2 * stuck
| IndB of closure * value * value * stuck | IndB of closure * value * value * stuck

View File

@ -1,5 +1,6 @@
module P = AbsImplicitt module P = AbsImplicitt
module R = RawSyntax module R = RawSyntax
module C = Common
open R 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) | ExpPair (e1, e2) -> Pair (proc e e1, proc e e2)
| ExpFst e1 -> Fst (proc e e1) | ExpFst e1 -> Fst (proc e e1)
| ExpSnd e1 -> Snd (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) = and unwrapLambda (e : P.id list) (bs : P.bD list) (sc : P.exp) =
match bs with match bs with

View File

@ -15,6 +15,7 @@
(library (library
(name Raw) (name Raw)
(libraries Core)
(modules AbsImplicitt (modules AbsImplicitt
BNFC_Util BNFC_Util
LexImplicitt LexImplicitt

View File

@ -19,6 +19,15 @@ ExpAppE. Exp1 ::= Exp1 Exp2;
ExpFst. Exp1 ::= "pr" Exp2; ExpFst. Exp1 ::= "pr" Exp2;
ExpSnd. Exp1 ::= "pr" Exp2; ExpSnd. Exp1 ::= "pr" Exp2;
ExpSuc. Exp1 ::= "S" 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; ExpVar. Exp2 ::= Id;
ExpT0. Exp2 ::= ""; ExpT0. Exp2 ::= "";
ExpT1. Exp2 ::= ""; ExpT1. Exp2 ::= "";
@ -31,6 +40,7 @@ ExpFalse. Exp2 ::= "F";
ExpPair. Exp2 ::= "" Exp "," Exp ""; ExpPair. Exp2 ::= "" Exp "," Exp "";
ExpHole. Exp2 ::= "?"; ExpHole. Exp2 ::= "?";
coercions Exp 2 ; coercions Exp 2 ;
VarDef. Def ::= "def" Id ":" Exp "" Exp; VarDef. Def ::= "def" Id ":" Exp "" Exp;