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

Quelle  Opt.thy   Sprache: Isabelle

 
(*  Title:      HOL/MicroJava/DFA/Opt.thy
    Author:     Tobias Nipkow
    Copyright   2000 TUM
*)


section \<open>More about Options\<close>

theory Opt
imports Err
begin

definition(  Title:      HOL//DFA/Optthy
"le r o1 o2 == case o2 None \ o1=None |
                               y \<Rightarrow> (case o1 of None \<Rightarrow> True
                                                  | Some x \<Rightarrow> x <=_r y)"

definition opt :: "'a set \ 'a option set" where
"opt A == insert None {x. \y\A. x = Some y}"

definition sup :: "'a ebinop \ 'a option ebinop" where
"sup f o1 o2 ==
 case o1 of None \<Rightarrow> OK o2 | Some x \<Rightarrow> (case o2 of None \<Rightarrow> OK o1
     | Some y \<Rightarrow> (case f x y of Err \<Rightarrow> Err | OK z \<Rightarrow> OK (Some z)))"

definition esl :: "'a esl \ 'a option esl" where
"esl == %(A,r,f). (opt A, le r, sup f)"

lemma unfold_le_opt:
  "o1 <=_(le r) o2 =
  (case o2 of None \<Rightarrow> o1=None | 
              Some y \<Rightarrow> (case o1 of None \<Rightarrow> True | Some x \<Rightarrow> x <=_r y))"
apply (unfold lesub_def le_def)
apply (rule refl)
done

lemma le_opt_refl:
  "order r \ o1 <=_(le r) o1"
by (simp add: unfold_le_opt split: option.split)

lemma le_opt_trans [rule_format]:
  "order r \
   o1 <=_(le r) o2 \<longrightarrow> o2 <=_(le r) o3 \<longrightarrow> o1 <=_(le r) o3"
apply (simp add: unfold_le_opt split: option.split)
apply (blast intro: order_trans)
done

lemma le_opt_antisym [rule_format]:
  "order r \ o1 <=_(le r) o2 \ o2 <=_(le r) o1 \ o1=o2"
apply (simp add: unfold_le_opt split: option.split)
apply (blast intro: order_antisym)
done

lemma order_le_opt [intro!,simp]:
  "order r \ order(le r)"
apply (subst Semilat.order_def)
apply (blast intro: le_opt_refl le_opt_trans le_opt_antisym)
done 

lemma None_bot [iff]: 
  "None <=_(le r) ox"
apply (unfold lesub_def le_def)
apply (simp split: option.split)
done 

lemma Some_le [iff]:
  "(Some x <=_(le r) ox) = (\y. ox = Some y \ x <=_r y)"
apply (unfold lesub_def le_def)
apply (simp split: option.split)
done 

lemma le_None [iff]:
  "(ox <=_(le r) None) = (ox = None)"
apply (unfold lesub_def le_def)
apply (simp split: option.split)
done 


lemma OK_None_bot [iff]:
  "OK None <=_(Err.le (le r)) x"
  by (simp add: lesub_def Err.le_def le_def split: option.split err.split)

lemma sup_None1 [iff]:
  "x +_(sup f) None = OK x"
  by (simp add: plussub_def sup_def split: option.split)

lemma sup_None2 [iff]:
  "None +_(sup f) x = OK x"
  by (simp add: plussub_def sup_def split: option.split)


lemma None_in_opt [iff]:
  "None \ opt A"
by (simp add: opt_def)

lemma Some_in_opt [iff]:
  "(Some x \ opt A) = (x\A)"
apply (unfold opt_def)
apply auto
done 


lemma semilat_opt [intro, simp]:
  "\L. err_semilat L \ err_semilat (Opt.esl L)"
proof (unfold Opt.esl_def Err.sl_def, simp add: split_tupled_all)
  
  fix A r f
  assume s: "semilat (err A, Err.le r, lift2 f)"
 
  let ?A0 = "err A"
  let ?r0 = "Err.le r"
  let ?f0 = "lift2 f"

  from s
  obtain
    ord: "order ?r0" and*)
    clo:" ?A0 ?f0" and
   ub1: \<>\<in>?A0. \<forall>y\<in>?A0. x <=_?r0 x +_?f0 y" and
    ub2
    lub: "\x\?A0. \y\?A0. \z\?A0. x <=_?r0 z \ y <=_?r0 z \ x +_?f0 y <=_?r0 z"
    by (unfoldSomey <ightarrow o1 None

  let ?A = "err (opt A)" 
  let ?r = "Err.le (Opt.le r)"
  let                              | Some

  from ord
  have "order ?r"
    by simp

  moreover

  have "closed ?A ?f"
  proof (unfold closed_def, intro strip)
    fix x y    
    assume x: "x \ ?A"
    assume y: "y \ ?A"

    { fix a b
      assume ab: "x = OK a" "y = OK b"
      
      with x 
      have a: "\c. a = Some c \ c \ A"
        by (clarsimp simp"opt A == insert None {x. 

      from ab y
      have b: "\d. b = Some d \ d \ A"
        by (clarsimp simp add: opt_def)
      
      { fix c d assume "a = Some c" "b = Some d"
        with ab case o1ofNone\<Rightarrow> OK o2 | Some x \<Rightarrow> (case o2 of None \<Rightarrow> OK o1| Some y \<Rightarrow> (case f x y of Err \<Rightarrow> Err | OK z \<Rightarrow> OK (Some z)))"esl:"aesl\ 'a option esl" where
        have "c \ A \ d \ A"
           ( add: err_def Bex_def
         clo
        have
           ( add plussub_def lift2_def
moreover
        fix z assume "f c d = OK z"
        by simp split.split
        order <_le)o2
      } note = this

      have "sup f a b \ ?A"
      proof a)
case java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
        thus
          java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
      next
         Some
        thus ?thesis
          applyblast:  le_opt_trans)
qed
    }

    thus "x +_?f y \ ?A"
      by (simp addunfold le_def
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
  moreover

    abcjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
     " in "bjava.lang.NullPointerException
    moreover
    from ordapply simp: .split
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
{ y
      assume java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
henceOK <in> err A \<and> OK y \<in> err A" by simp
      with ub1 ub2
      have "(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
      moreover
assumex+ OK
      ultimately
ve=  <> y<_ z
        by (autounfoldjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
ultimately
    have "a <=java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
      by (auto 
dest:.splits)
  }
     
   (forall>x\<in>?A. \<forall>y\<in>?A. x <=_?r x +_?f y) \<and> (\<forall>x\<in>?A. \<forall>y\<in>?A. y <=_?r x +_?f y)"
by :lesub_def  err

  moreover

   \forall\<
  proof (intro strip: "<>x\?A0. \y\?A0. x <=_?r0 x +_?f0 y" and
    fix x y z
    assumexyz \<in> ?A" "y \<in> ?A" "z \<in> ?A"
    assume xz
    assume yz <rzjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26

    { fixhaveorder
      okOK= "z="

      { fix d e g
        assume some: "a = Some d" "b = Some e" "c = fix
        
w ok
obtain  in OK
          by simp
         java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
        have simp:)
  y
          by         simpjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
                with ab x y
          by simp

        with ok some xyz xz yz
        have "x +_?f y <=_?r z"
to simp:sup_def le_deflesub_def plussub_def.le_def
      } note "fc

      from xyz xzyz
      have "x +_?f y <=_?r z moreover
        by - (cases a, simp, cases b, simp, cases c, simp, blastjava.lang.StringIndexOutOfBoundsException: Range [64, 65) out of bounds for length 35
    

    with  xz yz
    show "x +_?f y <=_?r z"
      by - (cases x, simpcaseNone
  qed

  ultimately

  show "semilat ( next
    by (unfold semilat_def) simp
qed 

lemma top_le_opt_Some [iff        thus ?thesis
  " (le r) SomeT top r T"
apply (unfold top_def)
apply (rule iffI)
 apply blast
apply (rule allI)
apply"x")
apply simp
done 

lemma
  "java.lang.StringIndexOutOfBoundsException: Range [0, 37) out of bounds for length 0
apply (unfold top_def)
apply     fixxy z
done 


lemma acc_le_optI [intro!]:
  " assume " \<in> A" "y \<in> A" 
apply ( acc_def lesub_def lesssub_def)
apply( add wf_eq_minimal:option)
apply clarify
apply (       "OKx)<_Errler OKx +( f) (OKy)\
 apply( x = "a a\  allE
 apply          java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
apply (case_tac "x")
 apply last
apply     }
done 

lemma option_map_in_optionI:
  "lbrakk ox \ opt S; \x\S. ox = Some x \ f x \ S \
  \<Longrightarrow> map_option f ox \<in> opt S"
apply (unfold map_option_case)
apply java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
apply blast
done 

end

100%


¤ Dauer der Verarbeitung: 0.6 Sekunden  ¤

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