Skip to main content

WfNet

Struct WfNet 

Source
pub struct WfNet<S = SoundnessUnknown> { /* private fields */ }
Expand description

A workflow net (WF-net): a Petri net with a single source and sink place and a soundness state tracked at the type level by the S typestate parameter.

The S parameter is one of SoundnessUnknown (default), SoundnessClaimed, or SoundnessWitnessed — empty-enum markers used via PhantomData. The field/parameter is a claim about soundness, never a computed proof: WfNet::validate checks only structural WF-net shape (initial and final markings present), and the soundness transition methods merely re-type the claim; they do not compute soundness.

Structure-only: actual soundness witnessing graduates to wasm4pm, which produces the witness that justifies moving to SoundnessWitnessed.

Implementations§

Source§

impl WfNet<SoundnessUnknown>

Source

pub fn new(net: PetriNet, final_marking: Marking) -> Self

Construct a WF-net in the SoundnessUnknown state from a Petri net and a final marking.

use wasm4pm_compat::petri::{WfNet, PetriNet, Place, Transition, Arc, Marking};
let net = PetriNet::new(
    [Place::new("src"), Place::new("snk")],
    [Transition::new("t", "a")],
    [Arc::place_to_transition("src", "t"), Arc::transition_to_place("t", "snk")],
    Marking::new([("src".to_string(), 1)]),
);
let wf = WfNet::new(net, Marking::new([("snk".to_string(), 1)]));
assert!(wf.validate().is_ok());
Source§

impl<S> WfNet<S>

Source

pub fn net(&self) -> &PetriNet

The underlying Petri net.

Source

pub fn final_marking(&self) -> Option<&Marking>

The final marking, if declared.

Source

pub fn validate(&self) -> Result<(), PetriRefusal>

Structurally validate the WF-net shape.

Checks that the underlying net is structurally well-formed, that an initial marking places at least one token (PetriRefusal::MissingInitialMarking), and that a final marking is declared (PetriRefusal::MissingFinalMarking). It does not check soundness, safeness, or boundedness — those graduate to wasm4pm.

use wasm4pm_compat::petri::{WfNet, PetriNet, Place, Transition, Arc, Marking, PetriRefusal};
// Initial marking is empty -> MissingInitialMarking.
let net = PetriNet::new(
    [Place::new("src"), Place::new("snk")],
    [Transition::new("t", "a")],
    [Arc::place_to_transition("src", "t"), Arc::transition_to_place("t", "snk")],
    Marking::empty(),
);
let wf = WfNet::new(net, Marking::new([("snk".to_string(), 1)]));
assert_eq!(wf.validate(), Err(PetriRefusal::MissingInitialMarking));
Source

pub fn claim_sound(self) -> WfNet<SoundnessClaimed>

Re-type this WF-net as carrying a soundness claim (unproven here).

This is a type-level re-tagging only — it computes nothing. Use it to record that an upstream source asserts soundness; discharge the claim by graduating to wasm4pm and witnessing it.

use wasm4pm_compat::petri::{WfNet, PetriNet, Marking, SoundnessClaimed};
let wf = WfNet::new(PetriNet::default(), Marking::new([("snk".to_string(), 1)]));
let _claimed: WfNet<SoundnessClaimed> = wf.claim_sound();

Trait Implementations§

Source§

impl<S: Clone> Clone for WfNet<S>

Source§

fn clone(&self) -> WfNet<S>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<S: Debug> Debug for WfNet<S>

Source§

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

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

impl<S: Eq> Eq for WfNet<S>

Source§

impl<S: PartialEq> PartialEq for WfNet<S>

Source§

fn eq(&self, other: &WfNet<S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S> StructuralPartialEq for WfNet<S>

Auto Trait Implementations§

§

impl<S> Freeze for WfNet<S>

§

impl<S> RefUnwindSafe for WfNet<S>
where S: RefUnwindSafe,

§

impl<S> Send for WfNet<S>
where S: Send,

§

impl<S> Sync for WfNet<S>
where S: Sync,

§

impl<S> Unpin for WfNet<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for WfNet<S>

§

impl<S> UnwindSafe for WfNet<S>
where S: UnwindSafe,

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> EvidenceKind for T

Source§

default fn kind_label(&self) -> &'static str

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.