use crate::HostTypes;
pub trait Predicate<H: HostTypes> {
fn evaluates_over(&self) -> &H::HostString;
type Term: crate::kernel::schema::Term<H>;
fn evaluator_term(&self) -> &Self::Term;
fn termination_witness(&self) -> &H::HostString;
type DescentMeasure: crate::kernel::recursion::DescentMeasure<H>;
fn bounded_evaluator(&self) -> &[Self::DescentMeasure];
}
pub trait TypePredicate<H: HostTypes>: Predicate<H> {}
pub trait StatePredicate<H: HostTypes>: Predicate<H> {}
pub trait SitePredicate<H: HostTypes>: Predicate<H> {}
pub trait DispatchRule<H: HostTypes> {
type Predicate: Predicate<H>;
fn dispatch_predicate(&self) -> &Self::Predicate;
fn dispatch_target(&self) -> &H::HostString;
fn dispatch_priority(&self) -> u64;
fn dispatch_index(&self) -> u64;
}
pub trait DispatchTable<H: HostTypes> {
type DispatchRule: DispatchRule<H>;
fn dispatch_rules(&self) -> &[Self::DispatchRule];
fn is_exhaustive(&self) -> bool;
fn is_mutually_exclusive(&self) -> bool;
}
pub trait GuardedTransition<H: HostTypes> {
type StatePredicate: StatePredicate<H>;
fn guard_predicate(&self) -> &Self::StatePredicate;
type Effect: crate::kernel::effect::Effect<H>;
fn guard_effect(&self) -> &Self::Effect;
type ReductionStep: crate::kernel::reduction::ReductionStep<H>;
fn guard_target(&self) -> &Self::ReductionStep;
}
pub trait MatchArm<H: HostTypes> {
type Predicate: Predicate<H>;
fn arm_predicate(&self) -> &Self::Predicate;
type Term: crate::kernel::schema::Term<H>;
fn arm_result(&self) -> &Self::Term;
fn arm_index(&self) -> u64;
}
pub trait MatchExpression<H: HostTypes>: crate::kernel::schema::Term<H> {
type MatchArm: MatchArm<H>;
fn match_arms(&self) -> &[Self::MatchArm];
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullPredicate<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullPredicate<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullPredicate<H> {
pub const ABSENT: NullPredicate<H> = NullPredicate {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> Predicate<H> for NullPredicate<H> {
fn evaluates_over(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
type Term = crate::kernel::schema::NullTerm<H>;
fn evaluator_term(&self) -> &Self::Term {
&<crate::kernel::schema::NullTerm<H>>::ABSENT
}
fn termination_witness(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
type DescentMeasure = crate::kernel::recursion::NullDescentMeasure<H>;
fn bounded_evaluator(&self) -> &[Self::DescentMeasure] {
&[]
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullTypePredicate<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullTypePredicate<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullTypePredicate<H> {
pub const ABSENT: NullTypePredicate<H> = NullTypePredicate {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> Predicate<H> for NullTypePredicate<H> {
fn evaluates_over(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
type Term = crate::kernel::schema::NullTerm<H>;
fn evaluator_term(&self) -> &Self::Term {
&<crate::kernel::schema::NullTerm<H>>::ABSENT
}
fn termination_witness(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
type DescentMeasure = crate::kernel::recursion::NullDescentMeasure<H>;
fn bounded_evaluator(&self) -> &[Self::DescentMeasure] {
&[]
}
}
impl<H: HostTypes> TypePredicate<H> for NullTypePredicate<H> {}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullStatePredicate<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullStatePredicate<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullStatePredicate<H> {
pub const ABSENT: NullStatePredicate<H> = NullStatePredicate {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> Predicate<H> for NullStatePredicate<H> {
fn evaluates_over(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
type Term = crate::kernel::schema::NullTerm<H>;
fn evaluator_term(&self) -> &Self::Term {
&<crate::kernel::schema::NullTerm<H>>::ABSENT
}
fn termination_witness(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
type DescentMeasure = crate::kernel::recursion::NullDescentMeasure<H>;
fn bounded_evaluator(&self) -> &[Self::DescentMeasure] {
&[]
}
}
impl<H: HostTypes> StatePredicate<H> for NullStatePredicate<H> {}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullSitePredicate<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullSitePredicate<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullSitePredicate<H> {
pub const ABSENT: NullSitePredicate<H> = NullSitePredicate {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> Predicate<H> for NullSitePredicate<H> {
fn evaluates_over(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
type Term = crate::kernel::schema::NullTerm<H>;
fn evaluator_term(&self) -> &Self::Term {
&<crate::kernel::schema::NullTerm<H>>::ABSENT
}
fn termination_witness(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
type DescentMeasure = crate::kernel::recursion::NullDescentMeasure<H>;
fn bounded_evaluator(&self) -> &[Self::DescentMeasure] {
&[]
}
}
impl<H: HostTypes> SitePredicate<H> for NullSitePredicate<H> {}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullDispatchRule<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullDispatchRule<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullDispatchRule<H> {
pub const ABSENT: NullDispatchRule<H> = NullDispatchRule {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> DispatchRule<H> for NullDispatchRule<H> {
type Predicate = NullPredicate<H>;
fn dispatch_predicate(&self) -> &Self::Predicate {
&<NullPredicate<H>>::ABSENT
}
fn dispatch_target(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
fn dispatch_priority(&self) -> u64 {
0
}
fn dispatch_index(&self) -> u64 {
0
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullDispatchTable<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullDispatchTable<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullDispatchTable<H> {
pub const ABSENT: NullDispatchTable<H> = NullDispatchTable {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> DispatchTable<H> for NullDispatchTable<H> {
type DispatchRule = NullDispatchRule<H>;
fn dispatch_rules(&self) -> &[Self::DispatchRule] {
&[]
}
fn is_exhaustive(&self) -> bool {
false
}
fn is_mutually_exclusive(&self) -> bool {
false
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullGuardedTransition<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullGuardedTransition<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullGuardedTransition<H> {
pub const ABSENT: NullGuardedTransition<H> = NullGuardedTransition {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> GuardedTransition<H> for NullGuardedTransition<H> {
type StatePredicate = NullStatePredicate<H>;
fn guard_predicate(&self) -> &Self::StatePredicate {
&<NullStatePredicate<H>>::ABSENT
}
type Effect = crate::kernel::effect::NullEffect<H>;
fn guard_effect(&self) -> &Self::Effect {
&<crate::kernel::effect::NullEffect<H>>::ABSENT
}
type ReductionStep = crate::kernel::reduction::NullReductionStep<H>;
fn guard_target(&self) -> &Self::ReductionStep {
&<crate::kernel::reduction::NullReductionStep<H>>::ABSENT
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullMatchArm<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullMatchArm<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullMatchArm<H> {
pub const ABSENT: NullMatchArm<H> = NullMatchArm {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> MatchArm<H> for NullMatchArm<H> {
type Predicate = NullPredicate<H>;
fn arm_predicate(&self) -> &Self::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
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullMatchExpression<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullMatchExpression<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullMatchExpression<H> {
pub const ABSENT: NullMatchExpression<H> = NullMatchExpression {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> crate::kernel::schema::Term<H> for NullMatchExpression<H> {}
impl<H: HostTypes> MatchExpression<H> for NullMatchExpression<H> {
type MatchArm = NullMatchArm<H>;
fn match_arms(&self) -> &[Self::MatchArm] {
&[]
}
}
#[derive(Debug)]
pub struct PredicateHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for PredicateHandle<H> {}
impl<H: HostTypes> Clone for PredicateHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for PredicateHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for PredicateHandle<H> {}
impl<H: HostTypes> core::hash::Hash for PredicateHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> PredicateHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait PredicateResolver<H: HostTypes> {
fn resolve(&self, handle: PredicateHandle<H>) -> Option<PredicateRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct PredicateRecord<H: HostTypes> {
pub evaluates_over: &'static H::HostString,
pub evaluator_term_handle: crate::kernel::schema::TermHandle<H>,
pub termination_witness: &'static H::HostString,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedPredicate<'r, R: PredicateResolver<H>, H: HostTypes> {
handle: PredicateHandle<H>,
resolver: &'r R,
record: Option<PredicateRecord<H>>,
}
impl<'r, R: PredicateResolver<H>, H: HostTypes> ResolvedPredicate<'r, R, H> {
#[inline]
pub fn new(handle: PredicateHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> PredicateHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&PredicateRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: PredicateResolver<H>, H: HostTypes> Predicate<H> for ResolvedPredicate<'r, R, H> {
fn evaluates_over(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
type Term = crate::kernel::schema::NullTerm<H>;
fn evaluator_term(&self) -> &Self::Term {
&<crate::kernel::schema::NullTerm<H>>::ABSENT
}
fn termination_witness(&self) -> &H::HostString {
match &self.record {
Some(r) => r.termination_witness,
None => H::EMPTY_HOST_STRING,
}
}
type DescentMeasure = crate::kernel::recursion::NullDescentMeasure<H>;
fn bounded_evaluator(&self) -> &[Self::DescentMeasure] {
&[]
}
}
impl<'r, R: PredicateResolver<H>, H: HostTypes> ResolvedPredicate<'r, R, H> {
#[inline]
pub fn resolve_evaluator_term<'r2, R2: crate::kernel::schema::TermResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::kernel::schema::ResolvedTerm<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::kernel::schema::ResolvedTerm::new(
record.evaluator_term_handle,
r,
))
}
}
#[derive(Debug)]
pub struct TypePredicateHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for TypePredicateHandle<H> {}
impl<H: HostTypes> Clone for TypePredicateHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for TypePredicateHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for TypePredicateHandle<H> {}
impl<H: HostTypes> core::hash::Hash for TypePredicateHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> TypePredicateHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait TypePredicateResolver<H: HostTypes> {
fn resolve(&self, handle: TypePredicateHandle<H>) -> Option<TypePredicateRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct TypePredicateRecord<H: HostTypes> {
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedTypePredicate<'r, R: TypePredicateResolver<H>, H: HostTypes> {
handle: TypePredicateHandle<H>,
resolver: &'r R,
record: Option<TypePredicateRecord<H>>,
}
impl<'r, R: TypePredicateResolver<H>, H: HostTypes> ResolvedTypePredicate<'r, R, H> {
#[inline]
pub fn new(handle: TypePredicateHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> TypePredicateHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&TypePredicateRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: TypePredicateResolver<H>, H: HostTypes> Predicate<H>
for ResolvedTypePredicate<'r, R, H>
{
fn evaluates_over(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
type Term = crate::kernel::schema::NullTerm<H>;
fn evaluator_term(&self) -> &Self::Term {
&<crate::kernel::schema::NullTerm<H>>::ABSENT
}
fn termination_witness(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
type DescentMeasure = crate::kernel::recursion::NullDescentMeasure<H>;
fn bounded_evaluator(&self) -> &[Self::DescentMeasure] {
&[]
}
}
impl<'r, R: TypePredicateResolver<H>, H: HostTypes> TypePredicate<H>
for ResolvedTypePredicate<'r, R, H>
{
}
#[derive(Debug)]
pub struct StatePredicateHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for StatePredicateHandle<H> {}
impl<H: HostTypes> Clone for StatePredicateHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for StatePredicateHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for StatePredicateHandle<H> {}
impl<H: HostTypes> core::hash::Hash for StatePredicateHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> StatePredicateHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait StatePredicateResolver<H: HostTypes> {
fn resolve(&self, handle: StatePredicateHandle<H>) -> Option<StatePredicateRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct StatePredicateRecord<H: HostTypes> {
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedStatePredicate<'r, R: StatePredicateResolver<H>, H: HostTypes> {
handle: StatePredicateHandle<H>,
resolver: &'r R,
record: Option<StatePredicateRecord<H>>,
}
impl<'r, R: StatePredicateResolver<H>, H: HostTypes> ResolvedStatePredicate<'r, R, H> {
#[inline]
pub fn new(handle: StatePredicateHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> StatePredicateHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&StatePredicateRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: StatePredicateResolver<H>, H: HostTypes> Predicate<H>
for ResolvedStatePredicate<'r, R, H>
{
fn evaluates_over(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
type Term = crate::kernel::schema::NullTerm<H>;
fn evaluator_term(&self) -> &Self::Term {
&<crate::kernel::schema::NullTerm<H>>::ABSENT
}
fn termination_witness(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
type DescentMeasure = crate::kernel::recursion::NullDescentMeasure<H>;
fn bounded_evaluator(&self) -> &[Self::DescentMeasure] {
&[]
}
}
impl<'r, R: StatePredicateResolver<H>, H: HostTypes> StatePredicate<H>
for ResolvedStatePredicate<'r, R, H>
{
}
#[derive(Debug)]
pub struct SitePredicateHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for SitePredicateHandle<H> {}
impl<H: HostTypes> Clone for SitePredicateHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for SitePredicateHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for SitePredicateHandle<H> {}
impl<H: HostTypes> core::hash::Hash for SitePredicateHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> SitePredicateHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait SitePredicateResolver<H: HostTypes> {
fn resolve(&self, handle: SitePredicateHandle<H>) -> Option<SitePredicateRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct SitePredicateRecord<H: HostTypes> {
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedSitePredicate<'r, R: SitePredicateResolver<H>, H: HostTypes> {
handle: SitePredicateHandle<H>,
resolver: &'r R,
record: Option<SitePredicateRecord<H>>,
}
impl<'r, R: SitePredicateResolver<H>, H: HostTypes> ResolvedSitePredicate<'r, R, H> {
#[inline]
pub fn new(handle: SitePredicateHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> SitePredicateHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&SitePredicateRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: SitePredicateResolver<H>, H: HostTypes> Predicate<H>
for ResolvedSitePredicate<'r, R, H>
{
fn evaluates_over(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
type Term = crate::kernel::schema::NullTerm<H>;
fn evaluator_term(&self) -> &Self::Term {
&<crate::kernel::schema::NullTerm<H>>::ABSENT
}
fn termination_witness(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
type DescentMeasure = crate::kernel::recursion::NullDescentMeasure<H>;
fn bounded_evaluator(&self) -> &[Self::DescentMeasure] {
&[]
}
}
impl<'r, R: SitePredicateResolver<H>, H: HostTypes> SitePredicate<H>
for ResolvedSitePredicate<'r, R, H>
{
}
#[derive(Debug)]
pub struct DispatchRuleHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for DispatchRuleHandle<H> {}
impl<H: HostTypes> Clone for DispatchRuleHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for DispatchRuleHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for DispatchRuleHandle<H> {}
impl<H: HostTypes> core::hash::Hash for DispatchRuleHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> DispatchRuleHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait DispatchRuleResolver<H: HostTypes> {
fn resolve(&self, handle: DispatchRuleHandle<H>) -> Option<DispatchRuleRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct DispatchRuleRecord<H: HostTypes> {
pub dispatch_predicate_handle: PredicateHandle<H>,
pub dispatch_target: &'static H::HostString,
pub dispatch_priority: u64,
pub dispatch_index: u64,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedDispatchRule<'r, R: DispatchRuleResolver<H>, H: HostTypes> {
handle: DispatchRuleHandle<H>,
resolver: &'r R,
record: Option<DispatchRuleRecord<H>>,
}
impl<'r, R: DispatchRuleResolver<H>, H: HostTypes> ResolvedDispatchRule<'r, R, H> {
#[inline]
pub fn new(handle: DispatchRuleHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> DispatchRuleHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&DispatchRuleRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: DispatchRuleResolver<H>, H: HostTypes> DispatchRule<H>
for ResolvedDispatchRule<'r, R, H>
{
type Predicate = NullPredicate<H>;
fn dispatch_predicate(&self) -> &Self::Predicate {
&<NullPredicate<H>>::ABSENT
}
fn dispatch_target(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
fn dispatch_priority(&self) -> u64 {
match &self.record {
Some(r) => r.dispatch_priority,
None => 0,
}
}
fn dispatch_index(&self) -> u64 {
match &self.record {
Some(r) => r.dispatch_index,
None => 0,
}
}
}
impl<'r, R: DispatchRuleResolver<H>, H: HostTypes> ResolvedDispatchRule<'r, R, H> {
#[inline]
pub fn resolve_dispatch_predicate<'r2, R2: PredicateResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<ResolvedPredicate<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(ResolvedPredicate::new(record.dispatch_predicate_handle, r))
}
}
#[derive(Debug)]
pub struct DispatchTableHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for DispatchTableHandle<H> {}
impl<H: HostTypes> Clone for DispatchTableHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for DispatchTableHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for DispatchTableHandle<H> {}
impl<H: HostTypes> core::hash::Hash for DispatchTableHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> DispatchTableHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait DispatchTableResolver<H: HostTypes> {
fn resolve(&self, handle: DispatchTableHandle<H>) -> Option<DispatchTableRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct DispatchTableRecord<H: HostTypes> {
pub is_exhaustive: bool,
pub is_mutually_exclusive: bool,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedDispatchTable<'r, R: DispatchTableResolver<H>, H: HostTypes> {
handle: DispatchTableHandle<H>,
resolver: &'r R,
record: Option<DispatchTableRecord<H>>,
}
impl<'r, R: DispatchTableResolver<H>, H: HostTypes> ResolvedDispatchTable<'r, R, H> {
#[inline]
pub fn new(handle: DispatchTableHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> DispatchTableHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&DispatchTableRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: DispatchTableResolver<H>, H: HostTypes> DispatchTable<H>
for ResolvedDispatchTable<'r, R, H>
{
type DispatchRule = NullDispatchRule<H>;
fn dispatch_rules(&self) -> &[Self::DispatchRule] {
&[]
}
fn is_exhaustive(&self) -> bool {
match &self.record {
Some(r) => r.is_exhaustive,
None => false,
}
}
fn is_mutually_exclusive(&self) -> bool {
match &self.record {
Some(r) => r.is_mutually_exclusive,
None => false,
}
}
}
#[derive(Debug)]
pub struct GuardedTransitionHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for GuardedTransitionHandle<H> {}
impl<H: HostTypes> Clone for GuardedTransitionHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for GuardedTransitionHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for GuardedTransitionHandle<H> {}
impl<H: HostTypes> core::hash::Hash for GuardedTransitionHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> GuardedTransitionHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait GuardedTransitionResolver<H: HostTypes> {
fn resolve(&self, handle: GuardedTransitionHandle<H>) -> Option<GuardedTransitionRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct GuardedTransitionRecord<H: HostTypes> {
pub guard_predicate_handle: StatePredicateHandle<H>,
pub guard_effect_handle: crate::kernel::effect::EffectHandle<H>,
pub guard_target_handle: crate::kernel::reduction::ReductionStepHandle<H>,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedGuardedTransition<'r, R: GuardedTransitionResolver<H>, H: HostTypes> {
handle: GuardedTransitionHandle<H>,
resolver: &'r R,
record: Option<GuardedTransitionRecord<H>>,
}
impl<'r, R: GuardedTransitionResolver<H>, H: HostTypes> ResolvedGuardedTransition<'r, R, H> {
#[inline]
pub fn new(handle: GuardedTransitionHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> GuardedTransitionHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&GuardedTransitionRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: GuardedTransitionResolver<H>, H: HostTypes> GuardedTransition<H>
for ResolvedGuardedTransition<'r, R, H>
{
type StatePredicate = NullStatePredicate<H>;
fn guard_predicate(&self) -> &Self::StatePredicate {
&<NullStatePredicate<H>>::ABSENT
}
type Effect = crate::kernel::effect::NullEffect<H>;
fn guard_effect(&self) -> &Self::Effect {
&<crate::kernel::effect::NullEffect<H>>::ABSENT
}
type ReductionStep = crate::kernel::reduction::NullReductionStep<H>;
fn guard_target(&self) -> &Self::ReductionStep {
&<crate::kernel::reduction::NullReductionStep<H>>::ABSENT
}
}
impl<'r, R: GuardedTransitionResolver<H>, H: HostTypes> ResolvedGuardedTransition<'r, R, H> {
#[inline]
pub fn resolve_guard_predicate<'r2, R2: StatePredicateResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<ResolvedStatePredicate<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(ResolvedStatePredicate::new(
record.guard_predicate_handle,
r,
))
}
#[inline]
pub fn resolve_guard_effect<'r2, R2: crate::kernel::effect::EffectResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::kernel::effect::ResolvedEffect<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::kernel::effect::ResolvedEffect::new(
record.guard_effect_handle,
r,
))
}
#[inline]
pub fn resolve_guard_target<'r2, R2: crate::kernel::reduction::ReductionStepResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::kernel::reduction::ResolvedReductionStep<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::kernel::reduction::ResolvedReductionStep::new(
record.guard_target_handle,
r,
))
}
}
#[derive(Debug)]
pub struct MatchArmHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for MatchArmHandle<H> {}
impl<H: HostTypes> Clone for MatchArmHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for MatchArmHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for MatchArmHandle<H> {}
impl<H: HostTypes> core::hash::Hash for MatchArmHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> MatchArmHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait MatchArmResolver<H: HostTypes> {
fn resolve(&self, handle: MatchArmHandle<H>) -> Option<MatchArmRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct MatchArmRecord<H: HostTypes> {
pub arm_predicate_handle: PredicateHandle<H>,
pub arm_result_handle: crate::kernel::schema::TermHandle<H>,
pub arm_index: u64,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedMatchArm<'r, R: MatchArmResolver<H>, H: HostTypes> {
handle: MatchArmHandle<H>,
resolver: &'r R,
record: Option<MatchArmRecord<H>>,
}
impl<'r, R: MatchArmResolver<H>, H: HostTypes> ResolvedMatchArm<'r, R, H> {
#[inline]
pub fn new(handle: MatchArmHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> MatchArmHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&MatchArmRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: MatchArmResolver<H>, H: HostTypes> MatchArm<H> for ResolvedMatchArm<'r, R, H> {
type Predicate = NullPredicate<H>;
fn arm_predicate(&self) -> &Self::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 {
match &self.record {
Some(r) => r.arm_index,
None => 0,
}
}
}
impl<'r, R: MatchArmResolver<H>, H: HostTypes> ResolvedMatchArm<'r, R, H> {
#[inline]
pub fn resolve_arm_predicate<'r2, R2: PredicateResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<ResolvedPredicate<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(ResolvedPredicate::new(record.arm_predicate_handle, r))
}
#[inline]
pub fn resolve_arm_result<'r2, R2: crate::kernel::schema::TermResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::kernel::schema::ResolvedTerm<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::kernel::schema::ResolvedTerm::new(
record.arm_result_handle,
r,
))
}
}
#[derive(Debug)]
pub struct MatchExpressionHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for MatchExpressionHandle<H> {}
impl<H: HostTypes> Clone for MatchExpressionHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for MatchExpressionHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for MatchExpressionHandle<H> {}
impl<H: HostTypes> core::hash::Hash for MatchExpressionHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> MatchExpressionHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait MatchExpressionResolver<H: HostTypes> {
fn resolve(&self, handle: MatchExpressionHandle<H>) -> Option<MatchExpressionRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct MatchExpressionRecord<H: HostTypes> {
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedMatchExpression<'r, R: MatchExpressionResolver<H>, H: HostTypes> {
handle: MatchExpressionHandle<H>,
resolver: &'r R,
record: Option<MatchExpressionRecord<H>>,
}
impl<'r, R: MatchExpressionResolver<H>, H: HostTypes> ResolvedMatchExpression<'r, R, H> {
#[inline]
pub fn new(handle: MatchExpressionHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> MatchExpressionHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&MatchExpressionRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: MatchExpressionResolver<H>, H: HostTypes> crate::kernel::schema::Term<H>
for ResolvedMatchExpression<'r, R, H>
{
}
impl<'r, R: MatchExpressionResolver<H>, H: HostTypes> MatchExpression<H>
for ResolvedMatchExpression<'r, R, H>
{
type MatchArm = NullMatchArm<H>;
fn match_arms(&self) -> &[Self::MatchArm] {
&[]
}
}
pub mod always {
pub const EVALUATES_OVER: &str = "https://uor.foundation/schema/Datum";
}
pub mod never {
pub const EVALUATES_OVER: &str = "https://uor.foundation/schema/Datum";
}
pub mod is_zero {
pub const EVALUATES_OVER: &str = "https://uor.foundation/schema/Datum";
}
pub mod is_unit {
pub const EVALUATES_OVER: &str = "https://uor.foundation/schema/Datum";
}
pub mod is_odd {
pub const EVALUATES_OVER: &str = "https://uor.foundation/schema/Datum";
}
pub mod is_even {
pub const EVALUATES_OVER: &str = "https://uor.foundation/schema/Datum";
}
pub mod is_involution {
pub const EVALUATES_OVER: &str = "https://uor.foundation/schema/Datum";
}
pub mod site_pinned {
pub const EVALUATES_OVER: &str = "https://uor.foundation/partition/SiteIndex";
}
pub mod site_free {
pub const EVALUATES_OVER: &str = "https://uor.foundation/partition/SiteIndex";
}
pub mod contradiction_reached {
pub const EVALUATES_OVER: &str = "https://uor.foundation/state/ContradictionBoundary";
}
pub mod budget_exhausted {
pub const EVALUATES_OVER: &str = "https://uor.foundation/partition/FreeRank";
}
pub mod reduction_converged {
pub const EVALUATES_OVER: &str = "https://uor.foundation/reduction/ReductionState";
}
pub mod is2_sat_shape {
pub const EVALUATES_OVER: &str = "https://uor.foundation/type/ConstrainedType";
}
pub mod is_horn_shape {
pub const EVALUATES_OVER: &str = "https://uor.foundation/type/ConstrainedType";
}
pub mod is_residual_fragment {
pub const EVALUATES_OVER: &str = "https://uor.foundation/type/ConstrainedType";
}
pub mod inhabitance_dispatch_table {
pub const IS_EXHAUSTIVE: bool = true;
pub const IS_MUTUALLY_EXCLUSIVE: bool = true;
}
pub mod inhabitance_rule_2sat {
pub const DISPATCH_PREDICATE: &str = "https://uor.foundation/predicate/Is2SatShape";
pub const DISPATCH_PRIORITY: i64 = 0;
pub const DISPATCH_TARGET: &str = "https://uor.foundation/resolver/TwoSatDecider";
}
pub mod inhabitance_rule_horn {
pub const DISPATCH_PREDICATE: &str = "https://uor.foundation/predicate/IsHornShape";
pub const DISPATCH_PRIORITY: i64 = 1;
pub const DISPATCH_TARGET: &str = "https://uor.foundation/resolver/HornSatDecider";
}
pub mod inhabitance_rule_residual {
pub const DISPATCH_PREDICATE: &str = "https://uor.foundation/predicate/IsResidualFragment";
pub const DISPATCH_PRIORITY: i64 = 2;
pub const DISPATCH_TARGET: &str = "https://uor.foundation/resolver/ResidualVerdictResolver";
}