public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[2];

            theorems[0] = new Analysis.DerivativeTransformation(_entityId,
                                                                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
            {
                Builder b = context.Builder;
                ReadOnlySignalSet squares = b.Square(port.OutputSignals);
                Signal one        = IntegerValue.ConstantOne(context);
                SignalSet outputs = new SignalSet();
                for (int i = 0; i < manipulatedInputs.Count; i++)
                {
                    outputs.Add((one + squares[i]) * manipulatedInputs[i]);
                }
                return(outputs);
            });

            theorems[1] = new BasicTransformation(_entityId.DerivePostfix("TrigonometricSubstitute"), new MathIdentifier("TrigonometricSubstitute", "Std"),
                                                  delegate() { return(new Pattern(new EntityCondition(_entityId))); },
                                                  delegate(Port port) { return(ManipulationPlan.DoAlter); },
                                                  delegate(Port port, SignalSet transformedInputs, bool hasTransformedInputs)
            {
                Signal[] ret = new Signal[transformedInputs.Count];
                for (int i = 0; i < ret.Length; i++)
                {
                    ret[i] = Std.Sine(port.Context, transformedInputs[i]) / Std.Cosine(port.Context, transformedInputs[i]);
                }
                return(ret);
            });

            return(theorems);
        }
예제 #2
0
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[2];

            theorems[0] = new Analysis.DerivativeTransformation(context.Library.LookupEntity(_entityId),
                                                                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
            {
                int cnt   = manipulatedInputs.Count - 1;
                Builder b = context.Builder;

                Signal[] multiplySignals = new Signal[cnt];
                Signal[] addSignals      = new Signal[cnt];

                for (int i = 0; i < cnt; i++)
                {
                    multiplySignals[i] = port.InputSignals[i + 1];
                }
                Signal left = b.DivideSimplified(manipulatedInputs[0], multiplySignals);

                for (int i = 0; i < cnt; i++)
                {
                    for (int j = 0; j < cnt; j++)
                    {
                        multiplySignals[j] = i == j ? b.Square(port.InputSignals[j + 1]) : port.InputSignals[j + 1];
                    }
                    Signal num    = b.MultiplySimplified(port.InputSignals[0], manipulatedInputs[i + 1]);
                    addSignals[i] = b.DivideSimplified(num, multiplySignals);
                }

                return(new SignalSet(b.SubtractSimplified(left, addSignals)));
            });

            theorems[1] = new Algebra.AutoSimplifyTransformation(context.Library.LookupEntity(_entityId),
                                                                 delegate(Port port)
            {
                // TODO
                return(ManipulationPlan.DoAlter);
            },
                                                                 delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs)
            {
                if (SimplifyFactors(manipulatedInputs) || hasManipulatedInputs)
                {
                    if (manipulatedInputs.Count == 0)
                    {
                        return(new SignalSet(StdPackage.Structures.IntegerValue.ConstantMultiplicativeIdentity(context)));
                    }
                    if (manipulatedInputs.Count == 1)
                    {
                        return(manipulatedInputs);
                    }
                    return(new SignalSet(context.Builder.Divide(manipulatedInputs)));
                }
                else
                {
                    return(port.OutputSignals);
                }
            });

            return(theorems);
        }
예제 #3
0
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[2];

            theorems[0] = new Analysis.DerivativeTransformation(context.Library.LookupEntity(_entityId),
                                                                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
            {
                Builder b                    = context.Builder;
                Signal[] outputs             = new Signal[manipulatedInputs.Count];
                ReadOnlySignalSet cotangents = Std.Cotangent(context, port.InputSignals);
                for (int i = 0; i < outputs.Length; i++)
                {
                    outputs[i] = b.MultiplySimplified(port.OutputSignals[i], cotangents[i], manipulatedInputs[i]);
                }
                return(b.Negate(outputs));
            });

            theorems[1] = new BasicTransformation("CosecantTrigonometricSusbtitute", "Std", "TrigonometricSubstitute", "Std",
                                                  delegate(Port port) { return(port.Entity.EntityId.Equals("Cosecant", "Std")); },
                                                  delegate(Port port) { return(ManipulationPlan.DoAlter); },
                                                  delegate(Port port, SignalSet transformedInputs, bool hasTransformedInputs)
            {
                return(port.Context.Builder.Invert(Std.Sine(port.Context, transformedInputs)));
                //Signal[] ret = new Signal[transformedInputs.Count];
                //for(int i = 0; i < ret.Length; i++)
                //    ret[i] = port.Context.Builder.Invert(Std.Sine(port.Context, transformedInputs[i]));
                //return ret;
            });

            return(theorems);
        }
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[1];

            theorems[0] = new AutoSimplifyTransformation(new MathIdentifier("GenericMathOpAutoSimplify", "Std"),
                delegate()
                {
                    return new Pattern(new ArchitectureCondition(delegate(Architecture a) { return a.IsMathematicalOperator; }));
                },
                delegate(Port port)
                {
                    return ManipulationPlan.DoAlter;
                },
                delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs)
                {
                    if(hasManipulatedInputs)
                        port = port.Entity.InstantiatePort(context, manipulatedInputs);
                    if(port.HasArchitectureLink && port.CurrentArchitecture.IsMathematicalOperator)
                        return port.CurrentArchitecture.ExecuteMathematicalOperator();
                    else
                        return port.OutputSignals;
                });

            return theorems;
        }
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[1];

            theorems[0] = new AutoSimplifyTransformation(new MathIdentifier("GenericMathOpAutoSimplify", "Std"),
                                                         delegate()
            {
                return(new Pattern(new ArchitectureCondition(delegate(Architecture a) { return a.IsMathematicalOperator; })));
            },
                                                         delegate(Port port)
            {
                return(ManipulationPlan.DoAlter);
            },
                                                         delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs)
            {
                if (hasManipulatedInputs)
                {
                    port = port.Entity.InstantiatePort(context, manipulatedInputs);
                }
                if (port.HasArchitectureLink && port.CurrentArchitecture.IsMathematicalOperator)
                {
                    return(port.CurrentArchitecture.ExecuteMathematicalOperator());
                }
                else
                {
                    return(port.OutputSignals);
                }
            });

            return(theorems);
        }
예제 #6
0
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[2];

            theorems[0] = new Analysis.DerivativeTransformation(context.Library.LookupEntity(_entityId),
                                                                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
            {
                Builder b                 = context.Builder;
                Signal[] outputs          = new Signal[manipulatedInputs.Count];
                ReadOnlySignalSet squares = b.Square(port.OutputSignals);
                Signal one                = IntegerValue.ConstantOne(context);
                for (int i = 0; i < outputs.Length; i++)
                {
                    outputs[i] = (one + squares[i]) * manipulatedInputs[i];
                }
                return(b.Negate(outputs));
            });

            theorems[1] = new BasicTransformation("CotangentTrigonometricSusbtitute", "Std", "TrigonometricSubstitute", "Std",
                                                  delegate(Port port) { return(port.Entity.EntityId.Equals("Cotangent", "Std")); },
                                                  delegate(Port port) { return(ManipulationPlan.DoAlter); },
                                                  delegate(Port port, SignalSet transformedInputs, bool hasTransformedInputs)
            {
                Signal[] ret = new Signal[transformedInputs.Count];
                for (int i = 0; i < ret.Length; i++)
                {
                    ret[i] = Std.Cosine(port.Context, transformedInputs[i]) / Std.Sine(port.Context, transformedInputs[i]);
                }
                return(ret);
            });

            return(theorems);
        }
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[2];

            theorems[0] = new Analysis.DerivativeTransformation(_entityId,
                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
                {
                    Builder b = context.Builder;
                    ReadOnlySignalSet squares = b.Square(port.OutputSignals);
                    Signal one = IntegerValue.ConstantOne(context);
                    SignalSet outputs = new SignalSet();
                    for(int i = 0; i < manipulatedInputs.Count; i++)
                        outputs.Add((one + squares[i]) * manipulatedInputs[i]);
                    return outputs;
                });

            theorems[1] = new BasicTransformation(_entityId.DerivePostfix("TrigonometricSubstitute"), new MathIdentifier("TrigonometricSubstitute", "Std"),
                delegate() { return new Pattern(new EntityCondition(_entityId)); },
                delegate(Port port) { return ManipulationPlan.DoAlter; },
                delegate(Port port, SignalSet transformedInputs, bool hasTransformedInputs)
                {
                    Signal[] ret = new Signal[transformedInputs.Count];
                    for(int i = 0; i < ret.Length; i++)
                        ret[i] = Std.Sine(port.Context, transformedInputs[i]) / Std.Cosine(port.Context, transformedInputs[i]);
                    return ret;
                });

            return theorems;
        }
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[2];

            theorems[0] = new Analysis.DerivativeTransformation(context.Library.LookupEntity(_entityId),
                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
                {
                    Builder b = context.Builder;
                    Signal[] outputs = new Signal[manipulatedInputs.Count];
                    ReadOnlySignalSet squares = b.Square(port.OutputSignals);
                    Signal one = IntegerValue.ConstantOne(context);
                    for(int i = 0; i < outputs.Length; i++)
                        outputs[i] = (one + squares[i]) * manipulatedInputs[i];
                    return b.Negate(outputs);
                });

            theorems[1] = new BasicTransformation("CotangentTrigonometricSusbtitute", "Std", "TrigonometricSubstitute", "Std",
                delegate(Port port) { return port.Entity.EntityId.Equals("Cotangent", "Std"); },
                delegate(Port port) { return ManipulationPlan.DoAlter; },
                delegate(Port port, SignalSet transformedInputs, bool hasTransformedInputs)
                {
                    Signal[] ret = new Signal[transformedInputs.Count];
                    for(int i = 0; i < ret.Length; i++)
                        ret[i] = Std.Cosine(port.Context, transformedInputs[i]) / Std.Sine(port.Context, transformedInputs[i]);
                    return ret;
                });

            return theorems;
        }
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[2];

            theorems[0] = new Analysis.DerivativeTransformation(context.Library.LookupEntity(_entityId),
                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
                {
                    return new SignalSet(context.Builder.SubtractSimplified(manipulatedInputs));
                });

            theorems[1] = new Algebra.AutoSimplifyTransformation(context.Library.LookupEntity(_entityId),
                delegate(Port port)
                {
                    // TODO
                    return ManipulationPlan.DoAlter;
                },
                delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs)
                {
                    if(SimplifySummands(manipulatedInputs) || hasManipulatedInputs)
                    {
                        if(manipulatedInputs.Count == 0)
                            return new SignalSet(StdPackage.Structures.IntegerValue.ConstantAdditiveIdentity(context));
                        if(manipulatedInputs.Count == 1)
                            return manipulatedInputs;
                        return new SignalSet(context.Builder.Subtract(manipulatedInputs));
                    }
                    else
                        return port.OutputSignals;
                });

            return theorems;
        }
예제 #10
0
        //public static Signal[] SimplifyOperands(List<Signal> signals)
        //{
        //    if(signals.Count>0 && Std.IsConstantOne(signals[0]))
        //        return new Signal[] { signals[0] };
        //    for(int i = signals.Count - 1; i > 0; i--) //don't touch first item
        //    {
        //        if(Std.IsConstantZero(signals[i]))
        //            return new Signal[] { IntegerValue.ConstantOne(signals[i].Context) };
        //        if(Std.IsConstantOne(signals[i]))
        //            signals.RemoveAt(i);
        //    }
        //    return signals.ToArray();
        //}

        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[1];

            //theorems[0] = new Analysis.DerivativeTransformation("PowerDerivative", "Std", context.Library.LookupEntity("Power", "Std"),
            //    delegate(Port port, Signal[] derivedInputSignals)
            //    {
            //        Signal innerA = derivedInputSignals[1] * context.Builder.NaturalLogarithm(port.InputSignals[0]);
            //        Signal innerB = (port.InputSignals[1] * derivedInputSignals[0]) / port.InputSignals[0];
            //        return port.OutputSignals[0] * (innerA + innerB);
            //    });

            theorems[0] = new Algebra.AutoSimplifyTransformation(context.Library.LookupEntity(_entityId),
                delegate(Port port)
                {
                    // TODO
                    return ManipulationPlan.DoAlter;
                },
                delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs)
                {
                    if(Std.IsConstantMultiplicativeIdentity(manipulatedInputs[0]))
                        return new SignalSet(manipulatedInputs[0]);
                    if(Std.IsConstantMultiplicativeIdentity(manipulatedInputs[1]))
                        return new SignalSet(manipulatedInputs[0]);
                    if(Std.IsConstantAdditiveIdentity(manipulatedInputs[1]))
                        return new SignalSet(IntegerValue.ConstantOne(port.Context));
                    if(hasManipulatedInputs)
                        return port.Entity.InstantiatePort(port.Context, manipulatedInputs).OutputSignals;
                    else
                        return port.OutputSignals;
                });

            return theorems;
        }
예제 #11
0
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[2];

            theorems[0] = new Analysis.DerivativeTransformation(_entityId,
                                                                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
            {
                Builder b = context.Builder;
                ReadOnlySignalSet tangents = Std.Tangent(context, port.InputSignals);
                SignalSet outputs          = new SignalSet();
                for (int i = 0; i < manipulatedInputs.Count; i++)
                {
                    outputs.Add(b.MultiplySimplified(port.OutputSignals[i], tangents[i], manipulatedInputs[i]));
                }
                return(outputs);
            });

            theorems[1] = new BasicTransformation(_entityId.DerivePostfix("TrigonometricSubstitute"), new MathIdentifier("TrigonometricSubstitute", "Std"),
                                                  delegate() { return(new Pattern(new EntityCondition(_entityId))); },
                                                  delegate(Port port) { return(ManipulationPlan.DoAlter); },
                                                  delegate(Port port, SignalSet transformedInputs, bool hasTransformedInputs)
            {
                return(port.Context.Builder.Invert(Std.Cosine(port.Context, transformedInputs)));
                //Signal[] ret = new Signal[transformedInputs.Length];
                //for(int i = 0; i < ret.Length; i++)
                //    ret[i] = port.Context.Builder.Invert(Std.Cosine(port.Context, transformedInputs[i]));
                //return ret;
            });

            return(theorems);
        }
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[2];

            theorems[0] = new Analysis.DerivativeTransformation(_entityId,
                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
                {
                    Builder b = context.Builder;
                    Signal[] outputs = new Signal[manipulatedInputs.Count];
                    ReadOnlySignalSet cotangents = Std.Cotangent(context, port.InputSignals);
                    for(int i = 0; i < outputs.Length; i++)
                        outputs[i] = b.MultiplySimplified(port.OutputSignals[i], cotangents[i], manipulatedInputs[i]);
                    return b.Negate(outputs);
                });

            theorems[1] = new BasicTransformation(_entityId.DerivePostfix("TrigonometricSubstitute"), new MathIdentifier("TrigonometricSubstitute", "Std"),
                delegate() { return new Pattern(new EntityCondition(_entityId)); },
                delegate(Port port) { return ManipulationPlan.DoAlter; },
                delegate(Port port, SignalSet transformedInputs, bool hasTransformedInputs)
                {
                    return port.Context.Builder.Invert(Std.Sine(port.Context, transformedInputs));
                    //Signal[] ret = new Signal[transformedInputs.Count];
                    //for(int i = 0; i < ret.Length; i++)
                    //    ret[i] = port.Context.Builder.Invert(Std.Sine(port.Context, transformedInputs[i]));
                    //return ret;
                });

            return theorems;
        }
예제 #13
0
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[0];



            return(theorems);
        }
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[0];

            //theorems[0] = new Analysis.DerivativeTransformation("HyperbolicCotangentDerivative", "Std", context.Library.LookupEntity("HyperbolicCotangent", "Std"),
            //    delegate(Port port, Signal[] derivedInputSignals)
            //    {
            //    });

            return theorems;
        }
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[0];

            //theorems[0] = new Analysis.DerivativeTransformation("HyperbolicCosineDerivative", "Std", context.Library.LookupEntity("HyperbolicCosine", "Std"),
            //    delegate(Port port, Signal[] derivedInputSignals)
            //    {
            //    });

            return(theorems);
        }
예제 #16
0
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[1];

            theorems[0] = new Analysis.DerivativeTransformation(context.Library.LookupEntity(_entityId),
                                                                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
            {
                return(context.Builder.Negate(manipulatedInputs));
            });

            return(theorems);
        }
예제 #17
0
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[1];

            theorems[0] = new Analysis.DerivativeTransformation(context.Library.LookupEntity(_entityId),
                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
                {
                    return context.Builder.Negate(manipulatedInputs);
                });

            return theorems;
        }
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[2];

            theorems[0] = new Analysis.DerivativeTransformation(_entityId,
                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
                {
                    int cnt = manipulatedInputs.Count - 1;
                    Builder b = context.Builder;

                    Signal[] multiplySignals = new Signal[cnt];
                    Signal[] addSignals = new Signal[cnt];

                    for(int i = 0; i < cnt; i++)
                        multiplySignals[i] = port.InputSignals[i + 1];
                    Signal left = b.DivideSimplified(manipulatedInputs[0], multiplySignals);

                    for(int i = 0; i < cnt; i++)
                    {
                        for(int j = 0; j < cnt; j++)
                            multiplySignals[j] = i == j ? b.Square(port.InputSignals[j + 1]) : port.InputSignals[j + 1];
                        Signal num = b.MultiplySimplified(port.InputSignals[0], manipulatedInputs[i + 1]);
                        addSignals[i] = b.DivideSimplified(num, multiplySignals);
                    }

                    return new SignalSet(b.SubtractSimplified(left, addSignals));
                });

            theorems[1] = new Algebra.AutoSimplifyTransformation(_entityId,
                delegate(Port port)
                {
                    // TODO
                    return ManipulationPlan.DoAlter;
                },
                delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs)
                {
                    if(SimplifyFactors(manipulatedInputs) || hasManipulatedInputs)
                    {
                        if(manipulatedInputs.Count == 0)
                            return new SignalSet(StdPackage.Structures.IntegerValue.ConstantMultiplicativeIdentity(context));
                        if(manipulatedInputs.Count == 1)
                            return manipulatedInputs;
                        return new SignalSet(context.Builder.Divide(manipulatedInputs));
                    }
                    else
                        return port.OutputSignals;
                });

            return theorems;
        }
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[2];

            theorems[0] = new Analysis.DerivativeTransformation(_entityId,
                                                                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
            {
                int cnt                  = manipulatedInputs.Count;
                Signal[] addSignals      = new Signal[cnt];
                Signal[] multiplySignals = new Signal[cnt];
                for (int i = 0; i < cnt; i++)
                {
                    for (int j = 0; j < cnt; j++)
                    {
                        multiplySignals[j] = i == j ? manipulatedInputs[j] : port.InputSignals[j];
                    }
                    addSignals[i] = context.Builder.MultiplySimplified(multiplySignals);
                }
                return(new SignalSet(context.Builder.AddSimplified(addSignals)));
            });

            theorems[1] = new Algebra.AutoSimplifyTransformation(_entityId,
                                                                 delegate(Port port)
            {
                // TODO
                return(ManipulationPlan.DoAlter);
            },
                                                                 delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs)
            {
                if (SimplifyFactors(manipulatedInputs) || hasManipulatedInputs)
                {
                    if (manipulatedInputs.Count == 0)
                    {
                        return(new SignalSet(StdPackage.Structures.IntegerValue.ConstantMultiplicativeIdentity(context)));
                    }
                    if (manipulatedInputs.Count == 1)
                    {
                        return(manipulatedInputs);
                    }
                    return(new SignalSet(context.Builder.Multiply(manipulatedInputs)));
                }
                else
                {
                    return(port.OutputSignals);
                }
            });

            return(theorems);
        }
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[1];

            theorems[0] = new Analysis.DerivativeTransformation(_entityId,
                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
                {
                    Builder b = context.Builder;
                    SignalSet outputs = new SignalSet();
                    for(int i = 0; i < manipulatedInputs.Count; i++)
                        outputs.Add(b.Negate(b.DivideSimplified(manipulatedInputs[i], b.Square(port.InputSignals[i]))));
                    return outputs;
                });

            return theorems;
        }
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[1];

            theorems[0] = new Analysis.DerivativeTransformation(context.Library.LookupEntity(_entityId),
                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
                {
                    Builder b = context.Builder;
                    SignalSet outputs = new SignalSet();
                    for(int i = 0; i < manipulatedInputs.Count; i++)
                        outputs.Add(manipulatedInputs[i] / port.InputSignals[i]);
                    return outputs;
                });

            return theorems;
        }
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[1];

            theorems[0] = new Analysis.DerivativeTransformation(_entityId,
                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
                {
                    Builder b = context.Builder;
                    SignalSet outputs = new SignalSet();
                    ReadOnlySignalSet cosines = Std.Cosine(context, port.InputSignals);
                    for(int i = 0; i < manipulatedInputs.Count; i++)
                        outputs.Add(cosines[i] * manipulatedInputs[i]);
                    return outputs;
                });

            return theorems;
        }
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[1];

            theorems[0] = new Analysis.DerivativeTransformation(_entityId,
                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
                {
                    Builder b = context.Builder;
                    Signal two = IntegerValue.ConstantTwo(context);
                    SignalSet outputs = new SignalSet();
                    for(int i = 0; i < manipulatedInputs.Count; i++)
                        outputs.Add(b.MultiplySimplified(two, port.InputSignals[i], manipulatedInputs[i]));
                    return outputs;
                });

            return theorems;
        }
예제 #24
0
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[1];

            theorems[0] = new Analysis.DerivativeTransformation(context.Library.LookupEntity(_entityId),
                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
                {
                    Builder b = context.Builder;
                    Signal[] outputs = new Signal[manipulatedInputs.Count];
                    ReadOnlySignalSet sines = Std.Sine(context, port.InputSignals);
                    for(int i = 0; i < outputs.Length; i++)
                        outputs[i] = sines[i] * manipulatedInputs[i];
                    return b.Negate(outputs);
                });

            return theorems;
        }
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[1];

            theorems[0] = new Analysis.DerivativeTransformation(context.Library.LookupEntity(_entityId),
                                                                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
            {
                Builder b         = context.Builder;
                SignalSet outputs = new SignalSet();
                for (int i = 0; i < manipulatedInputs.Count; i++)
                {
                    outputs.Add(manipulatedInputs[i] / port.InputSignals[i]);
                }
                return(outputs);
            });

            return(theorems);
        }
예제 #26
0
        public void AddTheorem(ITheorem theorem)
        {
            _theorems.Add(theorem.TheoremId, theorem);
            ITransformationTheorem transTheorem = theorem as ITransformationTheorem;

            if (transTheorem != null)
            {
                TransformationTypeTable table = AddTransformationType(transTheorem.TransformationTypeId);
                table.Add(transTheorem);
            }
            IPropagationTheorem propTheorem = theorem as IPropagationTheorem;

            if (propTheorem != null)
            {
                PropertyProviderTable table = AddPropertyProvider(propTheorem.PropertyTypeId);
                table.AddTheorem(propTheorem);
            }
        }
예제 #27
0
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[1];

            theorems[0] = new Analysis.DerivativeTransformation(_entityId,
                                                                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
            {
                Builder b         = context.Builder;
                SignalSet outputs = new SignalSet();
                for (int i = 0; i < manipulatedInputs.Count; i++)
                {
                    outputs.Add(b.Negate(b.DivideSimplified(manipulatedInputs[i], b.Square(port.InputSignals[i]))));
                }
                return(outputs);
            });

            return(theorems);
        }
        //public static Signal[] SimplifyOperands(List<Signal> signals)
        //{
        //    if(signals.Count>0 && Std.IsConstantOne(signals[0]))
        //        return new Signal[] { signals[0] };
        //    for(int i = signals.Count - 1; i > 0; i--) //don't touch first item
        //    {
        //        if(Std.IsConstantZero(signals[i]))
        //            return new Signal[] { IntegerValue.ConstantOne(signals[i].Context) };
        //        if(Std.IsConstantOne(signals[i]))
        //            signals.RemoveAt(i);
        //    }
        //    return signals.ToArray();
        //}

        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[1];

            //theorems[0] = new Analysis.DerivativeTransformation("PowerDerivative", "Std", context.Library.LookupEntity("Power", "Std"),
            //    delegate(Port port, Signal[] derivedInputSignals)
            //    {
            //        Signal innerA = derivedInputSignals[1] * context.Builder.NaturalLogarithm(port.InputSignals[0]);
            //        Signal innerB = (port.InputSignals[1] * derivedInputSignals[0]) / port.InputSignals[0];
            //        return port.OutputSignals[0] * (innerA + innerB);
            //    });

            theorems[0] = new Algebra.AutoSimplifyTransformation(_entityId,
                                                                 delegate(Port port)
            {
                // TODO
                return(ManipulationPlan.DoAlter);
            },
                                                                 delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs)
            {
                if (Std.IsConstantMultiplicativeIdentity(manipulatedInputs[0]))
                {
                    return(new SignalSet(manipulatedInputs[0]));
                }
                if (Std.IsConstantMultiplicativeIdentity(manipulatedInputs[1]))
                {
                    return(new SignalSet(manipulatedInputs[0]));
                }
                if (Std.IsConstantAdditiveIdentity(manipulatedInputs[1]))
                {
                    return(new SignalSet(IntegerValue.ConstantOne(port.Context)));
                }
                if (hasManipulatedInputs)
                {
                    return(port.Entity.InstantiatePort(port.Context, manipulatedInputs).OutputSignals);
                }
                else
                {
                    return(port.OutputSignals);
                }
            });

            return(theorems);
        }
예제 #29
0
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[1];

            theorems[0] = new Analysis.DerivativeTransformation(context.Library.LookupEntity(_entityId),
                                                                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
            {
                Builder b               = context.Builder;
                Signal[] outputs        = new Signal[manipulatedInputs.Count];
                ReadOnlySignalSet sines = Std.Sine(context, port.InputSignals);
                for (int i = 0; i < outputs.Length; i++)
                {
                    outputs[i] = sines[i] * manipulatedInputs[i];
                }
                return(b.Negate(outputs));
            });

            return(theorems);
        }
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[1];

            theorems[0] = new Analysis.DerivativeTransformation(_entityId,
                                                                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
            {
                Builder b                 = context.Builder;
                SignalSet outputs         = new SignalSet();
                ReadOnlySignalSet cosines = Std.Cosine(context, port.InputSignals);
                for (int i = 0; i < manipulatedInputs.Count; i++)
                {
                    outputs.Add(cosines[i] * manipulatedInputs[i]);
                }
                return(outputs);
            });

            return(theorems);
        }
예제 #31
0
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[1];

            theorems[0] = new Analysis.DerivativeTransformation(_entityId,
                                                                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
            {
                Builder b         = context.Builder;
                Signal two        = IntegerValue.ConstantTwo(context);
                SignalSet outputs = new SignalSet();
                for (int i = 0; i < manipulatedInputs.Count; i++)
                {
                    outputs.Add(b.MultiplySimplified(two, port.InputSignals[i], manipulatedInputs[i]));
                }
                return(outputs);
            });

            return(theorems);
        }
예제 #32
0
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[2];

            theorems[0] = new Analysis.DerivativeTransformation(context.Library.LookupEntity(_entityId),
                                                                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
            {
                return(new SignalSet(manipulatedInputs));
            });

            theorems[1] = new Algebra.AutoSimplifyTransformation(context.Library.LookupEntity(_entityId),
                                                                 delegate(Port port)
            {
                return(ManipulationPlan.DoAlter);
            },
                                                                 delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs)
            {
                return(new SignalSet(manipulatedInputs));
            });

            return(theorems);
        }
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[2];

            theorems[0] = new Analysis.DerivativeTransformation(_entityId,
                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
                {
                    return new SignalSet(manipulatedInputs);
                });

            theorems[1] = new Algebra.AutoSimplifyTransformation(_entityId,
                delegate(Port port)
                {
                    return ManipulationPlan.DoAlter;
                },
                delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs)
                {
                    return new SignalSet(manipulatedInputs);
                });

            return theorems;
        }
        public static ITheorem[] BuildTheorems(Context context)
        {
            ITheorem[] theorems = new ITheorem[2];

            theorems[0] = new Analysis.DerivativeTransformation(_entityId,
                                                                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
            {
                return(new SignalSet(context.Builder.AddSimplified(manipulatedInputs)));
            });

            theorems[1] = new Algebra.AutoSimplifyTransformation(_entityId,
                                                                 delegate(Port port)
            {
                // TODO
                return(ManipulationPlan.DoAlter);
            },
                                                                 delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs)
            {
                if (SimplifySummands(manipulatedInputs) || hasManipulatedInputs)
                {
                    if (manipulatedInputs.Count == 0)
                    {
                        return(new SignalSet(StdPackage.Structures.IntegerValue.ConstantAdditiveIdentity(context)));
                    }
                    if (manipulatedInputs.Count == 1)
                    {
                        return(manipulatedInputs);
                    }
                    return(new SignalSet(context.Builder.Add(manipulatedInputs)));
                }
                else
                {
                    return(port.OutputSignals);
                }
            });

            return(theorems);
        }
예제 #35
0
 public bool TryLookupTheorem(MathIdentifier theoremId, out ITheorem theorem)
 {
     return(theoremTable.TryLookupTheorem(theoremId, out theorem));
 }
예제 #36
0
 public bool TryLookupTheorem(MathIdentifier theoremId, out ITheorem value)
 {
     return(_theorems.TryGetValue(theoremId, out value));
 }