-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColoredFiles1.als
More file actions
90 lines (72 loc) · 1.69 KB
/
ColoredFiles1.als
File metadata and controls
90 lines (72 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
module Apps/ColoredFiles1
open Action
open Reaction
// App configuration
// Composed concepts
open Concepts/Trash[File]
open Concepts/Label[File,Color]
// One trash with labels
one sig T extends Trash {}
one sig L extends Label {}
// Types
sig File {}
sig Color {}
// Projections of the state of the concepts to simplify the specification and visualization
fun accessible : set File { T.accessible }
fun trashed : set File { T.trashed }
fun colors : File -> set Color { L.labels }
// The design goal
// Only accessible files can have colors
check Design {
always {
no reactions iff {
colors.Color in T.accessible
}
}
} for 2 but 10 Action, 10 Reaction expect 0
// Scenarios
// One file with all colors is deleted
// Then a reaction will clear all colors of all files
run Scenario {
eventually (File.colors = Color and T.delete[File])
eventually always no reactions
} for exactly 1 File, exactly 3 Color, 6 Action, 1 Reaction expect 1
// Reactions
/*
reaction delete_clear
when
T.delete[f]
where
some f.colors
then
L.clear[f]
*/
sig Delete_Clear extends Reaction { file : File }
fact {
all x,y : Delete_Clear | x.file = y.file implies x = y
}
fact {
all f : File | always {
(some d : Delete_Clear & reactions_to_add | d.file = f) iff (T.delete[f] and some f.colors)
(some d : Delete_Clear & reactions_to_remove | d.file = f) iff L.clear[f]
}
}
/*
reaction affix_error
when
L.affix[f,c]
where
f not in T.accessible
then
error
*/
sig Affix_Error extends Reaction { }
fact {
all x,y : Affix_Error | x = y
}
fact {
always {
(some Affix_Error & reactions_to_add) iff (some f : File, c : Color | L.affix[f,c] and f not in T.accessible)
(some Affix_Error & reactions_to_remove) iff error
}
}