=====================================================================
Prime Block Algorithm – Code Package (Protos Arché)
Prime-Block-Algorithmus – Code-Paket (Protos Arché)
=====================================================================

---------------------------------------------------------------------
ENGLISH
---------------------------------------------------------------------

Requirements: PHP >= 8.1 with pdo_sqlite (additionally gd for PNGs).

Contents
--------
src/BaseMath.php    Base-dependent mathematics: ord_p(b), periods in
                    any base 2-36, prime classification.
src/Database.php    SQLite layer: primes, analyses, residue-class
                    patterns and sieved blocks (WAL mode, transactions).
src/BlockSieve.php  The block sieve algorithm: patterns per (prime,
                    residue class) are created once, stored in SQLite
                    and reused via OR combination.
src/BlockScaler.php Block scaling: block sizes grow by squaring
                    (100 to 10,000), large blocks are assembled
                    modularly from small ones, capped by a maximum
                    value and a maximum block size.
cli/sieve.php       Sieve up to a limit:        php cli/sieve.php 100000
cli/scale.php       Build all squared tiers:    php cli/scale.php 1000000
cli/verify.php      Correctness test against the classic sieve of
                    Eratosthenes:               php cli/verify.php 10000
cli/make_pngs.php   Block bitmaps as PNG:       php cli/make_pngs.php 7 20

Core idea
---------
The number line is split into blocks of size B. For every prime p the
bit pattern of its multiples repeats after L = p / gcd(p, B) distinct
residue-class patterns. These patterns are computed once and stored.
New blocks are produced by OR-combining the matching patterns.
Positions that remain 0 are new primes - the algorithm continues
itself ("Never ending Primes").

The database (data/protos.db) is created automatically on first run.

---------------------------------------------------------------------
DEUTSCH
---------------------------------------------------------------------

Voraussetzungen: PHP >= 8.1 mit pdo_sqlite (für PNGs zusätzlich gd).

Inhalt
------
src/BaseMath.php    Basisabhängige Mathematik: ord_p(b), Perioden in
                    beliebiger Basis 2-36, Primklassifikation.
src/Database.php    SQLite-Schicht: Primzahlen, Analysen, Restklassen-
                    Muster und gesiebte Blöcke (WAL-Modus, Transaktionen).
src/BlockSieve.php  Der Block-Sieb-Algorithmus: Muster pro (Primzahl,
                    Restklasse) werden einmal erzeugt, in SQLite abgelegt
                    und per ODER-Verknüpfung wiederverwendet.
src/BlockScaler.php Blockvergrößerung: Blockgrößen wachsen zum Quadrat
                    (100 zu 10.000), große Blöcke werden modular aus
                    kleinen zusammengesetzt, gedeckelt durch Maximalwert
                    und maximale Blockgröße.
cli/sieve.php       Sieben bis zu einem Limit:  php cli/sieve.php 100000
cli/scale.php       Alle Quadrat-Stufen bauen:  php cli/scale.php 1000000
cli/verify.php      Korrektheitstest gegen das klassische Sieb des
                    Eratosthenes:               php cli/verify.php 10000
cli/make_pngs.php   Block-Bitmaps als PNG:      php cli/make_pngs.php 7 20

Kernidee
--------
Der Zahlenstrahl wird in Blöcke der Größe B zerlegt. Für jede Primzahl p
wiederholt sich das Bitmuster ihrer Vielfachen nach L = p / gcd(p, B)
verschiedenen Restklassen-Mustern. Diese Muster werden einmal berechnet
und gespeichert. Neue Blöcke entstehen durch ODER-Verknüpfung der
passenden Muster. Positionen, die 0 bleiben, sind neue Primzahlen - der
Algorithmus setzt sich selbst fort ("Never ending Primes").

Die Datenbank (data/protos.db) wird beim ersten Lauf automatisch angelegt.

---------------------------------------------------------------------
License / Lizenz: CC BY-NC-SA 4.0 - (c) 2025 Francesco Schauer