public static Term BVar(int i)
        {
            Contract.Requires(i >= 0);
            Term natConst = new NatConst(i);

            return(new TermApp(bvarId, natConst));
        }
        public static Term VariableConstr(int i, bool isBoundVar)
        {
            Contract.Requires(i >= 0);
            Term natConst = new NatConst(i);

            if (!isBoundVar)
            {
                return(new TermApp(varId, new List <Term> {
                    natConst
                }));
            }

            return(new TermApp(bvarId, new List <Term> {
                natConst
            }));
        }
        public static Term FunDecl(Function f, IVariableTranslationFactory varTranslationFactory,
                                   bool includeName = true)
        {
            var typeIsaVisitor = LemmaHelper.FunTypeIsaVisitor(f, varTranslationFactory);

            Term fname         = new StringConst(f.Name);
            Term numTypeParams = new NatConst(f.TypeParameters.Count);
            var  argTypes      = new TermList(f.InParams.Select(v => typeIsaVisitor.Translate(v.TypedIdent.Type)).ToList());
            var  retType       = typeIsaVisitor.Translate(f.OutParams.First().TypedIdent.Type);

            if (includeName)
            {
                return(new TermTuple(new List <Term> {
                    fname, numTypeParams, argTypes, retType
                }));
            }
            return(new TermTuple(new List <Term> {
                numTypeParams, argTypes, retType
            }));
        }
Esempio n. 4
0
        public override string VisitNatConst(NatConst t)
        {
            if (t.UseConstructorRepr)
            {
                var sb = new StringBuilder("");
                for (var i = t.Val; i > 0; i--)
                {
                    sb.Append("Suc(");
                }

                sb.Append(0);

                for (var i = 1; i <= t.Val; i++)
                {
                    sb.Append(")");
                }
                return(H.Parenthesis(sb.ToString()));
            }

            return(t.Val.ToString());
        }
 public bool TryTranslateVariableId(T variable, out Term id, out bool isBoundVar)
 {
     id = new NatConst(TranslateVariableIdx(variable, out isBoundVar));
     return(true);
 }