//
        // Append subtraction to this current problem; the subtraction occurs within the inner figure (shape).
        //
        public static FigSynthProblem AppendFigureSubtraction(FigSynthProblem that, FigSynthProblem toAppend)
        {
            BinarySynthOperation binaryAppend = toAppend as BinarySynthOperation;

            if (binaryAppend == null)
            {
                return(null);
            }

            if (that is SubtractionSynth)
            {
                // Verify that the outer part of toAppend is a figure in this problem.
                Figure          theShape         = (binaryAppend.leftProblem as UnarySynth).figure;
                FigSynthProblem leftShapeProblem = that.GetSynthByShape(theShape);

                if (leftShapeProblem == null)
                {
                    throw new ArgumentException("Shape is not in the given problem: " + theShape);
                }

                //
                // Create the new subtraction node and insert it into the copy.
                //
                // Since the 'left' expression was a shape, the 'right' is the actual shape we are appending.
                SubtractionSynth newSub = new SubtractionSynth(leftShapeProblem, binaryAppend.rightProblem);

                return(that.Copy().ReplaceUnary(theShape, newSub));
            }
            else if (that is AdditionSynth)
            {
                // Verify that the external form of that matches with the LHS of toAppend.
                Polygon outerPoly = Polygon.MakePolygon(that.GetExteriorSegments());
                if (!outerPoly.StructurallyEquals((binaryAppend.leftProblem as UnarySynth).figure))
                {
                    throw new ArgumentException("Exterior polygons do not match: " + (binaryAppend.leftProblem as UnarySynth).figure);
                }

                // Make a copy of that.
                return(new SubtractionSynth(that.Copy(), (binaryAppend.rightProblem as UnarySynth).figure));
            }
            else
            {
                throw new ArgumentException("Expected Addition or Subtraction; acquired neither.");
            }
        }
        //
        // Append subtraction to this current problem; the subtraction occurs within the inner figure (shape).
        //
        public static FigSynthProblem AppendFigureSubtraction(FigSynthProblem that, FigSynthProblem toAppend)
        {
            BinarySynthOperation binaryAppend = toAppend as BinarySynthOperation;
            if (binaryAppend == null) return null;

            if (that is SubtractionSynth)
            {
                // Verify that the outer part of toAppend is a figure in this problem.
                Figure theShape = (binaryAppend.leftProblem as UnarySynth).figure;
                FigSynthProblem leftShapeProblem = that.GetSynthByShape(theShape);

                if (leftShapeProblem == null)
                {
                    throw new ArgumentException("Shape is not in the given problem: " + theShape);
                }

                //
                // Create the new subtraction node and insert it into the copy.
                //
                // Since the 'left' expression was a shape, the 'right' is the actual shape we are appending.
                SubtractionSynth newSub = new SubtractionSynth(leftShapeProblem, binaryAppend.rightProblem);

                return that.Copy().ReplaceUnary(theShape, newSub);
            }
            else if (that is AdditionSynth)
            {
                // Verify that the external form of that matches with the LHS of toAppend.
                Polygon outerPoly = Polygon.MakePolygon(that.GetExteriorSegments());
                if (!outerPoly.StructurallyEquals((binaryAppend.leftProblem as UnarySynth).figure))
                {
                    throw new ArgumentException("Exterior polygons do not match: " + (binaryAppend.leftProblem as UnarySynth).figure);
                }

                // Make a copy of that.
                return new SubtractionSynth(that.Copy(), (binaryAppend.rightProblem as UnarySynth).figure);
            }
            else throw new ArgumentException("Expected Addition or Subtraction; acquired neither.");
        }