public class CongruenceClosure extends AbstractClosureRule implements Proof.LinearRule
Responsible for implementing congruence closure. That is, applying equalities to eliminate variables through substitution and simplify the overall proof. As an example, consider this assertion:
assert:
forall(int i, int j):
if:
i == 0
then:
i >= 0
This is a simple assertion that should be easily proved. To do this by
contradiction, we end up with the (skolemised) formula
(i == 0) && (i < 0). To establish the contradiction, we
substitute i == 0 through the formula i < 0 to
generate 0 < 0 (which immediately reduces to false). Such
substitutions are the responsibility of this rule.
Upon seeing a new equality (e.g. i == 0 above), this rule
searches back through the history of active truths for any opportunities to
apply the substitution. If/when a successful substitution occurs, then the
truth in question is subsumed and the substituted version asserted
instead. To reduce overhead, this rule employs a lexicographic ordering of
terms and always substitutes through the lowest available candidate in any
given equality.
NOTE: The problem of counting is a surprising issue with
congruence closure. This is possible, for example, when you have recursive
function or predicate applications. For example, consider a formula
x == f(x) && x < 0. Upon first substitution, we end up with
x == f(x) && f(x) < 0. Then, upon second substitution, we end up
with x == f(x) && f(f(x)) < 0, and so on. Therefore, care must
be taken in any such rule to ensure such looping does not occur.
| Modifier and Type | Class and Description |
|---|---|
static class |
CongruenceClosure.Assignment |
simp, types| Constructor and Description |
|---|
CongruenceClosure(Simplification simplify,
TypeSystem types) |
| Modifier and Type | Method and Description |
|---|---|
Proof.State |
apply(Proof.Delta.Set existingTruths,
Proof.State head,
Formula newTruth) |
wybs.lang.SyntacticItem |
construct(Proof.Delta.Set existingTruths,
Proof.State head,
wybs.lang.SyntacticItem term,
Formula newTruth,
List<Formula> dependencies)
When generating an entirely new term within a given rule (i.e.
|
String |
getName()
Get the name of this rule
|
WyalFile.Expr |
localConstruct(Proof.Delta.Set existingTruths,
Proof.State head,
WyalFile.Expr term,
Formula newTruth,
List<Formula> dependencies) |
static WyalFile.Expr |
max(WyalFile.Expr lhs,
WyalFile.Expr rhs) |
static WyalFile.Expr |
min(WyalFile.Expr lhs,
WyalFile.Expr rhs) |
static CongruenceClosure.Assignment |
rearrangeToAssignment(Formula.Equality equality)
Rearrange an equality into two parts.
|
static Arithmetic.Polynomial.Term |
selectCandidateForSubstitution(Arithmetic.Polynomial p)
Examine all terms in a polynomial to see whether any is a candidate for
substitution or not.
|
apply, apply, getExistingTruthsextractDefinedTerms, findAllInstances, substituteclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitapplypublic CongruenceClosure(Simplification simplify, TypeSystem types)
public String getName()
Proof.RulegetName in interface Proof.Rulepublic Proof.State apply(Proof.Delta.Set existingTruths, Proof.State head, Formula newTruth) throws wybs.lang.NameResolver.ResolutionError
apply in class AbstractClosureRulewybs.lang.NameResolver.ResolutionErrorpublic static CongruenceClosure.Assignment rearrangeToAssignment(Formula.Equality equality)
x+1 == y, we may
determine the lhs as x and the rhs as y - 1. A
lexicographic ordering of terms is used to select the candidate for
substitution, versus the rest.equality - --- The equality being rearrangedpublic static Arithmetic.Polynomial.Term selectCandidateForSubstitution(Arithmetic.Polynomial p)
p - public static WyalFile.Expr min(WyalFile.Expr lhs, WyalFile.Expr rhs)
public static WyalFile.Expr max(WyalFile.Expr lhs, WyalFile.Expr rhs)
public wybs.lang.SyntacticItem construct(Proof.Delta.Set existingTruths, Proof.State head, wybs.lang.SyntacticItem term, Formula newTruth, List<Formula> dependencies)
newTerm - public WyalFile.Expr localConstruct(Proof.Delta.Set existingTruths, Proof.State head, WyalFile.Expr term, Formula newTruth, List<Formula> dependencies)
Copyright © 2017. All rights reserved.