-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTesting.agda
105 lines (70 loc) · 3.06 KB
/
Testing.agda
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
module Testing where
open import LL
open import LAM
test : ∀ {A B} → (Value ((A & B) ⊸ A))
test = (lcur (FST ∘ cl)) ∙ unit
test2 : ∀ {A B} → (one ⟶ ((A & B) ⊸ A))
test2 = lcur (FST ∘ cl)
test2R : ∀ {A B} → Value ((A & B) ⊸ A)
test2R {A} {B} = run (linear (test2 {A} {B})) unit []
test3 : ∀ {A B} → ((A & B) ⟶ A)
test3 {A} {B} = lapp ∘ (or ∘ lcur (FST ∘ cr))
test3R : Value one
test3R = run (linear (test3 ∘ < id , id >)) unit []
add : (Nat ⊗ Nat) ⟶ Nat
add = lapp ∘ ((nrec (lcur cl) (lcur (succ ∘ lapp))) × id)
ZERO = zero ∙ unit
ONE = succ ∙ ZERO
TWO = succ ∙ ONE
testAdd1 : Value Nat
testAdd1 = app add (ONE , TWO)
testAdd2 : Value Nat
testAdd2 = run (linear add) (ONE , TWO) []
test4 : ∀ {A B} → ((A & B) ⊗ (A & B)) ⟶ (A ⊗ B)
test4 = FST × SND
test4R : Value (Nat ⊗ Nat)
test4R = app test4 ((< zero , succ ∘ zero > ∙ unit) , ((< zero , succ ∘ zero > ∙ unit)))
test5 : ∀ {A B C} → ((A & B) ⊗ (B ⊸ C)) ⟶ ((A ⊗ (B ⊸ C)) & C)
test5 = < FST × id , lapp ∘ (ex ∘ (SND × id)) >
test5R : Value ((one ⊗ (Nat ⊸ Nat)) & Nat)
test5R = app test5 ((< id , zero > ∙ unit) , ((lcur (succ ∘ cl)) ∙ unit) )
test6 : ∀ {A B C D} → ((A & B) ⊗ (C & D)) ⟶ ((A ⊗ C) & (B ⊗ D))
test6 = < FST × FST , SND × SND >
test7 : ∀ {A B} → (A & B) ⟶ (B & A)
test7 = < SND , FST >
test8 : ∀ {A B} → (A ⊕ B) ⟶ (B ⊕ A)
test8 = [ inr , inl ]
test11 : ∀ {A B C} → ((A ⊸ B) ⊗ (B ⊸ C)) ⟶ (A ⊸ C)
test11 = lcur ((((lapp ∘ ex) ∘ ((lapp ∘ ex) × id)) ∘ al) ∘ ex)
test12 : ∀ {A B C} → ((A ⊗ B) ⊸ C) ⟶ (A ⊸ (B ⊸ C))
test12 = lcur (lcur (lapp ∘ ar))
test13 : ∀ {A B C} → ((A ⊗ A) ⊗ ((A ⊸ B) ⊗ (A ⊸ C))) ⟶ (B ⊗ C)
test13 = ((lapp ∘ ex) × lapp) ∘ (((ar ∘ (al × id)) ∘ ex) ∘ ar)
test14 : (Nat ⊗ Nat) ⟶ (Nat ⊗ Nat)
test14 = (succ × (succ ∘ succ))
test14R : Value (Nat ⊗ Nat)
test14R = run (linear test14) (ZERO , ZERO) []
bnot : ∀ {A B} → (A ⊕ B) ⟶ (B ⊕ A)
bnot = [ inr , inl ]
band : ((one ⊕ one) ⊕ (one ⊕ one)) ⟶ (one ⊕ one)
band = [ [ inl , inl ] , id ]
bor : ((one ⊕ one) ⊕ (one ⊕ one)) ⟶ (one ⊕ one)
bor = [ id , [ inr , inr ] ]
bxor : ((one ⊕ one) ⊕ (one ⊕ one)) ⟶ (one ⊕ one)
bxor = [ id , bnot ]
truefalse : Value ((one ⊕ one) ⊕ (one ⊕ one))
truefalse = inr ∙ (inl ∙ unit)
xorR : Value (one ⊕ one)
xorR = run (linear bxor) truefalse []
orR : Value (one ⊕ one)
orR = run (linear bor) truefalse []
andR : Value (one ⊕ one)
andR = run (linear band) truefalse []
plusdist : ∀ {A} → (A ⊗ (one ⊕ one)) ⟶ ((A ⊗ one) ⊕ (A ⊗ one))
plusdist = inl ∘ (id × [ id , id ])
boolinv : ((one ⊕ one) ⊕ (one ⊕ one)) ⟶ ((one ⊕ one) ⊗ (one ⊕ one))
boolinv = [ [ (inl × inl) ∘ ol , (inl × inr) ∘ ol ] , [ (inr × inl) ∘ ol , (inr × inr) ∘ ol ] ]
true2 : ∀ {A B} → Value ((A & B) ⊸ (A ⊕ B))
true2 = (lcur ((inl ∘ FST) ∘ cl)) ∙ unit
false2 : ∀ {A B} → Value ((A & B) ⊸ (A ⊕ B))
false2 = (lcur ((inr ∘ SND) ∘ cl)) ∙ unit