anchor.diff:              compute l mid |> ignore
               if mid < stringSize + 1 then
                   compute mid m |> ignore
  +
           if mid < stringSize + 1 then
               completeT (l, mid, mid, m)
   
       and completeT (l1, m1, l2, m2) =
           assert (m1 - l1 = m2 - l2)
   
  +        let addProbToMatrix (matrix: Map<_, double [,]>) row column key prob = 
  +                (matrix.Item key).[row, column] <- (matrix.Item key).[row, column] + prob
  +                
  +        let updateTMatrixCell row column (nonTerm, prob) = addProbToMatrix tMatrix row column nonTerm prob
  +
           if m1 - l1 = 1 && m1 = l2 then
               let currentChar = strToParse.[l1]
  -            srl.Item currentChar |> List.map (fun (nt, prob) -> (tMatrix.Item nt).[l1, l1 + 1] <- prob) |> ignore
  +            let nonTerms = simpleRules.Item currentChar
  +
  +            nonTerms
  +            |> List.iter (updateTMatrixCell l1 (l1 + 1))
  +
           else if m1 - l1 = 1 && m1 < l2 then
  +            assert (m2 <= stringSize + 1)
  +
               let headsFromTail (tail, tailProb) = 
  -                if crl.ContainsKey tail then 
  -                    crl.Item tail |> List.map (fun (head, headProb) -> (head, headProb * tailProb)) 
  +                if complexRules.ContainsKey tail then 
  +                    complexRules.Item tail |> List.map (fun (head, headProb) -> head, headProb * tailProb)
                   else 
                       []
   
               let tails = pMatrix |> Map.map (fun _ probs -> probs.[l1, l2]) |> Map.filter (fun _ prob -> prob > 0.)
  -            let heads = tails |> Map.toSeq |> Seq.map headsFromTail |> Seq.concat
  -
  -            heads |> Seq.map (fun (head, prob) -> (tMatrix.Item head).[l1, l2] <- (tMatrix.Item head).[l1, l2] + prob) |> List.ofSeq |> ignore
  +            let heads = tails |> Map.toList |> List.map headsFromTail |> List.concat
  +
  +            heads 
  +            |> List.iter (updateTMatrixCell l1 l2)
   
           else if m1 - l1 > 1 then
  +            assert (l2 < stringSize + 1)
  +
               let mid1: int = int (l1 + m1) / 2
               let mid2: int = int (l2 + m2) / 2
   
  
positive.code: //    B -> 'b', 0.4
  //    B -> 'b', 0.4
  
      let check str res = 
          let toCheck = recognize str crl srl erl nonterminals S
  //        printfn "%.10f" toCheck |> ignore
          assert (abs(res - toCheck) < 1e-14) 
        
  
      check "abb"     0.032        |> ignore    
      check "aaabbcc" 0.0000524288 |> ignore
  
  
  //    System.Console.ReadLine() |> ignore
      0
negative.code:                                     
      let completeP where from1 from2 = 
          let completeOnePair (nt1, nt2) =
                  addToP (nt1, nt2) (subMatrixMult tMatrix.[nt1] tMatrix.[nt2] from1 from2) where
          pMatrix |> Map.iter (fun nts _ -> completeOnePair nts)
  
      
      let rec compute l m =
  