blob: b369eb5328ea06962e460ae7b249324867d7eb15 (
plain)
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
|
(;module:
lux
(lux [io]
(control [monad #+ do]
pipe)
(data [product]
[number]
text/format
(coll [list "L/" Functor<List> Fold<List>]
["D" dict]
["s" set]))
["r" math/random "r/" Monad<Random>]
test)
(luxc (lang ["la" analysis]
["ls" synthesis])
[synthesizer])
(../.. common))
(context: "Dummy variables."
(<| (times +100)
(do @
[maskedA gen-primitive
temp r;nat
#let [maskA (#la;Case maskedA
(list [(#la;BindP temp)
(#la;Variable (#;Local temp))]))]]
(test "Dummy variables created to mask expressions get eliminated during synthesis."
(|> (synthesizer;synthesize maskA)
(corresponds? maskedA))))))
(context: "Let expressions."
(<| (times +100)
(do @
[registerA r;nat
inputA gen-primitive
outputA gen-primitive
#let [letA (#la;Case inputA
(list [(#la;BindP registerA)
outputA]))]]
(test "Can detect and reify simple 'let' expressions."
(|> (synthesizer;synthesize letA)
(case> (#ls;Let registerS inputS outputS)
(and (n.= registerA registerS)
(corresponds? inputA inputS)
(corresponds? outputA outputS))
_
false))))))
(context: "If expressions."
(<| (times +100)
(do @
[then|else r;bool
inputA gen-primitive
thenA gen-primitive
elseA gen-primitive
#let [ifA (if then|else
(#la;Case inputA
(list [(#la;BoolP true) thenA]
[(#la;BoolP false) elseA]))
(#la;Case inputA
(list [(#la;BoolP false) elseA]
[(#la;BoolP true) thenA])))]]
(test "Can detect and reify simple 'if' expressions."
(|> (synthesizer;synthesize ifA)
(case> (#ls;If inputS thenS elseS)
(and (corresponds? inputA inputS)
(corresponds? thenA thenS)
(corresponds? elseA elseS))
_
false))))))
|