use crate::HostTypes;
pub trait BoundedRecursion<H: HostTypes> {
type DescentMeasure: DescentMeasure<H>;
fn measure(&self) -> &Self::DescentMeasure;
type BaseCase: BaseCase<H>;
fn base_case(&self) -> &Self::BaseCase;
type RecursiveCase: RecursiveCase<H>;
fn recursive_case(&self) -> &Self::RecursiveCase;
type Predicate: crate::kernel::predicate::Predicate<H>;
fn base_predicate(&self) -> &Self::Predicate;
type ComputationDatum: crate::user::morphism::ComputationDatum<H>;
fn recursion_body(&self) -> &Self::ComputationDatum;
fn initial_measure(&self) -> u64;
}
pub trait DescentMeasure<H: HostTypes> {
fn measure_value(&self) -> u64;
}
pub trait BaseCase<H: HostTypes>: crate::kernel::predicate::MatchArm<H> {}
pub trait RecursiveCase<H: HostTypes>: crate::kernel::predicate::MatchArm<H> {}
pub trait RecursiveStep<H: HostTypes> {
type Transform: crate::user::morphism::Transform<H>;
fn step_decomposition(&self) -> &Self::Transform;
type DescentMeasure: DescentMeasure<H>;
fn step_measure_pre(&self) -> &Self::DescentMeasure;
fn step_measure_post(&self) -> &Self::DescentMeasure;
}
pub trait RecursionTrace<H: HostTypes>: crate::bridge::trace::ComputationTrace<H> {}
pub trait StructuralRecursion<H: HostTypes>: BoundedRecursion<H> {}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullBoundedRecursion<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullBoundedRecursion<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullBoundedRecursion<H> {
pub const ABSENT: NullBoundedRecursion<H> = NullBoundedRecursion {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> BoundedRecursion<H> for NullBoundedRecursion<H> {
type DescentMeasure = NullDescentMeasure<H>;
fn measure(&self) -> &Self::DescentMeasure {
&<NullDescentMeasure<H>>::ABSENT
}
type BaseCase = NullBaseCase<H>;
fn base_case(&self) -> &Self::BaseCase {
&<NullBaseCase<H>>::ABSENT
}
type RecursiveCase = NullRecursiveCase<H>;
fn recursive_case(&self) -> &Self::RecursiveCase {
&<NullRecursiveCase<H>>::ABSENT
}
type Predicate = crate::kernel::predicate::NullPredicate<H>;
fn base_predicate(&self) -> &Self::Predicate {
&<crate::kernel::predicate::NullPredicate<H>>::ABSENT
}
type ComputationDatum = crate::user::morphism::NullComputationDatum<H>;
fn recursion_body(&self) -> &Self::ComputationDatum {
&<crate::user::morphism::NullComputationDatum<H>>::ABSENT
}
fn initial_measure(&self) -> u64 {
0
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullDescentMeasure<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullDescentMeasure<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullDescentMeasure<H> {
pub const ABSENT: NullDescentMeasure<H> = NullDescentMeasure {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> DescentMeasure<H> for NullDescentMeasure<H> {
fn measure_value(&self) -> u64 {
0
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullBaseCase<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullBaseCase<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullBaseCase<H> {
pub const ABSENT: NullBaseCase<H> = NullBaseCase {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> crate::kernel::predicate::MatchArm<H> for NullBaseCase<H> {
type Predicate = crate::kernel::predicate::NullPredicate<H>;
fn arm_predicate(&self) -> &Self::Predicate {
&<crate::kernel::predicate::NullPredicate<H>>::ABSENT
}
type Term = crate::kernel::schema::NullTerm<H>;
fn arm_result(&self) -> &Self::Term {
&<crate::kernel::schema::NullTerm<H>>::ABSENT
}
fn arm_index(&self) -> u64 {
0
}
}
impl<H: HostTypes> BaseCase<H> for NullBaseCase<H> {}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullRecursiveCase<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullRecursiveCase<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullRecursiveCase<H> {
pub const ABSENT: NullRecursiveCase<H> = NullRecursiveCase {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> crate::kernel::predicate::MatchArm<H> for NullRecursiveCase<H> {
type Predicate = crate::kernel::predicate::NullPredicate<H>;
fn arm_predicate(&self) -> &Self::Predicate {
&<crate::kernel::predicate::NullPredicate<H>>::ABSENT
}
type Term = crate::kernel::schema::NullTerm<H>;
fn arm_result(&self) -> &Self::Term {
&<crate::kernel::schema::NullTerm<H>>::ABSENT
}
fn arm_index(&self) -> u64 {
0
}
}
impl<H: HostTypes> RecursiveCase<H> for NullRecursiveCase<H> {}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullRecursiveStep<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullRecursiveStep<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullRecursiveStep<H> {
pub const ABSENT: NullRecursiveStep<H> = NullRecursiveStep {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> RecursiveStep<H> for NullRecursiveStep<H> {
type Transform = crate::user::morphism::NullTransform<H>;
fn step_decomposition(&self) -> &Self::Transform {
&<crate::user::morphism::NullTransform<H>>::ABSENT
}
type DescentMeasure = NullDescentMeasure<H>;
fn step_measure_pre(&self) -> &Self::DescentMeasure {
&<NullDescentMeasure<H>>::ABSENT
}
fn step_measure_post(&self) -> &Self::DescentMeasure {
&<NullDescentMeasure<H>>::ABSENT
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullRecursionTrace<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullRecursionTrace<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullRecursionTrace<H> {
pub const ABSENT: NullRecursionTrace<H> = NullRecursionTrace {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> crate::bridge::trace::ComputationTrace<H> for NullRecursionTrace<H> {
type Datum = crate::kernel::schema::NullDatum<H>;
fn input(&self) -> &Self::Datum {
&<crate::kernel::schema::NullDatum<H>>::ABSENT
}
fn output(&self) -> &Self::Datum {
&<crate::kernel::schema::NullDatum<H>>::ABSENT
}
type ComputationStep = crate::bridge::trace::NullComputationStep<H>;
fn step(&self) -> &[Self::ComputationStep] {
&[]
}
type DihedralElement = crate::bridge::observable::NullDihedralElement<H>;
fn monodromy(&self) -> &Self::DihedralElement {
&<crate::bridge::observable::NullDihedralElement<H>>::ABSENT
}
type Certificate = crate::bridge::cert::NullCertificate<H>;
fn certified_by(&self) -> &Self::Certificate {
&<crate::bridge::cert::NullCertificate<H>>::ABSENT
}
type ResidualEntropy = crate::bridge::observable::NullResidualEntropy<H>;
fn residual_entropy(&self) -> &Self::ResidualEntropy {
&<crate::bridge::observable::NullResidualEntropy<H>>::ABSENT
}
fn is_geodesic(&self) -> bool {
false
}
type GeodesicViolation = crate::bridge::trace::NullGeodesicViolation<H>;
fn geodesic_violation(&self) -> &[Self::GeodesicViolation] {
&[]
}
fn cumulative_entropy_cost(&self) -> H::Decimal {
H::EMPTY_DECIMAL
}
fn adiabatically_ordered(&self) -> bool {
false
}
type MeasurementEvent = crate::bridge::trace::NullMeasurementEvent<H>;
fn measurement_event(&self) -> &[Self::MeasurementEvent] {
&[]
}
fn is_ar1_ordered(&self) -> bool {
false
}
fn is_dc10_selected(&self) -> bool {
false
}
}
impl<H: HostTypes> RecursionTrace<H> for NullRecursionTrace<H> {}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullStructuralRecursion<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullStructuralRecursion<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullStructuralRecursion<H> {
pub const ABSENT: NullStructuralRecursion<H> = NullStructuralRecursion {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> BoundedRecursion<H> for NullStructuralRecursion<H> {
type DescentMeasure = NullDescentMeasure<H>;
fn measure(&self) -> &Self::DescentMeasure {
&<NullDescentMeasure<H>>::ABSENT
}
type BaseCase = NullBaseCase<H>;
fn base_case(&self) -> &Self::BaseCase {
&<NullBaseCase<H>>::ABSENT
}
type RecursiveCase = NullRecursiveCase<H>;
fn recursive_case(&self) -> &Self::RecursiveCase {
&<NullRecursiveCase<H>>::ABSENT
}
type Predicate = crate::kernel::predicate::NullPredicate<H>;
fn base_predicate(&self) -> &Self::Predicate {
&<crate::kernel::predicate::NullPredicate<H>>::ABSENT
}
type ComputationDatum = crate::user::morphism::NullComputationDatum<H>;
fn recursion_body(&self) -> &Self::ComputationDatum {
&<crate::user::morphism::NullComputationDatum<H>>::ABSENT
}
fn initial_measure(&self) -> u64 {
0
}
}
impl<H: HostTypes> StructuralRecursion<H> for NullStructuralRecursion<H> {}
#[derive(Debug)]
pub struct BoundedRecursionHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for BoundedRecursionHandle<H> {}
impl<H: HostTypes> Clone for BoundedRecursionHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for BoundedRecursionHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for BoundedRecursionHandle<H> {}
impl<H: HostTypes> core::hash::Hash for BoundedRecursionHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> BoundedRecursionHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait BoundedRecursionResolver<H: HostTypes> {
fn resolve(&self, handle: BoundedRecursionHandle<H>) -> Option<BoundedRecursionRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct BoundedRecursionRecord<H: HostTypes> {
pub measure_handle: DescentMeasureHandle<H>,
pub base_case_handle: BaseCaseHandle<H>,
pub recursive_case_handle: RecursiveCaseHandle<H>,
pub base_predicate_handle: crate::kernel::predicate::PredicateHandle<H>,
pub recursion_body_handle: crate::user::morphism::ComputationDatumHandle<H>,
pub initial_measure: u64,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedBoundedRecursion<'r, R: BoundedRecursionResolver<H>, H: HostTypes> {
handle: BoundedRecursionHandle<H>,
resolver: &'r R,
record: Option<BoundedRecursionRecord<H>>,
}
impl<'r, R: BoundedRecursionResolver<H>, H: HostTypes> ResolvedBoundedRecursion<'r, R, H> {
#[inline]
pub fn new(handle: BoundedRecursionHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> BoundedRecursionHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&BoundedRecursionRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: BoundedRecursionResolver<H>, H: HostTypes> BoundedRecursion<H>
for ResolvedBoundedRecursion<'r, R, H>
{
type DescentMeasure = NullDescentMeasure<H>;
fn measure(&self) -> &Self::DescentMeasure {
&<NullDescentMeasure<H>>::ABSENT
}
type BaseCase = NullBaseCase<H>;
fn base_case(&self) -> &Self::BaseCase {
&<NullBaseCase<H>>::ABSENT
}
type RecursiveCase = NullRecursiveCase<H>;
fn recursive_case(&self) -> &Self::RecursiveCase {
&<NullRecursiveCase<H>>::ABSENT
}
type Predicate = crate::kernel::predicate::NullPredicate<H>;
fn base_predicate(&self) -> &Self::Predicate {
&<crate::kernel::predicate::NullPredicate<H>>::ABSENT
}
type ComputationDatum = crate::user::morphism::NullComputationDatum<H>;
fn recursion_body(&self) -> &Self::ComputationDatum {
&<crate::user::morphism::NullComputationDatum<H>>::ABSENT
}
fn initial_measure(&self) -> u64 {
match &self.record {
Some(r) => r.initial_measure,
None => 0,
}
}
}
impl<'r, R: BoundedRecursionResolver<H>, H: HostTypes> ResolvedBoundedRecursion<'r, R, H> {
#[inline]
pub fn resolve_measure<'r2, R2: DescentMeasureResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<ResolvedDescentMeasure<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(ResolvedDescentMeasure::new(record.measure_handle, r))
}
#[inline]
pub fn resolve_base_case<'r2, R2: BaseCaseResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<ResolvedBaseCase<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(ResolvedBaseCase::new(record.base_case_handle, r))
}
#[inline]
pub fn resolve_recursive_case<'r2, R2: RecursiveCaseResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<ResolvedRecursiveCase<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(ResolvedRecursiveCase::new(record.recursive_case_handle, r))
}
#[inline]
pub fn resolve_base_predicate<'r2, R2: crate::kernel::predicate::PredicateResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::kernel::predicate::ResolvedPredicate<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::kernel::predicate::ResolvedPredicate::new(
record.base_predicate_handle,
r,
))
}
#[inline]
pub fn resolve_recursion_body<'r2, R2: crate::user::morphism::ComputationDatumResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::user::morphism::ResolvedComputationDatum<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::user::morphism::ResolvedComputationDatum::new(
record.recursion_body_handle,
r,
))
}
}
#[derive(Debug)]
pub struct DescentMeasureHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for DescentMeasureHandle<H> {}
impl<H: HostTypes> Clone for DescentMeasureHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for DescentMeasureHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for DescentMeasureHandle<H> {}
impl<H: HostTypes> core::hash::Hash for DescentMeasureHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> DescentMeasureHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait DescentMeasureResolver<H: HostTypes> {
fn resolve(&self, handle: DescentMeasureHandle<H>) -> Option<DescentMeasureRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct DescentMeasureRecord<H: HostTypes> {
pub measure_value: u64,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedDescentMeasure<'r, R: DescentMeasureResolver<H>, H: HostTypes> {
handle: DescentMeasureHandle<H>,
resolver: &'r R,
record: Option<DescentMeasureRecord<H>>,
}
impl<'r, R: DescentMeasureResolver<H>, H: HostTypes> ResolvedDescentMeasure<'r, R, H> {
#[inline]
pub fn new(handle: DescentMeasureHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> DescentMeasureHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&DescentMeasureRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: DescentMeasureResolver<H>, H: HostTypes> DescentMeasure<H>
for ResolvedDescentMeasure<'r, R, H>
{
fn measure_value(&self) -> u64 {
match &self.record {
Some(r) => r.measure_value,
None => 0,
}
}
}
#[derive(Debug)]
pub struct BaseCaseHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for BaseCaseHandle<H> {}
impl<H: HostTypes> Clone for BaseCaseHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for BaseCaseHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for BaseCaseHandle<H> {}
impl<H: HostTypes> core::hash::Hash for BaseCaseHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> BaseCaseHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait BaseCaseResolver<H: HostTypes> {
fn resolve(&self, handle: BaseCaseHandle<H>) -> Option<BaseCaseRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct BaseCaseRecord<H: HostTypes> {
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedBaseCase<'r, R: BaseCaseResolver<H>, H: HostTypes> {
handle: BaseCaseHandle<H>,
resolver: &'r R,
record: Option<BaseCaseRecord<H>>,
}
impl<'r, R: BaseCaseResolver<H>, H: HostTypes> ResolvedBaseCase<'r, R, H> {
#[inline]
pub fn new(handle: BaseCaseHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> BaseCaseHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&BaseCaseRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: BaseCaseResolver<H>, H: HostTypes> crate::kernel::predicate::MatchArm<H>
for ResolvedBaseCase<'r, R, H>
{
type Predicate = crate::kernel::predicate::NullPredicate<H>;
fn arm_predicate(&self) -> &Self::Predicate {
&<crate::kernel::predicate::NullPredicate<H>>::ABSENT
}
type Term = crate::kernel::schema::NullTerm<H>;
fn arm_result(&self) -> &Self::Term {
&<crate::kernel::schema::NullTerm<H>>::ABSENT
}
fn arm_index(&self) -> u64 {
0
}
}
impl<'r, R: BaseCaseResolver<H>, H: HostTypes> BaseCase<H> for ResolvedBaseCase<'r, R, H> {}
#[derive(Debug)]
pub struct RecursiveCaseHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for RecursiveCaseHandle<H> {}
impl<H: HostTypes> Clone for RecursiveCaseHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for RecursiveCaseHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for RecursiveCaseHandle<H> {}
impl<H: HostTypes> core::hash::Hash for RecursiveCaseHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> RecursiveCaseHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait RecursiveCaseResolver<H: HostTypes> {
fn resolve(&self, handle: RecursiveCaseHandle<H>) -> Option<RecursiveCaseRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct RecursiveCaseRecord<H: HostTypes> {
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedRecursiveCase<'r, R: RecursiveCaseResolver<H>, H: HostTypes> {
handle: RecursiveCaseHandle<H>,
resolver: &'r R,
record: Option<RecursiveCaseRecord<H>>,
}
impl<'r, R: RecursiveCaseResolver<H>, H: HostTypes> ResolvedRecursiveCase<'r, R, H> {
#[inline]
pub fn new(handle: RecursiveCaseHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> RecursiveCaseHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&RecursiveCaseRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: RecursiveCaseResolver<H>, H: HostTypes> crate::kernel::predicate::MatchArm<H>
for ResolvedRecursiveCase<'r, R, H>
{
type Predicate = crate::kernel::predicate::NullPredicate<H>;
fn arm_predicate(&self) -> &Self::Predicate {
&<crate::kernel::predicate::NullPredicate<H>>::ABSENT
}
type Term = crate::kernel::schema::NullTerm<H>;
fn arm_result(&self) -> &Self::Term {
&<crate::kernel::schema::NullTerm<H>>::ABSENT
}
fn arm_index(&self) -> u64 {
0
}
}
impl<'r, R: RecursiveCaseResolver<H>, H: HostTypes> RecursiveCase<H>
for ResolvedRecursiveCase<'r, R, H>
{
}
#[derive(Debug)]
pub struct RecursiveStepHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for RecursiveStepHandle<H> {}
impl<H: HostTypes> Clone for RecursiveStepHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for RecursiveStepHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for RecursiveStepHandle<H> {}
impl<H: HostTypes> core::hash::Hash for RecursiveStepHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> RecursiveStepHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait RecursiveStepResolver<H: HostTypes> {
fn resolve(&self, handle: RecursiveStepHandle<H>) -> Option<RecursiveStepRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct RecursiveStepRecord<H: HostTypes> {
pub step_decomposition_handle: crate::user::morphism::TransformHandle<H>,
pub step_measure_pre_handle: DescentMeasureHandle<H>,
pub step_measure_post_handle: DescentMeasureHandle<H>,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedRecursiveStep<'r, R: RecursiveStepResolver<H>, H: HostTypes> {
handle: RecursiveStepHandle<H>,
resolver: &'r R,
record: Option<RecursiveStepRecord<H>>,
}
impl<'r, R: RecursiveStepResolver<H>, H: HostTypes> ResolvedRecursiveStep<'r, R, H> {
#[inline]
pub fn new(handle: RecursiveStepHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> RecursiveStepHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&RecursiveStepRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: RecursiveStepResolver<H>, H: HostTypes> RecursiveStep<H>
for ResolvedRecursiveStep<'r, R, H>
{
type Transform = crate::user::morphism::NullTransform<H>;
fn step_decomposition(&self) -> &Self::Transform {
&<crate::user::morphism::NullTransform<H>>::ABSENT
}
type DescentMeasure = NullDescentMeasure<H>;
fn step_measure_pre(&self) -> &Self::DescentMeasure {
&<NullDescentMeasure<H>>::ABSENT
}
fn step_measure_post(&self) -> &Self::DescentMeasure {
&<NullDescentMeasure<H>>::ABSENT
}
}
impl<'r, R: RecursiveStepResolver<H>, H: HostTypes> ResolvedRecursiveStep<'r, R, H> {
#[inline]
pub fn resolve_step_decomposition<'r2, R2: crate::user::morphism::TransformResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::user::morphism::ResolvedTransform<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::user::morphism::ResolvedTransform::new(
record.step_decomposition_handle,
r,
))
}
#[inline]
pub fn resolve_step_measure_pre<'r2, R2: DescentMeasureResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<ResolvedDescentMeasure<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(ResolvedDescentMeasure::new(
record.step_measure_pre_handle,
r,
))
}
#[inline]
pub fn resolve_step_measure_post<'r2, R2: DescentMeasureResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<ResolvedDescentMeasure<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(ResolvedDescentMeasure::new(
record.step_measure_post_handle,
r,
))
}
}
#[derive(Debug)]
pub struct RecursionTraceHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for RecursionTraceHandle<H> {}
impl<H: HostTypes> Clone for RecursionTraceHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for RecursionTraceHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for RecursionTraceHandle<H> {}
impl<H: HostTypes> core::hash::Hash for RecursionTraceHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> RecursionTraceHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait RecursionTraceResolver<H: HostTypes> {
fn resolve(&self, handle: RecursionTraceHandle<H>) -> Option<RecursionTraceRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct RecursionTraceRecord<H: HostTypes> {
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedRecursionTrace<'r, R: RecursionTraceResolver<H>, H: HostTypes> {
handle: RecursionTraceHandle<H>,
resolver: &'r R,
record: Option<RecursionTraceRecord<H>>,
}
impl<'r, R: RecursionTraceResolver<H>, H: HostTypes> ResolvedRecursionTrace<'r, R, H> {
#[inline]
pub fn new(handle: RecursionTraceHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> RecursionTraceHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&RecursionTraceRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: RecursionTraceResolver<H>, H: HostTypes> crate::bridge::trace::ComputationTrace<H>
for ResolvedRecursionTrace<'r, R, H>
{
type Datum = crate::kernel::schema::NullDatum<H>;
fn input(&self) -> &Self::Datum {
&<crate::kernel::schema::NullDatum<H>>::ABSENT
}
fn output(&self) -> &Self::Datum {
&<crate::kernel::schema::NullDatum<H>>::ABSENT
}
type ComputationStep = crate::bridge::trace::NullComputationStep<H>;
fn step(&self) -> &[Self::ComputationStep] {
&[]
}
type DihedralElement = crate::bridge::observable::NullDihedralElement<H>;
fn monodromy(&self) -> &Self::DihedralElement {
&<crate::bridge::observable::NullDihedralElement<H>>::ABSENT
}
type Certificate = crate::bridge::cert::NullCertificate<H>;
fn certified_by(&self) -> &Self::Certificate {
&<crate::bridge::cert::NullCertificate<H>>::ABSENT
}
type ResidualEntropy = crate::bridge::observable::NullResidualEntropy<H>;
fn residual_entropy(&self) -> &Self::ResidualEntropy {
&<crate::bridge::observable::NullResidualEntropy<H>>::ABSENT
}
fn is_geodesic(&self) -> bool {
false
}
type GeodesicViolation = crate::bridge::trace::NullGeodesicViolation<H>;
fn geodesic_violation(&self) -> &[Self::GeodesicViolation] {
&[]
}
fn cumulative_entropy_cost(&self) -> H::Decimal {
H::EMPTY_DECIMAL
}
fn adiabatically_ordered(&self) -> bool {
false
}
type MeasurementEvent = crate::bridge::trace::NullMeasurementEvent<H>;
fn measurement_event(&self) -> &[Self::MeasurementEvent] {
&[]
}
fn is_ar1_ordered(&self) -> bool {
false
}
fn is_dc10_selected(&self) -> bool {
false
}
}
impl<'r, R: RecursionTraceResolver<H>, H: HostTypes> RecursionTrace<H>
for ResolvedRecursionTrace<'r, R, H>
{
}
#[derive(Debug)]
pub struct StructuralRecursionHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for StructuralRecursionHandle<H> {}
impl<H: HostTypes> Clone for StructuralRecursionHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for StructuralRecursionHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for StructuralRecursionHandle<H> {}
impl<H: HostTypes> core::hash::Hash for StructuralRecursionHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> StructuralRecursionHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait StructuralRecursionResolver<H: HostTypes> {
fn resolve(&self, handle: StructuralRecursionHandle<H>)
-> Option<StructuralRecursionRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct StructuralRecursionRecord<H: HostTypes> {
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedStructuralRecursion<'r, R: StructuralRecursionResolver<H>, H: HostTypes> {
handle: StructuralRecursionHandle<H>,
resolver: &'r R,
record: Option<StructuralRecursionRecord<H>>,
}
impl<'r, R: StructuralRecursionResolver<H>, H: HostTypes> ResolvedStructuralRecursion<'r, R, H> {
#[inline]
pub fn new(handle: StructuralRecursionHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> StructuralRecursionHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&StructuralRecursionRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: StructuralRecursionResolver<H>, H: HostTypes> BoundedRecursion<H>
for ResolvedStructuralRecursion<'r, R, H>
{
type DescentMeasure = NullDescentMeasure<H>;
fn measure(&self) -> &Self::DescentMeasure {
&<NullDescentMeasure<H>>::ABSENT
}
type BaseCase = NullBaseCase<H>;
fn base_case(&self) -> &Self::BaseCase {
&<NullBaseCase<H>>::ABSENT
}
type RecursiveCase = NullRecursiveCase<H>;
fn recursive_case(&self) -> &Self::RecursiveCase {
&<NullRecursiveCase<H>>::ABSENT
}
type Predicate = crate::kernel::predicate::NullPredicate<H>;
fn base_predicate(&self) -> &Self::Predicate {
&<crate::kernel::predicate::NullPredicate<H>>::ABSENT
}
type ComputationDatum = crate::user::morphism::NullComputationDatum<H>;
fn recursion_body(&self) -> &Self::ComputationDatum {
&<crate::user::morphism::NullComputationDatum<H>>::ABSENT
}
fn initial_measure(&self) -> u64 {
0
}
}
impl<'r, R: StructuralRecursionResolver<H>, H: HostTypes> StructuralRecursion<H>
for ResolvedStructuralRecursion<'r, R, H>
{
}