public class ArrayLengthAxiom extends AbstractProofRule implements Proof.LinearRule
Responsible for inferring that a given array length expression (e.g.
|xs|) is non-negative (i.e. |xs| >= 0) at appropriate moments to
help find a contradiction. In otherwords, this rule implements the axiom that
arrays cannot have negative length. For example, consider a simple
assertion such as the following:
assert:
forall(int[] xs):
|xs| >= 0
This assertion shoud be easily proven. To do this following
proof-by-contradiction requires showing that |xs| < 0 leads to a
contradiction. This rule essentially looks for such situations and implicitly
infers |xs| >= 0 which then gives rise to the contradiction.
NOTE: An important aspect of this rule is when it should and should
not fire. A simple (expensive) strategy is to fire whenever an array length
expression is encountered --- but this is wasteful. For example, in
f(xs) >= 0 there is no point inferring |xs| >= 0 as
this cannot lead to a contradiction. Likewise, in |xs| > 0 there
is equally no point in inferring |xs| >= 0 as this is already
implied. This rule therefore fires only when |xs| is a positive
top-level term on an inequality. In fact, this matching scheme could be
further improved to reduce unnecessary firings. For example, there is no
point in matching "xs" in "1 < |xs|" since we cannot reach a contradiction.
simp, types| Constructor and Description |
|---|
ArrayLengthAxiom(Simplification simplify,
TypeSystem types) |
| Modifier and Type | Method and Description |
|---|---|
Proof.State |
apply(Proof.State state,
Formula truth) |
String |
getName()
Get the name of this rule
|
apply, extractDefinedTerms, findAllInstances, substituteclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitapplypublic ArrayLengthAxiom(Simplification simplify, TypeSystem types)
public String getName()
Proof.RulegetName in interface Proof.Rulepublic Proof.State apply(Proof.State state, Formula truth) throws wybs.lang.NameResolver.ResolutionError
apply in class AbstractProofRulewybs.lang.NameResolver.ResolutionErrorCopyright © 2017. All rights reserved.