diff -r 3cc1799daf08 -r ffbc65112d48 progs/enfa.scala --- a/progs/enfa.scala Tue Apr 25 12:33:16 2017 +0100 +++ b/progs/enfa.scala Fri Apr 28 11:01:25 2017 +0100 @@ -1,5 +1,5 @@ // epsilon NFAs...immediately translated into NFAs -// (needs nfa.scala) +// (needs :load nfa.scala in REPL) // fixpoint construction import scala.annotation.tailrec @@ -37,3 +37,29 @@ { case (q, c) => nexts(Set(q), c) }, q => ecl(Set(q)) exists fins) } + + +// eNFA examples +val enfa_trans1 : (State, Option[Char]) :=> Set[State] = + { case (Q0, Some('a')) => Set(Q0) + case (Q0, None) => Set(Q1, Q2) + case (Q1, Some('a')) => Set(Q1) + case (Q2, Some('b')) => Set(Q2) + } + +val enfa1 = eNFA(Set[State](Q0), enfa_trans1, Set[State](Q2)) + + +// +case object R1 extends State +case object R2 extends State +case object R3 extends State + +val enfa_trans2 : (State, Option[Char]) :=> Set[State] = + { case (R1, Some('b')) => Set(R3) + case (R1, None) => Set(R2) + case (R2, Some('a')) => Set(R1, R3) + } + + +val enfa2 = eNFA(Set[State](R1), enfa_trans1, Set[State](R3))