Showing
1 changed file
with
23 additions
and
19 deletions
... | @@ -140,47 +140,51 @@ class ARCTL_model_checker(CTL_model_checker): | ... | @@ -140,47 +140,51 @@ class ARCTL_model_checker(CTL_model_checker): |
140 | """ | 140 | """ |
141 | Input: | 141 | Input: |
142 | - universe is a sdd representing the state space (for example v.g.reachable) | 142 | - universe is a sdd representing the state space (for example v.g.reachable) |
143 | - - pred_dict is a dictionary associating transition label strings to shom representing the precedence relation for this label | 143 | + - pred_dict is a list of tuples associating shoms and vectors of label strings |
144 | - pred is a shom representing the precedence relation (inverse of the transition relation) | 144 | - pred is a shom representing the precedence relation (inverse of the transition relation) |
145 | - tau_label is the label representing invisible actions, or '_None' if no invisible actions | 145 | - tau_label is the label representing invisible actions, or '_None' if no invisible actions |
146 | """ | 146 | """ |
147 | - assert isinstance(pred_dict, dict), "pred_dict must be of type dict" | 147 | + assert isinstance(pred_dict, list), "pred_dict must be of type dict" |
148 | - assert len(pred_dict) >= 1, "pred_dict must contain at least one element" | ||
149 | - for e in pred_dict: # for each key of the dictionnary | ||
150 | - assert isinstance(e, str), "every key of pred_dict must be of type string" | ||
151 | - assert isinstance(pred_dict[e], shom), "every value of pred_dict must be of type shom" | ||
152 | self.pred_dict = pred_dict | 148 | self.pred_dict = pred_dict |
153 | - if tau_label in pred_dict: | 149 | + assert len(pred_dict) >= 1, "pred_dict must contain at least one element" |
150 | + self.alpha_labels = set() | ||
151 | + for action, labels in pred_dict: # for each key of the dictionnary | ||
152 | + assert isinstance(action, shom), "every key of pred_dict must be of type shom" | ||
153 | + for l in labels: | ||
154 | + assert isinstance(l, str), "every value of pred_dict must be of type str" | ||
155 | + self.alpha_labels.add(l) | ||
156 | + self.alpha_labels = list(self.alpha_labels) | ||
157 | + if tau_label in self.alpha_labels: | ||
154 | self.tau_label = tau_label | 158 | self.tau_label = tau_label |
155 | else: | 159 | else: |
156 | self.tau_label = None | 160 | self.tau_label = None |
157 | CTL_model_checker.__init__(self, universe, pred) | 161 | CTL_model_checker.__init__(self, universe, pred) |
158 | self.logic = "ARCTL" | 162 | self.logic = "ARCTL" |
159 | 163 | ||
160 | - def alpha_parse(self, alpha): | 164 | + def alpha_parse(self, alpha, labels): |
161 | if alpha.kind == 'bool': | 165 | if alpha.kind == 'bool': |
162 | assert isinstance(alpha.value, bool), repr(alpha) + " is of kind bool but its value is not a boolean" | 166 | assert isinstance(alpha.value, bool), repr(alpha) + " is of kind bool but its value is not a boolean" |
163 | if alpha.value: | 167 | if alpha.value: |
164 | - return self.EX | 168 | + return True |
165 | else: | 169 | else: |
166 | - return shom.empty() | 170 | + return False |
167 | elif alpha.kind == 'name': | 171 | elif alpha.kind == 'name': |
168 | - assert alpha.value in self.pred_dict.keys(), f"{alpha.value} is not an action label" | 172 | + assert alpha.value in self.alpha_labels, f"{alpha.value} is not an action label" |
169 | - return self.pred_dict[alpha.value] | 173 | + if self.tau_label: |
174 | + if self.tau_label in labels: | ||
175 | + return True | ||
176 | + return alpha.value in labels | ||
170 | elif alpha.kind == 'not': | 177 | elif alpha.kind == 'not': |
171 | - return self.EX.__sub__(self.build_pred_alpha(alpha.children[0])) # not sure of myself here | 178 | + return not(self.alpha_parse(alpha.children[0], labels)) |
172 | elif alpha.kind =='and': | 179 | elif alpha.kind =='and': |
173 | - return reduce(shom.__and__, [self.build_pred_alpha(child) for child in alpha.children], self.EX) | 180 | + return reduce(bool.__and__, [self.alpha_parse(child, labels) for child in alpha.children], True) |
174 | elif alpha.kind =='or': | 181 | elif alpha.kind =='or': |
175 | - return reduce(shom.__or__, [self.build_pred_alpha(child) for child in alpha.children], shom.empty()) | 182 | + return reduce(bool.__or__, [self.alpha_parse(child, labels) for child in alpha.children], False) |
176 | else: | 183 | else: |
177 | raise ValueError(repr(alpha) + "is not an action sub formula") | 184 | raise ValueError(repr(alpha) + "is not an action sub formula") |
178 | 185 | ||
179 | def build_pred_alpha(self, alpha): | 186 | def build_pred_alpha(self, alpha): |
180 | - pred_alpha = self.alpha_parse(alpha) | 187 | + return reduce(shom.__or__, [action for (action, labels) in self.pred_dict if self.alpha_parse(alpha, labels)], shom.empty()) |
181 | - if self.tau_label: | ||
182 | - pred_alpha = shom.__or__(pred_alpha, self.pred_dict[self.tau_label])# the invisible actions are added to pred | ||
183 | - return pred_alpha | ||
184 | 188 | ||
185 | def check(self, formula): | 189 | def check(self, formula): |
186 | """ | 190 | """ | ... | ... |
-
Please register or login to post a comment