Eval
public static Z3Body CreateBodyWitness( Z3Body z3ConstCheckedBody, Model model, List<JointType> evaluatedJoints, Z3Body defaultBody) { var witness = new Z3Body(); var jointTypes = EnumUtil.GetValues<JointType>(); foreach (var jointType in jointTypes) { if (evaluatedJoints.Contains(jointType)) { var joint = new Z3Point3D( model.Evaluate(z3ConstCheckedBody.Joints[jointType].X, true) as ArithExpr, model.Evaluate(z3ConstCheckedBody.Joints[jointType].Y, true) as ArithExpr, model.Evaluate(z3ConstCheckedBody.Joints[jointType].Z, true) as ArithExpr); witness.Joints.Add(jointType, joint); var norm = model.Evaluate(z3ConstCheckedBody.Norms[jointType]) as ArithExpr; // Check if norm is still an app (meaning it can be anything), then set it to be the default norm if (norm.ASTKind == Z3_ast_kind.Z3_APP_AST) witness.Norms.Add(jointType, defaultBody.Norms[jointType]); else witness.Norms.Add(jointType, norm); } else { witness.Joints.Add(jointType, defaultBody.Joints[jointType]); witness.Norms.Add(jointType, defaultBody.Norms[jointType]); } } return witness; }
/** \brief Custom model pretty printer. */ void display_model(System.IO.TextWriter w, Model model) { w.WriteLine("Custom model display:"); FuncDecl[] consts = model.ConstDecls; for (int i = 0; i < consts.Length; i++) { w.WriteLine("{0} |-> {1}", consts[i], model.Evaluate(consts[i].Apply())); } w.WriteLine("num consts: {0}", consts.Length); FuncDecl[] funcs = model.FuncDecls; foreach (FuncDecl f in funcs) { FuncInterp g = model.FuncInterp(f); w.WriteLine("function {0}:", f); for (int j = 0; j < g.Entries.Length; ++j) { for (int k = 0; k < g.Entries[j].Args.Length; ++k) { w.Write(" {0} ", g.Entries[j].Args[k]); } w.WriteLine(" |-> {0}", g.Entries[j].Value); } w.WriteLine(" else |-> {0}", g.Else); } }