# HG changeset patch # User Chengsong # Date 1587024855 -3600 # Node ID 6c5920fd02a7a7a81df251a39256c7b6a3002c16 # Parent c8ef391dd6f76db27b661d021bcd18ff00c19647 before changes to bsimp2 diff -r c8ef391dd6f7 -r 6c5920fd02a7 Spiral.scala --- a/Spiral.scala Fri Apr 10 11:58:11 2020 +0100 +++ b/Spiral.scala Thu Apr 16 09:14:15 2020 +0100 @@ -842,7 +842,7 @@ println(r) println(ders(s, r)) println(ders2(s,r)) - println("neq") + println("neq") } } } @@ -851,7 +851,7 @@ val bits = List(S,S,Z) val reg = ("a" | (("a")%) )~("b") val res = decode_aux(reg, bis) - val result = decode_aux(reg, bis) + val result = decode_aux(reg, bis) val result1 = decode_aux(reg, List(Z)) println(res) println(result) @@ -859,28 +859,32 @@ println(result1) } def finj_test0(c: Char, r: ARexp){ - val dr = bsimp(bder(c, r)) - val v = if(bnullable(dr)) mkeps(erase(dr)) else mkchr(erase(dr)) - val v0 = if(bnullable(dr)) mkeps(erase(bder(c,r))) else mkchr(erase(bder(c, r))) + val dr = (bder(c, r)) + val sdr = bsimp(dr) + val v = if(bnullable(sdr)) mkeps(erase(sdr)) else mkchr(erase(sdr)) + val v0 = if(bnullable(sdr)) mkeps(erase(bder(c,r))) else mkchr(erase(bder(c, r))) val v1 = inj(erase(r), c, v0) val v2 = fuzzy_inj(r, c, v) + println("regular expression original") + println(bits_print(r)) + println("regular expression derivative") + println(bits_print(dr)) + println("regular expression simped derivative") + println(bits_print(sdr)) + println("simplified value") + println(v) + println("unsimplified value") + println(v0) + println("normal injection") println(v1) + println("fuzzy injection") println(v2) - + println("inj "+r+c+v0) + println("fuzzy_inj "+r+c+v) } - def main(args: Array[String]) { - //finj_test0('b', fuse(List(S, Z), internalise( ( ("a"|"b")% ) ) )) - //finj_test0('a', fuse(List(S, Z), internalise( ( ("a"|"b")% ) ) )) - //finj_test0('b', bder('a', internalise( (("c" | "ab")%) ))) - //finj_test0('a', internalise( (("c" | "ab")%) )) - //this example gives us an exception - val r = internalise(ALTS(List(STAR(CHAR('c')), STAR(CHAR('b'))))) - val c = 'c' - //println(bits_print(r)) - //println(c) - //finj_test0(c, r) + def vunsimp_test(){ for(i <- 1 to 1000){ - val r = random_struct_gen(3)//[{ a}*~{{a}*}*] + val r = random_struct_gen(5)//[{ a}*~{{a}*}*] val c = (ran.nextInt(3) + 97).toChar//Sequ(Stars(List()),Stars(List())) val dr = der(c, r) val bdr = bder(c, internalise(r)) @@ -893,7 +897,21 @@ println(vunsimp(bdr, dv)(target_vr._2)) } } - + } + def main(args: Array[String]) { + //finj_test0('b', fuse(List(S, Z), internalise( ( ("a"|"b")% ) ) )) + //finj_test0('a', fuse(List(S, Z), internalise( ( ("a"|"b")% ) ) )) + //finj_test0('b', bder('a', internalise( (("c" | "ab")%) ))) + //finj_test0('a', internalise( (("c" | "ab")%) )) + //this example gives us an exception + //val r = internalise(ALTS(List(STAR(CHAR('c')), STAR(CHAR('b'))))) + //val c = 'c' + //if(bder(c, r) != internalise(der(c, erase(r)))) + //println("noooooo!") + //println(bits_print(r)) + //println(c) + //finj_test0(c, r) + vunsimp_test() } }