text stringlengths 0 828 |
|---|
"""""" |
old_training_data = self.training_data |
self.training_data = {x: [] for x in self.sm_vector} |
for t in self.smi_vector: |
src_state = t[:-1] |
symbol = t[-1:] |
found = False |
for dst_state in self.sm_vector: |
if self.observation_table[dst_state] == self.observation_table[t]: |
self._add_training_data(src_state, dst_state, symbol) |
found = True |
break |
if not found: |
return False, t |
assert self.training_data != old_training_data, \ |
""No update happened from previous round. The algo will loop infinetely"" |
return True, None" |
536,"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 |
"""""" |
self.observation_table[row, col] = self._membership_query(row + col)" |
537,"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.states[0] |
s_index = 0 |
for i in range(index): |
for arc in state: |
if arc.guard.is_sat(w_string[i]): |
state = mma.states[arc.dst_state] |
s_index = arc.dst_state |
# 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" |
538,"def _process_counter_example(self, mma, w_string): |
"""""""" |
Process a counterexample in the Rivest-Schapire way. |
Args: |
mma (DFA): The hypothesis automaton |
w_string (str): The examined string to be consumed |
Return: |
None |
"""""" |
if len(w_string) == 1: |
self.observation_table.smi_vector.append(w_string) |
for exp in self.observation_table.em_vector: |
self._fill_table_entry(w_string, exp) |
diff = len(w_string) |
same = 0 |
membership_answer = self._membership_query(w_string) |
while True: |
i = (same + diff) / 2 |
access_string = self._run_in_hypothesis(mma, w_string, i) |
if membership_answer != self._membership_query(access_string + w_string[i:]): |
diff = i |
else: |
same = i |
if diff - same == 1: |
break |
# First check if the transition is part of our training data. |
access_string = self._run_in_hypothesis(mma, w_string, diff - 1) |
wrong_transition = access_string + w_string[diff - 1] |
if wrong_transition not in self.observation_table.smi_vector: |
# If transition is not part of our training data add s_ib to Smi and |
# return to checking table closedness. |
self.observation_table.smi_vector.append(wrong_transition) |
for exp in self.observation_table.em_vector: |
self._fill_table_entry(wrong_transition, exp) |
return |
# This point presents a tradeoff between equivalence and membership |
# queries. If the transition in the counterexample'input_string breakpoint is not |
# part of our current training data (i.e. s_ib is not part of our Smi |
# set), then we assume a wrong transition and return to checking table |
# closure by adding s_ib to our training data. This saves a number of |
# membership queries since we don't add a row in our table unless |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.