public void Run() { Dictionary <string, string> cfg = new Dictionary <string, string>() { { "AUTO_CONFIG", "true" } }; using (Context ctx = new Context(cfg)) { IntExpr x = ctx.MkIntConst("x"); FuncDecl x_d = x.FuncDecl; Console.WriteLine("is_expr(x_d): " + x_d.IsExpr); Console.WriteLine("is_func_decl(x_d): " + x_d.IsFuncDecl); Console.WriteLine("x_d.Name: " + x_d.Name); Console.WriteLine("x_d.Range: " + x_d.Range); Console.WriteLine("x_d.Arity: " + x_d.Arity); Console.WriteLine("x_d() == x: " + (x_d.Apply() == x)); FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { ctx.IntSort, ctx.RealSort }, ctx.BoolSort); Console.WriteLine("f.Name: " + f.Name); Console.WriteLine("f.Range: " + f.Range); Console.WriteLine("f.Arity: " + f.Arity); for (uint i = 0; i < f.Arity; i++) { Console.WriteLine("domain(" + i + "): " + f.Domain[i]); } Console.WriteLine(f[x, ctx.MkInt2Real(x)]); Console.WriteLine(f[x, ctx.MkInt2Real(x)].FuncDecl == f); } }
public override void Visit(FuncDecl n) { n.declaring.accept(this); PlusScope(); foreach (SymDeclaring ast in n.declarings) { ast.accept(this); } foreach (AST ast in n.statments) { ast.accept(this); } if (n.returnValue == null && n.declaring.type != AST.VOID) { Error($"function {n.declaring.id} must use \"return\""); } else if (n.returnValue != null && n.declaring.type == AST.VOID) { Error($"function {n.declaring.id} must not use \"return\""); } else if (n.returnValue != null) { n.returnValue.accept(this); if (n.declaring.type != n.returnValue.type) { Error($"return must be of type {n.declaring.type}"); } } MinusScope(); funcs.Add(n); }
public void Run() { using (Context ctx = new Context()) { var s = ctx.MkFixedpoint(); BoolSort B = ctx.BoolSort; Sort BV8 = ctx.MkBitVecSort(8); FuncDecl edge = ctx.MkFuncDecl("edge", new Sort[] { BV8, BV8 }, B); FuncDecl path = ctx.MkFuncDecl("path", new Sort[] { BV8, BV8 }, B); BitVecExpr x = (BitVecExpr)ctx.MkBound(0, BV8); BitVecExpr y = (BitVecExpr)ctx.MkBound(1, BV8); BitVecExpr z = (BitVecExpr)ctx.MkBound(2, BV8); s.RegisterRelation(edge); s.RegisterRelation(path); s.AddRule(ctx.MkImplies((BoolExpr)edge[x, y], (BoolExpr)path[x, y])); s.AddRule(ctx.MkImplies(ctx.MkAnd((BoolExpr)path[x, y], (BoolExpr)path[y, z]), (BoolExpr)path[x, z])); for (uint i = 0; i < 128; ++i) { s.AddFact(edge, i, i + 1); } Console.WriteLine(s.Query((BoolExpr)path[ctx.MkBV(0, 8), ctx.MkBV(129, 8)])); Console.WriteLine(s.GetAnswer()); Console.WriteLine(s.Query((BoolExpr)path[ctx.MkBV(0, 8), ctx.MkBV(128, 8)])); Console.WriteLine(s.GetAnswer()); Console.WriteLine(s.Query((BoolExpr)path[x, ctx.MkBV(20, 8)])); Console.WriteLine(s.GetAnswer()); Console.WriteLine(s.Query(ctx.MkAnd((BoolExpr)path[x, y], (BoolExpr)path[y, ctx.MkBV(20, 8)]))); Console.WriteLine(s.GetAnswer()); } }
public void Run() { using (Context ctx = new Context()) { ctx.UpdateParamValue("DL_ENGINE", "1"); ctx.UpdateParamValue("DL_PDR_USE_FARKAS", "true"); // ctx.UpdateParamValue("VERBOSE","2"); var s = ctx.MkFixedpoint(); BoolSort B = ctx.BoolSort; IntSort I = ctx.IntSort; FuncDecl mc = ctx.MkFuncDecl("mc", new Sort[] { I, I }, B); ArithExpr x = (ArithExpr)ctx.MkBound(0, I); ArithExpr y = (ArithExpr)ctx.MkBound(1, I); ArithExpr z = (ArithExpr)ctx.MkBound(2, I); s.RegisterRelation(mc); BoolExpr gt = ctx.MkGt(x, ctx.MkInt(100)); s.AddRule(ctx.MkImplies(gt, (BoolExpr)mc[x, ctx.MkSub(x, ctx.MkInt(10))])); s.AddRule(ctx.MkImplies(ctx.MkAnd(ctx.MkNot(gt), (BoolExpr)mc[ctx.MkAdd(x, ctx.MkInt(11)), y], (BoolExpr)mc[y, z]), (BoolExpr)mc[x, z])); Console.WriteLine(s.Query(ctx.MkAnd((BoolExpr)mc[x, y], ctx.MkGt(y, ctx.MkInt(100))))); Console.WriteLine(s.GetAnswer()); Console.WriteLine(s.Query(ctx.MkAnd((BoolExpr)mc[x, y], ctx.MkLt(y, ctx.MkInt(91))))); Console.WriteLine(s.GetAnswer()); } }
/// <summary> /// Generates a slightly randomized expression. /// </summary> static BoolExpr MkRandomExpr(Context ctx, System.Random rng) { int limit = 1073741823; Sort i = ctx.IntSort; Sort b = ctx.BoolSort; Symbol sr1 = ctx.MkSymbol(rng.Next(0, limit)); Symbol sr2 = ctx.MkSymbol(rng.Next(0, limit)); Symbol sr3 = ctx.MkSymbol(rng.Next(0, limit)); FuncDecl r1 = ctx.MkFuncDecl(sr1, i, b); FuncDecl r2 = ctx.MkFuncDecl(sr2, i, b); FuncDecl r3 = ctx.MkFuncDecl(sr3, i, b); Symbol s = ctx.MkSymbol(rng.Next(0, limit)); Expr x = ctx.MkConst(s, i); BoolExpr r1x = (BoolExpr)ctx.MkApp(r1, x); BoolExpr r2x = (BoolExpr)ctx.MkApp(r2, x); BoolExpr r3x = (BoolExpr)ctx.MkApp(r3, x); Expr[] vars = { x }; BoolExpr rl1 = ctx.MkForall(vars, ctx.MkImplies(r1x, r2x)); BoolExpr rl2 = ctx.MkForall(vars, ctx.MkImplies(r2x, r1x)); BoolExpr rl3 = (BoolExpr)ctx.MkApp(r1, ctx.MkInt(3)); BoolExpr q = (BoolExpr)ctx.MkApp(r3, ctx.MkInt(2)); BoolExpr a1 = ctx.MkNot(q); BoolExpr q1 = ctx.MkExists(vars, ctx.MkAnd(r3x, r2x)); BoolExpr q2 = ctx.MkExists(vars, ctx.MkAnd(r3x, r1x)); BoolExpr[] all = { a1, q1, q2 }; return(ctx.MkAnd(all)); }
public override void Visit(FuncDecl n) { n.declaring.accept(this); emit("("); if (n.declarings.Count > 0) { SymDeclaring first = n.declarings[0]; foreach (SymDeclaring ast in n.declarings) { if (first != ast) { emit(", "); } ast.accept(this); } } emit(") {\n"); foreach (AST ast in n.statments) { ast.accept(this); } if (n.returnValue != null) { emit("return "); n.returnValue.accept(this); emit(";\n"); emit("}\n"); } }
public void Run() { Dictionary <string, string> cfg = new Dictionary <string, string>() { { "AUTO_CONFIG", "true" } }; using (Context ctx = new Context(cfg)) { Sort A = ctx.MkUninterpretedSort("A"); Expr x = ctx.MkConst("x", A); Expr y = ctx.MkConst("y", A); FuncDecl f = ctx.MkFuncDecl("f", A, A); Solver s = ctx.MkSolver(); s.Assert(ctx.MkEq(f[f[x]], x), ctx.MkEq(f[x], y), ctx.MkNot(ctx.MkEq(x, y))); Console.WriteLine(s.Check()); Model m = s.Model; Console.WriteLine(m); Console.WriteLine("interpretation assigned to A: "); foreach (Expr a in m.SortUniverse(A)) { Console.WriteLine(a); } } }
public void Run() { Dictionary <string, string> cfg = new Dictionary <string, string>() { { "AUTO_CONFIG", "true" } }; using (Context ctx = new Context(cfg)) { Sort A = ctx.MkUninterpretedSort("A"); Sort B = ctx.MkUninterpretedSort("B"); FuncDecl f = ctx.MkFuncDecl("f", A, B); Expr a1 = ctx.MkConst("a1", A); Expr a2 = ctx.MkConst("a2", A); Expr b = ctx.MkConst("b", B); Expr x = ctx.MkConst("x", A); Expr y = ctx.MkConst("y", A); Solver s = ctx.MkSolver(); s.Assert(ctx.MkNot(ctx.MkEq(a1, a2))); s.Assert(ctx.MkEq(f[a1], b)); s.Assert(ctx.MkEq(f[a2], b)); s.Assert(ctx.MkForall(new Expr[] { x, y }, ctx.MkImplies(ctx.MkEq(f[x], f[y]), ctx.MkEq(x, y)), 1, new Pattern[] { ctx.MkPattern(f[x], f[y]) })); Console.WriteLine(s); Console.WriteLine(s.Check()); } }
public void Run() { Dictionary <string, string> cfg = new Dictionary <string, string>() { { "AUTO_CONFIG", "true" } }; using (Context ctx = new Context(cfg)) { IntExpr x = ctx.MkIntConst("x"); IntExpr y = ctx.MkIntConst("y"); FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { ctx.IntSort, ctx.IntSort }, ctx.IntSort); FuncDecl g = ctx.MkFuncDecl("g", new Sort[] { ctx.IntSort }, ctx.IntSort); Expr n = f[f[g[x], g[g[x]]], g[g[y]]]; Console.WriteLine(n); Expr nn = n.Substitute(new Expr[] { g[g[x]], g[y] }, new Expr[] { y, ctx.MkAdd(x, ctx.MkInt(1)) }); Console.WriteLine(nn); Console.WriteLine(n.Substitute(g[g[x]], y)); } }
internal AcceptorBase(FuncDecl symbol, Expr guard, ExprSet[] lookahead) { this.symbol = symbol; this.guard = guard; this.lookahead = lookahead; this.lhs = new Pair <FuncDecl, Sequence <ExprSet> >(symbol, new Sequence <ExprSet>(lookahead)); }
public void Run() { using (Context ctx = new Context()) { Sort U = ctx.MkUninterpretedSort("U"); Console.WriteLine(U); Expr a = ctx.MkConst("a", U); a = ctx.MkConst("a", U); Expr b = ctx.MkConst("b", U); Expr c = ctx.MkConst("c", U); IntExpr x = ctx.MkIntConst("x"); IntExpr y = ctx.MkIntConst("y"); Console.WriteLine(ctx.MkAnd(ctx.MkEq(a, b), ctx.MkEq(a, c))); Console.WriteLine(U == ctx.IntSort); Sort U2 = ctx.MkUninterpretedSort("U"); Console.WriteLine(U == U2); U2 = ctx.MkUninterpretedSort("U2"); Console.WriteLine(U == U2); Console.WriteLine(ctx.MkDistinct(a, b, c)); FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { U, U }, U); Console.WriteLine(ctx.MkEq(f[a, b], b)); } }
public void Run() { Dictionary <string, string> cfg = new Dictionary <string, string>() { }; using (Context ctx = new Context(cfg)) { FuncDecl f = ctx.MkFuncDecl("f", ctx.IntSort, ctx.IntSort); FuncDecl g = ctx.MkFuncDecl("g", ctx.IntSort, ctx.IntSort); IntExpr a = ctx.MkIntConst("a"); IntExpr b = ctx.MkIntConst("b"); IntExpr c = ctx.MkIntConst("c"); IntExpr x = ctx.MkIntConst("x"); Solver s = ctx.MkSolver(); Params p = ctx.MkParams(); p.Add("AUTO_CONFIG", false); p.Add("MBQI", false); s.Parameters = p; s.Assert(ctx.MkForall(new Expr[] { x }, ctx.MkEq(f[g[x]], x), 1, new Pattern[] { ctx.MkPattern(f[g[x]]) })); s.Assert(ctx.MkEq(g[a], c)); s.Assert(ctx.MkEq(g[b], c)); s.Assert(ctx.MkDistinct(a, b)); Console.WriteLine(s); Console.WriteLine(s.Check()); } }
public void Run() { Dictionary <string, string> cfg = new Dictionary <string, string>() { { "AUTO_CONFIG", "true" } }; using (Context ctx = new Context(cfg)) { FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { ctx.IntSort, ctx.IntSort }, ctx.IntSort); IntExpr x = ctx.MkIntConst("x"); IntExpr y = ctx.MkIntConst("y"); Console.WriteLine(ctx.MkForall(new Expr[] { x, y }, ctx.MkEq(f[x, y], ctx.MkInt(0)))); Console.WriteLine(ctx.MkExists(new Expr[] { x }, ctx.MkGe((ArithExpr)f[x, x], ctx.MkInt(0)))); IntExpr a = ctx.MkIntConst("a"); IntExpr b = ctx.MkIntConst("b"); Solver s = ctx.MkSolver(); s.Assert(ctx.MkForall(new Expr[] { x }, ctx.MkEq(f[x, x], ctx.MkInt(0)))); s.Assert(ctx.MkEq(f[a, b], ctx.MkInt(1))); Console.WriteLine(s.Check()); Console.WriteLine(s.Model); } }
/// <summary> /// Make a new acceptor rule where k = lookahead.Length is the rank of the symbol. /// </summary> /// <param name="state">top state of the rule</param> /// <param name="symbol">symbol of the alphabet</param> /// <param name="guard">attribute guard</param> /// <param name="lookahead">bottom state sets of the rule</param> public TreeRule MkAcceptorRule(int state, string symbol, Expr guard, int[][] lookahead) { int symb_id = GetId(symbol); int k = ranks[symb_id]; if (state < 0 || lookahead == null || lookahead.Length != k || Array.Exists(lookahead, B => (B != null && Array.Exists(B, b => b < 0)))) { throw new AutomataException(AutomataExceptionKind.RankedAlphabet_InvalidAcceptorRuleArguments); } FuncDecl func = constructors[symb_id]; ExprSet[] termSets = new ExprSet[k]; for (int i = 0; i < k; i++) { termSets[i] = new ExprSet(); if (lookahead[i] != null) { for (int j = 0; j < lookahead[i].Length; j++) { termSets[i].Add(tt.Z.MkInt(lookahead[i][j])); } } } var acc = new TreeRule(tt.Z.MkInt(state), func, guard, null, termSets); return(acc); }
public void Run() { using (Context ctx = new Context()) { RealExpr x = ctx.MkRealConst("x"); RealExpr y = ctx.MkRealConst("y"); Console.WriteLine(ctx.MkEq(x, y)); Console.WriteLine(ctx.MkNot(ctx.MkEq(x, y))); BoolExpr f1 = ctx.MkEq(x, y); BoolExpr f2 = ctx.MkEq(x, y); BoolExpr f3 = ctx.MkNot(ctx.MkEq(x, y)); Console.WriteLine(f1 == f2); Console.WriteLine(f2 == f1); Console.WriteLine(f1 == f3); FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { ctx.IntSort, ctx.RealSort }, ctx.IntSort); IntExpr a = ctx.MkIntConst("a"); IntExpr b = ctx.MkIntConst("b"); Console.WriteLine(ctx.MkGt((IntExpr)f[a, ctx.MkInt2Real(a)], b)); Console.WriteLine(f.Range); Console.WriteLine(f.Arity); Console.WriteLine(f.Domain[0]); Console.WriteLine(f.Domain[1]); Console.WriteLine(f.DeclKind == Z3_decl_kind.Z3_OP_UNINTERPRETED); Console.WriteLine(ctx.MkAdd(a, b).FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ADD); Console.WriteLine(ctx.MkAdd(a, b).FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_UNINTERPRETED); } }
public void DefineFunction(string name, Expr body, params Expr[] vars) { if (reserved.Contains(name) || library.ContainsKey(name)) { throw new ArgumentException(string.Format("'{0}' is already defined", name)); } foreach (var v in z3p.GetVars(body)) { if (!Array.Exists(vars, v.Equals)) { throw new ArgumentException(string.Format("variable '{0}' in the definition of '{1}' is unbound", v, name)); } } try { Sort[] domain = Array.ConvertAll(vars, z3p.GetSort); Sort range = z3p.GetSort(body); FuncDecl func = z3p.MkFuncDecl(name, domain, range); library[name] = new Tuple <FuncDecl, Expr>(func, body); z3p.AssertAxiom(z3p.MkApp(func, vars), body, vars); } catch (Exception e) { throw new ArgumentException(string.Format("definition of '{0}' failed", name), e); } }
public void FuncDeclUnitTest() { try { FuncDecl funcDecl = new FuncDecl( new IntDcl("testFunc"), new List <SymDeclaring>() { new IntDcl("numi"), new FloatDcl("numf") }, new List <AST>() { new Decl(new IntDcl("ffs"), new Assigning(new SymReferencing("ffs"), new FloatConst("1337"))) }, new Expression("+", new SymReferencing("ffs"), new SymReferencing("numi"))); SymbolTableFilling symbolTableFilling = new SymbolTableFilling(); funcDecl.accept(symbolTableFilling); Dictionary <Tuple <string, string>, int> actual = AST.SymbolTable; Dictionary <Tuple <string, string>, int> expected = new Dictionary <Tuple <string, string>, int>() { { new Tuple <string, string>("1", "testFunc"), 2 }, { new Tuple <string, string>("11", "numi"), 2 }, { new Tuple <string, string>("11", "numf"), 3 }, { new Tuple <string, string>("11", "ffs"), 2 } }; Assert.IsTrue(ObjectCompare(actual, expected), "Function dcl faild"); } finally { AST.SymbolTable.Clear(); } }
public override void Visit(StructDef n) { n.type = AST.STRUCT; List <Tuple <string, int> > tuples = new List <Tuple <string, int> >(); PlusScope(); foreach (AST ast in n.declarings) { ast.accept(this); if (ast is SymDeclaring) { SymDeclaring symDeclaring = ast as SymDeclaring; tuples.Add(new Tuple <string, int>(symDeclaring.id, GetType(ast))); } else if (ast is FuncDecl) { FuncDecl funcDecl = ast as FuncDecl; SymDeclaring symDeclaring = funcDecl.declaring as SymDeclaring; tuples.Add(new Tuple <string, int>(symDeclaring.id, GetType(funcDecl.declaring))); } } MinusScope(); SymReferencing current = n.structType as SymReferencing; StructDic.Add(current.id, tuples); }
public static Expr Upcast(Context context, Expr objectForMemberAccess, Sort memberDeclaredObjectSort) { FuncDecl upcast = ((DatatypeSort)memberDeclaredObjectSort).Constructors .SingleOrDefault(c => c.Domain[0] == objectForMemberAccess.Sort); objectForMemberAccess = context.MkApp(upcast, objectForMemberAccess); return(objectForMemberAccess); }
internal void AddFuncDecl(FuncDecl funcDecl, string name, params object[] keys) { object[] objs = new object[keys.Length + 1]; objs[0] = name; Array.Copy(keys, 0, objs, 1, keys.Length); var s = new Sequence <object>(objs); funcDecls.Add(new Sequence <object>(objs), funcDecl); }
public bool FuncIncrementArgFrameSize(int scope) { FuncDecl func = funcTable[scope]; func.argFrameSize += 1; funcTable[scope] = func; return(true); }
public Expr MakeBoolToInt(Expr expr) { // Get the BoolToInt function FuncDecl boolToIntfunction = _functions["BoolToInt"].FuncDecl; // Create the functionCall Expr funcCall = _context.MkApp(boolToIntfunction, expr); // return(funcCall); }
public void TestFuncDecl() { Z3Provider z3p = new Z3Provider(); FuncDecl f = z3p.MkFuncDecl("foo[56:205]", z3p.IntSort, z3p.IntSort); //FuncDecl f = z3p.Z3.GetAppDecl(z3p.MkBvExtract(0, 0, z3p.MkNumeral(34, z3p.CharacterSort))); uint[] p = z3p.GetDeclParameters(f); Assert.AreEqual <int>(2, p.Length); Assert.AreEqual <uint>(56, p[0]); Assert.AreEqual <uint>(205, p[1]); }
private bool Contains(FuncDecl f, IEnumerable <FuncDecl> e) { foreach (FuncDecl f2 in e) { if (f2.Id == f.Id) { return(true); } } return(false); }
internal AcceptorBase(FuncDecl symbol, Expr guard, int rank) { this.symbol = symbol; this.guard = guard; ExprSet[] ts = new ExprSet[rank]; for (int i = 0; i < rank; i++) { ts[i] = new ExprSet(); } lookahead = ts; }
public BinaryTreeInfo(FuncDecl mkTree, FuncDecl mkLeaf, FuncDecl getLeafValue, FuncDecl isTree, FuncDecl isLeaf, FuncDecl getLeft, FuncDecl getRight) { this.MkTree = mkTree; this.GetLeft = getLeft; this.GetRight = getRight; this.MkLeaf = mkLeaf; this.GetLeafValue = getLeafValue; this.IsTree = isTree; this.IsLeaf = isLeaf; }
public void Run() { using (Context ctx = new Context()) { FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { ctx.IntSort, ctx.RealSort }, ctx.IntSort); try { Console.WriteLine(f.Domain[3]); } catch (IndexOutOfRangeException ex) { Console.WriteLine("failed: " + ex.Message); } IntExpr x = ctx.MkIntConst("x"); Console.WriteLine(f[ctx.MkInt(1), ctx.MkReal(1)]); Console.WriteLine(f[ctx.MkInt(1), ctx.MkReal(1)].Sort); Console.WriteLine(f[ctx.MkInt(1), ctx.MkReal(1)].NumArgs); foreach (Expr e in f[ctx.MkAdd(x, ctx.MkInt(1)), ctx.MkReal(1)].Args) { Console.WriteLine(e); } Console.WriteLine(f[ctx.MkAdd(x, ctx.MkInt(1)), ctx.MkReal(1)].Args[0]); Console.WriteLine(f[ctx.MkAdd(x, ctx.MkInt(1)), ctx.MkReal(1)].Args[0].Equals(ctx.MkAdd(x, ctx.MkInt(1)))); Console.WriteLine(f[ctx.MkAdd(x, ctx.MkInt(1)), ctx.MkReal(1)].FuncDecl[ctx.MkInt(2), ctx.MkInt2Real((IntExpr)ctx.MkAdd(x, ctx.MkInt(1)))]); Console.WriteLine(ctx.MkInt(1).IsExpr); Console.WriteLine(ctx.MkAdd(x, ctx.MkInt(1)).IsExpr); Console.WriteLine(ctx.MkForall(new Expr[] { x }, ctx.MkGt(x, ctx.MkInt(0))).IsExpr); Console.WriteLine(ctx.MkInt(1).IsConst); Console.WriteLine(x.IsConst); Console.WriteLine(ctx.MkAdd(x, ctx.MkInt(1)).IsConst); Console.WriteLine(ctx.MkForall(new Expr[] { x }, ctx.MkGt(x, ctx.MkInt(0))).IsConst); Console.WriteLine(ctx.MkForall(new Expr[] { x }, ctx.MkGt(x, ctx.MkInt(0))).Body.Args[0]); Console.WriteLine(ctx.MkForall(new Expr[] { x }, ctx.MkGt(x, ctx.MkInt(0))).Body.Args[0].IsExpr); Console.WriteLine(ctx.MkForall(new Expr[] { x }, ctx.MkGt(x, ctx.MkInt(0))).Body.Args[0].IsConst); Console.WriteLine(ctx.MkForall(new Expr[] { x }, ctx.MkGt(x, ctx.MkInt(0))).Body.Args[0].IsVar); Console.WriteLine(x.IsVar); Console.WriteLine(ctx.MkITE(ctx.MkTrue(), x, ctx.MkAdd(x, ctx.MkInt(1)))); Context ctx1 = new Context(); Console.WriteLine(ctx1.MkITE(ctx1.MkTrue(), x.Translate(ctx1), ctx.MkAdd(x, ctx.MkInt(1)).Translate(ctx1))); Console.WriteLine(ctx.MkITE(ctx.MkTrue(), ctx.MkInt(1), ctx.MkInt(1))); Console.WriteLine(ctx.MkDistinct(x, ctx.MkAdd(x, ctx.MkInt(1)), ctx.MkAdd(x, ctx.MkInt(2)))); Console.WriteLine(ctx1.MkAnd(ctx1.MkDistinct(x.Translate(ctx1), ctx1.MkInt(1)), ctx1.MkGt((IntExpr)x.Translate(ctx1), ctx1.MkInt(0)))); } }
private (string code, string codeID) Model2Asm(Model model) { //sb.Append(ToString(model)); ISet <string> program = new SortedSet <string>(); ISet <string> program2 = new SortedSet <string>(); foreach (FuncDecl funcDecl in model.ConstDecls) { Expr value = model.ConstInterp(funcDecl); if (value.IsBool && value.IsTrue) { //Console.WriteLine(funcDecl); string codeLine = funcDecl.Name.ToString(); string codeLine2 = funcDecl.Name.ToString(); foreach (string constant in this._constants.Keys) { if (codeLine.Contains(constant)) { FuncDecl constantFuncDecl = this._constants[constant].FuncDecl; string constantValue; if (Contains(constantFuncDecl, model.ConstDecls)) { constantValue = model.ConstInterp(this._constants[constant].FuncDecl).ToString(); } else { constantValue = "?"; } //string constantValue = ToolsZ3.ToStringHex(ToolsZ3.GetTv5Array(this._constants[constant], 64, this._solver, this._ctx)); codeLine = codeLine2.Replace('_', ' ').Replace(constant, constantValue); codeLine2 = codeLine2.Replace('_', ' '); break; } } program.Add(codeLine); program2.Add(codeLine2); } } StringBuilder sb = new StringBuilder(); StringBuilder sb2 = new StringBuilder(); foreach (string s in program) { sb.AppendLine(s); } foreach (string s in program2) { sb2.AppendLine(s); } return(sb.ToString(), sb2.ToString()); }
private Expr AccessMember(Expr objectForMemberAccess, MemberInfo memberInfo) { FuncDecl memberFunc = GetOrAddMemberAccessFunction(_context, _environment, memberInfo); Sort memberDeclaredObjectSort = memberFunc.Domain[0]; if (memberDeclaredObjectSort != objectForMemberAccess.Sort) { objectForMemberAccess = UpcastHelper.Upcast(_context, objectForMemberAccess, memberDeclaredObjectSort); } return(_context.MkApp(memberFunc, objectForMemberAccess)); }
/// <summary> /// Make an acceptor output term for the given symbol and states. /// </summary> internal Expr MkAcceptorOutput(FuncDecl f, params Expr[] states) { var args = new Expr[states.Length + 1]; args[0] = vars[0]; for (int i = 0; i < states.Length; i++) { args[i + 1] = tt.Z.MkApp(trans, states[i], vars[i + 1]); } var res = tt.Z.MkApp(f, args); return(res); }