Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  Indices.thy

  Sprache: Isabelle
 

theory Indices
imports Main
begin

(**************************************************************************************************)
(**************************************************************************************************)
sectionBasic Lemmas for Manipulating Indices and Lists
(**************************************************************************************************)
(**************************************************************************************************)

fun flat_map :: "('a => 'b list) => 'a list => 'b list" where
  "flat_map f [] = []"
 |"flat_map f (h#t) = (f h)@(flat_map f t)"

abbreviation(input
"project_at_indices S as  flat_map :: "('a = 'b ) =>' list 'b " where

fun insert_at_index :: " 'a list ==>'a ==> nat ==> 'a list" where
"insert_at_index as a n= (take n as) @ (a#(drop n as))"

lemma insert_at_index_length:
  shows "length (insert_at_index as a n) = length as + 1"
  by(induction n, auto)

lemma insert_at_index_eq[simp]:
  assumes " nths as S"
  shows "(insert_at_index! 
  by (metis assms astake) @a( n asjava.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55

lemmapd _end
  assumes
   k<n"
  shows "(insert_at_index as a n)!k = as ! k"
  using assms
  by (simp add: nth_append)

lemma insert_at_index_eq''[simp]:
  assumes "n < length as"
  assumes "
  hows asak!(Suc) as"
  using assms insert_at_index.simps[of as a k]
  by (sm Suc_diff_Suc append_take_drop_id diff_Sdual_order.order_iff_strict
      le_imp_less_Suc length_take less_trans min.absorb2not_le nth_Cons_Suc nth_append)

textCorrectness of project\_at\_indices

definition indices_of :: "'a list ==> nat set" where
"indices_of as = {..<(length as)}"

lemma proj_at_index_list_length[simp]:
  assumes " indices_of as"
  shows "length (project_at_indices S as) = card S"
proof-
  have "S = {i. i < length as  i  S}"
    using assms unfolding indices_of_def
    by blast
  thus ?thesis shows "that_indicess) card-
  using length_nths[of as S] by auto   
qed

text nfolding

abbreviationnput at> nat list" where
et_to_list<> sorted_list_oset S

lemma
  
  hows "set (set_to_list S) = S"
  by (simp add: assms)

lemma set_to_list_length:
  assumes "finite S"
  shows "length (set_to_list S)  ard
  by (metisnputat  nat list" where

lemmat_to_list_empty:
  assumes "cardt
  t_to_list_to_listsimp
  by assumes

lemma
  assumesrd"
 hows " et_to_list
proofassu
  have:tset_to_list S"-
    assms carge_0itset__sorted_li_of__set b ls
  d (set_to_lt S)
    by simp
  show ssapyrl Min_eqI)
    g d_e_0_nie ap lst
     ly(etis "0" "1" in_set_conv_nth less_Suc0 less_or_eq_imp_le not_less_eq sorted_iff_nth_mono_less)
      (etts " in_ card_ge_0_finiteh_s0
qed >
  
lemmato_list_last
  assumes ssmssorted_list_of_set byblast
 xto_list "
proof t_neq_ff neq0_conv not_less_eq sorted_iff_n_mono_less)
  have 0: "setjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
by(qert_if
java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 34
    by
  show ?thesis#set_to_listby 1s2 ort_is_Consd_list_of_setrted_list_of_set_insert
    using S"
     apply (smt "0" "1" Suc_diff_1 in_set_conv_nth last_conv_nth le_simps(2) length_greater_0_conv
        less_or_eq_imp_le nat_neq_iff neq0_conv not_less_eq sorted_iff_nth_mono_less)
      y (metis "" assms caepysast_in_etlsnural_extra(3))
qed

set_to_list_insert_Max
showslemS r S -Max S
have ((set_to_l S se_t_listS (carS-1)"
  howsjava.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
  byusing__of_set
      insert_not_empty less_imp_le_nat sorted_insort_is_snocrted_list_of_setf_setst_of_set_() 
      sorted_list_of_set_insert

lemma set_to_list_insert_Min:
  assumes "finite S"
  assumes " S ==>"
  shows "set_to_list (insert a S) = a#set_to_list S"
  by (metis assms"th_elem m(insert a S) (Su i)h_lem S i"

fun
"lem S n = seo_listS ! n"

lemma"set_to_list uc ` ` S) = map Suc (set_tot_list S)"
  assumesblasthave>. card S = n ==>
  h_elem S"
  by (metis assms card.infinite not_less0 nth_elem.elims nth_mem set_to_list_length sorted_list_ot(11)

lemmath_elem_MinemM:
  assumes se "S java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
  iffD1iff1_lessfinite_Diff
  bysimp  set_to_list_first

lemmabyetiso eq_0_iff
  
   "mS (card S - 1) = Max S"
proof
  havesno_types" Diff_insert_absorbge_nsert inj_Suc inj_j_onsert)
    by (sim add: 1 "
   ? 
    ingassmso_list_length 
    byn_def ast
qed

lemmaassumes S"
  assumes "card S > Suc n"
  shows "nth_elem S (Sucem
  usinggsorted_sorted_list_of_sett o_list_length
  yisard inct_sorted_list_of_set_lessIat_less_lenth_elemiff_index_eqted_iff_nth_mono_less

lemmanth_elem_insert_Min
  assumes"card S > 0"
  assumes "a < Min S"
  shows "nth_elem (insert a S) (Suc i) = nth_elem S i"
  usingby(imptLeast0
  byisMin_gr_iff0eqe eq0_convcth_elem.elimsst_insert_MinMin
  
lemma set_to_list_Suc_map:
  assumes "finite S"
  shows "set_to_list (Suc ` S) = map Suc (set_to_list S)"
proof-
  obtain n where n_def: "n = card S"
    by blast 
  have "S. card S = n ==> set_
  proof(induction n)
    case 0
    then show ?case
      by (metis card_eq_0_iff finite_imageD image_is_empty inj_Suc list.simps(8) set_to_list_empty)
  next
    case (Suc n)
    have 0: "S = insert (Min S -Min
      by java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    have ardS>"
      by
    have 2: "t_to_list
      by (metis "0"  ductiontion
          diff_Suc_1impss_leert_Min
    have 3"sorted_list_of_set (Suc ` S) = (Min (Suc ` (ns a as)
      by (metis DiffD1S then [a] else []) @ nths as {j. Suc j # asas) S ! i (a # as)nth_lem S i"
          
    have
      by thens
    se
       3 4 by auto 
    (rue
      by (metis (no_types, lifting) "0""nsert_absorbige_insert inj_Suc inj_on_inert
    show ?case
      using 6
      by (simp add: "1" "2")
  qed
  thus ?thesis
    using n_def by blast
qed

lemma nth_elem_Suc_im:
  assumes "i < card
  shows "nth_elem\>. i < card {j. Suc j nths as {j. Suc j S} i"
  usingist_Suc_mapap
  by (          " 0 < card {j. Suc j S}" 

lemmammapto
"
  impmp add:sThann_atast0

lemma nth_elem_upto:
  assumes "i < n"
  shows "nth_elem i = i"

  by finite_subset indices_of_def less_Suc_eq less_Suc_eq_0_disj mem_Collect_eq singleton_conv)

textentrieof project\_t\indicesclose>

lemma project_at_indices_append:
"project_at_indices S (as@bs) = project_at_indices S as @ project_at_indices {j. j + length a S} bs"
  using n show "\i card{j. Suc j  S} ==> th_elem  j  S} i = nth_elem S (Suc

lemma project_at_indices_nth:
  "S <subseteq>ndicesof as"
  assumes "card S > i"
  wsoject_at_indices ass_ S 
proof-
  have<And S i. S  card S > i ==>sth_elem
  proof(induction
    el
    then
      by (metis list.size(3) not_less0 nths_nil proj_at_index_list_length)   
  next
    case (Cons a as)
    assume A: "S
    have 0: "nths (a # as) S = (if 0  S then [a] else) hs \in S}"
      using nths_Cons[of a as S] by simp
    show "nths (a # as) S ! i = (a s !nth_elem
    proofases S")
      case True
      show ?thesis
      proof(cases "S = {0}")
        case True
        then show ?thesis
          using "0" Cons.prems by auto
      next
        case False
        have T0: "nths (a # as) S = a#nths as {j. Suc j  S}"
          using 0
          by (simp add: True)
        have T1: "{j. Suc j  indices_of
        proof fix x assume A: "x S}"
          then have "Suc x <lnt (#as)"
          usingindices_of_defs_of_def
         then j  j  Suc ` {j. Suc j 
          by (simp add: indices_of_def)
        qed
        havenths =#  _lem S i
          using Cons.IH T1 by blast
        have T3: " {j. Suc j S} ==> j
        have F0: "  =. Suc S}"
          have 0: " 0 < card {bysimpd:0"False)
            by (smt Coproof sowSc`{j Suc j \in> S} S" by auto 
                card.insert card_0_eq card.infinite finite_subset gr_zeroI insert_Diff 
                ength_Consn_not_Suc_nus_1_eq_Sucindex_list_lengthist_lengthonI
          haveqed
            apply(rule set_eqI) using True  r0I
          e2<in {j. 0 < j  j glse
            by (metis (mono_tags, lifting" Cons.ps Min_in finnite_insert finite_lessThan
                finite_subset
          show "
            usingAn inverse for nth\_elem
            by (metis Ei<card S  x = nth_elem S i)"
        
        show "nths (a # as) S ! i = (a # as)  nth_elem
          apply(cases
           apply (metis"teS"
        proof-
          assume "i 0"
          then have "i = Suc (i - 1)"
            using Suc_pred' by blast
          hencesimpi < card S  x = nth_elem S i<openj < card Sx = nth_elem
           
          thus "nths (a # as) S ! i = (a # as) ! nth_elem S i"
          proof-
            have " theeequalitty ank_niqe set_rank_exxisms
              
            hence 0: "nth_elem {j. 0 < j  S} (i - 1 elem
              using T3[of"> = Suc (i - 1) by auto

            have 1: "nths >S} ! (i-1) = as!m jin> S} (i-1)"
              using T2 by blast
            s2etret set_rank_nth_eminv byastfo
              y (tsCn.rems not_less0 nth_Cons' nth_elem_Suc)
            have 3: "(nth_elem S i)<in S"
            of
              have "Suc
              proof
                show "Suc ` {j. Suc j \<in> S} \<subseteq> {j. <  \<and> j \<in> S}"
                  by blast
                show "{j. 0 < j \<and> j \<in> S} \<subseteq> Suc ` {j. Suc j \<in> S}"
                  using Suc_pred 0conv_Suc_Sucbyuto
              qed
              
                using " \And. k \<in> C \<Longrightarrow> length k = n"
            qed
            show "nths (a # as) S -
              using "1" "2" "3" \<open>nths (#as =ths asj c <inS} ! (i - 1)\<close> by auto
java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 13
        qed
      qed
    next
      case False
      have:ths asS hsas{ c \<>S}"
        by (simp add: "0" False)
      have F1: "Suc `{. Succ <>S} = S"
      assumes"forallx \<in> C. \<exists>t. P x t"
            show "S \<subseteq> Suc ` {j. Suc j \<in> S}"  using False Suc_pred  
                by (smt image_iff mem_Collect_eq neq0_conv subsetI)
      qed
      have F2: "{j. Suc jby 
        using F1 
        by (metis unfoldingfibred_cell_at_ind_def_nd_defef
            mem_Collect_eq proj_at_index_list_length subset_iff)        
      have F3: "project_at_indices {j. Suc j \<in> S} as ! i =  nth_elemucj\<Sjava.lang.StringIndexOutOfBoundsException: Index 100 out of bounds for length 100
        using F2 Cons(1)[of "{j. Suc j \<in> S}"] Cons(2)
        by blast
      tissinsert_at_indexndexxpsnsert_at_index_project_awayproject_awayct_awayayv_image_eqI             java.lang.StringIndexOutOfBoundsException: Index 91 out of bounds for length 91
        using F0 F1 F2 nth_elem_Suc_im by fastforce
    qed
  qed
  then show ?
    using assms(1) assmsjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
qed

text\<opentis gth_mapength_uptt)

definition set_rank where
"set_rank S x = (THE list_segment_defdefth neq0_convnot_less0 lus_1_eq_Suc

lemma t_rank_existxist:
  assumes "finite S"
  assumes "x \<in> S"
  <xistsi. i < card S \<and> x = nth_elem S i"
  using assms nth_elem.simps[of S]
  by (metis in_set_conv_nth set_to_list_length sorted_list_of_set(1))  

lemma set_rank_unique:
  assumes "finite S"
  assumes "x \<in S"
  assumes   card \<and> x = nth_elem S i"
  assumes "j < usingsms ist_segment_concat    as byto
  shows "set (list_segment i j as) \<subseteq> set as"
assms _impsf]
  by (simp add: \<open>i < card S \<and> x = nth_elem S i\<close> \<open>j < card S \<and> _m<>
      nth_eq_iff_index_eq set_to_list_length)

lemma nth_elem_set_rank_inv:
  assumes "finite S"
  assumes "x \<in> S"
  shows "nth_elem S (set_rank S x) = x"
  using the_equality  set_rank_unique set_rank_exist assms 
  unfolding set_rank_def 
  by smt

lemma set_rank_nth_elem_inv:
  assumes "finite S"
  assumes "i < card S"
  shows "set_rank S (nth_elem S i) = i"
  using the_equality  set_rank_unique set_rank_exist assms 
  unfolding set_rank_def 
proof -
  show "(THE n. n < card S \<and> nth_elem S i = nth_elem S n) = i"
    using assms(1) assms(2) nth_elem_closed set_rank_unique by blast
qed
 
lemma set_rank_range:
  assumes "finite S"
  assumes "x \<in> S"
  shows "set_rank S x < card S"
  using assms(1) assms(2) set_rank_exist set_rank_nth_elem_inv by fastforce

lemma project_at_indices_nth':
  assumes "S \<subseteq> indices_of as"
  assumes "i \<in> S"
  shows "as ! i = project_at_indices S as ! (set_rank S i) "
  by (metis assms(1) assms(2) finite_lessThan finite_subset indices_of_def nth_elem_set_rank_inv 
      project_at_indices_nth set_rank_range)

fun proj_away_from_index :: "nat \<Rightarrow> 'a list \<Rightarrow> 'a list" (\<open>\<pi>\<^bsub>\<noteq>_\<^esub>\<close>)where
"proj_away_from_index n as = (take n as)@(drop (Suc n) as)"

text\<open>proj\_away\_from\_index is an inverse to insert\_at\_index\<close>

lemma insert_at_index_project_away[simp]:
  assumes "k < length as"
  assumes "bs = (insert_at_index as a k)"
  shows "\<pi>\<^bsub>\<noteq> k\<^esub> bs = as"
  using assms insert_at_index.simps[of as a k] proj_away_from_index.simps[of k bs]
  by (simp add: \<open>k < length as\<close> less_imp_le_nat min.absorb2)

definition fibred_cell :: "'a list set \<Rightarrow> ('a list \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a list set" where 
"fibred_cell C P = {as . \<exists>x t. as = (t#x) \<and> x \<in> C \<and> (P x t)}"

definition fibred_cell_at_ind :: "nat \<Rightarrow> 'a list set \<Rightarrow> ('a list \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a list set" where
"fibred_cell_at_ind n C P = {as . \<exists>x t. as = (insert_at_index x t n) \<and> x \<in> C \<and> (P x t)}"

lemma fibred_cell_lengths:
  assumes "\<And>k. k \<in> C \<Longrightarrow> length k = n"
  shows "k \<in> (fibred_cell C P) \<Longrightarrow> length k = Suc n"
proof-
  assume "k \<in> (fibred_cell C P)"
  obtain x t where "k = (t#x) \<and> x \<in> C \<and> P x t"
  proof -
    assume a1: "\<And>t x. k = t # x \<and> x \<in> C \<and> P x t \<Longrightarrow> thesis"
    have "\<exists>as a. k = a # as \<and> as \<in> C \<and> P as a"
      using \<open>k \<in> fibred_cell C P\<close> fibred_cell_def by blast
    then show ?thesis
      using a1 by blast
  qed
  then show ?thesis 
    by (simp add: assms)
qed

lemma fibred_cell_at_ind_lengths:
  assumes "\<And>k. k \<in> C \<Longrightarrow> length k = n"
  assumes "k \<le> n"
  shows "c \<in> (fibred_cell_at_ind k C P) \<Longrightarrow> length c = Suc n"
proof-
  assume "c \<in> (fibred_cell_at_ind k C P)"
  then obtain x t where "c = (insert_at_index x t k) \<and> x \<in> C \<and> (P x t)"
    using assms
    unfolding fibred_cell_at_ind_def 
    by blast
  then show ?thesis 
    by (simp add: assms(1))   
qed

lemma project_fibred_cell:
  assumes "\<And>k. k \<in> C \<Longrightarrow> length k = n"
  assumes "k < n"
  assumes "\<forall>x \<in> C. \<exists>t. P x t"
  shows "\<pi>\<^bsub>\<noteq> k\<^esub> ` (fibred_cell_at_ind k C P) = C"
proof
  show "\<pi>\<^bsub>\<noteq>k\<^esub> ` fibred_cell_at_ind k C P \<subseteq> C"
  proof
    fix x
    assume x_def: "x \<in> \<pi>\<^bsub>\<noteq>k\<^esub> ` fibred_cell_at_ind k C P"
    then obtain c where c_def: "x = \<pi>\<^bsub>\<noteq>k\<^esub> c \<and> c \<in>  fibred_cell_at_ind k C P"
      by blast
    then obtain y t where yt_def: "c = (insert_at_index y t k) \<and> y \<in> C \<and> (P y t)"
      using assms
      unfolding fibred_cell_at_ind_def 
      by blast
    have 0: "x =\<pi>\<^bsub>\<noteq>k\<^esub> c"
      by (simp add: c_def)
    have 1: "y =\<pi>\<^bsub>\<noteq>k\<^esub> c"
      using yt_def  assms(1) assms(2)
      by (metis insert_at_index_project_away)      
    have 2: "x = y" using 0 1 by auto 
    then show "x \<in> C"
      by (simp add: yt_def)
  qed
  show "C \<subseteq> \<pi>\<^bsub>\<noteq>k\<^esub> ` fibred_cell_at_ind k C P"
  proof fix x
    assume A: "x \<in> C"
    obtain t where t_def: "P x t"
      using assms A by auto 
    then show "x \<in> \<pi>\<^bsub>\<noteq>k\<^esub> ` fibred_cell_at_ind k C P"
    proof -
      have f1: "\<forall>a n A as. take n as @ (a::'a) # drop n as \<notin> A \<or> as \<in> \<pi>\<^bsub>\<noteq>n\<^esub> ` A \<or> \<not> n < length as"
        by (metis insert_at_index.simps insert_at_index_project_away rev_image_eqI)        
      have "\<forall>n. \<exists>as a. take n x @ t # drop n x = insert_at_index as a n \<and> as \<in> C \<and> P as a"
        using A t_def by auto 
      then have "\<forall>n. take n x @ t # drop n x \<in> {insert_at_index as a n |as a. as \<in> C \<and> P as a}"
        by blast
      then have "x \<in> \<pi>\<^bsub>\<noteq>k\<^esub> ` {insert_at_index as a k |as a. as \<in> C \<and> P as a}"
        using f1 by (metis (lifting) A assms(1) assms(2))
      then show ?thesis
        by (simp add: fibred_cell_at_ind_def)
    qed
  qed
qed

definition list_segment where
"list_segment i j as = map (nth as)  [i..<j]"

lemma list_segment_length:
  assumes "i \<le> j"
  assumes "j \<le>  length as"
  shows "length (list_segment i j as) = j - i"
  using  assms 
  unfolding list_segment_def   
  by (metis length_map length_upt)

lemma list_segment_drop:
  assumes "i < length as"
  shows "(list_segment i (length as) as) = drop i  as"
  by (metis One_nat_def Suc_diff_Suc add_diff_inverse_nat drop0  drop_map drop_upt
      less_Suc_eq list_segment_def map_nth neq0_conv not_less0 plus_1_eq_Suc)
  
lemma list_segment_concat:
  assumes "j \<le> k"
  assumes "i \<le> j"
  shows "(list_segment i j as) @ (list_segment j k as) = (list_segment i k as)"
  using assms   unfolding list_segment_def 
  using le_Suc_ex upt_add_eq_append 
  by fastforce

lemma list_segment_subset:
  assumes "j \<le> k"
  shows "set (list_segment i j as) \<subseteq> set (list_segment i k as)"
  apply(cases "i > j")
  unfolding list_segment_def 
  apply (metis in_set_conv_nth length_map list.size(3) order.asym subsetI upt_rec zero_order(3))
proof-
  assume "\<not> j < i"
  then have "i \<le>j"
    using not_le 
    by blast
  then have "list_segment i j as @ list_segment j k as = list_segment i k as"
    using assms list_segment_concat[of j k i as] by auto 
  then show "set (map ((!) as) [i..<j]) \<subseteq> set (map ((!) as) [i..<k])" 
    using set_append  unfolding list_segment_def 
    by (metis Un_upper1)
qed

lemma list_segment_subset_list_set:
  assumes "j \<le> length as"
  shows "set (list_segment i j as) \<subseteq> set as"
  apply(cases "i \<ge> j")
  apply (simp add: list_segment_def)
proof-
  assume A: "\<not> j \<le> i"
  then have B: "i < j"
    by auto 
  have 0: "list_segment i (length as) as = drop i as"
    using B assms list_segment_drop[of i as] less_le_trans 
    by blast
  have 1: "set (list_segment i j as) \<subseteq> set (list_segment i (length as) as)"
    using B assms list_segment_subset[of j "length as" i as] 
    by blast
  then show ?thesis 
  using assms 0 dual_order.trans  set_drop_subset[of i as]
    by metis
qed

definition fun_inv where 
"fun_inv = inv"



end

Messung V0.5 in Prozent
C=87 H=97 G=91

¤ Dauer der Verarbeitung: 0.6 Sekunden  (vorverarbeitet am  2026-06-10) ¤

*© 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 und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge