<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Thiru</title>
    <description>The latest articles on DEV Community by Thiru (@0xthiru).</description>
    <link>https://dev.to/0xthiru</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1767098%2F6f43968a-4a53-40e9-81a5-1c23af65f292.png</url>
      <title>DEV Community: Thiru</title>
      <link>https://dev.to/0xthiru</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/0xthiru"/>
    <language>en</language>
    <item>
      <title>Introducing Zean: Write Zig and prove it in Lean.</title>
      <dc:creator>Thiru</dc:creator>
      <pubDate>Wed, 18 Nov 2026 20:36:00 +0000</pubDate>
      <link>https://dev.to/0xthiru/introducing-zean-write-zig-and-prove-it-in-lean-26mj</link>
      <guid>https://dev.to/0xthiru/introducing-zean-write-zig-and-prove-it-in-lean-26mj</guid>
      <description>&lt;p&gt;We just open-sourced &lt;strong&gt;Zean&lt;/strong&gt; (Zig + Lean), a toolkit for translating supported Zig functions into executable Lean models and proving their behavior. It came out of our formal verification work on &lt;a href="https://github.com/okcontract/oksolc" rel="noopener noreferrer"&gt;oksolc&lt;/a&gt;, our Solidity compiler written in Zig.&lt;/p&gt;

&lt;p&gt;Zean works from AIR, Zig's analyzed intermediate representation. An instrumented compiler captures supported functions from AIR, and a translator emits executable Lean program definitions. Specifications and proofs live in separate handwritten Lean modules.&lt;/p&gt;

&lt;p&gt;A verification library derives the proof obligations for memory access, initialization, permissions, arithmetic, control flow and supported calls. You write the contracts and loop invariants. If an obligation still needs a mathematical argument, you supply that too, and Lean checks the proofs. Unsupported operations are rejected, and unresolved obligations stay open.&lt;/p&gt;

&lt;p&gt;The copy tutorial shows what that looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="n"&gt;inline&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;copyWord&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="kt"&gt;u32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;u32&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;export&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;u32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;u32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;usize&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;usize&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;copyWord&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The caller has to establish that the source has enough initialized words and the destination has enough writable storage. For the source-preservation contract, the two ranges also have to be disjoint. Under those assumptions the proofs show there are no invalid accesses or uninitialized reads. A successful run copies the source contents into the destination and preserves memory outside it. Modeled allocation exhaustion is an explicit permitted failure, and termination is a separate property.&lt;/p&gt;

&lt;p&gt;Change the loop bound from &lt;code&gt;&amp;lt; length&lt;/code&gt; to &lt;code&gt;&amp;lt;= length&lt;/code&gt; and you get an extra boundary access that the original contract can't justify. The tutorial also includes deliberately false claims that must fail verification.&lt;/p&gt;

&lt;p&gt;When the Zig source changes, you recapture the function to regenerate the model, then replay the proofs.&lt;/p&gt;

&lt;p&gt;This release covers memory-safety examples derived from Ziglings, buffer updates, copy loops, helper calls and a captured specialization of &lt;code&gt;std.mem.replaceScalar&lt;/code&gt;. It supports restricted AIR fragments, with explicit target and layout constraints. The capture pipeline, the Zig frontend and the native backend remain trust boundaries, so the proofs don't establish correctness of the final native binary or of the whole compiler.&lt;/p&gt;

&lt;p&gt;The idea is to keep design iteration in Zig and prove a component's contracts once it has settled.&lt;/p&gt;

&lt;p&gt;To try it you need Zig 0.17.1 and elan:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/okcontract/zean
&lt;span class="nb"&gt;cd&lt;/span&gt; zean
elan toolchain install leanprover/lean4:v4.35.0
zig build ziglings
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's released under Apache 2.0. If you write Zig or Lean, I'd like to know which functions you'd want to verify with it first.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Repo: &lt;a href="https://github.com/okcontract/zean" rel="noopener noreferrer"&gt;https://github.com/okcontract/zean&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Writeup: &lt;a href="https://okcontract.com/blog/introducing-zean-write-zig-and-prove-it-in-lean/" rel="noopener noreferrer"&gt;https://okcontract.com/blog/introducing-zean-write-zig-and-prove-it-in-lean/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you like it, leave a star on the repo. And if you'd like more updates, give us a follow: &lt;a href="https://x.com/okcontract" rel="noopener noreferrer"&gt;https://x.com/okcontract&lt;/a&gt;&lt;/p&gt;

</description>
      <category>zig</category>
    </item>
    <item>
      <title>Solidity Spec: an executable formal model of Solidity in Lean</title>
      <dc:creator>Thiru</dc:creator>
      <pubDate>Tue, 17 Nov 2026 20:29:50 +0000</pubDate>
      <link>https://dev.to/0xthiru/solidity-spec-an-executable-formal-model-of-solidity-in-lean-2j3g</link>
      <guid>https://dev.to/0xthiru/solidity-spec-an-executable-formal-model-of-solidity-in-lean-2j3g</guid>
      <description>&lt;p&gt;We are releasing &lt;strong&gt;Solidity Spec&lt;/strong&gt;, an open-source research preview of an executable formal model of Solidity in Lean. The repository is available at &lt;a href="https://github.com/okcontract/solidity-spec" rel="noopener noreferrer"&gt;okcontract/solidity-spec&lt;/a&gt;, alongside a paper describing its semantics and machine-checked proofs for explicitly defined parts of the model. The current profile targets Solidity 0.8.36 and the Cancun EVM on Lean 4.29.0.&lt;/p&gt;

&lt;p&gt;This work grows out of oksolc. Building and verifying a compiler requires a precise account of the behavior it must preserve. We developed these semantics alongside our compiler certificate models before extracting them into a standalone package so researchers can inspect, execute, and extend the model independently. Building the Lean package requires neither Zig nor a Python frontend, and it has no external Lean dependencies.&lt;/p&gt;

&lt;p&gt;Because the model is executable, we can both run concrete examples and prove properties in Lean about machine transitions, state invariants, and source-to-target agreement. To ensure the definitions actually match Solidity, we test them against the language reference and real compiler runs.&lt;/p&gt;

&lt;p&gt;Consider two memory references, &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt;, pointing to the same one-element &lt;code&gt;uint256[]&lt;/code&gt;, initially containing &lt;code&gt;1&lt;/code&gt;, in the following expression:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(a[0] = 2) + b[0]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reading through &lt;code&gt;b&lt;/code&gt; before the assignment gives &lt;code&gt;3&lt;/code&gt;; reading afterward gives &lt;code&gt;4&lt;/code&gt;. Solidity leaves the evaluation order of ordinary subexpressions unspecified while preserving statement order and Boolean short-circuiting. A compiled artifact picks one order, so a source model has to account for all permitted choices. Solidity Spec exposes those choices at each expression group and models the shared physical memory cell. Solidity's evaluation-order reference describes the language boundary behind this example.&lt;/p&gt;

&lt;p&gt;Calls, conversions, and failures complicate this further. Internal helpers can write through aliases, one argument can mutate state read by another, and a subsequent revert has to restore the call checkpoint. The model handles captured locations, copies, internal call frames, and rollbacks within a single execution machine. It also distinguishes Solidity panics and reverts from unsupported behavior or host fuel exhaustion, ensuring out-of-fuel runs are never mistaken for valid source results.&lt;/p&gt;

&lt;p&gt;The main safety theorem connects static checks on resolved syntax to an invariant over local values, physical heap contents, function handles, and saved continuations. Given a valid initial state and a closed, checked function table in the supported profile, any finite execution with enough fuel either preserves that invariant or yields a valid source outcome across all permitted evaluation orders. Source failures roll back to the checkpoint. The profile covers scalar operations, canonical memory word arrays and aliases, scalar persistent and transient storage, structured control flow, and closed internal calls (including recursion). Host fuel is tracked conservatively and kept separate from EVM gas, so the theorem holds without assuming termination.&lt;/p&gt;

&lt;p&gt;Formal Solidity semantics have a substantial history. Executable semantics in K and the Coq-based Lolisa appeared in 2018. Isabelle/Solidity provides executable semantics and program proofs, while Lean developments include SolidCore and SolidiKeY. Solidity Spec brings together non-deterministic expression order, physical memory aliasing, call rollback, scoped machine safety, and a quantified source-to-target proof in one model.&lt;/p&gt;

&lt;p&gt;This release does not formalize all of Solidity. The execution machine takes typed syntax trees with declarations and function references already resolved, leaving source parsing and elaboration outside the verified boundary. The safety theorem also covers a narrower subset than the full set of operations the machine can execute. Arbitrary external calls, inline assembly, full ABI encoding, and end-to-end compiler preservation remain future work. The paper details these boundaries and the development history.&lt;/p&gt;

&lt;p&gt;You can check the standalone package from a Solidity Spec checkout with the pinned Lean toolchain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;make replay
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It builds the libraries and regression modules, then rechecks the foundation, pilot, and scalar machine proof closures from scratch.&lt;/p&gt;

&lt;p&gt;Execution clients can import &lt;code&gt;Solidity.Execution&lt;/code&gt;. Additional lemmas live in &lt;code&gt;Solidity.Execution.Proofs&lt;/code&gt;, and the admitted-state safety theorems are in &lt;code&gt;Solidity.Execution.Safety&lt;/code&gt;. The top-level &lt;code&gt;Solidity&lt;/code&gt; import retains compatibility interfaces for existing proof clients. Earlier integration audits and compiler experiments used internal oksolc harnesses not included in this release; the paper separates those internal runs from the standalone checks reproducible in this repo.&lt;/p&gt;

&lt;p&gt;We welcome counterexamples, comparisons, and external proof clients that test these interfaces. Next, we plan to support direct Solidity source ingestion, stronger composition theorems, and larger compiler preservation proofs. The code, proofs, and paper are available at &lt;a href="https://github.com/okcontract/solidity-spec" rel="noopener noreferrer"&gt;okcontract/solidity-spec&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>opensource</category>
      <category>web3</category>
    </item>
  </channel>
</rss>
