src/HOL/IMP/Sec_Type_Expr.thy
author haftmann
Fri, 01 Nov 2013 18:51:14 +0100
changeset 54230 b1d955791529
parent 53015 a1119cf551e8
child 58889 5b7a9633cfa8
permissions -rw-r--r--
more simplification rules on unary and binary minus
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43158
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
     1
header "Security Type Systems"
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
     2
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
     3
theory Sec_Type_Expr imports Big_Step
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
     4
begin
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
     5
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
     6
subsection "Security Levels and Expressions"
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
     7
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
     8
type_synonym level = nat
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
     9
50342
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    10
class sec =
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    11
fixes sec :: "'a \<Rightarrow> nat"
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    12
43158
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    13
text{* The security/confidentiality level of each variable is globally fixed
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    14
for simplicity. For the sake of examples --- the general theory does not rely
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    15
on it! --- a variable of length @{text n} has security level @{text n}: *}
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    16
50342
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    17
instantiation list :: (type)sec
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    18
begin
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    19
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    20
definition "sec(x :: 'a list) = length x"
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    21
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    22
instance ..
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    23
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    24
end
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    25
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    26
instantiation aexp :: sec
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    27
begin
43158
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    28
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    29
fun sec_aexp :: "aexp \<Rightarrow> level" where
50342
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    30
"sec (N n) = 0" |
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    31
"sec (V x) = sec x" |
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50342
diff changeset
    32
"sec (Plus a\<^sub>1 a\<^sub>2) = max (sec a\<^sub>1) (sec a\<^sub>2)"
50342
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    33
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    34
instance ..
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    35
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    36
end
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    37
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    38
instantiation bexp :: sec
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    39
begin
43158
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    40
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    41
fun sec_bexp :: "bexp \<Rightarrow> level" where
50342
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    42
"sec (Bc v) = 0" |
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    43
"sec (Not b) = sec b" |
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50342
diff changeset
    44
"sec (And b\<^sub>1 b\<^sub>2) = max (sec b\<^sub>1) (sec b\<^sub>2)" |
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50342
diff changeset
    45
"sec (Less a\<^sub>1 a\<^sub>2) = max (sec a\<^sub>1) (sec a\<^sub>2)"
50342
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    46
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    47
instance ..
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    48
e77b0dbcae5b tuned defs of sec_xyz
nipkow
parents: 45212
diff changeset
    49
end
43158
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    50
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    51
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    52
abbreviation eq_le :: "state \<Rightarrow> state \<Rightarrow> level \<Rightarrow> bool"
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    53
  ("(_ = _ '(\<le> _'))" [51,51,0] 50) where
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    54
"s = s' (\<le> l) == (\<forall> x. sec x \<le> l \<longrightarrow> s x = s' x)"
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    55
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    56
abbreviation eq_less :: "state \<Rightarrow> state \<Rightarrow> level \<Rightarrow> bool"
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    57
  ("(_ = _ '(< _'))" [51,51,0] 50) where
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    58
"s = s' (< l) == (\<forall> x. sec x < l \<longrightarrow> s x = s' x)"
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    59
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    60
lemma aval_eq_if_eq_le:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50342
diff changeset
    61
  "\<lbrakk> s\<^sub>1 = s\<^sub>2 (\<le> l);  sec a \<le> l \<rbrakk> \<Longrightarrow> aval a s\<^sub>1 = aval a s\<^sub>2"
43158
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    62
by (induct a) auto
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    63
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    64
lemma bval_eq_if_eq_le:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50342
diff changeset
    65
  "\<lbrakk> s\<^sub>1 = s\<^sub>2 (\<le> l);  sec b \<le> l \<rbrakk> \<Longrightarrow> bval b s\<^sub>1 = bval b s\<^sub>2"
43158
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    66
by (induct b) (auto simp add: aval_eq_if_eq_le)
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    67
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    68
end