Theory MMI_prelude

theory MMI_prelude
imports Order_ZF_1
(* 
    This file is a part of MMIsar - a translation of Metamath's set.mm to Isabelle 2005 (ZF logic).

    Copyright (C) 2006  Slawomir Kolodynski

    This program is free software; Redistribution and use in source and binary forms, 
    with or without modification, are permitted provided that the following conditions are met:

   1. Redistributions of source code must retain the above copyright notice, 
   this list of conditions and the following disclaimer.
   2. Redistributions in binary form must reproduce the above copyright notice, 
   this list of conditions and the following disclaimer in the documentation and/or 
   other materials provided with the distribution.
   3. The name of the author may not be used to endorse or promote products 
   derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*)


header{*\isaheader{MMI\_prelude.thy}*}

theory MMI_prelude imports Order_ZF_1

begin

text{*Metamath's set.mm features a large (over 8000) collection of theorems 
  proven in the ZFC set theory. This theory is part of an attempt to translate
  those theorems to Isar so that they are available for Isabelle/ZF users.
  A total of about 1200 assertions have been translated, 600 of that 
  with proofs (the rest was proven automatically by Isabelle). 
  The translation was done with the support of the mmisar tool, whose source
  is included in the IsarMathLib distributions prior to version 1.6.4. 
  The translation tool was doing about 99 percent of work involved, with the rest
  mostly related to the difference between Isabelle/ZF and Metamath 
  metalogics. Metamath uses Tarski-Megill metalogic that does not have a notion
  of bound variables (see 
  @{text " http://planetx.cc.vt.edu/AsteroidMeta/Distinctors_vs_binders "}
  for details and discussion).
  The translation project is closed now as I decided that it was too boring 
  and tedious even with the support of mmisar software. Also, the translated
  proofs are not as readable as native Isar proofs which goes against IsarMathLib
  philosophy. *}

section{*Importing from Metamath - how is it done*}

text{*
  We are interested in importing the theorems about complex numbers
  that start from the "recnt" theorem on. This is done mostly automatically
  by the mmisar tool that is included in the IsarMathLib distributions prior
  to version 1.6.4.
  The tool 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 complex 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 statements
  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. In Metamath, 
  the proofs of theorems about complex numbers 
  depend only on 28 axioms of complex numbers and some basic logic and 
  set theory theorems.
  The tool finds which of these dependencies are not known yet and repeats 
  the process of getting their statements from Metamath 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 current @{text "MMI_Complex_ZF_x.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_logic_and_sets.thy"}.
  Most of the dependencies can be proven automatically by Isabelle.
  However, some manual work has to be done for the dependencies
  that 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 rarely works in practice without tweaking the mmisar
  source files every time a new batch is processed.*}

section{*The context for Metamath theorems*}

text{*We list the Metamth's axioms of complex numbers
  and define notation here.*}

text{*The next definition is what Metamath $X\in V$ is
  translated to. I am not sure why it works, probably because
  Isabelle does a type inference and the "=" sign
  indicates that both sides are sets.*}

definition
  IsASet :: "i=>o" ("_ isASet" [90] 90) where
  (*set_def[simp]: "X isASet ≡  X = X"*)
  IsASet_def[simp]: "X isASet ≡  X = X"

text{*The next locale sets up the context to which Metamath theorems
  about complex numbers are imported. It assumes the axioms
  of complex numbers and defines the notation used for complex numbers.
  
  One of the problems with importing theorems from Metamath is that
  Metamath allows direct infix notation for binary operations so 
  that the notation $a f b$ is allowed where $f$ is a function 
  (that is, a set of pairs). To my knowledge, 
  Isar allows only notation @{text "f`⟨a,b⟩"} with a possibility of 
  defining a syntax say @{text "a \<ca> b"} to mean the same as @{text "f`⟨a,b⟩"} 
  (please correct me if I am wrong here). This is why we have
  two objects for addition: one called @{text "caddset"} that represents
  the binary function, and the second one called @{text "ca"} which 
  defines the @{text "a \<ca> b"} notation for @{text "caddset`⟨a,b⟩"}.
  The same applies to multiplication of real numbers.
  
  Another difficulty is that Metamath allows to define sets with syntax
  $\{ x | p\}$ where $p$ is some formula that (usually) depends on $x$.
  Isabelle allows the set comprehension like this only as a subset of another 
  set i.e. $\{x\in A . p(x)\}$. This forces us to have a sligtly different 
  definition of (complex) natural numbers, requiring explicitly that natural 
  numbers is a subset of reals. Because of that, the proofs of Metamath theorems 
  that reference the definition directly can not be imported. 
  *}

locale MMIsar0 =
  fixes real ("\<real>")
  fixes complex ("\<complex>")
  fixes one ("\<one>")
  fixes zero ("\<zero>")
  fixes iunit ("\<i>")
  fixes caddset ("\<caddset>")
  fixes cmulset ("\<cmulset>")
  fixes lessrrel ("\<lsrset>")

  fixes ca (infixl "\<ca>" 69)
  defines ca_def: "a \<ca> b ≡ \<caddset>`⟨a,b⟩"
  fixes cm (infixl "·" 71)
  defines cm_def: "a · b ≡ \<cmulset>`⟨a,b⟩"
  fixes sub (infixl "\<cs>" 69)
  defines sub_def: "a \<cs> b ≡ \<Union> { x ∈ \<complex>. b \<ca> x = a }"
  fixes cneg ("\<cn>_" 95)
  defines cneg_def: "\<cn> a ≡ \<zero> \<cs> a"
  fixes cdiv (infixl "\<cdiv>" 70)
  defines cdiv_def: "a \<cdiv> b ≡ \<Union> { x ∈ \<complex>. b · x = a }"
  fixes cpnf ("\<cpnf>")
  defines cpnf_def: "\<cpnf> ≡ \<complex>"
  fixes cmnf ("\<cmnf>")
  defines cmnf_def: "\<cmnf> ≡ {\<complex>}"
  fixes cxr ("\<real>*")
  defines cxr_def: "\<real>* ≡ \<real> ∪ {\<cpnf>,\<cmnf>}"
  fixes cxn ("\<nat>")
  defines cxn_def: "\<nat> ≡ \<Inter> {N ∈ Pow(\<real>). \<one> ∈ N ∧ (∀n. n∈N --> n\<ca>\<one> ∈ N)}"
  fixes lessr (infix "\<lsr>" 68)
  defines lessr_def: "a \<lsr> b ≡ ⟨a,b⟩ ∈ \<lsrset>"
  fixes cltrrset ("\<cltrrset>")
  defines cltrrset_def: 
  "\<cltrrset> ≡ (\<lsrset> ∩ \<real>×\<real>) ∪ {⟨\<cmnf>,\<cpnf>⟩} ∪ 
  (\<real>×{\<cpnf>}) ∪ ({\<cmnf>}×\<real> )"
  fixes cltrr (infix "\<ls>" 68)
  defines cltrr_def: "a \<ls> b ≡ ⟨a,b⟩ ∈ \<cltrrset>"
  fixes convcltrr (infix ">" 68)
  defines convcltrr_def: "a > b ≡ ⟨a,b⟩ ∈ converse(\<cltrrset>)"
  fixes lsq (infix "\<lsq>" 68)
  defines lsq_def: "a \<lsq> b ≡ ¬ (b \<ls> a)"
  fixes two ("\<two>")
  defines two_def: "\<two> ≡ \<one>\<ca>\<one>"
  fixes three ("\<three>")
  defines three_def: "\<three> ≡ \<two>\<ca>\<one>"
  fixes four ("\<four>")
  defines four_def: "\<four> ≡ \<three>\<ca>\<one>"
  fixes five ("\<five>")
  defines five_def: "\<five> ≡ \<four>\<ca>\<one>"
  fixes six ("\<six>")
  defines six_def: "\<six> ≡ \<five>\<ca>\<one>"
  fixes seven ("\<seven>")
  defines seven_def: "\<seven> ≡ \<six>\<ca>\<one>"
  fixes eight ("\<eight>")
  defines eight_def: "\<eight> ≡ \<seven>\<ca>\<one>"
  fixes nine ("\<nine>")
  defines nine_def: "\<nine> ≡ \<eight>\<ca>\<one>"

  assumes MMI_pre_axlttri: 
  "A ∈ \<real> ∧ B ∈ \<real> --> (A \<lsr> B <-> ¬(A=B ∨ B \<lsr> A))"
  assumes MMI_pre_axlttrn: 
  "A ∈ \<real> ∧ B ∈ \<real> ∧ C ∈ \<real> --> ((A \<lsr> B ∧ B \<lsr> C) --> A \<lsr> C)"
  assumes MMI_pre_axltadd:
  "A ∈ \<real> ∧ B ∈ \<real> ∧ C ∈ \<real> --> (A \<lsr> B --> C\<ca>A \<lsr> C\<ca>B)"
  assumes MMI_pre_axmulgt0:
  "A ∈ \<real> ∧ B ∈ \<real> --> ( \<zero> \<lsr> A ∧ \<zero> \<lsr> B --> \<zero> \<lsr> A·B)"
  assumes MMI_pre_axsup:
  "A ⊆ \<real> ∧ A ≠ 0 ∧ (∃x∈\<real>. ∀y∈A. y \<lsr> x) -->
  (∃x∈\<real>. (∀y∈A. ¬(x \<lsr> y)) ∧ (∀y∈\<real>. (y \<lsr> x --> (∃z∈A. y \<lsr> z))))"
  assumes MMI_axresscn: "\<real> ⊆ \<complex>"
  assumes MMI_ax1ne0: "\<one> ≠ \<zero>"
  assumes MMI_axcnex: "\<complex> isASet"
  assumes MMI_axaddopr: "\<caddset> : ( \<complex> × \<complex> ) -> \<complex>"
  assumes MMI_axmulopr: "\<cmulset> : ( \<complex> × \<complex> ) -> \<complex>"
  assumes MMI_axmulcom: "A ∈ \<complex> ∧ B ∈ \<complex> --> A · B = B · A"
  assumes MMI_axaddcl: "A ∈ \<complex> ∧ B ∈ \<complex> --> A \<ca> B ∈ \<complex>"
  assumes MMI_axmulcl: "A ∈ \<complex> ∧ B ∈ \<complex> --> A · B ∈ \<complex>"
  assumes MMI_axdistr: 
  "A ∈ \<complex> ∧ B ∈ \<complex> ∧ C ∈ \<complex> --> A·(B \<ca> C) = A·B \<ca> A·C" 
  assumes MMI_axaddcom: "A ∈ \<complex> ∧ B ∈ \<complex> --> A \<ca> B = B \<ca> A"
  assumes MMI_axaddass: 
  "A ∈ \<complex> ∧ B ∈ \<complex> ∧ C ∈ \<complex> --> A \<ca> B \<ca> C = A \<ca> (B \<ca> C)"
  assumes MMI_axmulass: 
  "A ∈ \<complex> ∧ B ∈ \<complex> ∧ C ∈ \<complex> --> A · B · C = A · (B · C)"
  assumes MMI_ax1re: "\<one> ∈ \<real>"
  assumes MMI_axi2m1: "\<i> · \<i> \<ca> \<one> = \<zero>"
  assumes MMI_ax0id: "A ∈ \<complex> --> A \<ca> \<zero> = A"
  assumes MMI_axicn: "\<i> ∈ \<complex>"
  assumes MMI_axnegex: "A ∈ \<complex> --> ( ∃ x ∈ \<complex>. ( A \<ca> x ) = \<zero> )"
  assumes MMI_axrecex: "A ∈ \<complex> ∧ A ≠ \<zero> --> ( ∃ x ∈ \<complex>. A · x = \<one>)"
  assumes MMI_ax1id: "A ∈ \<complex> --> A · \<one> = A"
  assumes MMI_axaddrcl: "A ∈ \<real> ∧ B ∈ \<real> --> A \<ca> B ∈ \<real>"
  assumes MMI_axmulrcl: "A ∈ \<real> ∧ B ∈ \<real> --> A · B ∈ \<real>"
  assumes MMI_axrnegex: "A ∈ \<real> --> ( ∃ x ∈ \<real>. A \<ca> x = \<zero> )"
  assumes MMI_axrrecex: "A ∈ \<real> ∧ A ≠ \<zero> --> ( ∃ x ∈ \<real>. A · x = \<one> )";
  

end