Expand description
Import and export functionality for MMB binary proof format
See mm0-c/verifier.c
for information on the MMB format.
Modules§
- cmd
- Constants used in the MMB specification.
Macros§
- exhausted
- Something using an mmb file unexpectedly exhausted its input source.
- make_
index_ trait - Constructs a new trait for accessing a subcomponent of the index data, with automatic
impls for
()
,(A, B)
and the subcomponent itself. - trace
- Wrap other errors to allow for some backtracing.
Structs§
- Decl
Iter - An iterator over the declaration stream.
- DefBuilder
- An unfinished definition. The
unify
andproof
streams should be used to write unify and proof commands, respectively, and when completed thefinish
function will finalize the streams and return theTermId
of the new definition. - Header
- The header of an MMB file, which is always in the first bytes of the file.
It is followed by a
sorts: [
SortData
; num_sorts]
array (which we keep separate because of the dependency). - HypList
Ref - A handle to an list of hypothesis names in the index.
- HypNames
- This index subcomponent supplies hypothesis names for theorems.
- Hyps
Entry Ref - A handle to an symbol name entry in the index.
- Mm0Writer
- An
Mm0Writer
is a buffer for constructing an MMB file when the total number of sorts/terms/theorems is not yet known. It renders as much of the file as it can, so that the actual file write consists mostly ofmemcpy
s. - MmbFile
- A parsed
MMB
file, as a borrowed type. This does only shallow parsing; additional parsing is done on demand via functions on this type. - Name
Entry - An individual symbol name entry in the index.
- Name
Entry Ref - A handle to an symbol name entry in the index.
- Proof
Iter - An iterator over a proof command stream.
- Sort
Data - A sort entry in the file header. Each sort is one byte, which can be any combination
of the modifiers in
Modifiers::sort_data
:PURE
,STRICT
,PROVABLE
,FREE
. - Symbol
Names - This index subcomponent supplies names for sorts, terms, and theorems.
- Table
Entry - An index table entry, which is essentially an ID describing the table format, and some additional data to find the actual table.
- Term
Entry - An entry in the term table, which describes the “signature” of the term/def, the information needed to apply the term and use it in theorems.
- TermRef
- A reference to an entry in the term table.
- ThmBuilder
- An unfinished axiom or theorem. The
unify
andproof
streams should be used to write unify and proof commands, respectively, and when completed thefinish
function will finalize the streams and return theThmId
of the new theorem. - ThmEntry
- An entry in the theorem table, which describes the “signature” of the axiom/theorem, the information needed to apply the theorem to use it in other theorems.
- ThmRef
- A reference to an entry in the theorem table.
- Type
- An argument binder in a term/def or axiom/theorem.
- Unify
Iter - An iterator over a unify command stream.
- VarList
Ref - A handle to an list of variable names in the index.
- VarNames
- This index subcomponent supplies variable names for terms and theorems.
Enums§
- Numd
Stmt Cmd StmtCmd
aware of its position (represented by a typesafe integer) in the mmb file relative to other declarations.- Parse
Error - An error during parsing of an
MMB
file. - Proof
Cmd - A proof command, which acts on a stack machine with the following components:
- StmtCmd
- The main part of the proof consists of a sequence of declarations, and these commands denote the different kind of declaration that can be introduced.
- Unify
Cmd - Unify commands appear in the header data for a
def
oraxiom
/theorem
. They are executed by theProofCmd::Thm
command in order to perform substitutions. The state of the unify stack machine is:
Constants§
- MAX_
BOUND_ VARS - The maximum number of bound variables supported by the MMB format.
- TYPE_
BOUND_ MASK - bound mask:
10000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000
- TYPE_
DEPS_ MASK - deps mask:
00000000_11111111_11111111_11111111_11111111_11111111_11111111_11111111
- TYPE_
SORT_ MASK 10000000_11111111_11111111_11111111_11111111_11111111_11111111_11111111
Traits§
- HasHyp
Names - A trait for looking up a subcomponent of the index data.
- HasSymbol
Names - A trait for looking up a subcomponent of the index data.
- HasVar
Names - A trait for looking up a subcomponent of the index data.
- MmbIndex
Builder - A trait for populating the
data
field on the indexX
of anMmbFile
given a table entry. - NoHyp
Names - Signals that this type does not implement the respective index trait.
- NoSymbol
Names - Signals that this type does not implement the respective index trait.
- NoVar
Names - Signals that this type does not implement the respective index trait.
- Reopen
- An implementation of
Reopen
is a writer that can be closed and reopened to read what was just written.
Functions§
- cstr_
from_ bytes_ prefix - Construct a
&
CStr
from a prefix byte slice, by terminating at the first nul character. The second output is the remainder of the slice. - find_
header_ error - In the event that
MmbFile::parse
fails when parsing the header, use this to get a more detailed error report (since the zerocopy parser forHeader
is just pass/fail). This method will panic if it’s not able to find a problem with the header, since a disagreement withMmbFile::parse
means something else is going on that needs to looked at. - parse_
cmd - From a (full) mmb file and a start position, parse the raw data
for a command, which is a
[(u8, u32)]
pair of(cmd, data)
. Also returns the new start position, which is the old position plus the size ofcmd
, and the size ofdata
which varies despite ending up as au32
. - try_
next_ cmd - Return the raw command data (a pair
[(u8, u32)]
) while ensuring that an iterator which is literally empty has terminated at the correct location, where the correct location is signalled by the presence of a0
command. - u32_
as_ usize - Converts
n
fromu32
tousize
or panics (which should not happen since we don’t support 16 bit systems). - write_
cmd - Encode the command
cmd
(one of theSTMT_*
,PROOF_*
orUNIFY_*
commands in this module, which are all 6 bit numbers) with the givendata
field according to the following scheme: - write_
cmd_ bytes - This is like
write_cmd
, but it is followed by the byte arraybuf
, and the initialdata
field is the length of the entire expression (the initial command byte, thedata
field, and the buffer). This can’t be expressed withwrite_cmd
directly because of the circular dependency where the value ofdata
determines the size of the initial command, which affects the value ofdata
.
Type Aliases§
- Arg
- Newtype for
Type
that makes some situations easier to read. - Bare
MmbFile - An MMB file parser with no index parser.
- Basic
Index - A basic index, usable for getting names of declarations and variables.
- Basic
MmbFile - An MMB file parser with a basic index, usable for getting names of declarations and variables.