<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Aaron Windsor</title>
    <description></description>
    <link>http://blog.aaw.io/</link>
    <atom:link href="http://blog.aaw.io/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Sun, 26 Oct 2025 09:11:22 -0400</pubDate>
    <lastBuildDate>Sun, 26 Oct 2025 09:11:22 -0400</lastBuildDate>
    <generator>Jekyll v4.4.1</generator>
    
      <item>
        <title>Work-efficient Prefix Sums</title>
        <description>&lt;p&gt;The prefix sums &lt;em&gt;p&lt;/em&gt; of an array &lt;em&gt;a&lt;/em&gt; are defined as:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;p[0] = a[0]
p[1] = a[0] + a[1]
p[2] = a[0] + a[1] + a[2]
...
p[n-1] = a[0] + a[1] + ... + a[n-1]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;But if you actually want to compute the prefix sums, you wouldn’t use that formula.
Instead, you’d compress all the repetitive sums and compute &lt;em&gt;p&lt;/em&gt; with only &lt;em&gt;n-1&lt;/em&gt; total
additions:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;p[0] = a[0]
p[1] = p[0] + a[1]
p[2] = p[1] + a[2]
...
p[n-1] = p[n-2] + a[n-1]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If you want to compute prefix sums in parallel instead, it’s easy to come up with a scheme
that can compute all the &lt;em&gt;p&lt;/em&gt;’s in &lt;em&gt;O(log n)&lt;/em&gt; time, but it’s harder to come up with a scheme
that’s &lt;em&gt;work-efficient&lt;/em&gt;, meaning it does &lt;em&gt;O(n)&lt;/em&gt; total additions – the same amount
of work as the sequential sum above.&lt;/p&gt;

&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Brent%E2%80%93Kung_adder&quot;&gt;Brent-Kung adder&lt;/a&gt; uses work-efficient parallel prefix sums to propagate carries. The adder doesn’t
actually compute &lt;em&gt;sums&lt;/em&gt;, but instead accumulates a special operator &lt;em&gt;o&lt;/em&gt; across an entire array. Since &lt;em&gt;o&lt;/em&gt; is associative, the same
ideas for prefix sums apply, so I’ll just talk about sums in the rest of this post.&lt;/p&gt;

&lt;p&gt;In the original Brent-Kung paper&lt;sup id=&quot;fnref:2&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; they show a variant of this network to illustrate
the work-efficient prefix sum computation on 16 elements:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/prefix-sums/16.svg&quot; alt=&quot;A work-efficient prefix sum network for n=16&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The computation flows from top to bottom, with inputs fed into the wires at the top. Whenever there’s a small
circle on wire i leading to a large +-circle on wire j, you add the current contents of wire i to wire j and
store the result in wire j. At the bottom of the diagram, each wire &lt;em&gt;i&lt;/em&gt; holds &lt;em&gt;p[i]&lt;/em&gt;, the prefix sum of all
input elements up to and including wire &lt;em&gt;i&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Brent and Kung cite a paper by Ladner and Fischer&lt;sup id=&quot;fnref:1&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; for the network construction. The &lt;a href=&quot;https://en.wikipedia.org/wiki/Prefix_sum#Parallel_algorithms&quot;&gt;Wikipedia page for
prefix sums&lt;/a&gt; also has a diagram like the one above and cites Ladner and Fischer as well as two other papers in
Russian from around the same time. The &lt;a href=&quot;https://dl.acm.org/doi/pdf/10.1145/322217.322232&quot;&gt;Ladner-Fischer paper&lt;/a&gt; provides a recursive construction of these
networks in the form of network diagrams, but no pseudocode to generate them and no explicit proof that they’re
correct. I’m sure it’s easy to prove by induction, but the whole construction was pretty mysterious to me at
first. The Wikipedia entry has a high-level description of the networks, but did not leave me feeling like
I was ready to write code to generate them:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;3. Express each term of the final sequence y0, y1, y2, … as the sum of up to two terms of these
intermediate sequences: y0 = x0, y1 = z0, y2 = z0 + x2, y3 = w1, etc. After the first value, each
successive number yi is either copied from a position half as far through the w sequence, or is
the previous value added to one value in the x sequence.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I wanted to find code to generate these networks because I’m using the Brent-Kung adder in &lt;a href=&quot;https://github.com/aaw/cnfc&quot;&gt;cncf, the CNF compiler&lt;/a&gt;
I’m working on. The Brent-Kung adder is simple and achieves logarithmic delay because of the work-efficient parallel
prefix sum scheme, which should make it nice for encoding SAT problems that involve arithmetic. In circuits, delay means time, but in SAT
encodings, delay means inference complexity to a solver. All else being equal, doing unit propagation
or resolution over a long chain of clauses should be more expensive for a solver than simpler encodings, although
it doesn’t always work that way. But in general, achieving simple, low-depth encodings is a good overall goal
for generating CNF encodings.&lt;/p&gt;

&lt;h2 id=&quot;the-ladner-fischer-networks&quot;&gt;The Ladner-Fischer Networks&lt;/h2&gt;

&lt;p&gt;Ladner and Fischer provide a mutually recursive definition of their prefix sum network.
I translated it to Python as:&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Generates the Ladner-Fischer network P_k on wires xs with parameter k.
# To generate a prefix sum network for n elements, call
# ladner_fischer_network(list(range(n))).
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;ladner_fischer_network&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;half&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;math&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ceil&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;yield&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;ladner_fischer_network&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;half&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;yield&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;ladner_fischer_network&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;half&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;yield&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;from &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;half&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;xs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;xs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;half&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;yield&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;zip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[::&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;xs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;new_xs&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;xs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;new_xs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;yield&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;ladner_fischer_network&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new_xs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;yield&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;zip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;xs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The function above just generates the wire indices for the network to compare,
from left-to-right and top-to-bottom. So:&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ladner_fischer_network&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))))&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;[(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;corresponds to the network diagram:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/prefix-sums/7.svg&quot; alt=&quot;A work-efficient prefix sum network for n=7&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;a-menagerie-of-networks&quot;&gt;A Menagerie of Networks&lt;/h2&gt;

&lt;p&gt;Now that we can generate these, you can sit back and stare at the patterns in a few larger ones for a minute:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/prefix-sums/33.svg&quot; alt=&quot;A work-efficient prefix sum network for n=33&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/prefix-sums/90.svg&quot; alt=&quot;A work-efficient prefix sum network for n=90&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/prefix-sums/150.svg&quot; alt=&quot;A work-efficient prefix sum network for n=150&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We know how to generate the prefix sum networks now, but you probably can’t yet draw one on a blank
sheet of paper from first principles or explain why they’re correct.&lt;/p&gt;

&lt;h2 id=&quot;simpler&quot;&gt;Simpler?&lt;/h2&gt;

&lt;p&gt;I came up with a different algorithm for generating these networks that I think is a little
clearer, and makes it easier to see that the construction is correct. Like the previous Python
code for the recursive generation of Ladner-Fischer networks, my algorithm
takes a list of all wires you want to generate the network on (so you’d pass [0,1,2,3,4] if you
wanted to generate a network on 5 elements). The entire algorithm is just:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Merge the elements of the list in pairs, keeping the latter element in each pair in a new merged array. Each merge
of wires &lt;em&gt;i&lt;/em&gt; and &lt;em&gt;j&lt;/em&gt; generates a sum operation on &lt;em&gt;i&lt;/em&gt; and &lt;em&gt;j&lt;/em&gt;.&lt;/li&gt;
  &lt;li&gt;Repeat this merging process until the resulting merged array has only one element.
Go back through all the arrays you’ve created (the original and any merged arrays) and mark the first element of each “finished”.&lt;/li&gt;
  &lt;li&gt;Go back through the merged arrays in the reverse order they were created.
For any unfinished index you find in this reverse scan, generate a sum operation on that wire and the wire to the left
of it in the merged array, storing the result in the unfinished index. Mark the unfinished index as finished whenever this happens.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, to generate the 13-element prefix sum network, we’d start with [0,1,2,3,4,5,6,7,8,9,10,11,12]. The merging
steps generate the following sequences of arrays:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;[0,1,2,3,4,5,6,7,8,9,10,11,12]&lt;/li&gt;
  &lt;li&gt;[1,3,5,7,9,11,12]&lt;/li&gt;
  &lt;li&gt;[3,7,11,12]&lt;/li&gt;
  &lt;li&gt;[7,12]&lt;/li&gt;
  &lt;li&gt;[12]&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Notice that since we start with an odd number of elements, 12 has no buddy to merge with until the third. That’s
fine, we just bring it along to the next step without any merge when it can’t pair up with a buddy. Now, if we’ve dilligently marked the first element in
each array as “finished” (0,1,3,7, and 12), we end up in this state at the end (with finished elements starred):&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;[0*,1*,2,3*,4,5,6,7*,8,9,10,11,12*]&lt;/li&gt;
  &lt;li&gt;[1*,3*,5,7*,9,11,12*]&lt;/li&gt;
  &lt;li&gt;[3*,7*,11,12*]&lt;/li&gt;
  &lt;li&gt;[7*,12*]&lt;/li&gt;
  &lt;li&gt;[12*]&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When we iterate through in reverse order, we combine 7 with 11 and mark 11 finished once we get to the third array,
then combine 3 and 5 into 5 and 7 and 9 into 9 once we get back to the second array, and so on. All these combine
operations taken together create the correct work-efficient prefix sum schedule:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/prefix-sums/13.svg&quot; alt=&quot;A work-efficient prefix sum network for n=13&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The for this iterative generation in Python is:&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;generate_prefix_sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;reduced&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))]&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reduced&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;prev&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;current&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reduced&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;zip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;prev&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[::&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;prev&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]):&lt;/span&gt;
            &lt;span class=&quot;nf&quot;&gt;yield &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;current&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;prev&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;current&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;prev&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;reduced&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;current&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;finished&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reduced&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;reversed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reduced&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;item&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;enumerate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;item&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;finished&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
                &lt;span class=&quot;nf&quot;&gt;yield &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;finished&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;generate_prefix_sum&lt;/code&gt; generates exactly the same networks as the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ladner_fischer_network&lt;/code&gt; function in the previous section.
This iterative algorithm is something I can reproduce on a sheet of paper without any reference to recursive
definitions and it’s also something I can convince myself is correct – you just need to reason about
the contents of “finished” wires and the order in which they’re finished for a little bit.&lt;/p&gt;

&lt;p&gt;In any case, now we have two ways to generate these Ladner-Fischer prefix sum networks.&lt;/p&gt;

&lt;h2 id=&quot;afterword&quot;&gt;Afterword&lt;/h2&gt;

&lt;p&gt;After all of this work, did the Ladner-Fischer network help &lt;a href=&quot;https://github.com/aaw/cnfc&quot;&gt;cnfc&lt;/a&gt; generate better encodings? Let’s try proving a large number is prime.
I’ve got an &lt;a href=&quot;https://github.com/aaw/cnfc/tree/master/examples/prime&quot;&gt;example&lt;/a&gt; in cnfc that produces formulas that
are satisfiable exactly when the given input number is composite.&lt;/p&gt;

&lt;p&gt;First, just generating prefix sums using a naive sequential accumulation:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;~/cnfc$ poetry run python3 examples/prime/prime.py 100123456789 /tmp/cnf /tmp/extractor.py
~/cnfc$ grep &quot;p &quot; /tmp/cnf  # Number of variables and clauses in the encoding
p cnf 15211 48400
~/cnfc$ time kissat /tmp/cnf &amp;gt; /tmp/kissat-out  # Solve the formula

real    1m20.329s
user    1m19.655s
sys     0m0.597s
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now, again, with the Ladner-Fischer network dropped in instead:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;~/cnfc$ poetry run python3 examples/prime/prime.py 100123456789 /tmp/cnf /tmp/extractor.py
~/cnfc$ grep &quot;p &quot; /tmp/cnf   # Number of variables and clauses in the encoding
p cnf 20362 63853
~/cnfc$ time kissat /tmp/cnf &amp;gt; /tmp/kissat-out  # Solve the formula

real    1m33.597s
user    1m32.979s
sys     0m0.612s
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So we use slightly more variables and clauses when we drop in the new prefix sum network,
which is expected. The encoding of the primality test is basically all adders (multiplication
is implemented with the grade-school repeated addition algorithm) and the Ladner-Fischer network
uses about twice as many operations as the linear accumulation of prefix sums. These encodings
don’t have any standard preprocessing applied, but the numbers don’t change much if I do a
little unit-propagation, subsumption, etc.&lt;/p&gt;

&lt;p&gt;But we don’t get any kind of great speedup with the more complicated network, and in fact
it made the solver work a little harder in all of the examples I tried, even with composite numbers
instead of primes. So for now, I’m not replacing the simpler linear-delay
prefix sum network with the lower-depth Ladner-Fischer prefix-sum network. But I’ll keep the
code around in case these numbers change if/when I encode multiplication with something better
than repeated addition.&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:2&quot;&gt;
      &lt;p&gt;Brent, Richard P. and H. T. Kung. “A Regular Layout for Parallel Adders.” IEEE Transactions on Computers C-31 (1982): 260-264. &lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:1&quot;&gt;
      &lt;p&gt;Richard E. Ladner and Michael J. Fischer. 1980. Parallel Prefix Computation. J. ACM 27, 4 (Oct. 1980), 831–838. &lt;a href=&quot;https://doi.org/10.1145/322217.322232&quot;&gt;https://doi.org/10.1145/322217.322232&lt;/a&gt; &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
        <pubDate>Sun, 05 Nov 2023 12:58:00 -0500</pubDate>
        <link>http://blog.aaw.io/2023/11/05/work-efficient-prefix-sums.html</link>
        <guid isPermaLink="true">http://blog.aaw.io/2023/11/05/work-efficient-prefix-sums.html</guid>
        
        
      </item>
    
      <item>
        <title>Intersecting Set-Pair Systems</title>
        <description>&lt;p&gt;An intersecting set-pair system is a set of pairs &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mo fence=&quot;true&quot;&gt;{&lt;/mo&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;A&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;B&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mtext&gt;  &lt;/mtext&gt;&lt;mo fence=&quot;true&quot; lspace=&quot;0.05em&quot; rspace=&quot;0.05em&quot;&gt;|&lt;/mo&gt;&lt;mtext&gt;  &lt;/mtext&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;≤&lt;/mo&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo&gt;≤&lt;/mo&gt;&lt;mi&gt;m&lt;/mi&gt;&lt;mo fence=&quot;true&quot;&gt;}&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;\left\{ (A_i, B_i) \;\middle|\; 1 \le i \le m \right\}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;minner&quot;&gt;&lt;span class=&quot;mopen delimcenter&quot; style=&quot;top:0em;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.3117em;&quot;&gt;&lt;span style=&quot;top:-2.55em;margin-left:0em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.15em;&quot;&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=&quot;mpunct&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.05017em;&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.3117em;&quot;&gt;&lt;span style=&quot;top:-2.55em;margin-left:-0.0502em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.15em;&quot;&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=&quot;mclose&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;delimcenter&quot; style=&quot;top:0em;&quot;&gt;∣&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;≤&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;≤&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;mclose delimcenter&quot; style=&quot;top:0em;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
with some additional restrictions on how the sets &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;A&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;A&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6833em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; and &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;B&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;B&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6833em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.05017em;&quot;&gt;B&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; intersect. The classic setup requires
&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;A&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mo&gt;∩&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;B&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∅&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;A_i \cap B_i = \emptyset&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8333em;vertical-align:-0.15em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.3117em;&quot;&gt;&lt;span style=&quot;top:-2.55em;margin-left:0em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.15em;&quot;&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=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;∩&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8333em;vertical-align:-0.15em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.05017em;&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.3117em;&quot;&gt;&lt;span style=&quot;top:-2.55em;margin-left:-0.0502em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.15em;&quot;&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=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8056em;vertical-align:-0.0556em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;∅&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; for all &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;i&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6595em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; but &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;A&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mo&gt;∩&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;B&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mo mathvariant=&quot;normal&quot;&gt;≠&lt;/mo&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∅&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;A_i \cap B_i \neq \emptyset&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8333em;vertical-align:-0.15em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.3117em;&quot;&gt;&lt;span style=&quot;top:-2.55em;margin-left:0em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.15em;&quot;&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=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;∩&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8889em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.05017em;&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.3117em;&quot;&gt;&lt;span style=&quot;top:-2.55em;margin-left:-0.0502em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.15em;&quot;&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=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;&lt;span class=&quot;mrel&quot;&gt;&lt;span class=&quot;mord vbox&quot;&gt;&lt;span class=&quot;thinbox&quot;&gt;&lt;span class=&quot;rlap&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8889em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;inner&quot;&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mrel&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;fix&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8056em;vertical-align:-0.0556em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;∅&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; for all &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo mathvariant=&quot;normal&quot;&gt;≠&lt;/mo&gt;&lt;mi&gt;j&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;i \neq j&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8889em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;&lt;span class=&quot;mrel&quot;&gt;&lt;span class=&quot;mord vbox&quot;&gt;&lt;span class=&quot;thinbox&quot;&gt;&lt;span class=&quot;rlap&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8889em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;inner&quot;&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mrel&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;fix&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.854em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.05724em;&quot;&gt;j&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;Here’s an example:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{ ({1,2}, {3,4}),
  ({1,4}, {2,5}),
  ({2,3}, {1,4}) }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;How large can an intersecting set-pair system be? With just the restrictions above, Bollobás proved
that if &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;msub&gt;&lt;mi&gt;A&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;mo&gt;≤&lt;/mo&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;|A_i| \le a&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;∣&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.3117em;&quot;&gt;&lt;span style=&quot;top:-2.55em;margin-left:0em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.15em;&quot;&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=&quot;mord&quot;&gt;∣&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;≤&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; and &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;msub&gt;&lt;mi&gt;B&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;mo&gt;≤&lt;/mo&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;|B_i| \le b&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;∣&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.05017em;&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.3117em;&quot;&gt;&lt;span style=&quot;top:-2.55em;margin-left:-0.0502em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.15em;&quot;&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=&quot;mord&quot;&gt;∣&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;≤&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; for all &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;i&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6595em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;, then &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;m&lt;/mi&gt;&lt;mo&gt;≤&lt;/mo&gt;&lt;mrow&gt;&lt;mo fence=&quot;true&quot;&gt;(&lt;/mo&gt;&lt;mfrac linethickness=&quot;0px&quot;&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;/mrow&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;/mfrac&gt;&lt;mo fence=&quot;true&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;m \le \binom{a+b}{b}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.7719em;vertical-align:-0.136em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;≤&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1.2801em;vertical-align:-0.35em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mopen delimcenter&quot; style=&quot;top:0em;&quot;&gt;&lt;span class=&quot;delimsizing size1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mfrac&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.9301em;&quot;&gt;&lt;span style=&quot;top:-2.355em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.144em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mbin mtight&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.345em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mclose delimcenter&quot; style=&quot;top:0em;&quot;&gt;&lt;span class=&quot;delimsizing size1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;.
And that bound is tight because all &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;(a,b)&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mpunct&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; partitions of a set of size &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;a+b&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6667em;vertical-align:-0.0833em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
form an intersecting set-pair system.&lt;/p&gt;

&lt;p&gt;Recently, Füredi, Gyárfás, and Király [&lt;a href=&quot;https://arxiv.org/abs/1911.03067&quot;&gt;2019&lt;/a&gt;] explored intersecting set-pair
systems with the additional restriction that &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;mi&gt;A&lt;/mi&gt;&lt;mo&gt;∩&lt;/mo&gt;&lt;mi&gt;B&lt;/mi&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;|A \cap B| = 1&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;∣&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;∩&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.05017em;&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;∣&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; for all &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo mathvariant=&quot;normal&quot;&gt;≠&lt;/mo&gt;&lt;mi&gt;j&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;i \neq j&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8889em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;&lt;span class=&quot;mrel&quot;&gt;&lt;span class=&quot;mord vbox&quot;&gt;&lt;span class=&quot;thinbox&quot;&gt;&lt;span class=&quot;rlap&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8889em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;inner&quot;&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mrel&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;fix&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.854em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.05724em;&quot;&gt;j&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;.
Holzman [&lt;a href=&quot;https://holzman.technion.ac.il/files/2021/10/Set_pair_ejc.pdf&quot;&gt;2021&lt;/a&gt;] followed their paper with a proof that
&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;m&lt;/mi&gt;&lt;mo&gt;≤&lt;/mo&gt;&lt;mfrac&gt;&lt;mn&gt;29&lt;/mn&gt;&lt;mn&gt;30&lt;/mn&gt;&lt;/mfrac&gt;&lt;mrow&gt;&lt;mo fence=&quot;true&quot;&gt;(&lt;/mo&gt;&lt;mfrac linethickness=&quot;0px&quot;&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;/mrow&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;/mfrac&gt;&lt;mo fence=&quot;true&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;m \le \frac{29}{30} \binom{a+b}{b}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.7719em;vertical-align:-0.136em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;≤&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1.2801em;vertical-align:-0.35em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mopen nulldelimiter&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mfrac&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.8451em;&quot;&gt;&lt;span style=&quot;top:-2.655em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;30&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.23em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;frac-line&quot; style=&quot;border-bottom-width:0.04em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.394em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;29&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.345em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mclose nulldelimiter&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mopen delimcenter&quot; style=&quot;top:0em;&quot;&gt;&lt;span class=&quot;delimsizing size1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mfrac&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.9301em;&quot;&gt;&lt;span style=&quot;top:-2.355em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.144em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mbin mtight&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.345em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mclose delimcenter&quot; style=&quot;top:0em;&quot;&gt;&lt;span class=&quot;delimsizing size1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; for such set-pair systems, and
Kostochka, McCourt, and Nahvi [&lt;a href=&quot;https://arxiv.org/abs/2104.08562&quot;&gt;2021&lt;/a&gt;] have recently proven that
&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;m&lt;/mi&gt;&lt;mo&gt;≤&lt;/mo&gt;&lt;mfrac&gt;&lt;mn&gt;5&lt;/mn&gt;&lt;mn&gt;6&lt;/mn&gt;&lt;/mfrac&gt;&lt;mrow&gt;&lt;mo fence=&quot;true&quot;&gt;(&lt;/mo&gt;&lt;mfrac linethickness=&quot;0px&quot;&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;/mrow&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;/mfrac&gt;&lt;mo fence=&quot;true&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;m \le \frac{5}{6} \binom{a+b}{b}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.7719em;vertical-align:-0.136em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;≤&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1.2801em;vertical-align:-0.35em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mopen nulldelimiter&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mfrac&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.8451em;&quot;&gt;&lt;span style=&quot;top:-2.655em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;6&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.23em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;frac-line&quot; style=&quot;border-bottom-width:0.04em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.394em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;5&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.345em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mclose nulldelimiter&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mopen delimcenter&quot; style=&quot;top:0em;&quot;&gt;&lt;span class=&quot;delimsizing size1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mfrac&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.9301em;&quot;&gt;&lt;span style=&quot;top:-2.355em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.144em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mbin mtight&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.345em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mclose delimcenter&quot; style=&quot;top:0em;&quot;&gt;&lt;span class=&quot;delimsizing size1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;I tried to see if &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mfrac&gt;&lt;mn&gt;5&lt;/mn&gt;&lt;mn&gt;6&lt;/mn&gt;&lt;/mfrac&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;\frac{5}{6}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1.1901em;vertical-align:-0.345em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mopen nulldelimiter&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mfrac&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.8451em;&quot;&gt;&lt;span style=&quot;top:-2.655em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;6&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.23em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;frac-line&quot; style=&quot;border-bottom-width:0.04em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.394em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;5&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.345em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mclose nulldelimiter&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; was tight for small $a$ and $b$ using a SAT solver. It doesn’t
look like it is, and some of these constructions look interesting, so here they are:&lt;/p&gt;

&lt;h2 id=&quot;a2&quot;&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;a=2&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;When &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;a = 2&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;, Füredi, Gyárfás, and Király give a closed-form solution for &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;m&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;m&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;m&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; when &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;mo&gt;≥&lt;/mo&gt;&lt;mn&gt;4&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;b \ge 4&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8304em;vertical-align:-0.136em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;≥&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;4&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;.
So the results in this section are really just an exercise in verifying their results.&lt;/p&gt;

&lt;p&gt;For &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;a = b = 2&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;, I was able to verify that $m = 5$ by generating a system with 5 pairs and
proving that a system of size 6 doesn’t exist. The system of size 5 below is actually unique under permutations
of the ground set:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{ ({1, 2}, {3, 4}),
  ({1, 4}, {2, 5}),
  ({2, 3}, {1, 5}),
  ({3, 5}, {2, 4}),
  ({4, 5}, {1, 3}) }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;For &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;3&lt;/mn&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;mi&gt;m&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;7&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;a = 2, b = 3, m = 7&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8889em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mpunct&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8389em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mpunct&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;7&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;, I was again able to generate a system of size 7 and prove no system
of size 8 exists:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{ ({1, 2}, {3, 4, 5}),
  ({1, 3}, {2, 6, 7}),
  ({2, 4}, {1, 6, 7}),
  ({3, 6}, {1, 4, 5}),
  ({4, 7}, {2, 3, 5}),
  ({5, 6}, {2, 3, 7}),
  ({5, 7}, {1, 4, 6}) }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This time, there were 9 distinct systems under permutations. I stopped counting distinct solutions after
this because it gets a little tedious with a SAT solver (you find a solution, add a clause that blocks that
solution, repeat).&lt;/p&gt;

&lt;p&gt;At &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;4&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;a = 2, b = 4&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8889em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mpunct&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;4&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;, I could generate a system of size 9 but couldn’t prove a system of size 10 didn’t exist (the SAT
solver ran for too long and I killed it):&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{ ({1, 2},  {3, 4, 5, 6}),
  ({2, 5},  {1, 3, 4, 6}),
  ({2, 6},  {1, 3, 4, 5}),
  ({3, 10}, {2, 4, 11, 12}),
  ({3, 11}, {2, 4, 10, 12}),
  ({3, 12}, {2, 4, 10, 11}),
  ({4, 7},  {2, 3, 8, 9}),
  ({4, 8},  {2, 3, 7, 9}),
  ({4, 9},  {2, 3, 7, 8}) }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Same story for &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;mo&gt;∈&lt;/mo&gt;&lt;mo stretchy=&quot;false&quot;&gt;{&lt;/mo&gt;&lt;mn&gt;5&lt;/mn&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;mn&gt;6&lt;/mn&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;mn&gt;7&lt;/mn&gt;&lt;mo stretchy=&quot;false&quot;&gt;}&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;a = 2, b \in \{ 5, 6, 7 \}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8889em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mpunct&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;∈&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mpunct&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;mpunct&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;: I could generate a system of maximum size pretty easily
but didn’t bother trying to prove a larger system doesn’t exist.&lt;/p&gt;

&lt;p&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;5&lt;/mn&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;mi&gt;m&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;12&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;a = 2, b = 5, m = 12&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8889em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mpunct&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8389em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mpunct&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;12&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{ ({1, 2},  {3, 4, 5, 6, 7}),
  ({2, 4},  {1, 3, 5, 6, 7}),
  ({2, 5},  {1, 3, 4, 6, 7}),
  ({3, 11}, {2, 6, 7, 15, 16}),
  ({3, 15}, {2, 6, 7, 11, 16}),
  ({3, 16}, {2, 6, 7, 11, 15}),
  ({6, 10}, {2, 3, 7, 12, 14}),
  ({6, 12}, {2, 3, 7, 10, 14}),
  ({6, 14}, {2, 3, 7, 10, 12}),
  ({7, 8},  {2, 3, 6, 9, 13}),
  ({7, 9},  {2, 3, 6, 8, 13}),
  ({7, 13}, {2, 3, 6, 8, 9}) }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;6&lt;/mn&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;mi&gt;m&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;16&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;a = 2, b = 6, m = 16&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8889em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mpunct&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8389em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;mpunct&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;16&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{ ({1, 2},  {3, 4, 5, 6, 7, 8}),
  ({2, 5},  {1, 3, 4, 6, 7, 8}),
  ({2, 6},  {1, 3, 4, 5, 7, 8}),
  ({2, 8},  {1, 3, 4, 5, 6, 7}),
  ({3, 9},  {2, 4, 7, 11, 12, 19}),
  ({3, 11}, {2, 4, 7, 9, 12, 19}),
  ({3, 12}, {2, 4, 7, 9, 11, 19}),
  ({3, 19}, {2, 4, 7, 9, 11, 12}),
  ({4, 15}, {2, 3, 7, 16, 18, 20}),
  ({4, 16}, {2, 3, 7, 15, 18, 20}),
  ({4, 18}, {2, 3, 7, 15, 16, 20}),
  ({4, 20}, {2, 3, 7, 15, 16, 18}),
  ({7, 10}, {2, 3, 4, 13, 14, 17}),
  ({7, 13}, {2, 3, 4, 10, 14, 17}),
  ({7, 14}, {2, 3, 4, 10, 13, 17}),
  ({7, 17}, {2, 3, 4, 10, 13, 14}) }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;7&lt;/mn&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;mi&gt;m&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;20&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;a = 2, b = 7, m = 20&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8889em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mpunct&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8389em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;mpunct&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;20&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{ ({1, 2},  {3, 4, 5, 6, 7, 8, 9}),
  ({1, 3},  {2, 4, 5, 6, 7, 8, 9}),
  ({1, 4},  {2, 3, 5, 6, 7, 8, 9}),
  ({1, 6},  {2, 3, 4, 5, 7, 8, 9}),
  ({5, 12}, {1, 7, 8, 9, 13, 22, 24}),
  ({5, 13}, {1, 7, 8, 9, 12, 22, 24}),
  ({5, 22}, {1, 7, 8, 9, 12, 13, 24}),
  ({5, 24}, {1, 7, 8, 9, 12, 13, 22}),
  ({7, 10}, {1, 5, 8, 9, 11, 15, 19}),
  ({7, 11}, {1, 5, 8, 9, 10, 15, 19}),
  ({7, 15}, {1, 5, 8, 9, 10, 11, 19}),
  ({7, 19}, {1, 5, 8, 9, 10, 11, 15}),
  ({8, 14}, {1, 5, 7, 9, 17, 21, 25}),
  ({8, 17}, {1, 5, 7, 9, 14, 21, 25}),
  ({8, 21}, {1, 5, 7, 9, 14, 17, 25}),
  ({8, 25}, {1, 5, 7, 9, 14, 17, 21}),
  ({9, 16}, {1, 5, 7, 8, 18, 20, 23}),
  ({9, 18}, {1, 5, 7, 8, 16, 20, 23}),
  ({9, 20}, {1, 5, 7, 8, 16, 18, 23}),
  ({9, 23}, {1, 5, 7, 8, 16, 18, 20}) }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I stopped here because I wanted to move on to &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;3&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;a=3&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; where a closed form for &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;m&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;m&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;m&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; isn’t known.&lt;/p&gt;

&lt;h2 id=&quot;a3&quot;&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;3&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;a=3&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;For &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;3&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;a=3&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;, we only know the upper bound &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;m&lt;/mi&gt;&lt;mo&gt;≤&lt;/mo&gt;&lt;mfrac&gt;&lt;mn&gt;5&lt;/mn&gt;&lt;mn&gt;6&lt;/mn&gt;&lt;/mfrac&gt;&lt;mrow&gt;&lt;mo fence=&quot;true&quot;&gt;(&lt;/mo&gt;&lt;mfrac linethickness=&quot;0px&quot;&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;/mrow&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;/mfrac&gt;&lt;mo fence=&quot;true&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;m \le \frac{5}{6} \binom{a+b}{b}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.7719em;vertical-align:-0.136em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;≤&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1.2801em;vertical-align:-0.35em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mopen nulldelimiter&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mfrac&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.8451em;&quot;&gt;&lt;span style=&quot;top:-2.655em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;6&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.23em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;frac-line&quot; style=&quot;border-bottom-width:0.04em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.394em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;5&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.345em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mclose nulldelimiter&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mopen delimcenter&quot; style=&quot;top:0em;&quot;&gt;&lt;span class=&quot;delimsizing size1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mfrac&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.9301em;&quot;&gt;&lt;span style=&quot;top:-2.355em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.144em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mbin mtight&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.345em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mclose delimcenter&quot; style=&quot;top:0em;&quot;&gt;&lt;span class=&quot;delimsizing size1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
when &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;mo&gt;≥&lt;/mo&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;a,b \ge 2&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8889em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mpunct&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;≥&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; from Kostochka, McCourt, and Nahvi’s work.&lt;/p&gt;

&lt;p&gt;Here’s what I could find:&lt;/p&gt;

&lt;p&gt;For &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;b=1&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;m&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;4&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;m=4&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;4&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{ ({1, 2, 3}, {4}),
  ({1, 2, 4}, {3}),
  ({1, 3, 4}, {2}),
  ({2, 3, 4}, {1}) }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We already know that &lt;span class=&quot;katex-error&quot; title=&quot;ParseError: KaTeX parse error: Can&amp;#x27;t use function &amp;#x27;$&amp;#x27; in math mode at position 4: m=7$̲ when $b=2&quot; style=&quot;color:#cc0000&quot;&gt;m=7$ when $b=2&lt;/span&gt; by symmetry from the results in the previous section.&lt;/p&gt;

&lt;p&gt;When &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;3&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;b=3&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;m&lt;/mi&gt;&lt;mo&gt;≥&lt;/mo&gt;&lt;mn&gt;10&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;m \ge 10&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.7719em;vertical-align:-0.136em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;≥&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;10&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{ ({1, 2, 3},   {4, 5, 6}),
  ({1, 3, 5},   {2, 9, 10}),
  ({1, 5, 9},   {3, 7, 8}),
  ({2, 3, 6},   {1, 7, 8}),
  ({2, 6, 7},   {3, 9, 10}),
  ({4, 7, 10},  {2, 5, 8}),
  ({4, 8, 9},   {1, 6, 10}),
  ({4, 8, 10},  {3, 7, 9}),
  ({5, 7, 10}), {1, 4, 6}),
  ({6, 8, 9},   {2, 4, 5}) }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I couldn’t prove that there’s no system with &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;3&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;a = b = 3&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; and &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;m&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;11&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;m = 11&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;11&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;. One thing that
I could prove (in about 2 hours with a SAT solver) is that no system with &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;3&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;a = b = 3&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; and
&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;m&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;11&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;m = 11&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;11&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; and a ground set of cardinality 10 or 11 exists. So that’s good evidence
that the system above is the largest possible, since any larger system would have to use at least a
12-element ground set.&lt;/p&gt;

&lt;p&gt;When &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;4&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;b=4&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;4&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;m&lt;/mi&gt;&lt;mo&gt;≥&lt;/mo&gt;&lt;mn&gt;15&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;m \ge 15&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.7719em;vertical-align:-0.136em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;≥&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;15&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{ ({1, 2, 3},   {4, 5, 6, 7}),
  ({1, 2, 5},   {3, 6, 7, 12}),
  ({2, 3, 4},   {1, 6, 7, 12}),
  ({2, 4, 12},  {3, 5, 6, 7}),
  ({2, 5, 12},  {1, 4, 6, 7}),
  ({6, 11, 14}, {2, 7, 13, 16}),
  ({6, 11, 16}, {2, 7, 14, 18}),
  ({6, 13, 14}, {2, 7, 11, 18}),
  ({6, 13, 18}, {2, 7, 14, 16}),
  ({6, 16, 18}, {2, 7, 11, 13}),
  ({7, 8, 10},  {2, 6, 15, 17}),
  ({7, 8, 17},  {2, 6, 9, 10}),
  ({7, 9, 15},  {2, 6, 10, 17}),
  ({7, 9, 17},  {2, 6, 8, 15}),
  ({7, 10, 15}, {2, 6, 8, 9}) }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I couldn’t prove any more partial results after this, even by restricting the size of the ground set.&lt;/p&gt;

&lt;p&gt;Finally, when &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;5&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;b = 5&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;5&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;m&lt;/mi&gt;&lt;mo&gt;≥&lt;/mo&gt;&lt;mn&gt;20&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;m \ge 20&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.7719em;vertical-align:-0.136em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;≥&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;20&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{ ({1, 2, 3},   {4, 5, 6, 7, 8}),
  ({1, 2, 8},   {3, 5, 6, 7, 17}),
  ({2, 3, 4},   {1, 5, 6, 7, 17}),
  ({2, 4, 17},  {3, 5, 6, 7, 8}),
  ({2, 8, 17},  {1, 4, 5, 6, 7}),
  ({5, 9, 11},  {2, 6, 7, 13, 18}),
  ({5, 9, 13},  {2, 6, 7, 11, 14}),
  ({5, 11, 18}, {2, 6, 7, 9, 14}),
  ({5, 13, 14}, {2, 6, 7, 9, 18}),
  ({5, 14, 18}, {2, 6, 7, 11, 13}),
  ({6, 12, 16}, {2, 5, 7, 15, 23}),
  ({6, 12, 23}, {2, 5, 7, 16, 22}),
  ({6, 15, 16}, {2, 5, 7, 12, 22}),
  ({6, 15, 22}, {2, 5, 7, 16, 23}),
  ({6, 22, 23}, {2, 5, 7, 12, 15}),
  ({7, 10, 21}, {2, 5, 6, 19, 24}),
  ({7, 10, 24}, {2, 5, 6, 20, 21}),
  ({7, 19, 20}, {2, 5, 6, 21, 24}),
  ({7, 19, 21}, {2, 5, 6, 10, 20}),
  ({7, 20, 24}, {2, 5, 6, 10, 19}) }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To wrap up, here’s a table summarizing the lower bounds for &lt;i&gt;m&lt;/i&gt; when &lt;i&gt;a=3&lt;/i&gt;
implied by the constructions above compared to the current best upper bounds from
the formula &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;m&lt;/mi&gt;&lt;mo&gt;≤&lt;/mo&gt;&lt;mfrac&gt;&lt;mn&gt;5&lt;/mn&gt;&lt;mn&gt;6&lt;/mn&gt;&lt;/mfrac&gt;&lt;mrow&gt;&lt;mo fence=&quot;true&quot;&gt;(&lt;/mo&gt;&lt;mfrac linethickness=&quot;0px&quot;&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;/mrow&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;/mfrac&gt;&lt;mo fence=&quot;true&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;m \le \frac{5}{6} \binom{a+b}{b}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.7719em;vertical-align:-0.136em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;≤&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1.2801em;vertical-align:-0.35em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mopen nulldelimiter&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mfrac&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.8451em;&quot;&gt;&lt;span style=&quot;top:-2.655em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;6&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.23em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;frac-line&quot; style=&quot;border-bottom-width:0.04em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.394em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;5&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.345em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mclose nulldelimiter&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mopen delimcenter&quot; style=&quot;top:0em;&quot;&gt;&lt;span class=&quot;delimsizing size1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mfrac&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.9301em;&quot;&gt;&lt;span style=&quot;top:-2.355em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.144em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mbin mtight&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.345em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mclose delimcenter&quot; style=&quot;top:0em;&quot;&gt;&lt;span class=&quot;delimsizing size1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;  a  &lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;  b  &lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;  m ≥ ?  &lt;/th&gt;
      &lt;th&gt;  m ≤ ?  &lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;4&lt;/td&gt;
      &lt;td&gt;4&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;7&lt;/td&gt;
      &lt;td&gt;8.33…&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;10&lt;/td&gt;
      &lt;td&gt;16.666…&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;4&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;15&lt;/td&gt;
      &lt;td&gt;29.1666…&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;20&lt;/td&gt;
      &lt;td&gt;46.666…&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;br /&gt;
The closed form for the upper bound only applies for &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;mo&gt;≥&lt;/mo&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;a, b \ge 2&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8889em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mpunct&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;≥&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; so I just put “4” in the first
row for the upper bound since that’s clearly exact.&lt;/p&gt;

&lt;p&gt;I think my lower bounds are pretty tight
because there was a noticable threshold between the results I could find (which the
SAT solver could find in seconds or minutes) and the proofs I couldn’t find (which
made the SAT solver just hang for hours or days).&lt;/p&gt;

&lt;p&gt;I’ve put the &lt;a href=&quot;https://gist.github.com/aaw/8073201f61ecf46dc18e4a9f300f4575&quot;&gt;script I used to generate SAT instances and the decoder I used to
take SAT solutions and generate canonical set systems&lt;/a&gt; online. You just need Python 3
to run both scripts. I used mainly &lt;a href=&quot;https://github.com/arminbiere/kissat&quot;&gt;kissat&lt;/a&gt; and &lt;a href=&quot;https://github.com/arminbiere/cadical&quot;&gt;cadical&lt;/a&gt; to find these results.&lt;/p&gt;

</description>
        <pubDate>Sun, 10 Apr 2022 09:54:00 -0400</pubDate>
        <link>http://blog.aaw.io/2022/04/10/intersecting-set-pair-systems.html</link>
        <guid isPermaLink="true">http://blog.aaw.io/2022/04/10/intersecting-set-pair-systems.html</guid>
        
        
      </item>
    
      <item>
        <title>The Presidential Rectangle</title>
        <description>&lt;p&gt;In 1976, Robert Cass Keller &lt;a href=&quot;https://digitalcommons.butler.edu/wordways/vol9/iss1/3/&quot;&gt;proposed a puzzle&lt;/a&gt; in &lt;a href=&quot;https://digitalcommons.butler.edu/wordways/&quot;&gt;Word Ways&lt;/a&gt; that was inspired by Benjamin Franklin’s
quote “We must all hang together, or assuredly we shall all hang separately”. The puzzle asks you
to fit the first 33 distinct surnames of American Presidents into a rectangle of minimum area using
the following rules:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Names can only be placed left-to-right or top-to-bottom&lt;/li&gt;
  &lt;li&gt;Letters in adjacent cells must belong to a common name&lt;/li&gt;
  &lt;li&gt;Every name must be connected by some path of intersecting names to every other name (“We must all hang together…”)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Keller mentions a similar contest in a British magazine involving the 50 U.S. states. The winner
apparently fit them all into a 23-by-29 rectangle.&lt;/p&gt;

&lt;p&gt;In the next issue, &lt;a href=&quot;https://digitalcommons.butler.edu/wordways/vol9/iss2/4/&quot;&gt;Sam Harlan presented the first solution&lt;/a&gt; to Keller’s puzzle, a 17-by-31 rectangle with
total area 527:&lt;/p&gt;

&lt;table&gt;
  &lt;tr&gt;
    &lt;td&gt;W&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;M&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;C&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;J&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;K&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;P&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;L&lt;/td&gt;
    &lt;td&gt;K&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;V&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;L&lt;/td&gt;
    &lt;td&gt;M&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;I&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;X&lt;/td&gt; &lt;td&gt;O&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;L&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;J&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;E&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;M&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;Y&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;R&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;V&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;B&lt;/td&gt; &lt;td&gt;U&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;U&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt;
    &lt;td&gt;A&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;U&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;S&lt;/td&gt;
    &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;R&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;V&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;C&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;V&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;U&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;E&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;W&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;R&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;1976 was an election year, which meant the set of presidential surnames was about to increase by one.
Harlan mentioned that Jimmy Carter (the eventual winner)
could easily be packed into the existing solution
using the first “e” in Pierce.&lt;/p&gt;

&lt;p&gt;In 1993, shortly after Bill Clinton’s election, &lt;a href=&quot;https://digitalcommons.butler.edu/wordways/vol26/iss2/5/&quot;&gt;Darryl Francis produced a new rectangle&lt;/a&gt; that was
smaller than Harlan’s solution by two columns (17-by-29, for a total area of 493) and included the
entire current set of 37 presidential surnames including Carter, Reagan, Bush, and Clinton:&lt;/p&gt;

&lt;table&gt;
  &lt;tr&gt;
    &lt;td&gt;W&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;B&lt;/td&gt; &lt;td&gt;U&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;P&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;X&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;J&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;K&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;L&lt;/td&gt;
    &lt;td&gt;M&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;V&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;K&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;V&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;J&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;R&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;V&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;B&lt;/td&gt; &lt;td&gt;U&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;U&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt;
    &lt;td&gt;A&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;P&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;U&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;W&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;S&lt;/td&gt;
    &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;R&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;V&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;U&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;K&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;C&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;M&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;In next issue of Word Ways, &lt;a href=&quot;https://digitalcommons.butler.edu/wordways/vol26/iss3/14/&quot;&gt;Lee Sallows presented a 19-by-22 grid&lt;/a&gt; containing the same set of
37 surnames. The
resulting area (418) was a massive reduction from previous attempts, but his
grid contained an isolated Ford-Polk-Jackson component. Sallows noted that some “purists”
might therefore disqualify his rectangle.&lt;/p&gt;

&lt;p&gt;Such a purist showed up in the very next issue, when &lt;a href=&quot;https://digitalcommons.butler.edu/wordways/vol26/iss4/6/&quot;&gt;Leonard Gordon presented a
completely connected 19-by-22 grid&lt;/a&gt; as well as the following new record-setting 17-by-24 grid
with area 408:&lt;/p&gt;

&lt;table&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;F&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;J&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;G&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;X&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;J&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt;
    &lt;td&gt;D&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;S&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;I&lt;/td&gt;
    &lt;td&gt;D&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;L&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;K&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;B&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;V&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;P&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;K&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;V&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;B&lt;/td&gt;
    &lt;td&gt;U&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;T&lt;/td&gt;
    &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;W&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;G&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;W&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;B&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;R&lt;/td&gt;
    &lt;td&gt;T&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;U&lt;/td&gt; &lt;td&gt;R&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;R&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;U&lt;/td&gt;
    &lt;td&gt;M&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;K&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;F&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;P&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;W&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;H&lt;/td&gt;
    &lt;td&gt;I&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;D&lt;/td&gt;
    &lt;td&gt;I&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;K&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;N&lt;/td&gt;
    &lt;td&gt;L&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;V&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;J&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;Gordon &lt;a href=&quot;https://digitalcommons.butler.edu/wordways/vol27/iss1/18/&quot;&gt;published an update a year later&lt;/a&gt;, presenting a tighter 18-by-22 solution with an area of 396:&lt;/p&gt;

&lt;table&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;F&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;G&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;X&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;J&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;I&lt;/td&gt;
    &lt;td&gt;D&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;L&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;P&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;R&lt;/td&gt;
    &lt;td&gt;C&lt;/td&gt; &lt;td&gt;E&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;V&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;P&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;K&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;V&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;B&lt;/td&gt;
    &lt;td&gt;U&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;B&lt;/td&gt; &lt;td&gt;U&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;H&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;U&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;G&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;W&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;E&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;W&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;R&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;J&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;B&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;R&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;U&lt;/td&gt;
    &lt;td&gt;M&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;S&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;F&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;K&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;K&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt;
    &lt;td&gt;O&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;V&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;K&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;S&lt;/td&gt;
    &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;W&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;N&lt;/td&gt;
    &lt;td&gt;G&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;J&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;Gordon’s rectangle above from 1994 is the last communication I can find on the Presidential Rectangle for a while,
even though thanks to the election of George W. Bush in 2000, the set of presidential surnames
didn’t change again until 2008.&lt;/p&gt;

&lt;p&gt;The Presidential Rectangle shows up as an exercise in Don Knuth’s Art of Computer Programming Vol. 4, Fascicle 5,
although the exercise asks for a square rather than a rectangle, and the exercise asks for the first 38
surnames up to and including Obama.&lt;/p&gt;

&lt;p&gt;The 20-by-20 solution (area: 400) is credited to Gary McDonald from 2017:&lt;/p&gt;

&lt;table&gt;
  &lt;tr&gt;
    &lt;td&gt;W&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;F&lt;/td&gt;
    &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;P&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;J&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;X&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;D&lt;/td&gt;
    &lt;td&gt;G&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;K&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;R&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;V&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;U&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;O&lt;/td&gt;
    &lt;td&gt;S&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;V&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;M&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;B&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;B&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;S&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;U&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt;
    &lt;td&gt;D&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;U&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;M&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;A&lt;/td&gt;
    &lt;td&gt;R&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;T&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;F&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;E&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;J&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;V&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;W&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;K&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;W&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;K&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;P&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;M&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;B&lt;/td&gt;
    &lt;td&gt;U&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;V&lt;/td&gt;
    &lt;td&gt;A&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;B&lt;/td&gt; &lt;td&gt;U&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;K&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;McDonald’s solution contains some elements from Gordon’s earlier patterns, including an updated
4-way intersection including Coolidge and Nixon. But I think the dense
Roosevelt-Adams-Harding-Obama-Cleveland-Jefferson block is really the centerpiece of the packing.&lt;/p&gt;

&lt;p&gt;Knuth mentions that a 19-by-19 solution is surely impossible, and after many attempts over the past few weeks,
I am also doubtful that a 19-by-19 packing exists. I was, however, able to pack all of the first 38 surnames
up to Obama in a 19-by-21 grid, which beats McDonald’s 20-by-20 solution by exactly 1 when scoring by total area.&lt;/p&gt;

&lt;p&gt;Here’s my 19-by-21:&lt;/p&gt;

&lt;table&gt;
  &lt;tr&gt;
    &lt;td&gt;B&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;U&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;B&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;O&lt;/td&gt;
    &lt;td&gt;E&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;C&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;P&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;K&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;U&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;K&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;S&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;B&lt;/td&gt; &lt;td&gt;U&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt;
    &lt;td&gt;E&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;J&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;A&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;U&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;J&lt;/td&gt;
    &lt;td&gt;E&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;X&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;W&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt;
    &lt;td&gt;Y&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;V&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;V&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;N&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;M&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;C&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;L&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;J&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;K&lt;/td&gt;
    &lt;td&gt;S&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;B&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;I&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;U&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;G&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;V&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;T&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;W&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;O&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;P&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;E&lt;/td&gt;
    &lt;td&gt;R&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;L&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;I was also able to construct a similar 21-by-21 packing of all 40 presidential surnames as of 2021, including
Trump and Biden:&lt;/p&gt;

&lt;table&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;B&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;B&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;R&lt;/td&gt;
    &lt;td&gt;U&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;F&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;B&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;U&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;U&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;P&lt;/td&gt; &lt;td&gt;O&lt;/td&gt;
    &lt;td&gt;L&lt;/td&gt; &lt;td&gt;K&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;M&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;J&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;O&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;B&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;D&lt;/td&gt;
    &lt;td&gt;E&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;A&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;U&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;X&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;J&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;W&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt;
    &lt;td&gt;A&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;V&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;V&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;N&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;M&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;C&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;C&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;M&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;L&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;J&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;K&lt;/td&gt;
    &lt;td&gt;S&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;B&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;I&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;U&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;G&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;H&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;V&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;T&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;W&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;S&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;O&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;O&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;G&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;P&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;E&lt;/td&gt;
    &lt;td&gt;R&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;L&lt;/td&gt; &lt;td&gt;I&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;O&lt;/td&gt; &lt;td&gt;L&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;R&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;T&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;N&lt;/td&gt; &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;Word Ways has suspended publication as of a year ago, otherwise I’d continue the
tradition by posting these constructions there. In the rest of this post, I’ll explain how
I found these new rectangles and share some tools that you can use to construct
similar word rectangles.&lt;/p&gt;

&lt;h1 id=&quot;sat-encoding&quot;&gt;SAT Encoding&lt;/h1&gt;

&lt;p&gt;You can frame the Presidential Rectangle problem as a set cover problem and use solvers
based on the &lt;a href=&quot;https://en.wikipedia.org/wiki/Dancing_Links&quot;&gt;Dancing Links&lt;/a&gt; technique to identify solutions but the connectedness
property is difficult to specify in that setting. Knuth describes a way to modify a solver to only
discover connected solutions instead of filtering out disconnected solutions as a
post-processing step. But SAT solvers are usually much more efficient at finding a solution
with multiple constraints like this, and I like playing around with complicated SAT encodings,
so I wanted to give that approach a go.&lt;/p&gt;

&lt;p&gt;My encoding creates a boolean variable &lt;em&gt;C&lt;sub&gt;(ch,r,c)&lt;/sub&gt;&lt;/em&gt; for every possible character &lt;em&gt;ch&lt;/em&gt;
and row &lt;em&gt;r&lt;/em&gt;, column &lt;em&gt;c&lt;/em&gt; pair in the rectangle. These variables represent “the cell at &lt;em&gt;(r, c)&lt;/em&gt;
in the rectangle contains character &lt;em&gt;ch&lt;/em&gt;”. I also add clauses that restrict
at most one &lt;em&gt;C&lt;sub&gt;(ch,r,c)&lt;/sub&gt;&lt;/em&gt; to be true for any &lt;em&gt;(r, c)&lt;/em&gt; pair.&lt;/p&gt;

&lt;p&gt;Now I can go through all surnames that I want to pack
in the rectangle and create variables &lt;em&gt;PH&lt;sub&gt;(x,r,c)&lt;/sub&gt;&lt;/em&gt; representing “surname &lt;em&gt;x&lt;/em&gt; is
placed horizontally starting at &lt;em&gt;(r,c)&lt;/em&gt;” and &lt;em&gt;PV&lt;sub&gt;(x,r,c)&lt;/sub&gt;&lt;/em&gt; respresenting
“&lt;em&gt;x&lt;/em&gt; is placed vertically starting at &lt;em&gt;(r,c)&lt;/em&gt;”. I create clauses connecting the
&lt;em&gt;PH&lt;sub&gt;(x,r,c)&lt;/sub&gt;&lt;/em&gt; and &lt;em&gt;PV&lt;sub&gt;(x,r,c)&lt;/sub&gt;&lt;/em&gt; to the &lt;em&gt;C&lt;sub&gt;(ch,r,c)&lt;/sub&gt;&lt;/em&gt; in
the natural way, spelling out the exact placements of characters in surname &lt;em&gt;x&lt;/em&gt; into cells
in the rectangle if &lt;em&gt;PH&lt;sub&gt;(x,r,c)&lt;/sub&gt;&lt;/em&gt; or &lt;em&gt;PV&lt;sub&gt;(x,r,c)&lt;/sub&gt;&lt;/em&gt; is true. Finally,
I add clauses that ensure that exactly one &lt;em&gt;PH&lt;sub&gt;(x,r,c)&lt;/sub&gt;&lt;/em&gt; or &lt;em&gt;PV&lt;sub&gt;(x,r,c)&lt;/sub&gt;&lt;/em&gt;
is true for any surname &lt;em&gt;x&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;At this point, any satisfying assignment of the variables must pack all of the surnames into the
rectangle and ensure that each cell in the rectangle is assigned at most one distinct character.
But recall the rules we started with:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Names can only be placed left-to-right or top-to-bottom&lt;/li&gt;
  &lt;li&gt;Letters in adjacent cells must belong to a common name&lt;/li&gt;
  &lt;li&gt;Every name must be connected by some path of intersecting names to every other name&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Without additional contraints, we could still violate rule 2 above by placing surnames too
close together in the rectangle.&lt;/p&gt;

&lt;p&gt;To encode the spacing constraints of rule 2, I introduced three more families of variables:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;em&gt;S&lt;sub&gt;(r,c)&lt;/sub&gt;&lt;/em&gt;: “spacer” variables.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;H&lt;sub&gt;(r,c)&lt;/sub&gt;&lt;/em&gt;: “horizontal cell” marker variables.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;V&lt;sub&gt;(r,c)&lt;/sub&gt;&lt;/em&gt;: “vertical cell” marker variables.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When a &lt;em&gt;PH&lt;sub&gt;(x,r,c)&lt;/sub&gt;&lt;/em&gt; or &lt;em&gt;PV&lt;sub&gt;(x,r,c)&lt;/sub&gt;&lt;/em&gt; is set, we set spacer variables
in the two cells before and after the placement of the surname. There may be
no cell that comes before or after a surname if it’s placed on the border of the rectangle,
and that’s fine, we just omit spacers when that happens. We also set &lt;em&gt;H&lt;sub&gt;(r,c)&lt;/sub&gt;&lt;/em&gt; on
all cells covered by the characters in a surname when &lt;em&gt;PH&lt;sub&gt;(x,r,c)&lt;/sub&gt;&lt;/em&gt; is set and
&lt;em&gt;V&lt;sub&gt;(r,c)&lt;/sub&gt;&lt;/em&gt; on all cells covered by the characters in a surname when &lt;em&gt;PV&lt;sub&gt;(x,r,c)&lt;/sub&gt;&lt;/em&gt;
is set.&lt;/p&gt;

&lt;p&gt;With that setup, we add some more clauses to guarantee that:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A spacer and a horizontal cell never co-occur&lt;/li&gt;
  &lt;li&gt;A spacer and a vertical cell never co-occur&lt;/li&gt;
  &lt;li&gt;Two horizontal cells can’t be vertically adjacent unless both are also vertical cells&lt;/li&gt;
  &lt;li&gt;Two vertical cells can’t be horizontally adjacent unless both are also horizontal cells.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At this point, there are already a lot of variables involved, so here’s an example that might
help make sense of the encoding so far: If POLK is placed horizontally in the cells (1,1), (1,2), (1,3), (1,4),
then &lt;em&gt;PH&lt;sub&gt;(POLK,1,1)&lt;/sub&gt;&lt;/em&gt; is set and no other &lt;em&gt;PH&lt;sub&gt;(POLK,r,c)&lt;/sub&gt;&lt;/em&gt; or &lt;em&gt;PV&lt;sub&gt;(POLK,r,c)&lt;/sub&gt;&lt;/em&gt;
can be set. This also means that &lt;em&gt;C&lt;sub&gt;(P,1,1)&lt;/sub&gt;&lt;/em&gt;, &lt;em&gt;C&lt;sub&gt;(O,1,2)&lt;/sub&gt;&lt;/em&gt;, &lt;em&gt;C&lt;sub&gt;(L,1,3)&lt;/sub&gt;&lt;/em&gt;, and
&lt;em&gt;C&lt;sub&gt;(K,1,4)&lt;/sub&gt;&lt;/em&gt; get set and no other &lt;em&gt;C&lt;sub&gt;(ch,1,1)&lt;/sub&gt;&lt;/em&gt;, &lt;em&gt;C&lt;sub&gt;(ch,1,2)&lt;/sub&gt;&lt;/em&gt;, &lt;em&gt;C&lt;sub&gt;(ch,1,3)&lt;/sub&gt;&lt;/em&gt;,
or &lt;em&gt;C&lt;sub&gt;(ch,1,4)&lt;/sub&gt;&lt;/em&gt; can be set. Also, &lt;em&gt;S&lt;sub&gt;(1,0)&lt;/sub&gt;&lt;/em&gt; and &lt;em&gt;S&lt;sub&gt;(1,5)&lt;/sub&gt;&lt;/em&gt; get set, which
keeps any other surnames from using those cells. And &lt;em&gt;H&lt;sub&gt;(1,1)&lt;/sub&gt;&lt;/em&gt;, &lt;em&gt;H&lt;sub&gt;(1,2)&lt;/sub&gt;&lt;/em&gt;, &lt;em&gt;H&lt;sub&gt;(1,3)&lt;/sub&gt;&lt;/em&gt;,
and &lt;em&gt;H&lt;sub&gt;(1,4)&lt;/sub&gt;&lt;/em&gt; get set, which keeps horizontal surnames from occurring adjacent to POLK in row 0
or row 2 unless the cells are also vertical cells (to see why we make this exception, look at, for example,
the Reagan-Carter-Nixon-Coolidge intersection in Gary McDonald’s solution above).&lt;/p&gt;

&lt;p&gt;So we’ve encoded rules 1 and 2, and we’re left with rule 3: “Every name must be connected by
some path of intersecting names to every other name”. This is a little tedious but we can do it.
Define variables &lt;em&gt;R&lt;sub&gt;(x,y,i)&lt;/sub&gt;&lt;/em&gt; for every pair of surnames &lt;em&gt;x&lt;/em&gt; and &lt;em&gt;y&lt;/em&gt;
and each &lt;em&gt;i&lt;/em&gt; from &lt;em&gt;0&lt;/em&gt; to &lt;em&gt;N-2&lt;/em&gt;, where &lt;em&gt;N&lt;/em&gt; is the total number of surnames.
&lt;em&gt;R&lt;sub&gt;(x,y,i)&lt;/sub&gt;&lt;/em&gt; is true exactly when &lt;em&gt;x&lt;/em&gt; is reachable from &lt;em&gt;y&lt;/em&gt;
through a path consisting of exactly &lt;em&gt;i&lt;/em&gt; intermediate surnames. You can define it inductively
as follows:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;em&gt;R&lt;sub&gt;(x,y,0)&lt;/sub&gt;&lt;/em&gt; is true if any of the placements of &lt;em&gt;x&lt;/em&gt; and &lt;em&gt;y&lt;/em&gt;
that intersect are selected, or false if there are no such placements.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;R&lt;sub&gt;(x,y,i)&lt;/sub&gt;&lt;/em&gt; for &lt;em&gt;i &amp;gt; 0&lt;/em&gt; is true if there’s some &lt;em&gt;z&lt;/em&gt; such
that &lt;em&gt;R&lt;sub&gt;(x,z,0)&lt;/sub&gt;&lt;/em&gt; and &lt;em&gt;R&lt;sub&gt;(z,y,i-1)&lt;/sub&gt;&lt;/em&gt; are both true.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finally, we generate a set of variables &lt;em&gt;R&lt;sub&gt;(x,y)&lt;/sub&gt;&lt;/em&gt; for each pair of surnames &lt;em&gt;x&lt;/em&gt;, &lt;em&gt;y&lt;/em&gt; and
define each as the disjunction of
&lt;em&gt;R&lt;sub&gt;(x,y,i)&lt;/sub&gt;&lt;/em&gt; for &lt;em&gt;i&lt;/em&gt; from &lt;em&gt;0&lt;/em&gt; to &lt;em&gt;N-2&lt;/em&gt;, so that
&lt;em&gt;R&lt;sub&gt;(x,y)&lt;/sub&gt;&lt;/em&gt; is true exactly when there’s a path of any length from &lt;em&gt;x&lt;/em&gt; to &lt;em&gt;y&lt;/em&gt;.
Then we add unit clauses for each &lt;em&gt;R&lt;sub&gt;(x,y)&lt;/sub&gt;&lt;/em&gt; to the encoding to ensure
everything is connected to everything else.&lt;/p&gt;

&lt;p&gt;Now we can just run a SAT solver on the formula. If it returns a satisfying assignment, we
can extract the assignments of the &lt;em&gt;PH&lt;sub&gt;(x,r,c)&lt;/sub&gt;&lt;/em&gt; and &lt;em&gt;PV&lt;sub&gt;(x,r,c)&lt;/sub&gt;&lt;/em&gt;
for each surname &lt;em&gt;x&lt;/em&gt; to reconstruct the solution.&lt;/p&gt;

&lt;h1 id=&quot;assisted-solutions&quot;&gt;Assisted solutions&lt;/h1&gt;

&lt;p&gt;Unfortunately, the Presidential Rectangle is a bit too difficult even for modern SAT solvers.
You can, for example, find a packing of a dozen or so surnames in, say, a 12-by-12
square or prove that no such packing exists for an 11-by-11 square in a few minutes. But
packing even the first 38 presidential surnames into a 20-by-20 rectangle or proving a 19-by-19 packing
seems beyond the reach of today’s technology: I ran multiple state-of-the-art solvers for a week each on
problems like these with no results.&lt;/p&gt;

&lt;p&gt;Since I care more about finding packings than proving they don’t exist, I started to look for
ways to make the problem easier by targeting packings with additional constraints instead of solving
the general problem.&lt;/p&gt;

&lt;p&gt;Along these lines, I played around with:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Forces&lt;/strong&gt;: Some of the advances in the Presidential Rectangle came from re-using partial
packings that were successful in earlier attempts (Lee Sallows re-used Darryl Francis’s
Van Buren-Harding-Grant-Buchanan loop and Leonard Gordon’s solutions share many common
constructs, for example). It makes sense that you might want to force absolute positions
for some of the surnames and let the solver figure out the rest.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Relative Forces&lt;/strong&gt;: Similar to forces, these allow you to specify relative positions
instead of absolute posititions in the form of constraints that say things like “I’d like
Harding and Harrison to intersect in their first ‘H’”.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Partial Packings&lt;/strong&gt;: Allow the solver to pack a subset of a particular size into a
sub-rectangle. Partial packings are easy for the solver to figure out, and they could be
used incrementally with forces to figure out a full packing.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Minimizing Blank Cells&lt;/strong&gt;: A constraint that guarantees at most &lt;em&gt;N&lt;/em&gt; blank cells in a
packing helps create denser partial packings. Without adding something like this, if you
ask a solver for a partial packing of any 10 surnames into a 10-by-10 grid you’re likely
to just get the 10 shortest names.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I had some promising partial successes with each of these techniques. But the only thing that
really worked for me (and what gave me the 19-by-21 and 21-by-21 rectangles above) was to
hand-pack some of the trickier surnames and use those as absolute forces, letting the solver
figure out the rest. Both of my solutions above share the same lower half which I hand-crafted
and then fed into the solver with forces. That lower half helped the solver find both solutions
in just a few hours each.&lt;/p&gt;

&lt;h1 id=&quot;tools&quot;&gt;Tools&lt;/h1&gt;

&lt;p&gt;I’ve put the tools I used to generate the rectangles above up at
&lt;a href=&quot;http://github.com/aaw/presidential-rectangle&quot;&gt;github.com/aaw/presidential-rectangle&lt;/a&gt;.
They support all of the advanced features for assisted solutions described in the previous
section. Have fun creating your own rectangles!&lt;/p&gt;

</description>
        <pubDate>Sun, 07 Nov 2021 07:37:00 -0500</pubDate>
        <link>http://blog.aaw.io/2021/11/07/the-presidential-rectangle.html</link>
        <guid isPermaLink="true">http://blog.aaw.io/2021/11/07/the-presidential-rectangle.html</guid>
        
        
      </item>
    
      <item>
        <title>Partridge Puzzle</title>
        <description>&lt;p&gt;Robert T. Wainwright’s Partridge Puzzle for n=8 is: pack one 1x1 unit square, two 2x2 unit
squares, … , eight 8x8 unit squares into a larger 36 x 36 square. Since the
sum of the first n cubes is equal to the square of the sum of the first n integers,
it shouldn’t be impossible for any n, but n=8 is the smallest value where a packing
actually exists:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/partridge/partridge-8.png&quot; alt=&quot;Partridge puzzle solution for n=8&quot; /&gt;&lt;/p&gt;

&lt;!----
&lt;pre style=&quot;line-height:normal&quot;&gt;
┌───┬───┬─────────┬─────────────┬─────────────┬─────────────┬───────────┐
│  2│  2│         │             │             │             │           │
├───┴───┤         │             │             │             │           │
│       │         │             │             │             │           │
│       │        5│             │             │             │           │
│      4├─────────┤             │             │             │          6│
├───────┤         │            7│            7│            7├───────────┤
│       │         ├─────────────┴─┬───────────┴───┬─────────┤           │
│       │         │               │               │         │           │
│      4│        5│               │               │         │           │
├─────┬─┴─────────┤               │               │         │           │
│     │           │               │               │        5│          6│
│    3│           │               │               ├─────┬───┴───────────┤
├─────┤           │               │               │     │               │
│     │           │              8│              8│    3│               │
│    3│          6├─┬───────────┬─┴─────┬─────────┴─────┤               │
├─────┴───┬───────┴─┤           │       │               │               │
│         │         │           │       │               │               │
│         │         │           │      4│               │               │
│         │         │           ├───────┤               │              8│
│        5│        5│          6│       │               ├───────────────┤
├─────────┴─────┬───┴───────────┤       │               │               │
│               │               │      4│              8│               │
│               │               ├───────┴───┬───────────┤               │
│               │               │           │           │               │
│               │               │           │           │               │
│               │               │           │           │               │
│               │               │           │           │              8│
│              8│              8│          6│          6├───────────────┤
├─────────────┬─┴───────────┬───┴─────────┬─┴───────────┤               │
│             │             │             │             │               │
│             │             │             │             │               │
│             │             │             │             │               │
│             │             │             │             │               │
│             │             │             │             │               │
│            7│            7│            7│            7│              8│
└─────────────┴─────────────┴─────────────┴─────────────┴───────────────┘
&lt;/pre&gt;
--&gt;

&lt;p&gt;(The little unlabled square above is 1x1, but it’s too tiny for a label.)&lt;/p&gt;

&lt;p&gt;You can generate all solutions for n=8 at a terminal by running&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;examples/partridge/solve-partridge.sh 8
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;from &lt;a href=&quot;http://github.com/aaw/cover&quot;&gt;github.com/aaw/cover&lt;/a&gt; and waiting a
few minutes for the first one to appear.&lt;/p&gt;
</description>
        <pubDate>Sun, 05 Sep 2021 10:13:44 -0400</pubDate>
        <link>http://blog.aaw.io/2021/09/05/partridge-puzzle.html</link>
        <guid isPermaLink="true">http://blog.aaw.io/2021/09/05/partridge-puzzle.html</guid>
        
        
      </item>
    
      <item>
        <title>Comma-free codes</title>
        <description>&lt;p&gt;A set of strings is &lt;a href=&quot;https://en.wikipedia.org/wiki/Comma-free_code&quot;&gt;&lt;em&gt;comma-free&lt;/em&gt;&lt;/a&gt; if, for any two strings &lt;em&gt;x&lt;/em&gt; and &lt;em&gt;y&lt;/em&gt; in the
set, no substring of the concatenation &lt;em&gt;xy&lt;/em&gt; that overlaps both &lt;em&gt;x&lt;/em&gt; and &lt;em&gt;y&lt;/em&gt; is also in the set.&lt;/p&gt;

&lt;p&gt;Once again, my interest in comma-free codes is coming from Don Knuth’s
&lt;a href=&quot;https://www.pearson.com/store/p/the-art-of-computer-programming-volume-4-fascicle-5-mathematical-preliminaries-redux-introduction-to-backtracking-dancing-links/P100000291857/9780134671796&quot;&gt;Volume 4, Fascicle 5 of The Art of Computer Programming&lt;/a&gt;. Knuth covers a
souped-up backtracking algorithm to find comma-free codes and includes
an exercise that derives W. L. Eastman’s
algorithm for generating codes with odd word length&lt;sup id=&quot;fnref:2&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;. He also goes over Eastman’s algorithm
in his &lt;a href=&quot;https://www.youtube.com/watch?v=48iJx8FVuis&quot;&gt;2015 Christmas lecture&lt;/a&gt; as well, which must have been given around the time
he was writing Fascicle 5.&lt;/p&gt;

&lt;p&gt;In this post, I’ll describe how to use a SAT solver to discover comma-free codes.&lt;/p&gt;

&lt;h1 id=&quot;background&quot;&gt;Background&lt;/h1&gt;

&lt;p&gt;I’ll call a comma-free set a “code” and the strings in the set “codewords” in most of the rest of this post.&lt;/p&gt;

&lt;p&gt;A few warm-up examples to make the comma-free property concrete: if a comma-free code containing only words of
length three contains 123 and 456, then it can’t contain 234 or 345 and it can’t contain 561
or 612 (since those are substrings of 123456 and 456123, respectively). It also can’t contain
231, 312, 564, or 654 (since those are substrings of 123123 and 456456, respectively).&lt;/p&gt;

&lt;p&gt;The term “comma-free” comes from the fact that you can create messages just by
concatenating codewords together (without commas or other such delimiters) and those
messages will be uniquely decodable into codewords even if you start decoding 
somewhere in the middle of the message.&lt;/p&gt;

&lt;p&gt;For example, a comma-free code with words of length 3 over the alphabet {0,1,2} is:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{001, 002, 101, 102, 120, 121, 220, 221}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Given some partial message made up of these codewords:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;...011202212200012...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The interpretation of that message as codewords is unique. It has to be&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;...01,120,221,220,001,2...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;since neither of the other ways of interpreting it makes sense. Neither&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;...0,112,022,122,000,12...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

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

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;...011,202,212,200,012...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;contain any valid code words.&lt;/p&gt;

&lt;h1 id=&quot;upper-bounds&quot;&gt;Upper bounds&lt;/h1&gt;

&lt;p&gt;A &lt;a href=&quot;https://en.wikipedia.org/wiki/Lyndon_word&quot;&gt;Lyndon word&lt;/a&gt; is a string that’s a unique lexicographic minimum
among the multiset of all of its rotations.&lt;/p&gt;

&lt;p&gt;0001 is a Lyndon word because it’s the minimum among the rotations 0001, 0010, 0100, 1000.&lt;/p&gt;

&lt;p&gt;0101 is the minimum among all its rotations, but it’s not a Lyndon word because the minimum
is not unique among all four rotations: 0101, 1010, 0101, 1010. Any periodic string will have
the same problem.&lt;/p&gt;

&lt;p&gt;If the same codeword is repeated in a message, all of its other rotations overlap
both occurrences of the codeword (for example, 00010001 contains all rotations of 0001).
So a codeword and one of its rotation cannot both appear in a comma-free code. Furthermore, you
can’t have periodic codewords in a comma-free code (0101 creates ambiguity when concatenated
with itself as 01010101). These two facts mean that the number of Lyndon words of length n over
an alphabet of size m is an upper bound on the maximum size of a comma-free code with
the same parameters.&lt;/p&gt;

&lt;p&gt;There’s a closed-form formula for the number of Lyndon words of length n over an alphabet
of size m, but it &lt;a href=&quot;https://encyclopediaofmath.org/wiki/Lyndon_word&quot;&gt;involves the Möbius function&lt;/a&gt;. I’ll just use &lt;em&gt;LW(n,m)&lt;/em&gt; to represent it here –
it doesn’t matter what the formula is, I’m only interested in how close we can get to the optimal
size &lt;em&gt;LW(n,m)&lt;/em&gt; for various values of &lt;em&gt;n&lt;/em&gt; and &lt;em&gt;m&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;To tie all of this together, one way of viewing the process of creating a comma-free code
that’s as large as possible is just selecting at most one rotation of each Lyndon word while
avoiding conflicts. Let &lt;em&gt;CF(n,m)&lt;/em&gt; be the maximum size of a comma-free code with words
of length &lt;em&gt;n&lt;/em&gt; over an alphabet of size &lt;em&gt;m&lt;/em&gt;. If &lt;em&gt;LW(n,m)&lt;/em&gt; = &lt;em&gt;CF(n,m)&lt;/em&gt;, then there’s
some way of choosing one rotation of each Lyndon word to create a maximum-size comma-free code.&lt;/p&gt;

&lt;p&gt;For all odd &lt;em&gt;n&lt;/em&gt;, &lt;em&gt;LW(n,m)&lt;/em&gt; = &lt;em&gt;CF(n,m)&lt;/em&gt; and W.L. Eastman came up with an algorithm&lt;sup id=&quot;fnref:2:1&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;
that will create such a code. For even &lt;em&gt;n&lt;/em&gt;, not much is known
even for very small values of &lt;em&gt;n&lt;/em&gt; and &lt;em&gt;m&lt;/em&gt;. The case &lt;em&gt;n&lt;/em&gt;=2 was solved by
Golomb, Gordon, and Welch&lt;sup id=&quot;fnref:1&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;: &lt;em&gt;CF(2,m)&lt;/em&gt; = &lt;em&gt;floor(m&lt;sup&gt;2&lt;/sup&gt;/3)&lt;/em&gt;,
which is strictly less than &lt;em&gt;LW(n,m)&lt;/em&gt; for &lt;em&gt;m&lt;/em&gt; &amp;gt; 3.&lt;/p&gt;

&lt;p&gt;For example, here’s a comma-free code for n=2, m=4:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{10, 12, 30, 31, 32}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;LW(2,4)&lt;/em&gt; = 6 and the code above contains rotations of
all Lyndon words except for 02. And that’s as good as you can do: by Golumb, Gordon, and Welch’s
formula above, &lt;em&gt;CF(2,4)&lt;/em&gt; = 5, so there’s no comma-free code that includes all Lyndon words for n=2, m=4.&lt;/p&gt;

&lt;p&gt;Here’s a table of &lt;em&gt;LW(n,m)&lt;/em&gt; - &lt;em&gt;CF(n,m)&lt;/em&gt;, where &lt;em&gt;CF(n,m)&lt;/em&gt; is actually known:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: center&quot;&gt; &lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;m=2&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;m=3&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;m=4&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;m=5&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;m=6&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;m=7&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;m=8&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;m=9&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;m=10&lt;/th&gt;
      &lt;th&gt; &lt;/th&gt;
      &lt;th&gt; &lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;n=2&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;9&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;12&lt;/td&gt;
      &lt;td&gt;…&lt;/td&gt;
      &lt;td&gt;&lt;em&gt;LW(n,m) - floor(m&lt;sup&gt;2&lt;/sup&gt;/3)&lt;/em&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;n=3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;n=4&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;&lt;span style=&quot;background-color: #FFFF00&quot;&gt;11&lt;/span&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;n=5&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;n=6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;&lt;span style=&quot;background-color: #FFFF00&quot;&gt;3&lt;/span&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;n=7&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;n=8&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;n=9&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;n=10&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;n=11&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;n=12&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;&lt;span style=&quot;background-color: #FFFF00&quot;&gt;1&lt;/span&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;n=13&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;0&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;n=14&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Blanks in the table above are currently unknown. In particular, all rows after
n=13 are unknown. For even &lt;em&gt;n&lt;/em&gt;, &lt;em&gt;CF(n,m)&lt;/em&gt; gets really difficult to determine
really quickly and &lt;em&gt;LW(n,m)&lt;/em&gt; is only achievable for small values of &lt;em&gt;n&lt;/em&gt; and &lt;em&gt;m&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The three highlighted entries in the table are state-of-the-art and apparently
unknown at the time of the first printing of Volume 4, Fascicle 5. All of the
entries in rows with even &lt;em&gt;n&lt;/em&gt; above
are within reach of at most a day’s computation on a decent computer using a
SAT solver. In the rest of this post, I’ll describe how I calculated the values
in the table above for &lt;em&gt;n&lt;/em&gt; &amp;gt; 2.&lt;/p&gt;

&lt;h1 id=&quot;using-a-solver-to-find-comma-free-codes&quot;&gt;Using a Solver to Find Comma-free Codes&lt;/h1&gt;

&lt;p&gt;The general recipe I used for finding comma-free codes with a SAT solver was:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Write a Python program that takes arguments &lt;em&gt;n&lt;/em&gt;, &lt;em&gt;m&lt;/em&gt;, and &lt;em&gt;d&lt;/em&gt; on the
command line and generates a &lt;a href=&quot;http://www.satcompetition.org/2009/format-benchmarks2009.html&quot;&gt;DIMACS file&lt;/a&gt; with a formula that’s
satisfiable exactly when there’s a comma-free code on codewords of size
&lt;em&gt;n&lt;/em&gt; over alphabet of size &lt;em&gt;m&lt;/em&gt; with &lt;em&gt;d&lt;/em&gt; Lyndon words not chosen. So if
you run with &lt;em&gt;d&lt;/em&gt;=0 and get a satisfiable formula, &lt;em&gt;LW(n,m)&lt;/em&gt; = &lt;em&gt;CF(n,m)&lt;/em&gt;.&lt;/p&gt;

    &lt;p&gt;Some of the variables in the formula are indicators for particular codewords
being chosen in the code, so I generated comments in the DIMACS file (&lt;a href=&quot;https://raw.githubusercontent.com/aaw/sat/master/test/commafree-4-4-0.cnf&quot;&gt;example&lt;/a&gt;) that
would help me translate variables to codewords later.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For any pair of &lt;em&gt;n&lt;/em&gt;, &lt;em&gt;m&lt;/em&gt; I was interested in, I generated DIMACS files starting with
&lt;em&gt;d&lt;/em&gt; = 0 and ran Armin Biere’s &lt;a href=&quot;https://github.com/arminbiere/kissat&quot;&gt;kissat&lt;/a&gt; on the resulting files, increasing
&lt;em&gt;d&lt;/em&gt; and starting over until I found the smallest &lt;em&gt;d&lt;/em&gt; where the resulting
formula was satisfiable.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Using the satisfying assigment found by kissat, I could optionally extract a code by
matching the assignment up with comments in the DIMACS input file.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With this method, I was able to fill in the table in the previous section. If
you want to replicate this, you’ll need Python3 installed and a SAT solver like kissat.
Download two scripts:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/aaw/sat/blob/master/gen/commafree.py&quot;&gt;commafree.py&lt;/a&gt;: the input file generator&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://gist.github.com/aaw/430fa06b6f0c8db73b81c9b2f4afb079&quot;&gt;extract-code.py&lt;/a&gt;: a script that verifies and extracts comma-free codes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using these tools, you should be able to extract your own codes:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ commafree.py 4 2 0 &amp;gt; /tmp/commafree-4-2-0.cnf  # n=4, m=2, d=0
$ kissat /tmp/commafree-4-2-0.cnf &amp;gt; /tmp/kissat-4-2-0.out
$ [ $? -eq 10 ] &amp;amp;&amp;amp; extract-code.py /tmp/commafree-4-2-0.cnf /tmp/kissat-4-2-0.out
{1000, 1001, 1011}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;(The final command prints nothing if the formula was unsatisfiable, in which case
you need to increment &lt;em&gt;d&lt;/em&gt; and try again.)&lt;/p&gt;

&lt;p&gt;Some of the blank entries in the table above should be solvable today with a bit
more effort, particularly at the
frontier, like (&lt;em&gt;n&lt;/em&gt;,&lt;em&gt;m&lt;/em&gt;) = (4,6), (6,4), and (8,3). Maybe these
are already solvable by SAT solver tuning, symmetry-breaking or some other
preprocessing of the CNF files.&lt;/p&gt;

&lt;h1 id=&quot;the-sat-encoding&quot;&gt;The SAT Encoding&lt;/h1&gt;

&lt;p&gt;The heart of the process above is a Python program to generate DIMACS files,
but it’s nothing too complicated. It does the following:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Generate candidate codewords by iterating over all Lyndon words and their
rotations. This can be done with Knuth’s Algorithm 7.2.1.1 F from &lt;a href=&quot;https://www.pearson.com/store/p/art-of-computer-programming-volume-4a-the-combinatorial-algorithms-part-1/P100001186353/9780201038040&quot;&gt;The Art of
Computer Programming, Volume 4A&lt;/a&gt;. Associate
each of these words with a variable that’s true exactly when the codeword
has been chosen for the comma-free code.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Generate clauses for each Lyndon word that express “at most one codeword
from this Lyndon word and its rotations is chosen”.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Iterate over all pairs &lt;em&gt;x&lt;/em&gt;, &lt;em&gt;y&lt;/em&gt; of Lyndon word variables. For each pair,
discover all codewords &lt;em&gt;z&lt;/em&gt; that are disallowed in &lt;em&gt;xy&lt;/em&gt; or &lt;em&gt;yx&lt;/em&gt; by the
comma-free property and generate clauses for such triples &lt;em&gt;x&lt;/em&gt;, &lt;em&gt;y&lt;/em&gt;, &lt;em&gt;z&lt;/em&gt; that express “x, y, and z can’t
all occur in the comma-free code”.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Generate variables and clauses for each Lyndon word such that the variables
indicate “some rotation of this Lyndon word was chosen”.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Generate variables and clauses that sort the variables from the previous
step and assert that the smallest &lt;em&gt;d&lt;/em&gt; values are 0 and the &lt;em&gt;d+1&lt;/em&gt;-st value
is 1. I cheated here and didn’t do a full sort, I just applied a full row
of &lt;a href=&quot;https://en.wikipedia.org/wiki/Sorting_network&quot;&gt;comparators&lt;/a&gt; &lt;em&gt;d+1&lt;/em&gt; times – essentially &lt;em&gt;d+1&lt;/em&gt; rounds of bubblesort
to sort the smallest &lt;em&gt;d&lt;/em&gt; values only.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Again, you can check out the &lt;a href=&quot;https://github.com/aaw/sat/blob/master/gen/commafree.py&quot;&gt;generator source&lt;/a&gt; for full details.&lt;/p&gt;

&lt;h1 id=&quot;new-codes&quot;&gt;New Codes&lt;/h1&gt;

&lt;p&gt;So, finally, here’s a dump of the new codes I was able to discover. All of these
are now officially the maximum size comma-free codes for these values of &lt;em&gt;n&lt;/em&gt; and &lt;em&gt;m&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;n=4, m=5, size=139 (&lt;em&gt;LW(4,5)&lt;/em&gt; = 150):&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{0012, 0013, 0014, 0100, 0102, 0103, 0104, 0110, 0111, 0112, 0113, 0114, 0204,
 0212, 0213, 0214, 0304, 0312, 0313, 0314, 1012, 1013, 1014, 2000, 2002, 2003,
 2004, 2012, 2013, 2014, 2022, 2023, 2024, 2032, 2033, 2034, 2100, 2102, 2103,
 2104, 2110, 2111, 2112, 2113, 2114, 2204, 2212, 2213, 2214, 2224, 2234, 2304,
 2312, 2313, 2314, 2324, 2334, 3000, 3002, 3003, 3004, 3012, 3013, 3014, 3022,
 3023, 3024, 3032, 3033, 3034, 3100, 3102, 3103, 3104, 3110, 3111, 3112, 3113,
 3114, 3204, 3212, 3213, 3214, 3224, 3234, 3304, 3312, 3313, 3314, 3324, 3334,
 4000, 4002, 4003, 4004, 4012, 4013, 4014, 4022, 4023, 4024, 4032, 4033, 4034,
 4042, 4043, 4044, 4100, 4102, 4103, 4104, 4110, 4111, 4112, 4113, 4114, 4122,
 4123, 4124, 4132, 4133, 4134, 4142, 4143, 4144, 4204, 4212, 4213, 4214, 4224,
 4234, 4244, 4304, 4312, 4313, 4314, 4324, 4334, 4344}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;n=6, m=3, size=113 (&lt;em&gt;LW(6,3)&lt;/em&gt; = 116):&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{001000, 001100, 001101, 001102, 001200, 001201, 001202, 002000, 002100,
 002101, 002102, 002200, 002201, 002202, 010102, 011100, 011101, 011102,
 011110, 011111, 011200, 011201, 011202, 011210, 011211, 012100, 012101,
 012102, 012110, 012111, 012112, 012200, 012201, 012202, 012210, 012211,
 012220, 020100, 020102, 020110, 020120, 020200, 020210, 020220, 021100,
 021101, 021102, 021110, 021111, 021120, 021121, 021200, 021201, 021202,
 021210, 021211, 022100, 022101, 022102, 022110, 022111, 022112, 022120,
 022121, 022200, 022201, 022202, 022211, 022212, 101000, 101100, 101200,
 101201, 101202, 102000, 102100, 102200, 102201, 102202, 111200, 111201,
 111202, 111210, 111211, 112200, 112201, 112202, 112210, 112211, 112220,
 121200, 121201, 121202, 121210, 121211, 122120, 122121, 122211, 122212,
 212200, 212201, 212202, 212210, 212211, 212220, 222100, 222101, 222102,
 222200, 222201, 222202, 222211, 222212}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;n=12, m=2, size=334 (&lt;em&gt;LW(12,2)&lt;/em&gt; = 335):&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{000001000011, 000010000000, 000010000001, 000010000011, 000010000101,
 000100000101, 000100001001, 000101000011, 000101001011, 000110000001,
 000110000011, 000110000101, 000110000111, 000110001001, 000110001011,
 000110001101, 000110001111, 000110010001, 000110010011, 000110010101,
 000110010111, 000110011001, 000110011011, 000110011101, 000110011111,
 000111000011, 000111001011, 001000001001, 001000010001, 001001000011,
 001001001011, 001001010011, 001010000001, 001010000011, 001010000101,
 001010001001, 001010001011, 001010010001, 001010010011, 001010010101,
 001100000001, 001100000101, 001100001001, 001100001101, 001100010001,
 001100010101, 001100011101, 001101000011, 001101001011, 001101010011,
 001110000001, 001110000011, 001110000101, 001110001001, 001110001011,
 001110001101, 001110001111, 001110010001, 001110010011, 001110010101,
 001110011001, 001110011011, 001110011101, 001110011111, 001111000000,
 001111000011, 001111001011, 001111010011, 010000010001, 010001000011,
 010001010011, 010010000001, 010010000011, 010010000101, 010010010001,
 010010010011, 010010010101, 010010100011, 010100000001, 010100000101,
 010100001001, 010100010001, 010100010101, 010101000011, 010101001011,
 010101010011, 010110000001, 010110000011, 010110000101, 010110000111,
 010110001001, 010110001011, 010110001101, 010110001111, 010110010001,
 010110010011, 010110010101, 010110010111, 010110011001, 010110011011,
 010110011101, 010110011111, 010110100011, 010110100111, 010110101011,
 010111000011, 010111001011, 010111010011, 010111011011, 010111100011,
 010111101011, 010111111011, 011000000000, 011000000001, 011000001001,
 011000010001, 011001000011, 011001001011, 011001010011, 011001011011,
 011001101011, 011001111011, 011010000001, 011010000011, 011010000101,
 011010001001, 011010001011, 011010010001, 011010010011, 011010010101,
 011010011001, 011010011011, 011010100011, 011010101011, 011100000000,
 011100000001, 011100000101, 011100001001, 011100010001, 011100010101,
 011100011101, 011101000011, 011101001011, 011101010011, 011101011011,
 011101111011, 011110000011, 011110000101, 011110001001, 011110001011,
 011110010001, 011110010011, 011110010101, 011110011001, 011110011011,
 011110011101, 011110011111, 011110100011, 011110101011, 011111000011,
 011111001011, 011111010011, 011111011011, 011111100011, 011111101011,
 011111111011, 100001000011, 100010000000, 100010000001, 100010000011,
 100010000101, 100010100011, 100100000000, 100100000001, 100100000101,
 100100001001, 100101000011, 100101001011, 100110000001, 100110000011,
 100110000101, 100110000111, 100110001001, 100110001011, 100110001101,
 100110001111, 100110100011, 100110100111, 100110101011, 100111000011,
 100111001011, 100111100011, 100111101011, 101000000000, 101000000001,
 101000001001, 101000010001, 101001000011, 101001001011, 101001010011,
 101010000001, 101010000011, 101010000101, 101010001001, 101010001011,
 101010010001, 101010010011, 101010010101, 101010100011, 101010101011,
 101100000001, 101100000101, 101100001001, 101100001101, 101100010001,
 101100010101, 101100011101, 101101000011, 101101001011, 101101010011,
 101101011011, 101110000001, 101110000011, 101110000101, 101110001001,
 101110001011, 101110001101, 101110001111, 101110010001, 101110010011,
 101110010101, 101110011001, 101110011011, 101110011101, 101110011111,
 101110100011, 101110101011, 101111000000, 101111000011, 101111001011,
 101111010011, 101111100011, 101111101011, 101111111011, 110000010001,
 110001000011, 110001010011, 110010000001, 110010000011, 110010000101,
 110010010001, 110010010011, 110010010101, 110010100011, 110100000001,
 110100000101, 110100001001, 110100010001, 110100010101, 110101000011,
 110101001011, 110101010011, 110110000001, 110110000011, 110110000101,
 110110000111, 110110001001, 110110001011, 110110001101, 110110001111,
 110110010001, 110110010011, 110110010101, 110110010111, 110110011001,
 110110011011, 110110011101, 110110011111, 110110100011, 110110100111,
 110110101011, 110111000011, 110111001011, 110111010011, 110111010111,
 110111011011, 110111100011, 110111101011, 110111111011, 111000001001,
 111000010001, 111001000011, 111001001011, 111001010011, 111001101011,
 111001111011, 111010000001, 111010000011, 111010000101, 111010001001,
 111010001011, 111010010001, 111010010011, 111010010101, 111010100011,
 111010101011, 111100000101, 111100001001, 111100010001, 111100010101,
 111101000011, 111101001011, 111101010011, 111110000000, 111110000001,
 111110000011, 111110000101, 111110001001, 111110001011, 111110010001,
 111110010011, 111110010101, 111110011001, 111110011011, 111110011101,
 111110011111, 111110100011, 111110101011, 111111000011, 111111001011,
 111111010011, 111111100011, 111111101011, 111111111011}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:2&quot;&gt;
      &lt;p&gt;Eastman, W. L., On the Construction of Comma-Free Codes, IEEE Trans. IT-11 (1965), pp 263-267. &lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt; &lt;a href=&quot;#fnref:2:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;sup&gt;2&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:1&quot;&gt;
      &lt;p&gt;&lt;a href=&quot;https://www.cambridge.org/core/journals/canadian-journal-of-mathematics/article/commafree-codes/B78C35132E2BCD4A14459BE6A142FF30&quot;&gt;Golumb, S. W., B. Gordon, and L. R. Welch, Comma-free codes, Can. J. Math, vol. 10, 1958, pp 202-209.&lt;/a&gt; &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
        <pubDate>Wed, 20 Jan 2021 08:28:00 -0500</pubDate>
        <link>http://blog.aaw.io/2021/01/20/comma-free-codes.html</link>
        <guid isPermaLink="true">http://blog.aaw.io/2021/01/20/comma-free-codes.html</guid>
        
        
      </item>
    
      <item>
        <title>Twenty Questions with z3</title>
        <description>&lt;p&gt;Don Knuth’s &lt;a href=&quot;https://www.pearson.com/store/p/the-art-of-computer-programming-volume-4-fascicle-5-mathematical-preliminaries-redux-introduction-to-backtracking-dancing-links/P100000291857/9780134671796&quot;&gt;Volume 4, Fascicle 5 of The Art of Computer Programming&lt;/a&gt; has some great combinatorial
puzzles in the exercises, including a variant of a puzzle called &lt;a href=&quot;http://www.icynic.com/~don/20q4.html&quot;&gt;“Twenty Questions”&lt;/a&gt; invented by Donald Woods.&lt;/p&gt;

&lt;p&gt;Donald Woods has written up &lt;a href=&quot;http://www.icynic.com/~don/20qintro.html&quot;&gt;some history of the problem&lt;/a&gt; that probably serves as
a better introduction than I could give. Knuth introduces the puzzle as an exercise in backtracking (and has written
a fast backtracking solver for a variant of the problem &lt;a href=&quot;https://www-cs-faculty.stanford.edu/~knuth/programs/back-20q.w&quot;&gt;here&lt;/a&gt;), but you can also solve Twenty Questions using a
SAT solver, and that’s what I’ll describe in this post.&lt;/p&gt;

&lt;p&gt;I’ll use &lt;a href=&quot;https://github.com/Z3Prover/z3&quot;&gt;z3&lt;/a&gt; (with its Python frontend) to find the solution to the puzzle. z3 is technically a little more than
just a SAT solver, but the encoding of the problem in this post could easily be mapped down to a “pure” boolean formula
and fed to a SAT solver if you were patient and careful enough.&lt;/p&gt;

&lt;h1 id=&quot;the-questions&quot;&gt;The Questions&lt;/h1&gt;

&lt;p&gt;The questions start off easy, but the first few answers clearly depend on answers to &lt;em&gt;other&lt;/em&gt; questions:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;1. The first question whose answer is A is:

   (A) 1  (B) 2  (C) 3  (D) 4  (E) 5

2. The next question with the same answer as this one is:

   (A) 4  (B) 6  (C) 8  (D) 10  (E) 12
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;But wait, it gets harder! Instead of one question referencing another’s answer, some questions reference the
distribution of all answers to the entire set of questions:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;7. The answer that appears most often (possibly tied) is:

   (A) A  (B) B  (C) C  (D) D  (E) E

8. Ignoring those that occur equally often, the answer that appears least often is:

   (A) A  (B) B  (C) C  (D) D  (E) E

...

18. The number of prime-numbered questions whose answers are vowels is:

   (A) prime  (B) square  (C) odd  (D) even  (E) zero
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Finally, question 20 doesn’t just require you to know answers to other questions in the quiz,
you have to know the optimal score over any set of answers to the quiz:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;20. The maximum score that can be achieved on this test is:

   (A) 18  (B) 19  (C) 20  (D) indeterminate
   (E) achievable only by getting this question wrong
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You might want to leave question 20 out and solve 1-19 separately, then use the results
to figure out 20. But remember, some of the first 19 questions refer to the distribution of
answers on the quiz, which includes the answer to question 20!&lt;/p&gt;

&lt;h1 id=&quot;using-z3-to-find-solutions&quot;&gt;Using z3 to find solutions&lt;/h1&gt;

&lt;p&gt;My general idea in encoding this problem as a boolean formula is:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Start by defining 100 variables: x1a, x1b, x1c, x1d, x1e, x2a, x2b, …, x20e. x1a means “Question 1 is marked A”, and so on.&lt;/li&gt;
  &lt;li&gt;Make sure that each question has exactly one answer by adding some constraints to x1a-x1e, x2a-x2e, etc.&lt;/li&gt;
  &lt;li&gt;Define 20 more variables: x1, x2, x3, …, x20. x1 means “The answer to question 1 is correct”. Each of these is defined by an
expression involving the original 100 variables that represent answers to the questions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then we just let z3 run and try to satisfy as many of x1, x2, …, x20 as it can and interpret the
results.&lt;/p&gt;

&lt;h1 id=&quot;the-encoding&quot;&gt;The Encoding&lt;/h1&gt;

&lt;p&gt;My program starts off by declaring the boolean variables, something like:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;from z3 import *

x1 = Bool(&apos;x1&apos;)
...
x20 = Bool(&apos;x20&apos;)

x1a = Bool(&apos;x1a&apos;)
...
x20e = Bool(&apos;x20e&apos;)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I also want to write some helper functions that iterate over variables and answers, so I’ll define:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;answers = [None]
answers.append(dict(zip([&apos;A&apos;,&apos;B&apos;,&apos;C&apos;,&apos;D&apos;,&apos;E&apos;],
                        [x1a, x1b, x1c, x1d, x1e])))
...
answers.append(dict(zip([&apos;A&apos;,&apos;B&apos;,&apos;C&apos;,&apos;D&apos;,&apos;E&apos;],
                        [x20a, x20b, x20c, x20d, x20e])))
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;so that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;answers[7][&apos;D&apos;]&lt;/code&gt; gives you &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;x7d&lt;/code&gt;, for example. Also, there’s&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;correct = [None] + \
          [x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,x17,x18,x19,x20]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;so that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;correct[13]&lt;/code&gt; is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;x13&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I need to treat booleans as integers sometimes, so I do that with:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;def btoi(x): return If(x,1,0)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Finally, I want to reduce some sequences of expressions using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;And&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Or&lt;/code&gt;, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;+&lt;/code&gt;, but functional programming
is hard to read in Python, so I’ll use a few more helper functions:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;def SumOf(xs): return reduce(lambda x,y: x+y, xs)
def AndOf(xs): return reduce(lambda x,y: And(x,y), xs)
def OrOf(xs): return reduce(lambda x,y: Or(x,y), xs)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now we can start defining x1, x2, etc. in terms of the answers.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# 1. The first question whose answer is A is:
#     (A) 1  (B) 2  (C) 3  (D) 4  (E) 5

s.add(x1 == Or(x1a,
               And(x1b,x2a),
               And(x1c,x3a,Not(x2a)),
               And(x1d,x4a,Not(x2a),Not(x3a)),
               And(x1e,x5a,Not(x2a),Not(x3a),Not(x4a))))
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;z3 and Python make it easy to express some of the more complicated constraints:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# 3. The only two consecutive questions with identical answers are questions:
#    (A) 15 and 16  (B) 16 and 17  (C) 17 and 18  (D) 18 and 19  (E) 19 and 20

def same_answer(i,j):
    return Or(And(answers[i][&apos;A&apos;],answers[j][&apos;A&apos;]),
              And(answers[i][&apos;B&apos;],answers[j][&apos;B&apos;]),
              And(answers[i][&apos;C&apos;],answers[j][&apos;C&apos;]),
              And(answers[i][&apos;D&apos;],answers[j][&apos;D&apos;]),
              And(answers[i][&apos;E&apos;],answers[j][&apos;E&apos;]))

s.add(x3 == Or(And(x3a, same_answer(15, 16),
                   AndOf(Not(same_answer(i,i+1)) for i in range(1,20) if i != 15)),
               And(x3b, same_answer(16, 17),
                   AndOf(Not(same_answer(i,i+1)) for i in range(1,20) if i != 16)),
               And(x3c, same_answer(17, 18),
                   AndOf(Not(same_answer(i,i+1)) for i in range(1,20) if i != 17)),
               And(x3d, same_answer(18, 19),
                   AndOf(Not(same_answer(i,i+1)) for i in range(1,20) if i != 18)),
               And(x3e, same_answer(19, 20),
                   AndOf(Not(same_answer(i,i+1)) for i in range(1,20) if i != 19))))
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;A few of these were a little tricky. Question 8 wants the answer that occurs least often
among all answers that don’t occur the same number of times as another answer. So if A and B are both chosen 3 times
and C is chosen 4 times, C would be the correct answer.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# 8. Ignoring those that occur equally often, the answer that appears least
#    often is:
#    (A) A  (B) B  (C) C  (D) D  (E) E

def other_answers(ans): return set([&apos;A&apos;,&apos;B&apos;,&apos;C&apos;,&apos;D&apos;,&apos;E&apos;]) - set([ans])

def answer_tally(z): return SumOf(btoi(answers[i][z]) for i in range(1,21))

def least_of_distinct(ans):
    others = other_answers(ans)
    clauses = [answer_tally(ans) != answer_tally(x) for x in others]
    for x in others:
        remains = others - set([x])
        clauses.append(Or(answer_tally(ans) &amp;lt; answer_tally(x),
                          OrOf(answer_tally(x) == answer_tally(y) for y in remains)))
    return AndOf(clauses)

s.add(x8 == Or(And(x8a, least_of_distinct(&apos;A&apos;)),
               And(x8b, least_of_distinct(&apos;B&apos;)),
               And(x8c, least_of_distinct(&apos;C&apos;)),
               And(x8d, least_of_distinct(&apos;D&apos;)),
               And(x8e, least_of_distinct(&apos;E&apos;))))
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;All of the other questions up through 19 are pretty straightforward. But what should we do about question 20?&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;20. The maximum score that can be achieved on this test is:

   (A) 18  (B) 19  (C) 20  (D) indeterminate
   (E) achievable only by getting this question wrong
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We can’t correctly grade it just based on one solution to all of x1, x2, … x19. But if
we can find at least one valid solution with the first 19 correct, then C is correct. And if we can’t find
a solution with the first 19 correct, then maybe we can find one with 18 or 17 correct and fall back on B or A.
So we’ll punt for now and define it optimistically as:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;s.add(x20 == x20c)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We’ll hope to work down from there, re-defining it as needed.&lt;/p&gt;

&lt;h1 id=&quot;finding-the-solutions&quot;&gt;Finding the Solution(s)&lt;/h1&gt;

&lt;p&gt;Once we’ve defined x1 through x20, we can use z3 to check whether our formula is satisfiable and, if so,
get a model that maps variables to a satisfying assignment:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;if s.check() == sat:
    print_solution(s.model())
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;My &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;print_solution&lt;/code&gt; just prints out all of the answers using uppercase letters if the question
is correct and lowercase otherwise. Now we can add one more constraint to maximize the score:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;s.add(SumOf(btoi(correct[i]) for i in range(1,21)) &amp;gt;= 20)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When we do that, we see there’s no satisfying assignment at 20, so we reset our expectations and re-define
x20 as:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;s.add(x20 == x20b)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We update our maximization constraint to:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;s.add(SumOf(btoi(correct[i]) for i in range(1,21)) &amp;gt;= 19)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;and then find out that there is a solution with 19 correct:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;A E D C A B C D C A C E D B C A D A A c
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;What would it mean if this were the only solution with 19 correct? Then 20(E), which says that
the maximum score is achievable only by getting 20 wrong, would be correct! And once we
knew that 20(E) was correct, maybe there would be a solution with all 20 correct. But if that optimal
solution with 20(E) correct
stands, then 20(E) (“the maximum score is achievable only by getting 20 wrong”) is necessarily incorrect!
And if we can get stuck in that kind of circular reasoning going back and forth between 20(E) being
true and false, doesn’t that mean that 20(D) (“the answer to 20 is indeterminate”) is then true?&lt;/p&gt;

&lt;p&gt;Before we go too far down that path, we need to keep looking for solutions with 19 questions correct.
Clearly, we need to iterate over all satisfying assignments at a given score to make any
sense of a solution to 20. To do that, we can modify our check/print logic:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;while s.check() == sat:
    m = s.model()
    print_solution(m)
    block_solution(s,m)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Where &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;block_solution&lt;/code&gt; adds a new clause to the solver that prohibits the most recent solution:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;def block_solution(s, m):
    ans = [v for vv in [answers[i].values() for i in range(1,21)] for v in vv]
    s.add(Not(And(AndOf(v == m[v] for v in ans),
                  AndOf(v == m[v] for v in correct[1:]))))
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now when we run the solver and iterate over all solutions with score at least 19, we get:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;A E D C A B C D C A C E D B C A D A A c
D C E A B A D C D A E D A E D B D B E e
D C E A B E B C E A B E A E D B D A b B
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Whew, so that settles it – 20(E) is incorrect since there is one way to achieve the maximum
possible score (19) without getting question 20 incorrect. And 20(D) is clearly incorrect since
20(E) is incorrect and there is an absolute achievable best score for the quiz.&lt;/p&gt;

&lt;p&gt;So B is the only correct answer for question 20 and the above three answers are the only three ways to
achieve the maximum score of 19. We’re done!&lt;/p&gt;

&lt;h1 id=&quot;final-thoughts&quot;&gt;Final Thoughts&lt;/h1&gt;

&lt;p&gt;Question 20 is supposed to
be the kicker, but question 9 is also a little weird:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;9. The sum of all question numbers whose answers are correct and the same as
   this one is in the range:
   (A) 59 to 62, inclusive
   (B) 52 to 55, inclusive
   (C) 44 to 49, inclusive
   (D) 61 to 67, inclusive
   (E) 44 to 53, inclusive
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It’s the only one of the questions other than 20 that depends on its own correctness.
You can see this in the way I encoded it:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;def answer_sum(ans):
    return SumOf(If(And(correct[i],answers[i][ans]), i, 0) for i in range(1,21))

s.add(x9 == Or(And(x9a, answer_sum(&apos;A&apos;) &amp;gt;= 59, answer_sum(&apos;A&apos;) &amp;lt;= 62),
               And(x9b, answer_sum(&apos;B&apos;) &amp;gt;= 52, answer_sum(&apos;B&apos;) &amp;lt;= 55),
               And(x9c, answer_sum(&apos;C&apos;) &amp;gt;= 44, answer_sum(&apos;C&apos;) &amp;lt;= 49),
               And(x9d, answer_sum(&apos;D&apos;) &amp;gt;= 61, answer_sum(&apos;D&apos;) &amp;lt;= 67),
               And(x9e, answer_sum(&apos;E&apos;) &amp;gt;= 44, answer_sum(&apos;E&apos;) &amp;lt;= 53)))
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When I say it “depends on its own correctness”, I just mean that x9 appears on both the
left and the right side of the == in the definition of x9 (recall that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;correct[9]&lt;/code&gt; is just x9).&lt;/p&gt;

&lt;p&gt;Think about any specific case where x9 is correct: for example, if question 9 is marked “A”
and the sum of all question numbers with A as the answer that are correct (including question 9)
is, say, 61. 9(A) is clearly correct here, but a grader would be just as correct if they marked 9
wrong: in that case, the sum of all question numbers that are correct and have A as the answer is now
61 - 9 = 52, which is no longer in the range [59, 62].&lt;/p&gt;

&lt;p&gt;Since none of the ranges in question 9 span more than 9 numbers, &lt;em&gt;any&lt;/em&gt; time question 9 is marked
correct, it can also be marked incorrect – it’s all up to the grader! This sort of choice in grading
never really comes into play since we’re always looking to maximize the score, but it does make
you think about clever alternatives for question 20 that could introduce some indeterminate
conclusions.&lt;/p&gt;

&lt;p&gt;In fact, if you look back at my definition for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;block_solution&lt;/code&gt;, you’ll see that it blocks both
the answers (x1a, x2b, etc.) and the whether or not they’re correct (x1, x2, …) when blocking
an solution. You have to do this to get correct results, otherwise the solver could come across
a solution where question 9 could be graded correct to get a score of 19 but choose to grade it
incorrect instead, giving it a score of 18. If you only block the choices of answers, that solution
gets blocked and the solver is never able to discover the “alternative grading” that would give it 19 points.&lt;/p&gt;

&lt;h1 id=&quot;more-final-thoughts&quot;&gt;More Final Thoughts&lt;/h1&gt;

&lt;p&gt;My full Python solution is &lt;a href=&quot;https://github.com/aaw/twenty-questions/blob/main/20q.py&quot;&gt;here&lt;/a&gt; if you want to run it or play around with the constraints.&lt;/p&gt;

&lt;p&gt;If you think this is interesting, you should check out Knuth’s treatment of a variant
of this problem in Exercises 7.2.2.71-72 of in &lt;a href=&quot;https://www.pearson.com/store/p/the-art-of-computer-programming-volume-4-fascicle-5-mathematical-preliminaries-redux-introduction-to-backtracking-dancing-links/P100000291857/9780134671796&quot;&gt;Volume 4, Fascicle 5 of The Art of Computer Programming&lt;/a&gt;.
The latter exercise plays around with constraints to see what happens when the answer to question
20 isn’t as clear-cut as it was in Donald Wood’s original problem.&lt;/p&gt;

&lt;p&gt;The Twenty Questions puzzle is Copyright 2000, 2001, 2015 by Donald R. Woods.&lt;/p&gt;

</description>
        <pubDate>Sun, 01 Nov 2020 16:05:32 -0500</pubDate>
        <link>http://blog.aaw.io/2020/11/01/twenty-questions.html</link>
        <guid isPermaLink="true">http://blog.aaw.io/2020/11/01/twenty-questions.html</guid>
        
        
      </item>
    
      <item>
        <title>Simulating Levenshtein Automata</title>
        <description>&lt;p&gt;A &lt;a href=&quot;https://en.wikipedia.org/wiki/Levenshtein_automaton&quot;&gt;Levenshtein Automaton&lt;/a&gt; is a finite state machine that recognizes all
strings within a given &lt;a href=&quot;https://en.wikipedia.org/wiki/Edit_distance&quot;&gt;edit distance&lt;/a&gt; from a fixed string.
Here’s a Levenshtein Automaton that accepts all
strings within edit distance 2 from “banana”:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/levtrie/nfa-banana.png&quot; alt=&quot;A Levenshtein Automata for &amp;quot;banana&amp;quot; with d=2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The epsilon transitions represent the empty string. The * transitions
are shorthand for “any character” to save space in the diagram, but the
actual automaton has one transition for every possible input character anywhere
you see a *. The automaton accepts a string &lt;em&gt;s&lt;/em&gt; exactly when
there’s a directed path from the start state on the lower left to any of the
accept states on the right such that the concatenation of all of the labels on
the path in order equals &lt;em&gt;s&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The automaton above is an &lt;a href=&quot;https://en.wikipedia.org/wiki/Nondeterministic_finite_automaton&quot;&gt;NFA&lt;/a&gt; but it looks like three
copies of a &lt;a href=&quot;https://en.wikipedia.org/wiki/Deterministic_finite_automaton&quot;&gt;DFA&lt;/a&gt; accepting the string “banana” stacked on top of each other.
Transitions between the three DFAs represent edit operations under the
&lt;a href=&quot;https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance&quot;&gt;Damerau-Levenshtein metric&lt;/a&gt;: a transition going up represents
the insertion of a character, a diagonal epsilon transition represents the
deletion of a character, and a diagonal * transition represents
a substitution.&lt;/p&gt;

&lt;p&gt;Levenshtein Automata can be used as one part of a data structure that generates
spelling corrections. The
other component is a &lt;a href=&quot;https://en.wikipedia.org/wiki/Trie&quot;&gt;Trie&lt;/a&gt; that contains all correctly spelled words.
Any word that’s accepted by both the Trie and the Levenshtein Automaton is a
word that’s correctly spelled and up to edit distance &lt;em&gt;d&lt;/em&gt; from the query.
Given a query, you’d generate a Levenshtein Automaton for that query with the
desired edit distance and then traverse both the automaton and the Trie in
parallel, yielding a word whenever you reach an accept state in the Levenshtein
Automaton and at a leaf node in the Trie at the same time.&lt;/p&gt;

&lt;p&gt;Generating a non-deterministic Levenshtein Automaton is straightforward.
The node and edge structure of the automaton above for the query “banana” isn’t a function
of the word “banana” at all – only the transition labels would be different if you
wanted to create a similar automaton accepting anything within edit distance 2 of any
other six-letter word. Increasing or decreasing the edit distance just
involves adding or removing one or more rows of identical
states. Increasing or decreasing the length of the fixed word just involves
adding or removing one or more columns.&lt;/p&gt;

&lt;p&gt;Unfortunately, even though generating a non-deterministic Levenshtein Automaton is easy,
simulating it efficiently isn’t. In general,
simulating all execution paths of an NFA with &lt;em&gt;n&lt;/em&gt; states on an input of length
&lt;em&gt;m&lt;/em&gt; can take time &lt;em&gt;O(nm)&lt;/em&gt; just to keep up with the bookkeeping:
a state in the simulation is a subset of states in the NFA and you have to
update that set of up to &lt;em&gt;n&lt;/em&gt; states &lt;em&gt;m&lt;/em&gt; times during the simulation.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.16.652&quot;&gt;Schulz and Mihov introduced Levenshtein Automata&lt;/a&gt; and showed
how to generate and simulate them in linear time in the length of an input string.
The implementation they describe involves a preprocessing step that creates a DFA
defined by a transition table whose size grows very quickly with the edit distance &lt;em&gt;d&lt;/em&gt;.
The implementation starts with a two-dimensional table from which many of the entries can
be removed because they represent dead states. For &lt;em&gt;d&lt;/em&gt;=1, a 5 &lt;em&gt;x&lt;/em&gt; 8 table
is reduced to just 9 entries, for &lt;em&gt;d&lt;/em&gt;=2, a 30 &lt;em&gt;x&lt;/em&gt; 32 table is reduced to
one with just 80 entries. For &lt;em&gt;d&lt;/em&gt;=3 and 4, the tables start with
196 &lt;em&gt;x&lt;/em&gt; 128 = 25,088 and 1352 x 512 = 692,224 entries, respectively, before
removing dead states.&lt;/p&gt;

&lt;p&gt;The Lucene project &lt;a href=&quot;http://blog.mikemccandless.com/2011/03/lucenes-fuzzyquery-is-100-times-faster.html&quot;&gt;implemented&lt;/a&gt; Schulz and Mihov’s scheme, but only for
&lt;a href=&quot;https://github.com/apache/lucene-solr/blob/master/lucene/core/src/java/org/apache/lucene/util/automaton/Lev1ParametricDescription.java&quot;&gt;&lt;em&gt;d&lt;/em&gt; = 1&lt;/a&gt; and &lt;a href=&quot;https://github.com/apache/lucene-solr/blob/master/lucene/core/src/java/org/apache/lucene/util/automaton/Lev2ParametricDescription.java&quot;&gt;&lt;em&gt;d&lt;/em&gt; = 2&lt;/a&gt;. Their implementation uses a Python script
from another project, &lt;a href=&quot;https://sites.google.com/site/rrettesite/moman&quot;&gt;Moman&lt;/a&gt;, to generate Java code with the transition
tables offline.&lt;/p&gt;

&lt;p&gt;It’s hard to beat a table-driven DFA for matching regular expressions,
but on the other hand, it’s not clear that the simulation of the Levenshtein
Automaton is the bottleneck in a spelling corrector. The size of the Levenshtein
Automaton is dwarfed by the size of the Trie containing the correctly spelled
words, and since query processing involves simulating both the Trie and the
Levenshtein Automaton in parallel, the main bottleneck in the simulation will
likely be the I/O expense of loading nodes for the Trie. Because of their high
and irregular branching factor, Tries are all but impossible to lay out in
memory with any kind of locality of reference for an arbitrary query.&lt;/p&gt;

&lt;p&gt;So maybe there’s a simpler way to simulate Levenshtein Automata that’s
theoretically slower but will give us about the same real-world performance.
Jules Jacobs recently wrote &lt;a href=&quot;http://julesjacobs.github.io/2015/06/17/disqus-levenshtein-simple-and-fast.html&quot;&gt;a post describing a pretty
substantial simplification&lt;/a&gt; that simulates an automaton using states
based on rows in the two-dimensional matrix of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Wagner%E2%80%93Fischer_algorithm&quot;&gt;Wagner-Fischer algorithm&lt;/a&gt; to
compute edit distance. The simulation takes &lt;em&gt;O(nd)&lt;/em&gt; time for an input of
length &lt;em&gt;n&lt;/em&gt;, which is essentially as good as an implementation based on
Schulz and Mihov’s scheme since &lt;em&gt;d&lt;/em&gt; is often small and fixed.&lt;/p&gt;

&lt;p&gt;You can also derive an &lt;em&gt;O(nd)&lt;/em&gt; time simulation by just directly simulating
the NFA that I described at the beginning of this post. You just need to make
a few optimizations based on the highly regular structure of this family of
NFAs, but all of the optimizations are relatively straightforward. I’ll describe
those optimizations in this post. I’ve also implemented everything I describe here
in a Go package called &lt;a href=&quot;http://github.com/aaw/levtrie&quot;&gt;levtrie&lt;/a&gt; that provides a map-like interface to a Trie
equipped with a Levenshtein Automaton.&lt;/p&gt;

&lt;h1 id=&quot;alternatives-to-levenshtein-automata&quot;&gt;Alternatives to Levenshtein Automata&lt;/h1&gt;

&lt;p&gt;First, some more background. You can skip this section and the next if you
already understand why Levenshtein Automata are a good choice for indexing
a set of words by edit distance.&lt;/p&gt;

&lt;p&gt;Edit distance is a &lt;a href=&quot;https://en.wikipedia.org/wiki/Metric_(mathematics)&quot;&gt;metric&lt;/a&gt; and there are &lt;a href=&quot;https://en.wikipedia.org/wiki/Metric_tree&quot;&gt;many data
structures&lt;/a&gt; that index keys by distance under various metrics.
Maybe the most appropriate metric tree for edit distance is the &lt;a href=&quot;https://en.wikipedia.org/wiki/BK-tree&quot;&gt;BK-Tree&lt;/a&gt;.
The BK-Tree, like other metric trees, has two big disadvantages: first, the
layout of the tree is highly dependent on the distribution and the insertion
order, so it’s hard to quote good bounds on how balanced the tree is in general.
Second, during lookups, you have to compute the distance function at each node along
the search path,
which can be expensive for an metric like edit distance that takes quadratic
time to compute (or &lt;em&gt;O(nd)&lt;/em&gt; if you optimize for computing distance at most &lt;em&gt;d&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Locality-sensitive_hashing&quot;&gt;Locality-sensitive hashing&lt;/a&gt;
is another option, but, like metric trees, even after hashing to a bucket you’re
left with a set of candidates on which you need to exhaustively calculate edit
distance. It’s also very difficult with most metrics to get anywhere close to
perfect recall with locality-sensitve hashing and perfect recall is essential
to spelling correction since there are often just a few good correction
candidates.&lt;/p&gt;

&lt;p&gt;Still another alternative is to index the &lt;a href=&quot;https://en.wikipedia.org/wiki/N-gram&quot;&gt;n-grams&lt;/a&gt; of all correctly spelled
words and put them in an inverted index. At query time, you’d break up the query string into
n-grams and search the inverted index for them all, running an actual edit distance
computation as a final pass on all of the candidates that come back. This doesn’t
always work well in practice, since, for example, if you’re trying to retrieve
“bahama” from the query “banana” (edit distance 2), none of the 3-grams match (bahama
breaks up into “bah”, “aha”, “ham”, “ama” and banana breaks up into
“ban”, “ana”, “nan”, and “ana”). Even moving down to 2-grams doesn’t
help much; only the leading 2-gram “ba” matches so you’d have to retrieve all
strings that start with “ba”
and exhaustively test edit distance on all of them to find “banana”.&lt;/p&gt;

&lt;p&gt;In contrast to all of the methods described above, using a
Trie with a Levenshtein Automaton doesn’t ever require exhaustively calculating
edit distance during lookups: the cost of computing edit distance is incremental
and shared among many candidates that share paths in the Trie. A Trie can also
efficiently return all strings that are suffixes of the query string, which
is a popular feature with most on-the-fly spelling correctors: instead of
waiting for someone to type the entire word “banona” to return the suggestion
“banana”, you can start returning suggestions as soon as they’ve typed “ban” or
even “ba” by exploring paths from those prefixes in the Trie.&lt;/p&gt;

&lt;h1 id=&quot;finding-edits-in-a-trie-without-automata&quot;&gt;Finding edits in a Trie without automata&lt;/h1&gt;

&lt;p&gt;Levenshtein Automata are used to generate an optimized Trie traversal but
you can actually build a quick-and-dirty spelling corrector using just a Trie. I’ll
walk through that construction in this section since it motivates why you’d want
to augment a Trie with a Levenshtein Automaton in the first place.&lt;/p&gt;

&lt;p&gt;Suppose that your query string is “banana”. To figure out if that exact string is
in the Trie, you’d just use the sequence of characters in the string to find a
path through the Trie:
starting from the root, transition on the “b” edge to a node one level down, then transition
on an “a” edge, then an “n” edge, and so on, until you’re at the end of the string.
If the word is in the Trie, then
at the end of the traversal you will have reached
a node that represents the last character of that word. Otherwise, you will have
stopped at some point along the way because there wasn’t an edge available to make the
transition you needed to make, in which case you know the word you’re looking up isn’t
in the Trie.&lt;/p&gt;

&lt;p&gt;Instead, if you wanted to find both exact matches to “banana” and words in the Trie
that were a few edits away,
you could extend the search process to branch out a little and try paths that
correspond to edits.
If you want to find words that are at most, say, 2 edits away from “banana”, you could
start your traversal at the root but perform the following four searches
while keeping track of an edit budget that’s initially 2:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;em&gt;Simulate no edit&lt;/em&gt;: Move from the root to the second
level of the Trie on the edge labeled “b”. Keep your edit budget at 2 and set the remaining string to match
to “anana”.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;Simulate an insertion before the first character&lt;/em&gt;: For every edge out of the root of the Trie, move
to the second level of the Trie along that edge. Decrement your edit budget to 1 and keep the remaining string
to match set to “banana”.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;Simulate a deletion of the first character&lt;/em&gt;: Don’t move from the root of the Trie at all, simply decrement your
edit budget to 1 and update the string  you want to match to “anana”.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;Simulate a substitution for the first character&lt;/em&gt;: For every edge out of the root of the Trie except
the edge labeled “b”, move to the second level of the Trie along that edge, decrement your edit budget to 1,
and update the remaining string you want to match to “anana”.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now just keep recursively applying these cases at each new node you explore and
stop the traversal once you reach an edit budget that’s negative. If you ever get to
a leaf node with a non-negative edit budget at least as big as the remaining string
length, return that string as a match.&lt;/p&gt;

&lt;p&gt;This traversal will discover all strings in the Trie that are within a fixed edit distance of
a query but the traversal does a lot of repeated work. You can generate the correctly-spelled
word “banana” from the misspelled word “banaba” using either a substitution,
a deletion followed by an insertion,
or an insertion followed by a deletion. This means that in the traversal we defined above, we’ll
visit the node in the Trie defined by “banan” at least three times from three different search paths.
The search also has degenerate paths that just
burn the error budget but do no useful work, for example a deletion followed by an insertion
of the same character. These paths just put you back in the same position the traversal started
from with a smaller edit budget.&lt;/p&gt;

&lt;p&gt;Again, because of their large branching factor, Tries don’t have good locality of reference. Each
time you follow a pointer to another node, you’re likely jumping to memory that at the very
least causes a cache miss, so popping the same state several times to explore can be expensive.
You might think you could optimize this a little by marking Trie nodes as “visited” when you first
see them and avoiding exploring visited nodes more than once. But you can also see the same node
through different search paths with different edit budgets, so you’d have to store more than
just a visited flag – you’d at least need to store the minimum edit budget that you’d visited
the node with. If you ever saw the node on a search path with a greater edit budget, you could
prune that portion of the search, but that still means that you could end up exploring a node up
to &lt;em&gt;d&lt;/em&gt; times on a search for words within with edit distance &lt;em&gt;d&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;A Levenshtein Automaton maintains all of the search state so that you never have to traverse
a path in the Trie more than once. If you use a deterministic Levenshtein Automaton like
&lt;a href=&quot;http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.16.652&quot;&gt;Schulz and Mihov’s original scheme&lt;/a&gt;, it’s really as efficient a way to encode the search
state as you can get: each transition from state to state in the automaton is just a &lt;em&gt;O(1)&lt;/em&gt;
table lookup.&lt;/p&gt;

&lt;p&gt;There’s some history of people rediscovering ways to maintain the search state
through more or less efficient means: &lt;a href=&quot;http://stevehanov.ca/blog/index.php?id=114&quot;&gt;Steve Hanov described&lt;/a&gt; a method of
keeping track of the search state using the Wagner-Fischer matrix that allows you to update
states in time &lt;em&gt;O(m)&lt;/em&gt; when searching for a string of length &lt;em&gt;m&lt;/em&gt;. The method that Jules Jacobs
describes is similar but optimized even further to get a &lt;em&gt;O(d)&lt;/em&gt; update time
for edit distance &lt;em&gt;d&lt;/em&gt;, regardless of the length of the input string. The method I’ll describe
in the next two sections also has an &lt;em&gt;O(d)&lt;/em&gt; time bound on state transitions but it isn’t
directly derived from the Wagner-Fischer edit distance algorithm.&lt;/p&gt;

&lt;h1 id=&quot;an-ond2-time-simulation&quot;&gt;An &lt;em&gt;O(nd&lt;sup&gt;2&lt;/sup&gt;)&lt;/em&gt;-time simulation&lt;/h1&gt;

&lt;p&gt;Now back to the original Levenshtein NFA construction at the beginning of this post.
Instead of creating a DFA from the NFA, we just want to simulate the DFA.
To simulate one, we need to maintain a set of active states as we read input characters, accepting
exactly when we’ve read all of the input and there’s at least one accepting state in our current set
of active states.&lt;/p&gt;

&lt;p&gt;We initialize the set of active states to contain just the NFA’s start state plus anything
reachable by an epsilon transition.
On each input character, we create an initially empty new set of active states and iterate
through all current active states, trying to take any valid
transition from each state on the current input character and adding the resulting state
and anything else reachable by epsilon transitions
to the new set of active states if we succeed. When we’re done with iterating through
all current active states, the new set of active states becomes current and we proceed
to the next input character. If we’re done reading input characters and there’s an accept
state in our set of active states, we accept, otherwise we reject.&lt;/p&gt;

&lt;p&gt;Let’s walk through a simulation of the Levenshtein NFA that accepts all words within edit
distance 2 of “banana”. We’ll feed it the input string “bahama”. The set of active states are highlighted
in blue at each step below. First, the initial state of the NFA
contains all states on the diagonal including the initial state:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/levtrie/nfa-banana-initial.png&quot; alt=&quot;A Levenshtein Automata for &amp;quot;banana&amp;quot; with d=2 in its initial state&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After consuming “b”, active states are again highlighted in blue:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/levtrie/nfa-banana-b.png&quot; alt=&quot;A Levenshtein Automata for &amp;quot;banana&amp;quot; with d=2 after consuming &amp;quot;b&amp;quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After consuming “ba”:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/levtrie/nfa-banana-ba.png&quot; alt=&quot;A Levenshtein Automata for &amp;quot;banana&amp;quot; with d=2 after consuming &amp;quot;ba&amp;quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After consuming “bah”:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/levtrie/nfa-banana-bah.png&quot; alt=&quot;A Levenshtein Automata for &amp;quot;banana&amp;quot; with d=2 after consuming &amp;quot;bah&amp;quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After consuming “baha”:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/levtrie/nfa-banana-baha.png&quot; alt=&quot;A Levenshtein Automata for &amp;quot;banana&amp;quot; with d=2 after consuming &amp;quot;baha&amp;quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After consuming “baham”:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/levtrie/nfa-banana-baham.png&quot; alt=&quot;A Levenshtein Automata for &amp;quot;banana&amp;quot; with d=2 after consuming &amp;quot;baham&amp;quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;And finally, after consuming “bahama”, a string that’s edit distance 2 from “banana”, we end up in an
accepting state:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/levtrie/nfa-banana-bahama.png&quot; alt=&quot;A Levenshtein Automata for &amp;quot;banana&amp;quot; with d=2 after consuming &amp;quot;bahama&amp;quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We want to bound the time complexity of simulating an NFA from this family of Levenshtein NFAs.
One way to do this is to bound
the maximum number of possible active states, since simulating the NFA on an input of length
&lt;em&gt;n&lt;/em&gt; involves updating the entire set of active states &lt;em&gt;n&lt;/em&gt; times. Since a Levenshtein NFA created for
a word of length &lt;em&gt;m&lt;/em&gt; and edit distance &lt;em&gt;d&lt;/em&gt; has &lt;em&gt;(m + 1) * (d + 1)&lt;/em&gt;
states, this means that the worst-case time complexity for simulating that NFA on an input of
length &lt;em&gt;n&lt;/em&gt; could be as bad as
&lt;em&gt;O(nmd)&lt;/em&gt;. We can get a better bound by being a little more careful in
our simulation.&lt;/p&gt;

&lt;p&gt;The first thing to notice about the family of Levenshtein NFAs is that the diagonals contain paths
of epsilon transitions all the way up. This means that
any time a state is active, all other states further up on the same diagonal are active. Instead of
keeping track of the set of active states, then, we can just keep track of the lowest active state on
every diagonal. We’ll call this minimum active index the “floor” of the diagonal.&lt;/p&gt;

&lt;p&gt;We’ll start numbering floors from the bottom: any diagonal with a state active in the bottom
row of NFA states has floor 0. Since there are &lt;em&gt;d + 1&lt;/em&gt; rows in the NFA, the maximum floor a
diagonal can have is &lt;em&gt;d&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;To make sure that every state in the NFA is contained in some diagonal, we just need to create a
few fake diagonals that extend out to the left a little bit to add to the set of diagonals that
are anchored by the states in the bottom level of the NFA:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/levtrie/nfa-banana-fake-diags.png&quot; alt=&quot;Identifying diagonals in a Levenshtein Automata&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Indexed like this, a Levenshtein NFA has &lt;em&gt;m + d + 1&lt;/em&gt; diagonals. This means that any active
state in the NFA can be represented by a set of at most &lt;em&gt;m + d + 1&lt;/em&gt; diagonal floors.&lt;/p&gt;

&lt;p&gt;Actually, we never end up needing to consider all &lt;em&gt;m + d + 1&lt;/em&gt; diagonals at once.
There’s only ever one diagonal with floor 0 at any
point in time, since consuming an input character while one diagonal has a floor at position 0
transfers the state to position 1 in the previous diagonal, position 1 in the current diagonal,
and possibly to position 0 in the next diagonal:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/levtrie/level-0-transition.png&quot; alt=&quot;A single level-0 transition in a Levenshtein Automaton&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This fact generalizes to higher positions in the set of diagonals: there’s always a sliding window of
at most &lt;em&gt;2d + 1&lt;/em&gt; diagonals that are active at level &lt;em&gt;d&lt;/em&gt; or lower. You can prove this by
induction on &lt;em&gt;d&lt;/em&gt; where the general induction step looks at a window of &lt;em&gt;2d - 1&lt;/em&gt;
diagonals at level &lt;em&gt;d - 1&lt;/em&gt; and shows that they can expand to a window of at most &lt;em&gt;2d + 1&lt;/em&gt;
at level &lt;em&gt;d&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;A particular example of the general case is illustrated below, with a starting state illustrated by
all light blue and dark blue nodes. These light blue and dark blue nodes cover 5 diagonals at level 2
or lower. The green nodes illustrate all new nodes that can be active after a transition from
this state. The green and dark blue nodes together illustrate possible active nodes after the
transition, covering 7 diagonals at level 3 or lower:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/levtrie/multi-level-transition.png&quot; alt=&quot;A general transition in a Levenshtein Automaton&quot; /&gt;&lt;/p&gt;

&lt;p&gt;All of this means that instead of tracking all &lt;em&gt;m + d - 1&lt;/em&gt; diagonals, we only ever need to track
a set of &lt;em&gt;2d + 1&lt;/em&gt; diagonal positions plus an offset into the NFA. The sliding window of diagonals that
we track moves through the NFA and we increment the offset by one each time we consume an
input character.&lt;/p&gt;

&lt;p&gt;To update a single diagonal when we read an input character, we need to take the minimum of:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The previous floor of the diagonal, plus one (shown in red below).&lt;/li&gt;
  &lt;li&gt;The previous floor of the next diagonal, plus one (shown in green below).&lt;/li&gt;
  &lt;li&gt;The smallest index in the previous diagonal that has a transition on the input character, if any (shown in dark blue below).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The figure below shows all three of the contributions to a single diagonal’s update:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/levtrie/contributions-to-diagonal-update.png&quot; alt=&quot;Contributions to a single diagonal update&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Since we’re storing the state as a collection of &lt;em&gt;2d + 1&lt;/em&gt; diagonal floors plus an offset,
the first two items in the list above (red and green updates in the figure above) can be computed in constant time.
The third item can be computed by iterating over all &lt;em&gt;d + 1&lt;/em&gt; horizontal transitions
from the previous diagonal to see if any match the current input character.&lt;/p&gt;

&lt;p&gt;Here’s pseudocode for our current algorithm for a fixed value of &lt;em&gt;d&lt;/em&gt;
with a few details omitted:&lt;/p&gt;

&lt;pre&gt;
// Returns a structure representing an initial state for a Levenshtein NFA. The
// State structure just contains:
//  * d, the edit distance.
//  * An array of 2*d + 1 integers representing floors.
//  * An integer offset into the underlying string being matched.
State InitialState(d) { ... }

// Returns the floor of the ith diagonal in state s. Returns d + 1 if i is
// out of bounds.
int Floor(State s, int i) { ... }

// Returns the smallest index in the ith diagonal of state s that has a
// transition on character ch. If none exists, returns d + 1.
int SmallestIndexWithTransition(State s, string w, int i, char ch) { ... }

// Set the ith diagonal floor in state s to x.
void SetDiagonal(State* s, int i, int x) { ... }

// Returns true exactly when the given state is an accepting state.
bool IsAccepting(State s) { ... }

// Simulate the Levenshtein NFA for string w and distance d on the string u.
bool SimulateNFA(string w, int d, string u) {
  State s = InitialState(d)
  for each ch in u {
    State t = s
    t.offset = s.offset + 1
    for i from 0 to 2*d + 1 {
      int x = Floor(s, i + 1) + 1                       // Diagonal
      int y = Floor(s, i + 2) + 1                       // Up
      int z = SmallestIndexWithTransition(s, w, i, ch)  // Horizontal
      SetDiagonal(&amp;amp;t, i, Min(x, y, z))
    }
    s = t
  }
  return IsAccepting(s)
}
&lt;/pre&gt;

&lt;p&gt;For each of the &lt;em&gt;n&lt;/em&gt; characters in the input string, we iterate over the &lt;em&gt;2d + 1&lt;/em&gt;
diagonals in the state and compute the three components of the diagonal update.
Two of the three components (&lt;em&gt;x&lt;/em&gt; and &lt;em&gt;y&lt;/em&gt; in the pseudocode above) are floor
computations which are really just array accesses, so they’re both constant
time operations. The third component (&lt;em&gt;z&lt;/em&gt; in the pseudocode above, the result
of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SmallestIndexWithTransition&lt;/code&gt;) is the most expensive, taking time &lt;em&gt;O(d)&lt;/em&gt; to
compute, so the inner loop takes time &lt;em&gt;O(d&lt;sup&gt;2&lt;/sup&gt;)&lt;/em&gt; and the entire
simulation takes time &lt;em&gt;O(nd&lt;sup&gt;2&lt;/sup&gt;)&lt;/em&gt;.&lt;/p&gt;

&lt;h1 id=&quot;an-ond-time-simulation&quot;&gt;An &lt;em&gt;O(nd)&lt;/em&gt;-time simulation&lt;/h1&gt;

&lt;p&gt;To get from &lt;em&gt;O(d&lt;sup&gt;2&lt;/sup&gt;)&lt;/em&gt; to &lt;em&gt;O(d)&lt;/em&gt; time per state transition and &lt;em&gt;O(nd)&lt;/em&gt;
for the entire simulation, there’s one final trick: making the
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SmallestIndexWithTransition&lt;/code&gt; function in the pseudocode above run in constant
time.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SmallestIndexWithTransition&lt;/code&gt; needs to be called on each of the at most &lt;em&gt;2d + 1&lt;/em&gt;
active diagonals to find the smallest index above the floor of the diagonal with
a horizontal transition on the current input character. Luckily, there’s a lot of overlap
between the horizontal transitions of two consecutive diagonals: if you read the
horizontal transitions of any diagonal from bottom to top, they form a substring
of length &lt;em&gt;d + 1&lt;/em&gt; of the string the automaton was generated with. Any two consecutive
diagonals have an overlap of &lt;em&gt;d&lt;/em&gt; characters in these substrings:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/levtrie/jump-array.png&quot; alt=&quot;Overlap between horizontal transitions between consecutive diagonals&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The horizontal transitions from a set of &lt;em&gt;2d + 1&lt;/em&gt; consecutive diagonals span a
substring of length at most &lt;em&gt;3d + 2&lt;/em&gt;. This overlap between the horizontal transitions of
consecutive diagonals means
that instead of iterating up each diagonal doing &lt;em&gt;O(d)&lt;/em&gt; work to figure out the
first applicable horizontal transition, if any, for each of the &lt;em&gt;2d + 1&lt;/em&gt; diagonals,
we can instead precompute all the transitions on the substring of length &lt;em&gt;3d + 2&lt;/em&gt; once
and use that precomputed result to calculate &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SmallestIndexWithTransition&lt;/code&gt; on each
diagonal.&lt;/p&gt;

&lt;p&gt;This precomputation just involves calculating, for each index in the &lt;em&gt;3d + 2&lt;/em&gt;
character window, the next index in the window that matches the current input
character. For example, if the window was the string “cookbook”:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    [c][o][o][k][b][o][o][k]
     0  1  2  3  4  5  6  7
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;our precomputed jump array for the character ‘k’ would look like:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    [3][3][3][3][7][7][7][7]
     0  1  2  3  4  5  6  7
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Each index in the jump array tells us the next index of the character ‘k’ in the
window. If we look in the jump array at the index of a particular diagonal plus its
floor, the jump array tells us the next applicable horizontal transition on that diagonal.&lt;/p&gt;

&lt;p&gt;The jump array needs to be initialized once per transition but initialization only takes time
&lt;em&gt;O(d)&lt;/em&gt; and all subsequent calls to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SmallestIndexWithTransition&lt;/code&gt;
can then be implemented with just a constant-time access into the jump array. Now everything
inside the for loop that iterates over &lt;em&gt;2d + 1&lt;/em&gt; diagonals runs in constant time and computing
a transition of the NFA only takes time &lt;em&gt;O(d)&lt;/em&gt;.&lt;/p&gt;

&lt;h1 id=&quot;final-thoughts&quot;&gt;Final Thoughts&lt;/h1&gt;

&lt;p&gt;I’ve implemented all of this in the Go package &lt;a href=&quot;http://github.com/aaw/levtrie&quot;&gt;levtrie&lt;/a&gt; and the code in that
package is a better place to look if you’re interested in more details after reading
this post.&lt;/p&gt;

&lt;p&gt;I took some shortcuts
there to make the code a little more readable at the expense of some unnecessary
memory bloat. In particular, the Trie implementation is very simple: each node keeps
a map of runes to children and no intermediate nodes are suppressed. The key for each
node, implicitly defined by the path through the Trie, is duplicated in the key-value
struct stored at each node.&lt;/p&gt;

&lt;p&gt;If you’re looking to implement something similar and speed it up,
the first thing to consider is replacing the basic Trie with a &lt;a href=&quot;https://en.wikipedia.org/wiki/Radix_tree&quot;&gt;Radix&lt;/a&gt; or &lt;a href=&quot;http://cr.yp.to/critbit.html&quot;&gt;Crit-bit tree&lt;/a&gt;.
A Crit-bit tree will dramatically reduce the memory usage and the number of
node accesses needed for Trie traversals, but it will also complicate the logic of
the parallel search through the Trie and Levenshtein Automaton. Instead of iterating
over all runes emanating from a node in the Trie and matching those up with transitions
in the Levenshtein Automata, you’ll have to do something more careful. You could
add some logic to traverse the Crit-bit tree from a node, simulating an iteration over
all single-character transitions. Multi-byte characters make this a little more tricky
than an ASCII alphabet. You might have an easier time converting the the Levenshtein
Automata itself to have an alphabet of bytes instead of multibyte characters, which
would then match up better with a Radix tree with byte transitions.&lt;/p&gt;

</description>
        <pubDate>Fri, 25 Aug 2017 17:58:17 -0400</pubDate>
        <link>http://blog.aaw.io/2017/08/25/levenshtein-automata.html</link>
        <guid isPermaLink="true">http://blog.aaw.io/2017/08/25/levenshtein-automata.html</guid>
        
        
      </item>
    
      <item>
        <title>Regular Expression Search via Graph Cuts</title>
        <description>&lt;p&gt;Google used to offer a search engine called
&lt;a href=&quot;https://en.wikipedia.org/wiki/Google_Code_Search&quot;&gt;Code Search&lt;/a&gt; which
let you use regular expressions to search code.
I never thought Code Search was doing anything much more sophisticated than
something along the lines of a fast, distributed grep until Russ Cox explained
how it worked in a &lt;a href=&quot;https://swtch.com/~rsc/regexp/regexp4.html&quot;&gt;blog post&lt;/a&gt;
and released &lt;a href=&quot;https://github.com/google/codesearch&quot;&gt;codesearch&lt;/a&gt;, a smaller-scale
implementation.
Both the post and the code are fascinating – it turns out that Code Search
was doing something much more sophisticated than a distributed grep.&lt;/p&gt;

&lt;p&gt;The big idea in codesearch is an engine that translates a large class of regular
expressions into queries that can be run against a standard inverted index.
In this post, I’m going to describe a different implementation of such an engine
using some of the same ideas in
codesearch along with a well-known algorithm for finding the minimum-weight
node cut in a graph. I think the result is a little bit simpler conceptually than
the query-building technique that codesearch uses, particularly if you
understand textbook regular expressions but don’t know a lot about the
internals of any particular regular expression library.&lt;/p&gt;

&lt;p&gt;The implementation I’ll describe is available as a Go package at
&lt;a href=&quot;https://github.com/aaw/regrams&quot;&gt;https://github.com/aaw/regrams&lt;/a&gt;. It’s a few hundred lines of code and the benchmarks
show it running only about 4-5 times slower than codesearch’s regular
expression-to-query translation. Both engines run on the order of microseconds for
individual queries, so a few times slower is still very usable for a search engine.&lt;/p&gt;

&lt;h1 id=&quot;trigram-queries-and-regular-expression-search&quot;&gt;Trigram queries and regular expression search&lt;/h1&gt;

&lt;p&gt;First, a little background about codesearch’s approach to regular expression search.&lt;/p&gt;

&lt;p&gt;Before it can process queries, codesearch creates an inverted index from all the
files you want to search. The index contains all overlapping substrings of length 3
(“trigrams”) that occur in any of the files.
If you index a file called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;greetings.txt&lt;/code&gt; which contains just the
string &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Hello, world!&lt;/code&gt;,
the resulting trigram index would contain entries for
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Hel&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ell&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;llo&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lo,&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;o,_&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;,_w&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_wo&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wor&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;orl&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rld&lt;/code&gt;, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ld!&lt;/code&gt;.
When you look up any of those trigrams in the index,
you’ll get a list of files: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;greetings.txt&lt;/code&gt; and any other files that contain
the trigram you’ve looked up. At query time, codesearch extracts trigrams from the regular expression
and uses those trigrams to look up some candidate documents in the index.&lt;/p&gt;

&lt;p&gt;The trigram queries used by codesearch are just trigrams combined with ANDs and ORs.
For a simple regular expression like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Hello&lt;/code&gt;, codesearch might generate the trigram
query &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Hel AND ell AND llo&lt;/code&gt;. Looking that query up in the index would return all of
the indexed files that contain all three of the trigrams &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Hel&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ell&lt;/code&gt;, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;llo&lt;/code&gt;.
A more complicated regular expression like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;abc(d|e)&lt;/code&gt; might generate the trigram
query &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;abc AND (bcd OR bce)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Sometimes there’s no good trigram query for a regular expression. This can happen
if the regular expression accepts strings of length less than 3. The regular
expression &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[0-9]+&lt;/code&gt;, for example, accepts strings of digits of length 1 and 2 so
we can’t use a trigram query to search for files that match that expression.
There also may not be a good trigram query if the regular expression accepts too many
different strings. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[a-z]{3}&lt;/code&gt; is a short regular expression but it needs an enormous
trigram query with 17,576 trigrams OR-ed together to capture its meaning. If you leave
off any of those 17,576 trigrams from the query, you risk false negatives: files that
match the query but aren’t returned from your trigram query. You’d be better off
grepping files in most cases than running such a large query.&lt;/p&gt;

&lt;p&gt;Finally, even when codesearch can come up with a good trigram query, it can get false
positives in its result set from the trigram index. The regular expression &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Hello&lt;/code&gt;’s trigram query
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Hel AND ell AND llo&lt;/code&gt; matches not just files containing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Hello&lt;/code&gt; but also files that
contain things like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Help smell this fellow&lt;/code&gt;. Since false positives like this are
possible, a regular expression search based on trigram queries will need to
post-process trigram query results by running the regular expression over each file
that comes back. The goal, then, is just to generate a small enough set of candidate
documents so that the query generation, lookup in the inverted index, and post-processing
with the original regular expression runs much more quickly than exhaustive grepping over
files.&lt;/p&gt;

&lt;p&gt;codesearch generates these trigram queries by parsing the regular expression using Go’s
&lt;a href=&quot;https://golang.org/pkg/regexp/syntax/&quot;&gt;regexp/syntax&lt;/a&gt;, then analyzing the
parsed regular expression and converting it into structures
that describe what trigrams each portion of the regular expresssion can match.
These structures are then combined
based on a table of rules derived from the meaning of the regular expression operations
involved. The structures maintained during this process
keep track of several attributes of the pieces of the regular expression
their analyzing: whether that portion matches the empty string as well as sets
of trigrams that can match exactly as well as prefixes
and suffixes. The whole process is quick and, along with some boolean simplification of
the resulting trigram queries, generates succinct queries without false negatives.&lt;/p&gt;

&lt;h1 id=&quot;generating-trigram-queries-with-graph-cuts&quot;&gt;Generating trigram queries with graph cuts&lt;/h1&gt;

&lt;p&gt;Instead of generating trigram queries by analyzing the structure of the regular
expression, &lt;a href=&quot;https://github.com/aaw/regrams&quot;&gt;regrams&lt;/a&gt; transforms the regular expression
into an &lt;a href=&quot;https://en.wikipedia.org/wiki/Nondeterministic_finite_automaton&quot;&gt;NFA&lt;/a&gt; and
analyzes that.&lt;/p&gt;

&lt;p&gt;regrams uses an NFA with some extra annotations on the states. Getting
to an NFA from a regular expression in Go is pretty simple with the &lt;a href=&quot;https://golang.org/pkg/regexp/syntax/&quot;&gt;regexp/syntax&lt;/a&gt;
package: running &lt;a href=&quot;https://golang.org/pkg/regexp/syntax/#Parse&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Parse&lt;/code&gt;&lt;/a&gt; on the
string, then &lt;a href=&quot;https://golang.org/pkg/regexp/syntax/#Regexp.Simplify&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Simplify&lt;/code&gt;&lt;/a&gt; on the
resulting expression yields a normal form that’s easy to work with. regrams massages the
simplified expression into an even simpler form that’s closer to a textbook regular
expression, containing only concatenation (.), alternation (|), and Kleene star (*)
operations on literals and empty strings. This simplified expression
might match more than the original expression but it never matches less, so it’s fine
for generating a trigram query. Finally, regrams converts the simplified regular
expression into an NFA using &lt;a href=&quot;https://en.wikipedia.org/wiki/Thompson%27s_construction&quot;&gt;Thompson’s algorithm&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Next, any state that has a literal transition gets
annotated with a set of trigrams that are reachable starting from that state. There
are a few exceptions: if we start collecting the set of trigrams but realize it’s
going to be too large, we’ll bail out and the state will get an empty set of
trigrams. Also, if we start collecting the set of trigrams but realize that you
can reach the accept state of the NFA in 2 or fewer steps, we’ll bail out, since
that means that we can’t represent the query from that node with trigrams. So we end up
with annotations on some of the nodes in the NFA that describe trigram OR queries,
but only on the nodes that are easy to write trigram OR queries for.&lt;/p&gt;

&lt;p&gt;Here’s an example NFA for the regular expression &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ab(c|d*)ef&lt;/code&gt; with trigram set
annotations in blue below each node:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/nfa-trigram-sets.png&quot; alt=&quot;An NFA with annotated trigram sets&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Notice that nodes with only epsilon transitions in the NFA above don’t get trigram
annotations and nodes that can reach the accept state in fewer than 3 literal
transitions like the node with the “e” transition and the node with the “f” transition
don’t have trigram set annotations. Every other node is annotated with the set of
trigrams that can be generated from that node by following an unlimited number of
epsilon transitions and exactly three literal transitions.&lt;/p&gt;

&lt;p&gt;Creating a trigram query from the NFA above is now just an exercise in applying
the right graph algorithm. A good trigram OR query – one that captures a set of
trigrams that must appear in any string matching the regular expression but is as
small as possible – corresponds to a minimal set of trigram-annotated nodes in the
NFA that, when removed, disconnect the initial state from the final state. In
graph theory, a set of nodes that, when removed, disconnects two nodes s and t in the
graph is called an s-t node cut.
A node cut in our NFA separating the start and accept nodes corresponds to a
complete set of trigrams that must be present in any string that
matches the regular expression: there’s no way for a string to be accepted by the
NFA but to go through one of the nodes in the cut.&lt;/p&gt;

&lt;p&gt;In the NFA above, there are only two minimal node
cuts that consist only of trigram-annotated nodes: the cut consisting of only the
node with the “a” transition and the cut consisting of only the node with the “b”
transition.&lt;/p&gt;

&lt;p&gt;Once we’ve extracted a node cut consisting only of trigram-annotated nodes, we can just OR all of
the trigrams in the cut together and, by the argument above, we’ve got a valid trigram
query for the original regular expression: at least one of those trigrams must be
present in any string that matches the regular expression. Continuing with the
example above, depending on which cut we choose, we either
get the trigram query &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;abc OR abd OR abe&lt;/code&gt; or the trigram query &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bce OR bdd OR bde OR bef&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;At this point, our query is a single big OR defined by the cut and we’ve likely used relatively few
of the trigram sets we’ve annotated the graph with. But because we’ve just isolated
a cut, that cut splits the NFA (and also the corresponding regular expression) into two parts, and if we now clean up
both of those two parts of the NFA a little, we can run the same cut analysis on each of two those parts
recursively to extract more trigram queries. We just keep isolating cuts recursively
until we can’t find a cut with trigram-annotated nodes, at which point there’s nothing good left
to generate a query with. All of the OR queries we generate like this can be
AND-ed together to create one final query.&lt;/p&gt;

&lt;p&gt;In the example NFA we’re working with, that means that if we choose the cut
with just the node with a “b” transition, it generates the trigram query &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bce OR bdd OR bde OR bef&lt;/code&gt;
and splits the NFA into two parts: the part with the “a” transition and everything
after the “b” transition node:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/nfa-trigram-sets-split.png&quot; alt=&quot;The same NFA from before, now with a cut at the node with a &amp;quot;b&amp;quot; transition removed&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We can now recursively consider both sub-NFAs. We see a single cut in the
first NFA that generates the trigram query &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;abc OR abd OR abe&lt;/code&gt; and no cut in the second
NFA that consists of just trigram annotated nodes: even if you remove both the
node with a “c” transition and the node with a “d” transition, there’s still
a path from the initial state in the sub-NFA to the accept state through the
lower-level epsilon-transition around the node with a “d” transition. Since there
are no cuts left in any of the subgraphs, our final trigram query for the entire
regular expression &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ab(c|d*)ef&lt;/code&gt; is all of the subqueries AND-ed together, which is
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(abc OR abd OR abe) AND (bce OR bdd OR bde OR bef)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The fact that we couldn’t extract a cut from the second NFA is by design: that
NFA corresponds to the regular expression &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(c|d*)ef&lt;/code&gt;, which matches the string
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ef&lt;/code&gt; that we can’t express with a trigram query.&lt;/p&gt;

&lt;h1 id=&quot;finding-minimal-node-cuts&quot;&gt;Finding minimal node cuts&lt;/h1&gt;

&lt;p&gt;So how do you find a minimal cut consisting only of trigram-annotated nodes?
If we label each node in a trigram-annotated NFA with the size of its trigram set or
with “infinity” if it doesn’t have a trigram set, then we can frame the problem
as a search for a minimum-weight node cut in the graph that separates the initial
and final state. Because of the way we’ve set up the node weights, finding the
minimum-weight node cut will tell us if we actually have a usable query: the cut
can be used to generate a query exactly when its weight is non-infinite.&lt;/p&gt;

&lt;p&gt;Finding a minimum-weight cut in a graph that separates two distinguished nodes
is a tractable optimization problem and is
especially easy in simple graphs like the NFAs that we get from regular expressions.
Minimum-weight cuts are closely related to maximum weight “flows”, and if you ever
took an algorithms course you may have run into
the &lt;a href=&quot;https://en.wikipedia.org/wiki/Max-flow_min-cut_theorem&quot;&gt;max-flow min-cut theorem&lt;/a&gt;
that formalizes this duality. If you imagine a graph as a set of pipes of differing
widths, flowing in the direction of the arrows between nodes, the max flow
represents the most amount of fluid that can flow through the pipes at any point
in time. The minimum-weight cut is a bottleneck that constrains the maximum flow you
can push through.&lt;/p&gt;

&lt;p&gt;The simplest way to find a minimum-weight cut, then, is to find a maximum-weight
flow, which really boils down to initializing all nodes with capacities as described
above (each capacity will either be infinite or the size of the trigram set) and then
repeatedly finding a path that goes from the start node to the accept node through
nodes of non-zero capacity. Every time we find such a path, we reduce the
capacity of all nodes on the path by the minimum capacity on the path.
Eventually, there are no paths left except those that go through zero-capacity nodes
and those zero-capacity nodes can be used to recover the minimal cut.&lt;/p&gt;

&lt;p&gt;There are more sophisticated ways of finding a maximum-weight flow,
but the complexity of this algorithm is never more than the number of edges in the
NFA times the maximum allowable trigram set size. Since we bound both the maximum
size of the NFA allowed and the size of the maximum trigram set in the regrams
implementation, the complexity never gets out of hand here, and in practice it’s
very quick and even out-performs some theoretically faster optimizations like the
&lt;a href=&quot;https://en.wikipedia.org/wiki/Edmonds%E2%80%93Karp_algorithm&quot;&gt;Edmonds-Karp&lt;/a&gt; search
order in my tests.&lt;/p&gt;

&lt;h1 id=&quot;examples&quot;&gt;Examples&lt;/h1&gt;

&lt;p&gt;So what do the results look like? Here are a few examples which you can play with
on your own if you have a Go development environment. Just build the regrams
commmand line wrapper and follow along:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;go get github.com/aaw/regrams
go build -o regrams github.com/aaw/regrams/cmd/regrams
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The trigram queries are written with implicit AND
and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;|&lt;/code&gt; for OR, so &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;abc AND (bcd OR bce)&lt;/code&gt; comes out looking like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;abc (bcd|bce)&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ ./regrams &apos;Hello, world!&apos;
( wo) (, w) (Hel) (ell) (ld!) (llo) (lo,) (o, ) (orl) (rld) (wor)
$ ./regrams &apos;a(bc)+d&apos;
(abc) (bcb|bcd)
$ ./regrams &apos;ab(c|d*)ef&apos;
(abc|abd|abe) (bce|bdd|bde|bef)
$ ./regrams &apos;(?i)abc&apos;
(ABC|ABc|AbC|Abc|aBC|aBc|abC|abc)
$ ./regrams &apos;abc[a-zA-Z]de(f|g)h*i{3}&apos;
(abc) (def|deg) (efh|efi|egh|egi) (fhh|fhi|fii|ghh|ghi|gii) (iii)
$ ./regrams &apos;[0-9]+&apos;  # No trigrams match single or double digit strings
Couldn&apos;t generate a query
$ ./regrams &apos;[a-z]{3}&apos;  # Too many trigrams
Couldn&apos;t generate a query
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;regrams is also available as a Go package, too: just import &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;github.com/aaw/regrams&lt;/code&gt;
and then call &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;regrams.MakeQuery&lt;/code&gt; on a string to parse a regular expression into a trigram
query. The trigram query returned is a slice-of-slices of strings, which represents a big
AND or ORs: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[[&quot;abc&quot;], [&quot;bcd&quot;, &quot;bce&quot;]]&lt;/code&gt; represents &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;abc (bcd|bce)&lt;/code&gt;.&lt;/p&gt;

&lt;h1 id=&quot;optimizations&quot;&gt;Optimizations&lt;/h1&gt;

&lt;p&gt;There’s at least one major optimization that’s possible but isn’t yet implemented
in regrams: we could extract node-disjoint paths instead of just node cuts and
get more specific queries.&lt;/p&gt;

&lt;p&gt;For example, if you ask regrams to generate a query for
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(abcde|vwxyz)&lt;/code&gt;, it’ll generate &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(abc|vwx) (bcd|wxy) (cde|xyz)&lt;/code&gt;, which isn’t as specific
as the query &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(abc bcd cde)|(vwx wxy xyz)&lt;/code&gt;. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(abc|vwx)&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(bcd|wxy)&lt;/code&gt;, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(cde|xyz)&lt;/code&gt;
represent three distinct cuts in the NFA. If we didn’t stop at node cuts, and instead
augmented the nodes in the cut with disjoint paths, we could avoid this situation
and always return the best trigram query for a regular expression. To do this, we’d
need some algorithmic version of something like &lt;a href=&quot;https://en.wikipedia.org/wiki/Menger%27s_theorem&quot;&gt;Menger’s theorem&lt;/a&gt;
that extracts node-disjoint paths from our NFAs that go through only nodes with
non-infinite capacity.&lt;/p&gt;

&lt;h1 id=&quot;related-work&quot;&gt;Related Work&lt;/h1&gt;

&lt;p&gt;codesearch isn’t the only attempt at generating trigram queries from regular
expressions. In 2002, Cho and Rajagopalan published
“&lt;a href=&quot;http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.18.6659&quot;&gt;A Fast Regular Expression Indexing Engine&lt;/a&gt;”,
which describes a search engine called FREE that shares a lot of the ideas
found in codesearch, including using an n-gram index to index the underlying
documents and generating queries against that index using some rules
based on the structure of those regular expressions. The rules are much
simpler than those used by codesearch and FREE doesn’t have an actual
implementation that I know of.&lt;/p&gt;

&lt;p&gt;Postgres also now
&lt;a href=&quot;https://www.pgcon.org/2012/schedule/events/383.en.html&quot;&gt;supports regular expression search&lt;/a&gt;
via &lt;a href=&quot;https://github.com/postgres/postgres/blob/master/contrib/pg_trgm/trgm_regexp.c&quot;&gt;an implementation by Alexander Korotkov&lt;/a&gt;
in the &lt;a href=&quot;https://www.postgresql.org/docs/9.3/static/pgtrgm.html&quot;&gt;pg_tgrm module&lt;/a&gt;.
Korotkov’s implementation apparently generates a special NFA with trigram transitions after
converting the original regular expression to an NFA, then extracts a query from
that trigram NFA. Korotkov’s implementation seems similar to regrams in that all of
the analysis is done on an NFA, but I don’t understand enough about it to say
anything more. I’d love to read a description of the technique somewhere. It seems
to generate slightly better queries than regrams based on some of the documentation, for
example generating &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(abe AND bef) OR (cde AND def)) AND efg&lt;/code&gt; from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(ab|cd)efg&lt;/code&gt;, whereas regrams
would generate &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(abe OR cde) AND (bef OR def) AND efg&lt;/code&gt; from the same regular expression.&lt;/p&gt;
</description>
        <pubDate>Fri, 10 Jun 2016 16:51:47 -0400</pubDate>
        <link>http://blog.aaw.io/2016/06/10/regrams-intro.html</link>
        <guid isPermaLink="true">http://blog.aaw.io/2016/06/10/regrams-intro.html</guid>
        
        
      </item>
    
  </channel>
</rss>
