pub enum SortExpr {
Name(Arc<str>),
App {
name: Arc<str>,
args: Vec<Term>,
},
}Expand description
A sort expression: a plain sort name or a dependent sort applied to argument terms.
Appears in Operation::output,
Operation::inputs entries, and
SortParam::sort, wherever a sort occurs.
Normalization invariant: every SortExpr produced by constructors
and public operations is normalized. A normalized value uses the
Name spelling whenever the argument list is empty; App { name, args: [] } never appears in normalized values. This invariant is enforced
by the smart constructor SortExpr::app, by Self::subst, by
Self::rename_head, by Self::apply_maps, and by the custom
serde::Deserialize impl. The derived PartialEq and Hash are
replaced with manual impls that treat Name(n) and App { name: n, args: [] } as equal (in case a caller constructs a non-normalized
value directly through the App variant).
The serde representation uses #[serde(untagged)], so Name(n)
serializes as the bare string "n" and App serializes as a struct
with name and args fields.
Variants§
Name(Arc<str>)
A plain sort name with no parameters applied.
App
A dependent sort applied to argument terms, e.g. Tm(Γ, A).
Implementations§
Source§impl SortExpr
impl SortExpr
Sourcepub fn app(name: impl Into<Arc<str>>, args: Vec<Term>) -> Self
pub fn app(name: impl Into<Arc<str>>, args: Vec<Term>) -> Self
Smart constructor: produces Self::Name when args is empty,
otherwise Self::App. This is the only way to construct a
normalized SortExpr::App; direct use of the App variant is
allowed for backwards compatibility, but normalization should be
restored via Self::normalize before the value escapes its
local context.
Sourcepub fn normalize(self) -> Self
pub fn normalize(self) -> Self
Normalize this expression: collapse App { name, args: [] } into
Name(name). Idempotent; leaves already-normalized values
unchanged. The argument list is not recursed into because the
term AST inside arguments does not share this two-spelling
ambiguity.
Sourcepub const fn head(&self) -> &Arc<str> ⓘ
pub const fn head(&self) -> &Arc<str> ⓘ
Extract the bare sort name, ignoring any applied arguments.
Sourcepub fn subst(&self, mapping: &FxHashMap<Arc<str>, Term>) -> Self
pub fn subst(&self, mapping: &FxHashMap<Arc<str>, Term>) -> Self
Substitute mapping (parameter name to term) throughout this sort
expression’s argument terms.
Sourcepub fn alpha_eq(&self, other: &Self) -> bool
pub fn alpha_eq(&self, other: &Self) -> bool
Structural equality modulo Name(n) == App { name: n, args: [] }.
Equivalent to PartialEq::eq after the normalization invariant;
retained as a named method for documentation and for code that
wants to make the two-spelling quotient explicit at call sites.
Sourcepub fn alpha_eq_modulo_rewrites(
&self,
other: &Self,
rules: &[DirectedEquation],
step_limit: usize,
) -> bool
pub fn alpha_eq_modulo_rewrites( &self, other: &Self, rules: &[DirectedEquation], step_limit: usize, ) -> bool
Definitional equality modulo a directed-rewrite system.
Normalizes both sides by rewriting every argument term with
crate::eq::normalize under rules and a bounded step budget,
then compares the normalized sort expressions with
Self::alpha_eq. Heads must agree; if they do not, no amount
of rewriting closes the gap and the function returns false
immediately. Callers that want the strict structural equality
should continue to use Self::alpha_eq.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for SortExpr
impl<'de> Deserialize<'de> for SortExpr
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Normalize on load: any App { name, args: [] } incoming from JSON
collapses to Name(name) so that every downstream consumer sees
the canonical spelling.
Source§impl Hash for SortExpr
impl Hash for SortExpr
Source§impl PartialEq for SortExpr
impl PartialEq for SortExpr
Source§fn eq(&self, other: &Self) -> bool
fn eq(&self, other: &Self) -> bool
Two sort expressions are equal when their heads and argument lists
agree. This reduces Name(n) to App { name: n, args: [] } under
equality, matching SortExpr::alpha_eq and ensuring that the
Eq/Hash contract holds across both spellings.
impl Eq for SortExpr
Auto Trait Implementations§
impl Freeze for SortExpr
impl RefUnwindSafe for SortExpr
impl Send for SortExpr
impl Sync for SortExpr
impl Unpin for SortExpr
impl UnsafeUnpin for SortExpr
impl UnwindSafe for SortExpr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more