src/HOL/MicroJava/BV/Convert.thy
changeset 10056 9f84ffa4a8d0
parent 10042 7164dc0d24d8
child 10060 4522e59b7d84
equal deleted inserted replaced
10055:2264bdd8becc 10056:9f84ffa4a8d0
    38                        Err  => True
    38                        Err  => True
    39                      | Ok t => (case a' of Err => False | Ok t' => P t' t)"
    39                      | Ok t => (case a' of Err => False | Ok t' => P t' t)"
    40 
    40 
    41   (* lifts a relation to option with None as bottom element *)
    41   (* lifts a relation to option with None as bottom element *)
    42   lift_bottom :: "('a => 'b => bool) => ('a option => 'b option => bool)"
    42   lift_bottom :: "('a => 'b => bool) => ('a option => 'b option => bool)"
    43   "lift_bottom P a' a == case a' of 
    43   "lift_bottom P a' a == 
    44                           None    => True 
    44    case a' of 
    45                         | Some t' => (case a of None => False | Some t => P t' t)"
    45      None    => True 
    46 
    46    | Some t' => (case a of None => False | Some t => P t' t)"
    47   sup_ty_opt :: "['code prog,ty err,ty err] => bool" ("_ \<turnstile> _ <=o _" [71,71] 70)
    47 
       
    48   sup_ty_opt :: "['code prog,ty err,ty err] => bool" 
       
    49                  ("_ \<turnstile> _ <=o _" [71,71] 70)
    48   "sup_ty_opt G == lift_top (\<lambda>t t'. G \<turnstile> t \<preceq> t')"
    50   "sup_ty_opt G == lift_top (\<lambda>t t'. G \<turnstile> t \<preceq> t')"
    49 
    51 
    50   sup_loc :: "['code prog,locvars_type,locvars_type] => bool" 
    52   sup_loc :: "['code prog,locvars_type,locvars_type] => bool" 
    51               ("_ \<turnstile> _ <=l _"  [71,71] 70)
    53               ("_ \<turnstile> _ <=l _"  [71,71] 70)
    52   "G \<turnstile> LT <=l LT' == list_all2 (\<lambda>t t'. (G \<turnstile> t <=o t')) LT LT'"
    54   "G \<turnstile> LT <=l LT' == list_all2 (\<lambda>t t'. (G \<turnstile> t <=o t')) LT LT'"
    53 
    55 
    54   sup_state :: "['code prog,state_type,state_type] => bool"	  
    56   sup_state :: "['code prog,state_type,state_type] => bool"	  
    55                ("_ \<turnstile> _ <=s _"  [71,71] 70)
    57                ("_ \<turnstile> _ <=s _"  [71,71] 70)
    56   "G \<turnstile> s <=s s' == (G \<turnstile> map Ok (fst s) <=l map Ok (fst s')) \<and> G \<turnstile> snd s <=l snd s'"
    58   "G \<turnstile> s <=s s' == 
       
    59    (G \<turnstile> map Ok (fst s) <=l map Ok (fst s')) \<and> G \<turnstile> snd s <=l snd s'"
    57 
    60 
    58   sup_state_opt :: "['code prog,state_type option,state_type option] => bool" 
    61   sup_state_opt :: "['code prog,state_type option,state_type option] => bool" 
    59                    ("_ \<turnstile> _ <=' _"  [71,71] 70)
    62                    ("_ \<turnstile> _ <=' _"  [71,71] 70)
    60   "sup_state_opt G == lift_bottom (\<lambda>t t'. G \<turnstile> t <=s t')"
    63   "sup_state_opt G == lift_bottom (\<lambda>t t'. G \<turnstile> t <=s t')"
    61 
    64 
    62 syntax (HTML output) 
    65 syntax (HTML output) 
    63   sup_ty_opt :: "['code prog,ty err,ty err] => bool" ("_ |- _ <=o _")
    66   sup_ty_opt    :: "['code prog,ty err,ty err] => bool" 
    64   sup_loc :: "['code prog,locvars_type,locvars_type] => bool" ("_ |- _ <=l _"  [71,71] 70)
    67                    ("_ |- _ <=o _")
    65   sup_state :: "['code prog,state_type,state_type] => bool"	("_ |- _ <=s _"  [71,71] 70)
    68   sup_loc       :: "['code prog,locvars_type,locvars_type] => bool" 
    66   sup_state_opt :: "['code prog,state_type option,state_type option] => bool" ("_ |- _ <=' _"  [71,71] 70)
    69                    ("_ |- _ <=l _"  [71,71] 70)
       
    70   sup_state     :: "['code prog,state_type,state_type] => bool"	
       
    71                    ("_ |- _ <=s _"  [71,71] 70)
       
    72   sup_state_opt :: "['code prog,state_type option,state_type option] => bool"
       
    73                    ("_ |- _ <=' _"  [71,71] 70)
    67                    
    74                    
    68 
    75 
    69 lemma not_Err_eq [iff]:
    76 lemma not_Err_eq [iff]:
    70   "(x \<noteq> Err) = (\<exists>a. x = Ok a)" 
    77   "(x \<noteq> Err) = (\<exists>a. x = Ok a)" 
    71   by (cases x) auto
    78   by (cases x) auto
    78 lemma lift_top_refl [simp]:
    85 lemma lift_top_refl [simp]:
    79   "[| !!x. P x x |] ==> lift_top P x x"
    86   "[| !!x. P x x |] ==> lift_top P x x"
    80   by (simp add: lift_top_def split: err.splits)
    87   by (simp add: lift_top_def split: err.splits)
    81 
    88 
    82 lemma lift_top_trans [trans]:
    89 lemma lift_top_trans [trans]:
    83   "[| !!x y z. [| P x y; P y z |] ==> P x z; lift_top P x y; lift_top P y z |] 
    90   "[| !!x y z. [| P x y; P y z |] ==> P x z; lift_top P x y; lift_top P y z |]
    84   ==> lift_top P x z"
    91   ==> lift_top P x z"
    85 proof -
    92 proof -
    86   assume [trans]: "!!x y z. [| P x y; P y z |] ==> P x z"
    93   assume [trans]: "!!x y z. [| P x y; P y z |] ==> P x z"
    87   assume a: "lift_top P x y"
    94   assume a: "lift_top P x y"
    88   assume b: "lift_top P y z"
    95   assume b: "lift_top P y z"
   139 lemma lift_bottom_refl [simp]:
   146 lemma lift_bottom_refl [simp]:
   140   "[| !!x. P x x |] ==> lift_bottom P x x"
   147   "[| !!x. P x x |] ==> lift_bottom P x x"
   141   by (simp add: lift_bottom_def split: option.splits)
   148   by (simp add: lift_bottom_def split: option.splits)
   142 
   149 
   143 lemma lift_bottom_trans [trans]:
   150 lemma lift_bottom_trans [trans]:
   144   "[| !!x y z. [| P x y; P y z |] ==> P x z; lift_bottom P x y; lift_bottom P y z |]
   151   "[| !!x y z. [| P x y; P y z |] ==> P x z; 
       
   152       lift_bottom P x y; lift_bottom P y z |]
   145   ==> lift_bottom P x z"
   153   ==> lift_bottom P x z"
   146 proof -
   154 proof -
   147   assume [trans]: "!!x y z. [| P x y; P y z |] ==> P x z"
   155   assume [trans]: "!!x y z. [| P x y; P y z |] ==> P x z"
   148   assume a: "lift_bottom P x y"
   156   assume a: "lift_bottom P x y"
   149   assume b: "lift_bottom P y z"
   157   assume b: "lift_bottom P y z"
   284   show ?thesis by blast
   292   show ?thesis by blast
   285 qed
   293 qed
   286 
   294 
   287 
   295 
   288 theorem all_nth_sup_loc:
   296 theorem all_nth_sup_loc:
   289   "\<forall>b. length a = length b --> (\<forall> n. n < length a --> (G \<turnstile> (a!n) <=o (b!n))) --> 
   297   "\<forall>b. length a = length b --> (\<forall> n. n < length a --> (G \<turnstile> (a!n) <=o (b!n))) 
   290        (G \<turnstile> a <=l b)" (is "?P a")
   298   --> (G \<turnstile> a <=l b)" (is "?P a")
   291 proof (induct a)
   299 proof (induct a)
   292   show "?P []" by simp
   300   show "?P []" by simp
   293 
   301 
   294   fix l ls assume IH: "?P ls"
   302   fix l ls assume IH: "?P ls"
   295   
   303