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>
impl WfNet<SoundnessUnknown>
Sourcepub fn new(net: PetriNet, final_marking: Marking) -> Self
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>
impl<S> WfNet<S>
Sourcepub fn final_marking(&self) -> Option<&Marking>
pub fn final_marking(&self) -> Option<&Marking>
The final marking, if declared.
Sourcepub fn validate(&self) -> Result<(), PetriRefusal>
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));Sourcepub fn claim_sound(self) -> WfNet<SoundnessClaimed>
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();