-
Notifications
You must be signed in to change notification settings - Fork 1
/
Fusion.v
631 lines (585 loc) · 17.3 KB
/
Fusion.v
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
Require Import Equality.
Require Import Modal_Library Deductive_System Sets.
(* Typeclass that states that we "lift" indexes of either base set to fusion set *)
Class lift_conv (A B: Type): Type := {
lift: A -> B
}.
Section Fusion.
(*Index sets*)
Context {I1: Set}.
Context {I2: Set}.
(*Fusion of indexes is simply disjoint set union*)
Definition fusion: Set :=
I1 + I2.
(*Instances of the modal index set typeclass*)
Context {X1: @modal_index_set I1}.
Context {X2: @modal_index_set I2}.
(*Indexes of the fusion*)
Instance fusion_index_set: @modal_index_set fusion := {|
C i :=
match i with
| inl a => @C I1 X1 a
| inr b => @C I2 X2 b
end
|}.
(*** Helper Notations ***)
(* Modal Indexes of either logic and the logic resulting from their fusion *)
Local Notation modal_index1 := (@modal_index I1 X1).
Local Notation modal_index2 := (@modal_index I2 X2).
Local Notation modal_indexF := (@modal_index fusion fusion_index_set).
(* Formulas of either logic and the logic resulting from their fusion *)
Local Notation formula1 := (@formula I1 X1).
Local Notation formula2 := (@formula I2 X2).
Local Notation formulaF := (@formula fusion fusion_index_set).
(* Frames of either logic and the logic resulting from their fusion *)
Local Notation Frame1 := (@Frame I1 X1).
Local Notation Frame2 := (@Frame I2 X2).
Local Notation FrameF := (@Frame fusion fusion_index_set).
(* Models of either logic and the logic resulting from their fusion *)
Local Notation Model1 := (@Model I1 X1).
Local Notation Model2 := (@Model I2 X2).
Local Notation ModelF := (@Model fusion fusion_index_set).
(* Axiom Sets of either logic and the logic resulting from their fusion *)
Local Notation axiom1 := (@axiom I1 X1).
Local Notation axiom2 := (@axiom I2 X2).
Local Notation axiomF := (@axiom fusion fusion_index_set).
(* Definition of the fusion of frames *)
Definition join_frames (f1: Frame1) (f2: Frame2) (H: W f2 = W f1): FrameF.
Proof.
constructor 1 with (W f1).
intros ([ idx | idx ], idx_valid) w v.
- exact (R f1 (Build_modal_index idx idx_valid) w v).
- rewrite <- H in w, v.
exact (R f2 (Build_modal_index idx idx_valid) w v).
Defined.
(* Proofs that we can "lift" indexes of either base system to the fusion system *)
Instance index_lift1: lift_conv modal_index1 modal_indexF.
Proof.
constructor; intros.
destruct H as (idx, idx_valid).
constructor 1 with (index := inl idx).
simpl; assumption.
Defined.
Instance index_lift2: lift_conv modal_index2 modal_indexF.
Proof.
constructor; intros.
destruct H as (idx, idx_valid).
constructor 1 with (index := inr idx).
simpl; assumption.
Defined.
(* Proofs that we can "lift" formulas of either base system to the fusion system *)
Instance formula_lift1: lift_conv formula1 formulaF.
Proof.
constructor; intros.
induction H.
- constructor 1.
exact n.
- constructor 2.
exact IHformula.
- constructor 3.
+ exact (lift m).
+ exact IHformula.
- constructor 4.
+ exact (lift m).
+ exact IHformula.
- constructor 5.
+ exact IHformula1.
+ exact IHformula2.
- constructor 6.
+ exact IHformula1.
+ exact IHformula2.
- constructor 7.
+ exact IHformula1.
+ exact IHformula2.
Defined.
Instance formula_lift2: lift_conv formula2 formulaF.
Proof.
constructor; intros.
induction H.
- constructor 1.
exact n.
- constructor 2.
exact IHformula.
- constructor 3.
+ exact (lift m).
+ exact IHformula.
- constructor 4.
+ exact (lift m).
+ exact IHformula.
- constructor 5.
+ exact IHformula1.
+ exact IHformula2.
- constructor 6.
+ exact IHformula1.
+ exact IHformula2.
- constructor 7.
+ exact IHformula1.
+ exact IHformula2.
Defined.
(* Some cheeky automation that may not work :-( *)
(* TODO: Ver se é possível fazer essa automação funcionar *)
Ltac lift_me_up type :=
repeat match goal with
| [H: type |- formulaF] => try (exact (lift H))
| _ => fail "expected fomulaF"
end.
(* Proofs that we can "lift" axioms of either base system to the fusion system *)
Instance axiom_lift1: lift_conv axiom1 axiomF.
Proof.
constructor; intros.
destruct H.
- constructor 1.
+ exact (lift f).
+ exact (lift f0).
- constructor 2.
+ exact (lift f).
+ exact (lift f0).
+ exact (lift f1).
- constructor 3.
+ exact (lift f).
+ exact (lift f0).
- constructor 4.
+ exact (lift f).
+ exact (lift f0).
- constructor 5.
+ exact (lift f).
+ exact (lift f0).
- constructor 6.
+ exact (lift f).
+ exact (lift f0).
- constructor 7.
+ exact (lift f).
+ exact (lift f0).
- constructor 8.
+ exact (lift f).
+ exact (lift f0).
- constructor 9.
+ exact (lift f).
+ exact (lift f0).
+ exact (lift f1).
- constructor 10.
exact (lift f).
- constructor 11.
+ exact (lift m).
+ exact (lift f).
+ exact (lift f0).
- constructor 12.
+ exact (lift m).
+ exact (lift f).
- constructor 13.
+ exact (lift m).
+ exact (lift f).
- constructor 14.
+ exact (lift m).
+ exact (lift f).
- constructor 15.
+ exact (lift m).
+ exact (lift f).
- constructor 16.
+ exact (lift m).
+ exact (lift f).
- constructor 17.
+ exact (lift m).
+ exact (lift f).
- constructor 18.
+ exact (lift m).
+ exact (lift f).
Defined.
Instance formula_axiom2: lift_conv axiom2 axiomF.
Proof.
constructor; intros.
destruct H.
- constructor 1.
+ exact (lift f).
+ exact (lift f0).
- constructor 2.
+ exact (lift f).
+ exact (lift f0).
+ exact (lift f1).
- constructor 3.
+ exact (lift f).
+ exact (lift f0).
- constructor 4.
+ exact (lift f).
+ exact (lift f0).
- constructor 5.
+ exact (lift f).
+ exact (lift f0).
- constructor 6.
+ exact (lift f).
+ exact (lift f0).
- constructor 7.
+ exact (lift f).
+ exact (lift f0).
- constructor 8.
+ exact (lift f).
+ exact (lift f0).
- constructor 9.
+ exact (lift f).
+ exact (lift f0).
+ exact (lift f1).
- constructor 10.
exact (lift f).
- constructor 11.
+ exact (lift m).
+ exact (lift f).
+ exact (lift f0).
- constructor 12.
+ exact (lift m).
+ exact (lift f).
- constructor 13.
+ exact (lift m).
+ exact (lift f).
- constructor 14.
+ exact (lift m).
+ exact (lift f).
- constructor 15.
+ exact (lift m).
+ exact (lift f).
- constructor 16.
+ exact (lift m).
+ exact (lift f).
- constructor 17.
+ exact (lift m).
+ exact (lift f).
- constructor 18.
+ exact (lift m).
+ exact (lift f).
Defined.
(* Proving that lift and instantiate are commutative *)
Lemma instantiate_lift_inversion1:
forall (p: axiom1) (f: formulaF),
instantiate (lift p) = f ->
f = lift (instantiate p).
Proof.
intros.
induction p; auto.
Qed.
Lemma instantiate_lift_inversion2:
forall (p: axiom2) (f: formulaF),
instantiate (lift p) = f ->
f = lift (instantiate p).
Proof.
intros.
induction p; auto.
Qed.
(* Proving that we can recover the frames/models of the base logics after fusion *)
Lemma split_frame1:
FrameF -> Frame1.
Proof.
intros F.
destruct F as (W, R).
constructor 1 with W.
intros idx w v.
apply R.
- destruct idx.
constructor 1 with (index := inl index).
assumption.
- exact w.
- exact v.
Defined.
Lemma split_model1:
ModelF -> Model1.
Proof.
intros M.
destruct M as (F, v).
constructor 1 with (F := split_frame1 F).
destruct F; simpl in *.
exact v.
Defined.
(* Proving that if we lift a model that was split we get a fusion model back*)
Instance lift_split_model1 M: @lift_conv (W (F (split_model1 M))) (W (F M)).
Proof.
constructor; intros.
destruct M as ((W, R), v);
simpl in *.
assumption.
Defined.
(* Proving that splitting model preserves evaluation of formulas *)
(* That is, if a formula was true/false in the base model, it will be true/false
in the fusion model *)
Lemma split_model1_coherence:
forall M f w,
fun_validation (split_model1 M) w f <->
fun_validation M (lift w) (lift f).
Proof.
intros until f.
destruct M as ((W, R), v).
set (F := Build_Frame W R).
set (M := Build_Model F v).
fold M in v; simpl in v.
induction f; split; intros.
- assumption.
- assumption.
- replace (lift (Neg f)) with (Neg (lift f)) by auto.
intros ?H.
eapply H.
apply IHf.
assumption.
- replace (lift (Neg f)) with (Neg (lift f)) in H by auto.
intros ?H.
eapply H.
apply IHf.
assumption.
- replace (lift (Box m f)) with (Box (lift m) (lift f)) by auto.
intros w' ?.
apply IHf.
apply H.
assumption.
- replace (lift (Box m f)) with (Box (lift m) (lift f)) in H by auto.
intros w' ?.
apply IHf.
apply H.
assumption.
- replace (lift (Dia m f)) with (Dia (lift m) (lift f)) by auto.
destruct H as (w', ?, ?).
exists w';
[ | apply IHf]; assumption.
- replace (lift (Dia m f)) with (Dia (lift m) (lift f)) in H by auto.
destruct H as (w', ?, ?).
exists w';
[ | apply IHf]; assumption.
- replace (lift (And f1 f2)) with (And (lift f1) (lift f2)) by auto.
destruct H; constructor;
[ apply IHf1 | apply IHf2 ];
assumption.
- replace (lift (And f1 f2)) with (And (lift f1) (lift f2)) in H by auto.
destruct H; constructor;
[ apply IHf1 | apply IHf2 ];
assumption.
- replace (lift (Or f1 f2)) with (Or (lift f1) (lift f2)) by auto.
destruct H;
[left; apply IHf1 | right; apply IHf2];
assumption.
- replace (lift (Or f1 f2)) with (Or (lift f1) (lift f2)) in H by auto.
destruct H;
[left; apply IHf1 | right; apply IHf2];
assumption.
- replace (lift (Implies f1 f2)) with (Implies (lift f1) (lift f2)) by auto.
intros ?H.
apply IHf2.
apply H.
apply IHf1.
assumption.
- replace (lift (Implies f1 f2)) with (Implies (lift f1) (lift f2)) in H by auto.
intros ?H.
apply IHf2.
apply H.
apply IHf1.
assumption.
Qed.
(* Same as before, but now for frame2 *)
Lemma split_frame2:
FrameF -> Frame2.
Proof.
intros F.
destruct F as (W, R).
constructor 1 with W.
intros idx w v.
apply R.
- destruct idx.
constructor 1 with (index := inr index).
assumption.
- exact w.
- exact v.
Defined.
Lemma split_model2:
ModelF -> Model2.
Proof.
intros M.
destruct M as (F, v).
constructor 1 with (F := split_frame2 F).
destruct F; simpl in *.
exact v.
Defined.
Instance lift_split_model2 M: @lift_conv (W (F (split_model2 M))) (W (F M)).
Proof.
constructor; intros.
destruct M as ((W, R), v);
simpl in *.
assumption.
Defined.
Lemma split_model2_coherence:
forall M f w,
fun_validation (split_model2 M) w f <->
fun_validation M (lift w) (lift f).
Proof.
intros until f.
destruct M as ((W, R), v).
set (F := Build_Frame W R).
set (M := Build_Model F v).
fold M in v; simpl in v.
induction f; split; intros.
- assumption.
- assumption.
- replace (lift (Neg f)) with (Neg (lift f)) by auto.
intros ?H.
eapply H.
apply IHf.
assumption.
- replace (lift (Neg f)) with (Neg (lift f)) in H by auto.
intros ?H.
eapply H.
apply IHf.
assumption.
- replace (lift (Box m f)) with (Box (lift m) (lift f)) by auto.
intros w' ?.
apply IHf.
apply H.
assumption.
- replace (lift (Box m f)) with (Box (lift m) (lift f)) in H by auto.
intros w' ?.
apply IHf.
apply H.
assumption.
- replace (lift (Dia m f)) with (Dia (lift m) (lift f)) by auto.
destruct H as (w', ?, ?).
exists w';
[ | apply IHf]; assumption.
- replace (lift (Dia m f)) with (Dia (lift m) (lift f)) in H by auto.
destruct H as (w', ?, ?).
exists w';
[ | apply IHf]; assumption.
- replace (lift (And f1 f2)) with (And (lift f1) (lift f2)) by auto.
destruct H; constructor;
[ apply IHf1 | apply IHf2 ];
assumption.
- replace (lift (And f1 f2)) with (And (lift f1) (lift f2)) in H by auto.
destruct H; constructor;
[ apply IHf1 | apply IHf2 ];
assumption.
- replace (lift (Or f1 f2)) with (Or (lift f1) (lift f2)) by auto.
destruct H;
[left; apply IHf1 | right; apply IHf2];
assumption.
- replace (lift (Or f1 f2)) with (Or (lift f1) (lift f2)) in H by auto.
destruct H;
[left; apply IHf1 | right; apply IHf2];
assumption.
- replace (lift (Implies f1 f2)) with (Implies (lift f1) (lift f2)) by auto.
intros ?H.
apply IHf2.
apply H.
apply IHf1.
assumption.
- replace (lift (Implies f1 f2)) with (Implies (lift f1) (lift f2)) in H
by auto.
intros ?H.
apply IHf2.
apply H.
apply IHf1.
assumption.
Qed.
(* Classes of Frames of either logic and the logic resulting from their fusion *)
Variable P1: Frame1 -> Prop.
Variable P2: Frame2 -> Prop.
Definition PF: FrameF -> Prop :=
fun F =>
P1 (split_frame1 F) /\ P2 (split_frame2 F).
(* Axiom Systems of either logic and the axiom system resulting from fusion *)
Variable A1: axiom1 -> Prop.
Variable A2: axiom2 -> Prop.
Inductive fusion_axioms: axiomF -> Prop :=
| fusion_axioms1:
forall p, A1 p -> fusion_axioms (lift p)
| fusion_axioms2:
forall p, A2 p -> fusion_axioms (lift p).
End Fusion.
(* Generic Definition of Soundness (in the base library we only have this definition for K) *)
Definition sound I `{X: @modal_index_set I} P A: Prop :=
forall G p,
(A; G |-- p) -> entails_modal_class P G p.
(* Proof of transfer of soundness by the fusion *)
Theorem soundness_transfer:
forall I1 `{X1: @modal_index_set I1} P1 A1,
forall I2 `{X2: @modal_index_set I2} P2 A2,
sound I1 P1 A1 ->
sound I2 P2 A2 ->
sound fusion (PF P1 P2) (fusion_axioms A1 A2).
Proof.
intros.
intros G p ?H M ?H ?H.
(*
The original soundness goal is of the form:
(fusion_axioms A1 A2; G |-- p) -> entails_modal_class (PF P1 P2) G p.
As we've introduced the premisse of the ->, we must prove that entails_modal_class (PF P1 P2) G p
Given the hypothesis that fusion_axioms A1 A2; G |-- p
We proced by induction on this hypothesis
*)
induction H1; intro.
- (* Case 0: Premisse *)
now apply H3.
- (*
Case 1: Instance of an Axiom
We proceed by analising from which system the axiom comes from
*)
destruct H1.
+ (* Either A1 *)
apply instantiate_lift_inversion1 in H4; subst.
assert (A1; Empty |-- instantiate p) by now constructor 2 with p.
set (M1 := split_model1 M).
specialize (H Empty _ H4 M1).
assert (P1 (F M1)).
* destruct M as ((W, F), v).
apply H2.
* specialize (H H5).
assert (theory_modal M1 Empty) by inversion 1.
specialize (H H6).
destruct M as ((W, F), v).
simpl in H, H2, H3, w.
specialize (H w).
apply split_model1_coherence in H.
assumption.
+ (* Or A2 *)
apply instantiate_lift_inversion2 in H4; subst.
assert (A2; Empty |-- instantiate p) by now constructor 2 with p.
set (M2 := split_model2 M).
specialize (H0 Empty _ H4 M2).
assert (P2 (F M2)).
* destruct M as ((W, F), v).
apply H2.
* specialize (H0 H5).
assert (theory_modal M2 Empty) by inversion 1.
specialize (H0 H6).
destruct M as ((W, F), v).
simpl in H0, H2, H3, w.
specialize (H0 w).
apply split_model2_coherence in H0.
assumption.
- (* Case 2: Modus Ponens *)
apply IHdeduction1;
[ | apply IHdeduction2];
assumption.
- (* Case 3: Necessitation *)
intros w' ?.
apply IHdeduction.
inversion 1.
Qed.
(* For the example *)
Require Import Soundness Modal_Notations.
(* TODO: Figure out were to put these examples! *)
Section Soundness_Transfer_Example.
Local Instance unit_index: @modal_index_set unit := {|
(* Use the whole universe (i.e., unit). *)
C x := True
|}.
(* The only possible index in the system. *)
Local Definition idx: modal_index :=
Build_modal_index tt I.
(* We define X as the fusion of two copies of System S4 on idx. *)
Local Definition X :=
fusion_axioms (S4 idx) (S4 idx).
(* Condition on frames: both need to be pre-orders. *)
Local Definition P: Frame -> Prop :=
fun F => preorder_frame F idx.
(* We prove System X is sound from soundness of System S4 alone. *)
Goal
sound fusion (PF P P) X.
Proof.
apply soundness_transfer.
- intros G p ? M ?.
now apply soundness_S4 with (idx := idx).
- intros G p ? M ?.
now apply soundness_S4 with (idx := idx).
Qed.
End Soundness_Transfer_Example.