Definitions in Mizar
Table of Contents
1. Introduction
These are some quick notes on Josef Urban's "Translating Mizar for First Order Theorem Provers", In Mathematical Knowledge Management: Proceedings of the Second International Conference (Eds., A. Asperti, B. Buchberger, J.H. Davenport), Springer-Verlag, Lecture Notes in Computer Science vol 2594, 2003, pp. 203–215.
The Mizar Syntax might be consulted from time to time. All syntactic
categories will be written in pseudo-BNF brackets, like so:
<category>
. (The Mizar wiki appears to use some variant of EBNF, it
seems.)
For some concrete examples of definitions, see some worked example definitions in finite group theory.
2. General Descriptions
2.1. Mizar Language
The main parts of a Mizar article are:
- Definitions
<Definitional-Items>
<Function>
<Predicate>
<Mode>
<Structure>
<Attribute-Definition>
<Theorems>
<Schemes>
2.1.1. Attributes
Attributes are predicates handled specially by the system, according to
rules defined by the user in <Cluster-Registrations>
.
2.1.2. Terms
All Mizar terms are typed. There is a largest (default) type called
set
or Any
.
All other types have one or more mother types.
Types of variables are given either in global <Reservations>
or local
<Loci-Definitions>
or inside quantified formulas.
Types of other terms are computed according to <Functor-Definitions>
.
Types can have arguments (i.e., be parametrized) in Mizar, e.g.,
Element of X
or Function of NAT, REAL
are legal types with one or
two aguments, respectively.
References
- F. Wiedijk,
"Mizar's Soft Type System."
In: K. Schneider & J. Brandt (eds.), Theorem Proving in Higher Order Logics 2007, LNCS 4732, 383-399, 2007 pdf.
Discusses how Mizar handles types atop set theory.
2.1.3. Type Translation
Type translation is the largest part of the first order translation. There are two basic approaches to type translation:
- Types can be thought of as set-theoretic classes
- Types can be thought of as predicates; thus
set(X)
is true for anyX
,Integer(X)
is true iffX
is an integer, andElement(X,Y)
is true iffX
is an element ofY
.
2.2. Syntactic Levels
Constructors are the real, unambiguous functions, predicates, types, and attributes to which the patterns are translated before any checking takes place.
Patterns are mapped to the constructors; they accomodate the need for having different symbols for the same constructor or vice-versa.
The process, mapping patterns to constructors, is done separately for
each Mizar article depending on its <Environment-Declarations>
. It is
usually quite nontrivial.
(I suppose this is somewhat analogous to a macro system?)
2.3. First Order Formats, Outline of Translation
The possible choices were TPTP, DFG (for SPASS), and Otter formatting. Urban went with DFG for SPASS.
The basic approach to translation was the following:
- The Mizar Parser and Analyzer translated Mizar articles to the constructor level
- Absolute (i.e., context independent) names are given to all constructors
- Definitions of constructors translate usually to several first-order
formulas
- We have to translate both the type hierarchy information given in
the definition, and the actual
<Definiens>
- We have to translate both the type hierarchy information given in
the definition, and the actual
- Sometimes additional properties of the defined constructor are stated
inside the definition (e.g., commutativity, transitivity, etc.).
- They are also translated into corresponding first-order formulas.
- All formulas are relativized with respect to the typed variables
occurring in them; so
for x being Real holds x-x = 0
translates toReal(x) implies x-x=0
3. Translations of Mizar Definitions
3.1. Mode Definitions
The syntactic structure of <Mode-Definition>
is:
<Mode-Definition> = "mode" <Mode-Pattern> ( [ <Specification> ] [ "means" <Definiens> ] ";" <Correctness-Conditions> | "is" <Type-Expression> ";" ) { <Mode-Property> } . <Mode-Pattern> = <Mode-Symbol> [ "of" <Loci> ] . <Mode-Symbol> = <Symbol> | "set" <Loci> = <Locus> { "," <Locus> } <Locus> = <Variable-Identifier>
An example of this might be:
definition let X; mode Element of X means :Def2: it in X if X is non empty otherwise it is empty; existency by BOOLE:def 1; consistency; end;
- We have the
<Loci-Declaration>
be the first statement after the definition, i.e., the "let X;
" is such a declaration. It declares the variables occurring in the definition. - The
<Specification>
part is missing for this example. (If it were present, it gives the "mother type" for the newly defined mode. If not, the largest typeset
is used as the mother type.) - The
<Definiens>
after the keywordmeans
consists of an optional<Label-Identifier>
and either (a) a simple sentence, or (b) several sentences separated by the keywordsif
andotherwise
. The latter condition (<Conditional-Definiens>
) is used for "per cases" definitions.- In our example, the
<Conditional-Definiens>
separates the case when the mode argumentX
is non-empty from the case when it is empty.- For the first case states, for any
it
(special variable used in definitions) being of typeElement of X
means thatit in X
- The second case, in the degenerate case when
X
is empty, being of the typeElement of X
means to be empty too.
- For the first case states, for any
- In our example, the
<Correctness-Conditions>
in our example is given by theexistence
andconsistency
conditions.- The
existence
condition states the extension of the defined type is non-empty - The
consistency
condition states the disjunction of all the cases into which the definition was split, is true.
- The
(Note, Element of
transforms a given set into a "soft type".)
Types in Mizar may be translated as predicates. So n
-ary types become
n+1
-ary predicates. So, the Mizar type qualification X is Element of
Y
will be translated as m1_subset_1(X,Y)
.
The definiens translates as m1_subset_1(X,Y) iff ( (not(empty(Y)) and
in(X,Y)) or (empty(X) and empty(Y)) )
.
The existence condition translates to: forall([Y], exists([X],
m1_subset_1(X,Y)))
Another couple examples, from binop_1.miz
:
definition let A be set; :: loci-declaration :: defines a unary operation on A mode UnOp of A is Function of A,A; :: defines a binary operation on A, note that [:A,A:] is the Cartesian product of A with A mode BinOp of A is Function of [:A,A:],A; end;
3.2. Predicate and Attribute Definitions
The syntactic structure to a <Predicate-Definition>
is:
<Predicate-Definition> = "pred" <Predicate-Pattern> [ "means" <Definiens> ] ";" <Correctness-Conditions> { <Predicate-Property> } .
3.2.1. Example
An example given:
definition let X,Y: pred X c= Y means :: TARSKI:def 3 x in X implies x in Y; reflexivity; end;
We have the <Loci-Declaration>
right after the definition, it is
specifically let X,Y;
indicating we have two sets X
and Y
.
Then we have the <Predicate-Pattern>
for our example be X c= Y
.
The <Definiens>
is "x in Y implies x in Y
".
The <Predicate-Property>
is states simply as reflexivity;
.
The <Correctness-Conditions>
occur only in redefinitions of
predicates, which we will discuss later.
So this definition creates both a pattern and a constructor.
3.2.2. Translation
The <Definiens>
formula is translated as equivalence:
r1_tarski(X,Y) iff (x in X implies x in Y)
.
The <Predicate-Property>
can be symmetry, connectedness, reflexivity,
or irreflexivity. We could add a corresponding theorem for each
property, e.g., proving r1_tarski(X,X)
.
3.2.3. Attributes
Attributes are very similar to predicates. They are used to restrict a
type to a subtype. They are adjectives which can be assembled together
(e.g., finite non empty set
uses the adjectives finite
and non
empty
— finite
and empty
are attributes, non empty
is the
negation of empty
). The syntax for it is:
<Attribute-Definition> = "attr" <Attribute-Pattern> "means" <Definiens> ";" <Correctness-Conditions> .
Here's an example:
definition let i be number; attr i is even means ex j being Integer st i = 2*j; end;
- We have the
<Loci-Definition>
be "let i be number
" - The
<Attribute-Pattern>
is here "i is even
" —is
is a keyword,even
is the attribute we are defining. - The
<Definiens>
is "ex j being Integer st i = 2*j
"
Example 2. From
Formalization of Fundamental Theorem of Finite Abelian Groups in Mizar (by Kazuhisa Nakasho,
Hiroyuki Okazaki, Hiroshi Yamazaki, and Yasunari Shidama) discusses the
formalization of groups in Mizar. The definition of a group appears in
group_1.miz
by first introducing attributes on the notion of a magma
(recall, a magma consists of a set equipped with some [not necessarily
associative] law of composition). Mizar refers to a multMagma
as a
magma with a single law of composition.
definition let IT be multMagma; :: definition 1: unital attr IT is unital means ex e being Element of IT st for h being Element of IT holds h * e = h & e * h = h; :: definition 2: group-like attr IT is Group-like means :Def2: ex e being Element of IT st for h being Element of IT holds h * e = h & e * h = h & ex g being Element of IT st h * g = e & g * h = e; :: definition 3: associative attr IT is associative means :Def3: for x,y,z being Element of IT holds (x*y )*z = x*(y*z); end;
This is really 3 attributes:
- A magma is defined to be "unital" if there is an element
e
such that for any elementh
of the magma,eh = he = h
. - A magma is group-like if there is a unit (with respect to the law of composition), and inverses exist.
- A magma is called associative if for any elements
x
,y
, andz
we have(xy)z = x(yz)
.
3.3. Functor Definitions
Functors are parametrized constants in Mizar. For example, if G
is a
group, then its identity element is 1_G
which is parametrized by G
.
The cyclic group \(\mathbb{Z}/n\mathbb{Z}\) is INT.Group(n)
parametrized
by a positive integer n
(this is defined in GR_CY_1:def 5
).
Functions must define the types of their arguments and the type of their
result. Several <Functor-Properties>
(like commutativity
) can be
associated with them. The syntax is:
<Functor-Definition> = "func" <Functor-Pattern> [ <Specification> ] [ ( "means" | "equals" ) <Definiens> ] ";" <Correctness-Conditions> { <Functor-Property> } . <Specification> = "->" <Type-Expression>
Mizar demands that every functor be accompanied by a proof of existence and uniqueness.
The example given:
definition let x be real number; func -x -> real number means :Def1: x + it = 0; existence by AXIOMS:19; uniqueness by Th10;
Lets analyze this definition.
- The
<Loci-Declaration>
declares a variablex
for the typenumber
with the adjectivereal
- The type
number
is now just a convenient synonym for the larget typeset
, andreal
is also defined in the same Mizar articlearytm
.
- The type
- The
<Functor-Pattern>
is-x
here - The
<Specification>
is-> real number
, which tells us the result type of the function (a real number). - The
<Definiens>
here is:Def1: x + it = 0
. - The
<Correctness-Condition>
, we have 2 of them which the system always checks:- "
existence
" states there exists an object (of the desired typereal number
) conforming to the<Definiens>
- "
uniqueness
" says it is unique (proven, in fact, by a previous theorem,Th10
)
- "
The definition creates one new pattern, and one new constructor.
Defining a "morphism" requires some involved work with cluster
registrations, it's not as simple as defining a new function. See, e.g.,
how group morphisms are defined in
group_6.miz
.
3.4. Structures
Intuitively, a structure is a tuple with named components.
From algstr_0.miz
, we have:
:: Multiplicative structures definition struct (1-sorted) multMagma (# carrier -> set, multF -> BinOp of the carrier #); end; :: multiplication is later defined as: :: :: definition :: let M be multMagma; :: let x,y be Element of M; :: func x*y -> Element of M equals :: (the multF of M).(x,y); :: coherence; :: end;
This introduces a multMagma
structure, which inherits the 1-sorted
structure. Loosely, structures are analogous to classes (they define new
types, they have a constructor — in this case, it's multMagma(# X, op #)
,
and so on). We can access the fields of the structure by writing
things like the multF of M
to get the multF
field, and the carrier
to get its underlying set.
(This is a common Mizar idiom, using carrier
as the name of the
underlying set of a mathematical gadget.)
Our intuition should be that a struct
is how Mizar encodes stuff and
structure (in the Baez–Dolan sense). Indeed, idiomatic Mizar will
encode a mathematical gadget in this manner, with a Gadget-like
attribute for a GadgetStr
structure, then we will find a
mode Gadget means Gadget-like GadgetStr
type definition.
Another example of a structure (from VECTSP_1
), this time using over
:
:: VECTSP_1 definition let F be 1-sorted; struct(addLoopStr) ModuleStr over F (# carrier -> set, addF -> BinOp of the carrier, ZeroF -> Element of the carrier, lmult -> Function of [:the carrier of F, the carrier:], the carrier #); end;
For details about structures in Mizar, see:
- Gilbert Lee and Piotr Rudnicki,
"Alternative aggregates in Mizar."
In Towards Mechanized Mathematical Assistants, pp. 327-341. Springer, Berlin, Heidelberg, 2007.
3.5. Cluster Registrations
There are several types of cluster registrations:
- Existential registration: asserts an attributed type is non empty (and thus permits us to use an attribute as an adjective)
- Conditional registration: propagates types (for example, every characteristic subgroup is also a normal subgroup; conditional registration makes this association automatic)
- Functorial registration, another propagation mechanism
For further reading about attributes, see:
- Christoph Schwarzweller,
"Mizar attributes: A technique to encode mathematical knowledge into type systems."
Studies in Logic, Grammar and Rhetoric 10, no. 23 (2007) pp.387–400.
4. References
So, just to collate all the citations in one place.
- Gilbert Lee and Piotr Rudnicki,
"Alternative aggregates in Mizar."
In Towards Mechanized Mathematical Assistants, pp. 327-341. Springer, Berlin, Heidelberg, 2007. - Christoph Schwarzweller,
"Mizar attributes: A technique to encode mathematical knowledge into type systems."
Studies in Logic, Grammar and Rhetoric 10, no. 23 (2007) pp.387–400. - Kazuhisa Nakasho and Hiroyuki Okazaki and Hiroshi Yamazaki and
Yasunari Shidama,
"Formalization of Fundamental Theorem of Finite Abelian Groups in Mizar".
In 6th Podlasie Conference on Mathematics (6PCM) (2014) pp.23–34. - Josef Urban,
"Translating Mizar for First Order Theorem Provers".
In Mathematical Knowledge Management: Proceedings of the Second International Conference (Eds., A. Asperti, B. Buchberger, J.H. Davenport), Springer-Verlag, Lecture Notes in Computer Science vol 2594, 2003, pp. 203–215. - F. Wiedijk,
"Mizar's Soft Type System."
In: K. Schneider & J. Brandt (eds.), Theorem Proving in Higher Order Logics 2007, LNCS 4732, 383-399, 2007 pdf.
- Discusses how Mizar handles types atop set theory.
- C. Kaliszyk and K. Pąk,
"Semantics of Mizar as an Isabelle Object Logic".
J Autom Reasoning 63 (2019) pp.557–595. https://doi.org/10.1007/s10817-018-9479-z- Discusses implementing Mizar in Isabelle, a fascinating exercise