<?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: Kentaro Goto</title>
    <description>The latest articles on DEV Community by Kentaro Goto (@gotoken).</description>
    <link>https://dev.to/gotoken</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%2F4242387%2Faab06f69-4c16-402e-a4ae-f4e46efe44cf.jpg</url>
      <title>DEV Community: Kentaro Goto</title>
      <link>https://dev.to/gotoken</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gotoken"/>
    <language>en</language>
    <item>
      <title>AI Models in the Age of Terabyte Data Plans — Using Neural Networks While They Download</title>
      <dc:creator>Kentaro Goto</dc:creator>
      <pubDate>Thu, 03 Dec 2026 00:40:25 +0000</pubDate>
      <link>https://dev.to/gotoken/ai-models-in-the-age-of-terabyte-data-plans-using-neural-networks-while-they-download-mn2</link>
      <guid>https://dev.to/gotoken/ai-models-in-the-age-of-terabyte-data-plans-using-neural-networks-while-they-download-mn2</guid>
      <description>&lt;h2&gt;
  
  
  What will we transmit when a terabyte is not enough?
&lt;/h2&gt;

&lt;p&gt;A relatively recent expression in colloquial Japanese is &lt;em&gt;giga ga tarinai&lt;/em&gt; (ギガが足りない), literally, "I don't have enough giga." Here, &lt;em&gt;giga&lt;/em&gt; is short for gigabytes and refers to one's monthly mobile data allowance. The expression means that you have used up that allowance and your access to the mobile network has been restricted.&lt;/p&gt;

&lt;p&gt;This got me wondering: if mobile networks offer much more capacity at much lower prices in the future, will people start saying "I don't have enough tera" instead, with &lt;em&gt;tera&lt;/em&gt; referring to terabytes? What would we be transmitting in such quantities?&lt;/p&gt;

&lt;p&gt;One answer might be games. A game like Genshin Impact is a very large download. Another might be video content.&lt;/p&gt;

&lt;p&gt;But I wanted to think of an entirely new use for that capacity. What about AI models such as large language models?&lt;/p&gt;

&lt;p&gt;Today, much of our use of AI takes the form of services accessed over the Internet. But for offline use, faster response times, confidentiality, and personal data protection, I expect that sooner or later the balance will shift toward inference on local devices.&lt;/p&gt;

&lt;p&gt;These can be quite large, and having to wait until a whole model has downloaded before using it seems a little frustrating. Could we start using it before the download finishes?&lt;/p&gt;

&lt;p&gt;Progressive JPEG images can be displayed before all the data arrives, becoming clearer as more of it is received. Could neural networks have a similar property?&lt;/p&gt;

&lt;p&gt;It turns out that there is already research motivated by precisely this idea: &lt;a href="https://arxiv.org/abs/2110.00916" rel="noopener noreferrer"&gt;Progressive Transmission and Inference of Deep Learning Models&lt;/a&gt; by Lee et al. (2021). The authors propose transmitting quantized weights in groups of bits, starting with the most significant ones, and performing image classification and object detection during reception (§III, Fig. 3). Neither inference during reception nor sending the most significant bits first is an invention of this experiment.&lt;/p&gt;

&lt;p&gt;What I wanted to know was not just whether a model gradually gets better, but &lt;strong&gt;which capabilities emerge, and in what order&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rules and facts
&lt;/h2&gt;

&lt;p&gt;Consider two kinds of knowledge: how to tell whether an integer is divisible by three, and the birth months of one hundred people.&lt;/p&gt;

&lt;p&gt;The first can be expressed as a short program. For the second, assuming there is no special relationship among the people, each birth month must be remembered individually.&lt;/p&gt;

&lt;p&gt;A neural network can learn both, but the information they require is quite different. If part of the model is missing, might a rule with a short description be easier to recover?&lt;/p&gt;

&lt;p&gt;There is prior work on this question too. &lt;a href="https://arxiv.org/abs/2310.13061" rel="noopener noreferrer"&gt;Doshi et al. (2024)&lt;/a&gt; show that generalization of correct rules and memorization of randomly corrupted labels can coexist in arithmetic tasks, and that pruning neurons involved in memorization affects the two differently. &lt;a href="https://arxiv.org/abs/2603.25579" rel="noopener noreferrer"&gt;Farné et al. (2026)&lt;/a&gt; formulate a learning problem involving rules and random facts, investigating how capacity and regularization affect the ability to learn both.&lt;/p&gt;

&lt;p&gt;However, having a short description, being represented across many weights, and being recoverable after information is lost are three different properties.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
  Direct transmission and information-theoretic lower bounds
  &lt;p&gt;Let 

&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Z&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 be a table of 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 independent, uniformly distributed bits representing facts, 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 the received information with a fixed budget of 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;B&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 bits, and 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;S&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 shared side information independent of the source. If information such as the positions of received bits depends on the source, it must also count toward the budget.&lt;/p&gt;



&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;I&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Z&lt;/span&gt;&lt;span class="mpunct"&gt;;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;S&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;≤&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;B&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;H&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Z&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;S&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;≥&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;n&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;B&lt;/span&gt;&lt;span class="mord"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;

&lt;p&gt;The average log loss for a uniformly selected fact has the following lower bound, using logarithms to base two:&lt;/p&gt;



&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;L&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathrm mtight"&gt;fact&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;B&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;≥&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop"&gt;max&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;0&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;B&lt;/span&gt;&lt;span class="mord"&gt;/&lt;/span&gt;&lt;span class="mord mathnormal"&gt;n&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mord"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;

&lt;p&gt;Sending facts directly in a fixed order and assigning a uniform distribution to facts not yet received achieves this bound for integer bit budgets. This is an expectation over the source and reception state, not a guarantee for each individual table.&lt;/p&gt;

&lt;p&gt;So far, we have measured log loss from the probability assigned to the correct answer. Another approach is to give up on perfect reconstruction and ask how much information is needed if we tolerate some errors. The branch of information theory that studies this trade-off is rate-distortion theory.&lt;/p&gt;

&lt;p&gt;Let 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Z&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 be the original data, 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord accent"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Z&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="accent-body"&gt;&lt;span class="mord"&gt;^&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 its reconstruction, and 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;d&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Z&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord accent"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Z&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="accent-body"&gt;&lt;span class="mord"&gt;^&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 a nonnegative function measuring their difference, called distortion. The rate-distortion function gives the minimum mutual information subject to a bound 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;D&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 on expected distortion:&lt;/p&gt;



&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;D&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;P&lt;/span&gt;&lt;span class="mopen mtight"&gt;(&lt;/span&gt;&lt;span class="mord accent mtight"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;Z&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="accent-body"&gt;&lt;span class="mord mtight"&gt;^&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mrel mtight"&gt;∣&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;Z&lt;/span&gt;&lt;span class="mclose mtight"&gt;)&lt;/span&gt;&lt;span class="mrel mtight"&gt;:&lt;/span&gt;&lt;span class="mspace mtight"&gt;&lt;/span&gt;&lt;span class="mord mathbb mtight"&gt;E&lt;/span&gt;&lt;span class="mopen mtight"&gt;[&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;d&lt;/span&gt;&lt;span class="mopen mtight"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;Z&lt;/span&gt;&lt;span class="mpunct mtight"&gt;,&lt;/span&gt;&lt;span class="mord accent mtight"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;Z&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="accent-body"&gt;&lt;span class="mord mtight"&gt;^&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose mtight"&gt;)]&lt;/span&gt;&lt;span class="mrel mtight"&gt;≤&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;D&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop"&gt;min&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;I&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Z&lt;/span&gt;&lt;span class="mpunct"&gt;;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord accent"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Z&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="accent-body"&gt;&lt;span class="mord"&gt;^&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;

&lt;p&gt;Information is measured in bits. For conventional asymptotic coding of an independent and identically distributed source, this is the limit on the achievable average coding rate. It does not imply that a finite object sent just once can always be encoded in that many bits.&lt;/p&gt;

&lt;p&gt;The Hamming distortion used here is the fraction of positions at which two bit strings differ. For a uniformly distributed binary source, 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;D&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;h&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;D&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 bits per source bit when 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;0&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;≤&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;D&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;≤&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;1/2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
, where 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;h&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;D&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;−&lt;/span&gt;&lt;span class="mord mathnormal"&gt;D&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop"&gt;&lt;span class="mop"&gt;lo&lt;span&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;D&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;D&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop"&gt;&lt;span class="mop"&gt;lo&lt;span&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;D&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 is the binary entropy. Perfect reconstruction requires one bit; if we can tolerate being wrong half the time on average, we need not send anything.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5k61dxmlbisfm4bdmvgc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5k61dxmlbisfm4bdmvgc.png" alt="Direct transmission of facts and the Hamming rate-distortion benchmark" width="800" height="560"&gt;&lt;/a&gt;&lt;/p&gt;
The horizontal axis is Hamming distortion per fact; the vertical axis is information in bits for all 256 facts. This is a different measure from log loss.



&lt;p&gt;This figure compares direct transmission, guessing facts not yet received, with the rate-distortion function. In the next figure, the source is instead a rule chosen uniformly from a finite family, and distortion is the fraction of inputs for which two rules give different answers.&lt;/p&gt;

&lt;p&gt;If there are 256 candidate rules, eight bits suffice to identify a rule given a shared interpreter. For a Bayesian predictor that enumerates all the candidates, the expected KL divergence at four received bits was approximately 0.089 bits for prefix reception and 0.727 bits for random reception. Both are zero at eight bits.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fju70vynnmnr5rl0ti5ex.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fju70vynnmnr5rl0ti5ex.png" alt="Numerical rate-distortion bounds for the finite rule family" width="800" height="581"&gt;&lt;/a&gt;&lt;/p&gt;
Hamming-distortion bounds for the particular finite rule family, not bounds on the reception requirements of neural models.



&lt;p&gt;Before the main experiment, direct encoding of fact tables of 16, 256, and 1,024 bits was checked against the theoretical bounds. The bounds and achievable examples follow from standard entropy inequalities; I make no claim to a new information-theoretic result. If the rule 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;F&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 and facts 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Z&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 are mutually independent and independent of the shared side information 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;S&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
, the same reception budget cannot be allocated to both twice:&lt;/p&gt;



&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;I&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;F&lt;/span&gt;&lt;span class="mpunct"&gt;;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;S&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;I&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Z&lt;/span&gt;&lt;span class="mpunct"&gt;;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;S&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;≤&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;B&lt;/span&gt;&lt;span class="mord"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a href="https://arxiv.org/abs/2610.16233" rel="noopener noreferrer"&gt;Xu et al. (2026)&lt;/a&gt; distinguish information used to learn rules, to memorize rule-independent facts, and to retain excess information about the selection of training samples (Lemma 4.1). Under assumptions concerning rule-decoding error and perfect fact recall, they derive a lower bound on the false-positive rate for sparse facts (Theorem 4.1). Their mutual-information budget during learning and the serialized reception budget here are different quantities, but the underlying question of rules and facts competing for information is shared.&lt;/p&gt;



&lt;br&gt;
&lt;p&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Building a tiny world
&lt;/h2&gt;

&lt;p&gt;Rules and facts are mixed together in natural language, so I constructed an artificial language with just two kinds of questions.&lt;/p&gt;

&lt;p&gt;One kind has answers determined by an arithmetic rule. The other requires consulting a random table. In both cases, the answer is True or False.&lt;/p&gt;

&lt;p&gt;I trained a small Transformer with approximately 100,000 parameters on these questions, then split up the learned weights. The experiment consists of filling in the missing bits, asking questions of the resulting model, and comparing its answers with those of the complete model.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo0t2ymq0vetnpybc43st.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo0t2ymq0vetnpybc43st.png" alt="From the artificial language to evaluation under partial reception" width="800" height="406"&gt;&lt;/a&gt;&lt;/p&gt;
The ground-truth rule and fact table are used to generate training data and score predictions, but are not passed to the component that fills in missing bits. Schematic.



&lt;p&gt;But the first problem arose before I even split the model.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
  The artificial language and evaluation method
  &lt;p&gt;The rules are binary functions of the following form:&lt;/p&gt;



&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;f&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;span class="mpunct mtight"&gt;,&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathbf"&gt;1&lt;/span&gt;&lt;span class="mopen"&gt;[(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;b&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;&lt;span class="mord"&gt;&lt;span class="mord mathrm"&gt;mod&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;257&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;128&lt;/span&gt;&lt;span class="mclose"&gt;]&lt;/span&gt;&lt;span class="mord"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;

&lt;p&gt;Here 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∈&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;…&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;16&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
, 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;b&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∈&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;0&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;…&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;15&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
, and 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∈&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;0&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;…&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;256&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
. The experimental family comprises 256 distinct binary functions (concepts), each defined on 257 input points. The facts consist of a table of 256 bits, assuming an independent, uniform source. This does not establish that the finite table is incompressible or Martin-Löf random.&lt;/p&gt;

&lt;p&gt;I score rule questions seen in training, unseen rule questions, and fact recall separately. Besides accuracy, I measure KL divergence (Kullback–Leibler divergence), which, when the true distribution is a point mass, equals the negative base-two logarithm of the probability assigned to the correct answer. A tied binary prediction receives a score of 0.5.&lt;/p&gt;

&lt;p&gt;Data generation, training, splitting, completion, and scoring were implemented in Julia. The completion component is designed not to receive the evaluation labels. Perturbation tests of the information boundary and cross-checks in a separate process were performed, but complete process isolation for every measurement is not guaranteed.&lt;/p&gt;



&lt;p&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Even the complete models did not work as intended
&lt;/h2&gt;

&lt;p&gt;First, the complete models need to have learned the rule.&lt;/p&gt;

&lt;p&gt;The first three models correctly answered every training example of the rule and every fact question. On unseen rule inputs, however, the results were as follows.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Seen rule inputs&lt;/th&gt;
&lt;th&gt;Unseen rule inputs&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;M1&lt;/td&gt;
&lt;td&gt;100%&lt;/td&gt;
&lt;td&gt;47.7%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;M2&lt;/td&gt;
&lt;td&gt;100%&lt;/td&gt;
&lt;td&gt;64.6%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;M3&lt;/td&gt;
&lt;td&gt;100%&lt;/td&gt;
&lt;td&gt;100%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Memorizing examples and their answers is not the same as learning a rule.&lt;/p&gt;

&lt;p&gt;I redesigned the evaluation set and explored training settings, but the pre-established acceptance criteria were still not met. I stopped the original confirmatory experiment.&lt;/p&gt;

&lt;p&gt;However, four pilot models from the redesign were available. Rather than selecting the best ones, I used all four in a separate exploratory experiment to see what happened under partial reception.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
  Preregistration and the stopping decision
  &lt;p&gt;In the initial training experiment (Phase 1A), only one of three models met the generalization criterion. An extrapolation issue in the evaluation split prompted a redesign of the training experiment (Phase 1A').&lt;/p&gt;

&lt;p&gt;The redesigned evaluation set for basic generalization is called G1. From scattered unseen inputs consisting of new combinations of tokens already encountered in training, we select items for which every candidate rule consistent with the training examples agrees on the answer. There are 22 such items for each of the two sources used here. The acceptance criterion is at least 90% accuracy and mean KL divergence below that of the zero-reception Bayesian predictor with a uniform prior over the rules. Nearest-neighbor interpolation can also satisfy this criterion, so passing it does not guarantee that the underlying rule has been learned.&lt;/p&gt;

&lt;p&gt;Three of the four pilots trained with fixed settings met G1. However, an additional hyperparameter search failed to meet its selection criteria, so the experiment was stopped according to plan.&lt;/p&gt;

&lt;p&gt;The planned formal partial-reception experiment (Phase 1B), further comparisons of splitting and completion methods (Phase 2), and training for missing-weight tolerance (Phase 3) were not carried out. The following exploratory work is not a substitute confirmatory experiment and does not establish or refute the original hypothesis. It includes evaluation sets for which generalization is poor even with the complete model.&lt;/p&gt;



&lt;p&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Splitting the model
&lt;/h2&gt;

&lt;p&gt;The learned weights are quantized into eight-bit sign-magnitude integers and arranged in two different orders.&lt;/p&gt;

&lt;p&gt;In fixed-block encoding (FB), individual weights are sent together. In bitplane encoding (BP), the sign and most significant magnitude bits are sent across the whole model first.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F66x03nx55fqxp1g1e2lm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F66x03nx55fqxp1g1e2lm.png" alt="Fixed-block and bitplane encoding" width="800" height="596"&gt;&lt;/a&gt;&lt;/p&gt;
A schematic example in which the first 16 of the same 32 bits have been received. Blue denotes received bits; gray denotes missing bits.



&lt;p&gt;Missing bits are filled with zeros or by tossing a fair coin for each bit. In addition to prefix reception, I compare random missing chunks. There is no additional training to make the model robust to missing bits.&lt;/p&gt;

&lt;p&gt;In the figures that follow, d1 and d2 denote two different pairs of a rule and a fact table, and s1 and s2 denote two pairs of training random seeds. For example, d1_s2 is the model trained on the first source using the second pair of seeds.&lt;/p&gt;

&lt;p&gt;In addition to Lee et al. (2021), related work includes &lt;a href="https://proceedings.mlr.press/v235/park24e.html" rel="noopener noreferrer"&gt;Any-Precision LLM&lt;/a&gt; by Park et al. (2024), which optimizes quantization from lower to higher bit widths. Devvrit et al. (2024) use &lt;a href="https://arxiv.org/abs/2310.07707" rel="noopener noreferrer"&gt;MatFormer&lt;/a&gt; to construct nested submodels during training, while Wang et al. (2025) use &lt;a href="https://arxiv.org/abs/2410.23918" rel="noopener noreferrer"&gt;BitStack&lt;/a&gt; to decompose weights into residual blocks that can be added as memory permits. The aim here is not to introduce a new delivery method that outperforms those systems, but to measure different capabilities under simple splitting and completion schemes.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
  Partial-reception conditions
  &lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Item&lt;/th&gt;
&lt;th&gt;Condition&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Models&lt;/td&gt;
&lt;td&gt;2 sources × 2 training seeds = 4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Quantization&lt;/td&gt;
&lt;td&gt;Sign-magnitude int8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Splitting&lt;/td&gt;
&lt;td&gt;FB / BP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reception&lt;/td&gt;
&lt;td&gt;Prefix / Random&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Completion&lt;/td&gt;
&lt;td&gt;Zero / Bernoulli(1/2)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Intermediate payload reception fractions&lt;/td&gt;
&lt;td&gt;25, 50, 75, 87.5, 95%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Total encoded length&lt;/td&gt;
&lt;td&gt;815,056 bits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scale header&lt;/td&gt;
&lt;td&gt;960 bits for 30 tensors&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Evaluations&lt;/td&gt;
&lt;td&gt;984 (246 per model)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Model names and abbreviations in the figures:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Label&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;d1&lt;/td&gt;
&lt;td&gt;Source 1: rule 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;b&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;13&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;12&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 and its random fact table&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;d2&lt;/td&gt;
&lt;td&gt;Source 2: rule 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;b&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;16&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;13&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 and a different random fact table&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;s1&lt;/td&gt;
&lt;td&gt;Seed pair 1 (initialization 810001, data order 820001)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;s2&lt;/td&gt;
&lt;td&gt;Seed pair 2 (initialization 810002, data order 820002)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pilot_d1_s1, etc.&lt;/td&gt;
&lt;td&gt;Pilot model identified by source and seed pair; pilot_ may be omitted in the figures&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;FB / BP&lt;/td&gt;
&lt;td&gt;Fixed block / Bitplane&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Prefix / Random&lt;/td&gt;
&lt;td&gt;Reception from the start of the stream / Reception of random chunks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;zero / bern (Bernoulli)&lt;/td&gt;
&lt;td&gt;Fill missing bits with zeros / Independent fair coin tosses&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;f32 / int8full&lt;/td&gt;
&lt;td&gt;Original Float32 model / Fully received eight-bit quantized model&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Both the rule and the fact table differ between d1 and d2. Differences between sources cannot be attributed to the rule alone.&lt;/p&gt;

&lt;p&gt;For evaluation-set labels, rule_train denotes seen rule inputs, fact denotes recall of learned facts, heldout denotes all unseen rule inputs, and g1 (scatter) denotes the scattered basic-generalization set described above. The region set contains a contiguous region withheld from training. G2 is a descriptive measure of extrapolation beyond simple reference predictors; for eligible rules, it divides the relevant evaluation items into an extrapolation set (g2_extrap) and the remaining set (g2_rest). G1 and G2 are local experimental labels, not standard benchmarks.&lt;/p&gt;

&lt;p&gt;The scale header is assumed to be fully available whenever the reception budget is positive, an optimistic condition. Random reception uses five masks, and Bernoulli completion uses three repetitions. The fully received quantized model is the baseline; quantization differences from the Float32 model are recorded separately.&lt;/p&gt;



&lt;br&gt;
&lt;p&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Capability recovery curves
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffhv88yva41413jgy87fl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffhv88yva41413jgy87fl.png" alt="Accuracy across all 1,152 trajectories" width="800" height="512"&gt;&lt;/a&gt;&lt;/p&gt;
The horizontal axis is the fraction of actually received bits, including the header. The vertical axis is accuracy. Lines interpolate between measured points.



&lt;p&gt;When fixed blocks were received in order and the remainder was filled with zeros, accuracy stayed at 50% even at 95% reception under the tensor ordering used here. This is likely because output-side tensors are located at the end of the stream.&lt;/p&gt;

&lt;p&gt;In contrast, receiving the most significant bitplanes first sometimes allowed high accuracy before the full model arrived.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2s22ayimbtsm1uobzd2q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2s22ayimbtsm1uobzd2q.png" alt="Bitplane prefix recovery curves grouped by task" width="800" height="616"&gt;&lt;/a&gt;&lt;/p&gt;
The 96 trajectories are colored by seen rule inputs, unseen rule inputs, and fact recall.



&lt;p&gt;In one model, at 75% reception, accuracy was 99% on seen rule inputs but 71% on facts. All four models showed a tendency for fact recall to recover later than rule-related metrics under bitplane prefix reception.&lt;/p&gt;

&lt;p&gt;This resembles my original expectation. But not all the models generalized to unseen inputs, and the rule and fact tasks differ in their construction. I cannot attribute the difference to compressibility.&lt;/p&gt;

&lt;p&gt;Differences in robustness between capabilities are not themselves new observations. &lt;a href="https://aclanthology.org/2026.emnlp-main.2367/" rel="noopener noreferrer"&gt;Sengupta et al. (2026)&lt;/a&gt; report that reasoning tasks tend to be more robust than question-answering tasks under pruning of large language models (§1, RQ1, Fig. 1). However, question answering is not the same task as random-fact recall, and pruning is not the same operation as bitplane reception.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
  Curves by method and caveats about aggregation
  &lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F740th1i6u0ewoju3tick.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F740th1i6u0ewoju3tick.png" alt="Fixed block, prefix reception" width="800" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fze9mn5vqvhciza9fn0ao.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fze9mn5vqvhciza9fn0ao.png" alt="Fixed block, random reception" width="800" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpihrtltuq501chdkrpzg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpihrtltuq501chdkrpzg.png" alt="Bitplane, prefix reception" width="800" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fknkt0snh7ij44xsakfxy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fknkt0snh7ij44xsakfxy.png" alt="Bitplane, random reception" width="800" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Nominal payload fraction&lt;/th&gt;
&lt;th&gt;Accuracy ≤60%&lt;/th&gt;
&lt;th&gt;Accuracy ≥90%&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;25%&lt;/td&gt;
&lt;td&gt;1131/1152&lt;/td&gt;
&lt;td&gt;1/1152&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;50%&lt;/td&gt;
&lt;td&gt;1107/1152&lt;/td&gt;
&lt;td&gt;7/1152&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;75%&lt;/td&gt;
&lt;td&gt;1053/1152&lt;/td&gt;
&lt;td&gt;54/1152&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;87.5%&lt;/td&gt;
&lt;td&gt;999/1152&lt;/td&gt;
&lt;td&gt;70/1152&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;95%&lt;/td&gt;
&lt;td&gt;883/1152&lt;/td&gt;
&lt;td&gt;140/1152&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The 1,152 trajectories are combinations of model, evaluation set, method, mask, and completion repetition. Random reception has five times as many trajectories as prefix reception, and the evaluation sets overlap. These counts do not estimate the probability of recovery across 1,152 independent models.&lt;/p&gt;

&lt;p&gt;Uniform predictions under FB/Prefix/zero were observed in all 140 evaluation cells, but other tensor orders were not tested. The 99% versus 71% example at 75% BP reception is a comparison between seen rule inputs and facts for pilot_d2_s1, not a comparison involving unseen inputs.&lt;/p&gt;



&lt;p&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  More information can make a model more wrong
&lt;/h2&gt;

&lt;p&gt;I had expected performance to improve gradually, as with an image. Instead, it could get worse before improving again.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbuj2ewuc5puocpy4h1wm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbuj2ewuc5puocpy4h1wm.png" alt="A measured example of nonmonotonic recovery" width="799" height="412"&gt;&lt;/a&gt;&lt;/p&gt;
Three measured points for pilot_d1_s2, G1, BP/Prefix/zero.



&lt;p&gt;In a more extreme example, receiving 95% of the fixed blocks and filling the remainder randomly reduced accuracy on binary rule questions to just a few percent. Yet the predicted probabilities were close to 0.5. Although the model was barely confident, it leaned slightly toward the wrong answer on many inputs.&lt;/p&gt;

&lt;p&gt;Large drops in accuracy from corrupted weights have also been reported in &lt;a href="https://link.springer.com/article/10.1007/s11227-024-06693-7" rel="noopener noreferrer"&gt;Catalán et al.'s (2025) research on hardware faults&lt;/a&gt;. What caught my attention here was not simply low accuracy, but a systematic reversal of the predictions despite low confidence.&lt;/p&gt;

&lt;p&gt;Could the errors resemble the predictions of a different rule? Or perhaps only the output side has been reversed. These are possible interpretations, not identified mechanisms.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
  Nonmonotonicity and low-confidence reversal
  &lt;p&gt;For pilot_d1_s2 under BP/Prefix/zero, G1 accuracy was 81.8%, 77.3%, and 86.4% at 75%, 87.5%, and 95% reception, respectively; KL divergence was 0.859, 2.01, and 0.76 bits. With only 22 G1 items, even one confidently wrong prediction can substantially change the mean KL divergence.&lt;/p&gt;

&lt;p&gt;At 95% FB/Prefix/Bernoulli reception, median accuracy on d2's rule-related evaluation sets ranged from 0.03 to 0.09, with KL divergence around 1.1–1.2 bits. In one example evaluated on all 257 inputs, accuracy was 0.031 and the distance between hard binary predictions and the true rule, scoring ties as 0.5, was 0.969.&lt;/p&gt;

&lt;p&gt;The real-valued scores a neural network's output layer assigns to candidate answers before converting them into probabilities are called logits. For 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;K&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 candidate answers, softmax is a function that maps the vector of logits 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;&lt;span class="mord mathbf"&gt;ℓ&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;ℓ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;…&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;ℓ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;K&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 to a probability distribution. The predicted probability of candidate 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 is defined as&lt;/p&gt;



&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop"&gt;&lt;span class="mord mathrm"&gt;softmax&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;&lt;span class="mord mathbf"&gt;ℓ&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mord mathnormal"&gt;i&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mop op-symbol small-op"&gt;∑&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;j&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;K&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop"&gt;exp&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;ℓ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;j&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mop"&gt;exp&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;ℓ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;i&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;…&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;K&lt;/span&gt;&lt;span class="mord"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;

&lt;p&gt;It exponentiates each logit and divides by the sum of the exponentials. All probabilities are positive and sum to one. A candidate with the largest logit has the largest probability, but the other candidates also receive positive probabilities.&lt;/p&gt;

&lt;p&gt;For binary classification, let the True and False logits be 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;ℓ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 and 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;ℓ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
. Their difference 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;z&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;ℓ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;ℓ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 alone determines the predicted probability 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 of True:&lt;/p&gt;



&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop"&gt;exp&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;−&lt;/span&gt;&lt;span class="mord mathnormal"&gt;z&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;z&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop"&gt;ln&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;

&lt;p&gt;This difference is the log odds, the natural logarithm of the probability ratio. At zero, both answers are equally likely; a positive value favors True, and a negative value favors False. Larger absolute values correspond to probabilities closer to zero or one.&lt;/p&gt;

&lt;p&gt;Suppose missing bits simply transform the logit difference into 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;−&lt;/span&gt;&lt;span class="mord mathnormal"&gt;ε&lt;/span&gt;&lt;span class="mord mathnormal"&gt;z&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
, where 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;ε&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;&amp;gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
. Accuracy then becomes one minus the original accuracy (with ties scored as 0.5), while small 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;ε&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 makes the predicted probabilities approach 0.5.&lt;/p&gt;

&lt;p&gt;Thus low-confidence reversal could result just from changes in the sign and scale of the output head, without the model acquiring a different internal rule. No intervention experiment was performed to establish this. Useful next steps would be to correlate logit differences with those of the fully received model and to restore only the output-side tensors.&lt;/p&gt;

&lt;p&gt;For nested received information, the expected conditional entropy for an optimal Bayesian predictor cannot increase:&lt;/p&gt;



&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;H&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Y&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;≤&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;H&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Y&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mord"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;

&lt;p&gt;But a neural network with completed weights is not that optimal predictor. The observed nonmonotonicity does not contradict information theory. Doshi et al. (2024) give examples of improved performance after pruning, and the empirical curves of Sengupta et al. (2026) also exhibit local rises and falls. Nonmonotonicity itself is not claimed as novel.&lt;/p&gt;



&lt;br&gt;
&lt;p&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Far from the right rule, but still close to a rule?
&lt;/h2&gt;

&lt;p&gt;At this point I changed my perspective.&lt;/p&gt;

&lt;p&gt;For each of the 256 rules, listing its answers to the 257 possible inputs gives a point in a 257-dimensional space. The partially received model's predicted probabilities of True form a point in the same space.&lt;/p&gt;

&lt;p&gt;We can then distinguish the distance to the true rule from the distance to the nearest rule, whichever one it is.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fk19f6hy3yyle712z469y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fk19f6hy3yyle712z469y.png" alt="Distances to the true and nearest rules" width="800" height="387"&gt;&lt;/a&gt;&lt;/p&gt;
A schematic two-dimensional representation of the 257-dimensional space.



&lt;p&gt;A prediction can be far from the true rule and still be close to another rule.&lt;/p&gt;

&lt;p&gt;Using the saved outputs of the 984 evaluations, I measured these distances. The model outputs tended to be closer to the target rule family than controls with randomly permuted input positions or random function families.&lt;/p&gt;

&lt;p&gt;But when the candidates were expanded to a wider family, the outputs were not demonstrably closer in a specific way to the original 256 arithmetic rules.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1osf3siqc2f8hyd8fr2n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1osf3siqc2f8hyd8fr2n.png" alt="Soft-distance trajectories under partial reception" width="799" height="416"&gt;&lt;/a&gt;&lt;/p&gt;
Measured distances to the true concept, the nearest concept, and other reference points.



&lt;p&gt;I cannot yet say that the model is being drawn toward a particular arithmetic structure. Even so, I find it interesting that geometry offers a way to investigate not only how accurate a model is, but &lt;strong&gt;what kind of errors it makes&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
  Concept geometry, null controls, and limitations
  &lt;p&gt;Let 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;F&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 be the rule family, 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;T&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∈&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;F&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 the true rule, and 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 the predicted probability of True.&lt;/p&gt;



&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;D&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;T&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;257&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;x&lt;/span&gt;&lt;span class="mrel mtight"&gt;=&lt;/span&gt;&lt;span class="mord mtight"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop op-symbol large-op"&gt;∑&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;256&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;∣&lt;/span&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;T&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mord"&gt;∣&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;



&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;D&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;C&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;f&lt;/span&gt;&lt;span class="mrel mtight"&gt;∈&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;F&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop"&gt;min&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;257&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;x&lt;/span&gt;&lt;span class="mrel mtight"&gt;=&lt;/span&gt;&lt;span class="mord mtight"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop op-symbol large-op"&gt;∑&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;256&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;∣&lt;/span&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;f&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mord"&gt;∣&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;

&lt;p&gt;By definition, 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;D&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;T&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;D&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;C&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;≥&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
. If the difference is zero, the true rule belongs to the set of nearest concepts. But under uniform predictions all candidates tie, so this does not imply unique identification.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fr6h8epnmywqdxdth12ys.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fr6h8epnmywqdxdth12ys.png" alt="Distance matrix of the finite rule family" width="800" height="845"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftaip9b8wrgaps847rcuz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftaip9b8wrgaps847rcuz.png" alt="Gap between the distance to the true concept and the nearest-concept distance" width="799" height="290"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Compared with the input-position permutation control (50 repetitions), observed distances were lower by 0.03–0.07 on average per model; compared with random function families (10 repetitions), they were lower by 0.022–0.059. However, when the family was expanded to 32,896 distinct functions, a function outside the original family was strictly closer than its nearest member in 66–72% of conditions.&lt;/p&gt;

&lt;p&gt;The number of null repetitions was smaller than planned, and the observations are not independent. These results are not formal p-values. There was no additional training or inference: this was a post-hoc analysis of saved logits.&lt;/p&gt;

&lt;p&gt;I also computed covering and packing numbers for the finite rule family (packing counts how many concepts can be selected with at least a specified separation), and rate-distortion bounds. Nearest-neighbor projection and Hamming distance are established tools of learning theory and information theory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmfymahcco7bmfakp8dye.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmfymahcco7bmfakp8dye.png" alt="Covering and packing bounds for the finite rule family" width="800" height="583"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;&lt;/p&gt;

&lt;p&gt;The target family contains 256 functions. But how many inputs can be assigned arbitrary combinations of answers? In statistical learning theory this is measured by the VC dimension. For this family I found that it lies between five and seven. It characterizes one aspect of the complexity of the object being learned, but does not directly tell us how many bits of the model's weights must be received.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
  VC dimension and its role in learning theory
  &lt;p&gt;The Vapnik–Chervonenkis dimension, or VC dimension, measures how freely a family of binary functions can assign labels to a finite set of inputs.&lt;/p&gt;

&lt;p&gt;Let 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;X&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 be the input space and 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;F&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;⊆&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;0&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;X&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 a family of binary functions. For a finite subset 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;A&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;⊆&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;X&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
, if&lt;/p&gt;



&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;F&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∣&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;f&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∣&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;:&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;f&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∈&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;F&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;

&lt;p&gt;equals the set of all binary functions on 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
, namely 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;0&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
, we say that 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;F&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 shatters 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
. The VC dimension is the supremum of the sizes of sets that can be shattered:&lt;/p&gt;



&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop"&gt;&lt;span class="mord mathrm"&gt;VCdim&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;F&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop"&gt;sup&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∣&lt;/span&gt;&lt;span class="mord mathnormal"&gt;A&lt;/span&gt;&lt;span class="mord"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;:&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;A&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;⊆&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;X&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;∣&lt;/span&gt;&lt;span class="mord mathnormal"&gt;A&lt;/span&gt;&lt;span class="mord"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;∞&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;∣&lt;/span&gt;&lt;span class="mord mathnormal"&gt;F&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∣&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;∣&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;2&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;∣&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;A&lt;/span&gt;&lt;span class="mord mtight"&gt;∣&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;

&lt;p&gt;For example, the family of threshold functions 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;f&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathbf"&gt;1&lt;/span&gt;&lt;span class="mopen"&gt;[&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;≥&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;t&lt;/span&gt;&lt;span class="mclose"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 on the real line can label any single point either zero or one. But for two points 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
, no threshold labels them one and zero, respectively. The VC dimension is therefore one, even though there are infinitely many possible thresholds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Sauer–Shelah lemma.&lt;/strong&gt; Let 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;d&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop"&gt;&lt;span class="mord mathrm"&gt;VCdim&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;F&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;∞&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
, and let the growth function be the maximum number of label patterns attainable on 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;m&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 points:&lt;/p&gt;



&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;Π&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;F&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;m&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;A&lt;/span&gt;&lt;span class="mrel mtight"&gt;⊆&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;X&lt;/span&gt;&lt;span class="mpunct mtight"&gt;,&lt;/span&gt;&lt;span class="mspace mtight"&gt;&lt;span class="mtight"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord mtight"&gt;∣&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;A&lt;/span&gt;&lt;span class="mord mtight"&gt;∣&lt;/span&gt;&lt;span class="mrel mtight"&gt;=&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;m&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop"&gt;max&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;∣&lt;/span&gt;&lt;span class="mord mathnormal"&gt;F&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∣&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;∣&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;

&lt;p&gt;Then, for 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;m&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;≤&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;∣&lt;/span&gt;&lt;span class="mord mathnormal"&gt;X&lt;/span&gt;&lt;span class="mord"&gt;∣&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
,&lt;/p&gt;



&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;Π&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;F&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;m&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;≤&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;i&lt;/span&gt;&lt;span class="mrel mtight"&gt;=&lt;/span&gt;&lt;span class="mord mtight"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop op-symbol large-op"&gt;∑&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;d&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen delimcenter"&gt;&lt;span class="delimsizing size3"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;m&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;&lt;span class="delimsizing size3"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;

&lt;p&gt;where binomial coefficients with 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;i&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;&amp;gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;m&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 are zero. With 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;d&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 fixed, the number of realizable patterns grows at most polynomially in 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;m&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
, rather than as the full 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;2&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;m&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 binary patterns.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connection to PAC learning.&lt;/strong&gt; Under the usual measurability conditions, &lt;a href="https://doi.org/10.1145/76359.76371" rel="noopener noreferrer"&gt;Blumer et al. (1989)&lt;/a&gt; established the equivalence of finite VC dimension and distribution-free PAC (Probably Approximately Correct) learnability for binary concept classes. In the realizable setting, the true function belongs to the class, and inputs are independently sampled from an unknown distribution. With enough examples, it is possible to learn a predictor whose true misclassification probability is at most 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;ε&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
, with probability at least 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;δ&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://jmlr.org/papers/v17/15-389.html" rel="noopener noreferrer"&gt;Hanneke (2016)&lt;/a&gt; gives the optimal sample complexity of realizable binary PAC learning, in the usual nontrivial parameter ranges, as&lt;/p&gt;



&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;Θ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;&lt;span class="delimsizing size3"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;ε&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;d&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop"&gt;ln&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;1/&lt;/span&gt;&lt;span class="mord mathnormal"&gt;δ&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;&lt;span class="delimsizing size3"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;

&lt;p&gt;This concerns the number of samples needed by an appropriate learning algorithm in the worst case over distributions. It does not guarantee the success of an arbitrary neural network's training procedure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The rule family used here.&lt;/strong&gt; Enumeration of the 256 concepts confirmed that every one of the 32 binary label patterns on 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;A&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;57&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;76&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;127&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;128&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;224&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 is realized by some function. The VC dimension is therefore at least five.&lt;/p&gt;

&lt;p&gt;Conversely, if eight points could be shattered, the 256 functions would correspond bijectively to all 256 eight-bit patterns. Exactly 128 functions would have to return one at each point, and all partial patterns would have to occur equally often. Using these necessary conditions to prune the search, I exhaustively searched for shattered eight-point sets and found none. Hence,&lt;/p&gt;



&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;5&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;≤&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop"&gt;&lt;span class="mord mathrm"&gt;VCdim&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;F&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;≤&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;7.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;

&lt;p&gt;Heuristic searches did not find shattered sets of six or seven points, but this does not prove their nonexistence. The exact value remains undetermined.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fi3u4rbf4too4exco2vr1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fi3u4rbf4too4exco2vr1.png" alt="Growth-function search results for the rule family" width="800" height="560"&gt;&lt;/a&gt;&lt;/p&gt;
Lower bounds obtained by search and theoretical upper bounds. The empirical lower bounds are not necessarily exact maxima.



&lt;p&gt;The number of training examples in PAC learning and the number of model bits received here are different quantities. The fixed evaluation split is not an independently and identically distributed sample, either. VC-dimension generalization guarantees cannot be directly applied to partially received models. I computed the dimension to characterize the richness of the target rule family alongside the geometry of model outputs.&lt;/p&gt;



&lt;br&gt;
&lt;p&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A model's reception characteristics
&lt;/h2&gt;

&lt;p&gt;This experiment did not establish the general conclusion that rules are more robust to partial reception than facts.&lt;/p&gt;

&lt;p&gt;What it did show, for a particular small set of models, was that recovery curves vary greatly with the splitting method and can even exhibit systematic low-confidence reversals. It also provided a way to examine recovery by distinguishing distance to the true rule from distance to the rule family.&lt;/p&gt;

&lt;p&gt;In the portions of the literature examined so far, I have not found an experiment that treats missing weights in terms of reception budget and measures both low-confidence systematic reversal and distance to a finite concept class on the same outputs. The general phenomenon of performance collapse due to bit errors or pruning is already known. Neither the generality nor the novelty of these observations has been established, and independent replication is especially important.&lt;/p&gt;

&lt;h3&gt;
  
  
  What did the experiment tell us?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Q. Can we use a model before its download finishes?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A. In some cases, yes, for the small Transformer studied here. Bitplane reception in particular sometimes yielded high accuracy before the whole model arrived. Inference during reception is already demonstrated in &lt;a href="https://arxiv.org/abs/2110.00916" rel="noopener noreferrer"&gt;Lee et al. (2021)&lt;/a&gt;. Related approaches include variable-precision models in &lt;a href="https://proceedings.mlr.press/v235/park24e.html" rel="noopener noreferrer"&gt;Park et al. (2024)&lt;/a&gt;, nested submodels in &lt;a href="https://arxiv.org/abs/2310.07707" rel="noopener noreferrer"&gt;Devvrit et al. (2024)&lt;/a&gt;, and progressive weight reconstruction in &lt;a href="https://arxiv.org/abs/2410.23918" rel="noopener noreferrer"&gt;Wang et al. (2025)&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q. Does receiving the same amount of data give a model the same capabilities?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A. No. With the tensor order used here, receiving fixed blocks in order and filling the remainder with zeros left binary accuracy at 50% even at 95% reception. Bitplane reception sometimes achieved high accuracy earlier. What is received matters, not just how much. Differences in the importance of individual bits have also been studied by Lee et al. (2021) and &lt;a href="https://link.springer.com/article/10.1007/s11227-024-06693-7" rel="noopener noreferrer"&gt;Catalán et al. (2025)&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q. Do rules recover earlier than facts?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A. Under bitplane prefix reception, fact recall tended to recover later than rule-related metrics in all four pilot models. However, some evaluation sets did not exhibit successful rule generalization, and we cannot attribute the difference to compressibility. &lt;a href="https://arxiv.org/abs/2310.13061" rel="noopener noreferrer"&gt;Doshi et al. (2024)&lt;/a&gt; and &lt;a href="https://arxiv.org/abs/2603.25579" rel="noopener noreferrer"&gt;Farné et al. (2026)&lt;/a&gt; study differences between rule generalization and memorization of examples or facts. &lt;a href="https://aclanthology.org/2026.emnlp-main.2367/" rel="noopener noreferrer"&gt;Sengupta et al. (2026)&lt;/a&gt; also report differences in robustness between capabilities under pruning. The original hypothesis itself remains unconfirmed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q. Must accuracy increase as more data arrives?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A. No. In one example, accuracy changed from 81.8% to 77.3% and then to 86.4% as reception increased from 75% to 87.5% and then to 95%. Nonmonotonic changes in performance under removal of model weights also occur in the pruning experiments of Doshi et al. (2024) and Sengupta et al. (2026).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q. Is a low-confidence model equivalent to one that answers randomly?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A. No. We observed systematic reversals with accuracy of only a few percent, even though predicted probabilities were close to 0.5. Severe performance degradation due to weight corruption has also been reported by Catalán et al. (2025). The mechanism behind the low-confidence reversal observed here remains unknown, and a change in the output head alone could potentially explain it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q. Can wrong answers retain rule-like structure?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A. Possibly. Saved outputs tended to be closer to the target rule family than random controls, but expanding the candidate family removed evidence of specific proximity to the original family. Distance-based analysis uses established mathematical tools, but within the literature examined, I have not found a prior experiment measuring this property under the same partial-reception conditions. Rule-like outputs do not establish that the model has acquired a rule internally.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q. Can we determine theoretically how many bits must arrive to recover a given capability?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A. For direct transmission of independent fact tables, we verified a lower bound on log loss and a way to attain it. The limits of coding with tolerated errors are addressed by the rate-distortion theory of &lt;a href="https://gwern.net/doc/cs/algorithm/information/1959-shannon.pdf" rel="noopener noreferrer"&gt;Shannon (1959)&lt;/a&gt;. &lt;a href="https://arxiv.org/abs/2610.16233" rel="noopener noreferrer"&gt;Xu et al. (2026)&lt;/a&gt; study the information budget for learning rules and facts. The VC-dimension bounds computed here also relate to the learning-theoretic results of &lt;a href="https://doi.org/10.1145/76359.76371" rel="noopener noreferrer"&gt;Blumer et al. (1989)&lt;/a&gt; and &lt;a href="https://jmlr.org/papers/v17/15-389.html" rel="noopener noreferrer"&gt;Hanneke (2016)&lt;/a&gt;. However, none of these results directly gives the required reception budget for neural-network weights. That remains an open question.&lt;/p&gt;

&lt;p&gt;There is also the question of what it means for a capability to have recovered. Tasks governed by precise rules, such as the mathematical functions used here, are relatively easy to evaluate because each input has a well-defined correct answer. For generative models such as LLMs, however, there may be multiple valid outputs for the same input, and methods for evaluating output quality and model capabilities are themselves still evolving. Characterizing the reception properties of practical generative models therefore requires considering not only how much data is received, but also what to evaluate and how to evaluate it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Future model delivery
&lt;/h3&gt;

&lt;p&gt;If partial reception becomes a common way of delivering models, perhaps model cards could tell us not only what a model can do at a given reception percentage, but what kinds of mistakes it tends to make.&lt;/p&gt;

&lt;p&gt;A download indicator of 75% might then tell us something about the capabilities of the model, rather than merely the progress of a file transfer. That was the kind of model I initially had in mind.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
  Experiment records, use of AI, reproducibility, and outstanding work
  &lt;p&gt;The experiments were conducted on November 26–27, 2026. The Julia evaluation pipeline, direct encoding, failure to pass the formal acceptance criteria, 984 exploratory partial-reception evaluations, and post-hoc analysis of the saved outputs are recorded separately. Measurement and scoring results were recalculated from saved logits and found to agree. A known regression-test failure (T8), a post-hoc analysis budget overrun, reduced numbers of null repetitions, and some unperformed controls remain.&lt;/p&gt;

&lt;p&gt;AI agents were used in design, implementation, execution, and independent review. Review decisions concern experimental procedures, not proofs of scientific hypotheses.&lt;/p&gt;

&lt;p&gt;The figures were selected from the experimental results available as of November 30, 2026. The experiment repository is private, and this article alone does not yet make the work fully reproducible by third parties. The scope of release of the code, conditions, and raw data will be considered separately. Extrapolation to large models, training for missing-weight tolerance, SVD completion, trade-offs between completion computation and communication, and guarantees under worst-case loss remain untested.&lt;/p&gt;



&lt;p&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Afterword
&lt;/h2&gt;

&lt;p&gt;Incidentally, while conducting this experiment, I was acutely aware that what I was running short of was not giga, but the usage allowance of my flat-rate AI subscription. I have also been wondering whether "I don't have enough tokens" is the AI equivalent of "I don't have enough giga" in mobile communications. As a way of describing the allowance, I find tokens less precise, more ambiguous, and harder to understand than giga. I hope a more fitting expression will emerge.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Lee et al., &lt;a href="https://arxiv.org/abs/2110.00916" rel="noopener noreferrer"&gt;Progressive Transmission and Inference of Deep Learning Models&lt;/a&gt;, ICMLA 2021.&lt;/li&gt;
&lt;li&gt;Doshi et al., &lt;a href="https://arxiv.org/abs/2310.13061" rel="noopener noreferrer"&gt;To Grok or not to Grok: Disentangling Generalization and Memorization on Corrupted Algorithmic Datasets&lt;/a&gt;, ICLR 2024.&lt;/li&gt;
&lt;li&gt;Farné et al., &lt;a href="https://arxiv.org/abs/2603.25579" rel="noopener noreferrer"&gt;The Rules-and-Facts Model for Simultaneous Generalization and Memorization in Neural Networks&lt;/a&gt;, arXiv:2603.25579, 2026.&lt;/li&gt;
&lt;li&gt;Xu et al., &lt;a href="https://arxiv.org/abs/2610.16233" rel="noopener noreferrer"&gt;Learning Rules, Memorizing Facts: An Information-Theoretic View of Hallucination&lt;/a&gt;, arXiv:2610.16233, 2026 (Lemma 4.1, Theorem 4.1).&lt;/li&gt;
&lt;li&gt;Park et al., &lt;a href="https://proceedings.mlr.press/v235/park24e.html" rel="noopener noreferrer"&gt;Any-Precision LLM: Low-Cost Deployment of Multiple, Different-Sized LLMs&lt;/a&gt;, ICML 2024.&lt;/li&gt;
&lt;li&gt;Devvrit et al., &lt;a href="https://arxiv.org/abs/2310.07707" rel="noopener noreferrer"&gt;MatFormer: Nested Transformer for Elastic Inference&lt;/a&gt;, NeurIPS 2024.&lt;/li&gt;
&lt;li&gt;Wang et al., &lt;a href="https://arxiv.org/abs/2410.23918" rel="noopener noreferrer"&gt;BitStack: Any-Size Compression of Large Language Models in Variable Memory Environments&lt;/a&gt;, ICLR 2025.&lt;/li&gt;
&lt;li&gt;Sengupta et al., &lt;a href="https://aclanthology.org/2026.emnlp-main.2367/" rel="noopener noreferrer"&gt;Pruning Laws for Large Language Models&lt;/a&gt;, EMNLP 2026.&lt;/li&gt;
&lt;li&gt;Catalán, Flich, Hernández, &lt;a href="https://link.springer.com/article/10.1007/s11227-024-06693-7" rel="noopener noreferrer"&gt;Exploiting neural networks bit-level redundancy to mitigate the impact of faults at inference&lt;/a&gt;, The Journal of Supercomputing 81, 183, 2025 (published online November 15, 2024) (§3, §5).&lt;/li&gt;
&lt;li&gt;Blumer, Ehrenfeucht, Haussler, Warmuth, &lt;a href="https://doi.org/10.1145/76359.76371" rel="noopener noreferrer"&gt;Learnability and the Vapnik-Chervonenkis Dimension&lt;/a&gt;, JACM 36(4), 1989.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hanneke, &lt;a href="https://jmlr.org/papers/v17/15-389.html" rel="noopener noreferrer"&gt;The Sample Complexity of PAC Learning&lt;/a&gt;, JMLR 17, 2016.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Shannon, &lt;a href="https://gwern.net/doc/cs/algorithm/information/1959-shannon.pdf" rel="noopener noreferrer"&gt;Coding Theorems for a Discrete Source With a Fidelity Criterion&lt;/a&gt;, IRE International Convention Record, 1959.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Relevant passages of references 1–9 were examined. References 10 and 11 are included as sources for fundamental results on VC dimension and PAC learning, and reference 12 as a foundational source for rate-distortion theory. A complete reading of every page, appendix, and proof, and a comprehensive novelty search, remain outstanding.&lt;/p&gt;

</description>
      <category>transformer</category>
      <category>lossy</category>
      <category>transmission</category>
      <category>experiment</category>
    </item>
    <item>
      <title>Formalizing Lazy Evaluation in Les with Lean — From Observation to an Executable Model, and on to Proofs</title>
      <dc:creator>Kentaro Goto</dc:creator>
      <pubDate>Fri, 20 Nov 2026 19:27:39 +0000</pubDate>
      <link>https://dev.to/gotoken/formalizing-lazy-evaluation-in-les-with-lean-from-observation-to-an-executable-model-and-on-to-1o39</link>
      <guid>https://dev.to/gotoken/formalizing-lazy-evaluation-in-les-with-lean-from-observation-to-an-executable-model-and-on-to-1o39</guid>
      <description>&lt;p&gt;I have started an experiment: observe the implementation of a small programming language, model its behavior in Lean, and prove properties of that model.&lt;/p&gt;

&lt;p&gt;The subject is &lt;a href="https://github.com/unak/les" rel="noopener noreferrer"&gt;Les&lt;/a&gt;, a scripting language that usa (unak on GitHub and elsewhere) is implementing in Go.&lt;/p&gt;

&lt;p&gt;The experiment lives in the repository &lt;a href="https://github.com/gotoken/les-spec" rel="noopener noreferrer"&gt;gotoken/les-spec&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The aim here is not to port the evaluator written in Go to another language. I run Les programs, observe their behavior, and consult the Go code when necessary to infer a conceptual model that explains that behavior: what information the evaluator keeps and what rules govern its computation. I describe that model in &lt;a href="https://lean-lang.org/" rel="noopener noreferrer"&gt;Lean&lt;/a&gt;, a language in which we can both write programs and have mathematical proofs checked.&lt;/p&gt;

&lt;p&gt;The goal is not merely to check that individual programs behave as expected, but &lt;strong&gt;to express properties of the model as mathematical propositions and prove that they hold in every case satisfying their hypotheses&lt;/strong&gt;. There can be infinitely many inputs and intermediate execution states, so this is a different task from testing.&lt;/p&gt;

&lt;p&gt;In normal execution, the Les CLI first performs lexical analysis and parsing to construct an abstract syntax tree (AST), then performs type inference and checking, and finally runs the program with the Go evaluator. This formalization focuses primarily on that last stage.&lt;/p&gt;

&lt;p&gt;The Lean evaluator therefore does not receive the Les source code directly. A tool called &lt;code&gt;lesdump&lt;/code&gt; reuses the Go implementation's lexer, parser, and type inference to produce a JSON representation of the AST and type analysis results. Lean reads and evaluates that representation. The original Go CLI's execution results are collected separately for comparison.&lt;/p&gt;

&lt;p&gt;As of November 15, 2026, I have an executable Lean evaluator for part of Les and have confirmed that it agrees with the Go implementation on what can be observed for 35 programs. I have also proved internal properties of the model in Lean, including that a delayed computation which finishes successfully has its result stored, and that requesting the value again from the same storage location does not repeat the computation. I also constructed a concrete example satisfying the theorem's hypotheses.&lt;/p&gt;

&lt;p&gt;I have not formalized all of Les. Nor have I proved that the Go implementation and the Lean model are mathematically equivalent. Inferring a specification from observations, running the model and comparing it against the original implementation, and proving properties of the model itself are separate tasks.&lt;/p&gt;

&lt;p&gt;This post sets out what I built, how I went about it, what I learned, and where I want to go next.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. What kind of language is Les?
&lt;/h2&gt;

&lt;p&gt;Les (Lazy Evaluation Script) is a scripting language implemented in Go, with an indentation-based syntax similar to Python's.&lt;/p&gt;

&lt;p&gt;It offers Ruby-like concise notation, a type system influenced by Go, type inference, structural interfaces, and more.&lt;/p&gt;

&lt;p&gt;Its most distinctive feature is that &lt;strong&gt;variables, function arguments, and so on are, as a rule, evaluated only when needed&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Consider the following program.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;choose&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;first&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;second&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;first&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="nf"&gt;choose&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This program prints &lt;code&gt;42&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Under ordinary eager evaluation (call-by-value), &lt;code&gt;1 / 0&lt;/code&gt; would be evaluated before the call and you would get a division by zero. Les never evaluates the unused second argument, so there is no error.&lt;/p&gt;

&lt;p&gt;Les also provides &lt;code&gt;force&lt;/code&gt; and a postfix &lt;code&gt;!&lt;/code&gt; to request evaluation explicitly.&lt;/p&gt;

&lt;p&gt;You can try Les without installing it locally: the &lt;a href="https://gotoken.github.io/les-playground/#ex=trace" rel="noopener noreferrer"&gt;Les Playground&lt;/a&gt; lets you run examples in your browser and edit the code to experiment on your own.&lt;/p&gt;

&lt;p&gt;Lazy evaluation itself has been studied and implemented in many programming languages, including Haskell and R. What makes Les interesting is that, on top of lazy evaluation, its rebinding and environment capture behave in distinctive ways.&lt;/p&gt;

&lt;h3&gt;
  
  
  Variables that exist at creation time are captured
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result is &lt;code&gt;2&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The right-hand side of &lt;code&gt;b&lt;/code&gt; is not evaluated right away. But &lt;code&gt;b&lt;/code&gt; captures the binding of &lt;code&gt;a&lt;/code&gt; that was visible when &lt;code&gt;b&lt;/code&gt; was created, so rebinding &lt;code&gt;a&lt;/code&gt; afterwards does not change what &lt;code&gt;b&lt;/code&gt; refers to.&lt;/p&gt;

&lt;h3&gt;
  
  
  Variables that do not exist at creation time are found later
&lt;/h3&gt;

&lt;p&gt;The following program, on the other hand, behaves differently.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result is &lt;code&gt;8&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When &lt;code&gt;b&lt;/code&gt; is created, &lt;code&gt;a&lt;/code&gt; does not exist yet, so &lt;code&gt;a&lt;/code&gt; is not captured. When &lt;code&gt;b&lt;/code&gt; is actually evaluated, &lt;code&gt;a&lt;/code&gt; is looked up in the live scope, and the binding found then, &lt;code&gt;7&lt;/code&gt;, is used.&lt;/p&gt;

&lt;p&gt;In other words, two things coexist in Les's lazy evaluation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A name that can be resolved when the thunk is created captures the binding of that moment.&lt;/li&gt;
&lt;li&gt;A name that cannot be resolved at creation time is resolved later, at evaluation time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Neither plain call-by-name nor the usual account of call-by-need with static scoping fully captures this.&lt;/p&gt;

&lt;p&gt;Furthermore, in Les, rebinding an existing name in the same scope forces the right-hand side on the spot. Initial binding and rebinding are evaluated at different times.&lt;/p&gt;

&lt;p&gt;The starting point of this formalization was to build a model that explains these rules not just one by one, but consistently even when they are combined.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. What the experiment set out to do
&lt;/h2&gt;

&lt;p&gt;From the start, I had no intention of writing a specification of all of Les or of porting the entire Go implementation to Lean.&lt;/p&gt;

&lt;p&gt;Instead, I set three separate goals.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The first is to record observable behavior.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For a given Les program, pin down what its standard output, standard error, and exit code are.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The second is a small executable model that explains that behavior.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For example, in the two programs from Section 1, &lt;code&gt;a&lt;/code&gt; is rebound later, yet the value that &lt;code&gt;b&lt;/code&gt; refers to is determined differently. Explaining that difference requires more than a mapping from variable names to values: we need to work out when references are resolved and what gets stored. I build rules and a representation of state that explain the observed cases consistently, and make them executable in Lean. This is the model of the language's semantics (the rules defining what programs mean and how they compute) used here. There is no need to copy Go's internal structures, but differential testing helps check that the model does not contradict observations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The third is to prove properties of the model.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What does it mean to prove a general property?
&lt;/h3&gt;

&lt;p&gt;Consider a simple mathematical example. We want to establish that &lt;code&gt;n + 1 &amp;gt; n&lt;/code&gt; for a natural number &lt;code&gt;n&lt;/code&gt;. Substituting &lt;code&gt;n = 0, 1, 2, ...&lt;/code&gt; gives us as many successful examples as we want. But there are infinitely many natural numbers, so no finite series of tests can exhaust them. A mathematical proof can instead explain why the inequality holds for an arbitrary natural number &lt;code&gt;n&lt;/code&gt;, covering values that have never been tried.&lt;/p&gt;

&lt;p&gt;What we want to know about this evaluator is similar. Suppose a delayed expression is evaluated and its result is stored, and we then ask for its value again. Running several programs and observing that the same value comes back is testing. But the combinations of expressions, variable bindings, storage locations, and intermediate execution states are vast and can be infinite in the model.&lt;/p&gt;

&lt;p&gt;In the theorem introduced in Section 4, instead of picking a particular expression or value, we treat them as arbitrary. Under the hypotheses that an unevaluated expression is stored in a given location and that its evaluation finishes successfully, we show that its result is stored in that location, and that requesting the value of the same location again from the resulting state returns the same value without changing the execution state. Lean checks not only the statement but also the mathematical proof that establishes it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;General means that the theorem covers every case in its stated domain that satisfies its hypotheses, not just the programs we have tried.&lt;/strong&gt; It does not establish that every Les program evaluates successfully, or that the value always stays the same if arbitrary other operations intervene.&lt;/p&gt;

&lt;p&gt;The distinction between testing and proving is also explained very clearly in the &lt;a href="https://samx.io/blog/topics/devlog/2026-09-26-ruby-lean.html" rel="noopener noreferrer"&gt;introduction to Sam Xifaras's ruby-lean post&lt;/a&gt;, which I discovered after finishing P2 (see Section 9 for a comparison).&lt;/p&gt;

&lt;p&gt;These are three separate tasks. Agreement with observations supports the model's adequacy, but does not prove equivalence to the Go implementation. Nor is a theorem about the model automatically a theorem about the original Go implementation.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. P0–P1: From observation to a Lean evaluator
&lt;/h2&gt;

&lt;h3&gt;
  
  
  P0: Pin down the target and make it reproducible
&lt;/h3&gt;

&lt;p&gt;First I pinned the target commit of Les:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;aa78fdcfc76b156e6b5ab4735516fcefadce954b&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I built the Go CLI from this commit and ran a minimal set of tests. At the same time I set up a build environment with Lean 4.25.0 and Lake.&lt;/p&gt;

&lt;p&gt;The reason for pinning a commit is to keep changes in the upstream implementation during the experiment from silently changing the observed results or the subject of the proofs.&lt;/p&gt;

&lt;p&gt;The first five tests checked &lt;code&gt;print&lt;/code&gt;, &lt;code&gt;exit&lt;/code&gt;, lazy evaluation of unused arguments, division by zero, and the like.&lt;/p&gt;

&lt;p&gt;Something that turned out to matter more than I expected: the Go CLI and Go's evaluator tests do not take the same path. At the pinned commit, the CLI's &lt;a href="https://github.com/unak/les/blob/aa78fdcfc76b156e6b5ab4735516fcefadce954b/cmd/les/main.go#L48-L98" rel="noopener noreferrer"&gt;&lt;code&gt;runPipeline&lt;/code&gt;&lt;/a&gt; separates normal execution into three stages.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Lexical analysis and parsing&lt;/strong&gt; (&lt;code&gt;ParseProgram&lt;/code&gt; on the parser): read the source and construct an AST. Syntax errors stop the pipeline here.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Type inference and checking&lt;/strong&gt; (&lt;code&gt;InferProgram&lt;/code&gt;): infer types and check their consistency. Type errors stop the pipeline, and type warnings are written to standard error.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Evaluation&lt;/strong&gt; (&lt;code&gt;EvalProgram&lt;/code&gt;): use the parsed AST and the type inferencer to evaluate expressions as they are needed.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Indeed, the CLI's &lt;code&gt;-c&lt;/code&gt; option stops after the first stage and &lt;code&gt;-t&lt;/code&gt; after the second; neither evaluates the program. Lazy evaluation concerns the computation in the third stage, not postponing parsing or type checking.&lt;/p&gt;

&lt;p&gt;The CLI's standard error can therefore contain not only runtime errors from the evaluator but also warnings from type inference before execution. I arranged the test inputs and expected values so as not to confuse these two kinds of behavior.&lt;/p&gt;

&lt;h3&gt;
  
  
  P1: What was observed with the Go CLI, and what &lt;code&gt;lesdump&lt;/code&gt; passes on
&lt;/h3&gt;

&lt;p&gt;Two jobs need to be kept apart here.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Observing execution results:&lt;/strong&gt; give &lt;code&gt;*.les&lt;/code&gt; to the Les CLI built in Go from the pinned commit, examine stdout, stderr, and the exit code, and pin them down in &lt;code&gt;*.expect.json&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Building the input for Lean:&lt;/strong&gt; &lt;code&gt;lesdump&lt;/code&gt;, which reuses the lexer, parser, and type analysis of the Go version, emits the abstract syntax tree (AST) and type analysis results for the same &lt;code&gt;*.les&lt;/code&gt; as JSON. Lean decodes that JSON and computes using its own evaluation rules.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An AST represents &lt;code&gt;a + 1&lt;/code&gt;, for example, as a tree consisting of an addition operation, the variable name &lt;code&gt;a&lt;/code&gt; on the left, and the integer literal &lt;code&gt;1&lt;/code&gt; on the right. Neither the actual value of &lt;code&gt;a&lt;/code&gt; nor the result of the addition is determined when this AST is constructed.&lt;/p&gt;

&lt;p&gt;In other words, &lt;a href="https://github.com/gotoken/les-spec/blob/main/lesdump/main.go" rel="noopener noreferrer"&gt;&lt;code&gt;lesdump&lt;/code&gt;&lt;/a&gt; is &lt;strong&gt;not an oracle that collects execution results but a bridge for sharing the front end&lt;/strong&gt; (the analysis performed before evaluation). For the supported sublanguage, it reuses the Go CLI's lexical analysis, parsing, and type inference routines, but does not invoke the Go evaluator. The Lean side does not independently verify the correctness of parsing or type inference either; it receives the JSON and performs evaluation.&lt;/p&gt;

&lt;p&gt;In the actual directory layout, for example, the correspondence looks like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4hy3du4d0hr8c4pqsmc6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4hy3du4d0hr8c4pqsmc6.png" alt="The same Les source goes through the Go CLI and lesdump; the Lean evaluator output is compared with the Go expectation." width="800" height="583"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The actual commands are as follows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bash scripts/bootstrap.sh
.work/bin/lesdump difftest/corpus/snapshot-late-rebind.les &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/snapshot.json
python3 difftest/run.py                &lt;span class="c"&gt;# check the pinned Go CLI against *.expect.json&lt;/span&gt;
python3 lesdump/test.py                &lt;span class="c"&gt;# check the AST JSON against the golden files&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; lean
lake build
lake exe les-syntax-test ../lesdump/golden 35
lake exe les-eval-test ../lesdump/golden ../difftest/corpus
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code that collects Go's stdout, stderr, and exit code is in &lt;a href="https://github.com/gotoken/les-spec/blob/main/difftest/run.py" rel="noopener noreferrer"&gt;&lt;code&gt;difftest/run.py&lt;/code&gt;&lt;/a&gt;. Apart from replacing environment-specific file paths with &lt;code&gt;&amp;lt;CASE&amp;gt;&lt;/code&gt;, it never automatically updates the expected values to whatever came out. &lt;a href="https://github.com/gotoken/les-spec/blob/main/lesdump/test.py" rel="noopener noreferrer"&gt;&lt;code&gt;lesdump/test.py&lt;/code&gt;&lt;/a&gt; also checks that the &lt;code&gt;lesdump&lt;/code&gt; JSON is deterministic and that unsupported syntax is explicitly rejected.&lt;/p&gt;

&lt;h3&gt;
  
  
  Terms first: Thunk, Cell, Heap, Scope, Env, Machine
&lt;/h3&gt;

&lt;p&gt;From here on, more and more &lt;strong&gt;terms describing the internal structure of the evaluator&lt;/strong&gt; appear that do not occur in Les source code. For readers new to them, let me first sort out where they come from.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;thunk&lt;/strong&gt;, a term from research on lazy evaluation, is a way of holding an expression that has not been computed yet as "something to compute when it is needed." It is not just the stored expression: it also needs the environment in which to evaluate that expression later. The strategy of storing the result and reusing it the second time is called &lt;strong&gt;call-by-need&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/unak/les/blob/aa78fdcfc76b156e6b5ab4735516fcefadce954b/pkg/eval/value.go" rel="noopener noreferrer"&gt;The &lt;code&gt;Thunk&lt;/code&gt; of the original Go implementation&lt;/a&gt; really does have the fields &lt;code&gt;Expr&lt;/code&gt;, &lt;code&gt;Env *Environment&lt;/code&gt;, &lt;code&gt;Value&lt;/code&gt;, &lt;code&gt;Evaluated&lt;/code&gt;, and &lt;code&gt;Evaluating&lt;/code&gt;. &lt;code&gt;Environment&lt;/code&gt; holds &lt;code&gt;store map[string]Value&lt;/code&gt; and &lt;code&gt;parent&lt;/code&gt;, and &lt;a href="https://github.com/unak/les/blob/aa78fdcfc76b156e6b5ab4735516fcefadce954b/pkg/eval/capture.go" rel="noopener noreferrer"&gt;&lt;code&gt;captureEnv&lt;/code&gt;&lt;/a&gt; copies the bindings that were visible at creation time.&lt;/p&gt;

&lt;p&gt;On the other hand, &lt;code&gt;Cell&lt;/code&gt;, &lt;code&gt;Machine&lt;/code&gt;, and the others below are &lt;strong&gt;representations and names chosen for the Lean evaluator in this experiment&lt;/strong&gt;. They are not one-to-one ports of Go's structs.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Term&lt;/th&gt;
&lt;th&gt;What it refers to&lt;/th&gt;
&lt;th&gt;Origin / how it is used here&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Thunk&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;An unevaluated expression plus the information needed to evaluate it later&lt;/td&gt;
&lt;td&gt;A common term in lazy evaluation. Go's Les also calls it &lt;code&gt;Thunk&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cell&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;A single storage location&lt;/strong&gt; holding an evaluated value, an unevaluated expression, or a marker meaning "being evaluated"&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;Cell&lt;/code&gt; in the Lean model. It holds not only thunks but also evaluated values&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Heap&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The storage area that manages cells by address, plus the list of scopes&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;Heap&lt;/code&gt; in the Lean model. Not the operating system's heap&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Scope&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The mapping from current variable names to cell addresses, plus the parent scope&lt;/td&gt;
&lt;td&gt;Scope in the usual language-implementation sense. In Lean it is referred to by &lt;code&gt;ScopeId&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Env&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The &lt;strong&gt;reference environment&lt;/strong&gt; that says where names are resolved when the expression is evaluated later&lt;/td&gt;
&lt;td&gt;Short for environment. The problem that Go's &lt;code&gt;Environment&lt;/code&gt; handles is split into &lt;code&gt;snap&lt;/code&gt; and &lt;code&gt;scope&lt;/code&gt; in Lean&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Machine&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The state that changes during evaluation, bundled together&lt;/td&gt;
&lt;td&gt;In the sense of an abstract machine or evaluator state. Here, the &lt;code&gt;Heap&lt;/code&gt; and the accumulated &lt;code&gt;stdout&lt;/code&gt;. Not a physical computer&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Whereas Go's &lt;code&gt;Environment&lt;/code&gt; holds references to values and thunks, Lean maps variable names to cell &lt;strong&gt;addresses (array indices)&lt;/strong&gt;. This indirection is what lets an old thunk keep using its original cell even after rebinding changes where a name points.&lt;/p&gt;

&lt;p&gt;With the terms in place, let's run actual programs and see which addresses remain.&lt;/p&gt;

&lt;h4&gt;
  
  
  Observation 1: capturing a binding (E14)
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://github.com/gotoken/les-spec/blob/main/difftest/corpus/snapshot-late-rebind.les" rel="noopener noreferrer"&gt;&lt;code&gt;snapshot-late-rebind.les&lt;/code&gt;&lt;/a&gt;, shown at the start, is these four lines.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The expected result from the pinned Go CLI is recorded like this in &lt;a href="https://github.com/gotoken/les-spec/blob/main/difftest/corpus/snapshot-late-rebind.expect.json" rel="noopener noreferrer"&gt;&lt;code&gt;snapshot-late-rebind.expect.json&lt;/code&gt;&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"stdout"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"stderr"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"exit_code"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"rules"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"E14"&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;In the &lt;a href="https://github.com/gotoken/les-spec/blob/main/lesdump/golden/snapshot-late-rebind.json" rel="noopener noreferrer"&gt;golden JSON&lt;/a&gt; from &lt;code&gt;lesdump&lt;/code&gt;, the second statement &lt;code&gt;b = a + 1&lt;/code&gt; is a &lt;code&gt;VarDecl&lt;/code&gt; whose right-hand side is a &lt;code&gt;Binary&lt;/code&gt;. Here is that statement alone (equivalent to &lt;code&gt;jq '.body[1]'&lt;/code&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"kind"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"VarDecl"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"b"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"pos"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"col"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"line"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"type_annot"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"kind"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Binary"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"left"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"kind"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Ident"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"a"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"pos"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"col"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"line"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&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="nl"&gt;"op"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"+"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"pos"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"col"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"line"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"right"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"kind"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Int"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"pos"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"col"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"line"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The important point is that &lt;strong&gt;this JSON contains no evaluation results such as "&lt;code&gt;a&lt;/code&gt; is 1" or "&lt;code&gt;b&lt;/code&gt; is 2"&lt;/strong&gt;. It only represents &lt;code&gt;VarDecl&lt;/code&gt;, &lt;code&gt;Binary&lt;/code&gt;, &lt;code&gt;Ident&lt;/code&gt;, and source positions. The type checker's &lt;code&gt;analysis.status&lt;/code&gt; is &lt;code&gt;ok&lt;/code&gt; in this case, but that too was not obtained by running anything.&lt;/p&gt;

&lt;p&gt;The output is &lt;code&gt;2&lt;/code&gt; because, when the thunk for &lt;code&gt;b&lt;/code&gt; is created, it captures &lt;strong&gt;not the value of &lt;code&gt;a&lt;/code&gt; but its cell address&lt;/strong&gt;, and keeps referring to the old cell even after the rebinding &lt;code&gt;a = 10&lt;/code&gt;. The Lean evaluator implements this rule, and the proofs in P2c guarantee part of this reference structure.&lt;/p&gt;

&lt;p&gt;Translated into Lean's storage, the state just before &lt;code&gt;print b&lt;/code&gt; looks conceptually like this. Cells &lt;code&gt;#0&lt;/code&gt; and &lt;code&gt;#1&lt;/code&gt; are for built-in functions, so in this example the first cell of &lt;code&gt;a&lt;/code&gt; is &lt;code&gt;#2&lt;/code&gt;. The numbers the arrows point to are &lt;strong&gt;not values but addresses in the cell array&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flxy7b7tcl8eisf1ikdcm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flxy7b7tcl8eisf1ikdcm.png" alt="The current a points to #4 (10), while the environment captured by b points to the old a at #2 (1)." width="800" height="467"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Line 1, &lt;code&gt;a = 1&lt;/code&gt;, creates &lt;code&gt;#2&lt;/code&gt;; line 2, &lt;code&gt;b = a + 1&lt;/code&gt;, creates &lt;code&gt;#3&lt;/code&gt;; and the rebinding on line 3, &lt;code&gt;a = 10&lt;/code&gt;, creates &lt;code&gt;#4&lt;/code&gt;. The name &lt;code&gt;a&lt;/code&gt; in &lt;code&gt;Heap.scopes[1]&lt;/code&gt; now points to &lt;code&gt;#4&lt;/code&gt;, but the &lt;code&gt;env_b.snap&lt;/code&gt; stored in &lt;code&gt;#3&lt;/code&gt; still points to &lt;code&gt;#2&lt;/code&gt;. So evaluating &lt;code&gt;b&lt;/code&gt; computes &lt;code&gt;1 + 1&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This is &lt;strong&gt;not a picture of Go's internal memory addresses&lt;/strong&gt;. It is a picture of the Lean Heap model built to explain Go's output. The real Go implementation uses pointers and &lt;code&gt;Environment&lt;/code&gt;; Lean uses integer addresses and arrays.&lt;/p&gt;

&lt;h4&gt;
  
  
  Observation 2: resolving a not-yet-bound name later (E15)
&lt;/h4&gt;

&lt;p&gt;By contrast, &lt;a href="https://github.com/gotoken/les-spec/blob/main/difftest/corpus/forward-ref-rebound.les" rel="noopener noreferrer"&gt;&lt;code&gt;forward-ref-rebound.les&lt;/code&gt;&lt;/a&gt; is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The expected result is &lt;code&gt;{"stdout": "8", "stderr": "", "exit_code": 0}&lt;/code&gt; in &lt;a href="https://github.com/gotoken/les-spec/blob/main/difftest/corpus/forward-ref-rebound.expect.json" rel="noopener noreferrer"&gt;&lt;code&gt;forward-ref-rebound.expect.json&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The shape of the AST is almost the same as before: the right-hand side of &lt;code&gt;b&lt;/code&gt; is again &lt;code&gt;Binary(Ident("a"), "+", Int(1))&lt;/code&gt;. But when &lt;code&gt;b&lt;/code&gt; is created, there is no binding for &lt;code&gt;a&lt;/code&gt;. So &lt;code&gt;a&lt;/code&gt; does not go into the snapshot, and when &lt;code&gt;print b&lt;/code&gt; first demands its value, the latest &lt;code&gt;a = 7&lt;/code&gt; in the current scope is found.&lt;/p&gt;

&lt;p&gt;This is &lt;strong&gt;the semantics of runtime environment capture and name resolution&lt;/strong&gt;, which you cannot see just by building the AST. The fact that two examples with the same &lt;code&gt;Binary&lt;/code&gt; AST return &lt;code&gt;2&lt;/code&gt; and &lt;code&gt;8&lt;/code&gt; is what motivated having a Heap and Env in Lean.&lt;/p&gt;

&lt;p&gt;Here, when the thunk for &lt;code&gt;b&lt;/code&gt; is created, &lt;code&gt;a&lt;/code&gt; does not exist yet, so &lt;code&gt;env_b.snap&lt;/code&gt; is empty. At evaluation time, the current binding is looked up by following &lt;code&gt;env_b.scope = 1&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkt6xtfrs2e4vf4ra83zm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkt6xtfrs2e4vf4ra83zm.png" alt="Since a is absent from b's snapshot, lookup in scope 1 resolves the latest a at #4." width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The difference between the earlier &lt;code&gt;2&lt;/code&gt; and this &lt;code&gt;8&lt;/code&gt; is not a difference in syntax such as &lt;code&gt;Binary&lt;/code&gt;, but &lt;strong&gt;whether the same name &lt;code&gt;a&lt;/code&gt; is resolved from &lt;code&gt;Env.snap&lt;/code&gt; or looked up later in the live &lt;code&gt;Scope&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Observation 3: results of lazy evaluation are shared (E9)
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://github.com/gotoken/les-spec/blob/main/difftest/corpus/memo-binding.les" rel="noopener noreferrer"&gt;&lt;code&gt;memo-binding.les&lt;/code&gt;&lt;/a&gt;, which checks memoization, is the following program.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;g&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="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="s2"&gt;"side;"&lt;/span&gt;
    &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;g&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="s2"&gt;"before;"&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The expected value from the pinned Go CLI is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"stdout"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"before;side;11"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"stderr"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"exit_code"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"rules"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"E9"&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;&lt;code&gt;g&lt;/code&gt; is not called when &lt;code&gt;x = g()&lt;/code&gt; is declared; it is evaluated exactly once, at the first &lt;code&gt;print x&lt;/code&gt;. The second &lt;code&gt;print x&lt;/code&gt; reuses the shared result. That is why &lt;code&gt;side;&lt;/code&gt; appears only once. On the &lt;code&gt;lesdump&lt;/code&gt; side, &lt;code&gt;g&lt;/code&gt; is output as a &lt;code&gt;FuncDef&lt;/code&gt; and &lt;code&gt;x = g()&lt;/code&gt; as a &lt;code&gt;VarDecl&lt;/code&gt; whose right-hand side is a &lt;code&gt;Call&lt;/code&gt;; the JSON says nothing about how many times anything is evaluated or how many side effects occur.&lt;/p&gt;

&lt;p&gt;In addition, for the failure case &lt;a href="https://github.com/gotoken/les-spec/blob/main/difftest/corpus/blackhole.les" rel="noopener noreferrer"&gt;&lt;code&gt;blackhole.les&lt;/code&gt;&lt;/a&gt;,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="s2"&gt;"ok"&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the result is stdout &lt;code&gt;ok&lt;/code&gt;, exit code 1, and stderr &lt;code&gt;Runtime Error: blackhole: circular reference detected in lazy thunk&lt;/code&gt; (with a trailing newline). &lt;code&gt;Cell.blackhole&lt;/code&gt;, introduced later in Lean, is the state that explains this observation.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the Lean side compares
&lt;/h3&gt;

&lt;p&gt;The Lean decoder turns &lt;code&gt;lesdump&lt;/code&gt;'s &lt;code&gt;{"kind":"Binary",…}&lt;/code&gt; into &lt;code&gt;Expr.binary&lt;/code&gt; and &lt;code&gt;{"kind":"VarDecl",…}&lt;/code&gt; into &lt;code&gt;Stmt.varDecl&lt;/code&gt;. Only a &lt;code&gt;Program&lt;/code&gt; that passed type checking becomes a &lt;code&gt;CheckedProgram&lt;/code&gt; and is run. This does not mean, however, that Lean has proved Go's type inference correct.&lt;/p&gt;

&lt;p&gt;The comparison in &lt;a href="https://github.com/gotoken/les-spec/blob/main/lean/Tests/Eval.lean" rel="noopener noreferrer"&gt;&lt;code&gt;lean/Tests/Eval.lean&lt;/code&gt;&lt;/a&gt; (comments in Japanese), reduced to its essentials, looks like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight lean"&gt;&lt;code&gt;&lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;verdictOf&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fuel&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Nat&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;src&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Except&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="nc"&gt;Verdict&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nb"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt; &lt;span class="n"&gt;fuel&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;← &lt;span class="n"&gt;progOf&lt;/span&gt; &lt;span class="n"&gt;src&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;verdict&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For each case, the test reads &lt;code&gt;lesdump/golden/*.json&lt;/code&gt; and &lt;code&gt;difftest/corpus/*.expect.json&lt;/code&gt; and compares the &lt;code&gt;stdout&lt;/code&gt;, &lt;code&gt;stderr&lt;/code&gt;, and &lt;code&gt;exitCode&lt;/code&gt; returned by &lt;code&gt;verdictOf&lt;/code&gt; with the expected values.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;UNSUPPORTED&lt;/code&gt; and &lt;code&gt;OUT_OF_FUEL&lt;/code&gt; are not counted as agreement. All 35 current cases are &lt;code&gt;PASS&lt;/code&gt;. Lean's syntax tests check decoding and re-encoding of the 35 JSON files, and 41 unit tests check evaluation on ASTs built directly.&lt;/p&gt;

&lt;p&gt;For example, the unit tests check not only that demanding three times produces the side effect once, but also, using the Heap taken out of &lt;code&gt;runMachine&lt;/code&gt;, that &lt;strong&gt;the shared cell really was rewritten to &lt;code&gt;.done&lt;/code&gt; after evaluation&lt;/strong&gt;. They also compare cell addresses to check that &lt;code&gt;b&lt;/code&gt;'s &lt;code&gt;Env.snap&lt;/code&gt; points to the &lt;code&gt;a&lt;/code&gt; from before the rebinding.&lt;/p&gt;

&lt;p&gt;These are "observation and execution tests." In P2, next, I prove properties of the corresponding Lean evaluator that do not depend on a finite set of tests.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. P2: What exactly was proved in Lean
&lt;/h2&gt;

&lt;p&gt;The 35 cases in P1 check &lt;strong&gt;agreement of observed results&lt;/strong&gt; such as &lt;code&gt;stdout&lt;/code&gt;. In P2, for &lt;strong&gt;the same Lean evaluator&lt;/strong&gt; used in that comparison, I built theorems of the form "from any initial state, if these conditions hold, the result is always this."&lt;/p&gt;

&lt;p&gt;The centerpiece is &lt;code&gt;whnf_suspended_ok_memo&lt;/code&gt; in &lt;a href="https://github.com/gotoken/les-spec/blob/main/lean/Les/Proofs/Memo.lean" rel="noopener noreferrer"&gt;&lt;code&gt;lean/Les/Proofs/Memo.lean&lt;/code&gt;&lt;/a&gt; (comments in Japanese). &lt;code&gt;whnf&lt;/code&gt; stands for &lt;strong&gt;weak head normal form&lt;/strong&gt;, a term used in lazy evaluation in functional languages. In this model it is the name of "the process that forces a given cell until its value is known." &lt;code&gt;whnf&lt;/code&gt; is neither a Lean built-in nor Les syntax; it is &lt;strong&gt;a function defined in this Lean evaluator&lt;/strong&gt;. To read what the theorem says concretely, let's first look at the Machine and the Cell.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.1 The evaluator's data types: sharing addresses, not names
&lt;/h3&gt;

&lt;p&gt;Here is a diagram of which Lean data types the terms above correspond to.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl0ce0jnmpr8y95ukzy34.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl0ce0jnmpr8y95ukzy34.png" alt="Machine contains stdout and Heap; Heap contains arrays of scopes and cells. Env holds captured addresses and the starting scope." width="800" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A &lt;code&gt;Machine&lt;/code&gt; is not "an object holding the whole program"; it bundles only &lt;strong&gt;the parts that are updated during evaluation&lt;/strong&gt;. The expression &lt;code&gt;Expr&lt;/code&gt; to run, its environment &lt;code&gt;Env&lt;/code&gt;, and the fuel that bounds the recursion depth are arguments of functions such as &lt;code&gt;evalE&lt;/code&gt;, &lt;code&gt;demand&lt;/code&gt;, and &lt;code&gt;whnf&lt;/code&gt;. &lt;code&gt;Machine.stdout&lt;/code&gt; keeps what &lt;code&gt;print&lt;/code&gt; outputs as a string instead of actually writing to a terminal. That is why the output up to an exception can still be compared.&lt;/p&gt;

&lt;p&gt;The following is an excerpt from the actual &lt;a href="https://github.com/gotoken/les-spec/blob/main/lean/Les/Eval/Types.lean" rel="noopener noreferrer"&gt;&lt;code&gt;lean/Les/Eval/Types.lean&lt;/code&gt;&lt;/a&gt; (comments in Japanese).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight lean"&gt;&lt;code&gt;&lt;span class="n"&gt;abbrev&lt;/span&gt; &lt;span class="nc"&gt;Addr&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nc"&gt;Nat&lt;/span&gt;
&lt;span class="n"&gt;abbrev&lt;/span&gt; &lt;span class="nc"&gt;ScopeId&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nc"&gt;Nat&lt;/span&gt;

&lt;span class="n"&gt;structure&lt;/span&gt; &lt;span class="nc"&gt;Env&lt;/span&gt; &lt;span class="k"&gt;where&lt;/span&gt;
  &lt;span class="n"&gt;snap&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;List&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt; × &lt;span class="nc"&gt;Addr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;scope&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ScopeId&lt;/span&gt;

&lt;span class="n"&gt;inductive&lt;/span&gt; &lt;span class="nc"&gt;Cell&lt;/span&gt; &lt;span class="k"&gt;where&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;done&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;suspended&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Expr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Env&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;blackhole&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Expr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;structure&lt;/span&gt; &lt;span class="nc"&gt;Scope&lt;/span&gt; &lt;span class="k"&gt;where&lt;/span&gt;
  &lt;span class="n"&gt;vars&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;List&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt; × &lt;span class="nc"&gt;Addr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;parent&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Option&lt;/span&gt; &lt;span class="nc"&gt;ScopeId&lt;/span&gt;

&lt;span class="n"&gt;structure&lt;/span&gt; &lt;span class="nc"&gt;Heap&lt;/span&gt; &lt;span class="k"&gt;where&lt;/span&gt;
  &lt;span class="n"&gt;cells&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Array&lt;/span&gt; &lt;span class="nc"&gt;Cell&lt;/span&gt;
  &lt;span class="n"&gt;scopes&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Array&lt;/span&gt; &lt;span class="nc"&gt;Scope&lt;/span&gt;

&lt;span class="n"&gt;structure&lt;/span&gt; &lt;span class="nc"&gt;Machine&lt;/span&gt; &lt;span class="k"&gt;where&lt;/span&gt;
  &lt;span class="n"&gt;heap&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Heap&lt;/span&gt;
  &lt;span class="n"&gt;stdout&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;

&lt;span class="n"&gt;abbrev&lt;/span&gt; &lt;span class="nc"&gt;EvalM&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nc"&gt;ExceptT&lt;/span&gt; &lt;span class="nc"&gt;Halt&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;StateM&lt;/span&gt; &lt;span class="nc"&gt;Machine&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Heap.cells&lt;/code&gt; is an array of cells, and an &lt;code&gt;Addr&lt;/code&gt; is an index into it. A scope's variables do not hold values directly; they hold cell addresses.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Env.snap&lt;/code&gt; is the list of names that could be resolved when the thunk was created, paired with their addresses, and &lt;code&gt;Env.scope&lt;/code&gt; is the number of the live scope in which names not yet captured are looked up. &lt;code&gt;Scope.vars&lt;/code&gt; holds the current mapping from names to addresses, and &lt;code&gt;Scope.parent&lt;/code&gt; refers to the parent scope. The division of labor is that &lt;code&gt;Env&lt;/code&gt; records "where an expression is evaluated from," and &lt;code&gt;Scope&lt;/code&gt; holds "which name is tied to which cell right now."&lt;/p&gt;

&lt;p&gt;&lt;code&gt;EvalM&lt;/code&gt; is not a standard Lean type either; it is an alias defined by this evaluator. It represents &lt;strong&gt;a computation that reads and writes the Machine state and may stop partway because of an error or &lt;code&gt;exit&lt;/code&gt;&lt;/strong&gt;. &lt;code&gt;StateM Machine&lt;/code&gt; handles the execution state, and &lt;code&gt;ExceptT Halt&lt;/code&gt; handles normal completion (&lt;code&gt;Except.ok&lt;/code&gt;) and the reason for stopping (&lt;code&gt;Except.error&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;The three states of &lt;code&gt;Cell&lt;/code&gt; exist to implement the following transitions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fayohs05ehx9tug8yhpyy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fayohs05ehx9tug8yhpyy.png" alt="First force changes suspended to blackhole; success changes it to done. Re-entry causes a circular-reference error; re-forcing done returns the value." width="799" height="342"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;evalE&lt;/code&gt;, &lt;code&gt;whnf&lt;/code&gt;, &lt;code&gt;demand&lt;/code&gt;: expressions, addresses, and values
&lt;/h3&gt;

&lt;p&gt;This matters when reading the Lean code. The evaluator has three functions with similar-sounding names.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Function&lt;/th&gt;
&lt;th&gt;Meaning of the name and its role&lt;/th&gt;
&lt;th&gt;From input to result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;evalE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Short for &lt;strong&gt;evaluate expression&lt;/strong&gt;. Processes an expression and returns the &lt;strong&gt;address&lt;/strong&gt; of the cell that will hold the result. For an identifier it returns the existing cell and does not force it yet&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;Expr → EvalM Addr&lt;/code&gt; (fuel and Env omitted)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;whnf&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Short for &lt;strong&gt;weak head normal form&lt;/strong&gt;. Forces the given cell on demand and returns its value. If the cell is unevaluated, it runs the expression and, on success, memoizes it as &lt;code&gt;done&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Addr → EvalM Value&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;demand&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;From the English &lt;em&gt;demand&lt;/em&gt; (to require a value). Passes the address obtained from &lt;code&gt;evalE&lt;/code&gt; to &lt;code&gt;whnf&lt;/code&gt; and requires the expression's &lt;strong&gt;value&lt;/strong&gt;. On error it also attaches the expression's position&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Expr → EvalM Value&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For example, passing the right-hand side of &lt;code&gt;b = a + 1&lt;/code&gt; to &lt;code&gt;evalE&lt;/code&gt; and passing it to &lt;code&gt;demand&lt;/code&gt; give results of different types and force different amounts. When the variable &lt;code&gt;b&lt;/code&gt; points to an unevaluated cell, the equivalent of &lt;code&gt;evalE (Ident "b")&lt;/code&gt; returns that &lt;strong&gt;address&lt;/strong&gt;, and &lt;code&gt;whnf&lt;/code&gt; evaluates the expression behind the address and returns a &lt;strong&gt;value&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fozcw92a4y5pij79owd3w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fozcw92a4y5pij79owd3w.png" alt="evalE maps Expr to Addr; whnf maps Addr to Value; demand composes the two." width="800" height="226"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As a general lazy-evaluation term, WHNF is the state reached by evaluating not the whole expression to full normal form, but only &lt;strong&gt;far enough to tell what the outermost value is&lt;/strong&gt;. For a lazy list, for example, once you know whether the outermost constructor is the empty list or &lt;code&gt;cons&lt;/code&gt;, the list is in WHNF even if its elements and tail are unevaluated. This is only the general explanation, though; &lt;strong&gt;the current Lean model of Les does not implement lists&lt;/strong&gt;. Here, &lt;code&gt;whnf&lt;/code&gt; is a function that turns a cell into a &lt;code&gt;Value&lt;/code&gt;, not "full normalization" that recursively evaluates every nested computation.&lt;/p&gt;

&lt;p&gt;These functions actually also take &lt;code&gt;fuel : Nat&lt;/code&gt; as their first argument. &lt;strong&gt;Fuel&lt;/strong&gt; is a limit on recursion given as a natural number; when it reaches zero the result is &lt;code&gt;outOfFuel&lt;/code&gt;. It does not count the number of instructions or the amount of computation of the whole run.&lt;/p&gt;

&lt;p&gt;At the heart of these transitions is &lt;code&gt;whnf&lt;/code&gt; in &lt;a href="https://github.com/gotoken/les-spec/blob/main/lean/Les/Eval/Eval.lean" rel="noopener noreferrer"&gt;&lt;code&gt;lean/Les/Eval/Eval.lean&lt;/code&gt;&lt;/a&gt; (comments in Japanese). Here is the actual definition.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight lean"&gt;&lt;code&gt;&lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;whnf&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Nat&lt;/span&gt; → &lt;span class="nc"&gt;Addr&lt;/span&gt; → &lt;span class="nc"&gt;EvalM&lt;/span&gt; &lt;span class="nc"&gt;Value&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="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;throw&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;outOfFuel&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;n&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="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="k"&gt;match&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;← &lt;span class="n"&gt;getHeap&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cell&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="k"&gt;with&lt;/span&gt;
    &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;none&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;throw&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;error&lt;/span&gt; &lt;span class="s2"&gt;"internal: dangling address"&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;absent&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;some&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;done&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;pure&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;
    &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;some&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;blackhole&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
      &lt;span class="n"&gt;throw&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;error&lt;/span&gt; &lt;span class="s2"&gt;"blackhole: circular reference detected in lazy thunk"&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;absent&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;some&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;suspended&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      &lt;span class="n"&gt;modHeap&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;·&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;setCell&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;blackhole&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; ← &lt;span class="n"&gt;demand&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;
      &lt;span class="n"&gt;modHeap&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;·&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;setCell&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;done&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="n"&gt;pure&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;demand&lt;/code&gt; evaluates an expression and then forces the resulting cell with &lt;code&gt;whnf&lt;/code&gt;. Because &lt;code&gt;EvalM&lt;/code&gt; is layered as &lt;code&gt;ExceptT Halt (StateM Machine)&lt;/code&gt;, the stdout and Heap written before an error survive even if an error occurs partway.&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;memo-binding.les&lt;/code&gt; above, the reason the first &lt;code&gt;print x&lt;/code&gt; produces the side effect and the second does not is expressed in this model as &lt;strong&gt;the cell at the same address changing from &lt;code&gt;suspended&lt;/code&gt; to &lt;code&gt;done&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.2 P2a: Local operations on the Heap
&lt;/h3&gt;

&lt;p&gt;For this model, I first studied &lt;code&gt;alloc&lt;/code&gt;, &lt;code&gt;setCell&lt;/code&gt;, and &lt;code&gt;bind&lt;/code&gt; in &lt;a href="https://github.com/gotoken/les-spec/blob/main/lean/Les/Proofs/Heap.lean" rel="noopener noreferrer"&gt;&lt;code&gt;Proofs/Heap.lean&lt;/code&gt;&lt;/a&gt; (comments in Japanese). For example, here is an actual lemma.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight lean"&gt;&lt;code&gt;&lt;span class="n"&gt;theorem&lt;/span&gt; &lt;span class="nc"&gt;Heap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;alloc_cell&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="n"&gt;_new&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Heap&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Cell&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;h&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;alloc&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cell&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;alloc&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;some&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;by&lt;/span&gt;
  &lt;span class="n"&gt;simp&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;Heap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;alloc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Heap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cell&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is a property that seems obvious: "when you allocate a new cell, the returned address holds that cell." But once it is established as a lemma, later proofs that change the state can cite it.&lt;/p&gt;

&lt;p&gt;Conversely, &lt;code&gt;Heap.bind&lt;/code&gt; can register any address, so not every Heap is automatically well-formed. Making the needed assumptions explicit led to the work in P2d.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.3 P2c: Proving the difference between &lt;code&gt;2&lt;/code&gt; and &lt;code&gt;8&lt;/code&gt; with addresses
&lt;/h3&gt;

&lt;p&gt;In P1, &lt;code&gt;snapshot-late-rebind.les&lt;/code&gt; gave &lt;code&gt;2&lt;/code&gt; and &lt;code&gt;forward-ref-rebound.les&lt;/code&gt; gave &lt;code&gt;8&lt;/code&gt;. What produces the difference is name resolution and environment capture in &lt;a href="https://github.com/gotoken/les-spec/blob/main/lean/Les/Eval/Eval.lean" rel="noopener noreferrer"&gt;&lt;code&gt;Eval.lean&lt;/code&gt;&lt;/a&gt; (comments in Japanese).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight lean"&gt;&lt;code&gt;&lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;lookupEnv&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;heap&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Heap&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Env&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Option&lt;/span&gt; &lt;span class="nc"&gt;Addr&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt;
  &lt;span class="k"&gt;match&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;snap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find&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="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;with&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;some&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;some&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;none&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lookup&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scope&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;

&lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;capture&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Expr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Env&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;EvalM&lt;/span&gt; &lt;span class="nc"&gt;Env&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;heap&lt;/span&gt; ← &lt;span class="n"&gt;getHeap&lt;/span&gt;
  &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;exprNames&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;eraseDups&lt;/span&gt;
  &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;snap&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;filterMap&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lookupEnv&lt;/span&gt; &lt;span class="n"&gt;heap&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;map&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; ·&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nb"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;snap&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;scope&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scope&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the identifiers that occur in an expression, &lt;code&gt;capture&lt;/code&gt; puts only the ones that can be resolved into &lt;code&gt;snap&lt;/code&gt;. Unbound names are left out.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;capture_preserves_under_bind&lt;/code&gt; in &lt;a href="https://github.com/gotoken/les-spec/blob/main/lean/Les/Proofs/Capture.lean" rel="noopener noreferrer"&gt;&lt;code&gt;Proofs/Capture.lean&lt;/code&gt;&lt;/a&gt; (comments in Japanese) shows that, for a captured name, a later &lt;code&gt;Heap.bind&lt;/code&gt; &lt;strong&gt;still returns the same address, and that rebinding operation does not change the contents of the original cell&lt;/strong&gt;. &lt;code&gt;capture_unbound_lookup&lt;/code&gt; and &lt;code&gt;forward_ref_rebound&lt;/code&gt; show, under conditions, that looking up a name that was not captured can see a later rebinding.&lt;/p&gt;

&lt;p&gt;So &lt;strong&gt;the name-resolution pieces&lt;/strong&gt; that correspond to the observed &lt;code&gt;2&lt;/code&gt; and &lt;code&gt;8&lt;/code&gt; are proved in Lean. These lemmas alone, however, do not amount to a whole-program theorem such as "running this Les source always yields &lt;code&gt;2&lt;/code&gt;."&lt;/p&gt;

&lt;h3&gt;
  
  
  4.4 P2d: From never removing a cell to keeping the original address
&lt;/h3&gt;

&lt;p&gt;What the first force needs is that the original thunk's address is still valid after &lt;code&gt;demand&lt;/code&gt; finishes.&lt;/p&gt;

&lt;p&gt;Here I proved a property that may look like a detour.&lt;/p&gt;

&lt;p&gt;The definitions in &lt;a href="https://github.com/gotoken/les-spec/blob/main/lean/Les/Proofs/Monotone.lean" rel="noopener noreferrer"&gt;&lt;code&gt;Proofs/Monotone.lean&lt;/code&gt;&lt;/a&gt; (comments in Japanese) are as follows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight lean"&gt;&lt;code&gt;&lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="nc"&gt;Machine&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CellsMono&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="s1"&gt;' : Machine) : Prop :=
  m.heap.cells.size ≤ m'&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cells&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;

&lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="nc"&gt;Mono&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;α &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;EvalM&lt;/span&gt; α&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Prop&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt;
  ∀ &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Machine&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CellsMono&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Mono&lt;/code&gt; is the name of a proposition defined here, taken from the mathematical term &lt;strong&gt;monotone&lt;/strong&gt;. It is not a built-in Lean verification command. &lt;code&gt;Mono x&lt;/code&gt; means that from any starting Machine, running &lt;code&gt;x&lt;/code&gt; &lt;strong&gt;never leaves the final Machine's cell array shorter&lt;/strong&gt;. This covers runs that end in an exception, not only successful ones. It is not a theorem about every intermediate state.&lt;/p&gt;

&lt;p&gt;The following theorem in &lt;a href="https://github.com/gotoken/les-spec/blob/main/lean/Les/Proofs/MonotoneEval.lean" rel="noopener noreferrer"&gt;&lt;code&gt;Proofs/MonotoneEval.lean&lt;/code&gt;&lt;/a&gt; (comments in Japanese) shows this for the actual mutually recursive evaluator.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight lean"&gt;&lt;code&gt;&lt;span class="n"&gt;theorem&lt;/span&gt; &lt;span class="n"&gt;demand_mono&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fuel&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Nat&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Expr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Env&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nc"&gt;Mono&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;demand&lt;/span&gt; &lt;span class="n"&gt;fuel&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="n"&gt;env&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="n"&gt;monoAt&lt;/span&gt; &lt;span class="n"&gt;fuel&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;2.2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;monoAt&lt;/code&gt; is a proposition that bundles &lt;code&gt;Mono&lt;/code&gt; for the &lt;strong&gt;11 mutually recursive functions&lt;/strong&gt;, including &lt;code&gt;evalE&lt;/code&gt;, &lt;code&gt;whnf&lt;/code&gt;, &lt;code&gt;demand&lt;/code&gt;, function calls, argument preparation, and statement execution. It is proved by induction on fuel.&lt;/p&gt;

&lt;p&gt;If no cell is removed from the array, an index that was valid at the start is still valid at the end. From this I derived &lt;code&gt;demand_validAddr&lt;/code&gt; and removed &lt;code&gt;hvalid&lt;/code&gt; (the assumption that the address is still valid after execution), which had previously been needed separately.&lt;/p&gt;

&lt;p&gt;The important point here is that &lt;strong&gt;the array length not decreasing does not mean the contents of each cell stay the same&lt;/strong&gt;. Updating &lt;code&gt;suspended&lt;/code&gt; to &lt;code&gt;blackhole&lt;/code&gt; or &lt;code&gt;done&lt;/code&gt; is allowed.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.5 The final theorem: &lt;code&gt;whnf_suspended_ok_memo&lt;/code&gt; (P2d-5)
&lt;/h3&gt;

&lt;p&gt;Putting all of this together gives &lt;a href="https://github.com/gotoken/les-spec/blob/main/lean/Les/Proofs/Memo.lean" rel="noopener noreferrer"&gt;&lt;code&gt;whnf_suspended_ok_memo&lt;/code&gt; in &lt;code&gt;Memo.lean&lt;/code&gt;&lt;/a&gt; (comments in Japanese). Below is the actual &lt;strong&gt;statement and the full proof&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight lean"&gt;&lt;code&gt;&lt;span class="n"&gt;theorem&lt;/span&gt; &lt;span class="n"&gt;whnf_suspended_ok_memo&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Nat&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Addr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Expr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Env&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;₂ &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Machine&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cell&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;some&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;suspended&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="n"&gt;env&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;hd&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;demand&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;blackholed&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;e&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="nc"&gt;Except&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;m&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;span class="n"&gt;whnf&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&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="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Except&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;₂ &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;heap&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;₂&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;setCell&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;done&lt;/span&gt; &lt;span class="n"&gt;v&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;span class="n"&gt;m&lt;/span&gt;₂ &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;heap&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;₂&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;setCell&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;done&lt;/span&gt; &lt;span class="n"&gt;v&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="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cell&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;some&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;done&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; ∧
      ∀ &lt;span class="n"&gt;k&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;whnf&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&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="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;₂ &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;heap&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;₂&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;setCell&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;done&lt;/span&gt; &lt;span class="n"&gt;v&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="nc"&gt;Except&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;₂ &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;heap&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;₂&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;setCell&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;done&lt;/span&gt; &lt;span class="n"&gt;v&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="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;by&lt;/span&gt;
  &lt;span class="n"&gt;have&lt;/span&gt; &lt;span class="n"&gt;h1&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;whnf_suspended_ok&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;₂ &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="n"&gt;hd&lt;/span&gt;
  &lt;span class="n"&gt;have&lt;/span&gt; &lt;span class="n"&gt;h2&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;whnf_suspended_ok_cell_valid&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;₂ &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="n"&gt;hd&lt;/span&gt; &lt;span class="n"&gt;h1&lt;/span&gt;
  &lt;span class="n"&gt;exact&lt;/span&gt; ⟨&lt;span class="n"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;k&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;whnf_done&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="n"&gt;h2&lt;/span&gt;⟩
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Lean notation for reading the statement
&lt;/h4&gt;

&lt;p&gt;In the theorem, &lt;code&gt;((demand n e env).run).run m&lt;/code&gt; is an expression that runs &lt;code&gt;demand&lt;/code&gt; from the execution state &lt;code&gt;m&lt;/code&gt; and yields &lt;strong&gt;a pair of the result and the state after execution&lt;/strong&gt;. &lt;code&gt;run&lt;/code&gt; appears twice because &lt;code&gt;EvalM&lt;/code&gt; consists of two layers, &lt;code&gt;ExceptT&lt;/code&gt; and &lt;code&gt;StateM&lt;/code&gt;, and each has to be unwrapped. Distinguishing the value from the state, the type of the result is roughly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight lean"&gt;&lt;code&gt;&lt;span class="nc"&gt;Except&lt;/span&gt; &lt;span class="nc"&gt;Halt&lt;/span&gt; &lt;span class="nc"&gt;Value&lt;/span&gt; × &lt;span class="nc"&gt;Machine&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Except.ok v&lt;/code&gt; means it finished normally with value &lt;code&gt;v&lt;/code&gt;; &lt;code&gt;Except.error h&lt;/code&gt; means it stopped for reason &lt;code&gt;h&lt;/code&gt;. Since the Machine remains as the second component of the pair, as in &lt;code&gt;(result, m₂)&lt;/code&gt;, the Heap and stdout can be inspected even after an error.&lt;/p&gt;

&lt;p&gt;To read the Lean theorem, it is enough to know just the following notation.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Notation&lt;/th&gt;
&lt;th&gt;How to read it in this theorem&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;theorem name (args) : proposition := by ...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Declares a proposition and proves it after &lt;code&gt;by&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;h : ...&lt;/code&gt;, &lt;code&gt;hd : ...&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Names given to &lt;strong&gt;hypotheses&lt;/strong&gt;. It does not declare them to hold unconditionally&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;∧&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;"and." Here there are three conclusions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;∀ k&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;"for every natural number &lt;code&gt;k&lt;/code&gt;"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;{ m₂ with heap := ... }&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Machine &lt;code&gt;m₂&lt;/code&gt; with only its &lt;code&gt;heap&lt;/code&gt; field updated&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;h1&lt;/code&gt;, &lt;code&gt;h2&lt;/code&gt;, &lt;code&gt;exact&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Combine lemmas already proved and hand over the required conclusion&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;code&gt;run.run&lt;/code&gt; and &lt;code&gt;∀&lt;/code&gt; are &lt;strong&gt;Lean notation&lt;/strong&gt;. By contrast, &lt;code&gt;whnf&lt;/code&gt;, &lt;code&gt;demand&lt;/code&gt;, and &lt;code&gt;Mono&lt;/code&gt; are &lt;strong&gt;names defined by les-spec&lt;/strong&gt;, the subject of this post. Keeping the two apart makes the theorem easier to follow.&lt;/p&gt;

&lt;p&gt;If you are not used to Lean notation, it is easier to read the theorem as two hypotheses and three conclusions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hypotheses&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;h&lt;/code&gt;: in the initial Machine &lt;code&gt;m&lt;/code&gt;, address &lt;code&gt;a&lt;/code&gt; holds the unevaluated expression &lt;code&gt;e&lt;/code&gt; with environment &lt;code&gt;env&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;hd&lt;/code&gt;: running &lt;code&gt;demand n e env&lt;/code&gt; from the state in which that cell has been made a &lt;code&gt;blackhole&lt;/code&gt; finishes normally, returning the value &lt;code&gt;v&lt;/code&gt; and leaving the Machine &lt;code&gt;m₂&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let &lt;code&gt;m₃&lt;/code&gt; be "the Machine &lt;code&gt;m₂&lt;/code&gt; with the cell at address &lt;code&gt;a&lt;/code&gt; rewritten to &lt;code&gt;done v&lt;/code&gt;."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusions&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The first &lt;code&gt;whnf (n+1) a&lt;/code&gt; returns &lt;code&gt;ok v&lt;/code&gt;, and the final state is &lt;code&gt;m₃&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Address &lt;code&gt;a&lt;/code&gt; in &lt;code&gt;m₃&lt;/code&gt; really does hold &lt;code&gt;done v&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Every later &lt;code&gt;whnf (k+1) a&lt;/code&gt; returns &lt;code&gt;ok v&lt;/code&gt; &lt;strong&gt;for any &lt;code&gt;k : Nat&lt;/code&gt;&lt;/strong&gt; and leaves &lt;code&gt;m₃&lt;/code&gt; unchanged.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is &lt;strong&gt;a general, cell-level property&lt;/strong&gt; behind the observation in &lt;code&gt;memo-binding.les&lt;/code&gt; that "&lt;code&gt;g()&lt;/code&gt; runs on the first demand, and demanding the same &lt;code&gt;x&lt;/code&gt; later does not repeat the side effect."&lt;/p&gt;

&lt;p&gt;The second conclusion matters in particular. It guarantees not merely that "forcing returned the same value," but that &lt;strong&gt;the memoized value stays at the shared address&lt;/strong&gt;. The third is an equation about the whole Machine, so re-forcing does not change stdout either.&lt;/p&gt;

&lt;p&gt;Note, however, that the theorem &lt;strong&gt;assumes &lt;code&gt;hd&lt;/code&gt;, that is, that &lt;code&gt;demand&lt;/code&gt; finishes normally&lt;/strong&gt;. It does not cover memoization on failure, such as a self-referential blackhole or division by zero. Nor does this single theorem guarantee that every reference to &lt;code&gt;x&lt;/code&gt; from an arbitrary Les program points to the same cell. That part is checked by the evaluator's implementation and by individual sharing tests.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.6 An example that satisfies the theorem's hypotheses, also built in Lean
&lt;/h3&gt;

&lt;p&gt;Putting a condition like &lt;code&gt;hd&lt;/code&gt; in a theorem leaves a nagging question: "Is this a condition that nothing ever actually satisfies?"&lt;/p&gt;

&lt;p&gt;So in &lt;a href="https://github.com/gotoken/les-spec/blob/main/lean/Les/Proofs/NonVacuity.lean" rel="noopener noreferrer"&gt;&lt;code&gt;Proofs/NonVacuity.lean&lt;/code&gt;&lt;/a&gt; (comments in Japanese), I prepared a concrete example in which one unevaluated cell is allocated in &lt;code&gt;Heap.initial&lt;/code&gt;, the one the real evaluator uses.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight lean"&gt;&lt;code&gt;&lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;memoWitnessExpr&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Expr&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;line&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="n"&gt;col&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="mi"&gt;42&lt;/span&gt;
&lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;memoWitnessEnv&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Env&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;snap&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="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;scope&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;globalScope&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;memoWitnessCell&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Cell&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;suspended&lt;/span&gt; &lt;span class="n"&gt;memoWitnessExpr&lt;/span&gt; &lt;span class="n"&gt;memoWitnessEnv&lt;/span&gt;

&lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;memoWitnessMachine&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Machine&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;heap&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Heap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;initial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;alloc&lt;/span&gt; &lt;span class="n"&gt;memoWitnessCell&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stdout&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;memoWitnessAddr&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Addr&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Heap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;initial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;alloc&lt;/span&gt; &lt;span class="n"&gt;memoWitnessCell&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The proof &lt;code&gt;memoWitness_suspended&lt;/code&gt; shows that the cell at that address is unevaluated. &lt;code&gt;memoWitness_demand_ok&lt;/code&gt; shows that running &lt;code&gt;demand 2&lt;/code&gt; from the state in which that cell is a &lt;code&gt;blackhole&lt;/code&gt; gives &lt;code&gt;ok (.int 42)&lt;/code&gt;. &lt;code&gt;memoWitness_structWF&lt;/code&gt; shows that the initial Heap satisfies the structural well-formedness defined earlier.&lt;/p&gt;

&lt;p&gt;Using these three, &lt;code&gt;whnf_suspended_ok_memo_nonvacuous&lt;/code&gt; proves that &lt;strong&gt;there is at least one Machine, expression, and environment for which both hypotheses of &lt;code&gt;whnf_suspended_ok_memo&lt;/code&gt; hold at once&lt;/strong&gt;. &lt;code&gt;memoWitness_integrated&lt;/code&gt; is an example that applies the integrated theorem there and derives its three conclusions.&lt;/p&gt;

&lt;p&gt;So the relationships are as follows.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fude31f2sdfl3vndjxpi7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fude31f2sdfl3vndjxpi7.png" alt="Go observation, lesdump AST, Lean evaluator, 35 comparison tests and lemmas, the conditional memoization theorem, and its non-vacuity witness." width="800" height="556"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The tests and proofs in the diagram &lt;strong&gt;target the same Lean evaluator, but they are not logically the same claim&lt;/strong&gt;. The theorem was not derived from the 35 agreements with Go, and the correctness of the whole Go implementation was not derived from the Lean theorem.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.7 How it was verified
&lt;/h3&gt;

&lt;p&gt;The theorems are also checked with &lt;code&gt;#print axioms&lt;/code&gt;. In &lt;a href="https://github.com/gotoken/les-spec/actions/runs/43715508019" rel="noopener noreferrer"&gt;the CI for PR #22&lt;/a&gt;, after the fix, &lt;code&gt;lake build&lt;/code&gt; with Lean 4.25.0 succeeded, the only axioms &lt;code&gt;whnf_suspended_ok_memo_nonvacuous&lt;/code&gt; and &lt;code&gt;memoWitness_integrated&lt;/code&gt; depend on are &lt;code&gt;propext&lt;/code&gt; and &lt;code&gt;Quot.sound&lt;/code&gt;, and there was no &lt;code&gt;sorryAx&lt;/code&gt;. All 35 corpus comparisons were also PASS.&lt;/p&gt;

&lt;p&gt;In fact, the first implementation of non-vacuity tried to prove &lt;code&gt;memoWitness_demand_ok&lt;/code&gt; simply with &lt;code&gt;rfl&lt;/code&gt;, and compilation failed. After confirming that evaluating an integer literal allocates a &lt;code&gt;done&lt;/code&gt; cell, I changed it to a lemma, &lt;code&gt;demand_int_ok&lt;/code&gt;, that proves success using &lt;code&gt;whnf_done&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That failure included, I learned that &lt;strong&gt;making the execution results agree and producing proofs the Lean kernel accepts are separate jobs&lt;/strong&gt;. There is now a GitHub Actions workflow that runs the Lean build and the evaluator's corpus tests at the PR stage.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. What Lean bought me
&lt;/h2&gt;

&lt;p&gt;What came out of this experiment is more than a reimplementation in another language.&lt;/p&gt;

&lt;p&gt;First, &lt;strong&gt;I could make the semantic preconditions explicit.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For example, &lt;code&gt;Heap.bind&lt;/code&gt; accepts even an invalid cell address as an argument. So you cannot say that Heap well-formedness is preserved unconditionally.&lt;/p&gt;

&lt;p&gt;Working through the proofs made clear which operation needs which condition. I also recorded a counterexample in which binding an invalid address actually breaks well-formedness.&lt;/p&gt;

&lt;p&gt;Next, &lt;strong&gt;I could separate concrete test results from general properties.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;"Running this program gives the same value" is a test.&lt;/p&gt;

&lt;p&gt;"For every Machine, forcing an evaluated cell again changes neither the value nor the state" is a theorem.&lt;/p&gt;

&lt;p&gt;The Lean proofs here are of the latter kind. For the Lean model in question, they cover every state that satisfies the theorem's hypotheses.&lt;/p&gt;

&lt;p&gt;One more: &lt;strong&gt;the formalization itself can proceed in small steps.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I did not need to design a complete semantics of the whole language from the start. Observing, preparing the data types I needed, building a small evaluator, and growing the set of properties I could prove about it was enough to build up results.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. How the work was actually done
&lt;/h2&gt;

&lt;p&gt;In this project, I have AI assist with implementation and proofs.&lt;/p&gt;

&lt;p&gt;Claude Sonnet 5.5 did most of the implementation and the Lean proof work, and I used a different model for carving up the specification, design, and pull request reviews. On GitHub I also used reviews by Codex.&lt;/p&gt;

&lt;p&gt;What I emphasized was not finishing everything at once with long instructions, but keeping units of work small and giving each one a stopping condition.&lt;/p&gt;

&lt;p&gt;The basic cycle is as follows.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Observe with the Go CLI and record the expected values and their basis.&lt;/li&gt;
&lt;li&gt;Look into the Go implementation only when needed, and design the Lean model.&lt;/li&gt;
&lt;li&gt;Implement one feature, or one set of theorems.&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;lake build&lt;/code&gt;, the differential tests, and the unit tests.&lt;/li&gt;
&lt;li&gt;Record which properties were proved and which were not.&lt;/li&gt;
&lt;li&gt;Open a PR and move on after review.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I also set a policy of consulting a more expensive model only when stuck on interpreting difficult semantics. In the later stages so far, I have not needed &lt;code&gt;semantics-opus&lt;/code&gt;, which is set up for that.&lt;/p&gt;

&lt;p&gt;I have not measured the models' token usage well enough, however, so &lt;strong&gt;I cannot yet conclude that this approach is cheaper than manual development or a different AI setup.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What I could confirm is that, with AI assistance, proofs checked by the Lean compiler can be built step by step.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. What has not been proved yet
&lt;/h2&gt;

&lt;p&gt;The results so far have clear limits.&lt;/p&gt;

&lt;p&gt;First, &lt;strong&gt;I have not proved the equivalence of the whole Go implementation of Les and the Lean model.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That the Go CLI and Lean agree on observed results for 35 cases, and that some properties of the Lean model are proved, are separate facts.&lt;/p&gt;

&lt;p&gt;Second, &lt;strong&gt;not all of Les's features are covered.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Lean model currently handles a small sublanguage made of 9 kinds of syntax nodes. The original Les's structs, pattern matching, complex type system, and so on are out of scope.&lt;/p&gt;

&lt;p&gt;Third, &lt;strong&gt;type safety is not proved.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The current Lean evaluator takes as input a &lt;code&gt;CheckedProgram&lt;/code&gt;, which says that type checking on the Go side succeeded. This does not mean that Lean independently proved the type checker correct.&lt;/p&gt;

&lt;p&gt;Fourth, &lt;strong&gt;full Heap well-formedness is not proved yet either.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The basic reference structure of scopes is checked, but references held inside cells, such as addresses stored in a thunk's environment or scopes held by closures, are not covered.&lt;/p&gt;

&lt;p&gt;I think leaving these unproved properties explicitly stated is also an important part of this experiment.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Where to go from here
&lt;/h2&gt;

&lt;p&gt;For now, I am thinking of the following order.&lt;/p&gt;

&lt;h3&gt;
  
  
  Near term: settle the P2 results as a reference point
&lt;/h3&gt;

&lt;p&gt;A successful first force, monotonicity of the number of cells, memoization, and the stability of re-forcing are integrated into &lt;code&gt;whnf_suspended_ok_memo&lt;/code&gt; in P2d-5. I also prepared a concrete witness, and the &lt;a href="https://github.com/gotoken/les-spec/blob/main/docs/proof-coverage.md" rel="noopener noreferrer"&gt;list of proof coverage&lt;/a&gt; records the differences between observation, execution checks, and theorems.&lt;/p&gt;

&lt;p&gt;Next, I will look at the parts that can still only be handled conditionally, such as the Heap and blackhole state left after a failed &lt;code&gt;demand&lt;/code&gt;, and well-formedness that includes references inside cells. I will not try to prove everything while adding new features, though; I will pick the invariants that are needed and proceed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Medium term: widen the language features covered
&lt;/h3&gt;

&lt;p&gt;In P3, I am considering adding Les features one at a time, such as &lt;code&gt;if&lt;/code&gt;, Tuple, Dict, and pattern matching. The order is not fixed; I will choose by looking at how observable each one is in the Go implementation and how it affects the existing proofs.&lt;/p&gt;

&lt;p&gt;Each time a feature is added, I will repeat the cycle: observe in Go, sort out the semantics, implement in Lean, and prove the needed properties.&lt;/p&gt;

&lt;p&gt;Rather than porting the whole language at once, I want to keep a working result at every stage.&lt;/p&gt;

&lt;h3&gt;
  
  
  Long term: strengthen the relationship between the implementation and the formal model
&lt;/h3&gt;

&lt;p&gt;Further out, I would like to be able to explain the relationship between the Go implementation and the Lean model more strongly than the current finite set of differential tests does.&lt;/p&gt;

&lt;p&gt;That will probably require making the scope of the target sublanguage clear, and then more exhaustive test generation and a closer look at the correspondence between implementation and specification.&lt;/p&gt;

&lt;p&gt;Formally proving the semantic correctness of the Go implementation itself is an even bigger challenge.&lt;/p&gt;

&lt;p&gt;Rather than making that the final goal right away, I will first aim for a state where observable specifications accumulate and the Lean model serves as a checkable reference model.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. &lt;code&gt;ruby-lean&lt;/code&gt;, which I learned about after finishing P2 — comparing notes with prior work
&lt;/h2&gt;

&lt;p&gt;In &lt;strong&gt;November 2026&lt;/strong&gt;, when I had brought the P2 proofs to a stopping point, I learned of &lt;a href="https://samx.io/blog/topics/devlog/2026-09-26-ruby-lean.html" rel="noopener noreferrer"&gt;“ruby-lean: A Ruby semantics with a type soundness proof”&lt;/a&gt;, published by Sam Xifaras on September 26 of the same year. A &lt;a href="https://samx.io/blog/topics/devlog/2026-09-26-ruby-lean-technical-appendix.html" rel="noopener noreferrer"&gt;technical appendix&lt;/a&gt; and the &lt;a href="https://github.com/sam-xif/ruby-lean" rel="noopener noreferrer"&gt;source code&lt;/a&gt; are also available.&lt;/p&gt;

&lt;p&gt;The post was published before I started this experiment, but &lt;strong&gt;I only learned about it after finishing P2&lt;/strong&gt;. So the design and implementation of P0–P2 were not based on &lt;code&gt;ruby-lean&lt;/code&gt;. What follows is an after-the-fact comparison of notes and a look at options for the future.&lt;/p&gt;

&lt;h3&gt;
  
  
  The same method, applied to a different language and different theorems
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;ruby-lean&lt;/code&gt; makes Ruby into a model executable in Lean 4, compares it with the real CRuby, and further proves &lt;strong&gt;a restricted typing judgment inspired by Sorbet and its soundness&lt;/strong&gt;. &lt;code&gt;les-spec&lt;/code&gt;, on the other hand, makes part of Les, written in Go, evaluable in Lean and proves things such as &lt;strong&gt;memoization of shared thunks, environment capture, and address validity&lt;/strong&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Aspect&lt;/th&gt;
&lt;th&gt;
&lt;code&gt;les-spec&lt;/code&gt; (at the end of P2)&lt;/th&gt;
&lt;th&gt;
&lt;code&gt;ruby-lean&lt;/code&gt; (as reported in September 2026)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Original implementation and focus&lt;/td&gt;
&lt;td&gt;Les in Go. Focus on lazy evaluation, rebinding, capture, and forward references&lt;/td&gt;
&lt;td&gt;CRuby. Also handles method calls, classes, dynamic modification, and more&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Input to Lean&lt;/td&gt;
&lt;td&gt;JSON AST from &lt;code&gt;lesdump&lt;/code&gt;, which goes through Go's parser and type checker&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Desugaring&lt;/strong&gt; of Ruby's surface syntax into a smaller core language&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Evaluator&lt;/td&gt;
&lt;td&gt;Fuel-bounded recursive functions &lt;code&gt;evalE&lt;/code&gt;, &lt;code&gt;whnf&lt;/code&gt;, &lt;code&gt;demand&lt;/code&gt;. &lt;code&gt;Machine&lt;/code&gt; holds the Heap and stdout&lt;/td&gt;
&lt;td&gt;A &lt;strong&gt;CESK abstract machine&lt;/strong&gt; that makes control, environment, store, and continuation explicit and steps through transitions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Differential checks&lt;/td&gt;
&lt;td&gt;Compares stdout, stderr, and exit code of 35 cases against the pinned Go CLI&lt;/td&gt;
&lt;td&gt;Uses CRuby's &lt;code&gt;bootstraptest&lt;/code&gt;, generated tests, and more. The technical appendix reports &lt;strong&gt;995 of 1,309&lt;/strong&gt; bootstraptest cases conforming on semantics&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Center of the proofs&lt;/td&gt;
&lt;td&gt;Internal properties of the evaluator, such as memoization on a &lt;strong&gt;successful&lt;/strong&gt; first force and the stability of re-forcing&lt;/td&gt;
&lt;td&gt;That &lt;strong&gt;programs accepted by the type checker&lt;/strong&gt; do not fall into the defined kinds of type-related errors&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The last row is not a ranking of the results. &lt;strong&gt;The properties each wants to prove are different.&lt;/strong&gt; The &lt;code&gt;ruby-lean&lt;/code&gt; result does not guarantee the soundness of all of Ruby or Sorbet, and the &lt;code&gt;les-spec&lt;/code&gt; result does not guarantee general equivalence of Go and Lean.&lt;/p&gt;

&lt;h3&gt;
  
  
  Comparison 1: an executable semantics and conformance to the implementation are separate problems
&lt;/h3&gt;

&lt;p&gt;The first thing confirmed was that the approach of separating &lt;strong&gt;Lean being able to check theorems&lt;/strong&gt; from &lt;strong&gt;the Lean evaluator correctly modeling the original language&lt;/strong&gt; is sound.&lt;/p&gt;

&lt;p&gt;Xifaras reports that while &lt;code&gt;ruby-lean&lt;/code&gt; passes a large set of differential tests, there is an unresolved discrepancy with CRuby around Ruby's implicit string conversion via &lt;code&gt;to_str&lt;/code&gt;, and publishes a concrete example. Having theorems about a model does not by itself guarantee that the model represents all the behavior of the original implementation.&lt;/p&gt;

&lt;p&gt;Likewise here, what &lt;code&gt;whnf_suspended_ok_memo&lt;/code&gt; proves is &lt;strong&gt;the cell update on success and re-forcing by Lean's &lt;code&gt;whnf&lt;/code&gt;&lt;/strong&gt;. It does not prove that Go's Les behaves the same way on every input. In light of this prior work too, it matters that I did not call the 35 agreements "semantic equivalence."&lt;/p&gt;

&lt;p&gt;In addition, the &lt;code&gt;ruby-lean&lt;/code&gt; technical appendix distinguishes existing conformance tests (Tier 0), generated tests (Tier 1), &lt;strong&gt;tests that insert &lt;code&gt;print&lt;/code&gt; in the middle to check the order in which side effects occur&lt;/strong&gt; (Tier 1.5), and complex tests generated by AI (Tier 3). For Les as well, it looks feasible to add tests that distinguish the shared thunks of &lt;code&gt;E9&lt;/code&gt;, the bindings of &lt;code&gt;E14/E15&lt;/code&gt;, and the evaluation order of &lt;code&gt;E17/E19&lt;/code&gt; not just by final values but by where side effects appear.&lt;/p&gt;

&lt;h3&gt;
  
  
  Comparison 2: same &lt;code&gt;Machine&lt;/code&gt; name, different evaluator structure
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;ruby-lean&lt;/code&gt;'s evaluator uses &lt;strong&gt;CESK&lt;/strong&gt; (&lt;em&gt;control, environment, store, continuation&lt;/em&gt;). Its &lt;code&gt;Machine&lt;/code&gt; contains &lt;code&gt;ctl&lt;/code&gt;, which says what to execute next, and &lt;code&gt;kont&lt;/code&gt;, a continuation stack holding the rest of the computation.&lt;/p&gt;

&lt;p&gt;In contrast, &lt;code&gt;les-spec&lt;/code&gt;'s &lt;code&gt;Machine&lt;/code&gt; holds a &lt;code&gt;Heap&lt;/code&gt; and &lt;code&gt;stdout&lt;/code&gt;. Which expression to evaluate next shows up as &lt;strong&gt;recursive calls&lt;/strong&gt; to &lt;code&gt;evalE&lt;/code&gt;, &lt;code&gt;whnf&lt;/code&gt;, and &lt;code&gt;demand&lt;/code&gt;; there is no explicit &lt;code&gt;kont&lt;/code&gt; stack.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo3iyovs2qymcdj7gqmr1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo3iyovs2qymcdj7gqmr1.png" alt="Comparison between the les-spec evaluator and Machine with Heap and stdout, and ruby-lean's Machine with ctl, kont, stack, heap and out." width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, the same name &lt;code&gt;Heap&lt;/code&gt; refers in &lt;code&gt;les-spec&lt;/code&gt; to &lt;strong&gt;an array of cells representing thunk states&lt;/strong&gt;, while in &lt;code&gt;ruby-lean&lt;/code&gt; it is centered on &lt;strong&gt;an array storing Ruby objects&lt;/strong&gt;. The terms are similar, but the models do not correspond one to one.&lt;/p&gt;

&lt;p&gt;These differences do not mean the current Les model must be rewritten as CESK right away. But if it is extended with &lt;code&gt;return&lt;/code&gt; / &lt;code&gt;break&lt;/code&gt;, exceptions, I/O, suspending and resuming evaluation, and so on, there is room to compare &lt;strong&gt;whether making continuations explicit makes the proofs easier&lt;/strong&gt;. The technical appendix also mentions that lemmas about decomposing the continuation stack helped the proofs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Comparison 3: not just more tests, but a way of working that keeps the proofs intact
&lt;/h3&gt;

&lt;p&gt;Another thing in common was the policy of &lt;strong&gt;stacking up small completion conditions&lt;/strong&gt; rather than having AI implement a large specification all at once.&lt;/p&gt;

&lt;p&gt;Xifaras calls this a &lt;strong&gt;ratchet&lt;/strong&gt; (a mechanism that only moves one way). In particular, when adding typing rules, the completion condition is not just that individual tests pass, but that &lt;strong&gt;the proof obligations of the added rule are met and the overall type soundness theorem still holds&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;les-spec&lt;/code&gt; too, observation, model, and proofs were split into small PRs. But as the failure of the first &lt;code&gt;lake build&lt;/code&gt; of &lt;code&gt;NonVacuity.lean&lt;/code&gt; for P2d-5's non-vacuity showed, splitting alone is not enough. After that, I added &lt;code&gt;lake build&lt;/code&gt; and the existing corpus tests to GitHub Actions. This is where the prior work's method and my own experience of failure line up.&lt;/p&gt;

&lt;h3&gt;
  
  
  Additional plans worth considering
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. Grow the differential tests in more than one way.&lt;/strong&gt; In addition to the 35 handwritten cases, I am considering generating Les programs that pass type checking, inserting observable side effects, and combining the existing examples of thunk sharing and environment capture. For this subject, &lt;strong&gt;which evaluation rules a test can distinguish&lt;/strong&gt; is a better yardstick than the sheer number of tests. Agreement between Go and Lean on generated tests is still observation, not proof.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Keep the existing theorems intact while adding features in P3.&lt;/strong&gt; When adding &lt;code&gt;if&lt;/code&gt;, Tuple, Dict, and so on, the completion condition will include keeping the proofs of &lt;code&gt;demand_mono&lt;/code&gt;, address validity, and memoization, in addition to agreement between the Go oracle and Lean. If an added evaluation rule needs a new precondition, its reason and scope will be stated explicitly. The idea is to apply the prior work's ratchet &lt;strong&gt;along two axes: the execution corpus and the proofs&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Consider whether translation to a core language is needed.&lt;/strong&gt; &lt;code&gt;ruby-lean&lt;/code&gt; translates surface Ruby syntax into a small core. As Les's supported syntax grows, translating to a small core might make the proofs shorter than adding each piece of surface syntax to Lean as is. On the other hand, it would then need to be verified that &lt;strong&gt;the desugaring itself does not change the behavior of the original program&lt;/strong&gt;. There is no plan to replace the current &lt;code&gt;lesdump&lt;/code&gt; right away.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. For types, consider options other than "porting the whole inference engine."&lt;/strong&gt; The current &lt;code&gt;CheckedProgram&lt;/code&gt; trusts the success of Go's type checking. &lt;code&gt;ruby-lean&lt;/code&gt; chose to have an &lt;strong&gt;untrusted generator&lt;/strong&gt; produce candidate typing derivations and have a Lean checker verify them. That is an option for verifying Les's types in the future. But in Les, with lazy evaluation, rebinding, and forward references, I would first have to define &lt;strong&gt;which errors type safety is supposed to rule out&lt;/strong&gt;. This is a long-term consideration, not work I have decided to add to the current P3.&lt;/p&gt;

&lt;p&gt;Learning about the prior work after the fact did not mean redoing the P2 work. Rather, it let me check &lt;strong&gt;the direction of keeping implementation observation and formal proof separate&lt;/strong&gt; against another practice. On the other hand, I think large undertakings such as CESK or a type soundness proof should be adopted or not once their purpose becomes necessary, not by transplanting the method as is.&lt;/p&gt;

&lt;p&gt;This section is a comparison based on &lt;a href="https://samx.io/blog/topics/devlog/2026-09-26-ruby-lean.html" rel="noopener noreferrer"&gt;the main post&lt;/a&gt;, the &lt;a href="https://samx.io/blog/topics/devlog/2026-09-26-ruby-lean-technical-appendix.html" rel="noopener noreferrer"&gt;technical appendix&lt;/a&gt;, and &lt;a href="https://github.com/sam-xif/ruby-lean" rel="noopener noreferrer"&gt;the published &lt;code&gt;ruby-lean&lt;/code&gt; code&lt;/a&gt;. The additional plans above are &lt;strong&gt;candidates&lt;/strong&gt;, not completed results.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Closing
&lt;/h2&gt;

&lt;p&gt;Taking Les as the subject, I found that formalizing a language implementation can begin without first writing a huge specification.&lt;/p&gt;

&lt;p&gt;Les is a relatively small implementation, yet it has semantically interesting elements: lazy evaluation, memoization, closures, environment capture, forward references, rebinding, and more.&lt;/p&gt;

&lt;p&gt;In particular, the mechanism of capturing names that existed at creation time and resolving names that were unbound later was a good subject for thinking about what kind of environment model is needed.&lt;/p&gt;

&lt;p&gt;And for the Lean model built from observations of the Go implementation, I was able to go as far as proving general properties.&lt;/p&gt;

&lt;p&gt;This is still a result limited to a small sublanguage, but I plan to keep adding observations and proofs bit by bit from here.&lt;/p&gt;

&lt;p&gt;Finally, my thanks to usa for publishing Les. And thank you for reading this post.&lt;/p&gt;

&lt;h3&gt;
  
  
  Related repositories
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/unak/les" rel="noopener noreferrer"&gt;unak/les&lt;/a&gt; — the Go language being formalized&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/gotoken/les-spec" rel="noopener noreferrer"&gt;gotoken/les-spec&lt;/a&gt; — this experiment (most documents have English translations; discussion in issues and PRs is mostly in Japanese)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/gotoken/les-spec/blob/main/docs/evaluator-design.md" rel="noopener noreferrer"&gt;Evaluator design notes&lt;/a&gt; — rules E1–E22 and their rationale&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/gotoken/les-spec/tree/main/difftest/corpus" rel="noopener noreferrer"&gt;Differential test corpus&lt;/a&gt; — the programs used for observation and their expected results&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/gotoken/les-spec/tree/main/lean/Les/Proofs" rel="noopener noreferrer"&gt;Lean proofs&lt;/a&gt; — proofs about the Heap, memoization, environment capture, monotonicity, and more&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>lean4</category>
      <category>les</category>
      <category>formalization</category>
      <category>ai</category>
    </item>
    <item>
      <title>Reading Lean Side by Side: Introducing Taiyak</title>
      <dc:creator>Kentaro Goto</dc:creator>
      <pubDate>Fri, 13 Nov 2026 15:20:33 +0000</pubDate>
      <link>https://dev.to/gotoken/reading-lean-side-by-side-introducing-taiyak-2f9</link>
      <guid>https://dev.to/gotoken/reading-lean-side-by-side-introducing-taiyak-2f9</guid>
      <description>&lt;h2&gt;
  
  
  I made Taiyak
&lt;/h2&gt;

&lt;p&gt;I made Taiyak, a browser tool that splits Lean 4 source into declarations and shows each one next to a translation into natural-language mathematics. The name comes from the Japanese &lt;em&gt;taiyaku&lt;/em&gt; (対訳), a text printed side by side with its translation.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Web version: &lt;a href="https://taiyak.pages.dev/" rel="noopener noreferrer"&gt;taiyak.pages.dev&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Source: &lt;a href="https://github.com/gotoken/taiyak" rel="noopener noreferrer"&gt;gotoken/taiyak&lt;/a&gt; (BSD-2-Clause)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It opens a GitHub URL (private repositories too), a ZIP file or a folder. It only reads the source and never runs Lean, so you need no Lean installation. Opened without a URL, it shows a demo: a formalization I tried on CRuby.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft9urcl4d61n7aowblytq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft9urcl4d61n7aowblytq.png" alt="The Taiyak screen with the demo Statements.lean open: Lean code on the left, the English translation on the right. Clicking ∀ in proposition P1 pops up an explanation of the universal quantifier."&gt;&lt;/a&gt;&lt;/p&gt;
Click ∀ to see what it means



&lt;h2&gt;
  
  
  It started with the CPython formalization
&lt;/h2&gt;

&lt;p&gt;It started when I read "&lt;a href="https://broyojo.com/python-formalization/" rel="noopener noreferrer"&gt;Formalizing CPython&lt;/a&gt;" by David Andrews and Chao Zhang. Working mainly with Claude Opus 5.5, they copy the functions of CPython 3.15.2 into Lean and check each one in four steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Copy: rewrite the C or Python source in Lean, keeping error messages and edge cases&lt;/li&gt;
&lt;li&gt;Test: run the Lean copy against the real CPython on at least 50,000 generated inputs per function&lt;/li&gt;
&lt;li&gt;Prove: state a property and have the machine check it; if it is false, keep the counterexample&lt;/li&gt;
&lt;li&gt;Check: another agent, one that did not write the copy, asks whether a broken implementation could still pass the proof&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So far they have written 613,318 lines of Lean, and along the way 418 bug reports have been filed against Python.&lt;/p&gt;

&lt;p&gt;It looked fascinating, so I tried to read it, but being new to Lean I found the theorems hard to take in one by one. Later I also started an experiment applying the same method to CRuby's &lt;code&gt;range.c&lt;/code&gt; (&lt;code&gt;rb_range_component_beg_len&lt;/code&gt;, which normalizes range arguments). Taiyak's demo is the Lean files from that experiment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not read it as a parallel text?
&lt;/h2&gt;

&lt;p&gt;Before learning Lean from scratch, perhaps I could read it if mathematical prose sat right next to it. It is the same idea as a bilingual reader for language learners.&lt;/p&gt;

&lt;p&gt;Lean, I thought, suits this well. Put an ordinary program into prose and you get an explanation of what it does, worded differently by every writer. A Lean theorem is itself a proposition, and a definition is a mathematical object. &lt;code&gt;∀ x, P x&lt;/code&gt; can only be translated as "for every x, P x". Because the right translation is nearly fixed as mathematics, setting it against the Lean also makes mistranslations easy to spot.&lt;/p&gt;

&lt;p&gt;As an example, here is the normalization of the start index in the demo's &lt;code&gt;Spec.lean&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight lean"&gt;&lt;code&gt;&lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;specBeg&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Input&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Int&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt;
  &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getD&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Next to it, Taiyak shows the heading "Definition: normalized start B" and the following formula, where b₀ is the start (0 if it is nil). Formulas are rendered with KaTeX.&lt;/p&gt;

&lt;p&gt;

&lt;/p&gt;
&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;B&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;&lt;span class="delimsizing size4"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mtable"&gt;&lt;span class="col-align-l"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;b&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;b&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="arraycolsep"&gt;&lt;/span&gt;&lt;span class="col-align-l"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;b&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;0&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;b&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;≥&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;0&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;



&lt;p&gt;The only other line is "negative values count from the end". Set against the three lines of Lean, you can tell at once whether the translation is right.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Lean proofs are trusted
&lt;/h2&gt;

&lt;p&gt;Lean proofs are trusted because the part that checks them is small, and a different implementation can check them again.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Propositions are types, and proofs are terms of those types. Whether a proof is correct comes down to a mechanical check that the term has the type.&lt;/li&gt;
&lt;li&gt;Only a small kernel does the checking. Automation such as tactics merely builds proof terms, and the kernel checks the result again, so even a bug in a tactic cannot get a false theorem through (&lt;a href="https://lean-lang.org/doc/reference/4.35.0-rc1/" rel="noopener noreferrer"&gt;Lean reference&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;The kernel can be re-checked by other implementations: the official lean4checker, &lt;a href="https://arxiv.org/abs/2403.14064" rel="noopener noreferrer"&gt;Lean4Lean&lt;/a&gt; written in Lean, Nanoda written in Rust and others. You do not have to trust the whole Lean implementation (&lt;a href="https://lean-lang.org/faq" rel="noopener noreferrer"&gt;Lean FAQ&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;The axioms a proof relies on are recorded. If &lt;code&gt;#print axioms&lt;/code&gt; shows only the standard &lt;code&gt;propext&lt;/code&gt;, &lt;code&gt;Classical.choice&lt;/code&gt; and &lt;code&gt;Quot.sound&lt;/code&gt;, all is well. &lt;code&gt;sorry&lt;/code&gt; shows up as &lt;code&gt;sorryAx&lt;/code&gt;, and &lt;code&gt;native_decide&lt;/code&gt; as &lt;code&gt;Lean.trustCompiler&lt;/code&gt;, which trusts the whole compiler, so shortcuts cannot hide (&lt;a href="https://lean-lang.org/doc/reference/4.29.0/ValidatingProofs/" rel="noopener noreferrer"&gt;Validating a Lean Proof&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What this guarantees, though, is only that the proof is correct. What a theorem statement means is a separate question, which I come back to below.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Lean and not Rocq? (a guess)
&lt;/h2&gt;

&lt;p&gt;Most companies working on theorem proving with AI use Lean. OpenAI used Coq (now Rocq) for GamePad in 2018, then moved to Lean (&lt;a href="https://arxiv.org/pdf/2605.27485" rel="noopener noreferrer"&gt;a summary of the history&lt;/a&gt;), and its openai/math release in 2026 is formalized in Lean 4 and Mathlib (&lt;a href="https://hyper.ai/en/datasets/openai-math" rel="noopener noreferrer"&gt;dataset description&lt;/a&gt;). The reasons have not been stated, so what follows is my guess.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mathlib exists.&lt;/strong&gt; It is one huge mathematics library, useful both as training data and as the vocabulary for stating problems. The CSLib paper also says Mathlib played a large part in training AI for mathematical reasoning (&lt;a href="https://arxiv.org/abs/2602.04846" rel="noopener noreferrer"&gt;CSLib&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ordinary mathematics can be written as it is.&lt;/strong&gt; Mathlib's culture uses the law of excluded middle and proof by contradiction freely. Paulson sees the Rocq community's insistence on constructive proof as having held back its use in mathematics, leaving that ground to Lean (&lt;a href="https://lawrencecpaulson.github.io/2026/04/23/Why_not_Lean.html" rel="noopener noreferrer"&gt;Why not just use Lean?&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It is also a programming language.&lt;/strong&gt; Lean definitions can be compiled and run. The "Test" step of the CPython formalization works by actually running the Lean copy and comparing it with CPython.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It is easy to drive from an agent.&lt;/strong&gt; elan and lake give a single toolchain, so setting up is not a puzzle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pass or fail is clear-cut.&lt;/strong&gt; Whether the kernel accepts a proof serves directly as the reward in reinforcement learning.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rocq has not stepped back, though. In October 2026 Anthropic and Theorem used Rocq to prove that 123 libraries do not crash, at the level of RISC-V machine code (&lt;a href="https://letsdatascience.com/blog/claude-wrote-180-million-lines-of-proofs-only-on-risc-v" rel="noopener noreferrer"&gt;coverage&lt;/a&gt;). Perhaps the split is Lean for mathematics and the meaning of languages, and Rocq for verification that builds on accumulated machine semantics.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generated Lean still has to be read by people
&lt;/h2&gt;

&lt;p&gt;The kernel guarantees only that "this statement was shown by this proof", not that the statement says what you meant. The Lean reference too treats whether a proof is correct and what a theorem statement means as separate questions. It also counts unreviewed AI-generated proofs among those to be handled with the same caution as malicious ones (&lt;a href="https://lean-lang.org/doc/reference/4.29.0/ValidatingProofs/" rel="noopener noreferrer"&gt;Validating a Lean Proof&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Three pitfalls are common:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The premises cannot be satisfied, so the theorem is vacuously true&lt;/li&gt;
&lt;li&gt;A definition is mistranscribed: the proof is correct, but about a definition that differs from the implementation&lt;/li&gt;
&lt;li&gt;The proposition proved is weaker than the property you wanted&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The "Check" step of Formalizing CPython is exactly the step that looks for these. In my CRuby experiment too, AI proposed the propositions and premises, and I confirmed them before moving on to the proofs. &lt;code&gt;NonVacuity.lean&lt;/code&gt; holds concrete inputs that satisfy each theorem's premises, showing that none is vacuous.&lt;/p&gt;

&lt;p&gt;In other words, what people need to read is not the proofs but the definitions and theorem statements. Proofs are the kernel's job; statements are ours. That is also why Taiyak folds long proofs from the start: I want the statements read first.&lt;/p&gt;

&lt;p&gt;Taiyak's translations are LLM output too, so they can be wrong. That is why they sit next to the Lean, where they can be checked against it, instead of replacing it.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use it
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open the &lt;a href="https://taiyak.pages.dev/" rel="noopener noreferrer"&gt;web version&lt;/a&gt;, enter a GitHub URL and press "Open"&lt;/li&gt;
&lt;li&gt;In "Settings", enter an API key from Anthropic, OpenAI, Google or OpenRouter. For a private repository, also enter a GitHub token: a link in Settings opens GitHub's token page with read-only access and a 30-day expiry already filled in&lt;/li&gt;
&lt;li&gt;Press "Translate this file", or "Translate" on a single block&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To help with reading:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Click Lean code for hints.&lt;/strong&gt; For an identifier you get a summary of its definition and a jump to it; symbols such as &lt;code&gt;∀&lt;/code&gt; and tactics such as &lt;code&gt;omega&lt;/code&gt; and &lt;code&gt;rcases&lt;/code&gt; get a short explanation&lt;/li&gt;
&lt;li&gt;"Ask Claude about this spot" lets you ask a question with the declaration as context&lt;/li&gt;
&lt;li&gt;When translating, Taiyak follows imports and sends the definitions the code refers to as context&lt;/li&gt;
&lt;li&gt;Translations are kept in the browser. Export them as JSON and commit them to the repository's &lt;code&gt;.taiyak/&lt;/code&gt;, and anyone can read the translations without an API key&lt;/li&gt;
&lt;li&gt;The URL in the address bar is a share link, and pressing a declaration's line numbers copies a link to that declaration&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Design decisions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Limiting where data can go, with headers
&lt;/h3&gt;

&lt;p&gt;Taiyak handles API keys and sometimes private source code. Rather than explaining in code that it sends nothing anywhere else, I thought it would be easier to verify if the browser enforced it.&lt;/p&gt;

&lt;p&gt;The web version returns a Content-Security-Policy from Cloudflare Pages' &lt;code&gt;_headers&lt;/code&gt;. Its &lt;code&gt;connect-src&lt;/code&gt; lists only the GitHub API and four LLM APIs, so if the page tries to send anything anywhere else, the browser refuses.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;connect-src https://api.github.com https://api.anthropic.com https://api.openai.com https://generativelanguage.googleapis.com https://openrouter.ai
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The inline script is pinned by its sha256, with &lt;code&gt;default-src 'none'&lt;/code&gt;, &lt;code&gt;form-action 'none'&lt;/code&gt;, &lt;code&gt;frame-ancestors 'none'&lt;/code&gt; and &lt;code&gt;Referrer-Policy: no-referrer&lt;/code&gt; as well. The build output is committed to the repository and CI checks that it matches the source, so what is served can be read on GitHub as it is.&lt;/p&gt;

&lt;h3&gt;
  
  
  Masking without a password field
&lt;/h3&gt;

&lt;p&gt;If the API key field were &lt;code&gt;type="password"&lt;/code&gt;, the password managers in Chrome and Safari would react and offer to save it as this site's login password. An API key is not for logging in to this site, so that gets in the way.&lt;/p&gt;

&lt;p&gt;So the field is an ordinary text input, masked with the CSS &lt;code&gt;-webkit-text-security: disc&lt;/code&gt;, and an eye button toggles visibility. Only browsers without that CSS fall back to &lt;code&gt;type="password"&lt;/code&gt;. The field also carries attributes that tell 1Password, Bitwarden and the like to ignore it. Keys are used only inside the browser, and saved to localStorage only if you choose "Remember in this browser".&lt;/p&gt;

&lt;p&gt;Honestly, though, I am torn. API keys are exactly what I would like to keep in a password manager: not as a login password, but with the manager acting as a vault for tokens. If you know a good way to do that, please tell me.&lt;/p&gt;

&lt;h3&gt;
  
  
  Matching the interface language to the translation
&lt;/h3&gt;

&lt;p&gt;Translations in Korean with the interface in Japanese would look awkward. So there is a single language choice, and the translations, the interface, the glossary and Claude's explanations all follow it. Interface text is built in for ten languages (Japanese, English, Simplified and Traditional Chinese, Korean, French, German, Spanish, Portuguese and Russian); other languages get the English interface. A setting can also fix the interface language on its own.&lt;/p&gt;

&lt;p&gt;Right-to-left languages such as Arabic and Hebrew are untested. Typing the language name should produce translations, but I cannot read them, so I cannot judge whether the display is right. Anyone willing to try is welcome.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I wish were different
&lt;/h2&gt;

&lt;p&gt;Translating needs an LLM API key. Taiyak cannot use the allowance of flat-rate plans such as Claude Pro or ChatGPT Plus today. Translating on the plan you already pay for would be the easiest, but that is not how it works.&lt;/p&gt;

&lt;p&gt;There are a few workarounds:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Publish &lt;code&gt;dist/claude-artifact.html&lt;/code&gt; as a claude.ai artifact, and each viewer translates with their own Claude account, with no API key. Pages inside claude.ai cannot reach GitHub, though, so you download the repository as a ZIP and load that&lt;/li&gt;
&lt;li&gt;OpenRouter's free models are available&lt;/li&gt;
&lt;li&gt;Google's Gemini API has a free tier. It is crowded, though: a translation of a single block took about three minutes to arrive. Gemini 4 Argon is not available on the free tier&lt;/li&gt;
&lt;li&gt;Commit the translations to &lt;code&gt;.taiyak/&lt;/code&gt;, and readers need no key at all&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As for ChatGPT, Sign in with ChatGPT arrived in September, letting Plus and Pro allowances be brought into outside tools without an API key. It covers products of participating partners, 16 at launch (&lt;a href="https://itbrief.com.au/story/openai-launches-chatgpt-sign-in-for-16-partner-tools" rel="noopener noreferrer"&gt;itbrief&lt;/a&gt;). I found no form that a personal site can freely build in, so I am watching it as a future option.&lt;/p&gt;

&lt;p&gt;I also tried supporting Gemini Nano, built into Chrome (the Prompt API). It needs no key and the code never leaves the device, which is appealing. But it is a small model, and translating Lean into mathematics seems too much for it: its translations fall short of the API models, and long declarations may not fit its input limit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Closing
&lt;/h2&gt;

&lt;p&gt;Lean written by AI is going to grow fast. With the kernel checking the proofs, what is left for people is reading whether "this statement is really the right one". I hope Taiyak becomes a way in for people new to Lean to join that work.&lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://broyojo.com/python-formalization/" rel="noopener noreferrer"&gt;Formalizing CPython&lt;/a&gt; (David Andrews, Chao Zhang)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://lean-lang.org/doc/reference/4.29.0/ValidatingProofs/" rel="noopener noreferrer"&gt;Validating a Lean Proof&lt;/a&gt; (Lean Language Reference)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://lean-lang.org/faq" rel="noopener noreferrer"&gt;Lean FAQ&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://arxiv.org/abs/2403.14064" rel="noopener noreferrer"&gt;Lean4Lean: Towards a formalized metatheory for the Lean theorem prover&lt;/a&gt; (Mario Carneiro)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://lawrencecpaulson.github.io/2026/04/23/Why_not_Lean.html" rel="noopener noreferrer"&gt;Why not just use Lean?&lt;/a&gt; (Lawrence C. Paulson)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://arxiv.org/abs/2602.04846" rel="noopener noreferrer"&gt;CSLib: The Lean Computer Science Library&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://arxiv.org/pdf/2605.27485" rel="noopener noreferrer"&gt;Automating Formal Verification with Agent-Guided Tree Search&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hyper.ai/en/datasets/openai-math" rel="noopener noreferrer"&gt;openai-math dataset&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://letsdatascience.com/blog/claude-wrote-180-million-lines-of-proofs-only-on-risc-v" rel="noopener noreferrer"&gt;Claude wrote 180 million lines of proofs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>lean4</category>
      <category>ruby</category>
      <category>ai</category>
      <category>formalization</category>
    </item>
  </channel>
</rss>
