Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.
Nächste SlideShare
×

Formal 7– Modelling state – looking within the system at internal behaviour

22 Aufrufe

Veröffentlicht am

Slides for the Formal Methods in HCI unit of my 2013 online course on HCI
https://hcibook.com/hcicourse/2013/unit/09-formal

* what is state?
* modelling state – stages
* example a car clock
* defining state – not too little or too much
* defining actions – internal and external consistency

Veröffentlicht in: Technologie
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Als Erste(r) kommentieren

• Gehören Sie zu den Ersten, denen das gefällt!

Formal 7– Modelling state – looking within the system at internal behaviour

1. 1.  modelling state looking within  
2. 2. what is state that in the present of that in the past which affects that of the future time
3. 3. modelling state describe state using variables – a bit like programming types of variables: – basic type: x: Nat – non-negative integer {0,1,2,...} – individual item from set: shape: {circle, line, rectangle} – subset of bigger set: selection: set Nat – set of integers – function (often finite): objects: Nat  shape – user defined: Point = x, y: Real – e.g. (1.79,-3.2) also: Int – pos or neg integer Real – fractional number String, etc.
4. 4. stages iteratively define: state – what needs to be remembered invariants – what is always true initial state – how it starts actions – what can happen to the state (need to relate these to mouse, keys, etc.) display – what the user sees (hears etc.) use scenarios to check they are what you want
5. 5. example: car clock three buttons: mode – cycles between hours, mins, seconds +/– – increments/decrements selected item we will define state and actions N.B. will not be right first time ... spot the mistakes ... 16:55:00 mode – +
6. 6. clock state – first attempt state hours: Nat mins: Nat – all just numbers secs: Nat hours < 24 ∧ mins < 60 ∧ secs < 60 initial state hours = 0 mins = 0 secs= 0 display hours “:” mins “:” secs invariant
7. 7. clock actions – first attempt increment (+) add 1 to selected item others unchanged decrement (–) similar mode cycle selected item what is it?
8. 8. clock state – second attempt state hours: Nat, mins: Nat, secs: Nat – all just numbers selected: { ‘NONE’, ‘HRS’, ‘MINS’, ‘SECS’ } hours < 24 ∧ mins < 60 ∧ secs < 60 initial state hours = 0, mins = 0, secs= 0 selected = ‘NONE’ display hours “:” mins “:” secs (with selected flashing)
9. 9. clock actions – second attempt increment (+) if ( selected = ‘NONE’ ) do nothing if ( selected = ‘HRS’ ) hours’ = hours+1 ... decrement (–) similar mode if ( selected = ‘NONE’ ) selected’ = ‘HRS’ ... variable with apostrophe (called ‘prime’) is state after action
10. 10. clock– scenario time is 22:58:33 user types: mode mode + + action selected hours mins secs NONE 22 58 33 mode HRS 22 58 33 mode MINS 22 58 33 increment (+) MINS 22 59 33 increment (+) MINS 22 60 33 !!!
11. 11. clock actions – third attempt increment (+) if ( selected = ‘NONE’ ) do nothing if ( selected = ‘HRS’ ) if ( hours < 23 ) hours’ = hours+1 if ( hours = 23 ) hours’ = 0 if ( selected = ‘MINS’ ) if ( mins< 59 ) mins’ = mins+1 if ( mins= 59 ) mins’ = 0 ...
12. 12. clock– scenario revisited time is 22:58:33 user types: mode mode + + action selected hours mins secs NONE 22 58 33 mode HRS 22 58 33 mode MINS 22 58 33 increment (+) MINS 22 59 33 increment (+) MINS 22 0 33 but does this want to become 23?
13. 13. defining state two problems: • too little state elements missing from specification may be deliberate e.g. dialogue level spec. • too much state too many states, too complex state may be deliberate redundancy, extensibility
14. 14. too little state forgotten elements e.g. ‘selected’ mode in car clock checking: – dialogue state can you work out current dialogue state? – action specification do you have enough information? – implicit global variables (see also later) suggest state missing
15. 15. too much state unreachable states too few actions (see later) constraints spare variables: constant/functional dependent dependent state e.g. first point of line, number being typed indistinguishable states what is observable? states are not orthogonal
16. 16. defining actions framing problems = too little in result state unreachable states – insufficient actions using ‘global’ variables implicit in operation definition beware extreme cases (e.g. empty document, cursor at end of line)
17. 17. internal and external consistency state scenarios actions invariants preserved? actions complete? missing state? makes sense? general properties specific examples  