Move closure functions to utils module

This commit is contained in:
2020-02-09 10:26:24 +07:00
parent c3860c1bf1
commit f83695b5dc
2 changed files with 26 additions and 26 deletions

View File

@@ -117,7 +117,7 @@ where
Some(definitions) =>
{
let or_arguments = definitions.definitions.into_iter()
.map(|x| existential_closure(x))
.map(|x| crate::existential_closure(x))
.collect::<Vec<_>>();
let or = foliage::Formula::or(or_arguments);
@@ -137,7 +137,7 @@ where
formula: Box::new(completed_definition),
};
universal_closure(scoped_formula)
crate::universal_closure(scoped_formula)
},
// This predicate has no definitions, so universally falsify it
None =>
@@ -168,7 +168,7 @@ where
formula: Box::new(not),
};
universal_closure(scoped_formula)
crate::universal_closure(scoped_formula)
},
}
};
@@ -446,7 +446,7 @@ fn read_rule(rule: &clingo::ast::Rule, context: &Context) -> Result<(), crate::E
formula: Box::new(formula),
};
let integrity_constraint = universal_closure(scoped_formula);
let integrity_constraint = crate::universal_closure(scoped_formula);
log::debug!("translated integrity constraint: {}",
crate::output::human_readable::display_formula(&integrity_constraint, None,
@@ -459,23 +459,3 @@ fn read_rule(rule: &clingo::ast::Rule, context: &Context) -> Result<(), crate::E
Ok(())
}
fn existential_closure(scoped_formula: crate::ScopedFormula) -> Box<foliage::Formula>
{
match scoped_formula.free_variable_declarations.is_empty()
{
true => scoped_formula.formula,
false => Box::new(foliage::Formula::exists(scoped_formula.free_variable_declarations,
scoped_formula.formula)),
}
}
fn universal_closure(scoped_formula: crate::ScopedFormula) -> Box<foliage::Formula>
{
match scoped_formula.free_variable_declarations.is_empty()
{
true => scoped_formula.formula,
false => Box::new(foliage::Formula::for_all(scoped_formula.free_variable_declarations,
scoped_formula.formula)),
}
}