private static bool CheckForAllStates(Expr output, Func <Expr, bool> phi) { if (output.ASTKind != Z3_ast_kind.Z3_APP_AST) { throw new AutomataException(AutomataExceptionKind.TreeTransducer_UnexpectedOutputExpr); } var f = output.FuncDecl; var args = output.Args; if (TreeTheory.IsTrans(f)) { //check the state condition for the first argument bool res = phi(args[0]); return(res); } else //must be constructor { for (int i = 1; i < args.Length; i++) { if (!CheckForAllStates(args[i], phi)) { return(false); } } return(true); } }
/// <summary> /// Enumerates all pairs Expr[]{state,child_variable}. /// </summary> static IEnumerable <Expr[]> GetStatesOf(Expr t) { if (t.ASTKind == Z3_ast_kind.Z3_APP_AST) { var args = t.Args; if (TreeTheory.IsTrans(t.FuncDecl)) { yield return(args); } else { for (int i = 1; i < args.Length; i++) { foreach (var s in GetStatesOf(args[i])) { yield return(s); } } } } }