1 / 26

Tabular Representation

Tabular Representation. Based on: Ryszard Janicki, David L. Parnas, and Jeffery Zucker. Tabular Representations in Relational Documents. Relational Methods in Computer Science, Springer-Verlag, 1996. 1. 1. 1. Outline. Motivation Simple tabular notation (raw table)

faunus
Télécharger la présentation

Tabular Representation

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. Tabular Representation Based on: Ryszard Janicki, David L. Parnas, and Jeffery Zucker. Tabular Representations in Relational Documents. Relational Methods in Computer Science, Springer-Verlag, 1996. 1 1 1

  2. Outline • Motivation • Simple tabular notation (raw table) • Full tabular notation (well-done table) • Cell connection graph • Table predicate rule • Table relation rule 2 2 2

  3. Motivation---Modeling Requirements • Monitored vs. controlled environmental quantities • Abstracted to mathematical variables whose values changed over time, i.e., time function. • Monitored: to be measured by the system (mi) • Controlled: to be controlled by the system (ci) • Requirements documented with two relations • NAT: describes the environment • dom (NAT): set of vectors of time-function m’s • ran (NAT):set of vectors of time-function c’s • (m, c)  NAT iff the environment allows • REQ: describes the effect of the system • dom (REQ): set of vectors of time-function m’s • ran (REQ):set of vectors of time-function c’s considered permissible • (m, c)  REQ iff the system should permit 3 3 3

  4. Motivation---Modeling Requirements Monitored vs. controlled environmental quantities Abstracted to mathematical variables whose values changed over time, i.e., time function. Monitored: to be measured by the system (mi) Controlled: to be controlled by the system (ci) Requirements documented with two relations NAT: describes the environment dom (NAT): set of vectors of time-function m’s ran (NAT):set of vectors of time-function c’s (m, c)  NAT iff the environment allows REQ: describes the effect of the system dom (NAT): set of vectors of time-function m’s ran (NAT):set of vectors of time-function c’s considered permissible (m, c)  NAT iff the system should permit Requirements can be documented as mathematical relations or functions! 4 4 4

  5. Motivation • Describe the following function in Z and OCL f(x,y) = 0 if x 0  y = 10 x if x < 0  y = 10 y2 if x 0  y > 10 -y2 if x 0  y < 10 x + y if x < 0  y > 10 x – y if x < 0  y < 10 5

  6. Motivation Describe the following function in Z and OCL f(x,y) = 0 if x 0  y = 10 x if x < 0  y = 10 y2 if x 0  y > 10 -y2 if x 0  y < 10 x + y if x < 0  y > 10 x – y if x < 0  y < 10 6

  7. In Z f(x,y) = 0 if x 0  y = 10 x if x < 0  y = 10 y2 if x 0  y > 10 -y2 if x 0  y < 10 x + y if x < 0  y > 10 x – y if x < 0  y < 10 f: Z  Z  Z 7

  8. In Z f: Z  Z  Z  x: Z, y: Z (x 0  y = 10  f(x,y) = 0)  (x < 0  y = 10  f(x,y) = x)  (x 0  y > 10  f(x,y) = y2 )  (x 0  y < 10  f(x,y) = -y2)  (x < 0  y > 10  f(x,y) = x + y)  (x < 0  y < 10  f(x,y) = x – y) f(x,y) = 0 if x 0  y = 10 x if x < 0  y = 10 y2 if x 0  y > 10 -y2 if x 0  y < 10 x + y if x < 0  y > 10 x – y if x < 0  y < 10 8

  9. In OCL f(x,y) = 0 if x 0  y = 10 x if x < 0  y = 10 y2 if x 0  y > 10 -y2 if x 0  y < 10 x + y if x < 0  y > 10 x – y if x < 0  y < 10 context Math::f(x: Integer, y: Integer): Integer pre: true post: result = ifx >= 0 andy = 10 then 0 else if x < 0 andy = 10 then x else if x >= 0 andy > 10 then y*y else if x >= 0 andy < 10 then –y*y else if x < 0 and y > 10 then x + y else if x < 0 andy < 10 thenx – y else 0 endif endif endif endif endif endif 9

  10. In OCL context Math::f(x: Integer, y: Integer): Integer pre: true post: result = ifx >= 0 andy = 10 then 0 else if x < 0 andy = 10 then x else if x >= 0 andy > 10 then y*y else if x >= 0 andy < 10 then –y*y else if x < 0 and y > 10 then x + y else if x < 0 andy < 10 thenx – y else 0 endif endif endif endif endif endif f(x,y) = 0 if x 0  y = 10 x if x < 0  y = 10 y2 if x 0  y > 10 -y2 if x 0  y < 10 x + y if x < 0  y > 10 x – y if x < 0  y < 10 Not very readable or checkable! 10

  11. Use a Table? f(x,y) = 0 if x 0  y = 10 x if x < 0  y = 10 y2 if x 0  y > 10 -y2 if x 0  y < 10 x + y if x < 0  y > 10 x – y if x < 0  y < 10 11

  12. Tabular Representation Elements • Header: an indexed set of cells, H = {hi | i  I}, where I = {1,2, …, k} • Grid indexed by headers H1, …, Hn, with Hj = {hij | i  Ij}, j = 1,.., n: an indexed set of cells G = {g | g I}, where I = I1 …  In Raw table skeleton • A collection of headers plus a grid indexed by this collection H1 = {hi1 | i = 1, 2, 3} H2 = {hi2 | i = 1, 2} G = {gij | i = 1, 2, 3 and j = 1, 2} 12

  13. Why Tabular Representations of Relations? • Conventional math descriptions • Too complex to parse to be really useful • Lengthy and hard to read and understand • Digital system • Not continuous <-> continuous function of analog • Domain and range: tuple of distinct types 13

  14. Exercise Using the tabular notation, specify a program that reserves a golf tee time. • The standard green fee is $65 on weekdays (Monday-Friday) and $80 on weekend (Saturday and Sunday). • However, an El Paso resident pays a reduced green fee of $45 and $60 on weekdays and weekend, respectively. • A senior (of age 60+) pays only $40 and $50 on weekdays and weekend, respectively. • A junior (of age <17) pays only $20 and $30 on weekdays and weekend, respectively. 14

  15. Sample Solution Q: Nested tables for resident/non-resident (thanks to Elsa)? 15

  16. Exercise • Specify the following function. g(x,y) = x + y if (x <0  y  0)  (x < y  y < 0) x - y if (0  x < y  y  0)  (y  x < 0  y < 0) y - x if (x  y  y  0)  (x  0  y < 0) 16

  17. Inverted Table • A header specifies the output of the function. H1 H2 G 17

  18. G Cell Connection Graph (CCG) • Characterizes information flow, i.e., where do I start reading the table and where do I get the result? • A relation interpreted as an acyclic directed graph • Each arch must either start from or end at the grid G. H1 H1 H2 H3 H2 G H3 H1 H1 H2 G H3 H2 G H3 18

  19. G Cell Connection Graph (CCG) • Characterizes information flow, i.e., where do I start reading the table and where do I get the result? • A relation interpreted as an acyclic directed graph • Each arch must either start from or end at the grid G. But, how the domain and values of the relation specified are determined? E.g., how to combine the cells? H1 H1 H2 H3 H2 G H3 H1 H1 H2 G H3 H2 G H3 19

  20. Well-Done Table Skeleton • Table skeleton with • Table predicate rule, PTspecifying the domain • Table relation rule, RT specifying the relation H1 G H2 PT(H1,H2) = H1 H2 RT(G) = G 20

  21. Exercise • Write the PT and RT of the following table and explain how to interpret the table. H1 H1 H1 H1 G G G H2 H2 H2 H2 21

  22. Example f(x,y) = 0 if x 0  y = 10 x if x < 0  y = 10 y2 if x 0  y > 10 -y2 if x 0  y < 10 x + y if x < 0  y > 10 x – y if x < 0  y < 10 H1 H2 G 22

  23. Exercise Using the full tabular notation, specify a program that reserves a golf tee time. • The standard green fee is $65 on weekdays (Monday-Friday) and $80 on weekend (Saturday and Sunday). • However, an El Paso resident pays a reduced green fee of $45 and $60 on weekdays and weekend, respectively. • A senior (of age 60+) pays only $40 and $50 on weekdays and weekend, respectively. • A junior (of age <17) pays only $20 and $30 on weekdays and weekend, respectively. 23

  24. Exercise 1. Using Z and the tabular notation, specify a program that hires an employee for a company. The program takes an employee’s name, gender, SSN, job position, and salary, and adds the employee to the company’s employee database. It should detect when some of the employee’s information is missing or invalid: • when the gender is not specified • when the job position is not specified • when the salary is less than 0 • when there already exists an employee with the same SSN 2. Compare the Z specification and the tabular specification. Is there any significant difference, and if so, which is better and why? 24

  25. Solution Assume a state variable emps, an input e and an output r. ALL_ERR denotes {n_err, s_err, g_err, p_err}. H1 Incomplete H3 H2 G H4

  26. Solution H1 H2 G

More Related