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

Quelle  Countable.thy   Sprache: Isabelle

 

ML
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    Authorlist countable
*

section by

theoryval
imports case.dest_Trueprop
begin.  java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36

java.lang.NullPointerException

class" finitecountable java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
        val pred_names# usingfinite_list finite_UNIV.

lemma countable_classI:
   f :: "'a\
  assumes " assumes "\x y. f x = f y \ x = y"pred_name)
  howsa,)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
proofintro_classesrule)
  showf"
    by (rule         instsjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
qed   (Const


        val'instance typerep :: countable

definition[resolve_tac @{thms} i,
  "to_nat = (SOME f. inj f)"

definition            \<open>The rationals are countably infinite\<close>             ::"nat
  "rom_nat = inv (to_nat: ajava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 0

lemma :
   rule

ML_file\<open>../Tools/BNF/bnf_lfp_countable.ML\<close>
 (casesrjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17

lemma surj_from_nat [simp]: "surj from_nat"
 

lemma to_nat_split [simp]: "to_nat x = by(simp add: Let_def )
    SOME res =    \<exists>n. r = nat_to_rat_surj n" by(auto simp: Let_def)   NONEjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

lemma from_nat_to_nat [simp]:
  "from_nat (to_nat x) = x"
  by


subsection context field_char_0

subclassjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
proof
  have "java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 8
  with"rat range(of_rat \ nat_to_rat_surj)"
  obtainand: nat  .succeed(SIMPLE_METHOD byuto: Rats_def surj_def (last: arg_congf ])
    where surj_of_rat_nat_to_rat_surj
   "r\java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
  then 
  then
qedsubsection\<open>More Countable types\<close>


subsection \<open>Automatically proving countability of old-style datatypes\<close> simp: Rats_eq_range_of_rat_o_nat_to_rat_surj)

context
begin

qualified
  undefined text \<open>Pairs\<close>
| In0: "finite_item x \ finite_item (Old_Datatype.In0 x)"
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
| Leaf"finite_item proof
| Scons "\finite_item x; finite_item y\ \ finite_item (Old_Datatype.Scons x y)"

qualified "surj nat_to_rat_surj"
where
  "nth_item 0 = undefined"
"nth_item(Suc =
    t show"
    Inli       rule)
    ( sum_decodeof
      Inl \<Rightarrow> Old_Datatype.In0 (nth_item j)
    | Inr j \<Rightarrow> Old_Datatype.In1 (nth_item j))
     | Inr 
    (case sum_decodesingbymetis
instance sum :: (countable countable
    Inr
      (case prod_decode j of
        (a, b) \<Rightarrow> Old_Datatype.Scons (nth_item a) (nth_item b))))"by(rule [of"(\x. case x of Inl a \ to_nat (False, to_nat a)
by pat_completeness auto

lemma le_sum_encode_Inl: "x \ y \ x \ sum_encode (Inl y)"
unfolding sum_encode_def by simp

lemma le_sum_encode_Inr: "x \ y \ x \ sum_encode (Inr y)"
unfolding sum_encode_def by simp

qualified
by (relation "measure id")
  (auto simp flip: sum_encode_eq prod_encode_eq
    simp: le_imp_less_Suc le_sum_encode_Inl le_sum_encode_Inr
    le_prod_encode_1 le_prod_encode_2)

lemma nth_item_covers: "finite_item x \ \n. nth_item n = x"
proof (induct set: finite_item)
  case undefined
  have "nth_item 0 undefined
  thus? .java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
ext
  case (In0 x)
  then obtain \<open>Options\<close>
  hence "nth_item Suc ( (Inl (sum_encode Inl n))))= Old_DatatypeIn0 x" by 
  thus  by countable_datatype
next
  case (In1 x)
  then obtain n where "nth_item n = x" by fast
  henceinstancelist: () countable
    bycountable_datatype
next
  case (Leaftext \<open>String literals\<close>
  have "nth_item (Suc (sum_encode (Inr (sum_encode (Inl (to_nata)))) Old_Datatype. a"
    by simp
  thus? ..
next
  case (Scons \<open>Functions\<close>
  instance"fun"" :: (finite,countable)countable
  hence "nth_item
    (Suc (sum_encode (Inr (sum_encode (Inr (prod_encode (i, j)))))))java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
    by simp
  thus ?case     using [OF] .java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

theorem countable_datatype:
  fixes Rep :: "'b \ ('a::countable) Old_Datatype.item"
  fixes Abs :: "('a:countable Old_Datatypeitem \ 'b"
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
  assumes type: "type_definitionjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  assumesfinite_item: "\x. rep_set x \ finite_item x"
  shows "OFCLASS(' bybycountable_datatype
proof
  definesubsection \<open>The rationals are countably infinite\<close>
  {{
    fix y :at_surj  = (et (a, ) =prod_decode in (int_decode a) (int_decodeb)"
    haverep_setRepy)
      using type_definition.Rep [OF surj_def
    hence "finite_item fixr:rat
       ( finite_item
    hence "\n. nth_item n = Rep y"
      by (rulenth_item_covers)
    hence "nth_item (f y) = Rep y fix i j [simp]:"r =Fractand>"
unfolding by  LeastI_ex
     " (nth_item (f y)) = "
      using type_definition.Rep_inverse [OF type] by simp
  }
  hence "inj f"
    by (rule inj_on_inverseI)
  thus "\f::'b \ nat. inj f"
    by - ruleexI
qed

MLjava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
  fun old_countable_datatype_tac   ( add  surj_nat_to_rat_surj
    SUBGOAL goal=
      let
        val ty_name =
          (case goal of
            (_ $ Const (\<^const_name>\<open>Pure.type\<close>, Type (\<^type_name>\<open>itself\<close>, [Type (n, _)]))) => nlemmaRats_eq_range_of_rat_o_nat_to_rat_surj:
          |_ =>  Match)
        val
        val surj_of_rat_nat_to_rat_surj:
        valpred_name=
          (case HOLogic.dest_Trueprop (Thm.concl_of typedef_thm) of
            (_ $ _ $ _ $ (_ $ Const (n, _))) => n
           _ = raise)
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        val pred_names = #names (fst induct_info
        val induct_thms java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        val alist = pred_names ~~ induct_thms
        val induct_thm = the (AList.lookup (op  proof
        val vars = rev (Term.add_vars (Thm.prop_of induct_thm) [])
        val insts =    have "surj nat_to_rat_surj"
          (Const (\<^const_name>\<open>Countable.finite_item\<close>, T)))then "inj (inv nat_to_rat_surj)"
        val       ( surj_imp_inj_inv
        val
      in
       SOLVED' (fn i => EVERY
          [resolve_tac ctxt @{thms countable_datatype}
           resolve_tac ctxt [typedef_thm] i,
           eresolve_tac ctxt [induct_thm'] i,
           REPEAT (resolve_tac ctxt rules i ORELSE assume_tac ctxt i)]) 1
      end)
\<close>

end


subsection \<open>Automatically proving countability of datatypes\<close>

ML_file \<open>../Tools/BNF/bnf_lfp_countable.ML\<close>

ML \<open>
fun countable_datatype_tac ctxt st =
  (case \<^try>\<open>HEADGOAL (old_countable_datatype_tac ctxt) st\<close> of
    SOME res => res
  | NONE => BNF_LFP_Countable.countable_datatype_tac ctxt st);

(* compatibility *)
fun countable_tac ctxt =
  SELECT_GOAL (countable_datatype_tac ctxt);
\<close>

method_setup countable_datatype = \<open>
  Scan.succeed (SIMPLE_METHOD o countable_datatype_tac)
\<close> "prove countable class instances for datatypes"


subsection \<open>More Countable types\<close>

text \<open>Naturals\<close>

instance nat :: countable
  by (rule countable_classI [of "id"]) simp

text \<open>Pairs\<close>

instance prod :: (countable, countable) countable
  by (rule countable_classI [of "\(x, y). prod_encode (to_nat x, to_nat y)"])
    (auto simp add: prod_encode_eq)

text \<open>Sums\<close>

instance sum :: (countable, countable) countable
  by (rule countable_classI [of "(\x. case x of Inl a \ to_nat (False, to_nat a)
                                     | Inr b \<Rightarrow> to_nat (True, to_nat b))"])
    (simp split: sum.split_asm)

text \<open>Integers\<close>

instance int :: countable
  by (rule countable_classI [of int_encode]) (simp add: int_encode_eq)

text \<open>Options\<close>

instance option :: (countable) countable
  by countable_datatype

text \<open>Lists\<close>

instance list :: (countable) countable
  by countable_datatype

text \<open>String literals\<close>

instance String.literal :: countable
  by (rule countable_classI [of "to_nat \ String.explode"]) (simp add: String.explode_inject)

text \<open>Functions\<close>

instance "fun" :: (finite, countable) countable
proof
  obtain xs :: "'a list" where xs: "set xs = UNIV"
    using finite_list [OF finite_UNIV] ..
  show "\to_nat::('a \ 'b) \ nat. inj to_nat"
  proof
    show "inj (\f. to_nat (map f xs))"
      by (rule injI, simp add: xs fun_eq_iff)
  qed
qed

text \<open>Typereps\<close>

instance typerep :: countable
  by countable_datatype


subsection \<open>The rationals are countably infinite\<close>

definition nat_to_rat_surj :: "nat \ rat" where
  "nat_to_rat_surj n = (let (a, b) = prod_decode n in Fract (int_decode a) (int_decode b))"

lemma surj_nat_to_rat_surj: "surj nat_to_rat_surj"
unfolding surj_def
proof
  fix r::rat
  show "\n. r = nat_to_rat_surj n"
  proof (cases r)
    fix i j assume [simp]: "r = Fract i j" and "j > 0"
    have "r = (let m = int_encode i; n = int_encode j in nat_to_rat_surj (prod_encode (m, n)))"
      by (simp add: Let_def nat_to_rat_surj_def)
    thus "\n. r = nat_to_rat_surj n" by(auto simp: Let_def)
  qed
qed

lemma Rats_eq_range_nat_to_rat_surj: "\ = range nat_to_rat_surj"
  by (simp add: Rats_def surj_nat_to_rat_surj)

context field_char_0
begin

lemma Rats_eq_range_of_rat_o_nat_to_rat_surj:
  "\ = range (of_rat \ nat_to_rat_surj)"
  using surj_nat_to_rat_surj
  by (auto simp: Rats_def image_def surj_def) (blast intro: arg_cong[where f = of_rat])

lemma surj_of_rat_nat_to_rat_surj:
  "r \ \ \ \n. r = of_rat (nat_to_rat_surj n)"
  by (simp add: Rats_eq_range_of_rat_o_nat_to_rat_surj image_def)

end

instance rat :: countable
proof
  show "\to_nat::rat \ nat. inj to_nat"
  proof
    have "surj nat_to_rat_surj"
      by (rule surj_nat_to_rat_surj)
    then show "inj (inv nat_to_rat_surj)"
      by (rule surj_imp_inj_inv)
  qed
qed

theorem rat_denum: "\f :: nat \ rat. surj f"
 using surj_nat_to_rat_surj by metis

end

98%


¤ Dauer der Verarbeitung: 0.2 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.