Skip to content

Rule system: Remove free variable #3579

Description

@chriseth

This is more of a research issue, but I noticed the following:

If we have a constraint of the form

new_var_177 * (cmp_result_1 + cmp_result_2 - cmp_result_1 * cmp_result_2) - cmp_result_4 = 0

where new_var_177 only occurs here and cmp_result_* are all binary, then we can replace this constraint with an equivalent constraint that does not need new_var_177.

More general:

If we have a constraint of the form

F * A - B = 0

where F only occurs in that constraint, then this is equivalent to

A != 0 or B = 0

If A is binary, this condition can be written as

(1 - A) * B = 0

Maybe this can be generalized to other types of constraints.

For the constraint above, the main challenge for implementing this in the rule system is to correctly determine the range constraint of (cmp_result_1 + cmp_result_2 - cmp_result_1 * cmp_result_2).

We could do a structural analysis for exactly this structure, or we could detect that it only contains boolean variables and perform an exhaustive evaluation of the possible values. Maybe the latter could also be useful for replacing the exhaustive search altogether.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions