<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Formal-Methods on Andrew Helwer</title>
    <link>https://ahelwer.ca/tags/formal-methods/</link>
    <description>Recent content in Formal-Methods on Andrew Helwer</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Fri, 04 Jul 2025 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://ahelwer.ca/tags/formal-methods/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>A supposedly worthwhile contract I&#39;ll never do again</title>
      <link>https://ahelwer.ca/post/2025-07-04-tla-contracts/</link>
      <pubDate>Fri, 04 Jul 2025 00:00:00 +0000</pubDate>
      <guid>https://ahelwer.ca/post/2025-07-04-tla-contracts/</guid>
      <description>&lt;p&gt;Here I&amp;rsquo;ll talk about a type of TLA⁺ contract I&amp;rsquo;ve worked on a few times, and why it didn&amp;rsquo;t work out as well as hoped.&#xA;I&amp;rsquo;m not trying to torpedo other peoples&amp;rsquo; contracts here - I just hope to share this experience so others can structure their TLA⁺ contracts differently, hopefully leading to greater success for both parties and industry usage of TLA⁺ as a whole.&lt;/p&gt;&#xA;&lt;h1 id=&#34;the-proposal&#34;&gt;The proposal&lt;/h1&gt;&#xA;&lt;p&gt;The contract proposal goes like this: a client wants to build a distributed system, and has read that TLA⁺ is effective at modeling such things.&#xA;Conventional wisdom holds that it&amp;rsquo;s always cheaper to catch bugs earlier in the development pipeline, and what&amp;rsquo;s earlier than the design stage?&#xA;However, they don&amp;rsquo;t have any in-house TLA⁺ knowledge and are unsure about whether they want to invest in training or hiring.&#xA;Instead, they email me a proposal: could I do a short 1-3 month contract where I specify their system in TLA⁺ for them?&#xA;The benefits of this setup are generally reasoned as follows:&lt;/p&gt;</description>
    </item>
    <item>
      <title>The current state of TLA⁺ development</title>
      <link>https://ahelwer.ca/post/2025-05-15-tla-dev-status/</link>
      <pubDate>Thu, 15 May 2025 00:00:00 +0000</pubDate>
      <guid>https://ahelwer.ca/post/2025-05-15-tla-dev-status/</guid>
      <description>&lt;p&gt;The &lt;a href=&#34;https://conf.tlapl.us/2025-etaps/&#34;&gt;2025 TLA⁺ Community Event&lt;/a&gt; was held last week on May 4th at McMaster University in Hamilton, Ontario, Canada.&#xA;It was a satellite event to &lt;a href=&#34;https://etaps.org/2025/&#34;&gt;ETAPS 2025&lt;/a&gt;, which I also attended, and plan to write about in the near future.&#xA;I gave a talk somewhat-hucksterishly titled &lt;em&gt;It&amp;rsquo;s never been easier to write TLA⁺ tooling!&lt;/em&gt; which I will spin into a general account of the state of TLA⁺ development here.&#xA;The conference talks were all recorded, so if you&amp;rsquo;d like this blog post in video form you can watch it below:&lt;/p&gt;</description>
    </item>
    <item>
      <title>TLA⁺ is more than a DSL for breadth-first search</title>
      <link>https://ahelwer.ca/post/2024-09-18-tla-bfs-dsl/</link>
      <pubDate>Wed, 18 Sep 2024 00:00:00 +0000</pubDate>
      <guid>https://ahelwer.ca/post/2024-09-18-tla-bfs-dsl/</guid>
      <description>&lt;p&gt;Although it isn&amp;rsquo;t usually taught that way, a lot of TLA⁺ newcomers develop the understanding that TLA⁺ is just a fancy domain-specific language (DSL) for breadth-first search.&#xA;If you want to model all possible executions of a concurrent system - so the thinking goes - all you have to do is define:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The set of variables modeling your system&lt;/li&gt;&#xA;&lt;li&gt;The values of those variables in the initial state(s)&lt;/li&gt;&#xA;&lt;li&gt;Possible actions changing those variables to generate successor states&lt;/li&gt;&#xA;&lt;li&gt;Safety invariants you want to be true in every state&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The model checker will then use breadth-first search (BFS) to churn through all possible states (&amp;amp; thus execution orders) of your system, validating your invariants.&#xA;If one of your invariants fails, BFS gives you the shortest execution path reaching that state.&#xA;It even checks for deadlock by finding states with no possible successor states.&lt;/p&gt;</description>
    </item>
    <item>
      <title>TLA⁺ Unicode support</title>
      <link>https://ahelwer.ca/post/2024-05-28-tla-unicode/</link>
      <pubDate>Tue, 28 May 2024 00:00:00 +0000</pubDate>
      <guid>https://ahelwer.ca/post/2024-05-28-tla-unicode/</guid>
      <description>&lt;p&gt;TLA⁺ was developed by Leslie Lamport, originator of \(\LaTeX\), so it&amp;rsquo;s unsurprising that TLA⁺ syntax looks pretty \(\LaTeX\)-y.&#xA;It&amp;rsquo;s a very mathy language, with much use of symbols like (among others) &lt;code&gt;\A&lt;/code&gt;,&lt;code&gt;\E&lt;/code&gt;, &lt;code&gt;/\&lt;/code&gt;, &lt;code&gt;\/&lt;/code&gt;, and &lt;code&gt;\in&lt;/code&gt; denoting \(\forall\), \(\exists\), \(\land\), \(\lor\), and \(\in\) respectively.&#xA;The language tools include a &lt;code&gt;tla2tex&lt;/code&gt; command to format TLA⁺ specs into \(\LaTeX\) for integration in research papers.&#xA;However, research papers are not where I spend the most time looking at TLA⁺.&#xA;Here&amp;rsquo;s the tale of how I brought those beautiful symbols into the code editor, and how I learned to work with others in FOSS along the way!&lt;/p&gt;</description>
    </item>
    <item>
      <title>Wrangling monotonic systems in TLA⁺</title>
      <link>https://ahelwer.ca/post/2023-11-01-tla-finite-monotonic/</link>
      <pubDate>Wed, 01 Nov 2023 00:00:00 +0000</pubDate>
      <guid>https://ahelwer.ca/post/2023-11-01-tla-finite-monotonic/</guid>
      <description>&lt;p&gt;TLA⁺ sees a lot of use modeling distributed systems.&#xA;The ability to explore all possible interleavings of events makes concurrency simple to reason about.&#xA;For this TLA⁺ uses something called finite model-checking, which is really just a breadth-first search through the entire state space.&#xA;The key here - and this really must be emphasized - is that the model is &lt;em&gt;finite&lt;/em&gt;.&#xA;There can&amp;rsquo;t be an infinite number of states, or of course the model checker will run forever.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Using TLA⁺ at Work</title>
      <link>https://ahelwer.ca/post/2023-04-05-checkpoint-coordination/</link>
      <pubDate>Wed, 05 Apr 2023 00:00:00 +0000</pubDate>
      <guid>https://ahelwer.ca/post/2023-04-05-checkpoint-coordination/</guid>
      <description>&lt;p&gt;Here&amp;rsquo;s a short report of a time I used TLA⁺ at work, with interesting results.&#xA;TLA⁺ is a formal specification language that is particularly effective when applied to concurrent &amp;amp; distributed systems.&#xA;TLA⁺ made it tractable for an ordinary software engineer to reason about a tricky distributed systems problem, and it found a bug introduced by an &amp;ldquo;optimization&amp;rdquo; I tried to add (classic).&#xA;The bug required 12 sequential steps to occur and would not have been uncovered by ordinary testing.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Pseudocode Showdown</title>
      <link>https://ahelwer.ca/post/2023-03-30-pseudocode/</link>
      <pubDate>Thu, 30 Mar 2023 00:00:00 +0000</pubDate>
      <guid>https://ahelwer.ca/post/2023-03-30-pseudocode/</guid>
      <description>&lt;p&gt;Last weekend I had a conversation with an undergraduate student new to computer science, who was reading &lt;a href=&#34;https://en.wikipedia.org/wiki/Introduction_to_Algorithms&#34;&gt;CLRS&lt;/a&gt;.&#xA;&amp;ldquo;I wish&amp;rdquo; they said, &amp;ldquo;that all the pseudocode in my algorithms textbook was just written in Python.&amp;rdquo;&#xA;&amp;ldquo;Ah&amp;rdquo; I said, &amp;ldquo;but textbook authors sometimes want their work to endure beyond a decade.&amp;rdquo;&#xA;&amp;ldquo;But Python&amp;rsquo;s been around for a long time&amp;rdquo; came the reply, &amp;ldquo;and it&amp;rsquo;s very readable, and you can&amp;rsquo;t execute pseudocode anyway so what&amp;rsquo;s the harm?&amp;rdquo;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Writing a TLA⁺ tree-sitter grammar</title>
      <link>https://ahelwer.ca/post/2023-01-11-tree-sitter-tlaplus/</link>
      <pubDate>Wed, 11 Jan 2023 00:00:00 +0000</pubDate>
      <guid>https://ahelwer.ca/post/2023-01-11-tree-sitter-tlaplus/</guid>
      <description>&lt;p&gt;2021 saw the completion of my first substantial free software project: a &lt;a href=&#34;https://en.wikipedia.org/wiki/TLA%2B&#34;&gt;TLA⁺&lt;/a&gt; grammar for &lt;a href=&#34;https://tree-sitter.github.io/tree-sitter/&#34;&gt;tree-sitter&lt;/a&gt;, the error-tolerant incremental parser generator.&#xA;The project stabilized &amp;amp; found users over the course of 2022, then over the holidays I used it to build the &lt;a href=&#34;https://github.com/tlaplus-community/tlauc&#34;&gt;TLA⁺ Unicode Converter&lt;/a&gt;.&#xA;The new year is a time to reflect on the past and look to the future, so here in early 2023 seems ideal to publish my experience.&lt;/p&gt;&#xA;&lt;p&gt;Both TLA⁺ and tree-sitter itself ensured the project was fascinating on a technical level;&#xA;even more interesting were the social and psychological aspects of my first real involvement with the free software community!&#xA;I&amp;rsquo;ll go over why I wanted to create this project and the main technical challenges I faced doing so, then discuss the conditions that enabled me to create it and how free software development changed the way I think.&#xA;If you&amp;rsquo;d rather get the technical part in video form (with demos!), you can watch the presentation I gave at TLA⁺ Conf 2021 (slides: &lt;a href=&#34;https://ahelwer.ca/files/tla-tree-sitter.pdf&#34;&gt;pdf&lt;/a&gt;, &lt;a href=&#34;https://ahelwer.ca/files/tla-tree-sitter.odp&#34;&gt;odp&lt;/a&gt;):&#xA;&#xA;    &lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;&#xA;      &lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&#34; allowfullscreen=&#34;allowfullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube-nocookie.com/embed/qlZQErIByWU?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;&#xA;    &lt;/div&gt;&#xA;&lt;/p&gt;</description>
    </item>
    <item>
      <title>The Missing Prelude to The Little Typer&#39;s Trickiest Chapter</title>
      <link>https://ahelwer.ca/post/2022-10-13-little-typer-ch9/</link>
      <pubDate>Thu, 13 Oct 2022 00:00:00 +0000</pubDate>
      <guid>https://ahelwer.ca/post/2022-10-13-little-typer-ch9/</guid>
      <description>&lt;p&gt;It&amp;rsquo;s hard to find a textbook series garnering more effusive praise than &lt;em&gt;The Little Schemer&lt;/em&gt;, &lt;em&gt;The Little Prover&lt;/em&gt;, &lt;em&gt;The Little Typer&lt;/em&gt; &amp;amp; co.&#xA;&lt;a href=&#34;https://thelittletyper.com/&#34;&gt;&lt;em&gt;The Little Typer&lt;/em&gt;&lt;/a&gt; introduces dependent type theory and is the first of the series I&amp;rsquo;ve read.&#xA;I quickly grew to appreciate &amp;amp; enjoy its dialogue-based presentation - I&amp;rsquo;m a real convert!&#xA;I might release future didactic blog posts as a dialogue rather than straight recitation of material in block paragraphs.&#xA;Humans seem to naturally find conversations more interesting than the traditional lecture format of a single voice droning on, which might explain why comment sections often get more traction than the actual article being commented upon!&#xA;Or the popularity of topic podcasts versus lecture series.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Regexes in the Z3 Theorem Prover</title>
      <link>https://ahelwer.ca/post/2022-01-19-z3-rbac/</link>
      <pubDate>Wed, 19 Jan 2022 00:00:00 +0000</pubDate>
      <guid>https://ahelwer.ca/post/2022-01-19-z3-rbac/</guid>
      <description>&lt;p&gt;&lt;em&gt;Republished from Teleport&amp;rsquo;s official blog (&lt;a href=&#34;https://goteleport.com/blog/z3-rbac/&#34;&gt;link&lt;/a&gt;). I received compensation from Teleport for writing this post.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Z3 is a satisfiability modulo theories (SMT) solver developed by Microsoft Research.&#xA;With a description like that you&amp;rsquo;d expect it to be restricted to esoteric corners of the computerized mathematics world, but it&amp;rsquo;s made impressive inroads addressing conventional software engineering needs: analyzing &lt;a href=&#34;https://www.microsoft.com/en-us/research/blog/hyperscale-cloud-reliability-and-the-art-of-organic-collaboration/&#34;&gt;network ACLs&lt;/a&gt; and &lt;a href=&#34;https://github.com/Z3Prover/FirewallChecker&#34;&gt;firewalls&lt;/a&gt; in Microsoft Azure, for example.&#xA;Z3 is used to answer otherwise-unanswerable questions like &amp;ldquo;are these two firewalls equivalent?&amp;rdquo; or &amp;ldquo;does this set of network ACLs violate any security rules?&amp;rdquo;&lt;/p&gt;</description>
    </item>
    <item>
      <title>How do you reason about a probabilistic distributed system?</title>
      <link>https://ahelwer.ca/post/2020-09-11-probabilistic-distsys/</link>
      <pubDate>Fri, 11 Sep 2020 00:00:00 +0000</pubDate>
      <guid>https://ahelwer.ca/post/2020-09-11-probabilistic-distsys/</guid>
      <description>&lt;h2 id=&#34;in-which-i-am-stunted-upon-by-coin-flips&#34;&gt;In which I am stunted upon by coin flips&lt;/h2&gt;&#xA;&lt;p&gt;Wasn&amp;rsquo;t too long ago that I felt pretty good about my knowledge of distributed systems.&#xA;All someone &lt;em&gt;really&lt;/em&gt; needed in order to understand them, I thought, was a &lt;a href=&#34;https://www.youtube.com/watch?v=JEpsBg0AO6o&#34;&gt;thorough understanding of the paxos protocol&lt;/a&gt; and a willingness to reshape your brain in the image of TLA⁺.&#xA;Maybe add a dash of conflict-free replicated datatypes, just so you know what &amp;ldquo;eventual consistency&amp;rdquo; means.&#xA;Past that it&amp;rsquo;s just some optimizations and mashups which come easily to your TLA⁺-addled brain.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Doing a math assignment with the Lean theorem prover</title>
      <link>https://ahelwer.ca/post/2020-04-05-lean-assignment/</link>
      <pubDate>Sun, 05 Apr 2020 00:00:00 +0000</pubDate>
      <guid>https://ahelwer.ca/post/2020-04-05-lean-assignment/</guid>
      <description>&lt;p&gt;&lt;em&gt;Note: this post was written for Lean 3; the latest version, Lean 4, is a very different language.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Turn back the clock to 2009: a confused physics major newly infatuated with math and computer science, I enrolled in MATH 273: Numbers and Proofs at the University of Calgary.&#xA;This wasn&amp;rsquo;t my first encounter with mathematical proof; in first-year calculus I&amp;rsquo;d mastered rote regurgitation of delta-epsilon proofs.&#xA;Despite writing out several dozen, their meaning never progressed beyond a sort of incantation I can summon to this day (for every \( \epsilon &amp;gt; 0 \) there exists a \( \delta &amp;gt; 0 \) such that&amp;hellip;).&#xA;We were told on the first day of MATH 273 that the purpose of proof is to compel belief.&#xA;This was a bright start but sadly marked the beginning of a deeply embarrassing semester reaching its nadir when I asked the professor &amp;ldquo;how do we prove a definition&amp;rdquo; fully two-thirds of the way through the course.&#xA;I got a B-.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Checking Firewall Equivalence with Z3</title>
      <link>https://ahelwer.ca/post/2018-02-13-z3-firewall/</link>
      <pubDate>Tue, 13 Feb 2018 00:00:00 +0000</pubDate>
      <guid>https://ahelwer.ca/post/2018-02-13-z3-firewall/</guid>
      <description>&lt;p&gt;Lessons I&amp;rsquo;ve learned from software engineering are uniformly cynical:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Abstraction almost always fails; you can&amp;rsquo;t build something on top of a system without understanding how that system works.&lt;/li&gt;&#xA;&lt;li&gt;Bleeding-edge methods are a recipe for disaster&lt;/li&gt;&#xA;&lt;li&gt;Everything good is hype and you&amp;rsquo;ll only ever get a small fraction of the utility being promised.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Imagine my surprise, then, when the Z3 constraint solver from Microsoft Research effortlessly dispatched the thorniest technical problem I&amp;rsquo;ve been given in my short professional career.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Formal Verification, Casually Explained</title>
      <link>https://ahelwer.ca/post/2018-02-12-formal-verification/</link>
      <pubDate>Mon, 12 Feb 2018 00:00:00 +0000</pubDate>
      <guid>https://ahelwer.ca/post/2018-02-12-formal-verification/</guid>
      <description>&lt;h2 id=&#34;why-are-we-here&#34;&gt;Why are we here?&lt;/h2&gt;&#xA;&lt;p&gt;What guarantees does formal verification provide?&#xA;This question rests at the apex of a hierarchy of inquiry extending all the way down to how we can know anything at all!&lt;/p&gt;&#xA;&lt;h2 id=&#34;what-do-we-mean-by-software-correctness&#34;&gt;What do we mean by software correctness?&lt;/h2&gt;&#xA;&lt;p&gt;There are precisely two different ways for a piece of software to be correct:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The supreme deity of the universe descends from the heavens and decrees, with all the weight of Objective Truth, that a certain piece of software is correct.&lt;/li&gt;&#xA;&lt;li&gt;We have a list of things we want the software to do, and use logic to prove the software does these things.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Crafty readers will come up with, like, twenty different caveats to the second definition.&#xA;I encourage it! Take a minute to unearth some of the hidden assumptions. Good? Good.&#xA;I&amp;rsquo;ll talk about those hidden assumptions in greater detail below, but the point I want to make is this: &lt;em&gt;there is no such thing as inherently correct software&lt;/em&gt;.&#xA;Your wacky program could say 1 * 1 = 2, and that isn&amp;rsquo;t incorrect in any objective sense - if that&amp;rsquo;s how you want your program to behave, heck, knock yourself out.&#xA;We call our list of things we want the software to do a &lt;em&gt;specification&lt;/em&gt;.&#xA;A program is only correct (or incorrect) relative to its specification; if the program is correct relative to its specification, we say it &lt;em&gt;implements&lt;/em&gt; or &lt;em&gt;refines&lt;/em&gt; the specification.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
