CSC5125 Program Verification - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

CSC5125 Program Verification

Description:

Extending the Propositional Calculus and introducing a functional view of arrays ... Any tautology E is equivalent to the same predicate, but with all of its ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 14
Provided by: SteveC1
Category:

less

Transcript and Presenter's Notes

Title: CSC5125 Program Verification


1
CSC5125 Program Verification
  • Developing an approach towards reasoning about
    programs - 3

2
Extending the Propositional Calculus and
introducing a functional view of arrays
  • Material from Chapters 4 and 5
  • Quick review of quantification
  • General forms
  • (E i R E) and (A i R E)
  • Note that R refers to some range of values (not
    necessarily numeric), and E is some predicate
  • Example of non-numeric range
  • (A i person(i) Mortal(i))

3
Another couple notes on quantification
  • We assume the type of the value being quantified
    over (normally this is reasonable, but we will
    have to be careful later)
  • Any tautology E is equivalent to the same
    predicate, but with all of its identifiers
    universally quantified
  • This fact will help us in describing initial
    values in a program

4
Revisiting substitution
  • This is actually hard. We will be glossing over
    most of the particulars until we get to
    denotational semantics
  • Notation that will be used in the text

This notation refers to substituting all free
occurrences of x in predicate E with e
5
Textual substitution
  • Examples
  • Text error (4.4.5) should read

6
Substitution continued
7
Substitution and states
  • Remember that s(e) represents the value of
    expression e in state s.
  • s (s xv) says that state s is the same as
    state s except that identifier x has value v.

8
Substitution lemmas
  • 1) Substituting an expression e for x in E and
    then evaluating E in a state s yields the same
    result as substituting the value of e in state s
    for x and then evaluating
  • In other words
  • Proof is by structural induction

9
Substitution lemmas
10
Arrays
  • We talk about arrays as a special topic due to
    the fact that the way we will reason about them
    is slightly different that for Booleans and ints.
  • We will view arrays functionally namely as a
    map from a subset of the natural numbers to some
    type (the type of the array)

11
Arrays - notation
  • We will generally begin arrays at position 0,
    though there is no particular reason for doing so
    (except that Java does as well).
  • (b ie) (example (b 0T)) is just like the
    array b except that position i has value e.
  • Let b0..3 1,3,4,2. Then what is the
    following value of the array? (b 08 19 07)
  • perm((c 0x), C) is a permutation of array C but
    with x at position 0.

12
Array notation
  • Given array b
  • (A i 0lt i lt n bi lt x) we write b lt x
  • (A i 0lt i lt n bi 0) we write b 0
  • b37 x
  • b y (but note that b y is not the same as
    !(b!y)
  • (E i 0 lt i lt n bi x) we write x e b
  • Can also use picture notation

13
Arrays - definition
Note the similarity of the definition of how
arrays work to how states work!
Write a Comment
User Comments (0)
About PowerShow.com