src/HOL/MicroJava/BV/Product.thy
author kleing
Sun, 03 Mar 2002 16:59:08 +0100
changeset 13006 51c5f3f11d16
parent 12911 704713ca07ea
child 13074 96bf406fd3e5
permissions -rw-r--r--
symbolized
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12516
d09d0f160888 exceptions
kleing
parents: 11549
diff changeset
     1
(*  Title:      HOL/MicroJava/BV/Product.thy
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     2
    ID:         $Id$
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     3
    Author:     Tobias Nipkow
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     4
    Copyright   2000 TUM
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     5
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     6
Products as semilattices
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     7
*)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     8
12911
704713ca07ea new document
kleing
parents: 12516
diff changeset
     9
header {* \isaheader{Products as Semilattices} *}
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    10
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    11
theory Product = Err:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    12
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    13
constdefs
13006
51c5f3f11d16 symbolized
kleing
parents: 12911
diff changeset
    14
 le :: "'a ord \<Rightarrow> 'b ord \<Rightarrow> ('a * 'b) ord"
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    15
"le rA rB == %(a,b) (a',b'). a <=_rA a' & b <=_rB b'"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    16
13006
51c5f3f11d16 symbolized
kleing
parents: 12911
diff changeset
    17
 sup :: "'a ebinop \<Rightarrow> 'b ebinop \<Rightarrow> ('a * 'b)ebinop"
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    18
"sup f g == %(a1,b1)(a2,b2). Err.sup Pair (a1 +_f a2) (b1 +_g b2)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    19
13006
51c5f3f11d16 symbolized
kleing
parents: 12911
diff changeset
    20
 esl :: "'a esl \<Rightarrow> 'b esl \<Rightarrow> ('a * 'b ) esl"
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    21
"esl == %(A,rA,fA) (B,rB,fB). (A <*> B, le rA rB, sup fA fB)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    22
13006
51c5f3f11d16 symbolized
kleing
parents: 12911
diff changeset
    23
syntax "@lesubprod" :: "'a*'b \<Rightarrow> 'a ord \<Rightarrow> 'b ord \<Rightarrow> 'b \<Rightarrow> bool"
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    24
       ("(_ /<='(_,_') _)" [50, 0, 0, 51] 50)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    25
translations "p <=(rA,rB) q" == "p <=_(Product.le rA rB) q"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    26
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    27
lemma unfold_lesub_prod:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    28
  "p <=(rA,rB) q == le rA rB p q"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    29
  by (simp add: lesub_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    30
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    31
lemma le_prod_Pair_conv [iff]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    32
  "((a1,b1) <=(rA,rB) (a2,b2)) = (a1 <=_rA a2 & b1 <=_rB b2)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    33
  by (simp add: lesub_def le_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    34
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    35
lemma less_prod_Pair_conv:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    36
  "((a1,b1) <_(Product.le rA rB) (a2,b2)) = 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    37
  (a1 <_rA a2 & b1 <=_rB b2 | a1 <=_rA a2 & b1 <_rB b2)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    38
apply (unfold lesssub_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    39
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    40
apply blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    41
done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    42
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    43
lemma order_le_prod [iff]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    44
  "order(Product.le rA rB) = (order rA & order rB)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    45
apply (unfold order_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    46
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    47
apply blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    48
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    49
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    50
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    51
lemma acc_le_prodI [intro!]:
13006
51c5f3f11d16 symbolized
kleing
parents: 12911
diff changeset
    52
  "\<lbrakk> acc rA; acc rB \<rbrakk> \<Longrightarrow> acc(Product.le rA rB)"
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    53
apply (unfold acc_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    54
apply (rule wf_subset)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    55
 apply (erule wf_lex_prod)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    56
 apply assumption
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    57
apply (auto simp add: lesssub_def less_prod_Pair_conv lex_prod_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    58
done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    59
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    60
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    61
lemma closed_lift2_sup:
13006
51c5f3f11d16 symbolized
kleing
parents: 12911
diff changeset
    62
  "\<lbrakk> closed (err A) (lift2 f); closed (err B) (lift2 g) \<rbrakk> \<Longrightarrow> 
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    63
  closed (err(A<*>B)) (lift2(sup f g))";
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    64
apply (unfold closed_def plussub_def lift2_def err_def sup_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    65
apply (simp split: err.split)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    66
apply blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    67
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    68
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    69
lemma unfold_plussub_lift2:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    70
  "e1 +_(lift2 f) e2 == lift2 f e1 e2"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    71
  by (simp add: plussub_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    72
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    73
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    74
lemma plus_eq_Err_conv [simp]:
13006
51c5f3f11d16 symbolized
kleing
parents: 12911
diff changeset
    75
  "\<lbrakk> x:A; y:A; semilat(err A, Err.le r, lift2 f) \<rbrakk> 
51c5f3f11d16 symbolized
kleing
parents: 12911
diff changeset
    76
  \<Longrightarrow> (x +_f y = Err) = (~(? z:A. x <=_r z & y <=_r z))"
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    77
proof -
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    78
  have plus_le_conv2:
13006
51c5f3f11d16 symbolized
kleing
parents: 12911
diff changeset
    79
    "\<And>r f z. \<lbrakk> z : err A; semilat (err A, r, f); OK x : err A; OK y : err A;
51c5f3f11d16 symbolized
kleing
parents: 12911
diff changeset
    80
                 OK x +_f OK y <=_r z\<rbrakk> \<Longrightarrow> OK x <=_r z \<and> OK y <=_r z"
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    81
    by (rule plus_le_conv [THEN iffD1])
11549
e7265e70fd7c renamed "antecedent" case to "rule_context";
wenzelm
parents: 10496
diff changeset
    82
  case rule_context
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    83
  thus ?thesis
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    84
  apply (rule_tac iffI)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    85
   apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    86
   apply (drule OK_le_err_OK [THEN iffD2])
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    87
   apply (drule OK_le_err_OK [THEN iffD2])
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    88
   apply (drule semilat_lub)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    89
        apply assumption
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    90
       apply assumption
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    91
      apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    92
     apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    93
    apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    94
   apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    95
  apply (case_tac "x +_f y")
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    96
   apply assumption
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    97
  apply (rename_tac "z")
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    98
  apply (subgoal_tac "OK z: err A")
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    99
  apply (frule plus_le_conv2)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   100
       apply assumption
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   101
      apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   102
      apply blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   103
     apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   104
    apply (blast dest: semilatDorderI order_refl)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   105
   apply blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   106
  apply (erule subst)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   107
  apply (unfold semilat_def err_def closed_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   108
  apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   109
  done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   110
qed
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   111
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   112
lemma err_semilat_Product_esl:
13006
51c5f3f11d16 symbolized
kleing
parents: 12911
diff changeset
   113
  "\<And>L1 L2. \<lbrakk> err_semilat L1; err_semilat L2 \<rbrakk> \<Longrightarrow> err_semilat(Product.esl L1 L2)"
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   114
apply (unfold esl_def Err.sl_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   115
apply (simp (no_asm_simp) only: split_tupled_all)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   116
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   117
apply (simp (no_asm) only: semilat_Def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   118
apply (simp (no_asm_simp) only: semilatDclosedI closed_lift2_sup)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   119
apply (simp (no_asm) only: unfold_lesub_err Err.le_def unfold_plussub_lift2 sup_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   120
apply (auto elim: semilat_le_err_OK1 semilat_le_err_OK2
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   121
            simp add: lift2_def  split: err.split)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   122
apply (blast dest: semilatDorderI)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   123
apply (blast dest: semilatDorderI)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   124
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   125
apply (rule OK_le_err_OK [THEN iffD1])
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   126
apply (erule subst, subst OK_lift2_OK [symmetric], rule semilat_lub)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   127
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   128
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   129
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   130
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   131
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   132
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   133
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   134
apply (rule OK_le_err_OK [THEN iffD1])
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   135
apply (erule subst, subst OK_lift2_OK [symmetric], rule semilat_lub)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   136
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   137
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   138
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   139
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   140
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   141
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   142
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   143
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   144
end