Exemple #1
0
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
Exemple #2
0
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
Exemple #3
0
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))
Exemple #4
0
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
Exemple #5
0
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
Exemple #6
0
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
Exemple #7
0
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
Exemple #8
0
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
Exemple #9
0
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
Exemple #10
0
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
Exemple #11
0
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)
Exemple #12
0
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)
Exemple #13
0
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)
Exemple #14
0
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)
Exemple #15
0
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