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