1 / 20

Arrays

Arrays. Daniel Kroening and Ofer Strichman Decision Procedure. Array logic. Arrays are a basic data structure that is used in most software programs modeling memories and caches in hardware design. Array logic permits expressions over arrays.

jessie
Download Presentation

Arrays

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Arrays Daniel Kroening and OferStrichman Decision Procedure

  2. Array logic • Arrays are a basic data structure that is used in most software programs • modeling memories and caches in hardware design. • Array logic permits expressions over arrays. • Arrays can be formalized as maps from an index type to an element type. • Array logic has two basic operations • Reading • Writing

  3. Contents • Introduction • Arrays as uninterpreted function • A reduction algorithm for array logic • Conclusion

  4. Array logic • Array is the set of functions that map an index value to an element. • Index type TI • Element type TE • Array type • Let denote an array. • Two basic operations on arrays: • Reading : reads an element with index from a. The value of the element of index i is denoted by a[i]. • Writing : writes an element with . Let denote the value to be written. The array a where element i has been replaced by e is denoted by a{i e}.

  5. Index logic • Index logic • The index logic should permit existential and universal quantification. • Existential quantification • “There exists an array element that is zero” • Universal quantification • “All elements of the array are greater than zero” • Array logic is defined by index logic and element logic • Validity for array logic is undecidable, since index logic permits existential and universal quantification. • First-order-logic is undecidable.

  6. The syntax of array logic • atomI denotes an atom in the index logic • atomE denotes an atom in the element logic

  7. Read-over-write axiom • Read-over-write axiom • McCarthy proposed. • After the value e has been written into array a at index i, the value of this array at index i is e. The value at any index j ≠ imatches that in the array before the write operation at index j:

  8. Example • The main step of correctness argument is to show that the invariant in the line 7 is maintained by the assignment in line 6. • A common way to do so is to generate verification conditions.

  9. Example (cond.) • We can obtain the following verification condition for the claim: • Proving validity of this formula shows that the loop invariant is maintained. • Prove by means of read-over-write axiom

  10. Arrays as uninterpreted functions • Here we consider a method to check satisfiability of array logic formula whose quantifications are removed by a reduction mechanism. • We will see the reduction scheme. • array logic formula with quantification  array logic formula without quantification • Here • array logic formula without quantification  equality formula with uninterpreted functions • How to reduce? • array type  uninterpreted function • index type  function argument

  11. Example • Array logic without quantification • Equality formula with an uninterpreted function • Apply Bryant’s reduction

  12. A reduction algorithm for array logic • We define here a restricted class of array logic formulas in order to obtain decidability. • Recall arbitrary formula of original array logic is undecidable. • From hereon we will learn how to reduce given an array logic formula to the decidable array logic formula. • We consider formulas that are Boolean combinations of array property. • The reduced decidable array logic formula has array property.

  13. Array property • Def. An array logic formula is called an array property if and only if it is of the form • and satisfies the following conditions: • The predicate , called the index guard, must follow the grammar. • The predicate is called the value constraint. The “integer-identifier” used in “term” must not be .

  14. Extensionality rule • Def. Extensionality rule is the elementwise equality of two arrays. • Extensionality is an array property: • index guard is simply TRUE in this case. • is the value constraint of Extensionality rule.

  15. Example • Array logic formula • Array property formula • Only second conjunct is not array property formula • Write-rule : Array updates can be handled by replacing each expression of the form by a fresh variable a’ of array type, and by adding two constraints that correspond directly to the two cases of the read-over-write axiom: 1. for the value that is written, 2. for the values that are unchanged.

  16. A reduction algorithm • Array-Reduction • Input : An array property formula • Output : A formula with uninterpreted functions • Apply the write rule to remove all array updates from . • Replace all existential quantifications of the form by P(j), where j is a fresh variable. • Replace all universal quantifications of the form by • Replace the array read operations by uninterpreted functions and obtain . • return .

  17. A reduction algorithm • In step 3 • The universal quantifiers replaced by the conjunction , where the set denotes the index variables that i might possibly be equal to in the formula . • set contains the following element : • All variables used as an array index in that are not quantified variables. • All variables used inside index guards in that are not quantified variables. • If contains none of the above, is {0} in order to obtain a nonempty set of index variables.

  18. Example • We want to check satisfiability of 1. Apply the write rule to remove all array updates from . 2. Replace all existential quantifications of the form by P(z), where zis a fresh variable. = = =

  19. Example (cond.) 3. Replace all universal quantifications of the form by , where = { i, z } 4. Remove trivially satisfied conjuncts. 5. Replace the two arrays a and a’ by uninterpreted functions Fa and Fa’.

  20. Conclusion • Validity of an array logic formula without any reduction is undecidable. • Reduction algorithm needed. • Reduction algorithm outputs a formula with uninterpreted functions

More Related