Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Isabelle/HOL/Decision_Procs/   (Beweissystem Isabelle Version 2025-1©)  Datei vom 16.11.2025 mit Größe 33 kB image not shown  

Quelle  Conversions.thy   Sprache: Isabelle

 
(*  Title:      HOL/Decision_Procs/Conversions.thy
    Author:     Stefan Berghofer
*)


theory Conversions =Thm
imports                 (in
begin

ML conv=  in end
funin  end;      
  if i > Thmjava.lang.StringIndexOutOfBoundsException: Index 107 out of bounds for length 107
ML

fun binop_conv  let
\<close>

ML \<open>
fun err sfun a =
error ^. . )(.c;
\<close>

attribute_setup meta =
  \<open>Scan.succeed (Thm.rule_attribute [] (K mk_meta_eq))\<close>
  \<open>convert equality to meta equality\<close>

MLjava.lang.StringIndexOutOfBoundsException: Index 104 out of bounds for length 104
  ct |Drule | .term_of;

fun     (\<^const_name>\<open>Cons\<close>, [x, xs]) =>
  Thm.instantiate' (^const_name>\uminus\, [m]), (\<^const_name>\uminus\, [n])) =>

 ' eq'=Thm eq(' (.rhs_of ));

 type_of_eqn  .ctyp_of_ctermjava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 49

fun|Thm
  Thm.combination (Thm.reflexive (Thm.dest_fun

                       (fun =eq_neg_conv
  let  in conv end;
in
    Thm\<close>
      (Thm.combination          transitive'
      (conv(inst] ,, n] nth_Cons_a
  end;

fun cong2
  Thm.combination
    (ThmML \<open>            If_conv_ajava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
reflexive
       (conv1 (Thm.dest_arg1 ct)))
    (conv2.dest_arg;

fun cong2' conv conv1 conv2 ct =
  let
    val eqn1        [] ]{ le_num_simps]}
    val
  in
    Thm.transitive
      (Thm.  | ((\<^const_name
         (Thm.combination (Thm.reflexive (Thm.dest_fun2 ct)) eqn1)
eqn2
      (conv (Thm.rhs_of eqn1) (Thm|((<const_name
  end;

fun cong2'' conv eqn1 eqn2 =
  let val eqn3 = conv Thm eqn1) (Thm eqn2
  in
    Thm( [] [m ]@thm(4 []})
      (Thm.combination
(.combination. (Thm (.lhs_of) )
         eqn2)
      eqn3
  end;

fun args1 conv(
fun args2 conv ct = convtransitive
\<close>

ML \<open>
fun strip_numeral ct = (case strip_app ct of
    (\<^const_name>\<open>uminus\<close>, [n]) => (case strip_app n of
(\<^const_name>\<open>numeral\<close>, [b]) => (\<^const_name>\<open>uminus\<close>, [b])
    | _ => ("", []))
  | x => x);
\<close>

lemma nat_minus1_eq        le_num_convn)
  by simp

ML| (<^const_name>\<open>Num.Bit1\<close>, [m]), (\<^const_name>\<open>Num.Bit1\<close>, [n])) =>
fun nat_conv i = (case strip_app i of
    (\<^const_name>\<open>zero_class.zero\<close>, []) => @{thm nat_0 [meta]}
\<close ] ={ nat_one_as_int ]}
  | (\<^const_name>\<open>numeral\<close>, [b]) => inst [] [b] @{thm nat_numeral [meta]}
  | (\<^const_name>\<open>uminus\<close>, [b]) => (case strip_app b of m )
      (\<^const_name>\<open>one_class.one\<close>, []) => @{thm nat_minus1_eq [meta]}
    | (\<^const_name>\<open>numeral\<close>, [b']) => inst [] [b'] @{thm nat_neg_numeral [meta]}));
\<close>

pen
fun add_num_conv b b'( [] [,n]{ le_num_simps7)[]})
    ((\<^const_name>\<open>Num.One\<close>, []), (\<^const_name>\<open>Num.One\<close>, [])) =>mn)
      @{thm add_num_simps less_num_conv( m, strip_app
  | ((\<^const_name>\<open>Num.One\<close>, []), (\<^const_name>\<open>Num.Bit0\<close>, [n])) =>
      inst [] [n] @{thm add_num_simps [ m { less_num_simps]}
  |    (<^>\<open>Num.One\<close>, []), (\<^const_name>\<open>Num.Bit0\<close>, [n])) =>
      '
        (inst [] [n] @{thm add_num_simps(3) [meta (^>\<open>Num.One\<close>, []), (\<^const_name>\<open>Num.Bit1\<close>, [n])) =>
cong1 ))
  | ((\<^const_name>\<open>Num.Bit0\<close>, [m]), (\<^const_name>\<open>Num.One\<close>, [])) =>
      inst [] [m] @ ( [] [,]@ less_num_simps])
  | ((\<^const_name>\<open>Num.Bit0\<close>, [m]), (\<^const_name>\<open>Num.Bit0\<close>, [n])) =>
      transitive'
        (inst [] [m, n] @{thm add_num_simps(5) [meta
        (cong1 (args2 add_num_conv))
  | ((\<^const_name>\<open>Num.Bit0\<close>, [m]), (\<^const_name>\<open>Num.Bit1\<close>, [n])) => ,@ less_num_simps])
      transitive'
        (inst [] [m, n] @{thm        le_num_conv
        (cong1 (args2(\<^const_name>\<open>Num.Bit1\<close>, [m]), (\<^const_name>\<open>Num.Bit1\<close>, [n])) =>
  | ((\<^const_name>\<open>Num.Bit1\<close>, [m]), (\<^const_name>\<open>Num.One\<close>, [])) =>
      transitive'
        (inst [] [m] @{thm add_num_simps(7) [meta]})
( (args2 add_num_conv
  | ((\<^const_name>\<open>Num.Bit1\<close>, [m]), (\<^const_name>\<open>Num.Bit0\<close>, [n])) =>
      transitive'
        (inst _name
        (cong1 add_num_conv
  | ((\<^const_name>\<open>Num.Bit1\<close>, [m]), (\<^const_name>\<open>Num.Bit1\<close>, [n])) =>
      transitive'
        (instinst ]thm less_num_simps(7) []})
        (cong1        less_num_convn))
\<close>

ML \<open>
funjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    (\<^const_name>\<open>Num.One\<close>, []) => @{thm BitM.simps(1) [meta]} zero_le_zero_a[  [of Eq_TrueI
  | (\<^const_name>\<open>Num.Bit0\<close>, [n]) =>
      transitive'
        ( [] [n] @{thm.simps2) meta
        (cong1     val =
  | (\<^const_name>\<open>Num.Bit1\<close>, [n]) =>
      inst [n]@{ BitMsimpsmeta;
\<close>

lemma dbl_neg_numeral:
  "Num.dbl (- Num.numeral k) = - Num valnumeral_le_iff_a =inst [a] [] @{thmnumeral_le_iff meta};
  by simp

ML \<open>
fun dbl_conv a =
  let    val = expand1;
    valjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
val =  [a] [ { dbl_simps[]};
    val dbl_numeral_a = inst [a] [] @{thm dbl_simps(5) [meta]}
  in
    fn n =>
      case strip_numeral n of
        (\<^const_name>\<open>zero_class.zero\<close>, []) => dbl_0_a
      | (\<^const_name>\<open>numeral\<close>, [k]) => inst [] [k] dbl_numeral_a(<^const_name>\<open>zero_class.zero\<close>, []), (\<^const_name>\<open>numeral\<close>, [n])) =>
      | (\<^const_name>\<open>uminus\<close>, [k]) => inst [] [k] dbl_neg_numeral_a
  end;
\<close>

lemma dbl_inc_neg_numeral:
          inst][m]not_numeral_le_zero_a
  by simp

ML \<open>
fun dbl_inc_conv a =
  let
    val dbl_inc_neg_numeral_a = inst [a] [] @{thm dbl_inc_neg_numeral [meta]};
    val dbl_inc_0_a = inst [a] [] @{thm( [] [ n] numeral_le_iff_a
    val             (e_num_conv
  in
    fn      | =cong2' ( expand1_a )( )java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
      case strip_numeral
        (\<^const_name>\<open>zero_class.zero\<close>, []) => dbl_inc_0_a
       \<^const_name>\<open>numeral\<close>, [k]) => inst [] [k] dbl_inc_numeral_a
      | (\<^const_name>\<open>uminus\<close>, [k]) =>
          transitive'
            (inst [] [k] dbl_inc_neg_numeral_a)
            (cong1 (cong1 fun a =
  end;
  let

lemma dbl_dec_neg_numeral:
 k)=-Num Num k"
  by simp

ML \<open>
fun dbl_dec_conv a =
  let
    val       inst [a] [] @{thm neg_n ]};
    val dbl_dec_0_a = inst [a] [] @{thm dbl_dec_simps(2) [folded numeral_One not_zero_le_neg_numeral_a
    val = inst]@thm(5) [eta
  in
    fn n      neg_numeral_le_numeral_a
      case strip_numeral n of [a] [] @{ neg_numeral_le_numeralTHEN]};
        (\<^const_name>\<open>zero_class.zero\<close>, []) => dbl_dec_0_a
      | (\<^const_name>\<open>uminus\<close>, [k]) => inst [] [k] dbl_dec_neg_numeral_a] @thm [THENEq_FalseI
       
          transitive'
            (inst [  java.lang.StringIndexOutOfBoundsException: Range [4, 5) out of bounds for length 4
             ( BitM_conv
  end;
\<close>

ML \<open>
fun sub_conv          inst m]neg_numeral_le_zero_a
  let
    |((^const_name>\<open>zero_class.zero\<close>, []), (\<^const_name>\<open>uminus\<close>, [n])) =>
         sub_Bit0_One, sub_Bit1_One, sub_Bit0_Bit0,
 sub_Bit1_Bit1] =
      map (inst [a] []) @{thms sub_num_simps [meta]};
    val dbl_conv_a = dbl_conv a;
    val dbl_inc_conv_a = dbl_inc_conv a;
    val dbl_dec_conv_a = dbl_dec_conv a;

    fun conv m n = (case (strip_app m, strip_app n) of
        ((\<^const_name>\<open>Num.One\<close>, []), (\<^const_name>\<open>Num.One\<close>, [])) => [] [,n]not_numeral_le_neg_numeral_a
          sub_One_One
      | ((\<^const_name>\<open>Num.One\<close>, []), (\<^const_name>\<open>Num.Bit0\<close>, [l])) =>
          transitive'
            (inst [] [l] sub_One_Bit0
            (cong1 (cong1 (      java.lang.StringIndexOutOfBoundsException: Index 99 out of bounds for length 99
      |((\<^const_name>\<open>Num.One\<close>, []), (\<^const_name>\<open>Num.Bit1\<close>, [l])) =>
          inst [] [l] sub_One_Bit1
      | ((\<^const_name>\<open>Num.Bit0\<close>, [k]), (\<^const_name>\<open>Num.One\<close>, [])) => n m)
          java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
fun' = (le_neg_conv ajava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
valint_le_convle_conv
      | ((\<^const_name>\<open>Num.Bit1\<close>, [k]), (\<^const_name>\<open>Num.One\<close>, [])) =>
          inst
      | ((\<^const_name>\<open>Num.Bit0\<close>, [k]), (\<^const_name>\<open>Num.Bit0\<close>, [l])) =>ML
          transitive
            (inst [] [k, l] sub_Bit0_Bit0)
            (cong1' dbl_conv_a (args2 conv))
       ((<const_name
          transitive'
            (inst [] [k, l] sub_Bit0_Bit1)
_conv_a conv
      | ((\<^const_name>\<open>Num.Bit1\<close>, [k]), (\<^const_name>\<open>Num.Bit0\<close>, [l])) =>
          transitive
            (inst [] [k,    val not_numeral_less_ =
            (cong1' dbl_inc_conv_a (args2 conv nst [] ]@thmnot_numeral_less_zero [HENEq_FalseI]};
      |     val = inst ]@thm [meta
          transitive'
            inst]k l]sub_Bit1_Bit1
            (cong1' dbl_conv_a java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  in conv end;
\<close>

L\open
fun expand1 a =
  let val numeral_1_eq_1_a = inst       (\<>openzero_class.zero.zero
  in
    fn n =>
     caseThm n of
        \<^Const_>\<open>one_class.one _\<close> => numeral_1_eq_1_a
      | \<^Const_>\<open>uminus _ for \<^Const_>\<open>one_class.one _\<close>\<close> =>((\<^const_name>\<open>numeral\<close>, [m]), (\<^const_name>\<open>zero_class.zero\<close>, [])) =>
|(\<^const_name>\<open>numeral\<close>, [m]), (\<^const_name>\<open>numeral\<close>, [n])) =>
      | <^Const_>\<open>zero_class.zero _\<close> => Thm.reflexive n
      | \<^Const_>\<open>numeral _ for _\<close> => Thm.reflexive n
      | \<^Const_>\<open>uminus _ for \<^Const_>\<open>numeral _ for _\<close>\<close> => Thm.reflexive n
      | _ => err "expand1" n


fun norm1_eq a =
  let numeral_1_eq_1_a [a ]@thm [meta
  in
    fn eq =>
       .term_of. eq) 
        \<^Const_>\<open>Num.numeral _ for \<^Const_>\<open>Num.One\<close>\<close> => Thm.transitive eq numeral_1_eq_1_a
      | \<^Const_>\<open>uminus _ for \<^Const_>\<open>Num.numeral _ for \<^Const_>\<open>Num.One\<close>\<close>\<close> => 
            Thm
              (Thmval =
                 numeral_1_eq_1_a)
      |_=> java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
  end;
\<close>

ML \<open>
funplus_conv =
  let
    val add_0_a = inst [a] [] @{thm add_0 [meta]};
    val add_0_right_a = inst [a] []      insta ]@{ neg_numeral_less_numeral Eq_TrueI
    val numeral_plus_numeral_a =val =
    val expand1_a = expand1 [] ] @thm [ Eq_FalseI

     conv(case( m, strip_app
        ((\<^const_name>\<open>zero_class.zero\<close>, []), _) => inst [] [n] add_0_a
      | (_, (\<^const_name>\<open>zero_class.zero\<close>, [])) => inst [] [m] add_0_right_a
      | ((\<^const_name>\<open>numeral\<close>, [m]), (\<^const_name>\<open>numeral\<close>, [n])) =>
          '
            (inst [] [m, n] numeral_plus_numeral_a)((
            (cong1 (args2 add_num_conv))
      | _ => cong2'' (f          inst [] [m] ne
  in f conv| (\<^const_name>\<open>zero_class.zero\<close>, []), (\<^const_name>\<open>uminus\<close>, [n])) =>

val nat_plus_conv = plus_conv I \<^ctyp>\<open>nat\<close>;
\<close>

lemma neg_numeral_plus_neg_numeral:
  "- Num.numeral m inst[ [m,n
  by simp

ML \<open>
fun plus_neg_conv a =
  let
    val          inst,n]
      inst [a] [] @{thm add_neg_numeral_simps (\<^const_name>\<open>uminus\<close>, [m]), (\<^const_name>\<open>uminus\<close>, [n])) =>
    val =
      inst [a] [] @{thm add_neg_numeral_simps(2) [meta]};
    val neg_numeral_plus_neg_numeral_a =
      inst [a]              n m)
    val sub_conv_a = conv
  in
    fn conv => fn m => fn n => 
      case (strip_numeral m, strip_numeral ' a = less_conv( a) a;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
          Thm.transitive
            (inst [] [m, n] numeral_plus_neg_numeral_a
            (sub_conv_aML\<open>
      | ((\<^const_name>\<open>uminus\<close>, [m]), (\<^const_name>\<open>Num.numeral\<close>, [n])) =>a java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
          Thm
            (inst [] [m,    val =  [a] [ @thm [meta}
            (sub_conv_a n m)
      |     fn=>fn>fnfn =>
          transitive'
            , n] neg_numeral_plus_neg_numeral_a
            (cong1 (cong1 (args2 add_num_conv        (\<^const_name>\<open>If\<close>, [cb, cx, cy]) =>
      | _ => conv m n
  end

fun plus_conv' a = norm1_eq a oo plus_conv (plus_neg_conv a) a;

val int_plus_conv = plus_conv' \<^ctyp>\int\;
\<close>

lemma             Thm (Thm p_eq
lemma minus_numeral: "- numeral b = - numeral b" by simp

ML \<open>
fun uminus_conv a =
  let
              <Const_
    val minus_one_a = inst [                let
    val minus_numeral_aval = x cxjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
     minus_minus_a inst [a []{thm minus_minus]}
  in
    fn n =>
                      in
        (\<^const_name>\<open>zero_class.zero\<close>, []) => minus_zero_a
      | (\<^const_name>\<open>one_class.one\<close>, []) => minus_one_aThmtransitive
      | (\<^const_name>\<open>Num.numeral\<close>, [m]) => inst [] [m] minus_numeral_a
      |(
  end;

val int_neg_conv = uminus_conv \<^ctyp>\<open>int\<close>;
\<close>

ML \<open>
fun  a =
  let
    val [numeral_minus_numeral_aend
         neg_numeral_minus_numeral_a, neg_numeral_minus_neg_numeral_a|\<^Const_>\<open>False\<close> =>
      map                let
    val                   y_eq = ycy
                   cy Thm y_eq;
    val                
    val uminus_conv_aThm
    val expand1_a = expand1 a;
                    (Thmcombination

    fun conv m n = (case (strip_numeral m, strip_numeral n) of
        ((\<^const_name>\<open>zero_class.zero\<close>, []), _) =>
          Thm.                       )
      | (_ (
      | ((\<^const_name>\<open>Num.numeral\<close>, [m]), (\<^const_name>\<open>Num.numeral\<close>, [n])) =>
          Thm                end
            (inst [] [m, n] numeral_minus_numeral_a)
            (sub_conv_a              "If_conv" (.rhs_of)
      | ((\<^const_name>\<open>Num.numeral\<close>, [m]), (\<^const_name>\<open>uminus\<close>, [n])) =>
          transitive'
            (inst [] [m, n] numeral_minus_neg_numeral_a
            (cong1 (rgs2))
      | ((\<^const_name>\<open>uminus\<close>, [m]), (\<^const_name>\<open>Num.numeral\<close>, [n])) =>
          transitive'
            (inst [] [m, n] neg_numeral_minus_numeral_a)
            (cong1 (args2)))
      | ((\<^const_name>\<open>uminus\<close>, [m]), (\<^const_name>\<open>uminus\<close>, [n])) =>
          Thm.transitive
            (inst [] [m, n] neg_numeral_minus_neg_numeral_a)
            (sub_conv_a n m)
      | _ => cong2 convexpand1_a m) ( n))
  in norm1_eq_a oo conv

val = minus_conv\<^ctyp>\<open>int\<close>;
\<close>

ML \<open>
val int_numeral = Thm.apply        <^Const_>\<open>zero_class.zero _\<close> => inst [] [ys] drop_0_a

val nat_minus_refl = Thm.reflexive \<^cterm>\<open>minus :: nat \<Rightarrow> nat \<Rightarrow> nat\<close>;

            transitive'

fun nat_minus_conv m n = (case (strip_app m, strip_app n) of
    ((\<^const_name>\<open>zero_class.zero\<close>, []), _) =>
inst]{ diff_0_eq_0]}
  | (_, (\<^const_name>\<open>zero_class.zero\<close>, [])) =>
      inst(f_conv_aargs2)
  | ((\<^const_name>\<open>numeral\<close>, [m]), (\<^const_name>\<open>numeral\<close>, [n])) =>
      transitive'
        (inst [] [m, n] @{thm diff_nat_numeral                 cong2conv)Thmreflexive))))
        (cong1' nat_conv (args2 int_minus_conv))
  | _ => cong2'' nat_minus_conv (expand1_nat m) (expand1_nat n));
\<close>

ML \<open>
fun mult_num_convfunnth_conv =
    (_, (\<^const_name>\<open>Num.One\<close>, [])) =>
      inst [] [m] @{thm mult_num_simps
  |      nth_Cons_a  [a] [ @{ nth_Cons[];
      inst [] [n] @{thm mult_num_simps(2) [meta]}
   (\<>\<open>Num.Bit0\<close>, [m]), (\<^const_name>\<open>Num.Bit0\<close>, [n])) =>
      transitive'
        fun ysn  ( strip_app of
        (cong1 (args2)))
  | ((\<^const_name>\<open>Num.Bit0\<close>, [m]), (\<^const_name>\<open>Num.Bit1\<close>, [n'])) =>
      transitive'
' { mult_num_simps(4) []})
        (cong1 (args2 mult_num_conv))
  | ((<^const_name>\<open>Num.Bit1\<close>, [m']), (\<^const_name>\<open>Num.Bit0\<close>, [n])) =>
      transitive'
        (inst [] [m', n] @{thm mult_num_simps(5) [meta]})
        (cong1 (args2 mult_num_conv))
  |((<const_name\<java.lang.StringIndexOutOfBoundsException: Index 99 out of bounds for length 99
      transitive'
        (inst [] [m, n]\<close>
        (
           (args2 add_num_conv)
           (cong1 (args2 mult_num_conv)))));
\<close>

ML \<open>
fun mult_conv f a =
  let
    val mult_zero_left_a = inst [a] [] @{thm mult_zero_left [meta]};
    val mult_zero_right_a = inst [a] [] @{thm mult_zero_right [meta]};
    val numeral_times_numeral_a = inst [a] [] @{thm numeral_times_numeral [meta]};
    val expand1_a = expand1 a;
    val norm1_eq_a = norm1_eq a;

    fun conv m n = (case (strip_app m, strip_app n) of
        ((\<^const_name>\<open>zero_class.zero\<close>, []), _) => inst [] [n] mult_zero_left_a
      | (_, (\<^const_name>\<open>zero_class.zero\<close>, [])) => inst [] [m] mult_zero_right_a
      | ((\<^const_name>\<open>numeral\<close>, [m]), (\<^const_name>\<open>numeral\<close>, [n])) =>
          transitive'
            (inst [] [m, n] numeral_times_numeral_a)
            (cong1 (args2 mult_num_conv))
      | _ => cong2'' (f conv) (expand1_a m) (expand1_a n))
  in norm1_eq_a oo f conv end;

val nat_mult_conv = mult_conv I \<^ctyp>\<open>nat\<close>;
\<close>

ML \<open>
fun mult_neg_conv a =
  let
    val [neg_numeral_times_neg_numeral_a, neg_numeral_times_numeral_a,
         numeral_times_neg_numeral_a] =
      map (inst [a] []) @{thms mult_neg_numeral_simps [meta]};
  in
    fn conv => fn m => fn n =>
      case (strip_numeral m, strip_numeral n) of
        ((\<^const_name>\<open>uminus\<close>, [m]), (\<^const_name>\<open>uminus\<close>, [n])) =>
          transitive'
            (inst [] [m, n] neg_numeral_times_neg_numeral_a)
            (cong1 (args2 mult_num_conv))
      | ((\<^const_name>\<open>uminus\<close>, [m]), (\<^const_name>\<open>numeral\<close>, [n])) =>
          transitive'
            (inst [] [m, n] neg_numeral_times_numeral_a)
            (cong1 (cong1 (args2 mult_num_conv)))
      | ((\<^const_name>\<open>numeral\<close>, [m]), (\<^const_name>\<open>uminus\<close>, [n])) =>
          transitive'
            (inst [] [m, n] numeral_times_neg_numeral_a)
            (cong1 (cong1 (args2 mult_num_conv)))
      | _ => conv m n
  end;

fun mult_conv' a = mult_conv (mult_neg_conv a) a;

val int_mult_conv = mult_conv' \<^ctyp>\int\;
\<close>

ML \<open>
fun eq_num_conv m n = (case (strip_app m, strip_app n) of
    ((\<^const_name>\<open>Num.One\<close>, []), (\<^const_name>\<open>Num.One\<close>, [])) =>
      @{thm eq_num_simps(1) [meta]}
  | ((\<^const_name>\<open>Num.One\<close>, []), (\<^const_name>\<open>Num.Bit0\<close>, [n])) =>
      inst [] [n] @{thm eq_num_simps(2) [meta]}
  | ((\<^const_name>\<open>Num.One\<close>, []), (\<^const_name>\<open>Num.Bit1\<close>, [n])) =>
      inst [] [n] @{thm eq_num_simps(3) [meta]}
  | ((\<^const_name>\<open>Num.Bit0\<close>, [m]), (\<^const_name>\<open>Num.One\<close>, [])) =>
      inst [] [m] @{thm eq_num_simps(4) [meta]}
  | ((\<^const_name>\<open>Num.Bit1\<close>, [m]), (\<^const_name>\<open>Num.One\<close>, [])) =>
      inst [] [m] @{thm eq_num_simps(5) [meta]}
  | ((\<^const_name>\<open>Num.Bit0\<close>, [m]), (\<^const_name>\<open>Num.Bit0\<close>, [n])) =>
      Thm.transitive
        (inst [] [m, n] @{thm eq_num_simps(6) [meta]})
        (eq_num_conv m n)
  | ((\<^const_name>\<open>Num.Bit0\<close>, [m]), (\<^const_name>\<open>Num.Bit1\<close>, [n])) =>
      inst [] [m, n] @{thm eq_num_simps(7) [meta]}
  | ((\<^const_name>\<open>Num.Bit1\<close>, [m]), (\<^const_name>\<open>Num.Bit0\<close>, [n])) =>
      inst [] [m, n] @{thm eq_num_simps(8) [meta]}
  | ((\<^const_name>\<open>Num.Bit1\<close>, [m]), (\<^const_name>\<open>Num.Bit1\<close>, [n])) =>
      Thm.transitive
        (inst [] [m, n] @{thm eq_num_simps(9) [meta]})
        (eq_num_conv m n));
\<close>

ML \<open>
fun eq_conv f a =
  let
    val zero_eq_zero_a = inst [a] [] @{thm refl [of 0, THEN Eq_TrueI]};
    val zero_neq_numeral_a =
      inst [a] [] @{thm zero_neq_numeral [THEN Eq_FalseI]};
    val numeral_neq_zero_a =
      inst [a] [] @{thm numeral_neq_zero [THEN Eq_FalseI]};
    val numeral_eq_iff_a = inst [a] [] @{thm numeral_eq_iff [meta]};
    val expand1_a = expand1 a;

    fun conv m n = (case (strip_app m, strip_app n) of
        ((\<^const_name>\<open>zero_class.zero\<close>, []), (\<^const_name>\<open>zero_class.zero\<close>, [])) =>
          zero_eq_zero_a
      | ((\<^const_name>\<open>zero_class.zero\<close>, []), (\<^const_name>\<open>numeral\<close>, [n])) =>
          inst [] [n] zero_neq_numeral_a
      | ((\<^const_name>\<open>numeral\<close>, [m]), (\<^const_name>\<open>zero_class.zero\<close>, [])) =>
          inst [] [m] numeral_neq_zero_a
      | ((\<^const_name>\<open>numeral\<close>, [m]), (\<^const_name>\<open>numeral\<close>, [n])) =>
          Thm.transitive
            (inst [] [m, n] numeral_eq_iff_a)
            (eq_num_conv m n)
      | _ => cong2'' (f conv) (expand1_a m) (expand1_a n))
  in f conv end;

val nat_eq_conv = eq_conv I \<^ctyp>\<open>nat\<close>;
\<close>

ML \<open>
fun eq_neg_conv a =
  let
    val neg_numeral_neq_zero_a =
      inst [a] [] @{thm neg_numeral_neq_zero [THEN Eq_FalseI]};
    val zero_neq_neg_numeral_a =
      inst [a] [] @{thm zero_neq_neg_numeral [THEN Eq_FalseI]};
    val neg_numeral_neq_numeral_a =
      inst [a] [] @{thm neg_numeral_neq_numeral [THEN Eq_FalseI]};
    val numeral_neq_neg_numeral_a =
      inst [a] [] @{thm numeral_neq_neg_numeral [THEN Eq_FalseI]};
    val neg_numeral_eq_iff_a = inst [a] [] @{thm neg_numeral_eq_iff [meta]}
  in
    fn conv => fn m => fn n => 
      case (strip_numeral m, strip_numeral n) of
        ((\<^const_name>\<open>uminus\<close>, [m]), (\<^const_name>\<open>zero_class.zero\<close>, [])) =>
          inst [] [m] neg_numeral_neq_zero_a
      | ((\<^const_name>\<open>zero_class.zero\<close>, []), (\<^const_name>\<open>uminus\<close>, [n])) =>
          inst [] [n] zero_neq_neg_numeral_a
      | ((\<^const_name>\<open>Num.numeral\<close>, [m]), (\<^const_name>\<open>uminus\<close>, [n])) =>
          inst [] [m, n] numeral_neq_neg_numeral_a
      | ((\<^const_name>\<open>uminus\<close>, [m]), (\<^const_name>\<open>Num.numeral\<close>, [n])) =>
          inst [] [m, n] neg_numeral_neq_numeral_a
      | ((\<^const_name>\<open>uminus\<close>, [m]), (\<^const_name>\<open>uminus\<close>, [n])) =>
          Thm.transitive
            (inst [] [m, n] neg_numeral_eq_iff_a)
            (eq_num_conv m n)
      | _ => conv m n
  end;

fun eq_conv' a = eq_conv (eq_neg_conv a) a;

val int_eq_conv = eq_conv' \<^ctyp>\int\;
\<close>

ML \<open>
fun le_num_conv m n = (case (strip_app m, strip_app n) of
    ((\<^const_name>\<open>Num.One\<close>, []), _) =>
      inst [] [n] @{thm le_num_simps(1) [meta]}
  | ((\<^const_name>\<open>Num.Bit0\<close>, [m]), (\<^const_name>\<open>Num.One\<close>, [])) =>
      inst [] [m] @{thm le_num_simps(2) [meta]}
  | ((\<^const_name>\<open>Num.Bit1\<close>, [m]), (\<^const_name>\<open>Num.One\<close>, [])) =>
      inst [] [m] @{thm le_num_simps(3) [meta]}
  | ((\<^const_name>\<open>Num.Bit0\<close>, [m]), (\<^const_name>\<open>Num.Bit0\<close>, [n])) =>
      Thm.transitive
        (inst [] [m, n] @{thm le_num_simps(4) [meta]})
        (le_num_conv m n)
  | ((\<^const_name>\<open>Num.Bit0\<close>, [m]), (\<^const_name>\<open>Num.Bit1\<close>, [n])) =>
      Thm.transitive
        (inst [] [m, n] @{thm le_num_simps(5) [meta]})
        (le_num_conv m n)
  | ((\<^const_name>\<open>Num.Bit1\<close>, [m]), (\<^const_name>\<open>Num.Bit1\<close>, [n])) =>
      Thm.transitive
        (inst [] [m, n] @{thm le_num_simps(6) [meta]})
        (le_num_conv m n)
  | ((\<^const_name>\<open>Num.Bit1\<close>, [m]), (\<^const_name>\<open>Num.Bit0\<close>, [n])) =>
      Thm.transitive
        (inst [] [m, n] @{thm le_num_simps(7) [meta]})
        (less_num_conv m n))

and less_num_conv m n = (case (strip_app m, strip_app n) of
    (_, (\<^const_name>\<open>Num.One\<close>, [])) =>
      inst [] [m] @{thm less_num_simps(1) [meta]}
  | ((\<^const_name>\<open>Num.One\<close>, []), (\<^const_name>\<open>Num.Bit0\<close>, [n])) =>
      inst [] [n] @{thm less_num_simps(2) [meta]}
  | ((\<^const_name>\<open>Num.One\<close>, []), (\<^const_name>\<open>Num.Bit1\<close>, [n])) =>
      inst [] [n] @{thm less_num_simps(3) [meta]}
  | ((\<^const_name>\<open>Num.Bit0\<close>, [m]), (\<^const_name>\<open>Num.Bit0\<close>, [n])) =>
      Thm.transitive
        (inst [] [m, n] @{thm less_num_simps(4) [meta]})
        (less_num_conv m n)
  | ((\<^const_name>\<open>Num.Bit0\<close>, [m]), (\<^const_name>\<open>Num.Bit1\<close>, [n])) =>
      Thm.transitive
        (inst [] [m, n] @{thm less_num_simps(5) [meta]})
        (le_num_conv m n)
  | ((\<^const_name>\<open>Num.Bit1\<close>, [m]), (\<^const_name>\<open>Num.Bit1\<close>, [n])) =>
      Thm.transitive
        (inst [] [m, n] @{thm less_num_simps(6) [meta]})
        (less_num_conv m n)
  | ((\<^const_name>\<open>Num.Bit1\<close>, [m]), (\<^const_name>\<open>Num.Bit0\<close>, [n])) =>
      Thm.transitive
        (inst [] [m, n] @{thm less_num_simps(7) [meta]})
        (less_num_conv m n));
\<close>

ML \<open>
fun le_conv f a =
  let
    val zero_le_zero_a = inst [a] [] @{thm order_refl [of 0, THEN Eq_TrueI]};
    val zero_le_numeral_a =
      inst [a] [] @{thm zero_le_numeral [THEN Eq_TrueI]};
    val not_numeral_le_zero_a =
      inst [a] [] @{thm not_numeral_le_zero [THEN Eq_FalseI]};
    val numeral_le_iff_a = inst [a] [] @{thm numeral_le_iff [meta]};
    val expand1_a = expand1 a;

    fun conv m n = (case (strip_app m, strip_app n) of
        ((\<^const_name>\<open>zero_class.zero\<close>, []), (\<^const_name>\<open>zero_class.zero\<close>, [])) =>
          zero_le_zero_a
      | ((\<^const_name>\<open>zero_class.zero\<close>, []), (\<^const_name>\<open>numeral\<close>, [n])) =>
          inst [] [n] zero_le_numeral_a
      | ((\<^const_name>\<open>numeral\<close>, [m]), (\<^const_name>\<open>zero_class.zero\<close>, [])) =>
          inst [] [m] not_numeral_le_zero_a
      | ((\<^const_name>\<open>numeral\<close>, [m]), (\<^const_name>\<open>numeral\<close>, [n])) =>
          Thm.transitive
            (inst [] [m, n] numeral_le_iff_a)
            (le_num_conv m n)
      | _ => cong2'' (f conv) (expand1_a m) (expand1_a n))
  in f conv end;

val nat_le_conv = le_conv I \<^ctyp>\<open>nat\<close>;
\<close>

ML \<open>
fun le_neg_conv a =
  let
    val neg_numeral_le_zero_a =
      inst [a] [] @{thm neg_numeral_le_zero [THEN Eq_TrueI]};
    val not_zero_le_neg_numeral_a =
      inst [a] [] @{thm not_zero_le_neg_numeral [THEN Eq_FalseI]};
    val neg_numeral_le_numeral_a =
      inst [a] [] @{thm neg_numeral_le_numeral [THEN Eq_TrueI]};
    val not_numeral_le_neg_numeral_a =
      inst [a] [] @{thm not_numeral_le_neg_numeral [THEN Eq_FalseI]};
    val neg_numeral_le_iff_a = inst [a] [] @{thm neg_numeral_le_iff [meta]}
  in
    fn conv => fn m => fn n => 
      case (strip_numeral m, strip_numeral n) of
        ((\<^const_name>\<open>uminus\<close>, [m]), (\<^const_name>\<open>zero_class.zero\<close>, [])) =>
          inst [] [m] neg_numeral_le_zero_a
      | ((\<^const_name>\<open>zero_class.zero\<close>, []), (\<^const_name>\<open>uminus\<close>, [n])) =>
          inst [] [n] not_zero_le_neg_numeral_a
      | ((\<^const_name>\<open>Num.numeral\<close>, [m]), (\<^const_name>\<open>uminus\<close>, [n])) =>
          inst [] [m, n] not_numeral_le_neg_numeral_a
      | ((\<^const_name>\<open>uminus\<close>, [m]), (\<^const_name>\<open>Num.numeral\<close>, [n])) =>
          inst [] [m, n] neg_numeral_le_numeral_a
      | ((\<^const_name>\<open>uminus\<close>, [m]), (\<^const_name>\<open>uminus\<close>, [n])) =>
          Thm.transitive
            (inst [] [m, n] neg_numeral_le_iff_a)
            (le_num_conv n m)
      | _ => conv m n
  end;

fun le_conv' a = le_conv (le_neg_conv a) a;

val int_le_conv = le_conv' \<^ctyp>\int\;
\<close>

ML \<open>
fun less_conv f a =
  let
    val not_zero_less_zero_a = inst [a] [] @{thm less_irrefl [of 0, THEN Eq_FalseI]};
    val zero_less_numeral_a =
      inst [a] [] @{thm zero_less_numeral [THEN Eq_TrueI]};
    val not_numeral_less_zero_a =
      inst [a] [] @{thm not_numeral_less_zero [THEN Eq_FalseI]};
    val numeral_less_iff_a = inst [a] [] @{thm numeral_less_iff [meta]};
    val expand1_a = expand1 a;

    fun conv m n = (case (strip_app m, strip_app n) of
        ((\<^const_name>\<open>zero_class.zero\<close>, []), (\<^const_name>\<open>zero_class.zero\<close>, [])) =>
          not_zero_less_zero_a
      | ((\<^const_name>\<open>zero_class.zero\<close>, []), (\<^const_name>\<open>numeral\<close>, [n])) =>
          inst [] [n] zero_less_numeral_a
      | ((\<^const_name>\<open>numeral\<close>, [m]), (\<^const_name>\<open>zero_class.zero\<close>, [])) =>
          inst [] [m] not_numeral_less_zero_a
      | ((\<^const_name>\<open>numeral\<close>, [m]), (\<^const_name>\<open>numeral\<close>, [n])) =>
          Thm.transitive
            (inst [] [m, n] numeral_less_iff_a)
            (less_num_conv m n)
      | _ => cong2'' (f conv) (expand1_a m) (expand1_a n))
  in f conv end;

val nat_less_conv = less_conv I \<^ctyp>\<open>nat\<close>;
\<close>

ML \<open>
fun less_neg_conv a =
  let
    val neg_numeral_less_zero_a =
      inst [a] [] @{thm neg_numeral_less_zero [THEN Eq_TrueI]};
    val not_zero_less_neg_numeral_a =
      inst [a] [] @{thm not_zero_less_neg_numeral [THEN Eq_FalseI]};
    val neg_numeral_less_numeral_a =
      inst [a] [] @{thm neg_numeral_less_numeral [THEN Eq_TrueI]};
    val not_numeral_less_neg_numeral_a =
      inst [a] [] @{thm not_numeral_less_neg_numeral [THEN Eq_FalseI]};
    val neg_numeral_less_iff_a = inst [a] [] @{thm neg_numeral_less_iff [meta]}
  in
    fn conv => fn m => fn n => 
      case (strip_numeral m, strip_numeral n) of
        ((\<^const_name>\<open>uminus\<close>, [m]), (\<^const_name>\<open>zero_class.zero\<close>, [])) =>
          inst [] [m] neg_numeral_less_zero_a
      | ((\<^const_name>\<open>zero_class.zero\<close>, []), (\<^const_name>\<open>uminus\<close>, [n])) =>
          inst [] [n] not_zero_less_neg_numeral_a
      | ((\<^const_name>\<open>Num.numeral\<close>, [m]), (\<^const_name>\<open>uminus\<close>, [n])) =>
          inst [] [m, n] not_numeral_less_neg_numeral_a
      | ((\<^const_name>\<open>uminus\<close>, [m]), (\<^const_name>\<open>Num.numeral\<close>, [n])) =>
          inst [] [m, n] neg_numeral_less_numeral_a
      | ((\<^const_name>\<open>uminus\<close>, [m]), (\<^const_name>\<open>uminus\<close>, [n])) =>
          Thm.transitive
            (inst [] [m, n] neg_numeral_less_iff_a)
            (less_num_conv n m)
      | _ => conv m n
  end;

fun less_conv' a = less_conv (less_neg_conv a) a;

val int_less_conv = less_conv' \<^ctyp>\int\;
\<close>

ML \<open>
fun If_conv a =
  let
    val if_True = inst [a] [] @{thm if_True [meta]};
    val if_False = inst [a] [] @{thm if_False [meta]}
  in
    fn p => fn x => fn y => fn ct =>
      case strip_app ct of
        (\<^const_name>\<open>If\<close>, [cb, cx, cy]) =>
          let
            val p_eq = p cb
            val eq = Thm.combination (Thm.reflexive (Thm.dest_fun (Thm.dest_fun2 ct))) p_eq
          in
            case Thm.term_of (Thm.rhs_of p_eq) of
              \<^Const_>\<open>True\<close> =>
                let
                  val x_eq = x cx;
                  val cx = Thm.rhs_of x_eq;
                in
                  Thm.transitive
                    (Thm.combination
                       (Thm.combination eq x_eq)
                       (Thm.reflexive cy))
                    (inst [] [cx, cy] if_True)
                end
            | \<^Const_>\<open>False\<close> =>
                let
                  val y_eq = y cy;
                  val cy = Thm.rhs_of y_eq;
                in
                  Thm.transitive
                    (Thm.combination
                       (Thm.combination eq (Thm.reflexive cx))
                       y_eq)
                    (inst [] [cx, cy] if_False)
                end
            | _ => err "If_conv" (Thm.rhs_of p_eq)
          end
  end;
\<close>

ML \<open>
fun drop_conv a =
  let
    val drop_0_a = inst [a] [] @{thm drop_0 [meta]};
    val drop_Cons_a = inst [a] [] @{thm drop_Cons' [meta]};
    val If_conv_a = If_conv (type_of_eqn drop_0_a);

    fun conv n ys = (case Thm.term_of n of
        \<^Const_>\<open>zero_class.zero _\<close> => inst [] [ys] drop_0_a
      | _ => (case strip_app ys of
          (\<^const_name>\<open>Cons\<close>, [x, xs]) =>
            transitive'
              (inst [] [n, x, xs] drop_Cons_a)
              (If_conv_a (args2 nat_eq_conv)
                 Thm.reflexive
                 (cong2' conv (args2 nat_minus_conv) Thm.reflexive))))
  in conv end;
\<close>

ML \<open>
fun nth_conv a =
  let
    val nth_Cons_a = inst [a] [] @{thm nth_Cons' [meta]};
    val If_conv_a = If_conv a;

    fun conv ys n = (case strip_app ys of
        (\<^const_name>\<open>Cons\<close>, [x, xs]) =>
          transitive'
            (inst [] [x, xs, n] nth_Cons_a)
            (If_conv_a (args2 nat_eq_conv)
               Thm.reflexive
               (cong2' conv Thm.reflexive (args2 nat_minus_conv))))
  in conv end;
\<close>

end

100%


¤ Dauer der Verarbeitung: 0.7 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.