author | Chengsong |
Wed, 27 May 2020 22:23:52 +0100 | |
changeset 151 | 73f990bc6843 |
parent 150 | b51d34113d47 |
permissions | -rwxr-xr-x |
151 | 1 |
|
2 |
import Spiral._ |
|
0 | 3 |
import Element.elem |
4 |
import RexpRelated._ |
|
5 |
import RexpRelated.Rexp._ |
|
151 | 6 |
//import Partial._ |
0 | 7 |
import scala.collection.mutable.ListBuffer |
151 | 8 |
|
0 | 9 |
object Spiral{ |
10 |
||
11 |
||
12 |
val alphabet = ("""abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:"=()\;-+*!<>\/%{} """+"\n\t").toSet//Set('a','b','c') |
|
151 | 13 |
|
0 | 14 |
val arr_of_size = ListBuffer.empty[Int] |
2 | 15 |
|
151 | 16 |
|
0 | 17 |
val ran = scala.util.Random |
18 |
var alphabet_size = 3 |
|
19 |
def balanced_seq_star_gen(depth: Int, star: Boolean): Rexp = { |
|
20 |
if(depth == 1){ |
|
21 |
((ran.nextInt(4) + 97).toChar).toString |
|
22 |
} |
|
23 |
else if(star){ |
|
24 |
STAR(balanced_seq_star_gen(depth - 1, false)) |
|
25 |
} |
|
26 |
else{ |
|
27 |
SEQ(balanced_seq_star_gen(depth - 1, true), balanced_seq_star_gen(depth - 1, true)) |
|
28 |
} |
|
29 |
} |
|
30 |
def random_struct_gen(depth:Int): Rexp = { |
|
31 |
val dice = ran.nextInt(3) |
|
32 |
val dice2 = ran.nextInt(3) |
|
151 | 33 |
val new_depth = (List(0, depth - 1 - dice2)).max |
34 |
(dice, new_depth) match { |
|
0 | 35 |
case (_, 0) => ((ran.nextInt(3) + 97).toChar).toString |
151 | 36 |
case (0, i) => STAR(random_struct_gen(new_depth)) |
37 |
case (1, i) => SEQ(random_struct_gen(new_depth), random_struct_gen(new_depth)) |
|
38 |
case (2, i) => ALTS( List(random_struct_gen(new_depth), random_struct_gen(new_depth)) ) |
|
0 | 39 |
} |
40 |
} |
|
41 |
def balanced_struct_gen(depth: Int): Rexp = { |
|
42 |
val dice = ran.nextInt(3) |
|
43 |
(dice, depth) match { |
|
44 |
case (_, 0) => ((ran.nextInt(3) + 97).toChar).toString |
|
45 |
case (0, i) => STAR(random_struct_gen(depth - 1)) |
|
46 |
case (1, i) => SEQ(random_struct_gen(depth - 1), random_struct_gen(depth - 1)) |
|
47 |
case (2, i) => ALTS( List(random_struct_gen(depth - 1), random_struct_gen(depth - 1) ) ) |
|
48 |
} |
|
49 |
} |
|
6 | 50 |
def random_pool(n: Int, d: Int) : Stream[Rexp] = n match { |
51 |
case 0 => (for (i <- 1 to 10) yield balanced_struct_gen(d)).toStream |
|
52 |
case n => { |
|
53 |
val rs = random_pool(n - 1, d) |
|
54 |
rs #::: |
|
55 |
(for (i <- (1 to 10).toStream) yield balanced_struct_gen(d)) #::: |
|
56 |
(for (i <- (1 to 10).toStream) yield random_struct_gen(d)) |
|
57 |
} |
|
58 |
} |
|
59 |
||
0 | 60 |
def rd_string_gen(alp_size: Int, len: Int): String = { |
61 |
if( len > 0) |
|
62 |
((ran.nextInt(alp_size) + 97).toChar).toString + rd_string_gen(alp_size, len - 1) |
|
63 |
else |
|
64 |
((ran.nextInt(alp_size) + 97).toChar).toString |
|
65 |
} |
|
66 |
def plot(b: List[Int]){ |
|
67 |
println(b(0),b.max) |
|
68 |
||
69 |
} |
|
151 | 70 |
|
71 |
||
0 | 72 |
def star_gen(dp: Int): Rexp = { |
73 |
if(dp > 0) |
|
74 |
STAR(star_gen(dp - 1)) |
|
75 |
else |
|
76 |
"a" |
|
77 |
} |
|
78 |
def strs_gen(len: Int, num: Int): List[String] = { |
|
79 |
if(num > 0){ |
|
80 |
rd_string_gen(3, len)::strs_gen(len, num - 1) |
|
81 |
} |
|
82 |
else{ |
|
83 |
Nil |
|
84 |
} |
|
85 |
} |
|
151 | 86 |
|
0 | 87 |
val mkst = "abcdefghijklmnopqrstuvwxyz" |
151 | 88 |
|
5 | 89 |
val big_panda = STAR(STAR(STAR(ALTS(List(ALTS(List(CHAR('c'), CHAR('b'))), SEQ(CHAR('c'),CHAR('c'))))))) |
90 |
val str_panda = "ccccb" |
|
91 |
||
93 | 92 |
def bstostick(bs: List[Bit]): Element = bs match { |
93 |
//case b::Nil => elem(b.toString) |
|
94 |
case b::bs1 => elem(b.toString) beside bstostick(bs1) |
|
95 |
case Nil => elem(' ', 1, 1) |
|
96 |
} |
|
151 | 97 |
def aregex_simple_print(r: ARexp): Element = r match { |
93 | 98 |
case AALTS(bs,rs) => { |
99 |
val bitstick = bstostick(bs) |
|
100 |
rs match { |
|
101 |
case r::rs1 => |
|
102 |
rs1.foldLeft( |
|
103 |
((elem("(") left_align bitstick) beside |
|
151 | 104 |
aregex_simple_print(r)) )( (acc, r2) => acc beside ((elem(" + ") above elem(" ")) beside aregex_simple_print(r2) )) beside |
93 | 105 |
elem(")") |
106 |
case Nil => elem(' ', 1, 1) |
|
107 |
} |
|
108 |
} |
|
109 |
case ASEQ(bs, r1, r2) => { |
|
151 | 110 |
((elem("[") left_align bstostick(bs)) beside aregex_simple_print(r1) beside elem("~") beside aregex_simple_print(r2) beside (elem("]") above elem(" "))) |
93 | 111 |
} |
112 |
case ASTAR(bs, r) => { |
|
113 |
r match { |
|
114 |
case AONE(_) | AZERO | ACHAR(_, _) => { |
|
151 | 115 |
(elem("{") left_align bstostick(bs)) beside (aregex_simple_print(r) beside elem("}*")) |
93 | 116 |
} |
117 |
case _ => { |
|
151 | 118 |
(elem("{") left_align bstostick(bs)) beside (aregex_simple_print(r) beside elem("}*")) |
93 | 119 |
} |
120 |
} |
|
121 |
} |
|
122 |
case AONE(bs) => { |
|
123 |
elem("1") left_align bstostick(bs) |
|
124 |
} |
|
125 |
case ACHAR(bs, c) => { |
|
126 |
elem(c, 1, 1) left_align bstostick(bs) |
|
127 |
} |
|
128 |
case AZERO => |
|
129 |
{ |
|
130 |
elem ("0") above elem(" ") |
|
131 |
} |
|
132 |
} |
|
151 | 133 |
def regex_simple_print(r: Rexp): Unit = r match { |
93 | 134 |
case ALTS( r::rs ) => { |
135 |
print("(") |
|
151 | 136 |
regex_simple_print(r) |
93 | 137 |
rs.map(r2=>{ |
138 |
print(" + ") |
|
151 | 139 |
regex_simple_print(r2) |
93 | 140 |
}) |
141 |
print(")") |
|
142 |
} |
|
143 |
case SEQ(r1, r2) => { |
|
151 | 144 |
regex_simple_print(r1) |
93 | 145 |
print("~") |
151 | 146 |
regex_simple_print(r2) |
93 | 147 |
} |
148 |
case STAR(r) => { |
|
149 |
r match { |
|
150 |
case ONE | ZERO | CHAR(_) => { |
|
151 | 151 |
regex_simple_print(r) |
93 | 152 |
print("*") |
153 |
} |
|
154 |
case _ => { |
|
155 |
print("[") |
|
151 | 156 |
regex_simple_print(r) |
93 | 157 |
print("]*") |
158 |
} |
|
159 |
} |
|
160 |
} |
|
161 |
case ONE => { |
|
162 |
print("1") |
|
163 |
} |
|
164 |
case ZERO => { |
|
165 |
print("0") |
|
166 |
} |
|
167 |
case CHAR(c) =>{ |
|
168 |
print(c) |
|
169 |
} |
|
170 |
} |
|
171 |
//found r = SEQ(ALTS(List(CHAR(c), CHAR(a))),SEQ(ALTS(List(CHAR(a), CHAR(c))),ALTS(List(CHAR(b), CHAR(c))))) s = "aa" |
|
172 |
def bsimp_print(r: ARexp): Unit = r match { |
|
173 |
case ASEQ(bs, r1, r2) => |
|
174 |
{ |
|
175 |
println("0.r or r.0 to 0 or bs1 1.r to fuse bs++bs1 r") |
|
151 | 176 |
aregex_simple_print(bsimp(r1)) |
177 |
aregex_simple_print(bsimp(r2)) |
|
93 | 178 |
} |
179 |
case AALTS(bs, rs) => { |
|
180 |
println("rs.map(bsimp) equals *************") |
|
181 |
val rs_simp = rs.map(bsimp) |
|
182 |
for(r <- rs_simp){ |
|
151 | 183 |
println(aregex_simple_print(r)) |
93 | 184 |
} |
185 |
println("*************") |
|
186 |
println("flts(rs_simp)") |
|
187 |
val flat_res = flats(rs_simp) |
|
188 |
for(r <- flat_res){ |
|
151 | 189 |
println(aregex_simple_print(r)) |
93 | 190 |
} |
191 |
println("dB(flat_res)") |
|
192 |
val dist_res = distinctBy(flat_res, erase) |
|
193 |
for(r <- dist_res){ |
|
151 | 194 |
println(aregex_simple_print(r)) |
93 | 195 |
} |
196 |
dist_res match { |
|
197 |
case Nil => println("AZERO") |
|
198 |
case r::Nil => println("fuse(bs, r)") |
|
199 |
case rs => println("AALTS(bs, rs)") |
|
200 |
} |
|
201 |
} |
|
202 |
case _ => println("No simp at this level") |
|
203 |
} |
|
151 | 204 |
|
205 |
||
5 | 206 |
//simplified regex size 291, so called pd_simp size 70 (did not do simplification to terms in the PD set) |
10 | 207 |
def pushbits(r: ARexp): ARexp = r match { |
11
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
208 |
case AALTS(bs, rs) => AALTS(Nil, rs.map(r=>fuse(bs, pushbits(r)))) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
209 |
case ASEQ(bs, r1, r2) => ASEQ(bs, pushbits(r1), pushbits(r2)) |
10 | 210 |
case r => r |
211 |
} |
|
14 | 212 |
|
213 |
||
17 | 214 |
def nice_lex(r: Rexp, s: List[Char], ar: ARexp) : Val = s match { |
215 |
case Nil => |
|
216 |
if (nullable(r)){ |
|
217 |
val vr = mkeps(r) |
|
218 |
val bits1 = retrieve(ar, vr) |
|
219 |
val av = bsimp2(ar, vr) |
|
220 |
val bits2 = retrieve(av._1, av._2) |
|
221 |
if(bits1 != bits2) throw new Exception("bsimp2 does not work") |
|
222 |
vr |
|
223 |
} |
|
224 |
else throw new Exception("Not matched") |
|
225 |
case c::cs => { |
|
226 |
val vr = inj(r, c, nice_lex(der(c, r), cs, bder(c, ar))); |
|
227 |
val bits1 = retrieve(ar, vr); |
|
228 |
val av = bsimp2(ar, vr); |
|
229 |
val bits2 = retrieve(av._1, av._2); |
|
230 |
if(bits1 != bits2) throw new Exception("bsimp2 does not work"); |
|
231 |
vr |
|
232 |
} |
|
233 |
} |
|
234 |
def test_bsimp2(){ |
|
235 |
for(i <- 1 to 1000){ |
|
236 |
val rg = (balanced_struct_gen(9))//ASTAR(List(),AALTS(List(),List(ASTAR(List(Z),ACHAR(List(),'a')), ASEQ(List(S),ACHAR(List(),'a'),ACHAR(List(),'b')))))//internalise(balanced_struct_gen(3))//SEQ(ALTS(List(STAR("a"),ALTS(List("a","c")))),SEQ(ALTS(List("c","a")),ALTS(List("c","b")))) |
|
237 |
val st = rd_string_gen(3, 4) |
|
238 |
val a = internalise(rg) |
|
239 |
val final_derivative = ders(st.toList, rg) |
|
240 |
if(nullable(final_derivative)) |
|
241 |
nice_lex(rg, st.toList, a) |
|
242 |
} |
|
243 |
} |
|
15 | 244 |
|
17 | 245 |
def neat_retrieve(){ |
246 |
for(i <- 1 to 1000){ |
|
247 |
val rg = internalise(balanced_struct_gen(6))//ASTAR(List(),AALTS(List(),List(ASTAR(List(Z),ACHAR(List(),'a')), ASEQ(List(S),ACHAR(List(),'a'),ACHAR(List(),'b')))))//internalise(balanced_struct_gen(3))//SEQ(ALTS(List(STAR("a"),ALTS(List("a","c")))),SEQ(ALTS(List("c","a")),ALTS(List("c","b")))) |
|
248 |
val st = rd_string_gen(3, 5) |
|
249 |
val final_derivative = ders(st.toList, erase(rg)) |
|
250 |
if(nullable(final_derivative)){ |
|
251 |
val unsimplified_vl = mkeps(final_derivative) |
|
252 |
val arexp_for_retrieve = bders( st.toList, rg) |
|
253 |
val simp_ar_vl = bsimp2(arexp_for_retrieve, unsimplified_vl) |
|
254 |
val bits1 = retrieve(arexp_for_retrieve, unsimplified_vl) |
|
255 |
val bits2 = retrieve(simp_ar_vl._1, simp_ar_vl._2) |
|
256 |
if(bits1 != bits2){ |
|
257 |
println("nOOOOOOOOOO!") |
|
15 | 258 |
} |
259 |
} |
|
11
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
260 |
} |
17 | 261 |
} |
262 |
||
7 | 263 |
def radical_correctness(){ |
264 |
enum(3, "abc").map(tests_blexer_simp(strs(3, "abc"))).toSet |
|
265 |
random_pool(1, 5).map(tests_blexer_simp(strs(5, "abc"))).toSet |
|
266 |
} |
|
15 | 267 |
def christian_def(){ |
268 |
val r = ALTS(List(SEQ(ZERO,CHAR('b')), ONE)) |
|
269 |
val v = Right(Empty) |
|
270 |
val a = internalise(r) |
|
17 | 271 |
val a_v = bsimp2(a,v) |
15 | 272 |
println(s"Testing ${r} and ${v}") |
273 |
println(s"internalise(r) = ${a}") |
|
17 | 274 |
println(s"a_v = ${a_v}") |
15 | 275 |
val bs1 = retrieve(a, v) |
276 |
println(bs1) |
|
17 | 277 |
println(s"as = ${a_v._1}") |
15 | 278 |
//val bs2 = retrieve(as, decode(erase(as), bs1)) |
17 | 279 |
val bs3 = retrieve(a_v._1, a_v._2)//decode(erase(as), bs1) does not work |
280 |
//println(decode(erase(as), bs1)) |
|
281 |
println(s"bs1=${bs1}, bs3=${bs3}") |
|
282 |
//println(decode(erase(a_v._1), bs3)) |
|
15 | 283 |
} |
72 | 284 |
def christian_def2(){ |
89 | 285 |
val a = AALTS(List(S), List(AZERO, ASEQ(List(S), AALTS(List(S), List(AONE(List(S)), ACHAR(List(S), 'c'))), ACHAR(List(S),'c') )) ) |
286 |
//AALTS(List(Z), List(AZERO, ASEQ(List(), AALTS(List(),List(AONE(List()), ACHAR(Nil, 'b'))), ACHAR(Nil, 'b')) ) ) |
|
287 |
val unsimp = bsimp(bder('c',a)) |
|
288 |
val simped = bsimp(bder('c', bsimp(a)) ) |
|
72 | 289 |
println(bsimp(a)) |
89 | 290 |
if(unsimp != simped){ |
72 | 291 |
println(s"bsimp(bder c r) = ${unsimp}, whereas bsimp(bder c bsimp r) = ${simped}") |
292 |
} |
|
293 |
} |
|
16 | 294 |
|
87 | 295 |
def speed_test(){ |
296 |
val s0 = "a"*1000 |
|
297 |
val r = SEQ(STAR("a"), "b") |
|
298 |
for(i <- 1 to 30){ |
|
299 |
val s = s0*i |
|
300 |
val start = System.nanoTime() |
|
301 |
try{ |
|
302 |
blex_simp(internalise(r), s.toList) |
|
303 |
} |
|
304 |
catch{ |
|
305 |
case x: Exception => |
|
306 |
} |
|
307 |
val end = System.nanoTime() |
|
308 |
printf("%d %f\n",i, (end - start)/1.0e9) |
|
309 |
} |
|
310 |
} |
|
91 | 311 |
/* |
312 |
lemma retrieve_encode_STARS: |
|
313 |
assumes "∀v∈set vs. ⊨ v : r ∧ code v = retrieve (intern r) v" |
|
314 |
shows "code (Stars vs) = retrieve (ASTAR [] (intern r)) (Stars vs)" |
|
315 |
*/ |
|
316 |
def retrieve_encode_STARS(){ |
|
317 |
val r = ALT(CHAR('a'), SEQ(CHAR('a'),CHAR('b')) ) |
|
318 |
//val v = Stars(List(Sequ(Chr('a'), Chr('b')), Chr('a')) ) |
|
319 |
val v1 = Right(Sequ(Chr('a'), Chr('b'))) |
|
320 |
val v2 = Left(Chr('a')) |
|
321 |
val compressed1 = code(v1) |
|
322 |
val compressed2 = code(v2) |
|
323 |
val xompressed1 = retrieve(internalise(r), v1) |
|
324 |
val xompressed2 = retrieve(internalise(r), v2) |
|
325 |
println(compressed1, compressed2, xompressed1, xompressed2) |
|
326 |
val v = Stars(List(v1, v2)) |
|
327 |
val compressed = code(v) |
|
328 |
val a = ASTAR(List(), internalise(r)) |
|
329 |
val xompressed = retrieve(a, v) |
|
330 |
println(compressed, xompressed) |
|
331 |
} |
|
332 |
//what does contains7 do? |
|
333 |
//it causes exception |
|
334 |
//relation between retreive, bder and injection |
|
335 |
// a match error occurs when doing the injection |
|
336 |
def contains7(){ |
|
337 |
val r = STAR( SEQ(CHAR('a'),CHAR('b')) ) |
|
338 |
val v = Sequ(Chr('b'), Stars(List(Sequ(Chr('a'), Chr('b'))))) |
|
339 |
val a = internalise(r) |
|
340 |
val c = 'a' |
|
341 |
val v_aug = inj(r, c, v) |
|
342 |
println("bder c r:") |
|
343 |
println(bder(c, a)) |
|
344 |
println("r:") |
|
345 |
println(a) |
|
346 |
println("bits they can both produce:") |
|
347 |
println(retrieve(a, v_aug)) |
|
348 |
} |
|
349 |
def der_seq(r:ARexp, s: List[Char],acc: List[ARexp]) : List[ARexp] = s match{ |
|
350 |
case Nil => acc ::: List(r) |
|
351 |
case c::cs => der_seq(bder(c, r), cs, acc ::: List(r)) |
|
352 |
} |
|
353 |
def der_seq_rev(r:ARexp, s: List[Char], acc: List[ARexp]): List[ARexp] = s match{ |
|
354 |
case Nil => r::acc |
|
355 |
case c::cs =>der_seq_rev(r, cs, bders(s, r) :: acc ) |
|
356 |
} |
|
357 |
def re_close(l1: List[ARexp], l2: List[ARexp], re_init: ARexp): ARexp = l1 match { |
|
358 |
case Nil => re_init |
|
359 |
case c::cs => if(bnullable(c)) re_close(cs, l2.tail, AALTS(List(), List(re_init, fuse(mkepsBC(c), l2.head)) ) ) |
|
360 |
else re_close(cs, l2.tail, re_init) |
|
361 |
} |
|
92 | 362 |
//HERE |
91 | 363 |
def closed_string_der(r1: ARexp, r2: ARexp, s: String): ARexp = { |
364 |
val l1 = der_seq(r1, s.toList, Nil) |
|
365 |
val l2 = der_seq_rev(r2, s.toList, Nil) |
|
93 | 366 |
val Re = re_close((l1.reverse).tail, l2.tail, ASEQ(List(), l1.last, l2.head)) |
91 | 367 |
print(Re) |
368 |
val Comp = bders( s.toList, ASEQ(List(), r1, r2)) |
|
369 |
print(Comp ) |
|
370 |
if(Re != Comp){ |
|
371 |
println("boooooooooooooooo!joihniuguyfuyftyftyufuyids gheioueghrigdhxilj") |
|
372 |
} |
|
373 |
Re |
|
374 |
} |
|
375 |
def newxp1(){ |
|
376 |
val r1 = internalise("ab"|"") |
|
377 |
val r2 = internalise(("b")%) |
|
378 |
val s = "abbbbb" |
|
379 |
val s2= "bbbbb" |
|
380 |
val s3 = "aaaaaa" |
|
381 |
//closed_string_der(r1, r2, s) |
|
382 |
//closed_string_der(r1, r2, s2) |
|
383 |
closed_string_der(r1, r2, s3) |
|
384 |
} |
|
92 | 385 |
|
386 |
def string_der_test(){ |
|
387 |
for(i <- 0 to 10){ |
|
388 |
val s = rd_string_gen(alphabet_size, i).toList |
|
389 |
val r = random_struct_gen(2) |
|
390 |
if(ders(s, r) != ders2(s, r)){ |
|
391 |
println(i) |
|
392 |
println(s) |
|
393 |
println(r) |
|
394 |
println(ders(s, r)) |
|
395 |
println(ders2(s,r)) |
|
149 | 396 |
println("neq") |
92 | 397 |
} |
398 |
} |
|
399 |
} |
|
109 | 400 |
def have_fun(){ |
401 |
val bis = List(S,S) |
|
402 |
val bits = List(S,S,Z) |
|
403 |
val reg = ("a" | (("a")%) )~("b") |
|
404 |
val res = decode_aux(reg, bis) |
|
149 | 405 |
val result = decode_aux(reg, bis) |
109 | 406 |
val result1 = decode_aux(reg, List(Z)) |
407 |
println(res) |
|
408 |
println(result) |
|
409 |
println(bsimp(bders( "a".toList, internalise(reg)))) |
|
410 |
println(result1) |
|
411 |
} |
|
148 | 412 |
def finj_test0(c: Char, r: ARexp){ |
149 | 413 |
val dr = (bder(c, r)) |
414 |
val sdr = bsimp(dr) |
|
415 |
val v = if(bnullable(sdr)) mkeps(erase(sdr)) else mkchr(erase(sdr)) |
|
416 |
val v0 = if(bnullable(sdr)) mkeps(erase(bder(c,r))) else mkchr(erase(bder(c, r))) |
|
148 | 417 |
val v1 = inj(erase(r), c, v0) |
418 |
val v2 = fuzzy_inj(r, c, v) |
|
149 | 419 |
println("regular expression original") |
151 | 420 |
println(aregex_simple_print(r)) |
149 | 421 |
println("regular expression derivative") |
151 | 422 |
println(aregex_simple_print(dr)) |
149 | 423 |
println("regular expression simped derivative") |
151 | 424 |
println(aregex_simple_print(sdr)) |
149 | 425 |
println("simplified value") |
426 |
println(v) |
|
427 |
println("unsimplified value") |
|
428 |
println(v0) |
|
429 |
println("normal injection") |
|
148 | 430 |
println(v1) |
149 | 431 |
println("fuzzy injection") |
148 | 432 |
println(v2) |
149 | 433 |
println("inj "+r+c+v0) |
434 |
println("fuzzy_inj "+r+c+v) |
|
148 | 435 |
} |
149 | 436 |
def vunsimp_test(){ |
151 | 437 |
/*val bdr = AALTS( |
438 |
List(), |
|
439 |
List( |
|
440 |
AONE(List(S,Z)), |
|
441 |
ASTAR(List(Z,Z,S), ACHAR(List(),'c')), |
|
442 |
ASEQ(List(Z), ASTAR(List(S), ACHAR(List(), 'c')), ASTAR(List(S), ACHAR(List(), 'c') ) ) |
|
443 |
) |
|
444 |
)*/ |
|
445 |
val bdr = AALTS(List(),List(AALTS(List(Z),List(ASEQ(List(), |
|
446 |
ASEQ(List(),AONE(List(S)),ASTAR(List(),ACHAR(List(),'c'))),ASTAR(List(),ACHAR(List(),'c'))), |
|
447 |
ASEQ(List(Z),AONE(List(S)),ASTAR(List(),ACHAR(List(),'c'))))), AALTS(List(S),List(AONE(List(Z)), AZERO)))) |
|
448 |
val dr = erase(bdr) |
|
449 |
val dv = mkeps(dr) |
|
450 |
//val bdr = bder(c, internalise(r)) |
|
451 |
//val dv = mkeps(dr) |
|
452 |
println(aregex_simple_print(bdr)) |
|
453 |
println(dv) |
|
454 |
val target_vr = bsimp2(bdr, dv) |
|
455 |
println(aregex_simple_print(target_vr._1)) |
|
456 |
println(target_vr._2) |
|
457 |
println(vunsimp(bdr, dv)(target_vr._2)) |
|
149 | 458 |
} |
151 | 459 |
|
460 |
||
149 | 461 |
def main(args: Array[String]) { |
462 |
vunsimp_test() |
|
148 | 463 |
} |
464 |
||
0 | 465 |
} |