Partitions¶
A partition (parts/<hash>.jlp) is a container of kind 6
with all ten sections. It holds a consecutive part of the library's theory:
its own declarations, their named theory, the provenance of its axioms, the
support records the checker needs to rebuild them, the statements they
provide, and the proof-DAG rows that prove its theorems. The design is
ST9, which takes the layouts of sections 1 to 4, 6, 7
and 9 from ST8.
| Tag | Section | Stored |
|---|---|---|
| 1 | imports | compressed |
| 2 | declarations | compressed |
| 3 | theories | compressed |
| 4 | provenance | compressed |
| 5 | DAG directory | as is |
| 6 | reconstruction support | compressed |
| 7 | statements | compressed |
| 8 | DAG blocks | as is (its streams are compressed) |
| 9 | closed-form entries | compressed |
| 10 | export table | compressed |
Inside sections 1 to 4, 6, 7 and 9, integers are u32, strings are
u32-length UTF-8, lists are u32-counted, and identities are 32 bytes
(primitives). Sections 5, 8 and 10 use varints.
A loader recomputes sections 1 to 4, 6, 7, 9 and 10 from what it loaded and
requires each to equal what it read, byte for byte (FORMAT;
loading). The layouts below are therefore exact: a writer MUST
write them as given.
Compressed sections¶
compressed section := varint R, then one raw DEFLATE stream to the payload's end
R is the length of the section's content, the bytes the tables below
describe; the stream inflates to exactly those bytes. The reference writer
compresses at level 6 with the Store's encoder. A reader:
- reads
Ras a minimal varint (FORMATat the payload's first byte); - refuses an
Rabove itsmax_section_bytes(LIMIT) and anRabove 1,032 times the stream's length (FORMAT), both before inflating; - inflates with
Ras the output limit, refusing a malformed stream, a longer or shorter output, and bytes after the stream's end (FORMAT, at the stream's byte in the payload); - parses the content.
Every list's length is checked against the bytes left in the content before it is iterated.
Section 1: imports¶
imports := list of identity (minimum item 32 bytes)
The identities of the declarations that this partition's rows may reference
through REF rows, strictly increasing:
- in a partition of the library's first chain: every core declaration, every declaration of the profile, and every declaration of the earlier partitions of the chain;
- in a partition of a detached chain (below):
exactly the declarations its
REFrows name, and no others (FORMAT).
A REF row names its declaration by its position in this list.
Section 2: declarations¶
declarations := list of (identity[32], blob: declaration bytes) (minimum item 36 bytes)
Each own declaration, with its identity
(identities), in the order of the
partition's DECL rows: the DECL rows name section-2 positions 0, 1, 2, …
in row order (FORMAT otherwise). That is the writer's commit order, a
dependency order. The identity MUST be the hash of the bytes (IDENTITY
otherwise).
Section 3: theories¶
theories := list of (name: string, list of identity) (minimum items 8 and 32 bytes)
Exactly one named theory, named as the partition's manifest entry is, listing the identities of the own declarations in section-2 order.
Section 4: provenance¶
provenance := list of (identity[32], class: string, source: string) (minimum item 40 bytes)
One record for each own axiom, strictly increasing by identity, and no other
(FORMAT): judgment_shell's classification of the assumption and a
free-text source. The class is one of CORE, PROFILE_AXIOM,
LITERAL_KIND, ACU, DEFINITION, THEOREM, INSTANCE,
IMPORTED_STATEMENT, EXTERNAL, CHECKER, UNCLASSIFIED (FORMAT
otherwise). An article's axioms are written as IMPORTED_STATEMENT, with the
article's source as the source. Provenance labels results; it never decides
whether a declaration checks.
Section 5: the DAG directory¶
directory := varint N rows in the partition
varint B DAG blocks; 0 exactly when N = 0
B × (varint rows, varint length, digest[32])
root[32] the Merkle tree hash of the B digests
Each block's rows is at least 1, length is its byte length in section 8,
and digest is SHA-256 of 0x00 and the block's bytes. The rows sum to N
and the lengths to section 8's length. The root is RFC 6962's Merkle tree
hash over the digests, with 0x01 before each inner node's two hashes; it is
also in the partition's manifest record. The layout, its bounds and its
refusals are ST9.5.
Section 6: reconstruction support¶
support := u32 count, then count × (identity[32], list of identity) (minimum item 36 bytes)
One record for each declaration of section 2, in the same order, then one for each import of a support kind in section-1 order. The support kinds are ACU operators, literal kinds, instance definitions, class instances, and class relations. A record's list is the declaration's support basis (ST1.5). Every list a current writer produces is empty, and a loader recomputes the section with empty lists.
Section 7: statements¶
statements := u32 count, then count × (u32 position, u32 part, identity[32]) (minimum item 40)
u32 count, then count × (u32 position, list of name: string) (minimum item 8)
u32 count = 0
Three lists:
- Provided statements. For each statement an own declaration provides (identities), its declaration's position in section 2, the part that provides it, and its statement identity; strictly increasing by (position, part).
- Type-variable names. For each theorem stored by its key (one to six type variables), its position, strictly increasing, and the names its source gave its type variables, in key order.
- Aliases. Always empty: a library's aliases are in its manifest (section 4).
Section 8: DAG blocks¶
The partition's rows, numbered from the chain's base B_k
(below), split into blocks in row order. A block
ends after the first row at which the total raw length of its streams reaches
1,048,576 bytes; the last block may be shorter. Each block is
varint R, its row count, at least 1
16 × (varint, varint) each stream's raw length and compressed length, in stream order
bytes the compressed streams, in stream order
with each stream compressed by raw DEFLATE, and nothing between blocks. The rows' tags, their fields and the streams that hold them are ST9.2 to ST9.4, which this page does not repeat; the encoding is unique apart from the DEFLATE streams, and a reader refuses a block that should have ended earlier or, other than the last, ended too early.
Section 9: closed-form entries¶
entries := u32 count, then count × entry (minimum item 21 bytes)
entry := u32 position, u32 n, u32 m, u32 0, u32 0, u8 0
One entry for each own theorem whose proof row concludes an open sequent, in
section-2 order: position is the theorem's section-2 position, n the
number of locals the proof row depends on, and m the number of its
hypotheses. The theorem's statement is a closed form
\(\vdash \forall x_1 \dots x_n.\ h_1 \to \dots \to h_m \to \varphi\) of the row's
sequent: its canonical closure \(K\) (Definition Q-3d),
which orders the locals and hypotheses and names the type variables by the
sequent's content alone (ST9.6). The two zero
counts are the entry's lists of external claims, which a current writer
leaves empty, and the last byte, 0, says that the evidence is the theorem's
export-table entry. A theorem whose proof row is closed has no entry.
Section 10: the export table¶
exports := varint E, then E × export
export := name (varint length, UTF-8), statement[32], varint declaration, varint proof,
u8 0, or u8 1 then class and source (each a varint length and UTF-8)
One entry for each own Proven declaration, strictly increasing by name in
byte order: its name, which is its canonical name judgment.stmt.<hex>, its
statement identity, its section-2 position, the row number of the PROOF
row that proves it, and an optional provenance, which the reference writer
leaves absent. A loader requires the name, the statement identity and the
position to be those of the declaration it loaded, and the proof row to be a
PROOF row of the chain (ST9.6).
Sub-partitions and chains¶
A library's declarations are taken in commit order and split into
sub-partitions, numbered from 0, which share one name: the name of the
library's theory. A run ends before the declaration whose newly reachable
rows would take the run's estimated size past 2²⁴ bytes, unless the run is
empty; a single declaration whose rows alone exceed it is cut into
rows-only sub-partitions, which hold rows and no declaration, followed by
one that holds its DECL row. A sub-partition whose container would exceed
the container limits is cut again. The rules are
ST9.1.
Sub-partitions form a chain: one row numbering continues across it.
Sub-partition k's rows are numbered from B_k, the sum of the row counts that
the manifest records for the partitions before it in the chain, and its rows
reference an earlier sub-partition's rows by those numbers. Every row is
stored once, in the first partition that reaches it. A reference below B_k
to a DECL, PART or REF row is refused (FORMAT): a partition's
declaration rows are its own, and an earlier sub-partition's declarations are
imported through section 1 and a REF row. A LOCAL row and its fix frame
are always in one partition, the frame just after the local.
B_k comes from the manifest; no field of a partition records it. Two
sub-partitions whose rows encode alike, such as two small rows-only pieces of
one run, have the same bytes and so one file hash: the manifest names that
file at both positions, and publication stores it once
(publication).
A later version of a library keeps its base's partitions and appends new
sub-partitions. When the writer loaded its base's rows, they continue the
base's chain. When it imported only the base's statement layer, the first new
sub-partition is detached: its manifest record marks it so, it has no
dependencies, and it starts a new chain whose rows are numbered from 0, with
section 1 listing exactly the declarations its REF rows name
(ST9.1, detached additions).
Reading a partition¶
A reader:
- opens the container and checks the kind (
FORMATat 56) and that all ten sections are present (FORMATat 57); - inflates sections 1 to 4, 6, 7, 9 and 10;
- reads section 5, recomputes the Merkle root of its digests and requires it
to equal the directory's and the manifest's (
DIGEST), checks each block's digest (DIGEST), and decodes the blocks to rows numbered fromB_k, checking every reference's kind against the tags of the rows it names, earlier partitions' rows included (ST9.4); - reads section 10 against the rows;
- with a checker, commits the rows and checks them (loading).