Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/automata-core/src/alphabet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl<S: Symbol> Iterator for FreeMonoid<S> {
}

if carry {
self.current = std::iter::repeat(0).take(self.current.len() + 1).collect();
self.current = std::iter::repeat_n(0, self.current.len() + 1).collect();
}

Some(out)
Expand Down
14 changes: 7 additions & 7 deletions crates/automata-core/src/alphabet/propositional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl<RawTy: RawSymbolRepr> PropExpression<RawTy> {
_ty: PhantomData,
}
}
pub fn new(num_aps: u8, string: &str) -> PropExpression<RawTy> {
pub fn new(num_aps: u8, string: &str) -> Self {
let vars = BddVariableSet::new_anonymous(num_aps as u16);
Self::from_parts(num_aps, vars.eval_expression_string(string))
}
Expand Down Expand Up @@ -189,27 +189,27 @@ impl<RawTy: RawSymbolRepr> PropExpression<RawTy> {
}

impl<RawTy: RawSymbolRepr> std::ops::BitAnd for PropExpression<RawTy> {
type Output = PropExpression<RawTy>;
type Output = Self;

fn bitand(self, rhs: Self) -> Self::Output {
assert_eq!(self.num_aps, rhs.num_aps);
PropExpression {
Self {
num_aps: self.num_aps,
bdd: self.bdd.and(&rhs.bdd),
_ty: PhantomData,
}
}
}
impl<RawTy: RawSymbolRepr> std::ops::Not for PropExpression<RawTy> {
type Output = PropExpression<RawTy>;
type Output = Self;

fn not(self) -> Self::Output {
Self::from_parts(self.num_aps, self.bdd.not())
}
}

impl<RawTy: RawSymbolRepr> std::ops::BitOr for PropExpression<RawTy> {
type Output = PropExpression<RawTy>;
type Output = Self;
fn bitor(self, rhs: Self) -> Self::Output {
assert_eq!(self.num_aps, rhs.num_aps);
Self::from_parts(self.num_aps, self.bdd.or(&rhs.bdd))
Expand Down Expand Up @@ -285,8 +285,8 @@ impl<RawTy: RawSymbolRepr> Matcher<PropExpression<RawTy>> for PropSymbol<RawTy>
}
}

impl<RawTy: RawSymbolRepr> Matcher<PropExpression<RawTy>> for PropExpression<RawTy> {
fn matches(&self, expression: &PropExpression<RawTy>) -> bool {
impl<RawTy: RawSymbolRepr> Matcher<Self> for PropExpression<RawTy> {
fn matches(&self, expression: &Self) -> bool {
assert_eq!(self.num_aps, expression.num_aps);
// all values in self should also be in expression
// we share nothing with the complement of the expression
Expand Down
32 changes: 16 additions & 16 deletions crates/automata-core/src/alphabet/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ impl CharAlphabet {
}
}

impl Matcher<char> for char {
fn matches(&self, expression: &char) -> bool {
impl Matcher<Self> for char {
fn matches(&self, expression: &Self) -> bool {
self == expression
}
}

impl Expression for char {
type S = char;
type S = Self;
type SymbolsIter<'this>
= std::iter::Once<char>
= std::iter::Once<Self>
where
Self: 'this;
fn symbols(&self) -> Self::SymbolsIter<'_> {
Expand All @@ -88,11 +88,11 @@ impl Expression for char {
self == other
}

fn for_each<F: Fn(char)>(&self, f: F) {
fn for_each<F: Fn(Self)>(&self, f: F) {
(f)(*self)
}

fn matched_by(&self, symbol: char) -> bool {
fn matched_by(&self, symbol: Self) -> bool {
self == &symbol
}
}
Expand Down Expand Up @@ -163,16 +163,16 @@ impl SimpleAlphabet for CharAlphabet {
#[derive(Clone, Debug)]
pub struct Fixed<S: Symbol, const N: usize>([S; N]);

impl Matcher<usize> for usize {
fn matches(&self, expression: &usize) -> bool {
impl Matcher<Self> for usize {
fn matches(&self, expression: &Self) -> bool {
self == expression
}
}

impl Expression for usize {
type S = usize;
type S = Self;
type SymbolsIter<'this>
= std::iter::Once<usize>
= std::iter::Once<Self>
where
Self: 'this;

Expand All @@ -183,7 +183,7 @@ impl Expression for usize {
self == other
}

fn matched_by(&self, symbol: usize) -> bool {
fn matched_by(&self, symbol: Self) -> bool {
*self == symbol
}
}
Expand Down Expand Up @@ -260,16 +260,16 @@ impl InvertibleChar {
}
}

impl Matcher<InvertibleChar> for InvertibleChar {
fn matches(&self, expression: &InvertibleChar) -> bool {
impl Matcher<Self> for InvertibleChar {
fn matches(&self, expression: &Self) -> bool {
self == expression
}
}

impl Expression for InvertibleChar {
type S = InvertibleChar;
type S = Self;
type SymbolsIter<'this>
= std::iter::Once<InvertibleChar>
= std::iter::Once<Self>
where
Self: 'this;

Expand All @@ -280,7 +280,7 @@ impl Expression for InvertibleChar {
self == other
}

fn matched_by(&self, symbol: InvertibleChar) -> bool {
fn matched_by(&self, symbol: Self) -> bool {
*self == symbol
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/automata-core/src/word/finite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,10 @@ impl<S: Symbol> FiniteWord for Vec<S> {
self.iter().cloned()
}

fn collect_vec(&self) -> Vec<S> {
fn collect_vec(&self) -> Self {
self.clone()
}
fn into_vec(self) -> Vec<S> {
fn into_vec(self) -> Self {
self
}

Expand Down
4 changes: 2 additions & 2 deletions crates/automata-core/src/word/omega.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ impl<S: Symbol> From<&PeriodicOmegaWord<S>> for ReducedOmegaWord<S> {
}
}

impl<S: Symbol> From<&ReducedOmegaWord<S>> for ReducedOmegaWord<S> {
fn from(value: &ReducedOmegaWord<S>) -> Self {
impl<S: Symbol> From<&Self> for ReducedOmegaWord<S> {
fn from(value: &Self) -> Self {
Self::ultimately_periodic(value.spoke(), value.cycle())
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/automata-learning/src/passive/precise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ impl<A: Alphabet, const N: usize> From<FWPM<A>> for PreciseDPA<A, N> {
start.elapsed().as_micros()
);

PreciseDPA::new(leading, prc_dfas)
Self::new(leading, prc_dfas)
}
}

Expand Down
12 changes: 6 additions & 6 deletions crates/automata-learning/src/passive/sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,31 +102,31 @@ impl<A: Alphabet, W: Word<Symbol = A::Symbol>> SetSample<A, W> {
}
}

pub fn into_joined(self, other: SetSample<A, W>) -> SetSample<A, W> {
let SetSample {
pub fn into_joined(self, other: Self) -> Self {
let Self {
alphabet,
mut positive,
mut negative,
} = self;
positive.extend(other.positive);
negative.extend(other.negative);
SetSample {
Self {
positive,
negative,
alphabet,
}
}

pub fn append(&mut self, other: SetSample<A, W>) {
pub fn append(&mut self, other: Self) {
self.positive.extend(other.positive);
self.negative.extend(other.negative);
}

pub fn as_joined(&self, other: &SetSample<A, W>) -> SetSample<A, W>
pub fn as_joined(&self, other: &Self) -> Self
where
W: Clone,
{
SetSample {
Self {
alphabet: self.alphabet.clone(),
positive: self
.positive
Expand Down
16 changes: 4 additions & 12 deletions crates/automata/src/automaton.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,7 @@ where
/// dfa.add_edge((0, 'b', 0));
/// assert!(!dfa.accepts("bbabababbabbba"));
/// ```
pub fn new_with_initial_color(
alphabet: A,
initial_color: Q,
) -> Automaton<A, Z, Q, C, D, OMEGA, DET>
pub fn new_with_initial_color(alphabet: A, initial_color: Q) -> Self
where
D: ForAlphabet<A> + Sproutable,
Z: Default,
Expand All @@ -129,11 +126,7 @@ where
/// Uses `Self::new_with_initial_color` to create a new instance of
/// `Self` and then makes all transitions self-loops emitting the given
/// color.
pub fn new_trivial_with_initial_color(
alphabet: A,
initial_color: Q,
edge_color: C,
) -> Automaton<A, Z, Q, C, D, OMEGA, DET>
pub fn new_trivial_with_initial_color(alphabet: A, initial_color: Q, edge_color: C) -> Self
where
D: ForAlphabet<A> + Sproutable,
Z: Default,
Expand Down Expand Up @@ -276,15 +269,14 @@ where
}
}

impl<A, Z, Q, C, D, const OMEGA: bool> AsRef<Automaton<A, Z, Q, C, D, OMEGA>>
for Automaton<A, Z, Q, C, D, OMEGA>
impl<A, Z, Q, C, D, const OMEGA: bool> AsRef<Self> for Automaton<A, Z, Q, C, D, OMEGA>
where
A: Alphabet,
D: TransitionSystem<Alphabet = A, StateColor = Q, EdgeColor = C>,
Q: Color,
C: Color,
{
fn as_ref(&self) -> &Automaton<A, Z, Q, C, D, OMEGA> {
fn as_ref(&self) -> &Self {
self
}
}
Expand Down
12 changes: 4 additions & 8 deletions crates/automata/src/automaton/omega.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl OmegaAcceptanceCondition {
/// [`AcceptanceMask`]s.
pub fn satisfied(&self, infset: &OrderedSet<AcceptanceMask>) -> bool {
match self {
OmegaAcceptanceCondition::Parity(_low, _high) => infset
Self::Parity(_low, _high) => infset
.iter()
.map(|x| x.as_priority())
.min()
Expand All @@ -77,7 +77,7 @@ impl<A: Alphabet, const DET: bool> OmegaAutomaton<A, DET> {
ts: TS<A, Int, AcceptanceMask, DET>,
initial: DefaultIdType,
acceptance: OmegaAcceptanceCondition,
) -> OmegaAutomaton<A, DET> {
) -> Self {
OmegaAutomaton {
ts,
initial,
Expand Down Expand Up @@ -179,7 +179,7 @@ impl From<DeterministicOmegaAutomaton<PropAlphabet>> for DeterministicOmegaAutom
})
}))
.into_dts();
DeterministicOmegaAutomaton::new(ts, value.initial, value.acceptance)
Self::new(ts, value.initial, value.acceptance)
}
}

Expand Down Expand Up @@ -214,10 +214,6 @@ impl TryFrom<DeterministicOmegaAutomaton<CharAlphabet>>
}

assert!(value.initial().into_usize() < size);
Ok(DeterministicOmegaAutomaton::new(
ts,
value.initial,
value.acceptance,
))
Ok(Self::new(ts, value.initial, value.acceptance))
}
}
2 changes: 1 addition & 1 deletion crates/automata/src/congruence/cayley.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ where
/// Build a new Cayley graph from the given transition system.
pub fn new(ts: Ts) -> Self {
let alphabet = Directional::from_iter(ts.alphabet().universe());
Cayley {
Self {
expressions: alphabet.expression_map(),
m: TransitionMonoid::new(ts),
alphabet,
Expand Down
14 changes: 7 additions & 7 deletions crates/automata/src/congruence/transitionprofile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ impl Accumulates for Void {
fn update(&mut self, _other: &Self) {}

fn neutral() -> Self {
Void
Self
}

fn from_iter<'a, I: IntoIterator<Item = &'a Self>>(_iter: I) -> Self
where
Self: 'a,
{
Void
Self
}

fn from(x: Self) -> Self {
Expand All @@ -116,14 +116,14 @@ impl Accumulates for usize {
}

fn neutral() -> Self {
usize::MAX
Self::MAX
}

fn from_iter<'a, I: IntoIterator<Item = &'a Self>>(iter: I) -> Self
where
Self: 'a,
{
iter.into_iter().cloned().min().unwrap_or(usize::MAX)
iter.into_iter().cloned().min().unwrap_or(Self::MAX)
}

fn from(x: Self) -> Self {
Expand Down Expand Up @@ -366,12 +366,12 @@ where
0..self.tps.len()
}

fn build(ts: Ts) -> TransitionMonoid<Ts> {
fn build(ts: Ts) -> Self {
let indices = ts.state_indices().collect();
Self::build_for_states(ts, indices)
}

fn build_for_states(ts: Ts, states: Vec<Ts::StateIndex>) -> TransitionMonoid<Ts> {
fn build_for_states(ts: Ts, states: Vec<Ts::StateIndex>) -> Self {
let eps_profile = RunProfile::empty_for_states(states);
let mut tps = vec![(eps_profile.clone(), 0)];
let mut strings = vec![(vec![], ProfileEntry::Profile(0))];
Expand Down Expand Up @@ -405,7 +405,7 @@ where
}
}

TransitionMonoid { ts, tps, strings }
Self { ts, tps, strings }
}
}

Expand Down
Loading