Theory Metamath_interface

theory Metamath_interface
imports Complex_ZF MMI_prelude
(* 
This file is a part of IsarMathLib - 
a library of formalized mathematics for Isabelle/Isar.

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{Metamath\_interface.thy}*}

theory Metamath_interface imports Complex_ZF MMI_prelude

begin

text{*This theory contains some lemmas that make it possible to use 
  the theorems translated from Metamath in a the @{text "complex0"} 
  context.*}

section{*MMisar0 and complex0 contexts.*}

text{*In the section we show a lemma that the assumptions in 
   @{text "complex0"} context imply the assumptions of the @{text "MMIsar0"}
   context. The @{text "Metamath_sampler"} theory provides examples 
   how this lemma can be used.*}

text{*The next lemma states that we can use 
  the theorems proven in the @{text "MMIsar0"} context in
  the @{text "complex0"} context. Unfortunately we have to 
  use low level Isabelle methods "rule" and "unfold" in the proof, simp
  and blast fail on the order axioms.
  *}


lemma (in complex0) MMIsar_valid: 
  shows "MMIsar0(\<real>,\<complex>,\<one>,\<zero>,\<i>,CplxAdd(R,A),CplxMul(R,A,M),
  StrictVersion(CplxROrder(R,A,r)))"
proof -
  let ?real = "\<real>"
  let ?complex = "\<complex>"
  let ?zero = "\<zero>"
  let ?one = "\<one>"
  let ?iunit = "\<i>"
  let ?caddset = "CplxAdd(R,A)"
  let ?cmulset = "CplxMul(R,A,M)"
  let ?lessrrel = "StrictVersion(CplxROrder(R,A,r))"
  have "(∀a b. a ∈ ?real ∧ b ∈ ?real -->
    ⟨a, b⟩ ∈ ?lessrrel <-> ¬ (a = b ∨ ⟨b, a⟩ ∈ ?lessrrel))"
  proof -
    have I:
      "∀a b. a ∈ \<real> ∧ b ∈ \<real> --> (a \<lsr> b <-> ¬(a=b ∨ b \<lsr> a))"
      using pre_axlttri by blast;
    { fix a b assume "a ∈ ?real ∧ b ∈ ?real"
      with I have "(a \<lsr> b <-> ¬(a=b ∨ b \<lsr> a))"
	by blast;
      hence
	"⟨a, b⟩ ∈ ?lessrrel <-> ¬ (a = b ∨ ⟨b, a⟩ ∈ ?lessrrel)"
	by simp;
    } thus "(∀a b. a ∈ ?real ∧ b ∈ ?real -->
	(⟨a, b⟩ ∈ ?lessrrel <-> ¬ (a = b ∨ ⟨b, a⟩ ∈ ?lessrrel)))"
      by blast;
  qed;
  moreover
  have "(∀a b c.
    a ∈ ?real ∧ b ∈ ?real ∧ c ∈ ?real -->
    ⟨a, b⟩ ∈ ?lessrrel ∧ ⟨b, c⟩ ∈ ?lessrrel --> ⟨a, c⟩ ∈ ?lessrrel)"
  proof -
    have II: "∀a b c.  a ∈ \<real> ∧ b ∈ \<real> ∧ c ∈ \<real> --> 
      ((a \<lsr> b ∧ b \<lsr> c) --> a \<lsr> c)"
      using pre_axlttrn by blast;
    { fix a b c assume "a ∈ ?real ∧ b ∈ ?real ∧ c ∈ ?real"
      with II have "(a \<lsr> b ∧ b \<lsr> c) --> a \<lsr> c"
	by blast;
      hence 	
	"⟨a, b⟩ ∈ ?lessrrel ∧ ⟨b, c⟩ ∈ ?lessrrel --> ⟨a, c⟩ ∈ ?lessrrel"
	by simp;
    } thus  "(∀a b c.
	a ∈ ?real ∧ b ∈ ?real ∧ c ∈ ?real -->
	⟨a, b⟩ ∈ ?lessrrel ∧ ⟨b, c⟩ ∈ ?lessrrel --> ⟨a, c⟩ ∈ ?lessrrel)"
      by blast;
  qed;
  moreover have "(∀A B C.
    A ∈ ?real ∧ B ∈ ?real ∧ C ∈ ?real -->
    ⟨A, B⟩ ∈ ?lessrrel -->
    ⟨?caddset ` ⟨C, A⟩, ?caddset ` ⟨C, B⟩⟩ ∈ ?lessrrel)"
    using pre_axltadd by simp
  moreover have "(∀A B. A ∈ ?real ∧ B ∈ ?real -->
    ⟨?zero, A⟩ ∈ ?lessrrel ∧ ⟨?zero, B⟩ ∈ ?lessrrel -->
    ⟨?zero, ?cmulset ` ⟨A, B⟩⟩ ∈ ?lessrrel)"
    using pre_axmulgt0 by simp
  moreover have 
    "(∀S. S ⊆ ?real ∧ S ≠ 0 ∧ (∃x∈?real. ∀y∈S. ⟨y, x⟩ ∈ ?lessrrel) -->
    (∃x∈?real.
    (∀y∈S. ⟨x, y⟩ ∉ ?lessrrel) ∧
    (∀y∈?real. ⟨y, x⟩ ∈ ?lessrrel --> (∃z∈S. ⟨y, z⟩ ∈ ?lessrrel))))"
    using pre_axsup by simp;
  moreover have "\<real> ⊆ \<complex>" using axresscn by simp
  moreover have "\<one> ≠ \<zero>" using ax1ne0 by simp
  moreover have "\<complex> isASet" by simp;
  moreover have " CplxAdd(R,A) : \<complex> × \<complex> -> \<complex>" 
    using axaddopr by simp;
  moreover have "CplxMul(R,A,M) : \<complex> × \<complex> -> \<complex>" 
    using axmulopr by simp
  moreover have 
    "∀a b. a ∈ \<complex> ∧ b ∈ \<complex> --> a· b = b · a"
    using axmulcom by simp;
  hence "(∀a b. a ∈ \<complex> ∧ b ∈ \<complex> -->
          ?cmulset ` ⟨a, b⟩ = ?cmulset ` ⟨b, a⟩
    )" by simp;
  moreover have "∀a b. a ∈ \<complex> ∧ b ∈ \<complex> --> a \<ca> b ∈ \<complex>"
    using axaddcl by simp;
  hence "(∀a b. a ∈ \<complex> ∧ b ∈ \<complex> --> 
          ?caddset ` ⟨a, b⟩ ∈ \<complex>
      )" by simp;
  moreover have "∀a b. a ∈ \<complex> ∧ b ∈ \<complex> --> a · b ∈ \<complex>"
    using axmulcl by simp
  hence "(∀a b. a ∈ \<complex> ∧ b ∈ \<complex> --> 
    ?cmulset ` ⟨a, b⟩ ∈ \<complex> )" by simp;
  moreover have 
    "∀a b C. a ∈ \<complex> ∧ b ∈ \<complex> ∧ C ∈ \<complex> --> 
    a · (b \<ca> C) = a · b \<ca> a · C"
    using axdistr by simp
  hence "∀a b C.
         a ∈ \<complex> ∧ b ∈ \<complex> ∧ C ∈ \<complex> -->
         ?cmulset ` ⟨a, ?caddset ` ⟨b, C⟩⟩ =
         ?caddset `
         ⟨?cmulset ` ⟨a, b⟩, ?cmulset ` ⟨a, C⟩⟩" 
    by simp;
  moreover have "∀a b. a ∈ \<complex> ∧ b ∈ \<complex> -->
         a \<ca> b = b \<ca> a"
    using axaddcom by simp;
  hence "∀a b.
          a ∈ \<complex> ∧ b ∈ \<complex> -->
          ?caddset ` ⟨a, b⟩ = ?caddset ` ⟨b, a⟩" by simp;
  moreover have "∀a b C. a ∈ \<complex> ∧ b ∈ \<complex> ∧ C ∈ \<complex> -->
      a \<ca> b \<ca> C = a \<ca> (b \<ca> C)"
    using axaddass by simp
  hence "∀a b C.
          a ∈ \<complex> ∧ b ∈ \<complex> ∧ C ∈ \<complex> -->
          ?caddset ` ⟨?caddset ` ⟨a, b⟩, C⟩ =
          ?caddset ` ⟨a, ?caddset ` ⟨b, C⟩⟩" by simp;
  moreover have 
    "∀a b c. a ∈ \<complex> ∧ b ∈ \<complex> ∧ c ∈ \<complex> --> a·b·c = a·(b·c)"
    using axmulass by simp
  hence "∀a b C.
          a ∈ \<complex> ∧ b ∈ \<complex> ∧ C ∈ \<complex> -->
          ?cmulset ` ⟨?cmulset ` ⟨a, b⟩, C⟩ =
          ?cmulset ` ⟨a, ?cmulset ` ⟨b, C⟩⟩" by simp;
  moreover have "\<one> ∈ \<real>" using ax1re by simp;
  moreover have "\<i>·\<i> \<ca> \<one> = \<zero>"
    using axi2m1 by simp
  hence "?caddset ` ⟨?cmulset ` ⟨\<i>, \<i>⟩, \<one>⟩ = \<zero>" by simp;
  moreover have "∀a. a ∈ \<complex> --> a \<ca> \<zero> = a"
    using ax0id by simp;
  hence "∀a. a ∈ \<complex> --> ?caddset ` ⟨a, \<zero>⟩ = a" by simp;
  moreover have "\<i> ∈ \<complex>" using axicn by simp;
  moreover have "∀a. a ∈ \<complex> --> (∃x∈\<complex>. a \<ca> x = \<zero>)"
    using axnegex by simp;
  hence "∀a. a ∈ \<complex> --> 
    (∃x∈\<complex>. ?caddset ` ⟨a, x⟩ = \<zero>)" by simp;
  moreover have "∀a. a ∈ \<complex> ∧ a ≠ \<zero> --> (∃x∈\<complex>. a · x = \<one>)"
    using axrecex by simp
  hence "∀a. a ∈ \<complex> ∧ a ≠ \<zero> --> 
      ( ∃x∈\<complex>. ?cmulset ` ⟨a, x⟩ = \<one> )" by simp;
  moreover have "∀a. a ∈ \<complex> --> a·\<one> = a"
    using ax1id by simp
 hence " ∀a. a ∈ \<complex> --> 
        ?cmulset ` ⟨a, \<one>⟩ = a" by simp;
 moreover have "∀a b. a ∈ \<real> ∧ b ∈ \<real> --> a \<ca> b ∈ \<real>"
   using axaddrcl by simp;
 hence "∀a b. a ∈ \<real> ∧ b ∈ \<real> --> 
     ?caddset ` ⟨a, b⟩ ∈ \<real>" by simp;
 moreover have "∀a b. a ∈ \<real> ∧ b ∈ \<real> --> a · b ∈ \<real>"
   using axmulrcl by simp;
 hence "∀a b. a ∈ \<real> ∧ b ∈ \<real> --> 
     ?cmulset ` ⟨a, b⟩ ∈ \<real>" by simp;
 moreover have "∀a. a ∈ \<real> --> (∃x∈\<real>. a \<ca> x = \<zero>)"
   using axrnegex by simp
 hence "∀a. a ∈ \<real> --> 
   ( ∃x∈\<real>. ?caddset ` ⟨a, x⟩ = \<zero> )" by simp
 moreover have "∀a. a ∈ \<real> ∧ a≠\<zero> --> (∃x∈\<real>. a · x = \<one>)"
   using axrrecex by simp
 hence "∀a. a ∈ \<real> ∧ a ≠ \<zero> --> 
   ( ∃x∈\<real>. ?cmulset ` ⟨a, x⟩ = \<one>)" by simp;
 
  ultimately have 
"(
   (
      (
         ( ∀a b.
           a ∈ \<real> ∧ b ∈ \<real> -->
           ⟨a, b⟩ ∈ ?lessrrel <->
           ¬ (a = b ∨ ⟨b, a⟩ ∈ ?lessrrel)
         ) ∧
       
         ( ∀a b C.
           a ∈ \<real> ∧ b ∈ \<real> ∧ C ∈ \<real> -->
           ⟨a, b⟩ ∈ ?lessrrel ∧
           ⟨b, C⟩ ∈ ?lessrrel -->
           ⟨a, C⟩ ∈ ?lessrrel
         ) ∧
       
         (∀a b C.
           a ∈ \<real> ∧ b ∈ \<real> ∧ C ∈ \<real> -->
           ⟨a, b⟩ ∈ ?lessrrel -->
           ⟨?caddset ` ⟨C, a⟩, ?caddset ` ⟨C, b⟩⟩ ∈
           ?lessrrel
         )
      ) ∧
           
      (
         ( ∀a b.
           a ∈ \<real> ∧ b ∈ \<real> -->
           ⟨\<zero>, a⟩ ∈ ?lessrrel ∧
           ⟨\<zero>, b⟩ ∈ ?lessrrel -->
           ⟨\<zero>, ?cmulset ` ⟨a, b⟩⟩ ∈
           ?lessrrel
         ) ∧
           
         ( ∀S. S ⊆ \<real> ∧ S ≠ 0 ∧
             ( ∃x∈\<real>. ∀y∈S. ⟨y, x⟩ ∈ ?lessrrel
             ) -->
             ( ∃x∈\<real>. 
                ( ∀y∈S. ⟨x, y⟩ ∉ ?lessrrel
                ) ∧
                ( ∀y∈\<real>. ⟨y, x⟩ ∈ ?lessrrel -->
                   ( ∃z∈S. ⟨y, z⟩ ∈ ?lessrrel
                   )
                )
             )
         )
      ) ∧
      
      \<real> ⊆ \<complex> ∧ 
      \<one> ≠ \<zero>
   ) ∧
      
   ( \<complex> isASet ∧ ?caddset ∈ \<complex> × \<complex> -> \<complex> ∧ 
    ?cmulset ∈ \<complex> × \<complex> -> \<complex>
   ) ∧
   
   (
      (∀a b.
          a ∈ \<complex> ∧ b ∈ \<complex> -->
          ?cmulset ` ⟨a, b⟩ = ?cmulset ` ⟨b, a⟩
      ) ∧
      
      (∀a b. a ∈ \<complex> ∧ b ∈ \<complex> --> 
          ?caddset ` ⟨a, b⟩ ∈ \<complex>
      )
     
   ) ∧
     
   (∀a b. a ∈ \<complex> ∧ b ∈ \<complex> --> 
      ?cmulset ` ⟨a, b⟩ ∈ \<complex>
   ) ∧
     
   (∀a b C.
         a ∈ \<complex> ∧ b ∈ \<complex> ∧ C ∈ \<complex> -->
         ?cmulset ` ⟨a, ?caddset ` ⟨b, C⟩⟩ =
         ?caddset `
         ⟨?cmulset ` ⟨a, b⟩, ?cmulset ` ⟨a, C⟩⟩
   )
) ∧


(
   (
      (∀a b.
          a ∈ \<complex> ∧ b ∈ \<complex> -->
          ?caddset ` ⟨a, b⟩ = ?caddset ` ⟨b, a⟩
      ) ∧
      
      (∀a b C.
          a ∈ \<complex> ∧ b ∈ \<complex> ∧ C ∈ \<complex> -->
          ?caddset ` ⟨?caddset ` ⟨a, b⟩, C⟩ =
          ?caddset ` ⟨a, ?caddset ` ⟨b, C⟩⟩
      ) ∧
      
      (∀a b C.
          a ∈ \<complex> ∧ b ∈ \<complex> ∧ C ∈ \<complex> -->
          ?cmulset ` ⟨?cmulset ` ⟨a, b⟩, C⟩ =
          ?cmulset ` ⟨a, ?cmulset ` ⟨b, C⟩⟩
      )
   ) ∧
   
   
   (\<one> ∈ \<real> ∧ 
    ?caddset ` ⟨?cmulset ` ⟨\<i>, \<i>⟩, \<one>⟩ = \<zero>
   ) ∧
   
   (∀a. a ∈ \<complex> --> ?caddset ` ⟨a, \<zero>⟩ = a
   ) ∧
    
   \<i> ∈ \<complex>
) ∧
   
(
   (∀a. a ∈ \<complex> --> 
      (∃x∈\<complex>. ?caddset ` ⟨a, x⟩ = \<zero>
      )
   ) ∧
      
   ( ∀a. a ∈ \<complex> ∧ a ≠ \<zero> --> 
      ( ∃x∈\<complex>. ?cmulset ` ⟨a, x⟩ = \<one>
      )
   ) ∧
   
   ( ∀a. a ∈ \<complex> --> 
        ?cmulset ` ⟨a, \<one>⟩ = a
   )
) ∧
   
(
   ( ∀a b. a ∈ \<real> ∧ b ∈ \<real> --> 
     ?caddset ` ⟨a, b⟩ ∈ \<real>
   ) ∧
      
   ( ∀a b. a ∈ \<real> ∧ b ∈ \<real> --> 
     ?cmulset ` ⟨a, b⟩ ∈ \<real>
   )
) ∧
    
( ∀a. a ∈ \<real> --> 
   ( ∃x∈\<real>. ?caddset ` ⟨a, x⟩ = \<zero>
   ) 
) ∧
   
( ∀a. a ∈ \<real> ∧ a ≠ \<zero> --> 
   ( ∃x∈\<real>. ?cmulset ` ⟨a, x⟩ = \<one>
   )
)"
  by blast;
then show "MMIsar0(\<real>,\<complex>,\<one>,\<zero>,\<i>,CplxAdd(R,A),CplxMul(R,A,M),
  StrictVersion(CplxROrder(R,A,r)))" unfolding MMIsar0_def by blast;
qed;
  

end