NINE LAYERS OF 3 x 3 PRIME MAGIC SQUARES
WITH PREFIXES THAT VARY BY CELL
18 November 2026

CLASSIFICATION -- PLEASE READ FIRST

This package contains nine complete, digit-nested 3 x 3 prime magic squares.
Every layer has nine distinct primes. All 81 entries across the nine layers
are distinct, and all 72 row, column and principal diagonal sums pass.

The first five layers use uniform digit additions: the same prefix and/or
suffix is applied to all nine cells at each step. The final four layers use
different prefixes at different positions. Those nine prefixes themselves
form a magic square. Every previous entry remains unchanged as a literal
decimal suffix of the corresponding new entry.

This nine-layer construction therefore generalizes the uniform-prefix/suffix
rule used in the preceding work on Carlos Rivera's Puzzle 869. It is not a
claim that nine layers have been achieved under that stricter uniform rule.
The strict construction is currently verified through five layers.

THE LAYERS

Layer  Digits per entry  Exact magic constant
1       3                1977
2       5                79791
3      11                276797939217
4      22                4679206547676797939217
5      34                17031823963834679206547676797939217
6      44                180182252267031823963834679206547676797939217
7      54                1801809910080182252267031823963834679206547676797939217
8      64                18018225226801809910080182252267031823963834679206547676797939217
9      74                180180270288018225226801809910080182252267031823963834679206547676797939217

Each listed constant is shared by the three rows, three columns, and both
principal diagonals of that layer. The base square is:

  599  677  701
  761  659  557
  617  641  719

UNIFORM STEPS, THROUGH LAYER 5

1 to 2: prepend 2 and append 7.
2 to 3: prepend 92 and append 9739.
3 to 4: prepend 15597355158.
4 to 5: prepend 567727465461.

For example, the centre develops as follows:

  659
  26597
  92265979739
  1559735515892265979739
  5677274654611559735515892265979739

LAYERS 6 TO 9: MAGIC PREFIX MATRICES

Let A be a 3 x 3 magic square, with d decimal digits in every entry. Let P be
another 3 x 3 magic square of positive integers, with a common digit width.
Define the new square entry by entry as:

  B[r,c] = 10^d * P[r,c] + A[r,c].

In decimal notation this concatenates P[r,c] in front of A[r,c]. If the magic
constants of A and P are S_A and S_P, then every row, column and principal
diagonal of B has the same sum:

  S_B = 10^d * S_P + S_A.

This proves the preservation of the magic property. Primality is a separate
condition: the search selected prefix matrices for which all nine resulting
entries are prime, and every resulting prime has a verified certificate.

Every added prefix has ten digits. Thus peeling ten leading digits from
every entry of Layer 9 recovers Layer 8, and repeating that operation recovers
Layers 7, 6 and 5. The removed ten-digit values vary by cell.

Example prefix matrix for Layer 5 to Layer 6:

  4516430919  7623794178  5878000128
  7367644284  6006075075  4644505866
  6134150022  4388355972  7495719231

Its eight line sums are all 18018225225. The other three prefix matrices
and every full square are explicitly recorded in solution.json.

ACTUAL DATA FILES

Layer_01_3x3.csv through Layer_09_3x3.csv contain the nine actual squares.
Each file has exactly three rows with three comma-separated integers per row.
There are no headers or extra columns. Row and column positions in the CSV
are the actual square positions.

The outer entries have 74 digits. A text editor displays every digit. If
opening the CSVs in Excel, import the fields explicitly as Text: automatic
numeric conversion can discard digits beyond Excel's numeric precision.
The Python verifier always reads the complete integers exactly. solution.json
stores matrix entries and magic constants as decimal strings to preserve
their precision across software environments.

RUN THE GRAPHICAL VERIFIER

1. Extract the complete ZIP into an ordinary folder.
2. Open Verify_3x3_Nine_Layers_GUI.py in IDLE or Spyder and choose Run.
   On Windows, Launch_GUI.pyw also provides a double-click launcher when
   Python is associated with .pyw files and includes Tkinter.
3. The nine packaged CSVs are selected by default. Each Browse button lets
   you select the actual CSV for that layer.
4. Click "Verify all nine CSVs".
5. Read the results or click "Save report...".

Keep the Python files, solution.json and certificates.json together.
The GUI requires Python 3.8 or newer and its standard Tkinter component.
No NumPy, SymPy, FLINT, internet connection or command-line use is needed
for verification.

The optional command-line version is:

  python verify_solution.py

To save a fresh report:

  python verify_solution.py --report my_verification.txt

WHAT IS CHECKED

The verifier reads the selected CSVs; it does not generate the squares it
then checks. It verifies exact integer formatting, shape, digit widths,
distinctness, all 72 magic-line equalities, all 72 decimal nesting relations,
all four magic prefix matrices, their sum recurrences, and the distinction
between uniform and varying prefixes.

All 81 prime claims are proved by the supplied Pocklington certificates.
For a claimed prime n, the verifier checks a completely factored divisor
F of n-1 with F^2 > n, the primality proofs for every prime factor of F,
and the required modular-power and greatest-common-divisor identities.
The proof chains end at 2. The merged proof bundle has 589 stored nodes.
These are exact proofs, not probable-prime results.

The certificate checker uses only Python's integer arithmetic and standard
library. A separate audit using FLINT's proven-prime test also passed for
every entry. The full local report is verification_result.txt. Independent
audit records are in audits/.

CONSTRUCTION METHOD

The uniform search found the fifth-layer prefix by a modular wheel sieve
followed by prime screening and rigorous proof.

For the final four layers, write a 3 x 3 magic square using centre c and two
offsets a,b. Its entries have offsets 0, +/-a, +/-b, +/-(a+b), +/-(a-b).
For a chosen new centre, the program sieves four sets of indices for which
opposite entries are both prime candidates. It then finds indices u,v such
that u, v, u+v and u-v belong to their respective sets.

The prefix parameters were multiplied by 3003 = 3*7*11*13. Because the
decimal place-value factor is divisible by 2 and 5, this preserves each
old entry's nonzero residues modulo 2,3,5,7,11,13 and speeds the search.
All candidate primes were then rigorously checked, and the portable proof
certificates were generated and independently verified.

construction/ contains the C++ paired-sieve source and its Python driver.
Reconstructing the search requires a C++17 compiler with GMP and Python's
python-flint package. Rechecking the delivered solution requires neither.
The search begins with the supplied uniform_grade5.json. It can be rerun
from the construction folder using:

  c++ -O3 -std=c++17 pairsets.cpp -lgmpxx -lgmp -o pairsets
  python extend_chain.py

The driver labels the output as a construction with cellwise prefixes and
proves all nine new primes at each step before accepting the new layer.

STRICT UNIFORM SEARCH STATUS

A subsequent bounded search did not find a sixth layer obtained by adding
a common left prefix to this particular fifth-layer square. The search
scope and checkpoints are in research/. This is a result about that tested
extension search; it does not establish impossibility for other prefixes,
suffixes, starting squares, or nine-layer uniform constructions.

PROVENANCE AND REFERENCES

Layers 1-3 reproduce the first grade-3 example published with Carlos Rivera's
Puzzle 869. Layers 4-5 are uniform extensions found in this work. Layers 6-9
use the generalized magic-prefix-matrix construction described above.
The computations and verification were developed with OpenAI ChatGPT during
Roberto Carlo Angelone's project. No priority or minimality claim is made.

Carlos Rivera, "Puzzle 869. Prime nested magic squares."
https://www.primepuzzles.net/puzzles/puzz_869.htm
Original three-layer example:
https://www.primepuzzles.net/images/Pu869g3.JPG

FLINT, "Primality proving: APRCL and ECPP," including Pocklington's theorem.
https://flintlib.org/doc/algorithms/number-theory/primality-proving.html

References accessed 18 November 2026.

SHA256SUMS.txt records the exact package-file hashes. File hashes identify
the bytes; the mathematical verifier checks the properties independently.
