-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstlc.grammar
64 lines (43 loc) · 1.32 KB
/
stlc.grammar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
grammar
t :: '_term' ::= {{com Lambda calculus }}
| t1 t2 :: :: App {{com Application}}
| \ var : ty . t' :: :: Lam {{com Abstraction}}
{{ tex \lambda [[var]] : [[ty]] . [[t']]}}
| x :: :: Var {{ Variables }}
| c :: :: Const {{Constant}}
ty :: '_typ' ::=
| b :: :: TBase {{com Base Type}}
| ty1 -> ty2 :: :: TArrow {{com Arrow Type}}
var,x,y :: '_variables' ::= {{com Variables }}
G :: '_context' ::= {{com Typing contexts}}
| . :: :: EmptyCtx
| G , bnd :: :: ExtendCtx
bnd :: '_binding' ::= {{com Binding }}
| var : ty :: :: Bind
defns
Typing :: 'Typ_' ::=
defn
G |- t : ty :: :: typ :: 'typing'
{{Typing judgment}}
by
----------------------- :: BaseAx
G |- c : b
G , var1 : ty1 |- t1 : ty2
---------------------------------------- :: Lam
G |- \ var1 : ty1 . t' : ty1 -> ty2
G |- t1 : ty1 -> ty2
G |- t2 : ty1
----------------------- :: App
G |- t1 t2 : ty2
var1 : ty1 elem G
----------------------- :: Var
G |- var1 : ty1
defn
bnd elem G :: :: ctx :: 'inctx'
{{ Binding in context}}
by
------------------------------ :: CtxBase
var1 : ty1 elem G , var1 : ty1
var1 : ty1 elem G
------------------------------- :: CtxStep
var1 : ty1 elem G , var2 : ty2