Ejemplo n.º 1
0
        private static SymbolicTransform GenerateOneTimesXToXTransform()
        {
            var constraint = new BasicSymbolicConstraint(
                s => s.Type == SymbolType.Multiplication,
                new BasicSymbolicConstraint[] {
                new BasicSymbolicConstraint(
                    s => s.Type == SymbolType.Number && (Number)s == Numbers.One),
                new BasicSymbolicConstraint()
            }
                );
            var varName  = "value";
            var inputMap = new SymbolMap(
                new SymbolMap[]
            {
                new SymbolMap(),     // placeholder for left part
                new SymbolMap(new SymbolName(varName))
            }
                );
            var context = inputMap.GenerateContext();

            var outputExpression = new Variable(varName);
            var outputFunction   = new Function(outputExpression, context);

            return(SymbolicTransform.New(constraint, inputMap, outputFunction));
        }
Ejemplo n.º 2
0
        private static SymbolicTransform GenerateAdditionForceValuesLeftTransform()
        {
            // constraint where value is on the right, and
            // some non-left subtree is on the left
            var constraint = new BasicSymbolicConstraint(
                s => s.Type == SymbolType.Addition,
                new BasicSymbolicConstraint[] {
                new BasicSymbolicConstraint(
                    s => !s.Type.IsValue()
                    ),
                new BasicSymbolicConstraint(
                    s => s.Type.IsValue()
                    )
            }
                );

            var leftName  = "left";
            var rightName = "right";
            var inputMap  = new SymbolMap(new SymbolMap[]
            {
                new SymbolMap(new SymbolName(leftName)),
                new SymbolMap(new SymbolName(rightName))
            });
            var context = inputMap.GenerateContext();

            var outputExpression = new Addition(
                new Variable(rightName),
                new Variable(leftName)
                );
            var outputFunction = new Function(outputExpression, context);

            return(SymbolicTransform.New(constraint, inputMap, outputFunction));
        }