diff --git a/CHANGES b/CHANGES
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+* 0.6.0.0
+    - ported to Isabelle-2013 by Andreas Lochbihler
+    - removed buggy isabelle timout support
+    - tested compilation on GHC 7.4.2
+
 * 0.5.0.0
     - implemented proof generation for injective agreement
     - fixed bug in unification of inverse-key constructors
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -1,10 +1,9 @@
 README: The scyther-proof security protocol verification tool
 =============================================================
 
-Author: Simon Meier <simon.meier@inf.ethz.ch>
-
-Creation Date: 13/05/2011  --  Last Updated:  28/06/2012
-
+Authors: Simon Meier <iridcode@gmail.com>
+Creation Date: 2011-05-13
+Last Updated:  2013-02-27 by Andreas Lochbihler <andreas.lochbihler@inf.ethz.ch>
 
 1. Introduction
 ===============
@@ -56,42 +55,48 @@
 2.2 Installing the Isabelle/HOL theories
 ----------------------------------------
 
-Download and install full Isabelle2009-1 according to the installation
+Download and install full Isabelle2013 according to the installation
 instructions at
 
-    http://isabelle.in.tum.de/website-Isabelle2009-1/download_x86-linux.html
+    http://isabelle.in.tum.de/website-Isabelle2013/download_x86-linux.html
 
 The first time you call `scyther-proof` with the `--isabelle` flag it will
 build the logic image of the Isabelle/HOL theories formalizing the security
 protocol verification theory underlying `scyther-proof`.
 
-For enabling interactive processing of theory files based using our
-extensions to Isabelle's ISAR proof language use one of the following two
-variants.
+If you wish to use ProofGeneral to interactively process the theory files
+using our extensions to Isabelle's ISAR proof language, use one of the
+following two variants. This is needed in order to make the new ISAR keywords
+`role`, `protocol`, `sources`, and `prefix_close` available in the Emacs
+frontend. If you are using the Isabelle/jEdit Prover IDE, the keywords are
+automatically registered.
 
+
 Variant a: Brute Force
 ----------------------
 
-Overwrite the standard Emacs keywords file
+Copy the Emacs keywords file provided with the ESPL distribution at
 
-    $ISABELLE_HOME/etc/isar-keywords.el
+    $SCYTHER_PROOF_HOME/data/isabelle/src/isar-keywords.el
 
-with the Emacs keywords file provided with the ESPL distribution.
+to your local Isabelle configuration in
 
-    $SCYTHER_PROOF_HOME/isabelle/src/isar-keywords.el
+    $ISABELLE_HOME_USER/etc
 
-This is needed in order to make the new ISAR keywords `role`,
-`protocol`, `sources`, and `prefix_close` available in the Emacs
-frontend.
+This will replace any custom keyword file that you have already
+installed in that way. You can find out about $ISABELLE_HOME_USER
+by running
 
+    isabelle getenv ISABELLE_HOME_USER
 
+
 Variant b: Elegance
 -------------------
 
 A more elegant way is to copy the keywords file provided with our
 distribution to
 
-    $ISABELLE_HOME/etc/isar-keywords-ESPL.el
+    $ISABELLE_HOME_USER/etc/isar-keywords-ESPL.el
 
 and start Isabelle using the -k switch as follows.
 
@@ -104,7 +109,7 @@
 
 
 3.1 scyther-proof
-------------
+-----------------
 
 
   Usage Example
@@ -120,15 +125,13 @@
   all specified security properties together with the proof with the fewest
   number of chain rule applications to stdout.
 
-  In order to generate an Isabelle proof script two additional options need to
-  be added
+  To generate an Isabelle proof script, two additional options are required.
 
     scyther-proof $EXAMPLE_DIR/classic/NS_Public.spthy --shortest --output=nsl_cert.thy --ASCII
 
   The first one specifies the output file and the second one instructs
   scyther-proof to use Isabelle's ASCII notation as the output format.
 
-
   To build the source code documentation you can use the call
 
     cabal configure; cabal haddock
@@ -141,25 +144,40 @@
 3.2 The Isabelle/HOL theories
 -----------------------------
 
+   Note that in many case the easiest way to start with constructing
+   machine-checked proofs interactively is to use a proof script generated by
+   scyther-proof.
+
+   Using ProofGeneral
+   ------------------
+
    In the directory output by scyther-proof, load the Tutorial on interactive
    proof construction using the following commands
 
         cd <theory-dir-output-by-scytherproof>/src
         isabelle emacs Tutorial.thy
 
-    or if you've chosen the elegant variant
+    or if you've chosen the elegant variant for the keywords file
 
         isabelle emacs -k ESPL Tutorial.thy
 
-   Note that in many case the easiest way to start with constructing
-   machine-checked proofs interactively is to use a proof script generated by
-   scyther-proof.
 
+   Using the Isabelle/jEdit Prover IDE
+   -----------------------------------
 
+   In the directory output by scyther-proof, load the Tutorial on interactive
+   proof construction using the following commands
+
+        cd <theory-dir-output-by-scytherproof>/src
+        isabelle jedit -d $SCYTHER_PROOF_HOME/data/isabelle -l ESPL Tutorial.thy
+
+   where $SCYTHER_PROOF_HOME expands to the home directory of scyther-proof.
+
+
 ***
 
 `Happy Proving :)`
 
-In case of questions do not hesistate to contact me at
+In case of questions do not hesistate to contact Simon Meier at
 iridcode@gmail.com.
 
diff --git a/data/examples/iso9798/isabelle-parallel-proofs/isoiec-9798-2-bdkey_cert_auto.thy b/data/examples/iso9798/isabelle-parallel-proofs/isoiec-9798-2-bdkey_cert_auto.thy
--- a/data/examples/iso9798/isabelle-parallel-proofs/isoiec-9798-2-bdkey_cert_auto.thy
+++ b/data/examples/iso9798/isabelle-parallel-proofs/isoiec-9798-2-bdkey_cert_auto.thy
@@ -1,3214 +1,3514 @@
 theory "isoiec-9798-2-bdkey_cert_auto"
 imports
-  "../ESPLogic"
-begin
-
-role isoiec_9798_2_1_bdkey_A
-where "isoiec_9798_2_1_bdkey_A =
-  [ Send ''leak_A'' ( sN ''TNA'' )
-  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
-  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
-                  PEnc <| sC ''isoiec_9798_2_1_enc_1'', sN ''TNA'', sAV ''B'',
-                          sMV ''Text1''
-                       |>
-                       ( sKbd (AVar ''A'') (AVar ''B'') )
-               |>
-  ]"
-
-role isoiec_9798_2_1_bdkey_B
-where "isoiec_9798_2_1_bdkey_B =
-  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
-                  PEnc <| sC ''isoiec_9798_2_1_enc_1'', sMV ''TNA'', sAV ''B'',
-                          sMV ''Text1''
-                       |>
-                       ( sKbd (MVar ''A'') (AVar ''B'') )
-               |>
-  ]"
-
-role isoiec_9798_2_2_bdkey_A
-where "isoiec_9798_2_2_bdkey_A =
-  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text1'' |>
-  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
-  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
-                  PEnc <| sC ''isoiec_9798_2_2_enc_2'', sMV ''RB'', sMV ''B'',
-                          sMV ''Text2''
-                       |>
-                       ( sKbd (MVar ''B'') (AVar ''A'') )
-               |>
-  ]"
-
-role isoiec_9798_2_2_bdkey_B
-where "isoiec_9798_2_2_bdkey_B =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''RB'', sMV ''Text1'' |>
-  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
-                  PEnc <| sC ''isoiec_9798_2_2_enc_2'', sN ''RB'', sAV ''B'', sMV ''Text2''
-                       |>
-                       ( sKbd (AVar ''B'') (AVar ''A'') )
-               |>
-  ]"
-
-role isoiec_9798_2_3_bdkey_A
-where "isoiec_9798_2_3_bdkey_A =
-  [ Send ''leak_A'' ( sN ''TNA'' )
-  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
-  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
-                  PEnc <| sC ''isoiec_9798_2_3_enc_1'', sN ''TNA'', sAV ''B'',
-                          sMV ''Text1''
-                       |>
-                       ( sKbd (AVar ''A'') (AVar ''B'') )
-               |>
-  , Recv ''2'' <| sAV ''B'', sAV ''A'', sMV ''Text4'',
-                  PEnc <| sC ''isoiec_9798_2_3_enc_2'', sMV ''TNB'', sAV ''A'',
-                          sMV ''Text3''
-                       |>
-                       ( sKbd (AVar ''B'') (AVar ''A'') )
-               |>
-  ]"
-
-role isoiec_9798_2_3_bdkey_B
-where "isoiec_9798_2_3_bdkey_B =
-  [ Send ''leak_B'' ( sN ''TNB'' )
-  , Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
-                  PEnc <| sC ''isoiec_9798_2_3_enc_1'', sMV ''TNA'', sAV ''B'',
-                          sMV ''Text1''
-                       |>
-                       ( sKbd (MVar ''A'') (AVar ''B'') )
-               |>
-  , Recv ''text_2'' <| sMV ''Text3'', sMV ''Text4'' |>
-  , Send ''2'' <| sAV ''B'', sMV ''A'', sMV ''Text4'',
-                  PEnc <| sC ''isoiec_9798_2_3_enc_2'', sN ''TNB'', sMV ''A'',
-                          sMV ''Text3''
-                       |>
-                       ( sKbd (AVar ''B'') (MVar ''A'') )
-               |>
-  ]"
-
-role isoiec_9798_2_4_bdkey_A
-where "isoiec_9798_2_4_bdkey_A =
-  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text1'' |>
-  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
-  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
-                  PEnc <| sC ''isoiec_9798_2_4_enc_1'', sN ''RA'', sMV ''RB'', sMV ''B'',
-                          sMV ''Text2''
-                       |>
-                       ( sKbd (AVar ''A'') (MVar ''B'') )
-               |>
-  , Recv ''3'' <| sMV ''B'', sAV ''A'', sMV ''Text5'',
-                  PEnc <| sC ''isoiec_9798_2_4_enc_2'', sMV ''RB'', sN ''RA'',
-                          sMV ''Text4''
-                       |>
-                       ( sKbd (AVar ''A'') (MVar ''B'') )
-               |>
-  ]"
-
-role isoiec_9798_2_4_bdkey_B
-where "isoiec_9798_2_4_bdkey_B =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''RB'', sMV ''Text1'' |>
-  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
-                  PEnc <| sC ''isoiec_9798_2_4_enc_1'', sMV ''RA'', sN ''RB'', sAV ''B'',
-                          sMV ''Text2''
-                       |>
-                       ( sKbd (AVar ''A'') (AVar ''B'') )
-               |>
-  , Recv ''text_3'' <| sMV ''Text4'', sMV ''Text5'' |>
-  , Send ''3'' <| sAV ''B'', sAV ''A'', sMV ''Text5'',
-                  PEnc <| sC ''isoiec_9798_2_4_enc_2'', sN ''RB'', sMV ''RA'',
-                          sMV ''Text4''
-                       |>
-                       ( sKbd (AVar ''A'') (AVar ''B'') )
-               |>
-  ]"
-
-role isoiec_9798_2_5_bdkey_A
-where "isoiec_9798_2_5_bdkey_A =
-  [ Send ''leak_A'' <| sN ''TVPa'', sN ''TNa'' |>
-  , Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''A'', sAV ''P'', sN ''TVPa'', sAV ''B'',
-                  sMV ''Text1''
-               |>
-  , Recv ''2'' <| sAV ''P'', sAV ''A'', sMV ''Text4'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_2_1'', sN ''TVPa'', sMV ''Kab'',
-                          sAV ''A'', sAV ''B'', sMV ''Text3''
-                       |>
-                       ( sKbd (AVar ''A'') (AVar ''P'') ),
-                  sMV ''TokenPA_for_B''
-               |>
-  , Recv ''text_3'' <| sMV ''Text5'', sMV ''Text6'' |>
-  , Send ''3'' <| sAV ''A'', sAV ''B'', sMV ''Text6'', sAV ''P'',
-                  sMV ''TokenPA_for_B'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_3'', sN ''TNa'', sAV ''B'',
-                          sMV ''Text5''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''4'' <| sAV ''B'', sAV ''A'', sMV ''Text8'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_4'', sMV ''TNb'', sAV ''A'',
-                          sMV ''Text7''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_5_bdkey_B
-where "isoiec_9798_2_5_bdkey_B =
-  [ Send ''leak_B'' ( sN ''TNb'' )
-  , Recv ''3'' <| sMV ''A'', sAV ''B'', sMV ''Text6'', sMV ''P'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_2_2'', sMV ''TNp'', sMV ''Kab'',
-                          sMV ''A'', sAV ''B'', sMV ''Text2''
-                       |>
-                       ( sKbd (AVar ''B'') (MVar ''P'') ),
-                  PEnc <| sC ''isoiec_9798_2_5_enc_3'', sMV ''TNa'', sAV ''B'',
-                          sMV ''Text5''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''text_4'' <| sMV ''Text7'', sMV ''Text8'' |>
-  , Send ''4'' <| sAV ''B'', sMV ''A'', sMV ''Text8'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_4'', sN ''TNb'', sMV ''A'',
-                          sMV ''Text7''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_5_bdkey_P
-where "isoiec_9798_2_5_bdkey_P =
-  [ Send ''leak_P'' ( sN ''TNp'' )
-  , Recv ''1'' <| sMV ''A'', sAV ''P'', sMV ''TVPa'', sMV ''B'',
-                  sMV ''Text1''
-               |>
-  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'', sMV ''Text4'' |>
-  , Send ''2'' <| sAV ''P'', sMV ''A'', sMV ''Text4'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_2_1'', sMV ''TVPa'', sN ''Kab'',
-                          sMV ''A'', sMV ''B'', sMV ''Text3''
-                       |>
-                       ( sKbd (MVar ''A'') (AVar ''P'') ),
-                  PEnc <| sC ''isoiec_9798_2_5_enc_2_2'', sN ''TNp'', sN ''Kab'',
-                          sMV ''A'', sMV ''B'', sMV ''Text2''
-                       |>
-                       ( sKbd (MVar ''B'') (AVar ''P'') )
-               |>
-  ]"
-
-role isoiec_9798_2_6_bdkey_A
-where "isoiec_9798_2_6_bdkey_A =
-  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
-  , Recv ''text_2'' ( sMV ''Text2'' )
-  , Send ''2'' <| sAV ''A'', sAV ''P'', sN ''Ra'', sMV ''Rb'', sMV ''B'',
-                  sMV ''Text2''
-               |>
-  , Recv ''3'' <| sAV ''P'', sAV ''A'', sMV ''Text5'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_3_1'', sN ''Ra'', sMV ''Kab'',
-                          sAV ''A'', sMV ''B'', sMV ''Text4''
-                       |>
-                       ( sKbd (AVar ''A'') (AVar ''P'') ),
-                  sMV ''TokenPA_for_B''
-               |>
-  , Recv ''text_4'' <| sMV ''Text6'', sMV ''Text7'' |>
-  , Send ''4'' <| sAV ''A'', sMV ''B'', sMV ''Text7'', sAV ''P'',
-                  sMV ''TokenPA_for_B'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_4'', sN ''Rpa'', sMV ''Rb'',
-                          sMV ''Text6''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''5'' <| sMV ''B'', sAV ''A'', sMV ''Text9'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_5'', sMV ''Rb'', sN ''Rpa'',
-                          sMV ''Text8''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_6_bdkey_B
-where "isoiec_9798_2_6_bdkey_B =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
-  , Recv ''4'' <| sAV ''A'', sAV ''B'', sMV ''Text7'', sMV ''P'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_3_2'', sN ''Rb'', sMV ''Kab'',
-                          sAV ''A'', sAV ''B'', sMV ''Text3''
-                       |>
-                       ( sKbd (AVar ''B'') (MVar ''P'') ),
-                  PEnc <| sC ''isoiec_9798_2_6_enc_4'', sMV ''Rpa'', sN ''Rb'',
-                          sMV ''Text6''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
-  , Send ''5'' <| sAV ''B'', sAV ''A'', sMV ''Text9'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_5'', sN ''Rb'', sMV ''Rpa'',
-                          sMV ''Text8''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_6_bdkey_P
-where "isoiec_9798_2_6_bdkey_P =
-  [ Recv ''2'' <| sMV ''A'', sAV ''P'', sMV ''Ra'', sMV ''Rb'', sMV ''B'',
-                  sMV ''Text2''
-               |>
-  , Recv ''text_3'' <| sMV ''Text3'', sMV ''Text4'', sMV ''Text5'' |>
-  , Send ''3'' <| sAV ''P'', sMV ''A'', sMV ''Text5'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_3_1'', sMV ''Ra'', sN ''Kab'',
-                          sMV ''A'', sMV ''B'', sMV ''Text4''
-                       |>
-                       ( sKbd (MVar ''A'') (AVar ''P'') ),
-                  PEnc <| sC ''isoiec_9798_2_6_enc_3_2'', sMV ''Rb'', sN ''Kab'',
-                          sMV ''A'', sMV ''B'', sMV ''Text3''
-                       |>
-                       ( sKbd (MVar ''B'') (AVar ''P'') )
-               |>
-  ]"
-
-role isoiec_9798_2_5_special_TTP_bdkey_A
-where "isoiec_9798_2_5_special_TTP_bdkey_A =
-  [ Send ''leak_A'' <| sN ''TVPa'', sN ''TNa'' |>
-  , Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''A'', sAV ''P'', sN ''TVPa'', sAV ''B'',
-                  sMV ''Text1''
-               |>
-  , Recv ''2'' <| sAV ''P'', sAV ''A'', sMV ''Text4'',
-                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_2_1'', sN ''TVPa'',
-                          sMV ''Kab'', sAV ''B'', sMV ''Text3''
-                       |>
-                       ( sKbd (AVar ''A'') (AVar ''P'') ),
-                  sMV ''TokenPA_for_B''
-               |>
-  , Recv ''text_3'' <| sMV ''Text5'', sMV ''Text6'' |>
-  , Send ''3'' <| sAV ''A'', sAV ''B'', sMV ''Text6'', sAV ''P'',
-                  sMV ''TokenPA_for_B'',
-                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_3'', sN ''TNa'', sAV ''B'',
-                          sMV ''Text5''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''4'' <| sAV ''B'', sAV ''A'', sMV ''Text8'',
-                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_4'', sMV ''TNb'', sAV ''A'',
-                          sMV ''Text7''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_5_special_TTP_bdkey_B
-where "isoiec_9798_2_5_special_TTP_bdkey_B =
-  [ Send ''leak_B'' ( sN ''TNb'' )
-  , Recv ''3'' <| sMV ''A'', sAV ''B'', sMV ''Text6'', sMV ''P'',
-                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_2_2'', sMV ''TNp'',
-                          sMV ''Kab'', sMV ''A'', sMV ''Text2''
-                       |>
-                       ( sKbd (AVar ''B'') (MVar ''P'') ),
-                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_3'', sMV ''TNa'', sAV ''B'',
-                          sMV ''Text5''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''text_4'' <| sMV ''Text7'', sMV ''Text8'' |>
-  , Send ''4'' <| sAV ''B'', sMV ''A'', sMV ''Text8'',
-                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_4'', sN ''TNb'', sMV ''A'',
-                          sMV ''Text7''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_5_special_TTP_bdkey_P
-where "isoiec_9798_2_5_special_TTP_bdkey_P =
-  [ Send ''leak_P'' ( sN ''TNp'' )
-  , Recv ''1'' <| sMV ''A'', sAV ''P'', sMV ''TVPa'', sMV ''B'',
-                  sMV ''Text1''
-               |>
-  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'', sMV ''Text4'' |>
-  , Send ''2'' <| sAV ''P'', sMV ''A'', sMV ''Text4'',
-                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_2_1'', sMV ''TVPa'',
-                          sN ''Kab'', sMV ''B'', sMV ''Text3''
-                       |>
-                       ( sKbd (MVar ''A'') (AVar ''P'') ),
-                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_2_2'', sN ''TNp'',
-                          sN ''Kab'', sMV ''A'', sMV ''Text2''
-                       |>
-                       ( sKbd (MVar ''B'') (AVar ''P'') )
-               |>
-  ]"
-
-role isoiec_9798_2_6_special_TTP_bdkey_A
-where "isoiec_9798_2_6_special_TTP_bdkey_A =
-  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
-  , Recv ''text_2'' ( sMV ''Text2'' )
-  , Send ''2'' <| sAV ''A'', sAV ''P'', sN ''Ra'', sMV ''Rb'', sMV ''B'',
-                  sMV ''Text2''
-               |>
-  , Recv ''3'' <| sAV ''P'', sAV ''A'', sMV ''Text5'',
-                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_3_1'', sN ''Ra'',
-                          sMV ''Kab'', sMV ''B'', sMV ''Text4''
-                       |>
-                       ( sKbd (AVar ''A'') (AVar ''P'') ),
-                  sMV ''TokenPA_for_B''
-               |>
-  , Recv ''text_4'' <| sMV ''Text6'', sMV ''Text7'' |>
-  , Send ''4'' <| sAV ''A'', sMV ''B'', sMV ''Text7'', sAV ''P'',
-                  sMV ''TokenPA_for_B'',
-                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_4'', sN ''Rpa'', sMV ''Rb'',
-                          sMV ''Text6''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''5'' <| sMV ''B'', sAV ''A'', sMV ''Text9'',
-                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_5'', sMV ''Rb'', sN ''Rpa'',
-                          sMV ''Text8''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_6_special_TTP_bdkey_B
-where "isoiec_9798_2_6_special_TTP_bdkey_B =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
-  , Recv ''4'' <| sAV ''A'', sAV ''B'', sMV ''Text7'', sMV ''P'',
-                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_3_2'', sN ''Rb'',
-                          sMV ''Kab'', sAV ''A'', sMV ''Text3''
-                       |>
-                       ( sKbd (AVar ''B'') (MVar ''P'') ),
-                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_4'', sMV ''Rpa'', sN ''Rb'',
-                          sMV ''Text6''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
-  , Send ''5'' <| sAV ''B'', sAV ''A'', sMV ''Text9'',
-                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_5'', sN ''Rb'', sMV ''Rpa'',
-                          sMV ''Text8''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_6_special_TTP_bdkey_P
-where "isoiec_9798_2_6_special_TTP_bdkey_P =
-  [ Recv ''2'' <| sMV ''A'', sAV ''P'', sMV ''Ra'', sMV ''Rb'', sMV ''B'',
-                  sMV ''Text2''
-               |>
-  , Recv ''text_3'' <| sMV ''Text3'', sMV ''Text4'', sMV ''Text5'' |>
-  , Send ''3'' <| sAV ''P'', sMV ''A'', sMV ''Text5'',
-                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_3_1'', sMV ''Ra'',
-                          sN ''Kab'', sMV ''B'', sMV ''Text4''
-                       |>
-                       ( sKbd (MVar ''A'') (AVar ''P'') ),
-                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_3_2'', sMV ''Rb'',
-                          sN ''Kab'', sMV ''A'', sMV ''Text3''
-                       |>
-                       ( sKbd (MVar ''B'') (AVar ''P'') )
-               |>
-  ]"
-
-protocol isoiec_9798_2_bdkey
-where "isoiec_9798_2_bdkey =
-{ isoiec_9798_2_1_bdkey_A, isoiec_9798_2_1_bdkey_B,
-  isoiec_9798_2_2_bdkey_A, isoiec_9798_2_2_bdkey_B,
-  isoiec_9798_2_3_bdkey_A, isoiec_9798_2_3_bdkey_B,
-  isoiec_9798_2_4_bdkey_A, isoiec_9798_2_4_bdkey_B,
-  isoiec_9798_2_5_bdkey_A, isoiec_9798_2_5_bdkey_B,
-  isoiec_9798_2_5_bdkey_P, isoiec_9798_2_6_bdkey_A,
-  isoiec_9798_2_6_bdkey_B, isoiec_9798_2_6_bdkey_P,
-  isoiec_9798_2_5_special_TTP_bdkey_A, isoiec_9798_2_5_special_TTP_bdkey_B,
-  isoiec_9798_2_5_special_TTP_bdkey_P, isoiec_9798_2_6_special_TTP_bdkey_A,
-  isoiec_9798_2_6_special_TTP_bdkey_B, isoiec_9798_2_6_special_TTP_bdkey_P
-}"
-
-locale restricted_isoiec_9798_2_bdkey_state = isoiec_9798_2_bdkey_state +
-  assumes isoiec_9798_2_5_special_TTP_bdkey_different_actors_A_P:
-    "!! tid0 tid1.
-       [| roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_A;
-         roleMap r tid1 = Some isoiec_9798_2_5_special_TTP_bdkey_P;
-         s(AV ''P'' tid1) = s(AV ''A'' tid0)
-       |] ==> False"
-  assumes isoiec_9798_2_6_special_TTP_bdkey_different_actors_A_P:
-    "!! tid0 tid1.
-       [| roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_A;
-         roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_P;
-         s(AV ''P'' tid1) = s(AV ''A'' tid0)
-       |] ==> False"
-  assumes isoiec_9798_2_6_special_TTP_bdkey_different_actors_B_P:
-    "!! tid0 tid1.
-       [| roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_B;
-         roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_P;
-         s(AV ''P'' tid1) = s(AV ''B'' tid0)
-       |] ==> False"
-
-type_invariant isoiec_9798_2_bdkey_composed_typing for isoiec_9798_2_bdkey
-where "isoiec_9798_2_bdkey_composed_typing = mk_typing
-  [ ((isoiec_9798_2_1_bdkey_B, ''A''), (KnownT isoiec_9798_2_1_bdkey_B_1))
-  , ((isoiec_9798_2_3_bdkey_B, ''A''), (KnownT isoiec_9798_2_3_bdkey_B_1))
-  , ((isoiec_9798_2_5_bdkey_B, ''A''), (KnownT isoiec_9798_2_5_bdkey_B_3))
-  , ((isoiec_9798_2_5_bdkey_P, ''A''), (KnownT isoiec_9798_2_5_bdkey_P_1))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''A''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''A''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_1))
-  , ((isoiec_9798_2_6_bdkey_P, ''A''), (KnownT isoiec_9798_2_6_bdkey_P_2))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''A''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_2))
-  , ((isoiec_9798_2_2_bdkey_A, ''B''), (KnownT isoiec_9798_2_2_bdkey_A_1))
-  , ((isoiec_9798_2_4_bdkey_A, ''B''), (KnownT isoiec_9798_2_4_bdkey_A_1))
-  , ((isoiec_9798_2_5_bdkey_P, ''B''), (KnownT isoiec_9798_2_5_bdkey_P_1))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''B''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_1))
-  , ((isoiec_9798_2_6_bdkey_A, ''B''), (KnownT isoiec_9798_2_6_bdkey_A_1))
-  , ((isoiec_9798_2_6_bdkey_P, ''B''), (KnownT isoiec_9798_2_6_bdkey_P_2))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''B''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_1))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''B''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_2))
-  , ((isoiec_9798_2_5_bdkey_A, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_5_bdkey_A_2) (NonceT isoiec_9798_2_5_bdkey_P ''Kab'')))
-  , ((isoiec_9798_2_5_bdkey_B, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_5_bdkey_B_3) (NonceT isoiec_9798_2_5_bdkey_P ''Kab'')))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_2) (NonceT isoiec_9798_2_5_special_TTP_bdkey_P ''Kab'')))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3) (NonceT isoiec_9798_2_5_special_TTP_bdkey_P ''Kab'')))
-  , ((isoiec_9798_2_6_bdkey_A, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_6_bdkey_A_3) (NonceT isoiec_9798_2_6_bdkey_P ''Kab'')))
-  , ((isoiec_9798_2_6_bdkey_B, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_6_bdkey_B_4) (NonceT isoiec_9798_2_6_bdkey_P ''Kab'')))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_3) (NonceT isoiec_9798_2_6_special_TTP_bdkey_P ''Kab'')))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4) (NonceT isoiec_9798_2_6_special_TTP_bdkey_P ''Kab'')))
-  , ((isoiec_9798_2_5_bdkey_B, ''P''), (KnownT isoiec_9798_2_5_bdkey_B_3))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''P''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3))
-  , ((isoiec_9798_2_6_bdkey_B, ''P''), (KnownT isoiec_9798_2_6_bdkey_B_4))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''P''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4))
-  , ((isoiec_9798_2_4_bdkey_B, ''RA''),
-     (SumT (KnownT isoiec_9798_2_4_bdkey_B_2) (NonceT isoiec_9798_2_4_bdkey_A ''RA'')))
-  , ((isoiec_9798_2_2_bdkey_A, ''RB''), (KnownT isoiec_9798_2_2_bdkey_A_1))
-  , ((isoiec_9798_2_4_bdkey_A, ''RB''), (KnownT isoiec_9798_2_4_bdkey_A_1))
-  , ((isoiec_9798_2_6_bdkey_P, ''Ra''), (KnownT isoiec_9798_2_6_bdkey_P_2))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Ra''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_2))
-  , ((isoiec_9798_2_6_bdkey_A, ''Rb''), (KnownT isoiec_9798_2_6_bdkey_A_1))
-  , ((isoiec_9798_2_6_bdkey_P, ''Rb''), (KnownT isoiec_9798_2_6_bdkey_P_2))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Rb''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_1))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Rb''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_2))
-  , ((isoiec_9798_2_6_bdkey_B, ''Rpa''),
-     (SumT (KnownT isoiec_9798_2_6_bdkey_B_4) (NonceT isoiec_9798_2_6_bdkey_A ''Rpa'')))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Rpa''),
-     (SumT (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4) (NonceT isoiec_9798_2_6_special_TTP_bdkey_A ''Rpa'')))
-  , ((isoiec_9798_2_1_bdkey_B, ''TNA''),
-     (SumT (KnownT isoiec_9798_2_1_bdkey_B_1) (NonceT isoiec_9798_2_1_bdkey_A ''TNA'')))
-  , ((isoiec_9798_2_3_bdkey_B, ''TNA''),
-     (SumT (KnownT isoiec_9798_2_3_bdkey_B_1) (NonceT isoiec_9798_2_3_bdkey_A ''TNA'')))
-  , ((isoiec_9798_2_3_bdkey_A, ''TNB''),
-     (SumT (KnownT isoiec_9798_2_3_bdkey_A_2) (NonceT isoiec_9798_2_3_bdkey_B ''TNB'')))
-  , ((isoiec_9798_2_5_bdkey_B, ''TNa''),
-     (SumT (KnownT isoiec_9798_2_5_bdkey_B_3) (NonceT isoiec_9798_2_5_bdkey_A ''TNa'')))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''TNa''),
-     (SumT (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3) (NonceT isoiec_9798_2_5_special_TTP_bdkey_A ''TNa'')))
-  , ((isoiec_9798_2_5_bdkey_A, ''TNb''),
-     (SumT (KnownT isoiec_9798_2_5_bdkey_A_4) (NonceT isoiec_9798_2_5_bdkey_B ''TNb'')))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''TNb''),
-     (SumT (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_4) (NonceT isoiec_9798_2_5_special_TTP_bdkey_B ''TNb'')))
-  , ((isoiec_9798_2_5_bdkey_B, ''TNp''),
-     (SumT (KnownT isoiec_9798_2_5_bdkey_B_3) (NonceT isoiec_9798_2_5_bdkey_P ''TNp'')))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''TNp''),
-     (SumT (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3) (NonceT isoiec_9798_2_5_special_TTP_bdkey_P ''TNp'')))
-  , ((isoiec_9798_2_5_bdkey_P, ''TVPa''),
-     (KnownT isoiec_9798_2_5_bdkey_P_1))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''TVPa''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_1))
-  , ((isoiec_9798_2_1_bdkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_1_bdkey_A_text_1))
-  , ((isoiec_9798_2_1_bdkey_B, ''Text1''),
-     (KnownT isoiec_9798_2_1_bdkey_B_1))
-  , ((isoiec_9798_2_2_bdkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_2_bdkey_A_1))
-  , ((isoiec_9798_2_2_bdkey_B, ''Text1''),
-     (KnownT isoiec_9798_2_2_bdkey_B_text_1))
-  , ((isoiec_9798_2_3_bdkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_3_bdkey_A_text_1))
-  , ((isoiec_9798_2_3_bdkey_B, ''Text1''),
-     (KnownT isoiec_9798_2_3_bdkey_B_1))
-  , ((isoiec_9798_2_4_bdkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_4_bdkey_A_1))
-  , ((isoiec_9798_2_4_bdkey_B, ''Text1''),
-     (KnownT isoiec_9798_2_4_bdkey_B_text_1))
-  , ((isoiec_9798_2_5_bdkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_5_bdkey_A_text_1))
-  , ((isoiec_9798_2_5_bdkey_P, ''Text1''),
-     (KnownT isoiec_9798_2_5_bdkey_P_1))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_text_1))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''Text1''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_1))
-  , ((isoiec_9798_2_6_bdkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_6_bdkey_A_1))
-  , ((isoiec_9798_2_6_bdkey_B, ''Text1''),
-     (KnownT isoiec_9798_2_6_bdkey_B_text_1))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_1))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text1''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_text_1))
-  , ((isoiec_9798_2_1_bdkey_A, ''Text2''),
-     (KnownT isoiec_9798_2_1_bdkey_A_text_1))
-  , ((isoiec_9798_2_1_bdkey_B, ''Text2''),
-     (KnownT isoiec_9798_2_1_bdkey_B_1))
-  , ((isoiec_9798_2_2_bdkey_A, ''Text2''),
-     (KnownT isoiec_9798_2_2_bdkey_A_text_2))
-  , ((isoiec_9798_2_2_bdkey_B, ''Text2''),
-     (KnownT isoiec_9798_2_2_bdkey_B_2))
-  , ((isoiec_9798_2_3_bdkey_A, ''Text2''),
-     (KnownT isoiec_9798_2_3_bdkey_A_text_1))
-  , ((isoiec_9798_2_3_bdkey_B, ''Text2''),
-     (KnownT isoiec_9798_2_3_bdkey_B_1))
-  , ((isoiec_9798_2_4_bdkey_A, ''Text2''),
-     (KnownT isoiec_9798_2_4_bdkey_A_text_2))
-  , ((isoiec_9798_2_4_bdkey_B, ''Text2''),
-     (KnownT isoiec_9798_2_4_bdkey_B_2))
-  , ((isoiec_9798_2_5_bdkey_B, ''Text2''),
-     (KnownT isoiec_9798_2_5_bdkey_B_3))
-  , ((isoiec_9798_2_5_bdkey_P, ''Text2''),
-     (KnownT isoiec_9798_2_5_bdkey_P_text_2))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Text2''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''Text2''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_text_2))
-  , ((isoiec_9798_2_6_bdkey_A, ''Text2''),
-     (KnownT isoiec_9798_2_6_bdkey_A_text_2))
-  , ((isoiec_9798_2_6_bdkey_P, ''Text2''),
-     (KnownT isoiec_9798_2_6_bdkey_P_2))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text2''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_text_2))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Text2''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_2))
-  , ((isoiec_9798_2_2_bdkey_A, ''Text3''),
-     (KnownT isoiec_9798_2_2_bdkey_A_text_2))
-  , ((isoiec_9798_2_2_bdkey_B, ''Text3''),
-     (KnownT isoiec_9798_2_2_bdkey_B_2))
-  , ((isoiec_9798_2_3_bdkey_A, ''Text3''),
-     (KnownT isoiec_9798_2_3_bdkey_A_2))
-  , ((isoiec_9798_2_3_bdkey_B, ''Text3''),
-     (KnownT isoiec_9798_2_3_bdkey_B_text_2))
-  , ((isoiec_9798_2_4_bdkey_A, ''Text3''),
-     (KnownT isoiec_9798_2_4_bdkey_A_text_2))
-  , ((isoiec_9798_2_4_bdkey_B, ''Text3''),
-     (KnownT isoiec_9798_2_4_bdkey_B_2))
-  , ((isoiec_9798_2_5_bdkey_A, ''Text3''),
-     (KnownT isoiec_9798_2_5_bdkey_A_2))
-  , ((isoiec_9798_2_5_bdkey_P, ''Text3''),
-     (KnownT isoiec_9798_2_5_bdkey_P_text_2))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text3''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_2))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''Text3''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_text_2))
-  , ((isoiec_9798_2_6_bdkey_B, ''Text3''),
-     (KnownT isoiec_9798_2_6_bdkey_B_4))
-  , ((isoiec_9798_2_6_bdkey_P, ''Text3''),
-     (KnownT isoiec_9798_2_6_bdkey_P_text_3))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text3''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Text3''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_text_3))
-  , ((isoiec_9798_2_3_bdkey_A, ''Text4''),
-     (KnownT isoiec_9798_2_3_bdkey_A_2))
-  , ((isoiec_9798_2_3_bdkey_B, ''Text4''),
-     (KnownT isoiec_9798_2_3_bdkey_B_text_2))
-  , ((isoiec_9798_2_4_bdkey_A, ''Text4''),
-     (KnownT isoiec_9798_2_4_bdkey_A_3))
-  , ((isoiec_9798_2_4_bdkey_B, ''Text4''),
-     (KnownT isoiec_9798_2_4_bdkey_B_text_3))
-  , ((isoiec_9798_2_5_bdkey_A, ''Text4''),
-     (KnownT isoiec_9798_2_5_bdkey_A_2))
-  , ((isoiec_9798_2_5_bdkey_P, ''Text4''),
-     (KnownT isoiec_9798_2_5_bdkey_P_text_2))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text4''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_2))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''Text4''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_text_2))
-  , ((isoiec_9798_2_6_bdkey_A, ''Text4''),
-     (KnownT isoiec_9798_2_6_bdkey_A_3))
-  , ((isoiec_9798_2_6_bdkey_P, ''Text4''),
-     (KnownT isoiec_9798_2_6_bdkey_P_text_3))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text4''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_3))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Text4''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_text_3))
-  , ((isoiec_9798_2_4_bdkey_A, ''Text5''),
-     (KnownT isoiec_9798_2_4_bdkey_A_3))
-  , ((isoiec_9798_2_4_bdkey_B, ''Text5''),
-     (KnownT isoiec_9798_2_4_bdkey_B_text_3))
-  , ((isoiec_9798_2_5_bdkey_A, ''Text5''),
-     (KnownT isoiec_9798_2_5_bdkey_A_text_3))
-  , ((isoiec_9798_2_5_bdkey_B, ''Text5''),
-     (KnownT isoiec_9798_2_5_bdkey_B_3))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text5''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_text_3))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Text5''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3))
-  , ((isoiec_9798_2_6_bdkey_A, ''Text5''),
-     (KnownT isoiec_9798_2_6_bdkey_A_3))
-  , ((isoiec_9798_2_6_bdkey_P, ''Text5''),
-     (KnownT isoiec_9798_2_6_bdkey_P_text_3))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text5''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_3))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Text5''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_text_3))
-  , ((isoiec_9798_2_5_bdkey_A, ''Text6''),
-     (KnownT isoiec_9798_2_5_bdkey_A_text_3))
-  , ((isoiec_9798_2_5_bdkey_B, ''Text6''),
-     (KnownT isoiec_9798_2_5_bdkey_B_3))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text6''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_text_3))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Text6''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3))
-  , ((isoiec_9798_2_6_bdkey_A, ''Text6''),
-     (KnownT isoiec_9798_2_6_bdkey_A_text_4))
-  , ((isoiec_9798_2_6_bdkey_B, ''Text6''),
-     (KnownT isoiec_9798_2_6_bdkey_B_4))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text6''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_text_4))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text6''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4))
-  , ((isoiec_9798_2_5_bdkey_A, ''Text7''),
-     (KnownT isoiec_9798_2_5_bdkey_A_4))
-  , ((isoiec_9798_2_5_bdkey_B, ''Text7''),
-     (KnownT isoiec_9798_2_5_bdkey_B_text_4))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text7''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_4))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Text7''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_text_4))
-  , ((isoiec_9798_2_6_bdkey_A, ''Text7''),
-     (KnownT isoiec_9798_2_6_bdkey_A_text_4))
-  , ((isoiec_9798_2_6_bdkey_B, ''Text7''),
-     (KnownT isoiec_9798_2_6_bdkey_B_4))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text7''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_text_4))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text7''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4))
-  , ((isoiec_9798_2_5_bdkey_A, ''Text8''),
-     (KnownT isoiec_9798_2_5_bdkey_A_4))
-  , ((isoiec_9798_2_5_bdkey_B, ''Text8''),
-     (KnownT isoiec_9798_2_5_bdkey_B_text_4))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text8''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_4))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Text8''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_text_4))
-  , ((isoiec_9798_2_6_bdkey_A, ''Text8''),
-     (KnownT isoiec_9798_2_6_bdkey_A_5))
-  , ((isoiec_9798_2_6_bdkey_B, ''Text8''),
-     (KnownT isoiec_9798_2_6_bdkey_B_text_5))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text8''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_5))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text8''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_text_5))
-  , ((isoiec_9798_2_6_bdkey_A, ''Text9''),
-     (KnownT isoiec_9798_2_6_bdkey_A_5))
-  , ((isoiec_9798_2_6_bdkey_B, ''Text9''),
-     (KnownT isoiec_9798_2_6_bdkey_B_text_5))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text9''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_5))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text9''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_text_5))
-  , ((isoiec_9798_2_5_bdkey_A, ''TokenPA_for_B''),
-     (KnownT isoiec_9798_2_5_bdkey_A_2))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''TokenPA_for_B''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_2))
-  , ((isoiec_9798_2_6_bdkey_A, ''TokenPA_for_B''),
-     (KnownT isoiec_9798_2_6_bdkey_A_3))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''TokenPA_for_B''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_3))
-  ]"
-
-sublocale isoiec_9798_2_bdkey_state < isoiec_9798_2_bdkey_composed_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_2_bdkey_composed_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_2_bdkey_composed_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_2_1_bdkey_A_text_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_1_bdkey_A_text_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_1_bdkey_B_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_1_bdkey_B_1_TNA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
-               s(AV ''B'' tid0), s(MV ''Text1'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_1_bdkey_B_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
-               s(AV ''B'' tid0), s(MV ''Text1'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_1_bdkey_B_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_2_bdkey_A_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_2_bdkey_A_1_RB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_2_bdkey_A_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_2_bdkey_A_text_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_2_bdkey_A_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_2_bdkey_B_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_2_enc_2'', LN ''RB'' tid0, s(AV ''B'' tid0),
-               s(MV ''Text2'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_2_bdkey_B_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_bdkey_A_text_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_bdkey_A_text_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_bdkey_A_2_TNB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
-               s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_3_bdkey_A_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
-               s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_3_bdkey_A_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_bdkey_B_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_bdkey_B_1_TNA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
-               s(AV ''B'' tid0), s(MV ''Text1'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_3_bdkey_B_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
-               s(AV ''B'' tid0), s(MV ''Text1'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_3_bdkey_B_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_bdkey_B_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_bdkey_B_text_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_bdkey_A_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_bdkey_A_1_RB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_bdkey_A_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_bdkey_A_text_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_bdkey_A_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_bdkey_A_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_4_enc_2'', s(MV ''RB'' tid0), LN ''RA'' tid0,
-               s(MV ''Text4'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_4_bdkey_A_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_bdkey_B_2_RA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
-               s(AV ''B'' tid0), s(MV ''Text2'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_4_bdkey_B_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
-               s(AV ''B'' tid0), s(MV ''Text2'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_4_bdkey_B_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_bdkey_B_text_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_bdkey_B_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_A_2_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
-               s(MV ''Text3'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_bdkey_A_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
-               s(MV ''Text3'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_bdkey_A_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_A_2_TokenPA_for_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_A_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_A_text_3_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_A_4_TNb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
-               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_bdkey_A_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
-               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_bdkey_A_4_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_B_3_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_B_3_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
-               s(MV ''Text2'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_bdkey_B_3_P t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_B_3_TNa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
-               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_bdkey_B_3_TNp t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
-               s(MV ''Text2'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_bdkey_B_3_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
-               s(MV ''Text2'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_bdkey_B_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
-               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_bdkey_B_3_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_B_text_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_B_text_4_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_P_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_P_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_P_1_TVPa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_P_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_P_text_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_P_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_P_text_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_A_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_A_1_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_A_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_A_3_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
-               s(MV ''Text4'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_bdkey_A_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
-               s(MV ''Text4'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_bdkey_A_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_A_3_TokenPA_for_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_A_text_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_A_text_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_A_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_5'', s(MV ''Rb'' tid0), LN ''Rpa'' tid0,
-               s(MV ''Text8'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_bdkey_A_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_B_4_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
-               s(MV ''Text3'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_bdkey_B_4_P t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_B_4_Rpa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
-               s(MV ''Text6'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_bdkey_B_4_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
-               s(MV ''Text3'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_bdkey_B_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
-               s(MV ''Text6'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_bdkey_B_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_B_text_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_B_text_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_P_2_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_P_2_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_P_2_Ra t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_P_2_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_P_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_P_text_3_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_P_text_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_P_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_A_2_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_A_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_A_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_A_2_TokenPA_for_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_A_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_A_text_3_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_A_4_TNb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_4'', s(MV ''TNb'' tid0),
-               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_A_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_4'', s(MV ''TNb'' tid0),
-               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_A_4_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
-               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_P t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_TNa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_3'', s(MV ''TNa'' tid0),
-               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_TNp t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
-               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
-               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_3'', s(MV ''TNa'' tid0),
-               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_B_text_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_B_text_4_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_1_TVPa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_text_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_text_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_A_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_A_1_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_A_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_A_3_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid0,
-               s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_A_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid0,
-               s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_A_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_A_3_TokenPA_for_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_A_text_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_A_text_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_A_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_5'', s(MV ''Rb'' tid0),
-               LN ''Rpa'' tid0, s(MV ''Text8'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_A_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_P t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_Rpa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_4'', s(MV ''Rpa'' tid0),
-               LN ''Rb'' tid0, s(MV ''Text6'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_4'', s(MV ''Rpa'' tid0),
-               LN ''Rb'' tid0, s(MV ''Text6'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_B_text_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_B_text_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_2_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_2_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_2_Ra t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_2_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_text_3_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_text_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_2_bdkey_composed_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_2_bdkey_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_1_bdkey_B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_1_bdkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_1_bdkey_B_1 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_1_bdkey_A &
-        ( tid1, isoiec_9798_2_1_bdkey_A_1 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
-           s(MV ''Text1'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
-                s(MV ''Text1'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
-                          s(AV ''B'' tid0), s(MV ''Text1'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_1_bdkey_A_1_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_2_bdkey_B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_2_bdkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_2_bdkey_B_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_2_bdkey_A &
-        ( tid1, isoiec_9798_2_2_bdkey_A_2 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(MV ''RB'' tid1),
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''RB'' tid0,
-                s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_2_enc_2'', LN ''RB'' tid0, s(AV ''B'' tid0),
-                          s(MV ''Text2'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_2_bdkey_A_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_3_bdkey_A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_3_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_3_bdkey_A_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_3_bdkey_B &
-        ( tid1, isoiec_9798_2_3_bdkey_B_2 ) : steps t &
-        {| s(MV ''A'' tid1), s(AV ''B'' tid1), LN ''TNB'' tid1,
-           s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNB'' tid0),
-                s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
-                          s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_3_bdkey_B_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_3_bdkey_B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_3_bdkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_3_bdkey_B_1 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_3_bdkey_A &
-        ( tid1, isoiec_9798_2_3_bdkey_A_1 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
-           s(MV ''Text1'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
-                s(MV ''Text1'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
-                          s(AV ''B'' tid0), s(MV ''Text1'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_3_bdkey_A_1_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_4_bdkey_A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_4_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_4_bdkey_A_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_4_bdkey_B &
-        ( tid1, isoiec_9798_2_4_bdkey_B_3 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''RA'' tid1), LN ''RB'' tid1,
-           s(MV ''Text2'' tid1), s(MV ''Text4'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''RA'' tid0,
-                s(MV ''RB'' tid0), s(MV ''Text2'' tid0), s(MV ''Text4'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_4_enc_2'', s(MV ''RB'' tid0), LN ''RA'' tid0,
-                          s(MV ''Text4'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_4_bdkey_B_3_enc tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''A'' tid1) )
-               ( s(AV ''B'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_4_enc_1'', LN ''RA'' tid0, LN ''RB'' tid1,
-                              s(AV ''B'' tid1), s(MV ''Text2'' tid1)
-                           |}
-                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid1) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest!: ltk_secrecy)
-      next
-        case (isoiec_9798_2_4_bdkey_A_2_enc tid2) note_unified facts = this facts
-        thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-      qed (insert facts, fastsimp+)?
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_4_enc_1'', LN ''RA'' tid0, LN ''RB'' tid1,
-                              s(AV ''A'' tid0), s(MV ''Text2'' tid1)
-                           |}
-                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''A'' tid1) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest!: ltk_secrecy)
-      next
-        case (isoiec_9798_2_4_bdkey_A_2_enc tid2) note_unified facts = this facts
-        thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-      qed (insert facts, fastsimp+)?
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_4_bdkey_B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_4_bdkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_4_bdkey_B_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_4_bdkey_A &
-        ( tid1, isoiec_9798_2_4_bdkey_A_2 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''RA'' tid1, s(MV ''RB'' tid1),
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''RA'' tid0),
-                LN ''RB'' tid0, s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
-                          s(AV ''B'' tid0), s(MV ''Text2'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_4_bdkey_A_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_bdkey_P_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_P"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "LN ''Kab'' tid0 : knows t"
-  shows "False"
-using facts proof(sources! " LN ''Kab'' tid0 ")
-  case isoiec_9798_2_5_bdkey_P_2_Kab note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-next
-  case isoiec_9798_2_5_bdkey_P_2_Kab_1 note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-qed (insert facts, fastsimp+)?
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_bdkey_A_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_bdkey_A_2 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
-                          s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_bdkey_P_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp dest: isoiec_9798_2_5_bdkey_P_secret_Kab intro: event_predOrdI)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_bdkey_B_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_bdkey_B_3 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
-                          s(MV ''Text2'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_bdkey_P_2_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp dest: isoiec_9798_2_5_bdkey_P_secret_Kab intro: event_predOrdI)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_bdkey_A_non_injective_agreement_B:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_bdkey_A_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_bdkey_B &
-        ( tid1, isoiec_9798_2_5_bdkey_B_4 ) : steps t &
-        {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
-           s(MV ''Kab'' tid1), s(MV ''TNa'' tid1), s(MV ''Text5'' tid1),
-           LN ''TNb'' tid1, s(MV ''Text7'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
-                s(MV ''Kab'' tid0), LN ''TNa'' tid0, s(MV ''Text5'' tid0),
-                s(MV ''TNb'' tid0), s(MV ''Text7'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
-                          s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_bdkey_P_2_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
-                            s(AV ''A'' tid0), s(MV ''Text7'' tid0)
-                         |}
-                         ( LN ''Kab'' tid1 ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_5_bdkey_P_secret_Kab intro: event_predOrdI)
-    next
-      case (isoiec_9798_2_5_bdkey_B_4_enc tid2) note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid2),
-                              LN ''Kab'' tid1, s(AV ''A'' tid0), s(AV ''B'' tid2), s(MV ''Text2'' tid2)
-                           |}
-                           ( Kbd ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: isoiec_9798_2_5_bdkey_P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_5_bdkey_P_2_enc_1 tid3) note_unified facts = this facts
-        thus ?thesis proof(sources! "
-                         Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid2),
-                                s(AV ''B'' tid0), s(MV ''Text5'' tid2)
-                             |}
-                             ( LN ''Kab'' tid1 ) ")
-          case fake note_unified facts = this facts
-          thus ?thesis by (fastsimp dest: isoiec_9798_2_5_bdkey_P_secret_Kab intro: event_predOrdI)
-        next
-          case (isoiec_9798_2_5_bdkey_A_3_enc tid3) note_unified facts = this facts
-          thus ?thesis proof(sources! "
-                           Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid3, LN ''Kab'' tid1,
-                                  s(AV ''A'' tid3), s(AV ''B'' tid0), s(MV ''Text3'' tid3)
-                               |}
-                               ( Kbd ( s(AV ''A'' tid3) ) ( s(AV ''P'' tid3) ) ) ")
-            case fake note_unified facts = this facts
-            thus ?thesis by (fastsimp dest: isoiec_9798_2_5_bdkey_P_secret_Kab intro: event_predOrdI)
-          next
-            case (isoiec_9798_2_5_bdkey_P_2_enc tid4) note_unified facts = this facts
-            thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-          qed (insert facts, fastsimp+)?
-        qed (insert facts, fastsimp+)?
-      qed (insert facts, fastsimp+)?
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_bdkey_B_non_injective_agreement_A:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_bdkey_B_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_bdkey_A &
-        ( tid1, isoiec_9798_2_5_bdkey_A_3 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Kab'' tid1), LN ''TNa'' tid1, s(MV ''Text5'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                s(MV ''Kab'' tid0), s(MV ''TNa'' tid0), s(MV ''Text5'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
-                          s(MV ''Text2'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_bdkey_P_2_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
-                            s(AV ''B'' tid0), s(MV ''Text5'' tid0)
-                         |}
-                         ( LN ''Kab'' tid1 ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_5_bdkey_P_secret_Kab intro: event_predOrdI)
-    next
-      case (isoiec_9798_2_5_bdkey_A_3_enc tid2) note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid2, LN ''Kab'' tid1,
-                              s(AV ''A'' tid2), s(AV ''B'' tid0), s(MV ''Text3'' tid2)
-                           |}
-                           ( Kbd ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: isoiec_9798_2_5_bdkey_P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_5_bdkey_P_2_enc tid3) note_unified facts = this facts
-        thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-      qed (insert facts, fastsimp+)?
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_bdkey_A_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_bdkey_A_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_bdkey_P &
-        ( tid1, isoiec_9798_2_5_bdkey_P_2 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
-           s(MV ''TVPa'' tid1), s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
-                s(MV ''Kab'' tid0), LN ''TVPa'' tid0, s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
-                          s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_bdkey_P_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_bdkey_B_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_bdkey_B_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_bdkey_P &
-        ( tid1, isoiec_9798_2_5_bdkey_P_2 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
-           LN ''TNp'' tid1, s(MV ''Text2'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                s(MV ''Kab'' tid0), s(MV ''TNp'' tid0), s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
-                          s(MV ''Text2'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_bdkey_P_2_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_bdkey_P_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_bdkey_P"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "LN ''Kab'' tid0 : knows t"
-  shows "False"
-using facts proof(sources! " LN ''Kab'' tid0 ")
-  case isoiec_9798_2_6_bdkey_P_3_Kab note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-next
-  case isoiec_9798_2_6_bdkey_P_3_Kab_1 note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-qed (insert facts, fastsimp+)?
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_bdkey_A_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_bdkey_A_3 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
-                          s(MV ''Text4'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_bdkey_P_3_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp dest: isoiec_9798_2_6_bdkey_P_secret_Kab intro: event_predOrdI)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_bdkey_B_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_bdkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_bdkey_B_4 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
-                          s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp dest: isoiec_9798_2_6_bdkey_P_secret_Kab intro: event_predOrdI)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_bdkey_A_non_injective_agreement_B:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_bdkey_A_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_bdkey_B &
-        ( tid1, isoiec_9798_2_6_bdkey_B_5 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
-           s(MV ''Kab'' tid1), s(MV ''Rpa'' tid1), LN ''Rb'' tid1,
-           s(MV ''Text6'' tid1), s(MV ''Text8'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
-                s(MV ''Kab'' tid0), LN ''Rpa'' tid0, s(MV ''Rb'' tid0),
-                s(MV ''Text6'' tid0), s(MV ''Text8'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
-                          s(MV ''Text4'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_bdkey_P_3_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_2_6_enc_5'', s(MV ''Rb'' tid0), LN ''Rpa'' tid0,
-                            s(MV ''Text8'' tid0)
-                         |}
-                         ( LN ''Kab'' tid1 ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_6_bdkey_P_secret_Kab intro: event_predOrdI)
-    next
-      case (isoiec_9798_2_6_bdkey_B_5_enc tid2) note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid2, LN ''Kab'' tid1,
-                              s(AV ''A'' tid2), s(AV ''B'' tid2), s(MV ''Text3'' tid2)
-                           |}
-                           ( Kbd ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: isoiec_9798_2_6_bdkey_P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_6_bdkey_P_3_enc_1 tid3) note_unified facts = this facts
-        thus ?thesis proof(sources! "
-                         Enc {| LC ''isoiec_9798_2_6_enc_4'', LN ''Rpa'' tid0, LN ''Rb'' tid2,
-                                s(MV ''Text6'' tid2)
-                             |}
-                             ( LN ''Kab'' tid1 ) ")
-          case fake note_unified facts = this facts
-          thus ?thesis by (fastsimp dest: isoiec_9798_2_6_bdkey_P_secret_Kab intro: event_predOrdI)
-        next
-          case (isoiec_9798_2_6_bdkey_A_4_enc tid3) note_unified facts = this facts
-          thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-        qed (insert facts, fastsimp+)?
-      qed (insert facts, fastsimp+)?
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_bdkey_B_non_injective_agreement_A:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_bdkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_bdkey_B_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_bdkey_A &
-        ( tid1, isoiec_9798_2_6_bdkey_A_4 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Kab'' tid1), LN ''Rpa'' tid1, s(MV ''Rb'' tid1),
-           s(MV ''Text6'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                s(MV ''Kab'' tid0), s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
-                s(MV ''Text6'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
-                          s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
-                            s(MV ''Text6'' tid0)
-                         |}
-                         ( LN ''Kab'' tid1 ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_6_bdkey_P_secret_Kab intro: event_predOrdI)
-    next
-      case (isoiec_9798_2_6_bdkey_A_4_enc tid2) note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid2, LN ''Kab'' tid1,
-                              s(AV ''A'' tid2), s(MV ''B'' tid2), s(MV ''Text4'' tid2)
-                           |}
-                           ( Kbd ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: isoiec_9798_2_6_bdkey_P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_6_bdkey_P_3_enc tid3) note_unified facts = this facts
-        thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-      qed (insert facts, fastsimp+)?
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_bdkey_A_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_bdkey_A_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_bdkey_P &
-        ( tid1, isoiec_9798_2_6_bdkey_P_3 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Ra'' tid1), LN ''Kab'' tid1, s(MV ''Text4'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
-                LN ''Ra'' tid0, s(MV ''Kab'' tid0), s(MV ''Text4'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
-                          s(MV ''Text4'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_bdkey_P_3_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_bdkey_B_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_bdkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_bdkey_B_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_bdkey_P &
-        ( tid1, isoiec_9798_2_6_bdkey_P_3 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Rb'' tid1), LN ''Kab'' tid1, s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                LN ''Rb'' tid0, s(MV ''Kab'' tid0), s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
-                          s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_special_TTP_bdkey_P_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_P"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "LN ''Kab'' tid0 : knows t"
-  shows "False"
-using facts proof(sources! " LN ''Kab'' tid0 ")
-  case isoiec_9798_2_5_special_TTP_bdkey_P_2_Kab note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-next
-  case isoiec_9798_2_5_special_TTP_bdkey_P_2_Kab_1 note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-qed (insert facts, fastsimp+)?
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_special_TTP_bdkey_A_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_special_TTP_bdkey_A_2 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''P'' tid1) )
-               ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_5_special_TTP_bdkey_different_actors_A_P intro: event_predOrdI)
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_5_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_special_TTP_bdkey_B_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_special_TTP_bdkey_B_3 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
-                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc_1 tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''P'' tid1) )
-               ( s(MV ''B'' tid1) ) = Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_5_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_5_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_special_TTP_bdkey_A_non_injective_agreement_B:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_special_TTP_bdkey_A_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_special_TTP_bdkey_B &
-        ( tid1, isoiec_9798_2_5_special_TTP_bdkey_B_4 ) : steps t &
-        {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
-           s(MV ''Kab'' tid1), s(MV ''TNa'' tid1), s(MV ''Text5'' tid1),
-           LN ''TNb'' tid1, s(MV ''Text7'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
-                s(MV ''Kab'' tid0), LN ''TNa'' tid0, s(MV ''Text5'' tid0),
-                s(MV ''TNb'' tid0), s(MV ''Text7'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''P'' tid1) )
-               ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_5_special_TTP_bdkey_different_actors_A_P intro: event_predOrdI)
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_4'', s(MV ''TNb'' tid0),
-                              s(AV ''A'' tid0), s(MV ''Text7'' tid0)
-                           |}
-                           ( LN ''Kab'' tid1 ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: isoiec_9798_2_5_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_5_special_TTP_bdkey_B_4_enc tid2) note_unified facts = this facts
-        thus ?thesis proof(sources! "
-                         Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_3'', s(MV ''TNa'' tid2),
-                                s(AV ''B'' tid2), s(MV ''Text5'' tid2)
-                             |}
-                             ( LN ''Kab'' tid1 ) ")
-          case fake note_unified facts = this facts
-          thus ?thesis by (fastsimp dest: isoiec_9798_2_5_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
-        next
-          case (isoiec_9798_2_5_special_TTP_bdkey_A_3_enc tid3) note_unified facts = this facts
-          thus ?thesis proof(sources! "
-                           Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid3,
-                                  LN ''Kab'' tid1, s(AV ''B'' tid2), s(MV ''Text3'' tid3)
-                               |}
-                               ( Kbd ( s(AV ''A'' tid3) ) ( s(AV ''P'' tid3) ) ) ")
-            case fake note_unified facts = this facts
-            thus ?thesis by (fastsimp dest: isoiec_9798_2_5_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
-          next
-            case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid4) note_unified facts = this facts
-            thus ?thesis proof(sources! "
-                             Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid2),
-                                    LN ''Kab'' tid1, s(AV ''A'' tid0), s(MV ''Text2'' tid2)
-                                 |}
-                                 ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid2) ) ) ")
-              case fake note_unified facts = this facts
-              thus ?thesis by (fastsimp dest: isoiec_9798_2_5_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
-            next
-              case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc_1 tid3) note_unified facts = this facts
-              thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-            qed (insert facts, fastsimp+)?
-          qed (insert facts, fastsimp+)?
-        qed (insert facts, fastsimp+)?
-      qed (insert facts, fastsimp+)?
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_special_TTP_bdkey_B_non_injective_agreement_A:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_special_TTP_bdkey_B_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_special_TTP_bdkey_A &
-        ( tid1, isoiec_9798_2_5_special_TTP_bdkey_A_3 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Kab'' tid1), LN ''TNa'' tid1, s(MV ''Text5'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                s(MV ''Kab'' tid0), s(MV ''TNa'' tid0), s(MV ''Text5'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_3'', s(MV ''TNa'' tid0),
-                          s(AV ''B'' tid0), s(MV ''Text5'' tid0)
-                       |}
-                       ( s(MV ''Kab'' tid0) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest: isoiec_9798_2_5_special_TTP_bdkey_B_secret_Kab intro: event_predOrdI)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_A_3_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid1,
-                            s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid1)
-                         |}
-                         ( Kbd ( s(AV ''A'' tid1) ) ( s(AV ''P'' tid1) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_5_special_TTP_bdkey_B_secret_Kab intro: event_predOrdI)
-    next
-      case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid2) note_unified facts = this facts
-      hence "Kbd ( s(AV ''P'' tid2) )
-                 ( s(MV ''A'' tid2) ) = Kbd ( s(AV ''A'' tid1) ) ( s(AV ''P'' tid1) )"
-        by simp note facts = this facts
-      thus ?thesis proof(cases rule: Kbd_cases)
-        case noswap note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: isoiec_9798_2_5_special_TTP_bdkey_different_actors_A_P intro: event_predOrdI)
-      next
-        case swapped note_unified facts = this facts
-        thus ?thesis proof(sources! "
-                         Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
-                                LN ''Kab'' tid2, s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-                             |}
-                             ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-          case fake note_unified facts = this facts
-          thus ?thesis by (fastsimp dest!: ltk_secrecy)
-        next
-          case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc_1 tid3) note_unified facts = this facts
-          thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-        qed (insert facts, fastsimp+)?
-      qed (fastsimp+)?
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_special_TTP_bdkey_A_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_special_TTP_bdkey_A_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_special_TTP_bdkey_P &
-        ( tid1, isoiec_9798_2_5_special_TTP_bdkey_P_2 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
-           s(MV ''TVPa'' tid1), s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
-                s(MV ''Kab'' tid0), LN ''TVPa'' tid0, s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''P'' tid1) )
-               ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_5_special_TTP_bdkey_different_actors_A_P intro: event_predOrdI)
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_special_TTP_bdkey_B_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_special_TTP_bdkey_B_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_special_TTP_bdkey_P &
-        ( tid1, isoiec_9798_2_5_special_TTP_bdkey_P_2 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
-           LN ''TNp'' tid1, s(MV ''Text2'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                s(MV ''Kab'' tid0), s(MV ''TNp'' tid0), s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
-                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc_1 tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''P'' tid1) )
-               ( s(MV ''B'' tid1) ) = Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_3'', s(MV ''TNa'' tid0),
-                              s(AV ''B'' tid0), s(MV ''Text5'' tid0)
-                           |}
-                           ( LN ''Kab'' tid1 ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: isoiec_9798_2_5_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_5_special_TTP_bdkey_A_3_enc tid2) note_unified facts = this facts
-        thus ?thesis proof(sources! "
-                         Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid2,
-                                LN ''Kab'' tid1, s(AV ''B'' tid0), s(MV ''Text3'' tid2)
-                             |}
-                             ( Kbd ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
-          case fake note_unified facts = this facts
-          thus ?thesis by (fastsimp dest: isoiec_9798_2_5_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
-        next
-          case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid3) note_unified facts = this facts
-          thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-        qed (insert facts, fastsimp+)?
-      qed (insert facts, fastsimp+)?
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_special_TTP_bdkey_P_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_P"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "LN ''Kab'' tid0 : knows t"
-  shows "False"
-using facts proof(sources! " LN ''Kab'' tid0 ")
-  case isoiec_9798_2_6_special_TTP_bdkey_P_3_Kab note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-next
-  case isoiec_9798_2_6_special_TTP_bdkey_P_3_Kab_1 note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-qed (insert facts, fastsimp+)?
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_special_TTP_bdkey_A_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_special_TTP_bdkey_A_3 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid0,
-                          s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''P'' tid1) )
-               ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_6_special_TTP_bdkey_different_actors_A_P intro: event_predOrdI)
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_6_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_special_TTP_bdkey_B_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_special_TTP_bdkey_B_4 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''P'' tid1) )
-               ( s(MV ''B'' tid1) ) = Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_6_special_TTP_bdkey_different_actors_B_P intro: event_predOrdI)
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_6_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_special_TTP_bdkey_A_non_injective_agreement_B:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_special_TTP_bdkey_A_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_B &
-        ( tid1, isoiec_9798_2_6_special_TTP_bdkey_B_5 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
-           s(MV ''Kab'' tid1), s(MV ''Rpa'' tid1), LN ''Rb'' tid1,
-           s(MV ''Text6'' tid1), s(MV ''Text8'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
-                s(MV ''Kab'' tid0), LN ''Rpa'' tid0, s(MV ''Rb'' tid0),
-                s(MV ''Text6'' tid0), s(MV ''Text8'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid0,
-                          s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''P'' tid1) )
-               ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_6_special_TTP_bdkey_different_actors_A_P intro: event_predOrdI)
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_5'', s(MV ''Rb'' tid0),
-                              LN ''Rpa'' tid0, s(MV ''Text8'' tid0)
-                           |}
-                           ( LN ''Kab'' tid1 ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: isoiec_9798_2_6_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_6_special_TTP_bdkey_B_5_enc tid2) note_unified facts = this facts
-        thus ?thesis proof(sources! "
-                         Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid2,
-                                LN ''Kab'' tid1, s(AV ''A'' tid2), s(MV ''Text3'' tid2)
-                             |}
-                             ( Kbd ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) ) ) ")
-          case fake note_unified facts = this facts
-          thus ?thesis by (fastsimp dest: isoiec_9798_2_6_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
-        next
-          case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc_1 tid3) note_unified facts = this facts
-          hence "Kbd ( s(AV ''P'' tid0) )
-                     ( s(MV ''B'' tid0) ) = Kbd ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) )"
-            by simp note facts = this facts
-          thus ?thesis proof(cases rule: Kbd_cases)
-            case noswap note_unified facts = this facts
-            thus ?thesis by (fastsimp dest: isoiec_9798_2_6_special_TTP_bdkey_different_actors_B_P intro: event_predOrdI)
-          next
-            case swapped note_unified facts = this facts
-            thus ?thesis proof(sources! "
-                             Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_4'', LN ''Rpa'' tid0,
-                                    LN ''Rb'' tid2, s(MV ''Text6'' tid2)
-                                 |}
-                                 ( LN ''Kab'' tid1 ) ")
-              case fake note_unified facts = this facts
-              thus ?thesis by (fastsimp dest: isoiec_9798_2_6_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
-            next
-              case (isoiec_9798_2_6_special_TTP_bdkey_A_4_enc tid3) note_unified facts = this facts
-              thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-            qed (insert facts, fastsimp+)?
-          qed (fastsimp+)?
-        qed (insert facts, fastsimp+)?
-      qed (insert facts, fastsimp+)?
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_special_TTP_bdkey_B_non_injective_agreement_A:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_special_TTP_bdkey_B_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_A &
-        ( tid1, isoiec_9798_2_6_special_TTP_bdkey_A_4 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Kab'' tid1), LN ''Rpa'' tid1, s(MV ''Rb'' tid1),
-           s(MV ''Text6'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                s(MV ''Kab'' tid0), s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
-                s(MV ''Text6'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''P'' tid1) )
-               ( s(MV ''B'' tid1) ) = Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_6_special_TTP_bdkey_different_actors_B_P intro: event_predOrdI)
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_4'', s(MV ''Rpa'' tid0),
-                              LN ''Rb'' tid0, s(MV ''Text6'' tid0)
-                           |}
-                           ( LN ''Kab'' tid1 ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: isoiec_9798_2_6_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_6_special_TTP_bdkey_A_4_enc tid2) note_unified facts = this facts
-        thus ?thesis proof(sources! "
-                         Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid2,
-                                LN ''Kab'' tid1, s(MV ''B'' tid2), s(MV ''Text4'' tid2)
-                             |}
-                             ( Kbd ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
-          case fake note_unified facts = this facts
-          thus ?thesis by (fastsimp dest: isoiec_9798_2_6_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
-        next
-          case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc tid3) note_unified facts = this facts
-          hence "Kbd ( s(AV ''A'' tid2) )
-                     ( s(AV ''P'' tid2) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid1) )"
-            by simp note facts = this facts
-          thus ?thesis proof(cases rule: Kbd_cases)
-            case noswap note_unified facts = this facts
-            thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-          next
-            case swapped note_unified facts = this facts
-            thus ?thesis by (fastsimp dest: isoiec_9798_2_6_special_TTP_bdkey_different_actors_A_P intro: event_predOrdI)
-          qed (fastsimp+)?
-        qed (insert facts, fastsimp+)?
-      qed (insert facts, fastsimp+)?
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_special_TTP_bdkey_A_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_special_TTP_bdkey_A_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_P &
-        ( tid1, isoiec_9798_2_6_special_TTP_bdkey_P_3 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Ra'' tid1), LN ''Kab'' tid1, s(MV ''Text4'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
-                LN ''Ra'' tid0, s(MV ''Kab'' tid0), s(MV ''Text4'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid0,
-                          s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''P'' tid1) )
-               ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_6_special_TTP_bdkey_different_actors_A_P intro: event_predOrdI)
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_special_TTP_bdkey_B_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_special_TTP_bdkey_B_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_P &
-        ( tid1, isoiec_9798_2_6_special_TTP_bdkey_P_3 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Rb'' tid1), LN ''Kab'' tid1, s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                LN ''Rb'' tid0, s(MV ''Kab'' tid0), s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''P'' tid1) )
-               ( s(MV ''B'' tid1) ) = Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_6_special_TTP_bdkey_different_actors_B_P intro: event_predOrdI)
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
+  "ESPLogic"
+begin
+
+role isoiec_9798_2_1_bdkey_A
+where "isoiec_9798_2_1_bdkey_A =
+  [ Send ''leak_A'' ( sN ''TNA'' )
+  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
+  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
+                  PEnc <| sC ''isoiec_9798_2_1_enc_1'', sN ''TNA'', sAV ''B'',
+                          sMV ''Text1''
+                       |>
+                       ( sKbd (AVar ''A'') (AVar ''B'') )
+               |>
+  ]"
+
+role isoiec_9798_2_1_bdkey_B
+where "isoiec_9798_2_1_bdkey_B =
+  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
+                  PEnc <| sC ''isoiec_9798_2_1_enc_1'', sMV ''TNA'', sAV ''B'',
+                          sMV ''Text1''
+                       |>
+                       ( sKbd (MVar ''A'') (AVar ''B'') )
+               |>
+  ]"
+
+role isoiec_9798_2_2_bdkey_A
+where "isoiec_9798_2_2_bdkey_A =
+  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text1'' |>
+  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
+  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
+                  PEnc <| sC ''isoiec_9798_2_2_enc_2'', sMV ''RB'', sMV ''B'',
+                          sMV ''Text2''
+                       |>
+                       ( sKbd (MVar ''B'') (AVar ''A'') )
+               |>
+  ]"
+
+role isoiec_9798_2_2_bdkey_B
+where "isoiec_9798_2_2_bdkey_B =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''RB'', sMV ''Text1'' |>
+  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
+                  PEnc <| sC ''isoiec_9798_2_2_enc_2'', sN ''RB'', sAV ''B'', sMV ''Text2''
+                       |>
+                       ( sKbd (AVar ''B'') (AVar ''A'') )
+               |>
+  ]"
+
+role isoiec_9798_2_3_bdkey_A
+where "isoiec_9798_2_3_bdkey_A =
+  [ Send ''leak_A'' ( sN ''TNA'' )
+  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
+  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
+                  PEnc <| sC ''isoiec_9798_2_3_enc_1'', sN ''TNA'', sAV ''B'',
+                          sMV ''Text1''
+                       |>
+                       ( sKbd (AVar ''A'') (AVar ''B'') )
+               |>
+  , Recv ''2'' <| sAV ''B'', sAV ''A'', sMV ''Text4'',
+                  PEnc <| sC ''isoiec_9798_2_3_enc_2'', sMV ''TNB'', sAV ''A'',
+                          sMV ''Text3''
+                       |>
+                       ( sKbd (AVar ''B'') (AVar ''A'') )
+               |>
+  ]"
+
+role isoiec_9798_2_3_bdkey_B
+where "isoiec_9798_2_3_bdkey_B =
+  [ Send ''leak_B'' ( sN ''TNB'' )
+  , Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
+                  PEnc <| sC ''isoiec_9798_2_3_enc_1'', sMV ''TNA'', sAV ''B'',
+                          sMV ''Text1''
+                       |>
+                       ( sKbd (MVar ''A'') (AVar ''B'') )
+               |>
+  , Recv ''text_2'' <| sMV ''Text3'', sMV ''Text4'' |>
+  , Send ''2'' <| sAV ''B'', sMV ''A'', sMV ''Text4'',
+                  PEnc <| sC ''isoiec_9798_2_3_enc_2'', sN ''TNB'', sMV ''A'',
+                          sMV ''Text3''
+                       |>
+                       ( sKbd (AVar ''B'') (MVar ''A'') )
+               |>
+  ]"
+
+role isoiec_9798_2_4_bdkey_A
+where "isoiec_9798_2_4_bdkey_A =
+  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text1'' |>
+  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
+  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
+                  PEnc <| sC ''isoiec_9798_2_4_enc_1'', sN ''RA'', sMV ''RB'', sMV ''B'',
+                          sMV ''Text2''
+                       |>
+                       ( sKbd (AVar ''A'') (MVar ''B'') )
+               |>
+  , Recv ''3'' <| sMV ''B'', sAV ''A'', sMV ''Text5'',
+                  PEnc <| sC ''isoiec_9798_2_4_enc_2'', sMV ''RB'', sN ''RA'',
+                          sMV ''Text4''
+                       |>
+                       ( sKbd (AVar ''A'') (MVar ''B'') )
+               |>
+  ]"
+
+role isoiec_9798_2_4_bdkey_B
+where "isoiec_9798_2_4_bdkey_B =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''RB'', sMV ''Text1'' |>
+  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
+                  PEnc <| sC ''isoiec_9798_2_4_enc_1'', sMV ''RA'', sN ''RB'', sAV ''B'',
+                          sMV ''Text2''
+                       |>
+                       ( sKbd (AVar ''A'') (AVar ''B'') )
+               |>
+  , Recv ''text_3'' <| sMV ''Text4'', sMV ''Text5'' |>
+  , Send ''3'' <| sAV ''B'', sAV ''A'', sMV ''Text5'',
+                  PEnc <| sC ''isoiec_9798_2_4_enc_2'', sN ''RB'', sMV ''RA'',
+                          sMV ''Text4''
+                       |>
+                       ( sKbd (AVar ''A'') (AVar ''B'') )
+               |>
+  ]"
+
+role isoiec_9798_2_5_bdkey_A
+where "isoiec_9798_2_5_bdkey_A =
+  [ Send ''leak_A'' <| sN ''TVPa'', sN ''TNa'' |>
+  , Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''A'', sAV ''P'', sN ''TVPa'', sAV ''B'',
+                  sMV ''Text1''
+               |>
+  , Recv ''2'' <| sAV ''P'', sAV ''A'', sMV ''Text4'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_2_1'', sN ''TVPa'', sMV ''Kab'',
+                          sAV ''A'', sAV ''B'', sMV ''Text3''
+                       |>
+                       ( sKbd (AVar ''A'') (AVar ''P'') ),
+                  sMV ''TokenPA_for_B''
+               |>
+  , Recv ''text_3'' <| sMV ''Text5'', sMV ''Text6'' |>
+  , Send ''3'' <| sAV ''A'', sAV ''B'', sMV ''Text6'', sAV ''P'',
+                  sMV ''TokenPA_for_B'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_3'', sN ''TNa'', sAV ''B'',
+                          sMV ''Text5''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''4'' <| sAV ''B'', sAV ''A'', sMV ''Text8'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_4'', sMV ''TNb'', sAV ''A'',
+                          sMV ''Text7''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_5_bdkey_B
+where "isoiec_9798_2_5_bdkey_B =
+  [ Send ''leak_B'' ( sN ''TNb'' )
+  , Recv ''3'' <| sMV ''A'', sAV ''B'', sMV ''Text6'', sMV ''P'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_2_2'', sMV ''TNp'', sMV ''Kab'',
+                          sMV ''A'', sAV ''B'', sMV ''Text2''
+                       |>
+                       ( sKbd (AVar ''B'') (MVar ''P'') ),
+                  PEnc <| sC ''isoiec_9798_2_5_enc_3'', sMV ''TNa'', sAV ''B'',
+                          sMV ''Text5''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''text_4'' <| sMV ''Text7'', sMV ''Text8'' |>
+  , Send ''4'' <| sAV ''B'', sMV ''A'', sMV ''Text8'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_4'', sN ''TNb'', sMV ''A'',
+                          sMV ''Text7''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_5_bdkey_P
+where "isoiec_9798_2_5_bdkey_P =
+  [ Send ''leak_P'' ( sN ''TNp'' )
+  , Recv ''1'' <| sMV ''A'', sAV ''P'', sMV ''TVPa'', sMV ''B'',
+                  sMV ''Text1''
+               |>
+  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'', sMV ''Text4'' |>
+  , Send ''2'' <| sAV ''P'', sMV ''A'', sMV ''Text4'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_2_1'', sMV ''TVPa'', sN ''Kab'',
+                          sMV ''A'', sMV ''B'', sMV ''Text3''
+                       |>
+                       ( sKbd (MVar ''A'') (AVar ''P'') ),
+                  PEnc <| sC ''isoiec_9798_2_5_enc_2_2'', sN ''TNp'', sN ''Kab'',
+                          sMV ''A'', sMV ''B'', sMV ''Text2''
+                       |>
+                       ( sKbd (MVar ''B'') (AVar ''P'') )
+               |>
+  ]"
+
+role isoiec_9798_2_6_bdkey_A
+where "isoiec_9798_2_6_bdkey_A =
+  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
+  , Recv ''text_2'' ( sMV ''Text2'' )
+  , Send ''2'' <| sAV ''A'', sAV ''P'', sN ''Ra'', sMV ''Rb'', sMV ''B'',
+                  sMV ''Text2''
+               |>
+  , Recv ''3'' <| sAV ''P'', sAV ''A'', sMV ''Text5'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_3_1'', sN ''Ra'', sMV ''Kab'',
+                          sAV ''A'', sMV ''B'', sMV ''Text4''
+                       |>
+                       ( sKbd (AVar ''A'') (AVar ''P'') ),
+                  sMV ''TokenPA_for_B''
+               |>
+  , Recv ''text_4'' <| sMV ''Text6'', sMV ''Text7'' |>
+  , Send ''4'' <| sAV ''A'', sMV ''B'', sMV ''Text7'', sAV ''P'',
+                  sMV ''TokenPA_for_B'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_4'', sN ''Rpa'', sMV ''Rb'',
+                          sMV ''Text6''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''5'' <| sMV ''B'', sAV ''A'', sMV ''Text9'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_5'', sMV ''Rb'', sN ''Rpa'',
+                          sMV ''Text8''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_6_bdkey_B
+where "isoiec_9798_2_6_bdkey_B =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
+  , Recv ''4'' <| sAV ''A'', sAV ''B'', sMV ''Text7'', sMV ''P'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_3_2'', sN ''Rb'', sMV ''Kab'',
+                          sAV ''A'', sAV ''B'', sMV ''Text3''
+                       |>
+                       ( sKbd (AVar ''B'') (MVar ''P'') ),
+                  PEnc <| sC ''isoiec_9798_2_6_enc_4'', sMV ''Rpa'', sN ''Rb'',
+                          sMV ''Text6''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
+  , Send ''5'' <| sAV ''B'', sAV ''A'', sMV ''Text9'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_5'', sN ''Rb'', sMV ''Rpa'',
+                          sMV ''Text8''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_6_bdkey_P
+where "isoiec_9798_2_6_bdkey_P =
+  [ Recv ''2'' <| sMV ''A'', sAV ''P'', sMV ''Ra'', sMV ''Rb'', sMV ''B'',
+                  sMV ''Text2''
+               |>
+  , Recv ''text_3'' <| sMV ''Text3'', sMV ''Text4'', sMV ''Text5'' |>
+  , Send ''3'' <| sAV ''P'', sMV ''A'', sMV ''Text5'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_3_1'', sMV ''Ra'', sN ''Kab'',
+                          sMV ''A'', sMV ''B'', sMV ''Text4''
+                       |>
+                       ( sKbd (MVar ''A'') (AVar ''P'') ),
+                  PEnc <| sC ''isoiec_9798_2_6_enc_3_2'', sMV ''Rb'', sN ''Kab'',
+                          sMV ''A'', sMV ''B'', sMV ''Text3''
+                       |>
+                       ( sKbd (MVar ''B'') (AVar ''P'') )
+               |>
+  ]"
+
+role isoiec_9798_2_5_special_TTP_bdkey_A
+where "isoiec_9798_2_5_special_TTP_bdkey_A =
+  [ Send ''leak_A'' <| sN ''TVPa'', sN ''TNa'' |>
+  , Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''A'', sAV ''P'', sN ''TVPa'', sAV ''B'',
+                  sMV ''Text1''
+               |>
+  , Recv ''2'' <| sAV ''P'', sAV ''A'', sMV ''Text4'',
+                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_2_1'', sN ''TVPa'',
+                          sMV ''Kab'', sAV ''B'', sMV ''Text3''
+                       |>
+                       ( sKbd (AVar ''A'') (AVar ''P'') ),
+                  sMV ''TokenPA_for_B''
+               |>
+  , Recv ''text_3'' <| sMV ''Text5'', sMV ''Text6'' |>
+  , Send ''3'' <| sAV ''A'', sAV ''B'', sMV ''Text6'', sAV ''P'',
+                  sMV ''TokenPA_for_B'',
+                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_3'', sN ''TNa'', sAV ''B'',
+                          sMV ''Text5''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''4'' <| sAV ''B'', sAV ''A'', sMV ''Text8'',
+                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_4'', sMV ''TNb'', sAV ''A'',
+                          sMV ''Text7''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_5_special_TTP_bdkey_B
+where "isoiec_9798_2_5_special_TTP_bdkey_B =
+  [ Send ''leak_B'' ( sN ''TNb'' )
+  , Recv ''3'' <| sMV ''A'', sAV ''B'', sMV ''Text6'', sMV ''P'',
+                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_2_2'', sMV ''TNp'',
+                          sMV ''Kab'', sMV ''A'', sMV ''Text2''
+                       |>
+                       ( sKbd (AVar ''B'') (MVar ''P'') ),
+                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_3'', sMV ''TNa'', sAV ''B'',
+                          sMV ''Text5''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''text_4'' <| sMV ''Text7'', sMV ''Text8'' |>
+  , Send ''4'' <| sAV ''B'', sMV ''A'', sMV ''Text8'',
+                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_4'', sN ''TNb'', sMV ''A'',
+                          sMV ''Text7''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_5_special_TTP_bdkey_P
+where "isoiec_9798_2_5_special_TTP_bdkey_P =
+  [ Send ''leak_P'' ( sN ''TNp'' )
+  , Recv ''1'' <| sMV ''A'', sAV ''P'', sMV ''TVPa'', sMV ''B'',
+                  sMV ''Text1''
+               |>
+  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'', sMV ''Text4'' |>
+  , Send ''2'' <| sAV ''P'', sMV ''A'', sMV ''Text4'',
+                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_2_1'', sMV ''TVPa'',
+                          sN ''Kab'', sMV ''B'', sMV ''Text3''
+                       |>
+                       ( sKbd (MVar ''A'') (AVar ''P'') ),
+                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_2_2'', sN ''TNp'',
+                          sN ''Kab'', sMV ''A'', sMV ''Text2''
+                       |>
+                       ( sKbd (MVar ''B'') (AVar ''P'') )
+               |>
+  ]"
+
+role isoiec_9798_2_6_special_TTP_bdkey_A
+where "isoiec_9798_2_6_special_TTP_bdkey_A =
+  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
+  , Recv ''text_2'' ( sMV ''Text2'' )
+  , Send ''2'' <| sAV ''A'', sAV ''P'', sN ''Ra'', sMV ''Rb'', sMV ''B'',
+                  sMV ''Text2''
+               |>
+  , Recv ''3'' <| sAV ''P'', sAV ''A'', sMV ''Text5'',
+                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_3_1'', sN ''Ra'',
+                          sMV ''Kab'', sMV ''B'', sMV ''Text4''
+                       |>
+                       ( sKbd (AVar ''A'') (AVar ''P'') ),
+                  sMV ''TokenPA_for_B''
+               |>
+  , Recv ''text_4'' <| sMV ''Text6'', sMV ''Text7'' |>
+  , Send ''4'' <| sAV ''A'', sMV ''B'', sMV ''Text7'', sAV ''P'',
+                  sMV ''TokenPA_for_B'',
+                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_4'', sN ''Rpa'', sMV ''Rb'',
+                          sMV ''Text6''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''5'' <| sMV ''B'', sAV ''A'', sMV ''Text9'',
+                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_5'', sMV ''Rb'', sN ''Rpa'',
+                          sMV ''Text8''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_6_special_TTP_bdkey_B
+where "isoiec_9798_2_6_special_TTP_bdkey_B =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
+  , Recv ''4'' <| sAV ''A'', sAV ''B'', sMV ''Text7'', sMV ''P'',
+                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_3_2'', sN ''Rb'',
+                          sMV ''Kab'', sAV ''A'', sMV ''Text3''
+                       |>
+                       ( sKbd (AVar ''B'') (MVar ''P'') ),
+                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_4'', sMV ''Rpa'', sN ''Rb'',
+                          sMV ''Text6''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
+  , Send ''5'' <| sAV ''B'', sAV ''A'', sMV ''Text9'',
+                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_5'', sN ''Rb'', sMV ''Rpa'',
+                          sMV ''Text8''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_6_special_TTP_bdkey_P
+where "isoiec_9798_2_6_special_TTP_bdkey_P =
+  [ Recv ''2'' <| sMV ''A'', sAV ''P'', sMV ''Ra'', sMV ''Rb'', sMV ''B'',
+                  sMV ''Text2''
+               |>
+  , Recv ''text_3'' <| sMV ''Text3'', sMV ''Text4'', sMV ''Text5'' |>
+  , Send ''3'' <| sAV ''P'', sMV ''A'', sMV ''Text5'',
+                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_3_1'', sMV ''Ra'',
+                          sN ''Kab'', sMV ''B'', sMV ''Text4''
+                       |>
+                       ( sKbd (MVar ''A'') (AVar ''P'') ),
+                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_3_2'', sMV ''Rb'',
+                          sN ''Kab'', sMV ''A'', sMV ''Text3''
+                       |>
+                       ( sKbd (MVar ''B'') (AVar ''P'') )
+               |>
+  ]"
+
+protocol isoiec_9798_2_bdkey
+where "isoiec_9798_2_bdkey =
+{ isoiec_9798_2_1_bdkey_A, isoiec_9798_2_1_bdkey_B,
+  isoiec_9798_2_2_bdkey_A, isoiec_9798_2_2_bdkey_B,
+  isoiec_9798_2_3_bdkey_A, isoiec_9798_2_3_bdkey_B,
+  isoiec_9798_2_4_bdkey_A, isoiec_9798_2_4_bdkey_B,
+  isoiec_9798_2_5_bdkey_A, isoiec_9798_2_5_bdkey_B,
+  isoiec_9798_2_5_bdkey_P, isoiec_9798_2_6_bdkey_A,
+  isoiec_9798_2_6_bdkey_B, isoiec_9798_2_6_bdkey_P,
+  isoiec_9798_2_5_special_TTP_bdkey_A, isoiec_9798_2_5_special_TTP_bdkey_B,
+  isoiec_9798_2_5_special_TTP_bdkey_P, isoiec_9798_2_6_special_TTP_bdkey_A,
+  isoiec_9798_2_6_special_TTP_bdkey_B, isoiec_9798_2_6_special_TTP_bdkey_P
+}"
+
+locale restricted_isoiec_9798_2_bdkey_state = isoiec_9798_2_bdkey_state +
+  assumes isoiec_9798_2_5_special_TTP_bdkey_different_actors_A_P:
+    "!! tid0 tid1.
+       [| roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_A;
+         roleMap r tid1 = Some isoiec_9798_2_5_special_TTP_bdkey_P;
+         s(AV ''P'' tid1) = s(AV ''A'' tid0)
+       |] ==> False"
+  assumes isoiec_9798_2_6_special_TTP_bdkey_different_actors_A_P:
+    "!! tid0 tid1.
+       [| roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_A;
+         roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_P;
+         s(AV ''P'' tid1) = s(AV ''A'' tid0)
+       |] ==> False"
+  assumes isoiec_9798_2_6_special_TTP_bdkey_different_actors_B_P:
+    "!! tid0 tid1.
+       [| roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_B;
+         roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_P;
+         s(AV ''P'' tid1) = s(AV ''B'' tid0)
+       |] ==> False"
+
+type_invariant isoiec_9798_2_bdkey_composed_typing for isoiec_9798_2_bdkey
+where "isoiec_9798_2_bdkey_composed_typing = mk_typing
+  [ ((isoiec_9798_2_1_bdkey_B, ''A''), (KnownT isoiec_9798_2_1_bdkey_B_1))
+  , ((isoiec_9798_2_3_bdkey_B, ''A''), (KnownT isoiec_9798_2_3_bdkey_B_1))
+  , ((isoiec_9798_2_5_bdkey_B, ''A''), (KnownT isoiec_9798_2_5_bdkey_B_3))
+  , ((isoiec_9798_2_5_bdkey_P, ''A''), (KnownT isoiec_9798_2_5_bdkey_P_1))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''A''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''A''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_1))
+  , ((isoiec_9798_2_6_bdkey_P, ''A''), (KnownT isoiec_9798_2_6_bdkey_P_2))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''A''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_2))
+  , ((isoiec_9798_2_2_bdkey_A, ''B''), (KnownT isoiec_9798_2_2_bdkey_A_1))
+  , ((isoiec_9798_2_4_bdkey_A, ''B''), (KnownT isoiec_9798_2_4_bdkey_A_1))
+  , ((isoiec_9798_2_5_bdkey_P, ''B''), (KnownT isoiec_9798_2_5_bdkey_P_1))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''B''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_1))
+  , ((isoiec_9798_2_6_bdkey_A, ''B''), (KnownT isoiec_9798_2_6_bdkey_A_1))
+  , ((isoiec_9798_2_6_bdkey_P, ''B''), (KnownT isoiec_9798_2_6_bdkey_P_2))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''B''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_1))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''B''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_2))
+  , ((isoiec_9798_2_5_bdkey_A, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_5_bdkey_A_2) (NonceT isoiec_9798_2_5_bdkey_P ''Kab'')))
+  , ((isoiec_9798_2_5_bdkey_B, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_5_bdkey_B_3) (NonceT isoiec_9798_2_5_bdkey_P ''Kab'')))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_2) (NonceT isoiec_9798_2_5_special_TTP_bdkey_P ''Kab'')))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3) (NonceT isoiec_9798_2_5_special_TTP_bdkey_P ''Kab'')))
+  , ((isoiec_9798_2_6_bdkey_A, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_6_bdkey_A_3) (NonceT isoiec_9798_2_6_bdkey_P ''Kab'')))
+  , ((isoiec_9798_2_6_bdkey_B, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_6_bdkey_B_4) (NonceT isoiec_9798_2_6_bdkey_P ''Kab'')))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_3) (NonceT isoiec_9798_2_6_special_TTP_bdkey_P ''Kab'')))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4) (NonceT isoiec_9798_2_6_special_TTP_bdkey_P ''Kab'')))
+  , ((isoiec_9798_2_5_bdkey_B, ''P''), (KnownT isoiec_9798_2_5_bdkey_B_3))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''P''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3))
+  , ((isoiec_9798_2_6_bdkey_B, ''P''), (KnownT isoiec_9798_2_6_bdkey_B_4))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''P''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4))
+  , ((isoiec_9798_2_4_bdkey_B, ''RA''),
+     (SumT (KnownT isoiec_9798_2_4_bdkey_B_2) (NonceT isoiec_9798_2_4_bdkey_A ''RA'')))
+  , ((isoiec_9798_2_2_bdkey_A, ''RB''), (KnownT isoiec_9798_2_2_bdkey_A_1))
+  , ((isoiec_9798_2_4_bdkey_A, ''RB''), (KnownT isoiec_9798_2_4_bdkey_A_1))
+  , ((isoiec_9798_2_6_bdkey_P, ''Ra''), (KnownT isoiec_9798_2_6_bdkey_P_2))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Ra''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_2))
+  , ((isoiec_9798_2_6_bdkey_A, ''Rb''), (KnownT isoiec_9798_2_6_bdkey_A_1))
+  , ((isoiec_9798_2_6_bdkey_P, ''Rb''), (KnownT isoiec_9798_2_6_bdkey_P_2))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Rb''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_1))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Rb''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_2))
+  , ((isoiec_9798_2_6_bdkey_B, ''Rpa''),
+     (SumT (KnownT isoiec_9798_2_6_bdkey_B_4) (NonceT isoiec_9798_2_6_bdkey_A ''Rpa'')))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Rpa''),
+     (SumT (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4) (NonceT isoiec_9798_2_6_special_TTP_bdkey_A ''Rpa'')))
+  , ((isoiec_9798_2_1_bdkey_B, ''TNA''),
+     (SumT (KnownT isoiec_9798_2_1_bdkey_B_1) (NonceT isoiec_9798_2_1_bdkey_A ''TNA'')))
+  , ((isoiec_9798_2_3_bdkey_B, ''TNA''),
+     (SumT (KnownT isoiec_9798_2_3_bdkey_B_1) (NonceT isoiec_9798_2_3_bdkey_A ''TNA'')))
+  , ((isoiec_9798_2_3_bdkey_A, ''TNB''),
+     (SumT (KnownT isoiec_9798_2_3_bdkey_A_2) (NonceT isoiec_9798_2_3_bdkey_B ''TNB'')))
+  , ((isoiec_9798_2_5_bdkey_B, ''TNa''),
+     (SumT (KnownT isoiec_9798_2_5_bdkey_B_3) (NonceT isoiec_9798_2_5_bdkey_A ''TNa'')))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''TNa''),
+     (SumT (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3) (NonceT isoiec_9798_2_5_special_TTP_bdkey_A ''TNa'')))
+  , ((isoiec_9798_2_5_bdkey_A, ''TNb''),
+     (SumT (KnownT isoiec_9798_2_5_bdkey_A_4) (NonceT isoiec_9798_2_5_bdkey_B ''TNb'')))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''TNb''),
+     (SumT (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_4) (NonceT isoiec_9798_2_5_special_TTP_bdkey_B ''TNb'')))
+  , ((isoiec_9798_2_5_bdkey_B, ''TNp''),
+     (SumT (KnownT isoiec_9798_2_5_bdkey_B_3) (NonceT isoiec_9798_2_5_bdkey_P ''TNp'')))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''TNp''),
+     (SumT (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3) (NonceT isoiec_9798_2_5_special_TTP_bdkey_P ''TNp'')))
+  , ((isoiec_9798_2_5_bdkey_P, ''TVPa''),
+     (KnownT isoiec_9798_2_5_bdkey_P_1))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''TVPa''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_1))
+  , ((isoiec_9798_2_1_bdkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_1_bdkey_A_text_1))
+  , ((isoiec_9798_2_1_bdkey_B, ''Text1''),
+     (KnownT isoiec_9798_2_1_bdkey_B_1))
+  , ((isoiec_9798_2_2_bdkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_2_bdkey_A_1))
+  , ((isoiec_9798_2_2_bdkey_B, ''Text1''),
+     (KnownT isoiec_9798_2_2_bdkey_B_text_1))
+  , ((isoiec_9798_2_3_bdkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_3_bdkey_A_text_1))
+  , ((isoiec_9798_2_3_bdkey_B, ''Text1''),
+     (KnownT isoiec_9798_2_3_bdkey_B_1))
+  , ((isoiec_9798_2_4_bdkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_4_bdkey_A_1))
+  , ((isoiec_9798_2_4_bdkey_B, ''Text1''),
+     (KnownT isoiec_9798_2_4_bdkey_B_text_1))
+  , ((isoiec_9798_2_5_bdkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_5_bdkey_A_text_1))
+  , ((isoiec_9798_2_5_bdkey_P, ''Text1''),
+     (KnownT isoiec_9798_2_5_bdkey_P_1))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_text_1))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''Text1''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_1))
+  , ((isoiec_9798_2_6_bdkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_6_bdkey_A_1))
+  , ((isoiec_9798_2_6_bdkey_B, ''Text1''),
+     (KnownT isoiec_9798_2_6_bdkey_B_text_1))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_1))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text1''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_text_1))
+  , ((isoiec_9798_2_1_bdkey_A, ''Text2''),
+     (KnownT isoiec_9798_2_1_bdkey_A_text_1))
+  , ((isoiec_9798_2_1_bdkey_B, ''Text2''),
+     (KnownT isoiec_9798_2_1_bdkey_B_1))
+  , ((isoiec_9798_2_2_bdkey_A, ''Text2''),
+     (KnownT isoiec_9798_2_2_bdkey_A_text_2))
+  , ((isoiec_9798_2_2_bdkey_B, ''Text2''),
+     (KnownT isoiec_9798_2_2_bdkey_B_2))
+  , ((isoiec_9798_2_3_bdkey_A, ''Text2''),
+     (KnownT isoiec_9798_2_3_bdkey_A_text_1))
+  , ((isoiec_9798_2_3_bdkey_B, ''Text2''),
+     (KnownT isoiec_9798_2_3_bdkey_B_1))
+  , ((isoiec_9798_2_4_bdkey_A, ''Text2''),
+     (KnownT isoiec_9798_2_4_bdkey_A_text_2))
+  , ((isoiec_9798_2_4_bdkey_B, ''Text2''),
+     (KnownT isoiec_9798_2_4_bdkey_B_2))
+  , ((isoiec_9798_2_5_bdkey_B, ''Text2''),
+     (KnownT isoiec_9798_2_5_bdkey_B_3))
+  , ((isoiec_9798_2_5_bdkey_P, ''Text2''),
+     (KnownT isoiec_9798_2_5_bdkey_P_text_2))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Text2''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''Text2''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_text_2))
+  , ((isoiec_9798_2_6_bdkey_A, ''Text2''),
+     (KnownT isoiec_9798_2_6_bdkey_A_text_2))
+  , ((isoiec_9798_2_6_bdkey_P, ''Text2''),
+     (KnownT isoiec_9798_2_6_bdkey_P_2))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text2''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_text_2))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Text2''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_2))
+  , ((isoiec_9798_2_2_bdkey_A, ''Text3''),
+     (KnownT isoiec_9798_2_2_bdkey_A_text_2))
+  , ((isoiec_9798_2_2_bdkey_B, ''Text3''),
+     (KnownT isoiec_9798_2_2_bdkey_B_2))
+  , ((isoiec_9798_2_3_bdkey_A, ''Text3''),
+     (KnownT isoiec_9798_2_3_bdkey_A_2))
+  , ((isoiec_9798_2_3_bdkey_B, ''Text3''),
+     (KnownT isoiec_9798_2_3_bdkey_B_text_2))
+  , ((isoiec_9798_2_4_bdkey_A, ''Text3''),
+     (KnownT isoiec_9798_2_4_bdkey_A_text_2))
+  , ((isoiec_9798_2_4_bdkey_B, ''Text3''),
+     (KnownT isoiec_9798_2_4_bdkey_B_2))
+  , ((isoiec_9798_2_5_bdkey_A, ''Text3''),
+     (KnownT isoiec_9798_2_5_bdkey_A_2))
+  , ((isoiec_9798_2_5_bdkey_P, ''Text3''),
+     (KnownT isoiec_9798_2_5_bdkey_P_text_2))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text3''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_2))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''Text3''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_text_2))
+  , ((isoiec_9798_2_6_bdkey_B, ''Text3''),
+     (KnownT isoiec_9798_2_6_bdkey_B_4))
+  , ((isoiec_9798_2_6_bdkey_P, ''Text3''),
+     (KnownT isoiec_9798_2_6_bdkey_P_text_3))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text3''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Text3''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_text_3))
+  , ((isoiec_9798_2_3_bdkey_A, ''Text4''),
+     (KnownT isoiec_9798_2_3_bdkey_A_2))
+  , ((isoiec_9798_2_3_bdkey_B, ''Text4''),
+     (KnownT isoiec_9798_2_3_bdkey_B_text_2))
+  , ((isoiec_9798_2_4_bdkey_A, ''Text4''),
+     (KnownT isoiec_9798_2_4_bdkey_A_3))
+  , ((isoiec_9798_2_4_bdkey_B, ''Text4''),
+     (KnownT isoiec_9798_2_4_bdkey_B_text_3))
+  , ((isoiec_9798_2_5_bdkey_A, ''Text4''),
+     (KnownT isoiec_9798_2_5_bdkey_A_2))
+  , ((isoiec_9798_2_5_bdkey_P, ''Text4''),
+     (KnownT isoiec_9798_2_5_bdkey_P_text_2))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text4''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_2))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''Text4''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_text_2))
+  , ((isoiec_9798_2_6_bdkey_A, ''Text4''),
+     (KnownT isoiec_9798_2_6_bdkey_A_3))
+  , ((isoiec_9798_2_6_bdkey_P, ''Text4''),
+     (KnownT isoiec_9798_2_6_bdkey_P_text_3))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text4''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_3))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Text4''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_text_3))
+  , ((isoiec_9798_2_4_bdkey_A, ''Text5''),
+     (KnownT isoiec_9798_2_4_bdkey_A_3))
+  , ((isoiec_9798_2_4_bdkey_B, ''Text5''),
+     (KnownT isoiec_9798_2_4_bdkey_B_text_3))
+  , ((isoiec_9798_2_5_bdkey_A, ''Text5''),
+     (KnownT isoiec_9798_2_5_bdkey_A_text_3))
+  , ((isoiec_9798_2_5_bdkey_B, ''Text5''),
+     (KnownT isoiec_9798_2_5_bdkey_B_3))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text5''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_text_3))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Text5''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3))
+  , ((isoiec_9798_2_6_bdkey_A, ''Text5''),
+     (KnownT isoiec_9798_2_6_bdkey_A_3))
+  , ((isoiec_9798_2_6_bdkey_P, ''Text5''),
+     (KnownT isoiec_9798_2_6_bdkey_P_text_3))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text5''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_3))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Text5''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_text_3))
+  , ((isoiec_9798_2_5_bdkey_A, ''Text6''),
+     (KnownT isoiec_9798_2_5_bdkey_A_text_3))
+  , ((isoiec_9798_2_5_bdkey_B, ''Text6''),
+     (KnownT isoiec_9798_2_5_bdkey_B_3))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text6''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_text_3))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Text6''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3))
+  , ((isoiec_9798_2_6_bdkey_A, ''Text6''),
+     (KnownT isoiec_9798_2_6_bdkey_A_text_4))
+  , ((isoiec_9798_2_6_bdkey_B, ''Text6''),
+     (KnownT isoiec_9798_2_6_bdkey_B_4))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text6''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_text_4))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text6''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4))
+  , ((isoiec_9798_2_5_bdkey_A, ''Text7''),
+     (KnownT isoiec_9798_2_5_bdkey_A_4))
+  , ((isoiec_9798_2_5_bdkey_B, ''Text7''),
+     (KnownT isoiec_9798_2_5_bdkey_B_text_4))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text7''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_4))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Text7''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_text_4))
+  , ((isoiec_9798_2_6_bdkey_A, ''Text7''),
+     (KnownT isoiec_9798_2_6_bdkey_A_text_4))
+  , ((isoiec_9798_2_6_bdkey_B, ''Text7''),
+     (KnownT isoiec_9798_2_6_bdkey_B_4))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text7''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_text_4))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text7''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4))
+  , ((isoiec_9798_2_5_bdkey_A, ''Text8''),
+     (KnownT isoiec_9798_2_5_bdkey_A_4))
+  , ((isoiec_9798_2_5_bdkey_B, ''Text8''),
+     (KnownT isoiec_9798_2_5_bdkey_B_text_4))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text8''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_4))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Text8''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_text_4))
+  , ((isoiec_9798_2_6_bdkey_A, ''Text8''),
+     (KnownT isoiec_9798_2_6_bdkey_A_5))
+  , ((isoiec_9798_2_6_bdkey_B, ''Text8''),
+     (KnownT isoiec_9798_2_6_bdkey_B_text_5))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text8''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_5))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text8''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_text_5))
+  , ((isoiec_9798_2_6_bdkey_A, ''Text9''),
+     (KnownT isoiec_9798_2_6_bdkey_A_5))
+  , ((isoiec_9798_2_6_bdkey_B, ''Text9''),
+     (KnownT isoiec_9798_2_6_bdkey_B_text_5))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text9''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_5))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text9''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_text_5))
+  , ((isoiec_9798_2_5_bdkey_A, ''TokenPA_for_B''),
+     (KnownT isoiec_9798_2_5_bdkey_A_2))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''TokenPA_for_B''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_2))
+  , ((isoiec_9798_2_6_bdkey_A, ''TokenPA_for_B''),
+     (KnownT isoiec_9798_2_6_bdkey_A_3))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''TokenPA_for_B''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_3))
+  ]"
+
+sublocale isoiec_9798_2_bdkey_state < isoiec_9798_2_bdkey_composed_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_2_bdkey_composed_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_2_bdkey_composed_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_2_1_bdkey_A_text_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_1_bdkey_A_text_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_1_bdkey_B_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_1_bdkey_B_1_TNA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
+               s(AV ''B'' tid0), s(MV ''Text1'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_1_bdkey_B_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
+               s(AV ''B'' tid0), s(MV ''Text1'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_1_bdkey_B_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_2_bdkey_A_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_2_bdkey_A_1_RB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_2_bdkey_A_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_2_bdkey_A_text_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_2_bdkey_A_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_2_bdkey_B_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_2_enc_2'', LN ''RB'' tid0, s(AV ''B'' tid0),
+               s(MV ''Text2'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_2_bdkey_B_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_bdkey_A_text_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_bdkey_A_text_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_bdkey_A_2_TNB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
+               s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_3_bdkey_A_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
+               s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_3_bdkey_A_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_bdkey_B_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_bdkey_B_1_TNA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
+               s(AV ''B'' tid0), s(MV ''Text1'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_3_bdkey_B_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
+               s(AV ''B'' tid0), s(MV ''Text1'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_3_bdkey_B_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_bdkey_B_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_bdkey_B_text_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_bdkey_A_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_bdkey_A_1_RB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_bdkey_A_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_bdkey_A_text_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_bdkey_A_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_bdkey_A_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_4_enc_2'', s(MV ''RB'' tid0), LN ''RA'' tid0,
+               s(MV ''Text4'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_4_bdkey_A_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_bdkey_B_2_RA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
+               s(AV ''B'' tid0), s(MV ''Text2'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_4_bdkey_B_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
+               s(AV ''B'' tid0), s(MV ''Text2'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_4_bdkey_B_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_bdkey_B_text_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_bdkey_B_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_A_2_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
+               s(MV ''Text3'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_bdkey_A_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
+               s(MV ''Text3'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_bdkey_A_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_A_2_TokenPA_for_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_A_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_A_text_3_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_A_4_TNb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
+               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_bdkey_A_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
+               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_bdkey_A_4_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_B_3_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_B_3_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
+               s(MV ''Text2'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_bdkey_B_3_P t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_B_3_TNa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
+               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_bdkey_B_3_TNp t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
+               s(MV ''Text2'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_bdkey_B_3_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
+               s(MV ''Text2'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_bdkey_B_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
+               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_bdkey_B_3_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_B_text_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_B_text_4_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_P_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_P_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_P_1_TVPa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_P_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_P_text_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_P_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_P_text_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_A_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_A_1_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_A_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_A_3_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
+               s(MV ''Text4'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_bdkey_A_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
+               s(MV ''Text4'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_bdkey_A_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_A_3_TokenPA_for_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_A_text_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_A_text_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_A_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_5'', s(MV ''Rb'' tid0), LN ''Rpa'' tid0,
+               s(MV ''Text8'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_bdkey_A_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_B_4_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
+               s(MV ''Text3'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_bdkey_B_4_P t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_B_4_Rpa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
+               s(MV ''Text6'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_bdkey_B_4_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
+               s(MV ''Text3'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_bdkey_B_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
+               s(MV ''Text6'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_bdkey_B_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_B_text_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_B_text_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_P_2_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_P_2_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_P_2_Ra t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_P_2_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_P_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_P_text_3_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_P_text_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_P_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_A_2_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_A_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_A_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_A_2_TokenPA_for_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_A_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_A_text_3_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_A_4_TNb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_4'', s(MV ''TNb'' tid0),
+               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_A_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_4'', s(MV ''TNb'' tid0),
+               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_A_4_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
+               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_P t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_TNa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_3'', s(MV ''TNa'' tid0),
+               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_TNp t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
+               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
+               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_3'', s(MV ''TNa'' tid0),
+               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_B_text_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_B_text_4_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_P_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_P_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_P_1_TVPa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_P_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_P_text_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_P_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_P_text_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_A_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_A_1_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_A_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_A_3_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid0,
+               s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_A_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid0,
+               s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_A_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_A_3_TokenPA_for_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_A_text_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_A_text_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_A_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_5'', s(MV ''Rb'' tid0),
+               LN ''Rpa'' tid0, s(MV ''Text8'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_A_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_P t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_Rpa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_4'', s(MV ''Rpa'' tid0),
+               LN ''Rb'' tid0, s(MV ''Text6'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_4'', s(MV ''Rpa'' tid0),
+               LN ''Rb'' tid0, s(MV ''Text6'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_B_text_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_B_text_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_P_2_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_P_2_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_P_2_Ra t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_P_2_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_P_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_P_text_3_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_P_text_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_P_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_2_bdkey_composed_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_2_bdkey_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_1_bdkey_B_non_injective_agreement:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_1_bdkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_1_bdkey_B_1 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_1_bdkey_A &
+        ( tid1, isoiec_9798_2_1_bdkey_A_1 ) : steps t &
+        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
+           s(MV ''Text1'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
+                s(MV ''Text1'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
+                          s(AV ''B'' tid0), s(MV ''Text1'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_1_bdkey_A_1_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_2_bdkey_B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_2_bdkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_2_bdkey_B_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_2_bdkey_A &
+          ( tid1, isoiec_9798_2_2_bdkey_A_2 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(MV ''RB'' tid1),
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''RB'' tid0,
+                  s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_2_enc_2'', LN ''RB'' tid0, s(AV ''B'' tid0),
+                              s(MV ''Text2'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_2_bdkey_A_2_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_3_bdkey_A_non_injective_agreement:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_3_bdkey_A"
+    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_3_bdkey_A_2 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_3_bdkey_B &
+        ( tid1, isoiec_9798_2_3_bdkey_B_2 ) : steps t &
+        {| s(MV ''A'' tid1), s(AV ''B'' tid1), LN ''TNB'' tid1,
+           s(MV ''Text3'' tid1)
+        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNB'' tid0),
+                s(MV ''Text3'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
+                          s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_3_bdkey_B_2_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_3_bdkey_B_non_injective_agreement:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_3_bdkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_3_bdkey_B_1 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_3_bdkey_A &
+        ( tid1, isoiec_9798_2_3_bdkey_A_1 ) : steps t &
+        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
+           s(MV ''Text1'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
+                s(MV ''Text1'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
+                          s(AV ''B'' tid0), s(MV ''Text1'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_3_bdkey_A_1_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_4_bdkey_A_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_4_bdkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_4_bdkey_A_3 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_4_bdkey_B &
+          ( tid1, isoiec_9798_2_4_bdkey_B_3 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''RA'' tid1), LN ''RB'' tid1,
+             s(MV ''Text2'' tid1), s(MV ''Text4'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''RA'' tid0,
+                  s(MV ''RB'' tid0), s(MV ''Text2'' tid0), s(MV ''Text4'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_4_enc_2'', s(MV ''RB'' tid0), LN ''RA'' tid0,
+                              s(MV ''Text4'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_4_bdkey_B_3_enc tid1) note_unified facts = this facts
+        hence "Kbd ( s(AV ''A'' tid1) )
+                   ( s(AV ''B'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) )"
+          by simp note facts = this facts
+        thus ?thesis proof(cases rule: Kbd_cases)
+          case noswap note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_2_4_enc_1'', LN ''RA'' tid0, LN ''RB'' tid1,
+                                  s(AV ''B'' tid1), s(MV ''Text2'' tid1)
+                               |}
+                               ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid1) ) ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest!: ltk_secrecy)
+          next
+            case (isoiec_9798_2_4_bdkey_A_2_enc tid2) note_unified facts = this facts
+            thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+          qed (insert facts, fastforce+)?
+        next
+          case swapped note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_2_4_enc_1'', LN ''RA'' tid0, LN ''RB'' tid1,
+                                  s(AV ''A'' tid0), s(MV ''Text2'' tid1)
+                               |}
+                               ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''A'' tid1) ) ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest!: ltk_secrecy)
+          next
+            case (isoiec_9798_2_4_bdkey_A_2_enc tid2) note_unified facts = this facts
+            thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+          qed (insert facts, fastforce+)?
+        qed (fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_4_bdkey_B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_4_bdkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_4_bdkey_B_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_4_bdkey_A &
+          ( tid1, isoiec_9798_2_4_bdkey_A_2 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''RA'' tid1, s(MV ''RB'' tid1),
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''RA'' tid0),
+                  LN ''RB'' tid0, s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
+                              s(AV ''B'' tid0), s(MV ''Text2'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_4_bdkey_A_2_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_bdkey_P_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_P"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
+    "LN ''Kab'' tid0 : knows t"
+  shows "False"
+using facts proof(sources! " LN ''Kab'' tid0 ")
+  case isoiec_9798_2_5_bdkey_P_2_Kab note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+next
+  case isoiec_9798_2_5_bdkey_P_2_Kab_1 note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+qed (insert facts, fastforce+)?
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_bdkey_A_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_A"
+    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_bdkey_A_2 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
+                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
+                          s(MV ''Text3'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_5_bdkey_P_2_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce dest: isoiec_9798_2_5_bdkey_P_secret_Kab intro: event_predOrdI)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_bdkey_B_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_bdkey_B_3 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
+                          s(MV ''Text2'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_5_bdkey_P_2_enc_1 tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce dest: isoiec_9798_2_5_bdkey_P_secret_Kab intro: event_predOrdI)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_bdkey_A_injective_agreement_B:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_5_bdkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_5_bdkey_A_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_5_bdkey_B &
+          ( tid1, isoiec_9798_2_5_bdkey_B_4 ) : steps t &
+          {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
+             s(MV ''Kab'' tid1), s(MV ''TNa'' tid1), s(MV ''Text5'' tid1),
+             LN ''TNb'' tid1, s(MV ''Text7'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
+                  s(MV ''Kab'' tid0), LN ''TNa'' tid0, s(MV ''Text5'' tid0),
+                  s(MV ''TNb'' tid0), s(MV ''Text7'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
+                              s(MV ''Text3'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_5_bdkey_P_2_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
+                                s(AV ''A'' tid0), s(MV ''Text7'' tid0)
+                             |}
+                             ( LN ''Kab'' tid1 ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest: isoiec_9798_2_5_bdkey_P_secret_Kab intro: event_predOrdI)
+        next
+          case (isoiec_9798_2_5_bdkey_B_4_enc tid2) note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid2),
+                                  LN ''Kab'' tid1, s(AV ''A'' tid0), s(AV ''B'' tid2), s(MV ''Text2'' tid2)
+                               |}
+                               ( Kbd ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) ) ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest: isoiec_9798_2_5_bdkey_P_secret_Kab intro: event_predOrdI)
+          next
+            case (isoiec_9798_2_5_bdkey_P_2_enc_1 tid3) note_unified facts = this facts
+            thus ?thesis proof(sources! "
+                             Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid2),
+                                    s(AV ''B'' tid0), s(MV ''Text5'' tid2)
+                                 |}
+                                 ( LN ''Kab'' tid1 ) ")
+              case fake note_unified facts = this facts
+              thus ?thesis by (fastforce dest: isoiec_9798_2_5_bdkey_P_secret_Kab intro: event_predOrdI)
+            next
+              case (isoiec_9798_2_5_bdkey_A_3_enc tid3) note_unified facts = this facts
+              thus ?thesis proof(sources! "
+                               Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid3, LN ''Kab'' tid1,
+                                      s(AV ''A'' tid3), s(AV ''B'' tid0), s(MV ''Text3'' tid3)
+                                   |}
+                                   ( Kbd ( s(AV ''A'' tid3) ) ( s(AV ''P'' tid3) ) ) ")
+                case fake note_unified facts = this facts
+                thus ?thesis by (fastforce dest: isoiec_9798_2_5_bdkey_P_secret_Kab intro: event_predOrdI)
+              next
+                case (isoiec_9798_2_5_bdkey_P_2_enc tid4) note_unified facts = this facts
+                thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+              qed (insert facts, fastforce+)?
+            qed (insert facts, fastforce+)?
+          qed (insert facts, fastforce+)?
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_bdkey_B_non_injective_agreement_A:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_bdkey_B_3 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_5_bdkey_A &
+        ( tid1, isoiec_9798_2_5_bdkey_A_3 ) : steps t &
+        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(AV ''P'' tid1),
+           s(MV ''Kab'' tid1), LN ''TNa'' tid1, s(MV ''Text5'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                s(MV ''Kab'' tid0), s(MV ''TNa'' tid0), s(MV ''Text5'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
+                          s(MV ''Text2'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_5_bdkey_P_2_enc_1 tid1) note_unified facts = this facts
+    thus ?thesis proof(sources! "
+                     Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
+                            s(AV ''B'' tid0), s(MV ''Text5'' tid0)
+                         |}
+                         ( LN ''Kab'' tid1 ) ")
+      case fake note_unified facts = this facts
+      thus ?thesis by (fastforce dest: isoiec_9798_2_5_bdkey_P_secret_Kab intro: event_predOrdI)
+    next
+      case (isoiec_9798_2_5_bdkey_A_3_enc tid2) note_unified facts = this facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid2, LN ''Kab'' tid1,
+                              s(AV ''A'' tid2), s(AV ''B'' tid0), s(MV ''Text3'' tid2)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest: isoiec_9798_2_5_bdkey_P_secret_Kab intro: event_predOrdI)
+      next
+        case (isoiec_9798_2_5_bdkey_P_2_enc tid3) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed (insert facts, fastforce+)?
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_bdkey_A_injective_agreement_P:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_5_bdkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_5_bdkey_A_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_5_bdkey_P &
+          ( tid1, isoiec_9798_2_5_bdkey_P_2 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
+             s(MV ''TVPa'' tid1), s(MV ''Text3'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
+                  s(MV ''Kab'' tid0), LN ''TVPa'' tid0, s(MV ''Text3'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
+                              s(MV ''Text3'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_5_bdkey_P_2_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_bdkey_B_non_injective_agreement_P:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_bdkey_B_3 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_5_bdkey_P &
+        ( tid1, isoiec_9798_2_5_bdkey_P_2 ) : steps t &
+        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
+           LN ''TNp'' tid1, s(MV ''Text2'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                s(MV ''Kab'' tid0), s(MV ''TNp'' tid0), s(MV ''Text2'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
+                          s(MV ''Text2'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_5_bdkey_P_2_enc_1 tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_bdkey_P_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_6_bdkey_P"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
+    "LN ''Kab'' tid0 : knows t"
+  shows "False"
+using facts proof(sources! " LN ''Kab'' tid0 ")
+  case isoiec_9798_2_6_bdkey_P_3_Kab note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+next
+  case isoiec_9798_2_6_bdkey_P_3_Kab_1 note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+qed (insert facts, fastforce+)?
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_bdkey_A_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_6_bdkey_A"
+    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_6_bdkey_A_3 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
+                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
+                          s(MV ''Text4'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_6_bdkey_P_3_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce dest: isoiec_9798_2_6_bdkey_P_secret_Kab intro: event_predOrdI)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_bdkey_B_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_6_bdkey_B"
+    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_6_bdkey_B_4 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
+                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
+                          s(MV ''Text3'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_6_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce dest: isoiec_9798_2_6_bdkey_P_secret_Kab intro: event_predOrdI)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_bdkey_A_injective_agreement_B:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_bdkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_bdkey_A_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_bdkey_B &
+          ( tid1, isoiec_9798_2_6_bdkey_B_5 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
+             s(MV ''Kab'' tid1), s(MV ''Rpa'' tid1), LN ''Rb'' tid1,
+             s(MV ''Text6'' tid1), s(MV ''Text8'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
+                  s(MV ''Kab'' tid0), LN ''Rpa'' tid0, s(MV ''Rb'' tid0),
+                  s(MV ''Text6'' tid0), s(MV ''Text8'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
+                              s(MV ''Text4'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_bdkey_P_3_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_2_6_enc_5'', s(MV ''Rb'' tid0), LN ''Rpa'' tid0,
+                                s(MV ''Text8'' tid0)
+                             |}
+                             ( LN ''Kab'' tid1 ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest: isoiec_9798_2_6_bdkey_P_secret_Kab intro: event_predOrdI)
+        next
+          case (isoiec_9798_2_6_bdkey_B_5_enc tid2) note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid2, LN ''Kab'' tid1,
+                                  s(AV ''A'' tid2), s(AV ''B'' tid2), s(MV ''Text3'' tid2)
+                               |}
+                               ( Kbd ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) ) ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest: isoiec_9798_2_6_bdkey_P_secret_Kab intro: event_predOrdI)
+          next
+            case (isoiec_9798_2_6_bdkey_P_3_enc_1 tid3) note_unified facts = this facts
+            thus ?thesis proof(sources! "
+                             Enc {| LC ''isoiec_9798_2_6_enc_4'', LN ''Rpa'' tid0, LN ''Rb'' tid2,
+                                    s(MV ''Text6'' tid2)
+                                 |}
+                                 ( LN ''Kab'' tid1 ) ")
+              case fake note_unified facts = this facts
+              thus ?thesis by (fastforce dest: isoiec_9798_2_6_bdkey_P_secret_Kab intro: event_predOrdI)
+            next
+              case (isoiec_9798_2_6_bdkey_A_4_enc tid3) note_unified facts = this facts
+              thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+            qed (insert facts, fastforce+)?
+          qed (insert facts, fastforce+)?
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_bdkey_B_injective_agreement_A:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_bdkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(MV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_bdkey_B_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_bdkey_A &
+          ( tid1, isoiec_9798_2_6_bdkey_A_4 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
+             s(MV ''Kab'' tid1), LN ''Rpa'' tid1, s(MV ''Rb'' tid1),
+             s(MV ''Text6'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                  s(MV ''Kab'' tid0), s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
+                  s(MV ''Text6'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
+                              s(MV ''Text3'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
+                                s(MV ''Text6'' tid0)
+                             |}
+                             ( LN ''Kab'' tid1 ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest: isoiec_9798_2_6_bdkey_P_secret_Kab intro: event_predOrdI)
+        next
+          case (isoiec_9798_2_6_bdkey_A_4_enc tid2) note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid2, LN ''Kab'' tid1,
+                                  s(AV ''A'' tid2), s(MV ''B'' tid2), s(MV ''Text4'' tid2)
+                               |}
+                               ( Kbd ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest: isoiec_9798_2_6_bdkey_P_secret_Kab intro: event_predOrdI)
+          next
+            case (isoiec_9798_2_6_bdkey_P_3_enc tid3) note_unified facts = this facts
+            thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+          qed (insert facts, fastforce+)?
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_bdkey_A_injective_agreement_P:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_bdkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_bdkey_A_3 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_bdkey_P &
+          ( tid1, isoiec_9798_2_6_bdkey_P_3 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
+             s(MV ''Ra'' tid1), LN ''Kab'' tid1, s(MV ''Text4'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
+                  LN ''Ra'' tid0, s(MV ''Kab'' tid0), s(MV ''Text4'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
+                              s(MV ''Text4'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_bdkey_P_3_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_bdkey_B_injective_agreement_P:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_bdkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(MV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_bdkey_B_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_bdkey_P &
+          ( tid1, isoiec_9798_2_6_bdkey_P_3 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
+             s(MV ''Rb'' tid1), LN ''Kab'' tid1, s(MV ''Text3'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                  LN ''Rb'' tid0, s(MV ''Kab'' tid0), s(MV ''Text3'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
+                              s(MV ''Text3'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_special_TTP_bdkey_P_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_P"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
+    "LN ''Kab'' tid0 : knows t"
+  shows "False"
+using facts proof(sources! " LN ''Kab'' tid0 ")
+  case isoiec_9798_2_5_special_TTP_bdkey_P_2_Kab note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+next
+  case isoiec_9798_2_5_special_TTP_bdkey_P_2_Kab_1 note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+qed (insert facts, fastforce+)?
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_special_TTP_bdkey_A_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_A"
+    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_special_TTP_bdkey_A_2 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid0,
+                          s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid1) note_unified facts = this facts
+    hence "Kbd ( s(AV ''P'' tid1) )
+               ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
+      by simp note facts = this facts
+    thus ?thesis proof(cases rule: Kbd_cases)
+      case noswap note_unified facts = this facts
+      thus ?thesis by (fastforce dest: isoiec_9798_2_5_special_TTP_bdkey_different_actors_A_P intro: event_predOrdI)
+    next
+      case swapped note_unified facts = this facts
+      thus ?thesis by (fastforce dest: isoiec_9798_2_5_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
+    qed (fastforce+)?
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_special_TTP_bdkey_B_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_special_TTP_bdkey_B_3 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
+                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc_1 tid1) note_unified facts = this facts
+    hence "Kbd ( s(AV ''P'' tid1) )
+               ( s(MV ''B'' tid1) ) = Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) )"
+      by simp note facts = this facts
+    thus ?thesis proof(cases rule: Kbd_cases)
+      case noswap note_unified facts = this facts
+      thus ?thesis by (fastforce dest: isoiec_9798_2_5_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
+    next
+      case swapped note_unified facts = this facts
+      thus ?thesis by (fastforce dest: isoiec_9798_2_5_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
+    qed (fastforce+)?
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_special_TTP_bdkey_A_injective_agreement_B:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_5_special_TTP_bdkey_A_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_5_special_TTP_bdkey_B &
+          ( tid1, isoiec_9798_2_5_special_TTP_bdkey_B_4 ) : steps t &
+          {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
+             s(MV ''Kab'' tid1), s(MV ''TNa'' tid1), s(MV ''Text5'' tid1),
+             LN ''TNb'' tid1, s(MV ''Text7'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
+                  s(MV ''Kab'' tid0), LN ''TNa'' tid0, s(MV ''Text5'' tid0),
+                  s(MV ''TNb'' tid0), s(MV ''Text7'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid1) note_unified facts = this facts
+        hence "Kbd ( s(AV ''P'' tid1) )
+                   ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
+          by simp note facts = this facts
+        thus ?thesis proof(cases rule: Kbd_cases)
+          case noswap note_unified facts = this facts
+          thus ?thesis by (fastforce dest: isoiec_9798_2_5_special_TTP_bdkey_different_actors_A_P intro: event_predOrdI)
+        next
+          case swapped note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_4'', s(MV ''TNb'' tid0),
+                                  s(AV ''A'' tid0), s(MV ''Text7'' tid0)
+                               |}
+                               ( LN ''Kab'' tid1 ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest: isoiec_9798_2_5_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
+          next
+            case (isoiec_9798_2_5_special_TTP_bdkey_B_4_enc tid2) note_unified facts = this facts
+            thus ?thesis proof(sources! "
+                             Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_3'', s(MV ''TNa'' tid2),
+                                    s(AV ''B'' tid2), s(MV ''Text5'' tid2)
+                                 |}
+                                 ( LN ''Kab'' tid1 ) ")
+              case fake note_unified facts = this facts
+              thus ?thesis by (fastforce dest: isoiec_9798_2_5_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
+            next
+              case (isoiec_9798_2_5_special_TTP_bdkey_A_3_enc tid3) note_unified facts = this facts
+              thus ?thesis proof(sources! "
+                               Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid3,
+                                      LN ''Kab'' tid1, s(AV ''B'' tid2), s(MV ''Text3'' tid3)
+                                   |}
+                                   ( Kbd ( s(AV ''A'' tid3) ) ( s(AV ''P'' tid3) ) ) ")
+                case fake note_unified facts = this facts
+                thus ?thesis by (fastforce dest: isoiec_9798_2_5_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
+              next
+                case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid4) note_unified facts = this facts
+                thus ?thesis proof(sources! "
+                                 Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid2),
+                                        LN ''Kab'' tid1, s(AV ''A'' tid0), s(MV ''Text2'' tid2)
+                                     |}
+                                     ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid2) ) ) ")
+                  case fake note_unified facts = this facts
+                  thus ?thesis by (fastforce dest: isoiec_9798_2_5_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
+                next
+                  case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc_1 tid3) note_unified facts = this facts
+                  thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+                qed (insert facts, fastforce+)?
+              qed (insert facts, fastforce+)?
+            qed (insert facts, fastforce+)?
+          qed (insert facts, fastforce+)?
+        qed (fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_special_TTP_bdkey_B_non_injective_agreement_A:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_special_TTP_bdkey_B_3 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_5_special_TTP_bdkey_A &
+        ( tid1, isoiec_9798_2_5_special_TTP_bdkey_A_3 ) : steps t &
+        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(AV ''P'' tid1),
+           s(MV ''Kab'' tid1), LN ''TNa'' tid1, s(MV ''Text5'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                s(MV ''Kab'' tid0), s(MV ''TNa'' tid0), s(MV ''Text5'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_3'', s(MV ''TNa'' tid0),
+                          s(AV ''B'' tid0), s(MV ''Text5'' tid0)
+                       |}
+                       ( s(MV ''Kab'' tid0) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest: isoiec_9798_2_5_special_TTP_bdkey_B_secret_Kab intro: event_predOrdI)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_A_3_enc tid1) note_unified facts = this facts
+    thus ?thesis proof(sources! "
+                     Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid1,
+                            s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid1)
+                         |}
+                         ( Kbd ( s(AV ''A'' tid1) ) ( s(AV ''P'' tid1) ) ) ")
+      case fake note_unified facts = this facts
+      thus ?thesis by (fastforce dest: isoiec_9798_2_5_special_TTP_bdkey_B_secret_Kab intro: event_predOrdI)
+    next
+      case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid2) note_unified facts = this facts
+      hence "Kbd ( s(AV ''P'' tid2) )
+                 ( s(MV ''A'' tid2) ) = Kbd ( s(AV ''A'' tid1) ) ( s(AV ''P'' tid1) )"
+        by simp note facts = this facts
+      thus ?thesis proof(cases rule: Kbd_cases)
+        case noswap note_unified facts = this facts
+        thus ?thesis by (fastforce dest: isoiec_9798_2_5_special_TTP_bdkey_different_actors_A_P intro: event_predOrdI)
+      next
+        case swapped note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
+                                LN ''Kab'' tid2, s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+                             |}
+                             ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc_1 tid3) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (fastforce+)?
+    qed (insert facts, fastforce+)?
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_special_TTP_bdkey_A_injective_agreement_P:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_5_special_TTP_bdkey_A_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_5_special_TTP_bdkey_P &
+          ( tid1, isoiec_9798_2_5_special_TTP_bdkey_P_2 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
+             s(MV ''TVPa'' tid1), s(MV ''Text3'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
+                  s(MV ''Kab'' tid0), LN ''TVPa'' tid0, s(MV ''Text3'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid1) note_unified facts = this facts
+        hence "Kbd ( s(AV ''P'' tid1) )
+                   ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
+          by simp note facts = this facts
+        thus ?thesis proof(cases rule: Kbd_cases)
+          case noswap note_unified facts = this facts
+          thus ?thesis by (fastforce dest: isoiec_9798_2_5_special_TTP_bdkey_different_actors_A_P intro: event_predOrdI)
+        next
+          case swapped note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_special_TTP_bdkey_B_non_injective_agreement_P:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_special_TTP_bdkey_B_3 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_5_special_TTP_bdkey_P &
+        ( tid1, isoiec_9798_2_5_special_TTP_bdkey_P_2 ) : steps t &
+        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
+           LN ''TNp'' tid1, s(MV ''Text2'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                s(MV ''Kab'' tid0), s(MV ''TNp'' tid0), s(MV ''Text2'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
+                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc_1 tid1) note_unified facts = this facts
+    hence "Kbd ( s(AV ''P'' tid1) )
+               ( s(MV ''B'' tid1) ) = Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) )"
+      by simp note facts = this facts
+    thus ?thesis proof(cases rule: Kbd_cases)
+      case noswap note_unified facts = this facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_3'', s(MV ''TNa'' tid0),
+                              s(AV ''B'' tid0), s(MV ''Text5'' tid0)
+                           |}
+                           ( LN ''Kab'' tid1 ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest: isoiec_9798_2_5_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
+      next
+        case (isoiec_9798_2_5_special_TTP_bdkey_A_3_enc tid2) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid2,
+                                LN ''Kab'' tid1, s(AV ''B'' tid0), s(MV ''Text3'' tid2)
+                             |}
+                             ( Kbd ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest: isoiec_9798_2_5_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
+        next
+          case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid3) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    next
+      case swapped note_unified facts = this facts
+      thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+    qed (fastforce+)?
+  qed (insert facts, fastforce+)?
+qed
+
+
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_special_TTP_bdkey_P_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_P"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
+    "LN ''Kab'' tid0 : knows t"
+  shows "False"
+using facts proof(sources! " LN ''Kab'' tid0 ")
+  case isoiec_9798_2_6_special_TTP_bdkey_P_3_Kab note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+next
+  case isoiec_9798_2_6_special_TTP_bdkey_P_3_Kab_1 note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+qed (insert facts, fastforce+)?
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_special_TTP_bdkey_A_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_A"
+    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_6_special_TTP_bdkey_A_3 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid0,
+                          s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc tid1) note_unified facts = this facts
+    hence "Kbd ( s(AV ''P'' tid1) )
+               ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
+      by simp note facts = this facts
+    thus ?thesis proof(cases rule: Kbd_cases)
+      case noswap note_unified facts = this facts
+      thus ?thesis by (fastforce dest: isoiec_9798_2_6_special_TTP_bdkey_different_actors_A_P intro: event_predOrdI)
+    next
+      case swapped note_unified facts = this facts
+      thus ?thesis by (fastforce dest: isoiec_9798_2_6_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
+    qed (fastforce+)?
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_special_TTP_bdkey_B_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_B"
+    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_6_special_TTP_bdkey_B_4 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid0,
+                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
+    hence "Kbd ( s(AV ''P'' tid1) )
+               ( s(MV ''B'' tid1) ) = Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) )"
+      by simp note facts = this facts
+    thus ?thesis proof(cases rule: Kbd_cases)
+      case noswap note_unified facts = this facts
+      thus ?thesis by (fastforce dest: isoiec_9798_2_6_special_TTP_bdkey_different_actors_B_P intro: event_predOrdI)
+    next
+      case swapped note_unified facts = this facts
+      thus ?thesis by (fastforce dest: isoiec_9798_2_6_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
+    qed (fastforce+)?
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_special_TTP_bdkey_A_injective_agreement_B:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_special_TTP_bdkey_A_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_B &
+          ( tid1, isoiec_9798_2_6_special_TTP_bdkey_B_5 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
+             s(MV ''Kab'' tid1), s(MV ''Rpa'' tid1), LN ''Rb'' tid1,
+             s(MV ''Text6'' tid1), s(MV ''Text8'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
+                  s(MV ''Kab'' tid0), LN ''Rpa'' tid0, s(MV ''Rb'' tid0),
+                  s(MV ''Text6'' tid0), s(MV ''Text8'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid0,
+                              s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc tid1) note_unified facts = this facts
+        hence "Kbd ( s(AV ''P'' tid1) )
+                   ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
+          by simp note facts = this facts
+        thus ?thesis proof(cases rule: Kbd_cases)
+          case noswap note_unified facts = this facts
+          thus ?thesis by (fastforce dest: isoiec_9798_2_6_special_TTP_bdkey_different_actors_A_P intro: event_predOrdI)
+        next
+          case swapped note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_5'', s(MV ''Rb'' tid0),
+                                  LN ''Rpa'' tid0, s(MV ''Text8'' tid0)
+                               |}
+                               ( LN ''Kab'' tid1 ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest: isoiec_9798_2_6_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
+          next
+            case (isoiec_9798_2_6_special_TTP_bdkey_B_5_enc tid2) note_unified facts = this facts
+            thus ?thesis proof(sources! "
+                             Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid2,
+                                    LN ''Kab'' tid1, s(AV ''A'' tid2), s(MV ''Text3'' tid2)
+                                 |}
+                                 ( Kbd ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) ) ) ")
+              case fake note_unified facts = this facts
+              thus ?thesis by (fastforce dest: isoiec_9798_2_6_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
+            next
+              case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc_1 tid3) note_unified facts = this facts
+              hence "Kbd ( s(AV ''P'' tid0) )
+                         ( s(MV ''B'' tid0) ) = Kbd ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) )"
+                by simp note facts = this facts
+              thus ?thesis proof(cases rule: Kbd_cases)
+                case noswap note_unified facts = this facts
+                thus ?thesis by (fastforce dest: isoiec_9798_2_6_special_TTP_bdkey_different_actors_B_P intro: event_predOrdI)
+              next
+                case swapped note_unified facts = this facts
+                thus ?thesis proof(sources! "
+                                 Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_4'', LN ''Rpa'' tid0,
+                                        LN ''Rb'' tid2, s(MV ''Text6'' tid2)
+                                     |}
+                                     ( LN ''Kab'' tid1 ) ")
+                  case fake note_unified facts = this facts
+                  thus ?thesis by (fastforce dest: isoiec_9798_2_6_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
+                next
+                  case (isoiec_9798_2_6_special_TTP_bdkey_A_4_enc tid3) note_unified facts = this facts
+                  thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+                qed (insert facts, fastforce+)?
+              qed (fastforce+)?
+            qed (insert facts, fastforce+)?
+          qed (insert facts, fastforce+)?
+        qed (fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_special_TTP_bdkey_B_injective_agreement_A:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(MV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_special_TTP_bdkey_B_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_A &
+          ( tid1, isoiec_9798_2_6_special_TTP_bdkey_A_4 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
+             s(MV ''Kab'' tid1), LN ''Rpa'' tid1, s(MV ''Rb'' tid1),
+             s(MV ''Text6'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                  s(MV ''Kab'' tid0), s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
+                  s(MV ''Text6'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
+        hence "Kbd ( s(AV ''P'' tid1) )
+                   ( s(MV ''B'' tid1) ) = Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) )"
+          by simp note facts = this facts
+        thus ?thesis proof(cases rule: Kbd_cases)
+          case noswap note_unified facts = this facts
+          thus ?thesis by (fastforce dest: isoiec_9798_2_6_special_TTP_bdkey_different_actors_B_P intro: event_predOrdI)
+        next
+          case swapped note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_4'', s(MV ''Rpa'' tid0),
+                                  LN ''Rb'' tid0, s(MV ''Text6'' tid0)
+                               |}
+                               ( LN ''Kab'' tid1 ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest: isoiec_9798_2_6_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
+          next
+            case (isoiec_9798_2_6_special_TTP_bdkey_A_4_enc tid2) note_unified facts = this facts
+            thus ?thesis proof(sources! "
+                             Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid2,
+                                    LN ''Kab'' tid1, s(MV ''B'' tid2), s(MV ''Text4'' tid2)
+                                 |}
+                                 ( Kbd ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
+              case fake note_unified facts = this facts
+              thus ?thesis by (fastforce dest: isoiec_9798_2_6_special_TTP_bdkey_P_secret_Kab intro: event_predOrdI)
+            next
+              case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc tid3) note_unified facts = this facts
+              hence "Kbd ( s(AV ''A'' tid2) )
+                         ( s(AV ''P'' tid2) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid1) )"
+                by simp note facts = this facts
+              thus ?thesis proof(cases rule: Kbd_cases)
+                case noswap note_unified facts = this facts
+                thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+              next
+                case swapped note_unified facts = this facts
+                thus ?thesis by (fastforce dest: isoiec_9798_2_6_special_TTP_bdkey_different_actors_A_P intro: event_predOrdI)
+              qed (fastforce+)?
+            qed (insert facts, fastforce+)?
+          qed (insert facts, fastforce+)?
+        qed (fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_special_TTP_bdkey_A_injective_agreement_P:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_special_TTP_bdkey_A_3 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_P &
+          ( tid1, isoiec_9798_2_6_special_TTP_bdkey_P_3 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
+             s(MV ''Ra'' tid1), LN ''Kab'' tid1, s(MV ''Text4'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
+                  LN ''Ra'' tid0, s(MV ''Kab'' tid0), s(MV ''Text4'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid0,
+                              s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc tid1) note_unified facts = this facts
+        hence "Kbd ( s(AV ''P'' tid1) )
+                   ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
+          by simp note facts = this facts
+        thus ?thesis proof(cases rule: Kbd_cases)
+          case noswap note_unified facts = this facts
+          thus ?thesis by (fastforce dest: isoiec_9798_2_6_special_TTP_bdkey_different_actors_A_P intro: event_predOrdI)
+        next
+          case swapped note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_special_TTP_bdkey_B_injective_agreement_P:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(MV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_special_TTP_bdkey_B_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_P &
+          ( tid1, isoiec_9798_2_6_special_TTP_bdkey_P_3 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
+             s(MV ''Rb'' tid1), LN ''Kab'' tid1, s(MV ''Text3'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                  LN ''Rb'' tid0, s(MV ''Kab'' tid0), s(MV ''Text3'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
+        hence "Kbd ( s(AV ''P'' tid1) )
+                   ( s(MV ''B'' tid1) ) = Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) )"
+          by simp note facts = this facts
+        thus ?thesis proof(cases rule: Kbd_cases)
+          case noswap note_unified facts = this facts
+          thus ?thesis by (fastforce dest: isoiec_9798_2_6_special_TTP_bdkey_different_actors_B_P intro: event_predOrdI)
+        next
+          case swapped note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
 qed
 
 end
diff --git a/data/examples/iso9798/isabelle-parallel-proofs/isoiec-9798-2-udkey_cert_auto.thy b/data/examples/iso9798/isabelle-parallel-proofs/isoiec-9798-2-udkey_cert_auto.thy
--- a/data/examples/iso9798/isabelle-parallel-proofs/isoiec-9798-2-udkey_cert_auto.thy
+++ b/data/examples/iso9798/isabelle-parallel-proofs/isoiec-9798-2-udkey_cert_auto.thy
@@ -1,1843 +1,2023 @@
 theory "isoiec-9798-2-udkey_cert_auto"
 imports
-  "../ESPLogic"
-begin
-
-role isoiec_9798_2_1_udkey_A
-where "isoiec_9798_2_1_udkey_A =
-  [ Send ''leak_A'' ( sN ''TNA'' )
-  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
-  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
-                  PEnc <| sC ''isoiec_9798_2_1_enc_1'', sN ''TNA'', sMV ''Text1'' |>
-                       ( sK ''A'' ''B'' )
-               |>
-  ]"
-
-role isoiec_9798_2_1_udkey_B
-where "isoiec_9798_2_1_udkey_B =
-  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
-                  PEnc <| sC ''isoiec_9798_2_1_enc_1'', sMV ''TNA'', sMV ''Text1'' |>
-                       ( PSymK ( sMV ''A'' ) ( sAV ''B'' ) )
-               |>
-  ]"
-
-role isoiec_9798_2_2_udkey_A
-where "isoiec_9798_2_2_udkey_A =
-  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text1'' |>
-  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
-  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
-                  PEnc <| sC ''isoiec_9798_2_2_enc_2'', sMV ''RB'', sMV ''Text2'' |>
-                       ( PSymK ( sAV ''A'' ) ( sMV ''B'' ) )
-               |>
-  ]"
-
-role isoiec_9798_2_2_udkey_B
-where "isoiec_9798_2_2_udkey_B =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''RB'', sMV ''Text1'' |>
-  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
-                  PEnc <| sC ''isoiec_9798_2_2_enc_2'', sN ''RB'', sMV ''Text2'' |>
-                       ( sK ''A'' ''B'' )
-               |>
-  ]"
-
-role isoiec_9798_2_3_udkey_A
-where "isoiec_9798_2_3_udkey_A =
-  [ Send ''leak_A'' ( sN ''TNA'' )
-  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
-  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
-                  PEnc <| sC ''isoiec_9798_2_3_enc_1'', sN ''TNA'', sMV ''Text1'' |>
-                       ( sK ''A'' ''B'' )
-               |>
-  , Recv ''2'' <| sAV ''B'', sAV ''A'', sMV ''Text4'',
-                  PEnc <| sC ''isoiec_9798_2_3_enc_2'', sMV ''TNB'', sMV ''Text3'' |>
-                       ( sK ''B'' ''A'' )
-               |>
-  ]"
-
-role isoiec_9798_2_3_udkey_B
-where "isoiec_9798_2_3_udkey_B =
-  [ Send ''leak_B'' ( sN ''TNB'' )
-  , Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
-                  PEnc <| sC ''isoiec_9798_2_3_enc_1'', sMV ''TNA'', sMV ''Text1'' |>
-                       ( PSymK ( sMV ''A'' ) ( sAV ''B'' ) )
-               |>
-  , Recv ''text_2'' <| sMV ''Text3'', sMV ''Text4'' |>
-  , Send ''2'' <| sAV ''B'', sMV ''A'', sMV ''Text4'',
-                  PEnc <| sC ''isoiec_9798_2_3_enc_2'', sN ''TNB'', sMV ''Text3'' |>
-                       ( PSymK ( sAV ''B'' ) ( sMV ''A'' ) )
-               |>
-  ]"
-
-role isoiec_9798_2_4_udkey_A
-where "isoiec_9798_2_4_udkey_A =
-  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text1'' |>
-  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
-  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
-                  PEnc <| sC ''isoiec_9798_2_4_enc_1'', sN ''RA'', sMV ''RB'',
-                          sMV ''Text2''
-                       |>
-                       ( PSymK ( sAV ''A'' ) ( sMV ''B'' ) )
-               |>
-  , Recv ''3'' <| sMV ''B'', sAV ''A'', sMV ''Text5'',
-                  PEnc <| sC ''isoiec_9798_2_4_enc_2'', sMV ''RB'', sN ''RA'',
-                          sMV ''Text4''
-                       |>
-                       ( PSymK ( sMV ''B'' ) ( sAV ''A'' ) )
-               |>
-  ]"
-
-role isoiec_9798_2_4_udkey_B
-where "isoiec_9798_2_4_udkey_B =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''RB'', sMV ''Text1'' |>
-  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
-                  PEnc <| sC ''isoiec_9798_2_4_enc_1'', sMV ''RA'', sN ''RB'',
-                          sMV ''Text2''
-                       |>
-                       ( sK ''A'' ''B'' )
-               |>
-  , Recv ''text_3'' <| sMV ''Text4'', sMV ''Text5'' |>
-  , Send ''3'' <| sAV ''B'', sAV ''A'', sMV ''Text5'',
-                  PEnc <| sC ''isoiec_9798_2_4_enc_2'', sN ''RB'', sMV ''RA'',
-                          sMV ''Text4''
-                       |>
-                       ( sK ''B'' ''A'' )
-               |>
-  ]"
-
-role isoiec_9798_2_5_udkey_A
-where "isoiec_9798_2_5_udkey_A =
-  [ Send ''leak_A'' <| sN ''TVPa'', sN ''TNa'' |>
-  , Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''A'', sAV ''P'', sN ''TVPa'', sAV ''B'',
-                  sMV ''Text1''
-               |>
-  , Recv ''2'' <| sAV ''P'', sAV ''A'', sMV ''Text4'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_2_1'', sN ''TVPa'', sMV ''Kab'',
-                          sAV ''B'', sMV ''Text3''
-                       |>
-                       ( sK ''A'' ''P'' ),
-                  sMV ''TokenPA_for_B''
-               |>
-  , Recv ''text_3'' <| sMV ''Text5'', sMV ''Text6'' |>
-  , Send ''3'' <| sAV ''A'', sAV ''B'', sMV ''Text6'', sAV ''P'',
-                  sMV ''TokenPA_for_B'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_3'', sN ''TNa'', sAV ''B'',
-                          sMV ''Text5''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''4'' <| sAV ''B'', sAV ''A'', sMV ''Text8'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_4'', sMV ''TNb'', sAV ''A'',
-                          sMV ''Text7''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_5_udkey_B
-where "isoiec_9798_2_5_udkey_B =
-  [ Send ''leak_B'' ( sN ''TNb'' )
-  , Recv ''3'' <| sMV ''A'', sAV ''B'', sMV ''Text6'', sMV ''P'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_2_2'', sMV ''TNp'', sMV ''Kab'',
-                          sMV ''A'', sMV ''Text2''
-                       |>
-                       ( PSymK ( sAV ''B'' ) ( sMV ''P'' ) ),
-                  PEnc <| sC ''isoiec_9798_2_5_enc_3'', sMV ''TNa'', sAV ''B'',
-                          sMV ''Text5''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''text_4'' <| sMV ''Text7'', sMV ''Text8'' |>
-  , Send ''4'' <| sAV ''B'', sMV ''A'', sMV ''Text8'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_4'', sN ''TNb'', sMV ''A'',
-                          sMV ''Text7''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_5_udkey_P
-where "isoiec_9798_2_5_udkey_P =
-  [ Send ''leak_P'' ( sN ''TNp'' )
-  , Recv ''1'' <| sMV ''A'', sAV ''P'', sMV ''TVPa'', sMV ''B'',
-                  sMV ''Text1''
-               |>
-  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'', sMV ''Text4'' |>
-  , Send ''2'' <| sAV ''P'', sMV ''A'', sMV ''Text4'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_2_1'', sMV ''TVPa'', sN ''Kab'',
-                          sMV ''B'', sMV ''Text3''
-                       |>
-                       ( PSymK ( sMV ''A'' ) ( sAV ''P'' ) ),
-                  PEnc <| sC ''isoiec_9798_2_5_enc_2_2'', sN ''TNp'', sN ''Kab'',
-                          sMV ''A'', sMV ''Text2''
-                       |>
-                       ( PSymK ( sMV ''B'' ) ( sAV ''P'' ) )
-               |>
-  ]"
-
-role isoiec_9798_2_6_udkey_A
-where "isoiec_9798_2_6_udkey_A =
-  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
-  , Recv ''text_2'' ( sMV ''Text2'' )
-  , Send ''2'' <| sAV ''A'', sAV ''P'', sN ''Ra'', sMV ''Rb'', sMV ''B'',
-                  sMV ''Text2''
-               |>
-  , Recv ''3'' <| sAV ''P'', sAV ''A'', sMV ''Text5'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_3_1'', sN ''Ra'', sMV ''Kab'',
-                          sMV ''B'', sMV ''Text4''
-                       |>
-                       ( sK ''A'' ''P'' ),
-                  sMV ''TokenPA_for_B''
-               |>
-  , Recv ''text_4'' <| sMV ''Text6'', sMV ''Text7'' |>
-  , Send ''4'' <| sAV ''A'', sMV ''B'', sMV ''Text7'', sAV ''P'',
-                  sMV ''TokenPA_for_B'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_4'', sN ''Rpa'', sMV ''Rb'',
-                          sMV ''Text6''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''5'' <| sMV ''B'', sAV ''A'', sMV ''Text9'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_5'', sMV ''Rb'', sN ''Rpa'',
-                          sMV ''Text8''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_6_udkey_B
-where "isoiec_9798_2_6_udkey_B =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
-  , Recv ''4'' <| sAV ''A'', sAV ''B'', sMV ''Text7'', sMV ''P'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_3_2'', sN ''Rb'', sMV ''Kab'',
-                          sAV ''A'', sMV ''Text3''
-                       |>
-                       ( PSymK ( sAV ''B'' ) ( sMV ''P'' ) ),
-                  PEnc <| sC ''isoiec_9798_2_6_enc_4'', sMV ''Rpa'', sN ''Rb'',
-                          sMV ''Text6''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
-  , Send ''5'' <| sAV ''B'', sAV ''A'', sMV ''Text9'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_5'', sN ''Rb'', sMV ''Rpa'',
-                          sMV ''Text8''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_6_udkey_P
-where "isoiec_9798_2_6_udkey_P =
-  [ Recv ''2'' <| sMV ''A'', sAV ''P'', sMV ''Ra'', sMV ''Rb'', sMV ''B'',
-                  sMV ''Text2''
-               |>
-  , Recv ''text_3'' <| sMV ''Text3'', sMV ''Text4'', sMV ''Text5'' |>
-  , Send ''3'' <| sAV ''P'', sMV ''A'', sMV ''Text5'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_3_1'', sMV ''Ra'', sN ''Kab'',
-                          sMV ''B'', sMV ''Text4''
-                       |>
-                       ( PSymK ( sMV ''A'' ) ( sAV ''P'' ) ),
-                  PEnc <| sC ''isoiec_9798_2_6_enc_3_2'', sMV ''Rb'', sN ''Kab'',
-                          sMV ''A'', sMV ''Text3''
-                       |>
-                       ( PSymK ( sMV ''B'' ) ( sAV ''P'' ) )
-               |>
-  ]"
-
-protocol isoiec_9798_2_bdkey
-where "isoiec_9798_2_bdkey =
-{ isoiec_9798_2_1_udkey_A, isoiec_9798_2_1_udkey_B,
-  isoiec_9798_2_2_udkey_A, isoiec_9798_2_2_udkey_B,
-  isoiec_9798_2_3_udkey_A, isoiec_9798_2_3_udkey_B,
-  isoiec_9798_2_4_udkey_A, isoiec_9798_2_4_udkey_B,
-  isoiec_9798_2_5_udkey_A, isoiec_9798_2_5_udkey_B,
-  isoiec_9798_2_5_udkey_P, isoiec_9798_2_6_udkey_A,
-  isoiec_9798_2_6_udkey_B, isoiec_9798_2_6_udkey_P
-}"
-
-locale restricted_isoiec_9798_2_bdkey_state = isoiec_9798_2_bdkey_state
-
-type_invariant isoiec_9798_2_bdkey_composed_typing for isoiec_9798_2_bdkey
-where "isoiec_9798_2_bdkey_composed_typing = mk_typing
-  [ ((isoiec_9798_2_1_udkey_B, ''A''), (KnownT isoiec_9798_2_1_udkey_B_1))
-  , ((isoiec_9798_2_3_udkey_B, ''A''), (KnownT isoiec_9798_2_3_udkey_B_1))
-  , ((isoiec_9798_2_5_udkey_B, ''A''), (KnownT isoiec_9798_2_5_udkey_B_3))
-  , ((isoiec_9798_2_5_udkey_P, ''A''), (KnownT isoiec_9798_2_5_udkey_P_1))
-  , ((isoiec_9798_2_6_udkey_P, ''A''), (KnownT isoiec_9798_2_6_udkey_P_2))
-  , ((isoiec_9798_2_2_udkey_A, ''B''), (KnownT isoiec_9798_2_2_udkey_A_1))
-  , ((isoiec_9798_2_4_udkey_A, ''B''), (KnownT isoiec_9798_2_4_udkey_A_1))
-  , ((isoiec_9798_2_5_udkey_P, ''B''), (KnownT isoiec_9798_2_5_udkey_P_1))
-  , ((isoiec_9798_2_6_udkey_A, ''B''), (KnownT isoiec_9798_2_6_udkey_A_1))
-  , ((isoiec_9798_2_6_udkey_P, ''B''), (KnownT isoiec_9798_2_6_udkey_P_2))
-  , ((isoiec_9798_2_5_udkey_A, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_5_udkey_A_2) (NonceT isoiec_9798_2_5_udkey_P ''Kab'')))
-  , ((isoiec_9798_2_5_udkey_B, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_5_udkey_B_3) (NonceT isoiec_9798_2_5_udkey_P ''Kab'')))
-  , ((isoiec_9798_2_6_udkey_A, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_6_udkey_A_3) (NonceT isoiec_9798_2_6_udkey_P ''Kab'')))
-  , ((isoiec_9798_2_6_udkey_B, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_6_udkey_B_4) (NonceT isoiec_9798_2_6_udkey_P ''Kab'')))
-  , ((isoiec_9798_2_5_udkey_B, ''P''), (KnownT isoiec_9798_2_5_udkey_B_3))
-  , ((isoiec_9798_2_6_udkey_B, ''P''), (KnownT isoiec_9798_2_6_udkey_B_4))
-  , ((isoiec_9798_2_4_udkey_B, ''RA''),
-     (SumT (KnownT isoiec_9798_2_4_udkey_B_2) (NonceT isoiec_9798_2_4_udkey_A ''RA'')))
-  , ((isoiec_9798_2_2_udkey_A, ''RB''), (KnownT isoiec_9798_2_2_udkey_A_1))
-  , ((isoiec_9798_2_4_udkey_A, ''RB''), (KnownT isoiec_9798_2_4_udkey_A_1))
-  , ((isoiec_9798_2_6_udkey_P, ''Ra''), (KnownT isoiec_9798_2_6_udkey_P_2))
-  , ((isoiec_9798_2_6_udkey_A, ''Rb''), (KnownT isoiec_9798_2_6_udkey_A_1))
-  , ((isoiec_9798_2_6_udkey_P, ''Rb''), (KnownT isoiec_9798_2_6_udkey_P_2))
-  , ((isoiec_9798_2_6_udkey_B, ''Rpa''),
-     (SumT (KnownT isoiec_9798_2_6_udkey_B_4) (NonceT isoiec_9798_2_6_udkey_A ''Rpa'')))
-  , ((isoiec_9798_2_1_udkey_B, ''TNA''),
-     (SumT (KnownT isoiec_9798_2_1_udkey_B_1) (NonceT isoiec_9798_2_1_udkey_A ''TNA'')))
-  , ((isoiec_9798_2_3_udkey_B, ''TNA''),
-     (SumT (KnownT isoiec_9798_2_3_udkey_B_1) (NonceT isoiec_9798_2_3_udkey_A ''TNA'')))
-  , ((isoiec_9798_2_3_udkey_A, ''TNB''),
-     (SumT (KnownT isoiec_9798_2_3_udkey_A_2) (NonceT isoiec_9798_2_3_udkey_B ''TNB'')))
-  , ((isoiec_9798_2_5_udkey_B, ''TNa''),
-     (SumT (KnownT isoiec_9798_2_5_udkey_B_3) (NonceT isoiec_9798_2_5_udkey_A ''TNa'')))
-  , ((isoiec_9798_2_5_udkey_A, ''TNb''),
-     (SumT (KnownT isoiec_9798_2_5_udkey_A_4) (NonceT isoiec_9798_2_5_udkey_B ''TNb'')))
-  , ((isoiec_9798_2_5_udkey_B, ''TNp''),
-     (SumT (KnownT isoiec_9798_2_5_udkey_B_3) (NonceT isoiec_9798_2_5_udkey_P ''TNp'')))
-  , ((isoiec_9798_2_5_udkey_P, ''TVPa''),
-     (KnownT isoiec_9798_2_5_udkey_P_1))
-  , ((isoiec_9798_2_1_udkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_1_udkey_A_text_1))
-  , ((isoiec_9798_2_1_udkey_B, ''Text1''),
-     (KnownT isoiec_9798_2_1_udkey_B_1))
-  , ((isoiec_9798_2_2_udkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_2_udkey_A_1))
-  , ((isoiec_9798_2_2_udkey_B, ''Text1''),
-     (KnownT isoiec_9798_2_2_udkey_B_text_1))
-  , ((isoiec_9798_2_3_udkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_3_udkey_A_text_1))
-  , ((isoiec_9798_2_3_udkey_B, ''Text1''),
-     (KnownT isoiec_9798_2_3_udkey_B_1))
-  , ((isoiec_9798_2_4_udkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_4_udkey_A_1))
-  , ((isoiec_9798_2_4_udkey_B, ''Text1''),
-     (KnownT isoiec_9798_2_4_udkey_B_text_1))
-  , ((isoiec_9798_2_5_udkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_5_udkey_A_text_1))
-  , ((isoiec_9798_2_5_udkey_P, ''Text1''),
-     (KnownT isoiec_9798_2_5_udkey_P_1))
-  , ((isoiec_9798_2_6_udkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_6_udkey_A_1))
-  , ((isoiec_9798_2_6_udkey_B, ''Text1''),
-     (KnownT isoiec_9798_2_6_udkey_B_text_1))
-  , ((isoiec_9798_2_1_udkey_A, ''Text2''),
-     (KnownT isoiec_9798_2_1_udkey_A_text_1))
-  , ((isoiec_9798_2_1_udkey_B, ''Text2''),
-     (KnownT isoiec_9798_2_1_udkey_B_1))
-  , ((isoiec_9798_2_2_udkey_A, ''Text2''),
-     (KnownT isoiec_9798_2_2_udkey_A_text_2))
-  , ((isoiec_9798_2_2_udkey_B, ''Text2''),
-     (KnownT isoiec_9798_2_2_udkey_B_2))
-  , ((isoiec_9798_2_3_udkey_A, ''Text2''),
-     (KnownT isoiec_9798_2_3_udkey_A_text_1))
-  , ((isoiec_9798_2_3_udkey_B, ''Text2''),
-     (KnownT isoiec_9798_2_3_udkey_B_1))
-  , ((isoiec_9798_2_4_udkey_A, ''Text2''),
-     (KnownT isoiec_9798_2_4_udkey_A_text_2))
-  , ((isoiec_9798_2_4_udkey_B, ''Text2''),
-     (KnownT isoiec_9798_2_4_udkey_B_2))
-  , ((isoiec_9798_2_5_udkey_B, ''Text2''),
-     (KnownT isoiec_9798_2_5_udkey_B_3))
-  , ((isoiec_9798_2_5_udkey_P, ''Text2''),
-     (KnownT isoiec_9798_2_5_udkey_P_text_2))
-  , ((isoiec_9798_2_6_udkey_A, ''Text2''),
-     (KnownT isoiec_9798_2_6_udkey_A_text_2))
-  , ((isoiec_9798_2_6_udkey_P, ''Text2''),
-     (KnownT isoiec_9798_2_6_udkey_P_2))
-  , ((isoiec_9798_2_2_udkey_A, ''Text3''),
-     (KnownT isoiec_9798_2_2_udkey_A_text_2))
-  , ((isoiec_9798_2_2_udkey_B, ''Text3''),
-     (KnownT isoiec_9798_2_2_udkey_B_2))
-  , ((isoiec_9798_2_3_udkey_A, ''Text3''),
-     (KnownT isoiec_9798_2_3_udkey_A_2))
-  , ((isoiec_9798_2_3_udkey_B, ''Text3''),
-     (KnownT isoiec_9798_2_3_udkey_B_text_2))
-  , ((isoiec_9798_2_4_udkey_A, ''Text3''),
-     (KnownT isoiec_9798_2_4_udkey_A_text_2))
-  , ((isoiec_9798_2_4_udkey_B, ''Text3''),
-     (KnownT isoiec_9798_2_4_udkey_B_2))
-  , ((isoiec_9798_2_5_udkey_A, ''Text3''),
-     (KnownT isoiec_9798_2_5_udkey_A_2))
-  , ((isoiec_9798_2_5_udkey_P, ''Text3''),
-     (KnownT isoiec_9798_2_5_udkey_P_text_2))
-  , ((isoiec_9798_2_6_udkey_B, ''Text3''),
-     (KnownT isoiec_9798_2_6_udkey_B_4))
-  , ((isoiec_9798_2_6_udkey_P, ''Text3''),
-     (KnownT isoiec_9798_2_6_udkey_P_text_3))
-  , ((isoiec_9798_2_3_udkey_A, ''Text4''),
-     (KnownT isoiec_9798_2_3_udkey_A_2))
-  , ((isoiec_9798_2_3_udkey_B, ''Text4''),
-     (KnownT isoiec_9798_2_3_udkey_B_text_2))
-  , ((isoiec_9798_2_4_udkey_A, ''Text4''),
-     (KnownT isoiec_9798_2_4_udkey_A_3))
-  , ((isoiec_9798_2_4_udkey_B, ''Text4''),
-     (KnownT isoiec_9798_2_4_udkey_B_text_3))
-  , ((isoiec_9798_2_5_udkey_A, ''Text4''),
-     (KnownT isoiec_9798_2_5_udkey_A_2))
-  , ((isoiec_9798_2_5_udkey_P, ''Text4''),
-     (KnownT isoiec_9798_2_5_udkey_P_text_2))
-  , ((isoiec_9798_2_6_udkey_A, ''Text4''),
-     (KnownT isoiec_9798_2_6_udkey_A_3))
-  , ((isoiec_9798_2_6_udkey_P, ''Text4''),
-     (KnownT isoiec_9798_2_6_udkey_P_text_3))
-  , ((isoiec_9798_2_4_udkey_A, ''Text5''),
-     (KnownT isoiec_9798_2_4_udkey_A_3))
-  , ((isoiec_9798_2_4_udkey_B, ''Text5''),
-     (KnownT isoiec_9798_2_4_udkey_B_text_3))
-  , ((isoiec_9798_2_5_udkey_A, ''Text5''),
-     (KnownT isoiec_9798_2_5_udkey_A_text_3))
-  , ((isoiec_9798_2_5_udkey_B, ''Text5''),
-     (KnownT isoiec_9798_2_5_udkey_B_3))
-  , ((isoiec_9798_2_6_udkey_A, ''Text5''),
-     (KnownT isoiec_9798_2_6_udkey_A_3))
-  , ((isoiec_9798_2_6_udkey_P, ''Text5''),
-     (KnownT isoiec_9798_2_6_udkey_P_text_3))
-  , ((isoiec_9798_2_5_udkey_A, ''Text6''),
-     (KnownT isoiec_9798_2_5_udkey_A_text_3))
-  , ((isoiec_9798_2_5_udkey_B, ''Text6''),
-     (KnownT isoiec_9798_2_5_udkey_B_3))
-  , ((isoiec_9798_2_6_udkey_A, ''Text6''),
-     (KnownT isoiec_9798_2_6_udkey_A_text_4))
-  , ((isoiec_9798_2_6_udkey_B, ''Text6''),
-     (KnownT isoiec_9798_2_6_udkey_B_4))
-  , ((isoiec_9798_2_5_udkey_A, ''Text7''),
-     (KnownT isoiec_9798_2_5_udkey_A_4))
-  , ((isoiec_9798_2_5_udkey_B, ''Text7''),
-     (KnownT isoiec_9798_2_5_udkey_B_text_4))
-  , ((isoiec_9798_2_6_udkey_A, ''Text7''),
-     (KnownT isoiec_9798_2_6_udkey_A_text_4))
-  , ((isoiec_9798_2_6_udkey_B, ''Text7''),
-     (KnownT isoiec_9798_2_6_udkey_B_4))
-  , ((isoiec_9798_2_5_udkey_A, ''Text8''),
-     (KnownT isoiec_9798_2_5_udkey_A_4))
-  , ((isoiec_9798_2_5_udkey_B, ''Text8''),
-     (KnownT isoiec_9798_2_5_udkey_B_text_4))
-  , ((isoiec_9798_2_6_udkey_A, ''Text8''),
-     (KnownT isoiec_9798_2_6_udkey_A_5))
-  , ((isoiec_9798_2_6_udkey_B, ''Text8''),
-     (KnownT isoiec_9798_2_6_udkey_B_text_5))
-  , ((isoiec_9798_2_6_udkey_A, ''Text9''),
-     (KnownT isoiec_9798_2_6_udkey_A_5))
-  , ((isoiec_9798_2_6_udkey_B, ''Text9''),
-     (KnownT isoiec_9798_2_6_udkey_B_text_5))
-  , ((isoiec_9798_2_5_udkey_A, ''TokenPA_for_B''),
-     (KnownT isoiec_9798_2_5_udkey_A_2))
-  , ((isoiec_9798_2_6_udkey_A, ''TokenPA_for_B''),
-     (KnownT isoiec_9798_2_6_udkey_A_3))
-  ]"
-
-sublocale isoiec_9798_2_bdkey_state < isoiec_9798_2_bdkey_composed_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_2_bdkey_composed_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_2_bdkey_composed_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_2_1_udkey_A_text_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_1_udkey_A_text_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_1_udkey_B_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_1_udkey_B_1_TNA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
-               s(MV ''Text1'' tid0)
-            |}
-            ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_1_udkey_B_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
-               s(MV ''Text1'' tid0)
-            |}
-            ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_1_udkey_B_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_2_udkey_A_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_2_udkey_A_1_RB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_2_udkey_A_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_2_udkey_A_text_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_2_udkey_A_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_2_udkey_B_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_2_enc_2'', LN ''RB'' tid0, s(MV ''Text2'' tid0)
-            |}
-            ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_2_udkey_B_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_udkey_A_text_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_udkey_A_text_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_udkey_A_2_TNB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
-               s(MV ''Text3'' tid0)
-            |}
-            ( K ( s(AV ''B'' tid0) ) ( s(AV ''A'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_3_udkey_A_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
-               s(MV ''Text3'' tid0)
-            |}
-            ( K ( s(AV ''B'' tid0) ) ( s(AV ''A'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_3_udkey_A_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_udkey_B_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_udkey_B_1_TNA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
-               s(MV ''Text1'' tid0)
-            |}
-            ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_3_udkey_B_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
-               s(MV ''Text1'' tid0)
-            |}
-            ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_3_udkey_B_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_udkey_B_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_udkey_B_text_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_udkey_A_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_udkey_A_1_RB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_udkey_A_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_udkey_A_text_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_udkey_A_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_udkey_A_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_4_enc_2'', s(MV ''RB'' tid0), LN ''RA'' tid0,
-               s(MV ''Text4'' tid0)
-            |}
-            ( K ( s(MV ''B'' tid0) ) ( s(AV ''A'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_4_udkey_A_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_udkey_B_2_RA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
-               s(MV ''Text2'' tid0)
-            |}
-            ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_4_udkey_B_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
-               s(MV ''Text2'' tid0)
-            |}
-            ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_4_udkey_B_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_udkey_B_text_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_udkey_B_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_A_2_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
-            |}
-            ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_udkey_A_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
-            |}
-            ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_udkey_A_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_A_2_TokenPA_for_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_A_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_A_text_3_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_A_4_TNb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
-               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_udkey_A_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
-               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_udkey_A_4_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_B_3_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_B_3_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-            |}
-            ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_udkey_B_3_P t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_B_3_TNa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
-               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_udkey_B_3_TNp t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-            |}
-            ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_udkey_B_3_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-            |}
-            ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_udkey_B_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
-               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_udkey_B_3_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_B_text_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_B_text_4_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_P_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_P_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_P_1_TVPa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_P_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_P_text_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_P_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_P_text_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_A_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_A_1_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_A_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_A_3_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
-               s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
-            |}
-            ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_udkey_A_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
-               s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
-            |}
-            ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_udkey_A_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_A_3_TokenPA_for_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_A_text_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_A_text_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_A_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_5'', s(MV ''Rb'' tid0), LN ''Rpa'' tid0,
-               s(MV ''Text8'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_udkey_A_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_B_4_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-            |}
-            ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_udkey_B_4_P t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_B_4_Rpa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
-               s(MV ''Text6'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_udkey_B_4_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-            |}
-            ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_udkey_B_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
-               s(MV ''Text6'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_udkey_B_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_B_text_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_B_text_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_P_2_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_P_2_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_P_2_Ra t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_P_2_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_P_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_P_text_3_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_P_text_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_P_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_2_bdkey_composed_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_2_bdkey_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_1_udkey_B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_1_udkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_1_udkey_B_1 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_1_udkey_A &
-        ( tid1, isoiec_9798_2_1_udkey_A_1 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
-           s(MV ''Text1'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
-                s(MV ''Text1'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
-                          s(MV ''Text1'' tid0)
-                       |}
-                       ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_1_udkey_A_1_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_2_udkey_B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_2_udkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_2_udkey_B_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_2_udkey_A &
-        ( tid1, isoiec_9798_2_2_udkey_A_2 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(MV ''RB'' tid1),
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''RB'' tid0,
-                s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_2_enc_2'', LN ''RB'' tid0, s(MV ''Text2'' tid0)
-                       |}
-                       ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_2_udkey_A_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_3_udkey_A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_3_udkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_3_udkey_A_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_3_udkey_B &
-        ( tid1, isoiec_9798_2_3_udkey_B_2 ) : steps t &
-        {| s(MV ''A'' tid1), s(AV ''B'' tid1), LN ''TNB'' tid1,
-           s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNB'' tid0),
-                s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
-                          s(MV ''Text3'' tid0)
-                       |}
-                       ( K ( s(AV ''B'' tid0) ) ( s(AV ''A'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_3_udkey_B_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_3_udkey_B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_3_udkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_3_udkey_B_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_3_udkey_A &
-        ( tid1, isoiec_9798_2_3_udkey_A_1 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
-           s(MV ''Text1'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
-                s(MV ''Text1'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
-                          s(MV ''Text1'' tid0)
-                       |}
-                       ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_3_udkey_A_1_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_4_udkey_A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_4_udkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_4_udkey_A_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_4_udkey_B &
-        ( tid1, isoiec_9798_2_4_udkey_B_3 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''RA'' tid1), LN ''RB'' tid1,
-           s(MV ''Text2'' tid1), s(MV ''Text4'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''RA'' tid0,
-                s(MV ''RB'' tid0), s(MV ''Text2'' tid0), s(MV ''Text4'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_4_enc_2'', s(MV ''RB'' tid0), LN ''RA'' tid0,
-                          s(MV ''Text4'' tid0)
-                       |}
-                       ( K ( s(MV ''B'' tid0) ) ( s(AV ''A'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_4_udkey_B_3_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_2_4_enc_1'', LN ''RA'' tid0, LN ''RB'' tid1,
-                            s(MV ''Text2'' tid1)
-                         |}
-                         ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid1) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_2_4_udkey_A_2_enc tid2) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_4_udkey_B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_4_udkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_4_udkey_B_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_4_udkey_A &
-        ( tid1, isoiec_9798_2_4_udkey_A_2 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''RA'' tid1, s(MV ''RB'' tid1),
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''RA'' tid0),
-                LN ''RB'' tid0, s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
-                          s(MV ''Text2'' tid0)
-                       |}
-                       ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_4_udkey_A_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_udkey_P_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_P"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "LN ''Kab'' tid0 : knows t"
-  shows "False"
-using facts proof(sources! " LN ''Kab'' tid0 ")
-  case isoiec_9798_2_5_udkey_P_2_Kab note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-next
-  case isoiec_9798_2_5_udkey_P_2_Kab_1 note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-qed (insert facts, fastsimp+)?
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_udkey_A_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_udkey_A_2 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_udkey_P_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp dest: isoiec_9798_2_5_udkey_P_secret_Kab intro: event_predOrdI)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_udkey_B_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_udkey_B_3 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-                       |}
-                       ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_udkey_P_2_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp dest: isoiec_9798_2_5_udkey_P_secret_Kab intro: event_predOrdI)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_udkey_A_non_injective_agreement_B:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_udkey_A_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_udkey_B &
-        ( tid1, isoiec_9798_2_5_udkey_B_4 ) : steps t &
-        {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
-           s(MV ''Kab'' tid1), s(MV ''TNa'' tid1), s(MV ''Text5'' tid1),
-           LN ''TNb'' tid1, s(MV ''Text7'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
-                s(MV ''Kab'' tid0), LN ''TNa'' tid0, s(MV ''Text5'' tid0),
-                s(MV ''TNb'' tid0), s(MV ''Text7'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_udkey_P_2_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
-                            s(AV ''A'' tid0), s(MV ''Text7'' tid0)
-                         |}
-                         ( LN ''Kab'' tid1 ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_5_udkey_P_secret_Kab intro: event_predOrdI)
-    next
-      case (isoiec_9798_2_5_udkey_B_4_enc tid2) note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid2),
-                              LN ''Kab'' tid1, s(AV ''A'' tid0), s(MV ''Text2'' tid2)
-                           |}
-                           ( K ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: isoiec_9798_2_5_udkey_P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_5_udkey_P_2_enc_1 tid3) note_unified facts = this facts
-        thus ?thesis proof(sources! "
-                         Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid2),
-                                s(AV ''B'' tid0), s(MV ''Text5'' tid2)
-                             |}
-                             ( LN ''Kab'' tid1 ) ")
-          case fake note_unified facts = this facts
-          thus ?thesis by (fastsimp dest: isoiec_9798_2_5_udkey_P_secret_Kab intro: event_predOrdI)
-        next
-          case (isoiec_9798_2_5_udkey_A_3_enc tid3) note_unified facts = this facts
-          thus ?thesis proof(sources! "
-                           Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid3, LN ''Kab'' tid1,
-                                  s(AV ''B'' tid0), s(MV ''Text3'' tid3)
-                               |}
-                               ( K ( s(AV ''A'' tid3) ) ( s(AV ''P'' tid3) ) ) ")
-            case fake note_unified facts = this facts
-            thus ?thesis by (fastsimp dest: isoiec_9798_2_5_udkey_P_secret_Kab intro: event_predOrdI)
-          next
-            case (isoiec_9798_2_5_udkey_P_2_enc tid4) note_unified facts = this facts
-            thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-          qed (insert facts, fastsimp+)?
-        qed (insert facts, fastsimp+)?
-      qed (insert facts, fastsimp+)?
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_udkey_B_non_injective_agreement_A:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_udkey_B_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_udkey_A &
-        ( tid1, isoiec_9798_2_5_udkey_A_3 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Kab'' tid1), LN ''TNa'' tid1, s(MV ''Text5'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                s(MV ''Kab'' tid0), s(MV ''TNa'' tid0), s(MV ''Text5'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-                       |}
-                       ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_udkey_P_2_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
-                            s(AV ''B'' tid0), s(MV ''Text5'' tid0)
-                         |}
-                         ( LN ''Kab'' tid1 ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_5_udkey_P_secret_Kab intro: event_predOrdI)
-    next
-      case (isoiec_9798_2_5_udkey_A_3_enc tid2) note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid2, LN ''Kab'' tid1,
-                              s(AV ''B'' tid0), s(MV ''Text3'' tid2)
-                           |}
-                           ( K ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: isoiec_9798_2_5_udkey_P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_5_udkey_P_2_enc tid3) note_unified facts = this facts
-        thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-      qed (insert facts, fastsimp+)?
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_udkey_A_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_udkey_A_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_udkey_P &
-        ( tid1, isoiec_9798_2_5_udkey_P_2 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
-           s(MV ''TVPa'' tid1), s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
-                s(MV ''Kab'' tid0), LN ''TVPa'' tid0, s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_udkey_P_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_udkey_B_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_udkey_B_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_udkey_P &
-        ( tid1, isoiec_9798_2_5_udkey_P_2 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
-           LN ''TNp'' tid1, s(MV ''Text2'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                s(MV ''Kab'' tid0), s(MV ''TNp'' tid0), s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-                       |}
-                       ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_udkey_P_2_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_udkey_P_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_udkey_P"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "LN ''Kab'' tid0 : knows t"
-  shows "False"
-using facts proof(sources! " LN ''Kab'' tid0 ")
-  case isoiec_9798_2_6_udkey_P_3_Kab note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-next
-  case isoiec_9798_2_6_udkey_P_3_Kab_1 note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-qed (insert facts, fastsimp+)?
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_udkey_A_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_udkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_udkey_A_3 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
-                          s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
-                       |}
-                       ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_udkey_P_3_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp dest: isoiec_9798_2_6_udkey_P_secret_Kab intro: event_predOrdI)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_udkey_B_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_udkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_udkey_B_4 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_udkey_P_3_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp dest: isoiec_9798_2_6_udkey_P_secret_Kab intro: event_predOrdI)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_udkey_A_non_injective_agreement_B:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_udkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_udkey_A_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_udkey_B &
-        ( tid1, isoiec_9798_2_6_udkey_B_5 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
-           s(MV ''Kab'' tid1), s(MV ''Rpa'' tid1), LN ''Rb'' tid1,
-           s(MV ''Text6'' tid1), s(MV ''Text8'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
-                s(MV ''Kab'' tid0), LN ''Rpa'' tid0, s(MV ''Rb'' tid0),
-                s(MV ''Text6'' tid0), s(MV ''Text8'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
-                          s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
-                       |}
-                       ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_udkey_P_3_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_2_6_enc_5'', s(MV ''Rb'' tid0), LN ''Rpa'' tid0,
-                            s(MV ''Text8'' tid0)
-                         |}
-                         ( LN ''Kab'' tid1 ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_6_udkey_P_secret_Kab intro: event_predOrdI)
-    next
-      case (isoiec_9798_2_6_udkey_B_5_enc tid2) note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid2, LN ''Kab'' tid1,
-                              s(AV ''A'' tid2), s(MV ''Text3'' tid2)
-                           |}
-                           ( K ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: isoiec_9798_2_6_udkey_P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_6_udkey_P_3_enc_1 tid3) note_unified facts = this facts
-        thus ?thesis proof(sources! "
-                         Enc {| LC ''isoiec_9798_2_6_enc_4'', LN ''Rpa'' tid0, LN ''Rb'' tid2,
-                                s(MV ''Text6'' tid2)
-                             |}
-                             ( LN ''Kab'' tid1 ) ")
-          case fake note_unified facts = this facts
-          thus ?thesis by (fastsimp dest: isoiec_9798_2_6_udkey_P_secret_Kab intro: event_predOrdI)
-        next
-          case (isoiec_9798_2_6_udkey_A_4_enc tid3) note_unified facts = this facts
-          thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-        qed (insert facts, fastsimp+)?
-      qed (insert facts, fastsimp+)?
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_udkey_B_non_injective_agreement_A:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_udkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_udkey_B_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_udkey_A &
-        ( tid1, isoiec_9798_2_6_udkey_A_4 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Kab'' tid1), LN ''Rpa'' tid1, s(MV ''Rb'' tid1),
-           s(MV ''Text6'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                s(MV ''Kab'' tid0), s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
-                s(MV ''Text6'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_udkey_P_3_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
-                            s(MV ''Text6'' tid0)
-                         |}
-                         ( LN ''Kab'' tid1 ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: isoiec_9798_2_6_udkey_P_secret_Kab intro: event_predOrdI)
-    next
-      case (isoiec_9798_2_6_udkey_A_4_enc tid2) note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid2, LN ''Kab'' tid1,
-                              s(MV ''B'' tid2), s(MV ''Text4'' tid2)
-                           |}
-                           ( K ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: isoiec_9798_2_6_udkey_P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_6_udkey_P_3_enc tid3) note_unified facts = this facts
-        thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-      qed (insert facts, fastsimp+)?
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_udkey_A_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_udkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_udkey_A_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_udkey_P &
-        ( tid1, isoiec_9798_2_6_udkey_P_3 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Ra'' tid1), LN ''Kab'' tid1, s(MV ''Text4'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
-                LN ''Ra'' tid0, s(MV ''Kab'' tid0), s(MV ''Text4'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
-                          s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
-                       |}
-                       ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_udkey_P_3_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_udkey_B_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_udkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_udkey_B_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_udkey_P &
-        ( tid1, isoiec_9798_2_6_udkey_P_3 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Rb'' tid1), LN ''Kab'' tid1, s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                LN ''Rb'' tid0, s(MV ''Kab'' tid0), s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_udkey_P_3_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+  "ESPLogic"
+begin
+
+role isoiec_9798_2_1_udkey_A
+where "isoiec_9798_2_1_udkey_A =
+  [ Send ''leak_A'' ( sN ''TNA'' )
+  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
+  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
+                  PEnc <| sC ''isoiec_9798_2_1_enc_1'', sN ''TNA'', sMV ''Text1'' |>
+                       ( sK ''A'' ''B'' )
+               |>
+  ]"
+
+role isoiec_9798_2_1_udkey_B
+where "isoiec_9798_2_1_udkey_B =
+  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
+                  PEnc <| sC ''isoiec_9798_2_1_enc_1'', sMV ''TNA'', sMV ''Text1'' |>
+                       ( PSymK ( sMV ''A'' ) ( sAV ''B'' ) )
+               |>
+  ]"
+
+role isoiec_9798_2_2_udkey_A
+where "isoiec_9798_2_2_udkey_A =
+  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text1'' |>
+  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
+  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
+                  PEnc <| sC ''isoiec_9798_2_2_enc_2'', sMV ''RB'', sMV ''Text2'' |>
+                       ( PSymK ( sAV ''A'' ) ( sMV ''B'' ) )
+               |>
+  ]"
+
+role isoiec_9798_2_2_udkey_B
+where "isoiec_9798_2_2_udkey_B =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''RB'', sMV ''Text1'' |>
+  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
+                  PEnc <| sC ''isoiec_9798_2_2_enc_2'', sN ''RB'', sMV ''Text2'' |>
+                       ( sK ''A'' ''B'' )
+               |>
+  ]"
+
+role isoiec_9798_2_3_udkey_A
+where "isoiec_9798_2_3_udkey_A =
+  [ Send ''leak_A'' ( sN ''TNA'' )
+  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
+  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
+                  PEnc <| sC ''isoiec_9798_2_3_enc_1'', sN ''TNA'', sMV ''Text1'' |>
+                       ( sK ''A'' ''B'' )
+               |>
+  , Recv ''2'' <| sAV ''B'', sAV ''A'', sMV ''Text4'',
+                  PEnc <| sC ''isoiec_9798_2_3_enc_2'', sMV ''TNB'', sMV ''Text3'' |>
+                       ( sK ''B'' ''A'' )
+               |>
+  ]"
+
+role isoiec_9798_2_3_udkey_B
+where "isoiec_9798_2_3_udkey_B =
+  [ Send ''leak_B'' ( sN ''TNB'' )
+  , Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
+                  PEnc <| sC ''isoiec_9798_2_3_enc_1'', sMV ''TNA'', sMV ''Text1'' |>
+                       ( PSymK ( sMV ''A'' ) ( sAV ''B'' ) )
+               |>
+  , Recv ''text_2'' <| sMV ''Text3'', sMV ''Text4'' |>
+  , Send ''2'' <| sAV ''B'', sMV ''A'', sMV ''Text4'',
+                  PEnc <| sC ''isoiec_9798_2_3_enc_2'', sN ''TNB'', sMV ''Text3'' |>
+                       ( PSymK ( sAV ''B'' ) ( sMV ''A'' ) )
+               |>
+  ]"
+
+role isoiec_9798_2_4_udkey_A
+where "isoiec_9798_2_4_udkey_A =
+  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text1'' |>
+  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
+  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
+                  PEnc <| sC ''isoiec_9798_2_4_enc_1'', sN ''RA'', sMV ''RB'',
+                          sMV ''Text2''
+                       |>
+                       ( PSymK ( sAV ''A'' ) ( sMV ''B'' ) )
+               |>
+  , Recv ''3'' <| sMV ''B'', sAV ''A'', sMV ''Text5'',
+                  PEnc <| sC ''isoiec_9798_2_4_enc_2'', sMV ''RB'', sN ''RA'',
+                          sMV ''Text4''
+                       |>
+                       ( PSymK ( sMV ''B'' ) ( sAV ''A'' ) )
+               |>
+  ]"
+
+role isoiec_9798_2_4_udkey_B
+where "isoiec_9798_2_4_udkey_B =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''RB'', sMV ''Text1'' |>
+  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
+                  PEnc <| sC ''isoiec_9798_2_4_enc_1'', sMV ''RA'', sN ''RB'',
+                          sMV ''Text2''
+                       |>
+                       ( sK ''A'' ''B'' )
+               |>
+  , Recv ''text_3'' <| sMV ''Text4'', sMV ''Text5'' |>
+  , Send ''3'' <| sAV ''B'', sAV ''A'', sMV ''Text5'',
+                  PEnc <| sC ''isoiec_9798_2_4_enc_2'', sN ''RB'', sMV ''RA'',
+                          sMV ''Text4''
+                       |>
+                       ( sK ''B'' ''A'' )
+               |>
+  ]"
+
+role isoiec_9798_2_5_udkey_A
+where "isoiec_9798_2_5_udkey_A =
+  [ Send ''leak_A'' <| sN ''TVPa'', sN ''TNa'' |>
+  , Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''A'', sAV ''P'', sN ''TVPa'', sAV ''B'',
+                  sMV ''Text1''
+               |>
+  , Recv ''2'' <| sAV ''P'', sAV ''A'', sMV ''Text4'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_2_1'', sN ''TVPa'', sMV ''Kab'',
+                          sAV ''B'', sMV ''Text3''
+                       |>
+                       ( sK ''A'' ''P'' ),
+                  sMV ''TokenPA_for_B''
+               |>
+  , Recv ''text_3'' <| sMV ''Text5'', sMV ''Text6'' |>
+  , Send ''3'' <| sAV ''A'', sAV ''B'', sMV ''Text6'', sAV ''P'',
+                  sMV ''TokenPA_for_B'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_3'', sN ''TNa'', sAV ''B'',
+                          sMV ''Text5''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''4'' <| sAV ''B'', sAV ''A'', sMV ''Text8'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_4'', sMV ''TNb'', sAV ''A'',
+                          sMV ''Text7''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_5_udkey_B
+where "isoiec_9798_2_5_udkey_B =
+  [ Send ''leak_B'' ( sN ''TNb'' )
+  , Recv ''3'' <| sMV ''A'', sAV ''B'', sMV ''Text6'', sMV ''P'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_2_2'', sMV ''TNp'', sMV ''Kab'',
+                          sMV ''A'', sMV ''Text2''
+                       |>
+                       ( PSymK ( sAV ''B'' ) ( sMV ''P'' ) ),
+                  PEnc <| sC ''isoiec_9798_2_5_enc_3'', sMV ''TNa'', sAV ''B'',
+                          sMV ''Text5''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''text_4'' <| sMV ''Text7'', sMV ''Text8'' |>
+  , Send ''4'' <| sAV ''B'', sMV ''A'', sMV ''Text8'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_4'', sN ''TNb'', sMV ''A'',
+                          sMV ''Text7''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_5_udkey_P
+where "isoiec_9798_2_5_udkey_P =
+  [ Send ''leak_P'' ( sN ''TNp'' )
+  , Recv ''1'' <| sMV ''A'', sAV ''P'', sMV ''TVPa'', sMV ''B'',
+                  sMV ''Text1''
+               |>
+  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'', sMV ''Text4'' |>
+  , Send ''2'' <| sAV ''P'', sMV ''A'', sMV ''Text4'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_2_1'', sMV ''TVPa'', sN ''Kab'',
+                          sMV ''B'', sMV ''Text3''
+                       |>
+                       ( PSymK ( sMV ''A'' ) ( sAV ''P'' ) ),
+                  PEnc <| sC ''isoiec_9798_2_5_enc_2_2'', sN ''TNp'', sN ''Kab'',
+                          sMV ''A'', sMV ''Text2''
+                       |>
+                       ( PSymK ( sMV ''B'' ) ( sAV ''P'' ) )
+               |>
+  ]"
+
+role isoiec_9798_2_6_udkey_A
+where "isoiec_9798_2_6_udkey_A =
+  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
+  , Recv ''text_2'' ( sMV ''Text2'' )
+  , Send ''2'' <| sAV ''A'', sAV ''P'', sN ''Ra'', sMV ''Rb'', sMV ''B'',
+                  sMV ''Text2''
+               |>
+  , Recv ''3'' <| sAV ''P'', sAV ''A'', sMV ''Text5'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_3_1'', sN ''Ra'', sMV ''Kab'',
+                          sMV ''B'', sMV ''Text4''
+                       |>
+                       ( sK ''A'' ''P'' ),
+                  sMV ''TokenPA_for_B''
+               |>
+  , Recv ''text_4'' <| sMV ''Text6'', sMV ''Text7'' |>
+  , Send ''4'' <| sAV ''A'', sMV ''B'', sMV ''Text7'', sAV ''P'',
+                  sMV ''TokenPA_for_B'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_4'', sN ''Rpa'', sMV ''Rb'',
+                          sMV ''Text6''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''5'' <| sMV ''B'', sAV ''A'', sMV ''Text9'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_5'', sMV ''Rb'', sN ''Rpa'',
+                          sMV ''Text8''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_6_udkey_B
+where "isoiec_9798_2_6_udkey_B =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
+  , Recv ''4'' <| sAV ''A'', sAV ''B'', sMV ''Text7'', sMV ''P'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_3_2'', sN ''Rb'', sMV ''Kab'',
+                          sAV ''A'', sMV ''Text3''
+                       |>
+                       ( PSymK ( sAV ''B'' ) ( sMV ''P'' ) ),
+                  PEnc <| sC ''isoiec_9798_2_6_enc_4'', sMV ''Rpa'', sN ''Rb'',
+                          sMV ''Text6''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
+  , Send ''5'' <| sAV ''B'', sAV ''A'', sMV ''Text9'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_5'', sN ''Rb'', sMV ''Rpa'',
+                          sMV ''Text8''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_6_udkey_P
+where "isoiec_9798_2_6_udkey_P =
+  [ Recv ''2'' <| sMV ''A'', sAV ''P'', sMV ''Ra'', sMV ''Rb'', sMV ''B'',
+                  sMV ''Text2''
+               |>
+  , Recv ''text_3'' <| sMV ''Text3'', sMV ''Text4'', sMV ''Text5'' |>
+  , Send ''3'' <| sAV ''P'', sMV ''A'', sMV ''Text5'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_3_1'', sMV ''Ra'', sN ''Kab'',
+                          sMV ''B'', sMV ''Text4''
+                       |>
+                       ( PSymK ( sMV ''A'' ) ( sAV ''P'' ) ),
+                  PEnc <| sC ''isoiec_9798_2_6_enc_3_2'', sMV ''Rb'', sN ''Kab'',
+                          sMV ''A'', sMV ''Text3''
+                       |>
+                       ( PSymK ( sMV ''B'' ) ( sAV ''P'' ) )
+               |>
+  ]"
+
+protocol isoiec_9798_2_bdkey
+where "isoiec_9798_2_bdkey =
+{ isoiec_9798_2_1_udkey_A, isoiec_9798_2_1_udkey_B,
+  isoiec_9798_2_2_udkey_A, isoiec_9798_2_2_udkey_B,
+  isoiec_9798_2_3_udkey_A, isoiec_9798_2_3_udkey_B,
+  isoiec_9798_2_4_udkey_A, isoiec_9798_2_4_udkey_B,
+  isoiec_9798_2_5_udkey_A, isoiec_9798_2_5_udkey_B,
+  isoiec_9798_2_5_udkey_P, isoiec_9798_2_6_udkey_A,
+  isoiec_9798_2_6_udkey_B, isoiec_9798_2_6_udkey_P
+}"
+
+locale restricted_isoiec_9798_2_bdkey_state = isoiec_9798_2_bdkey_state
+
+type_invariant isoiec_9798_2_bdkey_composed_typing for isoiec_9798_2_bdkey
+where "isoiec_9798_2_bdkey_composed_typing = mk_typing
+  [ ((isoiec_9798_2_1_udkey_B, ''A''), (KnownT isoiec_9798_2_1_udkey_B_1))
+  , ((isoiec_9798_2_3_udkey_B, ''A''), (KnownT isoiec_9798_2_3_udkey_B_1))
+  , ((isoiec_9798_2_5_udkey_B, ''A''), (KnownT isoiec_9798_2_5_udkey_B_3))
+  , ((isoiec_9798_2_5_udkey_P, ''A''), (KnownT isoiec_9798_2_5_udkey_P_1))
+  , ((isoiec_9798_2_6_udkey_P, ''A''), (KnownT isoiec_9798_2_6_udkey_P_2))
+  , ((isoiec_9798_2_2_udkey_A, ''B''), (KnownT isoiec_9798_2_2_udkey_A_1))
+  , ((isoiec_9798_2_4_udkey_A, ''B''), (KnownT isoiec_9798_2_4_udkey_A_1))
+  , ((isoiec_9798_2_5_udkey_P, ''B''), (KnownT isoiec_9798_2_5_udkey_P_1))
+  , ((isoiec_9798_2_6_udkey_A, ''B''), (KnownT isoiec_9798_2_6_udkey_A_1))
+  , ((isoiec_9798_2_6_udkey_P, ''B''), (KnownT isoiec_9798_2_6_udkey_P_2))
+  , ((isoiec_9798_2_5_udkey_A, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_5_udkey_A_2) (NonceT isoiec_9798_2_5_udkey_P ''Kab'')))
+  , ((isoiec_9798_2_5_udkey_B, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_5_udkey_B_3) (NonceT isoiec_9798_2_5_udkey_P ''Kab'')))
+  , ((isoiec_9798_2_6_udkey_A, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_6_udkey_A_3) (NonceT isoiec_9798_2_6_udkey_P ''Kab'')))
+  , ((isoiec_9798_2_6_udkey_B, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_6_udkey_B_4) (NonceT isoiec_9798_2_6_udkey_P ''Kab'')))
+  , ((isoiec_9798_2_5_udkey_B, ''P''), (KnownT isoiec_9798_2_5_udkey_B_3))
+  , ((isoiec_9798_2_6_udkey_B, ''P''), (KnownT isoiec_9798_2_6_udkey_B_4))
+  , ((isoiec_9798_2_4_udkey_B, ''RA''),
+     (SumT (KnownT isoiec_9798_2_4_udkey_B_2) (NonceT isoiec_9798_2_4_udkey_A ''RA'')))
+  , ((isoiec_9798_2_2_udkey_A, ''RB''), (KnownT isoiec_9798_2_2_udkey_A_1))
+  , ((isoiec_9798_2_4_udkey_A, ''RB''), (KnownT isoiec_9798_2_4_udkey_A_1))
+  , ((isoiec_9798_2_6_udkey_P, ''Ra''), (KnownT isoiec_9798_2_6_udkey_P_2))
+  , ((isoiec_9798_2_6_udkey_A, ''Rb''), (KnownT isoiec_9798_2_6_udkey_A_1))
+  , ((isoiec_9798_2_6_udkey_P, ''Rb''), (KnownT isoiec_9798_2_6_udkey_P_2))
+  , ((isoiec_9798_2_6_udkey_B, ''Rpa''),
+     (SumT (KnownT isoiec_9798_2_6_udkey_B_4) (NonceT isoiec_9798_2_6_udkey_A ''Rpa'')))
+  , ((isoiec_9798_2_1_udkey_B, ''TNA''),
+     (SumT (KnownT isoiec_9798_2_1_udkey_B_1) (NonceT isoiec_9798_2_1_udkey_A ''TNA'')))
+  , ((isoiec_9798_2_3_udkey_B, ''TNA''),
+     (SumT (KnownT isoiec_9798_2_3_udkey_B_1) (NonceT isoiec_9798_2_3_udkey_A ''TNA'')))
+  , ((isoiec_9798_2_3_udkey_A, ''TNB''),
+     (SumT (KnownT isoiec_9798_2_3_udkey_A_2) (NonceT isoiec_9798_2_3_udkey_B ''TNB'')))
+  , ((isoiec_9798_2_5_udkey_B, ''TNa''),
+     (SumT (KnownT isoiec_9798_2_5_udkey_B_3) (NonceT isoiec_9798_2_5_udkey_A ''TNa'')))
+  , ((isoiec_9798_2_5_udkey_A, ''TNb''),
+     (SumT (KnownT isoiec_9798_2_5_udkey_A_4) (NonceT isoiec_9798_2_5_udkey_B ''TNb'')))
+  , ((isoiec_9798_2_5_udkey_B, ''TNp''),
+     (SumT (KnownT isoiec_9798_2_5_udkey_B_3) (NonceT isoiec_9798_2_5_udkey_P ''TNp'')))
+  , ((isoiec_9798_2_5_udkey_P, ''TVPa''),
+     (KnownT isoiec_9798_2_5_udkey_P_1))
+  , ((isoiec_9798_2_1_udkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_1_udkey_A_text_1))
+  , ((isoiec_9798_2_1_udkey_B, ''Text1''),
+     (KnownT isoiec_9798_2_1_udkey_B_1))
+  , ((isoiec_9798_2_2_udkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_2_udkey_A_1))
+  , ((isoiec_9798_2_2_udkey_B, ''Text1''),
+     (KnownT isoiec_9798_2_2_udkey_B_text_1))
+  , ((isoiec_9798_2_3_udkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_3_udkey_A_text_1))
+  , ((isoiec_9798_2_3_udkey_B, ''Text1''),
+     (KnownT isoiec_9798_2_3_udkey_B_1))
+  , ((isoiec_9798_2_4_udkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_4_udkey_A_1))
+  , ((isoiec_9798_2_4_udkey_B, ''Text1''),
+     (KnownT isoiec_9798_2_4_udkey_B_text_1))
+  , ((isoiec_9798_2_5_udkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_5_udkey_A_text_1))
+  , ((isoiec_9798_2_5_udkey_P, ''Text1''),
+     (KnownT isoiec_9798_2_5_udkey_P_1))
+  , ((isoiec_9798_2_6_udkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_6_udkey_A_1))
+  , ((isoiec_9798_2_6_udkey_B, ''Text1''),
+     (KnownT isoiec_9798_2_6_udkey_B_text_1))
+  , ((isoiec_9798_2_1_udkey_A, ''Text2''),
+     (KnownT isoiec_9798_2_1_udkey_A_text_1))
+  , ((isoiec_9798_2_1_udkey_B, ''Text2''),
+     (KnownT isoiec_9798_2_1_udkey_B_1))
+  , ((isoiec_9798_2_2_udkey_A, ''Text2''),
+     (KnownT isoiec_9798_2_2_udkey_A_text_2))
+  , ((isoiec_9798_2_2_udkey_B, ''Text2''),
+     (KnownT isoiec_9798_2_2_udkey_B_2))
+  , ((isoiec_9798_2_3_udkey_A, ''Text2''),
+     (KnownT isoiec_9798_2_3_udkey_A_text_1))
+  , ((isoiec_9798_2_3_udkey_B, ''Text2''),
+     (KnownT isoiec_9798_2_3_udkey_B_1))
+  , ((isoiec_9798_2_4_udkey_A, ''Text2''),
+     (KnownT isoiec_9798_2_4_udkey_A_text_2))
+  , ((isoiec_9798_2_4_udkey_B, ''Text2''),
+     (KnownT isoiec_9798_2_4_udkey_B_2))
+  , ((isoiec_9798_2_5_udkey_B, ''Text2''),
+     (KnownT isoiec_9798_2_5_udkey_B_3))
+  , ((isoiec_9798_2_5_udkey_P, ''Text2''),
+     (KnownT isoiec_9798_2_5_udkey_P_text_2))
+  , ((isoiec_9798_2_6_udkey_A, ''Text2''),
+     (KnownT isoiec_9798_2_6_udkey_A_text_2))
+  , ((isoiec_9798_2_6_udkey_P, ''Text2''),
+     (KnownT isoiec_9798_2_6_udkey_P_2))
+  , ((isoiec_9798_2_2_udkey_A, ''Text3''),
+     (KnownT isoiec_9798_2_2_udkey_A_text_2))
+  , ((isoiec_9798_2_2_udkey_B, ''Text3''),
+     (KnownT isoiec_9798_2_2_udkey_B_2))
+  , ((isoiec_9798_2_3_udkey_A, ''Text3''),
+     (KnownT isoiec_9798_2_3_udkey_A_2))
+  , ((isoiec_9798_2_3_udkey_B, ''Text3''),
+     (KnownT isoiec_9798_2_3_udkey_B_text_2))
+  , ((isoiec_9798_2_4_udkey_A, ''Text3''),
+     (KnownT isoiec_9798_2_4_udkey_A_text_2))
+  , ((isoiec_9798_2_4_udkey_B, ''Text3''),
+     (KnownT isoiec_9798_2_4_udkey_B_2))
+  , ((isoiec_9798_2_5_udkey_A, ''Text3''),
+     (KnownT isoiec_9798_2_5_udkey_A_2))
+  , ((isoiec_9798_2_5_udkey_P, ''Text3''),
+     (KnownT isoiec_9798_2_5_udkey_P_text_2))
+  , ((isoiec_9798_2_6_udkey_B, ''Text3''),
+     (KnownT isoiec_9798_2_6_udkey_B_4))
+  , ((isoiec_9798_2_6_udkey_P, ''Text3''),
+     (KnownT isoiec_9798_2_6_udkey_P_text_3))
+  , ((isoiec_9798_2_3_udkey_A, ''Text4''),
+     (KnownT isoiec_9798_2_3_udkey_A_2))
+  , ((isoiec_9798_2_3_udkey_B, ''Text4''),
+     (KnownT isoiec_9798_2_3_udkey_B_text_2))
+  , ((isoiec_9798_2_4_udkey_A, ''Text4''),
+     (KnownT isoiec_9798_2_4_udkey_A_3))
+  , ((isoiec_9798_2_4_udkey_B, ''Text4''),
+     (KnownT isoiec_9798_2_4_udkey_B_text_3))
+  , ((isoiec_9798_2_5_udkey_A, ''Text4''),
+     (KnownT isoiec_9798_2_5_udkey_A_2))
+  , ((isoiec_9798_2_5_udkey_P, ''Text4''),
+     (KnownT isoiec_9798_2_5_udkey_P_text_2))
+  , ((isoiec_9798_2_6_udkey_A, ''Text4''),
+     (KnownT isoiec_9798_2_6_udkey_A_3))
+  , ((isoiec_9798_2_6_udkey_P, ''Text4''),
+     (KnownT isoiec_9798_2_6_udkey_P_text_3))
+  , ((isoiec_9798_2_4_udkey_A, ''Text5''),
+     (KnownT isoiec_9798_2_4_udkey_A_3))
+  , ((isoiec_9798_2_4_udkey_B, ''Text5''),
+     (KnownT isoiec_9798_2_4_udkey_B_text_3))
+  , ((isoiec_9798_2_5_udkey_A, ''Text5''),
+     (KnownT isoiec_9798_2_5_udkey_A_text_3))
+  , ((isoiec_9798_2_5_udkey_B, ''Text5''),
+     (KnownT isoiec_9798_2_5_udkey_B_3))
+  , ((isoiec_9798_2_6_udkey_A, ''Text5''),
+     (KnownT isoiec_9798_2_6_udkey_A_3))
+  , ((isoiec_9798_2_6_udkey_P, ''Text5''),
+     (KnownT isoiec_9798_2_6_udkey_P_text_3))
+  , ((isoiec_9798_2_5_udkey_A, ''Text6''),
+     (KnownT isoiec_9798_2_5_udkey_A_text_3))
+  , ((isoiec_9798_2_5_udkey_B, ''Text6''),
+     (KnownT isoiec_9798_2_5_udkey_B_3))
+  , ((isoiec_9798_2_6_udkey_A, ''Text6''),
+     (KnownT isoiec_9798_2_6_udkey_A_text_4))
+  , ((isoiec_9798_2_6_udkey_B, ''Text6''),
+     (KnownT isoiec_9798_2_6_udkey_B_4))
+  , ((isoiec_9798_2_5_udkey_A, ''Text7''),
+     (KnownT isoiec_9798_2_5_udkey_A_4))
+  , ((isoiec_9798_2_5_udkey_B, ''Text7''),
+     (KnownT isoiec_9798_2_5_udkey_B_text_4))
+  , ((isoiec_9798_2_6_udkey_A, ''Text7''),
+     (KnownT isoiec_9798_2_6_udkey_A_text_4))
+  , ((isoiec_9798_2_6_udkey_B, ''Text7''),
+     (KnownT isoiec_9798_2_6_udkey_B_4))
+  , ((isoiec_9798_2_5_udkey_A, ''Text8''),
+     (KnownT isoiec_9798_2_5_udkey_A_4))
+  , ((isoiec_9798_2_5_udkey_B, ''Text8''),
+     (KnownT isoiec_9798_2_5_udkey_B_text_4))
+  , ((isoiec_9798_2_6_udkey_A, ''Text8''),
+     (KnownT isoiec_9798_2_6_udkey_A_5))
+  , ((isoiec_9798_2_6_udkey_B, ''Text8''),
+     (KnownT isoiec_9798_2_6_udkey_B_text_5))
+  , ((isoiec_9798_2_6_udkey_A, ''Text9''),
+     (KnownT isoiec_9798_2_6_udkey_A_5))
+  , ((isoiec_9798_2_6_udkey_B, ''Text9''),
+     (KnownT isoiec_9798_2_6_udkey_B_text_5))
+  , ((isoiec_9798_2_5_udkey_A, ''TokenPA_for_B''),
+     (KnownT isoiec_9798_2_5_udkey_A_2))
+  , ((isoiec_9798_2_6_udkey_A, ''TokenPA_for_B''),
+     (KnownT isoiec_9798_2_6_udkey_A_3))
+  ]"
+
+sublocale isoiec_9798_2_bdkey_state < isoiec_9798_2_bdkey_composed_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_2_bdkey_composed_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_2_bdkey_composed_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_2_1_udkey_A_text_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_1_udkey_A_text_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_1_udkey_B_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_1_udkey_B_1_TNA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
+               s(MV ''Text1'' tid0)
+            |}
+            ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_1_udkey_B_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
+               s(MV ''Text1'' tid0)
+            |}
+            ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_1_udkey_B_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_2_udkey_A_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_2_udkey_A_1_RB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_2_udkey_A_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_2_udkey_A_text_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_2_udkey_A_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_2_udkey_B_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_2_enc_2'', LN ''RB'' tid0, s(MV ''Text2'' tid0)
+            |}
+            ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_2_udkey_B_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_udkey_A_text_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_udkey_A_text_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_udkey_A_2_TNB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
+               s(MV ''Text3'' tid0)
+            |}
+            ( K ( s(AV ''B'' tid0) ) ( s(AV ''A'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_3_udkey_A_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
+               s(MV ''Text3'' tid0)
+            |}
+            ( K ( s(AV ''B'' tid0) ) ( s(AV ''A'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_3_udkey_A_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_udkey_B_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_udkey_B_1_TNA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
+               s(MV ''Text1'' tid0)
+            |}
+            ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_3_udkey_B_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
+               s(MV ''Text1'' tid0)
+            |}
+            ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_3_udkey_B_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_udkey_B_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_udkey_B_text_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_udkey_A_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_udkey_A_1_RB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_udkey_A_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_udkey_A_text_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_udkey_A_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_udkey_A_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_4_enc_2'', s(MV ''RB'' tid0), LN ''RA'' tid0,
+               s(MV ''Text4'' tid0)
+            |}
+            ( K ( s(MV ''B'' tid0) ) ( s(AV ''A'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_4_udkey_A_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_udkey_B_2_RA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
+               s(MV ''Text2'' tid0)
+            |}
+            ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_4_udkey_B_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
+               s(MV ''Text2'' tid0)
+            |}
+            ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_4_udkey_B_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_udkey_B_text_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_udkey_B_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_A_2_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
+            |}
+            ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_udkey_A_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
+            |}
+            ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_udkey_A_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_A_2_TokenPA_for_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_A_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_A_text_3_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_A_4_TNb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
+               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_udkey_A_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
+               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_udkey_A_4_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_B_3_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_B_3_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+            |}
+            ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_udkey_B_3_P t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_B_3_TNa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
+               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_udkey_B_3_TNp t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+            |}
+            ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_udkey_B_3_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+            |}
+            ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_udkey_B_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
+               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_udkey_B_3_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_B_text_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_B_text_4_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_P_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_P_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_P_1_TVPa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_P_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_P_text_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_P_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_P_text_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_A_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_A_1_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_A_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_A_3_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
+               s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
+            |}
+            ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_udkey_A_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
+               s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
+            |}
+            ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_udkey_A_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_A_3_TokenPA_for_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_A_text_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_A_text_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_A_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_5'', s(MV ''Rb'' tid0), LN ''Rpa'' tid0,
+               s(MV ''Text8'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_udkey_A_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_B_4_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+            |}
+            ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_udkey_B_4_P t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_B_4_Rpa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
+               s(MV ''Text6'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_udkey_B_4_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+            |}
+            ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_udkey_B_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
+               s(MV ''Text6'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_udkey_B_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_B_text_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_B_text_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_P_2_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_P_2_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_P_2_Ra t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_P_2_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_P_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_P_text_3_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_P_text_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_P_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_bdkey_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_2_bdkey_composed_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_2_bdkey_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_1_udkey_B_non_injective_agreement:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_1_udkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_1_udkey_B_1 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_1_udkey_A &
+        ( tid1, isoiec_9798_2_1_udkey_A_1 ) : steps t &
+        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
+           s(MV ''Text1'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
+                s(MV ''Text1'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
+                          s(MV ''Text1'' tid0)
+                       |}
+                       ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_1_udkey_A_1_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_2_udkey_B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_2_udkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_2_udkey_B_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_2_udkey_A &
+          ( tid1, isoiec_9798_2_2_udkey_A_2 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(MV ''RB'' tid1),
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''RB'' tid0,
+                  s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_2_enc_2'', LN ''RB'' tid0, s(MV ''Text2'' tid0)
+                           |}
+                           ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_2_udkey_A_2_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_3_udkey_A_non_injective_agreement:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_3_udkey_A"
+    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_3_udkey_A_2 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_3_udkey_B &
+        ( tid1, isoiec_9798_2_3_udkey_B_2 ) : steps t &
+        {| s(MV ''A'' tid1), s(AV ''B'' tid1), LN ''TNB'' tid1,
+           s(MV ''Text3'' tid1)
+        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNB'' tid0),
+                s(MV ''Text3'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
+                          s(MV ''Text3'' tid0)
+                       |}
+                       ( K ( s(AV ''B'' tid0) ) ( s(AV ''A'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_3_udkey_B_2_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_3_udkey_B_non_injective_agreement:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_3_udkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_3_udkey_B_2 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_3_udkey_A &
+        ( tid1, isoiec_9798_2_3_udkey_A_1 ) : steps t &
+        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
+           s(MV ''Text1'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
+                s(MV ''Text1'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
+                          s(MV ''Text1'' tid0)
+                       |}
+                       ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_3_udkey_A_1_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_4_udkey_A_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_4_udkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_4_udkey_A_3 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_4_udkey_B &
+          ( tid1, isoiec_9798_2_4_udkey_B_3 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''RA'' tid1), LN ''RB'' tid1,
+             s(MV ''Text2'' tid1), s(MV ''Text4'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''RA'' tid0,
+                  s(MV ''RB'' tid0), s(MV ''Text2'' tid0), s(MV ''Text4'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_4_enc_2'', s(MV ''RB'' tid0), LN ''RA'' tid0,
+                              s(MV ''Text4'' tid0)
+                           |}
+                           ( K ( s(MV ''B'' tid0) ) ( s(AV ''A'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_4_udkey_B_3_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_2_4_enc_1'', LN ''RA'' tid0, LN ''RB'' tid1,
+                                s(MV ''Text2'' tid1)
+                             |}
+                             ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid1) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_2_4_udkey_A_2_enc tid2) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_4_udkey_B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_4_udkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_4_udkey_B_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_4_udkey_A &
+          ( tid1, isoiec_9798_2_4_udkey_A_2 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''RA'' tid1, s(MV ''RB'' tid1),
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''RA'' tid0),
+                  LN ''RB'' tid0, s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
+                              s(MV ''Text2'' tid0)
+                           |}
+                           ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_4_udkey_A_2_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_udkey_P_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_P"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
+    "LN ''Kab'' tid0 : knows t"
+  shows "False"
+using facts proof(sources! " LN ''Kab'' tid0 ")
+  case isoiec_9798_2_5_udkey_P_2_Kab note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+next
+  case isoiec_9798_2_5_udkey_P_2_Kab_1 note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+qed (insert facts, fastforce+)?
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_udkey_A_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_A"
+    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_udkey_A_2 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
+                          s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
+                       |}
+                       ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_5_udkey_P_2_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce dest: isoiec_9798_2_5_udkey_P_secret_Kab intro: event_predOrdI)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_udkey_B_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_udkey_B_3 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+                       |}
+                       ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_5_udkey_P_2_enc_1 tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce dest: isoiec_9798_2_5_udkey_P_secret_Kab intro: event_predOrdI)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_udkey_A_injective_agreement_B:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_5_udkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_5_udkey_A_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_5_udkey_B &
+          ( tid1, isoiec_9798_2_5_udkey_B_4 ) : steps t &
+          {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
+             s(MV ''Kab'' tid1), s(MV ''TNa'' tid1), s(MV ''Text5'' tid1),
+             LN ''TNb'' tid1, s(MV ''Text7'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
+                  s(MV ''Kab'' tid0), LN ''TNa'' tid0, s(MV ''Text5'' tid0),
+                  s(MV ''TNb'' tid0), s(MV ''Text7'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_5_udkey_P_2_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
+                                s(AV ''A'' tid0), s(MV ''Text7'' tid0)
+                             |}
+                             ( LN ''Kab'' tid1 ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest: isoiec_9798_2_5_udkey_P_secret_Kab intro: event_predOrdI)
+        next
+          case (isoiec_9798_2_5_udkey_B_4_enc tid2) note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid2),
+                                  LN ''Kab'' tid1, s(AV ''A'' tid0), s(MV ''Text2'' tid2)
+                               |}
+                               ( K ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) ) ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest: isoiec_9798_2_5_udkey_P_secret_Kab intro: event_predOrdI)
+          next
+            case (isoiec_9798_2_5_udkey_P_2_enc_1 tid3) note_unified facts = this facts
+            thus ?thesis proof(sources! "
+                             Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid2),
+                                    s(AV ''B'' tid0), s(MV ''Text5'' tid2)
+                                 |}
+                                 ( LN ''Kab'' tid1 ) ")
+              case fake note_unified facts = this facts
+              thus ?thesis by (fastforce dest: isoiec_9798_2_5_udkey_P_secret_Kab intro: event_predOrdI)
+            next
+              case (isoiec_9798_2_5_udkey_A_3_enc tid3) note_unified facts = this facts
+              thus ?thesis proof(sources! "
+                               Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid3, LN ''Kab'' tid1,
+                                      s(AV ''B'' tid0), s(MV ''Text3'' tid3)
+                                   |}
+                                   ( K ( s(AV ''A'' tid3) ) ( s(AV ''P'' tid3) ) ) ")
+                case fake note_unified facts = this facts
+                thus ?thesis by (fastforce dest: isoiec_9798_2_5_udkey_P_secret_Kab intro: event_predOrdI)
+              next
+                case (isoiec_9798_2_5_udkey_P_2_enc tid4) note_unified facts = this facts
+                thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+              qed (insert facts, fastforce+)?
+            qed (insert facts, fastforce+)?
+          qed (insert facts, fastforce+)?
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_udkey_B_non_injective_agreement_A:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_udkey_B_3 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_5_udkey_A &
+        ( tid1, isoiec_9798_2_5_udkey_A_3 ) : steps t &
+        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(AV ''P'' tid1),
+           s(MV ''Kab'' tid1), LN ''TNa'' tid1, s(MV ''Text5'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                s(MV ''Kab'' tid0), s(MV ''TNa'' tid0), s(MV ''Text5'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+                       |}
+                       ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_5_udkey_P_2_enc_1 tid1) note_unified facts = this facts
+    thus ?thesis proof(sources! "
+                     Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
+                            s(AV ''B'' tid0), s(MV ''Text5'' tid0)
+                         |}
+                         ( LN ''Kab'' tid1 ) ")
+      case fake note_unified facts = this facts
+      thus ?thesis by (fastforce dest: isoiec_9798_2_5_udkey_P_secret_Kab intro: event_predOrdI)
+    next
+      case (isoiec_9798_2_5_udkey_A_3_enc tid2) note_unified facts = this facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid2, LN ''Kab'' tid1,
+                              s(AV ''B'' tid0), s(MV ''Text3'' tid2)
+                           |}
+                           ( K ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest: isoiec_9798_2_5_udkey_P_secret_Kab intro: event_predOrdI)
+      next
+        case (isoiec_9798_2_5_udkey_P_2_enc tid3) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed (insert facts, fastforce+)?
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_udkey_A_injective_agreement_P:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_5_udkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_5_udkey_A_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_5_udkey_P &
+          ( tid1, isoiec_9798_2_5_udkey_P_2 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
+             s(MV ''TVPa'' tid1), s(MV ''Text3'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
+                  s(MV ''Kab'' tid0), LN ''TVPa'' tid0, s(MV ''Text3'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_5_udkey_P_2_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_5_udkey_B_non_injective_agreement_P:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_udkey_B_3 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_5_udkey_P &
+        ( tid1, isoiec_9798_2_5_udkey_P_2 ) : steps t &
+        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
+           LN ''TNp'' tid1, s(MV ''Text2'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                s(MV ''Kab'' tid0), s(MV ''TNp'' tid0), s(MV ''Text2'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+                       |}
+                       ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_5_udkey_P_2_enc_1 tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_udkey_P_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_6_udkey_P"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
+    "LN ''Kab'' tid0 : knows t"
+  shows "False"
+using facts proof(sources! " LN ''Kab'' tid0 ")
+  case isoiec_9798_2_6_udkey_P_3_Kab note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+next
+  case isoiec_9798_2_6_udkey_P_3_Kab_1 note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+qed (insert facts, fastforce+)?
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_udkey_A_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_6_udkey_A"
+    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_6_udkey_A_3 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
+                          s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
+                       |}
+                       ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_6_udkey_P_3_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce dest: isoiec_9798_2_6_udkey_P_secret_Kab intro: event_predOrdI)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_udkey_B_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_6_udkey_B"
+    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_6_udkey_B_4 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
+                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+                       |}
+                       ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_6_udkey_P_3_enc_1 tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce dest: isoiec_9798_2_6_udkey_P_secret_Kab intro: event_predOrdI)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_udkey_A_injective_agreement_B:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_udkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_udkey_A_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_udkey_B &
+          ( tid1, isoiec_9798_2_6_udkey_B_5 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
+             s(MV ''Kab'' tid1), s(MV ''Rpa'' tid1), LN ''Rb'' tid1,
+             s(MV ''Text6'' tid1), s(MV ''Text8'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
+                  s(MV ''Kab'' tid0), LN ''Rpa'' tid0, s(MV ''Rb'' tid0),
+                  s(MV ''Text6'' tid0), s(MV ''Text8'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
+                              s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
+                           |}
+                           ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_udkey_P_3_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_2_6_enc_5'', s(MV ''Rb'' tid0), LN ''Rpa'' tid0,
+                                s(MV ''Text8'' tid0)
+                             |}
+                             ( LN ''Kab'' tid1 ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest: isoiec_9798_2_6_udkey_P_secret_Kab intro: event_predOrdI)
+        next
+          case (isoiec_9798_2_6_udkey_B_5_enc tid2) note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid2, LN ''Kab'' tid1,
+                                  s(AV ''A'' tid2), s(MV ''Text3'' tid2)
+                               |}
+                               ( K ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) ) ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest: isoiec_9798_2_6_udkey_P_secret_Kab intro: event_predOrdI)
+          next
+            case (isoiec_9798_2_6_udkey_P_3_enc_1 tid3) note_unified facts = this facts
+            thus ?thesis proof(sources! "
+                             Enc {| LC ''isoiec_9798_2_6_enc_4'', LN ''Rpa'' tid0, LN ''Rb'' tid2,
+                                    s(MV ''Text6'' tid2)
+                                 |}
+                                 ( LN ''Kab'' tid1 ) ")
+              case fake note_unified facts = this facts
+              thus ?thesis by (fastforce dest: isoiec_9798_2_6_udkey_P_secret_Kab intro: event_predOrdI)
+            next
+              case (isoiec_9798_2_6_udkey_A_4_enc tid3) note_unified facts = this facts
+              thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+            qed (insert facts, fastforce+)?
+          qed (insert facts, fastforce+)?
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_udkey_B_injective_agreement_A:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_udkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(MV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_udkey_B_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_udkey_A &
+          ( tid1, isoiec_9798_2_6_udkey_A_4 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
+             s(MV ''Kab'' tid1), LN ''Rpa'' tid1, s(MV ''Rb'' tid1),
+             s(MV ''Text6'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                  s(MV ''Kab'' tid0), s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
+                  s(MV ''Text6'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_udkey_P_3_enc_1 tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
+                                s(MV ''Text6'' tid0)
+                             |}
+                             ( LN ''Kab'' tid1 ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest: isoiec_9798_2_6_udkey_P_secret_Kab intro: event_predOrdI)
+        next
+          case (isoiec_9798_2_6_udkey_A_4_enc tid2) note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid2, LN ''Kab'' tid1,
+                                  s(MV ''B'' tid2), s(MV ''Text4'' tid2)
+                               |}
+                               ( K ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest: isoiec_9798_2_6_udkey_P_secret_Kab intro: event_predOrdI)
+          next
+            case (isoiec_9798_2_6_udkey_P_3_enc tid3) note_unified facts = this facts
+            thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+          qed (insert facts, fastforce+)?
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_udkey_A_injective_agreement_P:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_udkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_udkey_A_3 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_udkey_P &
+          ( tid1, isoiec_9798_2_6_udkey_P_3 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
+             s(MV ''Ra'' tid1), LN ''Kab'' tid1, s(MV ''Text4'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
+                  LN ''Ra'' tid0, s(MV ''Kab'' tid0), s(MV ''Text4'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
+                              s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
+                           |}
+                           ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_udkey_P_3_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_bdkey_state) isoiec_9798_2_6_udkey_B_injective_agreement_P:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_udkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(MV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_udkey_B_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_udkey_P &
+          ( tid1, isoiec_9798_2_6_udkey_P_3 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
+             s(MV ''Rb'' tid1), LN ''Kab'' tid1, s(MV ''Text3'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                  LN ''Rb'' tid0, s(MV ''Kab'' tid0), s(MV ''Text3'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_udkey_P_3_enc_1 tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
 qed
 
 end
diff --git a/data/examples/iso9798/isabelle-parallel-proofs/isoiec-9798-3_cert_auto.thy b/data/examples/iso9798/isabelle-parallel-proofs/isoiec-9798-3_cert_auto.thy
--- a/data/examples/iso9798/isabelle-parallel-proofs/isoiec-9798-3_cert_auto.thy
+++ b/data/examples/iso9798/isabelle-parallel-proofs/isoiec-9798-3_cert_auto.thy
@@ -1,2773 +1,3179 @@
 theory "isoiec-9798-3_cert_auto"
 imports
-  "../ESPLogic"
-begin
-
-role isoiec_9798_3_1_A
-where "isoiec_9798_3_1_A =
-  [ Send ''leak_A'' ( sN ''TNA'' )
-  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
-  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
-                  PSign <| sC ''isoiec_9798_3_1_sig_1'', sN ''TNA'', sAV ''B'',
-                           sMV ''Text1''
-                        |>
-                        ( sPK ''A'' )
-               |>
-  ]"
-
-role isoiec_9798_3_1_B
-where "isoiec_9798_3_1_B =
-  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
-                  PSign <| sC ''isoiec_9798_3_1_sig_1'', sMV ''TNA'', sAV ''B'',
-                           sMV ''Text1''
-                        |>
-                        ( PAsymPK ( sMV ''A'' ) )
-               |>
-  ]"
-
-role isoiec_9798_3_2_A
-where "isoiec_9798_3_2_A =
-  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
-  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
-  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
-                  PSign <| sC ''isoiec_9798_3_2_sig_2'', sN ''Ra'', sMV ''Rb'', sMV ''B'',
-                           sMV ''Text2''
-                        |>
-                        ( sPK ''A'' )
-               |>
-  ]"
-
-role isoiec_9798_3_2_B
-where "isoiec_9798_3_2_B =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
-  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
-                  PSign <| sC ''isoiec_9798_3_2_sig_2'', sMV ''Ra'', sN ''Rb'', sAV ''B'',
-                           sMV ''Text2''
-                        |>
-                        ( sPK ''A'' )
-               |>
-  ]"
-
-role isoiec_9798_3_3_A
-where "isoiec_9798_3_3_A =
-  [ Send ''leak_A'' ( sN ''TNA'' )
-  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
-  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
-                  PSign <| sC ''isoiec_9798_3_3_sig_1'', sN ''TNA'', sAV ''B'',
-                           sMV ''Text1''
-                        |>
-                        ( sPK ''A'' )
-               |>
-  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text4'',
-                  PSign <| sC ''isoiec_9798_3_3_sig_2'', sMV ''TNB'', sAV ''A'',
-                           sMV ''Text3''
-                        |>
-                        ( sPK ''B'' )
-               |>
-  ]"
-
-role isoiec_9798_3_3_B
-where "isoiec_9798_3_3_B =
-  [ Send ''leak_B'' ( sN ''TNB'' )
-  , Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
-                  PSign <| sC ''isoiec_9798_3_3_sig_1'', sMV ''TNA'', sAV ''B'',
-                           sMV ''Text1''
-                        |>
-                        ( PAsymPK ( sMV ''A'' ) )
-               |>
-  , Recv ''text_2'' <| sMV ''Text3'', sMV ''Text4'' |>
-  , Send ''2'' <| sMV ''A'', sAV ''B'', sMV ''Text4'',
-                  PSign <| sC ''isoiec_9798_3_3_sig_2'', sN ''TNB'', sMV ''A'',
-                           sMV ''Text3''
-                        |>
-                        ( sPK ''B'' )
-               |>
-  ]"
-
-role isoiec_9798_3_4_A
-where "isoiec_9798_3_4_A =
-  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text1'' |>
-  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
-  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
-                  PSign <| sC ''isoiec_9798_3_4_sig_1'', sN ''RA'', sMV ''RB'', sMV ''B'',
-                           sMV ''Text2''
-                        |>
-                        ( sPK ''A'' )
-               |>
-  , Recv ''3'' <| sMV ''B'', sAV ''A'', sMV ''Text5'',
-                  PSign <| sC ''isoiec_9798_3_4_sig_2'', sMV ''RB'', sN ''RA'', sAV ''A'',
-                           sMV ''Text4''
-                        |>
-                        ( PAsymPK ( sMV ''B'' ) )
-               |>
-  ]"
-
-role isoiec_9798_3_4_B
-where "isoiec_9798_3_4_B =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''RB'', sMV ''Text1'' |>
-  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
-                  PSign <| sC ''isoiec_9798_3_4_sig_1'', sMV ''RA'', sN ''RB'', sAV ''B'',
-                           sMV ''Text2''
-                        |>
-                        ( sPK ''A'' )
-               |>
-  , Recv ''text_3'' <| sMV ''Text4'', sMV ''Text5'' |>
-  , Send ''3'' <| sAV ''B'', sAV ''A'', sMV ''Text5'',
-                  PSign <| sC ''isoiec_9798_3_4_sig_2'', sN ''RB'', sMV ''RA'', sAV ''A'',
-                           sMV ''Text4''
-                        |>
-                        ( sPK ''B'' )
-               |>
-  ]"
-
-role isoiec_9798_3_5_A
-where "isoiec_9798_3_5_A =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''A'', sAV ''B'', sN ''RA'', sMV ''Text1'' |>
-  , Recv ''2'' <| sAV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text2'' |>
-  , Recv ''3'' <| sAV ''B'', sAV ''A'', sMV ''Text6'',
-                  PSign <| sC ''isoiec_9798_3_5_sig_1'', sMV ''RB'', sN ''RA'', sAV ''A'',
-                           sMV ''Text5''
-                        |>
-                        ( sPK ''B'' )
-               |>
-  , Recv ''text_4'' <| sMV ''Text3'', sMV ''Text4'' |>
-  , Send ''4'' <| sAV ''A'', sAV ''B'', sMV ''Text4'',
-                  PSign <| sC ''isoiec_9798_3_5_sig_2'', sN ''RA'', sMV ''RB'', sAV ''B'',
-                           sMV ''Text3''
-                        |>
-                        ( sPK ''A'' )
-               |>
-  ]"
-
-role isoiec_9798_3_5_B
-where "isoiec_9798_3_5_B =
-  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''RA'', sMV ''Text1'' |>
-  , Recv ''text_2'' ( sMV ''Text2'' )
-  , Send ''2'' <| sAV ''B'', sMV ''A'', sN ''RB'', sMV ''Text2'' |>
-  , Recv ''text_3'' <| sMV ''Text5'', sMV ''Text6'' |>
-  , Send ''3'' <| sAV ''B'', sMV ''A'', sMV ''Text6'',
-                  PSign <| sC ''isoiec_9798_3_5_sig_1'', sN ''RB'', sMV ''RA'', sMV ''A'',
-                           sMV ''Text5''
-                        |>
-                        ( sPK ''B'' )
-               |>
-  , Recv ''4'' <| sMV ''A'', sAV ''B'', sMV ''Text4'',
-                  PSign <| sC ''isoiec_9798_3_5_sig_2'', sMV ''RA'', sN ''RB'', sAV ''B'',
-                           sMV ''Text3''
-                        |>
-                        ( PAsymPK ( sMV ''A'' ) )
-               |>
-  ]"
-
-role isoiec_9798_3_6_1_A
-where "isoiec_9798_3_6_1_A =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''A'', sAV ''B'', sN ''Ra'', sMV ''Text1'' |>
-  , Recv ''2'' <| sAV ''A'', sAV ''B'', sN ''Ra'', sMV ''Rb'',
-                  sMV ''Text3'', sMV ''TokenBA''
-               |>
-  , Recv ''text_3'' ( sMV ''Text4'' )
-  , Send ''3'' <| sAV ''A'', sAV ''T'', sN ''Rpa'', sMV ''Rb'', sAV ''B'',
-                  sMV ''Text4''
-               |>
-  , Recv ''4'' <| sAV ''T'', sAV ''A'', sMV ''Text7'', sAV ''A'',
-                  sPK ''A'', sAV ''B'', sMV ''pkB'',
-                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_4_1'', sN ''Rpa'', sAV ''B'',
-                           sMV ''pkB'', sMV ''Text6''
-                        |>
-                        ( sPK ''T'' ),
-                  sMV ''TokenTA_for_B''
-               |>
-  , Send ''check_4_out'' ( PEnc <| sC ''check_4'', sMV ''TokenBA'' |>
-                                ( sN ''check_nonce_4'' )
-                         )
-  , Recv ''check_4_in'' ( PEnc <| sC ''check_4'',
-                                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_2'', sAV ''B'', sN ''Ra'',
-                                           sMV ''Rb'', sAV ''A'', sMV ''Text2''
-                                        |>
-                                        ( sMV ''pkB'' )
-                               |>
-                               ( sN ''check_nonce_4'' )
-                        )
-  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
-  , Send ''5'' <| sAV ''A'', sAV ''B'', sMV ''Text9'', sAV ''T'',
-                  sMV ''TokenTA_for_B'',
-                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_5'', sMV ''Rb'', sN ''Ra'',
-                           sAV ''B'', sAV ''A'', sMV ''Text8''
-                        |>
-                        ( sPK ''A'' )
-               |>
-  ]"
-
-role isoiec_9798_3_6_1_B
-where "isoiec_9798_3_6_1_B =
-  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Ra'', sMV ''Text1'' |>
-  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
-  , Send ''2'' <| sMV ''A'', sAV ''B'', sMV ''Ra'', sN ''Rb'',
-                  sMV ''Text3'',
-                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_2'', sAV ''B'', sMV ''Ra'',
-                           sN ''Rb'', sMV ''A'', sMV ''Text2''
-                        |>
-                        ( sPK ''B'' )
-               |>
-  , Recv ''5'' <| sMV ''A'', sAV ''B'', sMV ''Text9'', sMV ''T'',
-                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_4_2'', sN ''Rb'', sMV ''A'',
-                           sMV ''pkA'', sMV ''Text5''
-                        |>
-                        ( PAsymPK ( sMV ''T'' ) ),
-                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_5'', sN ''Rb'', sMV ''Ra5'',
-                           sAV ''B'', sMV ''A'', sMV ''Text8''
-                        |>
-                        ( sMV ''pkA'' )
-               |>
-  ]"
-
-role isoiec_9798_3_6_1_T
-where "isoiec_9798_3_6_1_T =
-  [ Recv ''3'' <| sMV ''A'', sAV ''T'', sMV ''Rpa'', sMV ''Rb'', sMV ''B'',
-                  sMV ''Text4''
-               |>
-  , Recv ''text_4'' <| sMV ''Text5'', sMV ''Text6'', sMV ''Text7'' |>
-  , Send ''4'' <| sAV ''T'', sMV ''A'', sMV ''Text7'', sMV ''A'',
-                  PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
-                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_4_1'', sMV ''Rpa'', sMV ''B'',
-                           PAsymPK ( sMV ''B'' ), sMV ''Text6''
-                        |>
-                        ( sPK ''T'' ),
-                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_4_2'', sMV ''Rb'', sMV ''A'',
-                           PAsymPK ( sMV ''A'' ), sMV ''Text5''
-                        |>
-                        ( sPK ''T'' )
-               |>
-  ]"
-
-role isoiec_9798_3_6_2_A
-where "isoiec_9798_3_6_2_A =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''A'', sAV ''B'', sN ''Ra'', sMV ''Text1'' |>
-  , Recv ''2'' <| sAV ''A'', sAV ''B'', sN ''Ra'', sMV ''Rb'',
-                  sMV ''Text3'', sMV ''TokenBA''
-               |>
-  , Recv ''text_3'' ( sMV ''Text4'' )
-  , Send ''3'' <| sAV ''A'', sAV ''T'', sN ''Rpa'', sMV ''Rb'', sAV ''B'',
-                  sMV ''Text4''
-               |>
-  , Recv ''4'' <| sAV ''T'', sAV ''A'', sMV ''Text7'', sAV ''A'',
-                  sPK ''A'', sAV ''B'', sMV ''pkB'', sMV ''TokenTA''
-               |>
-  , Send ''check_4_out'' ( PEnc <| sC ''check_4'', sMV ''TokenTA'',
-                                   sMV ''TokenBA''
-                                |>
-                                ( sN ''check_nonce_4'' )
-                         )
-  , Recv ''check_4_in'' ( PEnc <| sC ''check_4'',
-                                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_4'', sN ''Rpa'', sMV ''Rb'',
-                                           sAV ''A'', sMV ''pkA'', sAV ''B'', sMV ''pkB'', sMV ''Text5''
-                                        |>
-                                        ( sPK ''T'' ),
-                                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_2'', sAV ''B'', sN ''Ra'',
-                                           sMV ''Rb'', sAV ''A'', sMV ''Text2''
-                                        |>
-                                        ( sMV ''pkB'' )
-                               |>
-                               ( sN ''check_nonce_4'' )
-                        )
-  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
-  , Send ''5'' <| sAV ''A'', sAV ''B'', sN ''Rpa'', sMV ''Text9'',
-                  sAV ''T'', sMV ''TokenTA'',
-                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_5'', sMV ''Rb'', sN ''Ra'',
-                           sAV ''B'', sAV ''A'', sMV ''Text8''
-                        |>
-                        ( sPK ''A'' )
-               |>
-  ]"
-
-role isoiec_9798_3_6_2_B
-where "isoiec_9798_3_6_2_B =
-  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Ra'', sMV ''Text1'' |>
-  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
-  , Send ''2'' <| sMV ''A'', sAV ''B'', sMV ''Ra'', sN ''Rb'',
-                  sMV ''Text3'',
-                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_2'', sAV ''B'', sMV ''Ra'',
-                           sN ''Rb'', sMV ''A'', sMV ''Text2''
-                        |>
-                        ( sPK ''B'' )
-               |>
-  , Recv ''5'' <| sMV ''A'', sAV ''B'', sMV ''Rpa'', sMV ''Text9'',
-                  sMV ''T'',
-                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_4'', sMV ''Rpa'', sN ''Rb'',
-                           sMV ''A'', sMV ''pkA'', sAV ''B'', sMV ''pkB'', sMV ''Text5''
-                        |>
-                        ( PAsymPK ( sMV ''T'' ) ),
-                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_5'', sN ''Rb'', sMV ''Ra5'',
-                           sAV ''B'', sMV ''A'', sMV ''Text8''
-                        |>
-                        ( sMV ''pkA'' )
-               |>
-  ]"
-
-role isoiec_9798_3_6_2_T
-where "isoiec_9798_3_6_2_T =
-  [ Recv ''3'' <| sMV ''A'', sAV ''T'', sMV ''Rpa'', sMV ''Rb'', sMV ''B'',
-                  sMV ''Text4''
-               |>
-  , Recv ''text_4'' <| sMV ''Text5'', sMV ''Text7'' |>
-  , Send ''4'' <| sAV ''T'', sMV ''A'', sMV ''Text7'', sMV ''A'',
-                  PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
-                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_4'', sMV ''Rpa'', sMV ''Rb'',
-                           sMV ''A'', PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
-                           sMV ''Text5''
-                        |>
-                        ( sPK ''T'' )
-               |>
-  ]"
-
-role isoiec_9798_3_7_1_A
-where "isoiec_9798_3_7_1_A =
-  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
-  , Recv ''text_2'' ( sMV ''Text2'' )
-  , Send ''2'' <| sAV ''A'', sAV ''T'', sN ''Rpa'', sMV ''Rb'', sAV ''A'',
-                  sMV ''B'', sMV ''Text2''
-               |>
-  , Recv ''3'' <| sAV ''T'', sAV ''A'', sMV ''Text5'', sAV ''A'',
-                  sPK ''A'', sMV ''B'', sMV ''pkB'',
-                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_3_1'', sN ''Rpa'', sMV ''B'',
-                           sMV ''pkB'', sMV ''Text4''
-                        |>
-                        ( sPK ''T'' ),
-                  sMV ''TokenTA_for_B''
-               |>
-  , Recv ''text_4'' <| sMV ''Text6'', sMV ''Text7'' |>
-  , Send ''4'' <| sAV ''A'', sMV ''B'', sN ''Rpa'', sMV ''Text7'',
-                  sAV ''T'', sMV ''TokenTA_for_B'',
-                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_4'', sMV ''Rb'', sN ''Ra'',
-                           sMV ''B'', sAV ''A'', sMV ''Text6''
-                        |>
-                        ( sPK ''A'' )
-               |>
-  , Recv ''5'' <| sAV ''A'', sMV ''B'', sN ''Ra'', sMV ''Rb'',
-                  sMV ''Text9'',
-                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_5'', sN ''Ra'', sMV ''Rb'',
-                           sAV ''A'', sMV ''B'', sMV ''Text8''
-                        |>
-                        ( sMV ''pkB'' )
-               |>
-  ]"
-
-role isoiec_9798_3_7_1_B
-where "isoiec_9798_3_7_1_B =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
-  , Recv ''4'' <| sAV ''A'', sAV ''B'', sMV ''Rpa'', sMV ''Text9'',
-                  sMV ''T'',
-                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_3_2'', sN ''Rb'', sAV ''A'',
-                           sMV ''pkA'', sMV ''Text3''
-                        |>
-                        ( PAsymPK ( sMV ''T'' ) ),
-                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_4'', sN ''Rb'', sMV ''Ra'',
-                           sAV ''B'', sAV ''A'', sMV ''Text6''
-                        |>
-                        ( sMV ''pkA'' )
-               |>
-  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
-  , Send ''5'' <| sAV ''A'', sAV ''B'', sMV ''Ra'', sN ''Rb'',
-                  sMV ''Text9'',
-                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_5'', sMV ''Ra'', sN ''Rb'',
-                           sAV ''A'', sAV ''B'', sMV ''Text8''
-                        |>
-                        ( sPK ''B'' )
-               |>
-  ]"
-
-role isoiec_9798_3_7_1_T
-where "isoiec_9798_3_7_1_T =
-  [ Recv ''2'' <| sMV ''A'', sAV ''T'', sMV ''Rpa'', sMV ''Rb'', sMV ''A'',
-                  sMV ''B'', sMV ''Text2''
-               |>
-  , Recv ''text_3'' <| sMV ''Text3'', sMV ''Text4'', sMV ''Text5'' |>
-  , Send ''3'' <| sAV ''T'', sMV ''A'', sMV ''Text5'', sMV ''A'',
-                  PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
-                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_3_1'', sMV ''Rpa'', sMV ''B'',
-                           PAsymPK ( sMV ''B'' ), sMV ''Text4''
-                        |>
-                        ( sPK ''T'' ),
-                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_3_2'', sMV ''Rb'', sMV ''A'',
-                           PAsymPK ( sMV ''A'' ), sMV ''Text3''
-                        |>
-                        ( sPK ''T'' )
-               |>
-  ]"
-
-role isoiec_9798_3_7_2_A
-where "isoiec_9798_3_7_2_A =
-  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
-  , Recv ''text_2'' ( sMV ''Text2'' )
-  , Send ''2'' <| sAV ''A'', sAV ''T'', sN ''Rpa'', sMV ''Rb'', sAV ''A'',
-                  sMV ''B'', sMV ''Text2''
-               |>
-  , Recv ''3'' <| sAV ''T'', sAV ''A'', sMV ''Text5'', sAV ''A'',
-                  sPK ''A'', sMV ''B'', sMV ''pkB'', sMV ''TokenTA''
-               |>
-  , Send ''check_3_out'' ( PEnc <| sC ''check_4'', sMV ''TokenTA'' |>
-                                ( sN ''check_nonce_4'' )
-                         )
-  , Recv ''check_3_in'' ( PEnc <| sC ''check_4'',
-                                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_3'', sN ''Rpa'', sMV ''Rb'',
-                                           sAV ''A'', sMV ''pkA'', sMV ''B'', sMV ''pkB'', sMV ''Text3''
-                                        |>
-                                        ( sPK ''T'' )
-                               |>
-                               ( sN ''check_nonce_4'' )
-                        )
-  , Recv ''text_4'' <| sMV ''Text6'', sMV ''Text7'' |>
-  , Send ''4'' <| sAV ''A'', sMV ''B'', sN ''Rpa'', sMV ''Text7'',
-                  sAV ''T'', sMV ''TokenTA'',
-                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_4'', sMV ''Rb'', sN ''Ra'',
-                           sMV ''B'', sAV ''A'', sMV ''Text6''
-                        |>
-                        ( sPK ''A'' )
-               |>
-  , Recv ''5'' <| sAV ''A'', sMV ''B'', sN ''Ra'', sMV ''Rb'',
-                  sMV ''Text9'',
-                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_5'', sN ''Ra'', sMV ''Rb'',
-                           sAV ''A'', sMV ''B'', sMV ''Text8''
-                        |>
-                        ( sMV ''pkB'' )
-               |>
-  ]"
-
-role isoiec_9798_3_7_2_B
-where "isoiec_9798_3_7_2_B =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
-  , Recv ''4'' <| sAV ''A'', sAV ''B'', sMV ''Rpa'', sMV ''Text9'',
-                  sMV ''T'',
-                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_3'', sMV ''Rpa'', sN ''Rb'',
-                           sAV ''A'', sMV ''pkA'', sAV ''B'', sMV ''pkB'', sMV ''Text3''
-                        |>
-                        ( PAsymPK ( sMV ''T'' ) ),
-                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_4'', sN ''Rb'', sMV ''Ra'',
-                           sAV ''B'', sAV ''A'', sMV ''Text6''
-                        |>
-                        ( sMV ''pkA'' )
-               |>
-  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
-  , Send ''5'' <| sAV ''A'', sAV ''B'', sMV ''Ra'', sN ''Rb'',
-                  sMV ''Text9'',
-                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_5'', sMV ''Ra'', sN ''Rb'',
-                           sAV ''A'', sAV ''B'', sMV ''Text8''
-                        |>
-                        ( sPK ''B'' )
-               |>
-  ]"
-
-role isoiec_9798_3_7_2_T
-where "isoiec_9798_3_7_2_T =
-  [ Recv ''2'' <| sMV ''A'', sAV ''T'', sMV ''Rpa'', sMV ''Rb'', sMV ''A'',
-                  sMV ''B'', sMV ''Text2''
-               |>
-  , Recv ''text_3'' <| sMV ''Text3'', sMV ''Text5'' |>
-  , Send ''3'' <| sAV ''T'', sMV ''A'', sMV ''Text5'', sMV ''A'',
-                  PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
-                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_3'', sMV ''Rpa'', sMV ''Rb'',
-                           sMV ''A'', PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
-                           sMV ''Text3''
-                        |>
-                        ( sPK ''T'' )
-               |>
-  ]"
-
-protocol isoiec_9798_3
-where "isoiec_9798_3 =
-{ isoiec_9798_3_1_A, isoiec_9798_3_1_B, isoiec_9798_3_2_A,
-  isoiec_9798_3_2_B, isoiec_9798_3_3_A, isoiec_9798_3_3_B,
-  isoiec_9798_3_4_A, isoiec_9798_3_4_B, isoiec_9798_3_5_A,
-  isoiec_9798_3_5_B, isoiec_9798_3_6_1_A, isoiec_9798_3_6_1_B,
-  isoiec_9798_3_6_1_T, isoiec_9798_3_6_2_A, isoiec_9798_3_6_2_B,
-  isoiec_9798_3_6_2_T, isoiec_9798_3_7_1_A, isoiec_9798_3_7_1_B,
-  isoiec_9798_3_7_1_T, isoiec_9798_3_7_2_A, isoiec_9798_3_7_2_B,
-  isoiec_9798_3_7_2_T
-}"
-
-locale restricted_isoiec_9798_3_state = isoiec_9798_3_state
-
-type_invariant isoiec_9798_3_composed_typing for isoiec_9798_3
-where "isoiec_9798_3_composed_typing = mk_typing
-  [ ((isoiec_9798_3_1_B, ''A''), (KnownT isoiec_9798_3_1_B_1))
-  , ((isoiec_9798_3_3_B, ''A''), (KnownT isoiec_9798_3_3_B_1))
-  , ((isoiec_9798_3_5_B, ''A''), (KnownT isoiec_9798_3_5_B_1))
-  , ((isoiec_9798_3_6_1_B, ''A''), (KnownT isoiec_9798_3_6_1_B_1))
-  , ((isoiec_9798_3_6_1_T, ''A''), (KnownT isoiec_9798_3_6_1_T_3))
-  , ((isoiec_9798_3_6_2_B, ''A''), (KnownT isoiec_9798_3_6_2_B_1))
-  , ((isoiec_9798_3_6_2_T, ''A''), (KnownT isoiec_9798_3_6_2_T_3))
-  , ((isoiec_9798_3_7_1_T, ''A''), (KnownT isoiec_9798_3_7_1_T_2))
-  , ((isoiec_9798_3_7_2_T, ''A''), (KnownT isoiec_9798_3_7_2_T_2))
-  , ((isoiec_9798_3_2_A, ''B''), (KnownT isoiec_9798_3_2_A_1))
-  , ((isoiec_9798_3_4_A, ''B''), (KnownT isoiec_9798_3_4_A_1))
-  , ((isoiec_9798_3_6_1_T, ''B''), (KnownT isoiec_9798_3_6_1_T_3))
-  , ((isoiec_9798_3_6_2_T, ''B''), (KnownT isoiec_9798_3_6_2_T_3))
-  , ((isoiec_9798_3_7_1_A, ''B''), (KnownT isoiec_9798_3_7_1_A_1))
-  , ((isoiec_9798_3_7_1_T, ''B''), (KnownT isoiec_9798_3_7_1_T_2))
-  , ((isoiec_9798_3_7_2_A, ''B''), (KnownT isoiec_9798_3_7_2_A_1))
-  , ((isoiec_9798_3_7_2_T, ''B''), (KnownT isoiec_9798_3_7_2_T_2))
-  , ((isoiec_9798_3_4_B, ''RA''), (KnownT isoiec_9798_3_4_B_2))
-  , ((isoiec_9798_3_5_B, ''RA''), (KnownT isoiec_9798_3_5_B_1))
-  , ((isoiec_9798_3_4_A, ''RB''), (KnownT isoiec_9798_3_4_A_1))
-  , ((isoiec_9798_3_5_A, ''RB''), (KnownT isoiec_9798_3_5_A_2))
-  , ((isoiec_9798_3_2_B, ''Ra''), (KnownT isoiec_9798_3_2_B_2))
-  , ((isoiec_9798_3_6_1_B, ''Ra''), (KnownT isoiec_9798_3_6_1_B_1))
-  , ((isoiec_9798_3_6_2_B, ''Ra''), (KnownT isoiec_9798_3_6_2_B_1))
-  , ((isoiec_9798_3_7_1_B, ''Ra''), (KnownT isoiec_9798_3_7_1_B_4))
-  , ((isoiec_9798_3_7_2_B, ''Ra''), (KnownT isoiec_9798_3_7_2_B_4))
-  , ((isoiec_9798_3_6_1_B, ''Ra5''), (KnownT isoiec_9798_3_6_1_B_5))
-  , ((isoiec_9798_3_6_2_B, ''Ra5''), (KnownT isoiec_9798_3_6_2_B_5))
-  , ((isoiec_9798_3_2_A, ''Rb''), (KnownT isoiec_9798_3_2_A_1))
-  , ((isoiec_9798_3_6_1_A, ''Rb''), (KnownT isoiec_9798_3_6_1_A_2))
-  , ((isoiec_9798_3_6_1_T, ''Rb''), (KnownT isoiec_9798_3_6_1_T_3))
-  , ((isoiec_9798_3_6_2_A, ''Rb''), (KnownT isoiec_9798_3_6_2_A_2))
-  , ((isoiec_9798_3_6_2_T, ''Rb''), (KnownT isoiec_9798_3_6_2_T_3))
-  , ((isoiec_9798_3_7_1_A, ''Rb''), (KnownT isoiec_9798_3_7_1_A_1))
-  , ((isoiec_9798_3_7_1_T, ''Rb''), (KnownT isoiec_9798_3_7_1_T_2))
-  , ((isoiec_9798_3_7_2_A, ''Rb''), (KnownT isoiec_9798_3_7_2_A_1))
-  , ((isoiec_9798_3_7_2_T, ''Rb''), (KnownT isoiec_9798_3_7_2_T_2))
-  , ((isoiec_9798_3_6_1_T, ''Rpa''), (KnownT isoiec_9798_3_6_1_T_3))
-  , ((isoiec_9798_3_6_2_B, ''Rpa''), (KnownT isoiec_9798_3_6_2_B_5))
-  , ((isoiec_9798_3_6_2_T, ''Rpa''), (KnownT isoiec_9798_3_6_2_T_3))
-  , ((isoiec_9798_3_7_1_B, ''Rpa''), (KnownT isoiec_9798_3_7_1_B_4))
-  , ((isoiec_9798_3_7_1_T, ''Rpa''), (KnownT isoiec_9798_3_7_1_T_2))
-  , ((isoiec_9798_3_7_2_B, ''Rpa''), (KnownT isoiec_9798_3_7_2_B_4))
-  , ((isoiec_9798_3_7_2_T, ''Rpa''), (KnownT isoiec_9798_3_7_2_T_2))
-  , ((isoiec_9798_3_6_1_B, ''T''), (KnownT isoiec_9798_3_6_1_B_5))
-  , ((isoiec_9798_3_6_2_B, ''T''), (KnownT isoiec_9798_3_6_2_B_5))
-  , ((isoiec_9798_3_7_1_B, ''T''), (KnownT isoiec_9798_3_7_1_B_4))
-  , ((isoiec_9798_3_7_2_B, ''T''), (KnownT isoiec_9798_3_7_2_B_4))
-  , ((isoiec_9798_3_1_B, ''TNA''), (KnownT isoiec_9798_3_1_B_1))
-  , ((isoiec_9798_3_3_B, ''TNA''), (KnownT isoiec_9798_3_3_B_1))
-  , ((isoiec_9798_3_3_A, ''TNB''), (KnownT isoiec_9798_3_3_A_2))
-  , ((isoiec_9798_3_1_A, ''Text1''), (KnownT isoiec_9798_3_1_A_text_1))
-  , ((isoiec_9798_3_1_B, ''Text1''), (KnownT isoiec_9798_3_1_B_1))
-  , ((isoiec_9798_3_2_A, ''Text1''), (KnownT isoiec_9798_3_2_A_1))
-  , ((isoiec_9798_3_2_B, ''Text1''), (KnownT isoiec_9798_3_2_B_text_1))
-  , ((isoiec_9798_3_3_A, ''Text1''), (KnownT isoiec_9798_3_3_A_text_1))
-  , ((isoiec_9798_3_3_B, ''Text1''), (KnownT isoiec_9798_3_3_B_1))
-  , ((isoiec_9798_3_4_A, ''Text1''), (KnownT isoiec_9798_3_4_A_1))
-  , ((isoiec_9798_3_4_B, ''Text1''), (KnownT isoiec_9798_3_4_B_text_1))
-  , ((isoiec_9798_3_5_A, ''Text1''), (KnownT isoiec_9798_3_5_A_text_1))
-  , ((isoiec_9798_3_5_B, ''Text1''), (KnownT isoiec_9798_3_5_B_1))
-  , ((isoiec_9798_3_6_1_A, ''Text1''), (KnownT isoiec_9798_3_6_1_A_text_1))
-  , ((isoiec_9798_3_6_1_B, ''Text1''), (KnownT isoiec_9798_3_6_1_B_1))
-  , ((isoiec_9798_3_6_2_A, ''Text1''), (KnownT isoiec_9798_3_6_2_A_text_1))
-  , ((isoiec_9798_3_6_2_B, ''Text1''), (KnownT isoiec_9798_3_6_2_B_1))
-  , ((isoiec_9798_3_7_1_A, ''Text1''), (KnownT isoiec_9798_3_7_1_A_1))
-  , ((isoiec_9798_3_7_1_B, ''Text1''), (KnownT isoiec_9798_3_7_1_B_text_1))
-  , ((isoiec_9798_3_7_2_A, ''Text1''), (KnownT isoiec_9798_3_7_2_A_1))
-  , ((isoiec_9798_3_7_2_B, ''Text1''), (KnownT isoiec_9798_3_7_2_B_text_1))
-  , ((isoiec_9798_3_1_A, ''Text2''), (KnownT isoiec_9798_3_1_A_text_1))
-  , ((isoiec_9798_3_1_B, ''Text2''), (KnownT isoiec_9798_3_1_B_1))
-  , ((isoiec_9798_3_2_A, ''Text2''), (KnownT isoiec_9798_3_2_A_text_2))
-  , ((isoiec_9798_3_2_B, ''Text2''), (KnownT isoiec_9798_3_2_B_2))
-  , ((isoiec_9798_3_3_A, ''Text2''), (KnownT isoiec_9798_3_3_A_text_1))
-  , ((isoiec_9798_3_3_B, ''Text2''), (KnownT isoiec_9798_3_3_B_1))
-  , ((isoiec_9798_3_4_A, ''Text2''), (KnownT isoiec_9798_3_4_A_text_2))
-  , ((isoiec_9798_3_4_B, ''Text2''), (KnownT isoiec_9798_3_4_B_2))
-  , ((isoiec_9798_3_5_A, ''Text2''), (KnownT isoiec_9798_3_5_A_2))
-  , ((isoiec_9798_3_5_B, ''Text2''), (KnownT isoiec_9798_3_5_B_text_2))
-  , ((isoiec_9798_3_6_1_A, ''Text2''),
-     (KnownT isoiec_9798_3_6_1_A_check_4_in))
-  , ((isoiec_9798_3_6_1_B, ''Text2''), (KnownT isoiec_9798_3_6_1_B_text_2))
-  , ((isoiec_9798_3_6_2_A, ''Text2''),
-     (KnownT isoiec_9798_3_6_2_A_check_4_in))
-  , ((isoiec_9798_3_6_2_B, ''Text2''), (KnownT isoiec_9798_3_6_2_B_text_2))
-  , ((isoiec_9798_3_7_1_A, ''Text2''), (KnownT isoiec_9798_3_7_1_A_text_2))
-  , ((isoiec_9798_3_7_1_T, ''Text2''), (KnownT isoiec_9798_3_7_1_T_2))
-  , ((isoiec_9798_3_7_2_A, ''Text2''), (KnownT isoiec_9798_3_7_2_A_text_2))
-  , ((isoiec_9798_3_7_2_T, ''Text2''), (KnownT isoiec_9798_3_7_2_T_2))
-  , ((isoiec_9798_3_2_A, ''Text3''), (KnownT isoiec_9798_3_2_A_text_2))
-  , ((isoiec_9798_3_2_B, ''Text3''), (KnownT isoiec_9798_3_2_B_2))
-  , ((isoiec_9798_3_3_A, ''Text3''), (KnownT isoiec_9798_3_3_A_2))
-  , ((isoiec_9798_3_3_B, ''Text3''), (KnownT isoiec_9798_3_3_B_text_2))
-  , ((isoiec_9798_3_4_A, ''Text3''), (KnownT isoiec_9798_3_4_A_text_2))
-  , ((isoiec_9798_3_4_B, ''Text3''), (KnownT isoiec_9798_3_4_B_2))
-  , ((isoiec_9798_3_5_A, ''Text3''), (KnownT isoiec_9798_3_5_A_text_4))
-  , ((isoiec_9798_3_5_B, ''Text3''), (KnownT isoiec_9798_3_5_B_4))
-  , ((isoiec_9798_3_6_1_A, ''Text3''), (KnownT isoiec_9798_3_6_1_A_2))
-  , ((isoiec_9798_3_6_1_B, ''Text3''), (KnownT isoiec_9798_3_6_1_B_text_2))
-  , ((isoiec_9798_3_6_2_A, ''Text3''), (KnownT isoiec_9798_3_6_2_A_2))
-  , ((isoiec_9798_3_6_2_B, ''Text3''), (KnownT isoiec_9798_3_6_2_B_text_2))
-  , ((isoiec_9798_3_7_1_B, ''Text3''), (KnownT isoiec_9798_3_7_1_B_4))
-  , ((isoiec_9798_3_7_1_T, ''Text3''), (KnownT isoiec_9798_3_7_1_T_text_3))
-  , ((isoiec_9798_3_7_2_A, ''Text3''),
-     (KnownT isoiec_9798_3_7_2_A_check_3_in))
-  , ((isoiec_9798_3_7_2_B, ''Text3''), (KnownT isoiec_9798_3_7_2_B_4))
-  , ((isoiec_9798_3_7_2_T, ''Text3''), (KnownT isoiec_9798_3_7_2_T_text_3))
-  , ((isoiec_9798_3_3_A, ''Text4''), (KnownT isoiec_9798_3_3_A_2))
-  , ((isoiec_9798_3_3_B, ''Text4''), (KnownT isoiec_9798_3_3_B_text_2))
-  , ((isoiec_9798_3_4_A, ''Text4''), (KnownT isoiec_9798_3_4_A_3))
-  , ((isoiec_9798_3_4_B, ''Text4''), (KnownT isoiec_9798_3_4_B_text_3))
-  , ((isoiec_9798_3_5_A, ''Text4''), (KnownT isoiec_9798_3_5_A_text_4))
-  , ((isoiec_9798_3_5_B, ''Text4''), (KnownT isoiec_9798_3_5_B_4))
-  , ((isoiec_9798_3_6_1_A, ''Text4''), (KnownT isoiec_9798_3_6_1_A_text_3))
-  , ((isoiec_9798_3_6_1_T, ''Text4''), (KnownT isoiec_9798_3_6_1_T_3))
-  , ((isoiec_9798_3_6_2_A, ''Text4''), (KnownT isoiec_9798_3_6_2_A_text_3))
-  , ((isoiec_9798_3_6_2_T, ''Text4''), (KnownT isoiec_9798_3_6_2_T_3))
-  , ((isoiec_9798_3_7_1_A, ''Text4''), (KnownT isoiec_9798_3_7_1_A_3))
-  , ((isoiec_9798_3_7_1_T, ''Text4''), (KnownT isoiec_9798_3_7_1_T_text_3))
-  , ((isoiec_9798_3_4_A, ''Text5''), (KnownT isoiec_9798_3_4_A_3))
-  , ((isoiec_9798_3_4_B, ''Text5''), (KnownT isoiec_9798_3_4_B_text_3))
-  , ((isoiec_9798_3_5_A, ''Text5''), (KnownT isoiec_9798_3_5_A_3))
-  , ((isoiec_9798_3_5_B, ''Text5''), (KnownT isoiec_9798_3_5_B_text_3))
-  , ((isoiec_9798_3_6_1_B, ''Text5''), (KnownT isoiec_9798_3_6_1_B_5))
-  , ((isoiec_9798_3_6_1_T, ''Text5''), (KnownT isoiec_9798_3_6_1_T_text_4))
-  , ((isoiec_9798_3_6_2_A, ''Text5''),
-     (KnownT isoiec_9798_3_6_2_A_check_4_in))
-  , ((isoiec_9798_3_6_2_B, ''Text5''), (KnownT isoiec_9798_3_6_2_B_5))
-  , ((isoiec_9798_3_6_2_T, ''Text5''), (KnownT isoiec_9798_3_6_2_T_text_4))
-  , ((isoiec_9798_3_7_1_A, ''Text5''), (KnownT isoiec_9798_3_7_1_A_3))
-  , ((isoiec_9798_3_7_1_T, ''Text5''), (KnownT isoiec_9798_3_7_1_T_text_3))
-  , ((isoiec_9798_3_7_2_A, ''Text5''), (KnownT isoiec_9798_3_7_2_A_3))
-  , ((isoiec_9798_3_7_2_T, ''Text5''), (KnownT isoiec_9798_3_7_2_T_text_3))
-  , ((isoiec_9798_3_5_A, ''Text6''), (KnownT isoiec_9798_3_5_A_3))
-  , ((isoiec_9798_3_5_B, ''Text6''), (KnownT isoiec_9798_3_5_B_text_3))
-  , ((isoiec_9798_3_6_1_A, ''Text6''), (KnownT isoiec_9798_3_6_1_A_4))
-  , ((isoiec_9798_3_6_1_T, ''Text6''), (KnownT isoiec_9798_3_6_1_T_text_4))
-  , ((isoiec_9798_3_7_1_A, ''Text6''), (KnownT isoiec_9798_3_7_1_A_text_4))
-  , ((isoiec_9798_3_7_1_B, ''Text6''), (KnownT isoiec_9798_3_7_1_B_4))
-  , ((isoiec_9798_3_7_2_A, ''Text6''), (KnownT isoiec_9798_3_7_2_A_text_4))
-  , ((isoiec_9798_3_7_2_B, ''Text6''), (KnownT isoiec_9798_3_7_2_B_4))
-  , ((isoiec_9798_3_6_1_A, ''Text7''), (KnownT isoiec_9798_3_6_1_A_4))
-  , ((isoiec_9798_3_6_1_T, ''Text7''), (KnownT isoiec_9798_3_6_1_T_text_4))
-  , ((isoiec_9798_3_6_2_A, ''Text7''), (KnownT isoiec_9798_3_6_2_A_4))
-  , ((isoiec_9798_3_6_2_T, ''Text7''), (KnownT isoiec_9798_3_6_2_T_text_4))
-  , ((isoiec_9798_3_7_1_A, ''Text7''), (KnownT isoiec_9798_3_7_1_A_text_4))
-  , ((isoiec_9798_3_7_2_A, ''Text7''), (KnownT isoiec_9798_3_7_2_A_text_4))
-  , ((isoiec_9798_3_6_1_A, ''Text8''), (KnownT isoiec_9798_3_6_1_A_text_5))
-  , ((isoiec_9798_3_6_1_B, ''Text8''), (KnownT isoiec_9798_3_6_1_B_5))
-  , ((isoiec_9798_3_6_2_A, ''Text8''), (KnownT isoiec_9798_3_6_2_A_text_5))
-  , ((isoiec_9798_3_6_2_B, ''Text8''), (KnownT isoiec_9798_3_6_2_B_5))
-  , ((isoiec_9798_3_7_1_A, ''Text8''), (KnownT isoiec_9798_3_7_1_A_5))
-  , ((isoiec_9798_3_7_1_B, ''Text8''), (KnownT isoiec_9798_3_7_1_B_text_5))
-  , ((isoiec_9798_3_7_2_A, ''Text8''), (KnownT isoiec_9798_3_7_2_A_5))
-  , ((isoiec_9798_3_7_2_B, ''Text8''), (KnownT isoiec_9798_3_7_2_B_text_5))
-  , ((isoiec_9798_3_6_1_A, ''Text9''), (KnownT isoiec_9798_3_6_1_A_text_5))
-  , ((isoiec_9798_3_6_1_B, ''Text9''), (KnownT isoiec_9798_3_6_1_B_5))
-  , ((isoiec_9798_3_6_2_A, ''Text9''), (KnownT isoiec_9798_3_6_2_A_text_5))
-  , ((isoiec_9798_3_6_2_B, ''Text9''), (KnownT isoiec_9798_3_6_2_B_5))
-  , ((isoiec_9798_3_7_1_A, ''Text9''), (KnownT isoiec_9798_3_7_1_A_5))
-  , ((isoiec_9798_3_7_1_B, ''Text9''), (KnownT isoiec_9798_3_7_1_B_4))
-  , ((isoiec_9798_3_7_2_A, ''Text9''), (KnownT isoiec_9798_3_7_2_A_5))
-  , ((isoiec_9798_3_7_2_B, ''Text9''), (KnownT isoiec_9798_3_7_2_B_4))
-  , ((isoiec_9798_3_6_1_A, ''TokenBA''), (KnownT isoiec_9798_3_6_1_A_2))
-  , ((isoiec_9798_3_6_2_A, ''TokenBA''), (KnownT isoiec_9798_3_6_2_A_2))
-  , ((isoiec_9798_3_6_2_A, ''TokenTA''), (KnownT isoiec_9798_3_6_2_A_4))
-  , ((isoiec_9798_3_7_2_A, ''TokenTA''), (KnownT isoiec_9798_3_7_2_A_3))
-  , ((isoiec_9798_3_6_1_A, ''TokenTA_for_B''),
-     (KnownT isoiec_9798_3_6_1_A_4))
-  , ((isoiec_9798_3_7_1_A, ''TokenTA_for_B''),
-     (KnownT isoiec_9798_3_7_1_A_3))
-  , ((isoiec_9798_3_6_1_B, ''pkA''), (KnownT isoiec_9798_3_6_1_B_5))
-  , ((isoiec_9798_3_6_2_A, ''pkA''),
-     (KnownT isoiec_9798_3_6_2_A_check_4_in))
-  , ((isoiec_9798_3_6_2_B, ''pkA''), (KnownT isoiec_9798_3_6_2_B_5))
-  , ((isoiec_9798_3_7_1_B, ''pkA''), (KnownT isoiec_9798_3_7_1_B_4))
-  , ((isoiec_9798_3_7_2_A, ''pkA''),
-     (KnownT isoiec_9798_3_7_2_A_check_3_in))
-  , ((isoiec_9798_3_7_2_B, ''pkA''), (KnownT isoiec_9798_3_7_2_B_4))
-  , ((isoiec_9798_3_6_1_A, ''pkB''), (KnownT isoiec_9798_3_6_1_A_4))
-  , ((isoiec_9798_3_6_2_A, ''pkB''), (KnownT isoiec_9798_3_6_2_A_4))
-  , ((isoiec_9798_3_6_2_B, ''pkB''), (KnownT isoiec_9798_3_6_2_B_5))
-  , ((isoiec_9798_3_7_1_A, ''pkB''), (KnownT isoiec_9798_3_7_1_A_3))
-  , ((isoiec_9798_3_7_2_A, ''pkB''), (KnownT isoiec_9798_3_7_2_A_3))
-  , ((isoiec_9798_3_7_2_B, ''pkB''), (KnownT isoiec_9798_3_7_2_B_4))
-  ]"
-
-sublocale isoiec_9798_3_state < isoiec_9798_3_composed_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_3_composed_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_3_composed_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_3_1_A_text_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_1_A_text_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_1_B_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_1_B_1_TNA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_1_B_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_1_B_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_2_A_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_2_A_1_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_2_A_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_2_A_text_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_2_A_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_2_B_2_Ra t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_2_B_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_2_B_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_3_A_text_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_3_A_text_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_3_A_2_TNB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_3_A_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_3_A_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_3_B_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_3_B_1_TNA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_3_B_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_3_B_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_3_B_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_3_B_text_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_A_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_A_1_RB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_A_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_A_text_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_A_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_A_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_A_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_B_2_RA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_B_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_B_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_B_text_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_B_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_A_2_RB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_A_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_A_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_A_3_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_A_text_4_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_A_text_4_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_B_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_B_1_RA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_B_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_B_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_B_text_3_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_B_4_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_B_4_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_A_2_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_A_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_A_2_TokenBA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_A_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_A_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_A_4_TokenTA_for_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_A_4_pkB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_A_check_4_in_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''check_4'',
-               {| LC ''isoiec_9798_3_6_opt_1_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
-                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-               |},
-               Enc {| LC ''isoiec_9798_3_6_opt_1_sig_2'', s(AV ''B'' tid0),
-                      LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                   |}
-                   ( inv(s(MV ''pkB'' tid0)) )
-            |}
-            ( LN ''check_nonce_4'' tid0 ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_3_6_1_A_text_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_A_text_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_B_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_B_1_Ra t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_B_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_B_text_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_B_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_B_5_Ra5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_B_5_T t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_B_5_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_B_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_B_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_B_5_pkA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_T_3_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_T_3_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_T_3_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_T_3_Rpa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_T_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_T_text_4_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_T_text_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_T_text_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_A_2_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_A_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_A_2_TokenBA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_A_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_A_4_TokenTA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_A_4_pkB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_A_check_4_in_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''check_4'',
-               {| {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                     s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                     s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                  |},
-                  Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                         s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                         s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                      |}
-                      ( SK ( s(AV ''T'' tid0) ) )
-               |},
-               {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
-                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-               |},
-               Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
-                      LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                   |}
-                   ( inv(s(MV ''pkB'' tid0)) )
-            |}
-            ( LN ''check_nonce_4'' tid0 ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_3_6_2_A_check_4_in_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''check_4'',
-               {| {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                     s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                     s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                  |},
-                  Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                         s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                         s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                      |}
-                      ( SK ( s(AV ''T'' tid0) ) )
-               |},
-               {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
-                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-               |},
-               Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
-                      LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                   |}
-                   ( inv(s(MV ''pkB'' tid0)) )
-            |}
-            ( LN ''check_nonce_4'' tid0 ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_3_6_2_A_check_4_in_pkA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''check_4'',
-               {| {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                     s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                     s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                  |},
-                  Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                         s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                         s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                      |}
-                      ( SK ( s(AV ''T'' tid0) ) )
-               |},
-               {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
-                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-               |},
-               Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
-                      LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                   |}
-                   ( inv(s(MV ''pkB'' tid0)) )
-            |}
-            ( LN ''check_nonce_4'' tid0 ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_3_6_2_A_text_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_A_text_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_1_Ra t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_text_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_5_Ra5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_5_Rpa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_5_T t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_5_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_5_pkA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_5_pkB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_T_3_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_T_3_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_T_3_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_T_3_Rpa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_T_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_T_text_4_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_T_text_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_A_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_A_1_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_A_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_A_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_A_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_A_3_TokenTA_for_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_A_3_pkB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_A_text_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_A_text_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_A_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_A_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_B_4_Ra t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_B_4_Rpa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_B_4_T t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_B_4_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_B_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_B_4_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_B_4_pkA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_B_text_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_T_2_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_T_2_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_T_2_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_T_2_Rpa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_T_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_T_text_3_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_T_text_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_T_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_A_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_A_1_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_A_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_A_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_A_3_TokenTA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_A_3_pkB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_A_check_3_in_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''check_4'',
-               {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
-                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                  s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-               |},
-               Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
-                      s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                      s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-                   |}
-                   ( SK ( s(AV ''T'' tid0) ) )
-            |}
-            ( LN ''check_nonce_4'' tid0 ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_3_7_2_A_check_3_in_pkA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''check_4'',
-               {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
-                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                  s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-               |},
-               Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
-                      s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                      s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-                   |}
-                   ( SK ( s(AV ''T'' tid0) ) )
-            |}
-            ( LN ''check_nonce_4'' tid0 ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_3_7_2_A_text_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_A_text_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_A_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_A_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_B_4_Ra t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_B_4_Rpa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_B_4_T t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_B_4_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_B_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_B_4_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_B_4_pkA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_B_4_pkB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_B_text_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_T_2_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_T_2_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_T_2_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_T_2_Rpa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_T_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_T_text_3_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_T_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_composed_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_3_composed_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_3_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_1_B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_1_B"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_1_B_1 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_1_A &
-        ( tid1, isoiec_9798_3_1_A_1 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
-           s(MV ''Text1'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
-                s(MV ''Text1'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_1_sig_1'', s(MV ''TNA'' tid0),
-                          s(AV ''B'' tid0), s(MV ''Text1'' tid0)
-                       |}
-                       ( SK ( s(MV ''A'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_1_A_1_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_2_B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_2_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_2_B_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_2_A &
-        ( tid1, isoiec_9798_3_2_A_2 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
-                LN ''Rb'' tid0, s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_2_sig_2'', s(MV ''Ra'' tid0), LN ''Rb'' tid0,
-                          s(AV ''B'' tid0), s(MV ''Text2'' tid0)
-                       |}
-                       ( SK ( s(AV ''A'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_2_A_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_3_A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_3_A"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_3_A_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_3_B &
-        ( tid1, isoiec_9798_3_3_B_2 ) : steps t &
-        {| s(MV ''A'' tid1), s(AV ''B'' tid1), LN ''TNB'' tid1,
-           s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNB'' tid0),
-                s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_3_sig_2'', s(MV ''TNB'' tid0),
-                          s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( SK ( s(AV ''B'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_3_B_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_3_B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_3_B"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_3_B_1 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_3_A &
-        ( tid1, isoiec_9798_3_3_A_1 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
-           s(MV ''Text1'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
-                s(MV ''Text1'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_3_sig_1'', s(MV ''TNA'' tid0),
-                          s(AV ''B'' tid0), s(MV ''Text1'' tid0)
-                       |}
-                       ( SK ( s(MV ''A'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_3_A_1_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_4_A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_4_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_4_A_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_4_B &
-        ( tid1, isoiec_9798_3_4_B_3 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''RA'' tid1), LN ''RB'' tid1,
-           s(MV ''Text2'' tid1), s(MV ''Text4'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''RA'' tid0,
-                s(MV ''RB'' tid0), s(MV ''Text2'' tid0), s(MV ''Text4'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_4_sig_2'', s(MV ''RB'' tid0), LN ''RA'' tid0,
-                          s(AV ''A'' tid0), s(MV ''Text4'' tid0)
-                       |}
-                       ( SK ( s(MV ''B'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_4_B_3_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_4_sig_1'', LN ''RA'' tid0, LN ''RB'' tid1,
-                            s(AV ''B'' tid1), s(MV ''Text2'' tid1)
-                         |}
-                         ( SK ( s(AV ''A'' tid0) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_3_4_A_2_enc tid2) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_4_B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_4_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_4_B_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_4_A &
-        ( tid1, isoiec_9798_3_4_A_2 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''RA'' tid1, s(MV ''RB'' tid1),
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''RA'' tid0),
-                LN ''RB'' tid0, s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_4_sig_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
-                          s(AV ''B'' tid0), s(MV ''Text2'' tid0)
-                       |}
-                       ( SK ( s(AV ''A'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_4_A_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_5_A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_5_A"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_5_A_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_5_B &
-        ( tid1, isoiec_9798_3_5_B_3 ) : steps t &
-        {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''RA'' tid1), LN ''RB'' tid1,
-           s(MV ''Text5'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''RA'' tid0,
-                s(MV ''RB'' tid0), s(MV ''Text5'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_5_sig_1'', s(MV ''RB'' tid0), LN ''RA'' tid0,
-                          s(AV ''A'' tid0), s(MV ''Text5'' tid0)
-                       |}
-                       ( SK ( s(AV ''B'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_5_B_3_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_5_B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_5_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_5_B_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_5_A &
-        ( tid1, isoiec_9798_3_5_A_4 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''RA'' tid1, s(MV ''RB'' tid1),
-           s(MV ''Text3'' tid1), s(MV ''Text5'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''RA'' tid0),
-                LN ''RB'' tid0, s(MV ''Text3'' tid0), s(MV ''Text5'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_5_sig_2'', s(MV ''RA'' tid0), LN ''RB'' tid0,
-                          s(AV ''B'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( SK ( s(MV ''A'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_5_A_4_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_5_sig_1'', LN ''RB'' tid0, LN ''RA'' tid1,
-                            s(AV ''A'' tid1), s(MV ''Text5'' tid1)
-                         |}
-                         ( SK ( s(AV ''B'' tid0) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_3_5_B_3_enc tid2) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_6_1_A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_6_1_A"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_6_1_A_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_6_1_B &
-        ( tid1, isoiec_9798_3_6_1_B_2 ) : steps t &
-        {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''Ra'' tid0,
-                s(MV ''Rb'' tid0), s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''check_4'',
-                          {| LC ''isoiec_9798_3_6_opt_1_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
-                             s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                          |},
-                          Enc {| LC ''isoiec_9798_3_6_opt_1_sig_2'', s(AV ''B'' tid0),
-                                 LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                              |}
-                              ( inv(s(MV ''pkB'' tid0)) )
-                       |}
-                       ( LN ''check_nonce_4'' tid0 ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis proof(sources! " LN ''check_nonce_4'' tid0 ")
-    qed (insert facts, fastsimp+)?
-  next
-    case (isoiec_9798_3_6_1_A_check_4_out_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_6_opt_1_sig_2'', s(AV ''B'' tid0),
-                            LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                         |}
-                         ( inv(s(MV ''pkB'' tid0)) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_3_6_opt_1_sig_4_1'', LN ''Rpa'' tid0,
-                              s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text6'' tid0)
-                           |}
-                           ( SK ( s(AV ''T'' tid0) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest!: ltk_secrecy)
-      next
-        case (isoiec_9798_3_6_1_T_4_enc tid1) note_unified facts = this facts
-        thus ?thesis by (fastsimp dest!: ltk_secrecy)
-      qed (insert facts, fastsimp+)?
-    next
-      case (isoiec_9798_3_6_1_B_2_enc tid1) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_6_1_B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_6_1_B"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_6_1_B_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_6_1_A &
-        ( tid1, isoiec_9798_3_6_1_A_5 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
-           s(MV ''Text8'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra5'' tid0),
-                LN ''Rb'' tid0, s(MV ''Text8'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_6_opt_1_sig_4_2'', LN ''Rb'' tid0,
-                          s(MV ''A'' tid0), s(MV ''pkA'' tid0), s(MV ''Text5'' tid0)
-                       |}
-                       ( SK ( s(MV ''T'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_6_1_T_4_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_6_opt_1_sig_5'', LN ''Rb'' tid0,
-                            s(MV ''Ra5'' tid0), s(AV ''B'' tid0), s(MV ''A'' tid0),
-                            s(MV ''Text8'' tid0)
-                         |}
-                         ( SK ( s(MV ''A'' tid0) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_3_6_1_A_5_enc tid2) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_6_1_A_non_injective_agreement_T:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_6_1_A"
-    "RLKR(s(AV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_6_1_A_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_6_1_T &
-        ( tid1, isoiec_9798_3_6_1_T_4 ) : steps t &
-        {| s(MV ''B'' tid1), s(AV ''T'' tid1), s(MV ''Rpa'' tid1),
-           PK ( s(MV ''B'' tid1) ), s(MV ''Text6'' tid1)
-        |} = {| s(AV ''B'' tid0), s(AV ''T'' tid0), LN ''Rpa'' tid0,
-                s(MV ''pkB'' tid0), s(MV ''Text6'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_6_opt_1_sig_4_1'', LN ''Rpa'' tid0,
-                          s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text6'' tid0)
-                       |}
-                       ( SK ( s(AV ''T'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_6_1_T_4_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_6_1_B_non_injective_agreement_T:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_6_1_B"
-    "RLKR(s(MV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_6_1_B_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_6_1_T &
-        ( tid1, isoiec_9798_3_6_1_T_4 ) : steps t &
-        {| s(MV ''A'' tid1), s(AV ''T'' tid1), s(MV ''Rb'' tid1),
-           PK ( s(MV ''A'' tid1) ), s(MV ''Text5'' tid1)
-        |} = {| s(MV ''A'' tid0), s(MV ''T'' tid0), LN ''Rb'' tid0,
-                s(MV ''pkA'' tid0), s(MV ''Text5'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_6_opt_1_sig_4_2'', LN ''Rb'' tid0,
-                          s(MV ''A'' tid0), s(MV ''pkA'' tid0), s(MV ''Text5'' tid0)
-                       |}
-                       ( SK ( s(MV ''T'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_6_1_T_4_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_6_2_A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_6_2_A"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_6_2_A_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_6_2_B &
-        ( tid1, isoiec_9798_3_6_2_B_2 ) : steps t &
-        {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''Ra'' tid0,
-                s(MV ''Rb'' tid0), s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''check_4'',
-                          {| {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                                s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                                s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                             |},
-                             Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                                    s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                                    s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                                 |}
-                                 ( SK ( s(AV ''T'' tid0) ) )
-                          |},
-                          {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
-                             s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                          |},
-                          Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
-                                 LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                              |}
-                              ( inv(s(MV ''pkB'' tid0)) )
-                       |}
-                       ( LN ''check_nonce_4'' tid0 ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis proof(sources! " LN ''check_nonce_4'' tid0 ")
-    qed (insert facts, fastsimp+)?
-  next
-    case (isoiec_9798_3_6_2_A_check_4_out_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
-                            LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                         |}
-                         ( inv(s(MV ''pkB'' tid0)) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                              s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                              s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                           |}
-                           ( SK ( s(AV ''T'' tid0) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest!: ltk_secrecy)
-      next
-        case (isoiec_9798_3_6_2_T_4_enc tid1) note_unified facts = this facts
-        thus ?thesis by (fastsimp dest!: ltk_secrecy)
-      qed (insert facts, fastsimp+)?
-    next
-      case (isoiec_9798_3_6_2_B_2_enc tid1) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_6_2_B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_6_2_B"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_6_2_B_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_6_2_A &
-        ( tid1, isoiec_9798_3_6_2_A_5 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
-           s(MV ''Text8'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra5'' tid0),
-                LN ''Rb'' tid0, s(MV ''Text8'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', s(MV ''Rpa'' tid0),
-                          LN ''Rb'' tid0, s(MV ''A'' tid0), s(MV ''pkA'' tid0), s(AV ''B'' tid0),
-                          s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                       |}
-                       ( SK ( s(MV ''T'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_6_2_T_4_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_6_opt_2_sig_5'', LN ''Rb'' tid0,
-                            s(MV ''Ra5'' tid0), s(AV ''B'' tid0), s(MV ''A'' tid0),
-                            s(MV ''Text8'' tid0)
-                         |}
-                         ( SK ( s(MV ''A'' tid0) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_3_6_2_A_5_enc tid2) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_6_2_A_non_injective_agreement_T:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_6_2_A"
-    "RLKR(s(AV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_6_2_A_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_6_2_T &
-        ( tid1, isoiec_9798_3_6_2_T_4 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''T'' tid1),
-           s(MV ''Rpa'' tid1), s(MV ''Rb'' tid1), PK ( s(MV ''A'' tid1) ),
-           PK ( s(MV ''B'' tid1) ), s(MV ''Text5'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''T'' tid0),
-                LN ''Rpa'' tid0, s(MV ''Rb'' tid0), s(MV ''pkA'' tid0),
-                s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''check_4'',
-                          {| {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                                s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                                s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                             |},
-                             Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                                    s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                                    s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                                 |}
-                                 ( SK ( s(AV ''T'' tid0) ) )
-                          |},
-                          {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
-                             s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                          |},
-                          Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
-                                 LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                              |}
-                              ( inv(s(MV ''pkB'' tid0)) )
-                       |}
-                       ( LN ''check_nonce_4'' tid0 ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis proof(sources! " LN ''check_nonce_4'' tid0 ")
-    qed (insert facts, fastsimp+)?
-  next
-    case (isoiec_9798_3_6_2_A_check_4_out_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                            s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                            s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                         |}
-                         ( SK ( s(AV ''T'' tid0) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_3_6_2_T_4_enc tid1) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_6_2_B_non_injective_agreement_T:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_6_2_B"
-    "RLKR(s(MV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_6_2_B_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_6_2_T &
-        ( tid1, isoiec_9798_3_6_2_T_4 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''T'' tid1),
-           s(MV ''Rpa'' tid1), s(MV ''Rb'' tid1), PK ( s(MV ''A'' tid1) ),
-           PK ( s(MV ''B'' tid1) ), s(MV ''Text5'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''T'' tid0),
-                s(MV ''Rpa'' tid0), LN ''Rb'' tid0, s(MV ''pkA'' tid0),
-                s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', s(MV ''Rpa'' tid0),
-                          LN ''Rb'' tid0, s(MV ''A'' tid0), s(MV ''pkA'' tid0), s(AV ''B'' tid0),
-                          s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                       |}
-                       ( SK ( s(MV ''T'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_6_2_T_4_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_7_1_A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_7_1_A"
-    "RLKR(s(AV ''T'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_7_1_A_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_7_1_B &
-        ( tid1, isoiec_9798_3_7_1_B_5 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
-           s(MV ''Text8'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''Ra'' tid0,
-                s(MV ''Rb'' tid0), s(MV ''Text8'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_7_opt_1_sig_3_1'', LN ''Rpa'' tid0,
-                          s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text4'' tid0)
-                       |}
-                       ( SK ( s(AV ''T'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_7_1_T_3_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_7_opt_1_sig_5'', LN ''Ra'' tid0,
-                            s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
-                            s(MV ''Text8'' tid0)
-                         |}
-                         ( SK ( s(MV ''B'' tid0) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_3_7_1_B_5_enc tid2) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_7_1_B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_7_1_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_7_1_B_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_7_1_A &
-        ( tid1, isoiec_9798_3_7_1_A_4 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
-           s(MV ''Text6'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
-                LN ''Rb'' tid0, s(MV ''Text6'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_7_opt_1_sig_3_2'', LN ''Rb'' tid0,
-                          s(AV ''A'' tid0), s(MV ''pkA'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( SK ( s(MV ''T'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_7_1_T_3_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_7_opt_1_sig_4'', LN ''Rb'' tid0,
-                            s(MV ''Ra'' tid0), s(AV ''B'' tid0), s(AV ''A'' tid0),
-                            s(MV ''Text6'' tid0)
-                         |}
-                         ( SK ( s(AV ''A'' tid0) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_3_7_1_A_4_enc tid2) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_7_1_A_non_injective_agreement_T:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_7_1_A"
-    "RLKR(s(AV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_7_1_A_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_7_1_T &
-        ( tid1, isoiec_9798_3_7_1_T_3 ) : steps t &
-        {| s(MV ''B'' tid1), s(AV ''T'' tid1), s(MV ''Rpa'' tid1),
-           PK ( s(MV ''B'' tid1) ), s(MV ''Text4'' tid1)
-        |} = {| s(MV ''B'' tid0), s(AV ''T'' tid0), LN ''Rpa'' tid0,
-                s(MV ''pkB'' tid0), s(MV ''Text4'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_7_opt_1_sig_3_1'', LN ''Rpa'' tid0,
-                          s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text4'' tid0)
-                       |}
-                       ( SK ( s(AV ''T'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_7_1_T_3_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_7_1_B_non_injective_agreement_T:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_7_1_B"
-    "RLKR(s(MV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_7_1_B_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_7_1_T &
-        ( tid1, isoiec_9798_3_7_1_T_3 ) : steps t &
-        {| s(MV ''A'' tid1), s(AV ''T'' tid1), s(MV ''Rb'' tid1),
-           PK ( s(MV ''A'' tid1) ), s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''T'' tid0), LN ''Rb'' tid0,
-                s(MV ''pkA'' tid0), s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_7_opt_1_sig_3_2'', LN ''Rb'' tid0,
-                          s(AV ''A'' tid0), s(MV ''pkA'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( SK ( s(MV ''T'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_7_1_T_3_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_7_2_A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_7_2_A"
-    "RLKR(s(AV ''T'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_7_2_A_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_7_2_B &
-        ( tid1, isoiec_9798_3_7_2_B_5 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
-           s(MV ''Text8'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''Ra'' tid0,
-                s(MV ''Rb'' tid0), s(MV ''Text8'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''check_4'',
-                          {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
-                             s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                             s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-                          |},
-                          Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
-                                 s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                                 s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-                              |}
-                              ( SK ( s(AV ''T'' tid0) ) )
-                       |}
-                       ( LN ''check_nonce_4'' tid0 ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis proof(sources! " LN ''check_nonce_4'' tid0 ")
-    qed (insert facts, fastsimp+)?
-  next
-    case (isoiec_9798_3_7_2_A_check_3_out_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
-                            s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                            s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-                         |}
-                         ( SK ( s(AV ''T'' tid0) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_3_7_2_T_3_enc tid1) note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_3_7_opt_2_sig_5'', LN ''Ra'' tid0,
-                              s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
-                              s(MV ''Text8'' tid0)
-                           |}
-                           ( SK ( s(MV ''B'' tid0) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest!: ltk_secrecy)
-      next
-        case (isoiec_9798_3_7_2_B_5_enc tid2) note_unified facts = this facts
-        thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-      qed (insert facts, fastsimp+)?
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_7_2_B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_7_2_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_7_2_B_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_7_2_A &
-        ( tid1, isoiec_9798_3_7_2_A_4 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
-           s(MV ''Text6'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
-                LN ''Rb'' tid0, s(MV ''Text6'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', s(MV ''Rpa'' tid0),
-                          LN ''Rb'' tid0, s(AV ''A'' tid0), s(MV ''pkA'' tid0), s(AV ''B'' tid0),
-                          s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( SK ( s(MV ''T'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_7_2_T_3_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_7_opt_2_sig_4'', LN ''Rb'' tid0,
-                            s(MV ''Ra'' tid0), s(AV ''B'' tid0), s(AV ''A'' tid0),
-                            s(MV ''Text6'' tid0)
-                         |}
-                         ( SK ( s(AV ''A'' tid0) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_3_7_2_A_4_enc tid2) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_7_2_A_non_injective_agreement_T:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_7_2_A"
-    "RLKR(s(AV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_7_2_A_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_7_2_T &
-        ( tid1, isoiec_9798_3_7_2_T_3 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''T'' tid1),
-           s(MV ''Rpa'' tid1), s(MV ''Rb'' tid1), PK ( s(MV ''A'' tid1) ),
-           PK ( s(MV ''B'' tid1) ), s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''T'' tid0),
-                LN ''Rpa'' tid0, s(MV ''Rb'' tid0), s(MV ''pkA'' tid0),
-                s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''check_4'',
-                          {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
-                             s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                             s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-                          |},
-                          Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
-                                 s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                                 s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-                              |}
-                              ( SK ( s(AV ''T'' tid0) ) )
-                       |}
-                       ( LN ''check_nonce_4'' tid0 ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis proof(sources! " LN ''check_nonce_4'' tid0 ")
-    qed (insert facts, fastsimp+)?
-  next
-    case (isoiec_9798_3_7_2_A_check_3_out_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
-                            s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                            s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-                         |}
-                         ( SK ( s(AV ''T'' tid0) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_3_7_2_T_3_enc tid1) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_7_2_B_non_injective_agreement_T:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_7_2_B"
-    "RLKR(s(MV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_7_2_B_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_7_2_T &
-        ( tid1, isoiec_9798_3_7_2_T_3 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''T'' tid1),
-           s(MV ''Rpa'' tid1), s(MV ''Rb'' tid1), PK ( s(MV ''A'' tid1) ),
-           PK ( s(MV ''B'' tid1) ), s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''T'' tid0),
-                s(MV ''Rpa'' tid0), LN ''Rb'' tid0, s(MV ''pkA'' tid0),
-                s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', s(MV ''Rpa'' tid0),
-                          LN ''Rb'' tid0, s(AV ''A'' tid0), s(MV ''pkA'' tid0), s(AV ''B'' tid0),
-                          s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( SK ( s(MV ''T'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_7_2_T_3_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+  "ESPLogic"
+begin
+
+role isoiec_9798_3_1_A
+where "isoiec_9798_3_1_A =
+  [ Send ''leak_A'' ( sN ''TNA'' )
+  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
+  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
+                  PSign <| sC ''isoiec_9798_3_1_sig_1'', sN ''TNA'', sAV ''B'',
+                           sMV ''Text1''
+                        |>
+                        ( sPK ''A'' )
+               |>
+  ]"
+
+role isoiec_9798_3_1_B
+where "isoiec_9798_3_1_B =
+  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
+                  PSign <| sC ''isoiec_9798_3_1_sig_1'', sMV ''TNA'', sAV ''B'',
+                           sMV ''Text1''
+                        |>
+                        ( PAsymPK ( sMV ''A'' ) )
+               |>
+  ]"
+
+role isoiec_9798_3_2_A
+where "isoiec_9798_3_2_A =
+  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
+  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
+  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
+                  PSign <| sC ''isoiec_9798_3_2_sig_2'', sN ''Ra'', sMV ''Rb'', sMV ''B'',
+                           sMV ''Text2''
+                        |>
+                        ( sPK ''A'' )
+               |>
+  ]"
+
+role isoiec_9798_3_2_B
+where "isoiec_9798_3_2_B =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
+  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
+                  PSign <| sC ''isoiec_9798_3_2_sig_2'', sMV ''Ra'', sN ''Rb'', sAV ''B'',
+                           sMV ''Text2''
+                        |>
+                        ( sPK ''A'' )
+               |>
+  ]"
+
+role isoiec_9798_3_3_A
+where "isoiec_9798_3_3_A =
+  [ Send ''leak_A'' ( sN ''TNA'' )
+  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
+  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
+                  PSign <| sC ''isoiec_9798_3_3_sig_1'', sN ''TNA'', sAV ''B'',
+                           sMV ''Text1''
+                        |>
+                        ( sPK ''A'' )
+               |>
+  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text4'',
+                  PSign <| sC ''isoiec_9798_3_3_sig_2'', sMV ''TNB'', sAV ''A'',
+                           sMV ''Text3''
+                        |>
+                        ( sPK ''B'' )
+               |>
+  ]"
+
+role isoiec_9798_3_3_B
+where "isoiec_9798_3_3_B =
+  [ Send ''leak_B'' ( sN ''TNB'' )
+  , Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
+                  PSign <| sC ''isoiec_9798_3_3_sig_1'', sMV ''TNA'', sAV ''B'',
+                           sMV ''Text1''
+                        |>
+                        ( PAsymPK ( sMV ''A'' ) )
+               |>
+  , Recv ''text_2'' <| sMV ''Text3'', sMV ''Text4'' |>
+  , Send ''2'' <| sMV ''A'', sAV ''B'', sMV ''Text4'',
+                  PSign <| sC ''isoiec_9798_3_3_sig_2'', sN ''TNB'', sMV ''A'',
+                           sMV ''Text3''
+                        |>
+                        ( sPK ''B'' )
+               |>
+  ]"
+
+role isoiec_9798_3_4_A
+where "isoiec_9798_3_4_A =
+  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text1'' |>
+  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
+  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
+                  PSign <| sC ''isoiec_9798_3_4_sig_1'', sN ''RA'', sMV ''RB'', sMV ''B'',
+                           sMV ''Text2''
+                        |>
+                        ( sPK ''A'' )
+               |>
+  , Recv ''3'' <| sMV ''B'', sAV ''A'', sMV ''Text5'',
+                  PSign <| sC ''isoiec_9798_3_4_sig_2'', sMV ''RB'', sN ''RA'', sAV ''A'',
+                           sMV ''Text4''
+                        |>
+                        ( PAsymPK ( sMV ''B'' ) )
+               |>
+  ]"
+
+role isoiec_9798_3_4_B
+where "isoiec_9798_3_4_B =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''RB'', sMV ''Text1'' |>
+  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
+                  PSign <| sC ''isoiec_9798_3_4_sig_1'', sMV ''RA'', sN ''RB'', sAV ''B'',
+                           sMV ''Text2''
+                        |>
+                        ( sPK ''A'' )
+               |>
+  , Recv ''text_3'' <| sMV ''Text4'', sMV ''Text5'' |>
+  , Send ''3'' <| sAV ''B'', sAV ''A'', sMV ''Text5'',
+                  PSign <| sC ''isoiec_9798_3_4_sig_2'', sN ''RB'', sMV ''RA'', sAV ''A'',
+                           sMV ''Text4''
+                        |>
+                        ( sPK ''B'' )
+               |>
+  ]"
+
+role isoiec_9798_3_5_A
+where "isoiec_9798_3_5_A =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''A'', sAV ''B'', sN ''RA'', sMV ''Text1'' |>
+  , Recv ''2'' <| sAV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text2'' |>
+  , Recv ''3'' <| sAV ''B'', sAV ''A'', sMV ''Text6'',
+                  PSign <| sC ''isoiec_9798_3_5_sig_1'', sMV ''RB'', sN ''RA'', sAV ''A'',
+                           sMV ''Text5''
+                        |>
+                        ( sPK ''B'' )
+               |>
+  , Recv ''text_4'' <| sMV ''Text3'', sMV ''Text4'' |>
+  , Send ''4'' <| sAV ''A'', sAV ''B'', sMV ''Text4'',
+                  PSign <| sC ''isoiec_9798_3_5_sig_2'', sN ''RA'', sMV ''RB'', sAV ''B'',
+                           sMV ''Text3''
+                        |>
+                        ( sPK ''A'' )
+               |>
+  ]"
+
+role isoiec_9798_3_5_B
+where "isoiec_9798_3_5_B =
+  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''RA'', sMV ''Text1'' |>
+  , Recv ''text_2'' ( sMV ''Text2'' )
+  , Send ''2'' <| sAV ''B'', sMV ''A'', sN ''RB'', sMV ''Text2'' |>
+  , Recv ''text_3'' <| sMV ''Text5'', sMV ''Text6'' |>
+  , Send ''3'' <| sAV ''B'', sMV ''A'', sMV ''Text6'',
+                  PSign <| sC ''isoiec_9798_3_5_sig_1'', sN ''RB'', sMV ''RA'', sMV ''A'',
+                           sMV ''Text5''
+                        |>
+                        ( sPK ''B'' )
+               |>
+  , Recv ''4'' <| sMV ''A'', sAV ''B'', sMV ''Text4'',
+                  PSign <| sC ''isoiec_9798_3_5_sig_2'', sMV ''RA'', sN ''RB'', sAV ''B'',
+                           sMV ''Text3''
+                        |>
+                        ( PAsymPK ( sMV ''A'' ) )
+               |>
+  ]"
+
+role isoiec_9798_3_6_1_A
+where "isoiec_9798_3_6_1_A =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''A'', sAV ''B'', sN ''Ra'', sMV ''Text1'' |>
+  , Recv ''2'' <| sAV ''A'', sAV ''B'', sN ''Ra'', sMV ''Rb'',
+                  sMV ''Text3'', sMV ''TokenBA''
+               |>
+  , Recv ''text_3'' ( sMV ''Text4'' )
+  , Send ''3'' <| sAV ''A'', sAV ''T'', sN ''Rpa'', sMV ''Rb'', sAV ''B'',
+                  sMV ''Text4''
+               |>
+  , Recv ''4'' <| sAV ''T'', sAV ''A'', sMV ''Text7'', sAV ''A'',
+                  sPK ''A'', sAV ''B'', sMV ''pkB'',
+                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_4_1'', sN ''Rpa'', sAV ''B'',
+                           sMV ''pkB'', sMV ''Text6''
+                        |>
+                        ( sPK ''T'' ),
+                  sMV ''TokenTA_for_B''
+               |>
+  , Send ''check_4_out'' ( PEnc <| sC ''check_4'', sMV ''TokenBA'' |>
+                                ( sN ''check_nonce_4'' )
+                         )
+  , Recv ''check_4_in'' ( PEnc <| sC ''check_4'',
+                                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_2'', sAV ''B'', sN ''Ra'',
+                                           sMV ''Rb'', sAV ''A'', sMV ''Text2''
+                                        |>
+                                        ( sMV ''pkB'' )
+                               |>
+                               ( sN ''check_nonce_4'' )
+                        )
+  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
+  , Send ''5'' <| sAV ''A'', sAV ''B'', sMV ''Text9'', sAV ''T'',
+                  sMV ''TokenTA_for_B'',
+                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_5'', sMV ''Rb'', sN ''Ra'',
+                           sAV ''B'', sAV ''A'', sMV ''Text8''
+                        |>
+                        ( sPK ''A'' )
+               |>
+  ]"
+
+role isoiec_9798_3_6_1_B
+where "isoiec_9798_3_6_1_B =
+  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Ra'', sMV ''Text1'' |>
+  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
+  , Send ''2'' <| sMV ''A'', sAV ''B'', sMV ''Ra'', sN ''Rb'',
+                  sMV ''Text3'',
+                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_2'', sAV ''B'', sMV ''Ra'',
+                           sN ''Rb'', sMV ''A'', sMV ''Text2''
+                        |>
+                        ( sPK ''B'' )
+               |>
+  , Recv ''5'' <| sMV ''A'', sAV ''B'', sMV ''Text9'', sMV ''T'',
+                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_4_2'', sN ''Rb'', sMV ''A'',
+                           sMV ''pkA'', sMV ''Text5''
+                        |>
+                        ( PAsymPK ( sMV ''T'' ) ),
+                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_5'', sN ''Rb'', sMV ''Ra'',
+                           sAV ''B'', sMV ''A'', sMV ''Text8''
+                        |>
+                        ( sMV ''pkA'' )
+               |>
+  ]"
+
+role isoiec_9798_3_6_1_T
+where "isoiec_9798_3_6_1_T =
+  [ Recv ''3'' <| sMV ''A'', sAV ''T'', sMV ''Rpa'', sMV ''Rb'', sMV ''B'',
+                  sMV ''Text4''
+               |>
+  , Recv ''text_4'' <| sMV ''Text5'', sMV ''Text6'', sMV ''Text7'' |>
+  , Send ''4'' <| sAV ''T'', sMV ''A'', sMV ''Text7'', sMV ''A'',
+                  PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
+                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_4_1'', sMV ''Rpa'', sMV ''B'',
+                           PAsymPK ( sMV ''B'' ), sMV ''Text6''
+                        |>
+                        ( sPK ''T'' ),
+                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_4_2'', sMV ''Rb'', sMV ''A'',
+                           PAsymPK ( sMV ''A'' ), sMV ''Text5''
+                        |>
+                        ( sPK ''T'' )
+               |>
+  ]"
+
+role isoiec_9798_3_6_2_A
+where "isoiec_9798_3_6_2_A =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''A'', sAV ''B'', sN ''Ra'', sMV ''Text1'' |>
+  , Recv ''2'' <| sAV ''A'', sAV ''B'', sN ''Ra'', sMV ''Rb'',
+                  sMV ''Text3'', sMV ''TokenBA''
+               |>
+  , Recv ''text_3'' ( sMV ''Text4'' )
+  , Send ''3'' <| sAV ''A'', sAV ''T'', sN ''Rpa'', sMV ''Rb'', sAV ''B'',
+                  sMV ''Text4''
+               |>
+  , Recv ''4'' <| sAV ''T'', sAV ''A'', sMV ''Text7'', sAV ''A'',
+                  sPK ''A'', sAV ''B'', sMV ''pkB'', sMV ''TokenTA''
+               |>
+  , Send ''check_4_out'' ( PEnc <| sC ''check_4'', sMV ''TokenTA'',
+                                   sMV ''TokenBA''
+                                |>
+                                ( sN ''check_nonce_4'' )
+                         )
+  , Recv ''check_4_in'' ( PEnc <| sC ''check_4'',
+                                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_4'', sN ''Rpa'', sMV ''Rb'',
+                                           sAV ''A'', sMV ''pkA'', sAV ''B'', sMV ''pkB'', sMV ''Text5''
+                                        |>
+                                        ( sPK ''T'' ),
+                                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_2'', sAV ''B'', sN ''Ra'',
+                                           sMV ''Rb'', sAV ''A'', sMV ''Text2''
+                                        |>
+                                        ( sMV ''pkB'' )
+                               |>
+                               ( sN ''check_nonce_4'' )
+                        )
+  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
+  , Send ''5'' <| sAV ''A'', sAV ''B'', sN ''Rpa'', sMV ''Text9'',
+                  sAV ''T'', sMV ''TokenTA'',
+                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_5'', sMV ''Rb'', sN ''Ra'',
+                           sAV ''B'', sAV ''A'', sMV ''Text8''
+                        |>
+                        ( sPK ''A'' )
+               |>
+  ]"
+
+role isoiec_9798_3_6_2_B
+where "isoiec_9798_3_6_2_B =
+  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Ra'', sMV ''Text1'' |>
+  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
+  , Send ''2'' <| sMV ''A'', sAV ''B'', sMV ''Ra'', sN ''Rb'',
+                  sMV ''Text3'',
+                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_2'', sAV ''B'', sMV ''Ra'',
+                           sN ''Rb'', sMV ''A'', sMV ''Text2''
+                        |>
+                        ( sPK ''B'' )
+               |>
+  , Recv ''5'' <| sMV ''A'', sAV ''B'', sMV ''Rpa'', sMV ''Text9'',
+                  sMV ''T'',
+                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_4'', sMV ''Rpa'', sN ''Rb'',
+                           sMV ''A'', sMV ''pkA'', sAV ''B'', sMV ''pkB'', sMV ''Text5''
+                        |>
+                        ( PAsymPK ( sMV ''T'' ) ),
+                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_5'', sN ''Rb'', sMV ''Ra'',
+                           sAV ''B'', sMV ''A'', sMV ''Text8''
+                        |>
+                        ( sMV ''pkA'' )
+               |>
+  ]"
+
+role isoiec_9798_3_6_2_T
+where "isoiec_9798_3_6_2_T =
+  [ Recv ''3'' <| sMV ''A'', sAV ''T'', sMV ''Rpa'', sMV ''Rb'', sMV ''B'',
+                  sMV ''Text4''
+               |>
+  , Recv ''text_4'' <| sMV ''Text5'', sMV ''Text7'' |>
+  , Send ''4'' <| sAV ''T'', sMV ''A'', sMV ''Text7'', sMV ''A'',
+                  PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
+                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_4'', sMV ''Rpa'', sMV ''Rb'',
+                           sMV ''A'', PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
+                           sMV ''Text5''
+                        |>
+                        ( sPK ''T'' )
+               |>
+  ]"
+
+role isoiec_9798_3_7_1_A
+where "isoiec_9798_3_7_1_A =
+  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
+  , Recv ''text_2'' ( sMV ''Text2'' )
+  , Send ''2'' <| sAV ''A'', sAV ''T'', sN ''Rpa'', sMV ''Rb'', sAV ''A'',
+                  sMV ''B'', sMV ''Text2''
+               |>
+  , Recv ''3'' <| sAV ''T'', sAV ''A'', sMV ''Text5'', sAV ''A'',
+                  sPK ''A'', sMV ''B'', sMV ''pkB'',
+                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_3_1'', sN ''Rpa'', sMV ''B'',
+                           sMV ''pkB'', sMV ''Text4''
+                        |>
+                        ( sPK ''T'' ),
+                  sMV ''TokenTA_for_B''
+               |>
+  , Recv ''text_4'' <| sMV ''Text6'', sMV ''Text7'' |>
+  , Send ''4'' <| sAV ''A'', sMV ''B'', sN ''Rpa'', sMV ''Text7'',
+                  sAV ''T'', sMV ''TokenTA_for_B'',
+                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_4'', sMV ''Rb'', sN ''Ra'',
+                           sMV ''B'', sAV ''A'', sMV ''Text6''
+                        |>
+                        ( sPK ''A'' )
+               |>
+  , Recv ''5'' <| sAV ''A'', sMV ''B'', sN ''Ra'', sMV ''Rb'',
+                  sMV ''Text9'',
+                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_5'', sN ''Ra'', sMV ''Rb'',
+                           sAV ''A'', sMV ''B'', sMV ''Text8''
+                        |>
+                        ( sMV ''pkB'' )
+               |>
+  ]"
+
+role isoiec_9798_3_7_1_B
+where "isoiec_9798_3_7_1_B =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
+  , Recv ''4'' <| sAV ''A'', sAV ''B'', sMV ''Rpa'', sMV ''Text9'',
+                  sMV ''T'',
+                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_3_2'', sN ''Rb'', sAV ''A'',
+                           sMV ''pkA'', sMV ''Text3''
+                        |>
+                        ( PAsymPK ( sMV ''T'' ) ),
+                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_4'', sN ''Rb'', sMV ''Ra'',
+                           sAV ''B'', sAV ''A'', sMV ''Text6''
+                        |>
+                        ( sMV ''pkA'' )
+               |>
+  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
+  , Send ''5'' <| sAV ''A'', sAV ''B'', sMV ''Ra'', sN ''Rb'',
+                  sMV ''Text9'',
+                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_5'', sMV ''Ra'', sN ''Rb'',
+                           sAV ''A'', sAV ''B'', sMV ''Text8''
+                        |>
+                        ( sPK ''B'' )
+               |>
+  ]"
+
+role isoiec_9798_3_7_1_T
+where "isoiec_9798_3_7_1_T =
+  [ Recv ''2'' <| sMV ''A'', sAV ''T'', sMV ''Rpa'', sMV ''Rb'', sMV ''A'',
+                  sMV ''B'', sMV ''Text2''
+               |>
+  , Recv ''text_3'' <| sMV ''Text3'', sMV ''Text4'', sMV ''Text5'' |>
+  , Send ''3'' <| sAV ''T'', sMV ''A'', sMV ''Text5'', sMV ''A'',
+                  PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
+                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_3_1'', sMV ''Rpa'', sMV ''B'',
+                           PAsymPK ( sMV ''B'' ), sMV ''Text4''
+                        |>
+                        ( sPK ''T'' ),
+                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_3_2'', sMV ''Rb'', sMV ''A'',
+                           PAsymPK ( sMV ''A'' ), sMV ''Text3''
+                        |>
+                        ( sPK ''T'' )
+               |>
+  ]"
+
+role isoiec_9798_3_7_2_A
+where "isoiec_9798_3_7_2_A =
+  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
+  , Recv ''text_2'' ( sMV ''Text2'' )
+  , Send ''2'' <| sAV ''A'', sAV ''T'', sN ''Rpa'', sMV ''Rb'', sAV ''A'',
+                  sMV ''B'', sMV ''Text2''
+               |>
+  , Recv ''3'' <| sAV ''T'', sAV ''A'', sMV ''Text5'', sAV ''A'',
+                  sPK ''A'', sMV ''B'', sMV ''pkB'', sMV ''TokenTA''
+               |>
+  , Send ''check_3_out'' ( PEnc <| sC ''check_4'', sMV ''TokenTA'' |>
+                                ( sN ''check_nonce_4'' )
+                         )
+  , Recv ''check_3_in'' ( PEnc <| sC ''check_4'',
+                                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_3'', sN ''Rpa'', sMV ''Rb'',
+                                           sAV ''A'', sMV ''pkA'', sMV ''B'', sMV ''pkB'', sMV ''Text3''
+                                        |>
+                                        ( sPK ''T'' )
+                               |>
+                               ( sN ''check_nonce_4'' )
+                        )
+  , Recv ''text_4'' <| sMV ''Text6'', sMV ''Text7'' |>
+  , Send ''4'' <| sAV ''A'', sMV ''B'', sN ''Rpa'', sMV ''Text7'',
+                  sAV ''T'', sMV ''TokenTA'',
+                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_4'', sMV ''Rb'', sN ''Ra'',
+                           sMV ''B'', sAV ''A'', sMV ''Text6''
+                        |>
+                        ( sPK ''A'' )
+               |>
+  , Recv ''5'' <| sAV ''A'', sMV ''B'', sN ''Ra'', sMV ''Rb'',
+                  sMV ''Text9'',
+                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_5'', sN ''Ra'', sMV ''Rb'',
+                           sAV ''A'', sMV ''B'', sMV ''Text8''
+                        |>
+                        ( sMV ''pkB'' )
+               |>
+  ]"
+
+role isoiec_9798_3_7_2_B
+where "isoiec_9798_3_7_2_B =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
+  , Recv ''4'' <| sAV ''A'', sAV ''B'', sMV ''Rpa'', sMV ''Text9'',
+                  sMV ''T'',
+                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_3'', sMV ''Rpa'', sN ''Rb'',
+                           sAV ''A'', sMV ''pkA'', sAV ''B'', sMV ''pkB'', sMV ''Text3''
+                        |>
+                        ( PAsymPK ( sMV ''T'' ) ),
+                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_4'', sN ''Rb'', sMV ''Ra'',
+                           sAV ''B'', sAV ''A'', sMV ''Text6''
+                        |>
+                        ( sMV ''pkA'' )
+               |>
+  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
+  , Send ''5'' <| sAV ''A'', sAV ''B'', sMV ''Ra'', sN ''Rb'',
+                  sMV ''Text9'',
+                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_5'', sMV ''Ra'', sN ''Rb'',
+                           sAV ''A'', sAV ''B'', sMV ''Text8''
+                        |>
+                        ( sPK ''B'' )
+               |>
+  ]"
+
+role isoiec_9798_3_7_2_T
+where "isoiec_9798_3_7_2_T =
+  [ Recv ''2'' <| sMV ''A'', sAV ''T'', sMV ''Rpa'', sMV ''Rb'', sMV ''A'',
+                  sMV ''B'', sMV ''Text2''
+               |>
+  , Recv ''text_3'' <| sMV ''Text3'', sMV ''Text5'' |>
+  , Send ''3'' <| sAV ''T'', sMV ''A'', sMV ''Text5'', sMV ''A'',
+                  PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
+                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_3'', sMV ''Rpa'', sMV ''Rb'',
+                           sMV ''A'', PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
+                           sMV ''Text3''
+                        |>
+                        ( sPK ''T'' )
+               |>
+  ]"
+
+protocol isoiec_9798_3
+where "isoiec_9798_3 =
+{ isoiec_9798_3_1_A, isoiec_9798_3_1_B, isoiec_9798_3_2_A,
+  isoiec_9798_3_2_B, isoiec_9798_3_3_A, isoiec_9798_3_3_B,
+  isoiec_9798_3_4_A, isoiec_9798_3_4_B, isoiec_9798_3_5_A,
+  isoiec_9798_3_5_B, isoiec_9798_3_6_1_A, isoiec_9798_3_6_1_B,
+  isoiec_9798_3_6_1_T, isoiec_9798_3_6_2_A, isoiec_9798_3_6_2_B,
+  isoiec_9798_3_6_2_T, isoiec_9798_3_7_1_A, isoiec_9798_3_7_1_B,
+  isoiec_9798_3_7_1_T, isoiec_9798_3_7_2_A, isoiec_9798_3_7_2_B,
+  isoiec_9798_3_7_2_T
+}"
+
+locale restricted_isoiec_9798_3_state = isoiec_9798_3_state
+
+type_invariant isoiec_9798_3_composed_typing for isoiec_9798_3
+where "isoiec_9798_3_composed_typing = mk_typing
+  [ ((isoiec_9798_3_1_B, ''A''), (KnownT isoiec_9798_3_1_B_1))
+  , ((isoiec_9798_3_3_B, ''A''), (KnownT isoiec_9798_3_3_B_1))
+  , ((isoiec_9798_3_5_B, ''A''), (KnownT isoiec_9798_3_5_B_1))
+  , ((isoiec_9798_3_6_1_B, ''A''), (KnownT isoiec_9798_3_6_1_B_1))
+  , ((isoiec_9798_3_6_1_T, ''A''), (KnownT isoiec_9798_3_6_1_T_3))
+  , ((isoiec_9798_3_6_2_B, ''A''), (KnownT isoiec_9798_3_6_2_B_1))
+  , ((isoiec_9798_3_6_2_T, ''A''), (KnownT isoiec_9798_3_6_2_T_3))
+  , ((isoiec_9798_3_7_1_T, ''A''), (KnownT isoiec_9798_3_7_1_T_2))
+  , ((isoiec_9798_3_7_2_T, ''A''), (KnownT isoiec_9798_3_7_2_T_2))
+  , ((isoiec_9798_3_2_A, ''B''), (KnownT isoiec_9798_3_2_A_1))
+  , ((isoiec_9798_3_4_A, ''B''), (KnownT isoiec_9798_3_4_A_1))
+  , ((isoiec_9798_3_6_1_T, ''B''), (KnownT isoiec_9798_3_6_1_T_3))
+  , ((isoiec_9798_3_6_2_T, ''B''), (KnownT isoiec_9798_3_6_2_T_3))
+  , ((isoiec_9798_3_7_1_A, ''B''), (KnownT isoiec_9798_3_7_1_A_1))
+  , ((isoiec_9798_3_7_1_T, ''B''), (KnownT isoiec_9798_3_7_1_T_2))
+  , ((isoiec_9798_3_7_2_A, ''B''), (KnownT isoiec_9798_3_7_2_A_1))
+  , ((isoiec_9798_3_7_2_T, ''B''), (KnownT isoiec_9798_3_7_2_T_2))
+  , ((isoiec_9798_3_4_B, ''RA''), (KnownT isoiec_9798_3_4_B_2))
+  , ((isoiec_9798_3_5_B, ''RA''), (KnownT isoiec_9798_3_5_B_1))
+  , ((isoiec_9798_3_4_A, ''RB''), (KnownT isoiec_9798_3_4_A_1))
+  , ((isoiec_9798_3_5_A, ''RB''), (KnownT isoiec_9798_3_5_A_2))
+  , ((isoiec_9798_3_2_B, ''Ra''), (KnownT isoiec_9798_3_2_B_2))
+  , ((isoiec_9798_3_6_1_B, ''Ra''), (KnownT isoiec_9798_3_6_1_B_1))
+  , ((isoiec_9798_3_6_2_B, ''Ra''), (KnownT isoiec_9798_3_6_2_B_1))
+  , ((isoiec_9798_3_7_1_B, ''Ra''), (KnownT isoiec_9798_3_7_1_B_4))
+  , ((isoiec_9798_3_7_2_B, ''Ra''), (KnownT isoiec_9798_3_7_2_B_4))
+  , ((isoiec_9798_3_2_A, ''Rb''), (KnownT isoiec_9798_3_2_A_1))
+  , ((isoiec_9798_3_6_1_A, ''Rb''), (KnownT isoiec_9798_3_6_1_A_2))
+  , ((isoiec_9798_3_6_1_T, ''Rb''), (KnownT isoiec_9798_3_6_1_T_3))
+  , ((isoiec_9798_3_6_2_A, ''Rb''), (KnownT isoiec_9798_3_6_2_A_2))
+  , ((isoiec_9798_3_6_2_T, ''Rb''), (KnownT isoiec_9798_3_6_2_T_3))
+  , ((isoiec_9798_3_7_1_A, ''Rb''), (KnownT isoiec_9798_3_7_1_A_1))
+  , ((isoiec_9798_3_7_1_T, ''Rb''), (KnownT isoiec_9798_3_7_1_T_2))
+  , ((isoiec_9798_3_7_2_A, ''Rb''), (KnownT isoiec_9798_3_7_2_A_1))
+  , ((isoiec_9798_3_7_2_T, ''Rb''), (KnownT isoiec_9798_3_7_2_T_2))
+  , ((isoiec_9798_3_6_1_T, ''Rpa''), (KnownT isoiec_9798_3_6_1_T_3))
+  , ((isoiec_9798_3_6_2_B, ''Rpa''), (KnownT isoiec_9798_3_6_2_B_5))
+  , ((isoiec_9798_3_6_2_T, ''Rpa''), (KnownT isoiec_9798_3_6_2_T_3))
+  , ((isoiec_9798_3_7_1_B, ''Rpa''), (KnownT isoiec_9798_3_7_1_B_4))
+  , ((isoiec_9798_3_7_1_T, ''Rpa''), (KnownT isoiec_9798_3_7_1_T_2))
+  , ((isoiec_9798_3_7_2_B, ''Rpa''), (KnownT isoiec_9798_3_7_2_B_4))
+  , ((isoiec_9798_3_7_2_T, ''Rpa''), (KnownT isoiec_9798_3_7_2_T_2))
+  , ((isoiec_9798_3_6_1_B, ''T''), (KnownT isoiec_9798_3_6_1_B_5))
+  , ((isoiec_9798_3_6_2_B, ''T''), (KnownT isoiec_9798_3_6_2_B_5))
+  , ((isoiec_9798_3_7_1_B, ''T''), (KnownT isoiec_9798_3_7_1_B_4))
+  , ((isoiec_9798_3_7_2_B, ''T''), (KnownT isoiec_9798_3_7_2_B_4))
+  , ((isoiec_9798_3_1_B, ''TNA''), (KnownT isoiec_9798_3_1_B_1))
+  , ((isoiec_9798_3_3_B, ''TNA''), (KnownT isoiec_9798_3_3_B_1))
+  , ((isoiec_9798_3_3_A, ''TNB''), (KnownT isoiec_9798_3_3_A_2))
+  , ((isoiec_9798_3_1_A, ''Text1''), (KnownT isoiec_9798_3_1_A_text_1))
+  , ((isoiec_9798_3_1_B, ''Text1''), (KnownT isoiec_9798_3_1_B_1))
+  , ((isoiec_9798_3_2_A, ''Text1''), (KnownT isoiec_9798_3_2_A_1))
+  , ((isoiec_9798_3_2_B, ''Text1''), (KnownT isoiec_9798_3_2_B_text_1))
+  , ((isoiec_9798_3_3_A, ''Text1''), (KnownT isoiec_9798_3_3_A_text_1))
+  , ((isoiec_9798_3_3_B, ''Text1''), (KnownT isoiec_9798_3_3_B_1))
+  , ((isoiec_9798_3_4_A, ''Text1''), (KnownT isoiec_9798_3_4_A_1))
+  , ((isoiec_9798_3_4_B, ''Text1''), (KnownT isoiec_9798_3_4_B_text_1))
+  , ((isoiec_9798_3_5_A, ''Text1''), (KnownT isoiec_9798_3_5_A_text_1))
+  , ((isoiec_9798_3_5_B, ''Text1''), (KnownT isoiec_9798_3_5_B_1))
+  , ((isoiec_9798_3_6_1_A, ''Text1''), (KnownT isoiec_9798_3_6_1_A_text_1))
+  , ((isoiec_9798_3_6_1_B, ''Text1''), (KnownT isoiec_9798_3_6_1_B_1))
+  , ((isoiec_9798_3_6_2_A, ''Text1''), (KnownT isoiec_9798_3_6_2_A_text_1))
+  , ((isoiec_9798_3_6_2_B, ''Text1''), (KnownT isoiec_9798_3_6_2_B_1))
+  , ((isoiec_9798_3_7_1_A, ''Text1''), (KnownT isoiec_9798_3_7_1_A_1))
+  , ((isoiec_9798_3_7_1_B, ''Text1''), (KnownT isoiec_9798_3_7_1_B_text_1))
+  , ((isoiec_9798_3_7_2_A, ''Text1''), (KnownT isoiec_9798_3_7_2_A_1))
+  , ((isoiec_9798_3_7_2_B, ''Text1''), (KnownT isoiec_9798_3_7_2_B_text_1))
+  , ((isoiec_9798_3_1_A, ''Text2''), (KnownT isoiec_9798_3_1_A_text_1))
+  , ((isoiec_9798_3_1_B, ''Text2''), (KnownT isoiec_9798_3_1_B_1))
+  , ((isoiec_9798_3_2_A, ''Text2''), (KnownT isoiec_9798_3_2_A_text_2))
+  , ((isoiec_9798_3_2_B, ''Text2''), (KnownT isoiec_9798_3_2_B_2))
+  , ((isoiec_9798_3_3_A, ''Text2''), (KnownT isoiec_9798_3_3_A_text_1))
+  , ((isoiec_9798_3_3_B, ''Text2''), (KnownT isoiec_9798_3_3_B_1))
+  , ((isoiec_9798_3_4_A, ''Text2''), (KnownT isoiec_9798_3_4_A_text_2))
+  , ((isoiec_9798_3_4_B, ''Text2''), (KnownT isoiec_9798_3_4_B_2))
+  , ((isoiec_9798_3_5_A, ''Text2''), (KnownT isoiec_9798_3_5_A_2))
+  , ((isoiec_9798_3_5_B, ''Text2''), (KnownT isoiec_9798_3_5_B_text_2))
+  , ((isoiec_9798_3_6_1_A, ''Text2''),
+     (KnownT isoiec_9798_3_6_1_A_check_4_in))
+  , ((isoiec_9798_3_6_1_B, ''Text2''), (KnownT isoiec_9798_3_6_1_B_text_2))
+  , ((isoiec_9798_3_6_2_A, ''Text2''),
+     (KnownT isoiec_9798_3_6_2_A_check_4_in))
+  , ((isoiec_9798_3_6_2_B, ''Text2''), (KnownT isoiec_9798_3_6_2_B_text_2))
+  , ((isoiec_9798_3_7_1_A, ''Text2''), (KnownT isoiec_9798_3_7_1_A_text_2))
+  , ((isoiec_9798_3_7_1_T, ''Text2''), (KnownT isoiec_9798_3_7_1_T_2))
+  , ((isoiec_9798_3_7_2_A, ''Text2''), (KnownT isoiec_9798_3_7_2_A_text_2))
+  , ((isoiec_9798_3_7_2_T, ''Text2''), (KnownT isoiec_9798_3_7_2_T_2))
+  , ((isoiec_9798_3_2_A, ''Text3''), (KnownT isoiec_9798_3_2_A_text_2))
+  , ((isoiec_9798_3_2_B, ''Text3''), (KnownT isoiec_9798_3_2_B_2))
+  , ((isoiec_9798_3_3_A, ''Text3''), (KnownT isoiec_9798_3_3_A_2))
+  , ((isoiec_9798_3_3_B, ''Text3''), (KnownT isoiec_9798_3_3_B_text_2))
+  , ((isoiec_9798_3_4_A, ''Text3''), (KnownT isoiec_9798_3_4_A_text_2))
+  , ((isoiec_9798_3_4_B, ''Text3''), (KnownT isoiec_9798_3_4_B_2))
+  , ((isoiec_9798_3_5_A, ''Text3''), (KnownT isoiec_9798_3_5_A_text_4))
+  , ((isoiec_9798_3_5_B, ''Text3''), (KnownT isoiec_9798_3_5_B_4))
+  , ((isoiec_9798_3_6_1_A, ''Text3''), (KnownT isoiec_9798_3_6_1_A_2))
+  , ((isoiec_9798_3_6_1_B, ''Text3''), (KnownT isoiec_9798_3_6_1_B_text_2))
+  , ((isoiec_9798_3_6_2_A, ''Text3''), (KnownT isoiec_9798_3_6_2_A_2))
+  , ((isoiec_9798_3_6_2_B, ''Text3''), (KnownT isoiec_9798_3_6_2_B_text_2))
+  , ((isoiec_9798_3_7_1_B, ''Text3''), (KnownT isoiec_9798_3_7_1_B_4))
+  , ((isoiec_9798_3_7_1_T, ''Text3''), (KnownT isoiec_9798_3_7_1_T_text_3))
+  , ((isoiec_9798_3_7_2_A, ''Text3''),
+     (KnownT isoiec_9798_3_7_2_A_check_3_in))
+  , ((isoiec_9798_3_7_2_B, ''Text3''), (KnownT isoiec_9798_3_7_2_B_4))
+  , ((isoiec_9798_3_7_2_T, ''Text3''), (KnownT isoiec_9798_3_7_2_T_text_3))
+  , ((isoiec_9798_3_3_A, ''Text4''), (KnownT isoiec_9798_3_3_A_2))
+  , ((isoiec_9798_3_3_B, ''Text4''), (KnownT isoiec_9798_3_3_B_text_2))
+  , ((isoiec_9798_3_4_A, ''Text4''), (KnownT isoiec_9798_3_4_A_3))
+  , ((isoiec_9798_3_4_B, ''Text4''), (KnownT isoiec_9798_3_4_B_text_3))
+  , ((isoiec_9798_3_5_A, ''Text4''), (KnownT isoiec_9798_3_5_A_text_4))
+  , ((isoiec_9798_3_5_B, ''Text4''), (KnownT isoiec_9798_3_5_B_4))
+  , ((isoiec_9798_3_6_1_A, ''Text4''), (KnownT isoiec_9798_3_6_1_A_text_3))
+  , ((isoiec_9798_3_6_1_T, ''Text4''), (KnownT isoiec_9798_3_6_1_T_3))
+  , ((isoiec_9798_3_6_2_A, ''Text4''), (KnownT isoiec_9798_3_6_2_A_text_3))
+  , ((isoiec_9798_3_6_2_T, ''Text4''), (KnownT isoiec_9798_3_6_2_T_3))
+  , ((isoiec_9798_3_7_1_A, ''Text4''), (KnownT isoiec_9798_3_7_1_A_3))
+  , ((isoiec_9798_3_7_1_T, ''Text4''), (KnownT isoiec_9798_3_7_1_T_text_3))
+  , ((isoiec_9798_3_4_A, ''Text5''), (KnownT isoiec_9798_3_4_A_3))
+  , ((isoiec_9798_3_4_B, ''Text5''), (KnownT isoiec_9798_3_4_B_text_3))
+  , ((isoiec_9798_3_5_A, ''Text5''), (KnownT isoiec_9798_3_5_A_3))
+  , ((isoiec_9798_3_5_B, ''Text5''), (KnownT isoiec_9798_3_5_B_text_3))
+  , ((isoiec_9798_3_6_1_B, ''Text5''), (KnownT isoiec_9798_3_6_1_B_5))
+  , ((isoiec_9798_3_6_1_T, ''Text5''), (KnownT isoiec_9798_3_6_1_T_text_4))
+  , ((isoiec_9798_3_6_2_A, ''Text5''),
+     (KnownT isoiec_9798_3_6_2_A_check_4_in))
+  , ((isoiec_9798_3_6_2_B, ''Text5''), (KnownT isoiec_9798_3_6_2_B_5))
+  , ((isoiec_9798_3_6_2_T, ''Text5''), (KnownT isoiec_9798_3_6_2_T_text_4))
+  , ((isoiec_9798_3_7_1_A, ''Text5''), (KnownT isoiec_9798_3_7_1_A_3))
+  , ((isoiec_9798_3_7_1_T, ''Text5''), (KnownT isoiec_9798_3_7_1_T_text_3))
+  , ((isoiec_9798_3_7_2_A, ''Text5''), (KnownT isoiec_9798_3_7_2_A_3))
+  , ((isoiec_9798_3_7_2_T, ''Text5''), (KnownT isoiec_9798_3_7_2_T_text_3))
+  , ((isoiec_9798_3_5_A, ''Text6''), (KnownT isoiec_9798_3_5_A_3))
+  , ((isoiec_9798_3_5_B, ''Text6''), (KnownT isoiec_9798_3_5_B_text_3))
+  , ((isoiec_9798_3_6_1_A, ''Text6''), (KnownT isoiec_9798_3_6_1_A_4))
+  , ((isoiec_9798_3_6_1_T, ''Text6''), (KnownT isoiec_9798_3_6_1_T_text_4))
+  , ((isoiec_9798_3_7_1_A, ''Text6''), (KnownT isoiec_9798_3_7_1_A_text_4))
+  , ((isoiec_9798_3_7_1_B, ''Text6''), (KnownT isoiec_9798_3_7_1_B_4))
+  , ((isoiec_9798_3_7_2_A, ''Text6''), (KnownT isoiec_9798_3_7_2_A_text_4))
+  , ((isoiec_9798_3_7_2_B, ''Text6''), (KnownT isoiec_9798_3_7_2_B_4))
+  , ((isoiec_9798_3_6_1_A, ''Text7''), (KnownT isoiec_9798_3_6_1_A_4))
+  , ((isoiec_9798_3_6_1_T, ''Text7''), (KnownT isoiec_9798_3_6_1_T_text_4))
+  , ((isoiec_9798_3_6_2_A, ''Text7''), (KnownT isoiec_9798_3_6_2_A_4))
+  , ((isoiec_9798_3_6_2_T, ''Text7''), (KnownT isoiec_9798_3_6_2_T_text_4))
+  , ((isoiec_9798_3_7_1_A, ''Text7''), (KnownT isoiec_9798_3_7_1_A_text_4))
+  , ((isoiec_9798_3_7_2_A, ''Text7''), (KnownT isoiec_9798_3_7_2_A_text_4))
+  , ((isoiec_9798_3_6_1_A, ''Text8''), (KnownT isoiec_9798_3_6_1_A_text_5))
+  , ((isoiec_9798_3_6_1_B, ''Text8''), (KnownT isoiec_9798_3_6_1_B_5))
+  , ((isoiec_9798_3_6_2_A, ''Text8''), (KnownT isoiec_9798_3_6_2_A_text_5))
+  , ((isoiec_9798_3_6_2_B, ''Text8''), (KnownT isoiec_9798_3_6_2_B_5))
+  , ((isoiec_9798_3_7_1_A, ''Text8''), (KnownT isoiec_9798_3_7_1_A_5))
+  , ((isoiec_9798_3_7_1_B, ''Text8''), (KnownT isoiec_9798_3_7_1_B_text_5))
+  , ((isoiec_9798_3_7_2_A, ''Text8''), (KnownT isoiec_9798_3_7_2_A_5))
+  , ((isoiec_9798_3_7_2_B, ''Text8''), (KnownT isoiec_9798_3_7_2_B_text_5))
+  , ((isoiec_9798_3_6_1_A, ''Text9''), (KnownT isoiec_9798_3_6_1_A_text_5))
+  , ((isoiec_9798_3_6_1_B, ''Text9''), (KnownT isoiec_9798_3_6_1_B_5))
+  , ((isoiec_9798_3_6_2_A, ''Text9''), (KnownT isoiec_9798_3_6_2_A_text_5))
+  , ((isoiec_9798_3_6_2_B, ''Text9''), (KnownT isoiec_9798_3_6_2_B_5))
+  , ((isoiec_9798_3_7_1_A, ''Text9''), (KnownT isoiec_9798_3_7_1_A_5))
+  , ((isoiec_9798_3_7_1_B, ''Text9''), (KnownT isoiec_9798_3_7_1_B_4))
+  , ((isoiec_9798_3_7_2_A, ''Text9''), (KnownT isoiec_9798_3_7_2_A_5))
+  , ((isoiec_9798_3_7_2_B, ''Text9''), (KnownT isoiec_9798_3_7_2_B_4))
+  , ((isoiec_9798_3_6_1_A, ''TokenBA''), (KnownT isoiec_9798_3_6_1_A_2))
+  , ((isoiec_9798_3_6_2_A, ''TokenBA''), (KnownT isoiec_9798_3_6_2_A_2))
+  , ((isoiec_9798_3_6_2_A, ''TokenTA''), (KnownT isoiec_9798_3_6_2_A_4))
+  , ((isoiec_9798_3_7_2_A, ''TokenTA''), (KnownT isoiec_9798_3_7_2_A_3))
+  , ((isoiec_9798_3_6_1_A, ''TokenTA_for_B''),
+     (KnownT isoiec_9798_3_6_1_A_4))
+  , ((isoiec_9798_3_7_1_A, ''TokenTA_for_B''),
+     (KnownT isoiec_9798_3_7_1_A_3))
+  , ((isoiec_9798_3_6_1_B, ''pkA''), (KnownT isoiec_9798_3_6_1_B_5))
+  , ((isoiec_9798_3_6_2_A, ''pkA''),
+     (KnownT isoiec_9798_3_6_2_A_check_4_in))
+  , ((isoiec_9798_3_6_2_B, ''pkA''), (KnownT isoiec_9798_3_6_2_B_5))
+  , ((isoiec_9798_3_7_1_B, ''pkA''), (KnownT isoiec_9798_3_7_1_B_4))
+  , ((isoiec_9798_3_7_2_A, ''pkA''),
+     (KnownT isoiec_9798_3_7_2_A_check_3_in))
+  , ((isoiec_9798_3_7_2_B, ''pkA''), (KnownT isoiec_9798_3_7_2_B_4))
+  , ((isoiec_9798_3_6_1_A, ''pkB''), (KnownT isoiec_9798_3_6_1_A_4))
+  , ((isoiec_9798_3_6_2_A, ''pkB''), (KnownT isoiec_9798_3_6_2_A_4))
+  , ((isoiec_9798_3_6_2_B, ''pkB''), (KnownT isoiec_9798_3_6_2_B_5))
+  , ((isoiec_9798_3_7_1_A, ''pkB''), (KnownT isoiec_9798_3_7_1_A_3))
+  , ((isoiec_9798_3_7_2_A, ''pkB''), (KnownT isoiec_9798_3_7_2_A_3))
+  , ((isoiec_9798_3_7_2_B, ''pkB''), (KnownT isoiec_9798_3_7_2_B_4))
+  ]"
+
+sublocale isoiec_9798_3_state < isoiec_9798_3_composed_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_3_composed_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_3_composed_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_3_1_A_text_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_1_A_text_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_1_B_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_1_B_1_TNA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_1_B_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_1_B_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_2_A_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_2_A_1_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_2_A_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_2_A_text_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_2_A_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_2_B_2_Ra t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_2_B_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_2_B_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_3_A_text_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_3_A_text_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_3_A_2_TNB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_3_A_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_3_A_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_3_B_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_3_B_1_TNA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_3_B_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_3_B_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_3_B_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_3_B_text_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_A_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_A_1_RB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_A_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_A_text_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_A_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_A_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_A_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_B_2_RA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_B_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_B_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_B_text_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_B_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_A_2_RB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_A_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_A_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_A_3_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_A_text_4_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_A_text_4_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_B_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_B_1_RA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_B_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_B_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_B_text_3_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_B_4_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_B_4_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_A_2_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_A_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_A_2_TokenBA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_A_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_A_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_A_4_TokenTA_for_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_A_4_pkB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_A_check_4_in_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''check_4'',
+               {| LC ''isoiec_9798_3_6_opt_1_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
+                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+               |},
+               Enc {| LC ''isoiec_9798_3_6_opt_1_sig_2'', s(AV ''B'' tid0),
+                      LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                   |}
+                   ( inv(s(MV ''pkB'' tid0)) )
+            |}
+            ( LN ''check_nonce_4'' tid0 ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_3_6_1_A_text_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_A_text_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_B_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_B_1_Ra t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_B_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_B_text_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_B_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_B_5_T t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_B_5_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_B_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_B_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_B_5_pkA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_T_3_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_T_3_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_T_3_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_T_3_Rpa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_T_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_T_text_4_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_T_text_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_T_text_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_A_2_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_A_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_A_2_TokenBA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_A_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_A_4_TokenTA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_A_4_pkB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_A_check_4_in_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''check_4'',
+               {| {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                     s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                     s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                  |},
+                  Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                         s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                         s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                      |}
+                      ( SK ( s(AV ''T'' tid0) ) )
+               |},
+               {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
+                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+               |},
+               Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
+                      LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                   |}
+                   ( inv(s(MV ''pkB'' tid0)) )
+            |}
+            ( LN ''check_nonce_4'' tid0 ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_3_6_2_A_check_4_in_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''check_4'',
+               {| {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                     s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                     s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                  |},
+                  Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                         s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                         s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                      |}
+                      ( SK ( s(AV ''T'' tid0) ) )
+               |},
+               {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
+                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+               |},
+               Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
+                      LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                   |}
+                   ( inv(s(MV ''pkB'' tid0)) )
+            |}
+            ( LN ''check_nonce_4'' tid0 ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_3_6_2_A_check_4_in_pkA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''check_4'',
+               {| {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                     s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                     s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                  |},
+                  Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                         s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                         s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                      |}
+                      ( SK ( s(AV ''T'' tid0) ) )
+               |},
+               {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
+                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+               |},
+               Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
+                      LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                   |}
+                   ( inv(s(MV ''pkB'' tid0)) )
+            |}
+            ( LN ''check_nonce_4'' tid0 ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_3_6_2_A_text_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_A_text_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_1_Ra t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_text_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_5_Rpa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_5_T t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_5_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_5_pkA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_5_pkB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_T_3_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_T_3_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_T_3_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_T_3_Rpa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_T_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_T_text_4_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_T_text_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_A_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_A_1_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_A_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_A_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_A_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_A_3_TokenTA_for_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_A_3_pkB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_A_text_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_A_text_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_A_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_A_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_B_4_Ra t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_B_4_Rpa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_B_4_T t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_B_4_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_B_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_B_4_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_B_4_pkA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_B_text_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_T_2_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_T_2_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_T_2_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_T_2_Rpa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_T_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_T_text_3_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_T_text_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_T_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_A_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_A_1_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_A_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_A_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_A_3_TokenTA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_A_3_pkB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_A_check_3_in_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''check_4'',
+               {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
+                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                  s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+               |},
+               Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
+                      s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                      s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+                   |}
+                   ( SK ( s(AV ''T'' tid0) ) )
+            |}
+            ( LN ''check_nonce_4'' tid0 ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_3_7_2_A_check_3_in_pkA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''check_4'',
+               {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
+                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                  s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+               |},
+               Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
+                      s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                      s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+                   |}
+                   ( SK ( s(AV ''T'' tid0) ) )
+            |}
+            ( LN ''check_nonce_4'' tid0 ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_3_7_2_A_text_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_A_text_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_A_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_A_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_B_4_Ra t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_B_4_Rpa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_B_4_T t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_B_4_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_B_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_B_4_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_B_4_pkA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_B_4_pkB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_B_text_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_T_2_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_T_2_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_T_2_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_T_2_Rpa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_T_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_T_text_3_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_T_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_composed_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_3_composed_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_3_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_1_B_non_injective_agreement:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_3_1_B"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_3_1_B_1 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_3_1_A &
+        ( tid1, isoiec_9798_3_1_A_1 ) : steps t &
+        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
+           s(MV ''Text1'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
+                s(MV ''Text1'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_3_1_sig_1'', s(MV ''TNA'' tid0),
+                          s(AV ''B'' tid0), s(MV ''Text1'' tid0)
+                       |}
+                       ( SK ( s(MV ''A'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_3_1_A_1_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_2_B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_2_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_2_B_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_2_A &
+          ( tid1, isoiec_9798_3_2_A_2 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
+                  LN ''Rb'' tid0, s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_2_sig_2'', s(MV ''Ra'' tid0), LN ''Rb'' tid0,
+                              s(AV ''B'' tid0), s(MV ''Text2'' tid0)
+                           |}
+                           ( SK ( s(AV ''A'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_2_A_2_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_3_A_non_injective_agreement:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_3_3_A"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_3_3_A_2 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_3_3_B &
+        ( tid1, isoiec_9798_3_3_B_2 ) : steps t &
+        {| s(MV ''A'' tid1), s(AV ''B'' tid1), LN ''TNB'' tid1,
+           s(MV ''Text3'' tid1)
+        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNB'' tid0),
+                s(MV ''Text3'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_3_3_sig_2'', s(MV ''TNB'' tid0),
+                          s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+                       |}
+                       ( SK ( s(AV ''B'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_3_3_B_2_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_3_B_non_injective_agreement:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_3_3_B"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_3_3_B_1 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_3_3_A &
+        ( tid1, isoiec_9798_3_3_A_1 ) : steps t &
+        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
+           s(MV ''Text1'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
+                s(MV ''Text1'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_3_3_sig_1'', s(MV ''TNA'' tid0),
+                          s(AV ''B'' tid0), s(MV ''Text1'' tid0)
+                       |}
+                       ( SK ( s(MV ''A'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_3_3_A_1_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_4_A_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_4_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_4_A_3 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_4_B &
+          ( tid1, isoiec_9798_3_4_B_3 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''RA'' tid1), LN ''RB'' tid1,
+             s(MV ''Text2'' tid1), s(MV ''Text4'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''RA'' tid0,
+                  s(MV ''RB'' tid0), s(MV ''Text2'' tid0), s(MV ''Text4'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_4_sig_2'', s(MV ''RB'' tid0), LN ''RA'' tid0,
+                              s(AV ''A'' tid0), s(MV ''Text4'' tid0)
+                           |}
+                           ( SK ( s(MV ''B'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_4_B_3_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_4_sig_1'', LN ''RA'' tid0, LN ''RB'' tid1,
+                                s(AV ''B'' tid1), s(MV ''Text2'' tid1)
+                             |}
+                             ( SK ( s(AV ''A'' tid0) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_3_4_A_2_enc tid2) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_4_B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_4_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_4_B_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_4_A &
+          ( tid1, isoiec_9798_3_4_A_2 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''RA'' tid1, s(MV ''RB'' tid1),
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''RA'' tid0),
+                  LN ''RB'' tid0, s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_4_sig_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
+                              s(AV ''B'' tid0), s(MV ''Text2'' tid0)
+                           |}
+                           ( SK ( s(AV ''A'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_4_A_2_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_5_A_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_5_A &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_5_A_3 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_5_B &
+          ( tid1, isoiec_9798_3_5_B_3 ) : steps t &
+          {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''RA'' tid1), LN ''RB'' tid1,
+             s(MV ''Text5'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''RA'' tid0,
+                  s(MV ''RB'' tid0), s(MV ''Text5'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_5_sig_1'', s(MV ''RB'' tid0), LN ''RA'' tid0,
+                              s(AV ''A'' tid0), s(MV ''Text5'' tid0)
+                           |}
+                           ( SK ( s(AV ''B'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_5_B_3_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_5_B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_5_B &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(MV ''A'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_5_B_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_5_A &
+          ( tid1, isoiec_9798_3_5_A_4 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''RA'' tid1, s(MV ''RB'' tid1),
+             s(MV ''Text3'' tid1), s(MV ''Text5'' tid1)
+          |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''RA'' tid0),
+                  LN ''RB'' tid0, s(MV ''Text3'' tid0), s(MV ''Text5'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_5_sig_2'', s(MV ''RA'' tid0), LN ''RB'' tid0,
+                              s(AV ''B'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( SK ( s(MV ''A'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_5_A_4_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_5_sig_1'', LN ''RB'' tid0, LN ''RA'' tid1,
+                                s(AV ''A'' tid1), s(MV ''Text5'' tid1)
+                             |}
+                             ( SK ( s(AV ''B'' tid0) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_3_5_B_3_enc tid2) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_6_1_A_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_6_1_A &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(AV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_6_1_A_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_6_1_B &
+          ( tid1, isoiec_9798_3_6_1_B_2 ) : steps t &
+          {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''Ra'' tid0,
+                  s(MV ''Rb'' tid0), s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''check_4'',
+                              {| LC ''isoiec_9798_3_6_opt_1_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
+                                 s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                              |},
+                              Enc {| LC ''isoiec_9798_3_6_opt_1_sig_2'', s(AV ''B'' tid0),
+                                     LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                                  |}
+                                  ( inv(s(MV ''pkB'' tid0)) )
+                           |}
+                           ( LN ''check_nonce_4'' tid0 ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis proof(sources! " LN ''check_nonce_4'' tid0 ")
+        qed (insert facts, fastforce+)?
+      next
+        case (isoiec_9798_3_6_1_A_check_4_out_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_6_opt_1_sig_2'', s(AV ''B'' tid0),
+                                LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                             |}
+                             ( inv(s(MV ''pkB'' tid0)) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_3_6_opt_1_sig_4_1'', LN ''Rpa'' tid0,
+                                  s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text6'' tid0)
+                               |}
+                               ( SK ( s(AV ''T'' tid0) ) ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest!: ltk_secrecy)
+          next
+            case (isoiec_9798_3_6_1_T_4_enc tid1) note_unified facts = this facts
+            thus ?thesis by (fastforce dest!: ltk_secrecy)
+          qed (insert facts, fastforce+)?
+        next
+          case (isoiec_9798_3_6_1_B_2_enc tid1) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_6_1_B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_6_1_B &
+          RLKR(s(MV ''A'' tid0)) ~: reveals t &
+          RLKR(s(MV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_6_1_B_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_6_1_A &
+          ( tid1, isoiec_9798_3_6_1_A_5 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
+             s(MV ''Text8'' tid1)
+          |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
+                  LN ''Rb'' tid0, s(MV ''Text8'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_6_opt_1_sig_4_2'', LN ''Rb'' tid0,
+                              s(MV ''A'' tid0), s(MV ''pkA'' tid0), s(MV ''Text5'' tid0)
+                           |}
+                           ( SK ( s(MV ''T'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_6_1_T_4_enc_1 tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_6_opt_1_sig_5'', LN ''Rb'' tid0,
+                                s(MV ''Ra'' tid0), s(AV ''B'' tid0), s(MV ''A'' tid0),
+                                s(MV ''Text8'' tid0)
+                             |}
+                             ( SK ( s(MV ''A'' tid0) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_3_6_1_A_5_enc tid2) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_6_1_A_injective_agreement_T:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_6_1_A &
+          RLKR(s(AV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_6_1_A_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_6_1_T &
+          ( tid1, isoiec_9798_3_6_1_T_4 ) : steps t &
+          {| s(MV ''B'' tid1), s(AV ''T'' tid1), s(MV ''Rpa'' tid1),
+             PK ( s(MV ''B'' tid1) ), s(MV ''Text6'' tid1)
+          |} = {| s(AV ''B'' tid0), s(AV ''T'' tid0), LN ''Rpa'' tid0,
+                  s(MV ''pkB'' tid0), s(MV ''Text6'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_6_opt_1_sig_4_1'', LN ''Rpa'' tid0,
+                              s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text6'' tid0)
+                           |}
+                           ( SK ( s(AV ''T'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_6_1_T_4_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_6_1_B_injective_agreement_T:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_6_1_B &
+          RLKR(s(MV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_6_1_B_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_6_1_T &
+          ( tid1, isoiec_9798_3_6_1_T_4 ) : steps t &
+          {| s(MV ''A'' tid1), s(AV ''T'' tid1), s(MV ''Rb'' tid1),
+             PK ( s(MV ''A'' tid1) ), s(MV ''Text5'' tid1)
+          |} = {| s(MV ''A'' tid0), s(MV ''T'' tid0), LN ''Rb'' tid0,
+                  s(MV ''pkA'' tid0), s(MV ''Text5'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_6_opt_1_sig_4_2'', LN ''Rb'' tid0,
+                              s(MV ''A'' tid0), s(MV ''pkA'' tid0), s(MV ''Text5'' tid0)
+                           |}
+                           ( SK ( s(MV ''T'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_6_1_T_4_enc_1 tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_6_2_A_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_6_2_A &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(AV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_6_2_A_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_6_2_B &
+          ( tid1, isoiec_9798_3_6_2_B_2 ) : steps t &
+          {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''Ra'' tid0,
+                  s(MV ''Rb'' tid0), s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''check_4'',
+                              {| {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                                    s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                    s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                                 |},
+                                 Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                                        s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                        s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                                     |}
+                                     ( SK ( s(AV ''T'' tid0) ) )
+                              |},
+                              {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
+                                 s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                              |},
+                              Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
+                                     LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                                  |}
+                                  ( inv(s(MV ''pkB'' tid0)) )
+                           |}
+                           ( LN ''check_nonce_4'' tid0 ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis proof(sources! " LN ''check_nonce_4'' tid0 ")
+        qed (insert facts, fastforce+)?
+      next
+        case (isoiec_9798_3_6_2_A_check_4_out_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
+                                LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                             |}
+                             ( inv(s(MV ''pkB'' tid0)) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                  s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                               |}
+                               ( SK ( s(AV ''T'' tid0) ) ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest!: ltk_secrecy)
+          next
+            case (isoiec_9798_3_6_2_T_4_enc tid1) note_unified facts = this facts
+            thus ?thesis by (fastforce dest!: ltk_secrecy)
+          qed (insert facts, fastforce+)?
+        next
+          case (isoiec_9798_3_6_2_B_2_enc tid1) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_6_2_B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_6_2_B &
+          RLKR(s(MV ''A'' tid0)) ~: reveals t &
+          RLKR(s(MV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_6_2_B_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_6_2_A &
+          ( tid1, isoiec_9798_3_6_2_A_5 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
+             s(MV ''Text8'' tid1)
+          |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
+                  LN ''Rb'' tid0, s(MV ''Text8'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', s(MV ''Rpa'' tid0),
+                              LN ''Rb'' tid0, s(MV ''A'' tid0), s(MV ''pkA'' tid0), s(AV ''B'' tid0),
+                              s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                           |}
+                           ( SK ( s(MV ''T'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_6_2_T_4_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_6_opt_2_sig_5'', LN ''Rb'' tid0,
+                                s(MV ''Ra'' tid0), s(AV ''B'' tid0), s(MV ''A'' tid0),
+                                s(MV ''Text8'' tid0)
+                             |}
+                             ( SK ( s(MV ''A'' tid0) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_3_6_2_A_5_enc tid2) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_6_2_A_injective_agreement_T:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_6_2_A &
+          RLKR(s(AV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_6_2_A_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_6_2_T &
+          ( tid1, isoiec_9798_3_6_2_T_4 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''T'' tid1),
+             s(MV ''Rpa'' tid1), s(MV ''Rb'' tid1), PK ( s(MV ''A'' tid1) ),
+             PK ( s(MV ''B'' tid1) ), s(MV ''Text5'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''T'' tid0),
+                  LN ''Rpa'' tid0, s(MV ''Rb'' tid0), s(MV ''pkA'' tid0),
+                  s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''check_4'',
+                              {| {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                                    s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                    s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                                 |},
+                                 Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                                        s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                        s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                                     |}
+                                     ( SK ( s(AV ''T'' tid0) ) )
+                              |},
+                              {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
+                                 s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                              |},
+                              Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
+                                     LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                                  |}
+                                  ( inv(s(MV ''pkB'' tid0)) )
+                           |}
+                           ( LN ''check_nonce_4'' tid0 ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis proof(sources! " LN ''check_nonce_4'' tid0 ")
+        qed (insert facts, fastforce+)?
+      next
+        case (isoiec_9798_3_6_2_A_check_4_out_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                                s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                             |}
+                             ( SK ( s(AV ''T'' tid0) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_3_6_2_T_4_enc tid1) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_6_2_B_injective_agreement_T:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_6_2_B &
+          RLKR(s(MV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_6_2_B_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_6_2_T &
+          ( tid1, isoiec_9798_3_6_2_T_4 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''T'' tid1),
+             s(MV ''Rpa'' tid1), s(MV ''Rb'' tid1), PK ( s(MV ''A'' tid1) ),
+             PK ( s(MV ''B'' tid1) ), s(MV ''Text5'' tid1)
+          |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''T'' tid0),
+                  s(MV ''Rpa'' tid0), LN ''Rb'' tid0, s(MV ''pkA'' tid0),
+                  s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', s(MV ''Rpa'' tid0),
+                              LN ''Rb'' tid0, s(MV ''A'' tid0), s(MV ''pkA'' tid0), s(AV ''B'' tid0),
+                              s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                           |}
+                           ( SK ( s(MV ''T'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_6_2_T_4_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_7_1_A_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_7_1_A &
+          RLKR(s(AV ''T'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_7_1_A_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_7_1_B &
+          ( tid1, isoiec_9798_3_7_1_B_5 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
+             s(MV ''Text8'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''Ra'' tid0,
+                  s(MV ''Rb'' tid0), s(MV ''Text8'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_7_opt_1_sig_3_1'', LN ''Rpa'' tid0,
+                              s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text4'' tid0)
+                           |}
+                           ( SK ( s(AV ''T'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_7_1_T_3_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_7_opt_1_sig_5'', LN ''Ra'' tid0,
+                                s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
+                                s(MV ''Text8'' tid0)
+                             |}
+                             ( SK ( s(MV ''B'' tid0) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_3_7_1_B_5_enc tid2) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_7_1_B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_7_1_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(MV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_7_1_B_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_7_1_A &
+          ( tid1, isoiec_9798_3_7_1_A_4 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
+             s(MV ''Text6'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
+                  LN ''Rb'' tid0, s(MV ''Text6'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_7_opt_1_sig_3_2'', LN ''Rb'' tid0,
+                              s(AV ''A'' tid0), s(MV ''pkA'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( SK ( s(MV ''T'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_7_1_T_3_enc_1 tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_7_opt_1_sig_4'', LN ''Rb'' tid0,
+                                s(MV ''Ra'' tid0), s(AV ''B'' tid0), s(AV ''A'' tid0),
+                                s(MV ''Text6'' tid0)
+                             |}
+                             ( SK ( s(AV ''A'' tid0) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_3_7_1_A_4_enc tid2) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_7_1_A_injective_agreement_T:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_7_1_A &
+          RLKR(s(AV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_7_1_A_3 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_7_1_T &
+          ( tid1, isoiec_9798_3_7_1_T_3 ) : steps t &
+          {| s(MV ''B'' tid1), s(AV ''T'' tid1), s(MV ''Rpa'' tid1),
+             PK ( s(MV ''B'' tid1) ), s(MV ''Text4'' tid1)
+          |} = {| s(MV ''B'' tid0), s(AV ''T'' tid0), LN ''Rpa'' tid0,
+                  s(MV ''pkB'' tid0), s(MV ''Text4'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_7_opt_1_sig_3_1'', LN ''Rpa'' tid0,
+                              s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text4'' tid0)
+                           |}
+                           ( SK ( s(AV ''T'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_7_1_T_3_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_7_1_B_injective_agreement_T:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_7_1_B &
+          RLKR(s(MV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_7_1_B_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_7_1_T &
+          ( tid1, isoiec_9798_3_7_1_T_3 ) : steps t &
+          {| s(MV ''A'' tid1), s(AV ''T'' tid1), s(MV ''Rb'' tid1),
+             PK ( s(MV ''A'' tid1) ), s(MV ''Text3'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''T'' tid0), LN ''Rb'' tid0,
+                  s(MV ''pkA'' tid0), s(MV ''Text3'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_7_opt_1_sig_3_2'', LN ''Rb'' tid0,
+                              s(AV ''A'' tid0), s(MV ''pkA'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( SK ( s(MV ''T'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_7_1_T_3_enc_1 tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_7_2_A_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_7_2_A &
+          RLKR(s(AV ''T'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_7_2_A_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_7_2_B &
+          ( tid1, isoiec_9798_3_7_2_B_5 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
+             s(MV ''Text8'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''Ra'' tid0,
+                  s(MV ''Rb'' tid0), s(MV ''Text8'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''check_4'',
+                              {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
+                                 s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                 s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+                              |},
+                              Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
+                                     s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                     s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+                                  |}
+                                  ( SK ( s(AV ''T'' tid0) ) )
+                           |}
+                           ( LN ''check_nonce_4'' tid0 ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis proof(sources! " LN ''check_nonce_4'' tid0 ")
+        qed (insert facts, fastforce+)?
+      next
+        case (isoiec_9798_3_7_2_A_check_3_out_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
+                                s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+                             |}
+                             ( SK ( s(AV ''T'' tid0) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_3_7_2_T_3_enc tid1) note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_3_7_opt_2_sig_5'', LN ''Ra'' tid0,
+                                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
+                                  s(MV ''Text8'' tid0)
+                               |}
+                               ( SK ( s(MV ''B'' tid0) ) ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest!: ltk_secrecy)
+          next
+            case (isoiec_9798_3_7_2_B_5_enc tid2) note_unified facts = this facts
+            thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+          qed (insert facts, fastforce+)?
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_7_2_B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_7_2_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(MV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_7_2_B_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_7_2_A &
+          ( tid1, isoiec_9798_3_7_2_A_4 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
+             s(MV ''Text6'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
+                  LN ''Rb'' tid0, s(MV ''Text6'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', s(MV ''Rpa'' tid0),
+                              LN ''Rb'' tid0, s(AV ''A'' tid0), s(MV ''pkA'' tid0), s(AV ''B'' tid0),
+                              s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( SK ( s(MV ''T'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_7_2_T_3_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_7_opt_2_sig_4'', LN ''Rb'' tid0,
+                                s(MV ''Ra'' tid0), s(AV ''B'' tid0), s(AV ''A'' tid0),
+                                s(MV ''Text6'' tid0)
+                             |}
+                             ( SK ( s(AV ''A'' tid0) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_3_7_2_A_4_enc tid2) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_7_2_A_injective_agreement_T:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_7_2_A &
+          RLKR(s(AV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_7_2_A_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_7_2_T &
+          ( tid1, isoiec_9798_3_7_2_T_3 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''T'' tid1),
+             s(MV ''Rpa'' tid1), s(MV ''Rb'' tid1), PK ( s(MV ''A'' tid1) ),
+             PK ( s(MV ''B'' tid1) ), s(MV ''Text3'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''T'' tid0),
+                  LN ''Rpa'' tid0, s(MV ''Rb'' tid0), s(MV ''pkA'' tid0),
+                  s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''check_4'',
+                              {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
+                                 s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                 s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+                              |},
+                              Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
+                                     s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                     s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+                                  |}
+                                  ( SK ( s(AV ''T'' tid0) ) )
+                           |}
+                           ( LN ''check_nonce_4'' tid0 ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis proof(sources! " LN ''check_nonce_4'' tid0 ")
+        qed (insert facts, fastforce+)?
+      next
+        case (isoiec_9798_3_7_2_A_check_3_out_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
+                                s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+                             |}
+                             ( SK ( s(AV ''T'' tid0) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_3_7_2_T_3_enc tid1) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_state) isoiec_9798_3_7_2_B_injective_agreement_T:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_7_2_B &
+          RLKR(s(MV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_7_2_B_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_7_2_T &
+          ( tid1, isoiec_9798_3_7_2_T_3 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''T'' tid1),
+             s(MV ''Rpa'' tid1), s(MV ''Rb'' tid1), PK ( s(MV ''A'' tid1) ),
+             PK ( s(MV ''B'' tid1) ), s(MV ''Text3'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''T'' tid0),
+                  s(MV ''Rpa'' tid0), LN ''Rb'' tid0, s(MV ''pkA'' tid0),
+                  s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', s(MV ''Rpa'' tid0),
+                              LN ''Rb'' tid0, s(AV ''A'' tid0), s(MV ''pkA'' tid0), s(AV ''B'' tid0),
+                              s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( SK ( s(MV ''T'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_7_2_T_3_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
 qed
 
 end
diff --git a/data/examples/iso9798/isabelle-parallel-proofs/isoiec-9798-4-bdkey_cert_auto.thy b/data/examples/iso9798/isabelle-parallel-proofs/isoiec-9798-4-bdkey_cert_auto.thy
--- a/data/examples/iso9798/isabelle-parallel-proofs/isoiec-9798-4-bdkey_cert_auto.thy
+++ b/data/examples/iso9798/isabelle-parallel-proofs/isoiec-9798-4-bdkey_cert_auto.thy
@@ -1,6 +1,6 @@
 theory "isoiec-9798-4-bdkey_cert_auto"
 imports
-  "../ESPLogic"
+  "ESPLogic"
 begin
 
 role isoiec_9798_4_1_bdkey_A
@@ -214,217 +214,217 @@
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_1_bdkey_A_text_1_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_1_bdkey_B_1_A t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_1_bdkey_B_1_TNA t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_1_bdkey_B_1_Text1 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_1_bdkey_B_1_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_bdkey_A_1_B t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_bdkey_A_1_Rb t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_bdkey_A_1_Text1 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_bdkey_A_text_2_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_bdkey_A_text_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_bdkey_B_2_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_bdkey_B_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_bdkey_A_text_1_Text1 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_bdkey_A_text_1_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_bdkey_A_2_TNb t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_bdkey_A_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_bdkey_A_2_Text4 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_bdkey_B_1_A t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_bdkey_B_1_TNa t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_bdkey_B_1_Text1 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_bdkey_B_1_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_bdkey_B_text_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_bdkey_B_text_2_Text4 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_A_1_B t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_A_1_Rb t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_A_1_Text1 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_A_text_2_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_A_text_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_A_3_Text4 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_A_3_Text5 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_B_2_Ra t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_B_2_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_B_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_B_text_3_Text4 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_B_text_3_Text5 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_bdkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   qed
   thus "isoiec_9798_4_bdkey_composed_typing_state t r s" by unfold_locales auto
 qed
@@ -504,41 +504,61 @@
                            s(MV ''Text1'' tid0)
                         |} ")
     case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
   next
     case (isoiec_9798_4_1_bdkey_A_1_hash tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
 qed
 
-lemma (in restricted_isoiec_9798_4_bdkey_state) isoiec_9798_4_2_bdkey_B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_4_2_bdkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_4_2_bdkey_B_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_4_2_bdkey_A &
-        ( tid1, isoiec_9798_4_2_bdkey_A_2 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(MV ''Rb'' tid1),
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''Rb'' tid0,
-                s(MV ''Text2'' tid0)
-             |})"
+lemma (in restricted_isoiec_9798_4_bdkey_state) isoiec_9798_4_2_bdkey_B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_4_2_bdkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_4_2_bdkey_B_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_4_2_bdkey_A &
+          ( tid1, isoiec_9798_4_2_bdkey_A_2 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(MV ''Rb'' tid1),
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''Rb'' tid0,
+                  s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
 proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Hash {| {| LC ''CCF'', Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) |},
-                           LC ''isoiec_9798_4_2_ccf_2'', LN ''Rb'' tid0, s(AV ''B'' tid0),
-                           s(MV ''Text2'' tid0)
-                        |} ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_4_2_bdkey_A_2_hash tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Hash {| {| LC ''CCF'', Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) |},
+                               LC ''isoiec_9798_4_2_ccf_2'', LN ''Rb'' tid0, s(AV ''B'' tid0),
+                               s(MV ''Text2'' tid0)
+                            |} ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_4_2_bdkey_A_2_hash tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
 qed
 
 lemma (in restricted_isoiec_9798_4_bdkey_state) isoiec_9798_4_3_bdkey_A_non_injective_agreement:
@@ -564,11 +584,11 @@
                            s(MV ''Text3'' tid0)
                         |} ")
     case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
   next
     case (isoiec_9798_4_3_bdkey_B_2_hash tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
 qed
 
 lemma (in restricted_isoiec_9798_4_bdkey_state) isoiec_9798_4_3_bdkey_B_non_injective_agreement:
@@ -594,100 +614,140 @@
                            s(MV ''Text1'' tid0)
                         |} ")
     case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
   next
     case (isoiec_9798_4_3_bdkey_A_1_hash tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
 qed
 
-lemma (in restricted_isoiec_9798_4_bdkey_state) isoiec_9798_4_4_bdkey_A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_4_4_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_4_4_bdkey_A_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_4_4_bdkey_B &
-        ( tid1, isoiec_9798_4_4_bdkey_B_3 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
-           s(MV ''Text2'' tid1), s(MV ''Text4'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''Ra'' tid0,
-                s(MV ''Rb'' tid0), s(MV ''Text2'' tid0), s(MV ''Text4'' tid0)
-             |})"
+lemma (in restricted_isoiec_9798_4_bdkey_state) isoiec_9798_4_4_bdkey_A_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_4_4_bdkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_4_4_bdkey_A_3 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_4_4_bdkey_B &
+          ( tid1, isoiec_9798_4_4_bdkey_B_3 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
+             s(MV ''Text2'' tid1), s(MV ''Text4'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''Ra'' tid0,
+                  s(MV ''Rb'' tid0), s(MV ''Text2'' tid0), s(MV ''Text4'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
 proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Hash {| {| LC ''CCF'', Kbd ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) ) |},
-                           LC ''isoiec_9798_4_4_ccf_3'', s(MV ''Rb'' tid0), LN ''Ra'' tid0,
-                           s(MV ''Text4'' tid0)
-                        |} ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_4_4_bdkey_B_3_hash tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''A'' tid1) )
-               ( s(AV ''B'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
       thus ?thesis proof(sources! "
-                       Hash {| {| LC ''CCF'', Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid1) ) |},
-                               LC ''isoiec_9798_4_4_ccf_2'', LN ''Ra'' tid0, LN ''Rb'' tid1,
-                               s(AV ''B'' tid1), s(MV ''Text2'' tid1)
+                       Hash {| {| LC ''CCF'', Kbd ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) ) |},
+                               LC ''isoiec_9798_4_4_ccf_3'', s(MV ''Rb'' tid0), LN ''Ra'' tid0,
+                               s(MV ''Text4'' tid0)
                             |} ")
         case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest!: ltk_secrecy)
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
       next
-        case (isoiec_9798_4_4_bdkey_A_2_hash tid2) note_unified facts = this facts
-        thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-      qed (insert facts, fastsimp+)?
-    next
-      case swapped note_unified facts = this facts
+        case (isoiec_9798_4_4_bdkey_B_3_hash tid1) note_unified facts = this facts
+        hence "Kbd ( s(AV ''A'' tid1) )
+                   ( s(AV ''B'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) )"
+          by simp note facts = this facts
+        thus ?thesis proof(cases rule: Kbd_cases)
+          case noswap note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Hash {| {| LC ''CCF'', Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid1) ) |},
+                                   LC ''isoiec_9798_4_4_ccf_2'', LN ''Ra'' tid0, LN ''Rb'' tid1,
+                                   s(AV ''B'' tid1), s(MV ''Text2'' tid1)
+                                |} ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest!: ltk_secrecy)
+          next
+            case (isoiec_9798_4_4_bdkey_A_2_hash tid2) note_unified facts = this facts
+            thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+          qed (insert facts, fastforce+)?
+        next
+          case swapped note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Hash {| {| LC ''CCF'', Kbd ( s(AV ''A'' tid0) ) ( s(AV ''A'' tid1) ) |},
+                                   LC ''isoiec_9798_4_4_ccf_2'', LN ''Ra'' tid0, LN ''Rb'' tid1,
+                                   s(AV ''A'' tid0), s(MV ''Text2'' tid1)
+                                |} ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest!: ltk_secrecy)
+          next
+            case (isoiec_9798_4_4_bdkey_A_2_hash tid2) note_unified facts = this facts
+            thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+          qed (insert facts, fastforce+)?
+        qed (fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_4_bdkey_state) isoiec_9798_4_4_bdkey_B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_4_4_bdkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_4_4_bdkey_B_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_4_4_bdkey_A &
+          ( tid1, isoiec_9798_4_4_bdkey_A_2 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
+                  LN ''Rb'' tid0, s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
       thus ?thesis proof(sources! "
-                       Hash {| {| LC ''CCF'', Kbd ( s(AV ''A'' tid0) ) ( s(AV ''A'' tid1) ) |},
-                               LC ''isoiec_9798_4_4_ccf_2'', LN ''Ra'' tid0, LN ''Rb'' tid1,
-                               s(AV ''A'' tid0), s(MV ''Text2'' tid1)
+                       Hash {| {| LC ''CCF'', Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) |},
+                               LC ''isoiec_9798_4_4_ccf_2'', s(MV ''Ra'' tid0), LN ''Rb'' tid0,
+                               s(AV ''B'' tid0), s(MV ''Text2'' tid0)
                             |} ")
         case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest!: ltk_secrecy)
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
       next
-        case (isoiec_9798_4_4_bdkey_A_2_hash tid2) note_unified facts = this facts
-        thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-      qed (insert facts, fastsimp+)?
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_4_bdkey_state) isoiec_9798_4_4_bdkey_B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_4_4_bdkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_4_4_bdkey_B_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_4_4_bdkey_A &
-        ( tid1, isoiec_9798_4_4_bdkey_A_2 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
-                LN ''Rb'' tid0, s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Hash {| {| LC ''CCF'', Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) |},
-                           LC ''isoiec_9798_4_4_ccf_2'', s(MV ''Ra'' tid0), LN ''Rb'' tid0,
-                           s(AV ''B'' tid0), s(MV ''Text2'' tid0)
-                        |} ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_4_4_bdkey_A_2_hash tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+        case (isoiec_9798_4_4_bdkey_A_2_hash tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
 qed
 
 end
diff --git a/data/examples/iso9798/isabelle-parallel-proofs/isoiec-9798-4-udkey_cert_auto.thy b/data/examples/iso9798/isabelle-parallel-proofs/isoiec-9798-4-udkey_cert_auto.thy
--- a/data/examples/iso9798/isabelle-parallel-proofs/isoiec-9798-4-udkey_cert_auto.thy
+++ b/data/examples/iso9798/isabelle-parallel-proofs/isoiec-9798-4-udkey_cert_auto.thy
@@ -1,6 +1,6 @@
 theory "isoiec-9798-4-udkey_cert_auto"
 imports
-  "../ESPLogic"
+  "ESPLogic"
 begin
 
 role isoiec_9798_4_1_udkey_A
@@ -212,217 +212,217 @@
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_1_udkey_A_text_1_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_1_udkey_B_1_A t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_1_udkey_B_1_TNA t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_1_udkey_B_1_Text1 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_1_udkey_B_1_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_udkey_A_1_B t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_udkey_A_1_Rb t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_udkey_A_1_Text1 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_udkey_A_text_2_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_udkey_A_text_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_udkey_B_2_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_udkey_B_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_udkey_A_text_1_Text1 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_udkey_A_text_1_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_udkey_A_2_TNb t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_udkey_A_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_udkey_A_2_Text4 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_udkey_B_1_A t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_udkey_B_1_TNa t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_udkey_B_1_Text1 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_udkey_B_1_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_udkey_B_text_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_udkey_B_text_2_Text4 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_A_1_B t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_A_1_Rb t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_A_1_Text1 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_A_text_2_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_A_text_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_A_3_Text4 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_A_3_Text5 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_B_2_Ra t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_B_2_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_B_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_B_text_3_Text4 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_B_text_3_Text5 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_udkey_composed_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   qed
   thus "isoiec_9798_4_udkey_composed_typing_state t r s" by unfold_locales auto
 qed
@@ -501,40 +501,60 @@
                            LC ''isoiec_9798_4_1_ccf_1'', s(MV ''TNA'' tid0), s(MV ''Text1'' tid0)
                         |} ")
     case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
   next
     case (isoiec_9798_4_1_udkey_A_1_hash tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
 qed
 
-lemma (in restricted_isoiec_9798_4_udkey_state) isoiec_9798_4_2_udkey_B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_4_2_udkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_4_2_udkey_B_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_4_2_udkey_A &
-        ( tid1, isoiec_9798_4_2_udkey_A_2 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(MV ''Rb'' tid1),
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''Rb'' tid0,
-                s(MV ''Text2'' tid0)
-             |})"
+lemma (in restricted_isoiec_9798_4_udkey_state) isoiec_9798_4_2_udkey_B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_4_2_udkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_4_2_udkey_B_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_4_2_udkey_A &
+          ( tid1, isoiec_9798_4_2_udkey_A_2 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(MV ''Rb'' tid1),
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''Rb'' tid0,
+                  s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
 proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Hash {| {| LC ''CCF'', K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) |},
-                           LC ''isoiec_9798_4_2_ccf_2'', LN ''Rb'' tid0, s(MV ''Text2'' tid0)
-                        |} ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_4_2_udkey_A_2_hash tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Hash {| {| LC ''CCF'', K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) |},
+                               LC ''isoiec_9798_4_2_ccf_2'', LN ''Rb'' tid0, s(MV ''Text2'' tid0)
+                            |} ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_4_2_udkey_A_2_hash tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
 qed
 
 lemma (in restricted_isoiec_9798_4_udkey_state) isoiec_9798_4_3_udkey_A_non_injective_agreement:
@@ -559,11 +579,11 @@
                            LC ''isoiec_9798_4_3_ccf_2'', s(MV ''TNb'' tid0), s(MV ''Text3'' tid0)
                         |} ")
     case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
   next
     case (isoiec_9798_4_3_udkey_B_2_hash tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
 qed
 
 lemma (in restricted_isoiec_9798_4_udkey_state) isoiec_9798_4_3_udkey_B_non_injective_agreement:
@@ -588,81 +608,121 @@
                            LC ''isoiec_9798_4_3_ccf_1'', s(MV ''TNa'' tid0), s(MV ''Text1'' tid0)
                         |} ")
     case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
   next
     case (isoiec_9798_4_3_udkey_A_1_hash tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
 qed
 
-lemma (in restricted_isoiec_9798_4_udkey_state) isoiec_9798_4_4_udkey_A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_4_4_udkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_4_4_udkey_A_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_4_4_udkey_B &
-        ( tid1, isoiec_9798_4_4_udkey_B_3 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
-           s(MV ''Text2'' tid1), s(MV ''Text4'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''Ra'' tid0,
-                s(MV ''Rb'' tid0), s(MV ''Text2'' tid0), s(MV ''Text4'' tid0)
-             |})"
+lemma (in restricted_isoiec_9798_4_udkey_state) isoiec_9798_4_4_udkey_A_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_4_4_udkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_4_4_udkey_A_3 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_4_4_udkey_B &
+          ( tid1, isoiec_9798_4_4_udkey_B_3 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
+             s(MV ''Text2'' tid1), s(MV ''Text4'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''Ra'' tid0,
+                  s(MV ''Rb'' tid0), s(MV ''Text2'' tid0), s(MV ''Text4'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
 proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Hash {| {| LC ''CCF'', K ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) ) |},
-                           LC ''isoiec_9798_4_4_ccf_3'', s(MV ''Rb'' tid0), LN ''Ra'' tid0,
-                           s(MV ''Text4'' tid0)
-                        |} ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_4_4_udkey_B_3_hash tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Hash {| {| LC ''CCF'', K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid1) ) |},
-                             LC ''isoiec_9798_4_4_ccf_2'', LN ''Ra'' tid0, LN ''Rb'' tid1,
-                             s(MV ''Text2'' tid1)
-                          |} ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_4_4_udkey_A_2_hash tid2) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Hash {| {| LC ''CCF'', K ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) ) |},
+                               LC ''isoiec_9798_4_4_ccf_3'', s(MV ''Rb'' tid0), LN ''Ra'' tid0,
+                               s(MV ''Text4'' tid0)
+                            |} ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_4_4_udkey_B_3_hash tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Hash {| {| LC ''CCF'', K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid1) ) |},
+                                 LC ''isoiec_9798_4_4_ccf_2'', LN ''Ra'' tid0, LN ''Rb'' tid1,
+                                 s(MV ''Text2'' tid1)
+                              |} ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_4_4_udkey_A_2_hash tid2) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
 qed
 
-lemma (in restricted_isoiec_9798_4_udkey_state) isoiec_9798_4_4_udkey_B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_4_4_udkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_4_4_udkey_B_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_4_4_udkey_A &
-        ( tid1, isoiec_9798_4_4_udkey_A_2 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
-                LN ''Rb'' tid0, s(MV ''Text2'' tid0)
-             |})"
+lemma (in restricted_isoiec_9798_4_udkey_state) isoiec_9798_4_4_udkey_B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_4_4_udkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_4_4_udkey_B_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_4_4_udkey_A &
+          ( tid1, isoiec_9798_4_4_udkey_A_2 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
+                  LN ''Rb'' tid0, s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
 proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Hash {| {| LC ''CCF'', K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) |},
-                           LC ''isoiec_9798_4_4_ccf_2'', s(MV ''Ra'' tid0), LN ''Rb'' tid0,
-                           s(MV ''Text2'' tid0)
-                        |} ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_4_4_udkey_A_2_hash tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Hash {| {| LC ''CCF'', K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) |},
+                               LC ''isoiec_9798_4_4_ccf_2'', s(MV ''Ra'' tid0), LN ''Rb'' tid0,
+                               s(MV ''Text2'' tid0)
+                            |} ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_4_4_udkey_A_2_hash tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
 qed
 
 end
diff --git a/data/examples/iso9798/isabelle-proofs/isoiec-9798-2-bdkey_cert_auto.thy b/data/examples/iso9798/isabelle-proofs/isoiec-9798-2-bdkey_cert_auto.thy
--- a/data/examples/iso9798/isabelle-proofs/isoiec-9798-2-bdkey_cert_auto.thy
+++ b/data/examples/iso9798/isabelle-proofs/isoiec-9798-2-bdkey_cert_auto.thy
@@ -1,3702 +1,4002 @@
 theory "isoiec-9798-2-bdkey_cert_auto"
 imports
-  "../ESPLogic"
-begin
-
-role isoiec_9798_2_1_bdkey_A
-where "isoiec_9798_2_1_bdkey_A =
-  [ Send ''leak_A'' ( sN ''TNA'' )
-  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
-  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
-                  PEnc <| sC ''isoiec_9798_2_1_enc_1'', sN ''TNA'', sAV ''B'',
-                          sMV ''Text1''
-                       |>
-                       ( sKbd (AVar ''A'') (AVar ''B'') )
-               |>
-  ]"
-
-role isoiec_9798_2_1_bdkey_B
-where "isoiec_9798_2_1_bdkey_B =
-  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
-                  PEnc <| sC ''isoiec_9798_2_1_enc_1'', sMV ''TNA'', sAV ''B'',
-                          sMV ''Text1''
-                       |>
-                       ( sKbd (MVar ''A'') (AVar ''B'') )
-               |>
-  ]"
-
-protocol isoiec_9798_2_1_bdkey
-where "isoiec_9798_2_1_bdkey =
-{ isoiec_9798_2_1_bdkey_A, isoiec_9798_2_1_bdkey_B }"
-
-locale restricted_isoiec_9798_2_1_bdkey_state = isoiec_9798_2_1_bdkey_state
-
-type_invariant isoiec_9798_2_1_bdkey_msc_typing for isoiec_9798_2_1_bdkey
-where "isoiec_9798_2_1_bdkey_msc_typing = mk_typing
-  [ ((isoiec_9798_2_1_bdkey_B, ''A''), (KnownT isoiec_9798_2_1_bdkey_B_1))
-  , ((isoiec_9798_2_1_bdkey_B, ''TNA''),
-     (SumT (KnownT isoiec_9798_2_1_bdkey_B_1) (NonceT isoiec_9798_2_1_bdkey_A ''TNA'')))
-  , ((isoiec_9798_2_1_bdkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_1_bdkey_A_text_1))
-  , ((isoiec_9798_2_1_bdkey_B, ''Text1''),
-     (KnownT isoiec_9798_2_1_bdkey_B_1))
-  , ((isoiec_9798_2_1_bdkey_A, ''Text2''),
-     (KnownT isoiec_9798_2_1_bdkey_A_text_1))
-  , ((isoiec_9798_2_1_bdkey_B, ''Text2''),
-     (KnownT isoiec_9798_2_1_bdkey_B_1))
-  ]"
-
-sublocale isoiec_9798_2_1_bdkey_state < isoiec_9798_2_1_bdkey_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_2_1_bdkey_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_2_1_bdkey_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_2_1_bdkey_A_text_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_1_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_1_bdkey_A_text_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_1_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_1_bdkey_B_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_1_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_1_bdkey_B_1_TNA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_1_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
-               s(AV ''B'' tid0), s(MV ''Text1'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_1_bdkey_B_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_1_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
-               s(AV ''B'' tid0), s(MV ''Text1'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_1_bdkey_B_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_1_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_2_1_bdkey_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_2_1_bdkey_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_2_1_bdkey_state) B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_1_bdkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_1_bdkey_B_1 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_1_bdkey_A &
-        ( tid1, isoiec_9798_2_1_bdkey_A_1 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
-           s(MV ''Text1'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
-                s(MV ''Text1'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
-                          s(AV ''B'' tid0), s(MV ''Text1'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_1_bdkey_A_1_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-role isoiec_9798_2_2_bdkey_A
-where "isoiec_9798_2_2_bdkey_A =
-  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text1'' |>
-  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
-  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
-                  PEnc <| sC ''isoiec_9798_2_2_enc_2'', sMV ''RB'', sMV ''B'',
-                          sMV ''Text2''
-                       |>
-                       ( sKbd (MVar ''B'') (AVar ''A'') )
-               |>
-  ]"
-
-role isoiec_9798_2_2_bdkey_B
-where "isoiec_9798_2_2_bdkey_B =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''RB'', sMV ''Text1'' |>
-  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
-                  PEnc <| sC ''isoiec_9798_2_2_enc_2'', sN ''RB'', sAV ''B'', sMV ''Text2''
-                       |>
-                       ( sKbd (AVar ''B'') (AVar ''A'') )
-               |>
-  ]"
-
-protocol isoiec_9798_2_2_bdkey
-where "isoiec_9798_2_2_bdkey =
-{ isoiec_9798_2_2_bdkey_A, isoiec_9798_2_2_bdkey_B }"
-
-locale restricted_isoiec_9798_2_2_bdkey_state = isoiec_9798_2_2_bdkey_state
-
-type_invariant isoiec_9798_2_2_bdkey_msc_typing for isoiec_9798_2_2_bdkey
-where "isoiec_9798_2_2_bdkey_msc_typing = mk_typing
-  [ ((isoiec_9798_2_2_bdkey_A, ''B''), (KnownT isoiec_9798_2_2_bdkey_A_1))
-  , ((isoiec_9798_2_2_bdkey_A, ''RB''), (KnownT isoiec_9798_2_2_bdkey_A_1))
-  , ((isoiec_9798_2_2_bdkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_2_bdkey_A_1))
-  , ((isoiec_9798_2_2_bdkey_B, ''Text1''),
-     (KnownT isoiec_9798_2_2_bdkey_B_text_1))
-  , ((isoiec_9798_2_2_bdkey_A, ''Text2''),
-     (KnownT isoiec_9798_2_2_bdkey_A_text_2))
-  , ((isoiec_9798_2_2_bdkey_B, ''Text2''),
-     (KnownT isoiec_9798_2_2_bdkey_B_2))
-  , ((isoiec_9798_2_2_bdkey_A, ''Text3''),
-     (KnownT isoiec_9798_2_2_bdkey_A_text_2))
-  , ((isoiec_9798_2_2_bdkey_B, ''Text3''),
-     (KnownT isoiec_9798_2_2_bdkey_B_2))
-  ]"
-
-sublocale isoiec_9798_2_2_bdkey_state < isoiec_9798_2_2_bdkey_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_2_2_bdkey_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_2_2_bdkey_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_2_2_bdkey_A_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_2_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_2_bdkey_A_1_RB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_2_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_2_bdkey_A_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_2_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_2_bdkey_A_text_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_2_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_2_bdkey_A_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_2_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_2_bdkey_B_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_2_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_2_enc_2'', LN ''RB'' tid0, s(AV ''B'' tid0),
-               s(MV ''Text2'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_2_bdkey_B_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_2_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_2_2_bdkey_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_2_2_bdkey_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_2_2_bdkey_state) B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_2_bdkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_2_bdkey_B_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_2_bdkey_A &
-        ( tid1, isoiec_9798_2_2_bdkey_A_2 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(MV ''RB'' tid1),
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''RB'' tid0,
-                s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_2_enc_2'', LN ''RB'' tid0, s(AV ''B'' tid0),
-                          s(MV ''Text2'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_2_bdkey_A_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-role isoiec_9798_2_3_bdkey_A
-where "isoiec_9798_2_3_bdkey_A =
-  [ Send ''leak_A'' ( sN ''TNA'' )
-  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
-  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
-                  PEnc <| sC ''isoiec_9798_2_3_enc_1'', sN ''TNA'', sAV ''B'',
-                          sMV ''Text1''
-                       |>
-                       ( sKbd (AVar ''A'') (AVar ''B'') )
-               |>
-  , Recv ''2'' <| sAV ''B'', sAV ''A'', sMV ''Text4'',
-                  PEnc <| sC ''isoiec_9798_2_3_enc_2'', sMV ''TNB'', sAV ''A'',
-                          sMV ''Text3''
-                       |>
-                       ( sKbd (AVar ''B'') (AVar ''A'') )
-               |>
-  ]"
-
-role isoiec_9798_2_3_bdkey_B
-where "isoiec_9798_2_3_bdkey_B =
-  [ Send ''leak_B'' ( sN ''TNB'' )
-  , Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
-                  PEnc <| sC ''isoiec_9798_2_3_enc_1'', sMV ''TNA'', sAV ''B'',
-                          sMV ''Text1''
-                       |>
-                       ( sKbd (MVar ''A'') (AVar ''B'') )
-               |>
-  , Recv ''text_2'' <| sMV ''Text3'', sMV ''Text4'' |>
-  , Send ''2'' <| sAV ''B'', sMV ''A'', sMV ''Text4'',
-                  PEnc <| sC ''isoiec_9798_2_3_enc_2'', sN ''TNB'', sMV ''A'',
-                          sMV ''Text3''
-                       |>
-                       ( sKbd (AVar ''B'') (MVar ''A'') )
-               |>
-  ]"
-
-protocol isoiec_9798_2_3_bdkey
-where "isoiec_9798_2_3_bdkey =
-{ isoiec_9798_2_3_bdkey_A, isoiec_9798_2_3_bdkey_B }"
-
-locale restricted_isoiec_9798_2_3_bdkey_state = isoiec_9798_2_3_bdkey_state
-
-type_invariant isoiec_9798_2_3_bdkey_msc_typing for isoiec_9798_2_3_bdkey
-where "isoiec_9798_2_3_bdkey_msc_typing = mk_typing
-  [ ((isoiec_9798_2_3_bdkey_B, ''A''), (KnownT isoiec_9798_2_3_bdkey_B_1))
-  , ((isoiec_9798_2_3_bdkey_B, ''TNA''),
-     (SumT (KnownT isoiec_9798_2_3_bdkey_B_1) (NonceT isoiec_9798_2_3_bdkey_A ''TNA'')))
-  , ((isoiec_9798_2_3_bdkey_A, ''TNB''),
-     (SumT (KnownT isoiec_9798_2_3_bdkey_A_2) (NonceT isoiec_9798_2_3_bdkey_B ''TNB'')))
-  , ((isoiec_9798_2_3_bdkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_3_bdkey_A_text_1))
-  , ((isoiec_9798_2_3_bdkey_B, ''Text1''),
-     (KnownT isoiec_9798_2_3_bdkey_B_1))
-  , ((isoiec_9798_2_3_bdkey_A, ''Text2''),
-     (KnownT isoiec_9798_2_3_bdkey_A_text_1))
-  , ((isoiec_9798_2_3_bdkey_B, ''Text2''),
-     (KnownT isoiec_9798_2_3_bdkey_B_1))
-  , ((isoiec_9798_2_3_bdkey_A, ''Text3''),
-     (KnownT isoiec_9798_2_3_bdkey_A_2))
-  , ((isoiec_9798_2_3_bdkey_B, ''Text3''),
-     (KnownT isoiec_9798_2_3_bdkey_B_text_2))
-  , ((isoiec_9798_2_3_bdkey_A, ''Text4''),
-     (KnownT isoiec_9798_2_3_bdkey_A_2))
-  , ((isoiec_9798_2_3_bdkey_B, ''Text4''),
-     (KnownT isoiec_9798_2_3_bdkey_B_text_2))
-  ]"
-
-sublocale isoiec_9798_2_3_bdkey_state < isoiec_9798_2_3_bdkey_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_2_3_bdkey_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_2_3_bdkey_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_2_3_bdkey_A_text_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_3_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_bdkey_A_text_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_3_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_bdkey_A_2_TNB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_3_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
-               s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_3_bdkey_A_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_3_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
-               s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_3_bdkey_A_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_3_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_bdkey_B_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_3_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_bdkey_B_1_TNA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_3_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
-               s(AV ''B'' tid0), s(MV ''Text1'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_3_bdkey_B_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_3_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
-               s(AV ''B'' tid0), s(MV ''Text1'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_3_bdkey_B_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_3_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_bdkey_B_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_3_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_bdkey_B_text_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_3_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_2_3_bdkey_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_2_3_bdkey_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_2_3_bdkey_state) A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_3_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_3_bdkey_A_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_3_bdkey_B &
-        ( tid1, isoiec_9798_2_3_bdkey_B_2 ) : steps t &
-        {| s(MV ''A'' tid1), s(AV ''B'' tid1), LN ''TNB'' tid1,
-           s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNB'' tid0),
-                s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
-                          s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_3_bdkey_B_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_3_bdkey_state) B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_3_bdkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_3_bdkey_B_1 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_3_bdkey_A &
-        ( tid1, isoiec_9798_2_3_bdkey_A_1 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
-           s(MV ''Text1'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
-                s(MV ''Text1'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
-                          s(AV ''B'' tid0), s(MV ''Text1'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_3_bdkey_A_1_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-role isoiec_9798_2_4_bdkey_A
-where "isoiec_9798_2_4_bdkey_A =
-  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text1'' |>
-  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
-  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
-                  PEnc <| sC ''isoiec_9798_2_4_enc_1'', sN ''RA'', sMV ''RB'', sMV ''B'',
-                          sMV ''Text2''
-                       |>
-                       ( sKbd (AVar ''A'') (MVar ''B'') )
-               |>
-  , Recv ''3'' <| sMV ''B'', sAV ''A'', sMV ''Text5'',
-                  PEnc <| sC ''isoiec_9798_2_4_enc_2'', sMV ''RB'', sN ''RA'',
-                          sMV ''Text4''
-                       |>
-                       ( sKbd (AVar ''A'') (MVar ''B'') )
-               |>
-  ]"
-
-role isoiec_9798_2_4_bdkey_B
-where "isoiec_9798_2_4_bdkey_B =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''RB'', sMV ''Text1'' |>
-  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
-                  PEnc <| sC ''isoiec_9798_2_4_enc_1'', sMV ''RA'', sN ''RB'', sAV ''B'',
-                          sMV ''Text2''
-                       |>
-                       ( sKbd (AVar ''A'') (AVar ''B'') )
-               |>
-  , Recv ''text_3'' <| sMV ''Text4'', sMV ''Text5'' |>
-  , Send ''3'' <| sAV ''B'', sAV ''A'', sMV ''Text5'',
-                  PEnc <| sC ''isoiec_9798_2_4_enc_2'', sN ''RB'', sMV ''RA'',
-                          sMV ''Text4''
-                       |>
-                       ( sKbd (AVar ''A'') (AVar ''B'') )
-               |>
-  ]"
-
-protocol isoiec_9798_2_4_bdkey
-where "isoiec_9798_2_4_bdkey =
-{ isoiec_9798_2_4_bdkey_A, isoiec_9798_2_4_bdkey_B }"
-
-locale restricted_isoiec_9798_2_4_bdkey_state = isoiec_9798_2_4_bdkey_state
-
-type_invariant isoiec_9798_2_4_bdkey_msc_typing for isoiec_9798_2_4_bdkey
-where "isoiec_9798_2_4_bdkey_msc_typing = mk_typing
-  [ ((isoiec_9798_2_4_bdkey_A, ''B''), (KnownT isoiec_9798_2_4_bdkey_A_1))
-  , ((isoiec_9798_2_4_bdkey_B, ''RA''),
-     (SumT (KnownT isoiec_9798_2_4_bdkey_B_2) (NonceT isoiec_9798_2_4_bdkey_A ''RA'')))
-  , ((isoiec_9798_2_4_bdkey_A, ''RB''), (KnownT isoiec_9798_2_4_bdkey_A_1))
-  , ((isoiec_9798_2_4_bdkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_4_bdkey_A_1))
-  , ((isoiec_9798_2_4_bdkey_B, ''Text1''),
-     (KnownT isoiec_9798_2_4_bdkey_B_text_1))
-  , ((isoiec_9798_2_4_bdkey_A, ''Text2''),
-     (KnownT isoiec_9798_2_4_bdkey_A_text_2))
-  , ((isoiec_9798_2_4_bdkey_B, ''Text2''),
-     (KnownT isoiec_9798_2_4_bdkey_B_2))
-  , ((isoiec_9798_2_4_bdkey_A, ''Text3''),
-     (KnownT isoiec_9798_2_4_bdkey_A_text_2))
-  , ((isoiec_9798_2_4_bdkey_B, ''Text3''),
-     (KnownT isoiec_9798_2_4_bdkey_B_2))
-  , ((isoiec_9798_2_4_bdkey_A, ''Text4''),
-     (KnownT isoiec_9798_2_4_bdkey_A_3))
-  , ((isoiec_9798_2_4_bdkey_B, ''Text4''),
-     (KnownT isoiec_9798_2_4_bdkey_B_text_3))
-  , ((isoiec_9798_2_4_bdkey_A, ''Text5''),
-     (KnownT isoiec_9798_2_4_bdkey_A_3))
-  , ((isoiec_9798_2_4_bdkey_B, ''Text5''),
-     (KnownT isoiec_9798_2_4_bdkey_B_text_3))
-  ]"
-
-sublocale isoiec_9798_2_4_bdkey_state < isoiec_9798_2_4_bdkey_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_2_4_bdkey_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_2_4_bdkey_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_2_4_bdkey_A_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_bdkey_A_1_RB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_bdkey_A_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_bdkey_A_text_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_bdkey_A_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_bdkey_A_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_4_enc_2'', s(MV ''RB'' tid0), LN ''RA'' tid0,
-               s(MV ''Text4'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_4_bdkey_A_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_bdkey_B_2_RA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
-               s(AV ''B'' tid0), s(MV ''Text2'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_4_bdkey_B_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
-               s(AV ''B'' tid0), s(MV ''Text2'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_4_bdkey_B_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_bdkey_B_text_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_bdkey_B_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_2_4_bdkey_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_2_4_bdkey_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_2_4_bdkey_state) A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_4_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_4_bdkey_A_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_4_bdkey_B &
-        ( tid1, isoiec_9798_2_4_bdkey_B_3 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''RA'' tid1), LN ''RB'' tid1,
-           s(MV ''Text2'' tid1), s(MV ''Text4'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''RA'' tid0,
-                s(MV ''RB'' tid0), s(MV ''Text2'' tid0), s(MV ''Text4'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_4_enc_2'', s(MV ''RB'' tid0), LN ''RA'' tid0,
-                          s(MV ''Text4'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_4_bdkey_B_3_enc tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''A'' tid1) )
-               ( s(AV ''B'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_4_enc_1'', LN ''RA'' tid0, LN ''RB'' tid1,
-                              s(AV ''B'' tid1), s(MV ''Text2'' tid1)
-                           |}
-                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid1) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest!: ltk_secrecy)
-      next
-        case (isoiec_9798_2_4_bdkey_A_2_enc tid2) note_unified facts = this facts
-        thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-      qed (insert facts, fastsimp+)?
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_4_enc_1'', LN ''RA'' tid0, LN ''RB'' tid1,
-                              s(AV ''A'' tid0), s(MV ''Text2'' tid1)
-                           |}
-                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''A'' tid1) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest!: ltk_secrecy)
-      next
-        case (isoiec_9798_2_4_bdkey_A_2_enc tid2) note_unified facts = this facts
-        thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-      qed (insert facts, fastsimp+)?
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_4_bdkey_state) B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_4_bdkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_4_bdkey_B_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_4_bdkey_A &
-        ( tid1, isoiec_9798_2_4_bdkey_A_2 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''RA'' tid1, s(MV ''RB'' tid1),
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''RA'' tid0),
-                LN ''RB'' tid0, s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
-                          s(AV ''B'' tid0), s(MV ''Text2'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_4_bdkey_A_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-role isoiec_9798_2_5_bdkey_A
-where "isoiec_9798_2_5_bdkey_A =
-  [ Send ''leak_A'' <| sN ''TVPa'', sN ''TNa'' |>
-  , Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''A'', sAV ''P'', sN ''TVPa'', sAV ''B'',
-                  sMV ''Text1''
-               |>
-  , Recv ''2'' <| sAV ''P'', sAV ''A'', sMV ''Text4'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_2_1'', sN ''TVPa'', sMV ''Kab'',
-                          sAV ''A'', sAV ''B'', sMV ''Text3''
-                       |>
-                       ( sKbd (AVar ''A'') (AVar ''P'') ),
-                  sMV ''TokenPA_for_B''
-               |>
-  , Recv ''text_3'' <| sMV ''Text5'', sMV ''Text6'' |>
-  , Send ''3'' <| sAV ''A'', sAV ''B'', sMV ''Text6'', sAV ''P'',
-                  sMV ''TokenPA_for_B'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_3'', sN ''TNa'', sAV ''B'',
-                          sMV ''Text5''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''4'' <| sAV ''B'', sAV ''A'', sMV ''Text8'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_4'', sMV ''TNb'', sAV ''A'',
-                          sMV ''Text7''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_5_bdkey_B
-where "isoiec_9798_2_5_bdkey_B =
-  [ Send ''leak_B'' ( sN ''TNb'' )
-  , Recv ''3'' <| sMV ''A'', sAV ''B'', sMV ''Text6'', sMV ''P'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_2_2'', sMV ''TNp'', sMV ''Kab'',
-                          sMV ''A'', sAV ''B'', sMV ''Text2''
-                       |>
-                       ( sKbd (AVar ''B'') (MVar ''P'') ),
-                  PEnc <| sC ''isoiec_9798_2_5_enc_3'', sMV ''TNa'', sAV ''B'',
-                          sMV ''Text5''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''text_4'' <| sMV ''Text7'', sMV ''Text8'' |>
-  , Send ''4'' <| sAV ''B'', sMV ''A'', sMV ''Text8'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_4'', sN ''TNb'', sMV ''A'',
-                          sMV ''Text7''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_5_bdkey_P
-where "isoiec_9798_2_5_bdkey_P =
-  [ Send ''leak_P'' ( sN ''TNp'' )
-  , Recv ''1'' <| sMV ''A'', sAV ''P'', sMV ''TVPa'', sMV ''B'',
-                  sMV ''Text1''
-               |>
-  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'', sMV ''Text4'' |>
-  , Send ''2'' <| sAV ''P'', sMV ''A'', sMV ''Text4'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_2_1'', sMV ''TVPa'', sN ''Kab'',
-                          sMV ''A'', sMV ''B'', sMV ''Text3''
-                       |>
-                       ( sKbd (MVar ''A'') (AVar ''P'') ),
-                  PEnc <| sC ''isoiec_9798_2_5_enc_2_2'', sN ''TNp'', sN ''Kab'',
-                          sMV ''A'', sMV ''B'', sMV ''Text2''
-                       |>
-                       ( sKbd (MVar ''B'') (AVar ''P'') )
-               |>
-  ]"
-
-protocol isoiec_9798_2_5_bdkey
-where "isoiec_9798_2_5_bdkey =
-{ isoiec_9798_2_5_bdkey_A, isoiec_9798_2_5_bdkey_B,
-  isoiec_9798_2_5_bdkey_P
-}"
-
-locale restricted_isoiec_9798_2_5_bdkey_state = isoiec_9798_2_5_bdkey_state
-
-type_invariant isoiec_9798_2_5_bdkey_msc_typing for isoiec_9798_2_5_bdkey
-where "isoiec_9798_2_5_bdkey_msc_typing = mk_typing
-  [ ((isoiec_9798_2_5_bdkey_B, ''A''), (KnownT isoiec_9798_2_5_bdkey_B_3))
-  , ((isoiec_9798_2_5_bdkey_P, ''A''), (KnownT isoiec_9798_2_5_bdkey_P_1))
-  , ((isoiec_9798_2_5_bdkey_P, ''B''), (KnownT isoiec_9798_2_5_bdkey_P_1))
-  , ((isoiec_9798_2_5_bdkey_A, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_5_bdkey_A_2) (NonceT isoiec_9798_2_5_bdkey_P ''Kab'')))
-  , ((isoiec_9798_2_5_bdkey_B, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_5_bdkey_B_3) (NonceT isoiec_9798_2_5_bdkey_P ''Kab'')))
-  , ((isoiec_9798_2_5_bdkey_B, ''P''), (KnownT isoiec_9798_2_5_bdkey_B_3))
-  , ((isoiec_9798_2_5_bdkey_B, ''TNa''),
-     (SumT (KnownT isoiec_9798_2_5_bdkey_B_3) (NonceT isoiec_9798_2_5_bdkey_A ''TNa'')))
-  , ((isoiec_9798_2_5_bdkey_A, ''TNb''),
-     (SumT (KnownT isoiec_9798_2_5_bdkey_A_4) (NonceT isoiec_9798_2_5_bdkey_B ''TNb'')))
-  , ((isoiec_9798_2_5_bdkey_B, ''TNp''),
-     (SumT (KnownT isoiec_9798_2_5_bdkey_B_3) (NonceT isoiec_9798_2_5_bdkey_P ''TNp'')))
-  , ((isoiec_9798_2_5_bdkey_P, ''TVPa''),
-     (KnownT isoiec_9798_2_5_bdkey_P_1))
-  , ((isoiec_9798_2_5_bdkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_5_bdkey_A_text_1))
-  , ((isoiec_9798_2_5_bdkey_P, ''Text1''),
-     (KnownT isoiec_9798_2_5_bdkey_P_1))
-  , ((isoiec_9798_2_5_bdkey_B, ''Text2''),
-     (KnownT isoiec_9798_2_5_bdkey_B_3))
-  , ((isoiec_9798_2_5_bdkey_P, ''Text2''),
-     (KnownT isoiec_9798_2_5_bdkey_P_text_2))
-  , ((isoiec_9798_2_5_bdkey_A, ''Text3''),
-     (KnownT isoiec_9798_2_5_bdkey_A_2))
-  , ((isoiec_9798_2_5_bdkey_P, ''Text3''),
-     (KnownT isoiec_9798_2_5_bdkey_P_text_2))
-  , ((isoiec_9798_2_5_bdkey_A, ''Text4''),
-     (KnownT isoiec_9798_2_5_bdkey_A_2))
-  , ((isoiec_9798_2_5_bdkey_P, ''Text4''),
-     (KnownT isoiec_9798_2_5_bdkey_P_text_2))
-  , ((isoiec_9798_2_5_bdkey_A, ''Text5''),
-     (KnownT isoiec_9798_2_5_bdkey_A_text_3))
-  , ((isoiec_9798_2_5_bdkey_B, ''Text5''),
-     (KnownT isoiec_9798_2_5_bdkey_B_3))
-  , ((isoiec_9798_2_5_bdkey_A, ''Text6''),
-     (KnownT isoiec_9798_2_5_bdkey_A_text_3))
-  , ((isoiec_9798_2_5_bdkey_B, ''Text6''),
-     (KnownT isoiec_9798_2_5_bdkey_B_3))
-  , ((isoiec_9798_2_5_bdkey_A, ''Text7''),
-     (KnownT isoiec_9798_2_5_bdkey_A_4))
-  , ((isoiec_9798_2_5_bdkey_B, ''Text7''),
-     (KnownT isoiec_9798_2_5_bdkey_B_text_4))
-  , ((isoiec_9798_2_5_bdkey_A, ''Text8''),
-     (KnownT isoiec_9798_2_5_bdkey_A_4))
-  , ((isoiec_9798_2_5_bdkey_B, ''Text8''),
-     (KnownT isoiec_9798_2_5_bdkey_B_text_4))
-  , ((isoiec_9798_2_5_bdkey_A, ''TokenPA_for_B''),
-     (KnownT isoiec_9798_2_5_bdkey_A_2))
-  ]"
-
-sublocale isoiec_9798_2_5_bdkey_state < isoiec_9798_2_5_bdkey_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_2_5_bdkey_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_2_5_bdkey_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_2_5_bdkey_A_2_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
-               s(MV ''Text3'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_bdkey_A_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
-               s(MV ''Text3'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_bdkey_A_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_A_2_TokenPA_for_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_A_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_A_text_3_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_A_4_TNb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
-               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_bdkey_A_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
-               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_bdkey_A_4_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_B_3_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_B_3_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
-               s(MV ''Text2'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_bdkey_B_3_P t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_B_3_TNa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
-               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_bdkey_B_3_TNp t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
-               s(MV ''Text2'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_bdkey_B_3_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
-               s(MV ''Text2'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_bdkey_B_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
-               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_bdkey_B_3_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_B_text_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_B_text_4_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_P_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_P_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_P_1_TVPa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_P_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_P_text_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_P_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_bdkey_P_text_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_2_5_bdkey_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_2_5_bdkey_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_2_5_bdkey_state) P_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_P"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "LN ''Kab'' tid0 : knows t"
-  shows "False"
-using facts proof(sources! " LN ''Kab'' tid0 ")
-  case isoiec_9798_2_5_bdkey_P_2_Kab note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-next
-  case isoiec_9798_2_5_bdkey_P_2_Kab_1 note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-qed (insert facts, fastsimp+)?
-
-lemma (in restricted_isoiec_9798_2_5_bdkey_state) A_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_bdkey_A_2 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
-                          s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_bdkey_P_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_5_bdkey_state) B_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_bdkey_B_3 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
-                          s(MV ''Text2'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_bdkey_P_2_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_5_bdkey_state) A_non_injective_agreement_B:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_bdkey_A_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_bdkey_B &
-        ( tid1, isoiec_9798_2_5_bdkey_B_4 ) : steps t &
-        {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
-           s(MV ''Kab'' tid1), s(MV ''TNa'' tid1), s(MV ''Text5'' tid1),
-           LN ''TNb'' tid1, s(MV ''Text7'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
-                s(MV ''Kab'' tid0), LN ''TNa'' tid0, s(MV ''Text5'' tid0),
-                s(MV ''TNb'' tid0), s(MV ''Text7'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
-                          s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_bdkey_P_2_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
-                            s(AV ''A'' tid0), s(MV ''Text7'' tid0)
-                         |}
-                         ( LN ''Kab'' tid1 ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-    next
-      case (isoiec_9798_2_5_bdkey_B_4_enc tid2) note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid2),
-                              LN ''Kab'' tid1, s(AV ''A'' tid0), s(AV ''B'' tid2), s(MV ''Text2'' tid2)
-                           |}
-                           ( Kbd ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_5_bdkey_P_2_enc_1 tid3) note_unified facts = this facts
-        thus ?thesis proof(sources! "
-                         Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid2),
-                                s(AV ''B'' tid0), s(MV ''Text5'' tid2)
-                             |}
-                             ( LN ''Kab'' tid1 ) ")
-          case fake note_unified facts = this facts
-          thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-        next
-          case (isoiec_9798_2_5_bdkey_A_3_enc tid3) note_unified facts = this facts
-          thus ?thesis proof(sources! "
-                           Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid3, LN ''Kab'' tid1,
-                                  s(AV ''A'' tid3), s(AV ''B'' tid0), s(MV ''Text3'' tid3)
-                               |}
-                               ( Kbd ( s(AV ''A'' tid3) ) ( s(AV ''P'' tid3) ) ) ")
-            case fake note_unified facts = this facts
-            thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-          next
-            case (isoiec_9798_2_5_bdkey_P_2_enc tid4) note_unified facts = this facts
-            thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-          qed (insert facts, fastsimp+)?
-        qed (insert facts, fastsimp+)?
-      qed (insert facts, fastsimp+)?
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_5_bdkey_state) B_non_injective_agreement_A:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_bdkey_B_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_bdkey_A &
-        ( tid1, isoiec_9798_2_5_bdkey_A_3 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Kab'' tid1), LN ''TNa'' tid1, s(MV ''Text5'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                s(MV ''Kab'' tid0), s(MV ''TNa'' tid0), s(MV ''Text5'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
-                          s(MV ''Text2'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_bdkey_P_2_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
-                            s(AV ''B'' tid0), s(MV ''Text5'' tid0)
-                         |}
-                         ( LN ''Kab'' tid1 ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-    next
-      case (isoiec_9798_2_5_bdkey_A_3_enc tid2) note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid2, LN ''Kab'' tid1,
-                              s(AV ''A'' tid2), s(AV ''B'' tid0), s(MV ''Text3'' tid2)
-                           |}
-                           ( Kbd ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_5_bdkey_P_2_enc tid3) note_unified facts = this facts
-        thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-      qed (insert facts, fastsimp+)?
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_5_bdkey_state) A_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_bdkey_A_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_bdkey_P &
-        ( tid1, isoiec_9798_2_5_bdkey_P_2 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
-           s(MV ''TVPa'' tid1), s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
-                s(MV ''Kab'' tid0), LN ''TVPa'' tid0, s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
-                          s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_bdkey_P_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_5_bdkey_state) B_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_bdkey_B_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_bdkey_P &
-        ( tid1, isoiec_9798_2_5_bdkey_P_2 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
-           LN ''TNp'' tid1, s(MV ''Text2'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                s(MV ''Kab'' tid0), s(MV ''TNp'' tid0), s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
-                          s(MV ''Text2'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_bdkey_P_2_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-role isoiec_9798_2_6_bdkey_A
-where "isoiec_9798_2_6_bdkey_A =
-  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
-  , Recv ''text_2'' ( sMV ''Text2'' )
-  , Send ''2'' <| sAV ''A'', sAV ''P'', sN ''Ra'', sMV ''Rb'', sMV ''B'',
-                  sMV ''Text2''
-               |>
-  , Recv ''3'' <| sAV ''P'', sAV ''A'', sMV ''Text5'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_3_1'', sN ''Ra'', sMV ''Kab'',
-                          sAV ''A'', sMV ''B'', sMV ''Text4''
-                       |>
-                       ( sKbd (AVar ''A'') (AVar ''P'') ),
-                  sMV ''TokenPA_for_B''
-               |>
-  , Recv ''text_4'' <| sMV ''Text6'', sMV ''Text7'' |>
-  , Send ''4'' <| sAV ''A'', sMV ''B'', sMV ''Text7'', sAV ''P'',
-                  sMV ''TokenPA_for_B'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_4'', sN ''Rpa'', sMV ''Rb'',
-                          sMV ''Text6''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''5'' <| sMV ''B'', sAV ''A'', sMV ''Text9'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_5'', sMV ''Rb'', sN ''Rpa'',
-                          sMV ''Text8''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_6_bdkey_B
-where "isoiec_9798_2_6_bdkey_B =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
-  , Recv ''4'' <| sAV ''A'', sAV ''B'', sMV ''Text7'', sMV ''P'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_3_2'', sN ''Rb'', sMV ''Kab'',
-                          sAV ''A'', sAV ''B'', sMV ''Text3''
-                       |>
-                       ( sKbd (AVar ''B'') (MVar ''P'') ),
-                  PEnc <| sC ''isoiec_9798_2_6_enc_4'', sMV ''Rpa'', sN ''Rb'',
-                          sMV ''Text6''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
-  , Send ''5'' <| sAV ''B'', sAV ''A'', sMV ''Text9'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_5'', sN ''Rb'', sMV ''Rpa'',
-                          sMV ''Text8''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_6_bdkey_P
-where "isoiec_9798_2_6_bdkey_P =
-  [ Recv ''2'' <| sMV ''A'', sAV ''P'', sMV ''Ra'', sMV ''Rb'', sMV ''B'',
-                  sMV ''Text2''
-               |>
-  , Recv ''text_3'' <| sMV ''Text3'', sMV ''Text4'', sMV ''Text5'' |>
-  , Send ''3'' <| sAV ''P'', sMV ''A'', sMV ''Text5'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_3_1'', sMV ''Ra'', sN ''Kab'',
-                          sMV ''A'', sMV ''B'', sMV ''Text4''
-                       |>
-                       ( sKbd (MVar ''A'') (AVar ''P'') ),
-                  PEnc <| sC ''isoiec_9798_2_6_enc_3_2'', sMV ''Rb'', sN ''Kab'',
-                          sMV ''A'', sMV ''B'', sMV ''Text3''
-                       |>
-                       ( sKbd (MVar ''B'') (AVar ''P'') )
-               |>
-  ]"
-
-protocol isoiec_9798_2_6_bdkey
-where "isoiec_9798_2_6_bdkey =
-{ isoiec_9798_2_6_bdkey_A, isoiec_9798_2_6_bdkey_B,
-  isoiec_9798_2_6_bdkey_P
-}"
-
-locale restricted_isoiec_9798_2_6_bdkey_state = isoiec_9798_2_6_bdkey_state
-
-type_invariant isoiec_9798_2_6_bdkey_msc_typing for isoiec_9798_2_6_bdkey
-where "isoiec_9798_2_6_bdkey_msc_typing = mk_typing
-  [ ((isoiec_9798_2_6_bdkey_P, ''A''), (KnownT isoiec_9798_2_6_bdkey_P_2))
-  , ((isoiec_9798_2_6_bdkey_A, ''B''), (KnownT isoiec_9798_2_6_bdkey_A_1))
-  , ((isoiec_9798_2_6_bdkey_P, ''B''), (KnownT isoiec_9798_2_6_bdkey_P_2))
-  , ((isoiec_9798_2_6_bdkey_A, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_6_bdkey_A_3) (NonceT isoiec_9798_2_6_bdkey_P ''Kab'')))
-  , ((isoiec_9798_2_6_bdkey_B, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_6_bdkey_B_4) (NonceT isoiec_9798_2_6_bdkey_P ''Kab'')))
-  , ((isoiec_9798_2_6_bdkey_B, ''P''), (KnownT isoiec_9798_2_6_bdkey_B_4))
-  , ((isoiec_9798_2_6_bdkey_P, ''Ra''), (KnownT isoiec_9798_2_6_bdkey_P_2))
-  , ((isoiec_9798_2_6_bdkey_A, ''Rb''), (KnownT isoiec_9798_2_6_bdkey_A_1))
-  , ((isoiec_9798_2_6_bdkey_P, ''Rb''), (KnownT isoiec_9798_2_6_bdkey_P_2))
-  , ((isoiec_9798_2_6_bdkey_B, ''Rpa''),
-     (SumT (KnownT isoiec_9798_2_6_bdkey_B_4) (NonceT isoiec_9798_2_6_bdkey_A ''Rpa'')))
-  , ((isoiec_9798_2_6_bdkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_6_bdkey_A_1))
-  , ((isoiec_9798_2_6_bdkey_B, ''Text1''),
-     (KnownT isoiec_9798_2_6_bdkey_B_text_1))
-  , ((isoiec_9798_2_6_bdkey_A, ''Text2''),
-     (KnownT isoiec_9798_2_6_bdkey_A_text_2))
-  , ((isoiec_9798_2_6_bdkey_P, ''Text2''),
-     (KnownT isoiec_9798_2_6_bdkey_P_2))
-  , ((isoiec_9798_2_6_bdkey_B, ''Text3''),
-     (KnownT isoiec_9798_2_6_bdkey_B_4))
-  , ((isoiec_9798_2_6_bdkey_P, ''Text3''),
-     (KnownT isoiec_9798_2_6_bdkey_P_text_3))
-  , ((isoiec_9798_2_6_bdkey_A, ''Text4''),
-     (KnownT isoiec_9798_2_6_bdkey_A_3))
-  , ((isoiec_9798_2_6_bdkey_P, ''Text4''),
-     (KnownT isoiec_9798_2_6_bdkey_P_text_3))
-  , ((isoiec_9798_2_6_bdkey_A, ''Text5''),
-     (KnownT isoiec_9798_2_6_bdkey_A_3))
-  , ((isoiec_9798_2_6_bdkey_P, ''Text5''),
-     (KnownT isoiec_9798_2_6_bdkey_P_text_3))
-  , ((isoiec_9798_2_6_bdkey_A, ''Text6''),
-     (KnownT isoiec_9798_2_6_bdkey_A_text_4))
-  , ((isoiec_9798_2_6_bdkey_B, ''Text6''),
-     (KnownT isoiec_9798_2_6_bdkey_B_4))
-  , ((isoiec_9798_2_6_bdkey_A, ''Text7''),
-     (KnownT isoiec_9798_2_6_bdkey_A_text_4))
-  , ((isoiec_9798_2_6_bdkey_B, ''Text7''),
-     (KnownT isoiec_9798_2_6_bdkey_B_4))
-  , ((isoiec_9798_2_6_bdkey_A, ''Text8''),
-     (KnownT isoiec_9798_2_6_bdkey_A_5))
-  , ((isoiec_9798_2_6_bdkey_B, ''Text8''),
-     (KnownT isoiec_9798_2_6_bdkey_B_text_5))
-  , ((isoiec_9798_2_6_bdkey_A, ''Text9''),
-     (KnownT isoiec_9798_2_6_bdkey_A_5))
-  , ((isoiec_9798_2_6_bdkey_B, ''Text9''),
-     (KnownT isoiec_9798_2_6_bdkey_B_text_5))
-  , ((isoiec_9798_2_6_bdkey_A, ''TokenPA_for_B''),
-     (KnownT isoiec_9798_2_6_bdkey_A_3))
-  ]"
-
-sublocale isoiec_9798_2_6_bdkey_state < isoiec_9798_2_6_bdkey_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_2_6_bdkey_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_2_6_bdkey_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_2_6_bdkey_A_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_A_1_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_A_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_A_3_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
-               s(MV ''Text4'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_bdkey_A_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
-               s(MV ''Text4'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_bdkey_A_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_A_3_TokenPA_for_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_A_text_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_A_text_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_A_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_5'', s(MV ''Rb'' tid0), LN ''Rpa'' tid0,
-               s(MV ''Text8'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_bdkey_A_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_B_4_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
-               s(MV ''Text3'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_bdkey_B_4_P t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_B_4_Rpa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
-               s(MV ''Text6'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_bdkey_B_4_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
-               s(MV ''Text3'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_bdkey_B_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
-               s(MV ''Text6'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_bdkey_B_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_B_text_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_B_text_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_P_2_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_P_2_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_P_2_Ra t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_P_2_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_P_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_P_text_3_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_P_text_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_bdkey_P_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_2_6_bdkey_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_2_6_bdkey_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_2_6_bdkey_state) P_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_bdkey_P"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "LN ''Kab'' tid0 : knows t"
-  shows "False"
-using facts proof(sources! " LN ''Kab'' tid0 ")
-  case isoiec_9798_2_6_bdkey_P_3_Kab note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-next
-  case isoiec_9798_2_6_bdkey_P_3_Kab_1 note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-qed (insert facts, fastsimp+)?
-
-lemma (in restricted_isoiec_9798_2_6_bdkey_state) A_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_bdkey_A_3 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
-                          s(MV ''Text4'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_bdkey_P_3_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_6_bdkey_state) B_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_bdkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_bdkey_B_4 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
-                          s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_6_bdkey_state) A_non_injective_agreement_B:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_bdkey_A_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_bdkey_B &
-        ( tid1, isoiec_9798_2_6_bdkey_B_5 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
-           s(MV ''Kab'' tid1), s(MV ''Rpa'' tid1), LN ''Rb'' tid1,
-           s(MV ''Text6'' tid1), s(MV ''Text8'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
-                s(MV ''Kab'' tid0), LN ''Rpa'' tid0, s(MV ''Rb'' tid0),
-                s(MV ''Text6'' tid0), s(MV ''Text8'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
-                          s(MV ''Text4'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_bdkey_P_3_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_2_6_enc_5'', s(MV ''Rb'' tid0), LN ''Rpa'' tid0,
-                            s(MV ''Text8'' tid0)
-                         |}
-                         ( LN ''Kab'' tid1 ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-    next
-      case (isoiec_9798_2_6_bdkey_B_5_enc tid2) note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid2, LN ''Kab'' tid1,
-                              s(AV ''A'' tid2), s(AV ''B'' tid2), s(MV ''Text3'' tid2)
-                           |}
-                           ( Kbd ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_6_bdkey_P_3_enc_1 tid3) note_unified facts = this facts
-        thus ?thesis proof(sources! "
-                         Enc {| LC ''isoiec_9798_2_6_enc_4'', LN ''Rpa'' tid0, LN ''Rb'' tid2,
-                                s(MV ''Text6'' tid2)
-                             |}
-                             ( LN ''Kab'' tid1 ) ")
-          case fake note_unified facts = this facts
-          thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-        next
-          case (isoiec_9798_2_6_bdkey_A_4_enc tid3) note_unified facts = this facts
-          thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-        qed (insert facts, fastsimp+)?
-      qed (insert facts, fastsimp+)?
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_6_bdkey_state) B_non_injective_agreement_A:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_bdkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_bdkey_B_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_bdkey_A &
-        ( tid1, isoiec_9798_2_6_bdkey_A_4 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Kab'' tid1), LN ''Rpa'' tid1, s(MV ''Rb'' tid1),
-           s(MV ''Text6'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                s(MV ''Kab'' tid0), s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
-                s(MV ''Text6'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
-                          s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
-                            s(MV ''Text6'' tid0)
-                         |}
-                         ( LN ''Kab'' tid1 ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-    next
-      case (isoiec_9798_2_6_bdkey_A_4_enc tid2) note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid2, LN ''Kab'' tid1,
-                              s(AV ''A'' tid2), s(MV ''B'' tid2), s(MV ''Text4'' tid2)
-                           |}
-                           ( Kbd ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_6_bdkey_P_3_enc tid3) note_unified facts = this facts
-        thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-      qed (insert facts, fastsimp+)?
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_6_bdkey_state) A_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_bdkey_A_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_bdkey_P &
-        ( tid1, isoiec_9798_2_6_bdkey_P_3 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Ra'' tid1), LN ''Kab'' tid1, s(MV ''Text4'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
-                LN ''Ra'' tid0, s(MV ''Kab'' tid0), s(MV ''Text4'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
-                          s(MV ''Text4'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_bdkey_P_3_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_6_bdkey_state) B_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_bdkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_bdkey_B_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_bdkey_P &
-        ( tid1, isoiec_9798_2_6_bdkey_P_3 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Rb'' tid1), LN ''Kab'' tid1, s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                LN ''Rb'' tid0, s(MV ''Kab'' tid0), s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
-                          s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-role isoiec_9798_2_5_special_TTP_bdkey_A
-where "isoiec_9798_2_5_special_TTP_bdkey_A =
-  [ Send ''leak_A'' <| sN ''TVPa'', sN ''TNa'' |>
-  , Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''A'', sAV ''P'', sN ''TVPa'', sAV ''B'',
-                  sMV ''Text1''
-               |>
-  , Recv ''2'' <| sAV ''P'', sAV ''A'', sMV ''Text4'',
-                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_2_1'', sN ''TVPa'',
-                          sMV ''Kab'', sAV ''B'', sMV ''Text3''
-                       |>
-                       ( sKbd (AVar ''A'') (AVar ''P'') ),
-                  sMV ''TokenPA_for_B''
-               |>
-  , Recv ''text_3'' <| sMV ''Text5'', sMV ''Text6'' |>
-  , Send ''3'' <| sAV ''A'', sAV ''B'', sMV ''Text6'', sAV ''P'',
-                  sMV ''TokenPA_for_B'',
-                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_3'', sN ''TNa'', sAV ''B'',
-                          sMV ''Text5''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''4'' <| sAV ''B'', sAV ''A'', sMV ''Text8'',
-                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_4'', sMV ''TNb'', sAV ''A'',
-                          sMV ''Text7''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_5_special_TTP_bdkey_B
-where "isoiec_9798_2_5_special_TTP_bdkey_B =
-  [ Send ''leak_B'' ( sN ''TNb'' )
-  , Recv ''3'' <| sMV ''A'', sAV ''B'', sMV ''Text6'', sMV ''P'',
-                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_2_2'', sMV ''TNp'',
-                          sMV ''Kab'', sMV ''A'', sMV ''Text2''
-                       |>
-                       ( sKbd (AVar ''B'') (MVar ''P'') ),
-                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_3'', sMV ''TNa'', sAV ''B'',
-                          sMV ''Text5''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''text_4'' <| sMV ''Text7'', sMV ''Text8'' |>
-  , Send ''4'' <| sAV ''B'', sMV ''A'', sMV ''Text8'',
-                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_4'', sN ''TNb'', sMV ''A'',
-                          sMV ''Text7''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_5_special_TTP_bdkey_P
-where "isoiec_9798_2_5_special_TTP_bdkey_P =
-  [ Send ''leak_P'' ( sN ''TNp'' )
-  , Recv ''1'' <| sMV ''A'', sAV ''P'', sMV ''TVPa'', sMV ''B'',
-                  sMV ''Text1''
-               |>
-  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'', sMV ''Text4'' |>
-  , Send ''2'' <| sAV ''P'', sMV ''A'', sMV ''Text4'',
-                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_2_1'', sMV ''TVPa'',
-                          sN ''Kab'', sMV ''B'', sMV ''Text3''
-                       |>
-                       ( sKbd (MVar ''A'') (AVar ''P'') ),
-                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_2_2'', sN ''TNp'',
-                          sN ''Kab'', sMV ''A'', sMV ''Text2''
-                       |>
-                       ( sKbd (MVar ''B'') (AVar ''P'') )
-               |>
-  ]"
-
-protocol isoiec_9798_2_5_special_TTP_bdkey
-where "isoiec_9798_2_5_special_TTP_bdkey =
-{ isoiec_9798_2_5_special_TTP_bdkey_A,
-  isoiec_9798_2_5_special_TTP_bdkey_B, isoiec_9798_2_5_special_TTP_bdkey_P
-}"
-
-locale restricted_isoiec_9798_2_5_special_TTP_bdkey_state = isoiec_9798_2_5_special_TTP_bdkey_state +
-  assumes different_actors_A_P:
-    "!! tid0 tid1.
-       [| roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_A;
-         roleMap r tid1 = Some isoiec_9798_2_5_special_TTP_bdkey_P;
-         s(AV ''P'' tid1) = s(AV ''A'' tid0)
-       |] ==> False"
-
-type_invariant isoiec_9798_2_5_special_TTP_bdkey_msc_typing for isoiec_9798_2_5_special_TTP_bdkey
-where "isoiec_9798_2_5_special_TTP_bdkey_msc_typing = mk_typing
-  [ ((isoiec_9798_2_5_special_TTP_bdkey_B, ''A''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''A''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_1))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''B''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_1))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_2) (NonceT isoiec_9798_2_5_special_TTP_bdkey_P ''Kab'')))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3) (NonceT isoiec_9798_2_5_special_TTP_bdkey_P ''Kab'')))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''P''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''TNa''),
-     (SumT (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3) (NonceT isoiec_9798_2_5_special_TTP_bdkey_A ''TNa'')))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''TNb''),
-     (SumT (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_4) (NonceT isoiec_9798_2_5_special_TTP_bdkey_B ''TNb'')))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''TNp''),
-     (SumT (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3) (NonceT isoiec_9798_2_5_special_TTP_bdkey_P ''TNp'')))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''TVPa''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_1))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_text_1))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''Text1''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_1))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Text2''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''Text2''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_text_2))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text3''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_2))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''Text3''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_text_2))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text4''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_2))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''Text4''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_text_2))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text5''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_text_3))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Text5''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text6''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_text_3))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Text6''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text7''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_4))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Text7''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_text_4))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text8''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_4))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Text8''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_text_4))
-  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''TokenPA_for_B''),
-     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_2))
-  ]"
-
-sublocale isoiec_9798_2_5_special_TTP_bdkey_state < isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_2_5_special_TTP_bdkey_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_2_5_special_TTP_bdkey_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_2_5_special_TTP_bdkey_A_2_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_A_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_A_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_A_2_TokenPA_for_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_A_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_A_text_3_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_A_4_TNb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_4'', s(MV ''TNb'' tid0),
-               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_A_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_4'', s(MV ''TNb'' tid0),
-               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_A_4_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
-               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_P t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_TNa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_3'', s(MV ''TNa'' tid0),
-               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_TNp t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
-               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
-               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_3'', s(MV ''TNa'' tid0),
-               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_B_text_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_B_text_4_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_1_TVPa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_text_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_text_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_2_5_special_TTP_bdkey_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-
-lemma (in restricted_isoiec_9798_2_5_special_TTP_bdkey_state) P_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_P"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "LN ''Kab'' tid0 : knows t"
-  shows "False"
-using facts proof(sources! " LN ''Kab'' tid0 ")
-  case isoiec_9798_2_5_special_TTP_bdkey_P_2_Kab note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-next
-  case isoiec_9798_2_5_special_TTP_bdkey_P_2_Kab_1 note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-qed (insert facts, fastsimp+)?
-
-lemma (in restricted_isoiec_9798_2_5_special_TTP_bdkey_state) A_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_special_TTP_bdkey_A_2 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''P'' tid1) )
-               ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: different_actors_A_P intro: event_predOrdI)
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_5_special_TTP_bdkey_state) B_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_special_TTP_bdkey_B_3 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
-                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc_1 tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''P'' tid1) )
-               ( s(MV ''B'' tid1) ) = Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_5_special_TTP_bdkey_state) A_non_injective_agreement_B:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_special_TTP_bdkey_A_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_special_TTP_bdkey_B &
-        ( tid1, isoiec_9798_2_5_special_TTP_bdkey_B_4 ) : steps t &
-        {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
-           s(MV ''Kab'' tid1), s(MV ''TNa'' tid1), s(MV ''Text5'' tid1),
-           LN ''TNb'' tid1, s(MV ''Text7'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
-                s(MV ''Kab'' tid0), LN ''TNa'' tid0, s(MV ''Text5'' tid0),
-                s(MV ''TNb'' tid0), s(MV ''Text7'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''P'' tid1) )
-               ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: different_actors_A_P intro: event_predOrdI)
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_4'', s(MV ''TNb'' tid0),
-                              s(AV ''A'' tid0), s(MV ''Text7'' tid0)
-                           |}
-                           ( LN ''Kab'' tid1 ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_5_special_TTP_bdkey_B_4_enc tid2) note_unified facts = this facts
-        thus ?thesis proof(sources! "
-                         Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_3'', s(MV ''TNa'' tid2),
-                                s(AV ''B'' tid2), s(MV ''Text5'' tid2)
-                             |}
-                             ( LN ''Kab'' tid1 ) ")
-          case fake note_unified facts = this facts
-          thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-        next
-          case (isoiec_9798_2_5_special_TTP_bdkey_A_3_enc tid3) note_unified facts = this facts
-          thus ?thesis proof(sources! "
-                           Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid3,
-                                  LN ''Kab'' tid1, s(AV ''B'' tid2), s(MV ''Text3'' tid3)
-                               |}
-                               ( Kbd ( s(AV ''A'' tid3) ) ( s(AV ''P'' tid3) ) ) ")
-            case fake note_unified facts = this facts
-            thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-          next
-            case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid4) note_unified facts = this facts
-            thus ?thesis proof(sources! "
-                             Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid2),
-                                    LN ''Kab'' tid1, s(AV ''A'' tid0), s(MV ''Text2'' tid2)
-                                 |}
-                                 ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid2) ) ) ")
-              case fake note_unified facts = this facts
-              thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-            next
-              case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc_1 tid3) note_unified facts = this facts
-              thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-            qed (insert facts, fastsimp+)?
-          qed (insert facts, fastsimp+)?
-        qed (insert facts, fastsimp+)?
-      qed (insert facts, fastsimp+)?
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_5_special_TTP_bdkey_state) B_non_injective_agreement_A:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_special_TTP_bdkey_B_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_special_TTP_bdkey_A &
-        ( tid1, isoiec_9798_2_5_special_TTP_bdkey_A_3 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Kab'' tid1), LN ''TNa'' tid1, s(MV ''Text5'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                s(MV ''Kab'' tid0), s(MV ''TNa'' tid0), s(MV ''Text5'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_3'', s(MV ''TNa'' tid0),
-                          s(AV ''B'' tid0), s(MV ''Text5'' tid0)
-                       |}
-                       ( s(MV ''Kab'' tid0) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest: B_secret_Kab intro: event_predOrdI)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_A_3_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid1,
-                            s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid1)
-                         |}
-                         ( Kbd ( s(AV ''A'' tid1) ) ( s(AV ''P'' tid1) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: B_secret_Kab intro: event_predOrdI)
-    next
-      case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid2) note_unified facts = this facts
-      hence "Kbd ( s(AV ''P'' tid2) )
-                 ( s(MV ''A'' tid2) ) = Kbd ( s(AV ''A'' tid1) ) ( s(AV ''P'' tid1) )"
-        by simp note facts = this facts
-      thus ?thesis proof(cases rule: Kbd_cases)
-        case noswap note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: different_actors_A_P intro: event_predOrdI)
-      next
-        case swapped note_unified facts = this facts
-        thus ?thesis proof(sources! "
-                         Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
-                                LN ''Kab'' tid2, s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-                             |}
-                             ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-          case fake note_unified facts = this facts
-          thus ?thesis by (fastsimp dest!: ltk_secrecy)
-        next
-          case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc_1 tid3) note_unified facts = this facts
-          thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-        qed (insert facts, fastsimp+)?
-      qed (fastsimp+)?
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_5_special_TTP_bdkey_state) A_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_special_TTP_bdkey_A_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_special_TTP_bdkey_P &
-        ( tid1, isoiec_9798_2_5_special_TTP_bdkey_P_2 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
-           s(MV ''TVPa'' tid1), s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
-                s(MV ''Kab'' tid0), LN ''TVPa'' tid0, s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''P'' tid1) )
-               ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: different_actors_A_P intro: event_predOrdI)
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_5_special_TTP_bdkey_state) B_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_special_TTP_bdkey_B_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_special_TTP_bdkey_P &
-        ( tid1, isoiec_9798_2_5_special_TTP_bdkey_P_2 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
-           LN ''TNp'' tid1, s(MV ''Text2'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                s(MV ''Kab'' tid0), s(MV ''TNp'' tid0), s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
-                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc_1 tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''P'' tid1) )
-               ( s(MV ''B'' tid1) ) = Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_3'', s(MV ''TNa'' tid0),
-                              s(AV ''B'' tid0), s(MV ''Text5'' tid0)
-                           |}
-                           ( LN ''Kab'' tid1 ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_5_special_TTP_bdkey_A_3_enc tid2) note_unified facts = this facts
-        thus ?thesis proof(sources! "
-                         Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid2,
-                                LN ''Kab'' tid1, s(AV ''B'' tid0), s(MV ''Text3'' tid2)
-                             |}
-                             ( Kbd ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
-          case fake note_unified facts = this facts
-          thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-        next
-          case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid3) note_unified facts = this facts
-          thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-        qed (insert facts, fastsimp+)?
-      qed (insert facts, fastsimp+)?
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-role isoiec_9798_2_6_special_TTP_bdkey_A
-where "isoiec_9798_2_6_special_TTP_bdkey_A =
-  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
-  , Recv ''text_2'' ( sMV ''Text2'' )
-  , Send ''2'' <| sAV ''A'', sAV ''P'', sN ''Ra'', sMV ''Rb'', sMV ''B'',
-                  sMV ''Text2''
-               |>
-  , Recv ''3'' <| sAV ''P'', sAV ''A'', sMV ''Text5'',
-                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_3_1'', sN ''Ra'',
-                          sMV ''Kab'', sMV ''B'', sMV ''Text4''
-                       |>
-                       ( sKbd (AVar ''A'') (AVar ''P'') ),
-                  sMV ''TokenPA_for_B''
-               |>
-  , Recv ''text_4'' <| sMV ''Text6'', sMV ''Text7'' |>
-  , Send ''4'' <| sAV ''A'', sMV ''B'', sMV ''Text7'', sAV ''P'',
-                  sMV ''TokenPA_for_B'',
-                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_4'', sN ''Rpa'', sMV ''Rb'',
-                          sMV ''Text6''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''5'' <| sMV ''B'', sAV ''A'', sMV ''Text9'',
-                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_5'', sMV ''Rb'', sN ''Rpa'',
-                          sMV ''Text8''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_6_special_TTP_bdkey_B
-where "isoiec_9798_2_6_special_TTP_bdkey_B =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
-  , Recv ''4'' <| sAV ''A'', sAV ''B'', sMV ''Text7'', sMV ''P'',
-                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_3_2'', sN ''Rb'',
-                          sMV ''Kab'', sAV ''A'', sMV ''Text3''
-                       |>
-                       ( sKbd (AVar ''B'') (MVar ''P'') ),
-                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_4'', sMV ''Rpa'', sN ''Rb'',
-                          sMV ''Text6''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
-  , Send ''5'' <| sAV ''B'', sAV ''A'', sMV ''Text9'',
-                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_5'', sN ''Rb'', sMV ''Rpa'',
-                          sMV ''Text8''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_6_special_TTP_bdkey_P
-where "isoiec_9798_2_6_special_TTP_bdkey_P =
-  [ Recv ''2'' <| sMV ''A'', sAV ''P'', sMV ''Ra'', sMV ''Rb'', sMV ''B'',
-                  sMV ''Text2''
-               |>
-  , Recv ''text_3'' <| sMV ''Text3'', sMV ''Text4'', sMV ''Text5'' |>
-  , Send ''3'' <| sAV ''P'', sMV ''A'', sMV ''Text5'',
-                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_3_1'', sMV ''Ra'',
-                          sN ''Kab'', sMV ''B'', sMV ''Text4''
-                       |>
-                       ( sKbd (MVar ''A'') (AVar ''P'') ),
-                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_3_2'', sMV ''Rb'',
-                          sN ''Kab'', sMV ''A'', sMV ''Text3''
-                       |>
-                       ( sKbd (MVar ''B'') (AVar ''P'') )
-               |>
-  ]"
-
-protocol isoiec_9798_2_6_special_TTP_bdkey
-where "isoiec_9798_2_6_special_TTP_bdkey =
-{ isoiec_9798_2_6_special_TTP_bdkey_A,
-  isoiec_9798_2_6_special_TTP_bdkey_B, isoiec_9798_2_6_special_TTP_bdkey_P
-}"
-
-locale restricted_isoiec_9798_2_6_special_TTP_bdkey_state = isoiec_9798_2_6_special_TTP_bdkey_state +
-  assumes different_actors_A_P:
-    "!! tid0 tid1.
-       [| roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_A;
-         roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_P;
-         s(AV ''P'' tid1) = s(AV ''A'' tid0)
-       |] ==> False"
-  assumes different_actors_B_P:
-    "!! tid0 tid1.
-       [| roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_B;
-         roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_P;
-         s(AV ''P'' tid1) = s(AV ''B'' tid0)
-       |] ==> False"
-
-type_invariant isoiec_9798_2_6_special_TTP_bdkey_msc_typing for isoiec_9798_2_6_special_TTP_bdkey
-where "isoiec_9798_2_6_special_TTP_bdkey_msc_typing = mk_typing
-  [ ((isoiec_9798_2_6_special_TTP_bdkey_P, ''A''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_2))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''B''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_1))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''B''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_2))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_3) (NonceT isoiec_9798_2_6_special_TTP_bdkey_P ''Kab'')))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4) (NonceT isoiec_9798_2_6_special_TTP_bdkey_P ''Kab'')))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''P''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Ra''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_2))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Rb''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_1))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Rb''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_2))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Rpa''),
-     (SumT (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4) (NonceT isoiec_9798_2_6_special_TTP_bdkey_A ''Rpa'')))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_1))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text1''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_text_1))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text2''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_text_2))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Text2''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_2))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text3''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Text3''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_text_3))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text4''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_3))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Text4''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_text_3))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text5''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_3))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Text5''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_text_3))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text6''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_text_4))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text6''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text7''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_text_4))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text7''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text8''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_5))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text8''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_text_5))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text9''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_5))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text9''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_text_5))
-  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''TokenPA_for_B''),
-     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_3))
-  ]"
-
-sublocale isoiec_9798_2_6_special_TTP_bdkey_state < isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_2_6_special_TTP_bdkey_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_2_6_special_TTP_bdkey_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_2_6_special_TTP_bdkey_A_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_A_1_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_A_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_A_3_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid0,
-               s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_A_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid0,
-               s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
-            |}
-            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_A_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_A_3_TokenPA_for_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_A_text_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_A_text_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_A_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_5'', s(MV ''Rb'' tid0),
-               LN ''Rpa'' tid0, s(MV ''Text8'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_A_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_P t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_Rpa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_4'', s(MV ''Rpa'' tid0),
-               LN ''Rb'' tid0, s(MV ''Text6'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-            |}
-            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_4'', s(MV ''Rpa'' tid0),
-               LN ''Rb'' tid0, s(MV ''Text6'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_B_text_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_B_text_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_2_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_2_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_2_Ra t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_2_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_text_3_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_text_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_2_6_special_TTP_bdkey_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-
-
-lemma (in restricted_isoiec_9798_2_6_special_TTP_bdkey_state) P_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_P"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "LN ''Kab'' tid0 : knows t"
-  shows "False"
-using facts proof(sources! " LN ''Kab'' tid0 ")
-  case isoiec_9798_2_6_special_TTP_bdkey_P_3_Kab note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-next
-  case isoiec_9798_2_6_special_TTP_bdkey_P_3_Kab_1 note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-qed (insert facts, fastsimp+)?
-
-lemma (in restricted_isoiec_9798_2_6_special_TTP_bdkey_state) A_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_special_TTP_bdkey_A_3 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid0,
-                          s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''P'' tid1) )
-               ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: different_actors_A_P intro: event_predOrdI)
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_6_special_TTP_bdkey_state) B_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_special_TTP_bdkey_B_4 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''P'' tid1) )
-               ( s(MV ''B'' tid1) ) = Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: different_actors_B_P intro: event_predOrdI)
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_6_special_TTP_bdkey_state) A_non_injective_agreement_B:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_special_TTP_bdkey_A_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_B &
-        ( tid1, isoiec_9798_2_6_special_TTP_bdkey_B_5 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
-           s(MV ''Kab'' tid1), s(MV ''Rpa'' tid1), LN ''Rb'' tid1,
-           s(MV ''Text6'' tid1), s(MV ''Text8'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
-                s(MV ''Kab'' tid0), LN ''Rpa'' tid0, s(MV ''Rb'' tid0),
-                s(MV ''Text6'' tid0), s(MV ''Text8'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid0,
-                          s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''P'' tid1) )
-               ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: different_actors_A_P intro: event_predOrdI)
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_5'', s(MV ''Rb'' tid0),
-                              LN ''Rpa'' tid0, s(MV ''Text8'' tid0)
-                           |}
-                           ( LN ''Kab'' tid1 ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_6_special_TTP_bdkey_B_5_enc tid2) note_unified facts = this facts
-        thus ?thesis proof(sources! "
-                         Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid2,
-                                LN ''Kab'' tid1, s(AV ''A'' tid2), s(MV ''Text3'' tid2)
-                             |}
-                             ( Kbd ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) ) ) ")
-          case fake note_unified facts = this facts
-          thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-        next
-          case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc_1 tid3) note_unified facts = this facts
-          hence "Kbd ( s(AV ''P'' tid0) )
-                     ( s(MV ''B'' tid0) ) = Kbd ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) )"
-            by simp note facts = this facts
-          thus ?thesis proof(cases rule: Kbd_cases)
-            case noswap note_unified facts = this facts
-            thus ?thesis by (fastsimp dest: different_actors_B_P intro: event_predOrdI)
-          next
-            case swapped note_unified facts = this facts
-            thus ?thesis proof(sources! "
-                             Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_4'', LN ''Rpa'' tid0,
-                                    LN ''Rb'' tid2, s(MV ''Text6'' tid2)
-                                 |}
-                                 ( LN ''Kab'' tid1 ) ")
-              case fake note_unified facts = this facts
-              thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-            next
-              case (isoiec_9798_2_6_special_TTP_bdkey_A_4_enc tid3) note_unified facts = this facts
-              thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-            qed (insert facts, fastsimp+)?
-          qed (fastsimp+)?
-        qed (insert facts, fastsimp+)?
-      qed (insert facts, fastsimp+)?
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_6_special_TTP_bdkey_state) B_non_injective_agreement_A:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_special_TTP_bdkey_B_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_A &
-        ( tid1, isoiec_9798_2_6_special_TTP_bdkey_A_4 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Kab'' tid1), LN ''Rpa'' tid1, s(MV ''Rb'' tid1),
-           s(MV ''Text6'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                s(MV ''Kab'' tid0), s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
-                s(MV ''Text6'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''P'' tid1) )
-               ( s(MV ''B'' tid1) ) = Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: different_actors_B_P intro: event_predOrdI)
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_4'', s(MV ''Rpa'' tid0),
-                              LN ''Rb'' tid0, s(MV ''Text6'' tid0)
-                           |}
-                           ( LN ''Kab'' tid1 ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_6_special_TTP_bdkey_A_4_enc tid2) note_unified facts = this facts
-        thus ?thesis proof(sources! "
-                         Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid2,
-                                LN ''Kab'' tid1, s(MV ''B'' tid2), s(MV ''Text4'' tid2)
-                             |}
-                             ( Kbd ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
-          case fake note_unified facts = this facts
-          thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-        next
-          case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc tid3) note_unified facts = this facts
-          hence "Kbd ( s(AV ''A'' tid2) )
-                     ( s(AV ''P'' tid2) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid1) )"
-            by simp note facts = this facts
-          thus ?thesis proof(cases rule: Kbd_cases)
-            case noswap note_unified facts = this facts
-            thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-          next
-            case swapped note_unified facts = this facts
-            thus ?thesis by (fastsimp dest: different_actors_A_P intro: event_predOrdI)
-          qed (fastsimp+)?
-        qed (insert facts, fastsimp+)?
-      qed (insert facts, fastsimp+)?
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_6_special_TTP_bdkey_state) A_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_special_TTP_bdkey_A_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_P &
-        ( tid1, isoiec_9798_2_6_special_TTP_bdkey_P_3 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Ra'' tid1), LN ''Kab'' tid1, s(MV ''Text4'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
-                LN ''Ra'' tid0, s(MV ''Kab'' tid0), s(MV ''Text4'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid0,
-                          s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''P'' tid1) )
-               ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: different_actors_A_P intro: event_predOrdI)
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_6_special_TTP_bdkey_state) B_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_special_TTP_bdkey_B_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_P &
-        ( tid1, isoiec_9798_2_6_special_TTP_bdkey_P_3 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Rb'' tid1), LN ''Kab'' tid1, s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                LN ''Rb'' tid0, s(MV ''Kab'' tid0), s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''P'' tid1) )
-               ( s(MV ''B'' tid1) ) = Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: different_actors_B_P intro: event_predOrdI)
-    next
-      case swapped note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
+  "ESPLogic"
+begin
+
+role isoiec_9798_2_1_bdkey_A
+where "isoiec_9798_2_1_bdkey_A =
+  [ Send ''leak_A'' ( sN ''TNA'' )
+  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
+  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
+                  PEnc <| sC ''isoiec_9798_2_1_enc_1'', sN ''TNA'', sAV ''B'',
+                          sMV ''Text1''
+                       |>
+                       ( sKbd (AVar ''A'') (AVar ''B'') )
+               |>
+  ]"
+
+role isoiec_9798_2_1_bdkey_B
+where "isoiec_9798_2_1_bdkey_B =
+  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
+                  PEnc <| sC ''isoiec_9798_2_1_enc_1'', sMV ''TNA'', sAV ''B'',
+                          sMV ''Text1''
+                       |>
+                       ( sKbd (MVar ''A'') (AVar ''B'') )
+               |>
+  ]"
+
+protocol isoiec_9798_2_1_bdkey
+where "isoiec_9798_2_1_bdkey =
+{ isoiec_9798_2_1_bdkey_A, isoiec_9798_2_1_bdkey_B }"
+
+locale restricted_isoiec_9798_2_1_bdkey_state = isoiec_9798_2_1_bdkey_state
+
+type_invariant isoiec_9798_2_1_bdkey_msc_typing for isoiec_9798_2_1_bdkey
+where "isoiec_9798_2_1_bdkey_msc_typing = mk_typing
+  [ ((isoiec_9798_2_1_bdkey_B, ''A''), (KnownT isoiec_9798_2_1_bdkey_B_1))
+  , ((isoiec_9798_2_1_bdkey_B, ''TNA''),
+     (SumT (KnownT isoiec_9798_2_1_bdkey_B_1) (NonceT isoiec_9798_2_1_bdkey_A ''TNA'')))
+  , ((isoiec_9798_2_1_bdkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_1_bdkey_A_text_1))
+  , ((isoiec_9798_2_1_bdkey_B, ''Text1''),
+     (KnownT isoiec_9798_2_1_bdkey_B_1))
+  , ((isoiec_9798_2_1_bdkey_A, ''Text2''),
+     (KnownT isoiec_9798_2_1_bdkey_A_text_1))
+  , ((isoiec_9798_2_1_bdkey_B, ''Text2''),
+     (KnownT isoiec_9798_2_1_bdkey_B_1))
+  ]"
+
+sublocale isoiec_9798_2_1_bdkey_state < isoiec_9798_2_1_bdkey_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_2_1_bdkey_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_2_1_bdkey_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_2_1_bdkey_A_text_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_1_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_1_bdkey_A_text_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_1_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_1_bdkey_B_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_1_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_1_bdkey_B_1_TNA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_1_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
+               s(AV ''B'' tid0), s(MV ''Text1'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_1_bdkey_B_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_1_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
+               s(AV ''B'' tid0), s(MV ''Text1'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_1_bdkey_B_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_1_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_2_1_bdkey_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_2_1_bdkey_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_2_1_bdkey_state) B_non_injective_agreement:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_1_bdkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_1_bdkey_B_1 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_1_bdkey_A &
+        ( tid1, isoiec_9798_2_1_bdkey_A_1 ) : steps t &
+        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
+           s(MV ''Text1'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
+                s(MV ''Text1'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
+                          s(AV ''B'' tid0), s(MV ''Text1'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_1_bdkey_A_1_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
+qed
+
+role isoiec_9798_2_2_bdkey_A
+where "isoiec_9798_2_2_bdkey_A =
+  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text1'' |>
+  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
+  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
+                  PEnc <| sC ''isoiec_9798_2_2_enc_2'', sMV ''RB'', sMV ''B'',
+                          sMV ''Text2''
+                       |>
+                       ( sKbd (MVar ''B'') (AVar ''A'') )
+               |>
+  ]"
+
+role isoiec_9798_2_2_bdkey_B
+where "isoiec_9798_2_2_bdkey_B =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''RB'', sMV ''Text1'' |>
+  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
+                  PEnc <| sC ''isoiec_9798_2_2_enc_2'', sN ''RB'', sAV ''B'', sMV ''Text2''
+                       |>
+                       ( sKbd (AVar ''B'') (AVar ''A'') )
+               |>
+  ]"
+
+protocol isoiec_9798_2_2_bdkey
+where "isoiec_9798_2_2_bdkey =
+{ isoiec_9798_2_2_bdkey_A, isoiec_9798_2_2_bdkey_B }"
+
+locale restricted_isoiec_9798_2_2_bdkey_state = isoiec_9798_2_2_bdkey_state
+
+type_invariant isoiec_9798_2_2_bdkey_msc_typing for isoiec_9798_2_2_bdkey
+where "isoiec_9798_2_2_bdkey_msc_typing = mk_typing
+  [ ((isoiec_9798_2_2_bdkey_A, ''B''), (KnownT isoiec_9798_2_2_bdkey_A_1))
+  , ((isoiec_9798_2_2_bdkey_A, ''RB''), (KnownT isoiec_9798_2_2_bdkey_A_1))
+  , ((isoiec_9798_2_2_bdkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_2_bdkey_A_1))
+  , ((isoiec_9798_2_2_bdkey_B, ''Text1''),
+     (KnownT isoiec_9798_2_2_bdkey_B_text_1))
+  , ((isoiec_9798_2_2_bdkey_A, ''Text2''),
+     (KnownT isoiec_9798_2_2_bdkey_A_text_2))
+  , ((isoiec_9798_2_2_bdkey_B, ''Text2''),
+     (KnownT isoiec_9798_2_2_bdkey_B_2))
+  , ((isoiec_9798_2_2_bdkey_A, ''Text3''),
+     (KnownT isoiec_9798_2_2_bdkey_A_text_2))
+  , ((isoiec_9798_2_2_bdkey_B, ''Text3''),
+     (KnownT isoiec_9798_2_2_bdkey_B_2))
+  ]"
+
+sublocale isoiec_9798_2_2_bdkey_state < isoiec_9798_2_2_bdkey_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_2_2_bdkey_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_2_2_bdkey_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_2_2_bdkey_A_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_2_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_2_bdkey_A_1_RB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_2_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_2_bdkey_A_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_2_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_2_bdkey_A_text_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_2_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_2_bdkey_A_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_2_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_2_bdkey_B_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_2_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_2_enc_2'', LN ''RB'' tid0, s(AV ''B'' tid0),
+               s(MV ''Text2'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_2_bdkey_B_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_2_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_2_2_bdkey_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_2_2_bdkey_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_2_2_bdkey_state) B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_2_bdkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_2_bdkey_B_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_2_bdkey_A &
+          ( tid1, isoiec_9798_2_2_bdkey_A_2 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(MV ''RB'' tid1),
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''RB'' tid0,
+                  s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_2_enc_2'', LN ''RB'' tid0, s(AV ''B'' tid0),
+                              s(MV ''Text2'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_2_bdkey_A_2_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+role isoiec_9798_2_3_bdkey_A
+where "isoiec_9798_2_3_bdkey_A =
+  [ Send ''leak_A'' ( sN ''TNA'' )
+  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
+  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
+                  PEnc <| sC ''isoiec_9798_2_3_enc_1'', sN ''TNA'', sAV ''B'',
+                          sMV ''Text1''
+                       |>
+                       ( sKbd (AVar ''A'') (AVar ''B'') )
+               |>
+  , Recv ''2'' <| sAV ''B'', sAV ''A'', sMV ''Text4'',
+                  PEnc <| sC ''isoiec_9798_2_3_enc_2'', sMV ''TNB'', sAV ''A'',
+                          sMV ''Text3''
+                       |>
+                       ( sKbd (AVar ''B'') (AVar ''A'') )
+               |>
+  ]"
+
+role isoiec_9798_2_3_bdkey_B
+where "isoiec_9798_2_3_bdkey_B =
+  [ Send ''leak_B'' ( sN ''TNB'' )
+  , Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
+                  PEnc <| sC ''isoiec_9798_2_3_enc_1'', sMV ''TNA'', sAV ''B'',
+                          sMV ''Text1''
+                       |>
+                       ( sKbd (MVar ''A'') (AVar ''B'') )
+               |>
+  , Recv ''text_2'' <| sMV ''Text3'', sMV ''Text4'' |>
+  , Send ''2'' <| sAV ''B'', sMV ''A'', sMV ''Text4'',
+                  PEnc <| sC ''isoiec_9798_2_3_enc_2'', sN ''TNB'', sMV ''A'',
+                          sMV ''Text3''
+                       |>
+                       ( sKbd (AVar ''B'') (MVar ''A'') )
+               |>
+  ]"
+
+protocol isoiec_9798_2_3_bdkey
+where "isoiec_9798_2_3_bdkey =
+{ isoiec_9798_2_3_bdkey_A, isoiec_9798_2_3_bdkey_B }"
+
+locale restricted_isoiec_9798_2_3_bdkey_state = isoiec_9798_2_3_bdkey_state
+
+type_invariant isoiec_9798_2_3_bdkey_msc_typing for isoiec_9798_2_3_bdkey
+where "isoiec_9798_2_3_bdkey_msc_typing = mk_typing
+  [ ((isoiec_9798_2_3_bdkey_B, ''A''), (KnownT isoiec_9798_2_3_bdkey_B_1))
+  , ((isoiec_9798_2_3_bdkey_B, ''TNA''),
+     (SumT (KnownT isoiec_9798_2_3_bdkey_B_1) (NonceT isoiec_9798_2_3_bdkey_A ''TNA'')))
+  , ((isoiec_9798_2_3_bdkey_A, ''TNB''),
+     (SumT (KnownT isoiec_9798_2_3_bdkey_A_2) (NonceT isoiec_9798_2_3_bdkey_B ''TNB'')))
+  , ((isoiec_9798_2_3_bdkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_3_bdkey_A_text_1))
+  , ((isoiec_9798_2_3_bdkey_B, ''Text1''),
+     (KnownT isoiec_9798_2_3_bdkey_B_1))
+  , ((isoiec_9798_2_3_bdkey_A, ''Text2''),
+     (KnownT isoiec_9798_2_3_bdkey_A_text_1))
+  , ((isoiec_9798_2_3_bdkey_B, ''Text2''),
+     (KnownT isoiec_9798_2_3_bdkey_B_1))
+  , ((isoiec_9798_2_3_bdkey_A, ''Text3''),
+     (KnownT isoiec_9798_2_3_bdkey_A_2))
+  , ((isoiec_9798_2_3_bdkey_B, ''Text3''),
+     (KnownT isoiec_9798_2_3_bdkey_B_text_2))
+  , ((isoiec_9798_2_3_bdkey_A, ''Text4''),
+     (KnownT isoiec_9798_2_3_bdkey_A_2))
+  , ((isoiec_9798_2_3_bdkey_B, ''Text4''),
+     (KnownT isoiec_9798_2_3_bdkey_B_text_2))
+  ]"
+
+sublocale isoiec_9798_2_3_bdkey_state < isoiec_9798_2_3_bdkey_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_2_3_bdkey_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_2_3_bdkey_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_2_3_bdkey_A_text_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_3_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_bdkey_A_text_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_3_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_bdkey_A_2_TNB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_3_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
+               s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_3_bdkey_A_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_3_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
+               s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_3_bdkey_A_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_3_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_bdkey_B_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_3_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_bdkey_B_1_TNA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_3_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
+               s(AV ''B'' tid0), s(MV ''Text1'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_3_bdkey_B_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_3_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
+               s(AV ''B'' tid0), s(MV ''Text1'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_3_bdkey_B_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_3_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_bdkey_B_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_3_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_bdkey_B_text_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_3_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_2_3_bdkey_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_2_3_bdkey_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_2_3_bdkey_state) A_non_injective_agreement:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_3_bdkey_A"
+    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_3_bdkey_A_2 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_3_bdkey_B &
+        ( tid1, isoiec_9798_2_3_bdkey_B_2 ) : steps t &
+        {| s(MV ''A'' tid1), s(AV ''B'' tid1), LN ''TNB'' tid1,
+           s(MV ''Text3'' tid1)
+        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNB'' tid0),
+                s(MV ''Text3'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
+                          s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_3_bdkey_B_2_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_3_bdkey_state) B_non_injective_agreement:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_3_bdkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_3_bdkey_B_1 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_3_bdkey_A &
+        ( tid1, isoiec_9798_2_3_bdkey_A_1 ) : steps t &
+        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
+           s(MV ''Text1'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
+                s(MV ''Text1'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
+                          s(AV ''B'' tid0), s(MV ''Text1'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''A'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_3_bdkey_A_1_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
+qed
+
+role isoiec_9798_2_4_bdkey_A
+where "isoiec_9798_2_4_bdkey_A =
+  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text1'' |>
+  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
+  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
+                  PEnc <| sC ''isoiec_9798_2_4_enc_1'', sN ''RA'', sMV ''RB'', sMV ''B'',
+                          sMV ''Text2''
+                       |>
+                       ( sKbd (AVar ''A'') (MVar ''B'') )
+               |>
+  , Recv ''3'' <| sMV ''B'', sAV ''A'', sMV ''Text5'',
+                  PEnc <| sC ''isoiec_9798_2_4_enc_2'', sMV ''RB'', sN ''RA'',
+                          sMV ''Text4''
+                       |>
+                       ( sKbd (AVar ''A'') (MVar ''B'') )
+               |>
+  ]"
+
+role isoiec_9798_2_4_bdkey_B
+where "isoiec_9798_2_4_bdkey_B =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''RB'', sMV ''Text1'' |>
+  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
+                  PEnc <| sC ''isoiec_9798_2_4_enc_1'', sMV ''RA'', sN ''RB'', sAV ''B'',
+                          sMV ''Text2''
+                       |>
+                       ( sKbd (AVar ''A'') (AVar ''B'') )
+               |>
+  , Recv ''text_3'' <| sMV ''Text4'', sMV ''Text5'' |>
+  , Send ''3'' <| sAV ''B'', sAV ''A'', sMV ''Text5'',
+                  PEnc <| sC ''isoiec_9798_2_4_enc_2'', sN ''RB'', sMV ''RA'',
+                          sMV ''Text4''
+                       |>
+                       ( sKbd (AVar ''A'') (AVar ''B'') )
+               |>
+  ]"
+
+protocol isoiec_9798_2_4_bdkey
+where "isoiec_9798_2_4_bdkey =
+{ isoiec_9798_2_4_bdkey_A, isoiec_9798_2_4_bdkey_B }"
+
+locale restricted_isoiec_9798_2_4_bdkey_state = isoiec_9798_2_4_bdkey_state
+
+type_invariant isoiec_9798_2_4_bdkey_msc_typing for isoiec_9798_2_4_bdkey
+where "isoiec_9798_2_4_bdkey_msc_typing = mk_typing
+  [ ((isoiec_9798_2_4_bdkey_A, ''B''), (KnownT isoiec_9798_2_4_bdkey_A_1))
+  , ((isoiec_9798_2_4_bdkey_B, ''RA''),
+     (SumT (KnownT isoiec_9798_2_4_bdkey_B_2) (NonceT isoiec_9798_2_4_bdkey_A ''RA'')))
+  , ((isoiec_9798_2_4_bdkey_A, ''RB''), (KnownT isoiec_9798_2_4_bdkey_A_1))
+  , ((isoiec_9798_2_4_bdkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_4_bdkey_A_1))
+  , ((isoiec_9798_2_4_bdkey_B, ''Text1''),
+     (KnownT isoiec_9798_2_4_bdkey_B_text_1))
+  , ((isoiec_9798_2_4_bdkey_A, ''Text2''),
+     (KnownT isoiec_9798_2_4_bdkey_A_text_2))
+  , ((isoiec_9798_2_4_bdkey_B, ''Text2''),
+     (KnownT isoiec_9798_2_4_bdkey_B_2))
+  , ((isoiec_9798_2_4_bdkey_A, ''Text3''),
+     (KnownT isoiec_9798_2_4_bdkey_A_text_2))
+  , ((isoiec_9798_2_4_bdkey_B, ''Text3''),
+     (KnownT isoiec_9798_2_4_bdkey_B_2))
+  , ((isoiec_9798_2_4_bdkey_A, ''Text4''),
+     (KnownT isoiec_9798_2_4_bdkey_A_3))
+  , ((isoiec_9798_2_4_bdkey_B, ''Text4''),
+     (KnownT isoiec_9798_2_4_bdkey_B_text_3))
+  , ((isoiec_9798_2_4_bdkey_A, ''Text5''),
+     (KnownT isoiec_9798_2_4_bdkey_A_3))
+  , ((isoiec_9798_2_4_bdkey_B, ''Text5''),
+     (KnownT isoiec_9798_2_4_bdkey_B_text_3))
+  ]"
+
+sublocale isoiec_9798_2_4_bdkey_state < isoiec_9798_2_4_bdkey_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_2_4_bdkey_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_2_4_bdkey_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_2_4_bdkey_A_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_bdkey_A_1_RB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_bdkey_A_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_bdkey_A_text_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_bdkey_A_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_bdkey_A_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_4_enc_2'', s(MV ''RB'' tid0), LN ''RA'' tid0,
+               s(MV ''Text4'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_4_bdkey_A_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_bdkey_B_2_RA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
+               s(AV ''B'' tid0), s(MV ''Text2'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_4_bdkey_B_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
+               s(AV ''B'' tid0), s(MV ''Text2'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_4_bdkey_B_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_bdkey_B_text_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_bdkey_B_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_2_4_bdkey_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_2_4_bdkey_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_2_4_bdkey_state) A_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_4_bdkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_4_bdkey_A_3 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_4_bdkey_B &
+          ( tid1, isoiec_9798_2_4_bdkey_B_3 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''RA'' tid1), LN ''RB'' tid1,
+             s(MV ''Text2'' tid1), s(MV ''Text4'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''RA'' tid0,
+                  s(MV ''RB'' tid0), s(MV ''Text2'' tid0), s(MV ''Text4'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_4_enc_2'', s(MV ''RB'' tid0), LN ''RA'' tid0,
+                              s(MV ''Text4'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_4_bdkey_B_3_enc tid1) note_unified facts = this facts
+        hence "Kbd ( s(AV ''A'' tid1) )
+                   ( s(AV ''B'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) )"
+          by simp note facts = this facts
+        thus ?thesis proof(cases rule: Kbd_cases)
+          case noswap note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_2_4_enc_1'', LN ''RA'' tid0, LN ''RB'' tid1,
+                                  s(AV ''B'' tid1), s(MV ''Text2'' tid1)
+                               |}
+                               ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid1) ) ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest!: ltk_secrecy)
+          next
+            case (isoiec_9798_2_4_bdkey_A_2_enc tid2) note_unified facts = this facts
+            thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+          qed (insert facts, fastforce+)?
+        next
+          case swapped note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_2_4_enc_1'', LN ''RA'' tid0, LN ''RB'' tid1,
+                                  s(AV ''A'' tid0), s(MV ''Text2'' tid1)
+                               |}
+                               ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''A'' tid1) ) ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest!: ltk_secrecy)
+          next
+            case (isoiec_9798_2_4_bdkey_A_2_enc tid2) note_unified facts = this facts
+            thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+          qed (insert facts, fastforce+)?
+        qed (fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_4_bdkey_state) B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_4_bdkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_4_bdkey_B_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_4_bdkey_A &
+          ( tid1, isoiec_9798_2_4_bdkey_A_2 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''RA'' tid1, s(MV ''RB'' tid1),
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''RA'' tid0),
+                  LN ''RB'' tid0, s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
+                              s(AV ''B'' tid0), s(MV ''Text2'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_4_bdkey_A_2_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+role isoiec_9798_2_5_bdkey_A
+where "isoiec_9798_2_5_bdkey_A =
+  [ Send ''leak_A'' <| sN ''TVPa'', sN ''TNa'' |>
+  , Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''A'', sAV ''P'', sN ''TVPa'', sAV ''B'',
+                  sMV ''Text1''
+               |>
+  , Recv ''2'' <| sAV ''P'', sAV ''A'', sMV ''Text4'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_2_1'', sN ''TVPa'', sMV ''Kab'',
+                          sAV ''A'', sAV ''B'', sMV ''Text3''
+                       |>
+                       ( sKbd (AVar ''A'') (AVar ''P'') ),
+                  sMV ''TokenPA_for_B''
+               |>
+  , Recv ''text_3'' <| sMV ''Text5'', sMV ''Text6'' |>
+  , Send ''3'' <| sAV ''A'', sAV ''B'', sMV ''Text6'', sAV ''P'',
+                  sMV ''TokenPA_for_B'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_3'', sN ''TNa'', sAV ''B'',
+                          sMV ''Text5''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''4'' <| sAV ''B'', sAV ''A'', sMV ''Text8'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_4'', sMV ''TNb'', sAV ''A'',
+                          sMV ''Text7''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_5_bdkey_B
+where "isoiec_9798_2_5_bdkey_B =
+  [ Send ''leak_B'' ( sN ''TNb'' )
+  , Recv ''3'' <| sMV ''A'', sAV ''B'', sMV ''Text6'', sMV ''P'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_2_2'', sMV ''TNp'', sMV ''Kab'',
+                          sMV ''A'', sAV ''B'', sMV ''Text2''
+                       |>
+                       ( sKbd (AVar ''B'') (MVar ''P'') ),
+                  PEnc <| sC ''isoiec_9798_2_5_enc_3'', sMV ''TNa'', sAV ''B'',
+                          sMV ''Text5''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''text_4'' <| sMV ''Text7'', sMV ''Text8'' |>
+  , Send ''4'' <| sAV ''B'', sMV ''A'', sMV ''Text8'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_4'', sN ''TNb'', sMV ''A'',
+                          sMV ''Text7''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_5_bdkey_P
+where "isoiec_9798_2_5_bdkey_P =
+  [ Send ''leak_P'' ( sN ''TNp'' )
+  , Recv ''1'' <| sMV ''A'', sAV ''P'', sMV ''TVPa'', sMV ''B'',
+                  sMV ''Text1''
+               |>
+  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'', sMV ''Text4'' |>
+  , Send ''2'' <| sAV ''P'', sMV ''A'', sMV ''Text4'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_2_1'', sMV ''TVPa'', sN ''Kab'',
+                          sMV ''A'', sMV ''B'', sMV ''Text3''
+                       |>
+                       ( sKbd (MVar ''A'') (AVar ''P'') ),
+                  PEnc <| sC ''isoiec_9798_2_5_enc_2_2'', sN ''TNp'', sN ''Kab'',
+                          sMV ''A'', sMV ''B'', sMV ''Text2''
+                       |>
+                       ( sKbd (MVar ''B'') (AVar ''P'') )
+               |>
+  ]"
+
+protocol isoiec_9798_2_5_bdkey
+where "isoiec_9798_2_5_bdkey =
+{ isoiec_9798_2_5_bdkey_A, isoiec_9798_2_5_bdkey_B,
+  isoiec_9798_2_5_bdkey_P
+}"
+
+locale restricted_isoiec_9798_2_5_bdkey_state = isoiec_9798_2_5_bdkey_state
+
+type_invariant isoiec_9798_2_5_bdkey_msc_typing for isoiec_9798_2_5_bdkey
+where "isoiec_9798_2_5_bdkey_msc_typing = mk_typing
+  [ ((isoiec_9798_2_5_bdkey_B, ''A''), (KnownT isoiec_9798_2_5_bdkey_B_3))
+  , ((isoiec_9798_2_5_bdkey_P, ''A''), (KnownT isoiec_9798_2_5_bdkey_P_1))
+  , ((isoiec_9798_2_5_bdkey_P, ''B''), (KnownT isoiec_9798_2_5_bdkey_P_1))
+  , ((isoiec_9798_2_5_bdkey_A, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_5_bdkey_A_2) (NonceT isoiec_9798_2_5_bdkey_P ''Kab'')))
+  , ((isoiec_9798_2_5_bdkey_B, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_5_bdkey_B_3) (NonceT isoiec_9798_2_5_bdkey_P ''Kab'')))
+  , ((isoiec_9798_2_5_bdkey_B, ''P''), (KnownT isoiec_9798_2_5_bdkey_B_3))
+  , ((isoiec_9798_2_5_bdkey_B, ''TNa''),
+     (SumT (KnownT isoiec_9798_2_5_bdkey_B_3) (NonceT isoiec_9798_2_5_bdkey_A ''TNa'')))
+  , ((isoiec_9798_2_5_bdkey_A, ''TNb''),
+     (SumT (KnownT isoiec_9798_2_5_bdkey_A_4) (NonceT isoiec_9798_2_5_bdkey_B ''TNb'')))
+  , ((isoiec_9798_2_5_bdkey_B, ''TNp''),
+     (SumT (KnownT isoiec_9798_2_5_bdkey_B_3) (NonceT isoiec_9798_2_5_bdkey_P ''TNp'')))
+  , ((isoiec_9798_2_5_bdkey_P, ''TVPa''),
+     (KnownT isoiec_9798_2_5_bdkey_P_1))
+  , ((isoiec_9798_2_5_bdkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_5_bdkey_A_text_1))
+  , ((isoiec_9798_2_5_bdkey_P, ''Text1''),
+     (KnownT isoiec_9798_2_5_bdkey_P_1))
+  , ((isoiec_9798_2_5_bdkey_B, ''Text2''),
+     (KnownT isoiec_9798_2_5_bdkey_B_3))
+  , ((isoiec_9798_2_5_bdkey_P, ''Text2''),
+     (KnownT isoiec_9798_2_5_bdkey_P_text_2))
+  , ((isoiec_9798_2_5_bdkey_A, ''Text3''),
+     (KnownT isoiec_9798_2_5_bdkey_A_2))
+  , ((isoiec_9798_2_5_bdkey_P, ''Text3''),
+     (KnownT isoiec_9798_2_5_bdkey_P_text_2))
+  , ((isoiec_9798_2_5_bdkey_A, ''Text4''),
+     (KnownT isoiec_9798_2_5_bdkey_A_2))
+  , ((isoiec_9798_2_5_bdkey_P, ''Text4''),
+     (KnownT isoiec_9798_2_5_bdkey_P_text_2))
+  , ((isoiec_9798_2_5_bdkey_A, ''Text5''),
+     (KnownT isoiec_9798_2_5_bdkey_A_text_3))
+  , ((isoiec_9798_2_5_bdkey_B, ''Text5''),
+     (KnownT isoiec_9798_2_5_bdkey_B_3))
+  , ((isoiec_9798_2_5_bdkey_A, ''Text6''),
+     (KnownT isoiec_9798_2_5_bdkey_A_text_3))
+  , ((isoiec_9798_2_5_bdkey_B, ''Text6''),
+     (KnownT isoiec_9798_2_5_bdkey_B_3))
+  , ((isoiec_9798_2_5_bdkey_A, ''Text7''),
+     (KnownT isoiec_9798_2_5_bdkey_A_4))
+  , ((isoiec_9798_2_5_bdkey_B, ''Text7''),
+     (KnownT isoiec_9798_2_5_bdkey_B_text_4))
+  , ((isoiec_9798_2_5_bdkey_A, ''Text8''),
+     (KnownT isoiec_9798_2_5_bdkey_A_4))
+  , ((isoiec_9798_2_5_bdkey_B, ''Text8''),
+     (KnownT isoiec_9798_2_5_bdkey_B_text_4))
+  , ((isoiec_9798_2_5_bdkey_A, ''TokenPA_for_B''),
+     (KnownT isoiec_9798_2_5_bdkey_A_2))
+  ]"
+
+sublocale isoiec_9798_2_5_bdkey_state < isoiec_9798_2_5_bdkey_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_2_5_bdkey_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_2_5_bdkey_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_2_5_bdkey_A_2_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
+               s(MV ''Text3'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_bdkey_A_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
+               s(MV ''Text3'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_bdkey_A_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_A_2_TokenPA_for_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_A_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_A_text_3_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_A_4_TNb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
+               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_bdkey_A_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
+               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_bdkey_A_4_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_B_3_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_B_3_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
+               s(MV ''Text2'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_bdkey_B_3_P t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_B_3_TNa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
+               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_bdkey_B_3_TNp t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
+               s(MV ''Text2'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_bdkey_B_3_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
+               s(MV ''Text2'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_bdkey_B_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
+               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_bdkey_B_3_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_B_text_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_B_text_4_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_P_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_P_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_P_1_TVPa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_P_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_P_text_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_P_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_bdkey_P_text_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_2_5_bdkey_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_2_5_bdkey_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_2_5_bdkey_state) P_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_P"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
+    "LN ''Kab'' tid0 : knows t"
+  shows "False"
+using facts proof(sources! " LN ''Kab'' tid0 ")
+  case isoiec_9798_2_5_bdkey_P_2_Kab note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+next
+  case isoiec_9798_2_5_bdkey_P_2_Kab_1 note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+qed (insert facts, fastforce+)?
+
+lemma (in restricted_isoiec_9798_2_5_bdkey_state) A_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_A"
+    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_bdkey_A_2 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
+                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
+                          s(MV ''Text3'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_5_bdkey_P_2_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_5_bdkey_state) B_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_bdkey_B_3 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
+                          s(MV ''Text2'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_5_bdkey_P_2_enc_1 tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_5_bdkey_state) A_injective_agreement_B:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_5_bdkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_5_bdkey_A_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_5_bdkey_B &
+          ( tid1, isoiec_9798_2_5_bdkey_B_4 ) : steps t &
+          {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
+             s(MV ''Kab'' tid1), s(MV ''TNa'' tid1), s(MV ''Text5'' tid1),
+             LN ''TNb'' tid1, s(MV ''Text7'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
+                  s(MV ''Kab'' tid0), LN ''TNa'' tid0, s(MV ''Text5'' tid0),
+                  s(MV ''TNb'' tid0), s(MV ''Text7'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
+                              s(MV ''Text3'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_5_bdkey_P_2_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
+                                s(AV ''A'' tid0), s(MV ''Text7'' tid0)
+                             |}
+                             ( LN ''Kab'' tid1 ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+        next
+          case (isoiec_9798_2_5_bdkey_B_4_enc tid2) note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid2),
+                                  LN ''Kab'' tid1, s(AV ''A'' tid0), s(AV ''B'' tid2), s(MV ''Text2'' tid2)
+                               |}
+                               ( Kbd ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) ) ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+          next
+            case (isoiec_9798_2_5_bdkey_P_2_enc_1 tid3) note_unified facts = this facts
+            thus ?thesis proof(sources! "
+                             Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid2),
+                                    s(AV ''B'' tid0), s(MV ''Text5'' tid2)
+                                 |}
+                                 ( LN ''Kab'' tid1 ) ")
+              case fake note_unified facts = this facts
+              thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+            next
+              case (isoiec_9798_2_5_bdkey_A_3_enc tid3) note_unified facts = this facts
+              thus ?thesis proof(sources! "
+                               Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid3, LN ''Kab'' tid1,
+                                      s(AV ''A'' tid3), s(AV ''B'' tid0), s(MV ''Text3'' tid3)
+                                   |}
+                                   ( Kbd ( s(AV ''A'' tid3) ) ( s(AV ''P'' tid3) ) ) ")
+                case fake note_unified facts = this facts
+                thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+              next
+                case (isoiec_9798_2_5_bdkey_P_2_enc tid4) note_unified facts = this facts
+                thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+              qed (insert facts, fastforce+)?
+            qed (insert facts, fastforce+)?
+          qed (insert facts, fastforce+)?
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_5_bdkey_state) B_non_injective_agreement_A:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_bdkey_B_3 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_5_bdkey_A &
+        ( tid1, isoiec_9798_2_5_bdkey_A_3 ) : steps t &
+        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(AV ''P'' tid1),
+           s(MV ''Kab'' tid1), LN ''TNa'' tid1, s(MV ''Text5'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                s(MV ''Kab'' tid0), s(MV ''TNa'' tid0), s(MV ''Text5'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
+                          s(MV ''Text2'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_5_bdkey_P_2_enc_1 tid1) note_unified facts = this facts
+    thus ?thesis proof(sources! "
+                     Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
+                            s(AV ''B'' tid0), s(MV ''Text5'' tid0)
+                         |}
+                         ( LN ''Kab'' tid1 ) ")
+      case fake note_unified facts = this facts
+      thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+    next
+      case (isoiec_9798_2_5_bdkey_A_3_enc tid2) note_unified facts = this facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid2, LN ''Kab'' tid1,
+                              s(AV ''A'' tid2), s(AV ''B'' tid0), s(MV ''Text3'' tid2)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+      next
+        case (isoiec_9798_2_5_bdkey_P_2_enc tid3) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed (insert facts, fastforce+)?
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_5_bdkey_state) A_injective_agreement_P:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_5_bdkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_5_bdkey_A_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_5_bdkey_P &
+          ( tid1, isoiec_9798_2_5_bdkey_P_2 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
+             s(MV ''TVPa'' tid1), s(MV ''Text3'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
+                  s(MV ''Kab'' tid0), LN ''TVPa'' tid0, s(MV ''Text3'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
+                              s(MV ''Text3'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_5_bdkey_P_2_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_5_bdkey_state) B_non_injective_agreement_P:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_bdkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_bdkey_B_3 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_5_bdkey_P &
+        ( tid1, isoiec_9798_2_5_bdkey_P_2 ) : steps t &
+        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
+           LN ''TNp'' tid1, s(MV ''Text2'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                s(MV ''Kab'' tid0), s(MV ''TNp'' tid0), s(MV ''Text2'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(AV ''B'' tid0),
+                          s(MV ''Text2'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_5_bdkey_P_2_enc_1 tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
+qed
+
+role isoiec_9798_2_6_bdkey_A
+where "isoiec_9798_2_6_bdkey_A =
+  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
+  , Recv ''text_2'' ( sMV ''Text2'' )
+  , Send ''2'' <| sAV ''A'', sAV ''P'', sN ''Ra'', sMV ''Rb'', sMV ''B'',
+                  sMV ''Text2''
+               |>
+  , Recv ''3'' <| sAV ''P'', sAV ''A'', sMV ''Text5'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_3_1'', sN ''Ra'', sMV ''Kab'',
+                          sAV ''A'', sMV ''B'', sMV ''Text4''
+                       |>
+                       ( sKbd (AVar ''A'') (AVar ''P'') ),
+                  sMV ''TokenPA_for_B''
+               |>
+  , Recv ''text_4'' <| sMV ''Text6'', sMV ''Text7'' |>
+  , Send ''4'' <| sAV ''A'', sMV ''B'', sMV ''Text7'', sAV ''P'',
+                  sMV ''TokenPA_for_B'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_4'', sN ''Rpa'', sMV ''Rb'',
+                          sMV ''Text6''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''5'' <| sMV ''B'', sAV ''A'', sMV ''Text9'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_5'', sMV ''Rb'', sN ''Rpa'',
+                          sMV ''Text8''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_6_bdkey_B
+where "isoiec_9798_2_6_bdkey_B =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
+  , Recv ''4'' <| sAV ''A'', sAV ''B'', sMV ''Text7'', sMV ''P'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_3_2'', sN ''Rb'', sMV ''Kab'',
+                          sAV ''A'', sAV ''B'', sMV ''Text3''
+                       |>
+                       ( sKbd (AVar ''B'') (MVar ''P'') ),
+                  PEnc <| sC ''isoiec_9798_2_6_enc_4'', sMV ''Rpa'', sN ''Rb'',
+                          sMV ''Text6''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
+  , Send ''5'' <| sAV ''B'', sAV ''A'', sMV ''Text9'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_5'', sN ''Rb'', sMV ''Rpa'',
+                          sMV ''Text8''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_6_bdkey_P
+where "isoiec_9798_2_6_bdkey_P =
+  [ Recv ''2'' <| sMV ''A'', sAV ''P'', sMV ''Ra'', sMV ''Rb'', sMV ''B'',
+                  sMV ''Text2''
+               |>
+  , Recv ''text_3'' <| sMV ''Text3'', sMV ''Text4'', sMV ''Text5'' |>
+  , Send ''3'' <| sAV ''P'', sMV ''A'', sMV ''Text5'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_3_1'', sMV ''Ra'', sN ''Kab'',
+                          sMV ''A'', sMV ''B'', sMV ''Text4''
+                       |>
+                       ( sKbd (MVar ''A'') (AVar ''P'') ),
+                  PEnc <| sC ''isoiec_9798_2_6_enc_3_2'', sMV ''Rb'', sN ''Kab'',
+                          sMV ''A'', sMV ''B'', sMV ''Text3''
+                       |>
+                       ( sKbd (MVar ''B'') (AVar ''P'') )
+               |>
+  ]"
+
+protocol isoiec_9798_2_6_bdkey
+where "isoiec_9798_2_6_bdkey =
+{ isoiec_9798_2_6_bdkey_A, isoiec_9798_2_6_bdkey_B,
+  isoiec_9798_2_6_bdkey_P
+}"
+
+locale restricted_isoiec_9798_2_6_bdkey_state = isoiec_9798_2_6_bdkey_state
+
+type_invariant isoiec_9798_2_6_bdkey_msc_typing for isoiec_9798_2_6_bdkey
+where "isoiec_9798_2_6_bdkey_msc_typing = mk_typing
+  [ ((isoiec_9798_2_6_bdkey_P, ''A''), (KnownT isoiec_9798_2_6_bdkey_P_2))
+  , ((isoiec_9798_2_6_bdkey_A, ''B''), (KnownT isoiec_9798_2_6_bdkey_A_1))
+  , ((isoiec_9798_2_6_bdkey_P, ''B''), (KnownT isoiec_9798_2_6_bdkey_P_2))
+  , ((isoiec_9798_2_6_bdkey_A, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_6_bdkey_A_3) (NonceT isoiec_9798_2_6_bdkey_P ''Kab'')))
+  , ((isoiec_9798_2_6_bdkey_B, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_6_bdkey_B_4) (NonceT isoiec_9798_2_6_bdkey_P ''Kab'')))
+  , ((isoiec_9798_2_6_bdkey_B, ''P''), (KnownT isoiec_9798_2_6_bdkey_B_4))
+  , ((isoiec_9798_2_6_bdkey_P, ''Ra''), (KnownT isoiec_9798_2_6_bdkey_P_2))
+  , ((isoiec_9798_2_6_bdkey_A, ''Rb''), (KnownT isoiec_9798_2_6_bdkey_A_1))
+  , ((isoiec_9798_2_6_bdkey_P, ''Rb''), (KnownT isoiec_9798_2_6_bdkey_P_2))
+  , ((isoiec_9798_2_6_bdkey_B, ''Rpa''),
+     (SumT (KnownT isoiec_9798_2_6_bdkey_B_4) (NonceT isoiec_9798_2_6_bdkey_A ''Rpa'')))
+  , ((isoiec_9798_2_6_bdkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_6_bdkey_A_1))
+  , ((isoiec_9798_2_6_bdkey_B, ''Text1''),
+     (KnownT isoiec_9798_2_6_bdkey_B_text_1))
+  , ((isoiec_9798_2_6_bdkey_A, ''Text2''),
+     (KnownT isoiec_9798_2_6_bdkey_A_text_2))
+  , ((isoiec_9798_2_6_bdkey_P, ''Text2''),
+     (KnownT isoiec_9798_2_6_bdkey_P_2))
+  , ((isoiec_9798_2_6_bdkey_B, ''Text3''),
+     (KnownT isoiec_9798_2_6_bdkey_B_4))
+  , ((isoiec_9798_2_6_bdkey_P, ''Text3''),
+     (KnownT isoiec_9798_2_6_bdkey_P_text_3))
+  , ((isoiec_9798_2_6_bdkey_A, ''Text4''),
+     (KnownT isoiec_9798_2_6_bdkey_A_3))
+  , ((isoiec_9798_2_6_bdkey_P, ''Text4''),
+     (KnownT isoiec_9798_2_6_bdkey_P_text_3))
+  , ((isoiec_9798_2_6_bdkey_A, ''Text5''),
+     (KnownT isoiec_9798_2_6_bdkey_A_3))
+  , ((isoiec_9798_2_6_bdkey_P, ''Text5''),
+     (KnownT isoiec_9798_2_6_bdkey_P_text_3))
+  , ((isoiec_9798_2_6_bdkey_A, ''Text6''),
+     (KnownT isoiec_9798_2_6_bdkey_A_text_4))
+  , ((isoiec_9798_2_6_bdkey_B, ''Text6''),
+     (KnownT isoiec_9798_2_6_bdkey_B_4))
+  , ((isoiec_9798_2_6_bdkey_A, ''Text7''),
+     (KnownT isoiec_9798_2_6_bdkey_A_text_4))
+  , ((isoiec_9798_2_6_bdkey_B, ''Text7''),
+     (KnownT isoiec_9798_2_6_bdkey_B_4))
+  , ((isoiec_9798_2_6_bdkey_A, ''Text8''),
+     (KnownT isoiec_9798_2_6_bdkey_A_5))
+  , ((isoiec_9798_2_6_bdkey_B, ''Text8''),
+     (KnownT isoiec_9798_2_6_bdkey_B_text_5))
+  , ((isoiec_9798_2_6_bdkey_A, ''Text9''),
+     (KnownT isoiec_9798_2_6_bdkey_A_5))
+  , ((isoiec_9798_2_6_bdkey_B, ''Text9''),
+     (KnownT isoiec_9798_2_6_bdkey_B_text_5))
+  , ((isoiec_9798_2_6_bdkey_A, ''TokenPA_for_B''),
+     (KnownT isoiec_9798_2_6_bdkey_A_3))
+  ]"
+
+sublocale isoiec_9798_2_6_bdkey_state < isoiec_9798_2_6_bdkey_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_2_6_bdkey_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_2_6_bdkey_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_2_6_bdkey_A_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_A_1_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_A_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_A_3_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
+               s(MV ''Text4'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_bdkey_A_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
+               s(MV ''Text4'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_bdkey_A_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_A_3_TokenPA_for_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_A_text_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_A_text_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_A_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_5'', s(MV ''Rb'' tid0), LN ''Rpa'' tid0,
+               s(MV ''Text8'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_bdkey_A_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_B_4_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
+               s(MV ''Text3'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_bdkey_B_4_P t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_B_4_Rpa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
+               s(MV ''Text6'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_bdkey_B_4_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
+               s(MV ''Text3'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_bdkey_B_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
+               s(MV ''Text6'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_bdkey_B_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_B_text_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_B_text_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_P_2_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_P_2_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_P_2_Ra t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_P_2_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_P_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_P_text_3_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_P_text_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_bdkey_P_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_2_6_bdkey_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_2_6_bdkey_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_2_6_bdkey_state) P_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_6_bdkey_P"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
+    "LN ''Kab'' tid0 : knows t"
+  shows "False"
+using facts proof(sources! " LN ''Kab'' tid0 ")
+  case isoiec_9798_2_6_bdkey_P_3_Kab note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+next
+  case isoiec_9798_2_6_bdkey_P_3_Kab_1 note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+qed (insert facts, fastforce+)?
+
+lemma (in restricted_isoiec_9798_2_6_bdkey_state) A_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_6_bdkey_A"
+    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_6_bdkey_A_3 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
+                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
+                          s(MV ''Text4'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_6_bdkey_P_3_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_6_bdkey_state) B_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_6_bdkey_B"
+    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_6_bdkey_B_4 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
+                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
+                          s(MV ''Text3'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_6_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_6_bdkey_state) A_injective_agreement_B:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_bdkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_bdkey_A_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_bdkey_B &
+          ( tid1, isoiec_9798_2_6_bdkey_B_5 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
+             s(MV ''Kab'' tid1), s(MV ''Rpa'' tid1), LN ''Rb'' tid1,
+             s(MV ''Text6'' tid1), s(MV ''Text8'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
+                  s(MV ''Kab'' tid0), LN ''Rpa'' tid0, s(MV ''Rb'' tid0),
+                  s(MV ''Text6'' tid0), s(MV ''Text8'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
+                              s(MV ''Text4'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_bdkey_P_3_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_2_6_enc_5'', s(MV ''Rb'' tid0), LN ''Rpa'' tid0,
+                                s(MV ''Text8'' tid0)
+                             |}
+                             ( LN ''Kab'' tid1 ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+        next
+          case (isoiec_9798_2_6_bdkey_B_5_enc tid2) note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid2, LN ''Kab'' tid1,
+                                  s(AV ''A'' tid2), s(AV ''B'' tid2), s(MV ''Text3'' tid2)
+                               |}
+                               ( Kbd ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) ) ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+          next
+            case (isoiec_9798_2_6_bdkey_P_3_enc_1 tid3) note_unified facts = this facts
+            thus ?thesis proof(sources! "
+                             Enc {| LC ''isoiec_9798_2_6_enc_4'', LN ''Rpa'' tid0, LN ''Rb'' tid2,
+                                    s(MV ''Text6'' tid2)
+                                 |}
+                                 ( LN ''Kab'' tid1 ) ")
+              case fake note_unified facts = this facts
+              thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+            next
+              case (isoiec_9798_2_6_bdkey_A_4_enc tid3) note_unified facts = this facts
+              thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+            qed (insert facts, fastforce+)?
+          qed (insert facts, fastforce+)?
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_6_bdkey_state) B_injective_agreement_A:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_bdkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(MV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_bdkey_B_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_bdkey_A &
+          ( tid1, isoiec_9798_2_6_bdkey_A_4 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
+             s(MV ''Kab'' tid1), LN ''Rpa'' tid1, s(MV ''Rb'' tid1),
+             s(MV ''Text6'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                  s(MV ''Kab'' tid0), s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
+                  s(MV ''Text6'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
+                              s(MV ''Text3'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
+                                s(MV ''Text6'' tid0)
+                             |}
+                             ( LN ''Kab'' tid1 ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+        next
+          case (isoiec_9798_2_6_bdkey_A_4_enc tid2) note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid2, LN ''Kab'' tid1,
+                                  s(AV ''A'' tid2), s(MV ''B'' tid2), s(MV ''Text4'' tid2)
+                               |}
+                               ( Kbd ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+          next
+            case (isoiec_9798_2_6_bdkey_P_3_enc tid3) note_unified facts = this facts
+            thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+          qed (insert facts, fastforce+)?
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_6_bdkey_state) A_injective_agreement_P:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_bdkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_bdkey_A_3 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_bdkey_P &
+          ( tid1, isoiec_9798_2_6_bdkey_P_3 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
+             s(MV ''Ra'' tid1), LN ''Kab'' tid1, s(MV ''Text4'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
+                  LN ''Ra'' tid0, s(MV ''Kab'' tid0), s(MV ''Text4'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
+                              s(MV ''Text4'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_bdkey_P_3_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_6_bdkey_state) B_injective_agreement_P:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_bdkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(MV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_bdkey_B_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_bdkey_P &
+          ( tid1, isoiec_9798_2_6_bdkey_P_3 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
+             s(MV ''Rb'' tid1), LN ''Kab'' tid1, s(MV ''Text3'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                  LN ''Rb'' tid0, s(MV ''Kab'' tid0), s(MV ''Text3'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(AV ''B'' tid0),
+                              s(MV ''Text3'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+role isoiec_9798_2_5_special_TTP_bdkey_A
+where "isoiec_9798_2_5_special_TTP_bdkey_A =
+  [ Send ''leak_A'' <| sN ''TVPa'', sN ''TNa'' |>
+  , Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''A'', sAV ''P'', sN ''TVPa'', sAV ''B'',
+                  sMV ''Text1''
+               |>
+  , Recv ''2'' <| sAV ''P'', sAV ''A'', sMV ''Text4'',
+                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_2_1'', sN ''TVPa'',
+                          sMV ''Kab'', sAV ''B'', sMV ''Text3''
+                       |>
+                       ( sKbd (AVar ''A'') (AVar ''P'') ),
+                  sMV ''TokenPA_for_B''
+               |>
+  , Recv ''text_3'' <| sMV ''Text5'', sMV ''Text6'' |>
+  , Send ''3'' <| sAV ''A'', sAV ''B'', sMV ''Text6'', sAV ''P'',
+                  sMV ''TokenPA_for_B'',
+                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_3'', sN ''TNa'', sAV ''B'',
+                          sMV ''Text5''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''4'' <| sAV ''B'', sAV ''A'', sMV ''Text8'',
+                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_4'', sMV ''TNb'', sAV ''A'',
+                          sMV ''Text7''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_5_special_TTP_bdkey_B
+where "isoiec_9798_2_5_special_TTP_bdkey_B =
+  [ Send ''leak_B'' ( sN ''TNb'' )
+  , Recv ''3'' <| sMV ''A'', sAV ''B'', sMV ''Text6'', sMV ''P'',
+                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_2_2'', sMV ''TNp'',
+                          sMV ''Kab'', sMV ''A'', sMV ''Text2''
+                       |>
+                       ( sKbd (AVar ''B'') (MVar ''P'') ),
+                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_3'', sMV ''TNa'', sAV ''B'',
+                          sMV ''Text5''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''text_4'' <| sMV ''Text7'', sMV ''Text8'' |>
+  , Send ''4'' <| sAV ''B'', sMV ''A'', sMV ''Text8'',
+                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_4'', sN ''TNb'', sMV ''A'',
+                          sMV ''Text7''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_5_special_TTP_bdkey_P
+where "isoiec_9798_2_5_special_TTP_bdkey_P =
+  [ Send ''leak_P'' ( sN ''TNp'' )
+  , Recv ''1'' <| sMV ''A'', sAV ''P'', sMV ''TVPa'', sMV ''B'',
+                  sMV ''Text1''
+               |>
+  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'', sMV ''Text4'' |>
+  , Send ''2'' <| sAV ''P'', sMV ''A'', sMV ''Text4'',
+                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_2_1'', sMV ''TVPa'',
+                          sN ''Kab'', sMV ''B'', sMV ''Text3''
+                       |>
+                       ( sKbd (MVar ''A'') (AVar ''P'') ),
+                  PEnc <| sC ''isoiec_9798_2_5_special_TTP_enc_2_2'', sN ''TNp'',
+                          sN ''Kab'', sMV ''A'', sMV ''Text2''
+                       |>
+                       ( sKbd (MVar ''B'') (AVar ''P'') )
+               |>
+  ]"
+
+protocol isoiec_9798_2_5_special_TTP_bdkey
+where "isoiec_9798_2_5_special_TTP_bdkey =
+{ isoiec_9798_2_5_special_TTP_bdkey_A,
+  isoiec_9798_2_5_special_TTP_bdkey_B, isoiec_9798_2_5_special_TTP_bdkey_P
+}"
+
+locale restricted_isoiec_9798_2_5_special_TTP_bdkey_state = isoiec_9798_2_5_special_TTP_bdkey_state +
+  assumes different_actors_A_P:
+    "!! tid0 tid1.
+       [| roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_A;
+         roleMap r tid1 = Some isoiec_9798_2_5_special_TTP_bdkey_P;
+         s(AV ''P'' tid1) = s(AV ''A'' tid0)
+       |] ==> False"
+
+type_invariant isoiec_9798_2_5_special_TTP_bdkey_msc_typing for isoiec_9798_2_5_special_TTP_bdkey
+where "isoiec_9798_2_5_special_TTP_bdkey_msc_typing = mk_typing
+  [ ((isoiec_9798_2_5_special_TTP_bdkey_B, ''A''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''A''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_1))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''B''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_1))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_2) (NonceT isoiec_9798_2_5_special_TTP_bdkey_P ''Kab'')))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3) (NonceT isoiec_9798_2_5_special_TTP_bdkey_P ''Kab'')))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''P''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''TNa''),
+     (SumT (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3) (NonceT isoiec_9798_2_5_special_TTP_bdkey_A ''TNa'')))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''TNb''),
+     (SumT (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_4) (NonceT isoiec_9798_2_5_special_TTP_bdkey_B ''TNb'')))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''TNp''),
+     (SumT (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3) (NonceT isoiec_9798_2_5_special_TTP_bdkey_P ''TNp'')))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''TVPa''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_1))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_text_1))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''Text1''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_1))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Text2''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''Text2''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_text_2))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text3''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_2))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''Text3''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_text_2))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text4''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_2))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_P, ''Text4''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_P_text_2))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text5''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_text_3))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Text5''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text6''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_text_3))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Text6''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_3))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text7''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_4))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Text7''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_text_4))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''Text8''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_4))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_B, ''Text8''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_B_text_4))
+  , ((isoiec_9798_2_5_special_TTP_bdkey_A, ''TokenPA_for_B''),
+     (KnownT isoiec_9798_2_5_special_TTP_bdkey_A_2))
+  ]"
+
+sublocale isoiec_9798_2_5_special_TTP_bdkey_state < isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_2_5_special_TTP_bdkey_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_2_5_special_TTP_bdkey_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_2_5_special_TTP_bdkey_A_2_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_A_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_A_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_A_2_TokenPA_for_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_A_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_A_text_3_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_A_4_TNb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_4'', s(MV ''TNb'' tid0),
+               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_A_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_4'', s(MV ''TNb'' tid0),
+               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_A_4_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
+               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_P t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_TNa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_3'', s(MV ''TNa'' tid0),
+               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_TNp t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
+               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
+               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_3'', s(MV ''TNa'' tid0),
+               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_B_3_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_B_text_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_B_text_4_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_P_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_P_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_P_1_TVPa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_P_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_P_text_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_P_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_P_text_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_2_5_special_TTP_bdkey_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_2_5_special_TTP_bdkey_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+
+lemma (in restricted_isoiec_9798_2_5_special_TTP_bdkey_state) P_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_P"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
+    "LN ''Kab'' tid0 : knows t"
+  shows "False"
+using facts proof(sources! " LN ''Kab'' tid0 ")
+  case isoiec_9798_2_5_special_TTP_bdkey_P_2_Kab note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+next
+  case isoiec_9798_2_5_special_TTP_bdkey_P_2_Kab_1 note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+qed (insert facts, fastforce+)?
+
+lemma (in restricted_isoiec_9798_2_5_special_TTP_bdkey_state) A_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_A"
+    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_special_TTP_bdkey_A_2 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid0,
+                          s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid1) note_unified facts = this facts
+    hence "Kbd ( s(AV ''P'' tid1) )
+               ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
+      by simp note facts = this facts
+    thus ?thesis proof(cases rule: Kbd_cases)
+      case noswap note_unified facts = this facts
+      thus ?thesis by (fastforce dest: different_actors_A_P intro: event_predOrdI)
+    next
+      case swapped note_unified facts = this facts
+      thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+    qed (fastforce+)?
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_5_special_TTP_bdkey_state) B_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_special_TTP_bdkey_B_3 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
+                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc_1 tid1) note_unified facts = this facts
+    hence "Kbd ( s(AV ''P'' tid1) )
+               ( s(MV ''B'' tid1) ) = Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) )"
+      by simp note facts = this facts
+    thus ?thesis proof(cases rule: Kbd_cases)
+      case noswap note_unified facts = this facts
+      thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+    next
+      case swapped note_unified facts = this facts
+      thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+    qed (fastforce+)?
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_5_special_TTP_bdkey_state) A_injective_agreement_B:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_5_special_TTP_bdkey_A_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_5_special_TTP_bdkey_B &
+          ( tid1, isoiec_9798_2_5_special_TTP_bdkey_B_4 ) : steps t &
+          {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
+             s(MV ''Kab'' tid1), s(MV ''TNa'' tid1), s(MV ''Text5'' tid1),
+             LN ''TNb'' tid1, s(MV ''Text7'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
+                  s(MV ''Kab'' tid0), LN ''TNa'' tid0, s(MV ''Text5'' tid0),
+                  s(MV ''TNb'' tid0), s(MV ''Text7'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid1) note_unified facts = this facts
+        hence "Kbd ( s(AV ''P'' tid1) )
+                   ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
+          by simp note facts = this facts
+        thus ?thesis proof(cases rule: Kbd_cases)
+          case noswap note_unified facts = this facts
+          thus ?thesis by (fastforce dest: different_actors_A_P intro: event_predOrdI)
+        next
+          case swapped note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_4'', s(MV ''TNb'' tid0),
+                                  s(AV ''A'' tid0), s(MV ''Text7'' tid0)
+                               |}
+                               ( LN ''Kab'' tid1 ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+          next
+            case (isoiec_9798_2_5_special_TTP_bdkey_B_4_enc tid2) note_unified facts = this facts
+            thus ?thesis proof(sources! "
+                             Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_3'', s(MV ''TNa'' tid2),
+                                    s(AV ''B'' tid2), s(MV ''Text5'' tid2)
+                                 |}
+                                 ( LN ''Kab'' tid1 ) ")
+              case fake note_unified facts = this facts
+              thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+            next
+              case (isoiec_9798_2_5_special_TTP_bdkey_A_3_enc tid3) note_unified facts = this facts
+              thus ?thesis proof(sources! "
+                               Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid3,
+                                      LN ''Kab'' tid1, s(AV ''B'' tid2), s(MV ''Text3'' tid3)
+                                   |}
+                                   ( Kbd ( s(AV ''A'' tid3) ) ( s(AV ''P'' tid3) ) ) ")
+                case fake note_unified facts = this facts
+                thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+              next
+                case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid4) note_unified facts = this facts
+                thus ?thesis proof(sources! "
+                                 Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid2),
+                                        LN ''Kab'' tid1, s(AV ''A'' tid0), s(MV ''Text2'' tid2)
+                                     |}
+                                     ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid2) ) ) ")
+                  case fake note_unified facts = this facts
+                  thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+                next
+                  case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc_1 tid3) note_unified facts = this facts
+                  thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+                qed (insert facts, fastforce+)?
+              qed (insert facts, fastforce+)?
+            qed (insert facts, fastforce+)?
+          qed (insert facts, fastforce+)?
+        qed (fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_5_special_TTP_bdkey_state) B_non_injective_agreement_A:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_special_TTP_bdkey_B_3 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_5_special_TTP_bdkey_A &
+        ( tid1, isoiec_9798_2_5_special_TTP_bdkey_A_3 ) : steps t &
+        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(AV ''P'' tid1),
+           s(MV ''Kab'' tid1), LN ''TNa'' tid1, s(MV ''Text5'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                s(MV ''Kab'' tid0), s(MV ''TNa'' tid0), s(MV ''Text5'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_3'', s(MV ''TNa'' tid0),
+                          s(AV ''B'' tid0), s(MV ''Text5'' tid0)
+                       |}
+                       ( s(MV ''Kab'' tid0) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest: B_secret_Kab intro: event_predOrdI)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_A_3_enc tid1) note_unified facts = this facts
+    thus ?thesis proof(sources! "
+                     Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid1,
+                            s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid1)
+                         |}
+                         ( Kbd ( s(AV ''A'' tid1) ) ( s(AV ''P'' tid1) ) ) ")
+      case fake note_unified facts = this facts
+      thus ?thesis by (fastforce dest: B_secret_Kab intro: event_predOrdI)
+    next
+      case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid2) note_unified facts = this facts
+      hence "Kbd ( s(AV ''P'' tid2) )
+                 ( s(MV ''A'' tid2) ) = Kbd ( s(AV ''A'' tid1) ) ( s(AV ''P'' tid1) )"
+        by simp note facts = this facts
+      thus ?thesis proof(cases rule: Kbd_cases)
+        case noswap note_unified facts = this facts
+        thus ?thesis by (fastforce dest: different_actors_A_P intro: event_predOrdI)
+      next
+        case swapped note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
+                                LN ''Kab'' tid2, s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+                             |}
+                             ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc_1 tid3) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (fastforce+)?
+    qed (insert facts, fastforce+)?
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_5_special_TTP_bdkey_state) A_injective_agreement_P:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_5_special_TTP_bdkey_A_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_5_special_TTP_bdkey_P &
+          ( tid1, isoiec_9798_2_5_special_TTP_bdkey_P_2 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
+             s(MV ''TVPa'' tid1), s(MV ''Text3'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
+                  s(MV ''Kab'' tid0), LN ''TVPa'' tid0, s(MV ''Text3'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid1) note_unified facts = this facts
+        hence "Kbd ( s(AV ''P'' tid1) )
+                   ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
+          by simp note facts = this facts
+        thus ?thesis proof(cases rule: Kbd_cases)
+          case noswap note_unified facts = this facts
+          thus ?thesis by (fastforce dest: different_actors_A_P intro: event_predOrdI)
+        next
+          case swapped note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_5_special_TTP_bdkey_state) B_non_injective_agreement_P:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_special_TTP_bdkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_special_TTP_bdkey_B_3 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_5_special_TTP_bdkey_P &
+        ( tid1, isoiec_9798_2_5_special_TTP_bdkey_P_2 ) : steps t &
+        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
+           LN ''TNp'' tid1, s(MV ''Text2'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                s(MV ''Kab'' tid0), s(MV ''TNp'' tid0), s(MV ''Text2'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_2'', s(MV ''TNp'' tid0),
+                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc_1 tid1) note_unified facts = this facts
+    hence "Kbd ( s(AV ''P'' tid1) )
+               ( s(MV ''B'' tid1) ) = Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) )"
+      by simp note facts = this facts
+    thus ?thesis proof(cases rule: Kbd_cases)
+      case noswap note_unified facts = this facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_3'', s(MV ''TNa'' tid0),
+                              s(AV ''B'' tid0), s(MV ''Text5'' tid0)
+                           |}
+                           ( LN ''Kab'' tid1 ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+      next
+        case (isoiec_9798_2_5_special_TTP_bdkey_A_3_enc tid2) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_2_5_special_TTP_enc_2_1'', LN ''TVPa'' tid2,
+                                LN ''Kab'' tid1, s(AV ''B'' tid0), s(MV ''Text3'' tid2)
+                             |}
+                             ( Kbd ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+        next
+          case (isoiec_9798_2_5_special_TTP_bdkey_P_2_enc tid3) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    next
+      case swapped note_unified facts = this facts
+      thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+    qed (fastforce+)?
+  qed (insert facts, fastforce+)?
+qed
+
+role isoiec_9798_2_6_special_TTP_bdkey_A
+where "isoiec_9798_2_6_special_TTP_bdkey_A =
+  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
+  , Recv ''text_2'' ( sMV ''Text2'' )
+  , Send ''2'' <| sAV ''A'', sAV ''P'', sN ''Ra'', sMV ''Rb'', sMV ''B'',
+                  sMV ''Text2''
+               |>
+  , Recv ''3'' <| sAV ''P'', sAV ''A'', sMV ''Text5'',
+                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_3_1'', sN ''Ra'',
+                          sMV ''Kab'', sMV ''B'', sMV ''Text4''
+                       |>
+                       ( sKbd (AVar ''A'') (AVar ''P'') ),
+                  sMV ''TokenPA_for_B''
+               |>
+  , Recv ''text_4'' <| sMV ''Text6'', sMV ''Text7'' |>
+  , Send ''4'' <| sAV ''A'', sMV ''B'', sMV ''Text7'', sAV ''P'',
+                  sMV ''TokenPA_for_B'',
+                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_4'', sN ''Rpa'', sMV ''Rb'',
+                          sMV ''Text6''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''5'' <| sMV ''B'', sAV ''A'', sMV ''Text9'',
+                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_5'', sMV ''Rb'', sN ''Rpa'',
+                          sMV ''Text8''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_6_special_TTP_bdkey_B
+where "isoiec_9798_2_6_special_TTP_bdkey_B =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
+  , Recv ''4'' <| sAV ''A'', sAV ''B'', sMV ''Text7'', sMV ''P'',
+                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_3_2'', sN ''Rb'',
+                          sMV ''Kab'', sAV ''A'', sMV ''Text3''
+                       |>
+                       ( sKbd (AVar ''B'') (MVar ''P'') ),
+                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_4'', sMV ''Rpa'', sN ''Rb'',
+                          sMV ''Text6''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
+  , Send ''5'' <| sAV ''B'', sAV ''A'', sMV ''Text9'',
+                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_5'', sN ''Rb'', sMV ''Rpa'',
+                          sMV ''Text8''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_6_special_TTP_bdkey_P
+where "isoiec_9798_2_6_special_TTP_bdkey_P =
+  [ Recv ''2'' <| sMV ''A'', sAV ''P'', sMV ''Ra'', sMV ''Rb'', sMV ''B'',
+                  sMV ''Text2''
+               |>
+  , Recv ''text_3'' <| sMV ''Text3'', sMV ''Text4'', sMV ''Text5'' |>
+  , Send ''3'' <| sAV ''P'', sMV ''A'', sMV ''Text5'',
+                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_3_1'', sMV ''Ra'',
+                          sN ''Kab'', sMV ''B'', sMV ''Text4''
+                       |>
+                       ( sKbd (MVar ''A'') (AVar ''P'') ),
+                  PEnc <| sC ''isoiec_9798_2_6_special_TTP_enc_3_2'', sMV ''Rb'',
+                          sN ''Kab'', sMV ''A'', sMV ''Text3''
+                       |>
+                       ( sKbd (MVar ''B'') (AVar ''P'') )
+               |>
+  ]"
+
+protocol isoiec_9798_2_6_special_TTP_bdkey
+where "isoiec_9798_2_6_special_TTP_bdkey =
+{ isoiec_9798_2_6_special_TTP_bdkey_A,
+  isoiec_9798_2_6_special_TTP_bdkey_B, isoiec_9798_2_6_special_TTP_bdkey_P
+}"
+
+locale restricted_isoiec_9798_2_6_special_TTP_bdkey_state = isoiec_9798_2_6_special_TTP_bdkey_state +
+  assumes different_actors_A_P:
+    "!! tid0 tid1.
+       [| roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_A;
+         roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_P;
+         s(AV ''P'' tid1) = s(AV ''A'' tid0)
+       |] ==> False"
+  assumes different_actors_B_P:
+    "!! tid0 tid1.
+       [| roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_B;
+         roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_P;
+         s(AV ''P'' tid1) = s(AV ''B'' tid0)
+       |] ==> False"
+
+type_invariant isoiec_9798_2_6_special_TTP_bdkey_msc_typing for isoiec_9798_2_6_special_TTP_bdkey
+where "isoiec_9798_2_6_special_TTP_bdkey_msc_typing = mk_typing
+  [ ((isoiec_9798_2_6_special_TTP_bdkey_P, ''A''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_2))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''B''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_1))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''B''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_2))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_3) (NonceT isoiec_9798_2_6_special_TTP_bdkey_P ''Kab'')))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4) (NonceT isoiec_9798_2_6_special_TTP_bdkey_P ''Kab'')))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''P''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Ra''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_2))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Rb''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_1))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Rb''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_2))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Rpa''),
+     (SumT (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4) (NonceT isoiec_9798_2_6_special_TTP_bdkey_A ''Rpa'')))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_1))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text1''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_text_1))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text2''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_text_2))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Text2''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_2))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text3''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Text3''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_text_3))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text4''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_3))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Text4''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_text_3))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text5''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_3))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_P, ''Text5''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_P_text_3))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text6''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_text_4))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text6''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text7''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_text_4))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text7''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_4))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text8''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_5))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text8''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_text_5))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''Text9''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_5))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_B, ''Text9''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_B_text_5))
+  , ((isoiec_9798_2_6_special_TTP_bdkey_A, ''TokenPA_for_B''),
+     (KnownT isoiec_9798_2_6_special_TTP_bdkey_A_3))
+  ]"
+
+sublocale isoiec_9798_2_6_special_TTP_bdkey_state < isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_2_6_special_TTP_bdkey_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_2_6_special_TTP_bdkey_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_2_6_special_TTP_bdkey_A_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_A_1_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_A_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_A_3_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid0,
+               s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_A_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid0,
+               s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
+            |}
+            ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_A_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_A_3_TokenPA_for_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_A_text_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_A_text_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_A_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_5'', s(MV ''Rb'' tid0),
+               LN ''Rpa'' tid0, s(MV ''Text8'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_A_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_P t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_Rpa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_4'', s(MV ''Rpa'' tid0),
+               LN ''Rb'' tid0, s(MV ''Text6'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+            |}
+            ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_4'', s(MV ''Rpa'' tid0),
+               LN ''Rb'' tid0, s(MV ''Text6'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_B_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_B_text_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_B_text_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_P_2_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_P_2_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_P_2_Ra t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_P_2_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_P_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_P_text_3_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_P_text_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_P_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_2_6_special_TTP_bdkey_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_2_6_special_TTP_bdkey_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+
+
+lemma (in restricted_isoiec_9798_2_6_special_TTP_bdkey_state) P_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_P"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
+    "LN ''Kab'' tid0 : knows t"
+  shows "False"
+using facts proof(sources! " LN ''Kab'' tid0 ")
+  case isoiec_9798_2_6_special_TTP_bdkey_P_3_Kab note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+next
+  case isoiec_9798_2_6_special_TTP_bdkey_P_3_Kab_1 note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+qed (insert facts, fastforce+)?
+
+lemma (in restricted_isoiec_9798_2_6_special_TTP_bdkey_state) A_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_A"
+    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_6_special_TTP_bdkey_A_3 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid0,
+                          s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc tid1) note_unified facts = this facts
+    hence "Kbd ( s(AV ''P'' tid1) )
+               ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
+      by simp note facts = this facts
+    thus ?thesis proof(cases rule: Kbd_cases)
+      case noswap note_unified facts = this facts
+      thus ?thesis by (fastforce dest: different_actors_A_P intro: event_predOrdI)
+    next
+      case swapped note_unified facts = this facts
+      thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+    qed (fastforce+)?
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_6_special_TTP_bdkey_state) B_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_B"
+    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_6_special_TTP_bdkey_B_4 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid0,
+                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+                       |}
+                       ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
+    hence "Kbd ( s(AV ''P'' tid1) )
+               ( s(MV ''B'' tid1) ) = Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) )"
+      by simp note facts = this facts
+    thus ?thesis proof(cases rule: Kbd_cases)
+      case noswap note_unified facts = this facts
+      thus ?thesis by (fastforce dest: different_actors_B_P intro: event_predOrdI)
+    next
+      case swapped note_unified facts = this facts
+      thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+    qed (fastforce+)?
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_6_special_TTP_bdkey_state) A_injective_agreement_B:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_special_TTP_bdkey_A_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_B &
+          ( tid1, isoiec_9798_2_6_special_TTP_bdkey_B_5 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
+             s(MV ''Kab'' tid1), s(MV ''Rpa'' tid1), LN ''Rb'' tid1,
+             s(MV ''Text6'' tid1), s(MV ''Text8'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
+                  s(MV ''Kab'' tid0), LN ''Rpa'' tid0, s(MV ''Rb'' tid0),
+                  s(MV ''Text6'' tid0), s(MV ''Text8'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid0,
+                              s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc tid1) note_unified facts = this facts
+        hence "Kbd ( s(AV ''P'' tid1) )
+                   ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
+          by simp note facts = this facts
+        thus ?thesis proof(cases rule: Kbd_cases)
+          case noswap note_unified facts = this facts
+          thus ?thesis by (fastforce dest: different_actors_A_P intro: event_predOrdI)
+        next
+          case swapped note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_5'', s(MV ''Rb'' tid0),
+                                  LN ''Rpa'' tid0, s(MV ''Text8'' tid0)
+                               |}
+                               ( LN ''Kab'' tid1 ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+          next
+            case (isoiec_9798_2_6_special_TTP_bdkey_B_5_enc tid2) note_unified facts = this facts
+            thus ?thesis proof(sources! "
+                             Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid2,
+                                    LN ''Kab'' tid1, s(AV ''A'' tid2), s(MV ''Text3'' tid2)
+                                 |}
+                                 ( Kbd ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) ) ) ")
+              case fake note_unified facts = this facts
+              thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+            next
+              case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc_1 tid3) note_unified facts = this facts
+              hence "Kbd ( s(AV ''P'' tid0) )
+                         ( s(MV ''B'' tid0) ) = Kbd ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) )"
+                by simp note facts = this facts
+              thus ?thesis proof(cases rule: Kbd_cases)
+                case noswap note_unified facts = this facts
+                thus ?thesis by (fastforce dest: different_actors_B_P intro: event_predOrdI)
+              next
+                case swapped note_unified facts = this facts
+                thus ?thesis proof(sources! "
+                                 Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_4'', LN ''Rpa'' tid0,
+                                        LN ''Rb'' tid2, s(MV ''Text6'' tid2)
+                                     |}
+                                     ( LN ''Kab'' tid1 ) ")
+                  case fake note_unified facts = this facts
+                  thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+                next
+                  case (isoiec_9798_2_6_special_TTP_bdkey_A_4_enc tid3) note_unified facts = this facts
+                  thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+                qed (insert facts, fastforce+)?
+              qed (fastforce+)?
+            qed (insert facts, fastforce+)?
+          qed (insert facts, fastforce+)?
+        qed (fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_6_special_TTP_bdkey_state) B_injective_agreement_A:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(MV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_special_TTP_bdkey_B_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_A &
+          ( tid1, isoiec_9798_2_6_special_TTP_bdkey_A_4 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
+             s(MV ''Kab'' tid1), LN ''Rpa'' tid1, s(MV ''Rb'' tid1),
+             s(MV ''Text6'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                  s(MV ''Kab'' tid0), s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
+                  s(MV ''Text6'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
+        hence "Kbd ( s(AV ''P'' tid1) )
+                   ( s(MV ''B'' tid1) ) = Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) )"
+          by simp note facts = this facts
+        thus ?thesis proof(cases rule: Kbd_cases)
+          case noswap note_unified facts = this facts
+          thus ?thesis by (fastforce dest: different_actors_B_P intro: event_predOrdI)
+        next
+          case swapped note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_4'', s(MV ''Rpa'' tid0),
+                                  LN ''Rb'' tid0, s(MV ''Text6'' tid0)
+                               |}
+                               ( LN ''Kab'' tid1 ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+          next
+            case (isoiec_9798_2_6_special_TTP_bdkey_A_4_enc tid2) note_unified facts = this facts
+            thus ?thesis proof(sources! "
+                             Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid2,
+                                    LN ''Kab'' tid1, s(MV ''B'' tid2), s(MV ''Text4'' tid2)
+                                 |}
+                                 ( Kbd ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
+              case fake note_unified facts = this facts
+              thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+            next
+              case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc tid3) note_unified facts = this facts
+              hence "Kbd ( s(AV ''A'' tid2) )
+                         ( s(AV ''P'' tid2) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid1) )"
+                by simp note facts = this facts
+              thus ?thesis proof(cases rule: Kbd_cases)
+                case noswap note_unified facts = this facts
+                thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+              next
+                case swapped note_unified facts = this facts
+                thus ?thesis by (fastforce dest: different_actors_A_P intro: event_predOrdI)
+              qed (fastforce+)?
+            qed (insert facts, fastforce+)?
+          qed (insert facts, fastforce+)?
+        qed (fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_6_special_TTP_bdkey_state) A_injective_agreement_P:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_special_TTP_bdkey_A_3 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_P &
+          ( tid1, isoiec_9798_2_6_special_TTP_bdkey_P_3 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
+             s(MV ''Ra'' tid1), LN ''Kab'' tid1, s(MV ''Text4'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
+                  LN ''Ra'' tid0, s(MV ''Kab'' tid0), s(MV ''Text4'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_1'', LN ''Ra'' tid0,
+                              s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc tid1) note_unified facts = this facts
+        hence "Kbd ( s(AV ''P'' tid1) )
+                   ( s(MV ''A'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) )"
+          by simp note facts = this facts
+        thus ?thesis proof(cases rule: Kbd_cases)
+          case noswap note_unified facts = this facts
+          thus ?thesis by (fastforce dest: different_actors_A_P intro: event_predOrdI)
+        next
+          case swapped note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_6_special_TTP_bdkey_state) B_injective_agreement_P:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_special_TTP_bdkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(MV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_special_TTP_bdkey_B_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_special_TTP_bdkey_P &
+          ( tid1, isoiec_9798_2_6_special_TTP_bdkey_P_3 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
+             s(MV ''Rb'' tid1), LN ''Kab'' tid1, s(MV ''Text3'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                  LN ''Rb'' tid0, s(MV ''Kab'' tid0), s(MV ''Text3'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_special_TTP_enc_3_2'', LN ''Rb'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_special_TTP_bdkey_P_3_enc_1 tid1) note_unified facts = this facts
+        hence "Kbd ( s(AV ''P'' tid1) )
+                   ( s(MV ''B'' tid1) ) = Kbd ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) )"
+          by simp note facts = this facts
+        thus ?thesis proof(cases rule: Kbd_cases)
+          case noswap note_unified facts = this facts
+          thus ?thesis by (fastforce dest: different_actors_B_P intro: event_predOrdI)
+        next
+          case swapped note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
 qed
 
 end
diff --git a/data/examples/iso9798/isabelle-proofs/isoiec-9798-2-udkey_cert_auto.thy b/data/examples/iso9798/isabelle-proofs/isoiec-9798-2-udkey_cert_auto.thy
--- a/data/examples/iso9798/isabelle-proofs/isoiec-9798-2-udkey_cert_auto.thy
+++ b/data/examples/iso9798/isabelle-proofs/isoiec-9798-2-udkey_cert_auto.thy
@@ -1,2190 +1,2370 @@
 theory "isoiec-9798-2-udkey_cert_auto"
 imports
-  "../ESPLogic"
-begin
-
-role isoiec_9798_2_1_udkey_A
-where "isoiec_9798_2_1_udkey_A =
-  [ Send ''leak_A'' ( sN ''TNA'' )
-  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
-  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
-                  PEnc <| sC ''isoiec_9798_2_1_enc_1'', sN ''TNA'', sMV ''Text1'' |>
-                       ( sK ''A'' ''B'' )
-               |>
-  ]"
-
-role isoiec_9798_2_1_udkey_B
-where "isoiec_9798_2_1_udkey_B =
-  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
-                  PEnc <| sC ''isoiec_9798_2_1_enc_1'', sMV ''TNA'', sMV ''Text1'' |>
-                       ( PSymK ( sMV ''A'' ) ( sAV ''B'' ) )
-               |>
-  ]"
-
-protocol isoiec_9798_2_1_udkey
-where "isoiec_9798_2_1_udkey =
-{ isoiec_9798_2_1_udkey_A, isoiec_9798_2_1_udkey_B }"
-
-locale restricted_isoiec_9798_2_1_udkey_state = isoiec_9798_2_1_udkey_state
-
-type_invariant isoiec_9798_2_1_udkey_msc_typing for isoiec_9798_2_1_udkey
-where "isoiec_9798_2_1_udkey_msc_typing = mk_typing
-  [ ((isoiec_9798_2_1_udkey_B, ''A''), (KnownT isoiec_9798_2_1_udkey_B_1))
-  , ((isoiec_9798_2_1_udkey_B, ''TNA''),
-     (SumT (KnownT isoiec_9798_2_1_udkey_B_1) (NonceT isoiec_9798_2_1_udkey_A ''TNA'')))
-  , ((isoiec_9798_2_1_udkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_1_udkey_A_text_1))
-  , ((isoiec_9798_2_1_udkey_B, ''Text1''),
-     (KnownT isoiec_9798_2_1_udkey_B_1))
-  , ((isoiec_9798_2_1_udkey_A, ''Text2''),
-     (KnownT isoiec_9798_2_1_udkey_A_text_1))
-  , ((isoiec_9798_2_1_udkey_B, ''Text2''),
-     (KnownT isoiec_9798_2_1_udkey_B_1))
-  ]"
-
-sublocale isoiec_9798_2_1_udkey_state < isoiec_9798_2_1_udkey_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_2_1_udkey_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_2_1_udkey_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_2_1_udkey_A_text_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_1_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_1_udkey_A_text_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_1_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_1_udkey_B_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_1_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_1_udkey_B_1_TNA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_1_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
-               s(MV ''Text1'' tid0)
-            |}
-            ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_1_udkey_B_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_1_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
-               s(MV ''Text1'' tid0)
-            |}
-            ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_1_udkey_B_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_1_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_2_1_udkey_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_2_1_udkey_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_2_1_udkey_state) B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_1_udkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_1_udkey_B_1 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_1_udkey_A &
-        ( tid1, isoiec_9798_2_1_udkey_A_1 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
-           s(MV ''Text1'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
-                s(MV ''Text1'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
-                          s(MV ''Text1'' tid0)
-                       |}
-                       ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_1_udkey_A_1_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-role isoiec_9798_2_2_udkey_A
-where "isoiec_9798_2_2_udkey_A =
-  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text1'' |>
-  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
-  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
-                  PEnc <| sC ''isoiec_9798_2_2_enc_2'', sMV ''RB'', sMV ''Text2'' |>
-                       ( PSymK ( sAV ''A'' ) ( sMV ''B'' ) )
-               |>
-  ]"
-
-role isoiec_9798_2_2_udkey_B
-where "isoiec_9798_2_2_udkey_B =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''RB'', sMV ''Text1'' |>
-  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
-                  PEnc <| sC ''isoiec_9798_2_2_enc_2'', sN ''RB'', sMV ''Text2'' |>
-                       ( sK ''A'' ''B'' )
-               |>
-  ]"
-
-protocol isoiec_9798_2_2_udkey
-where "isoiec_9798_2_2_udkey =
-{ isoiec_9798_2_2_udkey_A, isoiec_9798_2_2_udkey_B }"
-
-locale restricted_isoiec_9798_2_2_udkey_state = isoiec_9798_2_2_udkey_state
-
-type_invariant isoiec_9798_2_2_udkey_msc_typing for isoiec_9798_2_2_udkey
-where "isoiec_9798_2_2_udkey_msc_typing = mk_typing
-  [ ((isoiec_9798_2_2_udkey_A, ''B''), (KnownT isoiec_9798_2_2_udkey_A_1))
-  , ((isoiec_9798_2_2_udkey_A, ''RB''), (KnownT isoiec_9798_2_2_udkey_A_1))
-  , ((isoiec_9798_2_2_udkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_2_udkey_A_1))
-  , ((isoiec_9798_2_2_udkey_B, ''Text1''),
-     (KnownT isoiec_9798_2_2_udkey_B_text_1))
-  , ((isoiec_9798_2_2_udkey_A, ''Text2''),
-     (KnownT isoiec_9798_2_2_udkey_A_text_2))
-  , ((isoiec_9798_2_2_udkey_B, ''Text2''),
-     (KnownT isoiec_9798_2_2_udkey_B_2))
-  , ((isoiec_9798_2_2_udkey_A, ''Text3''),
-     (KnownT isoiec_9798_2_2_udkey_A_text_2))
-  , ((isoiec_9798_2_2_udkey_B, ''Text3''),
-     (KnownT isoiec_9798_2_2_udkey_B_2))
-  ]"
-
-sublocale isoiec_9798_2_2_udkey_state < isoiec_9798_2_2_udkey_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_2_2_udkey_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_2_2_udkey_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_2_2_udkey_A_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_2_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_2_udkey_A_1_RB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_2_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_2_udkey_A_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_2_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_2_udkey_A_text_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_2_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_2_udkey_A_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_2_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_2_udkey_B_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_2_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_2_enc_2'', LN ''RB'' tid0, s(MV ''Text2'' tid0)
-            |}
-            ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_2_udkey_B_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_2_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_2_2_udkey_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_2_2_udkey_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_2_2_udkey_state) B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_2_udkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_2_udkey_B_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_2_udkey_A &
-        ( tid1, isoiec_9798_2_2_udkey_A_2 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(MV ''RB'' tid1),
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''RB'' tid0,
-                s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_2_enc_2'', LN ''RB'' tid0, s(MV ''Text2'' tid0)
-                       |}
-                       ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_2_udkey_A_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-role isoiec_9798_2_3_udkey_A
-where "isoiec_9798_2_3_udkey_A =
-  [ Send ''leak_A'' ( sN ''TNA'' )
-  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
-  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
-                  PEnc <| sC ''isoiec_9798_2_3_enc_1'', sN ''TNA'', sMV ''Text1'' |>
-                       ( sK ''A'' ''B'' )
-               |>
-  , Recv ''2'' <| sAV ''B'', sAV ''A'', sMV ''Text4'',
-                  PEnc <| sC ''isoiec_9798_2_3_enc_2'', sMV ''TNB'', sMV ''Text3'' |>
-                       ( sK ''B'' ''A'' )
-               |>
-  ]"
-
-role isoiec_9798_2_3_udkey_B
-where "isoiec_9798_2_3_udkey_B =
-  [ Send ''leak_B'' ( sN ''TNB'' )
-  , Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
-                  PEnc <| sC ''isoiec_9798_2_3_enc_1'', sMV ''TNA'', sMV ''Text1'' |>
-                       ( PSymK ( sMV ''A'' ) ( sAV ''B'' ) )
-               |>
-  , Recv ''text_2'' <| sMV ''Text3'', sMV ''Text4'' |>
-  , Send ''2'' <| sAV ''B'', sMV ''A'', sMV ''Text4'',
-                  PEnc <| sC ''isoiec_9798_2_3_enc_2'', sN ''TNB'', sMV ''Text3'' |>
-                       ( PSymK ( sAV ''B'' ) ( sMV ''A'' ) )
-               |>
-  ]"
-
-protocol isoiec_9798_2_3_udkey
-where "isoiec_9798_2_3_udkey =
-{ isoiec_9798_2_3_udkey_A, isoiec_9798_2_3_udkey_B }"
-
-locale restricted_isoiec_9798_2_3_udkey_state = isoiec_9798_2_3_udkey_state
-
-type_invariant isoiec_9798_2_3_udkey_msc_typing for isoiec_9798_2_3_udkey
-where "isoiec_9798_2_3_udkey_msc_typing = mk_typing
-  [ ((isoiec_9798_2_3_udkey_B, ''A''), (KnownT isoiec_9798_2_3_udkey_B_1))
-  , ((isoiec_9798_2_3_udkey_B, ''TNA''),
-     (SumT (KnownT isoiec_9798_2_3_udkey_B_1) (NonceT isoiec_9798_2_3_udkey_A ''TNA'')))
-  , ((isoiec_9798_2_3_udkey_A, ''TNB''),
-     (SumT (KnownT isoiec_9798_2_3_udkey_A_2) (NonceT isoiec_9798_2_3_udkey_B ''TNB'')))
-  , ((isoiec_9798_2_3_udkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_3_udkey_A_text_1))
-  , ((isoiec_9798_2_3_udkey_B, ''Text1''),
-     (KnownT isoiec_9798_2_3_udkey_B_1))
-  , ((isoiec_9798_2_3_udkey_A, ''Text2''),
-     (KnownT isoiec_9798_2_3_udkey_A_text_1))
-  , ((isoiec_9798_2_3_udkey_B, ''Text2''),
-     (KnownT isoiec_9798_2_3_udkey_B_1))
-  , ((isoiec_9798_2_3_udkey_A, ''Text3''),
-     (KnownT isoiec_9798_2_3_udkey_A_2))
-  , ((isoiec_9798_2_3_udkey_B, ''Text3''),
-     (KnownT isoiec_9798_2_3_udkey_B_text_2))
-  , ((isoiec_9798_2_3_udkey_A, ''Text4''),
-     (KnownT isoiec_9798_2_3_udkey_A_2))
-  , ((isoiec_9798_2_3_udkey_B, ''Text4''),
-     (KnownT isoiec_9798_2_3_udkey_B_text_2))
-  ]"
-
-sublocale isoiec_9798_2_3_udkey_state < isoiec_9798_2_3_udkey_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_2_3_udkey_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_2_3_udkey_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_2_3_udkey_A_text_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_3_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_udkey_A_text_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_3_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_udkey_A_2_TNB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_3_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
-               s(MV ''Text3'' tid0)
-            |}
-            ( K ( s(AV ''B'' tid0) ) ( s(AV ''A'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_3_udkey_A_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_3_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
-               s(MV ''Text3'' tid0)
-            |}
-            ( K ( s(AV ''B'' tid0) ) ( s(AV ''A'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_3_udkey_A_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_3_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_udkey_B_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_3_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_udkey_B_1_TNA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_3_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
-               s(MV ''Text1'' tid0)
-            |}
-            ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_3_udkey_B_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_3_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
-               s(MV ''Text1'' tid0)
-            |}
-            ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_3_udkey_B_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_3_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_udkey_B_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_3_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_3_udkey_B_text_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_3_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_2_3_udkey_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_2_3_udkey_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_2_3_udkey_state) A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_3_udkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_3_udkey_A_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_3_udkey_B &
-        ( tid1, isoiec_9798_2_3_udkey_B_2 ) : steps t &
-        {| s(MV ''A'' tid1), s(AV ''B'' tid1), LN ''TNB'' tid1,
-           s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNB'' tid0),
-                s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
-                          s(MV ''Text3'' tid0)
-                       |}
-                       ( K ( s(AV ''B'' tid0) ) ( s(AV ''A'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_3_udkey_B_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_3_udkey_state) B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_3_udkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_3_udkey_B_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_3_udkey_A &
-        ( tid1, isoiec_9798_2_3_udkey_A_1 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
-           s(MV ''Text1'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
-                s(MV ''Text1'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
-                          s(MV ''Text1'' tid0)
-                       |}
-                       ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_3_udkey_A_1_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-role isoiec_9798_2_4_udkey_A
-where "isoiec_9798_2_4_udkey_A =
-  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text1'' |>
-  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
-  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
-                  PEnc <| sC ''isoiec_9798_2_4_enc_1'', sN ''RA'', sMV ''RB'',
-                          sMV ''Text2''
-                       |>
-                       ( PSymK ( sAV ''A'' ) ( sMV ''B'' ) )
-               |>
-  , Recv ''3'' <| sMV ''B'', sAV ''A'', sMV ''Text5'',
-                  PEnc <| sC ''isoiec_9798_2_4_enc_2'', sMV ''RB'', sN ''RA'',
-                          sMV ''Text4''
-                       |>
-                       ( PSymK ( sMV ''B'' ) ( sAV ''A'' ) )
-               |>
-  ]"
-
-role isoiec_9798_2_4_udkey_B
-where "isoiec_9798_2_4_udkey_B =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''RB'', sMV ''Text1'' |>
-  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
-                  PEnc <| sC ''isoiec_9798_2_4_enc_1'', sMV ''RA'', sN ''RB'',
-                          sMV ''Text2''
-                       |>
-                       ( sK ''A'' ''B'' )
-               |>
-  , Recv ''text_3'' <| sMV ''Text4'', sMV ''Text5'' |>
-  , Send ''3'' <| sAV ''B'', sAV ''A'', sMV ''Text5'',
-                  PEnc <| sC ''isoiec_9798_2_4_enc_2'', sN ''RB'', sMV ''RA'',
-                          sMV ''Text4''
-                       |>
-                       ( sK ''B'' ''A'' )
-               |>
-  ]"
-
-protocol isoiec_9798_2_4_udkey
-where "isoiec_9798_2_4_udkey =
-{ isoiec_9798_2_4_udkey_A, isoiec_9798_2_4_udkey_B }"
-
-locale restricted_isoiec_9798_2_4_udkey_state = isoiec_9798_2_4_udkey_state
-
-type_invariant isoiec_9798_2_4_udkey_msc_typing for isoiec_9798_2_4_udkey
-where "isoiec_9798_2_4_udkey_msc_typing = mk_typing
-  [ ((isoiec_9798_2_4_udkey_A, ''B''), (KnownT isoiec_9798_2_4_udkey_A_1))
-  , ((isoiec_9798_2_4_udkey_B, ''RA''),
-     (SumT (KnownT isoiec_9798_2_4_udkey_B_2) (NonceT isoiec_9798_2_4_udkey_A ''RA'')))
-  , ((isoiec_9798_2_4_udkey_A, ''RB''), (KnownT isoiec_9798_2_4_udkey_A_1))
-  , ((isoiec_9798_2_4_udkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_4_udkey_A_1))
-  , ((isoiec_9798_2_4_udkey_B, ''Text1''),
-     (KnownT isoiec_9798_2_4_udkey_B_text_1))
-  , ((isoiec_9798_2_4_udkey_A, ''Text2''),
-     (KnownT isoiec_9798_2_4_udkey_A_text_2))
-  , ((isoiec_9798_2_4_udkey_B, ''Text2''),
-     (KnownT isoiec_9798_2_4_udkey_B_2))
-  , ((isoiec_9798_2_4_udkey_A, ''Text3''),
-     (KnownT isoiec_9798_2_4_udkey_A_text_2))
-  , ((isoiec_9798_2_4_udkey_B, ''Text3''),
-     (KnownT isoiec_9798_2_4_udkey_B_2))
-  , ((isoiec_9798_2_4_udkey_A, ''Text4''),
-     (KnownT isoiec_9798_2_4_udkey_A_3))
-  , ((isoiec_9798_2_4_udkey_B, ''Text4''),
-     (KnownT isoiec_9798_2_4_udkey_B_text_3))
-  , ((isoiec_9798_2_4_udkey_A, ''Text5''),
-     (KnownT isoiec_9798_2_4_udkey_A_3))
-  , ((isoiec_9798_2_4_udkey_B, ''Text5''),
-     (KnownT isoiec_9798_2_4_udkey_B_text_3))
-  ]"
-
-sublocale isoiec_9798_2_4_udkey_state < isoiec_9798_2_4_udkey_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_2_4_udkey_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_2_4_udkey_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_2_4_udkey_A_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_udkey_A_1_RB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_udkey_A_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_udkey_A_text_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_udkey_A_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_udkey_A_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_4_enc_2'', s(MV ''RB'' tid0), LN ''RA'' tid0,
-               s(MV ''Text4'' tid0)
-            |}
-            ( K ( s(MV ''B'' tid0) ) ( s(AV ''A'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_4_udkey_A_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_udkey_B_2_RA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
-               s(MV ''Text2'' tid0)
-            |}
-            ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_4_udkey_B_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
-               s(MV ''Text2'' tid0)
-            |}
-            ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_4_udkey_B_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_udkey_B_text_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_4_udkey_B_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_2_4_udkey_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_2_4_udkey_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_2_4_udkey_state) A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_4_udkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_4_udkey_A_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_4_udkey_B &
-        ( tid1, isoiec_9798_2_4_udkey_B_3 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''RA'' tid1), LN ''RB'' tid1,
-           s(MV ''Text2'' tid1), s(MV ''Text4'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''RA'' tid0,
-                s(MV ''RB'' tid0), s(MV ''Text2'' tid0), s(MV ''Text4'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_4_enc_2'', s(MV ''RB'' tid0), LN ''RA'' tid0,
-                          s(MV ''Text4'' tid0)
-                       |}
-                       ( K ( s(MV ''B'' tid0) ) ( s(AV ''A'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_4_udkey_B_3_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_2_4_enc_1'', LN ''RA'' tid0, LN ''RB'' tid1,
-                            s(MV ''Text2'' tid1)
-                         |}
-                         ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid1) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_2_4_udkey_A_2_enc tid2) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_4_udkey_state) B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_4_udkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_4_udkey_B_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_4_udkey_A &
-        ( tid1, isoiec_9798_2_4_udkey_A_2 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''RA'' tid1, s(MV ''RB'' tid1),
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''RA'' tid0),
-                LN ''RB'' tid0, s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
-                          s(MV ''Text2'' tid0)
-                       |}
-                       ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_4_udkey_A_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-role isoiec_9798_2_5_udkey_A
-where "isoiec_9798_2_5_udkey_A =
-  [ Send ''leak_A'' <| sN ''TVPa'', sN ''TNa'' |>
-  , Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''A'', sAV ''P'', sN ''TVPa'', sAV ''B'',
-                  sMV ''Text1''
-               |>
-  , Recv ''2'' <| sAV ''P'', sAV ''A'', sMV ''Text4'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_2_1'', sN ''TVPa'', sMV ''Kab'',
-                          sAV ''B'', sMV ''Text3''
-                       |>
-                       ( sK ''A'' ''P'' ),
-                  sMV ''TokenPA_for_B''
-               |>
-  , Recv ''text_3'' <| sMV ''Text5'', sMV ''Text6'' |>
-  , Send ''3'' <| sAV ''A'', sAV ''B'', sMV ''Text6'', sAV ''P'',
-                  sMV ''TokenPA_for_B'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_3'', sN ''TNa'', sAV ''B'',
-                          sMV ''Text5''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''4'' <| sAV ''B'', sAV ''A'', sMV ''Text8'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_4'', sMV ''TNb'', sAV ''A'',
-                          sMV ''Text7''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_5_udkey_B
-where "isoiec_9798_2_5_udkey_B =
-  [ Send ''leak_B'' ( sN ''TNb'' )
-  , Recv ''3'' <| sMV ''A'', sAV ''B'', sMV ''Text6'', sMV ''P'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_2_2'', sMV ''TNp'', sMV ''Kab'',
-                          sMV ''A'', sMV ''Text2''
-                       |>
-                       ( PSymK ( sAV ''B'' ) ( sMV ''P'' ) ),
-                  PEnc <| sC ''isoiec_9798_2_5_enc_3'', sMV ''TNa'', sAV ''B'',
-                          sMV ''Text5''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''text_4'' <| sMV ''Text7'', sMV ''Text8'' |>
-  , Send ''4'' <| sAV ''B'', sMV ''A'', sMV ''Text8'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_4'', sN ''TNb'', sMV ''A'',
-                          sMV ''Text7''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_5_udkey_P
-where "isoiec_9798_2_5_udkey_P =
-  [ Send ''leak_P'' ( sN ''TNp'' )
-  , Recv ''1'' <| sMV ''A'', sAV ''P'', sMV ''TVPa'', sMV ''B'',
-                  sMV ''Text1''
-               |>
-  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'', sMV ''Text4'' |>
-  , Send ''2'' <| sAV ''P'', sMV ''A'', sMV ''Text4'',
-                  PEnc <| sC ''isoiec_9798_2_5_enc_2_1'', sMV ''TVPa'', sN ''Kab'',
-                          sMV ''B'', sMV ''Text3''
-                       |>
-                       ( PSymK ( sMV ''A'' ) ( sAV ''P'' ) ),
-                  PEnc <| sC ''isoiec_9798_2_5_enc_2_2'', sN ''TNp'', sN ''Kab'',
-                          sMV ''A'', sMV ''Text2''
-                       |>
-                       ( PSymK ( sMV ''B'' ) ( sAV ''P'' ) )
-               |>
-  ]"
-
-protocol isoiec_9798_2_5_udkey
-where "isoiec_9798_2_5_udkey =
-{ isoiec_9798_2_5_udkey_A, isoiec_9798_2_5_udkey_B,
-  isoiec_9798_2_5_udkey_P
-}"
-
-locale restricted_isoiec_9798_2_5_udkey_state = isoiec_9798_2_5_udkey_state
-
-type_invariant isoiec_9798_2_5_udkey_msc_typing for isoiec_9798_2_5_udkey
-where "isoiec_9798_2_5_udkey_msc_typing = mk_typing
-  [ ((isoiec_9798_2_5_udkey_B, ''A''), (KnownT isoiec_9798_2_5_udkey_B_3))
-  , ((isoiec_9798_2_5_udkey_P, ''A''), (KnownT isoiec_9798_2_5_udkey_P_1))
-  , ((isoiec_9798_2_5_udkey_P, ''B''), (KnownT isoiec_9798_2_5_udkey_P_1))
-  , ((isoiec_9798_2_5_udkey_A, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_5_udkey_A_2) (NonceT isoiec_9798_2_5_udkey_P ''Kab'')))
-  , ((isoiec_9798_2_5_udkey_B, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_5_udkey_B_3) (NonceT isoiec_9798_2_5_udkey_P ''Kab'')))
-  , ((isoiec_9798_2_5_udkey_B, ''P''), (KnownT isoiec_9798_2_5_udkey_B_3))
-  , ((isoiec_9798_2_5_udkey_B, ''TNa''),
-     (SumT (KnownT isoiec_9798_2_5_udkey_B_3) (NonceT isoiec_9798_2_5_udkey_A ''TNa'')))
-  , ((isoiec_9798_2_5_udkey_A, ''TNb''),
-     (SumT (KnownT isoiec_9798_2_5_udkey_A_4) (NonceT isoiec_9798_2_5_udkey_B ''TNb'')))
-  , ((isoiec_9798_2_5_udkey_B, ''TNp''),
-     (SumT (KnownT isoiec_9798_2_5_udkey_B_3) (NonceT isoiec_9798_2_5_udkey_P ''TNp'')))
-  , ((isoiec_9798_2_5_udkey_P, ''TVPa''),
-     (KnownT isoiec_9798_2_5_udkey_P_1))
-  , ((isoiec_9798_2_5_udkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_5_udkey_A_text_1))
-  , ((isoiec_9798_2_5_udkey_P, ''Text1''),
-     (KnownT isoiec_9798_2_5_udkey_P_1))
-  , ((isoiec_9798_2_5_udkey_B, ''Text2''),
-     (KnownT isoiec_9798_2_5_udkey_B_3))
-  , ((isoiec_9798_2_5_udkey_P, ''Text2''),
-     (KnownT isoiec_9798_2_5_udkey_P_text_2))
-  , ((isoiec_9798_2_5_udkey_A, ''Text3''),
-     (KnownT isoiec_9798_2_5_udkey_A_2))
-  , ((isoiec_9798_2_5_udkey_P, ''Text3''),
-     (KnownT isoiec_9798_2_5_udkey_P_text_2))
-  , ((isoiec_9798_2_5_udkey_A, ''Text4''),
-     (KnownT isoiec_9798_2_5_udkey_A_2))
-  , ((isoiec_9798_2_5_udkey_P, ''Text4''),
-     (KnownT isoiec_9798_2_5_udkey_P_text_2))
-  , ((isoiec_9798_2_5_udkey_A, ''Text5''),
-     (KnownT isoiec_9798_2_5_udkey_A_text_3))
-  , ((isoiec_9798_2_5_udkey_B, ''Text5''),
-     (KnownT isoiec_9798_2_5_udkey_B_3))
-  , ((isoiec_9798_2_5_udkey_A, ''Text6''),
-     (KnownT isoiec_9798_2_5_udkey_A_text_3))
-  , ((isoiec_9798_2_5_udkey_B, ''Text6''),
-     (KnownT isoiec_9798_2_5_udkey_B_3))
-  , ((isoiec_9798_2_5_udkey_A, ''Text7''),
-     (KnownT isoiec_9798_2_5_udkey_A_4))
-  , ((isoiec_9798_2_5_udkey_B, ''Text7''),
-     (KnownT isoiec_9798_2_5_udkey_B_text_4))
-  , ((isoiec_9798_2_5_udkey_A, ''Text8''),
-     (KnownT isoiec_9798_2_5_udkey_A_4))
-  , ((isoiec_9798_2_5_udkey_B, ''Text8''),
-     (KnownT isoiec_9798_2_5_udkey_B_text_4))
-  , ((isoiec_9798_2_5_udkey_A, ''TokenPA_for_B''),
-     (KnownT isoiec_9798_2_5_udkey_A_2))
-  ]"
-
-sublocale isoiec_9798_2_5_udkey_state < isoiec_9798_2_5_udkey_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_2_5_udkey_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_2_5_udkey_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_2_5_udkey_A_2_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
-            |}
-            ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_udkey_A_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
-            |}
-            ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_udkey_A_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_A_2_TokenPA_for_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_A_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_A_text_3_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_A_4_TNb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
-               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_udkey_A_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
-               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_udkey_A_4_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_B_3_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_B_3_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-            |}
-            ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_udkey_B_3_P t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_B_3_TNa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
-               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_udkey_B_3_TNp t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-            |}
-            ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_udkey_B_3_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-            |}
-            ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_udkey_B_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
-               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_5_udkey_B_3_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_B_text_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_B_text_4_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_P_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_P_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_P_1_TVPa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_P_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_P_text_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_P_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_5_udkey_P_text_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_2_5_udkey_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_2_5_udkey_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_2_5_udkey_state) P_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_P"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "LN ''Kab'' tid0 : knows t"
-  shows "False"
-using facts proof(sources! " LN ''Kab'' tid0 ")
-  case isoiec_9798_2_5_udkey_P_2_Kab note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-next
-  case isoiec_9798_2_5_udkey_P_2_Kab_1 note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-qed (insert facts, fastsimp+)?
-
-lemma (in restricted_isoiec_9798_2_5_udkey_state) A_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_udkey_A_2 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_udkey_P_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_5_udkey_state) B_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_udkey_B_3 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-                       |}
-                       ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_udkey_P_2_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_5_udkey_state) A_non_injective_agreement_B:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_udkey_A_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_udkey_B &
-        ( tid1, isoiec_9798_2_5_udkey_B_4 ) : steps t &
-        {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
-           s(MV ''Kab'' tid1), s(MV ''TNa'' tid1), s(MV ''Text5'' tid1),
-           LN ''TNb'' tid1, s(MV ''Text7'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
-                s(MV ''Kab'' tid0), LN ''TNa'' tid0, s(MV ''Text5'' tid0),
-                s(MV ''TNb'' tid0), s(MV ''Text7'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_udkey_P_2_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
-                            s(AV ''A'' tid0), s(MV ''Text7'' tid0)
-                         |}
-                         ( LN ''Kab'' tid1 ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-    next
-      case (isoiec_9798_2_5_udkey_B_4_enc tid2) note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid2),
-                              LN ''Kab'' tid1, s(AV ''A'' tid0), s(MV ''Text2'' tid2)
-                           |}
-                           ( K ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_5_udkey_P_2_enc_1 tid3) note_unified facts = this facts
-        thus ?thesis proof(sources! "
-                         Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid2),
-                                s(AV ''B'' tid0), s(MV ''Text5'' tid2)
-                             |}
-                             ( LN ''Kab'' tid1 ) ")
-          case fake note_unified facts = this facts
-          thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-        next
-          case (isoiec_9798_2_5_udkey_A_3_enc tid3) note_unified facts = this facts
-          thus ?thesis proof(sources! "
-                           Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid3, LN ''Kab'' tid1,
-                                  s(AV ''B'' tid0), s(MV ''Text3'' tid3)
-                               |}
-                               ( K ( s(AV ''A'' tid3) ) ( s(AV ''P'' tid3) ) ) ")
-            case fake note_unified facts = this facts
-            thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-          next
-            case (isoiec_9798_2_5_udkey_P_2_enc tid4) note_unified facts = this facts
-            thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-          qed (insert facts, fastsimp+)?
-        qed (insert facts, fastsimp+)?
-      qed (insert facts, fastsimp+)?
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_5_udkey_state) B_non_injective_agreement_A:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_udkey_B_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_udkey_A &
-        ( tid1, isoiec_9798_2_5_udkey_A_3 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Kab'' tid1), LN ''TNa'' tid1, s(MV ''Text5'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                s(MV ''Kab'' tid0), s(MV ''TNa'' tid0), s(MV ''Text5'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-                       |}
-                       ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_udkey_P_2_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
-                            s(AV ''B'' tid0), s(MV ''Text5'' tid0)
-                         |}
-                         ( LN ''Kab'' tid1 ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-    next
-      case (isoiec_9798_2_5_udkey_A_3_enc tid2) note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid2, LN ''Kab'' tid1,
-                              s(AV ''B'' tid0), s(MV ''Text3'' tid2)
-                           |}
-                           ( K ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_5_udkey_P_2_enc tid3) note_unified facts = this facts
-        thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-      qed (insert facts, fastsimp+)?
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_5_udkey_state) A_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_udkey_A_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_udkey_P &
-        ( tid1, isoiec_9798_2_5_udkey_P_2 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
-           s(MV ''TVPa'' tid1), s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
-                s(MV ''Kab'' tid0), LN ''TVPa'' tid0, s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_udkey_P_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_5_udkey_state) B_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_5_udkey_B_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_5_udkey_P &
-        ( tid1, isoiec_9798_2_5_udkey_P_2 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
-           LN ''TNp'' tid1, s(MV ''Text2'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                s(MV ''Kab'' tid0), s(MV ''TNp'' tid0), s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
-                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
-                       |}
-                       ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_5_udkey_P_2_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-role isoiec_9798_2_6_udkey_A
-where "isoiec_9798_2_6_udkey_A =
-  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
-  , Recv ''text_2'' ( sMV ''Text2'' )
-  , Send ''2'' <| sAV ''A'', sAV ''P'', sN ''Ra'', sMV ''Rb'', sMV ''B'',
-                  sMV ''Text2''
-               |>
-  , Recv ''3'' <| sAV ''P'', sAV ''A'', sMV ''Text5'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_3_1'', sN ''Ra'', sMV ''Kab'',
-                          sMV ''B'', sMV ''Text4''
-                       |>
-                       ( sK ''A'' ''P'' ),
-                  sMV ''TokenPA_for_B''
-               |>
-  , Recv ''text_4'' <| sMV ''Text6'', sMV ''Text7'' |>
-  , Send ''4'' <| sAV ''A'', sMV ''B'', sMV ''Text7'', sAV ''P'',
-                  sMV ''TokenPA_for_B'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_4'', sN ''Rpa'', sMV ''Rb'',
-                          sMV ''Text6''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''5'' <| sMV ''B'', sAV ''A'', sMV ''Text9'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_5'', sMV ''Rb'', sN ''Rpa'',
-                          sMV ''Text8''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_6_udkey_B
-where "isoiec_9798_2_6_udkey_B =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
-  , Recv ''4'' <| sAV ''A'', sAV ''B'', sMV ''Text7'', sMV ''P'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_3_2'', sN ''Rb'', sMV ''Kab'',
-                          sAV ''A'', sMV ''Text3''
-                       |>
-                       ( PSymK ( sAV ''B'' ) ( sMV ''P'' ) ),
-                  PEnc <| sC ''isoiec_9798_2_6_enc_4'', sMV ''Rpa'', sN ''Rb'',
-                          sMV ''Text6''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
-  , Send ''5'' <| sAV ''B'', sAV ''A'', sMV ''Text9'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_5'', sN ''Rb'', sMV ''Rpa'',
-                          sMV ''Text8''
-                       |>
-                       ( sMV ''Kab'' )
-               |>
-  ]"
-
-role isoiec_9798_2_6_udkey_P
-where "isoiec_9798_2_6_udkey_P =
-  [ Recv ''2'' <| sMV ''A'', sAV ''P'', sMV ''Ra'', sMV ''Rb'', sMV ''B'',
-                  sMV ''Text2''
-               |>
-  , Recv ''text_3'' <| sMV ''Text3'', sMV ''Text4'', sMV ''Text5'' |>
-  , Send ''3'' <| sAV ''P'', sMV ''A'', sMV ''Text5'',
-                  PEnc <| sC ''isoiec_9798_2_6_enc_3_1'', sMV ''Ra'', sN ''Kab'',
-                          sMV ''B'', sMV ''Text4''
-                       |>
-                       ( PSymK ( sMV ''A'' ) ( sAV ''P'' ) ),
-                  PEnc <| sC ''isoiec_9798_2_6_enc_3_2'', sMV ''Rb'', sN ''Kab'',
-                          sMV ''A'', sMV ''Text3''
-                       |>
-                       ( PSymK ( sMV ''B'' ) ( sAV ''P'' ) )
-               |>
-  ]"
-
-protocol isoiec_9798_2_6_udkey
-where "isoiec_9798_2_6_udkey =
-{ isoiec_9798_2_6_udkey_A, isoiec_9798_2_6_udkey_B,
-  isoiec_9798_2_6_udkey_P
-}"
-
-locale restricted_isoiec_9798_2_6_udkey_state = isoiec_9798_2_6_udkey_state
-
-type_invariant isoiec_9798_2_6_udkey_msc_typing for isoiec_9798_2_6_udkey
-where "isoiec_9798_2_6_udkey_msc_typing = mk_typing
-  [ ((isoiec_9798_2_6_udkey_P, ''A''), (KnownT isoiec_9798_2_6_udkey_P_2))
-  , ((isoiec_9798_2_6_udkey_A, ''B''), (KnownT isoiec_9798_2_6_udkey_A_1))
-  , ((isoiec_9798_2_6_udkey_P, ''B''), (KnownT isoiec_9798_2_6_udkey_P_2))
-  , ((isoiec_9798_2_6_udkey_A, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_6_udkey_A_3) (NonceT isoiec_9798_2_6_udkey_P ''Kab'')))
-  , ((isoiec_9798_2_6_udkey_B, ''Kab''),
-     (SumT (KnownT isoiec_9798_2_6_udkey_B_4) (NonceT isoiec_9798_2_6_udkey_P ''Kab'')))
-  , ((isoiec_9798_2_6_udkey_B, ''P''), (KnownT isoiec_9798_2_6_udkey_B_4))
-  , ((isoiec_9798_2_6_udkey_P, ''Ra''), (KnownT isoiec_9798_2_6_udkey_P_2))
-  , ((isoiec_9798_2_6_udkey_A, ''Rb''), (KnownT isoiec_9798_2_6_udkey_A_1))
-  , ((isoiec_9798_2_6_udkey_P, ''Rb''), (KnownT isoiec_9798_2_6_udkey_P_2))
-  , ((isoiec_9798_2_6_udkey_B, ''Rpa''),
-     (SumT (KnownT isoiec_9798_2_6_udkey_B_4) (NonceT isoiec_9798_2_6_udkey_A ''Rpa'')))
-  , ((isoiec_9798_2_6_udkey_A, ''Text1''),
-     (KnownT isoiec_9798_2_6_udkey_A_1))
-  , ((isoiec_9798_2_6_udkey_B, ''Text1''),
-     (KnownT isoiec_9798_2_6_udkey_B_text_1))
-  , ((isoiec_9798_2_6_udkey_A, ''Text2''),
-     (KnownT isoiec_9798_2_6_udkey_A_text_2))
-  , ((isoiec_9798_2_6_udkey_P, ''Text2''),
-     (KnownT isoiec_9798_2_6_udkey_P_2))
-  , ((isoiec_9798_2_6_udkey_B, ''Text3''),
-     (KnownT isoiec_9798_2_6_udkey_B_4))
-  , ((isoiec_9798_2_6_udkey_P, ''Text3''),
-     (KnownT isoiec_9798_2_6_udkey_P_text_3))
-  , ((isoiec_9798_2_6_udkey_A, ''Text4''),
-     (KnownT isoiec_9798_2_6_udkey_A_3))
-  , ((isoiec_9798_2_6_udkey_P, ''Text4''),
-     (KnownT isoiec_9798_2_6_udkey_P_text_3))
-  , ((isoiec_9798_2_6_udkey_A, ''Text5''),
-     (KnownT isoiec_9798_2_6_udkey_A_3))
-  , ((isoiec_9798_2_6_udkey_P, ''Text5''),
-     (KnownT isoiec_9798_2_6_udkey_P_text_3))
-  , ((isoiec_9798_2_6_udkey_A, ''Text6''),
-     (KnownT isoiec_9798_2_6_udkey_A_text_4))
-  , ((isoiec_9798_2_6_udkey_B, ''Text6''),
-     (KnownT isoiec_9798_2_6_udkey_B_4))
-  , ((isoiec_9798_2_6_udkey_A, ''Text7''),
-     (KnownT isoiec_9798_2_6_udkey_A_text_4))
-  , ((isoiec_9798_2_6_udkey_B, ''Text7''),
-     (KnownT isoiec_9798_2_6_udkey_B_4))
-  , ((isoiec_9798_2_6_udkey_A, ''Text8''),
-     (KnownT isoiec_9798_2_6_udkey_A_5))
-  , ((isoiec_9798_2_6_udkey_B, ''Text8''),
-     (KnownT isoiec_9798_2_6_udkey_B_text_5))
-  , ((isoiec_9798_2_6_udkey_A, ''Text9''),
-     (KnownT isoiec_9798_2_6_udkey_A_5))
-  , ((isoiec_9798_2_6_udkey_B, ''Text9''),
-     (KnownT isoiec_9798_2_6_udkey_B_text_5))
-  , ((isoiec_9798_2_6_udkey_A, ''TokenPA_for_B''),
-     (KnownT isoiec_9798_2_6_udkey_A_3))
-  ]"
-
-sublocale isoiec_9798_2_6_udkey_state < isoiec_9798_2_6_udkey_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_2_6_udkey_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_2_6_udkey_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_2_6_udkey_A_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_A_1_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_A_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_A_3_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
-               s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
-            |}
-            ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_udkey_A_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
-               s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
-            |}
-            ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_udkey_A_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_A_3_TokenPA_for_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_A_text_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_A_text_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_A_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_5'', s(MV ''Rb'' tid0), LN ''Rpa'' tid0,
-               s(MV ''Text8'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_udkey_A_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_B_4_Kab t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-            |}
-            ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_udkey_B_4_P t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_B_4_Rpa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
-               s(MV ''Text6'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_udkey_B_4_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
-               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-            |}
-            ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_udkey_B_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
-               s(MV ''Text6'' tid0)
-            |}
-            ( s(MV ''Kab'' tid0) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_2_6_udkey_B_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_B_text_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_B_text_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_P_2_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_P_2_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_P_2_Ra t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_P_2_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_P_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_P_text_3_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_P_text_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_2_6_udkey_P_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_2_6_udkey_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_2_6_udkey_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_2_6_udkey_state) P_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_udkey_P"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "LN ''Kab'' tid0 : knows t"
-  shows "False"
-using facts proof(sources! " LN ''Kab'' tid0 ")
-  case isoiec_9798_2_6_udkey_P_3_Kab note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-next
-  case isoiec_9798_2_6_udkey_P_3_Kab_1 note_unified facts = this facts
-  thus ?thesis by (fastsimp dest!: ltk_secrecy)
-qed (insert facts, fastsimp+)?
-
-lemma (in restricted_isoiec_9798_2_6_udkey_state) A_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_udkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_udkey_A_3 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
-                          s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
-                       |}
-                       ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_udkey_P_3_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_6_udkey_state) B_secret_Kab:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_udkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_udkey_B_4 ) : steps t"
-    "s(MV ''Kab'' tid0) : knows t"
-  shows "False"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_udkey_P_3_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_6_udkey_state) A_non_injective_agreement_B:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_udkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_udkey_A_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_udkey_B &
-        ( tid1, isoiec_9798_2_6_udkey_B_5 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
-           s(MV ''Kab'' tid1), s(MV ''Rpa'' tid1), LN ''Rb'' tid1,
-           s(MV ''Text6'' tid1), s(MV ''Text8'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
-                s(MV ''Kab'' tid0), LN ''Rpa'' tid0, s(MV ''Rb'' tid0),
-                s(MV ''Text6'' tid0), s(MV ''Text8'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
-                          s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
-                       |}
-                       ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_udkey_P_3_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_2_6_enc_5'', s(MV ''Rb'' tid0), LN ''Rpa'' tid0,
-                            s(MV ''Text8'' tid0)
-                         |}
-                         ( LN ''Kab'' tid1 ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-    next
-      case (isoiec_9798_2_6_udkey_B_5_enc tid2) note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid2, LN ''Kab'' tid1,
-                              s(AV ''A'' tid2), s(MV ''Text3'' tid2)
-                           |}
-                           ( K ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_6_udkey_P_3_enc_1 tid3) note_unified facts = this facts
-        thus ?thesis proof(sources! "
-                         Enc {| LC ''isoiec_9798_2_6_enc_4'', LN ''Rpa'' tid0, LN ''Rb'' tid2,
-                                s(MV ''Text6'' tid2)
-                             |}
-                             ( LN ''Kab'' tid1 ) ")
-          case fake note_unified facts = this facts
-          thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-        next
-          case (isoiec_9798_2_6_udkey_A_4_enc tid3) note_unified facts = this facts
-          thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-        qed (insert facts, fastsimp+)?
-      qed (insert facts, fastsimp+)?
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_6_udkey_state) B_non_injective_agreement_A:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_udkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_udkey_B_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_udkey_A &
-        ( tid1, isoiec_9798_2_6_udkey_A_4 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Kab'' tid1), LN ''Rpa'' tid1, s(MV ''Rb'' tid1),
-           s(MV ''Text6'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                s(MV ''Kab'' tid0), s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
-                s(MV ''Text6'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_udkey_P_3_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
-                            s(MV ''Text6'' tid0)
-                         |}
-                         ( LN ''Kab'' tid1 ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-    next
-      case (isoiec_9798_2_6_udkey_A_4_enc tid2) note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid2, LN ''Kab'' tid1,
-                              s(MV ''B'' tid2), s(MV ''Text4'' tid2)
-                           |}
-                           ( K ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest: P_secret_Kab intro: event_predOrdI)
-      next
-        case (isoiec_9798_2_6_udkey_P_3_enc tid3) note_unified facts = this facts
-        thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-      qed (insert facts, fastsimp+)?
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_6_udkey_state) A_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_udkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_udkey_A_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_udkey_P &
-        ( tid1, isoiec_9798_2_6_udkey_P_3 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Ra'' tid1), LN ''Kab'' tid1, s(MV ''Text4'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
-                LN ''Ra'' tid0, s(MV ''Kab'' tid0), s(MV ''Text4'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
-                          s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
-                       |}
-                       ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_udkey_P_3_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_2_6_udkey_state) B_non_injective_agreement_P:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_2_6_udkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_2_6_udkey_B_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_2_6_udkey_P &
-        ( tid1, isoiec_9798_2_6_udkey_P_3 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
-           s(MV ''Rb'' tid1), LN ''Kab'' tid1, s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
-                LN ''Rb'' tid0, s(MV ''Kab'' tid0), s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
-                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_2_6_udkey_P_3_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+  "ESPLogic"
+begin
+
+role isoiec_9798_2_1_udkey_A
+where "isoiec_9798_2_1_udkey_A =
+  [ Send ''leak_A'' ( sN ''TNA'' )
+  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
+  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
+                  PEnc <| sC ''isoiec_9798_2_1_enc_1'', sN ''TNA'', sMV ''Text1'' |>
+                       ( sK ''A'' ''B'' )
+               |>
+  ]"
+
+role isoiec_9798_2_1_udkey_B
+where "isoiec_9798_2_1_udkey_B =
+  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
+                  PEnc <| sC ''isoiec_9798_2_1_enc_1'', sMV ''TNA'', sMV ''Text1'' |>
+                       ( PSymK ( sMV ''A'' ) ( sAV ''B'' ) )
+               |>
+  ]"
+
+protocol isoiec_9798_2_1_udkey
+where "isoiec_9798_2_1_udkey =
+{ isoiec_9798_2_1_udkey_A, isoiec_9798_2_1_udkey_B }"
+
+locale restricted_isoiec_9798_2_1_udkey_state = isoiec_9798_2_1_udkey_state
+
+type_invariant isoiec_9798_2_1_udkey_msc_typing for isoiec_9798_2_1_udkey
+where "isoiec_9798_2_1_udkey_msc_typing = mk_typing
+  [ ((isoiec_9798_2_1_udkey_B, ''A''), (KnownT isoiec_9798_2_1_udkey_B_1))
+  , ((isoiec_9798_2_1_udkey_B, ''TNA''),
+     (SumT (KnownT isoiec_9798_2_1_udkey_B_1) (NonceT isoiec_9798_2_1_udkey_A ''TNA'')))
+  , ((isoiec_9798_2_1_udkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_1_udkey_A_text_1))
+  , ((isoiec_9798_2_1_udkey_B, ''Text1''),
+     (KnownT isoiec_9798_2_1_udkey_B_1))
+  , ((isoiec_9798_2_1_udkey_A, ''Text2''),
+     (KnownT isoiec_9798_2_1_udkey_A_text_1))
+  , ((isoiec_9798_2_1_udkey_B, ''Text2''),
+     (KnownT isoiec_9798_2_1_udkey_B_1))
+  ]"
+
+sublocale isoiec_9798_2_1_udkey_state < isoiec_9798_2_1_udkey_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_2_1_udkey_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_2_1_udkey_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_2_1_udkey_A_text_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_1_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_1_udkey_A_text_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_1_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_1_udkey_B_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_1_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_1_udkey_B_1_TNA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_1_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
+               s(MV ''Text1'' tid0)
+            |}
+            ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_1_udkey_B_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_1_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
+               s(MV ''Text1'' tid0)
+            |}
+            ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_1_udkey_B_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_1_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_2_1_udkey_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_2_1_udkey_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_2_1_udkey_state) B_non_injective_agreement:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_1_udkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_1_udkey_B_1 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_1_udkey_A &
+        ( tid1, isoiec_9798_2_1_udkey_A_1 ) : steps t &
+        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
+           s(MV ''Text1'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
+                s(MV ''Text1'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_1_enc_1'', s(MV ''TNA'' tid0),
+                          s(MV ''Text1'' tid0)
+                       |}
+                       ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_1_udkey_A_1_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
+qed
+
+role isoiec_9798_2_2_udkey_A
+where "isoiec_9798_2_2_udkey_A =
+  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text1'' |>
+  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
+  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
+                  PEnc <| sC ''isoiec_9798_2_2_enc_2'', sMV ''RB'', sMV ''Text2'' |>
+                       ( PSymK ( sAV ''A'' ) ( sMV ''B'' ) )
+               |>
+  ]"
+
+role isoiec_9798_2_2_udkey_B
+where "isoiec_9798_2_2_udkey_B =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''RB'', sMV ''Text1'' |>
+  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
+                  PEnc <| sC ''isoiec_9798_2_2_enc_2'', sN ''RB'', sMV ''Text2'' |>
+                       ( sK ''A'' ''B'' )
+               |>
+  ]"
+
+protocol isoiec_9798_2_2_udkey
+where "isoiec_9798_2_2_udkey =
+{ isoiec_9798_2_2_udkey_A, isoiec_9798_2_2_udkey_B }"
+
+locale restricted_isoiec_9798_2_2_udkey_state = isoiec_9798_2_2_udkey_state
+
+type_invariant isoiec_9798_2_2_udkey_msc_typing for isoiec_9798_2_2_udkey
+where "isoiec_9798_2_2_udkey_msc_typing = mk_typing
+  [ ((isoiec_9798_2_2_udkey_A, ''B''), (KnownT isoiec_9798_2_2_udkey_A_1))
+  , ((isoiec_9798_2_2_udkey_A, ''RB''), (KnownT isoiec_9798_2_2_udkey_A_1))
+  , ((isoiec_9798_2_2_udkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_2_udkey_A_1))
+  , ((isoiec_9798_2_2_udkey_B, ''Text1''),
+     (KnownT isoiec_9798_2_2_udkey_B_text_1))
+  , ((isoiec_9798_2_2_udkey_A, ''Text2''),
+     (KnownT isoiec_9798_2_2_udkey_A_text_2))
+  , ((isoiec_9798_2_2_udkey_B, ''Text2''),
+     (KnownT isoiec_9798_2_2_udkey_B_2))
+  , ((isoiec_9798_2_2_udkey_A, ''Text3''),
+     (KnownT isoiec_9798_2_2_udkey_A_text_2))
+  , ((isoiec_9798_2_2_udkey_B, ''Text3''),
+     (KnownT isoiec_9798_2_2_udkey_B_2))
+  ]"
+
+sublocale isoiec_9798_2_2_udkey_state < isoiec_9798_2_2_udkey_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_2_2_udkey_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_2_2_udkey_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_2_2_udkey_A_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_2_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_2_udkey_A_1_RB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_2_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_2_udkey_A_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_2_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_2_udkey_A_text_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_2_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_2_udkey_A_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_2_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_2_udkey_B_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_2_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_2_enc_2'', LN ''RB'' tid0, s(MV ''Text2'' tid0)
+            |}
+            ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_2_udkey_B_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_2_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_2_2_udkey_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_2_2_udkey_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_2_2_udkey_state) B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_2_udkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_2_udkey_B_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_2_udkey_A &
+          ( tid1, isoiec_9798_2_2_udkey_A_2 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(MV ''RB'' tid1),
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''RB'' tid0,
+                  s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_2_enc_2'', LN ''RB'' tid0, s(MV ''Text2'' tid0)
+                           |}
+                           ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_2_udkey_A_2_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+role isoiec_9798_2_3_udkey_A
+where "isoiec_9798_2_3_udkey_A =
+  [ Send ''leak_A'' ( sN ''TNA'' )
+  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
+  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
+                  PEnc <| sC ''isoiec_9798_2_3_enc_1'', sN ''TNA'', sMV ''Text1'' |>
+                       ( sK ''A'' ''B'' )
+               |>
+  , Recv ''2'' <| sAV ''B'', sAV ''A'', sMV ''Text4'',
+                  PEnc <| sC ''isoiec_9798_2_3_enc_2'', sMV ''TNB'', sMV ''Text3'' |>
+                       ( sK ''B'' ''A'' )
+               |>
+  ]"
+
+role isoiec_9798_2_3_udkey_B
+where "isoiec_9798_2_3_udkey_B =
+  [ Send ''leak_B'' ( sN ''TNB'' )
+  , Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
+                  PEnc <| sC ''isoiec_9798_2_3_enc_1'', sMV ''TNA'', sMV ''Text1'' |>
+                       ( PSymK ( sMV ''A'' ) ( sAV ''B'' ) )
+               |>
+  , Recv ''text_2'' <| sMV ''Text3'', sMV ''Text4'' |>
+  , Send ''2'' <| sAV ''B'', sMV ''A'', sMV ''Text4'',
+                  PEnc <| sC ''isoiec_9798_2_3_enc_2'', sN ''TNB'', sMV ''Text3'' |>
+                       ( PSymK ( sAV ''B'' ) ( sMV ''A'' ) )
+               |>
+  ]"
+
+protocol isoiec_9798_2_3_udkey
+where "isoiec_9798_2_3_udkey =
+{ isoiec_9798_2_3_udkey_A, isoiec_9798_2_3_udkey_B }"
+
+locale restricted_isoiec_9798_2_3_udkey_state = isoiec_9798_2_3_udkey_state
+
+type_invariant isoiec_9798_2_3_udkey_msc_typing for isoiec_9798_2_3_udkey
+where "isoiec_9798_2_3_udkey_msc_typing = mk_typing
+  [ ((isoiec_9798_2_3_udkey_B, ''A''), (KnownT isoiec_9798_2_3_udkey_B_1))
+  , ((isoiec_9798_2_3_udkey_B, ''TNA''),
+     (SumT (KnownT isoiec_9798_2_3_udkey_B_1) (NonceT isoiec_9798_2_3_udkey_A ''TNA'')))
+  , ((isoiec_9798_2_3_udkey_A, ''TNB''),
+     (SumT (KnownT isoiec_9798_2_3_udkey_A_2) (NonceT isoiec_9798_2_3_udkey_B ''TNB'')))
+  , ((isoiec_9798_2_3_udkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_3_udkey_A_text_1))
+  , ((isoiec_9798_2_3_udkey_B, ''Text1''),
+     (KnownT isoiec_9798_2_3_udkey_B_1))
+  , ((isoiec_9798_2_3_udkey_A, ''Text2''),
+     (KnownT isoiec_9798_2_3_udkey_A_text_1))
+  , ((isoiec_9798_2_3_udkey_B, ''Text2''),
+     (KnownT isoiec_9798_2_3_udkey_B_1))
+  , ((isoiec_9798_2_3_udkey_A, ''Text3''),
+     (KnownT isoiec_9798_2_3_udkey_A_2))
+  , ((isoiec_9798_2_3_udkey_B, ''Text3''),
+     (KnownT isoiec_9798_2_3_udkey_B_text_2))
+  , ((isoiec_9798_2_3_udkey_A, ''Text4''),
+     (KnownT isoiec_9798_2_3_udkey_A_2))
+  , ((isoiec_9798_2_3_udkey_B, ''Text4''),
+     (KnownT isoiec_9798_2_3_udkey_B_text_2))
+  ]"
+
+sublocale isoiec_9798_2_3_udkey_state < isoiec_9798_2_3_udkey_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_2_3_udkey_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_2_3_udkey_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_2_3_udkey_A_text_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_3_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_udkey_A_text_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_3_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_udkey_A_2_TNB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_3_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
+               s(MV ''Text3'' tid0)
+            |}
+            ( K ( s(AV ''B'' tid0) ) ( s(AV ''A'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_3_udkey_A_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_3_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
+               s(MV ''Text3'' tid0)
+            |}
+            ( K ( s(AV ''B'' tid0) ) ( s(AV ''A'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_3_udkey_A_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_3_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_udkey_B_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_3_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_udkey_B_1_TNA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_3_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
+               s(MV ''Text1'' tid0)
+            |}
+            ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_3_udkey_B_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_3_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
+               s(MV ''Text1'' tid0)
+            |}
+            ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_3_udkey_B_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_3_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_udkey_B_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_3_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_3_udkey_B_text_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_3_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_2_3_udkey_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_2_3_udkey_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_2_3_udkey_state) A_non_injective_agreement:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_3_udkey_A"
+    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_3_udkey_A_2 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_3_udkey_B &
+        ( tid1, isoiec_9798_2_3_udkey_B_2 ) : steps t &
+        {| s(MV ''A'' tid1), s(AV ''B'' tid1), LN ''TNB'' tid1,
+           s(MV ''Text3'' tid1)
+        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNB'' tid0),
+                s(MV ''Text3'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_3_enc_2'', s(MV ''TNB'' tid0),
+                          s(MV ''Text3'' tid0)
+                       |}
+                       ( K ( s(AV ''B'' tid0) ) ( s(AV ''A'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_3_udkey_B_2_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_3_udkey_state) B_non_injective_agreement:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_3_udkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_3_udkey_B_2 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_3_udkey_A &
+        ( tid1, isoiec_9798_2_3_udkey_A_1 ) : steps t &
+        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
+           s(MV ''Text1'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
+                s(MV ''Text1'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_3_enc_1'', s(MV ''TNA'' tid0),
+                          s(MV ''Text1'' tid0)
+                       |}
+                       ( K ( s(MV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_3_udkey_A_1_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
+qed
+
+role isoiec_9798_2_4_udkey_A
+where "isoiec_9798_2_4_udkey_A =
+  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text1'' |>
+  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
+  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
+                  PEnc <| sC ''isoiec_9798_2_4_enc_1'', sN ''RA'', sMV ''RB'',
+                          sMV ''Text2''
+                       |>
+                       ( PSymK ( sAV ''A'' ) ( sMV ''B'' ) )
+               |>
+  , Recv ''3'' <| sMV ''B'', sAV ''A'', sMV ''Text5'',
+                  PEnc <| sC ''isoiec_9798_2_4_enc_2'', sMV ''RB'', sN ''RA'',
+                          sMV ''Text4''
+                       |>
+                       ( PSymK ( sMV ''B'' ) ( sAV ''A'' ) )
+               |>
+  ]"
+
+role isoiec_9798_2_4_udkey_B
+where "isoiec_9798_2_4_udkey_B =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''RB'', sMV ''Text1'' |>
+  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
+                  PEnc <| sC ''isoiec_9798_2_4_enc_1'', sMV ''RA'', sN ''RB'',
+                          sMV ''Text2''
+                       |>
+                       ( sK ''A'' ''B'' )
+               |>
+  , Recv ''text_3'' <| sMV ''Text4'', sMV ''Text5'' |>
+  , Send ''3'' <| sAV ''B'', sAV ''A'', sMV ''Text5'',
+                  PEnc <| sC ''isoiec_9798_2_4_enc_2'', sN ''RB'', sMV ''RA'',
+                          sMV ''Text4''
+                       |>
+                       ( sK ''B'' ''A'' )
+               |>
+  ]"
+
+protocol isoiec_9798_2_4_udkey
+where "isoiec_9798_2_4_udkey =
+{ isoiec_9798_2_4_udkey_A, isoiec_9798_2_4_udkey_B }"
+
+locale restricted_isoiec_9798_2_4_udkey_state = isoiec_9798_2_4_udkey_state
+
+type_invariant isoiec_9798_2_4_udkey_msc_typing for isoiec_9798_2_4_udkey
+where "isoiec_9798_2_4_udkey_msc_typing = mk_typing
+  [ ((isoiec_9798_2_4_udkey_A, ''B''), (KnownT isoiec_9798_2_4_udkey_A_1))
+  , ((isoiec_9798_2_4_udkey_B, ''RA''),
+     (SumT (KnownT isoiec_9798_2_4_udkey_B_2) (NonceT isoiec_9798_2_4_udkey_A ''RA'')))
+  , ((isoiec_9798_2_4_udkey_A, ''RB''), (KnownT isoiec_9798_2_4_udkey_A_1))
+  , ((isoiec_9798_2_4_udkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_4_udkey_A_1))
+  , ((isoiec_9798_2_4_udkey_B, ''Text1''),
+     (KnownT isoiec_9798_2_4_udkey_B_text_1))
+  , ((isoiec_9798_2_4_udkey_A, ''Text2''),
+     (KnownT isoiec_9798_2_4_udkey_A_text_2))
+  , ((isoiec_9798_2_4_udkey_B, ''Text2''),
+     (KnownT isoiec_9798_2_4_udkey_B_2))
+  , ((isoiec_9798_2_4_udkey_A, ''Text3''),
+     (KnownT isoiec_9798_2_4_udkey_A_text_2))
+  , ((isoiec_9798_2_4_udkey_B, ''Text3''),
+     (KnownT isoiec_9798_2_4_udkey_B_2))
+  , ((isoiec_9798_2_4_udkey_A, ''Text4''),
+     (KnownT isoiec_9798_2_4_udkey_A_3))
+  , ((isoiec_9798_2_4_udkey_B, ''Text4''),
+     (KnownT isoiec_9798_2_4_udkey_B_text_3))
+  , ((isoiec_9798_2_4_udkey_A, ''Text5''),
+     (KnownT isoiec_9798_2_4_udkey_A_3))
+  , ((isoiec_9798_2_4_udkey_B, ''Text5''),
+     (KnownT isoiec_9798_2_4_udkey_B_text_3))
+  ]"
+
+sublocale isoiec_9798_2_4_udkey_state < isoiec_9798_2_4_udkey_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_2_4_udkey_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_2_4_udkey_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_2_4_udkey_A_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_udkey_A_1_RB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_udkey_A_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_udkey_A_text_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_udkey_A_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_udkey_A_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_4_enc_2'', s(MV ''RB'' tid0), LN ''RA'' tid0,
+               s(MV ''Text4'' tid0)
+            |}
+            ( K ( s(MV ''B'' tid0) ) ( s(AV ''A'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_4_udkey_A_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_udkey_B_2_RA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
+               s(MV ''Text2'' tid0)
+            |}
+            ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_4_udkey_B_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
+               s(MV ''Text2'' tid0)
+            |}
+            ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_4_udkey_B_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_udkey_B_text_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_4_udkey_B_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_4_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_2_4_udkey_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_2_4_udkey_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_2_4_udkey_state) A_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_4_udkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_4_udkey_A_3 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_4_udkey_B &
+          ( tid1, isoiec_9798_2_4_udkey_B_3 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''RA'' tid1), LN ''RB'' tid1,
+             s(MV ''Text2'' tid1), s(MV ''Text4'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''RA'' tid0,
+                  s(MV ''RB'' tid0), s(MV ''Text2'' tid0), s(MV ''Text4'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_4_enc_2'', s(MV ''RB'' tid0), LN ''RA'' tid0,
+                              s(MV ''Text4'' tid0)
+                           |}
+                           ( K ( s(MV ''B'' tid0) ) ( s(AV ''A'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_4_udkey_B_3_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_2_4_enc_1'', LN ''RA'' tid0, LN ''RB'' tid1,
+                                s(MV ''Text2'' tid1)
+                             |}
+                             ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid1) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_2_4_udkey_A_2_enc tid2) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_4_udkey_state) B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_4_udkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_4_udkey_B_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_4_udkey_A &
+          ( tid1, isoiec_9798_2_4_udkey_A_2 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''RA'' tid1, s(MV ''RB'' tid1),
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''RA'' tid0),
+                  LN ''RB'' tid0, s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_4_enc_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
+                              s(MV ''Text2'' tid0)
+                           |}
+                           ( K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_4_udkey_A_2_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+role isoiec_9798_2_5_udkey_A
+where "isoiec_9798_2_5_udkey_A =
+  [ Send ''leak_A'' <| sN ''TVPa'', sN ''TNa'' |>
+  , Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''A'', sAV ''P'', sN ''TVPa'', sAV ''B'',
+                  sMV ''Text1''
+               |>
+  , Recv ''2'' <| sAV ''P'', sAV ''A'', sMV ''Text4'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_2_1'', sN ''TVPa'', sMV ''Kab'',
+                          sAV ''B'', sMV ''Text3''
+                       |>
+                       ( sK ''A'' ''P'' ),
+                  sMV ''TokenPA_for_B''
+               |>
+  , Recv ''text_3'' <| sMV ''Text5'', sMV ''Text6'' |>
+  , Send ''3'' <| sAV ''A'', sAV ''B'', sMV ''Text6'', sAV ''P'',
+                  sMV ''TokenPA_for_B'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_3'', sN ''TNa'', sAV ''B'',
+                          sMV ''Text5''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''4'' <| sAV ''B'', sAV ''A'', sMV ''Text8'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_4'', sMV ''TNb'', sAV ''A'',
+                          sMV ''Text7''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_5_udkey_B
+where "isoiec_9798_2_5_udkey_B =
+  [ Send ''leak_B'' ( sN ''TNb'' )
+  , Recv ''3'' <| sMV ''A'', sAV ''B'', sMV ''Text6'', sMV ''P'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_2_2'', sMV ''TNp'', sMV ''Kab'',
+                          sMV ''A'', sMV ''Text2''
+                       |>
+                       ( PSymK ( sAV ''B'' ) ( sMV ''P'' ) ),
+                  PEnc <| sC ''isoiec_9798_2_5_enc_3'', sMV ''TNa'', sAV ''B'',
+                          sMV ''Text5''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''text_4'' <| sMV ''Text7'', sMV ''Text8'' |>
+  , Send ''4'' <| sAV ''B'', sMV ''A'', sMV ''Text8'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_4'', sN ''TNb'', sMV ''A'',
+                          sMV ''Text7''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_5_udkey_P
+where "isoiec_9798_2_5_udkey_P =
+  [ Send ''leak_P'' ( sN ''TNp'' )
+  , Recv ''1'' <| sMV ''A'', sAV ''P'', sMV ''TVPa'', sMV ''B'',
+                  sMV ''Text1''
+               |>
+  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'', sMV ''Text4'' |>
+  , Send ''2'' <| sAV ''P'', sMV ''A'', sMV ''Text4'',
+                  PEnc <| sC ''isoiec_9798_2_5_enc_2_1'', sMV ''TVPa'', sN ''Kab'',
+                          sMV ''B'', sMV ''Text3''
+                       |>
+                       ( PSymK ( sMV ''A'' ) ( sAV ''P'' ) ),
+                  PEnc <| sC ''isoiec_9798_2_5_enc_2_2'', sN ''TNp'', sN ''Kab'',
+                          sMV ''A'', sMV ''Text2''
+                       |>
+                       ( PSymK ( sMV ''B'' ) ( sAV ''P'' ) )
+               |>
+  ]"
+
+protocol isoiec_9798_2_5_udkey
+where "isoiec_9798_2_5_udkey =
+{ isoiec_9798_2_5_udkey_A, isoiec_9798_2_5_udkey_B,
+  isoiec_9798_2_5_udkey_P
+}"
+
+locale restricted_isoiec_9798_2_5_udkey_state = isoiec_9798_2_5_udkey_state
+
+type_invariant isoiec_9798_2_5_udkey_msc_typing for isoiec_9798_2_5_udkey
+where "isoiec_9798_2_5_udkey_msc_typing = mk_typing
+  [ ((isoiec_9798_2_5_udkey_B, ''A''), (KnownT isoiec_9798_2_5_udkey_B_3))
+  , ((isoiec_9798_2_5_udkey_P, ''A''), (KnownT isoiec_9798_2_5_udkey_P_1))
+  , ((isoiec_9798_2_5_udkey_P, ''B''), (KnownT isoiec_9798_2_5_udkey_P_1))
+  , ((isoiec_9798_2_5_udkey_A, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_5_udkey_A_2) (NonceT isoiec_9798_2_5_udkey_P ''Kab'')))
+  , ((isoiec_9798_2_5_udkey_B, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_5_udkey_B_3) (NonceT isoiec_9798_2_5_udkey_P ''Kab'')))
+  , ((isoiec_9798_2_5_udkey_B, ''P''), (KnownT isoiec_9798_2_5_udkey_B_3))
+  , ((isoiec_9798_2_5_udkey_B, ''TNa''),
+     (SumT (KnownT isoiec_9798_2_5_udkey_B_3) (NonceT isoiec_9798_2_5_udkey_A ''TNa'')))
+  , ((isoiec_9798_2_5_udkey_A, ''TNb''),
+     (SumT (KnownT isoiec_9798_2_5_udkey_A_4) (NonceT isoiec_9798_2_5_udkey_B ''TNb'')))
+  , ((isoiec_9798_2_5_udkey_B, ''TNp''),
+     (SumT (KnownT isoiec_9798_2_5_udkey_B_3) (NonceT isoiec_9798_2_5_udkey_P ''TNp'')))
+  , ((isoiec_9798_2_5_udkey_P, ''TVPa''),
+     (KnownT isoiec_9798_2_5_udkey_P_1))
+  , ((isoiec_9798_2_5_udkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_5_udkey_A_text_1))
+  , ((isoiec_9798_2_5_udkey_P, ''Text1''),
+     (KnownT isoiec_9798_2_5_udkey_P_1))
+  , ((isoiec_9798_2_5_udkey_B, ''Text2''),
+     (KnownT isoiec_9798_2_5_udkey_B_3))
+  , ((isoiec_9798_2_5_udkey_P, ''Text2''),
+     (KnownT isoiec_9798_2_5_udkey_P_text_2))
+  , ((isoiec_9798_2_5_udkey_A, ''Text3''),
+     (KnownT isoiec_9798_2_5_udkey_A_2))
+  , ((isoiec_9798_2_5_udkey_P, ''Text3''),
+     (KnownT isoiec_9798_2_5_udkey_P_text_2))
+  , ((isoiec_9798_2_5_udkey_A, ''Text4''),
+     (KnownT isoiec_9798_2_5_udkey_A_2))
+  , ((isoiec_9798_2_5_udkey_P, ''Text4''),
+     (KnownT isoiec_9798_2_5_udkey_P_text_2))
+  , ((isoiec_9798_2_5_udkey_A, ''Text5''),
+     (KnownT isoiec_9798_2_5_udkey_A_text_3))
+  , ((isoiec_9798_2_5_udkey_B, ''Text5''),
+     (KnownT isoiec_9798_2_5_udkey_B_3))
+  , ((isoiec_9798_2_5_udkey_A, ''Text6''),
+     (KnownT isoiec_9798_2_5_udkey_A_text_3))
+  , ((isoiec_9798_2_5_udkey_B, ''Text6''),
+     (KnownT isoiec_9798_2_5_udkey_B_3))
+  , ((isoiec_9798_2_5_udkey_A, ''Text7''),
+     (KnownT isoiec_9798_2_5_udkey_A_4))
+  , ((isoiec_9798_2_5_udkey_B, ''Text7''),
+     (KnownT isoiec_9798_2_5_udkey_B_text_4))
+  , ((isoiec_9798_2_5_udkey_A, ''Text8''),
+     (KnownT isoiec_9798_2_5_udkey_A_4))
+  , ((isoiec_9798_2_5_udkey_B, ''Text8''),
+     (KnownT isoiec_9798_2_5_udkey_B_text_4))
+  , ((isoiec_9798_2_5_udkey_A, ''TokenPA_for_B''),
+     (KnownT isoiec_9798_2_5_udkey_A_2))
+  ]"
+
+sublocale isoiec_9798_2_5_udkey_state < isoiec_9798_2_5_udkey_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_2_5_udkey_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_2_5_udkey_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_2_5_udkey_A_2_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
+            |}
+            ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_udkey_A_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
+            |}
+            ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_udkey_A_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_A_2_TokenPA_for_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_A_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_A_text_3_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_A_4_TNb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
+               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_udkey_A_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
+               s(AV ''A'' tid0), s(MV ''Text7'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_udkey_A_4_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_B_3_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_B_3_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+            |}
+            ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_udkey_B_3_P t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_B_3_TNa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
+               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_udkey_B_3_TNp t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+            |}
+            ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_udkey_B_3_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+               s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+            |}
+            ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_udkey_B_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
+               s(AV ''B'' tid0), s(MV ''Text5'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_5_udkey_B_3_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_B_text_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_B_text_4_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_P_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_P_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_P_1_TVPa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_P_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_P_text_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_P_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_5_udkey_P_text_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_5_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_2_5_udkey_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_2_5_udkey_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_2_5_udkey_state) P_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_P"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
+    "LN ''Kab'' tid0 : knows t"
+  shows "False"
+using facts proof(sources! " LN ''Kab'' tid0 ")
+  case isoiec_9798_2_5_udkey_P_2_Kab note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+next
+  case isoiec_9798_2_5_udkey_P_2_Kab_1 note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+qed (insert facts, fastforce+)?
+
+lemma (in restricted_isoiec_9798_2_5_udkey_state) A_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_A"
+    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_udkey_A_2 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
+                          s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
+                       |}
+                       ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_5_udkey_P_2_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_5_udkey_state) B_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_udkey_B_3 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+                       |}
+                       ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_5_udkey_P_2_enc_1 tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_5_udkey_state) A_injective_agreement_B:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_5_udkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_5_udkey_A_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_5_udkey_B &
+          ( tid1, isoiec_9798_2_5_udkey_B_4 ) : steps t &
+          {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
+             s(MV ''Kab'' tid1), s(MV ''TNa'' tid1), s(MV ''Text5'' tid1),
+             LN ''TNb'' tid1, s(MV ''Text7'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
+                  s(MV ''Kab'' tid0), LN ''TNa'' tid0, s(MV ''Text5'' tid0),
+                  s(MV ''TNb'' tid0), s(MV ''Text7'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_5_udkey_P_2_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_2_5_enc_4'', s(MV ''TNb'' tid0),
+                                s(AV ''A'' tid0), s(MV ''Text7'' tid0)
+                             |}
+                             ( LN ''Kab'' tid1 ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+        next
+          case (isoiec_9798_2_5_udkey_B_4_enc tid2) note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid2),
+                                  LN ''Kab'' tid1, s(AV ''A'' tid0), s(MV ''Text2'' tid2)
+                               |}
+                               ( K ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) ) ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+          next
+            case (isoiec_9798_2_5_udkey_P_2_enc_1 tid3) note_unified facts = this facts
+            thus ?thesis proof(sources! "
+                             Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid2),
+                                    s(AV ''B'' tid0), s(MV ''Text5'' tid2)
+                                 |}
+                                 ( LN ''Kab'' tid1 ) ")
+              case fake note_unified facts = this facts
+              thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+            next
+              case (isoiec_9798_2_5_udkey_A_3_enc tid3) note_unified facts = this facts
+              thus ?thesis proof(sources! "
+                               Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid3, LN ''Kab'' tid1,
+                                      s(AV ''B'' tid0), s(MV ''Text3'' tid3)
+                                   |}
+                                   ( K ( s(AV ''A'' tid3) ) ( s(AV ''P'' tid3) ) ) ")
+                case fake note_unified facts = this facts
+                thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+              next
+                case (isoiec_9798_2_5_udkey_P_2_enc tid4) note_unified facts = this facts
+                thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+              qed (insert facts, fastforce+)?
+            qed (insert facts, fastforce+)?
+          qed (insert facts, fastforce+)?
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_5_udkey_state) B_non_injective_agreement_A:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_udkey_B_3 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_5_udkey_A &
+        ( tid1, isoiec_9798_2_5_udkey_A_3 ) : steps t &
+        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(AV ''P'' tid1),
+           s(MV ''Kab'' tid1), LN ''TNa'' tid1, s(MV ''Text5'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                s(MV ''Kab'' tid0), s(MV ''TNa'' tid0), s(MV ''Text5'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+                       |}
+                       ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_5_udkey_P_2_enc_1 tid1) note_unified facts = this facts
+    thus ?thesis proof(sources! "
+                     Enc {| LC ''isoiec_9798_2_5_enc_3'', s(MV ''TNa'' tid0),
+                            s(AV ''B'' tid0), s(MV ''Text5'' tid0)
+                         |}
+                         ( LN ''Kab'' tid1 ) ")
+      case fake note_unified facts = this facts
+      thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+    next
+      case (isoiec_9798_2_5_udkey_A_3_enc tid2) note_unified facts = this facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid2, LN ''Kab'' tid1,
+                              s(AV ''B'' tid0), s(MV ''Text3'' tid2)
+                           |}
+                           ( K ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+      next
+        case (isoiec_9798_2_5_udkey_P_2_enc tid3) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed (insert facts, fastforce+)?
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_5_udkey_state) A_injective_agreement_P:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_5_udkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_5_udkey_A_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_5_udkey_P &
+          ( tid1, isoiec_9798_2_5_udkey_P_2 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
+             s(MV ''TVPa'' tid1), s(MV ''Text3'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''P'' tid0),
+                  s(MV ''Kab'' tid0), LN ''TVPa'' tid0, s(MV ''Text3'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_5_enc_2_1'', LN ''TVPa'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''B'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_5_udkey_P_2_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_5_udkey_state) B_non_injective_agreement_P:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_5_udkey_B"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_5_udkey_B_3 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_2_5_udkey_P &
+        ( tid1, isoiec_9798_2_5_udkey_P_2 ) : steps t &
+        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1), LN ''Kab'' tid1,
+           LN ''TNp'' tid1, s(MV ''Text2'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                s(MV ''Kab'' tid0), s(MV ''TNp'' tid0), s(MV ''Text2'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_5_enc_2_2'', s(MV ''TNp'' tid0),
+                          s(MV ''Kab'' tid0), s(MV ''A'' tid0), s(MV ''Text2'' tid0)
+                       |}
+                       ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_5_udkey_P_2_enc_1 tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
+qed
+
+role isoiec_9798_2_6_udkey_A
+where "isoiec_9798_2_6_udkey_A =
+  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
+  , Recv ''text_2'' ( sMV ''Text2'' )
+  , Send ''2'' <| sAV ''A'', sAV ''P'', sN ''Ra'', sMV ''Rb'', sMV ''B'',
+                  sMV ''Text2''
+               |>
+  , Recv ''3'' <| sAV ''P'', sAV ''A'', sMV ''Text5'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_3_1'', sN ''Ra'', sMV ''Kab'',
+                          sMV ''B'', sMV ''Text4''
+                       |>
+                       ( sK ''A'' ''P'' ),
+                  sMV ''TokenPA_for_B''
+               |>
+  , Recv ''text_4'' <| sMV ''Text6'', sMV ''Text7'' |>
+  , Send ''4'' <| sAV ''A'', sMV ''B'', sMV ''Text7'', sAV ''P'',
+                  sMV ''TokenPA_for_B'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_4'', sN ''Rpa'', sMV ''Rb'',
+                          sMV ''Text6''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''5'' <| sMV ''B'', sAV ''A'', sMV ''Text9'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_5'', sMV ''Rb'', sN ''Rpa'',
+                          sMV ''Text8''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_6_udkey_B
+where "isoiec_9798_2_6_udkey_B =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
+  , Recv ''4'' <| sAV ''A'', sAV ''B'', sMV ''Text7'', sMV ''P'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_3_2'', sN ''Rb'', sMV ''Kab'',
+                          sAV ''A'', sMV ''Text3''
+                       |>
+                       ( PSymK ( sAV ''B'' ) ( sMV ''P'' ) ),
+                  PEnc <| sC ''isoiec_9798_2_6_enc_4'', sMV ''Rpa'', sN ''Rb'',
+                          sMV ''Text6''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
+  , Send ''5'' <| sAV ''B'', sAV ''A'', sMV ''Text9'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_5'', sN ''Rb'', sMV ''Rpa'',
+                          sMV ''Text8''
+                       |>
+                       ( sMV ''Kab'' )
+               |>
+  ]"
+
+role isoiec_9798_2_6_udkey_P
+where "isoiec_9798_2_6_udkey_P =
+  [ Recv ''2'' <| sMV ''A'', sAV ''P'', sMV ''Ra'', sMV ''Rb'', sMV ''B'',
+                  sMV ''Text2''
+               |>
+  , Recv ''text_3'' <| sMV ''Text3'', sMV ''Text4'', sMV ''Text5'' |>
+  , Send ''3'' <| sAV ''P'', sMV ''A'', sMV ''Text5'',
+                  PEnc <| sC ''isoiec_9798_2_6_enc_3_1'', sMV ''Ra'', sN ''Kab'',
+                          sMV ''B'', sMV ''Text4''
+                       |>
+                       ( PSymK ( sMV ''A'' ) ( sAV ''P'' ) ),
+                  PEnc <| sC ''isoiec_9798_2_6_enc_3_2'', sMV ''Rb'', sN ''Kab'',
+                          sMV ''A'', sMV ''Text3''
+                       |>
+                       ( PSymK ( sMV ''B'' ) ( sAV ''P'' ) )
+               |>
+  ]"
+
+protocol isoiec_9798_2_6_udkey
+where "isoiec_9798_2_6_udkey =
+{ isoiec_9798_2_6_udkey_A, isoiec_9798_2_6_udkey_B,
+  isoiec_9798_2_6_udkey_P
+}"
+
+locale restricted_isoiec_9798_2_6_udkey_state = isoiec_9798_2_6_udkey_state
+
+type_invariant isoiec_9798_2_6_udkey_msc_typing for isoiec_9798_2_6_udkey
+where "isoiec_9798_2_6_udkey_msc_typing = mk_typing
+  [ ((isoiec_9798_2_6_udkey_P, ''A''), (KnownT isoiec_9798_2_6_udkey_P_2))
+  , ((isoiec_9798_2_6_udkey_A, ''B''), (KnownT isoiec_9798_2_6_udkey_A_1))
+  , ((isoiec_9798_2_6_udkey_P, ''B''), (KnownT isoiec_9798_2_6_udkey_P_2))
+  , ((isoiec_9798_2_6_udkey_A, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_6_udkey_A_3) (NonceT isoiec_9798_2_6_udkey_P ''Kab'')))
+  , ((isoiec_9798_2_6_udkey_B, ''Kab''),
+     (SumT (KnownT isoiec_9798_2_6_udkey_B_4) (NonceT isoiec_9798_2_6_udkey_P ''Kab'')))
+  , ((isoiec_9798_2_6_udkey_B, ''P''), (KnownT isoiec_9798_2_6_udkey_B_4))
+  , ((isoiec_9798_2_6_udkey_P, ''Ra''), (KnownT isoiec_9798_2_6_udkey_P_2))
+  , ((isoiec_9798_2_6_udkey_A, ''Rb''), (KnownT isoiec_9798_2_6_udkey_A_1))
+  , ((isoiec_9798_2_6_udkey_P, ''Rb''), (KnownT isoiec_9798_2_6_udkey_P_2))
+  , ((isoiec_9798_2_6_udkey_B, ''Rpa''),
+     (SumT (KnownT isoiec_9798_2_6_udkey_B_4) (NonceT isoiec_9798_2_6_udkey_A ''Rpa'')))
+  , ((isoiec_9798_2_6_udkey_A, ''Text1''),
+     (KnownT isoiec_9798_2_6_udkey_A_1))
+  , ((isoiec_9798_2_6_udkey_B, ''Text1''),
+     (KnownT isoiec_9798_2_6_udkey_B_text_1))
+  , ((isoiec_9798_2_6_udkey_A, ''Text2''),
+     (KnownT isoiec_9798_2_6_udkey_A_text_2))
+  , ((isoiec_9798_2_6_udkey_P, ''Text2''),
+     (KnownT isoiec_9798_2_6_udkey_P_2))
+  , ((isoiec_9798_2_6_udkey_B, ''Text3''),
+     (KnownT isoiec_9798_2_6_udkey_B_4))
+  , ((isoiec_9798_2_6_udkey_P, ''Text3''),
+     (KnownT isoiec_9798_2_6_udkey_P_text_3))
+  , ((isoiec_9798_2_6_udkey_A, ''Text4''),
+     (KnownT isoiec_9798_2_6_udkey_A_3))
+  , ((isoiec_9798_2_6_udkey_P, ''Text4''),
+     (KnownT isoiec_9798_2_6_udkey_P_text_3))
+  , ((isoiec_9798_2_6_udkey_A, ''Text5''),
+     (KnownT isoiec_9798_2_6_udkey_A_3))
+  , ((isoiec_9798_2_6_udkey_P, ''Text5''),
+     (KnownT isoiec_9798_2_6_udkey_P_text_3))
+  , ((isoiec_9798_2_6_udkey_A, ''Text6''),
+     (KnownT isoiec_9798_2_6_udkey_A_text_4))
+  , ((isoiec_9798_2_6_udkey_B, ''Text6''),
+     (KnownT isoiec_9798_2_6_udkey_B_4))
+  , ((isoiec_9798_2_6_udkey_A, ''Text7''),
+     (KnownT isoiec_9798_2_6_udkey_A_text_4))
+  , ((isoiec_9798_2_6_udkey_B, ''Text7''),
+     (KnownT isoiec_9798_2_6_udkey_B_4))
+  , ((isoiec_9798_2_6_udkey_A, ''Text8''),
+     (KnownT isoiec_9798_2_6_udkey_A_5))
+  , ((isoiec_9798_2_6_udkey_B, ''Text8''),
+     (KnownT isoiec_9798_2_6_udkey_B_text_5))
+  , ((isoiec_9798_2_6_udkey_A, ''Text9''),
+     (KnownT isoiec_9798_2_6_udkey_A_5))
+  , ((isoiec_9798_2_6_udkey_B, ''Text9''),
+     (KnownT isoiec_9798_2_6_udkey_B_text_5))
+  , ((isoiec_9798_2_6_udkey_A, ''TokenPA_for_B''),
+     (KnownT isoiec_9798_2_6_udkey_A_3))
+  ]"
+
+sublocale isoiec_9798_2_6_udkey_state < isoiec_9798_2_6_udkey_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_2_6_udkey_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_2_6_udkey_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_2_6_udkey_A_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_A_1_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_A_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_A_3_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
+               s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
+            |}
+            ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_udkey_A_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
+               s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
+            |}
+            ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_udkey_A_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_A_3_TokenPA_for_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_A_text_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_A_text_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_A_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_5'', s(MV ''Rb'' tid0), LN ''Rpa'' tid0,
+               s(MV ''Text8'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_udkey_A_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_B_4_Kab t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+            |}
+            ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_udkey_B_4_P t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_B_4_Rpa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
+               s(MV ''Text6'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_udkey_B_4_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
+               s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+            |}
+            ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_udkey_B_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
+               s(MV ''Text6'' tid0)
+            |}
+            ( s(MV ''Kab'' tid0) ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_2_6_udkey_B_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_B_text_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_B_text_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_P_2_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_P_2_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_P_2_Ra t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_P_2_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_P_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_P_text_3_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_P_text_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_2_6_udkey_P_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_2_6_udkey_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_2_6_udkey_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_2_6_udkey_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_2_6_udkey_state) P_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_6_udkey_P"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
+    "LN ''Kab'' tid0 : knows t"
+  shows "False"
+using facts proof(sources! " LN ''Kab'' tid0 ")
+  case isoiec_9798_2_6_udkey_P_3_Kab note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+next
+  case isoiec_9798_2_6_udkey_P_3_Kab_1 note_unified facts = this facts
+  thus ?thesis by (fastforce dest!: ltk_secrecy)
+qed (insert facts, fastforce+)?
+
+lemma (in restricted_isoiec_9798_2_6_udkey_state) A_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_6_udkey_A"
+    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''P'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_6_udkey_A_3 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
+                          s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
+                       |}
+                       ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_6_udkey_P_3_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_6_udkey_state) B_secret_Kab:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_2_6_udkey_B"
+    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "RLKR(s(MV ''P'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_2_6_udkey_B_4 ) : steps t"
+    "s(MV ''Kab'' tid0) : knows t"
+  shows "False"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
+                          s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+                       |}
+                       ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_2_6_udkey_P_3_enc_1 tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_2_6_udkey_state) A_injective_agreement_B:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_udkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_udkey_A_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_udkey_B &
+          ( tid1, isoiec_9798_2_6_udkey_B_5 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''P'' tid1),
+             s(MV ''Kab'' tid1), s(MV ''Rpa'' tid1), LN ''Rb'' tid1,
+             s(MV ''Text6'' tid1), s(MV ''Text8'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
+                  s(MV ''Kab'' tid0), LN ''Rpa'' tid0, s(MV ''Rb'' tid0),
+                  s(MV ''Text6'' tid0), s(MV ''Text8'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
+                              s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
+                           |}
+                           ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_udkey_P_3_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_2_6_enc_5'', s(MV ''Rb'' tid0), LN ''Rpa'' tid0,
+                                s(MV ''Text8'' tid0)
+                             |}
+                             ( LN ''Kab'' tid1 ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+        next
+          case (isoiec_9798_2_6_udkey_B_5_enc tid2) note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid2, LN ''Kab'' tid1,
+                                  s(AV ''A'' tid2), s(MV ''Text3'' tid2)
+                               |}
+                               ( K ( s(AV ''B'' tid2) ) ( s(MV ''P'' tid2) ) ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+          next
+            case (isoiec_9798_2_6_udkey_P_3_enc_1 tid3) note_unified facts = this facts
+            thus ?thesis proof(sources! "
+                             Enc {| LC ''isoiec_9798_2_6_enc_4'', LN ''Rpa'' tid0, LN ''Rb'' tid2,
+                                    s(MV ''Text6'' tid2)
+                                 |}
+                                 ( LN ''Kab'' tid1 ) ")
+              case fake note_unified facts = this facts
+              thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+            next
+              case (isoiec_9798_2_6_udkey_A_4_enc tid3) note_unified facts = this facts
+              thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+            qed (insert facts, fastforce+)?
+          qed (insert facts, fastforce+)?
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_6_udkey_state) B_injective_agreement_A:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_udkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(MV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_udkey_B_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_udkey_A &
+          ( tid1, isoiec_9798_2_6_udkey_A_4 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
+             s(MV ''Kab'' tid1), LN ''Rpa'' tid1, s(MV ''Rb'' tid1),
+             s(MV ''Text6'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                  s(MV ''Kab'' tid0), s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
+                  s(MV ''Text6'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_udkey_P_3_enc_1 tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_2_6_enc_4'', s(MV ''Rpa'' tid0), LN ''Rb'' tid0,
+                                s(MV ''Text6'' tid0)
+                             |}
+                             ( LN ''Kab'' tid1 ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+        next
+          case (isoiec_9798_2_6_udkey_A_4_enc tid2) note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid2, LN ''Kab'' tid1,
+                                  s(MV ''B'' tid2), s(MV ''Text4'' tid2)
+                               |}
+                               ( K ( s(AV ''A'' tid2) ) ( s(AV ''P'' tid2) ) ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest: P_secret_Kab intro: event_predOrdI)
+          next
+            case (isoiec_9798_2_6_udkey_P_3_enc tid3) note_unified facts = this facts
+            thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+          qed (insert facts, fastforce+)?
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_6_udkey_state) A_injective_agreement_P:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_udkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''P'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_udkey_A_3 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_udkey_P &
+          ( tid1, isoiec_9798_2_6_udkey_P_3 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
+             s(MV ''Ra'' tid1), LN ''Kab'' tid1, s(MV ''Text4'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''P'' tid0),
+                  LN ''Ra'' tid0, s(MV ''Kab'' tid0), s(MV ''Text4'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_enc_3_1'', LN ''Ra'' tid0,
+                              s(MV ''Kab'' tid0), s(MV ''B'' tid0), s(MV ''Text4'' tid0)
+                           |}
+                           ( K ( s(AV ''A'' tid0) ) ( s(AV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_udkey_P_3_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_2_6_udkey_state) B_injective_agreement_P:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_2_6_udkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(MV ''P'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_2_6_udkey_B_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_2_6_udkey_P &
+          ( tid1, isoiec_9798_2_6_udkey_P_3 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''P'' tid1),
+             s(MV ''Rb'' tid1), LN ''Kab'' tid1, s(MV ''Text3'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''P'' tid0),
+                  LN ''Rb'' tid0, s(MV ''Kab'' tid0), s(MV ''Text3'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_2_6_enc_3_2'', LN ''Rb'' tid0,
+                              s(MV ''Kab'' tid0), s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( K ( s(AV ''B'' tid0) ) ( s(MV ''P'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_2_6_udkey_P_3_enc_1 tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
 qed
 
 end
diff --git a/data/examples/iso9798/isabelle-proofs/isoiec-9798-3_cert_auto.thy b/data/examples/iso9798/isabelle-proofs/isoiec-9798-3_cert_auto.thy
--- a/data/examples/iso9798/isabelle-proofs/isoiec-9798-3_cert_auto.thy
+++ b/data/examples/iso9798/isabelle-proofs/isoiec-9798-3_cert_auto.thy
@@ -1,3320 +1,3726 @@
 theory "isoiec-9798-3_cert_auto"
 imports
-  "../ESPLogic"
-begin
-
-role isoiec_9798_3_1_A
-where "isoiec_9798_3_1_A =
-  [ Send ''leak_A'' ( sN ''TNA'' )
-  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
-  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
-                  PSign <| sC ''isoiec_9798_3_1_sig_1'', sN ''TNA'', sAV ''B'',
-                           sMV ''Text1''
-                        |>
-                        ( sPK ''A'' )
-               |>
-  ]"
-
-role isoiec_9798_3_1_B
-where "isoiec_9798_3_1_B =
-  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
-                  PSign <| sC ''isoiec_9798_3_1_sig_1'', sMV ''TNA'', sAV ''B'',
-                           sMV ''Text1''
-                        |>
-                        ( PAsymPK ( sMV ''A'' ) )
-               |>
-  ]"
-
-protocol isoiec_9798_3_1
-where "isoiec_9798_3_1 = { isoiec_9798_3_1_A, isoiec_9798_3_1_B }"
-
-locale restricted_isoiec_9798_3_1_state = isoiec_9798_3_1_state
-
-type_invariant isoiec_9798_3_1_msc_typing for isoiec_9798_3_1
-where "isoiec_9798_3_1_msc_typing = mk_typing
-  [ ((isoiec_9798_3_1_B, ''A''), (KnownT isoiec_9798_3_1_B_1))
-  , ((isoiec_9798_3_1_B, ''TNA''), (KnownT isoiec_9798_3_1_B_1))
-  , ((isoiec_9798_3_1_A, ''Text1''), (KnownT isoiec_9798_3_1_A_text_1))
-  , ((isoiec_9798_3_1_B, ''Text1''), (KnownT isoiec_9798_3_1_B_1))
-  , ((isoiec_9798_3_1_A, ''Text2''), (KnownT isoiec_9798_3_1_A_text_1))
-  , ((isoiec_9798_3_1_B, ''Text2''), (KnownT isoiec_9798_3_1_B_1))
-  ]"
-
-sublocale isoiec_9798_3_1_state < isoiec_9798_3_1_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_3_1_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_3_1_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_3_1_A_text_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_1_A_text_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_1_B_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_1_B_1_TNA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_1_B_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_1_B_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_3_1_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_3_1_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_3_1_state) B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_1_B"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_1_B_1 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_1_A &
-        ( tid1, isoiec_9798_3_1_A_1 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
-           s(MV ''Text1'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
-                s(MV ''Text1'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_1_sig_1'', s(MV ''TNA'' tid0),
-                          s(AV ''B'' tid0), s(MV ''Text1'' tid0)
-                       |}
-                       ( SK ( s(MV ''A'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_1_A_1_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-role isoiec_9798_3_2_A
-where "isoiec_9798_3_2_A =
-  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
-  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
-  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
-                  PSign <| sC ''isoiec_9798_3_2_sig_2'', sN ''Ra'', sMV ''Rb'', sMV ''B'',
-                           sMV ''Text2''
-                        |>
-                        ( sPK ''A'' )
-               |>
-  ]"
-
-role isoiec_9798_3_2_B
-where "isoiec_9798_3_2_B =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
-  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
-                  PSign <| sC ''isoiec_9798_3_2_sig_2'', sMV ''Ra'', sN ''Rb'', sAV ''B'',
-                           sMV ''Text2''
-                        |>
-                        ( sPK ''A'' )
-               |>
-  ]"
-
-protocol isoiec_9798_3_2
-where "isoiec_9798_3_2 = { isoiec_9798_3_2_A, isoiec_9798_3_2_B }"
-
-locale restricted_isoiec_9798_3_2_state = isoiec_9798_3_2_state
-
-type_invariant isoiec_9798_3_2_msc_typing for isoiec_9798_3_2
-where "isoiec_9798_3_2_msc_typing = mk_typing
-  [ ((isoiec_9798_3_2_A, ''B''), (KnownT isoiec_9798_3_2_A_1))
-  , ((isoiec_9798_3_2_B, ''Ra''), (KnownT isoiec_9798_3_2_B_2))
-  , ((isoiec_9798_3_2_A, ''Rb''), (KnownT isoiec_9798_3_2_A_1))
-  , ((isoiec_9798_3_2_A, ''Text1''), (KnownT isoiec_9798_3_2_A_1))
-  , ((isoiec_9798_3_2_B, ''Text1''), (KnownT isoiec_9798_3_2_B_text_1))
-  , ((isoiec_9798_3_2_A, ''Text2''), (KnownT isoiec_9798_3_2_A_text_2))
-  , ((isoiec_9798_3_2_B, ''Text2''), (KnownT isoiec_9798_3_2_B_2))
-  , ((isoiec_9798_3_2_A, ''Text3''), (KnownT isoiec_9798_3_2_A_text_2))
-  , ((isoiec_9798_3_2_B, ''Text3''), (KnownT isoiec_9798_3_2_B_2))
-  ]"
-
-sublocale isoiec_9798_3_2_state < isoiec_9798_3_2_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_3_2_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_3_2_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_3_2_A_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_2_A_1_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_2_A_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_2_A_text_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_2_A_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_2_B_2_Ra t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_2_B_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_2_B_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_3_2_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_3_2_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_3_2_state) B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_2_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_2_B_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_2_A &
-        ( tid1, isoiec_9798_3_2_A_2 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
-                LN ''Rb'' tid0, s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_2_sig_2'', s(MV ''Ra'' tid0), LN ''Rb'' tid0,
-                          s(AV ''B'' tid0), s(MV ''Text2'' tid0)
-                       |}
-                       ( SK ( s(AV ''A'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_2_A_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-role isoiec_9798_3_3_A
-where "isoiec_9798_3_3_A =
-  [ Send ''leak_A'' ( sN ''TNA'' )
-  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
-  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
-                  PSign <| sC ''isoiec_9798_3_3_sig_1'', sN ''TNA'', sAV ''B'',
-                           sMV ''Text1''
-                        |>
-                        ( sPK ''A'' )
-               |>
-  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text4'',
-                  PSign <| sC ''isoiec_9798_3_3_sig_2'', sMV ''TNB'', sAV ''A'',
-                           sMV ''Text3''
-                        |>
-                        ( sPK ''B'' )
-               |>
-  ]"
-
-role isoiec_9798_3_3_B
-where "isoiec_9798_3_3_B =
-  [ Send ''leak_B'' ( sN ''TNB'' )
-  , Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
-                  PSign <| sC ''isoiec_9798_3_3_sig_1'', sMV ''TNA'', sAV ''B'',
-                           sMV ''Text1''
-                        |>
-                        ( PAsymPK ( sMV ''A'' ) )
-               |>
-  , Recv ''text_2'' <| sMV ''Text3'', sMV ''Text4'' |>
-  , Send ''2'' <| sMV ''A'', sAV ''B'', sMV ''Text4'',
-                  PSign <| sC ''isoiec_9798_3_3_sig_2'', sN ''TNB'', sMV ''A'',
-                           sMV ''Text3''
-                        |>
-                        ( sPK ''B'' )
-               |>
-  ]"
-
-protocol isoiec_9798_3_3
-where "isoiec_9798_3_3 = { isoiec_9798_3_3_A, isoiec_9798_3_3_B }"
-
-locale restricted_isoiec_9798_3_3_state = isoiec_9798_3_3_state
-
-type_invariant isoiec_9798_3_3_msc_typing for isoiec_9798_3_3
-where "isoiec_9798_3_3_msc_typing = mk_typing
-  [ ((isoiec_9798_3_3_B, ''A''), (KnownT isoiec_9798_3_3_B_1))
-  , ((isoiec_9798_3_3_B, ''TNA''), (KnownT isoiec_9798_3_3_B_1))
-  , ((isoiec_9798_3_3_A, ''TNB''), (KnownT isoiec_9798_3_3_A_2))
-  , ((isoiec_9798_3_3_A, ''Text1''), (KnownT isoiec_9798_3_3_A_text_1))
-  , ((isoiec_9798_3_3_B, ''Text1''), (KnownT isoiec_9798_3_3_B_1))
-  , ((isoiec_9798_3_3_A, ''Text2''), (KnownT isoiec_9798_3_3_A_text_1))
-  , ((isoiec_9798_3_3_B, ''Text2''), (KnownT isoiec_9798_3_3_B_1))
-  , ((isoiec_9798_3_3_A, ''Text3''), (KnownT isoiec_9798_3_3_A_2))
-  , ((isoiec_9798_3_3_B, ''Text3''), (KnownT isoiec_9798_3_3_B_text_2))
-  , ((isoiec_9798_3_3_A, ''Text4''), (KnownT isoiec_9798_3_3_A_2))
-  , ((isoiec_9798_3_3_B, ''Text4''), (KnownT isoiec_9798_3_3_B_text_2))
-  ]"
-
-sublocale isoiec_9798_3_3_state < isoiec_9798_3_3_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_3_3_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_3_3_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_3_3_A_text_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_3_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_3_A_text_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_3_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_3_A_2_TNB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_3_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_3_A_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_3_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_3_A_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_3_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_3_B_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_3_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_3_B_1_TNA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_3_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_3_B_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_3_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_3_B_1_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_3_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_3_B_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_3_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_3_B_text_2_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_3_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_3_3_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_3_3_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_3_3_state) A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_3_A"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_3_A_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_3_B &
-        ( tid1, isoiec_9798_3_3_B_2 ) : steps t &
-        {| s(MV ''A'' tid1), s(AV ''B'' tid1), LN ''TNB'' tid1,
-           s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNB'' tid0),
-                s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_3_sig_2'', s(MV ''TNB'' tid0),
-                          s(AV ''A'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( SK ( s(AV ''B'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_3_B_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_3_state) B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_3_B"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_3_B_1 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_3_A &
-        ( tid1, isoiec_9798_3_3_A_1 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
-           s(MV ''Text1'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
-                s(MV ''Text1'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_3_sig_1'', s(MV ''TNA'' tid0),
-                          s(AV ''B'' tid0), s(MV ''Text1'' tid0)
-                       |}
-                       ( SK ( s(MV ''A'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_3_A_1_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-role isoiec_9798_3_4_A
-where "isoiec_9798_3_4_A =
-  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text1'' |>
-  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
-  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
-                  PSign <| sC ''isoiec_9798_3_4_sig_1'', sN ''RA'', sMV ''RB'', sMV ''B'',
-                           sMV ''Text2''
-                        |>
-                        ( sPK ''A'' )
-               |>
-  , Recv ''3'' <| sMV ''B'', sAV ''A'', sMV ''Text5'',
-                  PSign <| sC ''isoiec_9798_3_4_sig_2'', sMV ''RB'', sN ''RA'', sAV ''A'',
-                           sMV ''Text4''
-                        |>
-                        ( PAsymPK ( sMV ''B'' ) )
-               |>
-  ]"
-
-role isoiec_9798_3_4_B
-where "isoiec_9798_3_4_B =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''RB'', sMV ''Text1'' |>
-  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
-                  PSign <| sC ''isoiec_9798_3_4_sig_1'', sMV ''RA'', sN ''RB'', sAV ''B'',
-                           sMV ''Text2''
-                        |>
-                        ( sPK ''A'' )
-               |>
-  , Recv ''text_3'' <| sMV ''Text4'', sMV ''Text5'' |>
-  , Send ''3'' <| sAV ''B'', sAV ''A'', sMV ''Text5'',
-                  PSign <| sC ''isoiec_9798_3_4_sig_2'', sN ''RB'', sMV ''RA'', sAV ''A'',
-                           sMV ''Text4''
-                        |>
-                        ( sPK ''B'' )
-               |>
-  ]"
-
-protocol isoiec_9798_3_4
-where "isoiec_9798_3_4 = { isoiec_9798_3_4_A, isoiec_9798_3_4_B }"
-
-locale restricted_isoiec_9798_3_4_state = isoiec_9798_3_4_state
-
-type_invariant isoiec_9798_3_4_msc_typing for isoiec_9798_3_4
-where "isoiec_9798_3_4_msc_typing = mk_typing
-  [ ((isoiec_9798_3_4_A, ''B''), (KnownT isoiec_9798_3_4_A_1))
-  , ((isoiec_9798_3_4_B, ''RA''), (KnownT isoiec_9798_3_4_B_2))
-  , ((isoiec_9798_3_4_A, ''RB''), (KnownT isoiec_9798_3_4_A_1))
-  , ((isoiec_9798_3_4_A, ''Text1''), (KnownT isoiec_9798_3_4_A_1))
-  , ((isoiec_9798_3_4_B, ''Text1''), (KnownT isoiec_9798_3_4_B_text_1))
-  , ((isoiec_9798_3_4_A, ''Text2''), (KnownT isoiec_9798_3_4_A_text_2))
-  , ((isoiec_9798_3_4_B, ''Text2''), (KnownT isoiec_9798_3_4_B_2))
-  , ((isoiec_9798_3_4_A, ''Text3''), (KnownT isoiec_9798_3_4_A_text_2))
-  , ((isoiec_9798_3_4_B, ''Text3''), (KnownT isoiec_9798_3_4_B_2))
-  , ((isoiec_9798_3_4_A, ''Text4''), (KnownT isoiec_9798_3_4_A_3))
-  , ((isoiec_9798_3_4_B, ''Text4''), (KnownT isoiec_9798_3_4_B_text_3))
-  , ((isoiec_9798_3_4_A, ''Text5''), (KnownT isoiec_9798_3_4_A_3))
-  , ((isoiec_9798_3_4_B, ''Text5''), (KnownT isoiec_9798_3_4_B_text_3))
-  ]"
-
-sublocale isoiec_9798_3_4_state < isoiec_9798_3_4_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_3_4_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_3_4_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_3_4_A_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_A_1_RB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_A_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_A_text_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_A_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_A_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_A_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_B_2_RA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_B_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_B_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_B_text_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_4_B_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_3_4_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_3_4_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_3_4_state) A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_4_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_4_A_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_4_B &
-        ( tid1, isoiec_9798_3_4_B_3 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''RA'' tid1), LN ''RB'' tid1,
-           s(MV ''Text2'' tid1), s(MV ''Text4'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''RA'' tid0,
-                s(MV ''RB'' tid0), s(MV ''Text2'' tid0), s(MV ''Text4'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_4_sig_2'', s(MV ''RB'' tid0), LN ''RA'' tid0,
-                          s(AV ''A'' tid0), s(MV ''Text4'' tid0)
-                       |}
-                       ( SK ( s(MV ''B'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_4_B_3_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_4_sig_1'', LN ''RA'' tid0, LN ''RB'' tid1,
-                            s(AV ''B'' tid1), s(MV ''Text2'' tid1)
-                         |}
-                         ( SK ( s(AV ''A'' tid0) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_3_4_A_2_enc tid2) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_4_state) B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_4_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_4_B_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_4_A &
-        ( tid1, isoiec_9798_3_4_A_2 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''RA'' tid1, s(MV ''RB'' tid1),
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''RA'' tid0),
-                LN ''RB'' tid0, s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_4_sig_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
-                          s(AV ''B'' tid0), s(MV ''Text2'' tid0)
-                       |}
-                       ( SK ( s(AV ''A'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_4_A_2_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-role isoiec_9798_3_5_A
-where "isoiec_9798_3_5_A =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''A'', sAV ''B'', sN ''RA'', sMV ''Text1'' |>
-  , Recv ''2'' <| sAV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text2'' |>
-  , Recv ''3'' <| sAV ''B'', sAV ''A'', sMV ''Text6'',
-                  PSign <| sC ''isoiec_9798_3_5_sig_1'', sMV ''RB'', sN ''RA'', sAV ''A'',
-                           sMV ''Text5''
-                        |>
-                        ( sPK ''B'' )
-               |>
-  , Recv ''text_4'' <| sMV ''Text3'', sMV ''Text4'' |>
-  , Send ''4'' <| sAV ''A'', sAV ''B'', sMV ''Text4'',
-                  PSign <| sC ''isoiec_9798_3_5_sig_2'', sN ''RA'', sMV ''RB'', sAV ''B'',
-                           sMV ''Text3''
-                        |>
-                        ( sPK ''A'' )
-               |>
-  ]"
-
-role isoiec_9798_3_5_B
-where "isoiec_9798_3_5_B =
-  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''RA'', sMV ''Text1'' |>
-  , Recv ''text_2'' ( sMV ''Text2'' )
-  , Send ''2'' <| sAV ''B'', sMV ''A'', sN ''RB'', sMV ''Text2'' |>
-  , Recv ''text_3'' <| sMV ''Text5'', sMV ''Text6'' |>
-  , Send ''3'' <| sAV ''B'', sMV ''A'', sMV ''Text6'',
-                  PSign <| sC ''isoiec_9798_3_5_sig_1'', sN ''RB'', sMV ''RA'', sMV ''A'',
-                           sMV ''Text5''
-                        |>
-                        ( sPK ''B'' )
-               |>
-  , Recv ''4'' <| sMV ''A'', sAV ''B'', sMV ''Text4'',
-                  PSign <| sC ''isoiec_9798_3_5_sig_2'', sMV ''RA'', sN ''RB'', sAV ''B'',
-                           sMV ''Text3''
-                        |>
-                        ( PAsymPK ( sMV ''A'' ) )
-               |>
-  ]"
-
-protocol isoiec_9798_3_5
-where "isoiec_9798_3_5 = { isoiec_9798_3_5_A, isoiec_9798_3_5_B }"
-
-locale restricted_isoiec_9798_3_5_state = isoiec_9798_3_5_state
-
-type_invariant isoiec_9798_3_5_msc_typing for isoiec_9798_3_5
-where "isoiec_9798_3_5_msc_typing = mk_typing
-  [ ((isoiec_9798_3_5_B, ''A''), (KnownT isoiec_9798_3_5_B_1))
-  , ((isoiec_9798_3_5_B, ''RA''), (KnownT isoiec_9798_3_5_B_1))
-  , ((isoiec_9798_3_5_A, ''RB''), (KnownT isoiec_9798_3_5_A_2))
-  , ((isoiec_9798_3_5_A, ''Text1''), (KnownT isoiec_9798_3_5_A_text_1))
-  , ((isoiec_9798_3_5_B, ''Text1''), (KnownT isoiec_9798_3_5_B_1))
-  , ((isoiec_9798_3_5_A, ''Text2''), (KnownT isoiec_9798_3_5_A_2))
-  , ((isoiec_9798_3_5_B, ''Text2''), (KnownT isoiec_9798_3_5_B_text_2))
-  , ((isoiec_9798_3_5_A, ''Text3''), (KnownT isoiec_9798_3_5_A_text_4))
-  , ((isoiec_9798_3_5_B, ''Text3''), (KnownT isoiec_9798_3_5_B_4))
-  , ((isoiec_9798_3_5_A, ''Text4''), (KnownT isoiec_9798_3_5_A_text_4))
-  , ((isoiec_9798_3_5_B, ''Text4''), (KnownT isoiec_9798_3_5_B_4))
-  , ((isoiec_9798_3_5_A, ''Text5''), (KnownT isoiec_9798_3_5_A_3))
-  , ((isoiec_9798_3_5_B, ''Text5''), (KnownT isoiec_9798_3_5_B_text_3))
-  , ((isoiec_9798_3_5_A, ''Text6''), (KnownT isoiec_9798_3_5_A_3))
-  , ((isoiec_9798_3_5_B, ''Text6''), (KnownT isoiec_9798_3_5_B_text_3))
-  ]"
-
-sublocale isoiec_9798_3_5_state < isoiec_9798_3_5_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_3_5_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_3_5_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_3_5_A_2_RB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_A_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_A_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_A_3_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_A_text_4_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_A_text_4_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_B_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_B_1_RA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_B_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_B_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_B_text_3_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_B_4_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_5_B_4_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_3_5_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_3_5_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_3_5_state) A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_5_A"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_5_A_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_5_B &
-        ( tid1, isoiec_9798_3_5_B_3 ) : steps t &
-        {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''RA'' tid1), LN ''RB'' tid1,
-           s(MV ''Text5'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''RA'' tid0,
-                s(MV ''RB'' tid0), s(MV ''Text5'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_5_sig_1'', s(MV ''RB'' tid0), LN ''RA'' tid0,
-                          s(AV ''A'' tid0), s(MV ''Text5'' tid0)
-                       |}
-                       ( SK ( s(AV ''B'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_5_B_3_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_5_state) B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_5_B"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_5_B_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_5_A &
-        ( tid1, isoiec_9798_3_5_A_4 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''RA'' tid1, s(MV ''RB'' tid1),
-           s(MV ''Text3'' tid1), s(MV ''Text5'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''RA'' tid0),
-                LN ''RB'' tid0, s(MV ''Text3'' tid0), s(MV ''Text5'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_5_sig_2'', s(MV ''RA'' tid0), LN ''RB'' tid0,
-                          s(AV ''B'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( SK ( s(MV ''A'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_5_A_4_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_5_sig_1'', LN ''RB'' tid0, LN ''RA'' tid1,
-                            s(AV ''A'' tid1), s(MV ''Text5'' tid1)
-                         |}
-                         ( SK ( s(AV ''B'' tid0) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_3_5_B_3_enc tid2) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-role isoiec_9798_3_6_1_A
-where "isoiec_9798_3_6_1_A =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''A'', sAV ''B'', sN ''Ra'', sMV ''Text1'' |>
-  , Recv ''2'' <| sAV ''A'', sAV ''B'', sN ''Ra'', sMV ''Rb'',
-                  sMV ''Text3'', sMV ''TokenBA''
-               |>
-  , Recv ''text_3'' ( sMV ''Text4'' )
-  , Send ''3'' <| sAV ''A'', sAV ''T'', sN ''Rpa'', sMV ''Rb'', sAV ''B'',
-                  sMV ''Text4''
-               |>
-  , Recv ''4'' <| sAV ''T'', sAV ''A'', sMV ''Text7'', sAV ''A'',
-                  sPK ''A'', sAV ''B'', sMV ''pkB'',
-                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_4_1'', sN ''Rpa'', sAV ''B'',
-                           sMV ''pkB'', sMV ''Text6''
-                        |>
-                        ( sPK ''T'' ),
-                  sMV ''TokenTA_for_B''
-               |>
-  , Send ''check_4_out'' ( PEnc <| sC ''check_4'', sMV ''TokenBA'' |>
-                                ( sN ''check_nonce_4'' )
-                         )
-  , Recv ''check_4_in'' ( PEnc <| sC ''check_4'',
-                                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_2'', sAV ''B'', sN ''Ra'',
-                                           sMV ''Rb'', sAV ''A'', sMV ''Text2''
-                                        |>
-                                        ( sMV ''pkB'' )
-                               |>
-                               ( sN ''check_nonce_4'' )
-                        )
-  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
-  , Send ''5'' <| sAV ''A'', sAV ''B'', sMV ''Text9'', sAV ''T'',
-                  sMV ''TokenTA_for_B'',
-                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_5'', sMV ''Rb'', sN ''Ra'',
-                           sAV ''B'', sAV ''A'', sMV ''Text8''
-                        |>
-                        ( sPK ''A'' )
-               |>
-  ]"
-
-role isoiec_9798_3_6_1_B
-where "isoiec_9798_3_6_1_B =
-  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Ra'', sMV ''Text1'' |>
-  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
-  , Send ''2'' <| sMV ''A'', sAV ''B'', sMV ''Ra'', sN ''Rb'',
-                  sMV ''Text3'',
-                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_2'', sAV ''B'', sMV ''Ra'',
-                           sN ''Rb'', sMV ''A'', sMV ''Text2''
-                        |>
-                        ( sPK ''B'' )
-               |>
-  , Recv ''5'' <| sMV ''A'', sAV ''B'', sMV ''Text9'', sMV ''T'',
-                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_4_2'', sN ''Rb'', sMV ''A'',
-                           sMV ''pkA'', sMV ''Text5''
-                        |>
-                        ( PAsymPK ( sMV ''T'' ) ),
-                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_5'', sN ''Rb'', sMV ''Ra5'',
-                           sAV ''B'', sMV ''A'', sMV ''Text8''
-                        |>
-                        ( sMV ''pkA'' )
-               |>
-  ]"
-
-role isoiec_9798_3_6_1_T
-where "isoiec_9798_3_6_1_T =
-  [ Recv ''3'' <| sMV ''A'', sAV ''T'', sMV ''Rpa'', sMV ''Rb'', sMV ''B'',
-                  sMV ''Text4''
-               |>
-  , Recv ''text_4'' <| sMV ''Text5'', sMV ''Text6'', sMV ''Text7'' |>
-  , Send ''4'' <| sAV ''T'', sMV ''A'', sMV ''Text7'', sMV ''A'',
-                  PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
-                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_4_1'', sMV ''Rpa'', sMV ''B'',
-                           PAsymPK ( sMV ''B'' ), sMV ''Text6''
-                        |>
-                        ( sPK ''T'' ),
-                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_4_2'', sMV ''Rb'', sMV ''A'',
-                           PAsymPK ( sMV ''A'' ), sMV ''Text5''
-                        |>
-                        ( sPK ''T'' )
-               |>
-  ]"
-
-protocol isoiec_9798_3_6_1
-where "isoiec_9798_3_6_1 =
-{ isoiec_9798_3_6_1_A, isoiec_9798_3_6_1_B, isoiec_9798_3_6_1_T }"
-
-locale restricted_isoiec_9798_3_6_1_state = isoiec_9798_3_6_1_state
-
-type_invariant isoiec_9798_3_6_1_msc_typing for isoiec_9798_3_6_1
-where "isoiec_9798_3_6_1_msc_typing = mk_typing
-  [ ((isoiec_9798_3_6_1_B, ''A''), (KnownT isoiec_9798_3_6_1_B_1))
-  , ((isoiec_9798_3_6_1_T, ''A''), (KnownT isoiec_9798_3_6_1_T_3))
-  , ((isoiec_9798_3_6_1_T, ''B''), (KnownT isoiec_9798_3_6_1_T_3))
-  , ((isoiec_9798_3_6_1_B, ''Ra''), (KnownT isoiec_9798_3_6_1_B_1))
-  , ((isoiec_9798_3_6_1_B, ''Ra5''), (KnownT isoiec_9798_3_6_1_B_5))
-  , ((isoiec_9798_3_6_1_A, ''Rb''), (KnownT isoiec_9798_3_6_1_A_2))
-  , ((isoiec_9798_3_6_1_T, ''Rb''), (KnownT isoiec_9798_3_6_1_T_3))
-  , ((isoiec_9798_3_6_1_T, ''Rpa''), (KnownT isoiec_9798_3_6_1_T_3))
-  , ((isoiec_9798_3_6_1_B, ''T''), (KnownT isoiec_9798_3_6_1_B_5))
-  , ((isoiec_9798_3_6_1_A, ''Text1''), (KnownT isoiec_9798_3_6_1_A_text_1))
-  , ((isoiec_9798_3_6_1_B, ''Text1''), (KnownT isoiec_9798_3_6_1_B_1))
-  , ((isoiec_9798_3_6_1_A, ''Text2''),
-     (KnownT isoiec_9798_3_6_1_A_check_4_in))
-  , ((isoiec_9798_3_6_1_B, ''Text2''), (KnownT isoiec_9798_3_6_1_B_text_2))
-  , ((isoiec_9798_3_6_1_A, ''Text3''), (KnownT isoiec_9798_3_6_1_A_2))
-  , ((isoiec_9798_3_6_1_B, ''Text3''), (KnownT isoiec_9798_3_6_1_B_text_2))
-  , ((isoiec_9798_3_6_1_A, ''Text4''), (KnownT isoiec_9798_3_6_1_A_text_3))
-  , ((isoiec_9798_3_6_1_T, ''Text4''), (KnownT isoiec_9798_3_6_1_T_3))
-  , ((isoiec_9798_3_6_1_B, ''Text5''), (KnownT isoiec_9798_3_6_1_B_5))
-  , ((isoiec_9798_3_6_1_T, ''Text5''), (KnownT isoiec_9798_3_6_1_T_text_4))
-  , ((isoiec_9798_3_6_1_A, ''Text6''), (KnownT isoiec_9798_3_6_1_A_4))
-  , ((isoiec_9798_3_6_1_T, ''Text6''), (KnownT isoiec_9798_3_6_1_T_text_4))
-  , ((isoiec_9798_3_6_1_A, ''Text7''), (KnownT isoiec_9798_3_6_1_A_4))
-  , ((isoiec_9798_3_6_1_T, ''Text7''), (KnownT isoiec_9798_3_6_1_T_text_4))
-  , ((isoiec_9798_3_6_1_A, ''Text8''), (KnownT isoiec_9798_3_6_1_A_text_5))
-  , ((isoiec_9798_3_6_1_B, ''Text8''), (KnownT isoiec_9798_3_6_1_B_5))
-  , ((isoiec_9798_3_6_1_A, ''Text9''), (KnownT isoiec_9798_3_6_1_A_text_5))
-  , ((isoiec_9798_3_6_1_B, ''Text9''), (KnownT isoiec_9798_3_6_1_B_5))
-  , ((isoiec_9798_3_6_1_A, ''TokenBA''), (KnownT isoiec_9798_3_6_1_A_2))
-  , ((isoiec_9798_3_6_1_A, ''TokenTA_for_B''),
-     (KnownT isoiec_9798_3_6_1_A_4))
-  , ((isoiec_9798_3_6_1_B, ''pkA''), (KnownT isoiec_9798_3_6_1_B_5))
-  , ((isoiec_9798_3_6_1_A, ''pkB''), (KnownT isoiec_9798_3_6_1_A_4))
-  ]"
-
-sublocale isoiec_9798_3_6_1_state < isoiec_9798_3_6_1_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_3_6_1_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_3_6_1_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_3_6_1_A_2_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_A_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_A_2_TokenBA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_A_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_A_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_A_4_TokenTA_for_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_A_4_pkB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_A_check_4_in_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''check_4'',
-               {| LC ''isoiec_9798_3_6_opt_1_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
-                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-               |},
-               Enc {| LC ''isoiec_9798_3_6_opt_1_sig_2'', s(AV ''B'' tid0),
-                      LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                   |}
-                   ( inv(s(MV ''pkB'' tid0)) )
-            |}
-            ( LN ''check_nonce_4'' tid0 ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_3_6_1_A_text_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_A_text_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_B_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_B_1_Ra t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_B_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_B_text_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_B_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_B_5_Ra5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_B_5_T t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_B_5_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_B_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_B_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_B_5_pkA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_T_3_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_T_3_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_T_3_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_T_3_Rpa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_T_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_T_text_4_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_T_text_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_1_T_text_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_3_6_1_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_3_6_1_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_3_6_1_state) A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_6_1_A"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_6_1_A_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_6_1_B &
-        ( tid1, isoiec_9798_3_6_1_B_2 ) : steps t &
-        {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''Ra'' tid0,
-                s(MV ''Rb'' tid0), s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''check_4'',
-                          {| LC ''isoiec_9798_3_6_opt_1_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
-                             s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                          |},
-                          Enc {| LC ''isoiec_9798_3_6_opt_1_sig_2'', s(AV ''B'' tid0),
-                                 LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                              |}
-                              ( inv(s(MV ''pkB'' tid0)) )
-                       |}
-                       ( LN ''check_nonce_4'' tid0 ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis proof(sources! " LN ''check_nonce_4'' tid0 ")
-    qed (insert facts, fastsimp+)?
-  next
-    case (isoiec_9798_3_6_1_A_check_4_out_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_6_opt_1_sig_2'', s(AV ''B'' tid0),
-                            LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                         |}
-                         ( inv(s(MV ''pkB'' tid0)) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_3_6_opt_1_sig_4_1'', LN ''Rpa'' tid0,
-                              s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text6'' tid0)
-                           |}
-                           ( SK ( s(AV ''T'' tid0) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest!: ltk_secrecy)
-      next
-        case (isoiec_9798_3_6_1_T_4_enc tid1) note_unified facts = this facts
-        thus ?thesis by (fastsimp dest!: ltk_secrecy)
-      qed (insert facts, fastsimp+)?
-    next
-      case (isoiec_9798_3_6_1_B_2_enc tid1) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_6_1_state) B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_6_1_B"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_6_1_B_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_6_1_A &
-        ( tid1, isoiec_9798_3_6_1_A_5 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
-           s(MV ''Text8'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra5'' tid0),
-                LN ''Rb'' tid0, s(MV ''Text8'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_6_opt_1_sig_4_2'', LN ''Rb'' tid0,
-                          s(MV ''A'' tid0), s(MV ''pkA'' tid0), s(MV ''Text5'' tid0)
-                       |}
-                       ( SK ( s(MV ''T'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_6_1_T_4_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_6_opt_1_sig_5'', LN ''Rb'' tid0,
-                            s(MV ''Ra5'' tid0), s(AV ''B'' tid0), s(MV ''A'' tid0),
-                            s(MV ''Text8'' tid0)
-                         |}
-                         ( SK ( s(MV ''A'' tid0) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_3_6_1_A_5_enc tid2) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_6_1_state) A_non_injective_agreement_T:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_6_1_A"
-    "RLKR(s(AV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_6_1_A_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_6_1_T &
-        ( tid1, isoiec_9798_3_6_1_T_4 ) : steps t &
-        {| s(MV ''B'' tid1), s(AV ''T'' tid1), s(MV ''Rpa'' tid1),
-           PK ( s(MV ''B'' tid1) ), s(MV ''Text6'' tid1)
-        |} = {| s(AV ''B'' tid0), s(AV ''T'' tid0), LN ''Rpa'' tid0,
-                s(MV ''pkB'' tid0), s(MV ''Text6'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_6_opt_1_sig_4_1'', LN ''Rpa'' tid0,
-                          s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text6'' tid0)
-                       |}
-                       ( SK ( s(AV ''T'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_6_1_T_4_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_6_1_state) B_non_injective_agreement_T:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_6_1_B"
-    "RLKR(s(MV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_6_1_B_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_6_1_T &
-        ( tid1, isoiec_9798_3_6_1_T_4 ) : steps t &
-        {| s(MV ''A'' tid1), s(AV ''T'' tid1), s(MV ''Rb'' tid1),
-           PK ( s(MV ''A'' tid1) ), s(MV ''Text5'' tid1)
-        |} = {| s(MV ''A'' tid0), s(MV ''T'' tid0), LN ''Rb'' tid0,
-                s(MV ''pkA'' tid0), s(MV ''Text5'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_6_opt_1_sig_4_2'', LN ''Rb'' tid0,
-                          s(MV ''A'' tid0), s(MV ''pkA'' tid0), s(MV ''Text5'' tid0)
-                       |}
-                       ( SK ( s(MV ''T'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_6_1_T_4_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-role isoiec_9798_3_6_2_A
-where "isoiec_9798_3_6_2_A =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''A'', sAV ''B'', sN ''Ra'', sMV ''Text1'' |>
-  , Recv ''2'' <| sAV ''A'', sAV ''B'', sN ''Ra'', sMV ''Rb'',
-                  sMV ''Text3'', sMV ''TokenBA''
-               |>
-  , Recv ''text_3'' ( sMV ''Text4'' )
-  , Send ''3'' <| sAV ''A'', sAV ''T'', sN ''Rpa'', sMV ''Rb'', sAV ''B'',
-                  sMV ''Text4''
-               |>
-  , Recv ''4'' <| sAV ''T'', sAV ''A'', sMV ''Text7'', sAV ''A'',
-                  sPK ''A'', sAV ''B'', sMV ''pkB'', sMV ''TokenTA''
-               |>
-  , Send ''check_4_out'' ( PEnc <| sC ''check_4'', sMV ''TokenTA'',
-                                   sMV ''TokenBA''
-                                |>
-                                ( sN ''check_nonce_4'' )
-                         )
-  , Recv ''check_4_in'' ( PEnc <| sC ''check_4'',
-                                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_4'', sN ''Rpa'', sMV ''Rb'',
-                                           sAV ''A'', sMV ''pkA'', sAV ''B'', sMV ''pkB'', sMV ''Text5''
-                                        |>
-                                        ( sPK ''T'' ),
-                                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_2'', sAV ''B'', sN ''Ra'',
-                                           sMV ''Rb'', sAV ''A'', sMV ''Text2''
-                                        |>
-                                        ( sMV ''pkB'' )
-                               |>
-                               ( sN ''check_nonce_4'' )
-                        )
-  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
-  , Send ''5'' <| sAV ''A'', sAV ''B'', sN ''Rpa'', sMV ''Text9'',
-                  sAV ''T'', sMV ''TokenTA'',
-                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_5'', sMV ''Rb'', sN ''Ra'',
-                           sAV ''B'', sAV ''A'', sMV ''Text8''
-                        |>
-                        ( sPK ''A'' )
-               |>
-  ]"
-
-role isoiec_9798_3_6_2_B
-where "isoiec_9798_3_6_2_B =
-  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Ra'', sMV ''Text1'' |>
-  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
-  , Send ''2'' <| sMV ''A'', sAV ''B'', sMV ''Ra'', sN ''Rb'',
-                  sMV ''Text3'',
-                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_2'', sAV ''B'', sMV ''Ra'',
-                           sN ''Rb'', sMV ''A'', sMV ''Text2''
-                        |>
-                        ( sPK ''B'' )
-               |>
-  , Recv ''5'' <| sMV ''A'', sAV ''B'', sMV ''Rpa'', sMV ''Text9'',
-                  sMV ''T'',
-                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_4'', sMV ''Rpa'', sN ''Rb'',
-                           sMV ''A'', sMV ''pkA'', sAV ''B'', sMV ''pkB'', sMV ''Text5''
-                        |>
-                        ( PAsymPK ( sMV ''T'' ) ),
-                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_5'', sN ''Rb'', sMV ''Ra5'',
-                           sAV ''B'', sMV ''A'', sMV ''Text8''
-                        |>
-                        ( sMV ''pkA'' )
-               |>
-  ]"
-
-role isoiec_9798_3_6_2_T
-where "isoiec_9798_3_6_2_T =
-  [ Recv ''3'' <| sMV ''A'', sAV ''T'', sMV ''Rpa'', sMV ''Rb'', sMV ''B'',
-                  sMV ''Text4''
-               |>
-  , Recv ''text_4'' <| sMV ''Text5'', sMV ''Text7'' |>
-  , Send ''4'' <| sAV ''T'', sMV ''A'', sMV ''Text7'', sMV ''A'',
-                  PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
-                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_4'', sMV ''Rpa'', sMV ''Rb'',
-                           sMV ''A'', PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
-                           sMV ''Text5''
-                        |>
-                        ( sPK ''T'' )
-               |>
-  ]"
-
-protocol isoiec_9798_3_6_2
-where "isoiec_9798_3_6_2 =
-{ isoiec_9798_3_6_2_A, isoiec_9798_3_6_2_B, isoiec_9798_3_6_2_T }"
-
-locale restricted_isoiec_9798_3_6_2_state = isoiec_9798_3_6_2_state
-
-type_invariant isoiec_9798_3_6_2_msc_typing for isoiec_9798_3_6_2
-where "isoiec_9798_3_6_2_msc_typing = mk_typing
-  [ ((isoiec_9798_3_6_2_B, ''A''), (KnownT isoiec_9798_3_6_2_B_1))
-  , ((isoiec_9798_3_6_2_T, ''A''), (KnownT isoiec_9798_3_6_2_T_3))
-  , ((isoiec_9798_3_6_2_T, ''B''), (KnownT isoiec_9798_3_6_2_T_3))
-  , ((isoiec_9798_3_6_2_B, ''Ra''), (KnownT isoiec_9798_3_6_2_B_1))
-  , ((isoiec_9798_3_6_2_B, ''Ra5''), (KnownT isoiec_9798_3_6_2_B_5))
-  , ((isoiec_9798_3_6_2_A, ''Rb''), (KnownT isoiec_9798_3_6_2_A_2))
-  , ((isoiec_9798_3_6_2_T, ''Rb''), (KnownT isoiec_9798_3_6_2_T_3))
-  , ((isoiec_9798_3_6_2_B, ''Rpa''), (KnownT isoiec_9798_3_6_2_B_5))
-  , ((isoiec_9798_3_6_2_T, ''Rpa''), (KnownT isoiec_9798_3_6_2_T_3))
-  , ((isoiec_9798_3_6_2_B, ''T''), (KnownT isoiec_9798_3_6_2_B_5))
-  , ((isoiec_9798_3_6_2_A, ''Text1''), (KnownT isoiec_9798_3_6_2_A_text_1))
-  , ((isoiec_9798_3_6_2_B, ''Text1''), (KnownT isoiec_9798_3_6_2_B_1))
-  , ((isoiec_9798_3_6_2_A, ''Text2''),
-     (KnownT isoiec_9798_3_6_2_A_check_4_in))
-  , ((isoiec_9798_3_6_2_B, ''Text2''), (KnownT isoiec_9798_3_6_2_B_text_2))
-  , ((isoiec_9798_3_6_2_A, ''Text3''), (KnownT isoiec_9798_3_6_2_A_2))
-  , ((isoiec_9798_3_6_2_B, ''Text3''), (KnownT isoiec_9798_3_6_2_B_text_2))
-  , ((isoiec_9798_3_6_2_A, ''Text4''), (KnownT isoiec_9798_3_6_2_A_text_3))
-  , ((isoiec_9798_3_6_2_T, ''Text4''), (KnownT isoiec_9798_3_6_2_T_3))
-  , ((isoiec_9798_3_6_2_A, ''Text5''),
-     (KnownT isoiec_9798_3_6_2_A_check_4_in))
-  , ((isoiec_9798_3_6_2_B, ''Text5''), (KnownT isoiec_9798_3_6_2_B_5))
-  , ((isoiec_9798_3_6_2_T, ''Text5''), (KnownT isoiec_9798_3_6_2_T_text_4))
-  , ((isoiec_9798_3_6_2_A, ''Text7''), (KnownT isoiec_9798_3_6_2_A_4))
-  , ((isoiec_9798_3_6_2_T, ''Text7''), (KnownT isoiec_9798_3_6_2_T_text_4))
-  , ((isoiec_9798_3_6_2_A, ''Text8''), (KnownT isoiec_9798_3_6_2_A_text_5))
-  , ((isoiec_9798_3_6_2_B, ''Text8''), (KnownT isoiec_9798_3_6_2_B_5))
-  , ((isoiec_9798_3_6_2_A, ''Text9''), (KnownT isoiec_9798_3_6_2_A_text_5))
-  , ((isoiec_9798_3_6_2_B, ''Text9''), (KnownT isoiec_9798_3_6_2_B_5))
-  , ((isoiec_9798_3_6_2_A, ''TokenBA''), (KnownT isoiec_9798_3_6_2_A_2))
-  , ((isoiec_9798_3_6_2_A, ''TokenTA''), (KnownT isoiec_9798_3_6_2_A_4))
-  , ((isoiec_9798_3_6_2_A, ''pkA''),
-     (KnownT isoiec_9798_3_6_2_A_check_4_in))
-  , ((isoiec_9798_3_6_2_B, ''pkA''), (KnownT isoiec_9798_3_6_2_B_5))
-  , ((isoiec_9798_3_6_2_A, ''pkB''), (KnownT isoiec_9798_3_6_2_A_4))
-  , ((isoiec_9798_3_6_2_B, ''pkB''), (KnownT isoiec_9798_3_6_2_B_5))
-  ]"
-
-sublocale isoiec_9798_3_6_2_state < isoiec_9798_3_6_2_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_3_6_2_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_3_6_2_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_3_6_2_A_2_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_A_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_A_2_TokenBA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_A_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_A_4_TokenTA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_A_4_pkB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_A_check_4_in_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''check_4'',
-               {| {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                     s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                     s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                  |},
-                  Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                         s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                         s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                      |}
-                      ( SK ( s(AV ''T'' tid0) ) )
-               |},
-               {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
-                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-               |},
-               Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
-                      LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                   |}
-                   ( inv(s(MV ''pkB'' tid0)) )
-            |}
-            ( LN ''check_nonce_4'' tid0 ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_3_6_2_A_check_4_in_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''check_4'',
-               {| {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                     s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                     s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                  |},
-                  Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                         s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                         s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                      |}
-                      ( SK ( s(AV ''T'' tid0) ) )
-               |},
-               {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
-                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-               |},
-               Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
-                      LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                   |}
-                   ( inv(s(MV ''pkB'' tid0)) )
-            |}
-            ( LN ''check_nonce_4'' tid0 ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_3_6_2_A_check_4_in_pkA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''check_4'',
-               {| {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                     s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                     s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                  |},
-                  Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                         s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                         s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                      |}
-                      ( SK ( s(AV ''T'' tid0) ) )
-               |},
-               {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
-                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-               |},
-               Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
-                      LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                   |}
-                   ( inv(s(MV ''pkB'' tid0)) )
-            |}
-            ( LN ''check_nonce_4'' tid0 ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_3_6_2_A_text_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_A_text_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_1_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_1_Ra t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_text_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_text_2_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_5_Ra5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_5_Rpa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_5_T t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_5_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_5_pkA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_B_5_pkB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_T_3_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_T_3_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_T_3_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_T_3_Rpa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_T_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_T_text_4_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_6_2_T_text_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_3_6_2_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_3_6_2_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_3_6_2_state) A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_6_2_A"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_6_2_A_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_6_2_B &
-        ( tid1, isoiec_9798_3_6_2_B_2 ) : steps t &
-        {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''Ra'' tid0,
-                s(MV ''Rb'' tid0), s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''check_4'',
-                          {| {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                                s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                                s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                             |},
-                             Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                                    s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                                    s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                                 |}
-                                 ( SK ( s(AV ''T'' tid0) ) )
-                          |},
-                          {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
-                             s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                          |},
-                          Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
-                                 LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                              |}
-                              ( inv(s(MV ''pkB'' tid0)) )
-                       |}
-                       ( LN ''check_nonce_4'' tid0 ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis proof(sources! " LN ''check_nonce_4'' tid0 ")
-    qed (insert facts, fastsimp+)?
-  next
-    case (isoiec_9798_3_6_2_A_check_4_out_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
-                            LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                         |}
-                         ( inv(s(MV ''pkB'' tid0)) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                              s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                              s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                           |}
-                           ( SK ( s(AV ''T'' tid0) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest!: ltk_secrecy)
-      next
-        case (isoiec_9798_3_6_2_T_4_enc tid1) note_unified facts = this facts
-        thus ?thesis by (fastsimp dest!: ltk_secrecy)
-      qed (insert facts, fastsimp+)?
-    next
-      case (isoiec_9798_3_6_2_B_2_enc tid1) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_6_2_state) B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_6_2_B"
-    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_6_2_B_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_6_2_A &
-        ( tid1, isoiec_9798_3_6_2_A_5 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
-           s(MV ''Text8'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra5'' tid0),
-                LN ''Rb'' tid0, s(MV ''Text8'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', s(MV ''Rpa'' tid0),
-                          LN ''Rb'' tid0, s(MV ''A'' tid0), s(MV ''pkA'' tid0), s(AV ''B'' tid0),
-                          s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                       |}
-                       ( SK ( s(MV ''T'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_6_2_T_4_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_6_opt_2_sig_5'', LN ''Rb'' tid0,
-                            s(MV ''Ra5'' tid0), s(AV ''B'' tid0), s(MV ''A'' tid0),
-                            s(MV ''Text8'' tid0)
-                         |}
-                         ( SK ( s(MV ''A'' tid0) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_3_6_2_A_5_enc tid2) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_6_2_state) A_non_injective_agreement_T:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_6_2_A"
-    "RLKR(s(AV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_6_2_A_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_6_2_T &
-        ( tid1, isoiec_9798_3_6_2_T_4 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''T'' tid1),
-           s(MV ''Rpa'' tid1), s(MV ''Rb'' tid1), PK ( s(MV ''A'' tid1) ),
-           PK ( s(MV ''B'' tid1) ), s(MV ''Text5'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''T'' tid0),
-                LN ''Rpa'' tid0, s(MV ''Rb'' tid0), s(MV ''pkA'' tid0),
-                s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''check_4'',
-                          {| {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                                s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                                s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                             |},
-                             Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                                    s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                                    s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                                 |}
-                                 ( SK ( s(AV ''T'' tid0) ) )
-                          |},
-                          {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
-                             s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                          |},
-                          Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
-                                 LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
-                              |}
-                              ( inv(s(MV ''pkB'' tid0)) )
-                       |}
-                       ( LN ''check_nonce_4'' tid0 ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis proof(sources! " LN ''check_nonce_4'' tid0 ")
-    qed (insert facts, fastsimp+)?
-  next
-    case (isoiec_9798_3_6_2_A_check_4_out_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
-                            s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                            s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                         |}
-                         ( SK ( s(AV ''T'' tid0) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_3_6_2_T_4_enc tid1) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_6_2_state) B_non_injective_agreement_T:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_6_2_B"
-    "RLKR(s(MV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_6_2_B_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_6_2_T &
-        ( tid1, isoiec_9798_3_6_2_T_4 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''T'' tid1),
-           s(MV ''Rpa'' tid1), s(MV ''Rb'' tid1), PK ( s(MV ''A'' tid1) ),
-           PK ( s(MV ''B'' tid1) ), s(MV ''Text5'' tid1)
-        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''T'' tid0),
-                s(MV ''Rpa'' tid0), LN ''Rb'' tid0, s(MV ''pkA'' tid0),
-                s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', s(MV ''Rpa'' tid0),
-                          LN ''Rb'' tid0, s(MV ''A'' tid0), s(MV ''pkA'' tid0), s(AV ''B'' tid0),
-                          s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
-                       |}
-                       ( SK ( s(MV ''T'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_6_2_T_4_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-role isoiec_9798_3_7_1_A
-where "isoiec_9798_3_7_1_A =
-  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
-  , Recv ''text_2'' ( sMV ''Text2'' )
-  , Send ''2'' <| sAV ''A'', sAV ''T'', sN ''Rpa'', sMV ''Rb'', sAV ''A'',
-                  sMV ''B'', sMV ''Text2''
-               |>
-  , Recv ''3'' <| sAV ''T'', sAV ''A'', sMV ''Text5'', sAV ''A'',
-                  sPK ''A'', sMV ''B'', sMV ''pkB'',
-                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_3_1'', sN ''Rpa'', sMV ''B'',
-                           sMV ''pkB'', sMV ''Text4''
-                        |>
-                        ( sPK ''T'' ),
-                  sMV ''TokenTA_for_B''
-               |>
-  , Recv ''text_4'' <| sMV ''Text6'', sMV ''Text7'' |>
-  , Send ''4'' <| sAV ''A'', sMV ''B'', sN ''Rpa'', sMV ''Text7'',
-                  sAV ''T'', sMV ''TokenTA_for_B'',
-                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_4'', sMV ''Rb'', sN ''Ra'',
-                           sMV ''B'', sAV ''A'', sMV ''Text6''
-                        |>
-                        ( sPK ''A'' )
-               |>
-  , Recv ''5'' <| sAV ''A'', sMV ''B'', sN ''Ra'', sMV ''Rb'',
-                  sMV ''Text9'',
-                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_5'', sN ''Ra'', sMV ''Rb'',
-                           sAV ''A'', sMV ''B'', sMV ''Text8''
-                        |>
-                        ( sMV ''pkB'' )
-               |>
-  ]"
-
-role isoiec_9798_3_7_1_B
-where "isoiec_9798_3_7_1_B =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
-  , Recv ''4'' <| sAV ''A'', sAV ''B'', sMV ''Rpa'', sMV ''Text9'',
-                  sMV ''T'',
-                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_3_2'', sN ''Rb'', sAV ''A'',
-                           sMV ''pkA'', sMV ''Text3''
-                        |>
-                        ( PAsymPK ( sMV ''T'' ) ),
-                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_4'', sN ''Rb'', sMV ''Ra'',
-                           sAV ''B'', sAV ''A'', sMV ''Text6''
-                        |>
-                        ( sMV ''pkA'' )
-               |>
-  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
-  , Send ''5'' <| sAV ''A'', sAV ''B'', sMV ''Ra'', sN ''Rb'',
-                  sMV ''Text9'',
-                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_5'', sMV ''Ra'', sN ''Rb'',
-                           sAV ''A'', sAV ''B'', sMV ''Text8''
-                        |>
-                        ( sPK ''B'' )
-               |>
-  ]"
-
-role isoiec_9798_3_7_1_T
-where "isoiec_9798_3_7_1_T =
-  [ Recv ''2'' <| sMV ''A'', sAV ''T'', sMV ''Rpa'', sMV ''Rb'', sMV ''A'',
-                  sMV ''B'', sMV ''Text2''
-               |>
-  , Recv ''text_3'' <| sMV ''Text3'', sMV ''Text4'', sMV ''Text5'' |>
-  , Send ''3'' <| sAV ''T'', sMV ''A'', sMV ''Text5'', sMV ''A'',
-                  PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
-                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_3_1'', sMV ''Rpa'', sMV ''B'',
-                           PAsymPK ( sMV ''B'' ), sMV ''Text4''
-                        |>
-                        ( sPK ''T'' ),
-                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_3_2'', sMV ''Rb'', sMV ''A'',
-                           PAsymPK ( sMV ''A'' ), sMV ''Text3''
-                        |>
-                        ( sPK ''T'' )
-               |>
-  ]"
-
-protocol isoiec_9798_3_7_1
-where "isoiec_9798_3_7_1 =
-{ isoiec_9798_3_7_1_A, isoiec_9798_3_7_1_B, isoiec_9798_3_7_1_T }"
-
-locale restricted_isoiec_9798_3_7_1_state = isoiec_9798_3_7_1_state
-
-type_invariant isoiec_9798_3_7_1_msc_typing for isoiec_9798_3_7_1
-where "isoiec_9798_3_7_1_msc_typing = mk_typing
-  [ ((isoiec_9798_3_7_1_T, ''A''), (KnownT isoiec_9798_3_7_1_T_2))
-  , ((isoiec_9798_3_7_1_A, ''B''), (KnownT isoiec_9798_3_7_1_A_1))
-  , ((isoiec_9798_3_7_1_T, ''B''), (KnownT isoiec_9798_3_7_1_T_2))
-  , ((isoiec_9798_3_7_1_B, ''Ra''), (KnownT isoiec_9798_3_7_1_B_4))
-  , ((isoiec_9798_3_7_1_A, ''Rb''), (KnownT isoiec_9798_3_7_1_A_1))
-  , ((isoiec_9798_3_7_1_T, ''Rb''), (KnownT isoiec_9798_3_7_1_T_2))
-  , ((isoiec_9798_3_7_1_B, ''Rpa''), (KnownT isoiec_9798_3_7_1_B_4))
-  , ((isoiec_9798_3_7_1_T, ''Rpa''), (KnownT isoiec_9798_3_7_1_T_2))
-  , ((isoiec_9798_3_7_1_B, ''T''), (KnownT isoiec_9798_3_7_1_B_4))
-  , ((isoiec_9798_3_7_1_A, ''Text1''), (KnownT isoiec_9798_3_7_1_A_1))
-  , ((isoiec_9798_3_7_1_B, ''Text1''), (KnownT isoiec_9798_3_7_1_B_text_1))
-  , ((isoiec_9798_3_7_1_A, ''Text2''), (KnownT isoiec_9798_3_7_1_A_text_2))
-  , ((isoiec_9798_3_7_1_T, ''Text2''), (KnownT isoiec_9798_3_7_1_T_2))
-  , ((isoiec_9798_3_7_1_B, ''Text3''), (KnownT isoiec_9798_3_7_1_B_4))
-  , ((isoiec_9798_3_7_1_T, ''Text3''), (KnownT isoiec_9798_3_7_1_T_text_3))
-  , ((isoiec_9798_3_7_1_A, ''Text4''), (KnownT isoiec_9798_3_7_1_A_3))
-  , ((isoiec_9798_3_7_1_T, ''Text4''), (KnownT isoiec_9798_3_7_1_T_text_3))
-  , ((isoiec_9798_3_7_1_A, ''Text5''), (KnownT isoiec_9798_3_7_1_A_3))
-  , ((isoiec_9798_3_7_1_T, ''Text5''), (KnownT isoiec_9798_3_7_1_T_text_3))
-  , ((isoiec_9798_3_7_1_A, ''Text6''), (KnownT isoiec_9798_3_7_1_A_text_4))
-  , ((isoiec_9798_3_7_1_B, ''Text6''), (KnownT isoiec_9798_3_7_1_B_4))
-  , ((isoiec_9798_3_7_1_A, ''Text7''), (KnownT isoiec_9798_3_7_1_A_text_4))
-  , ((isoiec_9798_3_7_1_A, ''Text8''), (KnownT isoiec_9798_3_7_1_A_5))
-  , ((isoiec_9798_3_7_1_B, ''Text8''), (KnownT isoiec_9798_3_7_1_B_text_5))
-  , ((isoiec_9798_3_7_1_A, ''Text9''), (KnownT isoiec_9798_3_7_1_A_5))
-  , ((isoiec_9798_3_7_1_B, ''Text9''), (KnownT isoiec_9798_3_7_1_B_4))
-  , ((isoiec_9798_3_7_1_A, ''TokenTA_for_B''),
-     (KnownT isoiec_9798_3_7_1_A_3))
-  , ((isoiec_9798_3_7_1_B, ''pkA''), (KnownT isoiec_9798_3_7_1_B_4))
-  , ((isoiec_9798_3_7_1_A, ''pkB''), (KnownT isoiec_9798_3_7_1_A_3))
-  ]"
-
-sublocale isoiec_9798_3_7_1_state < isoiec_9798_3_7_1_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_3_7_1_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_3_7_1_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_3_7_1_A_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_A_1_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_A_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_A_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_A_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_A_3_TokenTA_for_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_A_3_pkB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_A_text_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_A_text_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_A_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_A_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_B_4_Ra t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_B_4_Rpa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_B_4_T t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_B_4_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_B_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_B_4_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_B_4_pkA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_B_text_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_T_2_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_T_2_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_T_2_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_T_2_Rpa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_T_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_T_text_3_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_T_text_3_Text4 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_1_T_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_3_7_1_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_3_7_1_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_3_7_1_state) A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_7_1_A"
-    "RLKR(s(AV ''T'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_7_1_A_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_7_1_B &
-        ( tid1, isoiec_9798_3_7_1_B_5 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
-           s(MV ''Text8'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''Ra'' tid0,
-                s(MV ''Rb'' tid0), s(MV ''Text8'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_7_opt_1_sig_3_1'', LN ''Rpa'' tid0,
-                          s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text4'' tid0)
-                       |}
-                       ( SK ( s(AV ''T'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_7_1_T_3_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_7_opt_1_sig_5'', LN ''Ra'' tid0,
-                            s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
-                            s(MV ''Text8'' tid0)
-                         |}
-                         ( SK ( s(MV ''B'' tid0) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_3_7_1_B_5_enc tid2) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_7_1_state) B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_7_1_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_7_1_B_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_7_1_A &
-        ( tid1, isoiec_9798_3_7_1_A_4 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
-           s(MV ''Text6'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
-                LN ''Rb'' tid0, s(MV ''Text6'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_7_opt_1_sig_3_2'', LN ''Rb'' tid0,
-                          s(AV ''A'' tid0), s(MV ''pkA'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( SK ( s(MV ''T'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_7_1_T_3_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_7_opt_1_sig_4'', LN ''Rb'' tid0,
-                            s(MV ''Ra'' tid0), s(AV ''B'' tid0), s(AV ''A'' tid0),
-                            s(MV ''Text6'' tid0)
-                         |}
-                         ( SK ( s(AV ''A'' tid0) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_3_7_1_A_4_enc tid2) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_7_1_state) A_non_injective_agreement_T:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_7_1_A"
-    "RLKR(s(AV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_7_1_A_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_7_1_T &
-        ( tid1, isoiec_9798_3_7_1_T_3 ) : steps t &
-        {| s(MV ''B'' tid1), s(AV ''T'' tid1), s(MV ''Rpa'' tid1),
-           PK ( s(MV ''B'' tid1) ), s(MV ''Text4'' tid1)
-        |} = {| s(MV ''B'' tid0), s(AV ''T'' tid0), LN ''Rpa'' tid0,
-                s(MV ''pkB'' tid0), s(MV ''Text4'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_7_opt_1_sig_3_1'', LN ''Rpa'' tid0,
-                          s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text4'' tid0)
-                       |}
-                       ( SK ( s(AV ''T'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_7_1_T_3_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_7_1_state) B_non_injective_agreement_T:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_7_1_B"
-    "RLKR(s(MV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_7_1_B_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_7_1_T &
-        ( tid1, isoiec_9798_3_7_1_T_3 ) : steps t &
-        {| s(MV ''A'' tid1), s(AV ''T'' tid1), s(MV ''Rb'' tid1),
-           PK ( s(MV ''A'' tid1) ), s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''T'' tid0), LN ''Rb'' tid0,
-                s(MV ''pkA'' tid0), s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_7_opt_1_sig_3_2'', LN ''Rb'' tid0,
-                          s(AV ''A'' tid0), s(MV ''pkA'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( SK ( s(MV ''T'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_7_1_T_3_enc_1 tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
-qed
-
-role isoiec_9798_3_7_2_A
-where "isoiec_9798_3_7_2_A =
-  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
-  , Recv ''text_2'' ( sMV ''Text2'' )
-  , Send ''2'' <| sAV ''A'', sAV ''T'', sN ''Rpa'', sMV ''Rb'', sAV ''A'',
-                  sMV ''B'', sMV ''Text2''
-               |>
-  , Recv ''3'' <| sAV ''T'', sAV ''A'', sMV ''Text5'', sAV ''A'',
-                  sPK ''A'', sMV ''B'', sMV ''pkB'', sMV ''TokenTA''
-               |>
-  , Send ''check_3_out'' ( PEnc <| sC ''check_4'', sMV ''TokenTA'' |>
-                                ( sN ''check_nonce_4'' )
-                         )
-  , Recv ''check_3_in'' ( PEnc <| sC ''check_4'',
-                                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_3'', sN ''Rpa'', sMV ''Rb'',
-                                           sAV ''A'', sMV ''pkA'', sMV ''B'', sMV ''pkB'', sMV ''Text3''
-                                        |>
-                                        ( sPK ''T'' )
-                               |>
-                               ( sN ''check_nonce_4'' )
-                        )
-  , Recv ''text_4'' <| sMV ''Text6'', sMV ''Text7'' |>
-  , Send ''4'' <| sAV ''A'', sMV ''B'', sN ''Rpa'', sMV ''Text7'',
-                  sAV ''T'', sMV ''TokenTA'',
-                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_4'', sMV ''Rb'', sN ''Ra'',
-                           sMV ''B'', sAV ''A'', sMV ''Text6''
-                        |>
-                        ( sPK ''A'' )
-               |>
-  , Recv ''5'' <| sAV ''A'', sMV ''B'', sN ''Ra'', sMV ''Rb'',
-                  sMV ''Text9'',
-                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_5'', sN ''Ra'', sMV ''Rb'',
-                           sAV ''A'', sMV ''B'', sMV ''Text8''
-                        |>
-                        ( sMV ''pkB'' )
-               |>
-  ]"
-
-role isoiec_9798_3_7_2_B
-where "isoiec_9798_3_7_2_B =
-  [ Recv ''text_1'' ( sMV ''Text1'' )
-  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
-  , Recv ''4'' <| sAV ''A'', sAV ''B'', sMV ''Rpa'', sMV ''Text9'',
-                  sMV ''T'',
-                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_3'', sMV ''Rpa'', sN ''Rb'',
-                           sAV ''A'', sMV ''pkA'', sAV ''B'', sMV ''pkB'', sMV ''Text3''
-                        |>
-                        ( PAsymPK ( sMV ''T'' ) ),
-                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_4'', sN ''Rb'', sMV ''Ra'',
-                           sAV ''B'', sAV ''A'', sMV ''Text6''
-                        |>
-                        ( sMV ''pkA'' )
-               |>
-  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
-  , Send ''5'' <| sAV ''A'', sAV ''B'', sMV ''Ra'', sN ''Rb'',
-                  sMV ''Text9'',
-                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_5'', sMV ''Ra'', sN ''Rb'',
-                           sAV ''A'', sAV ''B'', sMV ''Text8''
-                        |>
-                        ( sPK ''B'' )
-               |>
-  ]"
-
-role isoiec_9798_3_7_2_T
-where "isoiec_9798_3_7_2_T =
-  [ Recv ''2'' <| sMV ''A'', sAV ''T'', sMV ''Rpa'', sMV ''Rb'', sMV ''A'',
-                  sMV ''B'', sMV ''Text2''
-               |>
-  , Recv ''text_3'' <| sMV ''Text3'', sMV ''Text5'' |>
-  , Send ''3'' <| sAV ''T'', sMV ''A'', sMV ''Text5'', sMV ''A'',
-                  PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
-                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_3'', sMV ''Rpa'', sMV ''Rb'',
-                           sMV ''A'', PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
-                           sMV ''Text3''
-                        |>
-                        ( sPK ''T'' )
-               |>
-  ]"
-
-protocol isoiec_9798_3_7_2
-where "isoiec_9798_3_7_2 =
-{ isoiec_9798_3_7_2_A, isoiec_9798_3_7_2_B, isoiec_9798_3_7_2_T }"
-
-locale restricted_isoiec_9798_3_7_2_state = isoiec_9798_3_7_2_state
-
-type_invariant isoiec_9798_3_7_2_msc_typing for isoiec_9798_3_7_2
-where "isoiec_9798_3_7_2_msc_typing = mk_typing
-  [ ((isoiec_9798_3_7_2_T, ''A''), (KnownT isoiec_9798_3_7_2_T_2))
-  , ((isoiec_9798_3_7_2_A, ''B''), (KnownT isoiec_9798_3_7_2_A_1))
-  , ((isoiec_9798_3_7_2_T, ''B''), (KnownT isoiec_9798_3_7_2_T_2))
-  , ((isoiec_9798_3_7_2_B, ''Ra''), (KnownT isoiec_9798_3_7_2_B_4))
-  , ((isoiec_9798_3_7_2_A, ''Rb''), (KnownT isoiec_9798_3_7_2_A_1))
-  , ((isoiec_9798_3_7_2_T, ''Rb''), (KnownT isoiec_9798_3_7_2_T_2))
-  , ((isoiec_9798_3_7_2_B, ''Rpa''), (KnownT isoiec_9798_3_7_2_B_4))
-  , ((isoiec_9798_3_7_2_T, ''Rpa''), (KnownT isoiec_9798_3_7_2_T_2))
-  , ((isoiec_9798_3_7_2_B, ''T''), (KnownT isoiec_9798_3_7_2_B_4))
-  , ((isoiec_9798_3_7_2_A, ''Text1''), (KnownT isoiec_9798_3_7_2_A_1))
-  , ((isoiec_9798_3_7_2_B, ''Text1''), (KnownT isoiec_9798_3_7_2_B_text_1))
-  , ((isoiec_9798_3_7_2_A, ''Text2''), (KnownT isoiec_9798_3_7_2_A_text_2))
-  , ((isoiec_9798_3_7_2_T, ''Text2''), (KnownT isoiec_9798_3_7_2_T_2))
-  , ((isoiec_9798_3_7_2_A, ''Text3''),
-     (KnownT isoiec_9798_3_7_2_A_check_3_in))
-  , ((isoiec_9798_3_7_2_B, ''Text3''), (KnownT isoiec_9798_3_7_2_B_4))
-  , ((isoiec_9798_3_7_2_T, ''Text3''), (KnownT isoiec_9798_3_7_2_T_text_3))
-  , ((isoiec_9798_3_7_2_A, ''Text5''), (KnownT isoiec_9798_3_7_2_A_3))
-  , ((isoiec_9798_3_7_2_T, ''Text5''), (KnownT isoiec_9798_3_7_2_T_text_3))
-  , ((isoiec_9798_3_7_2_A, ''Text6''), (KnownT isoiec_9798_3_7_2_A_text_4))
-  , ((isoiec_9798_3_7_2_B, ''Text6''), (KnownT isoiec_9798_3_7_2_B_4))
-  , ((isoiec_9798_3_7_2_A, ''Text7''), (KnownT isoiec_9798_3_7_2_A_text_4))
-  , ((isoiec_9798_3_7_2_A, ''Text8''), (KnownT isoiec_9798_3_7_2_A_5))
-  , ((isoiec_9798_3_7_2_B, ''Text8''), (KnownT isoiec_9798_3_7_2_B_text_5))
-  , ((isoiec_9798_3_7_2_A, ''Text9''), (KnownT isoiec_9798_3_7_2_A_5))
-  , ((isoiec_9798_3_7_2_B, ''Text9''), (KnownT isoiec_9798_3_7_2_B_4))
-  , ((isoiec_9798_3_7_2_A, ''TokenTA''), (KnownT isoiec_9798_3_7_2_A_3))
-  , ((isoiec_9798_3_7_2_A, ''pkA''),
-     (KnownT isoiec_9798_3_7_2_A_check_3_in))
-  , ((isoiec_9798_3_7_2_B, ''pkA''), (KnownT isoiec_9798_3_7_2_B_4))
-  , ((isoiec_9798_3_7_2_A, ''pkB''), (KnownT isoiec_9798_3_7_2_A_3))
-  , ((isoiec_9798_3_7_2_B, ''pkB''), (KnownT isoiec_9798_3_7_2_B_4))
-  ]"
-
-sublocale isoiec_9798_3_7_2_state < isoiec_9798_3_7_2_msc_typing_state
-proof -
-  have "(t,r,s) : approx isoiec_9798_3_7_2_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF isoiec_9798_3_7_2_msc_typing.monoTyp, completeness_cases_rule])
-    case (isoiec_9798_3_7_2_A_1_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_A_1_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_A_1_Text1 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_A_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_A_3_TokenTA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_A_3_pkB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_A_check_3_in_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''check_4'',
-               {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
-                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                  s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-               |},
-               Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
-                      s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                      s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-                   |}
-                   ( SK ( s(AV ''T'' tid0) ) )
-            |}
-            ( LN ''check_nonce_4'' tid0 ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_3_7_2_A_check_3_in_pkA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc {| LC ''check_4'',
-               {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
-                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                  s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-               |},
-               Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
-                      s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                      s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-                   |}
-                   ( SK ( s(AV ''T'' tid0) ) )
-            |}
-            ( LN ''check_nonce_4'' tid0 ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
-  next
-    case (isoiec_9798_3_7_2_A_text_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_A_text_4_Text7 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_A_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_A_5_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_B_4_Ra t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_B_4_Rpa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_B_4_T t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_B_4_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_B_4_Text6 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_B_4_Text9 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_B_4_pkA t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_B_4_pkB t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_B_text_5_Text8 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_T_2_A t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_T_2_B t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_T_2_Rb t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_T_2_Rpa t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_T_2_Text2 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_T_text_3_Text3 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  next
-    case (isoiec_9798_3_7_2_T_text_3_Text5 t r s tid0) note facts = this
-    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
-  qed
-  thus "isoiec_9798_3_7_2_msc_typing_state t r s" by unfold_locales auto
-qed
-
-text{* Prove secrecy of long-term keys. *}
-context isoiec_9798_3_7_2_state begin
-
-  (* This rule is unsafe in general, but OK here, 
-     as we are only reasoning about static compromise. 
-  *)
-  lemma static_longterm_key_reveal[dest!]:
-    "predOrd t (LKR a) e ==> RLKR a : reveals t"
-    by (auto intro: compr_predOrdI)
-
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "RLKR m ~: reveals t"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_sym_ud_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemma longterm_sym_bd_key_secrecy:
-    assumes facts:
-      "Kbd m1 m2 : knows t"
-      "RLKR m1 ~: reveals t"
-      "RLKR m2 ~: reveals t"
-      "m1 : Agent"
-      "m2 : Agent"
-    shows "False"
-  proof -
-    from facts 
-    have "KShr (agents {m1, m2}) : knows t"
-      by (auto simp: Kbd_def)
-    thus ?thesis using facts
-    proof (sources "KShr (agents {m1, m2})")
-    qed (auto simp: agents_def Agent_def)
-  qed
-
-  lemmas ltk_secrecy =
-    longterm_sym_ud_key_secrecy
-    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
-    longterm_sym_bd_key_secrecy
-    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-
-end
-
-lemma (in restricted_isoiec_9798_3_7_2_state) A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_7_2_A"
-    "RLKR(s(AV ''T'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_7_2_A_5 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_7_2_B &
-        ( tid1, isoiec_9798_3_7_2_B_5 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
-           s(MV ''Text8'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''Ra'' tid0,
-                s(MV ''Rb'' tid0), s(MV ''Text8'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''check_4'',
-                          {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
-                             s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                             s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-                          |},
-                          Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
-                                 s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                                 s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-                              |}
-                              ( SK ( s(AV ''T'' tid0) ) )
-                       |}
-                       ( LN ''check_nonce_4'' tid0 ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis proof(sources! " LN ''check_nonce_4'' tid0 ")
-    qed (insert facts, fastsimp+)?
-  next
-    case (isoiec_9798_3_7_2_A_check_3_out_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
-                            s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                            s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-                         |}
-                         ( SK ( s(AV ''T'' tid0) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_3_7_2_T_3_enc tid1) note_unified facts = this facts
-      thus ?thesis proof(sources! "
-                       Enc {| LC ''isoiec_9798_3_7_opt_2_sig_5'', LN ''Ra'' tid0,
-                              s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
-                              s(MV ''Text8'' tid0)
-                           |}
-                           ( SK ( s(MV ''B'' tid0) ) ) ")
-        case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest!: ltk_secrecy)
-      next
-        case (isoiec_9798_3_7_2_B_5_enc tid2) note_unified facts = this facts
-        thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-      qed (insert facts, fastsimp+)?
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_7_2_state) B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_7_2_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_7_2_B_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_7_2_A &
-        ( tid1, isoiec_9798_3_7_2_A_4 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
-           s(MV ''Text6'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
-                LN ''Rb'' tid0, s(MV ''Text6'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', s(MV ''Rpa'' tid0),
-                          LN ''Rb'' tid0, s(AV ''A'' tid0), s(MV ''pkA'' tid0), s(AV ''B'' tid0),
-                          s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( SK ( s(MV ''T'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_7_2_T_3_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_7_opt_2_sig_4'', LN ''Rb'' tid0,
-                            s(MV ''Ra'' tid0), s(AV ''B'' tid0), s(AV ''A'' tid0),
-                            s(MV ''Text6'' tid0)
-                         |}
-                         ( SK ( s(AV ''A'' tid0) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_3_7_2_A_4_enc tid2) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_7_2_state) A_non_injective_agreement_T:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_7_2_A"
-    "RLKR(s(AV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_7_2_A_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_7_2_T &
-        ( tid1, isoiec_9798_3_7_2_T_3 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''T'' tid1),
-           s(MV ''Rpa'' tid1), s(MV ''Rb'' tid1), PK ( s(MV ''A'' tid1) ),
-           PK ( s(MV ''B'' tid1) ), s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''T'' tid0),
-                LN ''Rpa'' tid0, s(MV ''Rb'' tid0), s(MV ''pkA'' tid0),
-                s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''check_4'',
-                          {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
-                             s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                             s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-                          |},
-                          Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
-                                 s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                                 s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-                              |}
-                              ( SK ( s(AV ''T'' tid0) ) )
-                       |}
-                       ( LN ''check_nonce_4'' tid0 ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis proof(sources! " LN ''check_nonce_4'' tid0 ")
-    qed (insert facts, fastsimp+)?
-  next
-    case (isoiec_9798_3_7_2_A_check_3_out_enc tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
-                            s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
-                            s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-                         |}
-                         ( SK ( s(AV ''T'' tid0) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_3_7_2_T_3_enc tid1) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_3_7_2_state) B_non_injective_agreement_T:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_3_7_2_B"
-    "RLKR(s(MV ''T'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_3_7_2_B_4 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_3_7_2_T &
-        ( tid1, isoiec_9798_3_7_2_T_3 ) : steps t &
-        {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''T'' tid1),
-           s(MV ''Rpa'' tid1), s(MV ''Rb'' tid1), PK ( s(MV ''A'' tid1) ),
-           PK ( s(MV ''B'' tid1) ), s(MV ''Text3'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''T'' tid0),
-                s(MV ''Rpa'' tid0), LN ''Rb'' tid0, s(MV ''pkA'' tid0),
-                s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', s(MV ''Rpa'' tid0),
-                          LN ''Rb'' tid0, s(AV ''A'' tid0), s(MV ''pkA'' tid0), s(AV ''B'' tid0),
-                          s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
-                       |}
-                       ( SK ( s(MV ''T'' tid0) ) ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_3_7_2_T_3_enc tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+  "ESPLogic"
+begin
+
+role isoiec_9798_3_1_A
+where "isoiec_9798_3_1_A =
+  [ Send ''leak_A'' ( sN ''TNA'' )
+  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
+  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
+                  PSign <| sC ''isoiec_9798_3_1_sig_1'', sN ''TNA'', sAV ''B'',
+                           sMV ''Text1''
+                        |>
+                        ( sPK ''A'' )
+               |>
+  ]"
+
+role isoiec_9798_3_1_B
+where "isoiec_9798_3_1_B =
+  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
+                  PSign <| sC ''isoiec_9798_3_1_sig_1'', sMV ''TNA'', sAV ''B'',
+                           sMV ''Text1''
+                        |>
+                        ( PAsymPK ( sMV ''A'' ) )
+               |>
+  ]"
+
+protocol isoiec_9798_3_1
+where "isoiec_9798_3_1 = { isoiec_9798_3_1_A, isoiec_9798_3_1_B }"
+
+locale restricted_isoiec_9798_3_1_state = isoiec_9798_3_1_state
+
+type_invariant isoiec_9798_3_1_msc_typing for isoiec_9798_3_1
+where "isoiec_9798_3_1_msc_typing = mk_typing
+  [ ((isoiec_9798_3_1_B, ''A''), (KnownT isoiec_9798_3_1_B_1))
+  , ((isoiec_9798_3_1_B, ''TNA''), (KnownT isoiec_9798_3_1_B_1))
+  , ((isoiec_9798_3_1_A, ''Text1''), (KnownT isoiec_9798_3_1_A_text_1))
+  , ((isoiec_9798_3_1_B, ''Text1''), (KnownT isoiec_9798_3_1_B_1))
+  , ((isoiec_9798_3_1_A, ''Text2''), (KnownT isoiec_9798_3_1_A_text_1))
+  , ((isoiec_9798_3_1_B, ''Text2''), (KnownT isoiec_9798_3_1_B_1))
+  ]"
+
+sublocale isoiec_9798_3_1_state < isoiec_9798_3_1_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_3_1_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_3_1_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_3_1_A_text_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_1_A_text_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_1_B_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_1_B_1_TNA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_1_B_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_1_B_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_3_1_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_3_1_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_3_1_state) B_non_injective_agreement:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_3_1_B"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_3_1_B_1 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_3_1_A &
+        ( tid1, isoiec_9798_3_1_A_1 ) : steps t &
+        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
+           s(MV ''Text1'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
+                s(MV ''Text1'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_3_1_sig_1'', s(MV ''TNA'' tid0),
+                          s(AV ''B'' tid0), s(MV ''Text1'' tid0)
+                       |}
+                       ( SK ( s(MV ''A'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_3_1_A_1_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
+qed
+
+role isoiec_9798_3_2_A
+where "isoiec_9798_3_2_A =
+  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
+  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
+  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
+                  PSign <| sC ''isoiec_9798_3_2_sig_2'', sN ''Ra'', sMV ''Rb'', sMV ''B'',
+                           sMV ''Text2''
+                        |>
+                        ( sPK ''A'' )
+               |>
+  ]"
+
+role isoiec_9798_3_2_B
+where "isoiec_9798_3_2_B =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
+  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
+                  PSign <| sC ''isoiec_9798_3_2_sig_2'', sMV ''Ra'', sN ''Rb'', sAV ''B'',
+                           sMV ''Text2''
+                        |>
+                        ( sPK ''A'' )
+               |>
+  ]"
+
+protocol isoiec_9798_3_2
+where "isoiec_9798_3_2 = { isoiec_9798_3_2_A, isoiec_9798_3_2_B }"
+
+locale restricted_isoiec_9798_3_2_state = isoiec_9798_3_2_state
+
+type_invariant isoiec_9798_3_2_msc_typing for isoiec_9798_3_2
+where "isoiec_9798_3_2_msc_typing = mk_typing
+  [ ((isoiec_9798_3_2_A, ''B''), (KnownT isoiec_9798_3_2_A_1))
+  , ((isoiec_9798_3_2_B, ''Ra''), (KnownT isoiec_9798_3_2_B_2))
+  , ((isoiec_9798_3_2_A, ''Rb''), (KnownT isoiec_9798_3_2_A_1))
+  , ((isoiec_9798_3_2_A, ''Text1''), (KnownT isoiec_9798_3_2_A_1))
+  , ((isoiec_9798_3_2_B, ''Text1''), (KnownT isoiec_9798_3_2_B_text_1))
+  , ((isoiec_9798_3_2_A, ''Text2''), (KnownT isoiec_9798_3_2_A_text_2))
+  , ((isoiec_9798_3_2_B, ''Text2''), (KnownT isoiec_9798_3_2_B_2))
+  , ((isoiec_9798_3_2_A, ''Text3''), (KnownT isoiec_9798_3_2_A_text_2))
+  , ((isoiec_9798_3_2_B, ''Text3''), (KnownT isoiec_9798_3_2_B_2))
+  ]"
+
+sublocale isoiec_9798_3_2_state < isoiec_9798_3_2_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_3_2_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_3_2_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_3_2_A_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_2_A_1_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_2_A_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_2_A_text_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_2_A_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_2_B_2_Ra t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_2_B_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_2_B_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_3_2_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_3_2_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_3_2_state) B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_2_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_2_B_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_2_A &
+          ( tid1, isoiec_9798_3_2_A_2 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
+                  LN ''Rb'' tid0, s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_2_sig_2'', s(MV ''Ra'' tid0), LN ''Rb'' tid0,
+                              s(AV ''B'' tid0), s(MV ''Text2'' tid0)
+                           |}
+                           ( SK ( s(AV ''A'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_2_A_2_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+role isoiec_9798_3_3_A
+where "isoiec_9798_3_3_A =
+  [ Send ''leak_A'' ( sN ''TNA'' )
+  , Recv ''text_1'' <| sMV ''Text1'', sMV ''Text2'' |>
+  , Send ''1'' <| sAV ''A'', sAV ''B'', sMV ''Text2'',
+                  PSign <| sC ''isoiec_9798_3_3_sig_1'', sN ''TNA'', sAV ''B'',
+                           sMV ''Text1''
+                        |>
+                        ( sPK ''A'' )
+               |>
+  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text4'',
+                  PSign <| sC ''isoiec_9798_3_3_sig_2'', sMV ''TNB'', sAV ''A'',
+                           sMV ''Text3''
+                        |>
+                        ( sPK ''B'' )
+               |>
+  ]"
+
+role isoiec_9798_3_3_B
+where "isoiec_9798_3_3_B =
+  [ Send ''leak_B'' ( sN ''TNB'' )
+  , Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Text2'',
+                  PSign <| sC ''isoiec_9798_3_3_sig_1'', sMV ''TNA'', sAV ''B'',
+                           sMV ''Text1''
+                        |>
+                        ( PAsymPK ( sMV ''A'' ) )
+               |>
+  , Recv ''text_2'' <| sMV ''Text3'', sMV ''Text4'' |>
+  , Send ''2'' <| sMV ''A'', sAV ''B'', sMV ''Text4'',
+                  PSign <| sC ''isoiec_9798_3_3_sig_2'', sN ''TNB'', sMV ''A'',
+                           sMV ''Text3''
+                        |>
+                        ( sPK ''B'' )
+               |>
+  ]"
+
+protocol isoiec_9798_3_3
+where "isoiec_9798_3_3 = { isoiec_9798_3_3_A, isoiec_9798_3_3_B }"
+
+locale restricted_isoiec_9798_3_3_state = isoiec_9798_3_3_state
+
+type_invariant isoiec_9798_3_3_msc_typing for isoiec_9798_3_3
+where "isoiec_9798_3_3_msc_typing = mk_typing
+  [ ((isoiec_9798_3_3_B, ''A''), (KnownT isoiec_9798_3_3_B_1))
+  , ((isoiec_9798_3_3_B, ''TNA''), (KnownT isoiec_9798_3_3_B_1))
+  , ((isoiec_9798_3_3_A, ''TNB''), (KnownT isoiec_9798_3_3_A_2))
+  , ((isoiec_9798_3_3_A, ''Text1''), (KnownT isoiec_9798_3_3_A_text_1))
+  , ((isoiec_9798_3_3_B, ''Text1''), (KnownT isoiec_9798_3_3_B_1))
+  , ((isoiec_9798_3_3_A, ''Text2''), (KnownT isoiec_9798_3_3_A_text_1))
+  , ((isoiec_9798_3_3_B, ''Text2''), (KnownT isoiec_9798_3_3_B_1))
+  , ((isoiec_9798_3_3_A, ''Text3''), (KnownT isoiec_9798_3_3_A_2))
+  , ((isoiec_9798_3_3_B, ''Text3''), (KnownT isoiec_9798_3_3_B_text_2))
+  , ((isoiec_9798_3_3_A, ''Text4''), (KnownT isoiec_9798_3_3_A_2))
+  , ((isoiec_9798_3_3_B, ''Text4''), (KnownT isoiec_9798_3_3_B_text_2))
+  ]"
+
+sublocale isoiec_9798_3_3_state < isoiec_9798_3_3_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_3_3_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_3_3_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_3_3_A_text_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_3_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_3_A_text_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_3_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_3_A_2_TNB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_3_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_3_A_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_3_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_3_A_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_3_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_3_B_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_3_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_3_B_1_TNA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_3_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_3_B_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_3_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_3_B_1_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_3_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_3_B_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_3_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_3_B_text_2_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_3_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_3_3_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_3_3_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_3_3_state) A_non_injective_agreement:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_3_3_A"
+    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_3_3_A_2 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_3_3_B &
+        ( tid1, isoiec_9798_3_3_B_2 ) : steps t &
+        {| s(MV ''A'' tid1), s(AV ''B'' tid1), LN ''TNB'' tid1,
+           s(MV ''Text3'' tid1)
+        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNB'' tid0),
+                s(MV ''Text3'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_3_3_sig_2'', s(MV ''TNB'' tid0),
+                          s(AV ''A'' tid0), s(MV ''Text3'' tid0)
+                       |}
+                       ( SK ( s(AV ''B'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_3_3_B_2_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
+qed
+
+lemma (in restricted_isoiec_9798_3_3_state) B_non_injective_agreement:
+  assumes facts:
+    "roleMap r tid0 = Some isoiec_9798_3_3_B"
+    "RLKR(s(MV ''A'' tid0)) ~: reveals t"
+    "( tid0, isoiec_9798_3_3_B_1 ) : steps t"
+  shows
+    "(?  tid1.
+        roleMap r tid1 = Some isoiec_9798_3_3_A &
+        ( tid1, isoiec_9798_3_3_A_1 ) : steps t &
+        {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''TNA'' tid1,
+           s(MV ''Text1'' tid1)
+        |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''TNA'' tid0),
+                s(MV ''Text1'' tid0)
+             |})"
+proof -
+  note_prefix_closed facts = facts
+  thus ?thesis proof(sources! "
+                   Enc {| LC ''isoiec_9798_3_3_sig_1'', s(MV ''TNA'' tid0),
+                          s(AV ''B'' tid0), s(MV ''Text1'' tid0)
+                       |}
+                       ( SK ( s(MV ''A'' tid0) ) ) ")
+    case fake note_unified facts = this facts
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
+  next
+    case (isoiec_9798_3_3_A_1_enc tid1) note_unified facts = this facts
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
+qed
+
+role isoiec_9798_3_4_A
+where "isoiec_9798_3_4_A =
+  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text1'' |>
+  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
+  , Send ''2'' <| sAV ''A'', sMV ''B'', sMV ''Text3'',
+                  PSign <| sC ''isoiec_9798_3_4_sig_1'', sN ''RA'', sMV ''RB'', sMV ''B'',
+                           sMV ''Text2''
+                        |>
+                        ( sPK ''A'' )
+               |>
+  , Recv ''3'' <| sMV ''B'', sAV ''A'', sMV ''Text5'',
+                  PSign <| sC ''isoiec_9798_3_4_sig_2'', sMV ''RB'', sN ''RA'', sAV ''A'',
+                           sMV ''Text4''
+                        |>
+                        ( PAsymPK ( sMV ''B'' ) )
+               |>
+  ]"
+
+role isoiec_9798_3_4_B
+where "isoiec_9798_3_4_B =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''RB'', sMV ''Text1'' |>
+  , Recv ''2'' <| sAV ''A'', sAV ''B'', sMV ''Text3'',
+                  PSign <| sC ''isoiec_9798_3_4_sig_1'', sMV ''RA'', sN ''RB'', sAV ''B'',
+                           sMV ''Text2''
+                        |>
+                        ( sPK ''A'' )
+               |>
+  , Recv ''text_3'' <| sMV ''Text4'', sMV ''Text5'' |>
+  , Send ''3'' <| sAV ''B'', sAV ''A'', sMV ''Text5'',
+                  PSign <| sC ''isoiec_9798_3_4_sig_2'', sN ''RB'', sMV ''RA'', sAV ''A'',
+                           sMV ''Text4''
+                        |>
+                        ( sPK ''B'' )
+               |>
+  ]"
+
+protocol isoiec_9798_3_4
+where "isoiec_9798_3_4 = { isoiec_9798_3_4_A, isoiec_9798_3_4_B }"
+
+locale restricted_isoiec_9798_3_4_state = isoiec_9798_3_4_state
+
+type_invariant isoiec_9798_3_4_msc_typing for isoiec_9798_3_4
+where "isoiec_9798_3_4_msc_typing = mk_typing
+  [ ((isoiec_9798_3_4_A, ''B''), (KnownT isoiec_9798_3_4_A_1))
+  , ((isoiec_9798_3_4_B, ''RA''), (KnownT isoiec_9798_3_4_B_2))
+  , ((isoiec_9798_3_4_A, ''RB''), (KnownT isoiec_9798_3_4_A_1))
+  , ((isoiec_9798_3_4_A, ''Text1''), (KnownT isoiec_9798_3_4_A_1))
+  , ((isoiec_9798_3_4_B, ''Text1''), (KnownT isoiec_9798_3_4_B_text_1))
+  , ((isoiec_9798_3_4_A, ''Text2''), (KnownT isoiec_9798_3_4_A_text_2))
+  , ((isoiec_9798_3_4_B, ''Text2''), (KnownT isoiec_9798_3_4_B_2))
+  , ((isoiec_9798_3_4_A, ''Text3''), (KnownT isoiec_9798_3_4_A_text_2))
+  , ((isoiec_9798_3_4_B, ''Text3''), (KnownT isoiec_9798_3_4_B_2))
+  , ((isoiec_9798_3_4_A, ''Text4''), (KnownT isoiec_9798_3_4_A_3))
+  , ((isoiec_9798_3_4_B, ''Text4''), (KnownT isoiec_9798_3_4_B_text_3))
+  , ((isoiec_9798_3_4_A, ''Text5''), (KnownT isoiec_9798_3_4_A_3))
+  , ((isoiec_9798_3_4_B, ''Text5''), (KnownT isoiec_9798_3_4_B_text_3))
+  ]"
+
+sublocale isoiec_9798_3_4_state < isoiec_9798_3_4_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_3_4_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_3_4_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_3_4_A_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_A_1_RB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_A_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_A_text_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_A_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_A_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_A_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_B_2_RA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_B_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_B_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_B_text_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_4_B_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_4_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_3_4_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_3_4_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_3_4_state) A_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_4_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_4_A_3 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_4_B &
+          ( tid1, isoiec_9798_3_4_B_3 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''RA'' tid1), LN ''RB'' tid1,
+             s(MV ''Text2'' tid1), s(MV ''Text4'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''RA'' tid0,
+                  s(MV ''RB'' tid0), s(MV ''Text2'' tid0), s(MV ''Text4'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_4_sig_2'', s(MV ''RB'' tid0), LN ''RA'' tid0,
+                              s(AV ''A'' tid0), s(MV ''Text4'' tid0)
+                           |}
+                           ( SK ( s(MV ''B'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_4_B_3_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_4_sig_1'', LN ''RA'' tid0, LN ''RB'' tid1,
+                                s(AV ''B'' tid1), s(MV ''Text2'' tid1)
+                             |}
+                             ( SK ( s(AV ''A'' tid0) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_3_4_A_2_enc tid2) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_4_state) B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_4_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_4_B_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_4_A &
+          ( tid1, isoiec_9798_3_4_A_2 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''RA'' tid1, s(MV ''RB'' tid1),
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''RA'' tid0),
+                  LN ''RB'' tid0, s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_4_sig_1'', s(MV ''RA'' tid0), LN ''RB'' tid0,
+                              s(AV ''B'' tid0), s(MV ''Text2'' tid0)
+                           |}
+                           ( SK ( s(AV ''A'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_4_A_2_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+role isoiec_9798_3_5_A
+where "isoiec_9798_3_5_A =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''A'', sAV ''B'', sN ''RA'', sMV ''Text1'' |>
+  , Recv ''2'' <| sAV ''B'', sAV ''A'', sMV ''RB'', sMV ''Text2'' |>
+  , Recv ''3'' <| sAV ''B'', sAV ''A'', sMV ''Text6'',
+                  PSign <| sC ''isoiec_9798_3_5_sig_1'', sMV ''RB'', sN ''RA'', sAV ''A'',
+                           sMV ''Text5''
+                        |>
+                        ( sPK ''B'' )
+               |>
+  , Recv ''text_4'' <| sMV ''Text3'', sMV ''Text4'' |>
+  , Send ''4'' <| sAV ''A'', sAV ''B'', sMV ''Text4'',
+                  PSign <| sC ''isoiec_9798_3_5_sig_2'', sN ''RA'', sMV ''RB'', sAV ''B'',
+                           sMV ''Text3''
+                        |>
+                        ( sPK ''A'' )
+               |>
+  ]"
+
+role isoiec_9798_3_5_B
+where "isoiec_9798_3_5_B =
+  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''RA'', sMV ''Text1'' |>
+  , Recv ''text_2'' ( sMV ''Text2'' )
+  , Send ''2'' <| sAV ''B'', sMV ''A'', sN ''RB'', sMV ''Text2'' |>
+  , Recv ''text_3'' <| sMV ''Text5'', sMV ''Text6'' |>
+  , Send ''3'' <| sAV ''B'', sMV ''A'', sMV ''Text6'',
+                  PSign <| sC ''isoiec_9798_3_5_sig_1'', sN ''RB'', sMV ''RA'', sMV ''A'',
+                           sMV ''Text5''
+                        |>
+                        ( sPK ''B'' )
+               |>
+  , Recv ''4'' <| sMV ''A'', sAV ''B'', sMV ''Text4'',
+                  PSign <| sC ''isoiec_9798_3_5_sig_2'', sMV ''RA'', sN ''RB'', sAV ''B'',
+                           sMV ''Text3''
+                        |>
+                        ( PAsymPK ( sMV ''A'' ) )
+               |>
+  ]"
+
+protocol isoiec_9798_3_5
+where "isoiec_9798_3_5 = { isoiec_9798_3_5_A, isoiec_9798_3_5_B }"
+
+locale restricted_isoiec_9798_3_5_state = isoiec_9798_3_5_state
+
+type_invariant isoiec_9798_3_5_msc_typing for isoiec_9798_3_5
+where "isoiec_9798_3_5_msc_typing = mk_typing
+  [ ((isoiec_9798_3_5_B, ''A''), (KnownT isoiec_9798_3_5_B_1))
+  , ((isoiec_9798_3_5_B, ''RA''), (KnownT isoiec_9798_3_5_B_1))
+  , ((isoiec_9798_3_5_A, ''RB''), (KnownT isoiec_9798_3_5_A_2))
+  , ((isoiec_9798_3_5_A, ''Text1''), (KnownT isoiec_9798_3_5_A_text_1))
+  , ((isoiec_9798_3_5_B, ''Text1''), (KnownT isoiec_9798_3_5_B_1))
+  , ((isoiec_9798_3_5_A, ''Text2''), (KnownT isoiec_9798_3_5_A_2))
+  , ((isoiec_9798_3_5_B, ''Text2''), (KnownT isoiec_9798_3_5_B_text_2))
+  , ((isoiec_9798_3_5_A, ''Text3''), (KnownT isoiec_9798_3_5_A_text_4))
+  , ((isoiec_9798_3_5_B, ''Text3''), (KnownT isoiec_9798_3_5_B_4))
+  , ((isoiec_9798_3_5_A, ''Text4''), (KnownT isoiec_9798_3_5_A_text_4))
+  , ((isoiec_9798_3_5_B, ''Text4''), (KnownT isoiec_9798_3_5_B_4))
+  , ((isoiec_9798_3_5_A, ''Text5''), (KnownT isoiec_9798_3_5_A_3))
+  , ((isoiec_9798_3_5_B, ''Text5''), (KnownT isoiec_9798_3_5_B_text_3))
+  , ((isoiec_9798_3_5_A, ''Text6''), (KnownT isoiec_9798_3_5_A_3))
+  , ((isoiec_9798_3_5_B, ''Text6''), (KnownT isoiec_9798_3_5_B_text_3))
+  ]"
+
+sublocale isoiec_9798_3_5_state < isoiec_9798_3_5_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_3_5_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_3_5_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_3_5_A_2_RB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_A_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_A_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_A_3_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_A_text_4_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_A_text_4_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_B_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_B_1_RA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_B_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_B_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_B_text_3_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_B_4_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_5_B_4_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_5_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_3_5_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_3_5_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_3_5_state) A_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_5_A &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_5_A_3 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_5_B &
+          ( tid1, isoiec_9798_3_5_B_3 ) : steps t &
+          {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''RA'' tid1), LN ''RB'' tid1,
+             s(MV ''Text5'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''RA'' tid0,
+                  s(MV ''RB'' tid0), s(MV ''Text5'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_5_sig_1'', s(MV ''RB'' tid0), LN ''RA'' tid0,
+                              s(AV ''A'' tid0), s(MV ''Text5'' tid0)
+                           |}
+                           ( SK ( s(AV ''B'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_5_B_3_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_5_state) B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_5_B &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(MV ''A'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_5_B_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_5_A &
+          ( tid1, isoiec_9798_3_5_A_4 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''RA'' tid1, s(MV ''RB'' tid1),
+             s(MV ''Text3'' tid1), s(MV ''Text5'' tid1)
+          |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''RA'' tid0),
+                  LN ''RB'' tid0, s(MV ''Text3'' tid0), s(MV ''Text5'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_5_sig_2'', s(MV ''RA'' tid0), LN ''RB'' tid0,
+                              s(AV ''B'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( SK ( s(MV ''A'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_5_A_4_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_5_sig_1'', LN ''RB'' tid0, LN ''RA'' tid1,
+                                s(AV ''A'' tid1), s(MV ''Text5'' tid1)
+                             |}
+                             ( SK ( s(AV ''B'' tid0) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_3_5_B_3_enc tid2) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+role isoiec_9798_3_6_1_A
+where "isoiec_9798_3_6_1_A =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''A'', sAV ''B'', sN ''Ra'', sMV ''Text1'' |>
+  , Recv ''2'' <| sAV ''A'', sAV ''B'', sN ''Ra'', sMV ''Rb'',
+                  sMV ''Text3'', sMV ''TokenBA''
+               |>
+  , Recv ''text_3'' ( sMV ''Text4'' )
+  , Send ''3'' <| sAV ''A'', sAV ''T'', sN ''Rpa'', sMV ''Rb'', sAV ''B'',
+                  sMV ''Text4''
+               |>
+  , Recv ''4'' <| sAV ''T'', sAV ''A'', sMV ''Text7'', sAV ''A'',
+                  sPK ''A'', sAV ''B'', sMV ''pkB'',
+                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_4_1'', sN ''Rpa'', sAV ''B'',
+                           sMV ''pkB'', sMV ''Text6''
+                        |>
+                        ( sPK ''T'' ),
+                  sMV ''TokenTA_for_B''
+               |>
+  , Send ''check_4_out'' ( PEnc <| sC ''check_4'', sMV ''TokenBA'' |>
+                                ( sN ''check_nonce_4'' )
+                         )
+  , Recv ''check_4_in'' ( PEnc <| sC ''check_4'',
+                                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_2'', sAV ''B'', sN ''Ra'',
+                                           sMV ''Rb'', sAV ''A'', sMV ''Text2''
+                                        |>
+                                        ( sMV ''pkB'' )
+                               |>
+                               ( sN ''check_nonce_4'' )
+                        )
+  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
+  , Send ''5'' <| sAV ''A'', sAV ''B'', sMV ''Text9'', sAV ''T'',
+                  sMV ''TokenTA_for_B'',
+                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_5'', sMV ''Rb'', sN ''Ra'',
+                           sAV ''B'', sAV ''A'', sMV ''Text8''
+                        |>
+                        ( sPK ''A'' )
+               |>
+  ]"
+
+role isoiec_9798_3_6_1_B
+where "isoiec_9798_3_6_1_B =
+  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Ra'', sMV ''Text1'' |>
+  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
+  , Send ''2'' <| sMV ''A'', sAV ''B'', sMV ''Ra'', sN ''Rb'',
+                  sMV ''Text3'',
+                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_2'', sAV ''B'', sMV ''Ra'',
+                           sN ''Rb'', sMV ''A'', sMV ''Text2''
+                        |>
+                        ( sPK ''B'' )
+               |>
+  , Recv ''5'' <| sMV ''A'', sAV ''B'', sMV ''Text9'', sMV ''T'',
+                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_4_2'', sN ''Rb'', sMV ''A'',
+                           sMV ''pkA'', sMV ''Text5''
+                        |>
+                        ( PAsymPK ( sMV ''T'' ) ),
+                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_5'', sN ''Rb'', sMV ''Ra'',
+                           sAV ''B'', sMV ''A'', sMV ''Text8''
+                        |>
+                        ( sMV ''pkA'' )
+               |>
+  ]"
+
+role isoiec_9798_3_6_1_T
+where "isoiec_9798_3_6_1_T =
+  [ Recv ''3'' <| sMV ''A'', sAV ''T'', sMV ''Rpa'', sMV ''Rb'', sMV ''B'',
+                  sMV ''Text4''
+               |>
+  , Recv ''text_4'' <| sMV ''Text5'', sMV ''Text6'', sMV ''Text7'' |>
+  , Send ''4'' <| sAV ''T'', sMV ''A'', sMV ''Text7'', sMV ''A'',
+                  PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
+                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_4_1'', sMV ''Rpa'', sMV ''B'',
+                           PAsymPK ( sMV ''B'' ), sMV ''Text6''
+                        |>
+                        ( sPK ''T'' ),
+                  PSign <| sC ''isoiec_9798_3_6_opt_1_sig_4_2'', sMV ''Rb'', sMV ''A'',
+                           PAsymPK ( sMV ''A'' ), sMV ''Text5''
+                        |>
+                        ( sPK ''T'' )
+               |>
+  ]"
+
+protocol isoiec_9798_3_6_1
+where "isoiec_9798_3_6_1 =
+{ isoiec_9798_3_6_1_A, isoiec_9798_3_6_1_B, isoiec_9798_3_6_1_T }"
+
+locale restricted_isoiec_9798_3_6_1_state = isoiec_9798_3_6_1_state
+
+type_invariant isoiec_9798_3_6_1_msc_typing for isoiec_9798_3_6_1
+where "isoiec_9798_3_6_1_msc_typing = mk_typing
+  [ ((isoiec_9798_3_6_1_B, ''A''), (KnownT isoiec_9798_3_6_1_B_1))
+  , ((isoiec_9798_3_6_1_T, ''A''), (KnownT isoiec_9798_3_6_1_T_3))
+  , ((isoiec_9798_3_6_1_T, ''B''), (KnownT isoiec_9798_3_6_1_T_3))
+  , ((isoiec_9798_3_6_1_B, ''Ra''), (KnownT isoiec_9798_3_6_1_B_1))
+  , ((isoiec_9798_3_6_1_A, ''Rb''), (KnownT isoiec_9798_3_6_1_A_2))
+  , ((isoiec_9798_3_6_1_T, ''Rb''), (KnownT isoiec_9798_3_6_1_T_3))
+  , ((isoiec_9798_3_6_1_T, ''Rpa''), (KnownT isoiec_9798_3_6_1_T_3))
+  , ((isoiec_9798_3_6_1_B, ''T''), (KnownT isoiec_9798_3_6_1_B_5))
+  , ((isoiec_9798_3_6_1_A, ''Text1''), (KnownT isoiec_9798_3_6_1_A_text_1))
+  , ((isoiec_9798_3_6_1_B, ''Text1''), (KnownT isoiec_9798_3_6_1_B_1))
+  , ((isoiec_9798_3_6_1_A, ''Text2''),
+     (KnownT isoiec_9798_3_6_1_A_check_4_in))
+  , ((isoiec_9798_3_6_1_B, ''Text2''), (KnownT isoiec_9798_3_6_1_B_text_2))
+  , ((isoiec_9798_3_6_1_A, ''Text3''), (KnownT isoiec_9798_3_6_1_A_2))
+  , ((isoiec_9798_3_6_1_B, ''Text3''), (KnownT isoiec_9798_3_6_1_B_text_2))
+  , ((isoiec_9798_3_6_1_A, ''Text4''), (KnownT isoiec_9798_3_6_1_A_text_3))
+  , ((isoiec_9798_3_6_1_T, ''Text4''), (KnownT isoiec_9798_3_6_1_T_3))
+  , ((isoiec_9798_3_6_1_B, ''Text5''), (KnownT isoiec_9798_3_6_1_B_5))
+  , ((isoiec_9798_3_6_1_T, ''Text5''), (KnownT isoiec_9798_3_6_1_T_text_4))
+  , ((isoiec_9798_3_6_1_A, ''Text6''), (KnownT isoiec_9798_3_6_1_A_4))
+  , ((isoiec_9798_3_6_1_T, ''Text6''), (KnownT isoiec_9798_3_6_1_T_text_4))
+  , ((isoiec_9798_3_6_1_A, ''Text7''), (KnownT isoiec_9798_3_6_1_A_4))
+  , ((isoiec_9798_3_6_1_T, ''Text7''), (KnownT isoiec_9798_3_6_1_T_text_4))
+  , ((isoiec_9798_3_6_1_A, ''Text8''), (KnownT isoiec_9798_3_6_1_A_text_5))
+  , ((isoiec_9798_3_6_1_B, ''Text8''), (KnownT isoiec_9798_3_6_1_B_5))
+  , ((isoiec_9798_3_6_1_A, ''Text9''), (KnownT isoiec_9798_3_6_1_A_text_5))
+  , ((isoiec_9798_3_6_1_B, ''Text9''), (KnownT isoiec_9798_3_6_1_B_5))
+  , ((isoiec_9798_3_6_1_A, ''TokenBA''), (KnownT isoiec_9798_3_6_1_A_2))
+  , ((isoiec_9798_3_6_1_A, ''TokenTA_for_B''),
+     (KnownT isoiec_9798_3_6_1_A_4))
+  , ((isoiec_9798_3_6_1_B, ''pkA''), (KnownT isoiec_9798_3_6_1_B_5))
+  , ((isoiec_9798_3_6_1_A, ''pkB''), (KnownT isoiec_9798_3_6_1_A_4))
+  ]"
+
+sublocale isoiec_9798_3_6_1_state < isoiec_9798_3_6_1_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_3_6_1_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_3_6_1_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_3_6_1_A_2_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_A_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_A_2_TokenBA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_A_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_A_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_A_4_TokenTA_for_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_A_4_pkB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_A_check_4_in_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''check_4'',
+               {| LC ''isoiec_9798_3_6_opt_1_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
+                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+               |},
+               Enc {| LC ''isoiec_9798_3_6_opt_1_sig_2'', s(AV ''B'' tid0),
+                      LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                   |}
+                   ( inv(s(MV ''pkB'' tid0)) )
+            |}
+            ( LN ''check_nonce_4'' tid0 ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_3_6_1_A_text_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_A_text_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_B_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_B_1_Ra t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_B_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_B_text_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_B_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_B_5_T t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_B_5_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_B_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_B_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_B_5_pkA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_T_3_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_T_3_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_T_3_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_T_3_Rpa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_T_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_T_text_4_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_T_text_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_1_T_text_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_3_6_1_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_3_6_1_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_3_6_1_state) A_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_6_1_A &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(AV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_6_1_A_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_6_1_B &
+          ( tid1, isoiec_9798_3_6_1_B_2 ) : steps t &
+          {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''Ra'' tid0,
+                  s(MV ''Rb'' tid0), s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''check_4'',
+                              {| LC ''isoiec_9798_3_6_opt_1_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
+                                 s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                              |},
+                              Enc {| LC ''isoiec_9798_3_6_opt_1_sig_2'', s(AV ''B'' tid0),
+                                     LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                                  |}
+                                  ( inv(s(MV ''pkB'' tid0)) )
+                           |}
+                           ( LN ''check_nonce_4'' tid0 ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis proof(sources! " LN ''check_nonce_4'' tid0 ")
+        qed (insert facts, fastforce+)?
+      next
+        case (isoiec_9798_3_6_1_A_check_4_out_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_6_opt_1_sig_2'', s(AV ''B'' tid0),
+                                LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                             |}
+                             ( inv(s(MV ''pkB'' tid0)) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_3_6_opt_1_sig_4_1'', LN ''Rpa'' tid0,
+                                  s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text6'' tid0)
+                               |}
+                               ( SK ( s(AV ''T'' tid0) ) ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest!: ltk_secrecy)
+          next
+            case (isoiec_9798_3_6_1_T_4_enc tid1) note_unified facts = this facts
+            thus ?thesis by (fastforce dest!: ltk_secrecy)
+          qed (insert facts, fastforce+)?
+        next
+          case (isoiec_9798_3_6_1_B_2_enc tid1) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_6_1_state) B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_6_1_B &
+          RLKR(s(MV ''A'' tid0)) ~: reveals t &
+          RLKR(s(MV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_6_1_B_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_6_1_A &
+          ( tid1, isoiec_9798_3_6_1_A_5 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
+             s(MV ''Text8'' tid1)
+          |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
+                  LN ''Rb'' tid0, s(MV ''Text8'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_6_opt_1_sig_4_2'', LN ''Rb'' tid0,
+                              s(MV ''A'' tid0), s(MV ''pkA'' tid0), s(MV ''Text5'' tid0)
+                           |}
+                           ( SK ( s(MV ''T'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_6_1_T_4_enc_1 tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_6_opt_1_sig_5'', LN ''Rb'' tid0,
+                                s(MV ''Ra'' tid0), s(AV ''B'' tid0), s(MV ''A'' tid0),
+                                s(MV ''Text8'' tid0)
+                             |}
+                             ( SK ( s(MV ''A'' tid0) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_3_6_1_A_5_enc tid2) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_6_1_state) A_injective_agreement_T:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_6_1_A &
+          RLKR(s(AV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_6_1_A_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_6_1_T &
+          ( tid1, isoiec_9798_3_6_1_T_4 ) : steps t &
+          {| s(MV ''B'' tid1), s(AV ''T'' tid1), s(MV ''Rpa'' tid1),
+             PK ( s(MV ''B'' tid1) ), s(MV ''Text6'' tid1)
+          |} = {| s(AV ''B'' tid0), s(AV ''T'' tid0), LN ''Rpa'' tid0,
+                  s(MV ''pkB'' tid0), s(MV ''Text6'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_6_opt_1_sig_4_1'', LN ''Rpa'' tid0,
+                              s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text6'' tid0)
+                           |}
+                           ( SK ( s(AV ''T'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_6_1_T_4_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_6_1_state) B_injective_agreement_T:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_6_1_B &
+          RLKR(s(MV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_6_1_B_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_6_1_T &
+          ( tid1, isoiec_9798_3_6_1_T_4 ) : steps t &
+          {| s(MV ''A'' tid1), s(AV ''T'' tid1), s(MV ''Rb'' tid1),
+             PK ( s(MV ''A'' tid1) ), s(MV ''Text5'' tid1)
+          |} = {| s(MV ''A'' tid0), s(MV ''T'' tid0), LN ''Rb'' tid0,
+                  s(MV ''pkA'' tid0), s(MV ''Text5'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_6_opt_1_sig_4_2'', LN ''Rb'' tid0,
+                              s(MV ''A'' tid0), s(MV ''pkA'' tid0), s(MV ''Text5'' tid0)
+                           |}
+                           ( SK ( s(MV ''T'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_6_1_T_4_enc_1 tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+role isoiec_9798_3_6_2_A
+where "isoiec_9798_3_6_2_A =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''A'', sAV ''B'', sN ''Ra'', sMV ''Text1'' |>
+  , Recv ''2'' <| sAV ''A'', sAV ''B'', sN ''Ra'', sMV ''Rb'',
+                  sMV ''Text3'', sMV ''TokenBA''
+               |>
+  , Recv ''text_3'' ( sMV ''Text4'' )
+  , Send ''3'' <| sAV ''A'', sAV ''T'', sN ''Rpa'', sMV ''Rb'', sAV ''B'',
+                  sMV ''Text4''
+               |>
+  , Recv ''4'' <| sAV ''T'', sAV ''A'', sMV ''Text7'', sAV ''A'',
+                  sPK ''A'', sAV ''B'', sMV ''pkB'', sMV ''TokenTA''
+               |>
+  , Send ''check_4_out'' ( PEnc <| sC ''check_4'', sMV ''TokenTA'',
+                                   sMV ''TokenBA''
+                                |>
+                                ( sN ''check_nonce_4'' )
+                         )
+  , Recv ''check_4_in'' ( PEnc <| sC ''check_4'',
+                                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_4'', sN ''Rpa'', sMV ''Rb'',
+                                           sAV ''A'', sMV ''pkA'', sAV ''B'', sMV ''pkB'', sMV ''Text5''
+                                        |>
+                                        ( sPK ''T'' ),
+                                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_2'', sAV ''B'', sN ''Ra'',
+                                           sMV ''Rb'', sAV ''A'', sMV ''Text2''
+                                        |>
+                                        ( sMV ''pkB'' )
+                               |>
+                               ( sN ''check_nonce_4'' )
+                        )
+  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
+  , Send ''5'' <| sAV ''A'', sAV ''B'', sN ''Rpa'', sMV ''Text9'',
+                  sAV ''T'', sMV ''TokenTA'',
+                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_5'', sMV ''Rb'', sN ''Ra'',
+                           sAV ''B'', sAV ''A'', sMV ''Text8''
+                        |>
+                        ( sPK ''A'' )
+               |>
+  ]"
+
+role isoiec_9798_3_6_2_B
+where "isoiec_9798_3_6_2_B =
+  [ Recv ''1'' <| sMV ''A'', sAV ''B'', sMV ''Ra'', sMV ''Text1'' |>
+  , Recv ''text_2'' <| sMV ''Text2'', sMV ''Text3'' |>
+  , Send ''2'' <| sMV ''A'', sAV ''B'', sMV ''Ra'', sN ''Rb'',
+                  sMV ''Text3'',
+                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_2'', sAV ''B'', sMV ''Ra'',
+                           sN ''Rb'', sMV ''A'', sMV ''Text2''
+                        |>
+                        ( sPK ''B'' )
+               |>
+  , Recv ''5'' <| sMV ''A'', sAV ''B'', sMV ''Rpa'', sMV ''Text9'',
+                  sMV ''T'',
+                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_4'', sMV ''Rpa'', sN ''Rb'',
+                           sMV ''A'', sMV ''pkA'', sAV ''B'', sMV ''pkB'', sMV ''Text5''
+                        |>
+                        ( PAsymPK ( sMV ''T'' ) ),
+                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_5'', sN ''Rb'', sMV ''Ra'',
+                           sAV ''B'', sMV ''A'', sMV ''Text8''
+                        |>
+                        ( sMV ''pkA'' )
+               |>
+  ]"
+
+role isoiec_9798_3_6_2_T
+where "isoiec_9798_3_6_2_T =
+  [ Recv ''3'' <| sMV ''A'', sAV ''T'', sMV ''Rpa'', sMV ''Rb'', sMV ''B'',
+                  sMV ''Text4''
+               |>
+  , Recv ''text_4'' <| sMV ''Text5'', sMV ''Text7'' |>
+  , Send ''4'' <| sAV ''T'', sMV ''A'', sMV ''Text7'', sMV ''A'',
+                  PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
+                  PSign <| sC ''isoiec_9798_3_6_opt_2_sig_4'', sMV ''Rpa'', sMV ''Rb'',
+                           sMV ''A'', PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
+                           sMV ''Text5''
+                        |>
+                        ( sPK ''T'' )
+               |>
+  ]"
+
+protocol isoiec_9798_3_6_2
+where "isoiec_9798_3_6_2 =
+{ isoiec_9798_3_6_2_A, isoiec_9798_3_6_2_B, isoiec_9798_3_6_2_T }"
+
+locale restricted_isoiec_9798_3_6_2_state = isoiec_9798_3_6_2_state
+
+type_invariant isoiec_9798_3_6_2_msc_typing for isoiec_9798_3_6_2
+where "isoiec_9798_3_6_2_msc_typing = mk_typing
+  [ ((isoiec_9798_3_6_2_B, ''A''), (KnownT isoiec_9798_3_6_2_B_1))
+  , ((isoiec_9798_3_6_2_T, ''A''), (KnownT isoiec_9798_3_6_2_T_3))
+  , ((isoiec_9798_3_6_2_T, ''B''), (KnownT isoiec_9798_3_6_2_T_3))
+  , ((isoiec_9798_3_6_2_B, ''Ra''), (KnownT isoiec_9798_3_6_2_B_1))
+  , ((isoiec_9798_3_6_2_A, ''Rb''), (KnownT isoiec_9798_3_6_2_A_2))
+  , ((isoiec_9798_3_6_2_T, ''Rb''), (KnownT isoiec_9798_3_6_2_T_3))
+  , ((isoiec_9798_3_6_2_B, ''Rpa''), (KnownT isoiec_9798_3_6_2_B_5))
+  , ((isoiec_9798_3_6_2_T, ''Rpa''), (KnownT isoiec_9798_3_6_2_T_3))
+  , ((isoiec_9798_3_6_2_B, ''T''), (KnownT isoiec_9798_3_6_2_B_5))
+  , ((isoiec_9798_3_6_2_A, ''Text1''), (KnownT isoiec_9798_3_6_2_A_text_1))
+  , ((isoiec_9798_3_6_2_B, ''Text1''), (KnownT isoiec_9798_3_6_2_B_1))
+  , ((isoiec_9798_3_6_2_A, ''Text2''),
+     (KnownT isoiec_9798_3_6_2_A_check_4_in))
+  , ((isoiec_9798_3_6_2_B, ''Text2''), (KnownT isoiec_9798_3_6_2_B_text_2))
+  , ((isoiec_9798_3_6_2_A, ''Text3''), (KnownT isoiec_9798_3_6_2_A_2))
+  , ((isoiec_9798_3_6_2_B, ''Text3''), (KnownT isoiec_9798_3_6_2_B_text_2))
+  , ((isoiec_9798_3_6_2_A, ''Text4''), (KnownT isoiec_9798_3_6_2_A_text_3))
+  , ((isoiec_9798_3_6_2_T, ''Text4''), (KnownT isoiec_9798_3_6_2_T_3))
+  , ((isoiec_9798_3_6_2_A, ''Text5''),
+     (KnownT isoiec_9798_3_6_2_A_check_4_in))
+  , ((isoiec_9798_3_6_2_B, ''Text5''), (KnownT isoiec_9798_3_6_2_B_5))
+  , ((isoiec_9798_3_6_2_T, ''Text5''), (KnownT isoiec_9798_3_6_2_T_text_4))
+  , ((isoiec_9798_3_6_2_A, ''Text7''), (KnownT isoiec_9798_3_6_2_A_4))
+  , ((isoiec_9798_3_6_2_T, ''Text7''), (KnownT isoiec_9798_3_6_2_T_text_4))
+  , ((isoiec_9798_3_6_2_A, ''Text8''), (KnownT isoiec_9798_3_6_2_A_text_5))
+  , ((isoiec_9798_3_6_2_B, ''Text8''), (KnownT isoiec_9798_3_6_2_B_5))
+  , ((isoiec_9798_3_6_2_A, ''Text9''), (KnownT isoiec_9798_3_6_2_A_text_5))
+  , ((isoiec_9798_3_6_2_B, ''Text9''), (KnownT isoiec_9798_3_6_2_B_5))
+  , ((isoiec_9798_3_6_2_A, ''TokenBA''), (KnownT isoiec_9798_3_6_2_A_2))
+  , ((isoiec_9798_3_6_2_A, ''TokenTA''), (KnownT isoiec_9798_3_6_2_A_4))
+  , ((isoiec_9798_3_6_2_A, ''pkA''),
+     (KnownT isoiec_9798_3_6_2_A_check_4_in))
+  , ((isoiec_9798_3_6_2_B, ''pkA''), (KnownT isoiec_9798_3_6_2_B_5))
+  , ((isoiec_9798_3_6_2_A, ''pkB''), (KnownT isoiec_9798_3_6_2_A_4))
+  , ((isoiec_9798_3_6_2_B, ''pkB''), (KnownT isoiec_9798_3_6_2_B_5))
+  ]"
+
+sublocale isoiec_9798_3_6_2_state < isoiec_9798_3_6_2_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_3_6_2_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_3_6_2_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_3_6_2_A_2_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_A_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_A_2_TokenBA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_A_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_A_4_TokenTA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_A_4_pkB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_A_check_4_in_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''check_4'',
+               {| {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                     s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                     s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                  |},
+                  Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                         s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                         s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                      |}
+                      ( SK ( s(AV ''T'' tid0) ) )
+               |},
+               {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
+                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+               |},
+               Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
+                      LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                   |}
+                   ( inv(s(MV ''pkB'' tid0)) )
+            |}
+            ( LN ''check_nonce_4'' tid0 ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_3_6_2_A_check_4_in_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''check_4'',
+               {| {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                     s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                     s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                  |},
+                  Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                         s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                         s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                      |}
+                      ( SK ( s(AV ''T'' tid0) ) )
+               |},
+               {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
+                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+               |},
+               Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
+                      LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                   |}
+                   ( inv(s(MV ''pkB'' tid0)) )
+            |}
+            ( LN ''check_nonce_4'' tid0 ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_3_6_2_A_check_4_in_pkA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''check_4'',
+               {| {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                     s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                     s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                  |},
+                  Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                         s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                         s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                      |}
+                      ( SK ( s(AV ''T'' tid0) ) )
+               |},
+               {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
+                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+               |},
+               Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
+                      LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                   |}
+                   ( inv(s(MV ''pkB'' tid0)) )
+            |}
+            ( LN ''check_nonce_4'' tid0 ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_3_6_2_A_text_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_A_text_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_1_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_1_Ra t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_text_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_text_2_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_5_Rpa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_5_T t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_5_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_5_pkA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_B_5_pkB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_T_3_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_T_3_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_T_3_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_T_3_Rpa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_T_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_T_text_4_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_6_2_T_text_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_6_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_3_6_2_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_3_6_2_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_3_6_2_state) A_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_6_2_A &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          RLKR(s(AV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_6_2_A_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_6_2_B &
+          ( tid1, isoiec_9798_3_6_2_B_2 ) : steps t &
+          {| s(MV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''Ra'' tid0,
+                  s(MV ''Rb'' tid0), s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''check_4'',
+                              {| {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                                    s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                    s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                                 |},
+                                 Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                                        s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                        s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                                     |}
+                                     ( SK ( s(AV ''T'' tid0) ) )
+                              |},
+                              {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
+                                 s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                              |},
+                              Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
+                                     LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                                  |}
+                                  ( inv(s(MV ''pkB'' tid0)) )
+                           |}
+                           ( LN ''check_nonce_4'' tid0 ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis proof(sources! " LN ''check_nonce_4'' tid0 ")
+        qed (insert facts, fastforce+)?
+      next
+        case (isoiec_9798_3_6_2_A_check_4_out_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
+                                LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                             |}
+                             ( inv(s(MV ''pkB'' tid0)) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                  s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                               |}
+                               ( SK ( s(AV ''T'' tid0) ) ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest!: ltk_secrecy)
+          next
+            case (isoiec_9798_3_6_2_T_4_enc tid1) note_unified facts = this facts
+            thus ?thesis by (fastforce dest!: ltk_secrecy)
+          qed (insert facts, fastforce+)?
+        next
+          case (isoiec_9798_3_6_2_B_2_enc tid1) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_6_2_state) B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_6_2_B &
+          RLKR(s(MV ''A'' tid0)) ~: reveals t &
+          RLKR(s(MV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_6_2_B_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_6_2_A &
+          ( tid1, isoiec_9798_3_6_2_A_5 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
+             s(MV ''Text8'' tid1)
+          |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
+                  LN ''Rb'' tid0, s(MV ''Text8'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', s(MV ''Rpa'' tid0),
+                              LN ''Rb'' tid0, s(MV ''A'' tid0), s(MV ''pkA'' tid0), s(AV ''B'' tid0),
+                              s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                           |}
+                           ( SK ( s(MV ''T'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_6_2_T_4_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_6_opt_2_sig_5'', LN ''Rb'' tid0,
+                                s(MV ''Ra'' tid0), s(AV ''B'' tid0), s(MV ''A'' tid0),
+                                s(MV ''Text8'' tid0)
+                             |}
+                             ( SK ( s(MV ''A'' tid0) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_3_6_2_A_5_enc tid2) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_6_2_state) A_injective_agreement_T:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_6_2_A &
+          RLKR(s(AV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_6_2_A_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_6_2_T &
+          ( tid1, isoiec_9798_3_6_2_T_4 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''T'' tid1),
+             s(MV ''Rpa'' tid1), s(MV ''Rb'' tid1), PK ( s(MV ''A'' tid1) ),
+             PK ( s(MV ''B'' tid1) ), s(MV ''Text5'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(AV ''T'' tid0),
+                  LN ''Rpa'' tid0, s(MV ''Rb'' tid0), s(MV ''pkA'' tid0),
+                  s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''check_4'',
+                              {| {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                                    s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                    s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                                 |},
+                                 Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                                        s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                        s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                                     |}
+                                     ( SK ( s(AV ''T'' tid0) ) )
+                              |},
+                              {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0), LN ''Ra'' tid0,
+                                 s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                              |},
+                              Enc {| LC ''isoiec_9798_3_6_opt_2_sig_2'', s(AV ''B'' tid0),
+                                     LN ''Ra'' tid0, s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''Text2'' tid0)
+                                  |}
+                                  ( inv(s(MV ''pkB'' tid0)) )
+                           |}
+                           ( LN ''check_nonce_4'' tid0 ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis proof(sources! " LN ''check_nonce_4'' tid0 ")
+        qed (insert facts, fastforce+)?
+      next
+        case (isoiec_9798_3_6_2_A_check_4_out_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', LN ''Rpa'' tid0,
+                                s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                s(AV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                             |}
+                             ( SK ( s(AV ''T'' tid0) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_3_6_2_T_4_enc tid1) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_6_2_state) B_injective_agreement_T:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_6_2_B &
+          RLKR(s(MV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_6_2_B_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_6_2_T &
+          ( tid1, isoiec_9798_3_6_2_T_4 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''T'' tid1),
+             s(MV ''Rpa'' tid1), s(MV ''Rb'' tid1), PK ( s(MV ''A'' tid1) ),
+             PK ( s(MV ''B'' tid1) ), s(MV ''Text5'' tid1)
+          |} = {| s(MV ''A'' tid0), s(AV ''B'' tid0), s(MV ''T'' tid0),
+                  s(MV ''Rpa'' tid0), LN ''Rb'' tid0, s(MV ''pkA'' tid0),
+                  s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_6_opt_2_sig_4'', s(MV ''Rpa'' tid0),
+                              LN ''Rb'' tid0, s(MV ''A'' tid0), s(MV ''pkA'' tid0), s(AV ''B'' tid0),
+                              s(MV ''pkB'' tid0), s(MV ''Text5'' tid0)
+                           |}
+                           ( SK ( s(MV ''T'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_6_2_T_4_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+role isoiec_9798_3_7_1_A
+where "isoiec_9798_3_7_1_A =
+  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
+  , Recv ''text_2'' ( sMV ''Text2'' )
+  , Send ''2'' <| sAV ''A'', sAV ''T'', sN ''Rpa'', sMV ''Rb'', sAV ''A'',
+                  sMV ''B'', sMV ''Text2''
+               |>
+  , Recv ''3'' <| sAV ''T'', sAV ''A'', sMV ''Text5'', sAV ''A'',
+                  sPK ''A'', sMV ''B'', sMV ''pkB'',
+                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_3_1'', sN ''Rpa'', sMV ''B'',
+                           sMV ''pkB'', sMV ''Text4''
+                        |>
+                        ( sPK ''T'' ),
+                  sMV ''TokenTA_for_B''
+               |>
+  , Recv ''text_4'' <| sMV ''Text6'', sMV ''Text7'' |>
+  , Send ''4'' <| sAV ''A'', sMV ''B'', sN ''Rpa'', sMV ''Text7'',
+                  sAV ''T'', sMV ''TokenTA_for_B'',
+                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_4'', sMV ''Rb'', sN ''Ra'',
+                           sMV ''B'', sAV ''A'', sMV ''Text6''
+                        |>
+                        ( sPK ''A'' )
+               |>
+  , Recv ''5'' <| sAV ''A'', sMV ''B'', sN ''Ra'', sMV ''Rb'',
+                  sMV ''Text9'',
+                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_5'', sN ''Ra'', sMV ''Rb'',
+                           sAV ''A'', sMV ''B'', sMV ''Text8''
+                        |>
+                        ( sMV ''pkB'' )
+               |>
+  ]"
+
+role isoiec_9798_3_7_1_B
+where "isoiec_9798_3_7_1_B =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
+  , Recv ''4'' <| sAV ''A'', sAV ''B'', sMV ''Rpa'', sMV ''Text9'',
+                  sMV ''T'',
+                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_3_2'', sN ''Rb'', sAV ''A'',
+                           sMV ''pkA'', sMV ''Text3''
+                        |>
+                        ( PAsymPK ( sMV ''T'' ) ),
+                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_4'', sN ''Rb'', sMV ''Ra'',
+                           sAV ''B'', sAV ''A'', sMV ''Text6''
+                        |>
+                        ( sMV ''pkA'' )
+               |>
+  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
+  , Send ''5'' <| sAV ''A'', sAV ''B'', sMV ''Ra'', sN ''Rb'',
+                  sMV ''Text9'',
+                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_5'', sMV ''Ra'', sN ''Rb'',
+                           sAV ''A'', sAV ''B'', sMV ''Text8''
+                        |>
+                        ( sPK ''B'' )
+               |>
+  ]"
+
+role isoiec_9798_3_7_1_T
+where "isoiec_9798_3_7_1_T =
+  [ Recv ''2'' <| sMV ''A'', sAV ''T'', sMV ''Rpa'', sMV ''Rb'', sMV ''A'',
+                  sMV ''B'', sMV ''Text2''
+               |>
+  , Recv ''text_3'' <| sMV ''Text3'', sMV ''Text4'', sMV ''Text5'' |>
+  , Send ''3'' <| sAV ''T'', sMV ''A'', sMV ''Text5'', sMV ''A'',
+                  PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
+                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_3_1'', sMV ''Rpa'', sMV ''B'',
+                           PAsymPK ( sMV ''B'' ), sMV ''Text4''
+                        |>
+                        ( sPK ''T'' ),
+                  PSign <| sC ''isoiec_9798_3_7_opt_1_sig_3_2'', sMV ''Rb'', sMV ''A'',
+                           PAsymPK ( sMV ''A'' ), sMV ''Text3''
+                        |>
+                        ( sPK ''T'' )
+               |>
+  ]"
+
+protocol isoiec_9798_3_7_1
+where "isoiec_9798_3_7_1 =
+{ isoiec_9798_3_7_1_A, isoiec_9798_3_7_1_B, isoiec_9798_3_7_1_T }"
+
+locale restricted_isoiec_9798_3_7_1_state = isoiec_9798_3_7_1_state
+
+type_invariant isoiec_9798_3_7_1_msc_typing for isoiec_9798_3_7_1
+where "isoiec_9798_3_7_1_msc_typing = mk_typing
+  [ ((isoiec_9798_3_7_1_T, ''A''), (KnownT isoiec_9798_3_7_1_T_2))
+  , ((isoiec_9798_3_7_1_A, ''B''), (KnownT isoiec_9798_3_7_1_A_1))
+  , ((isoiec_9798_3_7_1_T, ''B''), (KnownT isoiec_9798_3_7_1_T_2))
+  , ((isoiec_9798_3_7_1_B, ''Ra''), (KnownT isoiec_9798_3_7_1_B_4))
+  , ((isoiec_9798_3_7_1_A, ''Rb''), (KnownT isoiec_9798_3_7_1_A_1))
+  , ((isoiec_9798_3_7_1_T, ''Rb''), (KnownT isoiec_9798_3_7_1_T_2))
+  , ((isoiec_9798_3_7_1_B, ''Rpa''), (KnownT isoiec_9798_3_7_1_B_4))
+  , ((isoiec_9798_3_7_1_T, ''Rpa''), (KnownT isoiec_9798_3_7_1_T_2))
+  , ((isoiec_9798_3_7_1_B, ''T''), (KnownT isoiec_9798_3_7_1_B_4))
+  , ((isoiec_9798_3_7_1_A, ''Text1''), (KnownT isoiec_9798_3_7_1_A_1))
+  , ((isoiec_9798_3_7_1_B, ''Text1''), (KnownT isoiec_9798_3_7_1_B_text_1))
+  , ((isoiec_9798_3_7_1_A, ''Text2''), (KnownT isoiec_9798_3_7_1_A_text_2))
+  , ((isoiec_9798_3_7_1_T, ''Text2''), (KnownT isoiec_9798_3_7_1_T_2))
+  , ((isoiec_9798_3_7_1_B, ''Text3''), (KnownT isoiec_9798_3_7_1_B_4))
+  , ((isoiec_9798_3_7_1_T, ''Text3''), (KnownT isoiec_9798_3_7_1_T_text_3))
+  , ((isoiec_9798_3_7_1_A, ''Text4''), (KnownT isoiec_9798_3_7_1_A_3))
+  , ((isoiec_9798_3_7_1_T, ''Text4''), (KnownT isoiec_9798_3_7_1_T_text_3))
+  , ((isoiec_9798_3_7_1_A, ''Text5''), (KnownT isoiec_9798_3_7_1_A_3))
+  , ((isoiec_9798_3_7_1_T, ''Text5''), (KnownT isoiec_9798_3_7_1_T_text_3))
+  , ((isoiec_9798_3_7_1_A, ''Text6''), (KnownT isoiec_9798_3_7_1_A_text_4))
+  , ((isoiec_9798_3_7_1_B, ''Text6''), (KnownT isoiec_9798_3_7_1_B_4))
+  , ((isoiec_9798_3_7_1_A, ''Text7''), (KnownT isoiec_9798_3_7_1_A_text_4))
+  , ((isoiec_9798_3_7_1_A, ''Text8''), (KnownT isoiec_9798_3_7_1_A_5))
+  , ((isoiec_9798_3_7_1_B, ''Text8''), (KnownT isoiec_9798_3_7_1_B_text_5))
+  , ((isoiec_9798_3_7_1_A, ''Text9''), (KnownT isoiec_9798_3_7_1_A_5))
+  , ((isoiec_9798_3_7_1_B, ''Text9''), (KnownT isoiec_9798_3_7_1_B_4))
+  , ((isoiec_9798_3_7_1_A, ''TokenTA_for_B''),
+     (KnownT isoiec_9798_3_7_1_A_3))
+  , ((isoiec_9798_3_7_1_B, ''pkA''), (KnownT isoiec_9798_3_7_1_B_4))
+  , ((isoiec_9798_3_7_1_A, ''pkB''), (KnownT isoiec_9798_3_7_1_A_3))
+  ]"
+
+sublocale isoiec_9798_3_7_1_state < isoiec_9798_3_7_1_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_3_7_1_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_3_7_1_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_3_7_1_A_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_A_1_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_A_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_A_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_A_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_A_3_TokenTA_for_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_A_3_pkB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_A_text_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_A_text_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_A_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_A_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_B_4_Ra t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_B_4_Rpa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_B_4_T t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_B_4_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_B_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_B_4_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_B_4_pkA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_B_text_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_T_2_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_T_2_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_T_2_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_T_2_Rpa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_T_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_T_text_3_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_T_text_3_Text4 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_1_T_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_1_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_3_7_1_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_3_7_1_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_3_7_1_state) A_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_7_1_A &
+          RLKR(s(AV ''T'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_7_1_A_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_7_1_B &
+          ( tid1, isoiec_9798_3_7_1_B_5 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
+             s(MV ''Text8'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''Ra'' tid0,
+                  s(MV ''Rb'' tid0), s(MV ''Text8'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_7_opt_1_sig_3_1'', LN ''Rpa'' tid0,
+                              s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text4'' tid0)
+                           |}
+                           ( SK ( s(AV ''T'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_7_1_T_3_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_7_opt_1_sig_5'', LN ''Ra'' tid0,
+                                s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
+                                s(MV ''Text8'' tid0)
+                             |}
+                             ( SK ( s(MV ''B'' tid0) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_3_7_1_B_5_enc tid2) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_7_1_state) B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_7_1_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(MV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_7_1_B_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_7_1_A &
+          ( tid1, isoiec_9798_3_7_1_A_4 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
+             s(MV ''Text6'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
+                  LN ''Rb'' tid0, s(MV ''Text6'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_7_opt_1_sig_3_2'', LN ''Rb'' tid0,
+                              s(AV ''A'' tid0), s(MV ''pkA'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( SK ( s(MV ''T'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_7_1_T_3_enc_1 tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_7_opt_1_sig_4'', LN ''Rb'' tid0,
+                                s(MV ''Ra'' tid0), s(AV ''B'' tid0), s(AV ''A'' tid0),
+                                s(MV ''Text6'' tid0)
+                             |}
+                             ( SK ( s(AV ''A'' tid0) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_3_7_1_A_4_enc tid2) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_7_1_state) A_injective_agreement_T:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_7_1_A &
+          RLKR(s(AV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_7_1_A_3 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_7_1_T &
+          ( tid1, isoiec_9798_3_7_1_T_3 ) : steps t &
+          {| s(MV ''B'' tid1), s(AV ''T'' tid1), s(MV ''Rpa'' tid1),
+             PK ( s(MV ''B'' tid1) ), s(MV ''Text4'' tid1)
+          |} = {| s(MV ''B'' tid0), s(AV ''T'' tid0), LN ''Rpa'' tid0,
+                  s(MV ''pkB'' tid0), s(MV ''Text4'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_7_opt_1_sig_3_1'', LN ''Rpa'' tid0,
+                              s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text4'' tid0)
+                           |}
+                           ( SK ( s(AV ''T'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_7_1_T_3_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_7_1_state) B_injective_agreement_T:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_7_1_B &
+          RLKR(s(MV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_7_1_B_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_7_1_T &
+          ( tid1, isoiec_9798_3_7_1_T_3 ) : steps t &
+          {| s(MV ''A'' tid1), s(AV ''T'' tid1), s(MV ''Rb'' tid1),
+             PK ( s(MV ''A'' tid1) ), s(MV ''Text3'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''T'' tid0), LN ''Rb'' tid0,
+                  s(MV ''pkA'' tid0), s(MV ''Text3'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_7_opt_1_sig_3_2'', LN ''Rb'' tid0,
+                              s(AV ''A'' tid0), s(MV ''pkA'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( SK ( s(MV ''T'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_7_1_T_3_enc_1 tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+role isoiec_9798_3_7_2_A
+where "isoiec_9798_3_7_2_A =
+  [ Recv ''1'' <| sMV ''B'', sAV ''A'', sMV ''Rb'', sMV ''Text1'' |>
+  , Recv ''text_2'' ( sMV ''Text2'' )
+  , Send ''2'' <| sAV ''A'', sAV ''T'', sN ''Rpa'', sMV ''Rb'', sAV ''A'',
+                  sMV ''B'', sMV ''Text2''
+               |>
+  , Recv ''3'' <| sAV ''T'', sAV ''A'', sMV ''Text5'', sAV ''A'',
+                  sPK ''A'', sMV ''B'', sMV ''pkB'', sMV ''TokenTA''
+               |>
+  , Send ''check_3_out'' ( PEnc <| sC ''check_4'', sMV ''TokenTA'' |>
+                                ( sN ''check_nonce_4'' )
+                         )
+  , Recv ''check_3_in'' ( PEnc <| sC ''check_4'',
+                                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_3'', sN ''Rpa'', sMV ''Rb'',
+                                           sAV ''A'', sMV ''pkA'', sMV ''B'', sMV ''pkB'', sMV ''Text3''
+                                        |>
+                                        ( sPK ''T'' )
+                               |>
+                               ( sN ''check_nonce_4'' )
+                        )
+  , Recv ''text_4'' <| sMV ''Text6'', sMV ''Text7'' |>
+  , Send ''4'' <| sAV ''A'', sMV ''B'', sN ''Rpa'', sMV ''Text7'',
+                  sAV ''T'', sMV ''TokenTA'',
+                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_4'', sMV ''Rb'', sN ''Ra'',
+                           sMV ''B'', sAV ''A'', sMV ''Text6''
+                        |>
+                        ( sPK ''A'' )
+               |>
+  , Recv ''5'' <| sAV ''A'', sMV ''B'', sN ''Ra'', sMV ''Rb'',
+                  sMV ''Text9'',
+                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_5'', sN ''Ra'', sMV ''Rb'',
+                           sAV ''A'', sMV ''B'', sMV ''Text8''
+                        |>
+                        ( sMV ''pkB'' )
+               |>
+  ]"
+
+role isoiec_9798_3_7_2_B
+where "isoiec_9798_3_7_2_B =
+  [ Recv ''text_1'' ( sMV ''Text1'' )
+  , Send ''1'' <| sAV ''B'', sAV ''A'', sN ''Rb'', sMV ''Text1'' |>
+  , Recv ''4'' <| sAV ''A'', sAV ''B'', sMV ''Rpa'', sMV ''Text9'',
+                  sMV ''T'',
+                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_3'', sMV ''Rpa'', sN ''Rb'',
+                           sAV ''A'', sMV ''pkA'', sAV ''B'', sMV ''pkB'', sMV ''Text3''
+                        |>
+                        ( PAsymPK ( sMV ''T'' ) ),
+                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_4'', sN ''Rb'', sMV ''Ra'',
+                           sAV ''B'', sAV ''A'', sMV ''Text6''
+                        |>
+                        ( sMV ''pkA'' )
+               |>
+  , Recv ''text_5'' <| sMV ''Text8'', sMV ''Text9'' |>
+  , Send ''5'' <| sAV ''A'', sAV ''B'', sMV ''Ra'', sN ''Rb'',
+                  sMV ''Text9'',
+                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_5'', sMV ''Ra'', sN ''Rb'',
+                           sAV ''A'', sAV ''B'', sMV ''Text8''
+                        |>
+                        ( sPK ''B'' )
+               |>
+  ]"
+
+role isoiec_9798_3_7_2_T
+where "isoiec_9798_3_7_2_T =
+  [ Recv ''2'' <| sMV ''A'', sAV ''T'', sMV ''Rpa'', sMV ''Rb'', sMV ''A'',
+                  sMV ''B'', sMV ''Text2''
+               |>
+  , Recv ''text_3'' <| sMV ''Text3'', sMV ''Text5'' |>
+  , Send ''3'' <| sAV ''T'', sMV ''A'', sMV ''Text5'', sMV ''A'',
+                  PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
+                  PSign <| sC ''isoiec_9798_3_7_opt_2_sig_3'', sMV ''Rpa'', sMV ''Rb'',
+                           sMV ''A'', PAsymPK ( sMV ''A'' ), sMV ''B'', PAsymPK ( sMV ''B'' ),
+                           sMV ''Text3''
+                        |>
+                        ( sPK ''T'' )
+               |>
+  ]"
+
+protocol isoiec_9798_3_7_2
+where "isoiec_9798_3_7_2 =
+{ isoiec_9798_3_7_2_A, isoiec_9798_3_7_2_B, isoiec_9798_3_7_2_T }"
+
+locale restricted_isoiec_9798_3_7_2_state = isoiec_9798_3_7_2_state
+
+type_invariant isoiec_9798_3_7_2_msc_typing for isoiec_9798_3_7_2
+where "isoiec_9798_3_7_2_msc_typing = mk_typing
+  [ ((isoiec_9798_3_7_2_T, ''A''), (KnownT isoiec_9798_3_7_2_T_2))
+  , ((isoiec_9798_3_7_2_A, ''B''), (KnownT isoiec_9798_3_7_2_A_1))
+  , ((isoiec_9798_3_7_2_T, ''B''), (KnownT isoiec_9798_3_7_2_T_2))
+  , ((isoiec_9798_3_7_2_B, ''Ra''), (KnownT isoiec_9798_3_7_2_B_4))
+  , ((isoiec_9798_3_7_2_A, ''Rb''), (KnownT isoiec_9798_3_7_2_A_1))
+  , ((isoiec_9798_3_7_2_T, ''Rb''), (KnownT isoiec_9798_3_7_2_T_2))
+  , ((isoiec_9798_3_7_2_B, ''Rpa''), (KnownT isoiec_9798_3_7_2_B_4))
+  , ((isoiec_9798_3_7_2_T, ''Rpa''), (KnownT isoiec_9798_3_7_2_T_2))
+  , ((isoiec_9798_3_7_2_B, ''T''), (KnownT isoiec_9798_3_7_2_B_4))
+  , ((isoiec_9798_3_7_2_A, ''Text1''), (KnownT isoiec_9798_3_7_2_A_1))
+  , ((isoiec_9798_3_7_2_B, ''Text1''), (KnownT isoiec_9798_3_7_2_B_text_1))
+  , ((isoiec_9798_3_7_2_A, ''Text2''), (KnownT isoiec_9798_3_7_2_A_text_2))
+  , ((isoiec_9798_3_7_2_T, ''Text2''), (KnownT isoiec_9798_3_7_2_T_2))
+  , ((isoiec_9798_3_7_2_A, ''Text3''),
+     (KnownT isoiec_9798_3_7_2_A_check_3_in))
+  , ((isoiec_9798_3_7_2_B, ''Text3''), (KnownT isoiec_9798_3_7_2_B_4))
+  , ((isoiec_9798_3_7_2_T, ''Text3''), (KnownT isoiec_9798_3_7_2_T_text_3))
+  , ((isoiec_9798_3_7_2_A, ''Text5''), (KnownT isoiec_9798_3_7_2_A_3))
+  , ((isoiec_9798_3_7_2_T, ''Text5''), (KnownT isoiec_9798_3_7_2_T_text_3))
+  , ((isoiec_9798_3_7_2_A, ''Text6''), (KnownT isoiec_9798_3_7_2_A_text_4))
+  , ((isoiec_9798_3_7_2_B, ''Text6''), (KnownT isoiec_9798_3_7_2_B_4))
+  , ((isoiec_9798_3_7_2_A, ''Text7''), (KnownT isoiec_9798_3_7_2_A_text_4))
+  , ((isoiec_9798_3_7_2_A, ''Text8''), (KnownT isoiec_9798_3_7_2_A_5))
+  , ((isoiec_9798_3_7_2_B, ''Text8''), (KnownT isoiec_9798_3_7_2_B_text_5))
+  , ((isoiec_9798_3_7_2_A, ''Text9''), (KnownT isoiec_9798_3_7_2_A_5))
+  , ((isoiec_9798_3_7_2_B, ''Text9''), (KnownT isoiec_9798_3_7_2_B_4))
+  , ((isoiec_9798_3_7_2_A, ''TokenTA''), (KnownT isoiec_9798_3_7_2_A_3))
+  , ((isoiec_9798_3_7_2_A, ''pkA''),
+     (KnownT isoiec_9798_3_7_2_A_check_3_in))
+  , ((isoiec_9798_3_7_2_B, ''pkA''), (KnownT isoiec_9798_3_7_2_B_4))
+  , ((isoiec_9798_3_7_2_A, ''pkB''), (KnownT isoiec_9798_3_7_2_A_3))
+  , ((isoiec_9798_3_7_2_B, ''pkB''), (KnownT isoiec_9798_3_7_2_B_4))
+  ]"
+
+sublocale isoiec_9798_3_7_2_state < isoiec_9798_3_7_2_msc_typing_state
+proof -
+  have "(t,r,s) : approx isoiec_9798_3_7_2_msc_typing"
+  proof(cases rule: reachable_in_approxI_ext
+        [OF isoiec_9798_3_7_2_msc_typing.monoTyp, completeness_cases_rule])
+    case (isoiec_9798_3_7_2_A_1_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_A_1_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_A_1_Text1 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_A_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_A_3_TokenTA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_A_3_pkB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_A_check_3_in_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''check_4'',
+               {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
+                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                  s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+               |},
+               Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
+                      s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                      s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+                   |}
+                   ( SK ( s(AV ''T'' tid0) ) )
+            |}
+            ( LN ''check_nonce_4'' tid0 ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_3_7_2_A_check_3_in_pkA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    proof(sources! "
+        Enc {| LC ''check_4'',
+               {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
+                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                  s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+               |},
+               Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
+                      s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                      s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+                   |}
+                   ( SK ( s(AV ''T'' tid0) ) )
+            |}
+            ( LN ''check_nonce_4'' tid0 ) ")
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
+  next
+    case (isoiec_9798_3_7_2_A_text_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_A_text_4_Text7 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_A_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_A_5_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_B_4_Ra t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_B_4_Rpa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_B_4_T t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_B_4_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_B_4_Text6 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_B_4_Text9 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_B_4_pkA t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_B_4_pkB t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_B_text_5_Text8 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_T_2_A t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_T_2_B t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_T_2_Rb t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_T_2_Rpa t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_T_2_Text2 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_T_text_3_Text3 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  next
+    case (isoiec_9798_3_7_2_T_text_3_Text5 t r s tid0) note facts = this
+    then interpret state: isoiec_9798_3_7_2_msc_typing_state t r s
+      by unfold_locales auto
+    show ?case using facts
+    by (fastforce intro: event_predOrdI split: if_splits)
+  qed
+  thus "isoiec_9798_3_7_2_msc_typing_state t r s" by unfold_locales auto
+qed
+
+text{* Prove secrecy of long-term keys. *}
+context isoiec_9798_3_7_2_state begin
+
+  (* This rule is unsafe in general, but OK here, 
+     as we are only reasoning about static compromise. 
+  *)
+  lemma static_longterm_key_reveal[dest!]:
+    "predOrd t (LKR a) e ==> RLKR a : reveals t"
+    by (auto intro: compr_predOrdI)
+
+  lemma longterm_private_key_secrecy:
+    assumes facts:
+      "SK m : knows t"
+      "RLKR m ~: reveals t"
+    shows "False"
+  using facts by (sources "SK m")
+
+  lemma longterm_sym_ud_key_secrecy:
+    assumes facts:
+      "K m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+    shows "False"
+  using facts by (sources "K m1 m2")
+
+  lemma longterm_sym_bd_key_secrecy:
+    assumes facts:
+      "Kbd m1 m2 : knows t"
+      "RLKR m1 ~: reveals t"
+      "RLKR m2 ~: reveals t"
+      "m1 : Agent"
+      "m2 : Agent"
+    shows "False"
+  proof -
+    from facts 
+    have "KShr (agents {m1, m2}) : knows t"
+      by (auto simp: Kbd_def)
+    thus ?thesis using facts
+    proof (sources "KShr (agents {m1, m2})")
+    qed (auto simp: agents_def Agent_def)
+  qed
+
+  lemmas ltk_secrecy =
+    longterm_sym_ud_key_secrecy
+    longterm_sym_ud_key_secrecy[OF in_knows_predOrd1]
+    longterm_sym_bd_key_secrecy
+    longterm_sym_bd_key_secrecy[OF in_knows_predOrd1]
+    longterm_private_key_secrecy
+    longterm_private_key_secrecy[OF in_knows_predOrd1]
+
+end
+
+lemma (in restricted_isoiec_9798_3_7_2_state) A_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_7_2_A &
+          RLKR(s(AV ''T'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_7_2_A_5 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_7_2_B &
+          ( tid1, isoiec_9798_3_7_2_B_5 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
+             s(MV ''Text8'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''Ra'' tid0,
+                  s(MV ''Rb'' tid0), s(MV ''Text8'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''check_4'',
+                              {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
+                                 s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                 s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+                              |},
+                              Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
+                                     s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                     s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+                                  |}
+                                  ( SK ( s(AV ''T'' tid0) ) )
+                           |}
+                           ( LN ''check_nonce_4'' tid0 ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis proof(sources! " LN ''check_nonce_4'' tid0 ")
+        qed (insert facts, fastforce+)?
+      next
+        case (isoiec_9798_3_7_2_A_check_3_out_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
+                                s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+                             |}
+                             ( SK ( s(AV ''T'' tid0) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_3_7_2_T_3_enc tid1) note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Enc {| LC ''isoiec_9798_3_7_opt_2_sig_5'', LN ''Ra'' tid0,
+                                  s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''B'' tid0),
+                                  s(MV ''Text8'' tid0)
+                               |}
+                               ( SK ( s(MV ''B'' tid0) ) ) ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest!: ltk_secrecy)
+          next
+            case (isoiec_9798_3_7_2_B_5_enc tid2) note_unified facts = this facts
+            thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+          qed (insert facts, fastforce+)?
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_7_2_state) B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_7_2_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(MV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_7_2_B_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_7_2_A &
+          ( tid1, isoiec_9798_3_7_2_A_4 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
+             s(MV ''Text6'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
+                  LN ''Rb'' tid0, s(MV ''Text6'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', s(MV ''Rpa'' tid0),
+                              LN ''Rb'' tid0, s(AV ''A'' tid0), s(MV ''pkA'' tid0), s(AV ''B'' tid0),
+                              s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( SK ( s(MV ''T'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_7_2_T_3_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_7_opt_2_sig_4'', LN ''Rb'' tid0,
+                                s(MV ''Ra'' tid0), s(AV ''B'' tid0), s(AV ''A'' tid0),
+                                s(MV ''Text6'' tid0)
+                             |}
+                             ( SK ( s(AV ''A'' tid0) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_3_7_2_A_4_enc tid2) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_7_2_state) A_injective_agreement_T:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_7_2_A &
+          RLKR(s(AV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_7_2_A_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_7_2_T &
+          ( tid1, isoiec_9798_3_7_2_T_3 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''T'' tid1),
+             s(MV ''Rpa'' tid1), s(MV ''Rb'' tid1), PK ( s(MV ''A'' tid1) ),
+             PK ( s(MV ''B'' tid1) ), s(MV ''Text3'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), s(AV ''T'' tid0),
+                  LN ''Rpa'' tid0, s(MV ''Rb'' tid0), s(MV ''pkA'' tid0),
+                  s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''check_4'',
+                              {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
+                                 s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                 s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+                              |},
+                              Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
+                                     s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                     s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+                                  |}
+                                  ( SK ( s(AV ''T'' tid0) ) )
+                           |}
+                           ( LN ''check_nonce_4'' tid0 ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis proof(sources! " LN ''check_nonce_4'' tid0 ")
+        qed (insert facts, fastforce+)?
+      next
+        case (isoiec_9798_3_7_2_A_check_3_out_enc tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', LN ''Rpa'' tid0,
+                                s(MV ''Rb'' tid0), s(AV ''A'' tid0), s(MV ''pkA'' tid0),
+                                s(MV ''B'' tid0), s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+                             |}
+                             ( SK ( s(AV ''T'' tid0) ) ) ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_3_7_2_T_3_enc tid1) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_3_7_2_state) B_injective_agreement_T:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_3_7_2_B &
+          RLKR(s(MV ''T'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_3_7_2_B_4 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_3_7_2_T &
+          ( tid1, isoiec_9798_3_7_2_T_3 ) : steps t &
+          {| s(MV ''A'' tid1), s(MV ''B'' tid1), s(AV ''T'' tid1),
+             s(MV ''Rpa'' tid1), s(MV ''Rb'' tid1), PK ( s(MV ''A'' tid1) ),
+             PK ( s(MV ''B'' tid1) ), s(MV ''Text3'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''T'' tid0),
+                  s(MV ''Rpa'' tid0), LN ''Rb'' tid0, s(MV ''pkA'' tid0),
+                  s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Enc {| LC ''isoiec_9798_3_7_opt_2_sig_3'', s(MV ''Rpa'' tid0),
+                              LN ''Rb'' tid0, s(AV ''A'' tid0), s(MV ''pkA'' tid0), s(AV ''B'' tid0),
+                              s(MV ''pkB'' tid0), s(MV ''Text3'' tid0)
+                           |}
+                           ( SK ( s(MV ''T'' tid0) ) ) ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_3_7_2_T_3_enc tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
 qed
 
 end
diff --git a/data/examples/iso9798/isabelle-proofs/isoiec-9798-4-bdkey_cert_auto.thy b/data/examples/iso9798/isabelle-proofs/isoiec-9798-4-bdkey_cert_auto.thy
--- a/data/examples/iso9798/isabelle-proofs/isoiec-9798-4-bdkey_cert_auto.thy
+++ b/data/examples/iso9798/isabelle-proofs/isoiec-9798-4-bdkey_cert_auto.thy
@@ -1,6 +1,6 @@
 theory "isoiec-9798-4-bdkey_cert_auto"
 imports
-  "../ESPLogic"
+  "ESPLogic"
 begin
 
 role isoiec_9798_4_1_bdkey_A
@@ -55,37 +55,37 @@
     then interpret state: isoiec_9798_4_1_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_1_bdkey_A_text_1_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_1_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_1_bdkey_B_1_A t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_1_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_1_bdkey_B_1_TNA t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_1_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_1_bdkey_B_1_Text1 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_1_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_1_bdkey_B_1_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_1_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   qed
   thus "isoiec_9798_4_1_bdkey_msc_typing_state t r s" by unfold_locales auto
 qed
@@ -165,11 +165,11 @@
                            s(MV ''Text1'' tid0)
                         |} ")
     case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
   next
     case (isoiec_9798_4_1_bdkey_A_1_hash tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
 qed
 
 role isoiec_9798_4_2_bdkey_A
@@ -229,43 +229,43 @@
     then interpret state: isoiec_9798_4_2_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_bdkey_A_1_Rb t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_2_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_bdkey_A_1_Text1 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_2_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_bdkey_A_text_2_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_2_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_bdkey_A_text_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_2_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_bdkey_B_2_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_2_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_bdkey_B_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_2_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   qed
   thus "isoiec_9798_4_2_bdkey_msc_typing_state t r s" by unfold_locales auto
 qed
@@ -322,34 +322,54 @@
 
 end
 
-lemma (in restricted_isoiec_9798_4_2_bdkey_state) B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_4_2_bdkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_4_2_bdkey_B_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_4_2_bdkey_A &
-        ( tid1, isoiec_9798_4_2_bdkey_A_2 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(MV ''Rb'' tid1),
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''Rb'' tid0,
-                s(MV ''Text2'' tid0)
-             |})"
+lemma (in restricted_isoiec_9798_4_2_bdkey_state) B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_4_2_bdkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_4_2_bdkey_B_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_4_2_bdkey_A &
+          ( tid1, isoiec_9798_4_2_bdkey_A_2 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(MV ''Rb'' tid1),
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''Rb'' tid0,
+                  s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
 proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Hash {| {| LC ''CCF'', Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) |},
-                           LC ''isoiec_9798_4_2_ccf_2'', LN ''Rb'' tid0, s(AV ''B'' tid0),
-                           s(MV ''Text2'' tid0)
-                        |} ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_4_2_bdkey_A_2_hash tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Hash {| {| LC ''CCF'', Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) |},
+                               LC ''isoiec_9798_4_2_ccf_2'', LN ''Rb'' tid0, s(AV ''B'' tid0),
+                               s(MV ''Text2'' tid0)
+                            |} ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_4_2_bdkey_A_2_hash tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
 qed
 
 role isoiec_9798_4_3_bdkey_A
@@ -428,67 +448,67 @@
     then interpret state: isoiec_9798_4_3_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_bdkey_A_text_1_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_3_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_bdkey_A_2_TNb t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_3_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_bdkey_A_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_3_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_bdkey_A_2_Text4 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_3_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_bdkey_B_1_A t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_3_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_bdkey_B_1_TNa t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_3_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_bdkey_B_1_Text1 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_3_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_bdkey_B_1_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_3_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_bdkey_B_text_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_3_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_bdkey_B_text_2_Text4 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_3_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   qed
   thus "isoiec_9798_4_3_bdkey_msc_typing_state t r s" by unfold_locales auto
 qed
@@ -568,11 +588,11 @@
                            s(MV ''Text3'' tid0)
                         |} ")
     case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
   next
     case (isoiec_9798_4_3_bdkey_B_2_hash tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
 qed
 
 lemma (in restricted_isoiec_9798_4_3_bdkey_state) B_non_injective_agreement:
@@ -598,11 +618,11 @@
                            s(MV ''Text1'' tid0)
                         |} ")
     case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
   next
     case (isoiec_9798_4_3_bdkey_A_1_hash tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
 qed
 
 role isoiec_9798_4_4_bdkey_A
@@ -684,73 +704,73 @@
     then interpret state: isoiec_9798_4_4_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_A_1_Rb t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_4_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_A_1_Text1 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_4_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_A_text_2_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_4_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_A_text_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_4_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_A_3_Text4 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_4_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_A_3_Text5 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_4_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_B_2_Ra t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_4_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_B_2_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_4_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_B_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_4_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_B_text_3_Text4 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_4_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_bdkey_B_text_3_Text5 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_4_bdkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   qed
   thus "isoiec_9798_4_4_bdkey_msc_typing_state t r s" by unfold_locales auto
 qed
@@ -807,93 +827,133 @@
 
 end
 
-lemma (in restricted_isoiec_9798_4_4_bdkey_state) A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_4_4_bdkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_4_4_bdkey_A_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_4_4_bdkey_B &
-        ( tid1, isoiec_9798_4_4_bdkey_B_3 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
-           s(MV ''Text2'' tid1), s(MV ''Text4'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''Ra'' tid0,
-                s(MV ''Rb'' tid0), s(MV ''Text2'' tid0), s(MV ''Text4'' tid0)
-             |})"
+lemma (in restricted_isoiec_9798_4_4_bdkey_state) A_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_4_4_bdkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_4_4_bdkey_A_3 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_4_4_bdkey_B &
+          ( tid1, isoiec_9798_4_4_bdkey_B_3 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
+             s(MV ''Text2'' tid1), s(MV ''Text4'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''Ra'' tid0,
+                  s(MV ''Rb'' tid0), s(MV ''Text2'' tid0), s(MV ''Text4'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
 proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Hash {| {| LC ''CCF'', Kbd ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) ) |},
-                           LC ''isoiec_9798_4_4_ccf_3'', s(MV ''Rb'' tid0), LN ''Ra'' tid0,
-                           s(MV ''Text4'' tid0)
-                        |} ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_4_4_bdkey_B_3_hash tid1) note_unified facts = this facts
-    hence "Kbd ( s(AV ''A'' tid1) )
-               ( s(AV ''B'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) )"
-      by simp note facts = this facts
-    thus ?thesis proof(cases rule: Kbd_cases)
-      case noswap note_unified facts = this facts
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
       thus ?thesis proof(sources! "
-                       Hash {| {| LC ''CCF'', Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid1) ) |},
-                               LC ''isoiec_9798_4_4_ccf_2'', LN ''Ra'' tid0, LN ''Rb'' tid1,
-                               s(AV ''B'' tid1), s(MV ''Text2'' tid1)
+                       Hash {| {| LC ''CCF'', Kbd ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) ) |},
+                               LC ''isoiec_9798_4_4_ccf_3'', s(MV ''Rb'' tid0), LN ''Ra'' tid0,
+                               s(MV ''Text4'' tid0)
                             |} ")
         case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest!: ltk_secrecy)
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
       next
-        case (isoiec_9798_4_4_bdkey_A_2_hash tid2) note_unified facts = this facts
-        thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-      qed (insert facts, fastsimp+)?
-    next
-      case swapped note_unified facts = this facts
+        case (isoiec_9798_4_4_bdkey_B_3_hash tid1) note_unified facts = this facts
+        hence "Kbd ( s(AV ''A'' tid1) )
+                   ( s(AV ''B'' tid1) ) = Kbd ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) )"
+          by simp note facts = this facts
+        thus ?thesis proof(cases rule: Kbd_cases)
+          case noswap note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Hash {| {| LC ''CCF'', Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid1) ) |},
+                                   LC ''isoiec_9798_4_4_ccf_2'', LN ''Ra'' tid0, LN ''Rb'' tid1,
+                                   s(AV ''B'' tid1), s(MV ''Text2'' tid1)
+                                |} ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest!: ltk_secrecy)
+          next
+            case (isoiec_9798_4_4_bdkey_A_2_hash tid2) note_unified facts = this facts
+            thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+          qed (insert facts, fastforce+)?
+        next
+          case swapped note_unified facts = this facts
+          thus ?thesis proof(sources! "
+                           Hash {| {| LC ''CCF'', Kbd ( s(AV ''A'' tid0) ) ( s(AV ''A'' tid1) ) |},
+                                   LC ''isoiec_9798_4_4_ccf_2'', LN ''Ra'' tid0, LN ''Rb'' tid1,
+                                   s(AV ''A'' tid0), s(MV ''Text2'' tid1)
+                                |} ")
+            case fake note_unified facts = this facts
+            thus ?thesis by (fastforce dest!: ltk_secrecy)
+          next
+            case (isoiec_9798_4_4_bdkey_A_2_hash tid2) note_unified facts = this facts
+            thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+          qed (insert facts, fastforce+)?
+        qed (fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
+qed
+
+lemma (in restricted_isoiec_9798_4_4_bdkey_state) B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_4_4_bdkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_4_4_bdkey_B_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_4_4_bdkey_A &
+          ( tid1, isoiec_9798_4_4_bdkey_A_2 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
+                  LN ''Rb'' tid0, s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
+proof -
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
       thus ?thesis proof(sources! "
-                       Hash {| {| LC ''CCF'', Kbd ( s(AV ''A'' tid0) ) ( s(AV ''A'' tid1) ) |},
-                               LC ''isoiec_9798_4_4_ccf_2'', LN ''Ra'' tid0, LN ''Rb'' tid1,
-                               s(AV ''A'' tid0), s(MV ''Text2'' tid1)
+                       Hash {| {| LC ''CCF'', Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) |},
+                               LC ''isoiec_9798_4_4_ccf_2'', s(MV ''Ra'' tid0), LN ''Rb'' tid0,
+                               s(AV ''B'' tid0), s(MV ''Text2'' tid0)
                             |} ")
         case fake note_unified facts = this facts
-        thus ?thesis by (fastsimp dest!: ltk_secrecy)
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
       next
-        case (isoiec_9798_4_4_bdkey_A_2_hash tid2) note_unified facts = this facts
-        thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-      qed (insert facts, fastsimp+)?
-    qed (fastsimp+)?
-  qed (insert facts, fastsimp+)?
-qed
-
-lemma (in restricted_isoiec_9798_4_4_bdkey_state) B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_4_4_bdkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_4_4_bdkey_B_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_4_4_bdkey_A &
-        ( tid1, isoiec_9798_4_4_bdkey_A_2 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
-                LN ''Rb'' tid0, s(MV ''Text2'' tid0)
-             |})"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Hash {| {| LC ''CCF'', Kbd ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) |},
-                           LC ''isoiec_9798_4_4_ccf_2'', s(MV ''Ra'' tid0), LN ''Rb'' tid0,
-                           s(AV ''B'' tid0), s(MV ''Text2'' tid0)
-                        |} ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_4_4_bdkey_A_2_hash tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+        case (isoiec_9798_4_4_bdkey_A_2_hash tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
 qed
 
 end
diff --git a/data/examples/iso9798/isabelle-proofs/isoiec-9798-4-udkey_cert_auto.thy b/data/examples/iso9798/isabelle-proofs/isoiec-9798-4-udkey_cert_auto.thy
--- a/data/examples/iso9798/isabelle-proofs/isoiec-9798-4-udkey_cert_auto.thy
+++ b/data/examples/iso9798/isabelle-proofs/isoiec-9798-4-udkey_cert_auto.thy
@@ -1,6 +1,6 @@
 theory "isoiec-9798-4-udkey_cert_auto"
 imports
-  "../ESPLogic"
+  "ESPLogic"
 begin
 
 role isoiec_9798_4_1_udkey_A
@@ -55,37 +55,37 @@
     then interpret state: isoiec_9798_4_1_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_1_udkey_A_text_1_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_1_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_1_udkey_B_1_A t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_1_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_1_udkey_B_1_TNA t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_1_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_1_udkey_B_1_Text1 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_1_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_1_udkey_B_1_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_1_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   qed
   thus "isoiec_9798_4_1_udkey_msc_typing_state t r s" by unfold_locales auto
 qed
@@ -164,11 +164,11 @@
                            LC ''isoiec_9798_4_1_ccf_1'', s(MV ''TNA'' tid0), s(MV ''Text1'' tid0)
                         |} ")
     case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
   next
     case (isoiec_9798_4_1_udkey_A_1_hash tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
 qed
 
 role isoiec_9798_4_2_udkey_A
@@ -228,43 +228,43 @@
     then interpret state: isoiec_9798_4_2_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_udkey_A_1_Rb t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_2_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_udkey_A_1_Text1 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_2_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_udkey_A_text_2_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_2_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_udkey_A_text_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_2_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_udkey_B_2_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_2_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_2_udkey_B_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_2_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   qed
   thus "isoiec_9798_4_2_udkey_msc_typing_state t r s" by unfold_locales auto
 qed
@@ -321,33 +321,53 @@
 
 end
 
-lemma (in restricted_isoiec_9798_4_2_udkey_state) B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_4_2_udkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_4_2_udkey_B_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_4_2_udkey_A &
-        ( tid1, isoiec_9798_4_2_udkey_A_2 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(MV ''Rb'' tid1),
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''Rb'' tid0,
-                s(MV ''Text2'' tid0)
-             |})"
+lemma (in restricted_isoiec_9798_4_2_udkey_state) B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_4_2_udkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_4_2_udkey_B_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_4_2_udkey_A &
+          ( tid1, isoiec_9798_4_2_udkey_A_2 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), s(MV ''Rb'' tid1),
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), LN ''Rb'' tid0,
+                  s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
 proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Hash {| {| LC ''CCF'', K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) |},
-                           LC ''isoiec_9798_4_2_ccf_2'', LN ''Rb'' tid0, s(MV ''Text2'' tid0)
-                        |} ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_4_2_udkey_A_2_hash tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Hash {| {| LC ''CCF'', K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) |},
+                               LC ''isoiec_9798_4_2_ccf_2'', LN ''Rb'' tid0, s(MV ''Text2'' tid0)
+                            |} ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_4_2_udkey_A_2_hash tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
 qed
 
 role isoiec_9798_4_3_udkey_A
@@ -426,67 +446,67 @@
     then interpret state: isoiec_9798_4_3_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_udkey_A_text_1_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_3_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_udkey_A_2_TNb t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_3_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_udkey_A_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_3_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_udkey_A_2_Text4 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_3_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_udkey_B_1_A t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_3_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_udkey_B_1_TNa t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_3_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_udkey_B_1_Text1 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_3_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_udkey_B_1_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_3_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_udkey_B_text_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_3_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_3_udkey_B_text_2_Text4 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_3_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   qed
   thus "isoiec_9798_4_3_udkey_msc_typing_state t r s" by unfold_locales auto
 qed
@@ -565,11 +585,11 @@
                            LC ''isoiec_9798_4_3_ccf_2'', s(MV ''TNb'' tid0), s(MV ''Text3'' tid0)
                         |} ")
     case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
   next
     case (isoiec_9798_4_3_udkey_B_2_hash tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
 qed
 
 lemma (in restricted_isoiec_9798_4_3_udkey_state) B_non_injective_agreement:
@@ -594,11 +614,11 @@
                            LC ''isoiec_9798_4_3_ccf_1'', s(MV ''TNa'' tid0), s(MV ''Text1'' tid0)
                         |} ")
     case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
+    thus ?thesis by (fastforce dest!: ltk_secrecy)
   next
     case (isoiec_9798_4_3_udkey_A_1_hash tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+    thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+  qed (insert facts, fastforce+)?
 qed
 
 role isoiec_9798_4_4_udkey_A
@@ -678,73 +698,73 @@
     then interpret state: isoiec_9798_4_4_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_A_1_Rb t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_4_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_A_1_Text1 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_4_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_A_text_2_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_4_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_A_text_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_4_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_A_3_Text4 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_4_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_A_3_Text5 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_4_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_B_2_Ra t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_4_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_B_2_Text2 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_4_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_B_2_Text3 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_4_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_B_text_3_Text4 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_4_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (isoiec_9798_4_4_udkey_B_text_3_Text5 t r s tid0) note facts = this
     then interpret state: isoiec_9798_4_4_udkey_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   qed
   thus "isoiec_9798_4_4_udkey_msc_typing_state t r s" by unfold_locales auto
 qed
@@ -801,74 +821,114 @@
 
 end
 
-lemma (in restricted_isoiec_9798_4_4_udkey_state) A_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_4_4_udkey_A"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(MV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_4_4_udkey_A_3 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_4_4_udkey_B &
-        ( tid1, isoiec_9798_4_4_udkey_B_3 ) : steps t &
-        {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
-           s(MV ''Text2'' tid1), s(MV ''Text4'' tid1)
-        |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''Ra'' tid0,
-                s(MV ''Rb'' tid0), s(MV ''Text2'' tid0), s(MV ''Text4'' tid0)
-             |})"
+lemma (in restricted_isoiec_9798_4_4_udkey_state) A_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_4_4_udkey_A &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(MV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_4_4_udkey_A_3 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_4_4_udkey_B &
+          ( tid1, isoiec_9798_4_4_udkey_B_3 ) : steps t &
+          {| s(AV ''A'' tid1), s(AV ''B'' tid1), s(MV ''Ra'' tid1), LN ''Rb'' tid1,
+             s(MV ''Text2'' tid1), s(MV ''Text4'' tid1)
+          |} = {| s(AV ''A'' tid0), s(MV ''B'' tid0), LN ''Ra'' tid0,
+                  s(MV ''Rb'' tid0), s(MV ''Text2'' tid0), s(MV ''Text4'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
 proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Hash {| {| LC ''CCF'', K ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) ) |},
-                           LC ''isoiec_9798_4_4_ccf_3'', s(MV ''Rb'' tid0), LN ''Ra'' tid0,
-                           s(MV ''Text4'' tid0)
-                        |} ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_4_4_udkey_B_3_hash tid1) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Hash {| {| LC ''CCF'', K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid1) ) |},
-                             LC ''isoiec_9798_4_4_ccf_2'', LN ''Ra'' tid0, LN ''Rb'' tid1,
-                             s(MV ''Text2'' tid1)
-                          |} ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest!: ltk_secrecy)
-    next
-      case (isoiec_9798_4_4_udkey_A_2_hash tid2) note_unified facts = this facts
-      thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-    qed (insert facts, fastsimp+)?
-  qed (insert facts, fastsimp+)?
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Hash {| {| LC ''CCF'', K ( s(AV ''A'' tid0) ) ( s(MV ''B'' tid0) ) |},
+                               LC ''isoiec_9798_4_4_ccf_3'', s(MV ''Rb'' tid0), LN ''Ra'' tid0,
+                               s(MV ''Text4'' tid0)
+                            |} ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_4_4_udkey_B_3_hash tid1) note_unified facts = this facts
+        thus ?thesis proof(sources! "
+                         Hash {| {| LC ''CCF'', K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid1) ) |},
+                                 LC ''isoiec_9798_4_4_ccf_2'', LN ''Ra'' tid0, LN ''Rb'' tid1,
+                                 s(MV ''Text2'' tid1)
+                              |} ")
+          case fake note_unified facts = this facts
+          thus ?thesis by (fastforce dest!: ltk_secrecy)
+        next
+          case (isoiec_9798_4_4_udkey_A_2_hash tid2) note_unified facts = this facts
+          thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+        qed (insert facts, fastforce+)?
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
 qed
 
-lemma (in restricted_isoiec_9798_4_4_udkey_state) B_non_injective_agreement:
-  assumes facts:
-    "roleMap r tid0 = Some isoiec_9798_4_4_udkey_B"
-    "RLKR(s(AV ''A'' tid0)) ~: reveals t"
-    "RLKR(s(AV ''B'' tid0)) ~: reveals t"
-    "( tid0, isoiec_9798_4_4_udkey_B_2 ) : steps t"
-  shows
-    "(?  tid1.
-        roleMap r tid1 = Some isoiec_9798_4_4_udkey_A &
-        ( tid1, isoiec_9798_4_4_udkey_A_2 ) : steps t &
-        {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
-           s(MV ''Text2'' tid1)
-        |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
-                LN ''Rb'' tid0, s(MV ''Text2'' tid0)
-             |})"
+lemma (in restricted_isoiec_9798_4_4_udkey_state) B_injective_agreement:
+  "let
+     prems =
+       (% tid0.
+          roleMap r tid0 = Some isoiec_9798_4_4_udkey_B &
+          RLKR(s(AV ''A'' tid0)) ~: reveals t &
+          RLKR(s(AV ''B'' tid0)) ~: reveals t &
+          ( tid0, isoiec_9798_4_4_udkey_B_2 ) : steps t);
+     concs =
+       (% tid0 tid1.
+          roleMap r tid1 = Some isoiec_9798_4_4_udkey_A &
+          ( tid1, isoiec_9798_4_4_udkey_A_2 ) : steps t &
+          {| s(AV ''A'' tid1), s(MV ''B'' tid1), LN ''Ra'' tid1, s(MV ''Rb'' tid1),
+             s(MV ''Text2'' tid1)
+          |} = {| s(AV ''A'' tid0), s(AV ''B'' tid0), s(MV ''Ra'' tid0),
+                  LN ''Rb'' tid0, s(MV ''Text2'' tid0)
+               |})
+   in ? f. inj_on f (Collect prems) & (! i. prems i --> concs i (f i))"
+  (is "let prems = ?prems; concs = ?concs in ?P prems concs")
 proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! "
-                   Hash {| {| LC ''CCF'', K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) |},
-                           LC ''isoiec_9798_4_4_ccf_2'', s(MV ''Ra'' tid0), LN ''Rb'' tid0,
-                           s(MV ''Text2'' tid0)
-                        |} ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest!: ltk_secrecy)
-  next
-    case (isoiec_9798_4_4_udkey_A_2_hash tid1) note_unified facts = this facts
-    thus ?thesis by (fastsimp intro: event_predOrdI split: if_splits)
-  qed (insert facts, fastsimp+)?
+  { fix tid0 tid1
+    assume facts: "?prems tid0"
+    have " ? tid1. ?concs tid0 tid1"
+    proof -
+      note_unified facts = facts
+      note_prefix_closed facts = facts
+      thus ?thesis proof(sources! "
+                       Hash {| {| LC ''CCF'', K ( s(AV ''A'' tid0) ) ( s(AV ''B'' tid0) ) |},
+                               LC ''isoiec_9798_4_4_ccf_2'', s(MV ''Ra'' tid0), LN ''Rb'' tid0,
+                               s(MV ''Text2'' tid0)
+                            |} ")
+        case fake note_unified facts = this facts
+        thus ?thesis by (fastforce dest!: ltk_secrecy)
+      next
+        case (isoiec_9798_4_4_udkey_A_2_hash tid1) note_unified facts = this facts
+        thus ?thesis by (fastforce intro: event_predOrdI split: if_splits)
+      qed (insert facts, fastforce+)?
+    qed
+  }
+  note niagree = this
+  { fix i1 i2 j
+    assume "?concs i1 j & ?concs i2 j"
+    note_unified facts = this
+    have "i1 = i2" using facts by simp
+  }
+  note conc_inj = this
+  show ?thesis
+    by (fast intro!: iagree_to_niagree elim!: niagree conc_inj)
 qed
 
 end
diff --git a/data/isabelle/AUTHORS b/data/isabelle/AUTHORS
--- a/data/isabelle/AUTHORS
+++ b/data/isabelle/AUTHORS
@@ -1,4 +1,8 @@
-Simon Meier <meiersi@inf.ethz.ch>
+Simon Meier <iridcode@gmail.com>
+
+Port to Isabelle 2013:
+----------------------
+Andreas Lochbihler <andreas.lochbihler@inf.ethz.ch>
 
 Student contributor:
 ---------------------
diff --git a/data/isabelle/IsaMakefile b/data/isabelle/IsaMakefile
deleted file mode 100644
--- a/data/isabelle/IsaMakefile
+++ /dev/null
@@ -1,31 +0,0 @@
-
-## targets
-
-default: ESPL
-images: ESPL
-test: 
-
-all: images test
-
-
-## global settings
-
-SRC = $(ISABELLE_HOME)/src
-OUT = $(ISABELLE_OUTPUT)
-LOG = $(OUT)/log
-
-USEDIR = $(ISABELLE_TOOL) usedir -v true -i true ## -d pdf  ## -D generated
-
-
-## ESPL
-
-ESPL: $(OUT)/ESPL
-
-$(OUT)/ESPL: ## ROOT.ML document/root.tex src/*.thy src/ESPLogic/*.thy src/ESPLogic/*.ML
-	@$(USEDIR) -b -P http://isabelle.in.tum.de/library HOL ESPL
-
-
-## clean
-
-clean:
-	@rm -f $(OUT)/ESPL
diff --git a/data/isabelle/Makefile b/data/isabelle/Makefile
--- a/data/isabelle/Makefile
+++ b/data/isabelle/Makefile
@@ -26,12 +26,11 @@
 
 # The following commands require
 #
-#   a working installation of Isabelle2009-1
+#   a working installation of Isabelle2013
 #   (http://www.cl.cam.ac.uk/research/hvg/Isabelle/).
 #
 
 # build an image of the ESPL formalization in Isabelle. This is required for
 # the 'scyther-proof --isabelle' switch to work.
 espl-image:
-	isabelle make clean
-	isabelle make
+	isabelle build -cb -d . ESPL
diff --git a/data/isabelle/README b/data/isabelle/README
--- a/data/isabelle/README
+++ b/data/isabelle/README
@@ -1,10 +1,9 @@
 README: The scyther-proof security protocol verification tool
 =============================================================
 
-Author: Simon Meier <simon.meier@inf.ethz.ch>
-
-Creation Date: 13/05/2011  --  Last Updated:  28/06/2012
-
+Authors: Simon Meier <iridcode@gmail.com>
+Creation Date: 2011-05-13
+Last Updated:  2013-02-27 by Andreas Lochbihler <andreas.lochbihler@inf.ethz.ch>
 
 1. Introduction
 ===============
@@ -56,42 +55,48 @@
 2.2 Installing the Isabelle/HOL theories
 ----------------------------------------
 
-Download and install full Isabelle2009-1 according to the installation
+Download and install full Isabelle2013 according to the installation
 instructions at
 
-    http://isabelle.in.tum.de/website-Isabelle2009-1/download_x86-linux.html
+    http://isabelle.in.tum.de/website-Isabelle2013/download_x86-linux.html
 
 The first time you call `scyther-proof` with the `--isabelle` flag it will
 build the logic image of the Isabelle/HOL theories formalizing the security
 protocol verification theory underlying `scyther-proof`.
 
-For enabling interactive processing of theory files based using our
-extensions to Isabelle's ISAR proof language use one of the following two
-variants.
+If you wish to use ProofGeneral to interactively process the theory files
+using our extensions to Isabelle's ISAR proof language, use one of the
+following two variants. This is needed in order to make the new ISAR keywords
+`role`, `protocol`, `sources`, and `prefix_close` available in the Emacs
+frontend. If you are using the Isabelle/jEdit Prover IDE, the keywords are
+automatically registered.
 
+
 Variant a: Brute Force
 ----------------------
 
-Overwrite the standard Emacs keywords file
+Copy the Emacs keywords file provided with the ESPL distribution at
 
-    $ISABELLE_HOME/etc/isar-keywords.el
+    $SCYTHER_PROOF_HOME/data/isabelle/src/isar-keywords.el
 
-with the Emacs keywords file provided with the ESPL distribution.
+to your local Isabelle configuration in
 
-    $SCYTHER_PROOF_HOME/isabelle/src/isar-keywords.el
+    $ISABELLE_HOME_USER/etc
 
-This is needed in order to make the new ISAR keywords `role`,
-`protocol`, `sources`, and `prefix_close` available in the Emacs
-frontend.
+This will replace any custom keyword file that you have already
+installed in that way. You can find out about $ISABELLE_HOME_USER
+by running
 
+    isabelle getenv ISABELLE_HOME_USER
 
+
 Variant b: Elegance
 -------------------
 
 A more elegant way is to copy the keywords file provided with our
 distribution to
 
-    $ISABELLE_HOME/etc/isar-keywords-ESPL.el
+    $ISABELLE_HOME_USER/etc/isar-keywords-ESPL.el
 
 and start Isabelle using the -k switch as follows.
 
@@ -104,7 +109,7 @@
 
 
 3.1 scyther-proof
-------------
+-----------------
 
 
   Usage Example
@@ -120,15 +125,13 @@
   all specified security properties together with the proof with the fewest
   number of chain rule applications to stdout.
 
-  In order to generate an Isabelle proof script two additional options need to
-  be added
+  To generate an Isabelle proof script, two additional options are required.
 
     scyther-proof $EXAMPLE_DIR/classic/NS_Public.spthy --shortest --output=nsl_cert.thy --ASCII
 
   The first one specifies the output file and the second one instructs
   scyther-proof to use Isabelle's ASCII notation as the output format.
 
-
   To build the source code documentation you can use the call
 
     cabal configure; cabal haddock
@@ -141,25 +144,40 @@
 3.2 The Isabelle/HOL theories
 -----------------------------
 
+   Note that in many case the easiest way to start with constructing
+   machine-checked proofs interactively is to use a proof script generated by
+   scyther-proof.
+
+   Using ProofGeneral
+   ------------------
+
    In the directory output by scyther-proof, load the Tutorial on interactive
    proof construction using the following commands
 
         cd <theory-dir-output-by-scytherproof>/src
         isabelle emacs Tutorial.thy
 
-    or if you've chosen the elegant variant
+    or if you've chosen the elegant variant for the keywords file
 
         isabelle emacs -k ESPL Tutorial.thy
 
-   Note that in many case the easiest way to start with constructing
-   machine-checked proofs interactively is to use a proof script generated by
-   scyther-proof.
 
+   Using the Isabelle/jEdit Prover IDE
+   -----------------------------------
 
+   In the directory output by scyther-proof, load the Tutorial on interactive
+   proof construction using the following commands
+
+        cd <theory-dir-output-by-scytherproof>/src
+        isabelle jedit -d $SCYTHER_PROOF_HOME/data/isabelle -l ESPL Tutorial.thy
+
+   where $SCYTHER_PROOF_HOME expands to the home directory of scyther-proof.
+
+
 ***
 
 `Happy Proving :)`
 
-In case of questions do not hesistate to contact me at
+In case of questions do not hesistate to contact Simon Meier at
 iridcode@gmail.com.
 
diff --git a/data/isabelle/ROOT b/data/isabelle/ROOT
new file mode 100644
--- /dev/null
+++ b/data/isabelle/ROOT
@@ -0,0 +1,2 @@
+session ESPL = HOL +
+  theories "src/ESPLogic"
diff --git a/data/isabelle/ROOT.ML b/data/isabelle/ROOT.ML
deleted file mode 100644
--- a/data/isabelle/ROOT.ML
+++ /dev/null
@@ -1,1 +0,0 @@
-use_thy "src/ESPLogic"
diff --git a/data/isabelle/src/ESPLogic/Automation.thy b/data/isabelle/src/ESPLogic/Automation.thy
--- a/data/isabelle/src/ESPLogic/Automation.thy
+++ b/data/isabelle/src/ESPLogic/Automation.thy
@@ -15,11 +15,13 @@
   Syntax
   InferenceRules
   WeakTyping
-uses
-  espl_definitions
-  espl_methods
+keywords "role" "protocol" "type_invariant" :: thy_decl
+  and "prefix_close" :: prf_decl
 begin
 
+ML_file "espl_definitions.ML"
+ML_file "espl_methods.ML"
+
 section{* Automation *}
 
 subsection{* Setup of ISAR commands *}
@@ -153,235 +155,5 @@
     "(LKR (Lit (EveNonce i))) \<prec> e \<Longrightarrow> False"
   "e \<prec> (LKR (Lit (EveNonce i))) \<Longrightarrow> False"
 by(auto dest: predOrd_LKR_agent1 predOrd_LKR_agent2)
-
-
-subsection{* Testing the Infrastructure *}
-
-
-(*
-text{*
-  Commented out because new ISAR syntax comes only active after
-  the theory file that defines them.
-*}
-
-role C
-where "C =
-  [ Send ''1'' ( PEnc ( sN ''k'' ) ( sPK ''S'' ) )
-  , Recv ''2'' ( PHash ( sN ''k'' ) )
-  , Note ''3'' SessKey (sN ''k'')
-  ]"
-
-role S
-where "S =
-  [ Recv ''1'' ( PEnc ( sMV ''k'' ) ( sPK ''S'' ) )
-  , Send ''2'' ( PHash ( sMV ''k'' ) )
-  ]"
-
-protocol CR
-where "CR = { C, S }"
-
-locale restricted_CR_state = CR_state
-
-type_invariant auto_msc_typing for CR
-where "auto_msc_typing = mk_typing
-  [ ((S, ''k''), (SumT (KnownT S_1) (NonceT C ''k'')))
-  ]"
-
-
-lemma additional_reveal_order:
-  assumes facts:
-    "predOrd t (LKR a) c"
-  shows 
-    "a \<in> lkreveals t \<and> predOrd t (LKR a) c"
-using facts
-by(auto intro: event_predOrdI)
-
-sublocale CR_state < auto_msc_typing_state
-proof -
-  have "(t,r,s) : approx auto_msc_typing"
-  proof(cases rule: reachable_in_approxI_ext
-        [OF auto_msc_typing.monoTyp, completeness_cases_rule])
-    case (S_1_k t r s tid0) note facts = this
-    then interpret state: auto_msc_typing_state t r s
-      by unfold_locales auto
-    show ?case using facts
-    proof(sources! "
-        Enc ( s(MV ''k'' tid0) ) ( PK ( s(AV ''S'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits) | (fastsimp intro: event_predOrdI split: if_splits))+)?
-  qed
-  thus "auto_msc_typing_state t r s" by unfold_locales auto
-qed
-
-lemma (in restricted_CR_state) C_k_order_raw:
-   assumes facts:
-     "roleMap r tid0 = Some C"
-   shows
-     "LN ''k'' tid0 \<in> knows t \<longrightarrow>
-     (LKR (s(AV ''S'' tid0))) \<prec> (Ln (LN ''k'' tid0)) \<or> 
-     (St (tid0, C_3) \<prec> (Ln (LN ''k'' tid0)))" 
-     (is "?knows \<longrightarrow> ?order")
-proof
-  assume "?knows"
-  thus "?order" using facts
-  proof (sources "LN ''k'' tid0")
-    case C_1_k
-    thus ?thesis
-      by (sources "SK (s (AV ''S'' tid0))")  (fastsimp intro: event_predOrdI)+
-  qed auto
-qed
-
-(*
-lemmas (in restricted_CR_state) C_k_order = C_k_order_raw[rule_format, THEN additional_reveal_order]
-*)
-
-lemma (in restricted_CR_state) C_k_secrecy:
-  assumes facts:
-    "roleMap r tid0 = Some C"
-    "s(AV ''S'' tid0) ~: lkreveals t"
-    "(tid0, C_3) \<notin> steps t"
-    "LN ''k'' tid0 : knows t"
-  shows "False"
-using facts 
-by(fastsimp dest: C_k_order_raw[rule_format] 
-           intro: event_predOrdI)
-
-
-*)
-
-
-(*
-text{*
-  Commented out because new ISAR syntax comes only active after
-  the theory file that defines them.
-*}
-
-text{* Testing the role definition command *}
-role I
-where "I \<equiv> 
-  [ Send ''0'' (PEnc \<langle>sLC ''0'', sAV ''I'', sN ''ni''\<rangle> (sPK ''R''))
-  , Recv ''1'' (PEnc \<langle>sLC ''1'', sAV ''R'', sN ''ni'', sMV ''nr''\<rangle> (sPK ''I''))
-  , Send ''2'' (PEnc \<langle>sLC ''2'', sMV ''nr''\<rangle> (sPK ''R''))
-  ]"
-
-text{* A few of the proven theorems: *}
-thm I.weakly_atomic_convs
-thm I_def
-thm I.unfold
-thm I.wf_role
-thm I.distinct_steps
-thm I.in_set_conv
-thm I.zip_conv
-thm I.prefixClose_convs
-
-thm I_1_def
-thm I_1.unfold
-thm I_1_pt_def
-thm I_1.inst_conv
-thm I_1.sendStep_conv
-thm I_1.stepPat_conv
-thm I_1.FV_conv
-thm I_1.FMV_conv
-
-text{* 
-  Note that you should not need to use these theorems manually as the 
-  simplifier and the classical reasoner are already setup such that
-  they are used when appropriate.
-
-  The general design idea behind the rules is such that wherever possible
-  constants are not unfolded, as this simplifies proof states.
-*}
-
-text{* An additional role for testing purposes. *}
-role R
-where "R \<equiv>
-  [ Recv ''0'' (PEnc \<langle>sLC ''0'', sLAV ''I'', sLMV ''ni''\<rangle> (sPK ''R''))
-  , Send ''1'' (PEnc \<langle>sLC ''1'', sLAV ''R'', sLMV ''ni'', sLN ''nr''\<rangle> (sPK ''I''))
-  , Recv ''2'' (PEnc \<langle>sLC ''2'', sLN ''nr''\<rangle> (sPK ''R''))
-  ]"
-
-thm R.weakly_atomic_convs
-
-protocol nsl
-where "nsl = {I, R}"
-
-text{* Testing the protocol definition command; the generated theorems: *}
-thm nsl_def
-thm nsl.unfold
-thm nsl.wf_proto
-thm nsl.distinct_roles
-thm nsl.in_set_conv
-
-type_invariant typed_nsl for nsl
-where "typed_nsl = mk_typing
-   [ ((R, ''ni''), (SumT (KnownT R_0) (NonceT I ''ni'')))
-   , ((I, ''nr''), (SumT (KnownT I_1) (NonceT R ''nr'')))
-   ]"
-
-
-sublocale nsl_state \<subseteq> typed_nsl_state
-proof -
-  have "(t,r,s) \<in> approx typed_nsl"
-  proof(cases rule: reachable_in_approxI_ext
-                    [OF typed_nsl.monoTyp, completeness_cases_rule])
-    case (I_1_nr t r s i)
-    then interpret state: typed_nsl_state t r s
-      by unfold_locales auto
-    show ?case using I_1_nr
-    proof(sources "inst s i I_1_pt")
-    qed (fastsimp intro: event_predOrdI split: if_splits)+
-  next
-    case (R_0_ni t r s i)
-    then interpret state: typed_nsl_state t r s
-      by unfold_locales auto
-    show ?case using R_0_ni
-    proof(sources "inst s i R_0_pt")
-    qed (fastsimp intro: event_predOrdI split: if_splits)+
-  qed
-  thus "typed_nsl_state t r s" by unfold_locales auto
-qed
-
-context nsl_state begin
-  lemma longterm_private_key_secrecy:
-    assumes facts:
-      "SK m : knows t"
-      "m ~: Compromised"
-    shows "False"
-  using facts by (sources "SK m")
-
-  lemma longterm_shared_key_secrecy:
-    assumes facts:
-      "K m1 m2 : knows t"
-      "m1 ~: Compromised"
-      "m2 ~: Compromised"
-    shows "False"
-  using facts by (sources "K m1 m2")
-
-  lemmas ltk_secrecy =
-    longterm_shared_key_secrecy
-    longterm_shared_key_secrecy[OF in_knows_predOrd1]
-    longterm_private_key_secrecy
-    longterm_private_key_secrecy[OF in_knows_predOrd1]
-end
-
-lemma (in nsl_state) I_ni_secrecy:
-  assumes facts:
-    "roleMap r i = Some I"
-    "LN ''ni'' i \<in> knows t"
-    "s (AV ''I'' i) \<notin> lkreveals t"
-    "s (AV ''R'' i) \<notin> lkreveals t"   
-  shows "False"
-using facts proof(sources " LN ''ni'' tid0 ")
-  case I_0_ni thus ?thesis by (fastsimp dest!: ltk_secrecy)
-next
-  case (R_1_ni tid1) thus ?thesis 
-  proof(sources "inst s tid1 R_0_pt")
-    case I_0_enc thus ?thesis 
-      by (fastsimp dest!: ltk_secrecy)
-  qed (insert facts, (((clarsimp, order?) | order))+)?
-qed
-
-
-*)
-
 
 end
diff --git a/data/isabelle/src/ESPLogic/Capabilities.thy b/data/isabelle/src/ESPLogic/Capabilities.thy
--- a/data/isabelle/src/ESPLogic/Capabilities.thy
+++ b/data/isabelle/src/ESPLogic/Capabilities.thy
@@ -19,7 +19,7 @@
 chapter{* Compromising Adversary Capability *}
 
 section{* Partnering *}
-types partnering = "state \<Rightarrow> (tid \<times> tid) set"
+type_synonym partnering = "state \<Rightarrow> (tid \<times> tid) set"
 
 
 definition unionPart :: "partnering \<Rightarrow> partnering \<Rightarrow> partnering" (infix "UNP" 65)
@@ -31,7 +31,7 @@
 
 lemma union_unionPart_conv:
   "(a \<in> ((P1 \<union>\<^isub>P P2) q)) = (a \<in> (P1 q \<union> P2 q))"
-by (fastsimp simp add: unionPart_def)
+by (fastforce simp add: unionPart_def)
 
 
 definition mk_partnering :: "role \<Rightarrow> role \<Rightarrow> (pattern \<times> pattern \<times> rolestep) set \<Rightarrow> partnering"
@@ -44,10 +44,10 @@
  "((i,j) \<in> mk_partnering R1 R2 conds (t,r,s)) = 
    (roleMap r i = Some R1 \<and> roleMap r j = Some R2 \<and> 
    (\<forall> (p1,p2,st) \<in> conds. (j,st) \<in> steps t \<longrightarrow> (inst s i p1) = (inst s j p2)))"
-by (fastsimp simp add: mk_partnering_def)
+by (fastforce simp add: mk_partnering_def)
 
 lemma setEqImpTupleIn: "(X = Y) \<Longrightarrow> ((i,j) \<in> X) = ((i,j) \<in> Y)"
-by fastsimp
+by fastforce
 
 lemma uniquePartner: 
   assumes facts:
@@ -59,15 +59,15 @@
     "\<forall> j'. (i,j') \<in> mk_partnering R1 R2 conds (t,r,s) \<and> (j',st) \<in> steps t \<longrightarrow> j' = j"
 proof -
   have "inst s i pt1 = inst s j pt2"
-    using facts by (fastsimp simp add: mk_partnering_conv)
+    using facts by (fastforce simp add: mk_partnering_conv)
   moreover 
   hence "\<forall> j'. j' \<noteq> j \<longrightarrow> inst s j pt2 \<noteq> inst s j' pt2"
-    using facts by fastsimp
+    using facts by fastforce
   ultimately 
   have "\<forall> j'. j' \<noteq> j \<longrightarrow> inst s i pt1 \<noteq> inst s j' pt2"
-    by fastsimp
+    by fastforce
   hence "\<forall> j'. (j' \<noteq> j \<and> (j',st) \<in> steps t) \<longrightarrow>  (i,j') \<notin> mk_partnering R1 R2 conds (t,r,s)"
-    using facts by (fastsimp simp add: mk_partnering_conv)
+    using facts by (fastforce simp add: mk_partnering_conv)
   thus ?thesis
     by auto
 qed
@@ -78,11 +78,11 @@
   shows
    "roleMap r i = Some R1 \<and> roleMap r j = Some R2"
 using facts
-by (fastsimp simp add: mk_partnering_conv)
+by (fastforce simp add: mk_partnering_conv)
 
 section{* Capabilities *}
 
-types capability = "state \<Rightarrow> reveal set"
+type_synonym capability = "state \<Rightarrow> reveal set"
 
 subsection{* Helper Functions *}
 definition interCap :: "capability \<Rightarrow> capability \<Rightarrow> capability" (infix "INC" 65)
@@ -101,11 +101,11 @@
 
 lemma union_unionCap_conv:
   "(a \<in> ((C1 \<union>\<^isub>C C2) q)) = (a \<in> (C1 q \<union> C2 q))"
-by (fastsimp simp add: unionCap_def)
+by (fastforce simp add: unionCap_def)
 
 lemma inter_interCap_conv:
   "(a \<in> ((C1 \<inter>\<^isub>C C2) q)) = (a \<in> (C1 q \<inter> C2 q))"
-by (fastsimp simp add: interCap_def)
+by (fastforce simp add: interCap_def)
 
 
 subsection{* Adversary-Compromise Model *}
@@ -119,13 +119,13 @@
   (t,r,s) \<in> acm caps ; 
   reveal \<in> reveals t 
  \<rbrakk> \<Longrightarrow> \<exists> cap \<in> caps. reveal \<in> cap (t,r,s)"
-by(fastsimp simp add: acm_def)
+by(fastforce simp add: acm_def)
 
 
 lemma acm_monotone:
 "\<lbrakk> (t,r,s) \<in> acm caps \<rbrakk> 
  \<Longrightarrow> (t,r,s) \<in> acm (caps \<union> caps')"
-by(fastsimp simp add: acm_def)
+by(fastforce simp add: acm_def)
 
 subsection{* Implementation of Capabilities and Dot-Mapping *}
 
@@ -183,7 +183,7 @@
   "RCompr a b \<notin> LKRactor i c (t,r,s)"
   "RCompr a b \<notin> LKRafter i (t,r,s)"
   "RCompr a b \<notin> LKRafterCorrect i ps(t,r,s)"
-by(fastsimp)+
+by(fastforce)+
 
 
 subsubsection{* Compromises *}
@@ -230,20 +230,20 @@
   "RCompr RandGen j \<notin> SkR i ps q"
   "RCompr State j \<notin> RNR q"
   "RCompr SessKey j \<notin> RNR q"
-by(fastsimp simp add: StR_def SkR_def RNR_def)+
+by(fastforce simp add: StR_def SkR_def RNR_def)+
 
 
 lemma SkR_conv[simp]:
   "c \<in> SkR i ps (t,r,s) = (\<exists> j. (c = RCompr SessKey j) \<and> (i,j) \<notin> ps (t,r,s) \<and> j \<noteq> i )"
-by(fastsimp simp add: SkR_def)
+by(fastforce simp add: SkR_def)
 
 lemma RNR_conv[simp]:
   "c \<in> RNR (t,r,s) = (\<exists> j. (c = RCompr RandGen j))"
-by(fastsimp simp add: RNR_def)
+by(fastforce simp add: RNR_def)
 
 lemma StR_conv[simp]:
   "c \<in> StR i ps (t,r,s) = (\<exists> j. (c = RCompr State j) \<and> (i,j) \<notin> ps (t,r,s) \<and> j \<noteq> i )"
-by(fastsimp simp add: StR_def)
+by(fastforce simp add: StR_def)
 
 
 lemma (in reachable_state) LKRafterTrans:
@@ -253,6 +253,6 @@
     RLKR a \<in> LKRafter i (t,r,s);
     LKR a \<prec> St (i,st)
    \<rbrakk> \<Longrightarrow> False"
-by(fastsimp)
+by(fastforce)
 
 end
diff --git a/data/isabelle/src/ESPLogic/DistinctList.thy b/data/isabelle/src/ESPLogic/DistinctList.thy
--- a/data/isabelle/src/ESPLogic/DistinctList.thy
+++ b/data/isabelle/src/ESPLogic/DistinctList.thy
@@ -210,10 +210,10 @@
   by(auto dest: next_imp_less)
 
 lemma in_set_less1: "x \<prec> y \<Longrightarrow> x \<in> set xs"
-  by(simp add: pred_def in_set_listOrd1)
+  by(simp add: in_set_listOrd1)
 
 lemma in_set_less2: "x \<prec> y \<Longrightarrow> y \<in> set xs"
-  by(simp add: pred_def in_set_listOrd2)
+  by(simp add: in_set_listOrd2)
 
 lemmas in_set_next1 = in_set_less1[OF next_imp_less, rule_format]
 lemmas in_set_next2 = in_set_less2[OF next_imp_less, rule_format]
diff --git a/data/isabelle/src/ESPLogic/ExecMessage.thy b/data/isabelle/src/ESPLogic/ExecMessage.thy
--- a/data/isabelle/src/ESPLogic/ExecMessage.thy
+++ b/data/isabelle/src/ESPLogic/ExecMessage.thy
@@ -43,7 +43,7 @@
 
 translations
   "{|x, y, z|}"   == "{|x, {|y, z|}|}"
-  "{|x, y|}"      == "Tup x y"
+  "{|x, y|}"      == "(CONST Tup) x y"
 
 
 text{* 
@@ -85,7 +85,7 @@
 lemma Kbd_split_inj:
   "\<lbrakk> a \<in> Agent; b \<in> Agent; x \<in> Agent; y \<in> Agent \<rbrakk> \<Longrightarrow>
    (Kbd a b = Kbd x y) = (a = x \<and> b = y \<or> a = y \<and> b = x)"
-  apply(clarsimp simp: Kbd_def Agent_def agents_def expand_set_eq) 
+  apply(clarsimp simp: Kbd_def Agent_def agents_def set_eq_iff) 
   apply(rule iffI)
   apply(rename_tac a b x y)
   apply(safe)
@@ -126,7 +126,7 @@
 
 subsection{* Operations *}
 
-types store = "varid \<times> tid \<Rightarrow> execmsg"
+type_synonym store = "varid \<times> tid \<Rightarrow> execmsg"
 
 fun inv :: "execmsg \<Rightarrow> execmsg"
 where
diff --git a/data/isabelle/src/ESPLogic/ExplicitModel.thy b/data/isabelle/src/ESPLogic/ExplicitModel.thy
--- a/data/isabelle/src/ESPLogic/ExplicitModel.thy
+++ b/data/isabelle/src/ESPLogic/ExplicitModel.thy
@@ -34,9 +34,9 @@
   RCompr notetype tid
 | RLKR execmsg
 
-types explicit_trace = "rawevent list"
-types execstep = "tid \<times> rolestep"
-types threadpool = "tid \<rightharpoonup> (rolestep list \<times> rolestep list \<times> rolestep set)"
+type_synonym explicit_trace = "rawevent list"
+type_synonym execstep = "tid \<times> rolestep"
+type_synonym threadpool = "tid \<rightharpoonup> (rolestep list \<times> rolestep list \<times> rolestep set)"
 
 fun knows :: "explicit_trace \<Rightarrow> execmsg set"
 where
@@ -109,7 +109,7 @@
   by (auto simp: longTermKeys_def)
 
 
-types state = "explicit_trace \<times> threadpool \<times> store"
+type_synonym state = "explicit_trace \<times> threadpool \<times> store"
 
 inductive_set 
   reachable :: "proto \<Rightarrow> state set" 
@@ -208,7 +208,7 @@
 lemma role_in_P:  "done @ todo \<in> P"
 using thread_exists
 proof (induct arbitrary: i "done" todo skipped rule: reachable_induct)
-qed (fastsimp split: if_splits)+
+qed (fastforce split: if_splits)+
 
 end
 
@@ -297,7 +297,7 @@
 
 lemma RCompr_steps_conv:
   "RCompr ty i \<in> reveals t = (\<exists> l pt. (i, Note l ty pt) \<in> steps t)"
-by (fastsimp intro: reveals_to_steps steps_to_reveals)
+by (fastforce intro: reveals_to_steps steps_to_reveals)
 
 context reachable_thread
 begin
@@ -330,7 +330,7 @@
 using thread_exists
 proof(induct arbitrary: i "done" todo skipped rule: reachable_induct)
   case init
-  thus "?case" by fastsimp
+  thus "?case" by fastforce
 qed( auto split: if_splits)
 
 
@@ -348,7 +348,7 @@
 using thread_exists
 using distinct
 proof(induct arbitrary: i "done" todo skipped rule: reachable_induct)
-  case init thus ?case by fastsimp
+  case init thus ?case by fastforce
 next 
   case (send t r s i "done" l pt todo skipped m i' done' todo' skipped')
   thus ?case
@@ -357,8 +357,8 @@
     then interpret thread: 
       reachable_thread P t r s i "done" "Send l pt # todo" skipped'
       using send by unfold_locales auto
-    thus ?thesis 
-      using send `i = i'` by fastsimp 
+    show ?thesis 
+      using send `i = i'` by fastforce 
   qed auto
 next
   case (recv t r s i "done" l pt todo skipped m i' done' todo' skipped')
@@ -368,8 +368,8 @@
     then interpret thread: 
       reachable_thread P t r s i "done" "Recv l pt # todo" skipped'
       using recv by unfold_locales auto
-    thus ?thesis 
-      using recv `i = i'` by fastsimp 
+    show ?thesis 
+      using recv `i = i'` by fastforce
   qed auto
 next
   case (compr t r s i "done" l ty pt todo skipped m i' done' todo' skipped')  
@@ -382,8 +382,8 @@
       interpret thread:
         reachable_thread P t r s i "done" "Note l ty pt # todo" skipped'
         using compr  `i = i'` by unfold_locales auto
-      thus ?thesis using compr  `i = i'` `step = Note l ty pt` by (fastsimp dest: thread.skipped_in_done )
-    qed fastsimp
+      show ?thesis using compr  `i = i'` `step = Note l ty pt` by (fastforce dest: thread.skipped_in_done )
+    qed fastforce
   qed auto
 next
   case(skip t r s i "done" l ty pt todo skipped i' done' todo' skipped')
@@ -396,8 +396,8 @@
       interpret thread:
         reachable_thread P t r s i "done" "Note l ty pt # todo" skipped
         using skip  `i = i'` by unfold_locales auto
-      thus ?thesis using skip  `i = i'` `step = Note l ty pt` by fastsimp
-    qed fastsimp
+      show ?thesis using skip  `i = i'` `step = Note l ty pt` by fastforce
+    qed fastforce
  qed auto
 qed auto
 
@@ -406,7 +406,7 @@
 using thread_exists
 proof(induct arbitrary: i "done" todo skipped rule rule: reachable_induct)
   case init
-    thus "?case" by fastsimp
+    thus "?case" by fastforce
 qed ((unfold map_upd_Some_unfold)?, auto)+
 
 lemma in_steps_send:
@@ -414,7 +414,7 @@
 using thread_exists
 proof(induct arbitrary: i "done" todo skipped rule rule: reachable_induct)
   case init
-    thus "?case" by fastsimp
+    thus "?case" by fastforce
 qed ((unfold map_upd_Some_unfold)?, auto)+
 
 lemmas send_steps_in_done [elim!] = iffD1[OF in_steps_send, rule_format]
@@ -444,13 +444,13 @@
   "step \<in> set todo \<Longrightarrow> step \<notin> skipped"
 using distinct
 using role_in_P
-by(fastsimp dest: skipped_in_done)
+by(fastforce dest: skipped_in_done)
 
 lemma skipped_notin_todoD:
   "step \<in> skipped \<Longrightarrow> step \<notin> set todo"
 using distinct
 using role_in_P
-by(fastsimp dest: skipped_in_done)
+by(fastforce dest: skipped_in_done)
 
 lemma notin_steps_notin_trace:
   "(i, step) \<notin> steps t \<Longrightarrow> (Step (i, step)) \<notin> set t"
@@ -463,13 +463,13 @@
     "step \<in> set done"
 proof(cases step)
   case (Send l pt)
-    thus ?thesis using inSteps by (fastsimp dest: in_steps_send[THEN iffD2])
+    thus ?thesis using inSteps by (fastforce dest: in_steps_send[THEN iffD2])
 next
   case (Recv l pt)
-    thus ?thesis using inSteps by (fastsimp dest: in_steps_recv[THEN iffD2])
+    thus ?thesis using inSteps by (fastforce dest: in_steps_recv[THEN iffD2])
 next
   case (Note l ty pt)
-    thus ?thesis using inSteps by (fastsimp simp add: in_steps_conv_done_skipped)
+    thus ?thesis using inSteps by (fastforce simp add: in_steps_conv_done_skipped)
 qed
 
 
@@ -483,7 +483,7 @@
 
 lemma[dest]:
   "\<lbrakk> step \<in> set todo; step \<in> set done \<rbrakk> \<Longrightarrow> False"
-by(fastsimp dest: todo_notin_doneD)
+by(fastforce dest: todo_notin_doneD)
 
 lemma[dest]:
   "\<lbrakk> step \<in> set todo; step \<in> skipped \<rbrakk> \<Longrightarrow> False"
@@ -509,7 +509,7 @@
 proof(induct arbitrary: i "done" todo skipped rule: reachable_induct)
   case (init r s i "done" todo) 
   thus ?case
-    by fastsimp
+    by fastforce
 next
   case (send t r s i "done" l msg todo skipped m i' done' todo' skipped')
   thus ?case using send 
@@ -518,9 +518,9 @@
       interpret this_thread:
           reachable_thread P t r s i' "done" "Send l msg # todo'" skipped'
           using send `i = i'` by unfold_locales auto
-       thus ?thesis using send `i = i'`
-          by fastsimp
-  qed fastsimp
+       show?thesis using send `i = i'`
+          by fastforce
+  qed fastforce
 next
   case (recv t r s i "done" l msg todo skipped m i' done' todo' skipped')
   from recv show ?case 
@@ -529,9 +529,9 @@
       interpret this_thread:
           reachable_thread P t r s i' "done" "Recv l msg # todo'" skipped'
           using recv `i = i'` by unfold_locales auto
-       thus ?thesis using recv `i = i'`
-          by fastsimp
-  qed fastsimp
+       show ?thesis using recv `i = i'`
+          by fastforce
+  qed fastforce
 next
   case (compr t r s i "done" l ty msg todo skipped m i' done' todo' skipped')
   from compr show ?case 
@@ -540,9 +540,9 @@
       interpret this_thread:
           reachable_thread P t r s i' "done" "Note l ty msg # todo'" skipped'
           using compr `i = i'` by unfold_locales auto
-       thus ?thesis using compr `i = i'`
-          by fastsimp
-  qed fastsimp
+       show ?thesis using compr `i = i'`
+          by fastforce
+  qed fastforce
 next
   case (skip t r s i "done" l ty msg todo skipped i' done' todo' skipped') 
   from skip show ?case 
@@ -551,9 +551,9 @@
     then interpret this_thread:
       reachable_thread P t r s i "done" "Note l ty msg # todo" skipped
       using skip `i = i'` by unfold_locales auto
-    thus ?thesis using skip `i = i'`
-      by fastsimp
-  qed fastsimp
+    show ?thesis using skip `i = i'`
+      by fastforce
+  qed fastforce
 qed auto
 
 lemma listOrd_recv_role_imp_listOrd_trace:
@@ -695,21 +695,21 @@
     reachable_thread P t r s i "done" "Recv l msg # todo" skipped
     by unfold_locales auto
   show ?case using  `distinct' t` this_thread.distinct
-    by(fastsimp dest: this_thread.in_steps_in_done)
+    by(fastforce dest: this_thread.in_steps_in_done)
 next
   case (send t r s i "done" l msg todo skipped m)
   then interpret this_thread: 
     reachable_thread P t r s i "done" "Send l msg # todo" skipped
     by unfold_locales auto
   show ?case using `distinct' t` and this_thread.distinct
-    by(fastsimp dest: this_thread.in_steps_in_done)
+    by(fastforce dest: this_thread.in_steps_in_done)
 next
   case (compr t r s i "done" l ty msg todo skipped m)
   then interpret this_thread: 
      reachable_thread P t r s i "done" "Note l ty msg # todo" skipped
      by unfold_locales auto
   show ?case using `distinct' t` and this_thread.distinct
-     by(fastsimp dest: this_thread.in_steps_in_done)
+     by(fastforce dest: this_thread.in_steps_in_done)
 next
   case (skip t r s i "done" l ty msg todo skipped)
   then interpret this_thread: 
@@ -827,7 +827,7 @@
   "\<lbrakk>predOrd t (St a) (LKR d);   \<lbrakk> a \<in> steps t; RLKR d \<in> reveals t     \<rbrakk> \<Longrightarrow> R \<rbrakk> \<Longrightarrow> R"
   "\<lbrakk>predOrd t (Ln x) (LKR d);   \<lbrakk> x \<in> knows t; RLKR d \<in> reveals t     \<rbrakk> \<Longrightarrow> R \<rbrakk> \<Longrightarrow> R"
   "\<lbrakk>predOrd t (LKR c) (LKR d);  \<lbrakk> RLKR c \<in> reveals t; RLKR d \<in> reveals t \<rbrakk> \<Longrightarrow> R \<rbrakk> \<Longrightarrow> R"
-  by(fastsimp intro: event_predOrdI compr_predOrdI)+
+  by(fastforce intro: event_predOrdI compr_predOrdI)+
 
 
 lemma predOrd_LKR_agent1:
@@ -1047,7 +1047,7 @@
 next
   case decr thus ?case by(auto dest: pairParts_idemD)
 next
-  case tuple thus ?case by fastsimp
+  case tuple thus ?case by fastforce
 next
   case lkr thus ?case by(auto simp: longTermKeys_def)
 next
@@ -1070,37 +1070,37 @@
   then interpret s1: reachable_state P t r s
     by unfold_locales
   from hash show ?case
-    by (fastsimp dest: s1.rev_knows_pairParts_closedD)
+    by (fastforce dest: s1.rev_knows_pairParts_closedD)
 next
   case (encr t r s msg key)
   then interpret s1: reachable_state P t r s
     by unfold_locales
   from encr show ?case
-    by (fastsimp dest: s1.rev_knows_pairParts_closedD)
+    by (fastforce dest: s1.rev_knows_pairParts_closedD)
 next
   case (tuple t r s msg1 msg2)
   then interpret s1: reachable_state P t r s
     by unfold_locales
   from tuple show ?case
-    by (fastsimp dest: s1.rev_knows_pairParts_closedD)
+    by (fastforce dest: s1.rev_knows_pairParts_closedD)
 next
   case (decr t r s msg key)
   then interpret s1: reachable_state P t r s
     by unfold_locales
   from decr show ?case
-    by (fastsimp dest: s1.rev_knows_pairParts_closedD)
+    by (fastforce dest: s1.rev_knows_pairParts_closedD)
 next
   case (send t r s i "done" l msg todo msg)
   then interpret s1: reachable_state P t r s
     by unfold_locales
   from send show ?case
-    by (fastsimp dest: s1.rev_knows_pairParts_closedD)
+    by (fastforce dest: s1.rev_knows_pairParts_closedD)
 next
   case (recv t r s i "done" l msg todo)
   then interpret s1: reachable_state P t r s
     by unfold_locales
   from recv show ?case
-    by (fastsimp dest: s1.rev_knows_pairParts_closedD)
+    by (fastforce dest: s1.rev_knows_pairParts_closedD)
 next
   case (init r s) thus ?case by simp
 next
@@ -1108,25 +1108,25 @@
   then interpret s1: reachable_state P t r s
     by unfold_locales
   from lkr show ?case
-   by (fastsimp dest: s1.rev_knows_pairParts_closedD)
+   by (fastforce dest: s1.rev_knows_pairParts_closedD)
 next
   case (skip t r s i "done" l ty pt todo)
   then interpret s1: reachable_state P t r s 
     by unfold_locales
   from skip show ?case
-    by(fastsimp dest: s1.rev_knows_pairParts_closedD)
+    by(fastforce dest: s1.rev_knows_pairParts_closedD)
 next
   case (compr t r s i "done" l ty pt todo skipped m)
   then interpret s1: reachable_state P t r s
     by unfold_locales
   from compr show ?case
-    by(fastsimp dest: s1.rev_knows_pairParts_closedD)
+    by(fastforce dest: s1.rev_knows_pairParts_closedD)
 qed
 
 lemma Ln_before_inp:
   "(i, Recv l pt) \<in> steps t \<Longrightarrow> 
    \<exists> m. Some m = inst s i pt \<and> Ln m \<prec> St (i, Recv l pt)"
-  by (induct arbitrary: i l pt rule: reachable_induct) fastsimp+
+  by (induct arbitrary: i l pt rule: reachable_induct) fastforce+
 
 lemma Ln_before_inpE:
   "\<lbrakk> (i, Recv l pt) \<in> steps t;
@@ -1144,11 +1144,11 @@
 
 lemma split_before:
   "Ln (Tup m m') \<prec> y \<Longrightarrow> Ln m \<prec> y \<and> Ln m' \<prec> y"
-  by (fastsimp intro: pairParts_before)
+  by (fastforce intro: pairParts_before)
 
 lemma split_knows:
   "Tup m m' \<in> knows t \<Longrightarrow> m \<in> knows t \<and> m' \<in> knows t"
-  by (fastsimp intro: knows_pairParts_closedD)
+  by (fastforce intro: knows_pairParts_closedD)
 end
 
 subsection{* Case Distinction on Learning Messages *}
@@ -1207,7 +1207,7 @@
     hence "?case"
     proof(cases "m' = Enc m k")
       case True thus ?thesis
-	using `?here` Enc by fastsimp
+	using `?here` Enc by fastforce
     next
       case False thus ?thesis
 	using `?here` Enc
@@ -1217,7 +1217,7 @@
   moreover
   { assume "?nested"
     hence "?case" using Enc
-      by (fastsimp dest!: Enc(2))
+      by (fastforce dest!: Enc(2))
   }
   ultimately show ?case by fast
 qed auto
@@ -1257,17 +1257,17 @@
     (is "?ik0 \<or> ?hash \<or> ?enc \<or> ?tup \<or> ?chain t r s \<or> ?note t r s \<or> ?keys")
     moreover
     { assume "?ik0"  hence "?thesis" by blast }    moreover
-    { assume "?hash" hence "?thesis" by fastsimp } moreover
-    { assume "?enc"  hence "?thesis" by fastsimp } moreover
-    { assume "?tup"  hence "?thesis" by fastsimp } moreover
+    { assume "?hash" hence "?thesis" by fastforce } moreover
+    { assume "?enc"  hence "?thesis" by fastforce } moreover
+    { assume "?tup"  hence "?thesis" by fastforce } moreover
     { assume "?chain t r s"
       hence "?chain (t@t') r s" 
-	by (fastsimp intro!: decrChain_append)
+	by (fastforce intro!: decrChain_append)
       hence "?thesis" by blast
     } moreover
     { assume "?note t r s"
       hence "?note (t@t') r s" 
-	by (fastsimp intro!: decrChain_append)
+	by (fastforce intro!: decrChain_append)
       hence "?thesis" by blast
     } moreover
     { assume "?keys" hence "?thesis" by auto }
@@ -1284,14 +1284,14 @@
     let ?t' = "t @ [Learns {Hash m}]"
     note IH = hash(2)
     have "m' \<in> knows t \<or> m' = Hash m" (is "?old \<or> ?new")
-      using hash by fastsimp
+      using hash by fastforce
     moreover
     { assume "?new" hence ?case 
-	using `m \<in> knows t` by fastsimp 
+	using `m \<in> knows t` by fastforce 
     }
     moreover
     { assume "?old" 
-      hence ?case by (fastsimp intro!: IH cases_appendI_trace)
+      hence ?case by (fastforce intro!: IH cases_appendI_trace)
     }
     ultimately show ?case by fast
   next
@@ -1299,10 +1299,10 @@
     let ?t' = "t @ [Learns {Enc m k}]"
     note IH = encr(2)
     have "m' \<in> knows t \<or> m' = Enc m k" (is "?old \<or> ?new")
-      using encr by fastsimp
+      using encr by fastforce
     moreover
     { assume "?new" hence ?case 
-	using `m \<in> knows t` and `k \<in> knows t` by fastsimp 
+	using `m \<in> knows t` and `k \<in> knows t` by fastforce 
     }
     moreover
     { assume "?old" 
@@ -1314,10 +1314,10 @@
     let ?t' = "t @ [Learns {Tup x y}]"
     note IH = tuple(2)
     have "m' \<in> knows t \<or> m' = Tup x y" (is "?old \<or> ?new")
-      using tuple by fastsimp
+      using tuple by fastforce
     moreover
     { assume "?new" hence ?case 
-	using `x \<in> knows t` and `y \<in> knows t` by fastsimp 
+	using `x \<in> knows t` and `y \<in> knows t` by fastforce 
     }
     moreover
     { assume "?old" 
@@ -1331,30 +1331,28 @@
       by clarsimp
     moreover
     { assume "?ik0"   hence "?case" by blast    } moreover
-    { assume "?hash"  hence "?case" by fastsimp } moreover
-    { assume "?enc"   hence "?case" by fastsimp } moreover
-    { assume "?keys"  hence "?case" by fastsimp } moreover
-    { assume "?tup"   hence "?case" by fastsimp } moreover
+    { assume "?hash"  hence "?case" by fastforce } moreover
+    { assume "?enc"   hence "?case" by fastforce } moreover
+    { assume "?keys"  hence "?case" by fastforce } moreover
+    { assume "?tup"   hence "?case" by fastforce } moreover
     { let ?t' = "t@[Step (i, Recv l pt)]"
       and ?r' = "r(i \<mapsto> (done @ [Recv l pt], todo, skipped))"
       assume "?chain t r s" then
       obtain i' done' todo' l' pt' skipped' m
-	where thread': "r i' = Some (done', todo', skipped')"
-	and send: "Send l' pt' \<in> set done'"
+        where thread': "r i' = Some (done', todo', skipped')"
+        and send: "Send l' pt' \<in> set done'"
         and msg:  "Some m = inst s i' pt'"
-	and chain:"decrChain [] t {St (i', Send l' pt')} m m'"
-	by auto
+        and chain:"decrChain [] t {St (i', Send l' pt')} m m'"
+        by auto
       then interpret th1: reachable_thread P t r s i' done' todo' skipped'
-	using recv by unfold_locales auto
-      moreover
-      obtain done'' todo'' skipped''
-	where "Send l' pt' \<in> set done''"
-	and "?r' i' = Some (done'', todo'', skipped'')"
-	using `r i = Some (done, Recv l pt # todo, skipped)` thread' send
-	by (cases "i = i'") (fastsimp+)
-      ultimately
-      have "?chain ?t' ?r' s"
-	using chain msg
+        using recv by unfold_locales auto
+        obtain done'' todo'' skipped''
+        where "Send l' pt' \<in> set done''"
+        and "?r' i' = Some (done'', todo'', skipped'')"
+        using `r i = Some (done, Recv l pt # todo, skipped)` thread' send
+        by (cases "i = i'") (fastforce+)
+      hence "?chain ?t' ?r' s"
+        using chain msg
         by (fast intro!: decrChain_append)
       hence "?case" by auto
     } moreover
@@ -1362,27 +1360,25 @@
       and ?r' = "r(i \<mapsto> (done @ [Recv l pt], todo, skipped))"
       assume "?note t r s" then
       obtain i' done' todo' skipped' l' ty' pt' m
-	where thread': "r i' = Some (done', todo', skipped')"
-	and inDone: "Note l' ty' pt' \<in> set done'"
+        where thread': "r i' = Some (done', todo', skipped')"
+        and inDone: "Note l' ty' pt' \<in> set done'"
         and notSkipped: "Note l' ty' pt' \<notin> skipped'"
         and msg: "Some m = inst s i' pt'"
-	and chain: "decrChain [] t {St (i', Note l' ty' pt')} m m'"
+        and chain: "decrChain [] t {St (i', Note l' ty' pt')} m m'"
         by auto
       then interpret th1: reachable_thread P t r s i' done' todo' skipped'
-	using recv by unfold_locales auto
-      moreover
+        using recv by unfold_locales auto
       obtain done'' todo'' skipped''
-	where "Note l' ty' pt' \<in> set done''"
+        where "Note l' ty' pt' \<in> set done''"
         and "Note l' ty' pt' \<notin> skipped'' "
-	and "?r' i' = Some (done'', todo'', skipped'')"
-	using `r i = Some (done, Recv l pt # todo, skipped)` thread' inDone notSkipped
-	by (cases "i = i'") (fastsimp+)
-      ultimately
-      have "?note ?t' ?r' s" using msg chain notSkipped inDone
+        and "?r' i' = Some (done'', todo'', skipped'')"
+        using `r i = Some (done, Recv l pt # todo, skipped)` thread' inDone notSkipped
+        by (cases "i = i'") (fastforce+)
+      hence "?note ?t' ?r' s" using msg chain notSkipped inDone
         by (fast intro!: decrChain_append)
       hence "?case" by auto
     }
-    ultimately show ?case by fastsimp
+    ultimately show ?case by fastforce
   next
     case (send t r s i "done" l pt todo skipped m)
     then interpret th1: 
@@ -1392,23 +1388,23 @@
     let ?t' = "(t @ [Step (i, Send l pt)]) @ [Learns (pairParts m - knows t)]"
     have "m' \<in> knows t \<or> m' \<in> pairParts m \<and> m' \<notin> knows t \<and> Some m = inst s i pt" 
       (is "?old \<or> ?new")
-      using send by fastsimp
+      using send by fastforce
     moreover
     { assume "?new"
       hence "decrChain [] ?t' {St (i, Send l pt)} m m'"
-	by (fastsimp intro!: decrChain_unpair)
+	by (fastforce intro!: decrChain_unpair)
       moreover
       have "?r' i = Some (done @ [Send l pt], todo, skipped)"
 	using th1.thread_exists by auto
       ultimately
       have ?case using `Some m = inst s i pt`
-	apply-
+        apply-
         apply(rule disjI2)
         apply(rule disjI2)
         apply(rule disjI2)
         apply(rule disjI2)
         apply(rule disjI1)
-        apply(fastsimp)
+        apply(fastforce)
 	done
     }
     moreover
@@ -1418,10 +1414,10 @@
 	using send by clarsimp
       moreover
       { assume "?ik0"   hence "?case" by blast    } moreover
-      { assume "?hash"  hence "?case" by fastsimp } moreover
-      { assume "?enc"   hence "?case" by fastsimp } moreover
-      { assume "?keys"  hence "?case" by fastsimp } moreover
-      { assume "?tup"   hence "?case" by fastsimp } moreover
+      { assume "?hash"  hence "?case" by fastforce } moreover
+      { assume "?enc"   hence "?case" by fastforce } moreover
+      { assume "?keys"  hence "?case" by fastforce } moreover
+      { assume "?tup"   hence "?case" by fastforce } moreover
       { assume "?chain t r s" then
 	obtain i' done' todo' l' pt' skipped' m
 	  where thread': "r i' = Some (done', todo',skipped')"
@@ -1433,7 +1429,7 @@
 	  where "Send l' pt' \<in> set done''"
 	  and "(r(i \<mapsto> (done @ [Send l pt], todo, skipped))) i' = Some (done'', todo'',skipped'')"
 	  using `r i = Some (done, Send l pt # todo, skipped)` thread' send
-	  by (cases "i = i'") (fastsimp+)
+	  by (cases "i = i'") (fastforce+)
 	hence "?chain ?t' ?r' s"
 	  using chain msg
           by (fast intro!: decrChain_append)
@@ -1452,7 +1448,7 @@
           and "Note l' ty' pt' \<notin> skipped'' "
 	  and "?r' i' = Some (done'', todo'', skipped'')"
 	  using `r i = Some (done, Send l pt # todo, skipped)` thread' inDone notSkipped
-	  by (cases "i = i'") (fastsimp+)
+	  by (cases "i = i'") (fastforce+)
         hence "?note ?t' ?r' s" using chain notSkipped inDone msg
  	  by(fast intro!: decrChain_append)
         hence "?case" by auto
@@ -1468,7 +1464,7 @@
     note IH = decr(2)
     have "m' \<in> knows t \<or> m' \<in> pairParts m \<and> m' \<notin> knows t" 
       (is "?old \<or> ?new")
-      using decr by fastsimp
+      using decr by fastforce
     moreover
     { assume "?new"
       hence "m' \<in> pairParts m" and "m' \<notin> knows t" by auto
@@ -1499,9 +1495,9 @@
 	moreover
 	hence "decrChain [] ?t' {St (i', Send l' pt')} ms m'"
 	  using `?new` `Enc m k \<in> knows t` `inv k \<in> knows t`
-	  by (fastsimp intro!: decrChain_decrypt)
+	  by (fastforce intro!: decrChain_decrypt)
 	ultimately
-	have "?decchain ?t' m'" by fastsimp
+	have "?decchain ?t' m'" by fastforce
 	hence "?case" by blast
       }
       moreover
@@ -1516,9 +1512,9 @@
 	moreover
 	hence "decrChain [] ?t' {St (i', Note l' ty' pt')} ms m'"
 	  using `?new` `Enc m k \<in> knows t` `inv k \<in> knows t`
-	  by (fastsimp intro!: decrChain_decrypt)
+	  by (fastforce intro!: decrChain_decrypt)
 	ultimately
-	have "?notechain ?t' m'" by fastsimp
+	have "?notechain ?t' m'" by fastforce
 	hence "?case" by blast
       }
       ultimately have ?case by fast
@@ -1536,7 +1532,7 @@
     note IH = lkr(2)
     have "m' \<in> knows t \<or> m' \<in> longTermKeys a \<and> m' \<notin> knows t" 
       (is "?old \<or> ?new")
-    using lkr by fastsimp
+    using lkr by fastforce
     moreover 
     {
       assume "?old"
@@ -1552,16 +1548,16 @@
    case (skip t r s i "done" l ty pt todo skipped)
    then interpret this_thread:  reachable_thread P t r s i "done" "Note l ty pt # todo" skipped  by unfold_locales
    let ?r' = "r(i \<mapsto> (done @ [Note l ty pt], todo, insert (Note l ty pt) skipped))"
-   have "m' \<in> knows t" using skip by fastsimp
+   have "m' \<in> knows t" using skip by fastforce
    hence "?cases m' t r s" 
      (is "?ik0 \<or> ?hash \<or> ?enc \<or> ?tup \<or> ?chain t r s \<or> ?note t r s \<or> ?keys")
      using skip by clarsimp
    moreover
    { assume "?ik0"   hence "?case" by blast    } moreover
-   { assume "?hash"  hence "?case" by fastsimp } moreover
-   { assume "?enc"   hence "?case" by fastsimp } moreover
-   { assume "?keys"  hence "?case" by fastsimp } moreover
-   { assume "?tup"   hence "?case" by fastsimp } moreover
+   { assume "?hash"  hence "?case" by fastforce } moreover
+   { assume "?enc"   hence "?case" by fastforce } moreover
+   { assume "?keys"  hence "?case" by fastforce } moreover
+   { assume "?tup"   hence "?case" by fastforce } moreover
    { assume "?chain t r s" then
      obtain i' done' todo' l' pt' skipped' m
        where thread': "r i' = Some (done', todo',skipped')"
@@ -1573,7 +1569,7 @@
        where "Send l' pt' \<in> set done''"
        and "?r' i' = Some (done'', todo'',skipped'')"
        using skip(3) thread' send
-       by (cases "i = i'") (fastsimp+)
+       by (cases "i = i'") (fastforce+)
      hence "?chain t ?r'  s"
        using chain msg by fast
      hence "?case" by auto
@@ -1598,9 +1594,9 @@
        by fast
      hence "?case" by auto
    } moreover
-   { assume "?keys" hence "?case" by fastsimp }
+   { assume "?keys" hence "?case" by fastforce }
    ultimately  
-   show  "?case" by fastsimp
+   show  "?case" by fastforce
   next
    case(compr t r s i "done" l ty pt todo skipped m m')
    then interpret th1: 
@@ -1610,7 +1606,7 @@
     let ?t' = "(t @ [Step (i, Note l ty pt)]) @ [Learns (pairParts m - knows t)]"
     have "m' \<in> knows t \<or> m' \<in> pairParts m \<and> m' \<notin> knows t \<and> Some m = inst s i pt" 
       (is "?old \<or> ?new")
-      using compr by fastsimp
+      using compr by fastforce
     moreover
     { assume "?new"
   (*
@@ -1618,7 +1614,7 @@
       by auto
 *)
         hence "decrChain [] ?t' {St (i, Note l ty pt)} m m'" 
-          by (fastsimp intro!: decrChain_unpair)
+          by (fastforce intro!: decrChain_unpair)
       moreover
         have "?r' i = Some (done @ [Note l ty pt], todo, skipped)" 
           using th1.thread_exists by auto
@@ -1626,7 +1622,7 @@
         have "Note l ty pt \<in> set (Note l ty pt # todo)" 
           using th1.thread_exists by auto
         hence "Note l ty pt \<notin> skipped" 
-          by (fastsimp dest: th1.todo_notin_skippedD)
+          by (fastforce dest: th1.todo_notin_skippedD)
       ultimately
       have ?case using `Some m = inst s i pt`
 	apply-
@@ -1645,10 +1641,10 @@
 	using compr by clarsimp
       moreover
       { assume "?ik0"   hence "?case" by blast    } moreover
-      { assume "?hash"  hence "?case" by fastsimp } moreover
-      { assume "?enc"   hence "?case" by fastsimp } moreover
-      { assume "?keys"  hence "?case" by fastsimp } moreover
-      { assume "?tup"   hence "?case" by fastsimp } moreover
+      { assume "?hash"  hence "?case" by fastforce } moreover
+      { assume "?enc"   hence "?case" by fastforce } moreover
+      { assume "?keys"  hence "?case" by fastforce } moreover
+      { assume "?tup"   hence "?case" by fastforce } moreover
       { assume "?chain t r s" then
 	obtain i' done' todo' l' pt' skipped' m
 	  where thread': "r i' = Some (done', todo',skipped')"
@@ -1660,7 +1656,7 @@
 	  where "Send l' pt' \<in> set done''"
 	  and "(r(i \<mapsto> (done @ [Note l ty pt], todo, skipped))) i' = Some (done'', todo'',skipped'')"
 	  using compr(3) thread' send
-	  by (cases "i = i'") (fastsimp+)
+	  by (cases "i = i'") (fastforce+)
 	hence "?chain ?t' ?r' s" using chain msg
           by(fast intro!: decrChain_append)
 	hence "?case"  by auto
@@ -1678,7 +1674,7 @@
           and "Note l' ty' pt' \<notin> skipped'' "
 	  and "?r' i' = Some (done'', todo'', skipped'')"
 	  using `r i = Some (done, Note l ty pt # todo, skipped)` thread' inDone notSkipped
-	  by (cases "i = i'") (fastsimp+)
+	  by (cases "i = i'") (fastforce+)
         hence "?note ?t' ?r' s"
           using chain notSkipped inDone msg
           by(fast intro!: decrChain_append)
diff --git a/data/isabelle/src/ESPLogic/HOL_ext.thy b/data/isabelle/src/ESPLogic/HOL_ext.thy
--- a/data/isabelle/src/ESPLogic/HOL_ext.thy
+++ b/data/isabelle/src/ESPLogic/HOL_ext.thy
@@ -17,7 +17,7 @@
 
 lemma dom_upd [simp]: 
   "dom (\<lambda> a. if a = x then Some y else m a) = insert x (dom m)"
-  by(fastsimp simp: dom_if)
+  by(fastforce simp: dom_if)
 
 lemma map_leD: "\<lbrakk> m \<subseteq>\<^sub>m m'; m x = Some y \<rbrakk> \<Longrightarrow> m' x = Some y"
   by(force simp: map_le_def)
@@ -112,7 +112,7 @@
 *)
 fun forall_permute ctxt p ct =
   let
-    val cert = Thm.cterm_of (ProofContext.theory_of ctxt);
+    val cert = Thm.cterm_of (Proof_Context.theory_of ctxt);
     fun mk_cv (_, ty) n = cert (Free (n, ty));
     val string_of_perm = commas o map string_of_int;
     fun err msg = raise CTERM
@@ -213,7 +213,7 @@
 *)
 fun track_HOL_term ctxt x_t =
   let
-    val thy  = ProofContext.theory_of ctxt;
+    val thy  = Proof_Context.theory_of ctxt;
     val cert = Thm.cterm_of thy;
 
     val x_ty = Term.fastype_of x_t; 
@@ -226,7 +226,7 @@
     val Qx_ct   = cert (HOLogic.mk_Trueprop (Q_t $ x_t));
     val eq_x_ct = cert 
       (Abs ("y", x_ty, 
-            Const (@{const_name "op ="}, x_ty --> x_ty --> HOLogic.boolT)
+            Const (@{const_name "HOL.eq"}, x_ty --> x_ty --> HOLogic.boolT)
             $ x_t $ Bound 0));
 
     fun remove_tracking th' =
diff --git a/data/isabelle/src/ESPLogic/Hints.thy b/data/isabelle/src/ESPLogic/Hints.thy
--- a/data/isabelle/src/ESPLogic/Hints.thy
+++ b/data/isabelle/src/ESPLogic/Hints.thy
@@ -13,10 +13,10 @@
 theory Hints
 imports
   Main
-uses
-  espl_utils
 begin
 
+ML_file "espl_utils.ML"
+
 section{* A Theory of Hints for Marking Intermediate Results *}
 
 
@@ -90,3 +90,4 @@
 *}
 
 end
+
diff --git a/data/isabelle/src/ESPLogic/InferenceRules.thy b/data/isabelle/src/ESPLogic/InferenceRules.thy
--- a/data/isabelle/src/ESPLogic/InferenceRules.thy
+++ b/data/isabelle/src/ESPLogic/InferenceRules.thy
@@ -94,12 +94,12 @@
 proof -
   interpret reachable_thread P t r s i "done" "step#todo" skipped
     using facts by unfold_locales auto
-  hence "step \<in> set (step # todo)" by auto
-  hence "step \<notin> set done" using facts by (fastsimp dest!: todo_notin_doneD)
+  have "step \<in> set (step # todo)" by auto
+  hence "step \<notin> set done" using facts by (fastforce dest!: todo_notin_doneD)
   hence "(takeWhile (\<lambda> x. x \<noteq> step) done) = done" by auto
   hence "(takeWhile (\<lambda> x. x \<noteq> step) (done @ (step # todo))) = done" by auto
   moreover
-  have "R = (done @ (step # todo))" using facts by (fastsimp dest: roleMap_SomeD)
+  have "R = (done @ (step # todo))" using facts by (fastforce dest: roleMap_SomeD)
   ultimately show ?thesis by auto
 qed
 
@@ -138,10 +138,10 @@
   shows
     "(st \<in> set done \<and> st \<noteq> (Note l ty pt)) \<or> (st = step)"
 proof -
-  have "(st \<in> set R \<and> st \<noteq> (Note l ty pt)) \<or> (st = step)" using filtered by (fastsimp dest: filtered_role_conv)
+  have "(st \<in> set R \<and> st \<noteq> (Note l ty pt)) \<or> (st = step)" using filtered by (fastforce dest: filtered_role_conv)
   moreover
-  have "(takeWhile (\<lambda> x. x \<noteq> step) R) = done" using isThread by (fastsimp dest: take_while_is_done)
-  ultimately show ?thesis using isThread and filtered by fastsimp
+  have "(takeWhile (\<lambda> x. x \<noteq> step) R) = done" using isThread by (fastforce dest: take_while_is_done)
+  ultimately show ?thesis using isThread and filtered by fastforce
 qed
 
 lemma filtered_in_done:
@@ -153,7 +153,7 @@
   interpret this_thread:
     reachable_thread P t r s i "done" todo skipped
     using role_exists by unfold_locales auto
-  hence "step \<in> set done"
+  have "step \<in> set done"
     using step by (auto dest: this_thread.in_steps_in_done)
   moreover
   then obtain prefix suffix 
@@ -167,7 +167,7 @@
     assume "st \<noteq> step \<and> takeWhile (\<lambda>x. x \<noteq> step) R = prefix"
     hence "st \<in> set prefix" using inFiltered 
       by auto
-    hence ?thesis using done_split by fastsimp
+    hence ?thesis using done_split by fastforce
   }
   moreover {
     assume "st = step \<and> step \<in> set done"
@@ -236,7 +236,7 @@
     \<lbrakk> nextRel (filter (\<lambda> x. \<not> (noteStep x)) (takeWhile (\<lambda> x. x \<noteq> step) R) @ [step]) st st'
     \<rbrakk> \<Longrightarrow> St (i, st) \<prec> St (i, st')"
   shows "prefixClose s t R step i"
-using prems by (auto simp: prefixClose_def)
+using assms by (auto simp: prefixClose_def)
 
 lemma prefixCloseI:
   assumes step: "(i, step) \<in> steps t"
@@ -276,13 +276,13 @@
       apply -
       apply(rule conjI, assumption)
       apply(case_tac "st = step")
-        apply(fastsimp dest: this_thread.in_steps_conv_done_skipped[THEN iffD1])
-      apply(fastsimp dest!: this_thread.note_in_skipped note_filtered_revRole)
+        apply(fastforce dest: this_thread.in_steps_conv_done_skipped[THEN iffD1])
+      apply(fastforce dest!: this_thread.note_in_skipped note_filtered_revRole)
 
       apply(rule conjI, assumption)
       apply(case_tac "st' = step")
-        apply(fastsimp dest: this_thread.in_steps_conv_done_skipped[THEN iffD1])
-      by(fastsimp dest!: this_thread.note_in_skipped note_filtered_revRole)
+        apply(fastforce dest: this_thread.in_steps_conv_done_skipped[THEN iffD1])
+      by(fastforce dest!: this_thread.note_in_skipped note_filtered_revRole)
     hence steps: "(i, st) \<in> steps t" "(i, st') \<in> steps t"
       by(auto dest: this_thread.in_steps_conv_done_skipped[THEN iffD1])
     { assume "recvStep st" then
@@ -294,12 +294,12 @@
 
     have "listOrd R st st'" 
       using nextRel and R_split and done_split
-      by(fastsimp dest: nextRel_imp_listOrd listOrd_rev[THEN iffD1] listOrd_filter)
+      by(fastforce dest: nextRel_imp_listOrd listOrd_rev[THEN iffD1] listOrd_filter)
     hence "St (i, st) \<prec> St (i, st')"
       using role_exists steps R_split
       apply -
       apply(drule this_thread.in_steps_conv_done_skipped[THEN iffD1])
-      by(fastsimp dest!: this_thread.roleOrd_notSkipped_imp_listOrd_trace dest:listOrd_imp_predOrd)+
+      by(fastforce dest!: this_thread.roleOrd_notSkipped_imp_listOrd_trace dest:listOrd_imp_predOrd)+
     note input and this
   }
   ultimately show ?thesis
@@ -312,7 +312,7 @@
   "\<lbrakk> (i, step) \<in> steps t; roleMap r i = Some R \<rbrakk> \<Longrightarrow>
    prefixClose s t R step i \<and> 
    (recvStep step \<longrightarrow> (\<exists> m. Some m = inst s i (stepPat step) \<and> Ln m \<prec> St (i, step)))"
-  by (cases step) (fastsimp intro!: prefixCloseI Ln_before_inp)+
+  by (cases step) (fastforce intro!: prefixCloseI Ln_before_inp)+
 
 text{* 
   Used for prefix closing assumptions corresponding to a case of
@@ -343,14 +343,14 @@
       proof
         obtain l pt
           where recv_eq: "(Recv l pt) = (last (step # done))"
-          using recv by (fastsimp dest!: recvStepD)
+          using recv by (fastforce dest!: recvStepD)
         hence "Recv l pt \<in> set (step # done)" by auto
         thus ?thesis
           using thread_exists recv_eq
-          by(fastsimp dest!: this_thread.in_steps_recv[THEN iffD1])
+          by(fastforce dest!: this_thread.in_steps_recv[THEN iffD1])
         qed
     hence "?inp_last"
-      by (cases "last (step # done)") (fastsimp dest!: Ln_before_inp)+
+      by (cases "last (step # done)") (fastforce dest!: Ln_before_inp)+
   }
   moreover
   { 
@@ -361,7 +361,7 @@
     hence skipped: "st \<notin> skipped \<and> st' \<notin> skipped"
       proof(cases "st = step \<and> st' \<in> set done \<and> \<not> noteStep st'")
         case True
-        thus "?thesis" using listOrd not_skipped by (fastsimp dest: this_thread.note_in_skipped)
+        thus "?thesis" using listOrd not_skipped by (fastforce dest: this_thread.note_in_skipped)
       next
         case False
         note falseAsms = this
@@ -382,7 +382,7 @@
               assumption)
         apply(drule_tac ?Q = "listOrd done st st'" and ?P = "st = step \<and> st' \<in> set done" in disjI1)
         apply(drule listOrd.simps(2)[THEN iffD2])
-        by(fastsimp dest: listOrd_imp_predOrd this_thread.listOrd_done_imp_listOrd_trace)
+        by(fastforce dest: listOrd_imp_predOrd this_thread.listOrd_done_imp_listOrd_trace)
     next
       case False
       note assms = this
@@ -397,7 +397,7 @@
            apply(drule listOrd_filter)
            apply(drule_tac ?Q = "listOrd done st st'" and ?P = "st = step \<and> st' \<in> set done" in disjI2)
            apply(drule listOrd.simps(2)[THEN iffD2])
-           by (fastsimp dest: listOrd_imp_predOrd this_thread.listOrd_done_imp_listOrd_trace)
+           by (fastforce dest: listOrd_imp_predOrd this_thread.listOrd_done_imp_listOrd_trace)
       qed
     qed
     hence recv: "recvStep st \<Longrightarrow> 
@@ -432,22 +432,22 @@
   case (send t r s i "done" l pt todo m y)
   then interpret this_state: reachable_state P t r s by unfold_locales
   show ?case using send
-    by(fastsimp dest: this_state.knows_IK0)
+    by(fastforce dest: this_state.knows_IK0)
 next
   case (decr t r s m k y)
   then interpret this_state: reachable_state P t r s by unfold_locales
   show ?case using decr
-    by(fastsimp dest: this_state.knows_IK0)
+    by(fastforce dest: this_state.knows_IK0)
 next 
   case (lkr t r s a)
   then interpret this_state: reachable_state P t r s by unfold_locales
   show ?case using lkr
-    by(fastsimp dest: this_state.knows_IK0)
+    by(fastforce dest: this_state.knows_IK0)
 next 
   case (compr t r s "done" l ty pt todo skipped m y)
   then interpret this_state: reachable_state P t r s by unfold_locales
   show ?case using compr
-    by(fastsimp dest: this_state.knows_IK0)
+    by(fastforce dest: this_state.knows_IK0)
 qed auto
 
 lemmas nothing_before_IK0_iffs [iff] = in_IK0_simps[THEN nothing_before_IK0]
@@ -485,11 +485,11 @@
   and     conc_inj: "\<And> i1 i2 j. \<lbrakk> conc i1 j \<and> conc i2 j \<rbrakk> \<Longrightarrow> i1 = i2"
   shows "let prems = prem; 
              concs = conc
-         in \<exists>f. inj_on f prems \<and> (\<forall>i. prems i \<longrightarrow> concs i (f i))"
+         in \<exists>f. inj_on f (Collect prems) \<and> (\<forall>i. prems i \<longrightarrow> concs i (f i))"
 proof -
   let ?f = "\<lambda> i. SOME j. conc i j"
-  have "inj_on ?f prem"
-    apply(auto simp: inj_on_def mem_def dest!: niagree)
+  have "inj_on ?f (Collect prem)"
+    apply(auto simp: inj_on_def dest!: niagree)
     apply(rule_tac j="(SOME j. conc x j)" in conc_inj[OF conjI])
     apply(rule someI, simp+)+
     done
diff --git a/data/isabelle/src/ESPLogic/Protocol.thy b/data/isabelle/src/ESPLogic/Protocol.thy
--- a/data/isabelle/src/ESPLogic/Protocol.thy
+++ b/data/isabelle/src/ESPLogic/Protocol.thy
@@ -21,7 +21,7 @@
 
 subsubsection{* Patterns *}
 
-types id = string
+type_synonym id = string
 
 datatype varid = AVar id | MVar id
 
@@ -108,7 +108,7 @@
   They are currently defaulted to strings, but could be anything.
 *}
 
-types lbl = string
+type_synonym lbl = string
 
 datatype notetype = RandGen | State | SessKey
 
@@ -161,7 +161,7 @@
 qed auto
 
 
-types "role" = "rolestep list"
+type_synonym "role" = "rolestep list"
 
 fun recv_before :: "id set \<Rightarrow> role \<Rightarrow> bool"
 where
@@ -181,7 +181,7 @@
   
 subsubsection{* Protocols *}
 
-types proto = "role set"
+type_synonym proto = "role set"
 
 locale wf_proto =
   fixes P :: proto
@@ -242,7 +242,7 @@
   moreover have "distinct R" and "recv_before {} R" by auto
   ultimately obtain lbl' pt' where "Recv lbl' pt' \<in> set ys" 
                                 and "v \<in> FMV pt'"
-             by (fastsimp dest!: recv_before_sent_distinct_Send_FV intro!: FV)
+             by (fastforce dest!: recv_before_sent_distinct_Send_FV intro!: FV)
   hence "?received lbl' pt'" using split by auto
   thus ?thesis by blast
 qed
@@ -262,7 +262,7 @@
   moreover have "distinct R" and "recv_before {} R" by auto
   ultimately obtain lbl' pt' where "Recv lbl' pt' \<in> set ys" 
                                 and "v \<in> FMV pt'"
-             by (fastsimp dest!: recv_before_note_distinct_Note_FV intro!: FV)
+             by (fastforce dest!: recv_before_note_distinct_Note_FV intro!: FV)
   hence "?received lbl' pt'" using split by auto
   thus ?thesis by blast
 qed
@@ -291,7 +291,7 @@
 
 lemma aVars_singleton[iff]:
   "AVar a \<notin> aVars []"
-by(fastsimp simp add: aVars_def)
+by(fastforce simp add: aVars_def)
 
 lemma aVars_Nil [iff]: "aVars [] = {}"
   by (auto simp: aVars_def)
@@ -301,7 +301,7 @@
 
 lemma aVars_FAV_conv:
   "(AVar a \<in> aVars R) = (\<exists> s \<in> set R. \<exists> pt. (stepPat s = pt \<and> a \<in> FAV pt))"
-by (induct R rule: foldr.induct) ( fastsimp simp add: aVars_def)+
+by (induct R) ( fastforce simp add: aVars_def)+
 
 
 definition lastComStep :: "role \<rightharpoonup> rolestep"
@@ -334,7 +334,7 @@
         s
   )"
 proof (cases "[s\<leftarrow>xs . \<not> noteStep s]")
-qed (fastsimp simp add: lastComStep_def)+
+qed (fastforce simp add: lastComStep_def)+
 
 lemma firstComStep_Nil [iff]: "firstComStep [] = None"
   by (auto simp: firstComStep_def)
@@ -346,7 +346,7 @@
       Some x
   )"
 proof (cases "[s\<leftarrow>xs . \<not> noteStep s]")
-qed (fastsimp simp add: firstComStep_def)+ 
+qed (fastforce simp add: firstComStep_def)+ 
 
 
 
diff --git a/data/isabelle/src/ESPLogic/Syntax.thy b/data/isabelle/src/ESPLogic/Syntax.thy
--- a/data/isabelle/src/ESPLogic/Syntax.thy
+++ b/data/isabelle/src/ESPLogic/Syntax.thy
@@ -62,7 +62,7 @@
 
 translations
   "<|x, y, z|>"   == "<|x, <|y, z|> |>"
-  "<|x, y|>"      == "PTup x y"
+  "<|x, y|>"      == "CONST PTup x y"
 
 
 subsubsection{* Execution Messages *}
diff --git a/data/isabelle/src/ESPLogic/Unify.thy b/data/isabelle/src/ESPLogic/Unify.thy
--- a/data/isabelle/src/ESPLogic/Unify.thy
+++ b/data/isabelle/src/ESPLogic/Unify.thy
@@ -19,7 +19,9 @@
      espl_methods.ML. With a uses clause it would be
      loaded twice, which may result in strange effects.
   *)
-  Automation  
+  Automation
+keywords
+  "note_prefix_closed" "note_unified" "note_cyclic" :: prf_decl
 begin
 
 section{* Explicit unification of sets of equality theorems *}
@@ -137,14 +139,14 @@
 
   in (prod_ord bool_ord 
                 (prod_ord bool_ord 
-                  (prod_ord bool_ord TermOrd.term_ord)))
+                  (prod_ord bool_ord Term_Ord.term_ord)))
      (proj lhs, proj rhs) 
   end
 
 fun old_unify_term_ord (arg as (lhs,rhs)) = 
   if (is_variable_store_lookup lhs) then 
     if (is_variable_store_lookup rhs) then
-      TermOrd.term_ord arg
+      Term_Ord.term_ord arg
     else
       LESS
   else
@@ -153,38 +155,21 @@
     else
       if (is_roleMap lhs) then
         if (is_roleMap rhs) then
-          TermOrd.term_ord arg
+          Term_Ord.term_ord arg
         else
           LESS
       else
         if (is_roleMap rhs) then
           GREATER
         else
-          TermOrd.term_ord arg;
+          Term_Ord.term_ord arg;
           
 *}
 
-(*
-context reachable_state begin
-
 ML{*
 
-fun both t = (unify_term_ord t, old_unify_term_ord t);
-
-both (@{term "s (MV a b)"}, @{term "LN x i"});
-both (@{term "s (MV a b)"}, @{term "s (MV c d)"});
-both (swap (@{term "s (MV a b)"}, @{term "s (AV c d)"}));
-both (@{term "roleMap r i"}, @{term "Some R"});
-both (swap (@{term "roleMap r i"}, @{term "Some R"}));
-  
-
-*}
-*)
-
-ML{*
-
 structure UnifyDest = Named_Thms
-  (val name ="unify_dest"
+  (val name = @{binding "unify_dest"}
    val description = "Destruction rules to be used in note_unified")
 
 *}
@@ -218,7 +203,7 @@
 fun unify do_occurs_check ctxt ths =
   let
     (* TODO: Remove hack by using Named_Thms data functor. *)
-    val thm_by_name = ProofContext.get_thm ctxt;
+    val thm_by_name = Proof_Context.get_thm ctxt;
     val ss = simpset_of ctxt 
       delsimps map thm_by_name ["tid_eq_commute", "reorient_store_eq_store"];
 
@@ -252,12 +237,12 @@
             (case remove_Trueprop (Thm.concl_of th) of
                (@{const True})           => solve1 (done, todo)
              | (@{const False})          => [th]
-             | (@{const "op &"} $ _ $ _) =>
+             | (@{const "HOL.conj"} $ _ $ _) =>
                  solve1 ( done 
                         , (th RS @{thm conjunct1}) ::
                           (th RS @{thm conjunct2}) :: todo
                         )
-             | (Const (@{const_name "op ="},_) $ _ $ _) => 
+             | (Const (@{const_name "HOL.eq"},_) $ _ $ _) => 
                  (case reorient_HOL_eq unify_term_ord th of
                     NONE     => solve1 (done, todo)
                   | SOME th' =>
@@ -306,7 +291,7 @@
 
     fun modify_bound_thms ctxt b =
       let
-        val ths  = ProofContext.get_thms ctxt (ProofContext.full_name ctxt b);
+        val ths  = Proof_Context.get_thms ctxt (Proof_Context.full_name ctxt b);
       in
         ((b,[]), [(f ctxt ths,[])])
       end;
@@ -315,338 +300,41 @@
       state
       |> map_context_result 
           (fn ctxt => ctxt |>
-            (ProofContext.note_thmss "" 
+            (Proof_Context.note_thmss "" 
               (map (modify_bound_thms ctxt) bindings))
           )
       |> (fn (named_thss, state') =>
            state'
-           |> Proof.put_facts (SOME (maps snd named_thss))
+           |> Proof.set_facts (maps snd named_thss)
          )
   in
-    modify_and_renote o Proof.note_thmss args
+    modify_and_renote o Proof.note_thmss_cmd args
   end
-
 *}
 
 ML{*
 local
-  structure K = OuterKeyword;
-  structure T = Toplevel;
-
   fun define_cmd name info f =
-    OuterSyntax.command name info (K.tag_proof K.prf_decl)
-    (SpecParse.name_facts >> (T.print oo (T.proof o (note_modified_thmss f))));
+    Outer_Syntax.command name info
+    (Parse_Spec.name_facts >> (Toplevel.print oo (Toplevel.proof o (note_modified_thmss f))));
 in
   val _ = 
-    define_cmd "note_prefix_closed" 
+    define_cmd @{command_spec "note_prefix_closed"} 
       "prefix close facts and store them under the given name"
       ESPL_Methods.prefix_close_thms;
 
   val _ = 
-    define_cmd "note_unified" 
+    define_cmd @{command_spec "note_unified"}
       "unify equality facts and store them under the given name"
       (unify true);
 
   (* TODO: Implement this command - currently it is just notes. *)
   val _ = 
-    define_cmd "note_cyclic" 
+    define_cmd @{command_spec "note_cyclic"}
       "try to derive a cyclicity violation from the given facts and store them under the given name"
       (K I);
 
 end
 *}
-
-
-(*
-
-lemma (in reachable_state) test : "X"
-proof -
-  fix tid\<^isub>1 tid\<^isub>2 tid\<^isub>3
-  assume "s (MV ''ni'' tid\<^isub>1) = LN ''ni'' tid\<^isub>3"
-  and"s (MV ''ni'' tid\<^isub>1) = LN ''ni'' tid\<^isub>2"
-ML_prf{*
-  unify true @{context} @{thms this}
-  handle THM (_,_,ths) => ths
-
-*}
-  note_unified facts = this
-
-lemma
-
-*)
-
-(*
-
-ML{* @{const predOrd} *}
-ML{* @{term "predOrd t (Ln \<lbrace>LN ''ni'' i, x\<rbrace>) (Ln y)"} *}
-ML{*
-
-case @{term "predOrd t (Ln \<lbrace>LN ''ni'' i, x\<rbrace>) (Ln y)"} of
-    (@{const predOrd} $ _ $ (@{const Ln} $ (Const (@{const_name Tup},_) $ _ $ _)) $ _) =>
-       Const ("YES 1", TFree ("blah",["blih"]))
-  | (Const (@{const_name predOrd}, _) $ _ $ _ $ _ ) =>
-       Const ("YES 2", TFree ("blah",["blih"]))
-  | (x $ _ $ _ $ _ ) =>
-       x
-  | _ => Const ("no", TFree ("blah",["blih"]))
-
-*}
-
-lemma test: 
-  assumes facts:
-    "Enc x y = Enc t v"
-    "x = v"
-  shows "False"
-proof -
-  note_unified this = facts
-  thm this
-oops
-
-
-text{* Testing the role definition command *}
-role nslXInit
-where "nslXInit \<equiv> 
-  [ Send ''0'' (PEnc \<langle>sC ''0'', sAV ''I'', sN ''ni''\<rangle> (sPK ''R''))
-  , Recv ''1'' (PEnc \<langle>sC ''1'', sAV ''R'', sN ''ni'', sMV ''nr''\<rangle> (sPK ''I''))
-  , Send ''2'' (PEnc \<langle>sC ''2'', sMV ''nr''\<rangle> (sPK ''R''))
-  ]"
-
-text{* An additional role for testing purposes. *}
-role nslXResp
-where "nslXResp \<equiv>
-  [ Recv ''0'' (PEnc \<langle>sC ''0'', sLAV ''I'', sLMV ''ni''\<rangle> (sPK ''R''))
-  , Send ''1'' (PEnc \<langle>sC ''1'', sLAV ''R'', sLMV ''ni'', sLN ''nr''\<rangle> (sPK ''I''))
-  , Recv ''2'' (PEnc \<langle>sC ''2'', sLN ''nr''\<rangle> (sPK ''R''))
-  ]"
-
-protocol nslX
-where "nslX = {nslXInit, nslXResp}"
-
-locale atomic_nslX_state = typed_state nslX _ _ _ "weakly_atomic"
-
-lemma (in atomic_nslX_state) SK_from_IK0:
-  assumes facts:
-    "SK a \<in> knows t"
-  shows "a \<in> Compromised"
-using facts
-proof(sources "SK a")
-qed clarsimp
-
-lemma (in atomic_nslX_state) I_sec_ni:
-  assumes facts:
-    "roleMap r i = Some nslXInit"
-    "Ln (Tup (LN ''ni'' i) x) \<prec> Ln y"
-    "s(AV ''I'' i) \<notin> Compromised"
-    "s(AV ''R'' i) \<notin> Compromised"   
-  shows "False"
-using facts
-proof(sources! "LN ''ni'' i")
-  case nslXInit_0_ni
-  note_unified facts = facts this
-thm split_before[OF `Ln \<lbrace>LN ''ni'' i, x\<rbrace> \<prec> Ln y`]
-ML_prf{*
-@{term "Ln \<lbrace>LN ''ni'' i, x\<rbrace> \<prec> Ln y"}
-*}
-  thus ?thesis
-  proof(sources! "SK (s (AV ''R'' i))")
-    case ik0
-    note_unified facts = facts this
-    thus ?thesis by clarsimp
-  qed
-next
-  case (nslXInit_2_nr i1)
-  note_unified facts = facts this
-  thus ?thesis
-  proof(sources! "inst s i1 nslXInit_1_pt")
-    case fake
-    note_unified facts = facts this
-    thus ?thesis by order
-  next
-    case (nslXResp_1_enc r1)
-    note_unified facts = facts this
-    thus ?thesis .
-  qed
-next
-  case (nslXResp_1_ni r1)
-  note_unified facts = facts this
-  thus ?thesis
-  proof(sources "inst s r1 nslXResp_0_pt")
-    case fake
-    note_unified facts = facts this
-    thus ?thesis by order
-  next
-    case (nslXInit_0_enc i2)
-    note_unified facts = facts this
-    thus ?thesis
-    proof(sources! "SK (s (AV ''I'' i))")
-      case ik0
-      note_unified facts = facts this
-      thus ?thesis by clarsimp
-    qed
-  qed
-qed
-
-
-
-
-
-(* OLD TEST INFRASTRUCTURE
-
-
-ML{*
-
-val th1 = Thm.assume @{cterm "Trueprop (s (AV ''a'' i) = x)"};
-val th2 = Thm.assume @{cterm "Trueprop (PK (s (AV ''a'' i)) = inv (y))"};
-val th3 = Thm.assume @{cterm "Trueprop (Enc (LN ''a'' i) (PK (s (AV ''a'' j))) = 
-                                        Enc (LN ''a'' j) (PK (s (AV ''b'' i))))"};
-val th4 = Thm.assume @{cterm "Trueprop ((b::nat) < c)"};
-val th5 = Thm.assume @{cterm "Trueprop ((x::execmsg) = Enc (Tup y (PK x)) z)"};
-
-
-*}
-
-
-ML{*
-
-unify true @{context} [th1,th2,th3,th5,th1,th2,th3,th5,th1,th2,th3,th5,th1,th2,th3,th5]
-
-*}
-
-subsection{* Redefining the notes command *}
-
-text{*
-  note[prefix_closed] this = facts
-  note[unified] this = facts
-
-^ preferred version
-
-  note this[unified] = facts
-
-*}
-
-ML{*
-
-Proof.note_thmss
-*}
-
-ML{* 
-
-ProofContext.note_thmss
-*}
-
-note_prefix_closed
-note_unified
-note_cyclic
-
-ML{*
-
-local 
-  structure P = OuterParse;
-  structure S = SpecParse;
-
-  fun bling ctxt =
-    let val _ = Output.warning "test";
-    in ctxt end;
-
-  fun modifier (name, f) = P.$$$ name >> K f;
-  val modifiers = [("test", (K bling)),("unified",unify true)];
-in
-  val thms_mod = Scan.first (map modifier modifiers @ [Scan.succeed (K I)]);
-  val mod_name_facts = thms_mod -- S.name_facts
-end
-*}
- 
-
-
-lemma test: "blah"
-proof -
-  note_prefix_closed unified = sym allI
-    and blah = ballI
-  thm this
-  thm blah
-  thm unified
-  
-
-
-
-
-
-*)
-
-role C
-where "C =
-  [ Send ''1'' ( PEnc ( sN ''k'' ) ( sPK ''S'' ) )
-  , Recv ''2'' ( PHash ( sN ''k'' ) )             
-  ]"                                              
-
-role S
-where "S =
-  [ Recv ''1'' ( PEnc ( sMV ''k'' ) ( sPK ''S'' ) )
-  , Send ''2'' ( PHash ( sMV ''k'' ) )             
-  ]"                                               
-
-protocol CR
-where "CR = { C, S }"
-
-locale atomic_CR_state = atomic_state CR
-locale CR_state = reachable_state CR
-
-lemma (in atomic_CR_state) C_secret_k:
-  assumes facts:
-    "roleMap r i\<^isub>0 = Some C"
-    "s(AV ''S'' i\<^isub>0) \<notin> Compromised"
-    "LN ''k'' i\<^isub>0 \<in> knows t"
-  shows "False"
-using facts proof(sources! " LN ''k'' i\<^isub>0 ")
-  case C_1_k note_unified facts = this facts
-  thus ?thesis proof(sources! " SK ( s(AV ''S'' i\<^isub>0) ) ")
-  qed (insert facts, ((clarsimp, order?))+)?
-qed
-
-lemma (in CR_state) weak_atomicity:
-  "complete (t,r,s) atomicAnn"
-proof (cases rule: complete_atomicAnnI[completeness_cases_rule])
-  case (S_1_k t r s i\<^isub>0) note facts = this
-  then interpret state: atomic_state CR t r s
-    by unfold_locales assumption+
-  show ?case using facts
-  proof(sources! "
-      Enc ( s(MV ''k'' i\<^isub>0) ) ( PK ( s(AV ''S'' i\<^isub>0) ) ) ")
-  qed (insert facts, ((fastsimp simp: atomicAnn_def dest: state.extract_knows_hyps))+)?
-qed
-
-lemma (in atomic_CR_state) C_ni_synch:
-  assumes facts:
-    "roleMap r i\<^isub>1 = Some C"
-    "s(AV ''S'' i\<^isub>1) \<notin> Compromised"
-    "(i\<^isub>1, C_2) \<in> steps t"
-  shows
-    "\<exists>i\<^isub>2.
-       roleMap r i\<^isub>2 = Some S &
-       s(AV ''S'' i\<^isub>2) = s(AV ''S'' i\<^isub>1) &
-       s(MV ''k'' i\<^isub>2) = LN ''k'' i\<^isub>1 &
-       St(i\<^isub>1, C_1) \<prec> St(i\<^isub>1, C_2) &
-       St(i\<^isub>1, C_1) \<prec> St(i\<^isub>2, S_1) &
-       St(i\<^isub>2, S_2) \<prec> St(i\<^isub>1, C_2) &
-       St(i\<^isub>2, S_1) \<prec> St(i\<^isub>2, S_2)"
-proof -
-  note_prefix_closed facts = facts
-  thus ?thesis proof(sources! " Hash ( LN ''k'' i\<^isub>1 ) ")
-    case fake note_unified facts = this facts
-    thus ?thesis by (fastsimp dest: C_secret_k intro: event_predOrdI)
-  next
-    case (S_2_hash i\<^isub>2) note_unified facts = this facts
-    thus ?thesis proof(sources! "
-                     Enc ( LN ''k'' i\<^isub>1 ) ( PK ( s(AV ''S'' i\<^isub>2) ) ) ")
-      case fake note_unified facts = this facts
-      thus ?thesis by (fastsimp dest: C_secret_k intro: event_predOrdI)
-    next
-      case C_1_enc note_unified facts = this facts
-      thus ?thesis by force
-    qed
-  qed
-qed
-
-*)
 
 end
diff --git a/data/isabelle/src/ESPLogic/WeakTyping.thy b/data/isabelle/src/ESPLogic/WeakTyping.thy
--- a/data/isabelle/src/ESPLogic/WeakTyping.thy
+++ b/data/isabelle/src/ESPLogic/WeakTyping.thy
@@ -35,17 +35,17 @@
   to their type.
 *}
 
-types msgtype = "tid \<Rightarrow> state \<Rightarrow> execmsg set"
+type_synonym msgtype = "tid \<Rightarrow> state \<Rightarrow> execmsg set"
 
-types typing = "(role \<times> id) \<Rightarrow> msgtype"
+type_synonym typing = "(role \<times> id) \<Rightarrow> msgtype"
 
 definition approx :: "typing \<Rightarrow> state set"
-where "approx typing q \<equiv> case q of (t,r,s) \<Rightarrow>
+where "approx typing \<equiv> {q. case q of (t,r,s) \<Rightarrow>
   \<forall> (i,step) \<in> steps t. 
     \<forall> R. roleMap r i = Some R \<longrightarrow>
       (\<forall> n. MVar n \<in> FV (stepPat step) \<longrightarrow>
          s (MVar n, i) \<in> typing (R, n) i (t,r,s)
-      )"
+      )}"
 
 locale typed_state = reachable_state+
   fixes typing :: "typing"
@@ -65,7 +65,7 @@
       \<forall> R. roleMap r i = Some R \<longrightarrow>
         (\<forall> n. MVar n \<in> FV (stepPat step) \<longrightarrow>
            s (MVar n, i) \<in> typing (R, n) i (t,r,s)))"
-by (auto simp: approx_def mem_def)
+by (auto simp: approx_def)
 
 lemma in_approxI:
   assumes all_vars:
@@ -299,7 +299,7 @@
         then obtain l' msg' 
           where "(i, Recv l' msg') \<in> steps t" 
                 "MVar n \<in> FV msg'"
-          by (fastsimp dest!: th1.send_step_FV[OF th1.thread_exists])
+          by (fastforce dest!: th1.send_step_FV[OF th1.thread_exists])
         hence typed: "s (MV n i) \<in> typing (?role, n) i (t, r, s)"
           by (auto dest: IH[OF th1.thread_exists])
         have "done'@todo' = ?role"
@@ -388,9 +388,9 @@
               apply -
               apply(drule listOrd_append[THEN iffD1])
               apply(case_tac "listOrd done (Recv l'' pt'') (Note l' ty' pt')")
-                apply(fastsimp dest: in_set_listOrd1)
+                apply(fastforce dest: in_set_listOrd1)
               apply(case_tac "listOrd (Recv l pt # todo) (Recv l'' pt'') (Note l' ty' pt')")
-                apply(fastsimp dest: in_set_listOrd2 th1.done_notin_todoD)
+                apply(fastforce dest: in_set_listOrd2 th1.done_notin_todoD)
               apply(case_tac "Recv l'' pt'' \<in> set done \<and> Note l' ty' pt' \<in> set (Recv l pt # todo)")
               by(auto dest: th1.done_notin_todoD)
             hence "(i, Recv l'' pt'') \<in> steps t" by auto
@@ -424,7 +424,7 @@
               done
          qed
       }
-      ultimately show ?case by fastsimp
+      ultimately show ?case by fastforce
     next
       case (compr t r s i "done" l ty pt todo skipped m i' done' todo' step n skipped')
       then interpret th1: 
@@ -450,7 +450,7 @@
         then obtain l' msg' 
           where "(i, Recv l' msg') \<in> steps t" 
                 "MVar n \<in> FV msg'"
-          by (fastsimp dest!: th1.note_step_FV[OF th1.thread_exists])
+          by (fastforce dest!: th1.note_step_FV[OF th1.thread_exists])
         hence typed: "s (MV n i) \<in> typing (?role, n) i (t, r, s)"
           by (auto dest: IH[OF th1.thread_exists])
         have "done'@todo' = ?role"
@@ -974,7 +974,7 @@
     then interpret th1: typed_thread P t r s i "done" todo skipped "typing"
       using approximates by unfold_locales
     from inDone and notinSkipped have note_step: "(i, Note l ty pt) \<in> steps t" 
-      by (fastsimp dest!: th1.in_steps_eq_in_done)
+      by (fastforce dest!: th1.in_steps_eq_in_done)
     moreover
     have "prefixClose s t (done@todo) (Note l ty pt) i" using note_step
       by(auto intro!: prefixCloseI th1.roleMap)
@@ -994,7 +994,7 @@
     hence ?thesis by blast 
   }
   ultimately
-  show ?thesis by fastsimp
+  show ?thesis by fastforce
 qed
 
 
@@ -1025,9 +1025,9 @@
     apply(erule disjE)
     apply(clarsimp)
     apply(rule disjI2)
-    apply(fastsimp intro: less_le_trans)
+    apply(fastforce intro: less_le_trans)
     done
-qed fastsimp+
+qed fastforce+
 
 lemma (in reachable_state) decrChain_KnownT:
   assumes decrChain: "decrChain path t from m m'"
@@ -1039,7 +1039,7 @@
     where "im \<in> pairParts m" and "\<forall>f \<in> from. f \<prec> Ln im"
     using decrChain by (fast dest!: decrChain_imp_predOrd)
   with KnownT show ?thesis
-    by (fastsimp intro: pairParts_before)
+    by (fastforce intro: pairParts_before)
 qed
 
 lemma (in reachable_state) decrChain_KnownTE:
diff --git a/data/isabelle/src/ESPLogic/espl_definitions.ML b/data/isabelle/src/ESPLogic/espl_definitions.ML
--- a/data/isabelle/src/ESPLogic/espl_definitions.ML
+++ b/data/isabelle/src/ESPLogic/espl_definitions.ML
@@ -21,7 +21,7 @@
   (* Additional Utilities *)
   val unnamed_caseN: string
 
-  datatype steptyp = Recv | Send
+  datatype steptyp = Recv | Send | Note of term
   val mk_rolestep: steptyp * term * term -> term
   val dest_rolestep: term -> steptyp * term * term
   val dest_role: term -> (steptyp * term * term) list
@@ -120,26 +120,26 @@
 
    TODO: Check if there is a more stable machinery for that purpose.
 *)
-fun get_unfold_thms ctxt (Const (c,_)) = ProofContext.get_thms ctxt (c ^ ".unfold")
-  | get_unfold_thms ctxt (Free  (c,_)) = ProofContext.get_thms ctxt (c ^ ".unfold")
+fun get_unfold_thms ctxt (Const (c,_)) = Proof_Context.get_thms ctxt (c ^ ".unfold")
+  | get_unfold_thms ctxt (Free  (c,_)) = Proof_Context.get_thms ctxt (c ^ ".unfold")
   | get_unfold_thms _ t = raise TERM ("get_unfold_thms", [t])
 
 (* Lookup the term of the message of a role step *)
 fun get_rolestep_msg ctxt step_name = 
-  ProofContext.get_thm ctxt (Thm.def_name (step_name ^ "_pt"))
+  Proof_Context.get_thm ctxt (Thm.def_name (step_name ^ "_pt"))
   |> Thm.prop_of
   |> dest_HOL_def
   |> snd
 
 (* Extract identifiers of message variables in a pattern *)
 fun pat_msgvars (Const (@{const_name "PEnc"},_) $ m $ k)  = 
-      OrdList.union fast_string_ord (pat_msgvars m) (pat_msgvars k)
+      Ord_List.union fast_string_ord (pat_msgvars m) (pat_msgvars k)
   | pat_msgvars (Const (@{const_name "PTup"},_) $ x $ y)  = 
-      OrdList.union fast_string_ord (pat_msgvars x) (pat_msgvars y)
+      Ord_List.union fast_string_ord (pat_msgvars x) (pat_msgvars y)
   | pat_msgvars (Const (@{const_name "PHash"},_) $ x)     = 
       pat_msgvars x
   | pat_msgvars (Const (@{const_name "PSymK"},_) $ a $ b) = 
-      OrdList.union fast_string_ord (pat_msgvars a) (pat_msgvars b)
+      Ord_List.union fast_string_ord (pat_msgvars a) (pat_msgvars b)
   | pat_msgvars (Const (@{const_name "PAsymPK"},_) $ a)   =
       pat_msgvars a
   | pat_msgvars (Const (@{const_name "PAsymSK"},_) $ a)   =
@@ -288,7 +288,7 @@
       pat_def |> Thm.prop_of |> dest_HOL_def |> #2 |> pat_msgvars;
 
     val msgvars = Library.foldl 
-      (fn (vs,def) => OrdList.union fast_string_ord vs (pat_def_msgvars def)) 
+      (fn (vs,def) => Ord_List.union fast_string_ord vs (pat_def_msgvars def)) 
       ([],pat_defs);
 
   in
@@ -346,16 +346,12 @@
   end
 
 (* registering the role definition command as an outer keyword *)
-local structure P = OuterParse and K = OuterKeyword in
-
-  val roledef_parser = 
-    P.binding --| P.where_ -- (SpecParse.opt_thm_name ":" -- P.prop);
-
-  val _ =
-    OuterSyntax.local_theory "role" "security protocol role definition" 
-      K.thy_decl (roledef_parser >> (fn spec => define_role_cmd spec #> snd));
-end;
+val roledef_parser = 
+  Parse.binding --| Parse.where_ -- (Parse_Spec.opt_thm_name ":" -- Parse.prop);
 
+val _ =
+  Outer_Syntax.local_theory @{command_spec "role"} "security protocol role definition" 
+    (roledef_parser >> (fn spec => define_role_cmd spec #> snd));
 
 (******************************************************************************
 **  Protocol Definitions
@@ -402,14 +398,14 @@
   let
     val ((proto_const, (_, proto_def)), spec_ctxt) = params_ctxt 
       |> Specification.definition_cmd 
-        (SOME (raw_bind, SOME "Protocol.proto", NoSyn), raw_spec);
+        (SOME (raw_bind, SOME "Protocol.proto", NoSyn), raw_spec) true;
 
     val proto_name          = Binding.name_of raw_bind;
     fun mk_rel_binding name = 
       (Binding.qualify true proto_name (Binding.name name), srcs);
   in
     setup_proto mk_rel_binding (proto_const, proto_def) spec_ctxt
-    |> apsnd (Local_Theory.theory (fn thy =>
+    |> apsnd (Local_Theory.raw_theory (fn thy =>
         let
           val locale_b = Binding.name (proto_name ^ "_state");
           val _ = Output.writeln ("\nlocale\n  " ^ (Binding.name_of locale_b));
@@ -424,15 +420,14 @@
   end;
 
 (* registering the protocol definition command *)
-local structure P = OuterParse and K = OuterKeyword in
-  val protodef_parser = 
-    P.binding --| P.where_ -- (SpecParse.opt_thm_name ":" -- P.prop);
-  val _ =
-    OuterSyntax.local_theory "protocol" "security protocol definition" 
-      K.thy_decl (protodef_parser >> (fn spec => define_proto_cmd spec #> #2));
-end;
+val protodef_parser = 
+  Parse.binding --| Parse.where_ -- (Parse_Spec.opt_thm_name ":" -- Parse.prop);
 
+val _ =
+  Outer_Syntax.local_theory @{command_spec "protocol"} "security protocol definition" 
+    (protodef_parser >> (fn spec => define_proto_cmd spec #> #2));
 
+
 (******************************************************************************
 **  Sources Case Name Computation
 ******************************************************************************)
@@ -550,7 +545,7 @@
 (* Insert the case names into a theorem *)
 fun insert_case_names ctxt th =
   let
-    val thy           = ProofContext.theory_of ctxt;
+    val thy           = Proof_Context.theory_of ctxt;
     val cases         = source_case_names th;
     val case_hint     = Hints.mk_hint_thm thy "case_name" o HOLogic.mk_string o nth cases;
     fun ins_tac (_,i) = Method.insert_tac [case_hint (i-1)] i;
@@ -638,13 +633,13 @@
         ]
   in
     (FIRST' (map mk_elim_tac ty_elim_ths)) THEN'
-    (TRY o Clasimp.clarsimp_tac (clasimpset_of ctxt))
+    (TRY o Clasimp.clarsimp_tac ctxt)
   end;
 
 
 fun expand_knows_cases_tac ctxt ty_elim_ths =
   REPEAT_DETERM1 (
-    FIRST [ safe_tac (claset_of ctxt)
+    FIRST [ safe_tac ctxt
           , CHANGED_PROP (TRYALL (full_simp_tac (simpset_of ctxt)))
           , CHANGED_PROP (TRYALL (type_elim_tac ctxt ty_elim_ths))
           ] 
@@ -690,7 +685,7 @@
     val knows_ct = 
       HOLogic.mk_mem (msg_t, @{term "knows t"})
       |> HOLogic.mk_Trueprop
-      |> Thm.cterm_of (ProofContext.theory_of lthy);
+      |> Thm.cterm_of (Proof_Context.theory_of lthy);
 
     val knows_th = Thm.assume knows_ct;
   in 
@@ -698,7 +693,7 @@
     |> HOL_Ext.make_HOL_elim
     |> refine_knows_cases lthy (SOME msg_t)
     |> Thm.implies_intr knows_ct
-    |> singleton (ProofContext.export lthy ctxt) 
+    |> singleton (Proof_Context.export lthy ctxt) 
     |> Drule.zero_var_indexes
   end;
 
@@ -706,7 +701,7 @@
 (*** Precomputing and storing chain rule expansion in the actual theory ***)
 
 structure KnowsCasesCache = Named_Thms
-  (val name ="knows_cases_cache"
+  (val name = @{binding "knows_cases_cache"}
    val description = "Cache of protocol and message specific specializations of the knows_cases theorem")
 
 (* shorthand for attributes modifying the knowledge cases *)
@@ -758,10 +753,9 @@
   let
     val (typ_const,typ_def) = ann_def;
 
-    val cs = Classical.claset_of ctxt;
-    val ss = Simplifier.simpset_of ctxt 
-               addsimps [typ_def];
-    val ss_full = ss addsimps  @{thms mk_typing_def};
+    val autom_tac = auto_tac (map_simpset (fn ss => ss addsimps [typ_def]) ctxt)
+    val ss_full = Simplifier.simpset_of ctxt 
+               addsimps [typ_def] addsimps @{thms mk_typing_def};
     
     val vars = typ_def |> Thm.prop_of 
       |> ESPL_Utils.dest_HOL_def |> snd |> dest_mk_typing |> map fst;
@@ -770,9 +764,9 @@
 
     val mono_typ_th = (@{const monoTyp} $ typ_const)
       |> HOLogic.mk_Trueprop
-      |> Thm.cterm_of (ProofContext.theory_of ctxt)
+      |> Thm.cterm_of (Proof_Context.theory_of ctxt)
       |> (fn ct => Goal.prove_internal [] ct
-           (K (auto_tac (cs, ss)))
+           (K autom_tac)
          );
   in
    ctxt
@@ -792,9 +786,9 @@
       (Binding.qualify true (Binding.name_of b) (Binding.name name), srcs);
 
     val ((typ_const, (_, typ_def)), spec_ctxt) = params_ctxt 
-      |> Specification.definition_cmd 
+      |> Specification.definition_cmd
           (SOME (b, SOME "WeakTyping.typing", NoSyn)
-          , ((att,srcs), raw_def));
+          , ((att,srcs), raw_def)) true;
   in
     setup_typing mk_rel_binding (typ_const, typ_def) spec_ctxt
   end;
@@ -811,7 +805,7 @@
 fun type_invariant_cmd (spec as ((typing_b,proto_name),_)) lthy =
   lthy
   |> #2 o define_typing_cmd spec
-  |> Local_Theory.theory (fn thy =>
+  |> Local_Theory.raw_theory (fn thy =>
       let
         val typ_name = Binding.name_of typing_b;
         val typ_t    = Syntax.read_term_global thy typ_name;
@@ -821,7 +815,7 @@
 
         val (_,lthy) = 
           add_type_invariant_locale (locale_b, (typ_t, proto_t)) thy;
-        val case_th  = ProofContext.get_thm lthy "knows_cases";
+        val case_th  = Proof_Context.get_thm lthy "knows_cases";
       in
         lthy
         |> #2 o precompute_source_elim_rules case_th
@@ -830,14 +824,14 @@
    );
 
 (* register the type invariant definition command *)
-local structure P = OuterParse and K = OuterKeyword in
+local structure P = Parse and K = Keyword in
   val for_proto = P.$$$ "for" |-- P.term;
 
   val type_invariant_parser = 
-    P.binding -- for_proto --| P.where_ -- (SpecParse.opt_thm_name ":" -- P.prop);
+    P.binding -- for_proto --| P.where_ -- (Parse_Spec.opt_thm_name ":" -- P.prop);
   val _ =
-    OuterSyntax.local_theory "type_invariant" "type invariant definition" 
-      K.thy_decl (type_invariant_parser >> type_invariant_cmd);
+    Outer_Syntax.local_theory @{command_spec "type_invariant"} "type invariant definition" 
+      (type_invariant_parser >> type_invariant_cmd);
 end;
 
 end;
diff --git a/data/isabelle/src/ESPLogic/espl_methods.ML b/data/isabelle/src/ESPLogic/espl_methods.ML
--- a/data/isabelle/src/ESPLogic/espl_methods.ML
+++ b/data/isabelle/src/ESPLogic/espl_methods.ML
@@ -20,8 +20,8 @@
      : Proof.context -> bool -> term ->
        thm option -> thm list -> int -> thm -> (cases * thm) Seq.seq
   val sourcesP
-     : Context.generic * OuterLex.token list ->
-       ((bool * term) * thm option) * (Context.generic * OuterLex.token list)
+     : Context.generic * Token.T list ->
+       ((bool * term) * thm option) * (Context.generic * Token.T list)
 
   (* "prefix_close" proof state transformation *)
   val prefix_close_thms: Proof.context -> thm list -> thm list
@@ -69,7 +69,7 @@
            else
              TRY o Method.insert_tac facts' THEN'
              TRY o (
-                Clasimp.clarsimp_tac (clasimpset_of ctxt) THEN'
+                Clasimp.clarsimp_tac ctxt THEN'
                 TRY o Orders.order_tac ctxt []
              )
           )
@@ -86,9 +86,9 @@
 (* The tactic underlying the "sources" proof method *)
 fun sources_tac ctxt minimal msg_t opt_raw_rule facts =
   let
-    val thy = ProofContext.theory_of ctxt;
+    val thy = Proof_Context.theory_of ctxt;
     val cert = Thm.cterm_of thy;
-    val css as (_, ss) = Clasimp.clasimpset_of ctxt;
+    val ss = simpset_of ctxt;
 
     val raw_rules = case opt_raw_rule of
         SOME th => [th]
@@ -113,7 +113,7 @@
         (fn facts' => 
         ALLGOALS (Method.insert_tac (facts' @ facts)) THEN
         (ALLGOALS (assume_tac ORELSE' eresolve_tac predOrd_elim_ths)
-         ORELSE auto_tac (css addIs2 predOrd_elim_ths))
+         ORELSE auto_tac (ctxt addIs predOrd_elim_ths))
         )
       |> simplify ss
 
@@ -123,7 +123,7 @@
       | SOME th => finalize_knows_cases ctxt minimal facts th
   in
     fn i => fn st =>
-      CASES (Rule_Cases.make_common false (thy, Thm.prop_of rule) (fst cases)
+      CASES (Rule_Cases.make_common (thy, Thm.prop_of rule) (fst cases)
             )
             (Tactic.rtac rule i) st
   end;
@@ -139,10 +139,9 @@
    explicitly.
 *)
 local
-  structure P = OuterParse;
   val ruleN = "rule";
   val rule = Scan.lift (Args.$$$ ruleN -- Args.colon) |-- Attrib.thm;
-  val opt_bang = Scan.lift (Scan.optional (P.$$$ "!" >> K true) false);
+  val opt_bang = Scan.lift (Scan.optional (Parse.$$$ "!" >> K true) false);
 in
   val sourcesP = opt_bang -- Args.term -- Scan.option rule;
 end;
@@ -182,7 +181,7 @@
 *)
 fun prefix_close_thms ctxt facts = 
   let
-    val prefixClose_th = ProofContext.get_thm ctxt "ext_prefixClose";
+    val prefixClose_th = Proof_Context.get_thm ctxt "ext_prefixClose";
     fun close step roleMap = [step, roleMap] MRS prefixClose_th;
     val expand = Simplifier.simplify (Simplifier.simpset_of ctxt);
     val distinct_prop = distinct (Thm.eq_thm);
@@ -207,7 +206,7 @@
   let val ctxt  = Proof.context_of state;
       val facts = Proof.the_facts state;
       val facts' = facts @ prefix_close_thms ctxt facts
-  in Proof.put_facts (SOME facts') state end
+  in Proof.set_facts facts' state end
 
 (* A proof state transformation implementing prefix closing of
    the currently used facts.
@@ -219,12 +218,11 @@
       |> (fn {context = ctxt, facts=using, goal=_} => 
            prefix_close_thms ctxt using)
 
-  in Proof.using_i [[(using,[])]] state end;
+  in Proof.using [[(using,[])]] state end;
 
 (* registering the prefix_close command *)
 val _ =
-  OuterSyntax.command "prefix_close" "prefix close facts being used"
-    (OuterKeyword.tag_proof OuterKeyword.prf_decl)
+  Outer_Syntax.command @{command_spec "prefix_close"} "prefix close facts being used"
     (Scan.succeed (Toplevel.print o (Toplevel.proof prefix_close_cmd)));
 
 
@@ -277,7 +275,7 @@
 
   in 
     th
-    |> SINGLE (REPEAT (safe_tac cs THEN (TRYALL (full_simp_tac ss))))    
+    |> SINGLE (REPEAT (safe_tac (Context.proof_of ctxt) THEN (TRYALL (full_simp_tac ss))))    
     |> the
     |> add_case_info
   end
diff --git a/data/isabelle/src/ESPLogic/espl_utils.ML b/data/isabelle/src/ESPLogic/espl_utils.ML
--- a/data/isabelle/src/ESPLogic/espl_utils.ML
+++ b/data/isabelle/src/ESPLogic/espl_utils.ML
@@ -103,19 +103,19 @@
    premises 
 *)
 val local_standard' =
-  forall_intr_frees
+  Thm.forall_intr_frees
   #> `Thm.maxidx_of
   #-> (fn maxidx =>
     Thm.forall_elim_vars (maxidx + 1)
     #> Thm.strip_shyps
     #> zero_var_indexes
-    #> Thm.varifyT);
+    #> Thm.varifyT_global);
 
 (* Generate the theorem proving the expansion of a term wrto to the given
    simpset and convert it into a rule.
 *)
 fun expand_term ss t = t
-  |> Thm.cterm_of (ProofContext.theory_of (MetaSimplifier.the_context ss))
+  |> Thm.cterm_of (Proof_Context.theory_of (Raw_Simplifier.the_context ss))
   |> Simplifier.rewrite ss
   |> (fn conv => conv RS @{thm meta_eq_to_obj_eq}) 
   |> local_standard'
@@ -125,7 +125,7 @@
 
 (* create a simpset consisting only of the given theorems in the given context *)
 fun thms_to_simpset ctxt ths = 
-  Simplifier.context ctxt (MetaSimplifier.empty_ss addsimps ths);
+  Simplifier.context ctxt (Raw_Simplifier.empty_ss addsimps ths);
 
 (* Expand a list of terms and note the resulting theorems. *)
 fun notes_expansion ss to_expand = 
@@ -151,7 +151,7 @@
    inst is a positional instantiation.
 *)
 fun add_simple_locale b loc_name inst thy =
-  Expression.add_locale b (Binding.empty)
+  Expression.add_locale I b (Binding.empty)
   ( [ ( Locale.intern thy loc_name
       , ( ("",false)
         , Expression.Positional inst
diff --git a/data/isabelle/src/compromising_adversaries/CR_paper_acm.thy b/data/isabelle/src/compromising_adversaries/CR_paper_acm.thy
--- a/data/isabelle/src/compromising_adversaries/CR_paper_acm.thy
+++ b/data/isabelle/src/compromising_adversaries/CR_paper_acm.thy
@@ -71,7 +71,7 @@
     show ?case using facts
     proof(sources! "
         Enc ( s(MV ''k'' tid0) ) ( PK ( s(AV ''S'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits) | (fastsimp intro: event_predOrdI split: if_splits))+)?
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits) | (fastforce intro: event_predOrdI split: if_splits))+)?
   qed
   thus "auto_msc_typing_state t r s" by unfold_locales auto
 qed
@@ -213,12 +213,12 @@
     proof(sources "Enc (LN ''k'' test) (PK (s (AV ''S'' tid')))")
       case C_2_enc
       thus ?thesis 
-        by (fastsimp dest: compr_predOrdI)
+        by (fastforce dest: compr_predOrdI)
     qed
   next
     case C_5_k
     thus ?thesis
-      by (fastsimp dest: compr_predOrdI)
+      by (fastforce dest: compr_predOrdI)
   qed
 qed
 
@@ -232,7 +232,7 @@
   shows
     False
 using facts
-by(fastsimp dest: C_k_origin allowed_reveals)
+by(fastforce dest: C_k_origin allowed_reveals)
 
 lemma (in CR_state_ADVint) C_k_secrecy_others:
   assumes facts:
@@ -313,7 +313,7 @@
   proof(sources "Hash ( LN ''k'' test )")
     case fake
     thus ?thesis 
-      by(fastsimp dest: C_k_secrecy_protected intro: event_predOrdI)
+      by(fastforce dest: C_k_secrecy_protected intro: event_predOrdI)
   next
     case (S_3_hash tid2)
     thus ?thesis
@@ -323,23 +323,23 @@
     next
       case fake
       thus ?thesis
-        by (fastsimp dest: C_k_secrecy_protected intro: event_predOrdI)
+        by (fastforce dest: C_k_secrecy_protected intro: event_predOrdI)
     qed
   next
     case C_3_hash
     thus ?thesis
-      by(fastsimp dest: compr_predOrdI allowed_reveals)
+      by(fastforce dest: compr_predOrdI allowed_reveals)
   next
     case (S_2_hash tid2)
     thus ?thesis
     proof(sources "Enc (LN ''k'' test) (PK (s (AV ''S'' tid2)))")
       case fake
       thus ?thesis
-        by (fastsimp dest: C_k_secrecy_protected intro: event_predOrdI)
+        by (fastforce dest: C_k_secrecy_protected intro: event_predOrdI)
     next
       case C_2_enc
       thus ?thesis
-        by(fastsimp dest: compr_predOrdI allowed_reveals)
+        by(fastforce dest: compr_predOrdI allowed_reveals)
     qed
   qed
 qed
@@ -363,7 +363,7 @@
   proof(sources "Hash ( LN ''k'' test )")
     case fake
     thus ?thesis 
-      by(fastsimp dest: C_k_secrecy_others intro: event_predOrdI)
+      by(fastforce dest: C_k_secrecy_others intro: event_predOrdI)
   next
     case (S_3_hash tid2)
     thus ?thesis
@@ -373,23 +373,23 @@
     next
       case fake
       thus ?thesis
-        by (fastsimp dest: C_k_secrecy_others intro: event_predOrdI)
+        by (fastforce dest: C_k_secrecy_others intro: event_predOrdI)
     qed
   next
     case C_3_hash
     thus ?thesis
-      by(fastsimp dest: compr_predOrdI allowed_reveals)
+      by(fastforce dest: compr_predOrdI allowed_reveals)
   next
     case (S_2_hash tid2)
     thus ?thesis
     proof(sources "Enc (LN ''k'' test) (PK (s (AV ''S'' tid2)))")
       case fake
       thus ?thesis
-        by (fastsimp dest: C_k_secrecy_others intro: event_predOrdI)
+        by (fastforce dest: C_k_secrecy_others intro: event_predOrdI)
     next
       case C_2_enc
       thus ?thesis
-        by(fastsimp dest: compr_predOrdI allowed_reveals)
+        by(fastforce dest: compr_predOrdI allowed_reveals)
     qed
   qed
 qed
@@ -412,7 +412,7 @@
   proof(sources "Hash ( LN ''k'' test )")
     case fake
     thus ?thesis 
-      by(fastsimp dest: C_k_secrecy_sessKey intro: event_predOrdI)
+      by(fastforce dest: C_k_secrecy_sessKey intro: event_predOrdI)
   next
     case (S_3_hash tid2)
     thus ?thesis
@@ -422,23 +422,23 @@
     next
       case fake
       thus ?thesis
-        by (fastsimp dest: C_k_secrecy_sessKey intro: event_predOrdI)
+        by (fastforce dest: C_k_secrecy_sessKey intro: event_predOrdI)
     qed
   next
     case C_3_hash
     thus ?thesis
-      by(fastsimp dest: compr_predOrdI allowed_reveals)
+      by(fastforce dest: compr_predOrdI allowed_reveals)
   next
     case (S_2_hash tid2)
     thus ?thesis
     proof(sources "Enc (LN ''k'' test) (PK (s (AV ''S'' tid2)))")
       case fake
       thus ?thesis
-        by (fastsimp dest: C_k_secrecy_sessKey intro: event_predOrdI)
+        by (fastforce dest: C_k_secrecy_sessKey intro: event_predOrdI)
     next
       case C_2_enc
       thus ?thesis
-        by(fastsimp dest: compr_predOrdI allowed_reveals)
+        by(fastforce dest: compr_predOrdI allowed_reveals)
     qed
   qed
 qed
@@ -461,7 +461,7 @@
   proof(sources "Hash ( LN ''k'' test )")
     case fake
     thus ?thesis 
-      by(fastsimp dest: C_k_secrecy_state intro: event_predOrdI)
+      by(fastforce dest: C_k_secrecy_state intro: event_predOrdI)
   next
     case (S_3_hash tid2)
     thus ?thesis
@@ -471,23 +471,23 @@
     next
       case fake
       thus ?thesis
-        by (fastsimp dest: C_k_secrecy_state intro: event_predOrdI)
+        by (fastforce dest: C_k_secrecy_state intro: event_predOrdI)
     qed
   next
     case C_3_hash
     thus ?thesis
-      by(fastsimp dest: compr_predOrdI allowed_reveals)
+      by(fastforce dest: compr_predOrdI allowed_reveals)
   next
     case (S_2_hash tid2)
     thus ?thesis
     proof(sources "Enc (LN ''k'' test) (PK (s (AV ''S'' tid2)))")
       case fake
       thus ?thesis
-        by (fastsimp dest: C_k_secrecy_state intro: event_predOrdI)
+        by (fastforce dest: C_k_secrecy_state intro: event_predOrdI)
     next
       case C_2_enc
       thus ?thesis
-        by(fastsimp dest: compr_predOrdI allowed_reveals)
+        by(fastforce dest: compr_predOrdI allowed_reveals)
     qed
   qed
 qed
@@ -510,7 +510,7 @@
   proof(sources "Hash ( LN ''k'' test )")
     case fake
     thus ?thesis 
-      by(fastsimp dest: C_k_secrecy_actor intro: event_predOrdI)
+      by(fastforce dest: C_k_secrecy_actor intro: event_predOrdI)
   next
     case (S_3_hash tid2)
     thus ?thesis
@@ -520,23 +520,23 @@
     next
       case fake
       thus ?thesis
-        by (fastsimp dest: C_k_secrecy_actor intro: event_predOrdI)
+        by (fastforce dest: C_k_secrecy_actor intro: event_predOrdI)
     qed
   next
     case C_3_hash
     thus ?thesis
-      by(fastsimp dest: compr_predOrdI allowed_reveals)
+      by(fastforce dest: compr_predOrdI allowed_reveals)
   next
     case (S_2_hash tid2)
     thus ?thesis
     proof(sources "Enc (LN ''k'' test) (PK (s (AV ''S'' tid2)))")
       case fake
       thus ?thesis
-        by (fastsimp dest: C_k_secrecy_actor intro: event_predOrdI)
+        by (fastforce dest: C_k_secrecy_actor intro: event_predOrdI)
     next
       case C_2_enc
       thus ?thesis
-        by(fastsimp dest: compr_predOrdI allowed_reveals)
+        by(fastforce dest: compr_predOrdI allowed_reveals)
     qed
   qed
 qed
@@ -561,7 +561,7 @@
   proof(sources "Hash ( LN ''k'' test )")
     case fake
     thus ?thesis 
-      by(fastsimp dest: C_k_secrecy_all intro: event_predOrdI)
+      by(fastforce dest: C_k_secrecy_all intro: event_predOrdI)
   next
     case (S_3_hash tid2)
     thus ?thesis
@@ -571,23 +571,23 @@
     next
       case fake
       thus ?thesis
-        by (fastsimp dest: C_k_secrecy_all intro: event_predOrdI)
+        by (fastforce dest: C_k_secrecy_all intro: event_predOrdI)
     qed
   next
     case C_3_hash
     thus ?thesis
-      by(fastsimp dest: compr_predOrdI allowed_reveals)
+      by(fastforce dest: compr_predOrdI allowed_reveals)
   next
     case (S_2_hash tid2)
     thus ?thesis
     proof(sources "Enc (LN ''k'' test) (PK (s (AV ''S'' tid2)))")
       case fake
       thus ?thesis
-        by (fastsimp dest: C_k_secrecy_all intro: event_predOrdI)
+        by (fastforce dest: C_k_secrecy_all intro: event_predOrdI)
     next
       case C_2_enc
       thus ?thesis
-        by(fastsimp dest: compr_predOrdI allowed_reveals)
+        by(fastforce dest: compr_predOrdI allowed_reveals)
     qed
   qed
 qed
diff --git a/data/isabelle/src/compromising_adversaries/NS_Public_acm.thy b/data/isabelle/src/compromising_adversaries/NS_Public_acm.thy
--- a/data/isabelle/src/compromising_adversaries/NS_Public_acm.thy
+++ b/data/isabelle/src/compromising_adversaries/NS_Public_acm.thy
@@ -75,7 +75,7 @@
                s(AV ''R'' tid0)
             |}
             ( PK ( s(AV ''I'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits) | (fastsimp intro: event_predOrdI split: if_splits))+)?
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits) | (fastforce intro: event_predOrdI split: if_splits))+)?
   next
     case (R_1_ni t r s tid0)
     note facts = this
@@ -85,7 +85,7 @@
     proof(sources! "
         Enc {| LC ''1'', s(MV ''ni'' tid0), s(AV ''I'' tid0) |}
             ( PK ( s(AV ''R'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits) | (fastsimp intro: event_predOrdI split: if_splits))+)?
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits) | (fastforce intro: event_predOrdI split: if_splits))+)?
   qed
   thus "auto_msc_typing_state t r s" by unfold_locales auto
 qed
@@ -199,7 +199,7 @@
       "Enc {| LC ''2'', LN ''ni'' test, s(MV ''nr'' test), s(AV ''R'' test)|} ( PK ( s(AV ''I'' test) ) ) ")
     case fake
     thus ?thesis
-      by(fastsimp dest: I_ni_origin intro: event_predOrdI)
+      by(fastforce dest: I_ni_origin intro: event_predOrdI)
   next
     case (R_2_enc tid1')
     thus ?thesis
@@ -223,18 +223,18 @@
   proof(sources "Enc {| LC ''3'', LN ''nr'' test |} ( PK ( s(AV ''R'' test) ) ) ")
     case fake
     thus ?thesis 
-      by (fastsimp dest: R_nr_origin intro: event_predOrdI)
+      by (fastforce dest: R_nr_origin intro: event_predOrdI)
   next
     case (I_3_enc tid1) 
     thus ?thesis
     proof(sources "Enc {| LC ''2'', LN ''ni'' tid1, LN ''nr'' test, s(AV ''R'' test)|}( PK ( s(AV ''I'' tid1) ) ) ")
       case fake 
       thus ?thesis
-        by(fastsimp dest: R_nr_origin intro: event_predOrdI) 
+        by(fastforce dest: R_nr_origin intro: event_predOrdI) 
     next
       case R_2_enc
       thus ?thesis 
-        by (fastsimp dest: I_ni_origin intro: event_predOrdI) 
+        by (fastforce dest: I_ni_origin intro: event_predOrdI) 
     qed
   qed
 qed
@@ -256,7 +256,7 @@
   proof(sources "Hash \<lbrace>LN ''ni'' test, s (MV ''nr'' test)\<rbrace>")
     case fake
     thus ?thesis
-      by(fastsimp dest: I_ni_origin intro: event_predOrdI)
+      by(fastforce dest: I_ni_origin intro: event_predOrdI)
   next
     case I_4_hash
     thus ?thesis
@@ -268,7 +268,7 @@
        (PK (s (AV ''I'' test)))")
       case fake
       thus ?thesis
-        by(fastsimp dest: I_ni_origin intro: event_predOrdI)
+        by(fastforce dest: I_ni_origin intro: event_predOrdI)
     next
       case R_2_enc
       thus ?thesis
@@ -294,7 +294,7 @@
   proof(sources "Hash \<lbrace>s (MV ''ni'' test), LN ''nr'' test\<rbrace>")
     case fake
     thus ?thesis
-      by(fastsimp dest: R_nr_origin intro: event_predOrdI)
+      by(fastforce dest: R_nr_origin intro: event_predOrdI)
   next
     case R_4_hash
     thus ?thesis
@@ -306,7 +306,7 @@
        (PK (s (AV ''I'' tid1)))")
       case fake
       thus ?thesis
-        by(fastsimp dest: R_nr_origin intro: event_predOrdI)
+        by(fastforce dest: R_nr_origin intro: event_predOrdI)
     next
       case R_2_enc
       thus ?thesis
@@ -324,7 +324,7 @@
     "LN ''ni'' test \<in> knows t"
   shows "False"
 using facts
-by(insert I_ni_origin, fastsimp dest!: allowed_reveals)
+by(insert I_ni_origin, fastforce dest!: allowed_reveals)
 
 lemma (in ns_public_state_ADVall) R_nr_secrecy:
   assumes facts:
@@ -332,7 +332,7 @@
     "LN ''nr'' test \<in> knows t"
   shows "False"
 using facts
-by(insert R_nr_origin, fastsimp dest!: allowed_reveals)
+by(insert R_nr_origin, fastforce dest!: allowed_reveals)
 
 lemma (in ns_public_state_ADVall) I_nr_secrecy:
   assumes facts:
@@ -341,7 +341,7 @@
     "s(MV ''nr'' test) \<in>  knows t"
   shows "False"
 using facts
-by(insert I_nr_origin, fastsimp dest!: allowed_reveals)
+by(insert I_nr_origin, fastforce dest!: allowed_reveals)
 
 
 lemma (in ns_public_state_ADVall) R_ni_secrecy:
@@ -351,7 +351,7 @@
     "s(MV ''ni'' test) \<in> knows t"
   shows "False"
 using facts
-by(insert R_ni_origin, fastsimp dest!: allowed_reveals)
+by(insert R_ni_origin, fastforce dest!: allowed_reveals)
 
 lemma (in ns_public_state_ADVall) I_sessKey_secrecy:
   assumes facts:
@@ -410,7 +410,7 @@
     next
       case I_1_enc
       thus ?thesis
-        by(fastsimp)
+        by(fastforce)
     qed
   qed
 qed
diff --git a/data/isabelle/src/compromising_adversaries/PFS_acm.thy b/data/isabelle/src/compromising_adversaries/PFS_acm.thy
--- a/data/isabelle/src/compromising_adversaries/PFS_acm.thy
+++ b/data/isabelle/src/compromising_adversaries/PFS_acm.thy
@@ -82,8 +82,8 @@
       thus ?thesis proof(sources! "
                        Enc \<lbrace> LC ''2'', s(AV ''A'' tid0), s(MV ''k'' tid0) \<rbrace>
                            ( SK ( s(AV ''B'' tid0) ) ) ")
-      qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits) | (fastsimp intro: event_predOrdI split: if_splits))+)?
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
+      qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits) | (fastforce intro: event_predOrdI split: if_splits))+)?
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
   next
     case (B_1_pkNa t r s tid0) note facts = this
     then interpret state: auto_msc_typing_state t r s
@@ -92,7 +92,7 @@
     proof(sources! "
         Enc \<lbrace> LC ''1'', s(AV ''B'' tid0), s(MV ''pkNa'' tid0) \<rbrace>
             ( SK ( s(AV ''A'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits) | (fastsimp intro: event_predOrdI split: if_splits))+)?
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits) | (fastforce intro: event_predOrdI split: if_splits))+)?
   qed
   thus "auto_msc_typing_state t r s" by unfold_locales auto
 qed
@@ -156,7 +156,7 @@
                        ( SK ( s(AV ''A'' test) ) ) ")
       case fake
       thus ?thesis 
-      by (sources "SK (s (AV ''A'' test))") (fastsimp intro: predOrd_distinct'_trans)
+      by (sources "SK (s (AV ''A'' test))") (fastforce intro: predOrd_distinct'_trans)
     next
       case (A_1_enc tid1)
       thus ?thesis 
@@ -177,7 +177,7 @@
        (SK (s (AV ''A'' tid1)))")
           case fake
           thus ?thesis
-            by (sources "SK (s (AV ''A'' test))") (fastsimp intro: predOrd_distinct'_trans)
+            by (sources "SK (s (AV ''A'' test))") (fastforce intro: predOrd_distinct'_trans)
         next
           case (A_1_enc tid1')
           thus ?thesis
@@ -218,7 +218,7 @@
                        ( SK ( s(AV ''B'' test) ) ) ")
       case fake
       thus ?thesis
-      by (sources "SK (s (AV ''B'' test))") (fastsimp intro: predOrd_distinct'_trans)
+      by (sources "SK (s (AV ''B'' test))") (fastforce intro: predOrd_distinct'_trans)
     next
       case (B_2_enc_1 tid1)
       thus ?thesis
@@ -226,7 +226,7 @@
        (SK (s (AV ''A'' test)))")
         case fake
         thus ?thesis
-          by (sources "SK (s (AV ''A'' tid1))")(fastsimp intro: predOrd_distinct'_trans)    next
+          by (sources "SK (s (AV ''A'' tid1))")(fastforce intro: predOrd_distinct'_trans)    next
         case (A_1_enc tid1')
         thus ?thesis
            by (sources "SK (LN ''na'' tid1')")
@@ -345,7 +345,7 @@
       proof(sources "Enc \<lbrace>LC ''2'', s (AV ''A'' test), s (MV ''k'' test)\<rbrace> (SK (s (AV ''B'' test)))")
         case fake
         thus ?thesis
-          by (fastsimp dest: A_sec_k event_predOrdI)
+          by (fastforce dest: A_sec_k event_predOrdI)
       next
         case (B_2_enc_1 tid1)
         thus ?thesis
@@ -357,7 +357,7 @@
             thus ?thesis
               apply -
               apply(frule lkr_in_reveals_predOrd1)
-              by (fastsimp dest: allowed_reveals)
+              by (fastforce dest: allowed_reveals)
           qed
         next
           case (A_1_enc test)
@@ -376,7 +376,7 @@
             thus ?thesis
               apply -
               apply(frule lkr_in_reveals_predOrd1)
-              by (fastsimp dest: allowed_reveals)
+              by (fastforce dest: allowed_reveals)
           qed
         next
           case A_1_enc
@@ -426,7 +426,7 @@
             thus ?thesis
               apply -
               apply(frule lkr_in_reveals_predOrd1)
-              by (fastsimp dest: allowed_reveals)              
+              by (fastforce dest: allowed_reveals)              
           qed
         next
           case B_2_enc_1
@@ -439,7 +439,7 @@
               thus ?thesis
                 apply -
                 apply(frule lkr_in_reveals_predOrd1)
-                by (fastsimp dest: allowed_reveals)
+                by (fastforce dest: allowed_reveals)
             qed
           next
             case (A_1_enc tid2)
@@ -458,7 +458,7 @@
               thus ?thesis
                 apply -
                 apply(frule lkr_in_reveals_predOrd1)
-                by (fastsimp dest: allowed_reveals)
+                by (fastforce dest: allowed_reveals)
             qed
         next
           case A_1_enc
diff --git a/data/isabelle/src/compromising_adversaries/TLS_acm.thy b/data/isabelle/src/compromising_adversaries/TLS_acm.thy
--- a/data/isabelle/src/compromising_adversaries/TLS_acm.thy
+++ b/data/isabelle/src/compromising_adversaries/TLS_acm.thy
@@ -142,31 +142,31 @@
     then interpret state: auto_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (C_4_ps t r s tid0) note facts = this
     then interpret state: auto_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (S_1_nc t r s tid0) note facts = this
     then interpret state: auto_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (S_1_pc t r s tid0) note facts = this
     then interpret state: auto_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (S_1_sid t r s tid0) note facts = this
     then interpret state: auto_msc_typing_state t r s
       by unfold_locales auto
     show ?case using facts
-    by (fastsimp intro: event_predOrdI split: if_splits)
+    by (fastforce intro: event_predOrdI split: if_splits)
   next
     case (S_5_pms t r s tid0) note facts = this
     then interpret state: auto_msc_typing_state t r s
@@ -175,7 +175,7 @@
     proof(sources! "
         Enc {| LC ''TT0'', s(MV ''pms'' tid0) |}
             ( PK ( s(AV ''S'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits) | (fastsimp intro: event_predOrdI split: if_splits))+)?
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits) | (fastforce intro: event_predOrdI split: if_splits))+)?
   qed
   thus "auto_msc_typing_state t r s" by unfold_locales auto
 qed
@@ -1339,7 +1339,7 @@
 proof -
   from facts
   have "roleMap r tid1 = Some S"
-    by (fastsimp dest: mk_partneringRole simp add: TLS_partners_conv)
+    by (fastforce dest: mk_partneringRole simp add: TLS_partners_conv)
   note_prefix_closed facts = facts this
   thus ?thesis
   proof -
@@ -1348,14 +1348,14 @@
         {(sLAV ''C'', sLAV ''C'', S_1), (sLAV ''S'', sLAV ''S'', S_1),
          (sLMV ''ns'', sLN ''ns'', S_3), (sLN ''pms'', sLMV ''pms'', S_5)}
         (t, r, s)"
-      by (fastsimp simp add: TLS_partners_conv dest: mk_partneringRole)
+      by (fastforce simp add: TLS_partners_conv dest: mk_partneringRole)
     moreover
     from facts 
     have "(i, test) \<in> mk_partnering TLS_acm.C S
         {(sLAV ''C'', sLAV ''C'', S_1), (sLAV ''S'', sLAV ''S'', S_1),
          (sLMV ''ns'', sLN ''ns'', S_3), (sLN ''pms'', sLMV ''pms'', S_5)}
         (t, r, s)"
-      by (fastsimp simp add: TLS_partners_conv dest: mk_partneringRole)
+      by (fastforce simp add: TLS_partners_conv dest: mk_partneringRole)
     ultimately
     show ?thesis
       using facts
@@ -1485,12 +1485,12 @@
     note_unified facts = facts this
 
     hence "(test,tid1) \<in> TLS_partners (t,r,s)"
-      by fastsimp
+      by fastforce
     note_unified facts = facts this
     moreover 
     {
       assume "RLKR (s (AV ''S'' tid1)) \<in> reveals t"
-      hence "?thesis" using facts by fastsimp
+      hence "?thesis" using facts by fastforce
     }
     moreover{
       assume "(tid1, Note ''5'' State C_5_pt) \<in> steps t"
@@ -1509,20 +1509,20 @@
       note_unified facts = facts this
       obtain tid1a where
         partCompr: "(tid1, tid1a) \<in> TLS_partners (t, r, s) \<and> (tid1a, Note ''6'' State S_6_pt) \<in> steps t"
-        using facts by fastsimp
+        using facts by fastforce
       hence  "test = tid1a" using facts
         apply -
         apply(rule TLS_partners_revealsExist,assumption,assumption,rule event_predOrdI, assumption)          
-        by fastsimp+
+        by fastforce+
       hence "?thesis"
         using facts partCompr
-        by fastsimp
+        by fastforce
     }
     ultimately
     show ?thesis using facts
       apply -
       apply(frule event_predOrdI, frule C_pms_origin_reuse, assumption)
-      by fastsimp
+      by fastforce
   qed
 qed
 end
diff --git a/data/isabelle/src/compromising_adversaries/wPFS_acm.thy b/data/isabelle/src/compromising_adversaries/wPFS_acm.thy
--- a/data/isabelle/src/compromising_adversaries/wPFS_acm.thy
+++ b/data/isabelle/src/compromising_adversaries/wPFS_acm.thy
@@ -93,8 +93,8 @@
                        Enc \<lbrace> LC ''2'', LN ''sid'' tid0, s(AV ''A'' tid0), s(MV ''k'' tid0)
                            \<rbrace>
                            ( SK ( s(AV ''B'' tid0) ) ) ")
-      qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits) | (fastsimp intro: event_predOrdI split: if_splits))+)?
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits))+)?
+      qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits) | (fastforce intro: event_predOrdI split: if_splits))+)?
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits))+)?
   next
     case (B_1_pkNa t r s tid0) note facts = this
     then interpret state: auto_msc_typing_state t r s
@@ -105,7 +105,7 @@
               s(MV ''pkNa'' tid0)
             \<rbrace>
             ( SK ( s(AV ''A'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits) | (fastsimp intro: event_predOrdI split: if_splits))+)?
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits) | (fastforce intro: event_predOrdI split: if_splits))+)?
   next
     case (B_1_sid t r s tid0) note facts = this
     then interpret state: auto_msc_typing_state t r s
@@ -116,7 +116,7 @@
               s(MV ''pkNa'' tid0)
             \<rbrace>
             ( SK ( s(AV ''A'' tid0) ) ) ")
-    qed (insert facts, ((fastsimp intro: event_predOrdI split: if_splits) | (fastsimp intro: event_predOrdI split: if_splits))+)?
+    qed (insert facts, ((fastforce intro: event_predOrdI split: if_splits) | (fastforce intro: event_predOrdI split: if_splits))+)?
   qed
   thus "auto_msc_typing_state t r s" by unfold_locales auto
 qed
@@ -181,18 +181,18 @@
        (SK (s (AV ''A'' test)))")
       case fake
       thus ?thesis
-        by (sources "SK (s (AV ''A'' test))") (fastsimp intro: predOrd_distinct'_trans)
+        by (sources "SK (s (AV ''A'' test))") (fastforce intro: predOrd_distinct'_trans)
     next
       case (A_1_enc tid1)
       thus ?thesis 
       proof(sources " SK ( LN ''na'' tid1 ) ")
         case A_N1_SK
         thus ?thesis 
-          by (fastsimp intro: compr_predOrdI)
+          by (fastforce intro: compr_predOrdI)
       next
         case A_N0_SK
         thus ?thesis
-          by (fastsimp intro: compr_predOrdI)
+          by (fastforce intro: compr_predOrdI)
       qed
     qed
   next
@@ -268,14 +268,14 @@
     proof(sources "Enc \<lbrace>LC ''2'', LN ''sid'' test, s (AV ''A'' test), s (MV ''k'' test)\<rbrace> (SK (s (AV ''B'' test)))")
       case fake
       thus ?thesis
-        by (sources "SK (s (AV ''B'' test))") (fastsimp intro: predOrd_distinct'_trans)
+        by (sources "SK (s (AV ''B'' test))") (fastforce intro: predOrd_distinct'_trans)
     next
       case (B_2_enc_1 tid1)
       thus ?thesis
       proof(sources "Enc \<lbrace>LC ''1'', LN ''sid'' test, s (AV ''B'' test), s (MV ''pkNa'' tid1)\<rbrace> (SK (s (AV ''A'' test)))")
         case fake
         thus ?thesis
-          by (sources "SK (s (AV ''A'' test))") (fastsimp intro: predOrd_distinct'_trans)
+          by (sources "SK (s (AV ''A'' test))") (fastforce intro: predOrd_distinct'_trans)
       qed
     qed
   next
@@ -420,7 +420,7 @@
       proof(sources "Enc \<lbrace>LC ''2'', LN ''sid'' test, s (AV ''A'' test), s (MV ''k'' test)\<rbrace> (SK (s (AV ''B'' test)))")
         case fake
         thus ?thesis
-          by (fastsimp dest: A_sec_k event_predOrdI)
+          by (fastforce dest: A_sec_k event_predOrdI)
       next
         case (B_2_enc_1 tid1)
         thus ?thesis
@@ -432,7 +432,7 @@
             thus ?thesis
               apply -
               apply(frule lkr_in_reveals_predOrd1)
-              by (fastsimp dest: allowed_reveals)
+              by (fastforce dest: allowed_reveals)
           qed
         qed
       qed
@@ -447,7 +447,7 @@
             thus ?thesis
               apply -
               apply(frule lkr_in_reveals_predOrd1)
-              by (fastsimp dest: allowed_reveals)
+              by (fastforce dest: allowed_reveals)
           qed
         next
           case A_1_enc
@@ -480,7 +480,7 @@
       thus ?thesis
         apply -
         apply(frule lkr_in_reveals_predOrd1)
-        by (fastsimp dest: allowed_reveals)
+        by (fastforce dest: allowed_reveals)
     qed
   next
     case (A_1_enc tid1)
diff --git a/data/isabelle/src/isar-keywords.el b/data/isabelle/src/isar-keywords.el
--- a/data/isabelle/src/isar-keywords.el
+++ b/data/isabelle/src/isar-keywords.el
@@ -1,6 +1,6 @@
 ;;
 ;; Keyword classification tables for Isabelle/Isar.
-;; Generated from Pure + Pure-ProofGeneral + HOL + HOLCF + IOA + HOL-Boogie + HOL-Nominal + HOL-SMT + HOL-Statespace.
+;; Generated from HOLCF + HOL-BNF + HOL-Boogie + HOL-Library + HOL-Nominal + HOL-Statespace + HOL-SPARK + HOL-TPTP + HOL-Import.
 ;; *** DO NOT EDIT *** DO NOT EDIT *** DO NOT EDIT ***
 ;;
 
@@ -8,12 +8,9 @@
   '("\\."
     "\\.\\."
     "Isabelle\\.command"
-    "Isar\\.begin_document"
-    "Isar\\.define_command"
-    "Isar\\.edit_document"
-    "Isar\\.end_document"
     "ML"
     "ML_command"
+    "ML_file"
     "ML_prf"
     "ML_val"
     "ProofGeneral\\.inform_file_processed"
@@ -30,21 +27,17 @@
     "arities"
     "assume"
     "atom_decl"
-    "atp_info"
-    "atp_kill"
-    "atp_messages"
-    "atp_minimize"
     "attribute_setup"
-    "automaton"
     "ax_specification"
-    "axclass"
     "axiomatization"
     "axioms"
     "back"
+    "bnf_def"
     "boogie_end"
     "boogie_open"
     "boogie_status"
     "boogie_vc"
+    "bundle"
     "by"
     "cannot_undo"
     "case"
@@ -54,6 +47,7 @@
     "class_deps"
     "classes"
     "classrel"
+    "codata"
     "code_abort"
     "code_class"
     "code_const"
@@ -61,28 +55,26 @@
     "code_deps"
     "code_include"
     "code_instance"
-    "code_library"
-    "code_module"
     "code_modulename"
     "code_monad"
     "code_pred"
+    "code_reflect"
     "code_reserved"
     "code_thms"
     "code_type"
     "coinductive"
     "coinductive_set"
     "commit"
-    "constdefs"
     "consts"
-    "consts_code"
     "context"
     "corollary"
     "cpodef"
+    "data"
     "datatype"
     "declaration"
     "declare"
     "def"
-    "defaultsort"
+    "default_sort"
     "defer"
     "defer_recdef"
     "definition"
@@ -91,35 +83,45 @@
     "display_drafts"
     "domain"
     "domain_isomorphism"
+    "domaindef"
     "done"
     "enable_pr"
     "end"
+    "enriched_type"
     "equivariance"
     "exit"
     "export_code"
     "extract"
     "extract_type"
-    "finalconsts"
     "finally"
     "find_consts"
     "find_theorems"
+    "find_unused_assms"
     "fix"
-    "fixpat"
     "fixrec"
     "from"
     "full_prf"
     "fun"
     "function"
-    "global"
     "guess"
     "have"
     "header"
     "help"
     "hence"
-    "hide"
+    "hide_class"
+    "hide_const"
+    "hide_fact"
+    "hide_type"
+    "import_const_map"
+    "import_file"
+    "import_tptp"
+    "import_type_map"
+    "include"
+    "including"
     "inductive"
     "inductive_cases"
     "inductive_set"
+    "inductive_simps"
     "init_toplevel"
     "instance"
     "instantiation"
@@ -131,39 +133,42 @@
     "lemma"
     "lemmas"
     "let"
+    "lift_definition"
     "linear_undo"
-    "local"
     "local_setup"
     "locale"
+    "locale_deps"
     "method_setup"
     "moreover"
-    "new_domain"
     "next"
     "nitpick"
     "nitpick_params"
     "no_notation"
     "no_syntax"
     "no_translations"
+    "no_type_notation"
     "nominal_datatype"
     "nominal_inductive"
     "nominal_inductive2"
     "nominal_primrec"
-    "nonterminals"
-    "normal_form"
+    "nonterminal"
     "notation"
     "note"
+    "note_cyclic"
     "note_prefix_closed"
     "note_unified"
-    "note_cyclic"
+    "notepad"
     "obtain"
     "oops"
     "oracle"
     "overloading"
     "parse_ast_translation"
     "parse_translation"
+    "partial_function"
     "pcpodef"
     "pr"
     "prefer"
+    "prefix_close"
     "presume"
     "pretty_setmargin"
     "prf"
@@ -171,25 +176,35 @@
     "print_abbrevs"
     "print_antiquotations"
     "print_ast_translation"
-    "print_atps"
     "print_attributes"
     "print_binds"
+    "print_bnfs"
+    "print_bundles"
     "print_cases"
     "print_claset"
     "print_classes"
     "print_codeproc"
     "print_codesetup"
+    "print_coercion_maps"
+    "print_coercions"
     "print_commands"
     "print_configs"
     "print_context"
+    "print_dependencies"
     "print_drafts"
     "print_facts"
     "print_induct_rules"
+    "print_inductives"
     "print_interps"
     "print_locale"
     "print_locales"
     "print_methods"
     "print_orders"
+    "print_quotconsts"
+    "print_quotients"
+    "print_quotientsQ3"
+    "print_quotmaps"
+    "print_quotmapsQ3"
     "print_rules"
     "print_simpset"
     "print_statement"
@@ -204,8 +219,11 @@
     "pwd"
     "qed"
     "quickcheck"
+    "quickcheck_generator"
     "quickcheck_params"
     "quit"
+    "quotient_definition"
+    "quotient_type"
     "realizability"
     "realizers"
     "recdef"
@@ -216,15 +234,28 @@
     "remove_thy"
     "rep_datatype"
     "role"
-    "repdef"
+    "schematic_corollary"
+    "schematic_lemma"
+    "schematic_theorem"
     "sect"
     "section"
     "setup"
+    "setup_lifting"
     "show"
     "simproc_setup"
     "sledgehammer"
+    "sledgehammer_params"
     "smt_status"
+    "solve_direct"
     "sorry"
+    "spark_end"
+    "spark_open"
+    "spark_open_siv"
+    "spark_open_vcg"
+    "spark_proof_functions"
+    "spark_status"
+    "spark_types"
+    "spark_vc"
     "specification"
     "statespace"
     "subclass"
@@ -234,6 +265,7 @@
     "subsubsect"
     "subsubsection"
     "syntax"
+    "syntax_declaration"
     "term"
     "termination"
     "text"
@@ -246,17 +278,18 @@
     "thm_deps"
     "thus"
     "thy_deps"
-    "touch_thy"
     "translations"
+    "try"
+    "try0"
     "txt"
     "txt_raw"
     "typ"
+    "type_invariant"
+    "type_notation"
+    "type_synonym"
     "typed_print_translation"
     "typedecl"
     "typedef"
-    "types"
-    "types_code"
-    "type_invariant"
     "ultimately"
     "undo"
     "undos_proof"
@@ -265,77 +298,66 @@
     "use"
     "use_thy"
     "using"
-    "prefix_close"
     "value"
     "values"
     "welcome"
     "with"
+    "wrap_data"
+    "write"
     "{"
     "}"))
 
 (defconst isar-keywords-minor
-  '("actions"
-    "advanced"
+  '("advanced"
     "and"
     "assumes"
     "attach"
     "avoids"
     "begin"
     "binder"
-    "compose"
+    "checking"
     "congs"
     "constrains"
-    "contains"
+    "datatypes"
+    "defaults"
     "defines"
     "file"
     "fixes"
     "for"
-    "hide_action"
+    "functions"
     "hints"
     "identifier"
     "if"
     "imports"
     "in"
+    "includes"
     "infix"
     "infixl"
     "infixr"
-    "initially"
-    "inputs"
-    "internals"
     "is"
+    "keywords"
     "lazy"
     "module_name"
     "monos"
     "morphisms"
+    "no_dests"
     "notes"
     "obtains"
     "open"
     "output"
-    "outputs"
     "overloaded"
     "permissive"
     "pervasive"
-    "post"
-    "pre"
-    "rename"
-    "restrict"
+    "rep_compat"
     "shows"
-    "signature"
-    "states"
     "structure"
-    "to"
-    "transitions"
-    "transrel"
     "unchecked"
+    "unsafe"
     "uses"
     "where"))
 
 (defconst isar-keywords-control
   '("Isabelle\\.command"
-    "Isar\\.begin_document"
-    "Isar\\.define_command"
-    "Isar\\.edit_document"
-    "Isar\\.end_document"
     "ProofGeneral\\.inform_file_processed"
     "ProofGeneral\\.inform_file_retracted"
     "ProofGeneral\\.kill_proof"
@@ -343,64 +365,73 @@
     "ProofGeneral\\.restart"
     "ProofGeneral\\.undo"
     "cannot_undo"
+    "cd"
+    "commit"
+    "disable_pr"
+    "enable_pr"
     "exit"
     "init_toplevel"
     "kill"
+    "kill_thy"
     "linear_undo"
     "quit"
+    "remove_thy"
     "undo"
-    "undos_proof"))
+    "undos_proof"
+    "use_thy"))
 
 (defconst isar-keywords-diag
   '("ML_command"
     "ML_val"
     "ProofGeneral\\.pr"
-    "atp_info"
-    "atp_kill"
-    "atp_messages"
-    "atp_minimize"
     "boogie_status"
-    "cd"
     "class_deps"
     "code_deps"
     "code_thms"
-    "commit"
-    "disable_pr"
     "display_drafts"
-    "enable_pr"
     "export_code"
     "find_consts"
     "find_theorems"
+    "find_unused_assms"
     "full_prf"
     "header"
     "help"
-    "kill_thy"
+    "locale_deps"
     "nitpick"
-    "normal_form"
     "pr"
     "pretty_setmargin"
     "prf"
     "print_abbrevs"
     "print_antiquotations"
-    "print_atps"
     "print_attributes"
     "print_binds"
+    "print_bnfs"
+    "print_bundles"
     "print_cases"
     "print_claset"
     "print_classes"
     "print_codeproc"
     "print_codesetup"
+    "print_coercion_maps"
+    "print_coercions"
     "print_commands"
     "print_configs"
     "print_context"
+    "print_dependencies"
     "print_drafts"
     "print_facts"
     "print_induct_rules"
+    "print_inductives"
     "print_interps"
     "print_locale"
     "print_locales"
     "print_methods"
     "print_orders"
+    "print_quotconsts"
+    "print_quotients"
+    "print_quotientsQ3"
+    "print_quotmaps"
+    "print_quotmapsQ3"
     "print_rules"
     "print_simpset"
     "print_statement"
@@ -412,17 +443,18 @@
     "pwd"
     "quickcheck"
     "refute"
-    "remove_thy"
     "sledgehammer"
     "smt_status"
+    "solve_direct"
+    "spark_status"
     "term"
     "thm"
     "thm_deps"
     "thy_deps"
-    "touch_thy"
+    "try"
+    "try0"
     "typ"
     "unused_thms"
-    "use_thy"
     "value"
     "values"
     "welcome"))
@@ -444,128 +476,153 @@
 
 (defconst isar-keywords-theory-decl
   '("ML"
+    "ML_file"
     "abbreviation"
     "arities"
     "atom_decl"
     "attribute_setup"
-    "automaton"
-    "axclass"
     "axiomatization"
     "axioms"
     "boogie_end"
     "boogie_open"
+    "bundle"
     "class"
     "classes"
     "classrel"
+    "codata"
     "code_abort"
     "code_class"
     "code_const"
     "code_datatype"
     "code_include"
     "code_instance"
-    "code_library"
-    "code_module"
     "code_modulename"
     "code_monad"
+    "code_reflect"
     "code_reserved"
     "code_type"
     "coinductive"
     "coinductive_set"
-    "constdefs"
     "consts"
-    "consts_code"
     "context"
+    "data"
     "datatype"
     "declaration"
     "declare"
-    "defaultsort"
+    "default_sort"
     "defer_recdef"
     "definition"
     "defs"
     "domain"
     "domain_isomorphism"
+    "domaindef"
     "equivariance"
     "extract"
     "extract_type"
-    "finalconsts"
-    "fixpat"
     "fixrec"
     "fun"
-    "global"
-    "hide"
+    "hide_class"
+    "hide_const"
+    "hide_fact"
+    "hide_type"
+    "import_const_map"
+    "import_file"
+    "import_tptp"
+    "import_type_map"
     "inductive"
     "inductive_set"
     "instantiation"
     "judgment"
     "lemmas"
-    "local"
     "local_setup"
     "locale"
     "method_setup"
-    "new_domain"
     "nitpick_params"
     "no_notation"
     "no_syntax"
     "no_translations"
+    "no_type_notation"
     "nominal_datatype"
-    "nonterminals"
+    "nonterminal"
     "notation"
+    "notepad"
     "oracle"
     "overloading"
     "parse_ast_translation"
     "parse_translation"
+    "partial_function"
     "primrec"
     "print_ast_translation"
     "print_translation"
     "protocol"
+    "quickcheck_generator"
     "quickcheck_params"
     "realizability"
     "realizers"
     "recdef"
     "record"
     "refute_params"
-    "repdef"
     "role"
     "setup"
+    "setup_lifting"
     "simproc_setup"
+    "sledgehammer_params"
+    "spark_end"
+    "spark_open"
+    "spark_open_siv"
+    "spark_open_vcg"
+    "spark_proof_functions"
+    "spark_types"
     "statespace"
     "syntax"
+    "syntax_declaration"
     "text"
     "text_raw"
     "theorems"
     "translations"
+    "type_invariant"
+    "type_notation"
+    "type_synonym"
     "typed_print_translation"
     "typedecl"
-    "types"
-    "types_code"
-    "type_invariant"
     "use"))
 
 (defconst isar-keywords-theory-script
-  '("inductive_cases"))
+  '("inductive_cases"
+    "inductive_simps"))
 
 (defconst isar-keywords-theory-goal
   '("ax_specification"
+    "bnf_def"
     "boogie_vc"
     "code_pred"
     "corollary"
     "cpodef"
+    "enriched_type"
     "function"
     "instance"
     "interpretation"
     "lemma"
+    "lift_definition"
     "nominal_inductive"
     "nominal_inductive2"
     "nominal_primrec"
     "pcpodef"
+    "quotient_definition"
+    "quotient_type"
     "recdef_tc"
     "rep_datatype"
+    "schematic_corollary"
+    "schematic_lemma"
+    "schematic_theorem"
+    "spark_vc"
     "specification"
     "subclass"
     "sublocale"
     "termination"
     "theorem"
-    "typedef"))
+    "typedef"
+    "wrap_data"))
 
 (defconst isar-keywords-qed
   '("\\."
@@ -610,17 +667,19 @@
 (defconst isar-keywords-proof-decl
   '("ML_prf"
     "also"
+    "include"
+    "including"
     "let"
     "moreover"
     "note"
+    "note_cyclic"
     "note_prefix_closed"
     "note_unified"
-    "note_cyclic"
     "txt"
     "txt_raw"
     "unfolding"
     "using"
-    "prefix_close"))
+    "write"))
 
 (defconst isar-keywords-proof-asm
   '("assume"
diff --git a/interactive-only-src/Paths_scyther_proof.hs b/interactive-only-src/Paths_scyther_proof.hs
--- a/interactive-only-src/Paths_scyther_proof.hs
+++ b/interactive-only-src/Paths_scyther_proof.hs
@@ -12,7 +12,7 @@
 
 
 version :: Version
-version = Version {versionBranch = [0,5,0,0], versionTags = []}
+version = Version {versionBranch = [0,6,0,0], versionTags = []}
 bindir, libdir, datadir, libexecdir :: FilePath
 
 bindir     = "."
diff --git a/scyther-proof.cabal b/scyther-proof.cabal
--- a/scyther-proof.cabal
+++ b/scyther-proof.cabal
@@ -1,25 +1,27 @@
 build-type:         Simple
 name:               scyther-proof
-version:            0.5.0.0
+version:            0.6.0.0
 license:            GPL
 license-file:       LICENSE
 category:           Security, Theorem Provers
-author:             Simon Meier <simon.meier@inf.ethz.ch>
-maintainer:         Simon Meier <simon.meier@inf.ethz.ch>
-copyright:          Simon Meier, ETH Zurich, 2009-2011
-synopsis:           Automatic generation of Isabelle/HOL correctness proofs for security protocols.
-description:
-                    scyther-proof is a security protocol verification tool
+author:             Simon Meier <iridcode@gmail.com>, 
+                    Andreas Lochbihler <andreas.lochbihler@inf.ethz.ch>
+maintainer:         Simon Meier <iridcode@gmail.com>
+copyright:          Simon Meier, Andreas Lochbihler, ETH Zurich, 2009-2013
+
+synopsis:           Automatic generation of Isabelle/HOL correctness proofs 
+                    for security protocols.
+
+description:        scyther-proof is a security protocol verification tool
                     based on an algorithm similar to the Scyther tool developed
                     by Cas Cremers
                     (<http://people.inf.ethz.ch/cremersc/scyther/index.html>).
                     The theory underlying scyther-proof is described in the
-                    paper \"Strong Invariants for the Efficient Construction of
-                    Machine-Checked Protocol Security Proofs\" by Meier,
-                    Cremers, and Basin available from
-                    <http://people.inf.ethz.ch/meiersi/publications/index.html>
-
-homepage:           http://www.infsec.ethz.ch/people/meiersi/
+                    2013 Journal of Computer Security paper 
+                    \"Efficient Construction of 
+                    Machine-Checked Protocol Security Proofs\" 
+                    by Meier, Cremers, and Basin available from
+                    <https://github.com/meiersi/scyther-proof/tree/master/publications>.
 stability:          Beta
 cabal-version:      >= 1.8
 data-dir:           data
@@ -81,10 +83,9 @@
 
   isabelle/AUTHORS
   isabelle/document/root.tex
-  isabelle/IsaMakefile
   isabelle/Makefile
   isabelle/README
-  isabelle/ROOT.ML
+  isabelle/ROOT
   isabelle/src/isar-keywords.el
   isabelle/src/*.thy
   isabelle/src/ESPLogic/*.thy
diff --git a/src/Main.hs b/src/Main.hs
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -24,7 +24,6 @@
 import System.Directory
 import System.Isabelle
 import System.Info
-import System.Timeout
 import System.Timing
 import System.Environment
 import System.Process
@@ -63,7 +62,7 @@
   [ programName
   , " "
   , showVersion version
-  , ", (C) Simon Meier, ETH Zurich, 2009-2012"
+  , ", (C) Simon Meier, Andreas Lochbihler, ETH Zurich, 2009-2013"
   ]
 
 -- | Version string with HTML markup.
@@ -73,8 +72,9 @@
     , " "
     , showVersion version
     , ", &copy; "
-    , link "http://people.inf.ethz.ch/meiersi" "Simon Meier"
-    , ", ETH Zurich, 2009-2012"
+    , link "https://github.com/meiersi/scyther-proof" "Simon Meier"
+    , link "http://github.com/meiersi" "Andreas Lochbihler"
+    , ", ETH Zurich, 2009-2013"
     ]
   where
     link href name =
@@ -86,8 +86,10 @@
 
 -- | ESPL Theory directory.
 esplTheoryDir :: IO String
-esplTheoryDir = getDataFileName "isabelle"
-
+esplTheoryDir = do
+  currDir <- getCurrentDirectory
+  esplDir <- getDataFileName "isabelle"
+  return (if isAbsolute esplDir then esplDir else currDir </> esplDir)
 
 ------------------------------------------------------------------------------
 -- Argument parsing helpers
@@ -149,8 +151,8 @@
           , "  The '--html' flag requires the 'dot' tool from GraphViz available at:"
           , "    " ++ "http://www.graphviz.org/"
           , "  "
-          , "  The '--isabelle' flag requires the 'Isabelle-2009-1' release of Isabelle/HOL:"
-          , "    " ++ "http://isabelle.in.tum.de/website-Isabelle2009-1/download_x86-linux.html"
+          , "  The '--isabelle' flag requires the 'Isabelle-2013' release of Isabelle/HOL:"
+          , "    " ++ "http://isabelle.in.tum.de/website-Isabelle2013/index.html"
           , ""
           , "  Check the '" ++ readmePath ++ "' file for instructions on how to load the generated theory files in Isabelle's interactive mode."
           ]
@@ -196,15 +198,9 @@
                   "Number of parellel threads to be used for proof checking. \
                   \(The default is to use as many threads as there are cores.)"
 
-              , flagNone ["rebuild-logic"] (addEmpty "rebuildLogic")
-                  "Rebuild the ESPL logic image (required after updating its source)"
-
               , flagNone ["no-generation"] (addEmpty "noGeneration")
                   "Do not generate the theory files, but check the results using Isabelle."
 
-              , flagOpt "0" ["timeout"]   (upd "timeout") "SECONDS"
-                  "Timeout in seconds for proof generation and checking."
-
               , flagOpt "" ["hide-prefix"]   (upd "hidePrefix") "VALUE"
                   "Hide non-referenced properties with this prefix (default=auto)."
 
@@ -297,12 +293,11 @@
                 -> MVar (T.Table String) -- ^ Empty MVar for building the report.
                 -> IO ()
 translateWorker as templateFile reportVar
-  | null inFiles && not rebuildLogic = errHelpExit "no input iles given"
-  | otherwise                        = do
+  | null inFiles = errHelpExit "no input files given"
+  | otherwise    = do
       -- check required tools
       when (not dryRun && html)     (ensureGraphVizDot dotTool)
-      when (rebuildLogic || (not dryRun && isabelle))
-          (ensureIsabelleESPL rebuildLogic isabelleTool)
+      when (not dryRun && isabelle) (ensureIsabelleESPL isabelleTool)
 
       -- translate all input files and ensure report is written with a special
       -- interrupted marker when an exception like Ctrl-C happened
@@ -315,7 +310,6 @@
   where
     -- Tool paths and flags
     -----------------------
-    rebuildLogic = argExists "rebuildLogic" as
     isabelleTool = fromMaybe "isabelle" $ findArg "isabelle" as
     dotTool      = fromMaybe "dot"      $ findArg "html" as
 
@@ -370,28 +364,6 @@
       | argExists "composeParallel" as = composeParallel
       | otherwise                      = id
 
-    -- timeout handling
-    -------------------
-    maxTime :: Maybe Int
-    maxTime = findCheckedArg (0 <) "timeout" as
-
-    execWithTimeout :: IO a -> IO a
-    execWithTimeout io = case maxTime of
-        Nothing -> io
-        Just t  -> do
-            res <- timeout (t * 1000000) io
-            case res of
-              Nothing -> do
-                updateReport (T.appendCell $ "timeout: "++show maxTime++"s")
-                throw CustomTimeout
-              Just x -> return x
-
-    ignoringTimeout :: IO () -> IO ()
-    ignoringTimeout io = E.catch io handler
-      where
-      handler :: CustomTimeout -> IO ()
-      handler _ = return ()
-
     -- progress output for batch mode
     ---------------------------------
     putInfo   msg = unless dryRun (putStr   msg >> hFlush stdout)
@@ -467,6 +439,7 @@
       cmdLine <- getCommandLine
       time    <- getCurrentTime
       cpu     <- getCpuModel
+      esplSrc <- esplTheoryDir
       theoryToHtml $ GenerationInput {
           giHeader      = "Generated by " ++ htmlVersionStr
         , giTime        = time
@@ -483,7 +456,7 @@
         , giDotTool     = dotTool
         , giIsabelle    =
             if isabelle
-              then Just $ checkTheoryFile isabelleTool isabelleThreads 0 "ESPL"
+              then Just $ checkTheoryFile isabelleTool isabelleThreads esplSrc
               else Nothing
         }
 
@@ -615,7 +588,7 @@
     writeThyFile outPath thy = do
       if not noGeneration
         then do
-          tGen <- execWithTimeout . timed_ . writeFile outPath .
+          tGen <- timed_ . writeFile outPath .
                   thyToString $ adaptTheoryName outPath thy
           let prfSize = theoryProofSize thy
           reportNumber "Generation Time" tGen
@@ -628,9 +601,8 @@
           sequence_ . replicate 3 $ reportString "-" "--n"
       if isabelle
         then do
-          -- let isabelleTimeout = maxTime * 10^6 -- in microseconds
-          let isabelleTimeout = 0 -- because timeout construction for Isabelle is buggy currently
-          ((_, result), tCheck) <- timed $ checkTheoryFile isabelleTool isabelleThreads isabelleTimeout "ESPL" outPath
+          esplSrc <- esplTheoryDir
+          (result, tCheck) <- timed $ checkTheoryFile isabelleTool isabelleThreads esplSrc outPath
           reportNumber "Checking Time" tCheck
           case result of
             Nothing -> do
@@ -638,7 +610,7 @@
               reportString "Isabelle Status" "checked"
               reportString "Isabelle Message" ""
             Just msg -> do
-              mapM_ (putInfo . ('\t':)) ["CHECK FAILED", show tCheck, show msg]
+              mapM_ (putInfo . ('\t':)) ["CHECK FAILED", show tCheck, '\n' : msg]
               reportString "Isabelle Status" "check failed"
               reportString "Isabelle Message" (show msg)
         else
@@ -664,7 +636,7 @@
       outPath = mkOutPath inFile
 
     translateOneFile :: FilePath -> IO ()
-    translateOneFile inFile = ignoringTimeout (readThy inFile >>= processThy inFile)
+    translateOneFile inFile = readThy inFile >>= processThy inFile
 
 
 ------------------------------------------------------------------------------
@@ -774,27 +746,24 @@
 
 -- | Ensure a suitable version of the Isabelle/HOL 'isabelle' tool is installed
 -- and the 'ESPL' head is compiled.
-ensureIsabelleESPL :: Bool     -- ^ True if logic must rebuilt anyways.
-                   -> FilePath -- ^ Path to the 'isabelle' tool.
+ensureIsabelleESPL :: FilePath -- ^ Path to the 'isabelle' tool.
                    -> IO ()
-ensureIsabelleESPL rebuild isabelle = do
+ensureIsabelleESPL isabelle = do
     putStrLn $ "checking suitability of Isabelle tool: '" ++ isabelle ++ "'"
     _ <- testProcess checkVersion " version: " isabelle ["version"] ""
     success <- testProcess checkLogics " installed logics: " isabelle ["findlogics"] ""
-    if success && not rebuild
-      then putStrLn " (use the flag --rebuild-logic if your image of ESPL is outdated)"
-      else buildESPL
+    unless success buildESPL
     putStrLn ""
   where
     checkVersion out _
-      | "Isabelle2009-1" `isInfixOf` out = Right $ init out ++ ". OK."
+      | "Isabelle2013" `isInfixOf` out = Right $ init out ++ ". OK."
       | otherwise                        = Left  $ unlines $
           [ "WARNING:"
           , ""
-          , " " ++ programName ++ " requires Isabelle2009-1."
+          , " " ++ programName ++ " requires Isabelle2013."
           , " Proof checking is likely not to work."
-          , " Please download Isabelle2009-1 from:"
-          , "   http://isabelle.in.tum.de/website-Isabelle2009-1/download_x86-linux.html"
+          , " Please download Isabelle2013 from:"
+          , "   http://isabelle.in.tum.de/website-Isabelle2013/index.html"
           ]
 
     checkLogics out _
@@ -807,9 +776,9 @@
       putStrLn "Attempting to build ESPL logic (this may take several minutes):"
       theoryDir <- esplTheoryDir
       let isamake args =
-            runProcess isabelle ("make" :args) (Just theoryDir) Nothing Nothing Nothing Nothing
+            runProcess isabelle ("build" : "-d" : theoryDir : args) (Just theoryDir) Nothing Nothing Nothing Nothing
               >>= waitForProcess
-      exitCode <- isamake ["clean"] >> isamake []
+      exitCode <- isamake ["-b", "ESPL"]
       case exitCode of
         ExitSuccess -> putStrLn "Sucess! :-)\n---"
         ExitFailure code -> putStrLn $ unlines
diff --git a/src/Scyther/Theory/Html.hs b/src/Scyther/Theory/Html.hs
--- a/src/Scyther/Theory/Html.hs
+++ b/src/Scyther/Theory/Html.hs
@@ -74,10 +74,9 @@
   , giDotTool     :: String    -- ^ 'dot' tool to use.
   , giCmdLine     :: String    -- ^ The command line that was used in this call to
                                --   scyther-proof.
-  , giIsabelle    :: Maybe (FilePath -> IO (IO String, Maybe String))
+  , giIsabelle    :: Maybe (FilePath -> IO (Maybe String))
                                -- ^ A checking function calling isabelle with
-                               -- the right parameters and returning an IO function
-                               -- for retrieving the logfile contents and an error
+                               -- the right parameters which return an error
                                -- message in case the check didn't succeed.
   }
 
@@ -85,7 +84,6 @@
 data PathInfo = PathInfo {
     inputFileCopy   :: FilePath  -- ^ Path of input file copy.
   , proofScriptFile :: FilePath  -- ^ Path of generated Isabelle proof script.
-  , logFileCopy     :: FilePath  -- ^ Path of the copy of the logFile
   , outDir          :: FilePath  -- ^ Output directory.
   , imageDir        :: FilePath  -- ^ Relative directory for graphs.
   , filesDir        :: FilePath  -- ^ Relative directory for input and output files.
@@ -99,7 +97,6 @@
       { inputFileCopy   = filesDir info </> takeFileName (giInputFile input)
       , proofScriptFile = filesDir info </> 
           addExtension (takeBaseName (giInputFile input) ++ "_cert_auto") "thy"
-      , logFileCopy     = filesDir info </> "logfile"
       , outDir          = giOutDir input
       , imageDir        = "img"
       , filesDir        = "files"
@@ -119,8 +116,8 @@
 -- theories for exporting as JSON.
 jsGenerationInfo :: GenerationInput
                  -> NominalDiffTime  -- ^ Proof script generation time.
-                 -> Maybe (Bool, NominalDiffTime, FilePath) 
-                                     -- ^ Proof checking time and relative logfile path.
+                 -> Maybe (Bool, NominalDiffTime) 
+                                     -- ^ Proof checking time.
                  -> JSObject JSValue
 jsGenerationInfo input genTime optCheckInfo = toJSObject $
     [ ("header",      showJSON . toJSString $ giHeader input)
@@ -138,10 +135,8 @@
 
     checkInfo Nothing                              = 
         [ ("certificateStatus", showJSON . toJSString $ genTimeString) ]
-    checkInfo (Just (success, checkTime, logFile)) =
-        [ ( "certificateStatus", showJSON . toJSString $ genTimeString ++ status)
-        , ( "logFile", showJSON (toJSString "logfile", toJSString logFile))
-        ]
+    checkInfo (Just (success, checkTime)) =
+        [ ( "certificateStatus", showJSON . toJSString $ genTimeString ++ status) ]
       where
         status | success   = ", successfully checked in " ++ show checkTime
                | otherwise = ", CHECK FAILED after " ++ show checkTime
@@ -164,13 +159,11 @@
     Nothing           -> return Nothing
     Just machineCheck -> do
       putStr " checking proof script: " >> hFlush stdout
-      ((logFileContents, optErrMsg), checkTime) <- timed $ 
+      (optErrMsg, checkTime) <- timed $ 
         machineCheck (mkAbsolute paths $ proofScriptFile paths)
       putStrLn $ show checkTime
       -- write log file copy
-      contents <- logFileContents
-      writeAbsolute (logFileCopy paths) contents
-      return $ Just (isNothing optErrMsg, checkTime, logFileCopy paths)
+      return $ Just (isNothing optErrMsg, checkTime)
   -- json output
   let thyJSON = mkThyJSON (jsGenerationInfo input genTime optCheckInfo)
   writeAbsolute "theory.js"
diff --git a/src/Scyther/Theory/Pretty.hs b/src/Scyther/Theory/Pretty.hs
--- a/src/Scyther/Theory/Pretty.hs
+++ b/src/Scyther/Theory/Pretty.hs
@@ -343,8 +343,8 @@
 -- Isabelle tactic.
 isaTactic :: TrivReason -> String
 isaTactic TrivContradictoryPremises   = "((clarsimp, order?) | order)"
-isaTactic (TrivLongTermKeySecrecy _)  = "(fastsimp dest!: ltk_secrecy)"
-isaTactic TrivPremisesImplyConclusion = "(fastsimp intro: event_predOrdI split: if_splits)"
+isaTactic (TrivLongTermKeySecrecy _)  = "(fastforce dest!: ltk_secrecy)"
+isaTactic TrivPremisesImplyConclusion = "(fastforce intro: event_predOrdI split: if_splits)"
 
 -- | Isabelle proof of long-term key secrecy.
 isaLongTermKeySecrecyProof :: Protocol -> Doc
@@ -460,7 +460,7 @@
 
 
   prettyForwardContradiction thRef =
-    kwBy <-> text "(fastsimp dest:" <-> thRef <-> text "intro: event_predOrdI)"
+    kwBy <-> text "(fastforce dest:" <-> thRef <-> text "intro: event_predOrdI)"
   prettyForwardResolution thRef thSe mapping
     | isJust . destTypingFormula . seConcl $ thSe = emptyDoc
     | otherwise = do
@@ -491,7 +491,7 @@
       | any (`isPrefixOf` name) ["ik0", "fake"] || null newVars = text name
       | otherwise = parens $ text name <-> hsep (map ppNewVar newVars)
   prettyChainRuleQED _ trivCases
-    | null tactics = kwQED <-> text "(insert facts, fastsimp+)?" -- be conservative
+    | null tactics = kwQED <-> text "(insert facts, fastforce+)?" -- be conservative
     | otherwise    =
         kwQED <-> text "(insert facts, (" <> hsep (intersperse (text "|") tactics) <> text ")+)?"
     where
@@ -535,7 +535,7 @@
     ) $-$
     (text "thus ?thesis proof(cases rule: Kbd_cases)")
 
-  prettySplitEqQed = text "qed (fastsimp+)?"
+  prettySplitEqQed = text "qed (fastforce+)?"
 
   -- theory output
   prettyComment comment = text "(*" <-> text comment <-> text "*)"
@@ -601,7 +601,7 @@
     pure body $-$
     text "" $-$ text "end"
     where
-    imports = ["../ESPLogic"]
+    imports = ["ESPLogic"]
 
 
 -- | Pretty-print an injectivity sequent. Works only for two-party
@@ -614,7 +614,7 @@
            , nest 2 (sep [text "prems =", nest 2 $ ppPrems <> semi])
            , nest 2 (sep [text "concs =", nest 2 $ ppConcs])
            , text "in" <->
-               isaExists conf <> text "f. inj_on f prems" <-> isaAnd conf <->
+               isaExists conf <> text "f. inj_on f (Collect prems)" <-> isaAnd conf <->
                parens ( isaForall conf <> text "i. prems i" <->
                         isaImplies conf <-> text "concs i (f i)" )
            ]
diff --git a/src/System/Isabelle.hs b/src/System/Isabelle.hs
--- a/src/System/Isabelle.hs
+++ b/src/System/Isabelle.hs
@@ -2,57 +2,20 @@
 --
 -- Requirements:
 --
---   1. A working installation of Isabelle2009-1 (http://isabelle.in.tum.de/)
+--   1. A working installation of Isabelle2013 (http://isabelle.in.tum.de/)
 --   2. The \'isabelle\' command must be on the PATH.
 --
 module System.Isabelle (
   checkTheoryFile
 ) where
 
-import Data.Maybe
 import Data.List
 
 import System.FilePath
 import System.Directory
 import System.Process
 import System.IO
-
-import Control.Concurrent
-import Control.Monad
-import Control.Exception
-
-------------------------------------------------------------------------------
--- Utilities: TODO MOVE INTO GENERAL FILE
-------------------------------------------------------------------------------
-
--- | Create and use a temporary file ensuring that it is closed if the
--- computation fails.
---
--- See 'openTempFile' for more information on the parameters.
-withTempFile :: FilePath -> String -> ((FilePath, Handle) -> IO a) -> IO (a, FilePath)
-withTempFile dir nameTemplate io = 
-  bracket (openTempFile dir nameTemplate) (hClose . snd) 
-          (\args@(file,_) -> do{ x <- io args; return (x, file) })
-
--- | Like 'withTempFile' buth without returning the results of the inner
--- computation.
-withTempFile_ :: FilePath -> String -> ((FilePath, Handle) -> IO a) -> IO FilePath
-withTempFile_ dir nameTemplate io = snd `liftM` withTempFile dir nameTemplate io
-
--- | Waits the given amount of microseconds before trying to terminate the
--- process using 'terminateProcess'.
-waitForProcessTimeout :: Int -> ProcessHandle -> IO Bool
-waitForProcessTimeout maxTime hProc
-  | maxTime <= 0 = do _<- waitForProcess hProc; return False
-  | otherwise    = do
-      timeout <- newMVar False
-      _ <- forkIO $ do
-        threadDelay maxTime
-        modifyMVar_ timeout (return . const True)
-        terminateProcess hProc
-      _ <- waitForProcess hProc
-      readMVar timeout
-    
+import System.Exit
 
 ------------------------------------------------------------------------------
 -- Isabelle commands
@@ -61,51 +24,31 @@
 -- | Use Isabelle to check the correctness of a theory file.
 checkTheoryFile :: FilePath            -- ^ Path to 'isabelle' binary.
                 -> Maybe Int           -- ^ Number of parallel thread to use while checking.
-                -> Int                 -- ^ Maximal available time in micro-seconds
-                -> String              -- ^ Logic Image to use
+                -> FilePath            -- ^ Path to ESPL sources
                 -> FilePath            -- ^ Path to file to be checked
-                -> IO (IO String, Maybe String)
+                -> IO (Maybe String)
                    -- ^ If the check went through, log-file content only, otherwise
                    -- also an error message.
-checkTheoryFile isabelleTool threads maxTime logic thyFile = do
+checkTheoryFile isabelleTool threads esplSrc thyFile = do
   let thyName     = takeBaseName thyFile
-      rootName    = "ROOT-" ++ thyName ++ ".ML"
+      rootName    = "ROOT"
       sessionName = "scyther-proof-" ++ thyName
-  -- create ROOT.ML file
-  tmpDir <- getTemporaryDirectory
-  rootFile <- withTempFile_ tmpDir rootName 
-    (\(_, hRootFile) -> 
-      hPutStrLn hRootFile $ "use_thy \"" ++ dropExtension thyFile ++ "\""
-    )
+  
+  -- setup temporary directory
+  tmpDir <- createTempDirectory
+  copyFile thyFile (tmpDir </> addExtension thyName "thy")
+  writeFile (tmpDir </> rootName) ("session \"" ++ sessionName ++ "\" = ESPL + theories \"" ++ thyName ++ "\"")
   -- call "isabelle usedir"
-  finally 
-    (do let cmd = isabelleTool ++ 
-                     " usedir -f " ++ rootFile ++ 
-                     " -s " ++ sessionName ++ 
-                     " -M " ++ maybe "0" show threads ++
-                        " " ++ logic ++ " ."
-        (_,   _,    hErr, hProc) <- runInteractiveCommand cmd
-        isaOutVar <- newEmptyMVar
-        _ <-forkIO $ redirect hErr isaOutVar
-        timeout <- waitForProcessTimeout maxTime hProc
-        isaOut <- takeMVar isaOutVar
-        if timeout
-          then do return (return $ isaOut ++ "Interrupted due to timeout!"
-                         , Just $ "timeout: " ++ 
-                              show ((fromIntegral maxTime / 10E6)::Double) ++ "s")
-          else do return $ parseIsaOutput sessionName isaOut
-    )
-    (do removeFile rootFile)
+  (code, out, _err) <- readProcessWithExitCode isabelleTool
+     ["build", "-d", esplSrc, "-D", tmpDir, "-j", maybe "0" show threads]
+     ""
+  if code == ExitSuccess
+    then do
+      removeDirectoryRecursive tmpDir
+      return Nothing
+    else
+      return (Just (errMsg out))        
   where
-  -- | Redirect the contents of a the given handle into the message variable.
-  redirect hIn mvar = hGetContents hIn >>= putMVar mvar
-
-  -- | extract the log file name from the isabelle output
-  logFileName str = fromMaybe "no log file" $ do
-    let logIndicator = "(see also "
-    line <- find (logIndicator `isPrefixOf`) (lines str) 
-    init `liftM` stripPrefix logIndicator line
-  
   -- | Extract the error message from the isabelle output
   errMsg str = case break ("***" `isPrefixOf`) (lines str) of
     (_,[]) -> str
@@ -113,9 +56,12 @@
       (_,[]) -> unlines (first : ls)
       (ls',(fin:_)) -> unlines (first : ls'++[fin])
 
-  -- | Parse the Isabelle output.
-  parseIsaOutput sessionName str
-    | ("Finished "++logic++"-"++sessionName) `isInfixOf` str = (return str, Nothing)
-    | otherwise = (readFile (logFileName str), Just (errMsg str))
-
-        
+  createTempDirectory :: IO FilePath
+  createTempDirectory = do
+      tmpBase <- getTemporaryDirectory
+      -- hack to create a unique temporary directory
+      (tmpDir, handle) <- openTempFile tmpBase "scyther-proof_tmp"
+      hClose handle
+      removeFile tmpDir
+      createDirectory tmpDir
+      return tmpDir
