Z Predicates and Schemas - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Z Predicates and Schemas

Description:

d, n: Z d divides n n mod d = 0. 2 divides 14 (2, 14) divides ... x y x y. y x x y. 6. Cartoon of the Day (1/2) 7. Cartoon of the Day (2/2) 8. Editor Example ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 19
Provided by: marka6
Category:

less

Transcript and Presenter's Notes

Title: Z Predicates and Schemas


1
Z Predicates and Schemas
  • SE 420, Formal Methods
  • Mark Ardis, RIT

2
Outline
  • Predicate Calculus
  • Logical connectives
  • Quantifiers
  • Schemas
  • Definition
  • Initialization
  • Operations
  • Schema calculus

3
Logical Connectives
4
Universal Quantifiers
  • divides Z ? Z
  • ? d, n Z d divides n ? n mod d 0
  • 2 divides 14
  • (2, 14) ? divides

Note underline syntax for infix binary operator
5
Existential Quantifiers
  • ? i Z i lt 10
  • ? x ? y x lt y
  • ? y ? x x lt y

6
Cartoon of the Day (1/2)
7
Cartoon of the Day (2/2)
8
Editor Example
  • User can type in text
  • User can move cursor forward and backward through
    the text
  • User can delete the character in front of the
    cursor

9
State schemas
  • Editor
  • left, right TEXT
  • ( left ? right ) ? maxsize

left is before the cursor, right is after
closed box means that the declarations are local
10
Vending Machine Example
q
d
d
n
n
n
n
n
d
d
11
Exercise 1
Write a Z state schema for the vending machine
example, keeping track of the number of nickels,
dimes and quarters. Include a component of the
state that represents the monetary sum of the
coins.
12
Initialization schemas
conventional name begins with Init
  • InitEditor
  • Editor
  • left right ltgt

Editor is included
left and right come from Editor
13
Exercise 2
Write the Z initialization schema for the vending
machine.
14
Operation schemas
global declaration of printing characters
  • printing P Char
  • Insert
  • ? Editor
  • ch? CHAR
  • ch? ? printing
  • left left ? ltch?gt
  • right right

? means that the state will change
? means input (! means output)
precondition
left is the value after the operation
15
Exercise 3
Specify a version of the Add_Dime operation that
only works if the amount of money in the machine
is less than 20 cents.
16
Implicit preconditions
  • right_arrow CHAR
  • right_arrow ? printing
  • Forward
  • ? Editor
  • ch? CHAR
  • ch? right_arrow
  • left left ? lthead(right)gt
  • right tail(right)

implicit precondition right ? ltgt
17
Schema calculus
  • EOF
  • Editor
  • right ltgt
  • RightArrow
  • ch? CHAR
  • ch? right_arrow
  • T_Forward Forward ? ( EOF ? RightArrow ? ?
    Editor )

another state schema
an operation schema
? means that the state does not change
a one-line schema definition
18
Exercise 4
Specify a total function T_Add_Dime in terms of
Add_Dime.
Write a Comment
User Comments (0)
About PowerShow.com