public static List<EdgeAggregator> Instantiate(GroundedClause clause)
        {
            annotation.active = EngineUIBridge.JustificationSwitch.ANGLES_OF_EQUAL_MEASUREARE_CONGRUENT;

            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

            AngleEquation newAngEq = clause as AngleEquation;
            if (newAngEq == null) return newGrounded;

            // One side must be atomic
            int atomicity = newAngEq.GetAtomicity();
            if (atomicity != Equation.BOTH_ATOMIC) return newGrounded;

            // Split the information into the angle and its measure
            KeyValuePair<Angle, double> newAngleAndMeasure = ExtractFromEquation(newAngEq);

            // If splitting failed, we are not interested in the equation
            if (newAngleAndMeasure.Key == null) return newGrounded;

            // Can we create any new congruence relationships comparing numeric (deduced angle measure) values?
            foreach (AngleEquation oldEq in candiateAngleEquations)
            {
                KeyValuePair<Angle, double> oldEqAngle = ExtractFromEquation(oldEq);

                // Avoid generating equivalent angles
                if (!newAngleAndMeasure.Key.Equates(oldEqAngle.Key))
                {
                    // Do the angles have the same measure
                    if (Utilities.CompareValues(newAngleAndMeasure.Value, oldEqAngle.Value))
                    {
                        AlgebraicCongruentAngles acas = new AlgebraicCongruentAngles(newAngleAndMeasure.Key, oldEqAngle.Key);

                        // For hypergraph construction
                        List<GroundedClause> antecedent = new List<GroundedClause>();
                        antecedent.Add(newAngEq);
                        antecedent.Add(oldEq);

                        newGrounded.Add(new EdgeAggregator(antecedent, acas, annotation));
                    }
                }
            }

            // Add to the list for future reference
            candiateAngleEquations.Add(newAngEq);

            return newGrounded;
        }
Пример #2
0
        public static List<GenericInstantiator.EdgeAggregator> CreateTransitiveCongruence(Congruent congruent1, Congruent congruent2)
        {
            List<GenericInstantiator.EdgeAggregator> newGrounded = new List<GenericInstantiator.EdgeAggregator>();

            //
            // Create the antecedent clauses
            //
            List<GroundedClause> antecedent = new List<GroundedClause>();
            antecedent.Add(congruent1);
            antecedent.Add(congruent2);

            //
            // Create the consequent clause
            //
            Congruent newCC = null;
            if (congruent1 is CongruentSegments)
            {
                CongruentSegments css1 = congruent1 as CongruentSegments;
                CongruentSegments css2 = congruent2 as CongruentSegments;

                Segment shared = css1.SegmentShared(css2);

                newCC = new AlgebraicCongruentSegments(css1.OtherSegment(shared), css2.OtherSegment(shared));
            }
            else if (congruent1 is CongruentAngles)
            {
                CongruentAngles cas1 = congruent1 as CongruentAngles;
                CongruentAngles cas2 = congruent2 as CongruentAngles;

                Angle shared = cas1.AngleShared(cas2);

                newCC = new AlgebraicCongruentAngles(cas1.OtherAngle(shared), cas2.OtherAngle(shared));
            }

            if (newCC == null)
            {
                System.Diagnostics.Debug.WriteLine("");
                throw new NullReferenceException("Unexpected Problem in Atomic substitution...");
            }

            newGrounded.Add(new GenericInstantiator.EdgeAggregator(antecedent, newCC, annotation));

            return newGrounded;
        }