3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-02-17 14:21:45 +00:00
z3/src/muz/base/dl_rule_subsumption_index.cpp
Nikolaj Bjorner b19f94ae5b make include paths uniformly use path relative to src. #534
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2017-07-31 13:24:11 -07:00

84 lines
1.7 KiB
C++

/*++
Copyright (c) 2006 Microsoft Corporation
Module Name:
dl_rule_subsumption_index.cpp
Abstract:
Subsumption index for rules.
Currently an underapproximation (fails to identify some subsumptions).
Author:
Krystof Hoder (t-khoder) 2011-10-10.
Revision History:
--*/
#include <sstream>
#include "ast/ast_pp.h"
#include "muz/base/dl_rule_subsumption_index.h"
namespace datalog {
// -----------------------------------
//
// rule_subsumption_index
//
// -----------------------------------
void rule_subsumption_index::handle_unconditioned_rule(rule * r) {
SASSERT(r->get_tail_size()==0);
app * head = r->get_head();
func_decl * pred = head->get_decl();
app_set * head_set;
if(!m_unconditioned_heads.find(pred, head_set)) {
head_set = alloc(app_set);
m_unconditioned_heads.insert(pred, head_set);
}
head_set->insert(head);
}
void rule_subsumption_index::add(rule * r) {
m_ref_holder.push_back(r);
if(r->get_tail_size()==0) {
handle_unconditioned_rule(r);
}
m_rule_set.insert(r);
}
bool rule_subsumption_index::is_subsumed(app * query) {
func_decl * pred = query->get_decl();
app_set * head_set;
if(m_unconditioned_heads.find(pred, head_set)) {
if(head_set->contains(query)) {
return true;
}
}
return false;
}
bool rule_subsumption_index::is_subsumed(rule * r) {
app * head = r->get_head();
if(is_subsumed(head)) {
return true;
}
if(m_rule_set.contains(r)) {
return true;
}
return false;
}
};