-
Notifications
You must be signed in to change notification settings - Fork 0
/
Semantics.thy
10658 lines (9997 loc) · 840 KB
/
Semantics.thy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
theory Semantics
imports Frame
begin
abbreviation provenance_judge ("\<langle>_; _, _\<rangle>" [80,80,80] 80)
where "\<langle>xvec; yvec, \<pi>\<rangle> \<equiv> \<langle>xvec,\<langle>yvec,\<pi>\<rangle>\<rangle>"
abbreviation empty_provenance_judge ("\<langle>\<epsilon>; \<epsilon>, _\<rangle>" [80] 80)
where "\<langle>\<epsilon>; \<epsilon>, \<pi>\<rangle> \<equiv> F_assert(F_assert \<pi>)"
lemma tup_frame_eq_split:
fixes A\<^sub>F :: "name list"
and \<Psi>\<^sub>F :: "'a::fs_name"
and C :: "'b::fs_name"
and \<pi> :: "('c::fs_name) frame"
assumes "\<langle>A\<^sub>F, (\<Psi>\<^sub>F, \<pi>)\<rangle> = \<langle>A\<^sub>F', (\<Psi>\<^sub>F', \<pi>')\<rangle>"
shows "\<langle>A\<^sub>F, \<Psi>\<^sub>F\<rangle> = \<langle>A\<^sub>F', \<Psi>\<^sub>F'\<rangle>"
and "\<langle>A\<^sub>F,\<pi>\<rangle> = \<langle>A\<^sub>F',\<pi>'\<rangle>"
proof -
from assms have "length A\<^sub>F = length A\<^sub>F'"
by(rule frame_chain_eq_length)
hence "\<langle>A\<^sub>F, \<Psi>\<^sub>F\<rangle> = \<langle>A\<^sub>F', \<Psi>\<^sub>F'\<rangle> \<and> \<langle>A\<^sub>F,\<pi>\<rangle> = \<langle>A\<^sub>F',\<pi>'\<rangle>" using assms
proof(induct arbitrary: A\<^sub>F' \<Psi>\<^sub>F \<pi> \<Psi>\<^sub>F' \<pi>' rule: length_induct)
case(1 A\<^sub>F A\<^sub>F' \<Psi>\<^sub>F \<pi> \<Psi>\<^sub>F' \<pi>')
have ind_hyp: "\<And> ys x (xa::'a) (xb::'c frame) (xc::'a) (xd::'c frame). \<lbrakk>length ys < length A\<^sub>F; length ys = length x; \<langle>ys, (xa, xb)\<rangle> = \<langle>x, (xc, xd)\<rangle>\<rbrakk> \<Longrightarrow> \<langle>ys, xa\<rangle> = \<langle>x, xc\<rangle> \<and> \<langle>ys,xb\<rangle> = \<langle>x,xd\<rangle>"
using 1 by blast
show ?case
proof(cases A\<^sub>F)
case Nil
thus ?thesis using 1
by(cases A\<^sub>F') (simp_all add: frame.inject)
next
case (Cons a as)
then obtain b bs where b: "A\<^sub>F' = b # bs" using 1
by (metis length_0_conv list.exhaust)
have l: "length as < length A\<^sub>F" using Cons by simp
have l': "length as = length([(a,b)]\<bullet>bs)"
using `length A\<^sub>F = length A\<^sub>F'` unfolding Cons b by simp
show ?thesis using `length A\<^sub>F = length A\<^sub>F'` `\<langle>A\<^sub>F, (\<Psi>\<^sub>F, \<pi>)\<rangle> = \<langle>A\<^sub>F', (\<Psi>\<^sub>F', \<pi>')\<rangle>`
unfolding Cons b
by(auto simp add: frame.inject abs_fun_eq[OF pt_name_inst, OF at_name_inst] eqvts frame_res_chain_fresh dest: ind_hyp[OF l] ind_hyp[OF l, OF l'])
qed
qed
thus "\<langle>A\<^sub>F, \<Psi>\<^sub>F\<rangle> = \<langle>A\<^sub>F', \<Psi>\<^sub>F'\<rangle>" and "\<langle>A\<^sub>F,\<pi>\<rangle> = \<langle>A\<^sub>F',\<pi>'\<rangle>"
by auto
qed
lemma distinct_frames_eq:
fixes A\<^sub>F :: "name list"
and \<Psi>\<^sub>F :: "'a::fs_name"
and C :: "'b::fs_name"
and \<pi> :: "('c::fs_name) frame"
assumes "A\<^sub>F \<sharp>* C"
obtains A\<^sub>F' where "\<langle>A\<^sub>F, \<Psi>\<^sub>F\<rangle> = \<langle>A\<^sub>F', \<Psi>\<^sub>F\<rangle>" and "distinct A\<^sub>F'" and "A\<^sub>F' \<sharp>* C" and "\<langle>A\<^sub>F,\<pi>\<rangle> = \<langle>A\<^sub>F',\<pi>\<rangle>"
proof -
assume a: "(\<And>A\<^sub>F'. \<lbrakk>\<langle>A\<^sub>F, \<Psi>\<^sub>F\<rangle> = \<langle>A\<^sub>F', \<Psi>\<^sub>F\<rangle>; distinct A\<^sub>F'; A\<^sub>F' \<sharp>* C; \<langle>A\<^sub>F,\<pi>\<rangle> = \<langle>A\<^sub>F',\<pi>\<rangle>\<rbrakk> \<Longrightarrow> thesis)"
moreover from assms obtain A\<^sub>F' where F_eq: "\<langle>A\<^sub>F, (\<Psi>\<^sub>F,\<pi>)\<rangle> = \<langle>A\<^sub>F', (\<Psi>\<^sub>F,\<pi>)\<rangle>" and "distinct A\<^sub>F'" and "A\<^sub>F' \<sharp>* C"
by(erule_tac distinct_frame)
moreover hence "\<langle>A\<^sub>F, \<Psi>\<^sub>F\<rangle> = \<langle>A\<^sub>F', \<Psi>\<^sub>F\<rangle> \<and> \<langle>A\<^sub>F,\<pi>\<rangle> = \<langle>A\<^sub>F',\<pi>\<rangle>"
by(metis tup_frame_eq_split)
ultimately show thesis
by blast
qed
nominal_datatype ('a, 'b, 'c) bound_output =
B_out "'a::fs_name" "('a, 'b::fs_name, 'c::fs_name) psi" ("_ \<prec>' _" [110, 110] 110)
| B_step "\<guillemotleft>name\<guillemotright> ('a, 'b, 'c) bound_output" ("\<lparr>\<nu>_\<rparr>_" [110, 110] 110)
fun BO_res_chain :: "name list \<Rightarrow> ('a::fs_name, 'b::fs_name, 'c::fs_name) bound_output \<Rightarrow>
('a, 'b, 'c) bound_output"
where
BO_res_chain_base: "BO_res_chain [] B = B"
| BO_res_chain_step: "BO_res_chain (x#xs) B = \<lparr>\<nu>x\<rparr>(BO_res_chain xs B)"
abbreviation
BO_res_chain_judge ("\<lparr>\<nu>*_\<rparr>_" [80, 80] 80) where "\<lparr>\<nu>*xvec\<rparr>B \<equiv> BO_res_chain xvec B"
lemma BO_res_chain_eqvt[eqvt]:
fixes perm :: "name prm"
and lst :: "name list"
and B :: "('a::fs_name, 'b::fs_name, 'c::fs_name) bound_output"
shows "perm \<bullet> (\<lparr>\<nu>*xvec\<rparr>B) = \<lparr>\<nu>*(perm \<bullet> xvec)\<rparr>(perm \<bullet> B)"
by(induct_tac xvec, auto)
lemma BO_res_chain_simps[simp]:
fixes xvec :: "name list"
and N :: "'a::fs_name"
and P :: "('a, 'b::fs_name, 'c::fs_name) psi"
and N' :: 'a
and P' :: "('a, 'b, 'c) psi"
and B :: "('a, 'b, 'c) bound_output"
and B' :: "('a, 'b, 'c) bound_output"
shows "(\<lparr>\<nu>*xvec\<rparr>N \<prec>' P = N' \<prec>' P') = (xvec = [] \<and> N = N' \<and> P = P')"
and "(N' \<prec>' P' = \<lparr>\<nu>*xvec\<rparr>N \<prec>' P) = (xvec = [] \<and> N = N' \<and> P = P')"
and "(N' \<prec>' P' = N \<prec>' P) = (N = N' \<and> P = P')"
and "(\<lparr>\<nu>*xvec\<rparr>B = \<lparr>\<nu>*xvec\<rparr>B') = (B = B')"
by(induct xvec) (auto simp add: bound_output.inject alpha)
lemma output_fresh[simp]:
fixes Xs :: "name set"
and xvec :: "name list"
and N :: "'a::fs_name"
and P :: "('a, 'b::fs_name, 'c::fs_name) psi"
shows "(Xs \<sharp>* (N \<prec>' P)) = ((Xs \<sharp>* N) \<and> (Xs \<sharp>* P))"
and "(xvec \<sharp>* (N \<prec>' P)) = ((xvec \<sharp>* N) \<and> (xvec \<sharp>* P))"
by(auto simp add: fresh_star_def)
lemma bound_output_fresh:
fixes x :: name
and xvec :: "name list"
and B :: "('a::fs_name, 'b::fs_name, 'c::fs_name) bound_output"
shows "(x \<sharp> (\<lparr>\<nu>*xvec\<rparr>B)) = (x \<in> set xvec \<or> x \<sharp> B)"
by (induct xvec) (simp_all add: abs_fresh)
lemma bound_output_fresh_set:
fixes Xs :: "name set"
and xvec :: "name list"
and B :: "('a::fs_name, 'b::fs_name, 'c::fs_name) bound_output"
and yvec :: "name list"
and x :: name
shows "Xs \<sharp>* (\<lparr>\<nu>*xvec\<rparr>B) = (\<forall>x\<in>Xs. x \<in> set xvec \<or> x \<sharp> B)"
and "yvec \<sharp>* (\<lparr>\<nu>*xvec\<rparr>B) = (\<forall>x\<in>(set yvec). x \<in> set xvec \<or> x \<sharp> B)"
and "Xs \<sharp>* (\<lparr>\<nu>x\<rparr>B) = Xs \<sharp>* [x].B"
and "xvec \<sharp>* (\<lparr>\<nu>x\<rparr>B) = xvec \<sharp>* [x].B"
by(simp add: fresh_star_def bound_output_fresh)+
lemma BO_res_chain_supp:
fixes xvec :: "name list"
and B :: "('a::fs_name, 'b::fs_name, 'c::fs_name) bound_output"
shows "(supp(\<lparr>\<nu>*xvec\<rparr>B)::name set) = (supp B) - (supp xvec)"
by(induct xvec)
(auto simp add: bound_output.supp supp_list_nil supp_list_cons abs_supp supp_atm)
lemma bound_output_fresh_simps[simp]:
fixes Xs :: "name set"
and xvec :: "name list"
and B :: "('a::fs_name, 'b::fs_name, 'c::fs_name) bound_output"
and yvec :: "name list"
and x :: name
shows "Xs \<sharp>* xvec \<Longrightarrow> (Xs \<sharp>* (\<lparr>\<nu>*xvec\<rparr>B)) = (Xs \<sharp>* B)"
and "yvec \<sharp>* xvec \<Longrightarrow> yvec \<sharp>* (\<lparr>\<nu>*xvec\<rparr>B) = yvec \<sharp>* B"
and "xvec \<sharp>* (\<lparr>\<nu>*xvec\<rparr>B)"
and "x \<sharp> xvec \<Longrightarrow> x \<sharp> \<lparr>\<nu>*xvec\<rparr>B = x \<sharp> B"
apply(simp add: bound_output_fresh_set) apply(force simp add: fresh_star_def name_list_supp fresh_def)
apply(simp add: bound_output_fresh_set) apply(force simp add: fresh_star_def name_list_supp fresh_def)
apply(simp add: bound_output_fresh_set)
by(simp add: BO_res_chain_supp fresh_def)
lemma bound_output_chain_alpha:
fixes p :: "name prm"
and xvec :: "name list"
and B :: "('a::fs_name, 'b::fs_name, 'c::fs_name) bound_output"
and yvec :: "name list"
assumes xvec_freshB: "(p \<bullet> xvec) \<sharp>* B"
and S: "set p \<subseteq> set xvec \<times> set (p \<bullet> xvec)"
and "(set xvec) \<subseteq> (set yvec)"
shows "(\<lparr>\<nu>*yvec\<rparr>B) = (\<lparr>\<nu>*(p \<bullet> yvec)\<rparr>(p \<bullet> B))"
proof -
note pt_name_inst at_name_inst S
moreover from `(set xvec) \<subseteq> (set yvec)` have "set xvec \<sharp>* (\<lparr>\<nu>*yvec\<rparr>B)"
by(force simp add: bound_output_fresh_set)
moreover from xvec_freshB `(set xvec) \<subseteq> (set yvec)` have "set (p \<bullet> xvec) \<sharp>* (\<lparr>\<nu>*yvec\<rparr>B)"
by (simp add: bound_output_fresh_set) (simp add: fresh_star_def)
ultimately have "(\<lparr>\<nu>*yvec\<rparr>B) = p \<bullet> (\<lparr>\<nu>*yvec\<rparr>B)"
by (rule_tac pt_freshs_freshs [symmetric])
then show ?thesis by(simp add: eqvts)
qed
lemma bound_output_chain_alpha':
fixes p :: "name prm"
and xvec :: "name list"
and B :: "('a::fs_name, 'b::fs_name, 'c::fs_name) bound_output"
and yvec :: "name list"
and zvec :: "name list"
assumes xvec_freshB: "xvec \<sharp>* B"
and S: "set p \<subseteq> set xvec \<times> set yvec"
and "yvec \<sharp>* (\<lparr>\<nu>*zvec\<rparr>B)"
shows "(\<lparr>\<nu>*zvec\<rparr>B) = (\<lparr>\<nu>*(p \<bullet> zvec)\<rparr>(p \<bullet> B))"
proof -
note pt_name_inst at_name_inst S `yvec \<sharp>* (\<lparr>\<nu>*zvec\<rparr>B)`
moreover from xvec_freshB have "set (xvec) \<sharp>* (\<lparr>\<nu>*zvec\<rparr>B)"
by (simp add: bound_output_fresh_set) (simp add: fresh_star_def)
ultimately have "(\<lparr>\<nu>*zvec\<rparr>B) = p \<bullet> (\<lparr>\<nu>*zvec\<rparr>B)"
by (rule_tac pt_freshs_freshs [symmetric]) auto
then show ?thesis by(simp add: eqvts)
qed
lemma bound_output_chain_alpha'':
fixes p :: "name prm"
and xvec :: "name list"
and M :: "'a::fs_name"
and P :: "('a::fs_name, 'b::fs_name, 'c::fs_name) psi"
and yvec :: "name list"
assumes "(p \<bullet> xvec) \<sharp>* M"
and "(p \<bullet> xvec) \<sharp>* P"
and "set p \<subseteq> set xvec \<times> set (p \<bullet> xvec)"
and "(set xvec) \<subseteq> (set yvec)"
shows "(\<lparr>\<nu>*yvec\<rparr>M \<prec>' P) = (\<lparr>\<nu>*(p \<bullet> yvec)\<rparr>(p \<bullet> M) \<prec>' (p \<bullet> P))"
using assms
by(subst bound_output_chain_alpha) auto
lemma bound_output_chain_swap:
fixes x :: name
and y :: name
and N :: "'a::fs_name"
and P :: "('a, 'b::fs_name, 'c::fs_name) psi"
and xvec :: "name list"
assumes "y \<sharp> N"
and "y \<sharp> P"
and "x \<in> (set xvec)"
shows "\<lparr>\<nu>*xvec\<rparr>N \<prec>' P = \<lparr>\<nu>*([(x, y)] \<bullet> xvec)\<rparr>([(x ,y)] \<bullet> N) \<prec>' ([(x, y)] \<bullet> P)"
proof(case_tac "x=y")
assume "x=y"
thus ?thesis by simp
next
assume "x \<noteq> y"
with assms show ?thesis
by(rule_tac xvec="[x]" in bound_output_chain_alpha'') (auto simp add: calc_atm)
qed
lemma alpha_bound_output:
fixes x :: name
and y :: name
and B :: "('a::fs_name, 'b::fs_name, 'c::fs_name) bound_output"
assumes "y \<sharp> B"
shows "\<lparr>\<nu>x\<rparr>B = \<lparr>\<nu>y\<rparr>([(x, y)] \<bullet> B)"
using assms
by(auto simp add: bound_output.inject alpha fresh_left calc_atm)
lemma bound_output_eq_fresh:
fixes B :: "('a::fs_name, 'b::fs_name, 'c::fs_name) bound_output"
and C :: "('a, 'b, 'c) bound_output"
and x :: name
and y :: name
assumes "\<lparr>\<nu>x\<rparr>B = \<lparr>\<nu>y\<rparr>C"
and "x \<sharp> B"
shows "y \<sharp> C"
using assms
by(auto simp add: bound_output.inject alpha fresh_left calc_atm)
lemma bound_output_eq_supp:
fixes B :: "('a::fs_name, 'b::fs_name, 'c::fs_name) bound_output"
and C :: "('a, 'b, 'c) bound_output"
and x :: name
and y :: name
assumes "\<lparr>\<nu>x\<rparr>B = \<lparr>\<nu>y\<rparr>C"
and "x \<in> supp B"
shows "y \<in> supp C"
using assms
apply(auto simp add: bound_output.inject alpha fresh_left calc_atm)
apply(drule_tac pi="[(x, y)]" in pt_set_bij2[OF pt_name_inst, OF at_name_inst])
by(simp add: eqvts calc_atm)
lemma bound_output_chain_eq:
fixes xvec :: "name list"
and B :: "('a::fs_name, 'b::fs_name, 'c::fs_name) bound_output"
and yvec :: "name list"
and B' :: "('a, 'b, 'c) bound_output"
assumes "\<lparr>\<nu>*xvec\<rparr>B = \<lparr>\<nu>*yvec\<rparr>B'"
and "xvec \<sharp>* yvec"
and "length xvec = length yvec"
shows "\<exists>p. (set p) \<subseteq> (set xvec) \<times> set (yvec) \<and> distinct_perm p \<and> B = p \<bullet> B' \<and> (set (map fst p)) \<subseteq> (supp B) \<and> xvec \<sharp>* B' \<and> yvec \<sharp>* B"
proof -
obtain n where "n = length xvec" by auto
with assms show ?thesis
proof(induct n arbitrary: xvec yvec B B')
case(0 xvec yvec B B')
have Eq: "\<lparr>\<nu>*xvec\<rparr>B = \<lparr>\<nu>*yvec\<rparr>B'" by fact
from `0 = length xvec` have "xvec = []" by auto
moreover with `length xvec = length yvec` have "yvec = []"
by(case_tac yvec) auto
ultimately show ?case using Eq
by(simp add: bound_output.inject)
next
case(Suc n xvec yvec B B')
from `Suc n = length xvec`
obtain x xvec' where "xvec = x#xvec'" and "length xvec' = n"
by(case_tac xvec) auto
from `\<lparr>\<nu>*xvec\<rparr>B = \<lparr>\<nu>*yvec\<rparr>B'` `xvec = x # xvec'` `length xvec = length yvec`
obtain y yvec' where "\<lparr>\<nu>*(x#xvec')\<rparr>B = \<lparr>\<nu>*(y#yvec')\<rparr>B'"
and "yvec = y#yvec'" and "length xvec' = length yvec'"
by(case_tac yvec) auto
hence EQ: "\<lparr>\<nu>x\<rparr>(\<lparr>\<nu>*xvec'\<rparr>B) = \<lparr>\<nu>y\<rparr>(\<lparr>\<nu>*yvec'\<rparr>B')"
by simp
from `xvec = x#xvec'` `yvec=y#yvec'` `xvec \<sharp>* yvec`
have "x \<noteq> y" and "xvec' \<sharp>* yvec'" and "x \<sharp> yvec'" and "y \<sharp> xvec'"
by auto
have IH: "\<And>xvec yvec B B'. \<lbrakk>\<lparr>\<nu>*xvec\<rparr>(B::('a::fs_name, 'b::fs_name, 'c::fs_name) bound_output) = \<lparr>\<nu>*yvec\<rparr>B'; xvec \<sharp>* yvec; length xvec = length yvec; n = length xvec\<rbrakk> \<Longrightarrow> \<exists>p. (set p) \<subseteq> (set xvec) \<times> (set yvec) \<and> distinct_perm p \<and> B = p \<bullet> B' \<and> set(map fst p) \<subseteq> supp B \<and> xvec \<sharp>* B' \<and> yvec \<sharp>* B"
by fact
from EQ `x \<noteq> y` have EQ': "\<lparr>\<nu>*xvec'\<rparr>B = ([(x, y)] \<bullet> (\<lparr>\<nu>*yvec'\<rparr>B'))"
and x_fresh_B': "x \<sharp> (\<lparr>\<nu>*yvec'\<rparr>B')"
and y_freshB: "y \<sharp> (\<lparr>\<nu>*xvec'\<rparr>B)"
by(metis bound_output.inject alpha)+
from x_fresh_B' `x \<sharp> yvec'` have "x \<sharp> B'"
by(auto simp add: bound_output_fresh) (simp add: fresh_def name_list_supp)+
from y_freshB `y \<sharp> xvec'` have "y \<sharp> B"
by(auto simp add: bound_output_fresh) (simp add: fresh_def name_list_supp)+
show ?case
proof(case_tac "x \<sharp> \<lparr>\<nu>*xvec'\<rparr>B")
assume x_freshB: "x \<sharp> \<lparr>\<nu>*xvec'\<rparr>B"
with EQ have y_freshB': "y \<sharp> \<lparr>\<nu>*yvec'\<rparr>B'"
by(rule bound_output_eq_fresh)
with x_fresh_B' EQ' have "\<lparr>\<nu>*xvec'\<rparr>B = \<lparr>\<nu>*yvec'\<rparr>B'"
by(simp)
with `xvec' \<sharp>* yvec'` `length xvec' = length yvec'` `length xvec' = n` IH
obtain p where S: "(set p) \<subseteq> (set xvec') \<times> (set yvec')" and "distinct_perm p" and "B = p \<bullet> B'"
and "set(map fst p) \<subseteq> supp B" and "xvec' \<sharp>* B'" and "yvec' \<sharp>* B"
by blast
from S have "(set p) \<subseteq> set(x#xvec') \<times> set(y#yvec')" by auto
moreover note `xvec = x#xvec'` `yvec=y#yvec'` `distinct_perm p` `B = p \<bullet> B'`
`xvec' \<sharp>* B'` `x \<sharp> B'` `x \<sharp> B'` `yvec' \<sharp>* B` `y \<sharp> B` `set(map fst p) \<subseteq> supp B`
ultimately show ?case by auto
next
assume "\<not>(x \<sharp> \<lparr>\<nu>*xvec'\<rparr>B)"
hence x_suppB: "x \<in> supp(\<lparr>\<nu>*xvec'\<rparr>B)"
by(simp add: fresh_def)
with EQ have y_supp_b': "y \<in> supp (\<lparr>\<nu>*yvec'\<rparr>B')"
by(rule bound_output_eq_supp)
hence "y \<sharp> yvec'"
by(induct yvec') (auto simp add: bound_output.supp abs_supp)
with `x \<sharp> yvec'` EQ' have "\<lparr>\<nu>*xvec'\<rparr>B = \<lparr>\<nu>*yvec'\<rparr>([(x, y)] \<bullet> B')"
by(simp add: eqvts)
with `xvec' \<sharp>* yvec'` `length xvec' = length yvec'` `length xvec' = n` IH
obtain p where S: "(set p) \<subseteq> (set xvec') \<times> (set yvec')" and "distinct_perm p" and "B = p \<bullet> [(x, y)] \<bullet> B'"
and "set(map fst p) \<subseteq> supp B" and "xvec' \<sharp>* ([(x, y)] \<bullet> B')" and "yvec' \<sharp>* B"
by blast
from x_suppB have "x \<sharp> xvec'"
by(induct xvec') (auto simp add: bound_output.supp abs_supp)
with `x \<sharp> yvec'` `y \<sharp> xvec'` `y \<sharp> yvec'` S have "x \<sharp> p" and "y \<sharp> p"
apply(induct p)
by(auto simp add: name_list_supp) (auto simp add: fresh_def)
from S have "(set ((x, y)#p)) \<subseteq> (set(x#xvec')) \<times> (set(y#yvec'))"
by force
moreover from `x \<noteq> y` `x \<sharp> p` `y \<sharp> p` S `distinct_perm p`
have "distinct_perm((x,y)#p)" by simp
moreover from `B = p \<bullet> [(x, y)] \<bullet> B'` `x \<sharp> p` `y \<sharp> p` have "B = [(x, y)] \<bullet> p \<bullet> B'"
by(subst perm_compose) simp
hence "B = ((x, y)#p) \<bullet> B'" by simp
moreover from `xvec' \<sharp>* ([(x, y)] \<bullet> B')` have "([(x, y)] \<bullet> xvec') \<sharp>* ([(x, y)] \<bullet> [(x, y)] \<bullet> B')"
by(simp only: pt_fresh_star_bij[OF pt_name_inst, OF at_name_inst])
with `x \<sharp> xvec'` `y \<sharp> xvec'` `x \<sharp> B'` have "(x#xvec') \<sharp>* B'" by simp
moreover from `y \<sharp> B` `yvec' \<sharp>* B` have "(y#yvec') \<sharp>* B" by simp
moreover from `set(map fst p) \<subseteq> supp B` x_suppB `x \<sharp> xvec'`
have "set(map fst ((x, y)#p)) \<subseteq> supp B"
by(simp add: BO_res_chain_supp)
ultimately show ?case using `xvec=x#xvec'` `yvec=y#yvec'`
by metis
qed
qed
qed
lemma bound_output_chain_eq_length:
fixes xvec :: "name list"
and M :: "'a::fs_name"
and P :: "('a, 'b::fs_name, 'c::fs_name) psi"
and yvec :: "name list"
and N :: "'a::fs_name"
and Q :: "('a, 'b::fs_name, 'c::fs_name) psi"
assumes "\<lparr>\<nu>*xvec\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec\<rparr>N \<prec>' Q"
shows "length xvec = length yvec"
proof -
obtain n where "n = length xvec" by auto
with assms show ?thesis
proof(induct n arbitrary: xvec yvec M P N Q)
case(0 xvec yvec M P N Q)
from `0 = length xvec` have "xvec = []" by auto
moreover with `\<lparr>\<nu>*xvec\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec\<rparr>N \<prec>' Q` have "yvec = []"
by(case_tac yvec) auto
ultimately show ?case by simp
next
case(Suc n xvec yvec M P N Q)
from `Suc n = length xvec`
obtain x xvec' where "xvec = x#xvec'" and "length xvec' = n"
by(case_tac xvec) auto
from `\<lparr>\<nu>*xvec\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec\<rparr>N \<prec>' Q` `xvec = x # xvec'`
obtain y yvec' where "\<lparr>\<nu>*(x#xvec')\<rparr>M \<prec>' P = \<lparr>\<nu>*(y#yvec')\<rparr>N \<prec>' Q"
and "yvec = y#yvec'"
by(case_tac yvec) auto
hence EQ: "\<lparr>\<nu>x\<rparr>(\<lparr>\<nu>*xvec'\<rparr>M \<prec>' P) = \<lparr>\<nu>y\<rparr>(\<lparr>\<nu>*yvec'\<rparr>N \<prec>' Q)"
by simp
have IH: "\<And>xvec yvec M P N Q. \<lbrakk>\<lparr>\<nu>*xvec\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec\<rparr>N \<prec>' (Q::('a, 'b, 'c) psi); n = length xvec\<rbrakk> \<Longrightarrow> length xvec = length yvec"
by fact
show ?case
proof(case_tac "x = y")
assume "x = y"
with EQ have "\<lparr>\<nu>*xvec'\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec'\<rparr>N \<prec>' Q"
by(simp add: alpha bound_output.inject)
with IH `length xvec' = n` have "length xvec' = length yvec'"
by blast
with `xvec = x#xvec'` `yvec=y#yvec'`
show ?case by simp
next
assume "x \<noteq> y"
with EQ have "\<lparr>\<nu>*xvec'\<rparr>M \<prec>' P = [(x, y)] \<bullet> \<lparr>\<nu>*yvec'\<rparr>N \<prec>' Q"
by(simp add: alpha bound_output.inject)
hence "\<lparr>\<nu>*xvec'\<rparr>M \<prec>' P = \<lparr>\<nu>*([(x, y)] \<bullet> yvec')\<rparr>([(x, y)] \<bullet> N) \<prec>' ([(x, y)] \<bullet> Q)"
by(simp add: eqvts)
with IH `length xvec' = n` have "length xvec' = length ([(x, y)] \<bullet> yvec')"
by blast
hence "length xvec' = length yvec'"
by simp
with `xvec = x#xvec'` `yvec=y#yvec'`
show ?case by simp
qed
qed
qed
lemma bound_output_chain_eq':
fixes xvec :: "name list"
and M :: "'a::fs_name"
and P :: "('a, 'b::fs_name, 'c::fs_name) psi"
and yvec :: "name list"
and N :: 'a
and Q :: "('a::fs_name, 'b::fs_name, 'c::fs_name) psi"
assumes "\<lparr>\<nu>*xvec\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec\<rparr>N \<prec>' Q"
and "xvec \<sharp>* yvec"
shows "\<exists>p. (set p) \<subseteq> (set xvec) \<times> set (yvec) \<and> distinct_perm p \<and> M = p \<bullet> N \<and> P = p \<bullet> Q \<and> xvec \<sharp>* N \<and> xvec \<sharp>* Q \<and> yvec \<sharp>* M \<and> yvec \<sharp>* P"
using assms
apply(frule_tac bound_output_chain_eq_length)
apply(drule_tac bound_output_chain_eq)
by(auto simp add: bound_output.inject)
lemma bound_output_chain_eq'':
fixes xvec :: "name list"
and M :: "'a::fs_name"
and P :: "('a, 'b::fs_name, 'c::fs_name) psi"
and yvec :: "name list"
and N :: 'a
and Q :: "('a::fs_name, 'b::fs_name, 'c::fs_name) psi"
assumes "\<lparr>\<nu>*xvec\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec\<rparr>N \<prec>' Q"
and "xvec \<sharp>* yvec"
and "distinct xvec"
and "distinct yvec"
obtains p where "(set p) \<subseteq> (set xvec) \<times> set (p \<bullet> xvec)" and "distinct_perm p" and "yvec = p \<bullet> xvec" and "N = p \<bullet> M" and "Q = p \<bullet> P" and "xvec \<sharp>* N" and "xvec \<sharp>* Q" and "(p \<bullet> xvec) \<sharp>* M" and "(p \<bullet> xvec) \<sharp>* P"
proof -
assume "\<And>p. \<lbrakk>set p \<subseteq> set xvec \<times> set (p \<bullet> xvec); distinct_perm p; yvec = p \<bullet> xvec; N = p \<bullet> M; Q = p \<bullet> P; xvec \<sharp>* N; xvec \<sharp>* Q; (p \<bullet> xvec) \<sharp>* M; (p \<bullet> xvec) \<sharp>* P\<rbrakk> \<Longrightarrow> thesis"
moreover obtain n where "n = length xvec" by auto
with assms have "\<exists>p. (set p) \<subseteq> (set xvec) \<times> set (yvec) \<and> distinct_perm p \<and> yvec = p \<bullet> xvec \<and> N = p \<bullet> M \<and> Q = p \<bullet> P \<and> xvec \<sharp>* N \<and> xvec \<sharp>* Q \<and> (p \<bullet> xvec) \<sharp>* M \<and> (p \<bullet> xvec) \<sharp>* P"
proof(induct n arbitrary: xvec yvec M P N Q)
case(0 xvec yvec M P N Q)
have Eq: "\<lparr>\<nu>*xvec\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec\<rparr>N \<prec>' Q" by fact
from `0 = length xvec` have "xvec = []" by auto
moreover with Eq have "yvec = []"
by(case_tac yvec) auto
ultimately show ?case using Eq
by(simp add: bound_output.inject)
next
case(Suc n xvec yvec M P N Q)
from `Suc n = length xvec`
obtain x xvec' where "xvec = x#xvec'" and "length xvec' = n"
by(case_tac xvec) auto
from `\<lparr>\<nu>*xvec\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec\<rparr>N \<prec>' Q` `xvec = x # xvec'`
obtain y yvec' where "\<lparr>\<nu>*(x#xvec')\<rparr>M \<prec>' P = \<lparr>\<nu>*(y#yvec')\<rparr>N \<prec>' Q"
and "yvec = y#yvec'"
by(case_tac yvec) auto
hence EQ: "\<lparr>\<nu>x\<rparr>(\<lparr>\<nu>*xvec'\<rparr>M \<prec>' P) = \<lparr>\<nu>y\<rparr>(\<lparr>\<nu>*yvec'\<rparr>N \<prec>' Q)"
by simp
from `xvec = x#xvec'` `yvec=y#yvec'` `xvec \<sharp>* yvec`
have "x \<noteq> y" and "xvec' \<sharp>* yvec'" and "x \<sharp> yvec'" and "y \<sharp> xvec'"
by auto
from `distinct xvec` `distinct yvec` `xvec=x#xvec'` `yvec=y#yvec'` have "x \<sharp> xvec'" and "y \<sharp> yvec'" and "distinct xvec'" and "distinct yvec'"
by simp+
have IH: "\<And>xvec yvec M P N Q. \<lbrakk>\<lparr>\<nu>*xvec\<rparr>(M::'a) \<prec>' (P::('a, 'b, 'c) psi) = \<lparr>\<nu>*yvec\<rparr>N \<prec>' Q; xvec \<sharp>* yvec; distinct xvec; distinct yvec; n = length xvec\<rbrakk> \<Longrightarrow> \<exists>p. (set p) \<subseteq> (set xvec) \<times> (set yvec) \<and> distinct_perm p \<and> yvec = p \<bullet> xvec \<and> N = p \<bullet> M \<and> Q = p \<bullet> P \<and> xvec \<sharp>* N \<and> xvec \<sharp>* Q \<and> (p \<bullet> xvec) \<sharp>* M \<and> (p \<bullet> xvec) \<sharp>* P"
by fact
from EQ `x \<noteq> y` `x \<sharp> yvec'` `y \<sharp> yvec'` `y \<sharp> xvec'` `x \<sharp> xvec'` have "\<lparr>\<nu>*xvec'\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec'\<rparr>([(x, y)] \<bullet> N) \<prec>' ([(x, y)] \<bullet> Q)" and "x \<sharp> N" and "x \<sharp> Q" and "y \<sharp> M" and "y \<sharp> P"
apply -
apply(simp add: bound_output.inject alpha eqvts)
apply(simp add: bound_output.inject alpha eqvts)
apply(simp add: bound_output.inject alpha eqvts)
by(simp add: bound_output.inject alpha' eqvts)+
with `xvec' \<sharp>* yvec'` `distinct xvec'` `distinct yvec'` `length xvec' = n` IH
obtain p where S: "(set p) \<subseteq> (set xvec') \<times> (set yvec')" and "distinct_perm p" and "yvec' = p \<bullet> xvec'" and "([(x, y)] \<bullet> N) = p \<bullet> M" and "([(x, y)] \<bullet> Q) = p \<bullet> P" and "xvec' \<sharp>* ([(x, y)] \<bullet> N)" and "xvec' \<sharp>* ([(x, y)] \<bullet> Q)" and "yvec' \<sharp>* M" and "yvec' \<sharp>* P"
by metis
from S have "set((x, y)#p) \<subseteq> set(x#xvec') \<times> set(y#yvec')" by auto
moreover from `x \<sharp> xvec'` `x \<sharp> yvec'` `y \<sharp> xvec'` `y \<sharp> yvec'` S have "x \<sharp> p" and "y \<sharp> p"
apply(induct p)
by(auto simp add: fresh_prod name_list_supp) (auto simp add: fresh_def)
with S `distinct_perm p` `x \<noteq> y` have "distinct_perm((x, y)#p)" by auto
moreover from `yvec' = p \<bullet> xvec'` `x \<sharp> p` `y \<sharp> p` `x \<sharp> xvec'` `y \<sharp> xvec'` have "(y#yvec') = ((x, y)#p) \<bullet> (x#xvec')"
by(simp add: eqvts calc_atm perm_compose fresh_chain_simps)
moreover from `([(x, y)] \<bullet> N) = p \<bullet> M`
have "([(x, y)] \<bullet> [(x, y)] \<bullet> N) = [(x, y)] \<bullet> p \<bullet> M"
by(simp add: pt_bij)
hence "N = ((x, y)#p) \<bullet> M" by simp
moreover from `([(x, y)] \<bullet> Q) = p \<bullet> P`
have "([(x, y)] \<bullet> [(x, y)] \<bullet> Q) = [(x, y)] \<bullet> p \<bullet> P"
by(simp add: pt_bij)
hence "Q = ((x, y)#p) \<bullet> P" by simp
moreover from `xvec' \<sharp>* ([(x, y)] \<bullet> N)` have "([(x, y)] \<bullet> xvec') \<sharp>* ([(x, y)] \<bullet> [(x, y)] \<bullet> N)"
by(subst fresh_star_bij)
with `x \<sharp> xvec'` `y \<sharp> xvec'` have "xvec' \<sharp>* N" by simp
with `x \<sharp> N` have "(x#xvec') \<sharp>* N" by simp
moreover from `xvec' \<sharp>* ([(x, y)] \<bullet> Q)` have "([(x, y)] \<bullet> xvec') \<sharp>* ([(x, y)] \<bullet> [(x, y)] \<bullet> Q)"
by(subst fresh_star_bij)
with `x \<sharp> xvec'` `y \<sharp> xvec'` have "xvec' \<sharp>* Q" by simp
with `x \<sharp> Q` have "(x#xvec') \<sharp>* Q" by simp
moreover from `y \<sharp> M` `yvec' \<sharp>* M` have "(y#yvec') \<sharp>* M" by simp
moreover from `y \<sharp> P` `yvec' \<sharp>* P` have "(y#yvec') \<sharp>* P" by simp
ultimately show ?case using `xvec=x#xvec'` `yvec=y#yvec'`
by metis
qed
ultimately show ?thesis by blast
qed
lemma bound_output_eq_supp':
fixes x :: name
and xvec :: "name list"
and M :: "'a::fs_name"
and P :: "('a, 'b::fs_name, 'c::fs_name) psi"
and y :: name
and yvec :: "name list"
and N :: 'a
and Q :: "('a, 'b, 'c) psi"
assumes Eq: "\<lparr>\<nu>x\<rparr>(\<lparr>\<nu>*xvec\<rparr>M \<prec>' P) = \<lparr>\<nu>y\<rparr>(\<lparr>\<nu>*yvec\<rparr>N \<prec>' Q)"
and "x \<noteq> y"
and "x \<sharp> yvec"
and "x \<sharp> xvec"
and "y \<sharp> xvec"
and "y \<sharp> yvec"
and "xvec \<sharp>* yvec"
and "x \<in> supp M"
shows "y \<in> supp N"
proof -
from Eq `x \<noteq> y` `x \<sharp> yvec` `y \<sharp> yvec` have "\<lparr>\<nu>*xvec\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec\<rparr>([(x, y)] \<bullet> N) \<prec>' ([(x, y)] \<bullet> Q)"
by(simp add: bound_output.inject alpha eqvts)
then obtain p where S: "set p \<subseteq> set xvec \<times> set yvec" and "M = p \<bullet> [(x, y)] \<bullet> N" and "distinct_perm p" using `xvec \<sharp>* yvec`
by(blast dest: bound_output_chain_eq')
with `x \<in> supp M` have "x \<in> supp(p \<bullet> [(x, y)] \<bullet> N)" by simp
hence "(p \<bullet> x) \<in> p \<bullet> supp(p \<bullet> [(x, y)] \<bullet> N)"
by(simp add: pt_set_bij[OF pt_name_inst, OF at_name_inst])
with `x \<sharp> xvec` `x \<sharp> yvec` S `distinct_perm p` have "x \<in> supp([(x, y)] \<bullet> N)"
by(simp add: eqvts)
hence "([(x, y)] \<bullet> x) \<in> ([(x, y)] \<bullet> (supp([(x, y)] \<bullet> N)))"
by(simp add: pt_set_bij[OF pt_name_inst, OF at_name_inst])
with `x \<noteq> y` show ?thesis by(simp add: calc_atm eqvts)
qed
lemma bound_output_chain_open_ih:
fixes xvec :: "name list"
and x :: name
and B :: "('a::fs_name, 'b::fs_name, 'c::fs_name) bound_output"
and yvec :: "name list"
and y :: name
and B' :: "('a, 'b, 'c) bound_output"
assumes Eq: "\<lparr>\<nu>*xvec\<rparr>(\<lparr>\<nu>x\<rparr>B) = \<lparr>\<nu>*yvec\<rparr>(\<lparr>\<nu>y\<rparr>B')"
and L: "length xvec = length yvec"
and x_fresh_B': "x \<sharp> B'"
and x_freshxvec: "x \<sharp> xvec"
and x_freshyvec: "x \<sharp> yvec"
shows "\<lparr>\<nu>*xvec\<rparr>B = \<lparr>\<nu>*yvec\<rparr>([(x, y)] \<bullet> B')"
using assms
proof(induct n=="length xvec" arbitrary: xvec yvec y B' rule: nat.induct)
case(zero xvec yvec y B')
have "0 = length xvec" and "length xvec = length yvec" by fact+
moreover have "\<lparr>\<nu>*xvec\<rparr>\<lparr>\<nu>x\<rparr>B = \<lparr>\<nu>*yvec\<rparr>\<lparr>\<nu>y\<rparr>B'" by fact
ultimately show ?case by(auto simp add: bound_output.inject alpha)
next
case(Suc n xvec yvec y B')
have L: "length xvec = length yvec" and "Suc n = length xvec" by fact+
then obtain x' xvec' y' yvec' where x_eq: "xvec = x'#xvec'" and y_eq: "yvec = y'#yvec'"
and L': "length xvec' = length yvec'"
by(cases xvec, auto, cases yvec, auto)
have x_fresh_B': "x \<sharp> B'" by fact
have "x \<sharp> xvec" and "x \<sharp> yvec" by fact+
with x_eq y_eq have xineqx': "x \<noteq> x'" and x_freshxvec': "x \<sharp> xvec'"
and xineqy': "x \<noteq> y'" and x_freshyvec': "x \<sharp> yvec'"
by simp+
have "\<lparr>\<nu>*xvec\<rparr>\<lparr>\<nu>x\<rparr>B = \<lparr>\<nu>*yvec\<rparr>\<lparr>\<nu>y\<rparr>B'" by fact
with x_eq y_eq have Eq: "\<lparr>\<nu>x'\<rparr>(\<lparr>\<nu>*xvec'\<rparr>\<lparr>\<nu>x\<rparr>B) = \<lparr>\<nu>y'\<rparr>(\<lparr>\<nu>*yvec'\<rparr>\<lparr>\<nu>y\<rparr>B')" by simp
have IH: "\<And>xvec yvec y B'.
\<lbrakk>n = length xvec; \<lparr>\<nu>*xvec\<rparr>\<lparr>\<nu>x\<rparr>B = \<lparr>\<nu>*yvec\<rparr>\<lparr>\<nu>y\<rparr>B'; length xvec = length yvec; x \<sharp> B'; x \<sharp> xvec; x \<sharp> yvec\<rbrakk>
\<Longrightarrow> \<lparr>\<nu>*xvec\<rparr>B = \<lparr>\<nu>*yvec\<rparr>([(x, y)] \<bullet> B')" by fact
have "Suc n = length xvec" by fact
with x_eq have L'': "n = length xvec'" by simp
have "\<lparr>\<nu>x'\<rparr>(\<lparr>\<nu>*xvec'\<rparr>B) = \<lparr>\<nu>y'\<rparr>(\<lparr>\<nu>*yvec'\<rparr>([(x, y)] \<bullet> B'))"
proof(case_tac "x'=y'")
assume x'eqy': "x' = y'"
with Eq have "\<lparr>\<nu>*xvec'\<rparr>\<lparr>\<nu>x\<rparr>B = \<lparr>\<nu>*yvec'\<rparr>\<lparr>\<nu>y\<rparr>B'" by(simp add: bound_output.inject alpha)
hence "\<lparr>\<nu>*xvec'\<rparr>B = \<lparr>\<nu>*yvec'\<rparr>([(x, y)] \<bullet> B')" using L' x_fresh_B' x_freshxvec' x_freshyvec' L'' by(rule_tac IH)
with x'eqy' show ?thesis by(simp add: bound_output.inject alpha)
next
assume x'ineqy': "x' \<noteq> y'"
with Eq have Eq': "\<lparr>\<nu>*xvec'\<rparr>\<lparr>\<nu>x\<rparr>B = \<lparr>\<nu>*([(x', y')] \<bullet> yvec')\<rparr>\<lparr>\<nu>([(x', y')] \<bullet> y)\<rparr>([(x', y')] \<bullet> B')"
and x'_fresh_b': "x' \<sharp> \<lparr>\<nu>*yvec'\<rparr>\<lparr>\<nu>y\<rparr>B'"
by(simp add: bound_output.inject alpha eqvts)+
from L' have "length xvec' = length ([(x', y')] \<bullet> yvec')" by simp
moreover from xineqx' xineqy' x_fresh_B' have "x \<sharp> [(x', y')] \<bullet> B'" by(simp add: fresh_left calc_atm)
moreover from xineqx' xineqy' x_freshyvec' have "x \<sharp> [(x', y')] \<bullet> yvec'" by(simp add: fresh_left calc_atm)
ultimately have "\<lparr>\<nu>*xvec'\<rparr>B = \<lparr>\<nu>*([(x', y')] \<bullet> yvec')\<rparr>([(x, ([(x', y')] \<bullet> y))] \<bullet> [(x', y')] \<bullet> B')" using Eq' x_freshxvec' L''
by(rule_tac IH)
moreover from x'_fresh_b' have "x' \<sharp> \<lparr>\<nu>*yvec'\<rparr>([(x, y)] \<bullet> B')"
proof(case_tac "x' \<sharp> yvec'")
assume "x' \<sharp> yvec'"
with x'_fresh_b' have x'_fresh_b': "x' \<sharp> \<lparr>\<nu>y\<rparr>B'"
by(simp add: fresh_def BO_res_chain_supp)
show ?thesis
proof(case_tac "x'=y")
assume x'eqy: "x' = y"
show ?thesis
proof(case_tac "x=y")
assume "x=y"
with x_fresh_B' x'eqy show ?thesis by(simp add: BO_res_chain_supp fresh_def)
next
assume "x \<noteq> y"
with `x \<sharp> B'` have "y \<sharp> [(x, y)] \<bullet> B'" by(simp add: fresh_left calc_atm)
with x'eqy show ?thesis by(simp add: BO_res_chain_supp fresh_def)
qed
next
assume x'ineqy: "x' \<noteq> y"
with x'_fresh_b' have "x' \<sharp> B'" by(simp add: abs_fresh)
with xineqx' x'ineqy have "x' \<sharp> ([(x, y)] \<bullet> B')" by(simp add: fresh_left calc_atm)
thus ?thesis by(simp add: BO_res_chain_supp fresh_def)
qed
next
assume "\<not>x' \<sharp> yvec'"
thus ?thesis by(simp add: BO_res_chain_supp fresh_def)
qed
ultimately show ?thesis using x'ineqy' xineqx' xineqy'
apply(simp add: bound_output.inject alpha eqvts)
apply(subst perm_compose[of "[(x', y')]"])
by(simp add: calc_atm)
qed
with x_eq y_eq show ?case by simp
qed
lemma bound_output_par1_dest:
fixes xvec :: "name list"
and M :: "'a::fs_name"
and P :: "('a, 'b::fs_name, 'c::fs_name) psi"
and yvec :: "name list"
and N :: 'a
and Q :: "('a, 'b, 'c) psi"
and R :: "('a, 'b, 'c) psi"
assumes "\<lparr>\<nu>*xvec\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec\<rparr>N \<prec>' (Q \<parallel> R)"
and "xvec \<sharp>* R"
and "yvec \<sharp>* R"
obtains T where "P = T \<parallel> R" and "\<lparr>\<nu>*xvec\<rparr>M \<prec>' T = \<lparr>\<nu>*yvec\<rparr>N \<prec>' Q"
proof -
assume "\<And>T. \<lbrakk>P = T \<parallel> R; \<lparr>\<nu>*xvec\<rparr>M \<prec>' T = \<lparr>\<nu>*yvec\<rparr>N \<prec>' Q\<rbrakk> \<Longrightarrow> thesis"
moreover obtain n where "n = length xvec" by auto
with assms have "\<exists>T. P = T \<parallel> R \<and> \<lparr>\<nu>*xvec\<rparr>M \<prec>' T = \<lparr>\<nu>*yvec\<rparr>N \<prec>' Q"
proof(induct n arbitrary: xvec yvec M N P Q R)
case(0 xvec yvec M N P Q R)
have Eq: "\<lparr>\<nu>*xvec\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec\<rparr>N \<prec>' (Q \<parallel> R)" by fact
from `0 = length xvec` have "xvec = []" by auto
moreover with Eq have "yvec = []"
by(case_tac yvec) auto
ultimately show ?case using Eq
by(simp add: bound_output.inject)
next
case(Suc n xvec yvec M N P Q R)
from `Suc n = length xvec`
obtain x xvec' where "xvec = x#xvec'" and "length xvec' = n"
by(case_tac xvec) auto
from `\<lparr>\<nu>*xvec\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec\<rparr>N \<prec>' (Q \<parallel> R)` `xvec = x # xvec'`
obtain y yvec' where "\<lparr>\<nu>*(x#xvec')\<rparr>M \<prec>' P = \<lparr>\<nu>*(y#yvec')\<rparr>N \<prec>' (Q \<parallel> R)"
and "yvec = y#yvec'"
by(case_tac yvec) auto
hence EQ: "\<lparr>\<nu>x\<rparr>(\<lparr>\<nu>*xvec'\<rparr>M \<prec>' P) = \<lparr>\<nu>y\<rparr>(\<lparr>\<nu>*yvec'\<rparr>N \<prec>' (Q \<parallel> R))"
by simp
from `xvec \<sharp>* R` `yvec \<sharp>* R` `xvec = x#xvec'` `yvec = y#yvec'`
have "x \<sharp> R" and "xvec' \<sharp>* R" and "y \<sharp> R" and "yvec' \<sharp>* R" by auto
have IH: "\<And>xvec yvec M N P Q R. \<lbrakk>\<lparr>\<nu>*xvec\<rparr>M \<prec>' (P::('a, 'b, 'c) psi) = \<lparr>\<nu>*yvec\<rparr>N \<prec>' (Q \<parallel> R); xvec \<sharp>* R; yvec \<sharp>* R; n = length xvec\<rbrakk> \<Longrightarrow> \<exists>T. P = T \<parallel> R \<and> \<lparr>\<nu>*xvec\<rparr>M \<prec>' T = \<lparr>\<nu>*yvec\<rparr>N \<prec>' Q"
by fact
show ?case
proof(case_tac "x = y")
assume "x = y"
with EQ have "\<lparr>\<nu>*xvec'\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec'\<rparr>N \<prec>' (Q \<parallel> R)"
by(simp add: bound_output.inject alpha)
with `xvec' \<sharp>* R` `yvec' \<sharp>* R` `length xvec' = n`
obtain T where "P = T \<parallel> R" and "\<lparr>\<nu>*xvec'\<rparr>M \<prec>' T = \<lparr>\<nu>*yvec'\<rparr>N \<prec>' Q"
by(drule_tac IH) auto
with `xvec=x#xvec'` `yvec=y#yvec'` `x=y` show ?case
by(force simp add: bound_output.inject alpha)
next
assume "x \<noteq> y"
with EQ `x \<sharp> R` `y \<sharp> R`
have "\<lparr>\<nu>*xvec'\<rparr>M \<prec>' P = \<lparr>\<nu>*([(x, y)] \<bullet> yvec')\<rparr>([(x, y)] \<bullet> N) \<prec>' (([(x, y)] \<bullet> Q) \<parallel> R)"
and x_fresh_QR: "x \<sharp> \<lparr>\<nu>*yvec'\<rparr>N \<prec>' (Q \<parallel> R)"
by(simp add: bound_output.inject alpha eqvts)+
moreover from `yvec' \<sharp>* R` have "([(x, y)] \<bullet> yvec') \<sharp>* ([(x, y)] \<bullet> R)"
by(simp add: pt_fresh_star_bij[OF pt_name_inst, OF at_name_inst])
with `x \<sharp> R` `y \<sharp> R` have "([(x, y)] \<bullet> yvec') \<sharp>* R" by simp
moreover note `xvec' \<sharp>* R` `length xvec' = n`
ultimately obtain T where "P = T \<parallel> R" and A: "\<lparr>\<nu>*xvec'\<rparr>M \<prec>' T = \<lparr>\<nu>*([(x, y)] \<bullet> yvec')\<rparr>([(x, y)] \<bullet> N) \<prec>' ([(x, y)] \<bullet> Q)"
by(drule_tac IH) auto
from A have "\<lparr>\<nu>x\<rparr>(\<lparr>\<nu>*xvec'\<rparr>M \<prec>' T) = \<lparr>\<nu>x\<rparr>(\<lparr>\<nu>*([(x, y)] \<bullet> yvec')\<rparr>([(x, y)] \<bullet> N) \<prec>' ([(x, y)] \<bullet> Q))"
by(simp add: bound_output.inject alpha)
moreover from x_fresh_QR have "x \<sharp> \<lparr>\<nu>*yvec'\<rparr>N \<prec>' Q"
by(force simp add: bound_output_fresh)
ultimately show ?thesis using `P = T \<parallel> R` `xvec=x#xvec'` `yvec=y#yvec'` x_fresh_QR
by(force simp add: alpha_bound_output name_swap eqvts)
qed
qed
ultimately show ?thesis
by blast
qed
lemma bound_output_par1_dest':
fixes xvec :: "name list"
and M :: "'a::fs_name"
and P :: "('a, 'b::fs_name, 'c::fs_name) psi"
and yvec :: "name list"
and N :: 'a
and Q :: "('a, 'b, 'c) psi"
and R :: "('a, 'b, 'c) psi"
assumes "\<lparr>\<nu>*xvec\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec\<rparr>N \<prec>' (Q \<parallel> R)"
and "xvec \<sharp>* yvec"
obtains T p where "set p \<subseteq> set xvec \<times> set yvec" and "P = T \<parallel> (p \<bullet> R)" and "\<lparr>\<nu>*xvec\<rparr>M \<prec>' T = \<lparr>\<nu>*yvec\<rparr>N \<prec>' Q"
proof -
assume "\<And>p T. \<lbrakk>set p \<subseteq> set xvec \<times> set yvec; P = T \<parallel> (p \<bullet> R); \<lparr>\<nu>*xvec\<rparr>M \<prec>' T = \<lparr>\<nu>*yvec\<rparr>N \<prec>' Q\<rbrakk> \<Longrightarrow> thesis"
moreover obtain n where "n = length xvec" by auto
with assms have "\<exists>p T. set p \<subseteq> set xvec \<times> set yvec \<and> P = T \<parallel> (p \<bullet> R) \<and> \<lparr>\<nu>*xvec\<rparr>M \<prec>' T = \<lparr>\<nu>*yvec\<rparr>N \<prec>' Q"
proof(induct n arbitrary: xvec yvec M N P Q R)
case(0 xvec yvec M N P Q R)
have Eq: "\<lparr>\<nu>*xvec\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec\<rparr>N \<prec>' (Q \<parallel> R)" by fact
from `0 = length xvec` have "xvec = []" by auto
moreover with Eq have "yvec = []"
by(case_tac yvec) auto
ultimately show ?case using Eq
by(simp add: bound_output.inject)
next
case(Suc n xvec yvec M N P Q R)
from `Suc n = length xvec`
obtain x xvec' where "xvec = x#xvec'" and "length xvec' = n"
by(case_tac xvec) auto
from `\<lparr>\<nu>*xvec\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec\<rparr>N \<prec>' (Q \<parallel> R)` `xvec = x # xvec'`
obtain y yvec' where "\<lparr>\<nu>*(x#xvec')\<rparr>M \<prec>' P = \<lparr>\<nu>*(y#yvec')\<rparr>N \<prec>' (Q \<parallel> R)"
and "yvec = y#yvec'"
by(case_tac yvec) auto
hence Eq: "\<lparr>\<nu>x\<rparr>(\<lparr>\<nu>*xvec'\<rparr>M \<prec>' P) = \<lparr>\<nu>y\<rparr>(\<lparr>\<nu>*yvec'\<rparr>N \<prec>' (Q \<parallel> R))"
by simp
from `xvec = x#xvec'` `yvec=y#yvec'` `xvec \<sharp>* yvec` have "x \<noteq> y" and "x \<sharp> yvec'" and "y \<sharp> xvec'" and "xvec' \<sharp>* yvec'"
by auto
from Eq `x \<noteq> y` have Eq': "\<lparr>\<nu>*xvec'\<rparr>M \<prec>' P = [(x, y)] \<bullet> \<lparr>\<nu>*yvec'\<rparr>N \<prec>' (Q \<parallel> R)"
and x_fresh_QR: "x \<sharp> \<lparr>\<nu>*yvec'\<rparr>N \<prec>' (Q \<parallel> R)"
by(simp add: bound_output.inject alpha)+
have IH: "\<And>xvec yvec M N P Q R. \<lbrakk>\<lparr>\<nu>*xvec\<rparr>M \<prec>' (P::('a, 'b, 'c) psi) = \<lparr>\<nu>*yvec\<rparr>N \<prec>' (Q \<parallel> R); xvec \<sharp>* yvec; n = length xvec\<rbrakk> \<Longrightarrow> \<exists>p T. set p \<subseteq> set xvec \<times> set yvec \<and> P = T \<parallel> (p \<bullet> R) \<and> \<lparr>\<nu>*xvec\<rparr>M \<prec>' T = \<lparr>\<nu>*yvec\<rparr>N \<prec>' Q"
by fact
show ?case
proof(case_tac "x \<sharp> \<lparr>\<nu>*xvec'\<rparr>M \<prec>' P")
assume "x \<sharp> \<lparr>\<nu>*xvec'\<rparr>M \<prec>' P"
with Eq have y_fresh_qR: "y \<sharp> \<lparr>\<nu>*yvec'\<rparr>N \<prec>' (Q \<parallel> R)"
by(rule bound_output_eq_fresh)
with Eq' x_fresh_QR have "\<lparr>\<nu>*xvec'\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec'\<rparr>N \<prec>' (Q \<parallel> R)"
by simp
with `xvec' \<sharp>* yvec'` `length xvec' = n`
obtain p T where S: "set p \<subseteq> set xvec' \<times> set yvec'" and "P = T \<parallel> (p \<bullet> R)" and A: "\<lparr>\<nu>*xvec'\<rparr>M \<prec>' T = \<lparr>\<nu>*yvec'\<rparr>N \<prec>' Q"
by(drule_tac IH) auto
from y_fresh_qR x_fresh_QR have y_freshQ: "y \<sharp> \<lparr>\<nu>*yvec'\<rparr>N \<prec>' Q" and x_freshQ: "x \<sharp> \<lparr>\<nu>*yvec'\<rparr>N \<prec>' Q"
by(force simp add: BO_res_chain_supp fresh_def bound_output.supp psi.supp)+
hence "\<lparr>\<nu>x\<rparr>(\<lparr>\<nu>*yvec'\<rparr>N \<prec>' Q) = \<lparr>\<nu>y\<rparr>(\<lparr>\<nu>*yvec'\<rparr>N \<prec>' Q)" by (subst alpha_bound_output) simp+
with A have "\<lparr>\<nu>x\<rparr>(\<lparr>\<nu>*xvec'\<rparr>M \<prec>' T) = \<lparr>\<nu>y\<rparr>(\<lparr>\<nu>*yvec'\<rparr>N \<prec>' Q)" by simp
with `xvec=x#xvec'` `yvec=y#yvec'` S `P = T \<parallel> (p \<bullet> R)` show ?case
by auto
next
assume "\<not>(x \<sharp> \<lparr>\<nu>*xvec'\<rparr>M \<prec>' P)"
hence "x \<in> supp(\<lparr>\<nu>*xvec'\<rparr>M \<prec>' P)" by(simp add: fresh_def)
with Eq have "y \<in> supp(\<lparr>\<nu>*yvec'\<rparr>N \<prec>' (Q \<parallel> R))"
by(rule bound_output_eq_supp)
hence "y \<sharp> yvec'" by(simp add: BO_res_chain_supp fresh_def)
with Eq' `x \<sharp> yvec'` have "\<lparr>\<nu>*xvec'\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec'\<rparr>([(x, y)] \<bullet> N) \<prec>' (([(x, y)] \<bullet> Q) \<parallel> ([(x, y)] \<bullet> R))"
by(simp add: eqvts)
moreover note `xvec' \<sharp>* yvec'` `length xvec' = n`
ultimately obtain p T where S: "set p \<subseteq> set xvec' \<times> set yvec'" and "P = T \<parallel> (p \<bullet> [(x, y)] \<bullet> R)" and A: "\<lparr>\<nu>*xvec'\<rparr>M \<prec>' T = \<lparr>\<nu>*yvec'\<rparr>([(x, y)] \<bullet> N) \<prec>' ([(x, y)] \<bullet> Q)"
by(drule_tac IH) auto
from S have "set(p@[(x, y)]) \<subseteq> set(x#xvec') \<times> set(y#yvec')" by auto
moreover from `P = T \<parallel> (p \<bullet> [(x, y)] \<bullet> R)` have "P = T \<parallel> ((p @ [(x, y)]) \<bullet> R)"
by(simp add: pt2[OF pt_name_inst])
moreover from x_fresh_QR have x_freshQ: "x \<sharp> \<lparr>\<nu>*yvec'\<rparr>N \<prec>' Q"
by(force simp add: BO_res_chain_supp fresh_def bound_output.supp psi.supp)+
with `x \<sharp> yvec'` `y \<sharp> yvec'` `x \<noteq> y` have "y \<sharp> \<lparr>\<nu>*yvec'\<rparr>([(x, y)] \<bullet> N) \<prec>' ([(x, y)] \<bullet> Q)"
by(simp add: fresh_left calc_atm)
with `x \<sharp> yvec'` `y \<sharp> yvec'` have "\<lparr>\<nu>x\<rparr>(\<lparr>\<nu>*yvec'\<rparr>([(x, y)] \<bullet> N) \<prec>' ([(x, y)] \<bullet> Q)) = \<lparr>\<nu>y\<rparr>(\<lparr>\<nu>*yvec'\<rparr>N \<prec>' Q)"
by(subst alpha_bound_output) (assumption | simp add: eqvts)+
with A have "\<lparr>\<nu>x\<rparr>(\<lparr>\<nu>*xvec'\<rparr>M \<prec>' T) = \<lparr>\<nu>y\<rparr>(\<lparr>\<nu>*yvec'\<rparr>N \<prec>' Q)" by simp
ultimately show ?thesis using `xvec=x#xvec'` `yvec=y#yvec'`
by(rule_tac x="p@[(x, y)]" in exI) force
qed
qed
ultimately show ?thesis
by blast
qed
lemma bound_output_par2_dest:
fixes xvec :: "name list"
and M :: "'a::fs_name"
and P :: "('a, 'b::fs_name, 'c::fs_name) psi"
and yvec :: "name list"
and N :: 'a
and Q :: "('a, 'b, 'c) psi"
and R :: "('a, 'b, 'c) psi"
assumes "\<lparr>\<nu>*xvec\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec\<rparr>N \<prec>' (Q \<parallel> R)"
and "xvec \<sharp>* Q"
and "yvec \<sharp>* Q"
obtains T where "P = Q \<parallel> T" and "\<lparr>\<nu>*xvec\<rparr>M \<prec>' T = \<lparr>\<nu>*yvec\<rparr>N \<prec>' R"
proof -
assume "\<And>T. \<lbrakk>P = Q \<parallel> T; \<lparr>\<nu>*xvec\<rparr>M \<prec>' T = \<lparr>\<nu>*yvec\<rparr>N \<prec>' R\<rbrakk> \<Longrightarrow> thesis"
moreover obtain n where "n = length xvec" by auto
with assms have "\<exists>T. P = Q \<parallel> T \<and> \<lparr>\<nu>*xvec\<rparr>M \<prec>' T = \<lparr>\<nu>*yvec\<rparr>N \<prec>' R"
proof(induct n arbitrary: xvec yvec M N P Q R)
case(0 xvec yvec M N P Q R)
have Eq: "\<lparr>\<nu>*xvec\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec\<rparr>N \<prec>' (Q \<parallel> R)" by fact
from `0 = length xvec` have "xvec = []" by auto
moreover with Eq have "yvec = []"
by(case_tac yvec) auto
ultimately show ?case using Eq
by(simp add: bound_output.inject)
next
case(Suc n xvec yvec M N P Q R)
from `Suc n = length xvec`
obtain x xvec' where "xvec = x#xvec'" and "length xvec' = n"
by(case_tac xvec) auto
from `\<lparr>\<nu>*xvec\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec\<rparr>N \<prec>' (Q \<parallel> R)` `xvec = x # xvec'`
obtain y yvec' where "\<lparr>\<nu>*(x#xvec')\<rparr>M \<prec>' P = \<lparr>\<nu>*(y#yvec')\<rparr>N \<prec>' (Q \<parallel> R)"
and "yvec = y#yvec'"
by(case_tac yvec) auto
hence EQ: "\<lparr>\<nu>x\<rparr>(\<lparr>\<nu>*xvec'\<rparr>M \<prec>' P) = \<lparr>\<nu>y\<rparr>(\<lparr>\<nu>*yvec'\<rparr>N \<prec>' (Q \<parallel> R))"
by simp
from `xvec \<sharp>* Q` `yvec \<sharp>* Q` `xvec = x#xvec'` `yvec = y#yvec'`
have "x \<sharp> Q" and "xvec' \<sharp>* Q" and "y \<sharp> Q" and "yvec' \<sharp>* Q" by auto
have IH: "\<And>xvec yvec M N P Q R. \<lbrakk>\<lparr>\<nu>*xvec\<rparr>M \<prec>' (P::('a, 'b, 'c) psi) = \<lparr>\<nu>*yvec\<rparr>N \<prec>' (Q \<parallel> R); xvec \<sharp>* Q; yvec \<sharp>* Q; n = length xvec\<rbrakk> \<Longrightarrow> \<exists>T. P = Q \<parallel> T \<and> \<lparr>\<nu>*xvec\<rparr>M \<prec>' T = \<lparr>\<nu>*yvec\<rparr>N \<prec>' R"
by fact
show ?case
proof(case_tac "x = y")
assume "x = y"
with EQ have "\<lparr>\<nu>*xvec'\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec'\<rparr>N \<prec>' (Q \<parallel> R)"
by(simp add: bound_output.inject alpha)
with `xvec' \<sharp>* Q` `yvec' \<sharp>* Q` `length xvec' = n`
obtain T where "P = Q \<parallel> T" and "\<lparr>\<nu>*xvec'\<rparr>M \<prec>' T = \<lparr>\<nu>*yvec'\<rparr>N \<prec>' R"
by(drule_tac IH) auto
with `xvec=x#xvec'` `yvec=y#yvec'` `x=y` show ?case
by(force simp add: bound_output.inject alpha)
next
assume "x \<noteq> y"
with EQ `x \<sharp> Q` `y \<sharp> Q`
have "\<lparr>\<nu>*xvec'\<rparr>M \<prec>' P = \<lparr>\<nu>*([(x, y)] \<bullet> yvec')\<rparr>([(x, y)] \<bullet> N) \<prec>' (Q \<parallel> ([(x, y)] \<bullet> R))"
and x_fresh_QR: "x \<sharp> \<lparr>\<nu>*yvec'\<rparr>N \<prec>' (Q \<parallel> R)"
by(simp add: bound_output.inject alpha eqvts)+
moreover from `yvec' \<sharp>* Q` have "([(x, y)] \<bullet> yvec') \<sharp>* ([(x, y)] \<bullet> Q)"
by(simp add: pt_fresh_star_bij[OF pt_name_inst, OF at_name_inst])
with `x \<sharp> Q` `y \<sharp> Q` have "([(x, y)] \<bullet> yvec') \<sharp>* Q" by simp
moreover note `xvec' \<sharp>* Q` `length xvec' = n`
ultimately obtain T where "P = Q \<parallel> T" and A: "\<lparr>\<nu>*xvec'\<rparr>M \<prec>' T = \<lparr>\<nu>*([(x, y)] \<bullet> yvec')\<rparr>([(x, y)] \<bullet> N) \<prec>' ([(x, y)] \<bullet> R)"
by(drule_tac IH) auto
from A have "\<lparr>\<nu>x\<rparr>(\<lparr>\<nu>*xvec'\<rparr>M \<prec>' T) = \<lparr>\<nu>x\<rparr>(\<lparr>\<nu>*([(x, y)] \<bullet> yvec')\<rparr>([(x, y)] \<bullet> N) \<prec>' ([(x, y)] \<bullet> R))"
by(simp add: bound_output.inject alpha)
moreover from x_fresh_QR have "x \<sharp> \<lparr>\<nu>*yvec'\<rparr>N \<prec>' R"
by(force simp add: bound_output_fresh)
ultimately show ?thesis using `P = Q \<parallel> T` `xvec=x#xvec'` `yvec=y#yvec'` x_fresh_QR
by(force simp add: alpha_bound_output name_swap eqvts)
qed
qed
ultimately show ?thesis
by blast
qed
lemma bound_output_par2_dest':
fixes xvec :: "name list"
and M :: "'a::fs_name"
and P :: "('a, 'b::fs_name, 'c::fs_name) psi"
and yvec :: "name list"
and N :: 'a
and Q :: "('a, 'b, 'c) psi"
and R :: "('a, 'b, 'c) psi"
assumes "\<lparr>\<nu>*xvec\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec\<rparr>N \<prec>' (Q \<parallel> R)"
and "xvec \<sharp>* yvec"
obtains T p where "set p \<subseteq> set xvec \<times> set yvec" and "P = (p \<bullet> Q) \<parallel> T" and "\<lparr>\<nu>*xvec\<rparr>M \<prec>' T = \<lparr>\<nu>*yvec\<rparr>N \<prec>' R"
proof -
assume "\<And>p T. \<lbrakk>set p \<subseteq> set xvec \<times> set yvec; P = (p \<bullet> Q) \<parallel> T; \<lparr>\<nu>*xvec\<rparr>M \<prec>' T = \<lparr>\<nu>*yvec\<rparr>N \<prec>' R\<rbrakk> \<Longrightarrow> thesis"
moreover obtain n where "n = length xvec" by auto
with assms have "\<exists>p T. set p \<subseteq> set xvec \<times> set yvec \<and> P = (p \<bullet> Q) \<parallel> T \<and> \<lparr>\<nu>*xvec\<rparr>M \<prec>' T = \<lparr>\<nu>*yvec\<rparr>N \<prec>' R"
proof(induct n arbitrary: xvec yvec M N P Q R)
case(0 xvec yvec M N P Q R)
have Eq: "\<lparr>\<nu>*xvec\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec\<rparr>N \<prec>' (Q \<parallel> R)" by fact
from `0 = length xvec` have "xvec = []" by auto
moreover with Eq have "yvec = []"
by(case_tac yvec) auto
ultimately show ?case using Eq
by(simp add: bound_output.inject)
next
case(Suc n xvec yvec M N P Q R)
from `Suc n = length xvec`
obtain x xvec' where "xvec = x#xvec'" and "length xvec' = n"
by(case_tac xvec) auto
from `\<lparr>\<nu>*xvec\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec\<rparr>N \<prec>' (Q \<parallel> R)` `xvec = x # xvec'`
obtain y yvec' where "\<lparr>\<nu>*(x#xvec')\<rparr>M \<prec>' P = \<lparr>\<nu>*(y#yvec')\<rparr>N \<prec>' (Q \<parallel> R)"
and "yvec = y#yvec'"
by(case_tac yvec) auto
hence Eq: "\<lparr>\<nu>x\<rparr>(\<lparr>\<nu>*xvec'\<rparr>M \<prec>' P) = \<lparr>\<nu>y\<rparr>(\<lparr>\<nu>*yvec'\<rparr>N \<prec>' (Q \<parallel> R))"
by simp
from `xvec = x#xvec'` `yvec=y#yvec'` `xvec \<sharp>* yvec` have "x \<noteq> y" and "x \<sharp> yvec'" and "y \<sharp> xvec'" and "xvec' \<sharp>* yvec'"
by auto
from Eq `x \<noteq> y` have Eq': "\<lparr>\<nu>*xvec'\<rparr>M \<prec>' P = [(x, y)] \<bullet> \<lparr>\<nu>*yvec'\<rparr>N \<prec>' (Q \<parallel> R)"
and x_fresh_QR: "x \<sharp> \<lparr>\<nu>*yvec'\<rparr>N \<prec>' (Q \<parallel> R)"
by(simp add: bound_output.inject alpha)+
have IH: "\<And>xvec yvec M N P Q R. \<lbrakk>\<lparr>\<nu>*xvec\<rparr>M \<prec>' (P::('a, 'b, 'c) psi) = \<lparr>\<nu>*yvec\<rparr>N \<prec>' (Q \<parallel> R); xvec \<sharp>* yvec; n = length xvec\<rbrakk> \<Longrightarrow> \<exists>p T. set p \<subseteq> set xvec \<times> set yvec \<and> P = (p \<bullet> Q) \<parallel> T \<and> \<lparr>\<nu>*xvec\<rparr>M \<prec>' T = \<lparr>\<nu>*yvec\<rparr>N \<prec>' R"
by fact
show ?case
proof(case_tac "x \<sharp> \<lparr>\<nu>*xvec'\<rparr>M \<prec>' P")
assume "x \<sharp> \<lparr>\<nu>*xvec'\<rparr>M \<prec>' P"
with Eq have y_fresh_qR: "y \<sharp> \<lparr>\<nu>*yvec'\<rparr>N \<prec>' (Q \<parallel> R)"
by(rule bound_output_eq_fresh)
with Eq' x_fresh_QR have "\<lparr>\<nu>*xvec'\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec'\<rparr>N \<prec>' (Q \<parallel> R)"
by simp
with `xvec' \<sharp>* yvec'` `length xvec' = n`
obtain p T where S: "set p \<subseteq> set xvec' \<times> set yvec'" and "P = (p \<bullet> Q) \<parallel> T" and A: "\<lparr>\<nu>*xvec'\<rparr>M \<prec>' T = \<lparr>\<nu>*yvec'\<rparr>N \<prec>' R"
by(drule_tac IH) auto
from y_fresh_qR x_fresh_QR have y_freshR: "y \<sharp> \<lparr>\<nu>*yvec'\<rparr>N \<prec>' R" and x_freshQ: "x \<sharp> \<lparr>\<nu>*yvec'\<rparr>N \<prec>' R"
by(force simp add: BO_res_chain_supp fresh_def bound_output.supp psi.supp)+
hence "\<lparr>\<nu>x\<rparr>(\<lparr>\<nu>*yvec'\<rparr>N \<prec>' R) = \<lparr>\<nu>y\<rparr>(\<lparr>\<nu>*yvec'\<rparr>N \<prec>' R)" by (subst alpha_bound_output) simp+
with A have "\<lparr>\<nu>x\<rparr>(\<lparr>\<nu>*xvec'\<rparr>M \<prec>' T) = \<lparr>\<nu>y\<rparr>(\<lparr>\<nu>*yvec'\<rparr>N \<prec>' R)" by simp
with `xvec=x#xvec'` `yvec=y#yvec'` S `P = (p \<bullet> Q) \<parallel> T` show ?case
by auto
next
assume "\<not>(x \<sharp> \<lparr>\<nu>*xvec'\<rparr>M \<prec>' P)"
hence "x \<in> supp(\<lparr>\<nu>*xvec'\<rparr>M \<prec>' P)" by(simp add: fresh_def)
with Eq have "y \<in> supp(\<lparr>\<nu>*yvec'\<rparr>N \<prec>' (Q \<parallel> R))"
by(rule bound_output_eq_supp)
hence "y \<sharp> yvec'" by(simp add: BO_res_chain_supp fresh_def)
with Eq' `x \<sharp> yvec'` have "\<lparr>\<nu>*xvec'\<rparr>M \<prec>' P = \<lparr>\<nu>*yvec'\<rparr>([(x, y)] \<bullet> N) \<prec>' (([(x, y)] \<bullet> Q) \<parallel> ([(x, y)] \<bullet> R))"
by(simp add: eqvts)
moreover note `xvec' \<sharp>* yvec'` `length xvec' = n`
ultimately obtain p T where S: "set p \<subseteq> set xvec' \<times> set yvec'" and "P = (p \<bullet> [(x, y)] \<bullet> Q) \<parallel> T" and A: "\<lparr>\<nu>*xvec'\<rparr>M \<prec>' T = \<lparr>\<nu>*yvec'\<rparr>([(x, y)] \<bullet> N) \<prec>' ([(x, y)] \<bullet> R)"
by(drule_tac IH) auto
from S have "set(p@[(x, y)]) \<subseteq> set(x#xvec') \<times> set(y#yvec')" by auto
moreover from `P = (p \<bullet> [(x, y)] \<bullet> Q) \<parallel> T` have "P = ((p @ [(x, y)]) \<bullet> Q) \<parallel> T"
by(simp add: pt2[OF pt_name_inst])
moreover from x_fresh_QR have x_freshR: "x \<sharp> \<lparr>\<nu>*yvec'\<rparr>N \<prec>' R"
by(force simp add: BO_res_chain_supp fresh_def bound_output.supp psi.supp)+
with `x \<sharp> yvec'` `y \<sharp> yvec'` `x \<noteq> y` have "y \<sharp> \<lparr>\<nu>*yvec'\<rparr>([(x, y)] \<bullet> N) \<prec>' ([(x, y)] \<bullet> R)"
by(simp add: fresh_left calc_atm)
with `x \<sharp> yvec'` `y \<sharp> yvec'` have "\<lparr>\<nu>x\<rparr>(\<lparr>\<nu>*yvec'\<rparr>([(x, y)] \<bullet> N) \<prec>' ([(x, y)] \<bullet> R)) = \<lparr>\<nu>y\<rparr>(\<lparr>\<nu>*yvec'\<rparr>N \<prec>' R)"
by(subst alpha_bound_output) (assumption | simp add: eqvts)+
with A have "\<lparr>\<nu>x\<rparr>(\<lparr>\<nu>*xvec'\<rparr>M \<prec>' T) = \<lparr>\<nu>y\<rparr>(\<lparr>\<nu>*yvec'\<rparr>N \<prec>' R)" by simp
ultimately show ?thesis using `xvec=x#xvec'` `yvec=y#yvec'`
by(rule_tac x="p@[(x, y)]" in exI) force
qed
qed
ultimately show ?thesis
by blast
qed
lemma bound_output_app:
fixes xvec :: "name list"
and yvec :: "name list"
and B :: "('a::fs_name, 'b::fs_name, 'c::fs_name) bound_output"