-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOldExample.hs
137 lines (126 loc) · 3.87 KB
/
OldExample.hs
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
{-# LANGUAGE NoMonomorphismRestriction #-}
module OldExample where
import Interpret
import InterpretLog
-- (\ x -> (\ y z -> y + z) x x) (3 or 5)
firstNondetExample =
watchBounds "(\\ x -> (\\ y z -> y + z) x x) (3 or 5)" $ applyGoI
(watchBounds "\\ x -> (\\ y z -> y + z) x x" $ abstGoI "x" $
watchBounds "(\\ y z -> y + z) x x" $ applyGoI
(watchBounds "(\\ y z -> y + z) x" $ applyGoI
(watchBounds "\\ y z -> y + z" $ abstGoI "y" $
watchBounds "\\ z -> y + z" $ abstGoI "z" $
watchBounds "y + z" $ sumGoI "y" "z"
)
(watchBounds "x (left)" $ variableGoI "x")
)
(watchBounds "x (right)" $ variableGoI "x")
)
(watchBounds "3 or 5" $ oplusGoI
(watchBounds "3" $ constGoI 3)
(watchBounds "5" $ constGoI 5)
)
-- \ t s -> t + s
additionGoI =
watchBounds "\\ t s -> t + s" $ abstGoI "t" $
watchBounds "\\ s -> t + s" $ abstGoI "s" $
watchBounds "t + s" $ sumGoI "t" "s"
-- (\ f -> sum (f 0) (f 1)) (\ x -> 3 or 5)
-- 2014.5.10
secondNondetExample =
watchBounds "(\\ f -> sum (f 0) (f 1)) (\\ x -> 3 or 5)" $ applyGoI
(watchBounds "\\ f -> sum (f 0) (f 1))" $ abstGoI "f" $
watchBounds "sum (f 0) (f 1)" $ applyGoI
(watchBounds "sum (f 0)" $ applyGoI
additionGoI
(watchBounds "f 0" $ applyGoI
(watchBounds "f (left)" $ variableGoI "f")
(watchBounds "0" $ constGoI 0)
)
)
(watchBounds "f 1" $ applyGoI
(watchBounds "f (right)" $ variableGoI "f")
(watchBounds "1" $ constGoI 1)
)
)
(watchBounds "\\ x -> 3 or 5" $ abstGoI "x" $
(watchBounds "3 or 5" $ oplusGoI
(watchBounds "3" $ constGoI 3)
(watchBounds "5" $ constGoI 5)
)
)
-- "x + x" is wrong!!
-- (watchBounds "(\\ x -> x + x) (3 or 5)" $ applyGoI
-- (watchBounds "\\ x -> x + x" $ abstGoI "x" $
-- watchBounds "x + x" $ sumGoI "x" "x"
-- )
-- (watchBounds "3 or 5" $ oplusGoI
-- (watchBounds "3" $ constGoI 3)
-- (watchBounds "5" $ constGoI 5)
-- )
-- )
-- (\ x y -> x + y) 3 (5 or 6)
theNonDetTd =
(watchBounds "(\\ x y -> x + y) 3 (5 or 6)" $ applyGoI
(watchBounds "(\\ x y -> x + y) 3" $ applyGoI
(watchBounds "\\ x y -> x + y" $ abstGoI "x" $
(watchBounds "\\ y -> x + y" $ abstGoI "y" $
watchBounds "x + y" $ sumGoI "x" "y"
)
)
(constGoI 3)
)
(watchBounds "5 or 6" $ oplusGoI
(constGoI 5)
(constGoI 6)
)
)
-- (\ x -> (\ y z -> y + z) x x) 3
secondPureExample =
(watchBounds "(\\ x -> (\\ y z -> y + z) x x) 3" $ applyGoI
(watchBounds "\\ x -> (\\ y z -> y + z) x x" $ abstGoI "x" $
watchBounds "(\\ y z -> y + z) x x" $ applyGoI
(watchBounds "(\\ y z -> y + z) x" $ applyGoI
(watchBounds "\\ y z -> y + z" $ abstGoI "y" $
watchBounds "\\ z -> y + z" $ abstGoI "z" $
watchBounds "y + z" $ sumGoI "y" "z"
)
(watchBounds "x (left)" $ variableGoI "x")
)
(watchBounds "x (right)" $ variableGoI "x")
)
(watchBounds "3" $ constGoI 3)
)
-- (\ x y -> x + y) 5 3
firstPureExample =
(watchBounds "(\\ x y -> x + y) 5 3" $ applyGoI
(watchBounds "(\\ x y -> x + y) 5" $ applyGoI
(watchBounds "\\ x y -> x + y" $ abstGoI "x" $
(watchBounds "\\ y -> x + y" $ abstGoI "y" $
watchBounds "x + y" $ sumGoI "x" "y"
)
)
(watchBounds "5" $ constGoI 5)
)
(watchBounds "3" $ constGoI 3)
)
-- (\ x -> y) 3
wrongExample =
watchBounds "(\\ x -> y) 3" $ applyGoI
(watchBounds "\\ x -> y" $ abstGoI "x" $
watchBounds "y" $ variableGoI "y"
)
(watchBounds "3" $ constGoI 3)
{-
theTd =
applyGoI
(applyGoI
(abstGoI "x" $
(abstGoI "y" $
sumGoI "x" "y"
)
)
(constGoI 3)
)
(constGoI 5)
-}