Commit 0a5a49b6 authored by Bharat Garhewal's avatar Bharat Garhewal
Browse files

More refactoring

parent b9c922c2
......@@ -396,7 +396,7 @@ where
/// Checks whether the hypothesis and the observation tree agree.
#[must_use]
pub fn check_consistency(&mut self, hypothesis: &Mealy) -> CounterExample {
fn check_consistency(&mut self, hypothesis: &Mealy) -> CounterExample {
let temp = RefCell::borrow(&self.oq_oracle);
let o_tree = temp.borrow_tree();
let mut queue = VecDeque::<_>::new();
......
use crate::learner::l_sharp::{Rule2, Rule3};
use crate::oracles::equivalence::CounterExample;
use crate::{
ads::{
traits::{AdaptiveDistinguishingSequence, AdsStatus},
......@@ -11,15 +9,16 @@ use crate::{
},
learner::{
apartness::{compute_witness, states_are_apart},
l_sharp::{Rule2, Rule3},
obs_tree::{ObservationTree, TreeErr},
},
oracles::equivalence::CounterExample,
sul::SystemUnderLearning,
util::toolbox,
};
use itertools::Itertools;
use rand::prelude::SliceRandom;
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
use std::collections::VecDeque;
pub struct Oracle<'a, T> {
sul: &'a mut dyn SystemUnderLearning,
......@@ -314,30 +313,6 @@ where
}
}
pub fn check_consistency(&self, hypothesis: &Mealy) -> CounterExample {
let mut queue = VecDeque::from([(State::new(0), State::new(0))]);
while !queue.is_empty() {
let (q, r) = queue.pop_front().expect("Always safe!");
for i in toolbox::inputs_iterator(hypothesis.input_alphabet().len()) {
if let Some(((out_tree, dest_tree), (dest_hyp, out_hyp))) = self
.obs_tree
.get_out_succ(q, i)
.zip(Some(hypothesis.step_from(r, i)))
{
if out_hyp == out_tree {
queue.push_back((dest_tree, dest_hyp));
} else {
let mut inputs = self.obs_tree.get_access_seq(q);
inputs.push(i);
let outputs = self.obs_tree.get_observation(None, &inputs).expect("Safe");
return Some((inputs, outputs));
}
}
}
}
None
}
#[allow(clippy::type_complexity)]
fn answer_ads_from_tree(
&self,
......
......@@ -6,6 +6,7 @@ Specifically, we have two types of oracles:
2. Equivalence oracles.
*/
/// Collection of equivalence oracles.
pub mod equivalence;
/// Output oracles module.
pub mod membership;
......@@ -2,8 +2,7 @@
//!
//! ### Note
//! We currently have only one implementation of the
//! [`SystemUnderLearning`](self::SystemUnderLearning)
//! trait, which simulates a (known) FSM.
//! [`SystemUnderLearning`](self::SystemUnderLearning) trait, which simulates a (known) FSM.
use crate::automatadefs::mealy::{InputSymbol, OutputSymbol};
......@@ -26,8 +25,8 @@ pub trait SystemUnderLearning {
#[must_use]
fn trace(&mut self, input_seq: &[InputSymbol]) -> Box<[OutputSymbol]>;
/// Get the number of inputs and reset send to the SUL thus far,
/// and reset the counters.
/// Get the number of inputs and resets sent to the SUL thus far,
/// **and reset the counters**.
#[must_use]
fn get_counts(&mut self) -> (usize, usize);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment