-
Notifications
You must be signed in to change notification settings - Fork 1
/
PairExtension.xstw
53 lines (47 loc) · 1.17 KB
/
PairExtension.xstw
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
module PairExtension;
extension {
context-free syntax
"Pair" Type -> Type {cons("TyPair")}
desugarings
{ Pair T ~~~> (T->T->T) -> T }
context-free syntax
Term "." "1" -> Term {cons("Fst")}
Term "." "2" -> Term {cons("Snd")}
"(" Term "," Term ")" -> Term {cons("Pair")}
context-free priorities
Term Term -> Term >
{ Term "." "1" -> Term
Term "." "2" -> Term } >
Term "+" Term -> Term
inductive definitions
T-Fst:
C |- t : Pair T
---------------
C |- t.1 : T
T-Snd:
C |- t : Pair T
---------------
C |- t.2 : T
T-Pair:
(C |- t1 : T) (C |- t2 : T)
---------------------------
C |- (t1,t2) : Pair T
desugarings
{ (C |- t : S)
----------------
C |- [ t.1 ] : T
~~~~~~~~~~~~~~~~>
t (\a:T.\y:T.a)
where y = fresh(C,a:T) }
{ C |- t : S
----------------
C |- [ t.2 ] : T
~~~~~~~~~~~~~~~~>
t (\a:T.\b:T.b) }
{ (C |- t1 : T) (C |- t2 : T)
---------------------------
C |- [ (t1,t2) ] : S
~~~~~~~~~~~~~~~~~~~~~~~~~~~>
(\y:T->T->T. (y t1 t2))
where y = fresh(C) }
}