Quot/Examples/LarryDatatype.thy
author Christian Urban <urbanc@in.tum.de>
Fri, 11 Dec 2009 15:58:15 +0100
changeset 715 3d7a9d4d2bb6
parent 708 587e97d144a0
child 723 93dce7c71929
permissions -rw-r--r--
added Int example from Larry
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
715
3d7a9d4d2bb6 added Int example from Larry
Christian Urban <urbanc@in.tum.de>
parents: 708
diff changeset
     1
theory LarryDatatype
700
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
imports Main "../QuotMain"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
begin
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
subsection{*Defining the Free Algebra*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
datatype
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
  freemsg = NONCE  nat
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
        | MPAIR  freemsg freemsg
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
        | CRYPT  nat freemsg  
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
        | DECRYPT  nat freemsg
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
inductive 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
  msgrel::"freemsg \<Rightarrow> freemsg \<Rightarrow> bool" (infixl "\<sim>" 50)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
where 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
  CD:    "CRYPT K (DECRYPT K X) \<sim> X"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
| DC:    "DECRYPT K (CRYPT K X) \<sim> X"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
| NONCE: "NONCE N \<sim> NONCE N"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
| MPAIR: "\<lbrakk>X \<sim> X'; Y \<sim> Y'\<rbrakk> \<Longrightarrow> MPAIR X Y \<sim> MPAIR X' Y'"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
| CRYPT: "X \<sim> X' \<Longrightarrow> CRYPT K X \<sim> CRYPT K X'"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
| DECRYPT: "X \<sim> X' \<Longrightarrow> DECRYPT K X \<sim> DECRYPT K X'"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
| SYM:   "X \<sim> Y \<Longrightarrow> Y \<sim> X"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
| TRANS: "\<lbrakk>X \<sim> Y; Y \<sim> Z\<rbrakk> \<Longrightarrow> X \<sim> Z"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
702
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
    25
lemmas msgrel.intros[intro]
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
    26
700
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
text{*Proving that it is an equivalence relation*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
lemma msgrel_refl: "X \<sim> X"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
by (induct X, (blast intro: msgrel.intros)+)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
theorem equiv_msgrel: "equivp msgrel"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
proof (rule equivpI)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
  show "reflp msgrel" by (simp add: reflp_def msgrel_refl)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
  show "symp msgrel" by (simp add: symp_def, blast intro: msgrel.SYM)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
  show "transp msgrel" by (simp add: transp_def, blast intro: msgrel.TRANS)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
qed
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
subsection{*Some Functions on the Free Algebra*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
subsubsection{*The Set of Nonces*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
702
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
    43
fun
700
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
  freenonces :: "freemsg \<Rightarrow> nat set"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
where
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
  "freenonces (NONCE N) = {N}"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
| "freenonces (MPAIR X Y) = freenonces X \<union> freenonces Y"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
| "freenonces (CRYPT K X) = freenonces X"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
| "freenonces (DECRYPT K X) = freenonces X"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
theorem msgrel_imp_eq_freenonces: 
702
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
    52
  assumes a: "U \<sim> V"
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
    53
  shows "freenonces U = freenonces V"
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
    54
using a by (induct) (auto) 
700
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
subsubsection{*The Left Projection*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
text{*A function to return the left part of the top pair in a message.  It will
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
be lifted to the initial algrebra, to serve as an example of that process.*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
fun
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
  freeleft :: "freemsg \<Rightarrow> freemsg"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
where
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
  "freeleft (NONCE N) = NONCE N"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
| "freeleft (MPAIR X Y) = X"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
| "freeleft (CRYPT K X) = freeleft X"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
| "freeleft (DECRYPT K X) = freeleft X"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
text{*This theorem lets us prove that the left function respects the
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
equivalence relation.  It also helps us prove that MPair
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
  (the abstract constructor) is injective*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
lemma msgrel_imp_eqv_freeleft_aux:
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
  shows "freeleft U \<sim> freeleft U"
702
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
    73
by (induct rule: freeleft.induct) (auto)
700
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
theorem msgrel_imp_eqv_freeleft:
702
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
    76
  assumes a: "U \<sim> V" 
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
    77
  shows "freeleft U \<sim> freeleft V"
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
    78
using a
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
    79
by (induct)(auto intro: msgrel_imp_eqv_freeleft_aux)
700
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
subsubsection{*The Right Projection*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
text{*A function to return the right part of the top pair in a message.*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
fun
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
  freeright :: "freemsg \<Rightarrow> freemsg"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
where
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
  "freeright (NONCE N) = NONCE N"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
| "freeright (MPAIR X Y) = Y"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
| "freeright (CRYPT K X) = freeright X"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
| "freeright (DECRYPT K X) = freeright X"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
text{*This theorem lets us prove that the right function respects the
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
equivalence relation.  It also helps us prove that MPair
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    94
  (the abstract constructor) is injective*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
lemma msgrel_imp_eqv_freeright_aux:
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    96
  shows "freeright U \<sim> freeright U"
702
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
    97
by (induct rule: freeright.induct) (auto)
700
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    98
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
theorem msgrel_imp_eqv_freeright:
702
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
   100
  assumes a: "U \<sim> V" 
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
   101
  shows "freeright U \<sim> freeright V"
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
   102
using a
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
   103
by (induct) (auto intro: msgrel_imp_eqv_freeright_aux)
700
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
subsubsection{*The Discriminator for Constructors*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
text{*A function to distinguish nonces, mpairs and encryptions*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
fun 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
  freediscrim :: "freemsg \<Rightarrow> int"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
where
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
   "freediscrim (NONCE N) = 0"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   112
 | "freediscrim (MPAIR X Y) = 1"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   113
 | "freediscrim (CRYPT K X) = freediscrim X + 2"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   114
 | "freediscrim (DECRYPT K X) = freediscrim X - 2"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   116
text{*This theorem helps us prove @{term "Nonce N \<noteq> MPair X Y"}*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   117
theorem msgrel_imp_eq_freediscrim:
702
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
   118
  assumes a: "U \<sim> V"
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
   119
  shows "freediscrim U = freediscrim V"
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
   120
using a by (induct, auto)
700
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   121
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   122
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   123
subsection{*The Initial Algebra: A Quotiented Message Type*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   124
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
quotient  msg = freemsg / msgrel
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   126
  by (rule equiv_msgrel)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   127
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   128
text{*The abstract message constructors*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
quotient_def
705
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 704
diff changeset
   131
  "Nonce :: nat \<Rightarrow> msg"
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 704
diff changeset
   132
as
700
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
  "NONCE"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   135
quotient_def
705
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 704
diff changeset
   136
  "MPair :: msg \<Rightarrow> msg \<Rightarrow> msg"
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 704
diff changeset
   137
as
700
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
  "MPAIR"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   139
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
quotient_def
705
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 704
diff changeset
   141
  "Crypt :: nat \<Rightarrow> msg \<Rightarrow> msg"
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 704
diff changeset
   142
as
700
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   143
  "CRYPT"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
quotient_def
705
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 704
diff changeset
   146
  "Decrypt :: nat \<Rightarrow> msg \<Rightarrow> msg"
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 704
diff changeset
   147
as
700
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
  "DECRYPT"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
lemma [quot_respect]:
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   151
  shows "(op = ===> op \<sim> ===> op \<sim>) CRYPT CRYPT"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   152
by (auto intro: CRYPT)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   153
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   154
lemma [quot_respect]:
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   155
  shows "(op = ===> op \<sim> ===> op \<sim>) DECRYPT DECRYPT"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   156
by (auto intro: DECRYPT)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   157
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   158
text{*Establishing these two equations is the point of the whole exercise*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   159
theorem CD_eq [simp]: "Crypt K (Decrypt K X) = X"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   160
by (lifting CD)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   161
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   162
theorem DC_eq [simp]: "Decrypt K (Crypt K X) = X"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   163
by (lifting DC)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   164
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   165
subsection{*The Abstract Function to Return the Set of Nonces*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   166
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   167
quotient_def
705
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 704
diff changeset
   168
   "nonces:: msg \<Rightarrow> nat set"
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 704
diff changeset
   169
as
700
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   170
  "freenonces"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   171
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   172
text{*Now prove the four equations for @{term nonces}*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   173
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   174
lemma [quot_respect]:
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   175
  shows "(op \<sim> ===> op =) freenonces freenonces"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   176
by (simp add: msgrel_imp_eq_freenonces)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   177
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   178
lemma [quot_respect]:
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   179
  shows "(op = ===> op \<sim>) NONCE NONCE"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   180
by (simp add: NONCE)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   181
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   182
lemma nonces_Nonce [simp]: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   183
  shows "nonces (Nonce N) = {N}"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   184
by (lifting freenonces.simps(1))
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   185
 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   186
lemma [quot_respect]:
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   187
  shows " (op \<sim> ===> op \<sim> ===> op \<sim>) MPAIR MPAIR"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   188
by (simp add: MPAIR)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   189
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   190
lemma nonces_MPair [simp]: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   191
  shows "nonces (MPair X Y) = nonces X \<union> nonces Y"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   192
by (lifting freenonces.simps(2))
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   193
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   194
lemma nonces_Crypt [simp]: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   195
  shows "nonces (Crypt K X) = nonces X"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   196
by (lifting freenonces.simps(3))
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   197
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   198
lemma nonces_Decrypt [simp]: "nonces (Decrypt K X) = nonces X"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   199
by (lifting freenonces.simps(4))
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   200
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   201
subsection{*The Abstract Function to Return the Left Part*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   202
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   203
quotient_def
705
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 704
diff changeset
   204
  "left:: msg \<Rightarrow> msg"
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 704
diff changeset
   205
as
700
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   206
  "freeleft"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   207
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   208
lemma [quot_respect]:
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   209
  shows "(op \<sim> ===> op \<sim>) freeleft freeleft"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   210
by (simp add: msgrel_imp_eqv_freeleft)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   211
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   212
lemma left_Nonce [simp]: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   213
  shows "left (Nonce N) = Nonce N"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   214
by (lifting freeleft.simps(1))
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   215
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   216
lemma left_MPair [simp]: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   217
  shows "left (MPair X Y) = X"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   218
by (lifting freeleft.simps(2))
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   219
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   220
lemma left_Crypt [simp]: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   221
  shows "left (Crypt K X) = left X"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   222
by (lifting freeleft.simps(3))
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   223
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   224
lemma left_Decrypt [simp]: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   225
  shows "left (Decrypt K X) = left X"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   226
by (lifting freeleft.simps(4))
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   227
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   228
subsection{*The Abstract Function to Return the Right Part*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   229
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   230
quotient_def
705
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 704
diff changeset
   231
  "right:: msg \<Rightarrow> msg"
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 704
diff changeset
   232
as
700
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   233
  "freeright"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   234
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   235
text{*Now prove the four equations for @{term right}*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   236
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   237
lemma [quot_respect]:
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   238
  shows "(op \<sim> ===> op \<sim>) freeright freeright"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   239
by (simp add: msgrel_imp_eqv_freeright)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   240
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   241
lemma right_Nonce [simp]: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   242
  shows "right (Nonce N) = Nonce N"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   243
by (lifting freeright.simps(1))
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   244
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   245
lemma right_MPair [simp]: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   246
  shows "right (MPair X Y) = Y"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   247
by (lifting freeright.simps(2))
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   248
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   249
lemma right_Crypt [simp]: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   250
  shows "right (Crypt K X) = right X"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   251
by (lifting freeright.simps(3))
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   252
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   253
lemma right_Decrypt [simp]: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   254
  shows "right (Decrypt K X) = right X"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   255
by (lifting freeright.simps(4))
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   256
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   257
subsection{*Injectivity Properties of Some Constructors*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   258
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   259
lemma NONCE_imp_eq: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   260
  shows "NONCE m \<sim> NONCE n \<Longrightarrow> m = n"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   261
by (drule msgrel_imp_eq_freenonces, simp)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   262
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   263
text{*Can also be proved using the function @{term nonces}*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   264
lemma Nonce_Nonce_eq [iff]: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   265
  shows "(Nonce m = Nonce n) = (m = n)"
702
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
   266
proof
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
   267
  assume "Nonce m = Nonce n"
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
   268
  then show "m = n" by (lifting NONCE_imp_eq)
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
   269
next
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
   270
  assume "m = n" 
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
   271
  then show "Nonce m = Nonce n" by simp
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
   272
qed
700
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   273
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   274
lemma MPAIR_imp_eqv_left: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   275
  shows "MPAIR X Y \<sim> MPAIR X' Y' \<Longrightarrow> X \<sim> X'"
702
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
   276
by (drule msgrel_imp_eqv_freeleft) (simp)
700
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   277
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   278
lemma MPair_imp_eq_left: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   279
  assumes eq: "MPair X Y = MPair X' Y'" 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   280
  shows "X = X'"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   281
using eq by (lifting MPAIR_imp_eqv_left)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   282
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   283
lemma MPAIR_imp_eqv_right: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   284
  shows "MPAIR X Y \<sim> MPAIR X' Y' \<Longrightarrow> Y \<sim> Y'"
702
b89b578d15e6 slightly tuned
Christian Urban <urbanc@in.tum.de>
parents: 700
diff changeset
   285
by (drule msgrel_imp_eqv_freeright) (simp)
700
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   286
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   287
lemma MPair_imp_eq_right: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   288
  shows "MPair X Y = MPair X' Y' \<Longrightarrow> Y = Y'"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   289
by (lifting  MPAIR_imp_eqv_right)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   290
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   291
theorem MPair_MPair_eq [iff]: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   292
  shows "(MPair X Y = MPair X' Y') = (X=X' & Y=Y')" 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   293
by (blast dest: MPair_imp_eq_left MPair_imp_eq_right)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   294
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   295
lemma NONCE_neqv_MPAIR: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   296
  shows "\<not>(NONCE m \<sim> MPAIR X Y)"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   297
by (auto dest: msgrel_imp_eq_freediscrim)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   298
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   299
theorem Nonce_neq_MPair [iff]: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   300
  shows "Nonce N \<noteq> MPair X Y"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   301
by (lifting NONCE_neqv_MPAIR)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   302
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   303
text{*Example suggested by a referee*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   304
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   305
lemma CRYPT_NONCE_neq_NONCE:
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   306
  shows "\<not>(CRYPT K (NONCE M) \<sim> NONCE N)"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   307
by (auto dest: msgrel_imp_eq_freediscrim)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   308
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   309
theorem Crypt_Nonce_neq_Nonce: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   310
  shows "Crypt K (Nonce M) \<noteq> Nonce N"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   311
by (lifting CRYPT_NONCE_neq_NONCE)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   312
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   313
text{*...and many similar results*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   314
lemma CRYPT2_NONCE_neq_NONCE: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   315
  shows "\<not>(CRYPT K (CRYPT K' (NONCE M)) \<sim> NONCE N)"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   316
by (auto dest: msgrel_imp_eq_freediscrim)  
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   317
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   318
theorem Crypt2_Nonce_neq_Nonce: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   319
  shows "Crypt K (Crypt K' (Nonce M)) \<noteq> Nonce N"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   320
by (lifting CRYPT2_NONCE_neq_NONCE) 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   321
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   322
theorem Crypt_Crypt_eq [iff]: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   323
  shows "(Crypt K X = Crypt K X') = (X=X')" 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   324
proof
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   325
  assume "Crypt K X = Crypt K X'"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   326
  hence "Decrypt K (Crypt K X) = Decrypt K (Crypt K X')" by simp
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   327
  thus "X = X'" by simp
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   328
next
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   329
  assume "X = X'"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   330
  thus "Crypt K X = Crypt K X'" by simp
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   331
qed
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   332
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   333
theorem Decrypt_Decrypt_eq [iff]: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   334
  shows "(Decrypt K X = Decrypt K X') = (X=X')" 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   335
proof
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   336
  assume "Decrypt K X = Decrypt K X'"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   337
  hence "Crypt K (Decrypt K X) = Crypt K (Decrypt K X')" by simp
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   338
  thus "X = X'" by simp
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   339
next
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   340
  assume "X = X'"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   341
  thus "Decrypt K X = Decrypt K X'" by simp
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   342
qed
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   343
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   344
lemma msg_induct_aux:
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   345
  shows "\<lbrakk>\<And>N. P (Nonce N);
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   346
          \<And>X Y. \<lbrakk>P X; P Y\<rbrakk> \<Longrightarrow> P (MPair X Y);
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   347
          \<And>K X. P X \<Longrightarrow> P (Crypt K X);
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   348
          \<And>K X. P X \<Longrightarrow> P (Decrypt K X)\<rbrakk> \<Longrightarrow> P msg"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   349
by (lifting freemsg.induct)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   350
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   351
lemma msg_induct [case_names Nonce MPair Crypt Decrypt, cases type: msg]:
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   352
  assumes N: "\<And>N. P (Nonce N)"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   353
      and M: "\<And>X Y. \<lbrakk>P X; P Y\<rbrakk> \<Longrightarrow> P (MPair X Y)"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   354
      and C: "\<And>K X. P X \<Longrightarrow> P (Crypt K X)"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   355
      and D: "\<And>K X. P X \<Longrightarrow> P (Decrypt K X)"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   356
  shows "P msg"
704
0fd4abb5fade changed error message
Christian Urban <urbanc@in.tum.de>
parents: 702
diff changeset
   357
using N M C D by (rule msg_induct_aux)
700
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   358
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   359
subsection{*The Abstract Discriminator*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   360
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   361
text{*However, as @{text Crypt_Nonce_neq_Nonce} above illustrates, we don't
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   362
need this function in order to prove discrimination theorems.*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   363
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   364
quotient_def
705
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 704
diff changeset
   365
  "discrim:: msg \<Rightarrow> int"
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 704
diff changeset
   366
as
700
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   367
  "freediscrim"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   368
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   369
text{*Now prove the four equations for @{term discrim}*}
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   370
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   371
lemma [quot_respect]:
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   372
  shows "(op \<sim> ===> op =) freediscrim freediscrim"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   373
by (auto simp add: msgrel_imp_eq_freediscrim)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   374
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   375
lemma discrim_Nonce [simp]: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   376
  shows "discrim (Nonce N) = 0"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   377
by (lifting freediscrim.simps(1))
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   378
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   379
lemma discrim_MPair [simp]: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   380
  shows "discrim (MPair X Y) = 1"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   381
by (lifting freediscrim.simps(2))
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   382
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   383
lemma discrim_Crypt [simp]: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   384
  shows "discrim (Crypt K X) = discrim X + 2"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   385
by (lifting freediscrim.simps(3))
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   386
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   387
lemma discrim_Decrypt [simp]: 
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   388
  shows "discrim (Decrypt K X) = discrim X - 2"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   389
by (lifting freediscrim.simps(4))
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   390
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   391
end
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   392