public override string WriteProof()
        {
            var sb = new StringBuilder();

            _isWin = Cases.All(c => !c.BreakerWin);

            AddFigure(sb);
            BeginProof(sb);
            GeneratePossibleLists();
            GeneralizeAllBoards(sb);

            var wonBoards = new List <SuperSlimBoard>();

            for (int caseNumber = 1; caseNumber <= Cases.Count; caseNumber++)
            {
                var c      = Cases[caseNumber - 1];
                var boards = c.Boards.OrderBy(b => ToListString(b)).ToList();

                List <SuperSlimBoard> thisClaimBoards;
                if (caseNumber > 1 && !c.BreakerWin)
                {
                    thisClaimBoards = boards.SelectMany(b => new[] { b }.Union(_permutationLinked[b].Select(tup => tup.Item2))).ToList();
                }
                else
                {
                    thisClaimBoards = boards;
                }

                if (!c.BreakerWin)
                {
                    wonBoards.AddRange(thisClaimBoards);
                }

                var thisClaimBoardsTex = GeneralizeBoards(thisClaimBoards);

                sb.AppendLine();
                sb.AppendLine("\\bigskip");
                sb.AppendLine(string.Format("\\case{{{0}}}{{$B$ is one of " + thisClaimBoardsTex + ".}}", caseNumber));
                sb.AppendLine();
                sb.AppendLine("\\bigskip");

                if (c.BreakerWin)
                {
                    sb.AppendLine();

                    if (c.Superabundant)
                    {
                        sb.AppendLine("No single Kempe exchange gets from these boards to a previous case.");
                    }
                    else
                    {
                        sb.AppendLine("These boards are not superabundant.");
                    }
                }
                else if (caseNumber == 1)
                {
                    sb.AppendLine();
                    sb.AppendLine("In all these cases, $H$ is immediately colorable from the lists.");
                }
                else
                {
                    sb.AppendLine();

                    var swapCountGroups = boards.GroupBy(b => Mind.GetWinTreeInfo(b).Max(ti => ti.SwapVertices.Count)).ToList();
                    foreach (var swapCountGroup in swapCountGroups)
                    {
                        if (swapCountGroup.Key == 1)
                        {
                            sb.AppendLine("Each of the following boards can be handled by a single Kempe change that has an endpoint at infinity.");

                            foreach (var b in swapCountGroup)
                            {
                                Permutation pp;
                                var         listString = ToListString(b, out pp);

                                var treeInfo = Mind.GetWinTreeInfo(b);
                                var alpha    = Math.Min(pp[treeInfo.First().Alpha], pp[treeInfo.First().Beta]);
                                var beta     = Math.Max(pp[treeInfo.First().Alpha], pp[treeInfo.First().Beta]);
                                var groups   = treeInfo.GroupBy(ss => ss.SwapVertices[0]);

                                if (!CheckPermutationGoodNess(alpha, beta, listString, treeInfo.Select(ss => ss.SwapVertices[0]).Distinct().ToList()))
                                {
                                    sb.AppendLine();
                                    sb.AppendLine("there is badness here");
                                    sb.AppendLine();
                                }

                                sb.Append("$\\K_{" + alpha + "" + beta + ",\\infty}(" + listString + "," + groups.OrderBy(gg => gg.Key).Select(gg => gg.Key.GetActiveListIndex(b, _maxPot) + 1).Listify(null) + ")");
                                sb.AppendLine("\\Rightarrow $ " + groups.OrderBy(gg => gg.Key).Select(gg => "$" + GetChildBoardName(b, gg.First()) + "$").Listify(null) + " (Case " + treeInfo.Select(bc => GetHandledCaseNumber(b, bc)).Distinct().OrderBy(xx => xx).Listify() + ").");
                                sb.AppendLine();

                                if (_permutationLinked[b].Count > 0)
                                {
                                    sb.AppendLine();
                                    sb.AppendLine();
                                    sb.AppendLine("Free by vertex permutation: " + _permutationLinked[b].Select(ppp => "$" + ppp.Item1 + "\\Rightarrow " + ToListString(ppp.Item2) + "$").Listify());
                                    sb.AppendLine();
                                    sb.AppendLine();
                                }

                                sb.AppendLine("\\bigskip");
                                sb.AppendLine();
                            }
                        }
                        else if (swapCountGroup.Key == 2)
                        {
                            sb.AppendLine("\\bigskip");
                            sb.AppendLine();
                            sb.AppendLine("Each of the following boards can be handled by a single Kempe change.");
                            foreach (var b in swapCountGroup)
                            {
                                Permutation pp;
                                var         listString = ToListString(b, out pp);

                                var treeInfo = Mind.GetWinTreeInfo(b);
                                var alpha    = Math.Min(pp[treeInfo.First().Alpha], pp[treeInfo.First().Beta]);
                                var beta     = Math.Max(pp[treeInfo.First().Alpha], pp[treeInfo.First().Beta]);
                                var leftover = treeInfo.ToList();

                                if (!CheckPermutationGoodNess(alpha, beta, listString, treeInfo.SelectMany(ss => ss.SwapVertices).Distinct().ToList()))
                                {
                                    sb.AppendLine();
                                    sb.AppendLine("there is badness here");
                                    sb.AppendLine();
                                }

                                while (leftover.Count > 0)
                                {
                                    var commonestSwapper = Enumerable.Range(0, b._stackCount).MaxIndex(v => leftover.Count(bc => bc.SwapVertices.Contains(v)));
                                    var handledAll       = leftover.Where(bc => bc.SwapVertices.Contains(commonestSwapper)).ToList();
                                    var handled          = handledAll.Distinct(bc => bc.SwapVertices.Count == 1 ? -1 : bc.SwapVertices.Except(commonestSwapper).First()).ToList();

                                    sb.Append("$\\K_{" + alpha + "" + beta + "," + (commonestSwapper.GetActiveListIndex(b, _maxPot) + 1) + "}(" + listString);

                                    var single = handled.FirstOrDefault(bc => bc.SwapVertices.Count == 1);
                                    if (single != null)
                                    {
                                        sb.Append(",\\infty");
                                    }

                                    if (handled.Where(bc => bc.SwapVertices.Count > 1).Count() > 0)
                                    {
                                        sb.Append("," + handled.Where(bc => bc.SwapVertices.Count > 1).OrderBy(bc => bc.SwapVertices.Except(commonestSwapper).First()).Select(bc => bc.SwapVertices.Except(commonestSwapper).First().GetActiveListIndex(b, _maxPot) + 1).Listify(null));
                                    }
                                    sb.Append(")");

                                    sb.AppendLine("\\Rightarrow $ " + handled.OrderBy(bc => bc.SwapVertices.Count == 1 ? -1 : bc.SwapVertices.Except(commonestSwapper).First()).Select(bc => "$" + GetChildBoardName(b, bc) + "$").Listify(null) + " (Case " + handled.Select(bc => GetHandledCaseNumber(b, bc)).Distinct().OrderBy(xx => xx).Listify() + ").");
                                    sb.AppendLine();

                                    foreach (var bc in handledAll)
                                    {
                                        leftover.Remove(bc);
                                    }
                                }

                                if (_permutationLinked[b].Count > 0)
                                {
                                    sb.AppendLine();
                                    sb.AppendLine();
                                    sb.AppendLine("Free by vertex permutation: " + _permutationLinked[b].Select(ppp => "$" + ppp.Item1 + "\\Rightarrow " + ToListString(ppp.Item2) + "$").Listify());
                                    sb.AppendLine();
                                    sb.AppendLine();
                                }

                                sb.AppendLine();
                                sb.AppendLine("\\bigskip");
                                sb.AppendLine();
                            }
                        }
                    }
                }
            }

            EndProof(sb);

            return(sb.ToString());
        }
Пример #2
0
 private bool AllCasesClosed()
 {
     return(Cases.All(x => x.Type.StatusStrategy.IsStatusClosed(x)));
 }