4 def F_ALT(f1: Val => Val, f2: Val => Val) = (v:Val) => v match { | 
     4 def F_ALT(f1: Val => Val, f2: Val => Val) = (v:Val) => v match { | 
     5   case Right(v) => Right(f2(v))  | 
     5   case Right(v) => Right(f2(v))  | 
     6   case Left(v) => Left(f1(v))  | 
     6   case Left(v) => Left(f1(v))  | 
     7 }  | 
     7 }  | 
     8 def F_SEQ(f1: Val => Val, f2: Val => Val) = (v:Val) => v match { | 
     8 def F_SEQ(f1: Val => Val, f2: Val => Val) = (v:Val) => v match { | 
     9   case Seq(v1, v2) => Seq(f1(v1), f2(v2))  | 
     9   case Sequ(v1, v2) => Sequ(f1(v1), f2(v2))  | 
    10 }  | 
    10 }  | 
    11 def F_SEQ_Empty1(f1: Val => Val, f2: Val => Val) =   | 
    11 def F_SEQ_Empty1(f1: Val => Val, f2: Val => Val) =   | 
    12   (v:Val) => Seq(f1(Empty), f2(v))  | 
    12   (v:Val) => Sequ(f1(Empty), f2(v))  | 
    13 def F_SEQ_Empty2(f1: Val => Val, f2: Val => Val) =   | 
    13 def F_SEQ_Empty2(f1: Val => Val, f2: Val => Val) =   | 
    14   (v:Val) => Seq(f1(v), f2(Empty))  | 
    14   (v:Val) => Sequ(f1(v), f2(Empty))  | 
    15 def F_ERROR(v: Val): Val = throw new Exception("error") | 
    15 def F_ERROR(v: Val): Val = throw new Exception("error") | 
    16   | 
    16   | 
    17 // simplification of regular expressions returning also a  | 
    17 // simplification of regular expressions returning also a  | 
    18 // rectification function; no simplification under STAR   | 
    18 // rectification function; no simplification under STAR   | 
    19 def simp(r: Rexp): (Rexp, Val => Val) = r match { | 
    19 def simp(r: Rexp): (Rexp, Val => Val) = r match { |