<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Fabrizio Romano Genovese on Medium]]></title>
        <description><![CDATA[Stories by Fabrizio Romano Genovese on Medium]]></description>
        <link>https://medium.com/@fabrizio_99052?source=rss-738685c5aba7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*d5UPRXzKSGYcDIqW</url>
            <title>Stories by Fabrizio Romano Genovese on Medium</title>
            <link>https://medium.com/@fabrizio_99052?source=rss-738685c5aba7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 16:52:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@fabrizio_99052/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[FSM-Oracle Release]]></title>
            <link>https://medium.com/statebox/fsm-oracle-release-235e04a156ae?source=rss-738685c5aba7------2</link>
            <guid isPermaLink="false">https://medium.com/p/235e04a156ae</guid>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[petri-nets]]></category>
            <category><![CDATA[finite-state-machine]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[category-theory]]></category>
            <dc:creator><![CDATA[Fabrizio Romano Genovese]]></dc:creator>
            <pubDate>Wed, 29 Apr 2020 12:07:36 GMT</pubDate>
            <atom:updated>2020-04-29T12:07:36.610Z</atom:updated>
            <content:encoded><![CDATA[<p>Hoping this blogpost finds you all well and without any further ado, we’d like to announce a very important release for Statebox: <a href="https://github.com/statebox/fsm-oracle">the finite state machine oracle</a>.</p><p>A considerable amount of time has been spent on both research (more amazing stuff about this will follow in the coming months) and on formalizing a formally verified version of our <a href="https://github.com/statebox/idris-fsm-oracle">core</a> in Idris, which in turn has been implemented by many people from our team (mainly Sjoerd, Alex and Andre, which I thank for the incredible work!).</p><h4>What does it do?</h4><p>Now that we have a version of the core released, I’d like to explain what it does. The idea is simple:<em> You pass it a specification for a finite state machine/Petri net, an initial state and a sequence of actions, and the core will tell you if that sequence of actions is valid.</em></p><p>I know what you are thinking: “Wait what? You spent more than a year to get this?!” The short answer is “Yes, we have.” The long answer is “We decided to make an investment, and spent a lot of time developing our basic infrastructure so that building incrementally on it would be much easier later on”. An even better answer is: “Try it out yourself!”. In any case, with this post, I hope to convince you this choice is not as abysmally dumb as it sounds, but quite the opposite.</p><h4>Typedefs and Typed Core</h4><p>Several years ago we started two big projects at Statebox, namely <a href="https://github.com/typedefs">Typedefs</a> and Typed Core. <em>Typedefs is a formally verified programming language for types and terms. </em>Essentially, it allows to specify a universal format for types that can be recursively built out of type variables, products, coproducts and fixed point operators, and for their terms. Given Typedefs and their terms, one is able to automatically serialize and deserialize them to various formats, such as binary, S-expressions and JSON. This allows for a formally well-defined way of exchanging data between different programming languages.</p><p>On the other hand, <em>typed core is a formally verified implementation of the main engine that tells us if a given sequence of transitions fired in a Petri net is valid or not.</em> This is done in Idris, and relies on <a href="http://github.com/statebox/idris-ct/">idris-ct</a>, our formally verified category theory library.</p><p>Getting these two projects up to a point where they could be useful has been a lot of work, but it pays off! <em>Now, we can just define our categories effortlessly using idris-ct, and import/export their signatures and morphisms using Typedefs.</em></p><p>This is exactly what we did in our first version of the core, which we completed roughly a month ago. In it, the user is able to feed the core with a specification for a finite state machine, an initial state and a sequence of actions, specified as a path in the underlying FSM graph. This specification is exchanged using JSON, as in the following example:</p><pre>{<br>  &quot;_0&quot;: {<br>    &quot;_0&quot;: 5,<br>    &quot;_1&quot;: [<br>      {<br>       &quot;input&quot;: 1,<br>       &quot;output&quot;: 1<br>      },<br>      {<br>       &quot;input&quot;: 3,<br>       &quot;output&quot;: 4<br>      },<br>      {<br>       &quot;input&quot;: 2,<br>       &quot;output&quot;: 1<br>      },<br>      {<br>       &quot;input&quot;: 3,<br>       &quot;output&quot;: 2<br>      }]<br>  },<br>  &quot;_1&quot;: 3,<br>  &quot;_2&quot;: [3, 2, 0]<br>}</pre><p>Here, the first field specifies the “shape” of the FSM:</p><pre>&quot;_0&quot;: 5,<br>    &quot;_1&quot;: [<br>      {<br>       &quot;input&quot;: 1,<br>       &quot;output&quot;: 1<br>      },<br>      {<br>       &quot;input&quot;: 3,<br>       &quot;output&quot;: 4<br>      },<br>      {<br>       &quot;input&quot;: 2,<br>       &quot;output&quot;: 1<br>      },<br>      {<br>       &quot;input&quot;: 3,<br>       &quot;output&quot;: 2<br>      }]</pre><p>The first field tells us that the FSM has five vertexes, indexed 0, 1, 2, 3, 4 . The second field specifies the edges, indexed 0,1,2,3: The first edge goes from 1 to 1 , the second from 3 to 4 , the third from 2 to 1, the fourth from 3 to 2. All in all, the FSM looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*Wk_s2aYRuuNwQmyFtKHOVw.png" /></figure><p>Then we have:</p><pre>  &quot;_1&quot;: 3,<br>  &quot;_2&quot;: [3, 2, 0]</pre><p>Here the first field specifies the initial state (start from vertex 3), while the second one specifies a path, in this case (go through edge 3, then through edge 2, then through 0 ). The path is the one displayed below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/1*9EN7viUl-HmU43BO2ssYsg.png" /></figure><p>The point is that this JSON format is not arbitrary; it is the encoding of a Typedefs term. So if the term is malformed for whatever reason, Typedefs will throw an error automatically. We do not have to worry anymore about our parser being correct, because it is generated automatically from our definition!</p><p>Internally, a correct FSM specification is used as the signature to build the free category associated to it. Then, the path is evaluated: Either it forms a valid morphism or it doesn’t. If it doesn’t then we throw an error, if it does we check that the domain of such morphism is indeed the initial state specified. If this is the case we return a positive answer. In any case, the answer is again returned as a Typedefs term, and as such can be easily exchanged around.</p><blockquote>All in all, our software works like an oracle. The cool thing is that we can be very flexible about the types we use to exchange computational objects around since TDefs will take care of serialization and parsing for us. Moreover, we are using categorical constructions as typecheckers, and not some ad-hoc thing.</blockquote><p>The advantages of this approach are considerable. Less than two weeks ago we started working on the Petri net version of this, which amounts to taking symmetric strict monoidal categories as our typecheckers. We had already implemented those in idris-ct, and hence we were able to finish our work almost instantly. <strong>With an amount of minimal tweaking, we were able to recast our infrastructure completely to deal with Petri nets</strong>. Indeed, we are now in the process of documenting the new version of the core, which we will likely release in the coming months.</p><p>I hope that the advantages of employing categorical methods are now clear. It’s a lot of hassle in the beginning, but then things become way easier since in category theory everything is defined “canonically”, meaning that there is often just one way to do things, which is also the right one if you worked on the foundations of your project well enough.</p><p>Feel free to <a href="https://github.com/statebox/fsm-oracle/">play with the oracle we released</a>, and stay tuned for the new version that we’ll release soon!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=235e04a156ae" width="1" height="1" alt=""><hr><p><a href="https://medium.com/statebox/fsm-oracle-release-235e04a156ae">FSM-Oracle Release</a> was originally published in <a href="https://medium.com/statebox">Statebox</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Abstraction is the New Gold]]></title>
            <link>https://medium.com/statebox/abstraction-is-the-new-gold-40cb343f156e?source=rss-738685c5aba7------2</link>
            <guid isPermaLink="false">https://medium.com/p/40cb343f156e</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[category-theory]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Fabrizio Romano Genovese]]></dc:creator>
            <pubDate>Mon, 13 Jan 2020 12:00:39 GMT</pubDate>
            <atom:updated>2020-01-13T12:00:39.664Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*xCmHSDsAh8-7Xccc05IPKQ.png" /><figcaption><a href="https://ykode.id/making-sense-of-category-theory-6f901e39fa3c">https://ykode.id/making-sense-of-category-theory-6f901e39fa3c</a></figcaption></figure><p>As our dear readers widely know, Statebox is a company that heavily relies on category theory for the development of its products. Attention towards category theory by academia is not at all surprising. Applied category theory has become a fertile research field, as reflected by the several conferences and events which emerged in the past few years, such as <a href="https://www.appliedcategorytheory.org/">the yearly applied category theory conference (ACT)</a> or <a href="https://summit.statebox.org/">our own yearly summit</a>.</p><p>On the other hand, the enterprise sector seems to get increasingly aware of how categorical reasoning could impact their own future. In many niches of the tech space, there is a pervasive feeling that we finally possess the right formal tools to apply compositional techniques (that is, ACT) in a widespread fashion. Some companies are understanding this at a naïve level, and are reacting by, say, increasingly adopting functional programming languages for the development of their product stack. Other companies are instead fully aware of this, and are actively setting up research efforts in applied category theory.</p><h3>How category theory can help your company</h3><p>In <a href="https://www.cambridge.org/core/books/an-invitation-to-applied-category-theory/D4C5E5C2B019B2F9B8CE9A4E9E84D6BC">An Invitation to Applied Category Theory</a>, Fong and Spivak introduce their topic as follows:</p><blockquote>It is unmatched in its ability to organize and layer abstractions, to find commonalities between structures of all sorts.</blockquote><p>To give you an intuitive feeling of how category theory can impact company life, think about the following:</p><ul><li>at a high and abstract level, business is about connecting different ideas and crunching numbers to see how these ideas perform and become profitable;</li><li>programming is about connecting different pieces of software in a manner that will minimise generative effects, or as we like to call it, emergent behavior;</li><li>production and planning is about connecting different facts (e.g. travelling time and price from A to B) while keeping an eye on optimization.</li></ul><p>In all these examples, the idea of “connecting things to other things” is preeminent. <strong>Category theory provides a universal language to reason about these relationships.</strong> Now business planning and programming become just two different incarnations of the same underlying idea. Moreover, the use of functors (which are ways to map things to other things while preserving their connections) makes the unthinkable possible, e.g. <em>by mapping business workflows directly into code</em>. This is precisely what we are working on at <a href="https://statebox.org/">Statebox</a>, and you can see a minimal application of this in our video series about <a href="https://www.youtube.com/watch?v=hxEwmBQTQuI">designing smart contracts with Petri nets</a>.</p><h3>Do you need to be a mathematician to learn category theory?</h3><p>This is the most popular myth surrounding category theory adoption and we are here to bust it. Unfortunately, as all things when seen from the outside world, the ideas behind category theory can feel obscure and complicated. In addition to this, people seem to believe that you have to already know a lot of mathematics to get category theory right. This is clearly false, but such prejudice is reinforced by the fact that nearly all of the free learning material on the internet is directed at mathematicians, physicists and computer scientists.</p><h3>Too hard, won’t bother</h3><p>But how hard is it to learn category theory? In my experience as a category theory teacher, I’ve noticed that people tend to naturally think in compositional terms, but somehow they forget about it when they are taught other things. For this reason, learning category theory requires a shift in point of view that, once started, feels more as a re-discovery than as something new. This is confirmed by my own experience as a category theory student. When I myself had to learn category theory, I found out that the cause of my struggle was trying to understand category theory with the tools I had already acquired, instead of just starting from scratch. When things started clicking, I realized that category theory is, by definition, the most natural way to reason about and model systems. From this point of view it is evident that category theory is not difficult to learn, since its working principles are, most often than not, already well understood by its learners, who simply are not yet aware of this.</p><h3>Category Theory Course — March, Berlin</h3><p>For the above reasons and more, we decided to launch <a href="https://training.statebox.org/">a category theory course</a> aimed at programmers, system architects and businesses in general. We already have experience in teaching category theory to non mathematicians and we believe the best way to teach it is through examples tailored on the knowledge of the learners. In our course, we carefully evaluate the needs of our clients and their skillset, and figure out the most frictionless way to initiate your journey into categorical thinking.</p><p>The aim of our course is to provide a base layer of understanding of the main topics in ACT and show how they can be used to model systems. Then, you will be able to either deepen your knowledge by yourself by accessing previously unmanageable learning material on the internet or to interact with expert category theorists in the ACT community. You will be able to understand the category theory jargon, and <em>this will endow you with a universal language that facilitates the understanding of current research in the field as well as form abstractions and find similarities in seemingly unfamiliar spheres</em>. We truly believe that this opens the door to offering unique solutions to problem solving, regardless of the domain you find yourself in.</p><p>Join our category theory course on 24–27 March in Berlin. The course will be taught by yours truly with the support of at least one other guest category theorist from the ACT community. <a href="https://training.statebox.org/berlin.html">Sign up here</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40cb343f156e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/statebox/abstraction-is-the-new-gold-40cb343f156e">Abstraction is the New Gold</a> was originally published in <a href="https://medium.com/statebox">Statebox</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Behavioral Programming with Petri Nets à la Functional Way — Smart Contracts!]]></title>
            <link>https://medium.com/statebox/behavioral-programming-with-petri-nets-%C3%A0-la-functional-way-smart-contracts-96d801cef8cc?source=rss-738685c5aba7------2</link>
            <guid isPermaLink="false">https://medium.com/p/96d801cef8cc</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[petri]]></category>
            <category><![CDATA[behavioral-programming]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Fabrizio Romano Genovese]]></dc:creator>
            <pubDate>Fri, 15 Feb 2019 12:25:09 GMT</pubDate>
            <atom:updated>2019-02-15T12:39:36.437Z</atom:updated>
            <content:encoded><![CDATA[<h3>Behavioral Programming with Petri Nets à la Functional Way — Smart Contracts</h3><p>Hello everyone! As promised, this post continues the story about behavioral programming done with Petri nets. In the <a href="https://blog.statebox.org/behavioral-programming-with-petri-nets-%C3%A0-la-functional-way-a56e9a5bb06e">last post</a>, we modeled the dining philosophers problem to highlight how and why behavioral programming can be useful. In this blogpost we focus on modeling a smart contract using Petri net. For the video explanation, click below.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FhxEwmBQTQuI%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DhxEwmBQTQuI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FhxEwmBQTQuI%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6e975be5a7326b0c02a43991532e289f/href">https://medium.com/media/6e975be5a7326b0c02a43991532e289f/href</a></iframe><p>The net we drafted this time describes the behavior of a putative smart contract for online gambling. The kind of gambling game we want to describe is a rather simple one, like roulette or dices. We start by making the following assumptions:</p><ul><li>The player plays against the casino, as in a game of roulette.</li><li>The player can bet only once per game;</li><li>A certain amount of randomness is needed to establish if the player wins or loses.</li></ul><p>We drew inspiration from an already popular and deployed gaming platform on Ethereum, <a href="https://etheroll.com/">Etheroll</a>. In Etheroll, as the name suggests, you essentially make a bet, “roll” an imaginary dice and either win or lose. The smart contract describes the behavior of the game and how bets are handled is a clear use case for behavioral programming. We want to be certain that the contract satisfies certain properties, such as:</p><ul><li>ensure that the game is provably fair</li><li>guarantee that we will always be able to pay bets back without going bankrupt.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TgI-V1Yy538-5mEY-Hazig.png" /><figcaption>Initial draft of the smart contract process</figcaption></figure><p>The process starts with the transition highlighted in red, “Place bet”: It is the player that fires it, when a bet is placed. Then, the first thing that the contract does is query its current balance and establish if the bet can be covered or not (namely: would we end up being bankrupt if the player were to win?). If the bet cannot be covered, the contract gives the money back to the player, which is represented by the “Pay back” transition highlighted in green.</p><p>If the bet can instead be covered, the contract needs to get some random numbers to determine if the player wins or loses. Random number generation is a rather hard problem for Ethereum and blockchains in general, and diving into it is not in the scope of this post. To make things smooth, we just supposed that we can outsource the random number generation process by querying an oracle. Notice that this is not a crazy assumption since companies providing exactly this kind of services are already operating on Ethereum.</p><p>An oracle is fundamentally a smart contract which, when queried, produces a random number. We also expect this random number to come with some sort of proof of integrity that the random generation process has not been tampered with.</p><p>Firstly, our casino contract checks that we defined an address for the oracle. If this is not the case the query cannot be performed and so the process has to abort (which again means that the player gets the money back). This is implemented by falling back again to the red “Pay back” transition.</p><p>If on the other hand the oracle address is defined, we proceed by calculating the oracle fee. This is because the oracle represents a third party service and we are not expecting it to work for free. So we calculate how much money we have to give to the oracle, and we forward a request. Now three things can happen:</p><ul><li>The oracle doesn’t answer.</li><li>The oracle does answer, by firing the purple “Oracle Callback” transition. We get a random number back but the integrity proof doesn’t check out.</li><li>The oracle does answer, by firing the purple “Oracle Callback” transition. We get a random number back and we are satisfied with the proof.</li></ul><p>The third case is clearly the easiest one: We just use the number to calculate the outcome of the bet and we pay the user back.</p><p>In the other two cases, we resort to some alternatives: The second case is handled with a fallback strategy (e.g. we could just ignore the proof and keep going), while the first case can either be handled by trying to query the oracle again or by switching to a different random source (e.g. by using block numbers as entropy. Please, if you are really trying to set up an online casino <a href="https://ethereum.stackexchange.com/questions/62888/generating-random-numbers-in-solidity-based-on-block-hash">don’t do this</a>!).</p><p>So, this is our contract draft. At a first glance, it seems legit, right? No! It has all sorts of problems, which luckily enough we can formally spot. For instance, “Can Cover” produces two tokens in two different places, while “Address Undefined” just processes one of them. This means that the net can be driven to a situation where the output place of “Can Cover” on the right becomes unbounded, accumulating an infinite number of tokens which will be stuck forever. This situation is shown in the picture below, and it is ultimately a consequence of the fact that “Place Bet”, “Retry” and “Can Cover” all produce two tokens in two different places, leading to an unnecessary level of concurrency for this application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7DqZszdETGNwIsPugIJb7g.png" /><figcaption>Spotting problems with the initial draft</figcaption></figure><p>Another problem is that we estimate a bet can be covered but we didn’t specify the corresponding amount of money on the side while the outcome gets calculated. So, if one hundred high bets come in at the same time, and we estimate that we can separately cover all of them, we may nevertheless end up broke if they are all winning.</p><p>Well, so what’s the point? The point is that we have been able to spot these sort of problems <em>without writing one line of code. </em>This is where Statebox shines: <strong>We can spend time to refine our casino process before starting with the actual implementation, that will be formally driven by the Statebox compiler from the net to EVM code.</strong></p><p>Note moreover how we are able to have a <em>high-level overview</em> of who-gets-to-call-what in the contract: “Oracle Callback” can be called only by the Oracle contract, while “Place Bet” is an external call. All the other transitions are internal, meaning that they get to be fired by the contract itself. <em>This helps us understand how to define the interaction that the contract has with the “external world”.</em></p><p>Congrats for reading up to here! What follows is not covered in our video. Let’s continue by updating our contract taking all the above considerations into account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fFWUbalwIFdl30HgEW2DWw.png" /><figcaption>Refined smart contract process</figcaption></figure><p>As you can see many things have changed. First, so many colors! As before, we marked <strong>in red the transitions fired by the player</strong>, and <strong>in purple the ones fired by the oracle</strong>. <strong>Green transitions are now interpreted as “final”, representing when the process comes to an end</strong>. Moreover, <strong>we used blue to highlight transitions that send money out</strong>. Note how green transitions and blue ones coincided in the previous version of the contract.</p><p>Let’s spell this process out. The first thing we do when a bet comes is <strong>lock the bet money up</strong> via “Lock Bet Money”. Now, in case another bet comes in, the inbound money from the first bet won’t be used in the calculations of the second. This is part of the fix for the “putting money on the side” issue we highlighted above.</p><p>After, we calculate the free balance (that is, the amount of free money we can allocate to bets) and the fee needed to pay the oracle. If we determine that we can indeed cover our costs, we <strong>lock that money up </strong>via “Lock Win Money”. This is again to be sure that even if other bets alter the overall balance of the contract, this won’t affect the bet we are processing now.</p><p>In the new contract, moreover, we subtract the fee to the locked up money via “Subtract Fee To Win Money”. Note how this happens <strong>after</strong> the oracle request — along with the money to pay the fee — is sent.</p><p>Most notably, we introduced new, but similar transitions: “Free Win Money 1”, “Free Win Money 2” and “Free Win Money 3”. These are deputed to free the locked up money needed to pay the player in case of victory. <em>Using Statebox, these transitions will be all mapped to the same function, so you won’t have to type it over two times</em>. Nevertheless, they are different transitions in the net. <strong>This shows how in behavioral programming functions cannot be considered equal just by looking at the computation they perform: The context in which they are used also matters!</strong></p><p>Has the smart contract example helped with your understanding of how Statebox works? Feel free to leave a comment below. More examples will follow in the next weeks, so stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96d801cef8cc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/statebox/behavioral-programming-with-petri-nets-%C3%A0-la-functional-way-smart-contracts-96d801cef8cc">Behavioral Programming with Petri Nets à la Functional Way — Smart Contracts!</a> was originally published in <a href="https://medium.com/statebox">Statebox</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Behavioral Programming with Petri Nets à la Functional Way]]></title>
            <link>https://medium.com/statebox/behavioral-programming-with-petri-nets-%C3%A0-la-functional-way-a56e9a5bb06e?source=rss-738685c5aba7------2</link>
            <guid isPermaLink="false">https://medium.com/p/a56e9a5bb06e</guid>
            <category><![CDATA[petri]]></category>
            <category><![CDATA[visual-programming]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Fabrizio Romano Genovese]]></dc:creator>
            <pubDate>Thu, 31 Jan 2019 16:19:00 GMT</pubDate>
            <atom:updated>2019-02-15T13:23:11.523Z</atom:updated>
            <content:encoded><![CDATA[<h3>Behavioral Programming with Petri Nets</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*ZwLugfXHwyrrGecTad_ICg.png" /><figcaption>Image by <a href="https://www.inprnt.com/gallery/djdarnault/">Dustin d’Arnault</a></figcaption></figure><h3>À la functional way, through examples</h3><p>The Statebox language has come a long way in the past year, and so it’s time to illustrate how programming using Statebox works. Sure, the <a href="https://statebox.org/research/2018-07-22-monograph.html">monograph</a> details the mathematics behind Statebox but how do you actually use it?</p><p>Our codebase will soon be made public for everyone to read, but this is very different from making developers understand how Statebox can be useful in their everyday life. We felt we needed a series of tutorials worked out by means of examples, not only to document the use of Statebox per sé but also to teach the ways of what we call <strong>behavioral programming</strong>.</p><p>…And so we did! Lately we filmed a series of short videos explaining how to use Petri nets to design software. This series of blogposts will serve as a (not too verbose) addendum to better understand what’s going on in the videos.</p><h4>What is behavioral programming?</h4><p>Let’s start by clarifying what behavioral programming means using comparisons. In <strong>imperative programming</strong>, you think in terms of instructions, by literally giving to the computer a list of things to do. In <strong>functional programming</strong> you think functions, which then you pipe together to get the job done. In <strong>event-driven programming</strong>, you think in terms of things that can happen (events) and how to react to them. In <strong>behavioral programming</strong>, as the name suggests, you must think in terms of which properties (behavior) you want your software to have. In this sense, programming becomes <strong>goal-oriented</strong>, and starts with a high-level sketch of the software structure.</p><p>Throughout this tutorial, we will borrow the mantra of <a href="https://www.manning.com/books/type-driven-development-with-idris">type-driven development with Idris</a>, a great and very inspiring book by Edwin Brady: The mantra is <em>type, define, refine</em>. In our context, this means that we will start sketching the code structure, we will test for its behavior and then we will refine it so that it meets our goals.</p><p>We will start with a computer science classic originally proposed by Dijkstra in 1965, namely the <a href="https://en.wikipedia.org/wiki/Dining_philosophers_problem">dining philosophers problem</a>. Our related video is <a href="https://www.youtube.com/watch?v=iQVgyzgSUYM&amp;list=PLE2y3n8EQ6VzX28LQ9lVY1iVs3bsv6Qg5&amp;index=1">this one</a>.</p><p>It goes like this: You have four philosophers at a table which can either think or eat. The catch is that they have to share cutlery, and coordinate between them about this. Translating this to a real-world scenario, we can think about philosophers and cutlery in terms of <strong>processes</strong> and <strong>resources</strong> to be shared, respectively. The point about this example is that one has to be clever about refining access to resources to avoid a total mess. Indeed, in the video we give some resource-access rules that will turn out to be a recipe for disaster. The rules are as follows:</p><ul><li>In the beginning, all philosophers are thinking.</li><li>A philosopher wanting to eat will have to <strong>first</strong> take the cutlery piece on their left and <strong>then</strong> the cutlery piece on their right. <strong>Eating is not possible without having both cutlery pieces.</strong></li><li>After a philosopher finishes eating, the cutlery pieces must be put back on the table.</li><li>There are no other rules.</li></ul><p>Forgetting for a second about the fact that these people are sharing cutlery while eating (groooooss!!!), you can see what the problem is here: <strong>It is possible that all philosophers try to eat at the same time and that all of them end up having only one cutlery piece.</strong> Since we defined no rules for this circumstance, <strong>the process will inevitably jam</strong>: Each philosopher cannot put the cutlery down, since this can be done <strong>only</strong> when finished eating. On the other hand, a philosopher needs <strong>two</strong> cutlery pieces to eat which is not possible since they are all taken. Boom!</p><p>We start by showing how this problem can be modelled using <strong>Petri nets</strong>, the fundamental ingredient in the Statebox secret sauce. This is done in <a href="https://www.youtube.com/watch?v=gom8qrOmBxo&amp;list=PLE2y3n8EQ6VzX28LQ9lVY1iVs3bsv6Qg5&amp;index=2">this video</a>.</p><p>Ok, so we started with a very simple and understandable problem, and we in turn defined an ugly and complicated net to model it. It doesn’t seem like we gained much, right? Wrong! We did! In fact:</p><ul><li>We modelled philosophers and cutlery using places and transitions in our net,<strong> which can now be whatever we want them to be</strong>: In the Statebox environment places are datatypes, tokens are data of the type of the place they live in, and transitions are functions. Of course, <strong>we are free to specify datatypes and functions at a later stage</strong>, while for now we are allowed to care only about the code structure. If you think along these lines, <strong>we abstracted a very specific problem into a very general one</strong>, which can then be tailored to our needs.</li><li>By modelling the problem with Petri nets, we automatically get access to a lot of analysis tools which can automatically spot how nice the behavior of the net is. In fact, the problem highlighted above of all philosophers having only one cutlery piece corresponds to a property of Petri nets called <strong>deadlock</strong>, to which we can test our net against! Indeed, if we run formal analysis on our net we will find out that it can deadlock. Not nice, right? Right! …But the good thing is that having an automated way to spot a mess in our code structure gives us the opportunity to fix it <strong>before putting a real work case into it</strong>.</li></ul><p>So, starting with a bad-behaved problem, we <em>defined</em> a bad-behaved net. At least, we now happily realize that we were able to spot a deadlock <strong>before writing a single line of code</strong>. We want now to <em>refine</em> the net and fix it. This is done in the <a href="https://www.youtube.com/watch?v=V73F3kDSkgs&amp;index=3&amp;list=PLE2y3n8EQ6VzX28LQ9lVY1iVs3bsv6Qg5">next video</a>.</p><p>This star shaped net is <strong>deadlock-free</strong>, a condition which we can again check formally. The way we fixed the problem is by modifying the rules so that philosophers wanting to eat first need to reserve both pieces of cutlery at their side, then pick them up. This is not the only way to solve the problem, but it’s probably the simplest one. You can check the <a href="https://en.wikipedia.org/wiki/Dining_philosophers_problem">dining philosophers problem’s Wikipedia page</a> if you are looking for a different solution. In fact, why don’t you try to model one of the alternative solutions using Petri nets yourself?</p><p>The crux of our solution lies in limiting the amount of concurrency allowed in the system. Sure, now things are a bit less independent and a bit less concurrent, but at least now they are <em>guaranteed to work</em>.</p><p>Hopefully, you now got the general idea behind Statebox programming: First, starting with a goal (modelling philosophers at a table), defining a net to capture the problem mechanics and refining it so that it follows a prescribed behavior. Then, mapping places and transitions to datatypes and functions to obtain code in its final form. Between each of these steps, a ton of formal tools can help us find the right path to the next one.</p><p>In the next post, we will leave the realm of theoretical computer science examples to turn at more practical ones, where we will use Petri nets to model the behavior of a smart contract. Stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a56e9a5bb06e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/statebox/behavioral-programming-with-petri-nets-%C3%A0-la-functional-way-a56e9a5bb06e">Behavioral Programming with Petri Nets à la Functional Way</a> was originally published in <a href="https://medium.com/statebox">Statebox</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The poetry of Blockchain — A celebration of lateral thinking]]></title>
            <link>https://medium.com/statebox/the-poetry-of-blockchain-a-celebration-of-lateral-thinking-ee43c6e261a6?source=rss-738685c5aba7------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee43c6e261a6</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[lateral-thinking]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[philosophy]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Fabrizio Romano Genovese]]></dc:creator>
            <pubDate>Fri, 04 Jan 2019 19:17:10 GMT</pubDate>
            <atom:updated>2019-01-04T19:17:10.461Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Poetry of Blockchain — A Celebration of Lateral Thinking</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Jg_SjW-hVD90u4CL2bUmQ.jpeg" /><figcaption>“The Alchemist Discovering Phosphorus, Joseph Wright of Derby,” Hallie Ford Museum of Art Exhibits, accessed January 3, 2019, <a href="http://lib-omeka.willamette.edu/hfma/omeka/items/show/244">http://lib-omeka.willamette.edu/hfma/omeka/items/show/244</a>.</figcaption></figure><p>I’ve always been into hacking since the late nineties, when being less than ten years old I casually discovered IRC. At that time, curiously browsing through IRC channels, an entire universe unrolled before my eyes, made of swirling stories of how, being clever enough, you could use computers to make them do things that they weren’t supposed to do.</p><p>I have to admit, I’ve never been a good hacker. Nevertheless this experience had, at least on me, an everlasting educational value: I learned the importance of lateral thinking and the fact that, just because something is made or sold to carry out predefined tasks, it doesn’t necessarily mean that those tasks are everything it can do. All in all, this is the underlying principle behind hacking: With enough work, experience and practice, you can bend things around you to fit your needs. This led me to the idea that computers weren’t just made to be used, but were also a mean to express myself, that I could use them to define my own ecosystem, that I hadn’t to necessarily live in someone else’s. Shortly after, I realized that this kind of reasoning applied also to mathematical models: They weren’t as dogmatic and inflexible as I had been taught at school, since the very own language of Mathematics allows for any sort of convenient modification of its structures to made them applicable in different contexts. Since then, I decided to dedicate my life to Mathematics, which is still what I basically do now at Statebox: In a way, one could say that hacking defined my entire way of living.</p><p>However, if you ask everyone that has been in the scene long enough, you will be told that now things are completely different. Surely, systems in the past were much, much simpler than they are now. To make a good hacker, this is fundamental: A simpler system can be better understood, and understanding things deeply is a key step to acquire the necessary skills to modify them according to one’s needs. Making meaningful and rewarding experiences on simpler systems allows novices to gradually venture towards more complicated ones, refining their skills little by little.</p><p>On the other hand, computer software today is incredibly complicated and overengineered. If, at least naively speaking, vulnerability of software tends to grow along with its complexity, it is also true that exploring it to spot said vulnerabilities becomes increasingly time consuming. This sets the bar high for novices, because it translates in the obvious fact that one needs to be quite skilled before any hacking experience will start bearing the first fruits. Moreover, the idea that “With enough work, experience and practice, you can bend things around you to fit your needs” has educational value only if things start bending — albeit just by a little — quite soon after you start working hard. This motivates people to stay focused on their progress and on their work. But if the amount of work you need to put in before you see the first results is huge, then you’ll probably lose motivation before you get there.</p><p>Another crucial difference is that, back in the days, one could learn the principles of computer and telecommunication hacking just by lurking on IRC, or via mailing lists. More importantly, the community was still small, and not really on anyone else’s radar. “Cyberwar” wasn’t really a thing back then and there was still a big chunk of incredibly skilled people that were just hacking for fun. Also, such incredibly skilled people weren’t too difficult to reach, earning their respect was easier, and, accordingly, getting incredible insight by interacting with them was easier too. Today many of the most skilled hackers out there use their skill for a living, they are often employed by government agencies, and are overall incredibly jealous of their knowledge. If this makes perfect sense from a market perspective, it again sets the bar very high for novices: Not only the required skills they need to hack are higher now, but they are also increasingly lonely in their learning process.</p><p>Add to the mix the fact that software today, albeit being often open source, is designed with a black-box philosophy in mind: It is meant to be used, not to be explored. To be aware of this note how the user experience in operating systems evolved: In a modern smartphone or tablet, even taking a peek at the filesystem is a non-trivial task, and basically no phone is rooted by default (this is a true WTF thing for any hacker worth their name). It is evident how we are moving towards systems where the machine’s inner workings are concealed, and this is backed up by the idea that “the average user doesn’t want know, you need to be a developer to really care” ...But how am I supposed to become a developer if I am denied — by design — the desire to satisfy my curiosity, if I cannot learn how a machine works just by wandering into it?</p><p>The last piece of misery in this story is given by the decline of IRC, in favor of other platforms first, and social networks then. In the past, chats like IRC were organized by means of thematic channels: You wouldn’t decide who you wanted to talk with, but what you wanted to talk about. You would join a channel— say, #mathematics — and you would find a bunch of random, often unknown people, with an interest for maths. When platforms such as MSN became popular things changed, since you would need to add people to be able to chat with them. This turned the internet into a lonely place, where users would chat only with people they already knew. Also, the chat experience shifted from being mainly group-centered to be based on a one-on-one kind of communication, further killing enriching interaction.</p><p>All these things have had an incredibly negative impact on hacking and on its inherent educational value, turning curious but still largely inexperienced people into a bunch of lonely renegades with little chances of meeting each other and possible mentors. When this is not the case, it still happens in a market-focused environment, which has nothing to do with building one’s skills out of curiosity. In this respect, any old-school hacker would consider hackatons just plainly repulsive: Most often than not, they are nothing but a way to harvest people’s will to learn and motivation to get sellable stuff developed for free.</p><p>Ok, but where does the Blockchain get in this story? Well, the poetry of blockchain lies in the fact that it is still wildly underdeveloped, that decentralized infrastructure still can’t do much aside of very simple things, and on the fact that almost no decentralized system is industry-ready at the moment. Yes, enterprises have a big interest in Blockchain and things are changing quickly, but as they stand now very few, well established enterprises would give making their system totally decentralized a serious thought before going for it.</p><p>Many people complain about this being the current state of affairs, but if you look at it from the perspective of this blog post, it is wonderful: People have again something moderately simple to study and understand; they can still obtain quite big results just by developing basic skills; communities are still open enough to allow people to learn from experts and one can still consider many of them as peers, not as unknowable demigods. Moreover, being economics an integrating part of decentralized development, novices have a huge drive in putting work into being curious: Never as today one could make a pack of money just by exercising lateral thinking, either by developing a new, simple idea, or by finding a clever hack.</p><p>Think about what happened to the DAO: The vulnerability spotted back then was remarkably simpler, and hugely rewarding. When the hack happened, I felt like I had traveled back in time: That something that simple could be so destructive had an intrinsically old-school-hacking flavor to it, and even made it somehow romantic.</p><p>If this makes me think that much has still to be done to make Blockchain usable — and we as Statebox are surely part of this process — it also makes me happy and optimistic when I look at the future: Right now, people have the chance to learn again, and to refine their skills by means of old-school experimentation.</p><p>How does Statebox fit into all this? Well, we strive to be as hacker-friendly as possible. If we aim to get industry-strong software, we also aim to keep it simple, to keep it open, and hopefully to maintain close contact with the community out there. We want our software to be reliable but we also want it to be easily modifiable to fit other people’s needs, so that anyone can experiment with it, and spot vulnerabilities if there will ever be any. All in all, we want to give people not only a chance to use it, but also to learn with it, and to exercise their lateral thinking.</p><p>The poetry of Blockchain will die eventually, as it gradually turns in the usual gray over-engineered blob of code, driven by financial interest instead of sheer curiosity. This is simply the natural course of things, and I don’t think much can be done about it. But until that happens, we have the chance to delay the process as much as possible, to keep software lean and open, to preserve the poetry just for a bit longer. And hopefully, we’ll be able to set an example, and to prove that in a sea of chaos there is still a way to do things right, by backing up a development philosophy that takes responsibility in considering coming generations of users not just as clients, but as learners and peers as well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee43c6e261a6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/statebox/the-poetry-of-blockchain-a-celebration-of-lateral-thinking-ee43c6e261a6">The poetry of Blockchain — A celebration of lateral thinking</a> was originally published in <a href="https://medium.com/statebox">Statebox</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Smart Contracts and Their Issues]]></title>
            <link>https://medium.com/statebox/smart-contracts-and-their-issues-b492e38c8698?source=rss-738685c5aba7------2</link>
            <guid isPermaLink="false">https://medium.com/p/b492e38c8698</guid>
            <category><![CDATA[law]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <dc:creator><![CDATA[Fabrizio Romano Genovese]]></dc:creator>
            <pubDate>Thu, 15 Nov 2018 10:08:44 GMT</pubDate>
            <atom:updated>2018-11-15T10:08:44.502Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Note: This article was first published in </strong><a href="https://rethinking-law.owlit.de/document.aspx?docid=REL1284947"><strong>Rethinking Law, issue 1, on 31 October 2018</strong></a><strong>.</strong></p><p>Since the advent of Ethereum, one of the keystones of blockchain <a href="https://bitcoin.org/bitcoin.pdf">[1] </a>infrastructure has been <em>smart contracts </em><a href="https://github.com/ethereum/wiki/wiki/White-Paper">[2]</a>. Technically, as far as we are concerned, a smart contract is nothing more than a piece of code that runs on a blockchain. Having code running on a blockchain means two things: Firstly, being the history of operations happening on a blockchain <em>immutable</em>, smart contracts can be programmed to be immutable as well, in the sense that once they are issued they cannot be revoked. Secondly, all the code on the chain runs in a <em>decentralized</em> fashion: No one but the whole community “holds” the (virtual) machine on which such code is executed.</p><p>These two properties make smart contracts particularly appealing for use in law. Immutability means that a smart contract behaves like its traditional counterpart: The only way to make it “disappear” would be by taking down the whole blockchain on which the contract is hosted, which is infeasible. Following a comparison with traditional law, if a contract is signed and protected by a notary then one would have to bribe or get rid of the notary to take it back. The difference is that here the notary is the whole, worldwide community, making this kind of corruption virtually impossible.</p><p>Decentralization means that the contract cannot be manipulated. If smart contracts were to run in a centralized fashion, that is, on a centrally managed number of machines, one could change their behavior by seizing the “control room” administering the machines on which they run. Again, in the case of blockchains such a control room doesn’t exist and the machine is distributed worldwide, so this cannot happen. In this respect, smart contracts are even safer than traditional ones, where one has to trust that the notary responsible of safeguarding them won’t misbehave. Clearly the validity of such assumption becomes increasingly disputable as the economic value of the assets ruled by the contract rises.</p><p>Not everything is so nice, though. As we said earlier, smart contracts are pieces of code, and as such require a fair amount of technical skill to be properly written. But coders are not lawyers and lawyers are not coders, and in fact law and programming are traditionally considered rather disjoint worlds. This means that the skill set required to write a smart contract properly is incredibly rare to have, requiring competence both from the law side — one must understand what the contract is supposed to do and mean — and from the programming side — one needs to know how to express this properly using code.</p><p>To make things worse, the programming languages used to write smart contracts are still highly experimental and incredibly cumbersome to use, even for experienced coders. The natural consequence of this, without diving into technical details, is that it is rather easy to write a smart contract that does not behave as the writer intended. This is somewhat analogous to writing a traditional contract in a sloppy way, creating all sorts of loopholes.</p><p>For this reason, great effort is being put by researchers into the blockchain tech all over the world to find better programming languages for smart contracts, that is, better ways to write a contract’s underlying code. To understand how this effort is being directed, it is useful to compare programming and natural languages: There are essentially two reasons why people make mistakes — that is, they convey meaning differently from what they intended — while speaking a language. The first depends on the language itself, as in the case of a word meaning two completely different things that may be wrongly interpreted in some contexts. For instance, “We saw her duck” is one such sentence. The second depends on the language being itself cumbersome and difficult to use. For example, consider a non-native speaker having great difficulty using the grammatical rules of a language correctly.</p><p>In the case of programming languages for smart contracts, the majority of research and development efforts are being put into solving problems akin to our first example: The goal is obtaining languages that are semantically unambiguous, and whose behavior is always predictable and deterministic. Loosely speaking, we are trying to get rid of words with double meanings or sentences that can be read in multiple ways.</p><p><strong>The Statebox Approach</strong></p><p>In this respect, what we do at <em>Statebox</em> is different: We are designing a programming language that also solves problems of the second class. We are not just trying to make the language unambiguous and semantically precise, but also structured in a way that leverages human intuition, meaning that using and learning it should be an easy process. This language has a variety of applications, smart contracts being one of them.</p><p>To understand how this is done it is worth mentioning two key features in the Statebox approach and paradigm.</p><ul><li>The first is that our language is completely grounded in mathematics. All the implementation is built upon mathematical concepts and theories that are formally interlinked with each other, the most important ones being <em>category theory</em>, <em>Petri nets</em> and <em>type theory</em>. In particular, category theory is a sort of “mathematics superglue”, that is able to highlight and model links between different mathematical theories in a consistent, formal and well defined way.</li><li>The second is that all the concepts we adopt have a graphical counterpart, called <em>graphical calculus</em>. This is made possible by the fact that some constructions in category theory are proven to be equivalent to a calculus of diagrams, that is, there are theorems <a href="https://doi.org/10.1007/978-3-642-12821-9_4">[3]</a> that prove how there is no difference between working with these constructions using formulas or drawings: What can be proven is the same. An example of this is given in Figure 1, where an equation and its graphical counterpart are represented. Such results can take us pretty far: Probably one of the most spectacular examples of this is given by<em> categorical quantum mechanics</em>, initially developed by Abramsky and Coecke <a href="https://doi.org/10.1109/LICS.2004.1319636">[4]</a><a href="https://doi.org/10.1017/9781316219317">[5]</a>, which allows us to express and prove many important results in quantum mechanics diagrammatically: In fact, in Figure 1 you can see part of a quantum process both modeled traditionally and diagrammatically. Albeit they look radically different, they are proven to be equal.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*ZmKwQYS4PIwpk4Ei7J5C5g.png" /><figcaption>Figure 1, From <a href="https://doi.org/10.1017/9781316219317">[5]</a>: Low level language vs. high level language (visual) for describing a quantum process.</figcaption></figure><p>This twofold paradigm has important consequences for people using the language. The first is that the complexity and the mathematics are “hidden” in the images: As long as one knows how the images can be manipulated, knowing the mathematics is not needed. The second is that due to the equivalence between graphical calculi and their mathematical counterparts, one can be sure that what is expressed using images is formally precise and meaningful. In addition to this, Statebox heavily employs type theory to make things even more reliable. Type theory can be thought of as “the watchdog of mathematics” that runs under the hood, unbeknownst to the user. It ensures that the images are manipulated following the right rules, and will prevent the user from making any inadmissible manipulation.</p><p>Another benefit of having a programming language grounded in category theory is <em>functoriality</em>: As we have previously stated, category theory is the superglue of mathematics, and it provides tools to map mathematical theories to other mathematical theories. This property can be cleverly used to make Statebox <em>platform agnostic</em>: The Statebox programming language can be applied to any context — or to put it more technically, it can be compiled to any language and architecture — meaning that it can also be used outside blockchain applications. Among the most useful applications of this is the possibility of running Statebox directly on hardware via other tools from theoretical computer science such as <em>logic programming</em> <a href="https://arxiv.org/abs/1707.01550">[6]</a>, resulting in unmatched speed, efficiency and reliability.</p><p><strong>Statebox: Diagrammatic Programming</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*DrOz8PjuhQyCsciUS2mROA.png" /><figcaption>Figure 2</figcaption></figure><p>Let us now dive into how a Statebox program is drafted. In Figure 2 we can see a Petri net. It is composed of <em>places</em>, depicted as blue circles, which hold <em>tokens</em>, depicted as black dots. A place represents a type of resource, while a token in a place stands for a resource of that type. Finally <em>transitions</em>, depicted as gray squares, represent transformations that can turn resources of some type into resources of some other type, as prescribed by the inbound and outbound arcs connecting them to places.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*wQB9D3_QCfyn2a0pHB5x4g.png" /><figcaption>Figure 3</figcaption></figure><p>A net represents “the geometry of our code”, and the state of a program is inferred by looking at the distribution of tokens in a net. For instance, consider the net in Figure 3: If the net aims to represent the managing of orders, then we readily infer that there are two open orders, one processed, and three closed. On the contrary, in Figure 4 a single token is used to represent the state of a system, which alternates between two possible “active” and “inactive” configurations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*ssDCBxMrXbgVAIgFsMnWTA.png" /><figcaption>Figure 4</figcaption></figure><p>The great advantage of programming with Petri nets is that one can use them to model how code should work in terms of how the flow of information within it should behave. As shown above, this can be done completely graphically. Using already developed tools <a href="https://link.springer.com/chapter/10.1007/978-3-642-40206-7_29">[7]</a> it is then possible to check if a state can be reached from another one, that is, if starting from an initial distribution of tokens it is possible to apply transitions and end up having tokens arranged in a target final distribution. Such a property is very useful and allows us to check whether the information flow that we modeled leads to unintended behavior. For instance, one can verify that starting from the net in Figure 5 a distribution of tokens as in Figure 6 cannot be reached.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*31C2nNXkQLZf5_JCDbzSBA.png" /><figcaption>Figure 5</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*QnM3SekmQcUVbwstK-Vy-A.png" /><figcaption>Figure 6</figcaption></figure><p>Only after the net is drafted and the properties we are interested in are verified, it becomes possible to attribute meaning to transitions in the form of bits of code that perform the desired operations. At this point the whole net is compiled — that is, turned into a piece of “traditional” code which can be deployed on some existing platform.</p><p>It has to be pointed out how Statebox as a language has way more features than the ones outlined above, such as ways to glue nets together and tools to perform data analytics. The interested reader can take a look at the Statebox monograph, which details the mathematical specification of our language so far <a href="https://archive.statebox.org/#/documents/monograph">[8]</a>.</p><p><strong>Application in Law</strong></p><p>The possibilities of the Statebox programming language are profound when it comes to law. It provides a reliable paradigm to define smart contracts in a way that is compatible with our intuition. It does so while naturally offering a toolkit that enables us to verify whether what we write has the correct properties. Moreover, it requires close to zero coding skills since everything can be done graphically, while turning this into meaningful machine code is taken care of by the link with category theory highlighted in the previous sections.</p><p>This is particularly meaningful, since requiring lawyers to become programmers is an unrealistic requirement, if not the biggest obstacle that prevented smart contracts to become a widespread tool in law up to now.</p><p>The intrinsic simplicity of Statebox and its low learning curve make it appealing also in terms of the relationship that a law professional can have with clients: With Statebox, a law professional can listen to clients, and, while determining the nature of the contract to be drafted, start expressing it as a net. The client will quickly understand how such nets work, allowing for direct interaction with the professional: Clients can finally understand what is happening and provide direct feedback while the drafting process is still ongoing.</p><p>Statebox can also be used to build software infrastructure at any level. Having such infrastructure living on the blockchain is important when transparency and fairness matter, as we would expect with anything regarding the administration of a sovereign state. It is then reasonable to assume that a migration towards a “blockchained state infrastructure” will at some point happen, and that the level of complexity of software hosted on the blockchain — along with its scalability — will grow exponentially in the next years. Reducing such complexity — or to better say making it manageable and understandable — is one of the points where Statebox shines.</p><p>When it comes to specific applications of this to law, you can think about the whole computer infrastructure that aids, say, a judge to make a decision in court. This can range from ways to display and store evidence to machine-learning based algorithms that help the judge in making decisions. Much of this infrastructure is, at the moment, proprietary, closed source and not transparent enough, raising often ethical concerns, see e.g. <a href="https://www.propublica.org/article/machine-bias-risk-assessments-in-criminal-sentencing">[9]</a>. The right way to implement such tools should instead be as follows: Every time such software is used, a verifiable proof of the computation that happened and led to the result should be produced, including all those hidden parameters that are fed to the software heuristics. In this way it should be possible to verify, at least in principle, if, when and how and a given piece of software misbehaved. To make the process transparent, such proof must be produced and stored on the chain, and even better, one should be able to rerun the computation on different parameters and see the different results, potentially arguing against something that was concluded based on the original parameters used. Moreover, in matters where privacy is concerned, such proofs should also be <em>zero-knowledge</em>, meaning that an hypothetical verifier should be able to check if the proof is correct without knowing or gaining any information about the particular data on which such computation has been run.</p><p>We do possess, at the moment, all the needed mathematical infrastructure to turn what we said above into a reality. Nevertheless, the amount of complexity introduced when trying to turn such maths into a reliable implementation is enormous, which is why programming languages as Statebox will be ultimately needed if we want to fix the opaque, non-transparent software infrastructure used now.</p><p><strong>Conclusion</strong></p><p>Statebox is an ongoing project and we are far from having reached a definitive version of our product. At the moment a minimal viable product consisting of a Statebox language core, a graphical editor for nets and a first implementation of our typesystem are being developed. Nevertheless, it goes without saying that the only true measure when it comes to the effectiveness of a programming language is its adoption, and in this respect we hope to have given enough material to convince the reader of the usefulness of diagrammatic, categorical programming languages for smart contracts, and of their possible uses in law.</p><p>[1] Nakamoto, S. (2008). Bitcoin: <a href="https://bitcoin.org/bitcoin.pdf">A Peer-to-Peer Electronic Cash System. </a><a href="http://www.bitcoin.org,/"><em>www.bitcoin.org</em>,</a> 1–9.</p><p>[2] Buterin, V. (2014). <a href="https://github.com/ethereum/wiki/wiki/White-Paper">A Next-generation Smart Contract and Decentralized Application Platform</a>. <em>Ethereum</em>, 1–36.</p><p>[3] Selinger, P. (2010). <a href="https://doi.org/10.1007/978-3-642-12821-9_4">A Survey of Graphical Languages for Monoidal Categories.</a> In B. Coecke (Ed.), <em>New Structures for Physics</em> (Vol. 813, pp. 289355). Berlin, Heidelberg: Springer.</p><p>[4] Abramsky, S., &amp; Coecke, B. (2004). <a href="https://doi.org/10.1109/LICS.2004.1319636">A Categorical Semantics of Quantum Protocols.</a> In <em>Logic in Computer Science, 2004. Proceedings of the 19th Annual IEEE Symposium on</em> (pp. 415–425). IEEE.</p><p>[5] Coecke, B., &amp; Kissinger, A. (2017). <a href="https://doi.org/10.1017/9781316219317">P<em>icturing Quantum Processes: A First Course in Quantum Theory and Diagrammatic Reasoning</em>.</a> Cambridge: Cambridge University Press.</p><p>[6] Di Franco, A. (2017). <a href="https://arxiv.org/abs/1707.01550">Information-gain Computation</a>. <em>ArXiv:1707.01550 [Cs, Math]</em>.</p><p>[7] Sobociński, P., &amp; Stephens, O. (2013). <a href="https://link.springer.com/chapter/10.1007/978-3-642-40206-7_29">Penrose: Putting Compositionality to Work for Petri Net Reachability</a>. In: Heckel, R., &amp; Milius, S. (Eds.), <em>Algebra and Coalgebra in Computer Science. CALCO 2013. Lecture Notes in Computer Science</em>, vol 8089. Berlin, Heidelberg: Springer.</p><p>[8] Genovese, F. (2018). <a href="https://archive.statebox.org/#/documents/monograph">The Mathematical Specification of the Statebox Language</a>. <em>Statebox</em>.</p><p>[9] Angwin, J., Larson, J., Mattu S., &amp; Kirchner, L. (2016). <a href="https://www.propublica.org/article/machine-bias-risk-assessments-in-criminal-sentencing">Machine Bias: There’s software used across the country to predict future criminals. And it’s biased against blacks.</a><em> ProPublica.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b492e38c8698" width="1" height="1" alt=""><hr><p><a href="https://medium.com/statebox/smart-contracts-and-their-issues-b492e38c8698">Smart Contracts and Their Issues</a> was originally published in <a href="https://medium.com/statebox">Statebox</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Modularity vs Compositionality: A History of Misunderstandings]]></title>
            <link>https://medium.com/statebox/modularity-vs-compositionality-a-history-of-misunderstandings-be0150033568?source=rss-738685c5aba7------2</link>
            <guid isPermaLink="false">https://medium.com/p/be0150033568</guid>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[category-theory]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[petri-nets]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Fabrizio Romano Genovese]]></dc:creator>
            <pubDate>Mon, 24 Sep 2018 10:45:03 GMT</pubDate>
            <atom:updated>2019-03-05T11:23:34.343Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>I claim that <em>compositionality is extremely delicate</em>, and that it is so powerful that it is worth going to extreme lengths to achieve it. [Jules Hedges]</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nfZN799Uk-pScK2xbb0stg.jpeg" /><figcaption>From <a href="http://math.mit.edu/~dspivak/teaching/sp18/7Sketches.pdf"><strong>Seven Sketches in Compositionality</strong></a> by Brendan Fong and David Spivak</figcaption></figure><p>Having worked on compositional structures for my PhD degree, I am used to hearing about compositionality a lot. Though to my utmost surprise, the word “compositionality” is not just confined to the academic environment as I believed, but is actually often used in enterprise as a buzzword connected to outrageous claims.</p><blockquote>We call a system <em>modular </em>when it is composed of various parts that can be linked to each other.</blockquote><p>Well, let me tell you, ninety-nine percent of the time you hear the word “compositionality” you are being (intentionally?) lied to. What people really mean is “modularity”. In fact, compositionality is an incredibly difficult property to achieve when it comes to implementing complex systems.</p><p>But what is the difference? We call a system <em>modular </em>when it is composed of various parts that can be linked to each other. A typical example of a modular system is electric wires. If you open a socket in your wall you are free to connect wires to the socket in many different ways. Too bad that the ability to connect things together doesn’t allow you to infer anything about the behavior of the system as a whole. To be more precise, modularity guarantees that you can link things with each other, but doesn’t prevent the system from exhibiting <em>emergent behavior</em>, that in our case could be electric wires exploding in your face.</p><blockquote>Emergent behavior is more of a curse than a blessing in sensitive applications. In compositional systems emergent properties are preserved when composing things together.</blockquote><p>Emergent behavior is more of a curse than a blessing in sensitive applications. When your system has to manage something delicate, you want to be able to <em>predict </em>how it will behave as things get wired up together. This is, in a nutshell, what compositionality is: A system is <em>compositional</em> when linking its parts produces no emergent behavior, that is, when we are able to predict how a composed system will act just by looking at its components and the way they are related. Note that this doesn’t mean that, when linked together, components won’t act in a more complicated way than when they are on their own. It means, instead, that in this case it is predictable. Another way to put it is that <em>in</em> <em>compositional systems emergent properties are preserved when composing things together.</em></p><p>So, when someone claims that a system is compositional, one should immediately ask “C<em>ompositional with respect to what? Which properties are preserved when composing things together? Which kind of behavior are we able to completely predict and characterize when different parts of the system interact?</em>”</p><blockquote>Compositionality amounts to say that whoever developed the system you are using was able to understand and characterize it to the deepest possible level.</blockquote><p>Preserving meaningful properties while still having the freedom of composing things as we please is a super difficult thing to achieve, which makes compositionality very delicate. Change the smallest thing in the way components in your system behave, and you may lose it or when you are lucky, you may have to mathematically re-prove, from scratch, that the system is compositional. On the other hand, once you get it, compositionality is incredibly powerful, and amounts to say that whoever developed the system you are using was able to understand and characterize it to the deepest possible level.</p><blockquote>When someone claims that a system is compositional, one should immediately ask “<em>compositional with respect to what?”</em></blockquote><p>The delicate balance between compositionality and expressiveness is exactly what is keeping the Statebox team busy at the moment. We are sure of the respect in which our system is going to be compositional. In Statebox you will be able to link Petri nets together while preserving reachability and termination. We are sure about this because we have proved it, and I am going to add such proofs to the <a href="https://statebox.org/research/2018-07-22-monograph.html">monograph</a> pretty soon. Still, implementing compositional structures correctly takes time, and is challenging our devs to a great extent. Luckily our devs like challenges, and I hope you can wait a little bit more to see our code. :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be0150033568" width="1" height="1" alt=""><hr><p><a href="https://medium.com/statebox/modularity-vs-compositionality-a-history-of-misunderstandings-be0150033568">Modularity vs Compositionality: A History of Misunderstandings</a> was originally published in <a href="https://medium.com/statebox">Statebox</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Ethical Businessman Manifesto]]></title>
            <link>https://medium.com/@fabrizio_99052/the-ethical-businessman-manifesto-36e44fa28899?source=rss-738685c5aba7------2</link>
            <guid isPermaLink="false">https://medium.com/p/36e44fa28899</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[ethics]]></category>
            <category><![CDATA[entrepreneurship]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Fabrizio Romano Genovese]]></dc:creator>
            <pubDate>Tue, 31 Jul 2018 16:30:26 GMT</pubDate>
            <atom:updated>2018-07-31T16:30:26.337Z</atom:updated>
            <content:encoded><![CDATA[<p>Some time ago Statebox founder and friend Jelle told me about the <a href="https://criticalengineering.org/">Critical Engineering manifesto</a>. Many people in the Statebox team grew up in the first age of the internet, when hacking things was easier, new acquaintances could be made just by joining an IRC chatroom and copyright laws/privacy violations weren’t really a thing. When I first saw this document I just thought “It was about time that someone wrote a thing like this, and it’s a shame I haven’t been aware of its existence for years!” Now that I finally discovered it, I can only be grateful. Thanks, mate!</p><p>The Critical Engineer manifesto reflects the mindset and core beliefs of those “first settlers of the digital world”. It aims to present an ethical system making pioneers of the new era of computers responsible by letting them think about the consequences of technological advancement and by raising awareness on how the goals they wanted to pursue would have impacted society. It seems strange now but, for instance, back in the day it wasn’t always clear how hacking a computer system could literally result in huge job loss as well as in sending a powerful political statement about something: The digital world hadn’t yet impacted our lives enough to be considered “real”. Thus, laying the ethical foundation of the new warrior cast of the modern age, the hackers, has been essential to define who hackers are, and in which way they should contribute to society.</p><p>Today, we are facing a similar problem in industry. Every day is an El Dorado, with new disruptive tech being invented, startup projects ready to implement and commercialize it and a whole “it looks just like a game for now” state of mind that makes it very difficult to think about the long-term consequences of how such new tech and businesses are being set up.</p><p>It has to be said that the startup culture is populated by brilliant people with brilliant ideas, which most often than not are moved by the genuine will of making the world into a better place. Things often go wrong though, and heroes can turn into villains pretty quickly in the modern company environment.</p><p>For example, I remember how in the late nineties Google embodied everything hackers and digital pioneers believed in: Google was playing with a new kind of tech, the internet, that still had to be perceived by many as “a real thing that will soon become a key part of our life”: It looked revolutionary. People at Google were perceived as brilliant, pure minds focused on tech, science and open source, empowering the people with the freedom of editing and changing things as they wanted, and they were cool, unbelievably cool! I remember how everyone, looking at the Google X Labs, thought that those guys were literally on a mission to save the world by manufacturing revolutionary tech with the purpose of changing our lives forever, and for the better. While I am sure that many of the Google “big dogs” still perceive themselves as such, roughly 20 years later Google is considered by hackers as an evil vampire leeching on our privacy, sneeking into any crevice of our life unwanted, and completely ignoring any form of decency when it comes to violating our most basic digital freedom rights for revenue. How did this happen?</p><p>My point is that in the Startup culture people should think big from the beginning, not only tech-wise and business-wise, but ethic-wise. You never know when and how much you are going to scale, and when this happens, you don’t want to be unprepared. If scaling will have the unforeseen consequence of having to fire a big chunk of your workforce, what will you do? You will probably go for it, thinking “I’ll get them back on board in a way or another”, which not only will probably never happen, but will start your slow transformation from Anakin to Vader: You just began to sacrifice ethical rectitude for profit.</p><p>As a consequence, I thought useful to start assembling a small manifesto to remember entrepreneurs where they are going or, to better say, how they should go wherever they are going, keeping them focused on the real purpose the new business generation: Destroy the old system based on blind profit and greed without ending up, twenty years from now, being akin to who we call greedy pigs today. I am not an ideological person, so you will notice how the following points are not based on emotional and ideological arguments, but are instead cast from fully rational premises. Albeit focusing on an ethical idea of business, their underlying methodology is cynical, because the world is ruthless and won’t listen otherwise. This is a work in progress, and any sort of contribution is welcome.</p><ul><li>[Principle of reality] We live in a dirty, rigged social, economic and political system, based on inequality, profit and greed. Ubercapitalism won’t change overnight and political revolutions seem unlikely. What a modern businessman can do is try to play the system from the inside, and use disruptive ideas to shift the world equilibria towards more ethic causes.</li><li>[Principle of positivity] Businesses should be ethical. They should aim to empower people, steer society towards economic equality, and try to fix problems that put the whole humanity at risk (climate change, famine, pollution, diseases).</li><li>[Principle of non-negativity] If a business doesn’t positively contribute in some direction — i.e. it doesn’t actively do something to fix pollution — at least it shouldn’t contribute negatively — i.e. by polluting. No one can fight to solve all of the world’s problems at once, but we should avoid making things better at the price of worsening others.</li><li>[Principle of alliance] Ethical businesses should actively seek partnership with other ethical businesses, and avoid as much as possible unethical ones — e.g. don’t do business with Lockheed-Martin if possible, because in a way or another the tech you develop for them will be used to kill people.</li><li>[Principle of active endorsing] If an ethical business operates in a field where there is no competition with what you are doing, you should actively endorse it. Shoot posts on the internet, use your social media channels, help them consolidate their public image. Using your public image to back up an ethical cause means actively fighting for that cause.</li><li>[Principle of advantage] If you are in the power to do so, give to fair, ethical businesses an advantage with respect to unethical ones. If you can’t refuse to sell your products or services to an unethical business (because maybe the free market rules do not allow it), try at least to differentiate things such that ethical competitors get discounts or better rates.</li><li>[Principle of rationality] Ideology doesn’t work. You should try to steer society towards a more ethical direction not by emotional arguments, but by coldly analyzing things from a game-theoretical perspective: Give people rational incentives to go ethical over some unethical alternative. For example, if you produce vegetarian patties do not try to make meat-eaters to feel guilty for their choices, because they won’t. Instead, give them a patty that tastes the same, looks the same, bleeds the same but is vegetarian, for half of the price. They will prefer it because it is the most rational thing to do, and incidentally they will also stop eating meat.</li><li>[Principle of diplomacy] Use your ethical stance as a defining feature of your brand. This will be especially useful when you will have to deal with a board of directors, investors or other people that you share power with: Leverage on the fact that unethical decisions could damage the brand to steer their opinion towards ethical choices, that is, use their own greed as an advantage to do better things.</li><li>[Principle of end of life] When a business has served its ethical purpose, it reaches its end of life. Do not overgrow if this means venturing towards unethical paths. Instead, use your resources to refactor the business, so that you can start working on another cause without making damage where you made good. Don’t be the next Google.</li><li>[Principle of reinvesting] You should be rewarded for your work, but try to do it ethically: You don’t need an incredible personal fortune to be an happy person. Instead, keep part of the revenue for yourself but reinvest the majority of it in other ethical projects by spawning other companies, endorsing other ethical businesses, or by empowering other people.</li><li>[Principle of empowering] Things like charity are often ineffective, because they are not empowering. Giving 20 bucks to a homeless person won’t help them to change their life. On the contrary, giving 5 thousand or investing in an empowering scheme that gives the homeless access to affordable housing, education, jobs, and the possibility to go big with other ethical businesses do. Try to break the habit of contributing to society in an egoic way, that is, giving very little just to feel a bit better with yourself. Instead, think big. Devise projects that would rationally contribute to redistribute wealth, and to give people equal opportunities. Empowering people means more brilliant ideas to be turned into ethical business, which is good.</li><li>[Principle of timing] Thinking big does not mean postponing things forever. If you keep thinking that you are not big enough to start turning the world into a better place you are on the right track to become the next greedy pig. Do what you can everyday, and think big with respect to your possibilities. Do not sacrifice your short-term ethic plan in favor of a long-term one that may never come.</li><li>[Principle of clever financing] There are ethical projects that will always operate at a loss, or will operate at a loss until they go really, really big. One example is rhino poaching: Fighting it costs a lot of money and has no real revenue whatsoever. If you care about such “unfeasible” projects, you should first set up other ethical businesses that are easier to bootstrap and run, and then use their revenue to finance the unfeasible ones.</li><li>[Principle of non-attachment] Money and power are like chips at a poker table. They are tools, not goals. Do not be greedy, do not accumulate for the sake of having more. Use your money and power to fix things and eventually get rid of the majority of them once you achieved your goal.</li><li>[Principle of awareness] No one is perfect. You are not perfect and, as any other human being, full of contradictions. Just try to be aware of them and be realistic on how you are impacting the world: Try to avoid the situation where you believe to be an ethical saint but the reality is that you are a greedy bastard.</li></ul><p>This is all I got for now, but I am quite confident that this list will change in the next weeks, both in content and size. I just hope this can spark some sort of public discussion, because we need it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36e44fa28899" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Statebox? A discussion on founding principles]]></title>
            <link>https://medium.com/statebox/what-is-statebox-a-discussion-on-founding-principles-bd5f9f253272?source=rss-738685c5aba7------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd5f9f253272</guid>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[category-theory]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Fabrizio Romano Genovese]]></dc:creator>
            <pubDate>Wed, 13 Jun 2018 12:22:03 GMT</pubDate>
            <atom:updated>2018-06-13T12:22:03.352Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://statebox.org/">Statebox</a> has received a lot of hype and attention in the last months. Nevertheless, we admittedly released very little information about what we are working on, and about the development state of our project in general. One of the reasons for this is because we are absolutely horrified by the amount of vaporware going around in the tech industry and we don’t want to make any claim without being able to substantiate it.</p><p>Nevertheless, the time has come to sketch what Statebox is, which problems it aims to solve, and some of the main principles that are guiding us in its design. I will do this using the least amount of maths possible (hopefully zero), while being as conceptually clear as possible.</p><h3>A bit of history and sociology</h3><p>In the last ten years we witnessed massive innovations in the software industry. Almost anything now relies on software in one form or another, and this is pervasive to the point that we could say that each one of us, besides their normal life, has a digital life as well. <strong>All in all, remarkable are not only the technological advancements we are undergoing, but the social transformations that they bring forth</strong>. <a href="https://en.wikipedia.org/wiki/Free_software">Free software</a>, for instance, has become a standard for many big business players, and the consequent public availability of a huge codebase has massively contributed to the growth of the startup culture. The very idea of a startup, where a smallish team of developers is in principle able to create massively disruptive changes in the way the world as a whole thinks about software, wouldn’t be possible at all if code wasn’t free and readily available to edit.</p><p>In this context, let us think about the blockchain technology. One of its biggest innovations is proving that <strong>an open source, publicly managed codebase can also be used to manage very sensitive assets</strong>. Think about it, before blockchain was a thing, open source software was often limited to apps that weren’t managing financially valuable content. Then, suddenly, it turns out that the very same team of developers who creates a mobile app about kittens is also able to mint its own coin, and create an infrastructure literally managing billions.</p><p>This has, obviously, positive and negative effects. On the positive side, we are in principle able to destroy big financial monopolies and reallocate resources that have been blocked for a long time, in more efficient ways. Even more excitingly, we now have the means to completely re-think in which way we want to model our very own societies, reinventing political and social systems. This is an issue of its own and we could endlessly discuss the best way to do it, but let’s not sidetrack.</p><p>On the negative side, the means by which we can drive such changes are still wildly underdeveloped. The way we create software now is nowhere efficient, reliable and usable enough to manage such a complex infrastructure. This is not blockchain’s fault, it is about the way we think about programming.</p><p>For example, if the kitten app we mentioned above has a bug, it’s not a big deal. At worst, your kittens will be glitchy. But if the codebase underlying a cryptocurrency misbehaves, then you are potentially burning billions, or unwillingly funnelling them to some attacker’s account.</p><p>Again, the problem spawns from social transformations. Before the blockchain, only very strong financial groups were actually using software to manage money and valuable assets. Such groups can easily afford to put uncountable developers and engineers on their codebase to optimize and debug it big time: <strong>Given their close-to-infinity financial resources, they can literally attain reliable, optimal code by bruteforce</strong>. In the startup era this is clearly not true anymore. A startup of 10 people that creates a new currency doesn’t have the financial means for this bruteforce optimization process, and the result is that the high inefficiency of the current software-producing tools makes it prone to bugs, and often insecure.</p><p>It is clear, then, that we need more efficient ways to produce reliable software.</p><h3>About mathematicians, reality, and human error</h3><p>At this point, you are probably thinking “Ok, Statebox is just another programming language promising to be the next big deal”. Somehow, you are right, but let me tell you in which respect what we do is different. I am a mathematician, and I spent a big chunk of my life studying completely rational, immutable, perfect systems. <strong>The take-home message that I got from this is that applying this point of view to the real world only causes trouble.</strong> The quantity of unforeseen/unpredicted/unaccounted material that pops up when you try to use maths to model real-life phenomena is such that more often than not you end up being very disappointed — both with your model, that doesn’t really work, and with reality, that sometimes proves to be extremely difficult to tame. This is not something that maths can fix, and has to do with the inherent complexity of reality itself.</p><p>Unfortunately, many theoreticians are used to reason within their perfect models and are not fully aware of how things will do everything in their power to destroy their dreams when their models are implemented. With respect to having secure, reliable programming languages, I heard many people and companies claiming to have something “that is perfectly consistent, verified, mathemagically splendid and that <strong>JUSTWORKS™</strong>”. This is very nice, and surely a necessary condition to develop what will be the programming languages of the future, but it is not sufficient. <strong>What is not factored into this reasoning is how, most of the times, the error is human</strong>.</p><p>For instance, think about the C compiler. It is arguably one of the most splendid works of art you can think of. Audited for more than thirty years, incredibly efficient, virtually bugless. Still, producing wrong code in C is very easy, and that is because C is inherently difficult to use when it comes to turning complex ideas into code. Long story short, <strong>it is very easy to write code that does not do what you think it does</strong>.</p><p>Along the same lines, I heard about many projects proposing <a href="https://en.wikipedia.org/wiki/%CE%A0-calculus">pi-calculus</a> based programming languages for complex, decentralized infrastructure. Don’t get me wrong, pi-calculus is wonderful, I totally love it. It gives you a neat way to produce scalable, compositional software, that is moreover naturally suited for concurrency and decentralization. The only problem with this is that, for any human being, using pi-calculus to translate ideas into code is a nightmare. The formalism is so alien to our intuition that, even if the mathematical theory per sé is perfect, <strong>the programmer will most likely find a way to misuse it during coding</strong>. This is exactly why if you have to write some code you will use, say, Python instead of <a href="https://en.wikipedia.org/wiki/Malbolge">Malbolge</a>.</p><p>All in all — and this may sound strange considering my background — <strong>mathematical purism won’t save us from human error.</strong></p><h3>A simple proposal</h3><p><a href="https://www.manning.com/books/type-driven-development-with-idris"><em>Type-driven development with Idris</em></a> by Edwin Brady is a work of art. It is not just a book about functional programming — moreover teaching you Idris, which is a quite hardcore, seemingly unknown functional language — <strong>it is a book that explains why programming using types is great.</strong></p><p>The idea is simple: Imagine you have to write some complex software. Instead of doing it all in one go, you can start defining the type structure of the code. You can say that there is a given function, that will supposedly do some particular task in your software, and just specify a type for it, without defining it in full. You can then type check, that is, ask your Idris compiler if all the functions defined are typed in a way that allows them to be combined together as you specified. If the answer is positive, then you can focus on writing their definitions in full. This allows to lay down a skeleton first, and to populate it with details later on. <strong>This modus operandi, based on defining types and leaving holes in the code to be filled in stages, makes producing software much easier, since it makes possible to code in a conceptually layered fashion.</strong></p><p>At Statebox, when we saw this way of writing software, we immediately fell in love with it, but decided to ambitiously raise the stakes with another proposal:</p><p><strong>What if we can obtain full, consistent separation between software topology and meaning?</strong></p><h3>Separation</h3><p>The concept of <strong>separating things in a way such that they are two faces of the same coin</strong> is a very important concept in mathematics and theoretical computer science. Separations as such are everywhere: <a href="https://en.wikipedia.org/wiki/Syntax_(logic)">Syntax</a> and <a href="https://en.wikipedia.org/wiki/Semantics_of_logic">semantics</a> in logic, <a href="https://en.wikipedia.org/wiki/Operational_semantics">operational</a> and <a href="https://en.wikipedia.org/wiki/Denotational_semantics">denotational</a> semantics in programming languages, and so on. The idea of separation is that if on the one hand you want to describe some structure from one point of view (i.e. as a formal system), on the other you want to describe the same structure from another point of view (i.e. in terms of what meaning that structure has). <strong>You then want to prove that these descriptions are neatly connected with each other in a predictable way.</strong> If you have this, then you can seamlessly switch from one point of view to the other in a consistent way, allowing for compartmentalized thinking.</p><p>Software development is no different. It has a given <strong>shape</strong>, that is, a way to describe how different components interact with each other, and a given <strong>meaning</strong>, that tells you what the software actually does. Nearly every programmer out there, when complex code is to be written, sketches what the code is supposed to do on a piece of paper, maybe using some sort of flowchart or other similar graphical gadget. The sketch is then implemented, but the implementation is not “formal”, and therefore it’s prone to errors. What we are working on is a way to make this step of implementation well defined, and structured.</p><p>Statebox is a programming language which heavily relies on a mathematical framework called <a href="https://en.wikipedia.org/wiki/Category_theory"><strong>category theory</strong></a>. This theory is immensely powerful, and allows you to prove amazing things about the stuff you are defining. But what is even more exciting, is that many categories have a fully developed graphical formalism that is sound and complete with respect to the structures you describe. <strong>In layman’s terms, this means that in many cases you can use category theory to prove things with pictures</strong>.</p><p>To give you a simple example of this, the picture below represents quantum teleportation (<a href="https://arxiv.org/abs/0908.1787">I kid you not, this is not a joke</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*-UL4DuX8idr-DHj0.png" /></figure><p>Thanks to the formal links between this graphical formalism and some particular class of categories (<a href="https://ncatlab.org/nlab/show/compact+closed+category">compact closed categories</a>, in this case), <strong>this is not just a picture, but a theorem</strong>. I can literally translate this drawing into linear algebra with computer software, and obtain a “classical” mathematical description of teleportation.</p><p>In the next posts, I’ll dive a bit more into how Statebox works, but the message I want you to get for now is this: Imagine a programming language that is heavily formal, where one is able to write correct, verified-by-default software. <strong>Now also imagine that everything you do in Statebox has a graphical counterpart.</strong> You can literally draw the shape of your software and populate it with meaning afterwards, in a consistent way. You can visually debug what you are doing, all the time. You can actually build a product together with your clients, who are maybe for the first time in their life able to understand software development in a meaningful way and help you, often by simply pointing out that “this part of the drawing doesn’t really seem to capture what I have in mind”.</p><p><strong>At Statebox, we are not only trying to increment reliability and efficiency by using pretty maths, we are also trying to reduce human error, and get as close as possible to flawless code implementation.</strong> What it comes down to is leveraging “obvious”, “simple” things, i.e. complementing a formally structured environment with spatial intuition.</p><p>This may still sound vague for now, and more details will follow soon, but at least I hope I got your attention about what are some of the leading principles guiding our development and research right now.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd5f9f253272" width="1" height="1" alt=""><hr><p><a href="https://medium.com/statebox/what-is-statebox-a-discussion-on-founding-principles-bd5f9f253272">What is Statebox? A discussion on founding principles</a> was originally published in <a href="https://medium.com/statebox">Statebox</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>