-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHilbertFol2.v
1569 lines (1437 loc) · 73.6 KB
/
HilbertFol2.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 Fol.Prelude.Prelude.
Require Import Fol.Data.Vector.
Require Import Fol.Math.BooleanAlgebra.
Require Import Fol.Logic.BasicFol.
Require Import Fol.Logic.BasicFol2.
Require Import Fol.Logic.HilbertFol.
Require Import Fol.Math.ThN.
Import ListNotations.
Import FolNotations.
#[local] Infix "\in" := E.In.
#[local] Infix "\subseteq" := E.isSubsetOf.
#[local] Notation In := L.In.
Module FolHilbert.
Infix "⊢" := HilbertFol.proves : type_scope.
Notation "Gamma ⊬ C" := (~ Gamma ⊢ C) : type_scope.
Notation inconsistent' := BooleanAlgebra.inconsistent.
Section EXTRA1.
Lemma extend_alpha_proves {L : language} (Gamma : ensemble (frm L)) (Gamma' : ensemble (frm L)) (C : frm L)
(SUBSET : forall p : frm L, forall IN : p \in Gamma, exists p' : frm L, p ≡ p' /\ p' \in Gamma')
(PROVE : Gamma ⊢ C)
: Gamma' ⊢ C.
Proof.
destruct PROVE as (ps&INCL&(PF)).
assert (PROVE : E.fromList ps ⊢ C).
{ exists ps. split. done. econs. exact PF. }
clear PF. revert Gamma Gamma' C SUBSET INCL PROVE. induction ps as [ | p ps IH]; simpl; i.
- eapply extend_proves with (Gamma := E.fromList []). done. exact PROVE.
- exploit (SUBSET p). done!. intros (p'&ALPHA&IN). eapply for_Imp_E with (p := p').
+ eapply IH with (Gamma := Gamma).
* intros q q_in. exploit (SUBSET q); trivial.
* done!.
* rewrite <- ALPHA. rewrite Deduction_theorem. eapply extend_proves with (Gamma := E.fromList (p :: ps)); trivial. done!.
+ eapply for_ByHyp; trivial.
Qed.
Definition inconsistent {L : language} (Gamma : ensemble (frm L)) : Prop :=
forall p, Gamma ⊢ p.
Context {L : language}.
Lemma extend_infers (Gamma : ensemble (frm L)) (Gamma' : ensemble (frm L)) (C : frm L)
(INFERS : Gamma ⊢ C)
(SUBSET : Gamma \subseteq Gamma')
: Gamma' ⊢ C.
Proof.
eapply extend_proves; eauto.
Qed.
Lemma ByAssumption (Gamma : ensemble (frm L)) C
(IN : C \in Gamma)
: Gamma ⊢ C.
Proof.
eapply for_ByHyp; trivial.
Qed.
Lemma ContradictionI (Gamma : ensemble (frm L)) A
(INFERS1 : Gamma ⊢ A)
(INFERS2 : Gamma ⊢ Neg_frm A)
: Gamma ⊢ Bot_frm.
Proof.
eapply for_Imp_E. eapply for_Imp_E. exists []. split. done. econs. eapply proof_ex_falso. exact INFERS2. exact INFERS1.
Qed.
Lemma ContradictionE (Gamma : ensemble (frm L)) A
(INFERS1 : Gamma ⊢ Bot_frm)
: Gamma ⊢ A.
Proof.
eapply for_Imp_E with (p := All_frm 0 (Eqn_frm (Var_trm 0) (Var_trm 0))).
- eapply for_Imp_E with (p := Bot_frm).
+ exists []. split. done. econs. eapply proof_ex_falso.
+ eapply INFERS1.
- eapply extend_proves with (Gamma := E.empty). done. eapply for_All_I. done. eapply proves_reflexivity.
Qed.
Lemma NegationI (Gamma : ensemble (frm L)) A
(INFERS1 : E.insert A Gamma ⊢ Bot_frm)
: Gamma ⊢ Neg_frm A.
Proof.
rewrite <- Deduction_theorem in INFERS1. eapply for_Imp_E. 2: exact INFERS1. eapply for_compose.
- eapply for_CP1. eapply INFERS1.
- eapply for_Imp_I. eapply for_Imp_E.
+ exists []. split. done. econs. eapply proof_dni.
+ eapply extend_proves with (Gamma := E.empty). done. eapply for_All_I. done. eapply proves_reflexivity.
Qed.
Lemma NegationE (Gamma : ensemble (frm L)) A
(INFERS1 : E.insert (Neg_frm A) Gamma ⊢ Bot_frm)
: Gamma ⊢ A.
Proof.
eapply for_Imp_E. exists []. split. done. econs. eapply proof_dne. eapply NegationI. exact INFERS1.
Qed.
Lemma ConjunctionI (Gamma : ensemble (frm L)) A B
(INFERS1 : Gamma ⊢ A)
(INFERS2 : Gamma ⊢ B)
: Gamma ⊢ Con_frm A B.
Proof.
unfold Con_frm. eapply NegationI. eapply ContradictionI with (A := B).
- eapply extend_proves with (Gamma := Gamma). done!. eapply INFERS2.
- eapply for_Imp_E with (p := A). eapply ByAssumption. done!. eapply extend_proves with (Gamma := Gamma). done!. eapply INFERS1.
Qed.
Lemma ConjunctionE1 (Gamma : ensemble (frm L)) A B
(INFERS1 : Gamma ⊢ Con_frm A B)
: Gamma ⊢ A.
Proof.
eapply for_Imp_E. exists []. split. done. econs. eapply proof_dne. unfold Con_frm in INFERS1. eapply for_Imp_E. 2: exact INFERS1.
eapply for_CP1. eapply for_Imp_I. eapply for_Imp_I. eapply NegationI. eapply ContradictionI with (A := A); eapply for_ByHyp; done!.
Qed.
Lemma ConjunctionE2 (Gamma : ensemble (frm L)) A B
(INFERS1 : Gamma ⊢ Con_frm A B)
: Gamma ⊢ B.
Proof.
eapply for_Imp_E. exists []. split. done. econs. eapply proof_dne. unfold Con_frm in INFERS1. eapply for_Imp_E. 2: exact INFERS1.
eapply for_CP1. eapply for_Imp_I. eapply for_Imp_I. eapply NegationI. eapply ContradictionI with (A := B); eapply for_ByHyp; done!.
Qed.
Lemma DisjunctionI1 (Gamma : ensemble (frm L)) A B
(INFERS1 : Gamma ⊢ A)
: Gamma ⊢ Dis_frm A B.
Proof.
unfold Dis_frm. eapply NegationI. eapply ContradictionI with (A := A).
- eapply extend_proves with (Gamma := Gamma); done!.
- eapply ConjunctionE1. eapply ByAssumption. left. reflexivity.
Qed.
Lemma DisjunctionI2 (Gamma : ensemble (frm L)) A B
(INFERS1 : Gamma ⊢ B)
: Gamma ⊢ Dis_frm A B.
Proof.
unfold Dis_frm. eapply NegationI. eapply ContradictionI with (A := B).
- eapply extend_proves with (Gamma := Gamma); done!.
- eapply ConjunctionE2. eapply ByAssumption. left. reflexivity.
Qed.
Lemma DisjunctionE (Gamma : ensemble (frm L)) A B C
(INFERS1 : Gamma ⊢ Dis_frm A B)
(INFERS2 : E.insert A Gamma ⊢ C)
(INFERS3 : E.insert B Gamma ⊢ C)
: Gamma ⊢ C.
Proof.
eapply for_Imp_E. exists []. split. done. econs. eapply proof_dne.
eapply NegationI. unfold Dis_frm in INFERS1. eapply ContradictionI with (A := Con_frm (Neg_frm A) (Neg_frm B)).
- eapply ConjunctionI; rewrite <- Deduction_theorem; eapply for_CP1; eapply for_Imp_I; trivial.
- eapply extend_infers with (Gamma := Gamma); done!.
Qed.
Lemma ImplicationI (Gamma : ensemble (frm L)) A B
(INFERS1 : E.insert A Gamma ⊢ B)
: Gamma ⊢ Imp_frm A B.
Proof.
eapply for_Imp_I; trivial.
Qed.
Lemma ImplicationE (Gamma : ensemble (frm L)) A B
(INFERS1 : Gamma ⊢ Imp_frm A B)
(INFERS2 : Gamma ⊢ A)
: Gamma ⊢ B.
Proof.
eapply for_Imp_E; eauto.
Qed.
Lemma BiconditionalI (Gamma : ensemble (frm L)) A B
(INFERS1 : E.insert A Gamma ⊢ B)
(INFERS2 : E.insert B Gamma ⊢ A)
: Gamma ⊢ Iff_frm A B.
Proof.
unfold Iff_frm. eapply ConjunctionI; eapply for_Imp_I; eauto.
Qed.
Lemma BiconditionalE1 (Gamma : ensemble (frm L)) A B
(INFERS1 : Gamma ⊢ Iff_frm A B)
(INFERS2 : Gamma ⊢ A)
: Gamma ⊢ B.
Proof.
unfold Iff_frm in INFERS1. eapply for_Imp_E. eapply ConjunctionE1. eapply INFERS1. eapply INFERS2.
Qed.
Lemma BiconditionalE2 (Gamma : ensemble (frm L)) A B
(INFERS1 : Gamma ⊢ Iff_frm A B)
(INFERS2 : Gamma ⊢ B)
: Gamma ⊢ A.
Proof.
unfold Iff_frm in INFERS1. eapply for_Imp_E. eapply ConjunctionE2. eapply INFERS1. eapply INFERS2.
Qed.
Lemma UniversalI (Gamma : ensemble (frm L)) x y A
(FRESH1 : forall p, p \in Gamma -> is_free_in_frm y p = false)
(FRESH2 : is_free_in_frm y (All_frm x A) = false)
(INFERS1 : Gamma ⊢ subst_frm (one_subst x (Var_trm y)) A)
: Gamma ⊢ All_frm x A.
Proof.
eapply for_All_I' with (y := y); ss!.
Qed.
Lemma UniversalE (Gamma : ensemble (frm L)) x t A
(INFERS1 : Gamma ⊢ All_frm x A)
: Gamma ⊢ subst_frm (one_subst x t) A.
Proof.
eapply for_All_E with (t := t); ss!.
Qed.
Lemma ExistentialI (Gamma : ensemble (frm L)) x t A
(INFERS1 : Gamma ⊢ subst_frm (one_subst x t) A)
: Gamma ⊢ Exs_frm x A.
Proof.
unfold Exs_frm. eapply NegationI. eapply ContradictionI with (A := subst_frm (one_subst x t) (Neg_frm A)).
- eapply for_All_E. eapply for_ByHyp. done!.
- simpl. eapply NegationI. eapply ContradictionI with (A := subst_frm (one_subst x t) A).
+ eapply extend_infers. eapply INFERS1. done!.
+ eapply for_ByHyp. done!.
Qed.
Lemma ExistentialE (Gamma : ensemble (frm L)) x y A B
(FRESH1 : forall p, p \in Gamma -> is_free_in_frm y p = false)
(FRESH2 : is_free_in_frm y (All_frm x A) = false)
(FRESH3 : is_free_in_frm y B = false)
(INFERS1 : Gamma ⊢ Exs_frm x A)
(INFERS2 : E.insert (subst_frm (one_subst x (Var_trm y)) A) Gamma ⊢ B)
: Gamma ⊢ B.
Proof.
assert (claim : Gamma ⊢ Imp_frm (Neg_frm B) (All_frm x (Neg_frm A))).
{ eapply for_Imp_I. eapply for_All_I' with (y := y).
- intros p [-> | IN]; simpl; ss!.
- ss!.
- simpl. rewrite <- Deduction_theorem. eapply for_CP1. rewrite -> Deduction_theorem. eapply INFERS2.
}
apply for_CP1 in claim. eapply for_Imp_E. exists []. split. done. econs. eapply proof_dne.
eapply for_Imp_E. eapply claim. exact INFERS1.
Qed.
Lemma EquationI (Gamma : ensemble (frm L)) t
: Gamma ⊢ Eqn_frm t t.
Proof.
eapply proves_reflexivity.
Qed.
Lemma EquationE (Gamma : ensemble (frm L)) x t1 t2 A
(INFERS1 : Gamma ⊢ Eqn_frm t1 t2)
(INFERS2 : Gamma ⊢ subst_frm (one_subst x t1) A)
: Gamma ⊢ subst_frm (one_subst x t2) A.
Proof.
eapply for_Imp_E. 2: eapply INFERS2. eapply proves_eqn_frm. eapply INFERS1.
Qed.
Lemma Law_of_Excluded_Middle (A : frm L)
: E.empty ⊢ Dis_frm A (Neg_frm A).
Proof with repeat ((now left) || right).
eapply NegationE, ContradictionI.
- eapply DisjunctionI2, NegationI, ContradictionI.
+ eapply DisjunctionI1, ByAssumption...
+ eapply ByAssumption...
- eapply ByAssumption...
Qed.
Lemma Cut_property (Gamma : ensemble (frm L)) A B
(INFERS : Gamma ⊢ A)
(IMPLY : E.insert A Gamma ⊢ B)
: Gamma ⊢ B.
Proof.
assert (claim : Gamma ⊢ Imp_frm A B).
{ eapply ImplicationI; exact IMPLY. }
eapply ImplicationE; [exact claim | exact INFERS].
Qed.
#[local] Notation formula := (frm L).
#[global]
Instance formula_isBA : isBA formula :=
{ andB := Con_frm
; orB := Dis_frm
; notB := Neg_frm
; trueB := Imp_frm Bot_frm Bot_frm
; falseB := Bot_frm
}.
#[local] Obligation Tactic := i.
#[global, program]
Instance formula_isSetoid : isSetoid formula :=
{ eqProp (lhs : formula) (rhs : formula) := E.singleton lhs ⊢ rhs /\ E.singleton rhs ⊢ lhs }.
Next Obligation with done!.
split.
- ii. split; eapply ByAssumption...
- ii; des...
- ii; des. split; eapply Cut_property; try eassumption; eapply extend_infers; try eassumption...
Qed.
#[global]
Instance LBA_satisfiesBooleanAlgebraLaws
: BooleanAlgebraLaws formula_isBA.
Proof with done!.
repeat (split; ii); simpl in *; des.
{ eapply ConjunctionI.
- eapply Cut_property with (A := x1).
+ eapply ConjunctionE1, ByAssumption...
+ eapply extend_infers...
- eapply Cut_property with (A := y1).
+ eapply ConjunctionE2, ByAssumption...
+ eapply extend_infers...
}
{ eapply ConjunctionI.
- eapply Cut_property with (A := x2).
+ eapply ConjunctionE1, ByAssumption...
+ eapply extend_infers...
- eapply Cut_property with (A := y2).
+ eapply ConjunctionE2, ByAssumption...
+ eapply extend_infers...
}
{ eapply DisjunctionE.
- eapply ByAssumption...
- eapply DisjunctionI1, extend_infers...
- eapply DisjunctionI2, extend_infers...
}
{ eapply DisjunctionE.
- eapply ByAssumption...
- eapply DisjunctionI1, extend_infers...
- eapply DisjunctionI2, extend_infers...
}
{ eapply NegationI. eapply ContradictionI with (A := x1).
- eapply extend_infers...
- eapply ByAssumption...
}
{ eapply NegationI. eapply ContradictionI with (A := x2).
- eapply extend_infers...
- eapply ByAssumption...
}
{ eapply ConjunctionI.
- eapply ConjunctionI.
+ eapply ConjunctionE1, ByAssumption...
+ eapply ConjunctionE1, ConjunctionE2, ByAssumption...
- eapply ConjunctionE2, ConjunctionE2, ByAssumption...
}
{ eapply ConjunctionI.
- eapply ConjunctionE1, ConjunctionE1, ByAssumption...
- eapply ConjunctionI.
+ eapply ConjunctionE2, ConjunctionE1, ByAssumption...
+ eapply ConjunctionE2, ByAssumption...
}
{ eapply DisjunctionE.
- eapply ByAssumption...
- eapply DisjunctionI1, DisjunctionI1, ByAssumption. left...
- eapply DisjunctionE.
+ eapply ByAssumption. left...
+ eapply DisjunctionI1, DisjunctionI2, ByAssumption. left...
+ eapply DisjunctionI2, ByAssumption. left...
}
{ eapply DisjunctionE.
- eapply ByAssumption...
- eapply DisjunctionE.
+ eapply ByAssumption. left...
+ eapply DisjunctionI1, ByAssumption. left...
+ eapply DisjunctionI2, DisjunctionI1, ByAssumption. left...
- eapply DisjunctionI2, DisjunctionI2, ByAssumption. left...
}
{ eapply ConjunctionI.
- eapply ConjunctionE2, ByAssumption...
- eapply ConjunctionE1, ByAssumption...
}
{ eapply ConjunctionI.
- eapply ConjunctionE2, ByAssumption...
- eapply ConjunctionE1, ByAssumption...
}
{ eapply DisjunctionE.
- eapply ByAssumption...
- eapply DisjunctionI2, ByAssumption. left...
- eapply DisjunctionI1, ByAssumption. left...
}
{ eapply DisjunctionE.
- eapply ByAssumption...
- eapply DisjunctionI2, ByAssumption. left...
- eapply DisjunctionI1, ByAssumption. left...
}
{ eapply DisjunctionE.
- eapply ConjunctionE2, ByAssumption...
- eapply DisjunctionI1, ConjunctionI.
+ eapply ConjunctionE1, ByAssumption. right...
+ eapply ByAssumption. left...
- eapply DisjunctionI2, ConjunctionI.
+ eapply ConjunctionE1, ByAssumption. right...
+ eapply ByAssumption. left...
}
{ eapply DisjunctionE.
- eapply ByAssumption...
- eapply ConjunctionI.
+ eapply ConjunctionE1, ByAssumption. left...
+ eapply DisjunctionI1, ConjunctionE2, ByAssumption. left...
- eapply ConjunctionI.
+ eapply ConjunctionE1, ByAssumption. left...
+ eapply DisjunctionI2, ConjunctionE2, ByAssumption. left...
}
{ eapply DisjunctionE.
- eapply ConjunctionE1, ByAssumption...
- eapply DisjunctionI1, ConjunctionI.
+ eapply ByAssumption. left...
+ eapply ConjunctionE2, ByAssumption. right...
- eapply DisjunctionI2, ConjunctionI.
+ eapply ByAssumption. left...
+ eapply ConjunctionE2, ByAssumption. right...
}
{ eapply DisjunctionE.
- eapply ByAssumption...
- eapply ConjunctionI.
+ eapply DisjunctionI1, ConjunctionE1, ByAssumption. left...
+ eapply ConjunctionE2, ByAssumption. left...
- eapply ConjunctionI.
+ eapply DisjunctionI2, ConjunctionE1, ByAssumption. left...
+ eapply ConjunctionE2, ByAssumption. left...
}
{ eapply DisjunctionE.
- eapply ByAssumption...
- eapply ConjunctionI.
+ eapply DisjunctionE.
* eapply ByAssumption. right...
* eapply DisjunctionI1, ByAssumption. left...
* eapply DisjunctionI2, ConjunctionE1, ByAssumption. left...
+ eapply DisjunctionE.
* eapply ByAssumption. right...
* eapply DisjunctionI1, ByAssumption. left...
* eapply DisjunctionI2, ConjunctionE2, ByAssumption. left...
- eapply ConjunctionI.
+ eapply DisjunctionE.
* eapply ByAssumption. right...
* eapply DisjunctionI1, ByAssumption. left...
* eapply DisjunctionI2, ConjunctionE1, ByAssumption. left...
+ eapply DisjunctionE.
* eapply ByAssumption. right...
* eapply DisjunctionI1, ByAssumption. left...
* eapply DisjunctionI2, ConjunctionE2, ByAssumption. left...
}
{ eapply DisjunctionE.
- eapply ConjunctionE1, ByAssumption...
- eapply DisjunctionI1, ByAssumption. left...
- eapply DisjunctionE.
+ eapply ConjunctionE2, ByAssumption. right...
+ eapply DisjunctionI1, ByAssumption. left...
+ eapply DisjunctionI2, ConjunctionI.
* eapply ByAssumption. right; left...
* eapply ByAssumption. left...
}
{ eapply DisjunctionE.
- eapply ByAssumption...
- eapply ConjunctionI.
+ eapply DisjunctionI1, ConjunctionE1, ByAssumption. left...
+ eapply DisjunctionI1, ConjunctionE2, ByAssumption. left...
- eapply ConjunctionI.
+ eapply DisjunctionI2, ByAssumption. left...
+ eapply DisjunctionI2, ByAssumption. left...
}
{ eapply DisjunctionE.
- eapply ConjunctionE1, ByAssumption...
- eapply DisjunctionE.
+ eapply ConjunctionE2, ByAssumption. right...
+ eapply DisjunctionI1, ConjunctionI.
* eapply ByAssumption. right; left...
* eapply ByAssumption. left...
+ eapply DisjunctionI2, ByAssumption. left...
- eapply DisjunctionI2, ByAssumption. left...
}
{ eapply ConjunctionE2, ByAssumption... }
{ eapply ConjunctionI.
- eapply ImplicationI, ByAssumption. left...
- eapply ByAssumption...
}
{ eapply ConjunctionE1, ByAssumption... }
{ eapply ConjunctionI.
- eapply ByAssumption...
- eapply ImplicationI, ByAssumption. left...
}
{ eapply DisjunctionE.
- eapply ByAssumption...
- eapply ContradictionE, ByAssumption. left...
- eapply ByAssumption. left...
}
{ eapply DisjunctionI2, ByAssumption... }
{ eapply DisjunctionE.
- eapply ByAssumption...
- eapply ByAssumption. left...
- eapply ContradictionE, ByAssumption. left...
}
{ eapply DisjunctionI1, ByAssumption... }
{ eapply ConjunctionE1, ByAssumption... }
{ eapply ConjunctionI.
- eapply ByAssumption...
- eapply ContradictionE, ByAssumption...
}
{ eapply ConjunctionE2, ByAssumption... }
{ eapply ConjunctionI.
- eapply ContradictionE, ByAssumption...
- eapply ByAssumption...
}
{ eapply ImplicationI, ByAssumption. left... }
{ eapply DisjunctionI1, ImplicationI, ByAssumption. left... }
{ eapply ImplicationI, ByAssumption. left... }
{ eapply DisjunctionI2, ImplicationI, ByAssumption. left... }
{ eapply ConjunctionE1, ByAssumption... }
{ eapply ConjunctionI; eapply ByAssumption... }
{ eapply DisjunctionE.
- eapply ByAssumption...
- eapply ByAssumption. left...
- eapply ByAssumption. left...
}
{ eapply DisjunctionI1, ByAssumption... }
{ eapply ConjunctionE1, ByAssumption... }
{ eapply ConjunctionI.
- eapply ByAssumption...
- eapply DisjunctionI1, ByAssumption...
}
{ eapply DisjunctionE.
- eapply ByAssumption...
- eapply ByAssumption. left...
- eapply ConjunctionE1, ByAssumption. left...
}
{ eapply DisjunctionI1, ByAssumption... }
{ eapply ContradictionI with (A := x).
- eapply ConjunctionE1, ByAssumption...
- eapply ConjunctionE2, ByAssumption...
}
{ eapply ContradictionE, ByAssumption... }
{ eapply ImplicationI, ByAssumption. left... }
{ eapply extend_infers.
- eapply Law_of_Excluded_Middle.
- intros ? [].
}
Qed.
Lemma leB_iff (lhs : formula) (rhs : formula)
: lhs =< rhs <-> E.singleton lhs ⊢ rhs.
Proof with reflexivity || trivial.
simpl. split.
- intros [INFERS INFERS'].
eapply Cut_property with (A := Con_frm lhs rhs)...
eapply ConjunctionE2, ByAssumption. left...
- intros INFERS. split.
+ eapply ConjunctionE1, ByAssumption...
+ eapply ConjunctionI...
eapply ByAssumption...
Qed.
Lemma andsB_le_iff (xs : list formula) (b : formula)
: andsB xs =< b <-> (exists X, L.is_listrep_of xs X /\ X ⊢ b).
Proof.
split.
- intros LE. exists (E.fromList xs). split. done. revert b LE. induction xs as [ | x xs IH]; simpl; i.
+ destruct LE as [INFERS1 INFERS2]. eapply Cut_property with (A := Imp_frm Bot_frm Bot_frm).
* eapply ImplicationI. eapply for_ByHyp. done!.
* eapply extend_infers with (Gamma := E.singleton (Imp_frm Bot_frm Bot_frm)).
{ eapply ConjunctionE2. eapply INFERS2. }
{ done!. }
+ destruct LE as [INFERS1 INFERS2]. unfold leProp in IH. simpl in IH. eapply extend_proves with (Gamma := E.insert x (E.fromList xs)). done!.
rewrite <- Deduction_theorem. eapply IH. split.
* eapply ConjunctionE1. eapply ByAssumption. econs.
* eapply ConjunctionI.
{ eapply ByAssumption. done!. }
{ eapply ImplicationI. eapply ConjunctionE2 with (A := Con_frm x (andsB xs)). eapply for_Imp_E with (p := Con_frm x (andsB xs)).
- eapply for_Imp_I. eapply extend_infers. exact INFERS2. done!.
- eapply ConjunctionI; eapply for_ByHyp; done!.
}
- intros (X&EQ&PROVE). destruct PROVE as (ps&INCL&(PF)).
assert (SUBSET : forall q, L.In q ps -> L.In q xs) by ss!.
assert (LE : andsB ps =< b).
{ simpl. split.
- eapply ConjunctionE1; eapply for_ByHyp; done!.
- eapply ConjunctionI.
+ eapply for_ByHyp; done!.
+ assert (PROVE : E.fromList ps ⊢ b).
{ exists ps. split. done!. econs. exact PF. }
revert PROVE. clear. revert b. induction ps as [ | p ps IH]; simpl; i.
* eapply extend_infers. eapply PROVE. intros ? [].
* exploit (IH (Imp_frm p b)).
{ eapply for_Imp_I. eapply extend_infers. exact PROVE. done!. }
intros claim. rewrite Deduction_theorem in claim.
eapply for_Imp_E with (p := p); cycle 1. eapply ConjunctionE1; eapply for_ByHyp; done!.
eapply for_Imp_E with (p := andsB ps); cycle 1. eapply ConjunctionE2; eapply for_ByHyp; done!.
eapply for_Imp_E with (p := Con_frm p (andsB ps)); cycle 1. eapply for_ByHyp; done!.
eapply for_Imp_I. eapply for_Imp_I. eapply for_Imp_I. eapply extend_infers. eapply claim. done!.
}
clear X INCL EQ PF. revert b LE.
enough (WTS : andsB xs =< andsB ps).
{ ii. etransitivity; eauto. }
rewrite leB_iff. revert xs SUBSET. induction ps as [ | p ps IH]; simpl; i.
+ eapply for_Imp_I. eapply for_ByHyp. done!.
+ exploit (IH xs). done!. intros claim. eapply ConjunctionI; trivial.
exploit (SUBSET p). done!. clear. revert p. induction xs as [ | x xs IH]; simpl; intros p IN.
* tauto.
* destruct IN as [<- | IN].
{ eapply ConjunctionE1. eapply for_ByHyp; done!. }
{ eapply for_Imp_E; cycle 1. eapply ConjunctionE1. eapply for_ByHyp; econs.
eapply for_Imp_E; cycle 1. eapply ConjunctionE2. eapply for_ByHyp; econs.
eapply for_Imp_I. eapply for_Imp_I. eapply extend_infers. exact (IH p IN). done!.
}
Qed.
#[global]
Add Parametric Morphism :
(@proves L) with signature (eqProp ==> eqProp ==> iff)
as proves_compatWith_eqProp.
Proof.
intros X X' X_eq_X' b b' [INFERS1 INFERS2]. split.
- intros INFERS. eapply Cut_property with (A := b).
+ eapply extend_infers; done!.
+ eapply extend_infers; done!.
- intros INFERS. eapply Cut_property with (A := b').
+ eapply extend_infers; done!.
+ eapply extend_infers; done!.
Qed.
Variant Th (X : ensemble formula) (b : formula) : Prop :=
| In_Th
(INFERS : X ⊢ b)
: b \in Th X.
#[local] Hint Constructors Th : core.
Lemma in_Th_iff (X : ensemble formula) (b : formula)
: b \in Th X <-> X ⊢ b.
Proof.
split; eauto. intros [?]; trivial.
Qed.
#[global]
Add Parametric Morphism :
Th with signature (eqProp ==> eqProp)
as Th_lifts_eqProp.
Proof.
intros X X' X_eq_X' b. split; intros [INFERS]; econstructor.
- now rewrite <- X_eq_X'.
- now rewrite -> X_eq_X'.
Qed.
Lemma lemma1_of_1_3_8 (X : ensemble formula)
: isFilter (Th X).
Proof with reflexivity || eauto.
eapply isFilter_intro.
- exists trueB. econstructor.
eapply ImplicationI, ByAssumption; done!.
- intros x1 x2 [INFERS1] [INFERS2].
econstructor. eapply ConjunctionI; done!.
- intros x [INFERS] x' x_le_x'. apply leB_iff in x_le_x'.
econstructor. eapply Cut_property. exact INFERS.
eapply extend_infers with (Gamma := E.singleton x); done!.
Qed.
Lemma cl_isSubsetOf_Th (X : ensemble formula)
: cl X \subseteq Th X.
Proof with eauto.
intros b [xs ?]; des. apply andsB_le_iff in andsB_LE.
destruct andsB_LE as [X' [xs_repr_X' INFERS]].
econstructor. eapply extend_infers...
intros z z_in. eapply FINITE_SUBSET, xs_repr_X'...
Qed.
Lemma inconsistent_iff (Gamma : ensemble (frm L))
: inconsistent Gamma <-> Gamma ⊢ Bot_frm.
Proof.
split.
- intros INCONSISTENT. eapply INCONSISTENT.
- intros INCONSISTENT q. eapply ContradictionE. eapply INCONSISTENT.
Qed.
Corollary Th_isSubsetOf_cl (X : ensemble formula)
: Th X \subseteq cl X.
Proof.
intros b [PROVE]. destruct PROVE as (ps&INCL&(PF)). exists ps. split; unnw.
- done.
- rewrite andsB_le_iff. exists (E.intersection (E.fromList ps) X). split.
+ done!.
+ eapply extend_proves with (Gamma := E.fromList ps). done!. exists ps. split. done. econs. exact PF.
Qed.
Corollary cl_eq_Th (X : ensemble formula)
: cl X == Th X.
Proof.
s!. split.
- eapply cl_isSubsetOf_Th.
- eapply Th_isSubsetOf_cl.
Qed.
Lemma inconsistent_cl_iff (X : ensemble (frm L))
: Bot_frm \in cl X <-> X ⊢ Bot_frm.
Proof.
split.
- intros IN. rewrite cl_eq_Th in IN. destruct IN as [INFERS]. exact INFERS.
- intros INFERS. rewrite cl_eq_Th. econs. exact INFERS.
Qed.
Lemma filter_inconsistent_iff (F : ensemble formula)
(F_isFilter : isFilter F)
: inconsistent F <-> Bot_frm \in F.
Proof with eauto with *.
split.
- intros INCONSISTENT. pose proof (fact5_of_1_2_8 F F_isFilter) as SUBSET.
eapply SUBSET. rewrite inconsistent_cl_iff. now rewrite <- inconsistent_iff.
- intros IN. pose proof (fact3_of_1_2_8 F) as SUBSET.
rewrite inconsistent_iff. rewrite <- inconsistent_cl_iff. now eapply SUBSET.
Qed.
Lemma inconsistent_okay (Gamma : ensemble (frm L))
: inconsistent Gamma <-> inconsistent' (cl Gamma).
Proof.
unfold inconsistent'. rewrite inconsistent_iff. split.
- intros INFERS. exists Bot_frm. split; try reflexivity.
rewrite cl_eq_Th. econs; trivial.
- intros [botB [IN EQ]].
enough (WTS : Bot_frm \in Th Gamma).
{ destruct WTS; trivial. }
simpl in *. rewrite cl_eq_Th in IN. destruct EQ as [INFERS _].
econs. eapply cut_one with (A := botB); trivial. destruct IN as [PROVE]; trivial.
Qed.
Section UNION.
Variable f : nat -> ensemble (frm L).
Definition union_f : ensemble (frm L) :=
fun p => exists n, p \in f n.
Hypothesis incl : forall n1 : nat, forall n2 : nat, forall LE : n1 <= n2, f n1 \subseteq f n2.
Lemma subset_union_f n
: f n \subseteq union_f.
Proof.
intros q q_in. exists n. exact q_in.
Qed.
Lemma union_f_proves_iff p
: union_f ⊢ p <-> (exists n, f n ⊢ p).
Proof.
split.
- intros (ps&INCL&(PF)).
enough (WTS : exists n, E.fromList ps \subseteq f n).
{ destruct WTS as [n SUBSET]. exists n. exists ps. split; trivial. econs; exact PF. }
clear PF p. induction ps as [ | p ps IH]; simpl.
+ exists 0. done.
+ exploit IH. ii. eapply INCL. done!. intros [n SUBSET]. exploit (INCL p). done!. intros [m IN].
exists (max n m). intros q q_in. s!. destruct q_in as [-> | q_in].
* eapply incl with (n1 := m); done!.
* eapply incl with (n1 := n); done!.
- intros [n PROVE]. eapply extend_proves with (Gamma := f n). eapply subset_union_f. exact PROVE.
Qed.
Hypothesis equiconsistent : forall n : nat, inconsistent (f n) <-> inconsistent (f (S n)).
Lemma equiconsistent_union_f
: inconsistent (f 0) <-> inconsistent union_f.
Proof.
split.
- intros INCONSISTENT p. eapply extend_proves with (Gamma := f 0). eapply subset_union_f. eapply INCONSISTENT.
- do 2 rewrite inconsistent_iff. intros INCONSISTENT. rewrite union_f_proves_iff in INCONSISTENT. destruct INCONSISTENT as [n PROVE]. induction n as [ | n IH].
+ eapply PROVE.
+ eapply IH. rewrite <- inconsistent_iff. rewrite equiconsistent. rewrite inconsistent_iff. eapply PROVE.
Qed.
End UNION.
#[local] Hint Resolve fact1_of_1_2_8 fact2_of_1_2_8 fact3_of_1_2_8 fact4_of_1_2_8 fact5_of_1_2_8 lemma1_of_1_2_11 : core.
Context {enum_frm_L : isEnumerable formula}.
#[global]
Instance LindenbaumBooleanAlgebra : isCBA formula (SETOID := formula_isSetoid) :=
{ CBA_isBA := formula_isBA
; CBA_satisfiesBooleanAlgebraLaws := LBA_satisfiesBooleanAlgebraLaws
; CBA_countable := enum_frm_L
}.
Fixpoint axiom_set (X : ensemble formula) (n : nat) {struct n} : ensemble formula :=
match n with
| O => X
| S n => E.union (axiom_set X n) (insertion (improveFilter (Th X) n) n)
end.
Lemma lemma1_of_1_3_9 (X : ensemble formula) (n : nat)
: improveFilter (Th X) n == Th (axiom_set X n).
Proof with eauto with *.
revert X; induction n as [ | n IH]; [reflexivity | intros X b].
simpl. unfold Insertion. rewrite cl_eq_Th, IH. split; intros b_in.
- rewrite <- cl_eq_Th. rewrite <- cl_eq_Th in b_in. revert b b_in.
change ((cl (E.union (Th (axiom_set X n)) (insertion (Th (axiom_set X n)) n))) \subseteq (cl (E.union (axiom_set X n) (insertion (Th (axiom_set X n)) n)))).
transitivity (cl (cl (E.union (axiom_set X n) (insertion (Th (axiom_set X n)) n)))).
+ eapply fact4_of_1_2_8. intros b [b_in | b_in].
* rewrite <- cl_eq_Th in b_in. revert b b_in. eapply fact4_of_1_2_8. ii; left...
* rewrite cl_eq_Th. econstructor. eapply ByAssumption. right...
+ eapply fact5_of_1_2_8...
- rewrite <- cl_eq_Th. rewrite <- cl_eq_Th in b_in. revert b b_in.
eapply fact4_of_1_2_8. intros b [b_in | b_in].
+ left. econstructor. eapply ByAssumption...
+ right...
Qed.
Lemma axiom_set_equiconsistent (X : ensemble (frm L)) (n : nat)
: inconsistent (axiom_set X n) <-> inconsistent (axiom_set X (S n)).
Proof with eauto with *.
split.
- do 2 rewrite inconsistent_iff. intros INCONSISTENT. eapply extend_infers... done!.
- do 2 rewrite inconsistent_iff. do 2 rewrite <- in_Th_iff. intros INCONSISTENT.
rewrite <- lemma1_of_1_3_9 in *. pose proof (lemma2_of_1_2_13 (Th X)) as claim. eapply fact5_of_1_2_8.
+ eapply @lemma1_of_1_2_11 with (CBA := LindenbaumBooleanAlgebra). eapply lemma1_of_1_3_8.
+ rewrite cl_eq_Th. rewrite in_Th_iff. rewrite <- inconsistent_iff. rewrite inconsistent_okay. rewrite cl_eq_Th.
enough (WTS : inconsistent' (improveFilter (Th X) n)).
{ eapply inconsistent_compatWith_isSubsetOf... ii. rewrite in_Th_iff. eapply ByAssumption... }
eapply claim with (n2 := S n).
* eapply lemma1_of_1_3_8.
* enough (INFERS : improveFilter (Th X) (S n) ⊢ Bot_frm).
{ rewrite <- inconsistent_iff in INFERS. rewrite inconsistent_okay in INFERS.
eapply inconsistent_compatWith_isSubsetOf with (X := cl (improveFilter (Th X) (S n)))...
eapply fact5_of_1_2_8... eapply @lemma1_of_1_2_11 with (CBA := LindenbaumBooleanAlgebra). eapply lemma1_of_1_3_8.
}
simpl in INCONSISTENT. rewrite cl_eq_Th in INCONSISTENT. rewrite in_Th_iff in INCONSISTENT. simpl.
eapply extend_infers...
Qed.
Definition MaximallyConsistentSet (X : ensemble formula) : ensemble formula :=
completeFilterOf (Th X).
Definition full_axiom_set (X : ensemble formula) : ensemble formula :=
union_f (axiom_set X).
Lemma lemma2_of_1_3_9 (X : ensemble formula)
: MaximallyConsistentSet X \subseteq Th (full_axiom_set X).
Proof.
intros z [n z_in].
pose proof (proj1 (lemma1_of_1_3_9 X n z) z_in) as [INFERS].
econstructor. eapply extend_infers; eauto. ii. now exists n.
Qed.
Lemma lemma3_of_1_3_9_aux1 (xs : list formula) (X : ensemble formula)
(FINITE_SUBSET : L.is_finsubset_of xs (full_axiom_set X))
: exists m, L.is_finsubset_of xs (improveFilter (Th X) m).
Proof with eauto with *.
revert X FINITE_SUBSET. induction xs as [ | x xs IH]; simpl; ii.
- exists 0. tauto.
- assert (claim1 : forall z : formula, In z xs -> z \in full_axiom_set X) by now firstorder.
assert (claim2 : x \in full_axiom_set X) by now firstorder.
destruct claim2 as [n IN].
assert (claim3 : x \in improveFilter (Th X) n).
{ eapply lemma1_of_1_3_9. econstructor. eapply ByAssumption... }
pose proof (IH X claim1) as [m claim4].
assert (m <= n \/ n <= m) as [m_le_n | n_lt_m] by lia.
+ exists n. intros z [x_eq_z | z_in_xs].
{ subst z... }
{ eapply lemma1_of_1_2_12... }
+ exists m. intros z [x_eq_z | z_in_xs].
{ subst z. eapply lemma1_of_1_2_12... }
{ eapply claim4... }
Qed.
Lemma lemma3_of_1_3_9 (X : ensemble formula)
: Th (full_axiom_set X) \subseteq MaximallyConsistentSet X.
Proof with eauto with *.
intros z [INFERS]. destruct INFERS as (ps&INCL&(PF)).
pose proof (lemma3_of_1_3_9_aux1 ps X INCL) as [m claim1].
assert (claim2 : isFilter (improveFilter (Th X) m)).
{ eapply @lemma1_of_1_2_11 with (CBA := LindenbaumBooleanAlgebra). eapply lemma1_of_1_3_8. }
inversion claim2. exists m.
eapply CLOSED_UPWARD with (x := andsB ps).
- eapply fact5_of_1_2_8... exists ps...
- eapply andsB_le_iff. exists (E.intersection (E.fromList ps) (improveFilter (Th X) m)). split; done!.
Qed.
Variant MaximallyConsistentSet_spec (X : ensemble formula) (F : ensemble formula) : Prop :=
| MaximallyConsistentSetSpec_areTheFollowings
(SUBSET : Th X \subseteq F)
(EQUICONSISTENT : equiconsistent (Th X) F)
(CLOSED_infers : forall A : formula, A \in F <-> F ⊢ A)
(META_DN : forall A : formula, << NEGATION : Neg_frm A \in F -> Bot_frm \in F >> -> A \in F)
(IMPLICATION_FAITHFUL : forall A : formula, forall B : formula, Imp_frm A B \in F <-> << IMPLICATION : A \in F -> B \in F >>)
(FORALL_FAITHFUL : forall x : ivar, forall A : formula, All_frm x A \in F <-> << IMPLICATION : forall t : trm L, subst_frm (one_subst x t) A \in F >>)
: MaximallyConsistentSet_spec X F.
End EXTRA1.
Section HENKIN.
#[local] Infix "=~=" := is_similar_to : type_scope.
Context {L : language}.
#[local] Notation L' := (augmented_language L Henkin_constants).
#[local] Notation hatom := (ivar + Henkin_constants)%type.
#[local] Notation hsubst := (hatom -> trm L').
#[local] Existing Instance constant_symbols_sim.
#[local] Existing Instance trm_sim.
#[local] Existing Instance trms_sim.
#[local] Existing Instance frm_sim.
#[local] Existing Instance frms_sim.
Lemma Fun_eqAxm_HC_free (f : L'.(function_symbols))
: forall c : Henkin_constants, HC_occurs_in_frm c (Fun_eqAxm f) = false.
Proof.
enough (HACK : forall phi : trms L' _ -> trms L' _ -> frm L', forall c,
forall phi_a_b : forall a, forall b, forall claim : HC_occurs_in_trms c a = false /\ HC_occurs_in_trms c b = false, HC_occurs_in_frm c (phi a b) = false,
HC_occurs_in_frm c ((nat_rec (fun _ => frm L') (prod_rec (fun _ => frm L') phi (varcouples (function_arity_table L' f))) (fun n => fun q => Imp_frm (Eqn_frm (Var_trm (n + n)) (Var_trm (S (n + n)))) q) (function_arity_table L' f))) = false
).
{ ii. unfold Fun_eqAxm. eapply HACK. ii. now s!. }
induction (function_arity_table L' f) as [ | n IH]; simpl; ii.
- rewrite phi_a_b; trivial. split; trivial.
- s!. split. split; trivial. exploit (IH (fun ts : trms L' n => fun ts' : trms L' n => phi (S_trms n (Var_trm (n + n)) ts) (S_trms n (Var_trm (S (n + n))) ts'))).
+ ii. rewrite phi_a_b; trivial.
+ intros claim. simpl. destruct (varcouples n) as [lhs rhs] eqn: H_OBS; simpl in *. eapply claim.
Qed.
Lemma Rel_eqAxm_HC_free (R : L'.(relation_symbols))
: forall c : Henkin_constants, HC_occurs_in_frm c (Rel_eqAxm R) = false.
Proof.
enough (HACK : forall phi : trms L' _ -> trms L' _ -> frm L', forall c,
forall phi_a_b : forall a, forall b, forall claim : HC_occurs_in_trms c a = false /\ HC_occurs_in_trms c b = false, HC_occurs_in_frm c (phi a b) = false,
HC_occurs_in_frm c ((nat_rec (fun _ => frm L') (prod_rec (fun _ => frm L') phi (varcouples (relation_arity_table L' R))) (fun n => fun q => Imp_frm (Eqn_frm (Var_trm (n + n)) (Var_trm (S (n + n)))) q) (relation_arity_table L' R))) = false
).
{ ii. unfold Rel_eqAxm. eapply HACK. ii. now s!. }
induction (relation_arity_table L' R) as [ | n IH]; simpl; ii.
- rewrite phi_a_b; trivial. split; trivial.
- s!. split. split; trivial. exploit (IH (fun ts : trms L' n => fun ts' : trms L' n => phi (S_trms n (Var_trm (n + n)) ts) (S_trms n (Var_trm (S (n + n))) ts'))).
+ ii. rewrite phi_a_b; trivial.
+ intros claim. simpl. destruct (varcouples n) as [lhs rhs] eqn: H_OBS; simpl in *. eapply claim.
Qed.
Lemma twilight_Fun_eqAxm (f : L'.(function_symbols))
: E.empty ⊢ twilight_frm (Fun_eqAxm f).
Proof.
rewrite untwilight_frm. 2: exact (Fun_eqAxm_HC_free f). set (n := L'.(function_arity_table) f + L'.(function_arity_table) f). set (s := fun z : ivar => Var_trm (z * 2)).
replace (subst_frm s (Fun_eqAxm f)) with (subst_frm (fun x : ivar => if le_lt_dec n x then Var_trm x else s x) (Fun_eqAxm f)).
- eapply for_Imp_E with (p := close_from 0 n (Fun_eqAxm f)). eapply subst_frm_close_frm with (n := n) (s := s) (p := Fun_eqAxm f).
clearbody n. clear s. induction n as [ | n IH]; simpl.
+ exists []. split. done. econs. exact (EQN_FUN f).
+ eapply for_All_I. done. exact IH.
- eapply equiv_subst_in_frm_implies_subst_frm_same.
ii. destruct (le_lt_dec n z) as [LE | LT]; trivial. rewrite Fun_eqAxm_free_vars in FREE. lia.
Qed.
Lemma twilight_Rel_eqAxm (R : L'.(relation_symbols))
: E.empty ⊢ twilight_frm (Rel_eqAxm R).
Proof.
rewrite untwilight_frm. 2: exact (Rel_eqAxm_HC_free R). set (n := L'.(relation_arity_table) R + L'.(relation_arity_table) R). set (s := fun z : ivar => Var_trm (z * 2)).
replace (subst_frm s (Rel_eqAxm R)) with (subst_frm (fun x : ivar => if le_lt_dec n x then Var_trm x else s x) (Rel_eqAxm R)).
- eapply for_Imp_E with (p := close_from 0 n (Rel_eqAxm R)). eapply subst_frm_close_frm with (n := n) (s := s) (p := Rel_eqAxm R).
clearbody n. clear s. induction n as [ | n IH]; simpl.
+ exists []. split. done. econs. exact (EQN_REL R).
+ eapply for_All_I. done. exact IH.
- eapply equiv_subst_in_frm_implies_subst_frm_same.
ii. destruct (le_lt_dec n z) as [LE | LT]; trivial. rewrite Rel_eqAxm_free_vars in FREE. lia.
Qed.
#[local] Opaque Nat.mul Nat.div "mod".
Lemma proves_twilight (Gamma : ensemble (frm L')) (p : frm L')
(PROVE : Gamma ⊢ p)
: E.image twilight_frm Gamma ⊢ twilight_frm p.
Proof.
assert (empty_proof_intro : forall q : frm L', proof [] q -> E.empty ⊢ q).
{ ii. exists []. split. intros ?. done. econstructor. eassumption. }
destruct PROVE as (ps&INCL&(PF)).
assert (PROVE : E.fromList ps ⊢ p).
{ exists ps. split. done. econstructor. exact PF. }
clear PF. revert Gamma p INCL PROVE. induction ps as [ | q ps IH]; i.
- clear INCL. destruct PROVE as (ps&INCL&(PF)).
assert (ps_spec : forall q : frm L', ~ L.In q ps).
{ intros q q_in. done!. }
clear INCL. eapply extend_proves with (Gamma := E.empty). done.
clear Gamma. induction PF; i.
+ contradiction (ps_spec p (or_introl eq_refl)).
+ eapply for_Imp_E; [eapply IHPF1 | eapply IHPF2]; intros q'; specialize ps_spec with (q := q'); ss!.
+ simpl. eapply for_All_I. done. eapply IHPF. done.
+ simpl. eapply empty_proof_intro. eapply IMP1.
+ simpl. eapply empty_proof_intro. eapply IMP2.
+ simpl. eapply empty_proof_intro. eapply CP.
+ simpl. erewrite subst_hsubst_compat_in_frm. 2: ii; reflexivity.
replace (hsubst_frm (to_hsubst (one_subst x t)) p) with (hsubst_frm (one_hsubst (inl x) t) p).
* enough (WTS : (twilight_frm (hsubst_frm (one_hsubst (inl x) t) p)) ≡ (subst_frm (one_subst (2 * x) (twilight_trm t)) (twilight_frm p))).
{ rewrite WTS. eapply empty_proof_intro. eapply FA1. }
eapply twilight_frm_one_hsubst.
* eapply equiv_hsubst_in_frm_implies_hsubst_frm_same. ii. unfold one_hsubst, cons_hsubst, nil_hsubst. unfold to_hsubst. unfold one_subst, cons_subst, nil_subst.
destruct z as [z | z].
{ destruct (eqb _ _) as [ | ] eqn: H_OBS1; destruct (eq_dec _ _) as [EQ2 | NE2]; trivial.
- rewrite eqb_eq in H_OBS1. hinv H_OBS1.
- rewrite eqb_neq in H_OBS1. done!.
}
{ destruct (eqb _ _) as [ | ] eqn: H_OBS; trivial. rewrite eqb_eq in H_OBS. hinv H_OBS. }
+ simpl. eapply empty_proof_intro. eapply FA2.
red. rewrite Nat.mul_comm. rewrite <- twilight_frm_fvs. exact NOT_FREE.
+ simpl. eapply empty_proof_intro. eapply FA3.
+ eapply proves_reflexivity.
+ eapply for_Imp_I. eapply proves_symmetry. eapply for_ByHyp. done!.
+ eapply for_Imp_I. eapply for_Imp_I. eapply proves_transitivity with (t2 := twilight_trm (Var_trm 1)); eapply for_ByHyp; done!.
+ eapply twilight_Fun_eqAxm.