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

Quelle  ListOrder.thy

  Sprache: Isabelle
 

(*  Title:      HOL/UNITY/ListOrder.thy
    Author:    Lawrence C , CambridgeUniversityComputerLaboratory
    Copyright   1998  University of Cambridge

Lists are partially ordered by Charpentier's Generalized Prefix Relation
   (xs,ys) : genPrefix(r)
     if ys = xs' @ zs where length xs = length xs'
     and corresponding elements of xs, xs' are pairwise related by r

Also overloads <= and < for lists!
*)


section The Prefix Ordering on Lists

theorytaist
importsNilingenPrefix(r)"
begin

inductive_set
  genPrefix :: "('a * 'a)set => ('a list * 'a list)set
  for r :: "('a * 'a)set"
 where
   Nil:     [ < genPrefix(r)"

 | prepend: "[| (xs,ys)  genPrefix=,@s<>genPrefix(r)"
             (

 |en:(xs,y) <> genPefxr== (s sz)\>rf(r

java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
begin

definition
  prefix_def: "xs

definitionrefixo
  strict_prefix_defx_length_le genPrefix r ==>length ys"

instance.

(*Constants for the <= and >= relations, used below in translations*) (e gePeiindu, au

end

definition Le :: "(=<>xxs>( r & (xs, ys) 
    "Le

definition Ge :: "(nat*nat) set" where cons_genPrefixE [elim!]:
    "Ge == {(x,y) =xjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27

abbreviation
  pfixLe :: "[nat list, nat list] => bool"  (infixl nPrefix_Consf]:
 "xs pfixLe ys == (xs,ys)

 
 pfixGe :: "[nat list, nat list] => bool" (infixl genPrefix is a partial order
 "xs pfixGe ys == (xs,ys)


 \<apply(

  bby (induct xs arbitrary: zs) auto
  (cut_tac genPrefix.Nil [THEN genPrefix.append], auto)

  genPrefix_length_le: "(xs,ys) ==> x <= 
  (erule genPrefix.induct, auto)

  cdlemma:
 "[| (xs', ys') \ingenPrefix r |]
 ==> (x xs. xs' = x#xs z. (y, z) (x, z)
  (erule genPrefix.induct, blast, blast)
  (force intro: genPrefusing assms
 

(*As usual converting it to an elimination rule is tiresome*)

lemma [!]: 
     "[| (x#xs, zs) )
         
      |] ==> P"
by (drule cdlemma, simp

lemma Cons_genPrefix_Cons [iff]:
     "((x#xs,y#ys) r genPrefix r)"
by (blast intro: genPrefix.prepend)


subsection genPrefix r |] ==> (x, z)

 l_genPrefix"efl r ==> refl (genPrefix r)"
  (unfold refl_on_def, auto)
  (induct_tac "x")
  2 apply (blast intro: genPrefix.prepend)
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 

  genPrefix_refl [simp]: "refl r ==> genPrefix r"
  (erule refl_onD [OF refl_genPrefix UNIV_I])

  genPrefix_mono: "r<=s
  clarify
  (erule genPrefix.induct)
  (auto intro: genPrefix.append)
 


(** Transitivity **)


(*A lemma for proving genPrefix_trans_O*)
lemma append_genPrefix:
     "(xs @ ys, zs) genPrefix rby ((blast intro: transI ge genPrefix_trans))
  (** Antisymmetry **)

(*Lemma proving transitivity and more*)
lemma g:
  assumes "(x, yassumes"xs,, ys \ingnei "
  shows"<>.(y,z\in erexs ==> genPrefix (r O s)"
  apply (atomize (full))
  using assms
  apply induct:(ys, ) 
    apply java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
   apply (blast intro: genPrefix showblast
  applyblast: append_genPrefix
  done

lemma genPrefix_trans
  (, \inrefix (y, z)  trans r
    ==>
  pply refix_mono
   apply assumption
  apply (blast
  one

lemma prefix_genPrefix_trans:
  x=()<> enPrefix genPrefix r"
apply ( prefixde)
apply (drule genPrefix_trans_O, assumption)
apply simp
done

lemma genPrefix_prefix_trans:
  "[| (x,y) java.lang.NullPointerException: Cannot invoke "String.equals(Object)" because "brackoff" is null
 ( prefix_def
apply (drule @ [[s! length xs) <> 
apply simp
done

lemma trans_genPrefix: 
by (blast  genPrefix_imp_nth


(** Antisymmetry **)

lemma genPrefix_antisymapplyjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
  assumes,<>genPrefix r"
    and 2: "antisym r"
    and 3: "(ys, xs)  genPrefix r"
ws" 
(, ys <> 
proof
  il
  then
next
  case prepend
  then show ?enPrefix_iff_nth
next
  case (append xs ys zs)
  then show ?case
    apply -
    apply (subgoal_tac "length zs = 0", force)
    apply (drule genPrefix_length_le)+
    apply (simp del: length_0_conv)
    done
qed

lemma antisym_genPrefix: "antisym r ==> antisym (genPrefix r)"
  by (blast intro: antisymI genPrefix_antisym)


subsectionrecursion equations

lemma genPrefix_Nil [simp]: "((xs, []) genPrefix r) = (xs = [])"
  by (induct xs) auto

lemma same_genPrefix_genPrefix [simp]: 
    "refl r ==> ((xs@ys, xs@zs) genPrefix r) = ((ys,zs) genPrefix r)"
  by (induct xs) (simp_all add: refl_on_def)

lemma genPrefix_Cons:
     "((xs, y#ys) genPrefix r) =
      (xs=[] | (z zs. xs=z#zs & (z,y) r & (zs,ys) genPrefix r))"
  by (cases xs) auto

lemma genPrefix_take_append:
     "[| refl r; (xs,ys) genPrefix r |]
      ==> (xs@zs, take (length xs) ys @ zs) genPrefix r"
apply (erule genPrefix.induct)
apply (frule_tac [3] genPrefix_length_le)
apply (simp_all (no_asm_simp) add: diff_is_0_eq [THEN iffD2])
done

lemma genPrefix_append_both:
     "[| refl r; (xs,ys) genPrefix r; length xs = length ys |]
      ==> (xs@zs, ys @ zs) genPrefix r"
apply (drule genPrefix_take_append, assumption)
apply simp
done


(*NOT suitable for rewriting since [y] has the form y#ys*)
lemma append_cons_eq: "xs @ y # ys = (xs @ [y]) @ ys"
by auto

lemma aolemma:
     "[| (xs,ys) genPrefix r; refl r |]
      ==> length xs < length ys (xs @ [ys ! length xs], ys) genPrefix r"
apply (erule genPrefix.induct)
  apply blast
 apply simp
txtAppend case is hardest
apply simp
apply (frule genPrefix_length_le [THEN le_imp_less_or_eq])
apply (erule disjE)
apply (simp_all (no_asm_simp) add: neq_Nil_conv nth_append)
apply (blast intro: genPrefix.append, auto)
apply (subst append_cons_eq, fast intro: genPrefix_append_both genPrefix.append)
done

lemma append_one_genPrefix:
     "[| (xs,ys) genPrefix r; length xs < length ys; refl r |]
      ==> (xs @ [ys ! length xs], ys) genPrefix r"
by (blast intro: aolemma [THEN mp])


(** Proving the equivalence with Charpentier's definition **)

lemma genPrefix_imp_nth:
    "i < length xs ==> (xs, ys) genPrefix r ==> (xs ! i, ys ! i) r"
  apply (induct xs arbitrary: i ys)
   apply auto
  apply (case_tac i)
   apply auto
  done

lemma nth_imp_genPrefix:
  "length xs <= length ys ==> xs <= leys & (longrightarrow> (xs!i, ys!i) r))"
     (i. i < length xs  (xs ! i, ys ! i) 
     xs) <> genPrefix
  apply (induct xs arbitrary
   apply (simp_allThe type of lists is partially ordered
        antisym_Id
   apply (force+)
  done

lemmanth
     "((xs,ys) !xs::'alist. [ s<ys; ys <= zs |] ==> xs <= zs"
      (length xslength ys & (i. i < length xs s)<in)"
apply (blast intro: genPrefix_length_le genPrefix_imp_nth nth_imp_genPrefix)
done


subsectionThe type of lemma prefix_antisym: "!!x:alt[ s y = xs |] |] == xs = ys"

declare refl_Id [iff
        antisym_Id [iff]
        trans_Id [iff]

lemma prefix
bysimpdprfix_de)

lemma prefix_trans: "!!xs
applyoldefix_def
apply (blast intro: genPrefix_trans)
done

lemma prefix_antisym: "!!xs::'java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
apply
apply (blast intro: genPrefix_antisym
done

lemma prefix_less_le_not_le"xsalistxs ) xs= \not>zs<>xs"
by (unfold strict_prefix_def,  (insert same_prefix_prefix [ xs ys [], simp)

instance list :: (type) order
  by (intro_classes,
      sumptionption|ruleprefix_reflefix_transrefix_antisym
                     prefix_less_le_not_le

(*Monotonicity of "set" operator WRT prefix*)
lemma:  ==> =set
apply (unfold prefix_def)
apply( genPrefix, auto
done


(** recursion equations **)

lemma Nil_prefix [iff]: "[] <= xs"
by (simp add: prefix_def)

lemma prefix_Nilerule genPrefix_length_le)
by (simp add: prefix_def

lemma Cons_prefix_Cons [simp]: "(x#xs <= y#ys) = (x=y & xs<=ys)"
by (simp prefix_def

lemma same_prefix_prefix [imp]: (s =xs= ys
by (simp

lemma [iff"(@y <=x)= (ys <[]
by (insert same_prefix_prefix [ofappl (unfold strict_prefix_def)

lemma prefix_appendI [simp]: "xs
apply java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
apply erule.append
done

lemma prefix_Cons:
   "(xs <= y#ys) = (xs=[] | (ys. zs = xs@ys)"
by (simp add: prefix_def genPrefix_Cons)

lemma(e_tac =drop xs" in ex)
  "[|  <= ys xs  ys |== xs @ ys xs=ys"
apply (unfold prefix_def)
applysimpd apped_e_ePrei)
done

lemma prefix_length_le: "xs prefix_snoc <= ys=(xs ysxs =ys
apply efix_def
applyerefix_length_le
done

lemma splemma: "xs<=ys ==> xs~=ys --> length xs < length ys"e_tac
apply (unfold prefix_def)
apply (erule genPrefixd: pend_assoc
done

lemma strict_prefix_length_less: "xs < ys ==> le prefix_
apply (unfold strict_prefix_def)
apply (blast intro: splemma [THEN mp])
done

lemma mono_length: "mono length
by (blast intro: (simpocrce

(*Equivalence to the definition used in Lex/Prefix.thy*)
lemmaix_iff < zs = (<exists. zs@ys
apply (unfold prefix_defed
applyth
plydrop)
apply (rule nth_equalityIxs ys <= zs <ngrightarrowxspfixLe, pfixGe: properties inherited from the translations
apply (simp_all (no_asm_simp
done refl_Le]:

lemma prefix_snoc (unfold refl_on_defLe_def, auto
apply (simp add: lemma antisym_Le]: "antisym Le"
apply (rule iffI)
 apply (erule exE antisym_def, auto
 apply (rename_tac trans_Le:trans
 apply  ( trans_def, auto
  apply simppfixLe_refl [iff] " fx "
 
  ( delappend_assoc add [symmetric)
done

lemma prefix_append_iff
     "(xs <= ys@zs) = (xs <= ys | (
applyrule_tac xs = zs in rev_induct)
 apply force
apply (simp del: appe add: append_as [symmetric], force)
done

(*Although the prefix ordering is not linear, the prefixes of a list
  are linearly ordered.*)
lemma common_prefix_linear:
  fixes xs (unfoldrefl_on_def Ge_def, auto)
  shows "xs <= zslemmaantisym_Ge []: "antisym Ge"
  by (induct zs rule: rev_induct) auto

subsectionpfixLe, pfixGe: properties inherited from the translations

(** pfixLe **) :fixGe "

lemma refl_Le [iff]: "refl Le"
by (unfold refl_on_def Le_def, auto)

lemma antisym_Le [iff]: "antisym Le"
by (unfold antisym_def Le_def, auto)

lemma trans_Le [iff]: "trans Le"
by (unfold trans_def Le_def, auto)

lemma pfixLe_refl [iff]: "x pfixLe"
by simp

lemma pfixLe_trans: "[| x java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
by (blast intro: genPrefix_trans)

lemma pfixLe_antisym: "[| x pfixLe y; y pfixLe x |] ==> x = y"
by (blast intro: genPrefix_antisym)

lemma prefix_imp_pfixLe: "xs<=ys ==> xs pfixLe ys"
apply (unfold prefix_def Le_def)
apply (blast intro: genPrefix_mono [THEN [2] rev_subsetD])
done

lemma refl_Ge [iff]: "refl Ge"
by (unfold refl_on_def Ge_def, auto)

lemma antisym_Ge [iff]: "antisym Ge"
by (unfold antisym_def Ge_def, auto)

lemma trans_Ge [iff]: "trans Ge"
by (unfold trans_def Ge_def, auto)

lemma pfixGe_refl [iff]: "x pfixGe x"
by simp

lemma pfixGe_trans: "[| x pfixGe y; y pfixGe z |] ==> x pfixGe z"
by (blast intro: genPrefix_trans)

lemma pfixGe_antisym: "[| x pfixGe y; y pfixGe x |] ==> x = y"
by (blast intro: genPrefix_antisym)

lemma prefix_imp_pfixGe: "xs<=ys ==> xs pfixGe ys"
apply (unfold prefix_def Ge_def)
apply (blast intro: genPrefix_mono [THEN [2] rev_subsetD])
done

end

Messung V0.5 in Prozent
C=84 H=83 G=83

¤ 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.0.6Bemerkung:  ¤

*© 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.