Importing from Metamath to Isabelle - how is it done 
----------------------------------------------------

The contents of this directory:

- mmisar.hs, Utils.hs and Inner.hs contain the Haskell source of the mmisar tool

- known_theorems.txt contains the list of facts imported from Metamath in the current release of IsarMathLib, including the axioms for complex numbers

- readme.txt is this file

We are interested in importing the theorems about complex numbers
that start from recnt on. This is done mostly automatically
by the mmisar tool whose Haskell source is included in the this directory.
The tool can be compiled with GHC and works as follows:

First it reads the list of (Metamath) names of theorems 
that are already imported to IsarMathlib ("known theorems") 
and the list of theorems that are intended to be imported in this 
session ("new theorems"). 
The new theorems are consecutive theorems about real numbers
as they appear in the Metamath database.
Then mmisar creates a "Metamath script" that contains 
Metamath commands that open a log file and put the stataments
and proofs of the new theorems in that file in a readable format. 
The tool writes this script to a disk file and executes metamath 
with standard input redirected from that file. Then the log file is read
and its contents converted to the Isar format. The proofs of new theorems
depend only on axioms of real numbers and some basic set theory theorems.
The tool finds which depemdencies are not known yet and repeats 
the process of getting their statements from Matamath as with the 
new theorems. As a result of this process mmisar creates files 
new_theorems.thy, new_deps.thy and new_known_theorems.txt.
The file new_theorems.thy contains the theorems (with proofs) 
imported from Metamath in this session. These theorems are added
(by hand) to the MMIsar.thy file. The file new_deps.thy contains the 
statements of new dependencies with generic proofs "by auto".
These are added to the @{text "MMI_prelude.thy"} (the current file).
Most of them can be proven automatically by Isabelle.
Then some manual work has to be done for the dependencies
which Isabelle can not prove by itself and to correct problems related
to the fact that Metamath uses a metalogic based on 
distinct variable constraints (Tarski-Megill metalogic), 
rather than an explicit notion of free and bound variables.

The old list of known theorems is replaced by the new list and
mmisar is ready to convert the next batch of new theorems.
Of course this never works in practice without tweaking mmisar.hs
every time a new batch is processed.


