Spiral.scala
changeset 92 aaa2f2b52baf
parent 91 4fd50a6844aa
child 93 d486c12deeab
equal deleted inserted replaced
91:4fd50a6844aa 92:aaa2f2b52baf
   646   def re_close(l1: List[ARexp], l2: List[ARexp], re_init: ARexp): ARexp = l1 match {
   646   def re_close(l1: List[ARexp], l2: List[ARexp], re_init: ARexp): ARexp = l1 match {
   647     case Nil => re_init
   647     case Nil => re_init
   648     case c::cs => if(bnullable(c)) re_close(cs, l2.tail, AALTS(List(), List(re_init, fuse(mkepsBC(c), l2.head)) ) ) 
   648     case c::cs => if(bnullable(c)) re_close(cs, l2.tail, AALTS(List(), List(re_init, fuse(mkepsBC(c), l2.head)) ) ) 
   649     else re_close(cs, l2.tail, re_init)
   649     else re_close(cs, l2.tail, re_init)
   650   }
   650   }
       
   651   //HERE
   651   def closed_string_der(r1: ARexp, r2: ARexp, s: String): ARexp = {
   652   def closed_string_der(r1: ARexp, r2: ARexp, s: String): ARexp = {
   652     val l1 = der_seq(r1, s.toList, Nil)
   653     val l1 = der_seq(r1, s.toList, Nil)
   653     val l2 = der_seq_rev(r2, s.toList, Nil)
   654     val l2 = der_seq_rev(r2, s.toList, Nil)
   654     val Re = re_close(l1.reverse, l2, ASEQ(List(), l1.last, l2.head))
   655     val Re = re_close(l1.reverse, l2, ASEQ(List(), l1.last, l2.head))
   655     print(Re)
   656     print(Re)
   668     val s3 = "aaaaaa"
   669     val s3 = "aaaaaa"
   669     //closed_string_der(r1, r2, s)
   670     //closed_string_der(r1, r2, s)
   670     //closed_string_der(r1, r2, s2)
   671     //closed_string_der(r1, r2, s2)
   671     closed_string_der(r1, r2, s3)
   672     closed_string_der(r1, r2, s3)
   672   }
   673   }
       
   674 
       
   675   def string_der_test(){
       
   676     for(i <- 0 to 10){
       
   677       val s = rd_string_gen(alphabet_size, i).toList
       
   678       val r = random_struct_gen(2)
       
   679       if(ders(s, r) != ders2(s, r)){
       
   680         println(i)
       
   681         println(s)
       
   682         println(r)
       
   683         println(ders(s, r))
       
   684         println(ders2(s,r))
       
   685         println("neq")
       
   686       }
       
   687     }
       
   688   }
       
   689 
   673   def main(args: Array[String]) {
   690   def main(args: Array[String]) {
   674     newxp1()
   691     string_der_test()
       
   692     //comp(rd_string_gen(3,6).toList, random_struct_gen(7))
       
   693     //newxp1()
   675   //contains7()
   694   //contains7()
   676   //retrieve_encode_STARS()
   695   //retrieve_encode_STARS()
   677     //check_all()   
   696     //check_all()   
   678     //radical_correctness()
   697     //radical_correctness()
   679     //correctness_proof_convenient_path()
   698     //correctness_proof_convenient_path()