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