public static List<EdgeAggregator> Instantiate(GroundedClause c) { annotation.active = EngineUIBridge.JustificationSwitch.SEGMENT_ADDITION_AXIOM; List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); InMiddle im = c as InMiddle; if (im == null) return newGrounded; Segment s1 = new Segment(im.segment.Point1, im.point); Segment s2 = new Segment(im.point, im.segment.Point2); Addition sum = new Addition(s1, s2); GeometricSegmentEquation eq = new GeometricSegmentEquation(sum, im.segment); eq.MakeAxiomatic(); // For hypergraph List<GroundedClause> antecedent = Utilities.MakeList<GroundedClause>(im); newGrounded.Add(new EdgeAggregator(antecedent, eq, annotation)); return newGrounded; }
public static List<EdgeAggregator> InstantiateMidpointTheorem(GroundedClause original, Midpoint midpt) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); // Construct 2AM Multiplication product1 = new Multiplication(new NumericValue(2), new Segment(midpt.point, midpt.segment.Point1)); // Construct 2BM Multiplication product2 = new Multiplication(new NumericValue(2), new Segment(midpt.point, midpt.segment.Point2)); // 2X = AB GeometricSegmentEquation newEq1 = new GeometricSegmentEquation(product1, midpt.segment); GeometricSegmentEquation newEq2 = new GeometricSegmentEquation(product2, midpt.segment); // For hypergraph List<GroundedClause> antecedent = Utilities.MakeList<GroundedClause>(original); newGrounded.Add(new EdgeAggregator(antecedent, newEq1, annotation)); newGrounded.Add(new EdgeAggregator(antecedent, newEq2, annotation)); return newGrounded; }
private static List<EdgeAggregator> InstantiateToTheorem(Trapezoid trapezoid, GroundedClause original) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); // If median has not been checked, check now if (!trapezoid.IsMedianChecked()) trapezoid.FindMedian(); // Generate only if the median is valid (exists in the original figure) if (!trapezoid.IsMedianValid()) return newGrounded; Addition sum = new Addition(trapezoid.baseSegment, trapezoid.oppBaseSegment); Multiplication product = new Multiplication(new NumericValue(2), trapezoid.median); GeometricSegmentEquation gseq = new GeometricSegmentEquation(product, sum); // For hypergraph List<GroundedClause> antecedent = new List<GroundedClause>(); antecedent.Add(original); newGrounded.Add(new EdgeAggregator(antecedent, gseq, annotation)); return newGrounded; }
//private static readonly string NAME = "Simplification"; // // Given an equation, simplify algebraically using the following notions: // A + A = B -> 2A = B // A + B = B + C -> A = C // A + B = 2B + C -> A = B + C // public static Equation Simplify(Equation original) { // Do we have an equation? if (original == null) throw new ArgumentException(); // Is the equation 0 = 0? This should be allowed at it indicates a tautology if (original.lhs.Equals(new NumericValue(0)) && original.rhs.Equals(new NumericValue(0))) { throw new ArgumentException("Should not have an equation that is 0 = 0: " + original.ToString()); } // // Ideally, flattening would: // Remove all subtractions -> adding a negative instead // Distribute subtraction or multiplication over addition // // Flatten the equation so that each side is a sum of atomic expressions Equation copyEq = (Equation)original.DeepCopy(); FlatEquation flattened = new FlatEquation(copyEq.lhs.CollectTerms(), copyEq.rhs.CollectTerms()); //Debug.WriteLine("Equation prior to simplification: " + flattened.ToString()); // Combine terms only on each side (do not cross =) FlatEquation combined = CombineLikeTerms(flattened); //Debug.WriteLine("Equation after like terms combined on both sides: " + combined); // Combine terms across the equal sign FlatEquation across = CombineLikeTermsAcrossEqual(combined); //Debug.WriteLine("Equation after simplifying both sides: " + across); FlatEquation constSimplify = SimplifyForMultipliersAndConstants(across); // // Inflate the equation // Equation inflated = null; GroundedClause singleLeftExp = InflateEntireSide(constSimplify.lhsExps); GroundedClause singleRightExp = InflateEntireSide(constSimplify.rhsExps); if (original is AlgebraicSegmentEquation) { inflated = new AlgebraicSegmentEquation(singleLeftExp, singleRightExp); } else if (original is GeometricSegmentEquation) { inflated = new GeometricSegmentEquation(singleLeftExp, singleRightExp); } else if (original is AlgebraicAngleEquation) { inflated = new AlgebraicAngleEquation(singleLeftExp, singleRightExp); } else if (original is GeometricAngleEquation) { inflated = new GeometricAngleEquation(singleLeftExp, singleRightExp); } else if (original is AlgebraicArcEquation) { inflated = new AlgebraicArcEquation(singleLeftExp, singleRightExp); } else if (original is GeometricArcEquation) { inflated = new GeometricArcEquation(singleLeftExp, singleRightExp); } else if (original is AlgebraicAngleArcEquation) { inflated = new AlgebraicAngleArcEquation(singleLeftExp, singleRightExp); } else if (original is GeometricAngleArcEquation) { inflated = new GeometricAngleArcEquation(singleLeftExp, singleRightExp); } // If simplifying didn't do anything, return the original equation if (inflated.Equals(original)) { return original; } // // 0 = 0 should not be allowable. // if (inflated.lhs.Equals(new NumericValue(0)) && inflated.rhs.Equals(new NumericValue(0))) { return null; } return inflated; }