rocq/backend/NfbTotal.v
NFB's Gallina reader is total and its fuel never runs out (docs/nfb.md, Relation to the term form and the Rocq model).
Every function of NfbTerm.v is a Gallina function, so decode returns on every list of words, a module or none. Where a reader recurses on more than the structure of its input it takes fuel, and each call site gives it the length of the words it reads. This file proves that length is enough: with any more fuel each reader gives the same answer, so no input is refused for want of fuel (sections_fuel, group_fuel, blocks_fuel, rest_fuel, side_term_fuel, name_recs_fuel). Each holds because every round of the reader takes at least one word.
Whether fuel f and every larger fuel give the reader the same answer.
A reader whose answer is the same for the next fuel, from fuel f on, has enough fuel f.
Proof 4 steps Qed
Taking words
take n leaves n fewer words.
Proof 9 steps Qed
Reading n of what a reader reads, where the reader never leaves more words than it was given, leaves no more.
Proof 11 steps Qed
As read_n_length, for a counted list, which also takes its count.
Proof 5 steps Qed
Two readers that agree on every list of at most L words, the first never leaving more words than it was given, read the same n of them from at most L words.
Proof 7 steps Qed
As read_n_ext, for a counted list.
Proof 7 steps Qed
Sections
Splitting the words into sections, with fuel their length.
Proof 15 steps Qed
Side sections
Case on every match in the hypotheses, dropping the cases where one says none is some, then on every pair, and take apart each hypothesis that says some is some.
A side section's term leaves fewer words than it was given.
Proof 8 steps Qed
A side section's term, with fuel the length of its words: each level of the term takes a word.
Proof 17 steps Qed
One round of reading NAMES, with fuel S f.
Proof 1 step Qed
NAMES, with fuel the length of its words: each function's names take a word at least.
Proof 23 steps Qed
Instructions and blocks
An instruction leaves fewer words than it was given: at least its header is read.
Proof 3 steps Qed
One round of reading a group, with fuel S f.
Proof 1 step Qed
A group leaves no more words than it was given.
Proof 13 steps Qed
A group of instructions, with fuel the length of its words: each instruction takes a word.
Proof 14 steps Qed
Blocks, with fuel the length of their words.
Proof 21 steps Qed
Elements of a list
Whether reading the field f takes a word: all fields but a definition's.
Naming a definition reads no word.
The next word is one word.
A field leaves no more words than it was given, and fewer if it takes a word.
Proof 2 steps Qed
Fields leave no more words than they were given, and fewer if one of them takes a word.
Proof 8 steps Qed
One round of reading the rest, with fuel S f.
Proof 1 step Qed
The elements to the end of an instruction, with fuel the number of its words left, when each element takes a word.
Proof 20 steps Qed
Every list of a form read to the end has elements that take a word, so rest_fuel covers each one the reader reads.
Proof 2 steps Qed
The reader as a whole
decode gives every list of words a module or refuses it: it is a function, and by the lemmas above no refusal is for want of fuel.