💾 Archived View for siiky.srht.site › wiki › wp.statebox.mathematical_specification_statebox_languag… captured on 2024-08-25 at 00:20:17. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-03-21)

-=-=-=-=-=-=-

Statebox, "The Mathematical Specification of the Statebox Language"

siiky

2023/10/10

2023/10/10

2024/03/10

whitepaper,petri_nets,mathematics

https://doi.org/10.48550/arXiv.1906.07629

My first venture intro Petri nets.

Errors

p12, "We will often denote with T_N, P_N, (...) the set of places, transitions (...)", order of T_N and P_N is flipped.

p13, "(...) if and only if in any input place for =t= (...)", should be "all"

p22, "not the right place for an in-dept exposition"

p28, Fig3.3, (b) =id_B * lambda_A= on the right of the diagram should be =id_A * lambda_B= instead.

p37-38, Def3.6.7, Fig3.13a, the description and the diagram don't match? Def3.6.7 is probably the one needing an adjustment, since the examples and remarks following the figure match the figure.

p44, Def4.2.5, "A morphism of Petri nets M → N", should be "N → M".

p48, Fig4.6, mentions *Fig4.3* but it should be *Fig4.1*?

p52, Def4.5.1, s/occurrencies/occurrences/

p53, "This is again related to the fact that a Petri net carries less information that its corresponding FSSMC, (...)", "that" should be "than".

p55, "It is clear then than even if (...)", s/than/that/

p57, "Clearly, the fact that any net can now fire (...)", s/net/transition/ ?

p62, "(...) mapping from the net execution to the actual code takes care of (...)", s/code/& that/

Improvements

p15, Eg2.4.2, "(...) as in the figure above, (...)" The figure is in the following page.

p16, Def2.5.1, transition notation is different from Def2.3.7.

Questions

p14, Def2.3.7, "Figure 2.5 is an example of this, where °(t)_N ∧ (t)°_N is non-empty." Intersection of multisets is not defined (that I've seen).

p16, Def2.5.3, a net in a certain state is considered deadlocked even if a deadlock state isn't inevitable to be reached? (Not reachable, but reached)

p17, Def2.5.5, what does "can never fire" mean? There's no reachable state where the transition is enabled? And why is there a need for an intermediary state Y in the definition of "alive"? Isn't "Z reachable from X where the transition is enabled" enough? Doesn't "there is a firing sequence that, from Y, leads to a marking Z" mean the same as "Z is reachable from Y"?

p17, Rem2.5.6, "(...) it is trivial to prove that an alive Petri net is not deadlocked, and that every transition will always be enabled in the future (...)". Why? Isn't the net from Fig2.6 alive? Eventually, all transitions become dead (and so does the net).

p18-19, how to represent multiplicities of arcs other than 1?

p37, how do pushouts and coproducts differ?

p62, what do they meant with "we cannot concatenate tokens or perform any sort of list operation on them", refering to [Int]?

Petri Nets

Informal definition

Petri nets are composed of /places/, /transitions/, and /arcs/ (weighted on natural numbers). Places contain any number of /tokens/ (representing resources). Transitions are connected to places through arcs and can transform resources into other resources (this "transformation" is called /firing/).

A transition may be in one of two "states":

E.g.: If a transition has 2 incoming arcs of weight 2 and 3, then the corresponding places of each of the arcs must have at least 2 and 3 tokens, respectively.

-----

This is just one of the possible behaviours for preti nets, however, these constraints help studying the system as a whole with regards to reachability, existence or not of deadlocks, &c. More on how to improve/generalize this theory later.

Multisets

Multisets will be formalized as functions =X_S^{N_0} : S -> N_0= (=X= is the notation meaning "multiset of S"). Subsets of =S= are functions =S -> 2=. The /powermultiset/ of =S= is written as =S^+= (a circled plus sign) and is simply the set of =X_S^{N_0}(s)>0= with a finite number of =s= in =S=.

Squared =U= will be used for the disjoint union.

-----

Formal definition

A Petri net =N= is a quadruple =(P_N, T_N, °(-)_N, (-)°_N)=:

=°(t)_N(p)= is the weight of place =p= going into transition =t= -- input weight; =(t)°_N(p)= is the weight of place =p= coming out of transition =t= -- output weight.

As mentioned later on *Def2.3.7*, =°(-)_N= and =(-)°_N= needn't be disjunctive, that is, a place may be simultaneously an input and an output place of a transition.

Markings

/Markings/ are the (so called) "states" of a Petri net, that is, the number of tokens currently in each place: =X_{P_N}^{N_0}=.

Firing

Examples

(1) e.g., if transitions =t1= and =t2= have both a single input of 1 token from the same place, and that place a single token in it, then both transitions are enabled, but they can't fire simultaneously.

Reachability, safety, deadlocks

So a net is considered deadlocked even if the deadlock state isn't for sure to be reached? E.g., if it is possible to reach =Y= and =Z= from =X=, such that =Y= never reaches a deadlock state, but =Z= is a deadlock state (or it is certain to lead to a deadlock state), then =X= is considered deadlocked?

A net in a certain state is said to be alive if all its transitions are alive. In other words, when a net is alive in a certain state, all its transitions can (inevitably) eventually fire (in some future state).

An alive transition may become dead, that is, being alive doesn't guarantee that it will /always/ eventually be enabled (see the following remark).

state =X=, but after =X --t-> Y=, on =Y= it becomes dead.

Implementation

GreatSPN

Why is this useful?

Behavioral Programming with Petri Nets à la Functional Way -- Smart Contracts

Category Theory

What is category theory?

References [[id:56c62b63-739f-43d1-a5f7-afa4119cc425][/Mathematics: Form and Function/, Saunders MacLane]].

Mentions /compositionality/.

References [[id:570ea143-65ce-4e14-a713-e7ef5b450e5a][/Categories for the Working Mathematician/, Saunders MacLane]].

Class

Functors, natural transformations, natural isomorphisms

Monoidal categories

Mentions [[id:82994ef9-43fe-4437-be77-52ccb2b4e1ba][/Picturing Quantum Processes/, Bob Coecke, Aleks Kissinger]].

Mentions [[id:9c2f7406-83e7-4f7a-8d96-14d942157c3f][/A Survey of Graphical Languages for Monoidal Categories/, Bob Coecke]].

Monoidal functors

Products, coproducts, pushouts

Executions of Petri nets

Problem overview

Distinguishing between tokens becomes important, since different tokens will be processed differently by transitions.

The category Petri

The Execution of a net

Markings are represented by the product of places of the net.

Free strict symmetric monoidal categories (FSSMCs)

Thinking of =S= as the set of places of a net, =S^*= are the objects of =C=.

Notes that Categories require the identity morphisms and associativity of composition, but requiring isn't the same as guaranteeing, and so *Axioms (4.3)* are there to provide for them.

The categories =F(N)= and =U(C)=

Functors between executions

There is no general functorial definition for functors from Petri net morphisms to generator-preserving functor(?).

Lack of functoriality is not the end of the world

The fact established in the previous section is not such a big deal when the intent is to implement a programming language. Argues that the fact that FSSMCs use strings as part of their definition is actually a win for programming language implementers, the reason being that, historically, strings (sequences of elements, i.e., arrays) are one of the basic data structures available in programming languages.

This "manipulating strings is way easier than manipulating multisets" argument is doubtful...

Beyond standard Petri nets

Discusses slightly different Petri nets, such as /integer Petri nets/, where tokens may negative. Mentions /Executions in (Semi-)Integer Petri Nets are Compact Closed Categories/ and /Generalized Petri Nets/.

Briefly discusses how integer Petri nets may be used to represent (real) distributed behaviour with a simple example (*Fig4.10*): two entities (connected through the internet) choose simultaneously to fire a transition, that wouldn't be possible in a standard Petri net, were both transitions fired sequentially.

Also gives the idea that integer Petri nets may be used to represent faulty subnets of the system (i.e., bugs).

Also, the two events (users) think they fired first (because otherwise the one that fired second wouldn't have fired at all!). This is another conflict. While the network sequence of firings can be reconstructed with cup&cap if one knows the (absolute) real-world sequence of firings, each independent event (user) can't, because their (relative) real-world times differ.

Mentions /On the Category of Petri Net Computations/, [[id:96d36d95-0dc6-4f3b-a066-d3e03bbd0586][/Compositional Game Theory/]], and /Representations of Petri Net Interactions/.

Implementation

They're using (still? or has this changed in the meantime?) Idris to build the formal basis of the project. Specifically, they're using =idris-ct= as a start.

Why is this useful?

They present the "traditional" way of using Petri nets: model the system as a Petri net and verify the needed/desired properties; manually convert the net into code. This approach has at least a couple of problems: for one, Petri nets are only used as modelling tool, not a programming one; the manual Petri net to code conversion is error prone, which could lead to bugs.

They seem to imply that Statebox is looking to do things differently. Are they?

Folds

Problem Overview

In *Eg5.1.1* and *Eg5.1.2* presents the "problem", and an argument in favor of, of Petri nets not being able to represent algorithms in general (quicksort specifically in the examples). The counterargument by Statebox is "the right tool for the job": Petri nets could be used to specify more of the behaviour of an algorithm such as quicksort, but it's not their strong point. On top of that, many correct and performant implementations of these algorithms (such as quicksort) already exist, so writing them with Petri nets wouldn't be a good use of someone's time.

This seems to support my supposition that they seemed to imply that they don't mean to make yet another modelling tool but a real programming language based on Petri nets.

Mapping executions

They describe a Petri net as "infrastructure" in *Eg5.2.1*.

Different folds, shared types

Brings up the idea of subnets in folds, or composition of nets.

Why is this useful?

Mentions [[id:dbf1e72e-2acc-4c40-98c7-6c22512dc534][Typedefs]].