anchor.diff:          |Some old -> oldAst
           |None -> Some newAst
   
  -    let rec isContainPref (ast:AstNode option) (curAstPrefix:LabledPrefix<_>) (wasAstStarts:ResizeArray<AstNode> option) (findAst:AstNode option) (findPrefix:LabledPrefix<_>) (wasFindStarts:ResizeArray<AstNode> option) =    //to do
  -        if curAstPrefix = findPrefix    //bad compare
  -        then
  -            true
  +//to do add epsilon cases (think about epsilon cycle)
  +    let rec isContainPref (ast:AstNode option) (curAstPrefix:LabledPrefix<_>) (wasAstStarts:ResizeArray<AstNode> option) (findAst:AstNode option) (findPrefix:LabledPrefix<_>) (wasFindStarts:ResizeArray<AstNode> option) 
  +                            (wasAstPrefixes:ResizeArray<LabledPrefix<_>>) (wasFindPrefixes:ResizeArray<LabledPrefix<_>>) =    //to do
  +
  +        if wasAstPrefixes.Contains(curAstPrefix) || wasFindPrefixes.Contains(findPrefix)
  +        then
  +            false
           else
  -            match (curAstPrefix, findPrefix) with
  -            |(Pref astPref, Pref findPref) ->
  -                if astPref.Head = findPref.Head
  -                then
  -                    findPref.Tail.All(fun findTail -> astPref.Tail.Any(fun astTail -> isContainPref ast astTail None findAst findTail None))
  -                else
  +            let newWasAst = new ResizeArray<LabledPrefix<_>>()
  +            newWasAst.AddRange(wasAstPrefixes)
  +            newWasAst.Add(curAstPrefix)
  +            let newWasFind = new ResizeArray<LabledPrefix<_>>()
  +            newWasFind.AddRange(wasFindPrefixes)
  +            newWasFind.Add(findPrefix)
  +            if curAstPrefix = findPrefix    //bad compare
  +            then
  +                true
  +            else
  +                match (curAstPrefix, findPrefix) with
  +                |(Epsilon (gssV, astEpsPrefixes), _) ->
  +                    astEpsPrefixes.Any(fun astEpsPref -> isContainPref ast astEpsPref None findAst findPrefix wasFindStarts newWasAst newWasFind)
  +                |(_, Epsilon (gssV, findEpsPrefixes)) ->
  +                    findEpsPrefixes.All(fun findEpsPref -> isContainPref ast curAstPrefix wasAstStarts findAst findEpsPref None newWasAst newWasFind)
  +                |(Pref astPref, Pref findPref) ->
  +                    if astPref.Head = findPref.Head
  +                    then
  +                        findPref.Tail.All(fun findTail -> astPref.Tail.Any(fun astTail -> isContainPref ast astTail None findAst findTail None newWasAst newWasFind))
  +                    else
  +                        false
  +                |(Pref astPref, NontermStart (curFindAst, findAstPrefixes)) ->
  +                    let nextFindAst = getNewAst findAst curFindAst
  +                    match wasFindStarts with
  +                    |Some starts ->
  +                        if starts.Contains(curFindAst)
  +                        then
  +                            true
  +                        else
  +                            starts.Add(curFindAst)
  +                            findAstPrefixes.All(fun findAstPrefix -> isContainPref ast curAstPrefix wasAstStarts nextFindAst findAstPrefix wasFindStarts newWasAst newWasFind)
  +                    |None ->
  +                        let newWasFindStarts = new ResizeArray<_>()
  +                        newWasFindStarts.Add(curFindAst)
  +                        findAstPrefixes.All(fun findAstPrefix -> isContainPref ast curAstPrefix wasAstStarts nextFindAst findAstPrefix (Some newWasFindStarts) newWasAst newWasFind)
  +                |(Pref astPref, NontermEnd (curFindAst, findAstPrefixes)) ->
  +                    match findAst with
  +                    |Some fast ->
  +                        if fast = curFindAst
  +                        then
  +                            findAstPrefixes.All(fun findAstPrefix -> isContainPref ast curAstPrefix None None findAstPrefix None newWasAst newWasFind)
  +                        else
  +                            true
  +                    |None ->
  +                        true
  +                |(Pref astPref, End) ->
                       false
  -            |(Pref astPref, NontermStart (curFindAst, findAstPrefixes)) ->
  -                let nextFindAst = getNewAst findAst curFindAst
  -                match wasFindStarts with
  -                |Some starts ->
  -                    if starts.Contains(curFindAst)
  -                    then
  -                        true
  -                    else
  -                        starts.Add(curFindAst)
  -                        findAstPrefixes.All(fun findAstPrefix -> isContainPref ast curAstPrefix wasAstStarts nextFindAst findAstPrefix wasFindStarts)
  -                |None ->
  -                    let newWasFindStarts = new ResizeArray<_>()
  -                    newWasFindStarts.Add(curFindAst)
  -                    findAstPrefixes.All(fun findAstPrefix -> isContainPref ast curAstPrefix wasAstStarts nextFindAst findAstPrefix (Some newWasFindStarts))
  -            |(Pref astPref, NontermEnd (curFindAst, findAstPrefixes)) ->
  -                match findAst with
  -                |Some fast ->
  -                    if fast = curFindAst
  -                    then
  -                        findAstPrefixes.All(fun findAstPrefix -> isContainPref ast curAstPrefix None None findAstPrefix None)
  -                    else
  -                        true
  -                |None ->
  -                    true
  -            |(Pref astPref, End) ->
  -                false
  -            |(NontermStart (newAst, newAstPrefixes), Pref findPref) ->
  -                let nextAst = getNewAst ast newAst
  -                match wasAstStarts with
  -                |Some starts ->
  -                    if starts.Contains(newAst)
  -                    then
  -                        false
  -                    else
  -                        starts.Add(newAst)
  -                        newAstPrefixes.Any(fun newAstPrefix -> isContainPref nextAst newAstPrefix wasAstStarts findAst findPrefix wasFindStarts)
  -                |None ->
  -                    let newWasAstStarts = new ResizeArray<_>()
  -                    newWasAstStarts.Add(newAst)
  -                    newAstPrefixes.Any(fun newAstPrefix -> isContainPref nextAst newAstPrefix (Some newWasAstStarts) findAst findPrefix wasFindStarts)
  -            |(NontermStart (newAst, newAstPrefixes), NontermStart (curFindAst, findAstPrefixes)) ->
  -                let nextFindAst = getNewAst findAst curFindAst
  -                let nextAst = getNewAst ast newAst
  -                match (wasAstStarts, wasFindStarts) with
  -                |(Some astStarts, Some findStarts) ->
  -                    if findStarts.Contains(curFindAst)
  -                    then
  -                        true
  -                    else
  -                        if astStarts.Contains(newAst)
  +                |(NontermStart (newAst, newAstPrefixes), Pref findPref) ->
  +                    let nextAst = getNewAst ast newAst
  +                    match wasAstStarts with
  +                    |Some starts ->
  +                        if starts.Contains(newAst)
                           then
                               false
                           else
  -                            findStarts.Add(curFindAst)
  -                            astStarts.Add(newAst)
  -                            findAstPrefixes.All(fun findAstPrefix -> newAstPrefixes.Any(fun newAstPrefix -> isContainPref nextAst newAstPrefix wasAstStarts nextFindAst findAstPrefix wasFindStarts))
  -                |(Some astStarts, None) ->
  -                    if astStarts.Contains(newAst)
  -                    then
  -                        false
  -                    else
  -                        astStarts.Add(newAst)
  -                        let newWasFindStarts = new ResizeArray<_>()
  -                        newWasFindStarts.Add(curFindAst)
  -                        findAstPrefixes.All(fun findAstPrefix -> newAstPrefixes.Any(fun newAstPrefix -> isContainPref nextAst newAstPrefix wasAstStarts nextFindAst findAstPrefix (Some newWasFindStarts)))
  -                |(None, Some findStarts) ->
  -                    if findStarts.Contains(curFindAst)
  -                    then
  -                        true
  -                    else
  -                        findStarts.Add(curFindAst)
  +                            starts.Add(newAst)
  +                            newAstPrefixes.Any(fun newAstPrefix -> isContainPref nextAst newAstPrefix wasAstStarts findAst findPrefix wasFindStarts newWasAst newWasFind)
  +                    |None ->
                           let newWasAstStarts = new ResizeArray<_>()
                           newWasAstStarts.Add(newAst)
  -                        findAstPrefixes.All(fun findAstPrefix -> newAstPrefixes.Any(fun newAstPrefix -> isContainPref nextAst newAstPrefix (Some newWasAstStarts) nextFindAst findAstPrefix wasFindStarts))
  -
  -                |(None, None) ->
  -                    let newWasFindStarts = new ResizeArray<_>()
  -                    newWasFindStarts.Add(curFindAst)
  -                    let newWasAstStarts = new ResizeArray<_>()
  -                    newWasAstStarts.Add(newAst)
  -                    findAstPrefixes.All(fun findAstPrefix -> newAstPrefixes.Any(fun newAstPrefix -> isContainPref nextAst newAstPrefix (Some newWasAstStarts) nextFindAst findAstPrefix (Some newWasFindStarts)))
  -            |(NontermStart (newAst, newAstPrefixes), NontermEnd (curFindAst, findAstPrefixes)) ->
  -                let nextAst = getNewAst ast newAst
  -                match findAst with
  -                |Some fast ->
  -                    if fast = curFindAst
  -                    then
  -                        match wasAstStarts with
  -                        |Some starts ->
  -                            if starts.Contains(newAst)
  +                        newAstPrefixes.Any(fun newAstPrefix -> isContainPref nextAst newAstPrefix (Some newWasAstStarts) findAst findPrefix wasFindStarts newWasAst newWasFind)
  +                |(NontermStart (newAst, newAstPrefixes), NontermStart (curFindAst, findAstPrefixes)) ->
  +                    let nextFindAst = getNewAst findAst curFindAst
  +                    let nextAst = getNewAst ast newAst
  +                    match (wasAstStarts, wasFindStarts) with
  +                    |(Some astStarts, Some findStarts) ->
  +                        if findStarts.Contains(curFindAst)
  +                        then
  +                            true
  +                        else
  +                            if astStarts.Contains(newAst)
                               then
                                   false
                               else
  -                                starts.Add(newAst)
  -                                findAstPrefixes.All(fun findAstPrefix -> newAstPrefixes.Any(fun newAstPrefix -> isContainPref nextAst newAstPrefix wasAstStarts None findAstPrefix wasFindStarts))
  -                        |None ->
  +                                findStarts.Add(curFindAst)
  +                                astStarts.Add(newAst)
  +                                findAstPrefixes.All(fun findAstPrefix -> newAstPrefixes.Any(fun newAstPrefix -> isContainPref nextAst newAstPrefix wasAstStarts nextFindAst findAstPrefix wasFindStarts newWasAst newWasFind))
  +                    |(Some astStarts, None) ->
  +                        if astStarts.Contains(newAst)
  +                        then
  +                            false
  +                        else
  +                            astStarts.Add(newAst)
  +                            let newWasFindStarts = new ResizeArray<_>()
  +                            newWasFindStarts.Add(curFindAst)
  +                            findAstPrefixes.All(fun findAstPrefix -> newAstPrefixes.Any(fun newAstPrefix -> isContainPref nextAst newAstPrefix wasAstStarts nextFindAst findAstPrefix (Some newWasFindStarts) newWasAst newWasFind))
  +                    |(None, Some findStarts) ->
  +                        if findStarts.Contains(curFindAst)
  +                        then
  +                            true
  +                        else
  +                            findStarts.Add(curFindAst)
                               let newWasAstStarts = new ResizeArray<_>()
                               newWasAstStarts.Add(newAst)
  -                            findAstPrefixes.All(fun findAstPrefix -> newAstPrefixes.Any(fun newAstPrefix -> isContainPref nextAst newAstPrefix (Some newWasAstStarts) None findAstPrefix wasFindStarts))
  -                    else 
  +                            findAstPrefixes.All(fun findAstPrefix -> newAstPrefixes.Any(fun newAstPrefix -> isContainPref nextAst newAstPrefix (Some newWasAstStarts) nextFindAst findAstPrefix wasFindStarts newWasAst newWasFind))
  +
  +                    |(None, None) ->
  +                        let newWasFindStarts = new ResizeArray<_>()
  +                        newWasFindStarts.Add(curFindAst)
  +                        let newWasAstStarts = new ResizeArray<_>()
  +                        newWasAstStarts.Add(newAst)
  +                        findAstPrefixes.All(fun findAstPrefix -> newAstPrefixes.Any(fun newAstPrefix -> isContainPref nextAst newAstPrefix (Some newWasAstStarts) nextFindAst findAstPrefix (Some newWasFindStarts) newWasAst newWasFind))
  +                |(NontermStart (newAst, newAstPrefixes), NontermEnd (curFindAst, findAstPrefixes)) ->
  +                    let nextAst = getNewAst ast newAst
  +                    match findAst with
  +                    |Some fast ->
  +                        if fast = curFindAst
  +                        then
  +                            match wasAstStarts with
  +                            |Some starts ->
  +                                if starts.Contains(newAst)
  +                                then
  +                                    false
  +                                else
  +                                    starts.Add(newAst)
  +                                    findAstPrefixes.All(fun findAstPrefix -> newAstPrefixes.Any(fun newAstPrefix -> isContainPref nextAst newAstPrefix wasAstStarts None findAstPrefix wasFindStarts newWasAst newWasFind))
  +                            |None ->
  +                                let newWasAstStarts = new ResizeArray<_>()
  +                                newWasAstStarts.Add(newAst)
  +                                findAstPrefixes.All(fun findAstPrefix -> newAstPrefixes.Any(fun newAstPrefix -> isContainPref nextAst newAstPrefix (Some newWasAstStarts) None findAstPrefix wasFindStarts newWasAst newWasFind))
  +                        else 
  +                            true
  +                    |None ->
                           true
  -                |None ->
  -                    true
  -            |(NontermStart (newAst, newAstPrefixes), End) ->
  -                false //can newAst contain empty path?
  -            |(NontermEnd (newAst, newAstPrefixes), Pref findPref) ->
  -                match ast with
  -                |Some xast ->
  -                    if xast = newAst
  -                    then
  -                        newAstPrefixes.Any(fun newAstPrefix -> isContainPref None newAstPrefix None findAst findPrefix None)
  -                    else
  +                |(NontermStart (newAst, newAstPrefixes), End) ->
  +                    false //can newAst contain empty path?
  +                |(NontermEnd (newAst, newAstPrefixes), Pref findPref) ->
  +                    match ast with
  +                    |Some xast ->
  +                        if xast = newAst
  +                        then
  +                            newAstPrefixes.Any(fun newAstPrefix -> isContainPref None newAstPrefix None findAst findPrefix None newWasAst newWasFind)
  +                        else
  +                            false
  +                    |None ->
                           false
  -                |None ->
  -                    false
  -            |(NontermEnd (newAst, newAstPrefixes), NontermStart (curFindAst, findAstPrefixes)) ->
  -                let nextFindAst = getNewAst findAst curFindAst
  -                match ast with
  -                |Some xast ->
  -                    if xast = newAst
  -                    then
  -                        match wasFindStarts with
  -                        |Some starts ->
  -                            if starts.Contains(curFindAst)
  +                |(NontermEnd (newAst, newAstPrefixes), NontermStart (curFindAst, findAstPrefixes)) ->
  +                    let nextFindAst = getNewAst findAst curFindAst
  +                    match ast with
  +                    |Some xast ->
  +                        if xast = newAst
  +                        then
  +                            match wasFindStarts with
  +                            |Some starts ->
  +                                if starts.Contains(curFindAst)
  +                                then
  +                                    true
  +                                else
  +                                    starts.Add(curFindAst)
  +                                    findAstPrefixes.All(fun findAstPrefix -> newAstPrefixes.Any(fun newAstPrefix -> isContainPref None newAstPrefix wasAstStarts nextFindAst findAstPrefix wasFindStarts newWasAst newWasFind))
  +                            |None ->
  +                                let newWasFindStarts = new ResizeArray<_>()
  +                                newWasFindStarts.Add(curFindAst)
  +                                findAstPrefixes.All(fun findAstPrefix -> newAstPrefixes.Any(fun newAstPrefix -> isContainPref None newAstPrefix wasAstStarts nextFindAst findAstPrefix (Some newWasFindStarts) newWasAst newWasFind))
  +                        else
  +                            false
  +                    |None ->
  +                        false
  +                |(NontermEnd (newAst, newAstPrefixes), NontermEnd (curFindAst, findAstPrefixes)) ->
  +                    match (ast, findAst) with
  +                    |(Some xast, Some fast) ->
  +                        if xast = newAst
  +                        then
  +                            if fast = curFindAst
                               then
  +                                findAstPrefixes.All(fun findAstPrefix -> newAstPrefixes.Any(fun newAstPrefix -> isContainPref None newAstPrefix None None findAstPrefix None newWasAst newWasFind))
  +                            else
                                   true
  +                        else
  +                            if fast = curFindAst
  +                            then
  +                                false
                               else
  -                                starts.Add(curFindAst)
  -                                findAstPrefixes.All(fun findAstPrefix -> newAstPrefixes.Any(fun newAstPrefix -> isContainPref None newAstPrefix wasAstStarts nextFindAst findAstPrefix wasFindStarts))
  -                        |None ->
  -                            let newWasFindStarts = new ResizeArray<_>()
  -                            newWasFindStarts.Add(curFindAst)
  -                            findAstPrefixes.All(fun findAstPrefix -> newAstPrefixes.Any(fun newAstPrefix -> isContainPref None newAstPrefix wasAstStarts nextFindAst findAstPrefix (Some newWasFindStarts)))
  -                    else
  -                        false
  -                |None ->
  -                    false
  -            |(NontermEnd (newAst, newAstPrefixes), NontermEnd (curFindAst, findAstPrefixes)) ->
  -                match (ast, findAst) with
  -                |(Some xast, Some fast) ->
  -                    if xast = newAst
  -                    then
  -                        if fast = curFindAst
  -                        then
  -                            findAstPrefixes.All(fun findAstPrefix -> newAstPrefixes.Any(fun newAstPrefix -> isContainPref None newAstPrefix None None findAstPrefix None))
  -                        else
  -                            true
  -                    else
  +                                true
  +
  +                    |(Some xast, None) ->
  +                        true
  +                    |(None, Some fast) ->
                           if fast = curFindAst
                           then
                               false
                           else
                               true
  -
  -                |(Some xast, None) ->
  +                    |(None , None) ->
  +                        true
  +                |(NontermEnd (newAst, newAstPrefixes), End) ->
  +                    match ast with
  +                    |Some xast ->
  +                        if xast = newAst
  +                        then
  +                            newAstPrefixes.Contains(End)
  +                        else
  +                            false
  +                    |None ->
  +                        false
  +                |(End, Pref findPref) ->
  +                    false
  +                |(End, NontermStart (curFindAst, findAstPrefixes)) ->
  +                    match wasFindStarts with
  +                    |Some starts ->
  +                        if starts.Contains(curFindAst)
  +                        then
  +                            true
  +                        else
  +                            false   //can curFindAst contain empty path?
  +                    |None ->
  +                        false   //can curFindAst contain empty path?
  +                |(End, NontermEnd (curFindAst, findAstPrefixes)) ->
  +                    match findAst with
  +                    |Some fast ->
  +                        if fast = curFindAst
  +                        then
  +                            findAstPrefixes.Contains(End)
  +                        else
  +                            true
  +                    |None ->
  +                        true
  +                |(End, End) ->
                       true
  -                |(None, Some fast) ->
  -                    if fast = curFindAst
  -                    then
  -                        false
  -                    else
  -                        true
  -                |(None , None) ->
  -                    true
  -            |(NontermEnd (newAst, newAstPrefixes), End) ->
  -                match ast with
  -                |Some xast ->
  -                    if xast = newAst
  -                    then
  -                        newAstPrefixes.Contains(End)
  -                    else
  -                        false
  -                |None ->
  -                    false
  -            |(End, Pref findPref) ->
  -                false
  -            |(End, NontermStart (curFindAst, findAstPrefixes)) ->
  -                match wasFindStarts with
  -                |Some starts ->
  -                    if starts.Contains(curFindAst)
  -                    then
  -                        true
  -                    else
  -                        false   //can curFindAst contain empty path?
  -                |None ->
  -                    false   //can curFindAst contain empty path?
  -            |(End, NontermEnd (curFindAst, findAstPrefixes)) ->
  -                match findAst with
  -                |Some fast ->
  -                    if fast = curFindAst
  -                    then
  -                        findAstPrefixes.Contains(End)
  -                    else
  -                        true
  -                |None ->
  -                    true
  -            |(End, End) ->
  -                true
   
       let collectErrors (starts:ResizeArray<VInfo<_>>)=
           let was = new ResizeArray<_>()
  
positive.code:         customEnqueue(startV)
          newVertex.addEdge edge
  
          (*let prefixes = gssVertexesToPrefixes.[newVertex]
          for lprefixToAdd in lprefixesToAdd do
              addPrefix prefixes lprefixToAdd
          for e in outEdgesInnerGraph.[startV.vNum] do
              addNonZeroReduction newVertex e.Tag edge startV*)
  
          if isNotEps
          then
              let prefixes = gssVertexesToPrefixes.[newVertex]
              for lprefixToAdd in lprefixesToAdd do
  
negative.code:                                                             | _ -> false)
                          curLevel)
              then curLevel.Add(NontermStart (ast, astPrefixes))
  
          |Epsilon (gssVertex, prefixesToAdd) ->
              if not (ResizeArray.exists
                          (fun (lprefix:LabledPrefix<_>) -> match lprefix with
                                                              |Epsilon (epsGssv, epsPrefixes) -> epsGssv = gssVertex
                                                              | _ -> false)
                          curLevel) || curLevel = prefixesToAdd   //epsilon self arrow
              then curLevel.Add(Epsilon (gssVertex, prefixesToAdd))
  
          |Pref prefixToAdd -> 
              if not (ResizeArray.exists
  