umaudemc 0.12.1__py3-none-any.whl → 0.13.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
umaudemc/formatter.py CHANGED
@@ -89,23 +89,18 @@ def parse_state_format(sformat, strategy):
89
89
  tused > 0, sused > 0))
90
90
 
91
91
 
92
- def apply_edge_format(graph, origin, dest, eformat):
92
+ def apply_edge_format(stmt, eformat):
93
93
  """
94
94
  Edge label generator using a prebuilt format string.
95
95
 
96
- :param graph: Rewriting graph the transition belong to.
97
- :type graph: Maude rewriting graph.
98
- :param origin: Index of the origin state within the graph.
99
- :type origin: int
100
- :param dest: Index of the destination state within the graph.
101
- :type dest: int
96
+ :param stmt: Rule that caused the transition
97
+ :type stmt: Rule
102
98
  :param eformat: Prebuilt format string.
103
99
  :type eformat: str
104
100
  :returns: Formatted edge label.
105
101
  :rtype str
106
102
  """
107
103
 
108
- stmt = graph.getRule(origin, dest)
109
104
  label = stmt.getLabel()
110
105
  line = stmt.getLineNumber()
111
106
  opaque = ''
@@ -116,9 +111,8 @@ def apply_edge_format(graph, origin, dest, eformat):
116
111
  return eformat.format(stmt=stmt, label=label, line=line, opaque=opaque)
117
112
 
118
113
 
119
- def apply_edge_format_strat(graph, origin, dest, eformat):
114
+ def apply_edge_format_strat(trans, eformat):
120
115
  """Edge label generator for strategy-controlled using a prebuilt format string"""
121
- trans = graph.getTransition(origin, dest)
122
116
  opaque, label, stmt, line = '', '', '', ''
123
117
 
124
118
  if trans.getType() == maude.StrategyRewriteGraph.SOLUTION:
@@ -150,9 +144,9 @@ def parse_edge_format(eformat, strategy):
150
144
  eformat = re.sub(r'%(.\d+)?n', r'{line:\1}', eformat)
151
145
 
152
146
  if strategy:
153
- return lambda graph, origin, dest: apply_edge_format_strat(graph, origin, dest, eformat)
147
+ return lambda trans: apply_edge_format_strat(trans, eformat)
154
148
  else:
155
- return lambda graph, origin, dest: apply_edge_format(graph, origin, dest, eformat)
149
+ return lambda stmt: apply_edge_format(stmt, eformat)
156
150
 
157
151
 
158
152
  #
@@ -165,29 +159,30 @@ def print_term(graph, index):
165
159
  return graph.getStateTerm(index)
166
160
 
167
161
 
168
- def print_transition(graph, origin, dest):
162
+ def print_transition(stmt):
169
163
  """Default edge-label printing function"""
170
- return graph.getRule(origin, dest)
164
+ return stmt
171
165
 
172
166
 
173
- def print_transition_strat(graph, origin, dest):
167
+ def print_transition_strat(trans):
174
168
  """Default edge-label printing function with strategies"""
175
- trans = graph.getTransition(origin, dest)
176
- return {
177
- maude.StrategyRewriteGraph.RULE_APPLICATION : trans.getRule(),
178
- maude.StrategyRewriteGraph.OPAQUE_STRATEGY : trans.getStrategy(),
179
- maude.StrategyRewriteGraph.SOLUTION : ''
180
- }[trans.getType()]
169
+ ttype = trans.getType()
170
+
171
+ if ttype == maude.StrategyRewriteGraph.RULE_APPLICATION:
172
+ return trans.getRule()
173
+ elif ttype == maude.StrategyRewriteGraph.OPAQUE_STRATEGY:
174
+ return trans.getStrategy()
175
+ else:
176
+ return ''
181
177
 
182
178
 
183
- def print_transition_label(graph, origin, dest):
179
+ def print_transition_label(stmt):
184
180
  """Alternative edge-label printing function (only rule label)"""
185
- return graph.getRule(origin, dest).getLabel()
181
+ return stmt.getLabel()
186
182
 
187
183
 
188
- def print_transition_strat_label(graph, origin, dest):
184
+ def print_transition_strat_label(trans):
189
185
  """Alternative edge-label printing function with strategies (only rule/strategy label)"""
190
- trans = graph.getTransition(origin, dest)
191
186
  ttype = trans.getType()
192
187
 
193
188
  if ttype == maude.StrategyRewriteGraph.RULE_APPLICATION:
umaudemc/formulae.py CHANGED
@@ -22,7 +22,7 @@ def collect_aprops(form, aprops):
22
22
 
23
23
 
24
24
  def _add_path_premise_ctl(form, premise):
25
- """Add a premise to every path quantification in CTL* formulae"""
25
+ """Add a premise to every path quantification in CTL* formulae"""
26
26
  head, *rest = form
27
27
 
28
28
  if head == 'A_' or head == 'E_':
@@ -102,7 +102,7 @@ def _actionSpecParse(acspec, labels):
102
102
 
103
103
 
104
104
  def _formula2List(form, *extra_args):
105
- """Convert the formula parsed by Maude into an pure Python list"""
105
+ """Convert the formula parsed by Maude into a pure Python list"""
106
106
  prop_sort, variable_sort, labels = extra_args
107
107
 
108
108
  if form.getSort() <= prop_sort:
@@ -170,7 +170,7 @@ def _boundSpecParse(bound):
170
170
 
171
171
 
172
172
  def _probFormula2List(form, prop_sort, aprops):
173
- """Convert the probabilistic formula parsed by Maude into an pure Python list"""
173
+ """Convert the probabilistic formula parsed by Maude into a pure Python list"""
174
174
 
175
175
  if form.getSort() <= prop_sort:
176
176
  aprops.add(str(form))
@@ -269,7 +269,7 @@ class BaseParser:
269
269
  self.templog.parseTerm('tokenize("{}")'.format(formula.replace('"', '\"'))),
270
270
  self.templog.parseTerm(label_list)
271
271
  )
272
- parser_metamod.reduce()
272
+
273
273
  extmod = maude.downModule(parser_metamod)
274
274
 
275
275
  formula_kind = extmod.findSort('Formula').kind()
umaudemc/grapher.py CHANGED
@@ -43,8 +43,8 @@ class DOTGrapher:
43
43
  if bound == 0:
44
44
  return
45
45
 
46
- for next_state in graph.getNextStates(stateNr):
47
- elabel = self.elabel(graph, stateNr, next_state) if self.elabel else None
46
+ for next_state, edge in graph.getTransitions(stateNr):
47
+ elabel = self.elabel(edge) if self.elabel else None
48
48
  self.write_transition(stateNr, next_state, elabel)
49
49
 
50
50
  if next_state not in self.visited:
@@ -67,7 +67,8 @@ class PDOTGrapher(DOTGrapher):
67
67
  num, den = Fraction(p).limit_denominator().as_integer_ratio()
68
68
 
69
69
  # Standard labels are used too
70
- elabel = self.elabel(graph, start, end)
70
+ stmt = graph.getTransition(start, end) if graph.strategyControlled else graph.getRule(start, end)
71
+ elabel = self.elabel(stmt)
71
72
 
72
73
  return f'{num}/{den} {elabel}' if p != 1.0 else elabel
73
74
 
@@ -123,14 +124,14 @@ class TikZGrapher:
123
124
  if bound == 0:
124
125
  return
125
126
 
126
- for next_state in graph.getNextStates(stateNr):
127
+ for next_state, edge in graph.getTransitions(stateNr):
127
128
  print(f'\t{self.printState(graph, stateNr)}', file=self.outfile, end='')
128
129
  next_visited = next_state in self.visited
129
130
 
130
131
  if self.elabel is None:
131
132
  print(f' -> ', file=self.outfile, end='')
132
133
  else:
133
- label = str(self.elabel(graph, stateNr, next_state)).replace('"', '""')
134
+ label = str(self.elabel(edge)).replace('"', '""')
134
135
  print(f' ->["{label}"] ', file=self.outfile, end='')
135
136
 
136
137
  print(f'{self.printState(graph, next_state)};', file=self.outfile)