text
stringlengths
0
828
tuple (bool, str): True if the observation table is
closed and false otherwise. If the table is not closed
the escaping string is returned.
""""""
for t in self.smi_vector:
found = False
for s in self.sm_vector:
if self.observation_table[s] == self.observation_table[t]:
self.equiv_classes[t] = s
found = True
break
if not found:
return False, t
return True, None"
1091,"def _fill_table_entry(self, row, col):
""""""""""
Fill an entry of the observation table.
Args:
row (str): The row of the observation table
col (str): The column of the observation table
Returns:
None
""""""
prefix = self._membership_query(row)
full_output = self._membership_query(row + col)
length = len(commonprefix([prefix, full_output]))
self.observation_table[row, col] = full_output[length:]"
1092,"def _run_in_hypothesis(self, mma, w_string, index):
""""""""""
Run the string in the hypothesis automaton for index steps and then
return the access string for the state reached concatanated with the
rest of the string w.
Args:
mma (DFA): The hypothesis automaton
w_string (str): The examined string to be consumed
index (int): The index value for selecting the prefix of w
Return:
str: The access string
""""""
state = mma[0]
for i in range(index):
for arc in state:
if mma.isyms.find(arc.ilabel) == w_string[i]:
state = mma[arc.nextstate]
s_index = arc.nextstate
# The id of the state is its index inside the Sm list
access_string = self.observation_table.sm_vector[s_index]
logging.debug(
'Access string for %d: %s - %d ',
index,
access_string,
s_index)
return access_string"
1093,"def _check_suffix(self, w_string, access_string, index):
""""""
Checks if access string suffix matches with the examined string suffix
Args:
w_string (str): The examined string to be consumed
access_string (str): The access string for the state
index (int): The index value for selecting the prefix of w
Returns:
bool: A boolean valuei indicating if matching was successful
""""""
prefix_as = self._membership_query(access_string)
full_as = self._membership_query(access_string + w_string[index:])
prefix_w = self._membership_query(w_string[:index])
full_w = self._membership_query(w_string)
length = len(commonprefix([prefix_as, full_as]))
as_suffix = full_as[length:]
length = len(commonprefix([prefix_w, full_w]))
w_suffix = full_w[length:]
if as_suffix != w_suffix:
logging.debug('Access string state incorrect')
return True
logging.debug('Access string state correct.')
return False"
1094,"def _find_bad_transition(self, mma, w_string):
""""""
Checks for bad DFA transitions using the examined string
Args:
mma (DFA): The hypothesis automaton
w_string (str): The examined string to be consumed
Returns:
str: The prefix of the examined string that matches
""""""
conj_out = mma.consume_input(w_string)
targ_out = self._membership_query(w_string)
# TODO: handle different length outputs from conjecture and target
# hypothesis.
length = min(len(conj_out), len(targ_out))
diff = [i for i in range(length)
if conj_out[i] != targ_out[i]]
if len(diff) == 0:
diff_index = len(targ_out)