src/HOL/Tools/Qelim/ferrante_rackoff.ML
changeset 36945 9bec62c10714
parent 36862 952b2b102a0a
equal deleted inserted replaced
36944:dbf831a50e4a 36945:9bec62c10714
    67    fun fw mi th th' th'' =
    67    fun fw mi th th' th'' =
    68      let
    68      let
    69       val th0 = if mi then
    69       val th0 = if mi then
    70            instantiate ([],[(p1_v, p1),(p2_v, p2),(mp1_v, mp1), (mp2_v, mp2)]) th
    70            instantiate ([],[(p1_v, p1),(p2_v, p2),(mp1_v, mp1), (mp2_v, mp2)]) th
    71         else instantiate ([],[(p1_v, p1),(p2_v, p2),(mp1_v, pp1), (mp2_v, pp2)]) th
    71         else instantiate ([],[(p1_v, p1),(p2_v, p2),(mp1_v, pp1), (mp2_v, pp2)]) th
    72      in implies_elim (implies_elim th0 th') th'' end
    72      in Thm.implies_elim (Thm.implies_elim th0 th') th'' end
    73   in (fw true th1 th_1 th_1', fw false th2 th_2 th_2',
    73   in (fw true th1 th_1 th_1', fw false th2 th_2 th_2',
    74       fw true th3 th_3 th_3', fw false th4 th_4 th_4', fw true th5 th_5 th_5')
    74       fw true th3 th_3 th_3', fw false th4 th_4 th_4', fw true th5 th_5 th_5')
    75   end
    75   end
    76  val U_v = (Thm.dest_arg o Thm.dest_arg o Thm.dest_arg1) (cprop_of qe)
    76  val U_v = (Thm.dest_arg o Thm.dest_arg o Thm.dest_arg1) (cprop_of qe)
    77  fun main vs p =
    77  fun main vs p =
    86    val q = Thm.rhs_of nth
    86    val q = Thm.rhs_of nth
    87    val qx = Thm.rhs_of nthx
    87    val qx = Thm.rhs_of nthx
    88    val enth = Drule.arg_cong_rule ce nthx
    88    val enth = Drule.arg_cong_rule ce nthx
    89    val [th0,th1] = map (instantiate' [SOME cT] []) @{thms "finite.intros"}
    89    val [th0,th1] = map (instantiate' [SOME cT] []) @{thms "finite.intros"}
    90    fun ins x th =
    90    fun ins x th =
    91       implies_elim (instantiate' [] [(SOME o Thm.dest_arg o Thm.dest_arg)
    91       Thm.implies_elim (instantiate' [] [(SOME o Thm.dest_arg o Thm.dest_arg)
    92                                        (Thm.cprop_of th), SOME x] th1) th
    92                                        (Thm.cprop_of th), SOME x] th1) th
    93    val fU = fold ins u th0
    93    val fU = fold ins u th0
    94    val cU = funpow 2 Thm.dest_arg (Thm.cprop_of fU)
    94    val cU = funpow 2 Thm.dest_arg (Thm.cprop_of fU)
    95    local
    95    local
    96      val insI1 = instantiate' [SOME cT] [] @{thm "insertI1"}
    96      val insI1 = instantiate' [SOME cT] [] @{thm "insertI1"}
   100      case term_of S of
   100      case term_of S of
   101         Const(@{const_name Orderings.bot}, _) => raise CTERM ("provein : not a member!", [S])
   101         Const(@{const_name Orderings.bot}, _) => raise CTERM ("provein : not a member!", [S])
   102       | Const(@{const_name insert}, _) $ y $_ =>
   102       | Const(@{const_name insert}, _) $ y $_ =>
   103          let val (cy,S') = Thm.dest_binop S
   103          let val (cy,S') = Thm.dest_binop S
   104          in if term_of x aconv y then instantiate' [] [SOME x, SOME S'] insI1
   104          in if term_of x aconv y then instantiate' [] [SOME x, SOME S'] insI1
   105          else implies_elim (instantiate' [] [SOME x, SOME S', SOME cy] insI2)
   105          else Thm.implies_elim (instantiate' [] [SOME x, SOME S', SOME cy] insI2)
   106                            (provein x S')
   106                            (provein x S')
   107          end
   107          end
   108    end
   108    end
   109    val tabU = fold (fn t => fn tab => Termtab.update (term_of t, provein t cU) tab)
   109    val tabU = fold (fn t => fn tab => Termtab.update (term_of t, provein t cU) tab)
   110                    u Termtab.empty
   110                    u Termtab.empty
   150                           | Gt => [minf_gt, pinf_gt, nmi_gt, npi_gt, ld_gt]
   150                           | Gt => [minf_gt, pinf_gt, nmi_gt, npi_gt, ld_gt]
   151                           | Ge => [minf_ge, pinf_ge, nmi_ge, npi_ge, ld_ge]
   151                           | Ge => [minf_ge, pinf_ge, nmi_ge, npi_ge, ld_ge]
   152                           | Eq => [minf_eq, pinf_eq, nmi_eq, npi_eq, ld_eq]
   152                           | Eq => [minf_eq, pinf_eq, nmi_eq, npi_eq, ld_eq]
   153                           | NEq => [minf_neq, pinf_neq, nmi_neq, npi_neq, ld_neq])
   153                           | NEq => [minf_neq, pinf_neq, nmi_neq, npi_neq, ld_neq])
   154                     val tU = U t
   154                     val tU = U t
   155                     fun Ufw th = implies_elim th tU
   155                     fun Ufw th = Thm.implies_elim th tU
   156                  in [mi_th, pi_th, Ufw nmi_th, Ufw npi_th, Ufw ld_th]
   156                  in [mi_th, pi_th, Ufw nmi_th, Ufw npi_th, Ufw ld_th]
   157                  end
   157                  end
   158          in ([], K (mi_th, pi_th, nmi_th, npi_th, ld_th)) end)
   158          in ([], K (mi_th, pi_th, nmi_th, npi_th, ld_th)) end)
   159    val (minf_th, pinf_th, nmi_th, npi_th, ld_th) = divide_and_conquer decomp_mpinf q
   159    val (minf_th, pinf_th, nmi_th, npi_th, ld_th) = divide_and_conquer decomp_mpinf q
   160    val qe_th = Drule.implies_elim_list
   160    val qe_th = Drule.implies_elim_list
   162                    (instantiate' [] (map SOME [cU, qx, get_p1 minf_th, get_p1 pinf_th])
   162                    (instantiate' [] (map SOME [cU, qx, get_p1 minf_th, get_p1 pinf_th])
   163                         qe))
   163                         qe))
   164                   [fU, ld_th, nmi_th, npi_th, minf_th, pinf_th]
   164                   [fU, ld_th, nmi_th, npi_th, minf_th, pinf_th]
   165     val bex_conv =
   165     val bex_conv =
   166       Simplifier.rewrite (HOL_basic_ss addsimps simp_thms@(@{thms "bex_simps" (1-5)}))
   166       Simplifier.rewrite (HOL_basic_ss addsimps simp_thms@(@{thms "bex_simps" (1-5)}))
   167     val result_th = fconv_rule (arg_conv bex_conv) (transitive enth qe_th)
   167     val result_th = fconv_rule (arg_conv bex_conv) (Thm.transitive enth qe_th)
   168    in result_th
   168    in result_th
   169    end
   169    end
   170 
   170 
   171 in main
   171 in main
   172 end;
   172 end;