def remove_free_var_inequality(formula): from iegen.ast.visitor import RemoveFreeVarConstraintVisitor from iegen.ast import Inequality if iegen.settings.debug: before=str(formula) changed=RemoveFreeVarConstraintVisitor(Inequality).visit(formula).changed if changed and iegen.settings.debug: iegen.print_debug('Simplify: removed free variable inequality: %s -> %s'%(before,formula)) return changed
def inverse_simplify(obj): from iegen.ast.visitor import RemoveFreeVarFunctionVisitor from iegen import Set,Relation,PresSet,PresRelation from iegen.util import like_type if iegen.settings.debug: before=str(obj) v=RemoveFreeVarFunctionVisitor(iegen.simplify.inverse_pairs()) changed=v.visit(obj).changed if changed and iegen.settings.debug: iegen.print_debug('Simplify: inverse simplification: %s -> %s'%(before,obj)) if changed: notify_inverse_simplify_listeners(v.func_name,v.func_inv_name) return changed
def register_rule(rule_func,instance=None,rule_group=3): iegen.print_debug("Registering rule '%s' in rule group '%s'..."%(rule_func,rule_group)) if rule_group not in _registered_rules: _registered_rules[rule_group]=[] _registered_rules[rule_group].append((rule_func,instance))
def remove_contradictions(obj): from iegen.ast.visitor import RemoveContradictionsVisitor if iegen.settings.debug: before=str(obj) removed_contradiction=RemoveContradictionsVisitor().visit(obj).removed_contradiction if removed_contradiction and iegen.settings.debug: iegen.print_debug('Simplify: removed contradiction: %s -> %s'%(before,obj)) return removed_contradiction
def remove_tautologies(obj): from iegen.ast.visitor import RemoveTautologiesVisitor if iegen.settings.debug: before=str(obj) removed_tautology=RemoveTautologiesVisitor().visit(obj).removed_tautology if removed_tautology and iegen.settings.debug: iegen.print_debug('Simplify: removed tautology: %s -> %s'%(before,obj)) return removed_tautology
def remove_duplicate_constraints(obj): from iegen.ast.visitor import RemoveDuplicateConstraintsVisitor if iegen.settings.debug: before=str(obj) removed_constraint=RemoveDuplicateConstraintsVisitor().visit(obj).removed_constraint if removed_constraint and iegen.settings.debug: iegen.print_debug('Simplify: removed duplicate constraint: %s -> %s'%(before,obj)) return removed_constraint
def remove_symbolics(obj): from iegen.ast.visitor import RemoveSymbolicsVisitor if iegen.settings.debug: before=str(obj) removed_symbolic=RemoveSymbolicsVisitor().visit(obj).removed_symbolic if removed_symbolic and iegen.settings.debug: iegen.print_debug('Simplify: removed symbolic: %s -> %s'%(before,obj)) return removed_symbolic
def remove_duplicate_formulas(obj): from iegen.ast.visitor import RemoveDuplicateFormulasVisitor if iegen.settings.debug: before=str(obj) removed_formula=RemoveDuplicateFormulasVisitor().visit(obj).removed_formula if removed_formula and iegen.settings.debug: iegen.print_debug('Simplify: removed duplicate forumla: %s -> %s'%(before,obj)) return removed_formula
def remove_zero_coefficients(obj): from iegen.ast.visitor import RemoveZeroCoeffVisitor if iegen.settings.debug: before=str(obj) removed_term=RemoveZeroCoeffVisitor().visit(obj).removed_term if removed_term and iegen.settings.debug: iegen.print_debug('Simplify: removed zero coefficients: %s -> %s'%(before,obj)) return removed_term
def merge_terms(obj): from iegen.ast.visitor import MergeExpTermsVisitor if iegen.settings.debug: before=str(obj) merged_terms=MergeExpTermsVisitor().visit(obj).merged_terms if merged_terms and iegen.settings.debug: iegen.print_debug('Simplify: merged terms: %s -> %s'%(before,obj)) return merged_terms
def register_project_out_listener(listener_func,instance=None): listner_func_name=listener_func.__name__ iegen.print_debug("Registering project out listener '%s'"%(listner_func_name)) _project_out_listeners[listner_func_name]=(listener_func,instance)
def register_fm_listener(listener_func,instance=None): listner_func_name=listener_func.__name__ iegen.print_debug("Registering fm listener '%s'"%(listner_func_name)) _fm_listeners[listner_func_name]=(listener_func,instance)
def register_equality_simplify_listener(listener_func,instance=None): listner_func_name=listener_func.__name__ iegen.print_debug("Registering equality simplify listener '%s'"%(listner_func_name)) _equality_simplify_listeners[listner_func_name]=(listener_func,instance)
def register_inverse_simplify_listener(listener_func,instance=None): listner_func_name=listener_func.__name__ iegen.print_debug("Registering inverse simplify listener '%s'"%(listner_func_name)) _inverse_simplify_listeners[listner_func_name]=(listener_func,instance)
def remove_equal_functions(obj): from iegen.ast.visitor import RemoveEqualFunctionVisitor if iegen.settings.debug: before=str(obj) changed=RemoveEqualFunctionVisitor().visit(obj).changed if changed and iegen.settings.debug: iegen.print_debug('Simplify: removed equal functions: %s -> %s'%(before,obj)) return changed