EffectEthos

Struct EffectEthos 

Source
pub struct EffectEthos<D, S, T, ST, SYM, VS, VT>
where D: Datable + Clone, S: Spatial<VS> + Clone, T: Temporal<VT> + Clone, ST: SpaceTemporal<VS, VT> + Clone, SYM: Symbolic + Clone, VS: Clone, VT: Clone,
{ /* private fields */ }
Expand description

The EffectEthos provides a reasoning engine for deontic inference. It encapsulates all the necessary components to evaluate a proposed action against a set of teleological norms (Teloids).

For more details, see section 5 (Causality as EPP) and 8 (Teleology) in The EPP reference paper: https://github.com/deepcausality-rs/papers/blob/main/effect_propagation_process/epp.pdf

Implementations§

Source§

impl<D, S, T, ST, SYM, VS, VT> EffectEthos<D, S, T, ST, SYM, VS, VT>
where D: Datable + Clone, S: Spatial<VS> + Clone, T: Temporal<VT> + Clone, ST: SpaceTemporal<VS, VT> + Clone, SYM: Symbolic + Clone, VS: Clone, VT: Clone,

Source

pub fn add_deterministic_norm( self, id: TeloidID, action_identifier: &str, tags: &[TeloidTag], predicate: fn(&Context<D, S, T, ST, SYM, VS, VT>, &ProposedAction) -> bool, modality: TeloidModal, timestamp: u64, specificity: u32, priority: u32, ) -> Result<Self, DeonticError>

Adds a new deterministic norm to the ethos using a builder-style pattern.

This high-level method simplifies the process of adding norms by accepting all necessary components as arguments, constructing the Teloid internally, and handling all necessary updates to the store, graph, and indices.

§Arguments
  • id - The unique identifier for the new norm.
  • action_identifier - A string slice identifying the action this norm governs.
  • tags - A slice of string tags for categorization.
  • predicate - The function pointer that determines if the norm is active.
  • modality - The deontic status (Obligatory, Impermissible, Optional).
  • timestamp - The creation time of the norm for Lex Posterior.
  • specificity - The specificity level for Lex Specialis.
  • priority - The priority level for Lex Superior.
§Returns

A Result containing self for method chaining, or a DeonticError if the id already exists.

Source

pub fn add_uncertain_norm( self, id: TeloidID, action_identifier: &str, tags: &[TeloidTag], predicate: UncertainActivationPredicate<D, S, T, ST, SYM, VS, VT>, predicate_parameter: UncertainParameter, modality: TeloidModal, timestamp: u64, specificity: u32, priority: u32, ) -> Result<Self, DeonticError>

Adds a new uncertain norm to the ethos using a builder-style pattern.

Source

pub fn get_norm( &self, id: TeloidID, ) -> Option<&Teloid<D, S, T, ST, SYM, VS, VT>>

Retrieves a reference to a norm by its unique identifier.

This method provides read-only access to a Teloid stored within the EffectEthos based on its TeloidID.

§Arguments
  • id - The unique identifier of the norm to retrieve.
§Returns

An Option containing a reference to the Teloid if found, or None otherwise.

Defines an inheritance relationship between two norms by their IDs.

§Arguments
  • parent_id - The ID of the more general norm.
  • child_id - The ID of the more specific norm that inherits from the parent.
§Returns

A Result containing self for method chaining, or a DeonticError if either ID is not found or the graph is frozen.

Defines a defeasance relationship between two norms by their IDs.

§Arguments
  • defeater_id - The ID of the norm that can defeat the other.
  • defeated_id - The ID of the norm that can be defeated.
§Returns

A Result containing self for method chaining, or a DeonticError if either ID is not found or the graph is frozen.

Source§

impl<D, S, T, ST, SYM, VS, VT> EffectEthos<D, S, T, ST, SYM, VS, VT>
where D: Datable + Clone, S: Spatial<VS> + Clone, T: Temporal<VT> + Clone, ST: SpaceTemporal<VS, VT> + Clone, SYM: Symbolic + Clone, VS: Clone, VT: Clone,

Source

pub fn is_frozen(&self) -> bool

Checks if the internal graph is frozen for evaluation.

Source

pub fn freeze(&mut self)

Freezes the internal graph for evaluation.

Source

pub fn unfreeze(&mut self)

Unfreezes the internal graph for modification.

Source§

impl<D, S, T, ST, SYM, VS, VT> EffectEthos<D, S, T, ST, SYM, VS, VT>
where D: Datable + Clone, S: Spatial<VS> + Clone, T: Temporal<VT> + Clone, ST: SpaceTemporal<VS, VT> + Clone, SYM: Symbolic + Clone, VS: Clone, VT: Clone,

Source

pub fn is_verified(&self) -> bool

Source

pub fn verify_graph(&mut self) -> Result<(), DeonticError>

Verifies the integrity of the internal TeloidGraph, primarily checking for cycles. This is a required step before evaluation can proceed.

Source§

impl<D, S, T, ST, SYM, VS, VT> EffectEthos<D, S, T, ST, SYM, VS, VT>
where D: Datable + Clone, S: Spatial<VS> + Clone, T: Temporal<VT> + Clone, ST: SpaceTemporal<VS, VT> + Clone, SYM: Symbolic + Clone, VS: Clone, VT: Clone,

Source

pub fn new() -> Self

Creates a new, empty EffectEthos.

Source

pub fn from( teloid_store: TeloidStore<D, S, T, ST, SYM, VS, VT>, tag_index: TagIndex, teloid_graph: TeloidGraph, ) -> Self

Build an effect ethos

Trait Implementations§

Source§

impl<D, S, T, ST, SYM, VS, VT> Clone for EffectEthos<D, S, T, ST, SYM, VS, VT>
where D: Datable + Clone + Clone, S: Spatial<VS> + Clone + Clone, T: Temporal<VT> + Clone + Clone, ST: SpaceTemporal<VS, VT> + Clone + Clone, SYM: Symbolic + Clone + Clone, VS: Clone + Clone, VT: Clone + Clone,

Source§

fn clone(&self) -> EffectEthos<D, S, T, ST, SYM, VS, VT>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<D, S, T, ST, SYM, VS, VT> Debug for EffectEthos<D, S, T, ST, SYM, VS, VT>
where D: Datable + Clone + Debug, S: Spatial<VS> + Clone + Debug, T: Temporal<VT> + Clone + Debug, ST: SpaceTemporal<VS, VT> + Clone + Debug, SYM: Symbolic + Clone + Debug, VS: Clone + Debug, VT: Clone + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<D, S, T, ST, SYM, VS, VT> Default for EffectEthos<D, S, T, ST, SYM, VS, VT>
where D: Datable + Clone + Default, S: Spatial<VS> + Clone + Default, T: Temporal<VT> + Clone + Default, ST: SpaceTemporal<VS, VT> + Clone + Default, SYM: Symbolic + Clone + Default, VS: Clone + Default, VT: Clone + Default,

Source§

fn default() -> EffectEthos<D, S, T, ST, SYM, VS, VT>

Returns the “default value” for a type. Read more
Source§

impl<D, S, T, ST, SYM, VS, VT> DeonticExplainable<D, S, T, ST, SYM, VS, VT> for EffectEthos<D, S, T, ST, SYM, VS, VT>
where D: Datable + Clone, S: Spatial<VS> + Clone, T: Temporal<VT> + Clone, ST: SpaceTemporal<VS, VT> + Clone, SYM: Symbolic + Clone, VS: Clone, VT: Clone,

Source§

fn explain_verdict(&self, verdict: &Verdict) -> Result<String, DeonticError>

Explains the reasoning behind a given verdict. Read more
Source§

impl<D, S, T, ST, SYM, VS, VT> DeonticInferable<D, S, T, ST, SYM, VS, VT> for EffectEthos<D, S, T, ST, SYM, VS, VT>
where D: Datable + Clone, S: Spatial<VS> + Clone, T: Temporal<VT> + Clone, ST: SpaceTemporal<VS, VT> + Clone, SYM: Symbolic + Clone, VS: Clone, VT: Clone,

Source§

fn evaluate_action( &self, action: &ProposedAction, context: &Context<D, S, T, ST, SYM, VS, VT>, tags: &[TeloidTag], ) -> Result<Verdict, DeonticError>

Evaluates a proposed action against the established norms and beliefs within the EffectEthos system.

This method orchestrates the deontic inference process, which involves several key steps:

  1. Graph State Check: Ensures the internal teloid graph is frozen and verified for acyclicity to guarantee a stable and reliable evaluation.
  2. Filtering (Step 1): Identifies a candidate set of Teloids (norms/beliefs) relevant to the ProposedAction using a list of tags.
  3. Activation (Step 2): Filters the candidate Teloids based on their activation predicates, which determine if a Teloid is applicable in the given Context.
  4. Belief Inference & Conflict Resolution (Steps 3 & 4): Resolves any conflicts among the active Teloids to arrive at a final set of applicable norms.
  5. Verdict Finding (Step 5): Derives a final Verdict based on the resolved norms.
§Arguments
  • action - A reference to the ProposedAction to be evaluated.
  • context - A reference to the Context providing environmental and situational data.
  • tags - A slice of TeloidTags used to retrieve relevant norms from the tag index.
§Returns

A Result which is:

  • Ok(Verdict) if a verdict can be successfully derived.
  • Err(DeonticError) if the graph is not frozen, is cyclic, no relevant norms are found, no teloids are active, or if conflict resolution fails.

Auto Trait Implementations§

§

impl<D, S, T, ST, SYM, VS, VT> Freeze for EffectEthos<D, S, T, ST, SYM, VS, VT>

§

impl<D, S, T, ST, SYM, VS, VT> RefUnwindSafe for EffectEthos<D, S, T, ST, SYM, VS, VT>

§

impl<D, S, T, ST, SYM, VS, VT> Send for EffectEthos<D, S, T, ST, SYM, VS, VT>

§

impl<D, S, T, ST, SYM, VS, VT> Sync for EffectEthos<D, S, T, ST, SYM, VS, VT>

§

impl<D, S, T, ST, SYM, VS, VT> Unpin for EffectEthos<D, S, T, ST, SYM, VS, VT>

§

impl<D, S, T, ST, SYM, VS, VT> UnwindSafe for EffectEthos<D, S, T, ST, SYM, VS, VT>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.