1 module FAtimes 2 3 ( timesTNFA 4 , timesTNFApublic 5 ) 6 7 where 8 9 10 import Set 11 import FiniteMap 12 13 import Stuff 14 import Options 15 16 import TA 17 import FAtypes 18 import Ids 19 20 import FAmap 21 22 import FAcheat 23 24 --------------------------------------------------------------------------- 25 26 timesTNFA :: Opts -> TCon -> TNFA Int -> TNFA Int -> TNFA Int 27 -- dot product of two langugaes. 28 -- replaces one specified nullary constructor of the first language 29 -- with an epsilon trasition to the second language 30 timesTNFA opts tc 31 a @ (TNFA cons1 all1 starts1 moves1) 32 b = 33 let 34 m = 1 + maximum (0 : setToList all1) 35 TNFA cons2 all2 starts2 moves2 = mapTNFA opts (\ n -> n + m) b 36 37 -- all that can be constructed from the start 38 startmoves2 = starts2 `bind` (lookupset moves2) 39 40 change t = if stcon t == tc then startmoves2 else unitSet t 41 42 moves3 = mapFM (\ v ts -> ts `bind` change) moves1 43 44 cons = (cons1 `minusSet` unitSet tc) `unionSet` cons2 45 all = all1 `unionSet` all2 46 moves = plusFM_C (error "timesTNFA.moves") moves3 moves2 47 48 c = TNFA cons all starts1 moves 49 in 50 51 trinfo opts "times" c $ 52 c 53 54 55 timesTNFApublic :: Opts -> [TNFA Int] -> TNFA Int 56 timesTNFApublic opts args = 57 if length args /= 3 58 then error "timesTNFApublic.args" 59 else 60 let [tcarg, arg1, arg2] = args 61 in timesTNFA opts (cheat tcarg) arg1 arg2