public FuncDecl MkFuncDecl(string name, FuncDecl f) { Function h = (f as VCExprBoogieFunctionOp).Func; Function g = new Function(Token.NoToken, name, h.InParams, h.OutParams[0]); return(BoogieFunctionOp(g)); }
private Term SubstPredsRec(TermDict <Term> memo, Dictionary <FuncDecl, FuncDecl> subst, Term t) { Term res; if (memo.TryGetValue(t, out res)) { return(res); } if (t.GetKind() == TermKind.App) { var args = t.GetAppArgs(); args = args.Select(x => SubstPredsRec(memo, subst, x)).ToArray(); FuncDecl nf = null; var f = t.GetAppDecl(); if (subst.TryGetValue(f, out nf)) { res = ctx.MkApp(nf, args); } else { res = ctx.CloneApp(t, args); } } // TODO: handle quantifiers else { res = t; } memo.Add(t, res); return(res); }
/** Create a symbolic transformer. */ public Transformer CreateTransformer(FuncDecl[] _RelParams, Term[] _IndParams, Term _Formula) { Transformer t = new Transformer(); t.RelParams = _RelParams; t.IndParams = _IndParams; t.Formula = _Formula; t.owner = this; return t; }
public static DeclKind GetKind(this FuncDecl f) { if (f is VCExprBoogieFunctionOp) { return(DeclKind.Uninterpreted); } if (f == VCExpressionGenerator.AndOp) { return(DeclKind.And); } if (f == VCExpressionGenerator.ImpliesOp) { return(DeclKind.Implies); } return(DeclKind.Other); }
/** Create a node in the graph. The input is a term R(v_1...v_n) * where R is an arbitrary relational symbol and v_1...v_n are * arbitary distinct variables. The names are only of mnemonic value, * however, the number and type of arguments determine the type * of the relation at this node. */ public Node CreateNode(Term t) { Node n = new Node(); // Microsoft.Boogie.VCExprAST.VCExprNAry tn = t as Microsoft.Boogie.VCExprAST.VCExprNAry; // Term[] _IndParams = tn.ToArray(); Term[] _IndParams = t.GetAppArgs(); FuncDecl Name = t.GetAppDecl(); n.Annotation = CreateRelation(_IndParams, ctx.MkTrue()); n.Bound = CreateRelation(_IndParams, ctx.MkTrue()); n.owner = this; n.number = ++nodeCount; n.Name = Name; // just to have a unique name n.Incoming = new List <Edge>(); return(n); }
/** Convert an array of clauses to an RPFP. */ public void FromClauses(Term[] clauses) { FuncDecl failName = ctx.MkFuncDecl("@Fail", ctx.MkBoolSort()); foreach (var clause in clauses) { Node foo = GetNodeFromClause(clause, failName); if (foo != null) { nodes.Add(foo); } } foreach (var clause in clauses) { edges.Add(GetEdgeFromClause(clause, failName)); } }
private Node GetNodeFromClause(Term t, FuncDecl failName) { Term[] args = t.GetAppArgs(); Term body = args[0]; Term head = args[1]; FuncDecl Name; Term[] _IndParams; bool is_query = false; if (head.Equals(ctx.MkFalse())) { Name = failName; is_query = true; _IndParams = new Term[0]; } else { Name = head.GetAppDecl(); _IndParams = head.GetAppArgs(); } if (relationToNode.ContainsKey(Name)) { return(null); } for (int i = 0; i < _IndParams.Length; i++) { if (!IsVariable(_IndParams[i])) { Term v = ctx.MkConst("@a" + i.ToString(), _IndParams[i].GetSort()); _IndParams[i] = v; } } Term foo = ctx.MkApp(Name, _IndParams); Node node = CreateNode(foo); relationToNode[Name] = node; if (is_query) { node.Bound = CreateRelation(new Term[0], ctx.MkFalse()); } return(node); }
private Edge GetEdgeFromClause(Term t, FuncDecl failName) { Term[] args = t.GetAppArgs(); Term body = args[0]; Term head = args[1]; Term[] _IndParams; FuncDecl Name; if (head.IsFalse()) { Name = failName; _IndParams = new Term[0]; } else { _IndParams = head.GetAppArgs(); Name = head.GetAppDecl(); } for (int i = 0; i < _IndParams.Length; i++) { if (!IsVariable(_IndParams[i])) { Term v = ctx.MkConst("@a" + i.ToString(), _IndParams[i].GetSort()); body = ctx.MkAnd(body, ctx.MkEq(v, _IndParams[i])); _IndParams[i] = v; } } var relParams = new List <FuncDecl>(); var nodeParams = new List <RPFP.Node>(); var memo = new TermDict <Term>(); var done = new Dictionary <Term, Term>(); // note this hashes on equality, not reference! body = CollectParamsRec(memo, body, relParams, nodeParams, done); Transformer F = CreateTransformer(relParams.ToArray(), _IndParams, body); Node parent = relationToNode[Name]; return(CreateEdge(parent, F, nodeParams.ToArray())); }
private Node GetNodeFromClause(Term t, FuncDecl failName) { Term[] args = t.GetAppArgs(); Term body = args[0]; Term head = args[1]; FuncDecl Name; Term[] _IndParams; bool is_query = false; if (head.Equals(ctx.MkFalse())) { Name = failName; is_query = true; _IndParams = new Term[0]; } else { Name = head.GetAppDecl(); _IndParams = head.GetAppArgs(); } if (relationToNode.ContainsKey(Name)) return null; for (int i = 0; i < _IndParams.Length; i++) if (!IsVariable(_IndParams[i])) { Term v = ctx.MkConst("@a" + i.ToString(), _IndParams[i].GetSort()); _IndParams[i] = v; } Term foo = ctx.MkApp(Name, _IndParams); Node node = CreateNode(foo); relationToNode[Name] = node; if (is_query) node.Bound = CreateRelation(new Term[0], ctx.MkFalse()); return node; }
private Edge GetEdgeFromClause(Term t, FuncDecl failName) { Term[] args = t.GetAppArgs(); Term body = args[0]; Term head = args[1]; Term[] _IndParams; FuncDecl Name; if (head.IsFalse()) { Name = failName; _IndParams = new Term[0]; } else { _IndParams = head.GetAppArgs(); Name = head.GetAppDecl(); } for(int i = 0; i < _IndParams.Length; i++) if (!IsVariable(_IndParams[i])) { Term v = ctx.MkConst("@a" + i.ToString(), _IndParams[i].GetSort()); body = ctx.MkAnd(body, ctx.MkEq(v, _IndParams[i])); _IndParams[i] = v; } var relParams = new List<FuncDecl>(); var nodeParams = new List<RPFP.Node>(); var memo = new TermDict< Term>(); var done = new Dictionary<Term, Term>(); // note this hashes on equality, not reference! body = CollectParamsRec(memo, body, relParams, nodeParams,done); Transformer F = CreateTransformer(relParams.ToArray(), _IndParams, body); Node parent = relationToNode[Name]; return CreateEdge(parent, F, nodeParams.ToArray()); }
private Term NormalizeGoal(Term goal, FuncDecl label) { var f = goal.GetAppDecl(); var args = goal.GetAppArgs(); int number; if (!goalNumbering.TryGetValue(f, out number)) { number = goalNumbering.Count; goalNumbering.Add(f, number); } Term[] tvars = new Term[args.Length]; Term[] eqns = new Term[args.Length]; AnnotationInfo info = null; annotationInfo.TryGetValue(f.GetDeclName(), out info); for (int i = 0; i < args.Length; i++) { string pname = (info == null) ? i.ToString() : info.argnames[i]; tvars[i] = ctx.MkConst("@a" + number.ToString() + "_" + pname, args[i].GetSort()); eqns[i] = ctx.MkEq(tvars[i], args[i]); } return ctx.MkImplies(ctx.MkAnd(eqns), ctx.MkApp(label, ctx.MkApp(f, tvars))); }
public static string GetDeclName(this FuncDecl f) { return((f as VCExprBoogieFunctionOp).Func.Name); //TODO }
public Term MkApp(FuncDecl f, Term arg) { return(Function(f, arg)); }
public Term MkApp(FuncDecl f, Term[] args, Type[] /*!*/ typeArguments) { return(Function(f, args, typeArguments)); }
public Term MkApp(FuncDecl f, Term[] args) { return(Function(f, args)); }