public class ArrayIndexAxiom extends AbstractClosureRule implements Proof.LinearRule
Responsible for inferring that a given array index expression (e.g.
|xs|) is within bounds (i.e. for A[i] we have
(0 <= i) && (i < |A|)) at appropriate moments to help find a
contradiction. In otherwords, this rule implements the axiom that array
accesses should always be within bounds. For example, consider a simple
assertion such as the following:
assert:
forall(int[] xs):
if:
xs[0] == 0
then:
|xs| > 0
This assertion should 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 would
implicitly infers 0 < |xs| in which case, which gives 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 index
expression is encountered --- but this is wasteful. For example, in
f(xs[i]) >= 0 there is no point inferring i >= 0 as
this cannot lead to a contradiction.
simp, types| Constructor and Description |
|---|
ArrayIndexAxiom(Simplification simplify,
TypeSystem types) |
| Modifier and Type | Method and Description |
|---|---|
Proof.State |
apply(Proof.Delta.Set existingTruths,
Proof.State head,
Formula truth) |
Proof.State |
attemptInstantiation(Formula source,
List<WyalFile.Expr.Operator> matches,
Formula target,
Proof.State state) |
Proof.State |
attemptInstantiationByArrayAccess(Formula truth,
Proof.Delta.Set existingTruths,
Proof.State state) |
Proof.State |
attemptInstantiationByEquation(Formula truth,
Proof.Delta.Set existingTruths,
Proof.State state) |
String |
getName()
Get the name of this rule
|
apply, apply, getExistingTruthsextractDefinedTerms, findAllInstances, substituteclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitapplypublic ArrayIndexAxiom(Simplification simplify, TypeSystem types)
public String getName()
Proof.RulegetName in interface Proof.Rulepublic Proof.State apply(Proof.Delta.Set existingTruths, Proof.State head, Formula truth) throws wybs.lang.NameResolver.ResolutionError
apply in class AbstractClosureRulewybs.lang.NameResolver.ResolutionErrorpublic Proof.State attemptInstantiationByEquation(Formula truth, Proof.Delta.Set existingTruths, Proof.State state) throws wybs.lang.NameResolver.ResolutionError
wybs.lang.NameResolver.ResolutionErrorpublic Proof.State attemptInstantiationByArrayAccess(Formula truth, Proof.Delta.Set existingTruths, Proof.State state) throws wybs.lang.NameResolver.ResolutionError
wybs.lang.NameResolver.ResolutionErrorpublic Proof.State attemptInstantiation(Formula source, List<WyalFile.Expr.Operator> matches, Formula target, Proof.State state) throws wybs.lang.NameResolver.ResolutionError
wybs.lang.NameResolver.ResolutionErrorCopyright © 2017. All rights reserved.