forked from jon-jacky/PyModel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStackSynchronized.py
More file actions
38 lines (29 loc) · 1.03 KB
/
StackSynchronized.py
File metadata and controls
38 lines (29 loc) · 1.03 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
# pma.py Stack StackOneScenario StackDepthThree -m 6 -o StackSynchronized
# 4 states, 6 transitions, 4 accepting states, 0 unsafe states, 0 finished and 0 deadend states
# actions here are just labels, but must be symbols with __name__ attribute
def Push(): pass
def Pop(): pass
# states, key of each state here is its number in graph etc. below
states = {
0 : {'StackOneScenario': 0, 'Stack': {'stack': []}},
1 : {'StackOneScenario': 0, 'Stack': {'stack': [1]}},
2 : {'StackOneScenario': 0, 'Stack': {'stack': [1, 1]}},
3 : {'StackOneScenario': 0, 'Stack': {'stack': [1, 1, 1]}},
}
# initial state, accepting states, unsafe states, frontier states, deadend states
initial = 0
accepting = [0, 1, 2, 3]
unsafe = []
frontier = []
finished = []
deadend = []
runstarts = [0]
# finite state machine, list of tuples: (current, (action, args, result), next)
graph = (
(0, (Push, (1,), None), 1),
(1, (Push, (1,), None), 2),
(1, (Pop, (1,), None), 0),
(2, (Push, (1,), None), 3),
(2, (Pop, (1,), None), 1),
(3, (Pop, (1,), None), 2),
)