public CasExpr ToExpr()
        {
            var p = new CasPolynomial();

            p.Terms.Add(this);
            return(new CasExpr(p, CasPolynomial.ConstantPoly(1)));
        }
        public CasExpr VarExpr(CasVar v)
        {
            var t = new CasTerm(1);

            t.Variables[v] = 1;
            var p = new CasPolynomial();

            p.Terms.Add(t);
            return(new CasExpr(p, CasPolynomial.ConstantPoly(1)));
        }
        public CasExpr Substitute(CasExpr expr, CasVar forV)
        {
            if (!ContainsVar(forV))
            {
                return(new CasExpr(this, CasPolynomial.ConstantPoly(1)));
            }
            List <CasExpr> exprs = new List <CasExpr>();

            foreach (var t in Terms)
            {
                exprs.Add(t.Substitute(expr, forV));
            }
            var sum = CasExpr.ConstantExpr(0);

            foreach (var e in exprs)
            {
                sum = CasSystem.Instance.Add(sum, e);
            }
            return(sum);
        }
 public static CasExpr ConstantExpr(int c)
 {
     return(new CasExpr(CasPolynomial.ConstantPoly(c), CasPolynomial.ConstantPoly(1)));
 }