thys2/blexer2.sc
changeset 573 454ced557605
parent 564 3cbcd7cda0a9
child 591 b2d0de6aee18
--- a/thys2/blexer2.sc	Sat Jul 16 18:34:46 2022 +0100
+++ b/thys2/blexer2.sc	Thu Jul 21 20:21:52 2022 +0100
@@ -1466,35 +1466,42 @@
   }
 }
 // aaa_star()
+
+def matching_ways_counting(n: Int): Int = 
+  {
+    if(n == 0) 1
+    else if(n == 1) 2
+    else (for(i <- 1 to n - 1) 
+      yield matching_ways_counting(i) * matching_ways_counting(n - i) ).sum + (n + 1)
+  }
 def naive_matcher() {
   val r = STAR(STAR("a") ~ STAR("a"))
 
-  for(i <- 0 to 20) {
-    val s = "a" * i 
-    val t1 = System.nanoTime
-    matcher(s, r)
-    val duration = (System.nanoTime - t1) / 1e9d
-    print(i)
-    print(" ")
-    // print(duration)
-    // print(" ")
-    print(asize(bders_simp(s.toList, internalise(r))))
-    //print(size(ders_simp(s.toList, r)))
-    println()
-  }
-  // for(i <- 1 to 40000000 by 500000) {
-  //   val s = "a" * i
+  // for(i <- 0 to 10) {
+  //   val s = "a" * i 
   //   val t1 = System.nanoTime
-  //   val derssimp_result = ders_simp(s.toList, r)
+  //   matcher(s, r)
   //   val duration = (System.nanoTime - t1) / 1e9d
   //   print(i)
   //   print(" ")
-  //   print(duration)
+  //   // print(duration)
+  //   // print(" ")
+  //   (aprint(bders_simp(s.toList, internalise(r))))
+  //   //print(size(ders_simp(s.toList, r)))
   //   println()
   // }
+  for(i <- 1 to 3) {
+    val s = "a" * i
+    val t1 = System.nanoTime
+    val derssimp_result = ders_simp(s.toList, r)
+    println(i)
+    println(matching_ways_counting(i))
+    println(size(derssimp_result))
+    rprint(derssimp_result)
+  }
   
 }
-// naive_matcher()
+naive_matcher()
 //single(SEQ(SEQ(STAR(CHAR('b')),STAR(STAR(SEQ(CHAR('a'),CHAR('b'))))),
 //  SEQ(SEQ(CHAR('b'),STAR(ALTS(CHAR('a'),ONE))),ONE)))