3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-15 21:38:44 +00:00

add dl_context::has_facts(pred)

Signed-off-by: Nuno Lopes <t-nclaud@microsoft.com>
This commit is contained in:
Nuno Lopes 2013-04-05 18:12:58 -07:00
parent 5f298b6965
commit 1ef17cbe67
4 changed files with 16 additions and 1 deletions

View file

@ -780,6 +780,10 @@ namespace datalog {
add_fact(head->get_decl(), fact); add_fact(head->get_decl(), fact);
} }
bool context::has_facts(func_decl * pred) const {
return m_rel && m_rel->has_facts(pred);
}
void context::add_table_fact(func_decl * pred, const table_fact & fact) { void context::add_table_fact(func_decl * pred, const table_fact & fact) {
if (get_engine() == DATALOG_ENGINE) { if (get_engine() == DATALOG_ENGINE) {
ensure_rel(); ensure_rel();

View file

@ -249,6 +249,7 @@ namespace datalog {
void add_fact(app * head); void add_fact(app * head);
void add_fact(func_decl * pred, const relation_fact & fact); void add_fact(func_decl * pred, const relation_fact & fact);
bool has_facts(func_decl * pred) const;
void add_rule(rule_ref& r); void add_rule(rule_ref& r);
void add_rules(rule_ref_vector& rs); void add_rules(rule_ref_vector& rs);

View file

@ -497,6 +497,11 @@ namespace datalog {
} }
} }
bool rel_context::has_facts(func_decl * pred) const {
relation_base* r = try_get_relation(pred);
return r && !r->empty();
}
void rel_context::store_relation(func_decl * pred, relation_base * rel) { void rel_context::store_relation(func_decl * pred, relation_base * rel) {
get_rmanager().store_relation(pred, rel); get_rmanager().store_relation(pred, rel);
} }

View file

@ -92,10 +92,15 @@ namespace datalog {
*/ */
bool result_contains_fact(relation_fact const& f); bool result_contains_fact(relation_fact const& f);
/** \brief add facts to relation
*/
void add_fact(func_decl* pred, relation_fact const& fact); void add_fact(func_decl* pred, relation_fact const& fact);
void add_fact(func_decl* pred, table_fact const& fact); void add_fact(func_decl* pred, table_fact const& fact);
/** \brief check if facts were added to relation
*/
bool has_facts(func_decl * pred) const;
/** /**
\brief Store the relation \c rel under the predicate \c pred. The \c context object \brief Store the relation \c rel under the predicate \c pred. The \c context object
takes over the ownership of the relation object. takes over the ownership of the relation object.