1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
//! # Prelude
//!
//! Convenient re-exports of commonly used types and functions.
//!
//! ## Overview
//!
//! The prelude module provides a curated collection of the most frequently used
//! items from ArcWeight, allowing you to get started quickly with a single import:
//!
//! ```
//! use arcweight::prelude::*;
//! ```
//!
//! This import brings all essential types, traits, and functions into scope,
//! minimizing boilerplate while avoiding namespace pollution with rarely-used items.
//!
//! ## Contents
//!
//! ### Core Types
//!
//! | Category | Items |
//! |----------|-------|
//! | FST Types | [`VectorFst`], [`ConstFst`], [`CompactFst`] |
//! | Arc Type | [`Arc`] for representing transitions |
//! | Traits | [`Fst`], [`MutableFst`], [`ExpandedFst`] |
//! | Identifiers | [`StateId`], [`Label`], [`NO_STATE_ID`], [`NO_LABEL`] |
//!
//! ### Semirings
//!
//! All major semiring types and traits:
//!
//! | Category | Items |
//! |----------|-------|
//! | Common Weights | [`TropicalWeight`], [`ProbabilityWeight`], [`BooleanWeight`] |
//! | Additional Weights | [`LogWeight`], [`RealWeight`], [`ProductWeight`], [`StringWeight`] |
//! | Semiring Traits | [`Semiring`], [`StarSemiring`], [`DivisibleSemiring`] |
//!
//! ### Algorithms
//!
//! Essential FST algorithms with typical complexity bounds:
//!
//! | Operation | Functions | Complexity |
//! |-----------|-----------|------------|
//! | Composition | [`compose()`], [`compose_default()`] | $`O(\|V_1\| \cdot \|V_2\| \cdot D_1 \cdot D_2)`$ |
//! | Concatenation | [`concat()`] | $`O(\|V\| + \|E\|)`$ |
//! | Union | [`union()`] | $`O(\|V\| + \|E\|)`$ |
//! | Closure | [`closure()`], [`closure_plus()`] | $`O(\|V\| + \|E\|)`$ |
//! | Determinization | [`determinize()`] | $`O(2^{\|V\|})`$ worst case |
//! | Minimization | [`minimize()`], [`minimize_hopcroft()`] | $`O(\|V\| \log \|V\|)`$ |
//! | Epsilon Removal | [`remove_epsilons()`] | $`O(\|V\|^2 + \|V\| \cdot \|E\|)`$ |
//! | Shortest Path | [`shortest_path()`] | $`O(\|V\| \log \|V\| + \|E\|)`$ |
//!
//! ### I/O Operations
//!
//! File format support:
//!
//! | Format | Read | Write |
//! |--------|------|-------|
//! | Text | [`read_text()`] | [`write_text()`] |
//! | OpenFST | [`read_openfst()`] | [`write_openfst()`] |
//! | Binary (serde) | [`read_binary()`] | [`write_binary()`] |
//!
//! ### Properties and Utilities
//!
//! - **Property analysis:** [`compute_properties()`], [`FstProperties`], [`PropertyFlags`]
//! - **Symbol tables:** [`SymbolTable`] for label-to-string mappings
//! - **Path utilities:** [`FstPath`], [`PathIterExt`] for path extraction
//! - **Error handling:** [`Error`], [`Result`] types
//! - **Numeric traits:** [`Zero`], [`One`] from num-traits
//!
//! ## Examples
//!
//! ### Basic FST Construction
//!
//! ```
//! use arcweight::prelude::*;
//!
//! let mut fst = VectorFst::<TropicalWeight>::new();
//! let s0 = fst.add_state();
//! let s1 = fst.add_state();
//!
//! fst.set_start(s0);
//! fst.set_final(s1, TropicalWeight::one());
//! fst.add_arc(s0, Arc::new(1, 2, TropicalWeight::new(0.5), s1));
//! ```
//!
//! ### Algorithm Chaining
//!
//! ```
//! use arcweight::prelude::*;
//!
//! fn process_fst(fst: &VectorFst<TropicalWeight>) -> Result<VectorFst<TropicalWeight>> {
//! // Chain multiple operations
//! let deterministic: VectorFst<TropicalWeight> = determinize(fst)?;
//! let minimal: VectorFst<TropicalWeight> = minimize(&deterministic)?;
//! let reversed: VectorFst<TropicalWeight> = reverse(&minimal)?;
//! Ok(reversed)
//! }
//! ```
//!
//! ### Working with Different Semirings
//!
//! ```
//! use arcweight::prelude::*;
//!
//! // Boolean semiring for unweighted FSTs
//! let bool_fst = VectorFst::<BooleanWeight>::new();
//!
//! // Probability semiring for probabilistic models
//! let prob_fst = VectorFst::<ProbabilityWeight>::new();
//!
//! // Log semiring for numerical stability
//! let log_fst = VectorFst::<LogWeight>::new();
//! ```
//!
//! ## Design Philosophy
//!
//! The prelude is designed to include items that are:
//!
//! 1. **Frequently used:** Core types needed in most FST programs
//! 2. **Unambiguous:** No naming conflicts with common Rust items
//! 3. **Essential:** Fundamental to working with the library
//!
//! More specialized items remain in their respective modules to avoid
//! namespace pollution while keeping the prelude focused and ergonomic.
pub use ;
pub use crate::;
pub use crate;