# Check it yourself: Covering arrays

Don't take our word for it. Each result here comes with its files and a check guide, and each guide says which checks you can rerun yourself. Some results rest on logs from programs that are not part of this book, or on files available on request; the guide says which. Where your run matches ours, you checked that part rather than trusted it. If something breaks, confuses you or does not match, you are welcome to tell us. We fix mistakes in the open and credit the person who found them. Why a recipe and not our program: https://gocheckyourself.org/how-to-check/

You do not have to trust our results or our programs. This page tells you, step by step, how to check the published files with tools you already have. The full written recipe is the chapter 'Check it yourself: covering arrays, the one-column extension theory, and the Lean files' in https://gocheckyourself.org/text/covering-arrays-experts.txt.

Steps 1 to 8 have the command for Windows PowerShell and for macOS or Linux (bash), the output you should see, and a plain sentence on what a match means and what it does not. Steps 9 to 14 have no copy-paste script yet: each names the recipe to write yourself and the output to expect. If your output is different, the step has failed; do not skip it.

You need: a command line, and Python 3.10 or later (python on Windows, python3 on macOS or Linux) for the steps that run a script. Windows PowerShell 5.1 or later (pwsh also works). Scripts are short; read them before you run them.

## What is known not to work today

- Recipe 7 (comparison table): our copy of the pinned comparison table is not online; it is available on request. The same file is public: Charles J. Colbourn's covering array tables, November 2024 version, read through Christopher Smolen's ca-tools CSV file at commit 5ad91a4925e55e4a40a0332ae6d1aa66777e2429, https://raw.githubusercontent.com/chrispbsmolen/ca-tools/5ad91a4925e55e4a40a0332ae6d1aa66777e2429/table/ca_table.csv (chapter 3 of the book links it). The row compared for a width w: take the rows with t = 4, v = 2, snapshot_id equal to colbourn-2024-11-ug (the rows from Colbourn's tables) and k at least w; the upper bound is the smallest N among them. Expected: 154 for widths 200 to 206, 160 for 223, 173 for 325 to 338 and 174 for 339 to 345. Check that its SHA-256 is 30e5f10e226f881a413dd0a61f98bd7dac6d4dfb4916cf36505bdc31844833c0, then apply the rule of recipe 7 in the book's check guide by hand.
- Recipe 10: the hardness and rules Lean folders are not online; they are available on request. The written proofs for chapters 6 to 13 are not online either; they are available on request.
- Recipe 9 (the Lean package) needs Lean and about 8 GB and was not run here.
- Recipe 11 (the 13 by 13 locating array): the table ships; our own short checker does not. Write the check from the condition in the chapter; it takes a few lines.
- Recipe 6 needs the free program drat-trim; not run here. Recipes 4 and 5 (extension counts, whether two rows can be replaced by one) have no copy-paste script here; the check guide VERIFY.md text is the full instruction.
- All 29 strength-four arrays in plain Python on one core: several hours (about 1 to 1.5 minutes for a 201-column array and about 5 to 8 minutes for a 345-column array, on one core of an ordinary computer); spread over 16 processes, under an hour. Check one array, as in the steps below, or use a compiled language for all of them.

## Step 1: Make an empty working folder and say where the files are.

Windows PowerShell:

```powershell
$ProgressPreference = "SilentlyContinue"
$BASE = "https://gocheckyourself.org/data/files/covering-arrays"
New-Item -ItemType Directory -Force check-covering-arrays | Out-Null
Set-Location check-covering-arrays
```

macOS or Linux (bash):

```bash
BASE="https://gocheckyourself.org/data/files/covering-arrays"
mkdir -p check-covering-arrays && cd check-covering-arrays
```

You should see:

```
No output.
```

What a match shows, and what it does not: Nothing; this just makes a folder.

Cost: instant.

## Step 2: Download the list of fingerprints (SHA-256) that the book publishes for its files.

Files used (SHA-256):
- https://gocheckyourself.org/data/files/covering-arrays/certificates/SHA256SUMS.txt  0110ef3b33eb2aa26ffaec94503317973bb5be9e85d6609da1ff1f7b166b880c

Windows PowerShell:

```powershell
New-Item -ItemType Directory -Force certificates | Out-Null
Invoke-WebRequest -UseBasicParsing -UserAgent "Mozilla/5.0" "$BASE/certificates/SHA256SUMS.txt" -OutFile certificates/SHA256SUMS.txt
```

macOS or Linux (bash):

```bash
mkdir -p certificates
curl -fsSL "$BASE/certificates/SHA256SUMS.txt" -o certificates/SHA256SUMS.txt
```

You should see:

```
No output. The file certificates/SHA256SUMS.txt exists. Each line is 64 hex digits, a space, an optional star, and a file path.
```

What a match shows, and what it does not: The list comes from the same site as the files, so by itself it just catches damaged or swapped files, not a site that lies in both places. Compare the list's own SHA-256 (see inputs) with a copy you trust, such as one a friend keeps, or one kept anywhere other than this site.

Cost: instant.

## Step 3: Download every file named in the list, keeping the folder layout the list expects.

Files used (SHA-256):
- https://gocheckyourself.org/data/files/covering-arrays/certificates/SHA256SUMS.txt  0110ef3b33eb2aa26ffaec94503317973bb5be9e85d6609da1ff1f7b166b880c

Windows PowerShell:

```powershell
Get-Content certificates/SHA256SUMS.txt | Where-Object { $_.Trim() } | ForEach-Object {
  $rel = ($_ -replace '^[0-9a-fA-F]{64} [ *]','') -replace '^\./',''
  New-Item -ItemType Directory -Force (Split-Path -Parent (Join-Path $PWD $rel)) | Out-Null
  try { Invoke-WebRequest -UseBasicParsing -UserAgent "Mozilla/5.0" "$BASE/$rel" -OutFile $rel } catch { "NOT FOUND: $rel" }
}
```

macOS or Linux (bash):

```bash
while read -r h p; do
  p="${p#\*}"; p="${p#./}"; [ -z "$p" ] && continue
  mkdir -p "$(dirname "$p")"
  curl -fsSL "$BASE/$p" -o "$p" || echo "NOT FOUND: $p"
done < certificates/SHA256SUMS.txt
```

You should see:

```
One file per list line (113 lines). No output means every download worked.
```

What a match shows, and what it does not: A missing file can come back as the site's home page (status 200) instead of a not-found. The next step catches that, because the page's hash will not match.

Cost: a few minutes, depending on your connection (one test run took 5m45s).

## Step 4: Compare the SHA-256 fingerprint of every downloaded file with the published list.

Files used (SHA-256):
- https://gocheckyourself.org/data/files/covering-arrays/certificates/SHA256SUMS.txt  0110ef3b33eb2aa26ffaec94503317973bb5be9e85d6609da1ff1f7b166b880c

Windows PowerShell:

```powershell
$ok = 0; $bad = 0
Get-Content certificates/SHA256SUMS.txt | Where-Object { $_.Trim() } | ForEach-Object {
  $h = $_.Substring(0,64).ToLower()
  $rel = ($_ -replace '^[0-9a-fA-F]{64} [ *]','') -replace '^\./',''
  $f = Get-FileHash -Algorithm SHA256 -LiteralPath $rel -ErrorAction SilentlyContinue
  if ($f -and $f.Hash.ToLower() -eq $h) { $ok++ } else { $bad++; "NOT OK: $rel" }
}
"$ok OK, $bad not OK"
```

macOS or Linux (bash):

```bash
# Linux: sha256sum.  macOS: use "shasum -a 256 -c" instead of "sha256sum -c".
if command -v sha256sum >/dev/null; then C="sha256sum -c"; else C="shasum -a 256 -c"; fi
$C certificates/SHA256SUMS.txt 2>&1 | grep -v ": OK$" ; echo "$($C certificates/SHA256SUMS.txt 2>/dev/null | grep -c ": OK$") OK"
```

You should see:

```
PowerShell prints a line "113 OK, 0 not OK". bash prints every line that is not OK, then "113 OK".
```

What a match shows, and what it does not: A match shows that your files are exactly the files the list names. What the files say is tested by the other steps of this recipe. 

Cost: seconds.

## Step 5: Recipe 3: check a strength-two array over 4 symbols (22 rows, 9 columns) against the definition.

Files used (SHA-256):
- https://gocheckyourself.org/data/files/covering-arrays/certificates/small-exact/ca22-t2-k9-v4/array.txt  e92f8fd18d384bd3bce88d0b7ff82b7baf17cf7c435f69516499477808f321fa

Windows PowerShell:

```powershell
@'
# Covering array check, any strength t and alphabet size v, no sampling.
# Usage: python ca_cover.py <array.txt> <t> <v>        (one row per line, one digit per entry)
# Prints PASS, or FAIL with one column set (zero-based) and one missing pattern.
import sys
from itertools import product

path, t, v = sys.argv[1], int(sys.argv[2]), int(sys.argv[3])
raw = open(path, "rb").read()
assert b"\r" not in raw and raw.endswith(b"\n"), "file must use LF line endings and end with one"
rows = raw.decode("ascii").split("\n")[:-1]
N, k = len(rows), len(rows[0])
assert all(len(r) == k and all(ch in "0123456789"[:v] for ch in r) for r in rows), "bad row"

# colmask[c][s]: bit r set when row r has symbol s in column c
colmask = [[0] * v for _ in range(k)]
# rowsym[s][r]: bit d set when row r has symbol s in column d
rowsym = [[0] * N for _ in range(v)]
for r, row in enumerate(rows):
    for d, ch in enumerate(row):
        s = int(ch)
        colmask[d][s] |= 1 << r
        rowsym[s][r] |= 1 << d

def missing_columns(m, s, last):
    """columns d > last where no row of the row-set m shows symbol s"""
    acc = ((1 << k) - 1) >> (last + 1) << (last + 1)
    notsym = rowsym[s]
    while m and acc:
        low = m & -m
        acc &= ~notsym[low.bit_length() - 1]
        m ^= low
    return acc

def search(cols, masks):
    """masks: dict pattern(tuple) -> row mask, for the chosen columns"""
    if len(cols) == t - 1:
        last = cols[-1]
        for pat, m in masks.items():
            for s in range(v):
                if m == 0:
                    return cols, pat, "pattern already absent on fewer columns"
                bad = missing_columns(m, s, last)
                if bad:
                    d = (bad & -bad).bit_length() - 1
                    return cols + [d], pat + (s,), "pattern absent"
        return None
    start = cols[-1] + 1 if cols else 0
    for c in range(start, k - (t - 1 - len(cols))):
        new = {}
        for pat, m in masks.items():
            for s in range(v):
                new[pat + (s,)] = m & colmask[c][s]
        r = search(cols + [c], new)
        if r:
            return r
    return None

res = search([], {(): (1 << N) - 1})
if res:
    print("FAIL: columns", res[0], "pattern", res[1], "is missing")
    sys.exit(1)
print("PASS: %d rows, %d columns, strength %d, %d symbols: every choice of %d columns shows every pattern" % (N, k, t, v, t))
'@ | Set-Content -Encoding utf8 ca_cover.py
python ca_cover.py certificates/small-exact/ca22-t2-k9-v4/array.txt 2 4
```

macOS or Linux (bash):

```bash
cat > ca_cover.py <<'EOF'
# Covering array check, any strength t and alphabet size v, no sampling.
# Usage: python ca_cover.py <array.txt> <t> <v>        (one row per line, one digit per entry)
# Prints PASS, or FAIL with one column set (zero-based) and one missing pattern.
import sys
from itertools import product

path, t, v = sys.argv[1], int(sys.argv[2]), int(sys.argv[3])
raw = open(path, "rb").read()
assert b"\r" not in raw and raw.endswith(b"\n"), "file must use LF line endings and end with one"
rows = raw.decode("ascii").split("\n")[:-1]
N, k = len(rows), len(rows[0])
assert all(len(r) == k and all(ch in "0123456789"[:v] for ch in r) for r in rows), "bad row"

# colmask[c][s]: bit r set when row r has symbol s in column c
colmask = [[0] * v for _ in range(k)]
# rowsym[s][r]: bit d set when row r has symbol s in column d
rowsym = [[0] * N for _ in range(v)]
for r, row in enumerate(rows):
    for d, ch in enumerate(row):
        s = int(ch)
        colmask[d][s] |= 1 << r
        rowsym[s][r] |= 1 << d

def missing_columns(m, s, last):
    """columns d > last where no row of the row-set m shows symbol s"""
    acc = ((1 << k) - 1) >> (last + 1) << (last + 1)
    notsym = rowsym[s]
    while m and acc:
        low = m & -m
        acc &= ~notsym[low.bit_length() - 1]
        m ^= low
    return acc

def search(cols, masks):
    """masks: dict pattern(tuple) -> row mask, for the chosen columns"""
    if len(cols) == t - 1:
        last = cols[-1]
        for pat, m in masks.items():
            for s in range(v):
                if m == 0:
                    return cols, pat, "pattern already absent on fewer columns"
                bad = missing_columns(m, s, last)
                if bad:
                    d = (bad & -bad).bit_length() - 1
                    return cols + [d], pat + (s,), "pattern absent"
        return None
    start = cols[-1] + 1 if cols else 0
    for c in range(start, k - (t - 1 - len(cols))):
        new = {}
        for pat, m in masks.items():
            for s in range(v):
                new[pat + (s,)] = m & colmask[c][s]
        r = search(cols + [c], new)
        if r:
            return r
    return None

res = search([], {(): (1 << N) - 1})
if res:
    print("FAIL: columns", res[0], "pattern", res[1], "is missing")
    sys.exit(1)
print("PASS: %d rows, %d columns, strength %d, %d symbols: every choice of %d columns shows every pattern" % (N, k, t, v, t))
EOF
python3 ca_cover.py certificates/small-exact/ca22-t2-k9-v4/array.txt 2 4
```

You should see:

```
PASS: 22 rows, 9 columns, strength 2, 4 symbols: every choice of 2 columns shows every pattern
```

What a match shows, and what it does not: It shows this file is a covering array of that strength. It does not show that a smaller array is impossible.

Cost: under a second.

## Step 6: Same program on the strength-three array over two symbols (12 rows, 6 columns).

Files used (SHA-256):
- https://gocheckyourself.org/data/files/covering-arrays/certificates/small-exact/ca12-t3-k6-v2-nonextendible/array.txt  4ae1cb38635dadc1f89c6f46f46026c46e18bbc96adce9459ad634692d8531a3

Windows PowerShell:

```powershell
python ca_cover.py certificates/small-exact/ca12-t3-k6-v2-nonextendible/array.txt 3 2
```

macOS or Linux (bash):

```bash
python3 ca_cover.py certificates/small-exact/ca12-t3-k6-v2-nonextendible/array.txt 3 2
```

You should see:

```
PASS: 12 rows, 6 columns, strength 3, 2 symbols: every choice of 3 columns shows every pattern
```

What a match shows, and what it does not: Same as the previous step.

Cost: under a second.

## Step 7: Recipe 2: check one of the 29 strength-four arrays (145 rows, 201 columns): every one of the 65,998,350 choices of four columns, every one of 16 patterns.

Files used (SHA-256):
- https://gocheckyourself.org/data/files/covering-arrays/certificates/201-columns-145-rows/array.txt  9c00a0426b47359b05a559bafa6993296eea34e810ee9c0ad06bd81c28f5c527

Windows PowerShell:

```powershell
python ca_cover.py certificates/201-columns-145-rows/array.txt 4 2
```

macOS or Linux (bash):

```bash
python3 ca_cover.py certificates/201-columns-145-rows/array.txt 4 2
```

You should see:

```
PASS: 145 rows, 201 columns, strength 4, 2 symbols: every choice of 4 columns shows every pattern
```

What a match shows, and what it does not: It shows this one file is a strength-four covering array. Other arrays: change the path (the program reads the width from the file); the 345-column arrays take several minutes each.

Cost: about 1 minute on one core (measured: 58 seconds).

## Step 8: Change one byte in a copy of the 22-row array and run the same check: it must FAIL and name a column set.

Files used (SHA-256):
- https://gocheckyourself.org/data/files/covering-arrays/certificates/small-exact/ca22-t2-k9-v4/array.txt  e92f8fd18d384bd3bce88d0b7ff82b7baf17cf7c435f69516499477808f321fa

Windows PowerShell:

```powershell
python -c "b=bytearray(open('certificates/small-exact/ca22-t2-k9-v4/array.txt','rb').read()); b[0]^=1; open('tampered.txt','wb').write(b)"
python ca_cover.py tampered.txt 2 4
```

macOS or Linux (bash):

```bash
python3 -c "b=bytearray(open('certificates/small-exact/ca22-t2-k9-v4/array.txt','rb').read()); b[0]^=1; open('tampered.txt','wb').write(b)"
python3 ca_cover.py tampered.txt 2 4
```

You should see:

```
FAIL: columns [0, 2] pattern (2, 0) is missing
```

What a match shows, and what it does not: It shows the check can fail. A different changed byte may leave a file that still covers; that is why the byte is named here.

Cost: under a second.

## Step 9: Recipe 4: count the valid new columns of five small tables.

Files used (SHA-256):
- https://gocheckyourself.org/data/files/covering-arrays/certificates/fixtures/cube-16x4.txt  9aaf72ecce779ae86883c4b4cbe029dfcfa27903ffa873ffc3ad9ec9470ae928

Commands (same on both platforms; not run by us unless stated):

```
No copy-paste script yet. Write it yourself from the written recipe:
Chapter heading 'Recipe 4'. Try all 2^N 0/1 vectors against the class-lemma condition (strength 3).
```

You should see:

```
7,842 (16x4 cube), 0 (8x4 parity), 56 (16x8 extended Hamming code), 28 (12x4), 0 (12x6 non-extendible); deleting any one row of the 16x8 table leaves 0 in all 16 cases.
```

What a match shows, and what it does not: Counts for these tables alone.

Cost: seconds.

## Step 10: Recipe 5: whether two rows can be replaced by one: input any strength-four array and two row numbers a and b; delete them; list every four-column pattern no remaining row shows; the two rows can be replaced by one row exactly when no two listed patterns ask for opposite bits in a shared column.

Files used (SHA-256):
- https://gocheckyourself.org/data/files/covering-arrays/certificates/201-columns-145-rows/array.txt  9c00a0426b47359b05a559bafa6993296eea34e810ee9c0ad06bd81c28f5c527

Commands (same on both platforms; not run by us unless stated):

```
No copy-paste script yet. Write it yourself from the check guide VERIFY.md text:
Recipe 5, 'whether two rows can be replaced by one'.
```

You should see:

```
The listed patterns, and the answer: yes exactly when no two of them ask for opposite bits in a shared column.
```

What a match shows, and what it does not: The answer is about the two rows you chose. A no does not say a smaller array is impossible.

Cost: seconds.

## Step 11: Recipe 6: the DRAT proof with the free tool drat-trim.

Files used (SHA-256):
- https://gocheckyourself.org/data/files/covering-arrays/certificates/small-exact/ca12-t3-k9-v2-two-constant-rows/ca12_3_9_2_const2.cnf  da9940c154e5335b94680645594f0d4c79184dec7b538bc21531c3cbe4b40ad3

Commands (same on both platforms; not run by us unless stated):

```
No copy-paste script yet. Write it yourself from the written recipe:
Chapter heading 'Recipe 6'. Get drat-trim from its public repository and run it on the .cnf and .drat files.
```

You should see:

```
The output contains 's VERIFIED'; the .cnf has SHA-256 da9940c154e5335b94680645594f0d4c79184dec7b538bc21531c3cbe4b40ad3.
```

What a match shows, and what it does not: Does not show the formula says what the chapter claims; write your own encoding to confirm.

Cost: seconds with drat-trim.

## Step 12: Recipe 11: the 13 by 13 locating array. For every pair of columns i < j and every pair of values (a, b), take the set of rows showing a in column i and b in column j; all 312 sets must be non-empty and all different.

Files used (SHA-256):
- https://gocheckyourself.org/data/files/covering-arrays/locating-array/array-13x13.txt  05f03f3cca1799190e2cc17a74221929354d1cb8f3184d89b1e668538374fcbe

Commands (same on both platforms; not run by us unless stated):

```
No copy-paste script yet. Write it yourself from the written recipe:
Chapter heading 'Recipe 11'. Fetch the table from the locating-array folder; 13 lines of 13 digits, LF line endings.
```

You should see:

```
13 rows, 13 columns, 312 different non-empty row sets of 312, then PASS. Flipping any one of the 169 entries makes it FAIL.
```

What a match shows, and what it does not: It shows this table is a (1-bar,2)-locating array with 13 rows. It does not show that 12 rows are impossible; that is CONJECTURED.

Cost: under a second.

## Step 13: Recipe 8: the hub-row construction against brute force, on the 11 named sources in hub-row/data/sources.json (https://gocheckyourself.org/data/files/covering-arrays/hub-row/data/sources.json).

Files used (SHA-256):
- https://gocheckyourself.org/data/files/covering-arrays/hub-row/data/sources.json  02356f81eea692560246fbdb909c2c02f038b0d5000a9585b95f19b43fbb3bc4
- https://gocheckyourself.org/data/files/covering-arrays/hub-row/data/expected-results.json  c4ab35b8485cd873c9cc4a587f4566aac8125d03834581b967629d0681d683bf

Commands (same on both platforms; not run by us unless stated):

```
No copy-paste script yet. Write it yourself from the written recipe:
Chapter heading 'Recipe 8'; the construction and its proof are hub-row/PROOF.md.
```

You should see:

```
The table has strength 3 in every case, and it extends exactly when the source is satisfiable, as listed in expected-results.json.
```

What a match shows, and what it does not: It checks small cases. The general statement rests on the written proof.

Cost: seconds to minutes.

## Step 14: Recipes 7, 9 and 10 (comparison table, Lean package, hardness and rules Lean folders).

Commands (same on both platforms; not run by us unless stated):

```
No copy-paste script yet. Write it yourself from the written recipe:
Chapter headings 'Recipe 7', 'Recipe 9' and 'Recipe 10'.
```

You should see:

```
See the chapter.
```

What a match shows, and what it does not: Recipe 10 needs files that are not online (available on request); recipe 7's table is public at the commit named at the top of this recipe; recipe 9 needs Lean and about 8 GB.

Cost: recipe 9: 184 seconds from a fresh directory with the Mathlib cache (the book's own timing; we did not rerun recipe 9).

