-
Notifications
You must be signed in to change notification settings - Fork 2
/
unprove.v
2124 lines (2057 loc) · 71.1 KB
/
unprove.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
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
Require Import Utf8_core.
Require Import FunInd.
Require ILLVarInt. (* Don't want import it. *)
Import ILLVarInt.MILL. (* only this *)
Import FormulaMultiSet. (* and this *)
Require Import ILL_equiv.
Require Import emma_orig.
Open Scope ILL_scope.
Open Scope Emma.
Require Import Setoid.
Function appears (under_plus:bool) (v:nat) (f:formula) {struct f} : bool :=
match f with
| Proposition n => Nat.eqb n v
| Otimes f1 f2 | And f1 f2 =>
orb (appears under_plus v f1) (appears under_plus v f2)
| Oplus f1 f2 | Implies f1 f2 =>
if under_plus
then orb (appears under_plus v f1) (appears under_plus v f2)
else false
| Bang f => appears under_plus v f
| Zero => true
| _ => false
end.
Definition exists_in_env f gamma :=
fold _ (fun k acc => orb (f k) acc) gamma false.
Definition appears_in_env v := exists_in_env (appears true v).
Lemma iter_bool_proper : forall v, Morphisms.Proper
(ILLVarInt.MILL.eq ==> Logic.eq ==> Logic.eq ==> Logic.eq)
(iter bool
(λ (k0 : formula) (acc : bool), (appears true v k0 || acc)%bool)).
Proof.
intros v.
red.
red.
intros x y H.
apply eq_is_eq in H.
subst.
red.
intros x y0 H.
subst.
red.
intros;subst;reflexivity.
Qed.
Lemma iter_transpose_nkey : forall v,MapsPtes.transpose_neqkey Logic.eq
(iter bool
(λ (k : formula) (acc : bool), (appears true v k || acc)%bool)).
Proof.
red.
intros v k k' e e' a _.
revert k' e' a.
induction e as [ | e].
simpl.
intros k' e'.
induction e' as [ | e'].
simpl;intros.
case(appears true v k);case (appears true v k');simpl;reflexivity.
intros a.
simpl.
rewrite <- IHe'.
case(appears true v k);case (appears true v k');simpl;reflexivity.
intros k' e' a.
simpl.
rewrite (IHe k' e').
f_equal.
case(appears true v k);simpl.
2:reflexivity.
clear.
induction e' as [|e'].
simpl.
auto with *.
simpl.
case (appears true v k');simpl;auto.
Qed.
Lemma appears_in_env_morph : ∀ v Γ Γ', Γ == Γ' -> appears_in_env v Γ = appears_in_env v Γ'.
Proof.
intros v Γ Γ' H.
unfold appears_in_env, exists_in_env,fold.
revert Γ' H.
apply MapsPtes.fold_rec.
- intros m H Γ' H0.
rewrite H0 in H.
rewrite MapsPtes.fold_Empty.
reflexivity.
auto.
assumption.
- intros k e a m' m'' H H0 H1 H2 Γ' H3.
rewrite MapsPtes.fold_Add.
+ f_equal.
apply H2.
reflexivity.
+ auto.
+ apply iter_bool_proper.
+ apply iter_transpose_nkey.
+ assumption.
+ intro.
rewrite <- H3.
apply H1.
Qed.
Add Morphism appears_in_env with signature (Logic.eq ==> eq ==> Logic.eq) as morph_appears_in_env.
exact appears_in_env_morph.
Qed.
Lemma appears_false_is_appears_true : forall n p, appears false n p = true -> appears true n p = true.
Proof.
intros n p.
functional induction (appears false n p);simpl.
tauto.
intros H.
rewrite Bool.orb_true_iff in H;destruct H.
rewrite IHb0;auto.
rewrite IHb1;auto with *.
intros H.
rewrite Bool.orb_true_iff in H;destruct H.
rewrite IHb0;auto.
rewrite IHb1;auto with *.
intros H.
rewrite Bool.orb_true_iff in H;destruct H.
rewrite IHb0;auto.
rewrite IHb1;auto with *.
discriminate.
intros H.
rewrite Bool.orb_true_iff in H;destruct H.
rewrite IHb0;auto.
rewrite IHb1;auto with *.
discriminate.
auto.
reflexivity.
discriminate.
Qed.
Lemma exists_in_env_in : forall f φ Γ, φ∈Γ -> f φ = true -> exists_in_env f Γ = true.
Proof.
intros f φ Γ H H0.
revert φ H0 H.
unfold exists_in_env.
apply fold_rec_weak.
intros m m' a H H0 φ H1 H2.
rewrite <- H in H2;eauto.
intros φ H0 H.
unfold mem in H.
rewrite MapsPtes.F.empty_a in H;assumption.
intros k a m H φ H0 H1.
destruct (mem_destruct _ _ _ H1) as [H2|H2].
apply eq_is_eq in H2;subst.
rewrite H0;reflexivity.
rewrite H with (φ:=φ).
auto with *.
assumption.
assumption.
Qed.
Lemma in_exists_in_env : forall f Γ, exists_in_env f Γ = true -> exists φ,φ∈Γ/\ f φ = true.
Proof.
intros f Γ.
unfold exists_in_env.
apply fold_rec_weak.
intros m m' a H H0 H1.
destruct (H0 H1) as [φ H2].
rewrite H in H2.
exists φ;assumption.
discriminate.
intros k a m H H0.
rewrite Bool.orb_true_iff in H0.
destruct H0.
exists k;split;auto.
apply add_is_mem;apply FormulaOrdered.eq_refl.
destruct (H H0) as [φ [H1 H2]].
exists φ;split.
apply mem_add_comm;assumption.
assumption.
Qed.
Lemma not_exists_in_env_in : forall f Γ, exists_in_env f Γ = false -> forall φ, φ∈Γ -> f φ = false.
Proof.
intros f Γ.
unfold exists_in_env.
apply fold_rec_weak.
intros m m' a H H0 H1 φ H2.
rewrite <- H in H2;auto.
intros H φ H0.
unfold mem in H0;rewrite MapsPtes.F.empty_a in H0.
discriminate.
intros k a m H H0 φ H1.
rewrite Bool.orb_false_iff in H0;destruct H0.
destruct (mem_destruct _ _ _ H1).
apply eq_is_eq in H3;subst.
assumption.
auto.
Qed.
Lemma in_not_exists_in_env : forall f Γ, (forall φ, φ∈Γ -> f φ = false) -> exists_in_env f Γ = false.
Proof.
intros f Γ.
unfold exists_in_env.
apply fold_rec_weak.
intros m m' a H H0 H1.
apply H0.
intros φ H2.
rewrite H in H2;auto.
reflexivity.
intros k a m H H0.
rewrite H.
replace (f k) with false.
reflexivity.
symmetry.
apply H0.
apply add_is_mem.
apply FormulaOrdered.eq_refl.
intros φ H1.
apply H0.
apply mem_add_comm;assumption.
Qed.
Lemma exists_in_env_add : forall f φ Γ, exists_in_env f (φ::Γ) = ((f φ)|| (exists_in_env f Γ))%bool.
Proof.
intros f φ Γ.
case_eq (exists_in_env f (φ::Γ));intros Heq.
destruct (in_exists_in_env _ _ Heq) as [ψ [H1 H2]].
destruct (mem_destruct _ _ _ H1).
apply eq_is_eq in H;subst.
rewrite H2;reflexivity.
rewrite (exists_in_env_in _ _ _ H H2).
auto with *.
assert (Heq':=not_exists_in_env_in _ _ Heq).
rewrite in_not_exists_in_env.
rewrite Heq'.
reflexivity.
apply add_is_mem;apply FormulaOrdered.eq_refl.
intros φ0 H.
apply Heq';apply mem_add_comm;assumption.
Qed.
Lemma appears_in_env_in_appears : forall n φ Γ, φ∈Γ -> appears true n φ = true -> appears_in_env n Γ=true.
Proof.
intros n φ Γ.
unfold appears_in_env.
intros H H0.
apply exists_in_env_in with φ;assumption.
Qed.
Lemma appears_in_env_false_add :
forall n (Γ:t) φ, appears_in_env n (φ::Γ) = false ->
appears_in_env n Γ = false /\ appears true n φ = false.
Proof.
intros n Γ.
induction Γ using multiset_ind.
- intros φ H0.
rewrite <- H in H0.
assert (H':=IHΓ1 _ H0).
rewrite H in H';assumption.
- intros φ H.
case_eq (appears true n φ);intros Heq1.
+ unfold appears_in_env,exists_in_env,fold,add in H.
rewrite MapsPtes.F.empty_o in H.
rewrite (@MapsPtes.fold_add _ _ Logic.eq) in H.
* simpl in H.
rewrite Heq1 in H;discriminate.
* auto.
* apply iter_proper.
clear;repeat red.
intros x y H x0 y0 H0.
repeat red in H0.
apply eq_is_eq in H;subst;reflexivity.
* apply iter_transpose_nkey.
* rewrite MapsPtes.F.empty_in_iff;tauto.
+ auto.
- intros φ H.
assert (H':= not_exists_in_env_in _ _ H).
rewrite H' by (apply add_is_mem;apply FormulaOrdered.eq_refl).
split;auto.
apply in_not_exists_in_env.
intros φ0 H0.
apply H'.
apply mem_add_comm;assumption.
Qed.
Lemma appears_false_remove : ∀ n (Γ:t) φ, appears_in_env n Γ = false ->
appears_in_env n (Γ\φ) = false.
Proof.
intros v Γ φ.
induction Γ using multiset_ind.
rewrite H in IHΓ1;assumption.
rewrite remove_empty;tauto.
intros H.
destruct (appears_in_env_false_add _ _ _ H) as [H1 H2];clear H.
apply in_not_exists_in_env.
intros φ0 H.
case (FormulaOrdered.eq_dec x φ);intro Heq.
rewrite remove_same_add in H by (symmetry;assumption).
apply not_exists_in_env_in with (Γ:=Γ);assumption.
rewrite remove_diff_add in H by (intro abs;elim Heq;rewrite abs;reflexivity).
generalize (mem_destruct _ _ _ H);intros [H3|H3].
apply eq_is_eq in H3;subst; assumption.
assert (H':=IHΓ H1).
apply not_exists_in_env_in with (Γ:=Γ\φ); assumption.
Qed.
Lemma appears_false_union :
∀ n Δ Δ', appears_in_env n (Δ∪Δ') = false ->
appears_in_env n (Δ) = false /\
appears_in_env n (Δ') = false.
Proof.
intros n Δ Δ' H.
split;apply in_not_exists_in_env;intros.
apply not_exists_in_env_in with (Γ:=Δ∪Δ');try assumption.
apply mem_union_l;assumption.
apply not_exists_in_env_in with (Γ:=Δ∪Δ');try assumption.
apply mem_union_r;assumption.
Qed.
Lemma var_in_env : ∀ Γ φ n, (appears false n φ) = true -> appears_in_env n Γ = false -> Γ⊢φ -> False.
Proof.
intros Γ φ n H H0 H1.
revert H H0.
induction H1;intros Heq1 Heq2;simpl in *;try discriminate.
- rewrite H in Heq2.
unfold appears_in_env,exists_in_env,fold,Maps'.fold in Heq2. simpl in Heq2.
apply appears_false_is_appears_true in Heq1.
rewrite Heq1 in Heq2.
discriminate Heq2.
- apply IHILL_proof2.
assumption.
assert (Heq2' := Heq2).
apply (appears_false_remove _ _ (p⊸q)) in Heq2.
rewrite H0 in Heq2.
apply appears_false_union in Heq2.
destruct Heq2.
apply in_not_exists_in_env.
intros φ H3.
destruct (mem_destruct _ _ _ H3) as [H4|H4].
apply eq_is_eq in H4;subst.
assert (appears true n (p⊸q) = false).
apply not_exists_in_env_in with (Γ:=Γ); assumption.
simpl in H4.
rewrite Bool.orb_false_iff in H4;intuition.
apply not_exists_in_env_in with (Γ:=Δ'); assumption.
- rewrite H in Heq2.
apply appears_false_union in Heq2;destruct Heq2.
rewrite Bool.orb_true_iff in Heq1;destruct Heq1.
apply IHILL_proof1;assumption.
apply IHILL_proof2;assumption.
- apply IHILL_proof.
assumption.
assert (Heq2' := Heq2).
apply (appears_false_remove _ _ (p⊗q)) in Heq2.
apply in_not_exists_in_env.
intros φ H3.
assert (happear:appears true n (p⊗q) = false) by
(apply not_exists_in_env_in with (Γ:=Γ);assumption).
simpl in happear.
rewrite Bool.orb_false_iff in happear;intuition.
destruct (mem_destruct _ _ _ H3) as [H5|H5].
apply eq_is_eq in H5;subst;assumption.
destruct (mem_destruct _ _ _ H5) as [H6|H6].
apply eq_is_eq in H6;subst;assumption.
apply not_exists_in_env_in with (Γ:=Γ\p⊗q); assumption.
- apply IHILL_proof.
assumption.
assert (Heq2' := Heq2).
apply (appears_false_remove _ _ 1) in Heq2.
assumption.
- rewrite Bool.orb_true_iff in Heq1;destruct Heq1; eauto.
- apply IHILL_proof.
+ assumption.
+ assert (Heq2' := Heq2).
apply (appears_false_remove _ _ (p&q)) in Heq2.
apply in_not_exists_in_env.
intros φ H3.
assert (happear:appears true n (p&q) = false) by
(apply not_exists_in_env_in with (Γ:=Γ);assumption).
simpl in happear.
rewrite Bool.orb_false_iff in happear;intuition.
destruct (mem_destruct _ _ _ H3) as [H5|H5].
apply eq_is_eq in H5;subst;assumption.
apply not_exists_in_env_in with (Γ:=Γ\p&q); assumption.
- apply IHILL_proof.
assumption.
assert (Heq2' := Heq2).
apply (appears_false_remove _ _ (p&q)) in Heq2.
apply in_not_exists_in_env.
intros φ H3.
assert (happear:appears true n (p&q) = false) by
(apply not_exists_in_env_in with (Γ:=Γ);assumption).
simpl in happear.
rewrite Bool.orb_false_iff in happear;intuition.
destruct (mem_destruct _ _ _ H3) as [H5|H5].
apply eq_is_eq in H5;subst;assumption.
apply not_exists_in_env_in with (Γ:=Γ\p&q); assumption.
- apply IHILL_proof1.
assumption.
assert (Heq2' := Heq2).
apply (appears_false_remove _ _ (p⊕q)) in Heq2.
apply in_not_exists_in_env.
intros φ H3.
assert (happear:appears true n (p⊕q) = false) by
(apply not_exists_in_env_in with (Γ:=Γ);assumption).
simpl in happear.
rewrite Bool.orb_false_iff in happear;intuition.
destruct (mem_destruct _ _ _ H3) as [H5|H5].
apply eq_is_eq in H5;subst;assumption.
apply not_exists_in_env_in with (Γ:=Γ\p⊕q); assumption.
- assert (H':= not_exists_in_env_in _ _ Heq2).
generalize (H' _ H).
simpl;discriminate.
- apply IHILL_proof.
assumption.
assert (Heq2' := Heq2).
apply (appears_false_remove _ _ (!p)) in Heq2.
apply in_not_exists_in_env.
intros φ H3.
assert (happear:appears true n (!p) = false) by
(apply not_exists_in_env_in with (Γ:=Γ);assumption).
simpl in happear.
destruct (mem_destruct _ _ _ H3) as [H5|H5].
apply eq_is_eq in H5;subst;assumption.
apply not_exists_in_env_in with (Γ:=Γ\!p); assumption.
- apply IHILL_proof.
assumption.
assert (Heq2' := Heq2).
apply (appears_false_remove _ _ (!p)) in Heq2.
apply in_not_exists_in_env.
intros φ H3.
assert (happear:appears true n (!p) = false) by
(apply not_exists_in_env_in with (Γ:=Γ);assumption).
simpl in happear.
destruct (mem_destruct _ _ _ H3) as [H5|H5].
apply eq_is_eq in H5;subst;assumption.
apply not_exists_in_env_in with (Γ:=Γ); assumption.
- apply IHILL_proof.
assumption.
assert (Heq2' := Heq2).
apply (appears_false_remove _ _ (!p)) in Heq2.
apply in_not_exists_in_env.
intros φ H3.
assert (happear:appears true n (!p) = false) by
(apply not_exists_in_env_in with (Γ:=Γ);assumption).
simpl in happear.
apply not_exists_in_env_in with (Γ:=Γ\!p); assumption.
Qed.
Function sub_formula (φ ψ:formula) {struct ψ} : bool :=
if FormulaOrdered.eq_dec φ ψ
then true
else
match ψ with
| Implies f1 f2 | Otimes f1 f2 | Oplus f1 f2 | And f1 f2 =>
orb (sub_formula φ f1) (sub_formula φ f2)
| Bang f => sub_formula φ f
| _ => false
end.
Function contains_arrow (φ:formula) {struct φ} : bool :=
match φ with
| Implies f1 f2 => true
| Otimes f1 f2 | Oplus f1 f2 | And f1 f2 =>
orb (contains_arrow f1) (contains_arrow f2)
| Bang f => contains_arrow f
| _ => false
end.
Function is_arrows_of_prop (φ:formula) {struct φ} : bool :=
match φ with
| Proposition _ => true
| Implies (Proposition _) f2 => is_arrows_of_prop f2
| _ => false
end.
Function arrow_from_prop (φ:formula) {struct φ} : bool :=
match φ with
| Implies _ _ => is_arrows_of_prop φ
| Otimes f1 f2 | Oplus f1 f2 | And f1 f2 =>
andb (arrow_from_prop f1) (arrow_from_prop f2)
| Bang f => arrow_from_prop f
| Proposition _ => true
| _ => true
end.
Lemma is_arrows_of_prop_arrow_from_prop :
∀ (φ:formula), is_arrows_of_prop φ = true -> arrow_from_prop φ = true.
Proof.
intros φ.
functional induction (is_arrows_of_prop φ).
reflexivity.
simpl;tauto.
discriminate.
Qed.
Set Implicit Arguments.
Lemma proof_of_var : forall Γ ψ, Γ⊢ψ -> forall n, ψ = Proposition n ->
(∀ φ', φ'∈Γ -> sub_formula Zero φ' = false) ->
exists φ, φ∈Γ/\ sub_formula (Proposition n) φ = true.
Proof.
intros Γ ψ H.
induction H;intros n Heq Hnotzero;try discriminate.
- subst.
exists (Proposition n);split.
rewrite H.
apply add_is_mem.
apply FormulaOrdered.eq_refl.
simpl.
case (FormulaOrdered.eq_dec (Proposition n) (Proposition n)).
reflexivity.
intros abs.
elim abs;apply FormulaOrdered.eq_refl.
- subst.
destruct (IHILL_proof2 n (refl_equal _)) as [φ [h1 h2]].
intros φ' H3.
destruct (mem_destruct _ _ _ H3);clear H3.
apply eq_is_eq in H4;subst.
generalize (Hnotzero _ H).
simpl.
intros h;rewrite Bool.orb_false_iff in h;destruct h;assumption.
apply Hnotzero.
apply mem_remove_2 with (b:=p ⊸ q).
rewrite H0;apply mem_union_r;assumption.
destruct (mem_destruct _ _ _ h1);clear h1.
apply eq_is_eq in H3;subst.
exists (p ⊸ q);split.
assumption.
simpl;rewrite h2; apply Bool.orb_true_r.
exists φ;split;try assumption.
apply mem_remove_2 with (b:=p ⊸ q).
rewrite H0;apply mem_union_r;assumption.
- subst.
destruct (IHILL_proof _ (refl_equal _)).
intros φ' H1.
assert (H2 := Hnotzero _ H);simpl in H2.
rewrite Bool.orb_false_iff in H2;destruct H2.
destruct (mem_destruct _ _ _ H1) as [H4|H4];clear H1.
apply eq_is_eq in H4;subst;assumption.
destruct (mem_destruct _ _ _ H4) as [H1|H1];clear H4.
apply eq_is_eq in H1;subst;assumption.
apply Hnotzero.
eauto using mem_remove_2.
destruct H1 as [H1 H2].
destruct (mem_destruct _ _ _ H1) as [H4|H4];clear H1.
apply eq_is_eq in H4;subst.
exists (p⊗q);split;try assumption.
simpl;rewrite H2;auto with bool.
destruct (mem_destruct _ _ _ H4) as [H1|H1];clear H4.
apply eq_is_eq in H1;subst.
exists (p⊗q);split;try assumption.
simpl;rewrite H2;auto with bool.
exists x;split.
eauto using mem_remove_2.
assumption.
- subst.
destruct (IHILL_proof _ (refl_equal _)).
intros φ' H1.
eauto using mem_remove_2.
destruct H1 as [H1 H2].
exists x;split.
eauto using mem_remove_2.
assumption.
- subst.
destruct (IHILL_proof _ (refl_equal _)).
intros φ' H1.
assert (H2 := Hnotzero _ H);simpl in H2.
rewrite Bool.orb_false_iff in H2;destruct H2.
destruct (mem_destruct _ _ _ H1) as [H4|H4];clear H1.
apply eq_is_eq in H4;subst;assumption.
apply Hnotzero.
eauto using mem_remove_2.
destruct H1 as [H1 H2].
destruct (mem_destruct _ _ _ H1) as [H4|H4];clear H1.
apply eq_is_eq in H4;subst.
exists (p&q);split;try assumption.
simpl;rewrite H2;auto with bool.
exists x;split.
eauto using mem_remove_2.
assumption.
- subst.
destruct (IHILL_proof _ (refl_equal _)).
intros φ' H1.
assert (H2 := Hnotzero _ H);simpl in H2.
rewrite Bool.orb_false_iff in H2;destruct H2.
destruct (mem_destruct _ _ _ H1) as [H4|H4];clear H1.
apply eq_is_eq in H4;subst;assumption.
apply Hnotzero.
eauto using mem_remove_2.
destruct H1 as [H1 H2].
destruct (mem_destruct _ _ _ H1) as [H4|H4];clear H1.
apply eq_is_eq in H4;subst.
exists (p&q);split;try assumption.
simpl;rewrite H2;auto with bool.
exists x;split.
eauto using mem_remove_2.
assumption.
- subst.
(* clear H1. *)
destruct (IHILL_proof1 _ (refl_equal _)).
intros φ' H1'.
assert (H2 := Hnotzero _ H);simpl in H2.
rewrite Bool.orb_false_iff in H2;destruct H2.
destruct (mem_destruct _ _ _ H1') as [H4|H4];clear H1'.
apply eq_is_eq in H4;subst;assumption.
apply Hnotzero.
eauto using mem_remove_2.
destruct H2 as [H1' H2'].
destruct (mem_destruct _ _ _ H1') as [H4|H4];clear H1'.
apply eq_is_eq in H4;subst.
exists (p⊕q);split;try assumption.
simpl;rewrite H2';auto with bool.
exists x;split.
eauto using mem_remove_2.
assumption.
- assert (H1:=Hnotzero _ H);simpl in H1;discriminate.
- subst.
destruct (IHILL_proof _ (refl_equal _)).
intros φ' H1.
assert (H2 := Hnotzero _ H);simpl in H2.
destruct (mem_destruct _ _ _ H1) as [H4|H4];clear H1.
apply eq_is_eq in H4;subst;assumption.
apply Hnotzero.
eauto using mem_remove_2.
destruct H1 as [H1 H2].
destruct (mem_destruct _ _ _ H1) as [H4|H4];clear H1.
apply eq_is_eq in H4;subst.
exists (!p);split;try assumption.
exists x;split.
eauto using mem_remove_2.
assumption.
- subst.
destruct (IHILL_proof _ (refl_equal _)).
intros φ' H1.
assert (H2 := Hnotzero _ H);simpl in H2.
destruct (mem_destruct _ _ _ H1) as [H4|H4];clear H1.
apply eq_is_eq in H4;subst;assumption.
apply Hnotzero.
eauto using mem_remove_2.
destruct H1 as [H1 H2].
destruct (mem_destruct _ _ _ H1) as [H4|H4];clear H1.
apply eq_is_eq in H4;subst.
exists (!p);split;try assumption.
exists x;split.
eauto using mem_remove_2.
assumption.
- subst.
destruct (IHILL_proof _ (refl_equal _)).
intros φ' H1.
assert (H2 := Hnotzero _ H);simpl in H2.
eauto using mem_remove_2.
destruct H1 as [H1 H2].
exists x;split.
eauto using mem_remove_2.
assumption.
Qed.
Lemma unusable_implies_aux:
∀ n Γ ψ (prf:Γ⊢ψ) φ (Hin:((Proposition n) ⊸φ) ∈ Γ)
(Htopr:sub_formula (⊤) ψ = false) (Harrr:contains_arrow ψ = false)
(Harr:(∀ φ', φ' ∈ Γ -> contains_arrow φ' = true -> arrow_from_prop φ' = true))
(Hzero:(∀ φ', φ'∈Γ -> sub_formula Zero φ' = false))
(Htop:(∀ φ', φ'∈Γ -> sub_formula (⊤) φ' = false))
(Hsub:(∀ φ', φ'∈Γ -> sub_formula (Proposition n) φ' = true -> ((Proposition n)⊸φ) = φ')),
False.
Proof.
intros n Γ ψ hΓ.
induction hΓ;intros.
- assert (Htop':= Htop _ Hin).
simpl in Htop'.
rewrite H in Hin.
destruct (mem_destruct _ _ _ Hin);clear Hin.
apply eq_is_eq in H0;subst.
simpl in *.
discriminate.
rewrite empty_no_mem in H0;discriminate.
- discriminate.
- case (FormulaOrdered.eq_dec ((Proposition n) ⊸ φ) (p⊸q));intros Heq.
(* Top application *)
+ apply eq_is_eq in Heq;injection Heq;clear Heq;intros;subst.
assert (proof_of_var' := @proof_of_var _ _ hΓ1 _ (refl_equal _)).
destruct (proof_of_var') as [φ' [h1 h2]].
intros φ' H6.
apply Hzero.
apply mem_remove_2 with (Proposition n ⊸ q);rewrite H0;apply mem_union_l; assumption.
apply Hsub in h2.
2:{ apply mem_remove_2 with (Proposition n ⊸ q);rewrite H0;apply mem_union_l; assumption. }
subst.
apply IHhΓ1 with (φ:=q);try assumption.
simpl;tauto.
simpl;tauto.
intros φ' H1 H2.
apply Harr;try assumption.
apply mem_remove_2 with (Proposition n ⊸ q);rewrite H0;apply mem_union_l; assumption.
intros φ' H1.
apply Hzero;try assumption.
apply mem_remove_2 with (Proposition n ⊸ q);rewrite H0;apply mem_union_l; assumption.
intros φ' H1.
apply Htop;try assumption.
apply mem_remove_2 with (Proposition n ⊸ q);rewrite H0;apply mem_union_l; assumption.
intros φ' H1 H2.
apply Hsub;try assumption.
apply mem_remove_2 with (Proposition n ⊸ q);rewrite H0;apply mem_union_l; assumption.
(* not top application *)
+ assert (Hin':(Proposition n ⊸ φ)∈(Δ∪Δ')).
rewrite <- H0.
rewrite <- mem_remove_1.
exact Hin.
assumption.
destruct (mem_union_destruct _ _ _ Hin') as [Hin1|Hin1].
(* in Δ *)
* apply (IHhΓ1 _ Hin1);try assumption.
assert (Htop' := Htop _ H).
simpl in Htop';rewrite Bool.orb_false_iff in Htop';destruct Htop';assumption.
assert (Harr' := Harr _ H (refl_equal _)).
simpl in Harr'.
destruct p;try discriminate.
simpl;reflexivity.
intros φ' H1 H2.
apply Harr;try assumption.
apply mem_remove_2 with (p ⊸ q);rewrite H0;apply mem_union_l; assumption.
intros φ' H1.
apply Hzero;try assumption.
apply mem_remove_2 with (p ⊸ q);rewrite H0;apply mem_union_l; assumption.
intros φ' H1.
apply Htop;try assumption.
apply mem_remove_2 with (p ⊸ q);rewrite H0;apply mem_union_l; assumption.
intros φ' H1 H2.
apply Hsub;try assumption.
apply mem_remove_2 with (p ⊸ q);rewrite H0;apply mem_union_l; assumption.
(* in Δ' *)
* assert (Hin2 : (Proposition n ⊸ φ) ∈ (q::Δ')).
apply mem_add_comm;assumption.
apply (IHhΓ2 _ Hin2);try assumption.
(* contains *)
-- intros φ' H1 H2.
destruct (mem_destruct _ _ _ H1) as [H3|H3];clear H1.
apply eq_is_eq in H3;subst.
assert (Harr':=Harr _ H (refl_equal _)).
simpl in Harr'.
destruct p;try discriminate.
apply is_arrows_of_prop_arrow_from_prop;assumption.
apply Harr;try assumption.
apply mem_remove_2 with (p ⊸ q);rewrite H0;apply mem_union_r; assumption.
(* sub 0 *)
-- intros φ' H1.
destruct (mem_destruct _ _ _ H1) as [H3|H3];clear H1.
apply eq_is_eq in H3;subst.
assert (Hzero':=Hzero _ H);simpl in Hzero';rewrite Bool.orb_false_iff in Hzero';destruct Hzero';assumption.
apply Hzero.
apply mem_remove_2 with (p ⊸ q);rewrite H0;apply mem_union_r; assumption.
(* sub top *)
-- intros φ' H1.
destruct (mem_destruct _ _ _ H1) as [H3|H3];clear H1.
apply eq_is_eq in H3;subst.
assert (Htop':=Htop _ H);simpl in Htop';rewrite Bool.orb_false_iff in Htop';destruct Htop';assumption.
apply Htop.
apply mem_remove_2 with (p ⊸ q);rewrite H0;apply mem_union_r; assumption.
(* sub n *)
-- intros φ' H1 H2.
destruct (mem_destruct _ _ _ H1) as [H3|H3];clear H1.
apply eq_is_eq in H3;subst.
assert (Hsub' := Hsub _ H).
simpl in Hsub'.
rewrite H2 in Hsub'.
rewrite Bool.orb_true_r in Hsub'.
assert (Hsub'' := Hsub' (refl_equal _)).
injection Hsub'';clear - Heq;intros;subst.
elim Heq;apply FormulaOrdered.eq_refl.
apply Hsub;try assumption.
apply mem_remove_2 with (p ⊸ q);rewrite H0;apply mem_union_r; assumption.
- rewrite H in Hin.
simpl in Htopr;rewrite Bool.orb_false_iff in Htopr;destruct Htopr as [Htopp1 Htopq].
simpl in Harrr;rewrite Bool.orb_false_iff in Harrr;destruct Harrr as [Harrrp1 Harrrq].
destruct (mem_union_destruct _ _ _ Hin) as [Hin1|Hin1].
(* in Δ *)
* apply (IHhΓ1 _ Hin1);try assumption.
(* contain *)
-- intros φ' H0 H1.
apply Harr;try assumption.
rewrite H; auto using mem_union_l.
(* Zero *)
-- intros φ' H0.
apply Hzero.
rewrite H; auto using mem_union_l.
(* Top *)
-- intros φ' H0.
apply Htop.
rewrite H; auto using mem_union_l.
(* eq *)
-- intros φ' H0 H1.
apply Hsub;try assumption.
rewrite H; auto using mem_union_l.
(* in Δ' *)
* apply (IHhΓ2 _ Hin1);try assumption.
(* contain *)
-- intros φ' H0 H1.
apply Harr;try assumption.
rewrite H; auto using mem_union_r.
(* Zero *)
-- intros φ' H0.
apply Hzero.
rewrite H; auto using mem_union_r.
(* Top *)
-- intros φ' H0.
apply Htop.
rewrite H; auto using mem_union_r.
(* eq *)
-- intros φ' H0 H1.
apply Hsub;try assumption.
rewrite H; auto using mem_union_r.
- apply IHhΓ with φ;try assumption.
(* in *)
* do 2 apply mem_add_comm.
rewrite <- mem_remove_1.
assumption.
simpl;tauto.
(* contain *)
* intros φ' H0 H1.
destruct (mem_destruct _ _ _ H0) as [H2|H2];clear H0.
apply eq_is_eq in H2;subst.
assert (Harr' := Harr _ H);simpl in Harr';rewrite H1 in Harr'.
rewrite Bool.orb_true_r in Harr';assert (Harr'':= Harr' (refl_equal _)).
rewrite Bool.andb_true_iff in Harr'';destruct Harr'';assumption.
destruct (mem_destruct _ _ _ H2) as [H0|H0];clear H2.
apply eq_is_eq in H0;subst.
assert (Harr' := Harr _ H);simpl in Harr';rewrite H1 in Harr'.
rewrite Bool.orb_true_l in Harr';assert (Harr'':= Harr' (refl_equal _)).
rewrite Bool.andb_true_iff in Harr'';destruct Harr'';assumption.
apply mem_remove_2 in H0.
auto.
(* Zero *)
* intros φ' H0.
destruct (mem_destruct _ _ _ H0) as [H2|H2];clear H0.
apply eq_is_eq in H2;subst.
assert (Hzero' := Hzero _ H);simpl in Hzero'.
rewrite Bool.orb_false_iff in Hzero';destruct Hzero';assumption.
destruct (mem_destruct _ _ _ H2) as [H0|H0];clear H2.
apply eq_is_eq in H0;subst.
assert (Hzero' := Hzero _ H);simpl in Hzero'.
rewrite Bool.orb_false_iff in Hzero';destruct Hzero';assumption.
apply mem_remove_2 in H0.
auto.
(* Top *)
* intros φ' H0.
destruct (mem_destruct _ _ _ H0) as [H2|H2];clear H0.
apply eq_is_eq in H2;subst.
assert (Htop' := Htop _ H);simpl in Htop'.
rewrite Bool.orb_false_iff in Htop';destruct Htop';assumption.
destruct (mem_destruct _ _ _ H2) as [H0|H0];clear H2.
apply eq_is_eq in H0;subst.
assert (Htop' := Htop _ H);simpl in Htop'.
rewrite Bool.orb_false_iff in Htop';destruct Htop';assumption.
apply mem_remove_2 in H0.
auto.
(* sub *)
* intros φ' H0 H1.
destruct (mem_destruct _ _ _ H0) as [H2|H2];clear H0.
apply eq_is_eq in H2;subst.
assert (Hsub' := Hsub _ H);simpl in Hsub';rewrite H1 in Hsub'.
rewrite Bool.orb_true_r in Hsub';assert (Hsub'':= Hsub' (refl_equal _)).
discriminate.
destruct (mem_destruct _ _ _ H2) as [H0|H0];clear H2.
apply eq_is_eq in H0;subst.
assert (Hsub' := Hsub _ H);simpl in Hsub';rewrite H1 in Hsub'.
rewrite Bool.orb_true_l in Hsub';assert (Hsub'':= Hsub' (refl_equal _)).
discriminate.
apply mem_remove_2 in H0.
auto.
- clear - H Hin.
rewrite H in Hin.
rewrite empty_no_mem in Hin;discriminate.
- apply IHhΓ with φ;try assumption.
(* in *)
+ rewrite <- mem_remove_1.
assumption.
simpl;tauto.
(* contain *)
+ intros φ' H0 H1.
apply mem_remove_2 in H0.
auto.
(* Zero *)
+ intros φ' H0.
apply mem_remove_2 in H0.
auto.
(* Top *)
+ intros φ' H0.
apply mem_remove_2 in H0.
auto.
(* sub *)
+ intros φ' H0 H1.
apply mem_remove_2 in H0.
auto.
- apply IHhΓ1 with φ;try assumption.
(* topr *)
+ simpl in Htopr.
rewrite Bool.orb_false_iff in Htopr;destruct Htopr;assumption.
(* arrr *)
+ simpl in Harrr.
rewrite Bool.orb_false_iff in Harrr;destruct Harrr;assumption.
- apply IHhΓ with φ;try assumption.
(* in *)
+ apply mem_add_comm.
rewrite <- mem_remove_1.
assumption.
simpl;tauto.
(* contain *)
+ intros φ' H0 H1.
destruct (mem_destruct _ _ _ H0) as [H2|H2];clear H0.
apply eq_is_eq in H2;subst.
assert (Harr' := Harr _ H);simpl in Harr';rewrite H1 in Harr'.
rewrite Bool.orb_true_l in Harr';assert (Harr'':= Harr' (refl_equal _)).
rewrite Bool.andb_true_iff in Harr'';destruct Harr'';assumption.
apply mem_remove_2 in H2.
auto.
(* Zero *)
+ intros φ' H0.
destruct (mem_destruct _ _ _ H0) as [H2|H2];clear H0.
apply eq_is_eq in H2;subst.
assert (Hzero' := Hzero _ H);simpl in Hzero'.
rewrite Bool.orb_false_iff in Hzero';destruct Hzero';assumption.
apply mem_remove_2 in H2.
auto.
(* Top *)
+ intros φ' H0.
destruct (mem_destruct _ _ _ H0) as [H2|H2];clear H0.
apply eq_is_eq in H2;subst.
assert (Htop' := Htop _ H);simpl in Htop'.
rewrite Bool.orb_false_iff in Htop';destruct Htop';assumption.
apply mem_remove_2 in H2.
auto.
(* sub *)
+ intros φ' H0 H1.
destruct (mem_destruct _ _ _ H0) as [H2|H2];clear H0.
apply eq_is_eq in H2;subst.
assert (Hsub' := Hsub _ H);simpl in Hsub';rewrite H1 in Hsub'.
rewrite Bool.orb_true_l in Hsub';assert (Hsub'':= Hsub' (refl_equal _)).
discriminate.
apply mem_remove_2 in H2.
auto.
- apply IHhΓ with φ;try assumption.
(* in *)
+ apply mem_add_comm.
rewrite <- mem_remove_1.
assumption.
simpl;tauto.
(* contain *)
+ intros φ' H0 H1.
destruct (mem_destruct _ _ _ H0) as [H2|H2];clear H0.
apply eq_is_eq in H2;subst.
assert (Harr' := Harr _ H);simpl in Harr';rewrite H1 in Harr'.
rewrite Bool.orb_true_r in Harr';assert (Harr'':= Harr' (refl_equal _)).
rewrite Bool.andb_true_iff in Harr'';destruct Harr'';assumption.
apply mem_remove_2 in H2.
auto.
(* Zero *)
+ intros φ' H0.
destruct (mem_destruct _ _ _ H0) as [H2|H2];clear H0.
apply eq_is_eq in H2;subst.
assert (Hzero' := Hzero _ H);simpl in Hzero'.
rewrite Bool.orb_false_iff in Hzero';destruct Hzero';assumption.
apply mem_remove_2 in H2.
auto.
(* Top *)
+ intros φ' H0.
destruct (mem_destruct _ _ _ H0) as [H2|H2];clear H0.
apply eq_is_eq in H2;subst.
assert (Htop' := Htop _ H);simpl in Htop'.
rewrite Bool.orb_false_iff in Htop';destruct Htop';assumption.
apply mem_remove_2 in H2.
auto.
(* sub *)
+ intros φ' H0 H1.
destruct (mem_destruct _ _ _ H0) as [H2|H2];clear H0.
apply eq_is_eq in H2;subst.
assert (Hsub' := Hsub _ H);simpl in Hsub';rewrite H1 in Hsub'.