Schema and Schema Calculus - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Schema and Schema Calculus

Description:

Multiple simple schemas may be used to represent multiple simple components of a ... be primed, . Priming a Schema name would be equivalent to priming all the ... – PowerPoint PPT presentation

Number of Views:61
Avg rating:3.0/5.0
Slides: 15
Provided by: fts2
Category:

less

Transcript and Presenter's Notes

Title: Schema and Schema Calculus


1
Schema and Schema Calculus
  • Schemas allowed us to
  • Specify (Represent) the states of the system
  • Specify (Represent) the change of states of the
    system
  • Multiple simple schemas may be used to represent
    multiple simple components of a system.
  • How do we tie all these simple schemas together
    into a complex or more complete schema?
  • Manipulating Schemas
  • Inclusion
  • Extension
  • Combining Schemas via
  • Schema Calculus

2
Z-schemas as Objects
  • Similarity of schemas with
  • Set specification
  • Predicate specification
  • Functional, lambda specification
  • Set Specification
  • p Programs I p
    db_Programs
  • DB_Access
  • p Programs
  • p db_Programs

In set form
In schema form
db_Programs needs to be defined somewhere
3
Predicate Specification
  • p Programs MS(p) -gt has_bug(p)
  • Buggy_Programs
  • p Programs
  • p MS(p) -gt has_bug(p)

Note that has_bug is not defined What do you
think?
4
Lambda Specification
  • p db_Programs I size(p) lt 10 meg
    p
  • Small_Program
  • p db_Programs
  • size (p) lt 10 meg

- size is a fucntion? - Do we need to say that
size (p_memory) ? - Need to define p_memory?
5
Manipulating Schema Objects
  • Previous Schema may be represented with
    brackets
  • DB_Access , Small_Program
  • If we use braces Small_Program, then we mean
    the set representation of the schema called
    Small_Program
  • Schemas may be quantified
  • Small_Program /\ has_bug (p)
  • This is similar to ? p db_programs (size(p)
    lt 10 meg) ? has_bug(p)
  • (there exists a program p such that size(p) lt10
    meg and it has bugs)

6
Manipulating Schema Object (cont.)
  • Consider the following Schema
  • All_Programs
  • user_p , sys_p F Programs
  • user_p n sys_p
  • size(user_p) gt 0
  • size(sys_p) gt 0
  • All_Programs user_p
  • All_Programs sys_p

F stands for finite subset
Gives the number of user_p
Will project all sys_ps
7
Incorporating and Extending Schemas
  • We have discussed Schema Inclusion before (see
    note). A schema may be incorporated into another
    schema by including the former schema name into
    the signature component of the latter schema.
  • The result of the inclusion is to form a new
    schema whose signature is the union of the
    signatures of the 2 schemas.
  • The predicate of the new schema is the logical
    and of the predicates of the 2 schemas.
  • Note that one needs to look out for duplicate
    names to ensure that they are really the same
    data type, because duplicate names of the same
    data type are combined and reduced to one name.
  • Schema may also be primed, .
  • Priming a Schema name would be equivalent to
    priming all the variable names in the signature
    and in the predicate of the schema is primed.
  • Thus it really represents the system state after
    some operation.

8
Delta Symbols
  • Delta Symbol, , used in front of the schema
    name represents both the before and after states
    (the states may change, but not the constraints).
  • Let Editor be a schema specifying an editor
    before the change of states, and Editor be the
    schema specifying the same editor after the
    changes of the state.
  • Then Editor may just be inclusion of
    Editor and Editor
  • Editor
    Editor
  • Editor
    lstring, rstring TEXT
  • Editor
    (lstring Con rstring) lt max

  • Editor

  • lstring, rstring TEXT

  • (lstring Con rstring) lt max

where
9
Xi Symbol
  • The Xi, , symbol represents that the
    schema operation will not change any of the
    variable (data) state.
  • Thus it is an invariant schema
  • e.g.
  • Editor
  • strLen N
  • Editor
  • strLen ! lstring

This schema specifies an Editor whose left and
right strings do not change it outputs the
length of left string. The output operation
leaves all the variables alone.
10
Adding to Schema
  • Adding to the signature of the schema is done
    with a semicolon symbol
  • e.g. Adding a variable to All_Programs
  • More_P All_Programs new_p F Programs
  • Adding to the predicate of the schema is done
    with I symbol
  • e.g. Adding a predicate to More_P of above
  • N_Programs More_P I new_p lt user_p

11
Schema Calculus (with logical operators)
  • Z schemas can be logically operated on
  • logical conjunction, /\
  • The signature parts are merged (with duplicates
    reduced to one )
  • The predicates are joined logically with logical
    conjunction, /\ .
  • Logical disjunction, \/
  • The signature parts are merged (with duplicates
    reduced to one)
  • The predicates are joined logically with logical
    disjunction, \/
  • Logical negation,
  • The signature part of the schema stays the same
  • The predicates are negated

12
Example of Conjunction
  • Consider a simple division example from ( the way
    of Z by Jacky)

Quotient
num, div, quo, rem N
Division Quotient /\ Remainder
div 0 num (quo div ) rem
OR
Division
num, div, quo, rem N
Remainder
remember predicates are logically conjoined
rem, div N
div 0 num (quo div ) rem rem lt div
rem lt div
Remainder schema is included to ensure that 12
0 5 12 doesnt happen. That would trivialize
the predicate in Quotient because we can always
set quotient to be zero by setting num rem
13
Example of Disjunction
  • Continue the example from ( the way of Z Jacky)
  • Furthermore lets include the situation when the
    divisor is zero

DividebyZero
Complete_Div Division \/ DividebyZero
div, quo, rem N
OR
div 0 /\ quo 0 /\ rem0
Complete_Div
num, div, quo, rem N
( div 0 /\ num (quo div ) rem /\ rem lt
div ) \/ ( div0 /\ quo0 /\ rem 0)
14
Example of Negation
  • Negation of a schema is negating the predicates

Division
Division will result in the following
num, div, quo, rem N
Not_Division
div 0 num (quo div ) rem rem lt div
num, div, quo, rem N
(div 0) \/ (num (quo div ) rem) \/
(rem gt div)
Applying DeMorgans law
Write a Comment
User Comments (0)
About PowerShow.com