bool is_horn(expr* n) { expr* n1, *n2; while (is_forall(n)) n = to_quantifier(n)->get_expr(); if (m.is_implies(n, n1, n2) && is_predicate(n2)) { if (is_var(n1)) { return true; } if (is_quantifier(n1)) { return false; } app* a1 = to_app(n1); if (m.is_and(a1)) { for (unsigned i = 0; i < a1->get_num_args(); ++i) { if (!is_predicate(a1->get_arg(i)) && contains_predicate(a1->get_arg(i))) { return false; } } } else if (!is_predicate(a1) && contains_predicate(a1)) { return false; } return true; } return false; }
void check_predicate(ast_mark& mark, expr* a) { ptr_vector<expr> todo; todo.push_back(a); while (!todo.empty()) { a = todo.back(); todo.pop_back(); if (mark.is_marked(a)) { continue; } mark.mark(a, true); if (is_quantifier(a)) { a = to_quantifier(a)->get_expr(); todo.push_back(a); } else if (m.is_not(a) || m.is_and(a) || m.is_or(a) || m.is_implies(a)) { todo.append(to_app(a)->get_num_args(), to_app(a)->get_args()); } else if (m.is_ite(a)) { todo.push_back(to_app(a)->get_arg(1)); todo.push_back(to_app(a)->get_arg(2)); } else if (is_predicate(a)) { register_predicate(a); } } }
bool is_implication(expr* f) { expr* e1; while (is_forall(f)) { f = to_quantifier(f)->get_expr(); } while (m.is_implies(f, e1, f)) ; return is_predicate(f); }
void context::register_predicate(func_decl * decl, bool named) { if (!is_predicate(decl)) { m_pinned.push_back(decl); m_preds.insert(decl); if (named) { m_preds_by_name.insert(decl->get_name(), decl); } } }
formula_kind get_formula_kind(expr_ref& f) { expr_ref tmp(f); normalize(tmp); ast_mark mark; expr_ref_vector args(m), body(m); expr_ref head(m); expr* a = 0, *a1 = 0; qe::flatten_or(tmp, args); for (unsigned i = 0; i < args.size(); ++i) { a = args[i].get(); check_predicate(mark, a); if (m.is_not(a, a1)) { body.push_back(a1); } else if (is_predicate(a)) { if (head) { return IS_NONE; } head = a; } else { body.push_back(m.mk_not(a)); } } if (head) { if (!is_implication(f)) { f = m.mk_and(body.size(), body.c_ptr()); f = m.mk_implies(f, head); } return IS_RULE; } else { f = m.mk_and(body.size(), body.c_ptr()); return IS_QUERY; } }
void register_predicate(expr* a) { SASSERT(is_predicate(a)); m_ctx.register_predicate(to_app(a)->get_decl(), false); }
static int tl_lex(void) { int c; do { c = tl_Getchar(); yytext[0] = (char ) c; yytext[1] = '\0'; if (c <= 0) { Token(';'); } } while (c == ' '); /* '\t' is removed in tl_main.c */ if (c == '{' || c == '(') /* new 6.0.0 */ { if (is_predicate(c)) { read_upto_closing(c); tl_yylval = tl_nn(PREDICATE,ZN,ZN); if (!tl_yylval) { fatal("unexpected error 4", (char *) 0); } tl_yylval->sym = tl_lookup(yytext); return PREDICATE; } } if (c == '}') { tl_yyerror("unexpected '}'"); } if (islower(c)) { tl_getword(c, isalnum_); if (strcmp("true", yytext) == 0) { Token(TRUE); } if (strcmp("false", yytext) == 0) { Token(FALSE); } if (strcmp("always", yytext) == 0) { Token(ALWAYS); } if (strcmp("eventually", yytext) == 0) { Token(EVENTUALLY); } if (strcmp("until", yytext) == 0) { Token(U_OPER); } #ifdef NXT if (strcmp("next", yytext) == 0) { Token(NEXT); } #endif if (strcmp("c_expr", yytext) == 0) { Token(CEXPR); } if (strcmp("not", yytext) == 0) { Token(NOT); } tl_yylval = tl_nn(PREDICATE,ZN,ZN); if (!tl_yylval) { fatal("unexpected error 5", (char *) 0); } tl_yylval->sym = tl_lookup(yytext); return PREDICATE; } if (c == '<') { c = tl_Getchar(); if (c == '>') { Token(EVENTUALLY); } if (c != '-') { tl_UnGetchar(); tl_yyerror("expected '<>' or '<->'"); } c = tl_Getchar(); if (c == '>') { Token(EQUIV); } tl_UnGetchar(); tl_yyerror("expected '<->'"); } switch (c) { case '/' : c = tl_follow('\\', AND, '/'); break; case '\\': c = tl_follow('/', OR, '\\'); break; case '&' : c = tl_follow('&', AND, '&'); break; case '|' : c = tl_follow('|', OR, '|'); break; case '[' : c = tl_follow(']', ALWAYS, '['); break; case '-' : c = tl_follow('>', IMPLIES, '-'); break; case '!' : c = NOT; break; case 'U' : c = U_OPER; break; case 'V' : c = V_OPER; break; #ifdef NXT case 'X' : c = NEXT; break; #endif default : break; } Token(c); }
void context::register_predicate(func_decl * decl, bool named) { if (!is_predicate(decl)) { m_pinned.push_back(decl); m_preds.insert(decl); TRACE("dl", tout << mk_pp(decl, m) << "\n";);