author | wenzelm |
Wed, 12 Mar 2025 11:39:00 +0100 | |
changeset 82265 | 4b875a4c83b0 |
parent 81261 | 0c9075bdff38 |
permissions | -rw-r--r-- |
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
1 |
theory Needham_Schroeder_Base |
66453
cc19f7ca2ed6
session-qualified theory imports: isabelle imports -U -i -d '~~/src/Benchmarks' -a;
wenzelm
parents:
62290
diff
changeset
|
2 |
imports Main "HOL-Library.Predicate_Compile_Quickcheck" |
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
3 |
begin |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
4 |
|
58310 | 5 |
datatype agent = Alice | Bob | Spy |
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
6 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
7 |
definition agents :: "agent set" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
8 |
where |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
9 |
"agents = {Spy, Alice, Bob}" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
10 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
11 |
definition bad :: "agent set" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
12 |
where |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
13 |
"bad = {Spy}" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
14 |
|
58310 | 15 |
datatype key = pubEK agent | priEK agent |
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
16 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
17 |
fun invKey |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
18 |
where |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
19 |
"invKey (pubEK A) = priEK A" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
20 |
| "invKey (priEK A) = pubEK A" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
21 |
|
58310 | 22 |
datatype |
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
23 |
msg = Agent agent |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
24 |
| Key key |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
25 |
| Nonce nat |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
26 |
| MPair msg msg |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
27 |
| Crypt key msg |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
28 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
29 |
syntax |
81019
dd59daa3c37a
clarified inner-syntax markup, notably for enumerations: prefer "notation=mixfix" over "entity" via 'syntax_consts' (see also 70076ba563d2);
wenzelm
parents:
80768
diff
changeset
|
30 |
"_MTuple" :: "['a, args] \<Rightarrow> 'a * 'b" (\<open>(\<open>indent=2 notation=\<open>mixfix message tuple\<close>\<close>\<lbrace>_,/ _\<rbrace>)\<close>) |
81261 | 31 |
syntax_consts |
32 |
"_MTuple" \<rightleftharpoons> MPair |
|
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
33 |
translations |
81019
dd59daa3c37a
clarified inner-syntax markup, notably for enumerations: prefer "notation=mixfix" over "entity" via 'syntax_consts' (see also 70076ba563d2);
wenzelm
parents:
80768
diff
changeset
|
34 |
"\<lbrace>x, y, z\<rbrace>" \<rightleftharpoons> "\<lbrace>x, \<lbrace>y, z\<rbrace>\<rbrace>" |
dd59daa3c37a
clarified inner-syntax markup, notably for enumerations: prefer "notation=mixfix" over "entity" via 'syntax_consts' (see also 70076ba563d2);
wenzelm
parents:
80768
diff
changeset
|
35 |
"\<lbrace>x, y\<rbrace>" \<rightleftharpoons> "CONST MPair x y" |
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
36 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
37 |
inductive_set |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
38 |
parts :: "msg set => msg set" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
39 |
for H :: "msg set" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
40 |
where |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
41 |
Inj [intro]: "X \<in> H ==> X \<in> parts H" |
61984 | 42 |
| Fst: "\<lbrace>X,Y\<rbrace> \<in> parts H ==> X \<in> parts H" |
43 |
| Snd: "\<lbrace>X,Y\<rbrace> \<in> parts H ==> Y \<in> parts H" |
|
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
44 |
| Body: "Crypt K X \<in> parts H ==> X \<in> parts H" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
45 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
46 |
inductive_set |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
47 |
analz :: "msg set => msg set" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
48 |
for H :: "msg set" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
49 |
where |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
50 |
Inj [intro,simp] : "X \<in> H ==> X \<in> analz H" |
61984 | 51 |
| Fst: "\<lbrace>X,Y\<rbrace> \<in> analz H ==> X \<in> analz H" |
52 |
| Snd: "\<lbrace>X,Y\<rbrace> \<in> analz H ==> Y \<in> analz H" |
|
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
53 |
| Decrypt [dest]: |
67613 | 54 |
"[|Crypt K X \<in> analz H; Key(invKey K) \<in> analz H|] ==> X \<in> analz H" |
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
55 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
56 |
inductive_set |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
57 |
synth :: "msg set => msg set" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
58 |
for H :: "msg set" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
59 |
where |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
60 |
Inj [intro]: "X \<in> H ==> X \<in> synth H" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
61 |
| Agent [intro]: "Agent agt \<in> synth H" |
61984 | 62 |
| MPair [intro]: "[|X \<in> synth H; Y \<in> synth H|] ==> \<lbrace>X,Y\<rbrace> \<in> synth H" |
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
63 |
| Crypt [intro]: "[|X \<in> synth H; Key(K) \<in> H|] ==> Crypt K X \<in> synth H" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
64 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
65 |
primrec initState |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
66 |
where |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
67 |
initState_Alice: |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
68 |
"initState Alice = {Key (priEK Alice)} \<union> (Key ` pubEK ` agents)" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
69 |
| initState_Bob: |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
70 |
"initState Bob = {Key (priEK Bob)} \<union> (Key ` pubEK ` agents)" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
71 |
| initState_Spy: |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
72 |
"initState Spy = (Key ` priEK ` bad) \<union> (Key ` pubEK ` agents)" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
73 |
|
58310 | 74 |
datatype |
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
75 |
event = Says agent agent msg |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
76 |
| Gets agent msg |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
77 |
| Notes agent msg |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
78 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
79 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
80 |
primrec knows :: "agent => event list => msg set" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
81 |
where |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
82 |
knows_Nil: "knows A [] = initState A" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
83 |
| knows_Cons: |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
84 |
"knows A (ev # evs) = |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
85 |
(if A = Spy then |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
86 |
(case ev of |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
87 |
Says A' B X => insert X (knows Spy evs) |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
88 |
| Gets A' X => knows Spy evs |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
89 |
| Notes A' X => |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
90 |
if A' \<in> bad then insert X (knows Spy evs) else knows Spy evs) |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
91 |
else |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
92 |
(case ev of |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
93 |
Says A' B X => |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
94 |
if A'=A then insert X (knows A evs) else knows A evs |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
95 |
| Gets A' X => |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
96 |
if A'=A then insert X (knows A evs) else knows A evs |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
97 |
| Notes A' X => |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
98 |
if A'=A then insert X (knows A evs) else knows A evs))" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
99 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
100 |
abbreviation (input) |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
101 |
spies :: "event list => msg set" where |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
102 |
"spies == knows Spy" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
103 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
104 |
primrec used :: "event list => msg set" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
105 |
where |
61952 | 106 |
used_Nil: "used [] = \<Union>(parts ` initState ` agents)" |
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
107 |
| used_Cons: "used (ev # evs) = |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
108 |
(case ev of |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
109 |
Says A B X => parts {X} \<union> used evs |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
110 |
| Gets A X => used evs |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
111 |
| Notes A X => parts {X} \<union> used evs)" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
112 |
|
62290 | 113 |
subsection \<open>Preparations for sets\<close> |
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
114 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
115 |
fun find_first :: "('a => 'b option) => 'a list => 'b option" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
116 |
where |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
117 |
"find_first f [] = None" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
118 |
| "find_first f (x # xs) = (case f x of Some y => Some y | None => find_first f xs)" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
119 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
120 |
consts cps_of_set :: "'a set => ('a => term list option) => term list option" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
121 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
122 |
lemma |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
123 |
[code]: "cps_of_set (set xs) f = find_first f xs" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
124 |
sorry |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
125 |
|
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
48618
diff
changeset
|
126 |
consts pos_cps_of_set :: "'a set => ('a => (bool * term list) option) => natural => (bool * term list) option" |
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
48618
diff
changeset
|
127 |
consts neg_cps_of_set :: "'a set => ('a Quickcheck_Exhaustive.unknown => term list Quickcheck_Exhaustive.three_valued) => natural => term list Quickcheck_Exhaustive.three_valued" |
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
128 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
129 |
lemma |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
130 |
[code]: "pos_cps_of_set (set xs) f i = find_first f xs" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
131 |
sorry |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
132 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
133 |
consts find_first' :: "('b Quickcheck_Exhaustive.unknown => 'a Quickcheck_Exhaustive.three_valued) |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
134 |
=> 'b list => 'a Quickcheck_Exhaustive.three_valued" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
135 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
136 |
lemma [code]: |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
137 |
"find_first' f [] = Quickcheck_Exhaustive.No_value" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
138 |
"find_first' f (x # xs) = (case f (Quickcheck_Exhaustive.Known x) of Quickcheck_Exhaustive.No_value => find_first' f xs | Quickcheck_Exhaustive.Value x => Quickcheck_Exhaustive.Value x | Quickcheck_Exhaustive.Unknown_value => (case find_first' f xs of Quickcheck_Exhaustive.Value x => Quickcheck_Exhaustive.Value x | _ => Quickcheck_Exhaustive.Unknown_value))" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
139 |
sorry |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
140 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
141 |
lemma |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
142 |
[code]: "neg_cps_of_set (set xs) f i = find_first' f xs" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
143 |
sorry |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
144 |
|
62290 | 145 |
setup \<open> |
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
146 |
let |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
147 |
val Fun = Predicate_Compile_Aux.Fun |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
148 |
val Input = Predicate_Compile_Aux.Input |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
149 |
val Output = Predicate_Compile_Aux.Output |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
150 |
val Bool = Predicate_Compile_Aux.Bool |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
151 |
val oi = Fun (Output, Fun (Input, Bool)) |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
152 |
val ii = Fun (Input, Fun (Input, Bool)) |
74303 | 153 |
fun of_set compfuns \<^Type>\<open>fun T _\<close> = |
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
154 |
case body_type (Predicate_Compile_Aux.mk_monadT compfuns T) of |
74303 | 155 |
\<^Type>\<open>Quickcheck_Exhaustive.three_valued _\<close> => |
156 |
Const(\<^const_name>\<open>neg_cps_of_set\<close>, \<^Type>\<open>set T\<close> --> Predicate_Compile_Aux.mk_monadT compfuns T) |
|
157 |
| Type ("Predicate.pred", _) => Const(\<^const_name>\<open>pred_of_set\<close>, \<^Type>\<open>set T\<close> --> Predicate_Compile_Aux.mk_monadT compfuns T) |
|
158 |
| _ => Const(\<^const_name>\<open>pos_cps_of_set\<close>, \<^Type>\<open>set T\<close> --> Predicate_Compile_Aux.mk_monadT compfuns T) |
|
159 |
fun member compfuns (U as \<^Type>\<open>fun T _\<close>) = |
|
160 |
(absdummy T (absdummy \<^Type>\<open>set T\<close> (Predicate_Compile_Aux.mk_if compfuns |
|
161 |
\<^Const>\<open>Set.member T for \<open>Bound 1\<close> \<open>Bound 0\<close>\<close>))) |
|
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
162 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
163 |
in |
69597 | 164 |
Core_Data.force_modes_and_compilations \<^const_name>\<open>Set.member\<close> |
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
165 |
[(oi, (of_set, false)), (ii, (member, false))] |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
166 |
end |
62290 | 167 |
\<close> |
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
168 |
|
62290 | 169 |
subsection \<open>Derived equations for analz, parts and synth\<close> |
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
170 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
171 |
lemma [code]: |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
172 |
"analz H = (let |
67613 | 173 |
H' = H \<union> (\<Union>((%m. case m of \<lbrace>X, Y\<rbrace> => {X, Y} | Crypt K X => if Key (invKey K) \<in> H then {X} else {} | _ => {}) ` H)) |
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
174 |
in if H' = H then H else analz H')" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
175 |
sorry |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
176 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
177 |
lemma [code]: |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
178 |
"parts H = (let |
61984 | 179 |
H' = H \<union> (\<Union>((%m. case m of \<lbrace>X, Y\<rbrace> => {X, Y} | Crypt K X => {X} | _ => {}) ` H)) |
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
180 |
in if H' = H then H else parts H')" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
181 |
sorry |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
182 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
183 |
definition synth' :: "msg set => msg => bool" |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
184 |
where |
67613 | 185 |
"synth' H m = (m \<in> synth H)" |
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
186 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
187 |
lemmas [code_pred_intro] = synth.intros[folded synth'_def] |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
188 |
|
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
189 |
code_pred [generator_cps] synth' unfolding synth'_def by (rule synth.cases) fastforce+ |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
190 |
|
69597 | 191 |
setup \<open>Predicate_Compile_Data.ignore_consts [\<^const_name>\<open>analz\<close>, \<^const_name>\<open>knows\<close>]\<close> |
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
192 |
declare ListMem_iff[symmetric, code_pred_inline] |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
193 |
declare [[quickcheck_timing]] |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
194 |
|
58813 | 195 |
setup Exhaustive_Generators.setup_exhaustive_datatype_interpretation |
48243
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
196 |
declare [[quickcheck_full_support = false]] |
b149de01d669
adding three variants of the Needham-Schroeder formalisation as case studies for Quickcheck
bulwahn
parents:
diff
changeset
|
197 |
|
67399 | 198 |
end |