sim_lib_serial_core/certificate.rs
1//! Evidence returned by every accepted series transform.
2
3use crate::{AlphabetId, OrdinalMap, SerialAlphabet, Series, SeriesTransform};
4
5/// A source invariant explicitly relaxed by a transform.
6#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
7pub enum RelaxedInvariant {
8 /// Source positions were reordered.
9 SourceOrder,
10 /// Source symbols were replaced through a validated bijection.
11 SymbolIdentity,
12 /// The result belongs to a differently identified alphabet.
13 AlphabetIdentity,
14}
15
16/// Algebra evidence for one successfully applied transform.
17#[derive(Clone, Debug, PartialEq, Eq)]
18pub struct TransformCertificate<A: SerialAlphabet> {
19 /// Stable identity of the validated source alphabet.
20 pub source_alphabet: AlphabetId,
21 /// Stable identity of the validated target alphabet.
22 pub target_alphabet: AlphabetId,
23 /// Whether aggregate policy and counts were preserved under the bijections.
24 pub aggregate_preserved: bool,
25 /// Exact output-position to source-position map used by the transform.
26 pub order_map: OrdinalMap,
27 /// Exact inverse operation when the transform algebra supplies one.
28 pub inverse: Option<SeriesTransform<A>>,
29 /// Source invariants intentionally relaxed by this operation.
30 pub relaxed_invariants: Vec<RelaxedInvariant>,
31}
32
33/// A transformed series paired with the evidence that justifies it.
34#[derive(Clone, Debug, PartialEq, Eq)]
35pub struct TransformedSeries<A: SerialAlphabet> {
36 /// Valid target series.
37 pub series: Series<A>,
38 /// Source/target, order, inverse, and preservation evidence.
39 pub certificate: TransformCertificate<A>,
40}