-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDataMigrationFunctorExamples.v
More file actions
1589 lines (1427 loc) · 69.8 KB
/
DataMigrationFunctorExamples.v
File metadata and controls
1589 lines (1427 loc) · 69.8 KB
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 JMeq.
Require Export String.
Require Export DataMigrationFunctors PathsCategory PathsCategoryFunctors.
Require Import Notations Common Limits SetLimits SetColimits FEqualDep FunctorCategory DefinitionSimplification SetLimits SetColimits SpecializedCommaCategory CommaCategoryFunctors.
Set Implicit Arguments.
Generalizable All Variables.
Set Asymmetric Patterns.
Set Universe Polymorphism.
Local Open Scope type_scope.
Section helpers.
Definition eq_dec (T : Type) := forall a b : T, {a = b} + {a <> b}.
Theorem JMeq_type_mismatch_absurd A (a : A) B (b : B) : A <> B -> @JMeq A a B b -> False.
intros H0 H1;
destruct H1;
intuition.
Qed.
Lemma type_neq_helper (A B : Type) (a : A) : (forall b : B, JMeq a b -> False) -> A <> B.
intros H0 H1.
subst.
specialize (H0 a); intuition.
Qed.
(*
Section path_eq_dec.
Variable V : Type.
Variable E : V -> V -> Type.
Hypothesis Veq_dec : eq_dec V.
Hypothesis Eeq_dec : forall s d, eq_dec (E s d).
Inductive paths_eq (s : V) : forall d (p : path E s d) d' (p' : path E s d'), Prop :=
| noedges_eq : paths_eq NoEdges NoEdges
| addedge_eq : forall s' (p p' : path E s s') d (e : E s' d), paths_eq p p' -> paths_eq (AddEdge p e) (AddEdge p' e).
Definition paths_eq_dec' s d (p : path E s d) d' (p' : path E s d') : {paths_eq p p'} + {paths_eq p p' -> False}.
destruct (Veq_dec d d'); subst.
- induction p.
+ induction p'.
* solve [ left; constructor ].
* right. intro H. destruct H.
solve [ (left; congruence) || (right; apply eq_JMeq; discriminate) ].
Focus 2.
Definition mk_paths_eq s d (p p' : path E s d) : p = p' -> paths_eq p p'.
intro H.
subst.
Definition path_JMeq_dec : forall s d (p : path E s d) d' (p' : path E s d'),
{JMeq p p'} + {not (JMeq p p')}.
intros s d.
induction p.
- induction p'.
+ solve [ (left; apply eq_JMeq; congruence) || (right; apply eq_JMeq; discriminate) ].
+ right. intro.
admit.
- induction p'.
+ admit.
+ destruct
destruct H.
solve [ (left; apply eq_JMeq; congruence) || (right; apply eq_JMeq; discriminate) ].
left
eq_dec (path E s d).
unfold eq_dec.
intro s.
induction a.
Definition path_eq_dec V E (Veq : eq_dec V) (Eeq : forall s d : V, eq_dec (E s d)) (s d : V) : eq_dec (path E s d).
destruc
hnf; induction a.
Focus 2.
induction b.
solve [ (left; congruence) || (right; discriminate) ].
pose Eeq.
hnf in e.
Lemma noedges_not_JMeq_other_dest V (E : V -> V -> Type) (x s : V) :
x <> s -> forall d (p : path E s d), JMeq (@NoEdges V E x) p -> False.
intros H0 d p H1.
hnf in *.
Inductive unit' : Set := tt'.
Goal unit <> unit'.
intro.
assert (JMeq tt tt').
generalize tt tt'; rewrite H; repeat (let x := fresh in intro x; destruct x); reflexivity.
apply (@JMeq_type_mismatch_absurd _ _ _ _ _ .
subst H.
rewrite H.
generalize tt.
rewrite H.
subst.
Goal unit <> Empty_set.
intro.
assert Empty_set.
rewrite <- H.
constructor.
destruct H0.
Qed.
Lemma first_neq_implies_path_types_JMeq_absurd V E (s d s' d' : V) p0 p1 :
s <> s' -> @JMeq (path E s d) p0 (path E s' d') p1 -> False.
intros H0 H1; eapply (JMeq_type_mismatch_absurd _ H1).
Grab Existential Variables.
intro; hnf in *.
inversion H.
apply H0.
apply f_equal in H.
congruence.
discriminate.
*)
End helpers.
Local Ltac make_inductive_eq_dec :=
match goal with
| [ |- eq_dec ?T ] =>
intros ? ?; destruct_head T;
solve [ (left; congruence) || (right; discriminate) ]
end.
Ltac make_an_edge E s d hyp :=
let Etype' := constr:(E s d) in
let Etype := (eval simpl in Etype') in
assert (hyp : E s d) by constructor || fail "There is no edge of type" Etype "from" s "to" d.
Ltac find_an_edge_no_cleanup E s d cont :=
let e := fresh "e" in
make_an_edge E s d e;
cont e.
Ltac find_an_edge E s d cont :=
find_an_edge_no_cleanup E s d ltac:(fun e => cont e; destruct e).
Ltac find_the_edge_no_cleanup E s d cont :=
let Etype' := constr:(E s d) in
let Etype := (eval simpl in Etype') in
let e := fresh "e" in
let e' := fresh "e'" in
make_an_edge E s d e;
pose proof e as e';
(destruct e' as [ ] || fail "There are multiple edges of type" Etype "from" s "to" d);
cont e.
Ltac find_the_edge E s d cont :=
find_the_edge_no_cleanup E s d ltac:(fun e => cont e; destruct e).
Ltac find_a_path' E s d cont node_eq_dec check_node :=
(find_an_edge
E s d
ltac:(fun e => let p := constr:(AddEdge NoEdges e) in
cont p))
|| idtac.
Ltac find_a_path E s d node_eq_dec cont :=
find_a_path' E s d cont node_eq_dec ltac:(fun n => idtac).
Ltac find_the_path' E s d cont node_eq_dec check_node :=
(find_the_edge
E s d
ltac:(fun e => let p := constr:(AddEdge NoEdges e) in
cont p))
|| idtac.
Ltac find_the_path E s d node_eq_dec cont :=
find_the_path' E s d cont node_eq_dec ltac:(fun n => idtac).
Ltac eliminate_useless_paths_functor_cases_then tac :=
present_spcategory;
match goal with
| [ |- forall s d : ?fromObjectType,
?fromEdgeType s d ->
Morphism ?toCategory (@?Fs s) (@?Fd d) ] =>
let s := fresh "s" in
let d := fresh "d" in
let m := fresh "m" in
intros s d m;
let toObject := constr:(Fs s) in
let toObjectType := type of toObject in
let toEdge := constr:(Morphism toCategory (Fs s) (Fd d)) in
let toEdgeType := type of toEdge in
destruct_head fromObjectType; simpl in *;
destruct_head fromEdgeType; simpl in *;
hnf;
tac toObjectType toCategory
| _ => fail 2 "Goal should be of the form [forall s d : ?T, ?EdgeType s d -> ?Morphism ?D (@?F0 s) (?@F1 d)]."
end.
Ltac eliminate_useless_paths_functor_cases := eliminate_useless_paths_functor_cases_then ltac:(fun _ _ => idtac).
Ltac fill_unique_paths_functor' make_object_eq_dec :=
eliminate_useless_paths_functor_cases_then
ltac:(fun toObjectType toCategory =>
let toObject_eq_dec := fresh "toObject_eq_dec" in
(assert (toObject_eq_dec : eq_dec toObjectType) by (abstract make_object_eq_dec)
|| fail 1 "Failed to construct decision procedure for equality of" toObjectType "by" make_object_eq_dec);
match goal with
| [ |- path ?E ?s ?d ] =>
try find_the_path E s d toObject_eq_dec ltac:(fun p => exact p)
| [ |- ?G ] => fail 2 "Morphisms in" toCategory "are not paths, but look like" G
end
).
Ltac fill_unique_paths_functor := fill_unique_paths_functor' ltac:(idtac; make_inductive_eq_dec).
Section FunctorialDataMigration.
Section Example22.
Inductive C_Objects_Ex22 : Set := SSN_Ex22_C | FirstName_Ex22_C | LastName_Ex22_C | Salary_Ex22_C | T1_Ex22_C | T2_Ex22_C.
Inductive D_Objects_Ex22 : Set := SSN_Ex22_D | FirstName_Ex22_D | LastName_Ex22_D | Salary_Ex22_D | U_Ex22_D.
Inductive E_Objects_Ex22 : Set := SSN_Ex22_E | FirstName_Ex22_E | LastName_Ex22_E | V_Ex22_E.
Example C_Edges_Ex22 (s d : C_Objects_Ex22) : Set :=
match (s, d) with
| (T1_Ex22_C, SSN_Ex22_C) => unit
| (T1_Ex22_C, FirstName_Ex22_C) => unit
| (T1_Ex22_C, LastName_Ex22_C) => unit
| (T2_Ex22_C, FirstName_Ex22_C) => unit
| (T2_Ex22_C, LastName_Ex22_C) => unit
| (T2_Ex22_C, Salary_Ex22_C) => unit
| _ => Empty_set
end.
Example D_Edges_Ex22 (s d : D_Objects_Ex22) : Set :=
match (s, d) with
| (U_Ex22_D, SSN_Ex22_D) => unit
| (U_Ex22_D, FirstName_Ex22_D) => unit
| (U_Ex22_D, LastName_Ex22_D) => unit
| (U_Ex22_D, Salary_Ex22_D) => unit
| _ => Empty_set
end.
Example E_Edges_Ex22 (s d : E_Objects_Ex22) : Set :=
match (s, d) with
| (V_Ex22_E, SSN_Ex22_E) => unit
| (V_Ex22_E, FirstName_Ex22_E) => unit
| (V_Ex22_E, LastName_Ex22_E) => unit
| _ => Empty_set
end.
Example C_Category_Ex22 : LocallySmallSpecializedCategory _ := PathsCategory C_Edges_Ex22.
Example D_Category_Ex22 : LocallySmallSpecializedCategory _ := PathsCategory D_Edges_Ex22.
Example E_Category_Ex22 : LocallySmallSpecializedCategory _ := PathsCategory E_Edges_Ex22.
Example F_Functor_Ex22_ObjectOf (x : C_Objects_Ex22) : D_Objects_Ex22 :=
match x with
| SSN_Ex22_C => SSN_Ex22_D
| FirstName_Ex22_C => FirstName_Ex22_D
| LastName_Ex22_C => LastName_Ex22_D
| Salary_Ex22_C => Salary_Ex22_D
| T1_Ex22_C => U_Ex22_D
| T2_Ex22_C => U_Ex22_D
end.
Example G_Functor_Ex22_ObjectOf (x : E_Objects_Ex22) : D_Objects_Ex22 :=
match x with
| SSN_Ex22_E => SSN_Ex22_D
| FirstName_Ex22_E => FirstName_Ex22_D
| LastName_Ex22_E => LastName_Ex22_D
| V_Ex22_E => U_Ex22_D
end.
Example F_Functor_Ex22 : SpecializedFunctor C_Category_Ex22 D_Category_Ex22.
Proof.
apply (@FunctorFromPaths _ _ _ _ F_Functor_Ex22_ObjectOf).
fill_unique_paths_functor.
Defined.
Example G_Functor_Ex22 : SpecializedFunctor E_Category_Ex22 D_Category_Ex22.
Proof.
apply (@FunctorFromPaths _ _ _ _ G_Functor_Ex22_ObjectOf).
fill_unique_paths_functor.
Defined.
Inductive SSN := SSN_intro : string -> SSN.
Inductive FirstName := FirstName_intro : string -> FirstName.
Inductive LastName := LastName_intro : string -> LastName.
Inductive Salary := Salary_intro : nat -> Salary.
Section Example221.
Inductive Id_Ex221 := x11_Ex221 | x12_Ex221 | x13_Ex221.
Definition δ_Functor_Ex221_ObjectOf (x : D_Objects_Ex22) : Set :=
match x with
| SSN_Ex22_D => SSN
| FirstName_Ex22_D => FirstName
| LastName_Ex22_D => LastName
| Salary_Ex22_D => Salary
| U_Ex22_D => Id_Ex221
end.
Example δ_Functor_Ex221 : SpecializedFunctor D_Category_Ex22 SetCat.
Proof.
apply (@FunctorFromPaths _ _ _ _ δ_Functor_Ex221_ObjectOf).
eliminate_useless_paths_functor_cases;
intro id;
match goal with
| [ |- SSN ] =>
constructor;
exact (match id with
| x11_Ex221 => "101-22-0411"%string
| x12_Ex221 => "220-39-7479"%string
| x13_Ex221 => "775-33-2819"%string
end)
| [ |- FirstName ] =>
constructor;
exact (match id with
| x11_Ex221 => "David"%string
| x12_Ex221 => "Bertrand"%string
| x13_Ex221 => "Alan"%string
end)
| [ |- LastName ] =>
constructor;
exact (match id with
| x11_Ex221 => "Hilbert"%string
| x12_Ex221 => "Russell"%string
| x13_Ex221 => "Turing"%string
end)
| [ |- Salary ] =>
constructor;
exact (match id with
| x11_Ex221 => 150
| x12_Ex221 => 200
| x13_Ex221 => 200
end)
end.
Defined.
Eval compute in (ObjectOf ((PullbackAlong C_Category_Ex22 D_Category_Ex22 SetCat F_Functor_Ex22) δ_Functor_Ex221)).
Section Δ_F__δ__T1_Ex221_cleanup.
Example Δ_F__δ__T1_Ex221' :=
Eval compute in (fun d e =>
(@MorphismOf _ _ _ _
((PullbackAlong C_Category_Ex22 D_Category_Ex22 SetCat F_Functor_Ex22)
δ_Functor_Ex221)
T1_Ex22_C
d
(AddEdge NoEdges e))).
Example Δ_F__δ__T1_Ex221_with_type' : {T : Set & T }
:= Eval compute in @existT _ _ _ Δ_F__δ__T1_Ex221'.
Let Δ_F__δ__T1_Ex221_DE_Type : Set.
match eval compute in (projT1 Δ_F__δ__T1_Ex221_with_type') with
| forall d : ?D, @?E d -> _ => exact { d : D & E d }
end.
Defined.
Let Δ_F__δ__T1_Ex221_D_Type : Set.
match eval compute in (projT1 Δ_F__δ__T1_Ex221_with_type') with
| forall d : ?D, @?E d -> _ => exact D
end.
Defined.
Example Δ_F__δ__T1_Ex221_with_type'' (d : Δ_F__δ__T1_Ex221_D_Type) : {T : Set & T }.
Proof.
assert (H : focus Δ_F__δ__T1_Ex221_DE_Type) by constructor; unfold Δ_F__δ__T1_Ex221_DE_Type in *; hnf in d.
repeat match type of H with
| appcontext G[unit] => let x := fresh in
evar (x : Set);
let G' := context G[x] in
clear H;
assert (H : G') by constructor;
subst x
end;
repeat match type of H with
| appcontext G[Empty_set] => let G' := context G[unit] in
clear H;
assert (H : G') by constructor
end;
match type of H with
| focus ({ d0 : _ & @?f d0 }) => let P := fresh in pose (f d) as P; exists P; subst P; simpl; clear H;
pose d as d'; destruct d; try solve [ constructor ];
let g := fresh in pose (Δ_F__δ__T1_Ex221' d' tt) as g; compute in *;
exact g
end.
Defined.
End Δ_F__δ__T1_Ex221_cleanup.
Section Δ_F__δ__T2_Ex221_cleanup.
Example Δ_F__δ__T2_Ex221' :=
Eval compute in (fun d e =>
(@MorphismOf _ _ _ _
((PullbackAlong C_Category_Ex22 D_Category_Ex22 SetCat F_Functor_Ex22)
δ_Functor_Ex221)
T2_Ex22_C
d
(AddEdge NoEdges e))).
Example Δ_F__δ__T2_Ex221_with_type' : {T : Set & T }
:= Eval compute in @existT _ _ _ Δ_F__δ__T2_Ex221'.
Let Δ_F__δ__T2_Ex221_DE_Type : Set.
match eval compute in (projT1 Δ_F__δ__T2_Ex221_with_type') with
| forall d : ?D, @?E d -> _ => exact { d : D & E d }
end.
Defined.
Let Δ_F__δ__T2_Ex221_D_Type : Set.
match eval compute in (projT1 Δ_F__δ__T2_Ex221_with_type') with
| forall d : ?D, @?E d -> _ => exact D
end.
Defined.
Example Δ_F__δ__T2_Ex221_with_type'' (d : Δ_F__δ__T2_Ex221_D_Type) : {T : Set & T }.
Proof.
assert (H : focus Δ_F__δ__T2_Ex221_DE_Type) by constructor; unfold Δ_F__δ__T2_Ex221_DE_Type in *; hnf in d.
repeat match type of H with
| appcontext G[unit] => let x := fresh in
evar (x : Set);
let G' := context G[x] in
clear H;
assert (H : G') by constructor;
subst x
end;
repeat match type of H with
| appcontext G[Empty_set] => let G' := context G[unit] in
clear H;
assert (H : G') by constructor
end;
match type of H with
| focus ({ d0 : _ & @?f d0 }) => let P := fresh in pose (f d) as P; exists P; subst P; simpl; clear H;
pose d as d'; destruct d; try solve [ constructor ];
let g := fresh in pose (Δ_F__δ__T2_Ex221' d' tt) as g; compute in *;
exact g
end.
Defined.
End Δ_F__δ__T2_Ex221_cleanup.
Example Δ_F__δ__T1_Ex221 := Eval compute in (fun d => projT2 (Δ_F__δ__T1_Ex221_with_type'' d)).
Example Δ_F__δ__T2_Ex221 := Eval compute in (fun d => projT2 (Δ_F__δ__T2_Ex221_with_type'' d)).
Example Δ_F__δ__T1_Ex221_rev_T (x : Id_Ex221) (d : C_Objects_Ex22) : Type.
Proof.
pose (Δ_F__δ__T1_Ex221 d) as f;
destruct d; compute in *;
(specialize (f x); let t := type of f in exact t) || exact unit.
Defined.
Example Δ_F__δ__T1_Ex221_rev' (x : Id_Ex221) (d : C_Objects_Ex22) : Δ_F__δ__T1_Ex221_rev_T x d.
Proof.
pose (Δ_F__δ__T1_Ex221 d) as f;
destruct d; compute in *; exact (f x) || exact tt.
Defined.
Example Δ_F__δ__T1_Ex221_rev'' x d := Eval compute in Δ_F__δ__T1_Ex221_rev' x d.
Let typeof {T} (_ : T) := T.
Example Δ_F__δ__T1_Ex221_rev''' x d : typeof (Δ_F__δ__T1_Ex221_rev'' x d).
Proof.
pose (Δ_F__δ__T1_Ex221_rev'' x d) as f;
compute in *; destruct x; compute in *; destruct d; compute in *;
exact f.
Defined.
Example Δ_F__δ__T1_Ex221_rev x d := Eval compute in Δ_F__δ__T1_Ex221_rev''' x d.
Print Δ_F__δ__T1_Ex221_rev.
Print Δ_F__δ__T1_Ex221.
Print Δ_F__δ__T2_Ex221.
End Example221.
Section Example222.
Inductive T1_Id_Ex222 := x11_Ex222 | x12_Ex222 | x13_Ex222.
Inductive T2_Id_Ex222 := y1_Ex222 | y2_Ex222 | y3_Ex222 | y4_Ex222.
Definition γ_Functor_Ex222_ObjectOf (x : C_Objects_Ex22) : Set :=
match x with
| SSN_Ex22_C => SSN
| FirstName_Ex22_C => FirstName
| LastName_Ex22_C => LastName
| Salary_Ex22_C => Salary
| T1_Ex22_C => T1_Id_Ex222
| T2_Ex22_C => T2_Id_Ex222
end.
Example γ_Functor_Ex222 : SpecializedFunctor C_Category_Ex22 SetCat.
Proof.
apply (@FunctorFromPaths _ _ _ _ γ_Functor_Ex222_ObjectOf).
eliminate_useless_paths_functor_cases;
intro id;
match type of id with
| T1_Id_Ex222 =>
match goal with
| [ |- SSN ] =>
constructor;
exact (match id with
| x11_Ex222 => "101-22-0411"%string
| x12_Ex222 => "220-39-7479"%string
| x13_Ex222 => "775-33-2819"%string
end)
| [ |- FirstName ] =>
constructor;
exact (match id with
| x11_Ex222 => "David"%string
| x12_Ex222 => "Bertrand"%string
| x13_Ex222 => "Bertrand"%string
end)
| [ |- LastName ] =>
constructor;
exact (match id with
| x11_Ex222 => "Hilbert"%string
| x12_Ex222 => "Russell"%string
| x13_Ex222 => "Russell"%string
end)
end
| T2_Id_Ex222 =>
match goal with
| [ |- FirstName ] =>
constructor;
exact (match id with
| y1_Ex222 => "David"%string
| y2_Ex222 => "Bertrand"%string
| y3_Ex222 => "Bertrand"%string
| y4_Ex222 => "Alan"%string
end)
| [ |- LastName ] =>
constructor;
exact (match id with
| y1_Ex222 => "Hilbert"%string
| y2_Ex222 => "Russell"%string
| y3_Ex222 => "Russell"%string
| y4_Ex222 => "Turning"%string
end)
| [ |- Salary ] =>
constructor;
exact (match id with
| y1_Ex222 => 150
| y2_Ex222 => 200
| y3_Ex222 => 225
| y4_Ex222 => 200
end)
end
end.
Defined.
Check (@RightPushforwardAlong C_Category_Ex22
D_Category_Ex22
TypeCat
F_Functor_Ex22
(fun (g : SpecializedFunctorToType _) d => @TypeLimit
_
_
(RightPushforwardAlong_pre_Functor
C_Category_Ex22
D_Category_Ex22
TypeCat
F_Functor_Ex22
(g : SpecializedFunctorToType _)
d))).
Let U_Ex22_D_ex := Eval hnf in (ObjectOf (@RightPushforwardAlong C_Category_Ex22
D_Category_Ex22
TypeCat
F_Functor_Ex22
(fun (g : SpecializedFunctorToType _) d => @TypeLimit
_
_
(RightPushforwardAlong_pre_Functor
C_Category_Ex22
D_Category_Ex22
TypeCat
F_Functor_Ex22
(g : SpecializedFunctorToType _)
d)))
((γ_Functor_Ex222 : SpecializedFunctorToSet _) : SpecializedFunctorToType _)
U_Ex22_D).
Let Π_F__γ := (@RightPushforwardAlong C_Category_Ex22
D_Category_Ex22
TypeCat
F_Functor_Ex22
(fun (g : SpecializedFunctorToType _) d => @TypeLimit
_
_
(RightPushforwardAlong_pre_Functor
C_Category_Ex22
D_Category_Ex22
TypeCat
F_Functor_Ex22
(g : SpecializedFunctorToType _)
d)))
((γ_Functor_Ex222 : SpecializedFunctorToSet _) : SpecializedFunctorToType _).
Section Π_F__γ__T1_Ex222_cleanup.
Example Π_F__γ__U_Ex222' :=
Eval hnf in (@ObjectOf _ _ _ _
Π_F__γ
U_Ex22_D).
Example Π_F__γ__U_Ex222'' :=
Eval cbv beta iota zeta delta [Π_F__γ__U_Ex222'
Object
C_Edges_Ex22
SliceSpecializedCategory_Functor
RightPushforwardAlong_pre_Functor
γ_Functor_Ex222] in Π_F__γ__U_Ex222'.
Arguments Π_F__γ__U_Ex222'' /.
Example Π_F__γ__U_Ex222''' := Eval simpl in Π_F__γ__U_Ex222''.
Set Printing Coercions.
Let typeof {T} (_ : T) := T.
Example Π_F__γ__U_Ex222'''' : typeof Π_F__γ__U_Ex222'''.
Proof.
subst_body; hnf.
assert (f : focus Π_F__γ__U_Ex222''') by constructor.
unfold Π_F__γ__U_Ex222''' in f.
simpl in f.
unfold CommaSpecializedCategory_ObjectT in *; simpl in *.
unfold γ_Functor_Ex222_ObjectOf in *.
simpl in *.
unfold F_Functor_Ex22_ObjectOf in *.
match type of f with
| focus ?f' => exact f'
end.
Defined.
Example Π_F__γ__U_Ex222''''' : Type.
Proof.
assert (f : focus Π_F__γ__U_Ex222'''') by constructor.
unfold Π_F__γ__U_Ex222'''' in f; revert f.
subst_body; hnf.
intro f.
match type of f with
| focus ({ S0 : forall c : CommaSpecializedCategory_Object ?A ?B, @?C c |
@?D S0 }) =>
clear f; assert (f : focus ({ S0 : forall c : CommaSpecializedCategory_ObjectT A B,
C (Build_CommaSpecializedCategory_Object A B c) |
D (fun c => S0 (CommaSpecializedCategory_Object_Member c)) }))
by constructor;
unfold CommaSpecializedCategory_ObjectT in f; simpl in f
end.
match type of f with
| focus ({ S0 : ?ST |
forall (c c' : CommaSpecializedCategory_Object ?A ?B)
(g : CommaSpecializedCategory_Morphism (CommaSpecializedCategory_Object_Member c)
(CommaSpecializedCategory_Object_Member c')),
@?D S0 c c' g }) =>
clear f; assert (f : focus { S0 : ST |
forall (c c' : CommaSpecializedCategory_ObjectT A B)
(g : CommaSpecializedCategory_MorphismT c c'),
D S0
(Build_CommaSpecializedCategory_Object A B c)
(Build_CommaSpecializedCategory_Object A B c')
(Build_CommaSpecializedCategory_Morphism c c' g) })
by constructor;
unfold CommaSpecializedCategory_ObjectT, CommaSpecializedCategory_MorphismT in f;
simpl in f
end.
match type of f with
| focus ({ S0 : forall c : { ab : unit * ?B & @?C ab }, @?D c |
@?E S0 }) =>
clear f; assert (f : focus ({ S0 : forall (b : B) (c : C (tt, b)),
D (existT _ (tt, b) c) |
E (fun c => S0 (snd (projT1 c)) (projT2 c)) }))
by constructor;
simpl in f
end.
match type of f with
| focus ({ S0 : ?ST |
forall (c c' : ?C)
(g : { ab : unit * @?B c c' | @?D c c' ab }),
@?E S0 c c' g }) =>
clear f; assert (f : focus { S0 : ST |
forall (c c' : C)
(g : B c c')
(gp : D c c' (tt, g)),
E S0
c
c'
(existT _ (tt, g) gp)
})
by constructor;
simpl in f
end.
match type of f with
| focus ({ S0 : ?ST |
forall (c c' : { ab : unit * ?B & @?C ab }),
@?D S0 c c' }) =>
clear f; assert (f : focus { S0 : ST |
forall (b b' : B)
(c : C (tt, b))
(c' : C (tt, b')),
D S0
(existT _ (tt, b) c)
(existT _ (tt, b') c')
})
by constructor;
simpl in f
end.
repeat match type of f with
| appcontext G [fun x : ?T => match x with tt => ?R end] =>
clear f; let f' := context G[fun x : T => R] in
assert (f : f') by constructor;
simpl in f
end.
(*repeat match type of f with
| appcontext G [match _ with
| SSN_Ex22_C => Empty_set
| FirstName_Ex22_C => Empty_set
| LastName_Ex22_C => Empty_set
| Salary_Ex22_C => Empty_set
| T1_Ex22_C => Empty_set
| T2_Ex22_C => Empty_set
end] =>
clear f; let f' := context G[Empty_set] in
assert (f : f') by constructor;
simpl in f
end.*)
unfold C_Edges_Ex22 in f; simpl in f.
(*repeat match type of f with
| appcontext G [fun x : ?E => _] =>
match eval hnf in E with
| Empty_set =>
let T := fresh in
let F := fresh "Empty_set_func" in
evar (T : Type);
pose (fun x : E => match x return T with end) as F;
subst T;
clear f; let f' := context G[F] in
assert (f : f') by constructor;
simpl in f
end
end.*)
repeat match type of f with
| appcontext G [fun x : Empty_set => @?t x] =>
match type of t with
| Empty_set -> ?t' =>
let F := fresh "Empty_set_func" in
pose (fun x : Empty_set => match x return t' with end) as F;
clear f; let f' := context G[F] in
assert (f : f') by constructor;
simpl in f
end
end.
(*repeat match type of f with
| appcontext G [fun x : Empty_set => _] =>
let T := fresh in
let F := fresh "Empty_set_func" in
evar (T : Type);
pose (fun x : Empty_set => match x return T with end) as F;
subst T;
clear f; let f' := context G[F] in
assert (f : f') by constructor;
simpl in f
end;
subst_body.*)
(*repeat match type of f with
| appcontext G [fun x : ?E => _] =>
pose E;
match eval hnf in E with
| Empty_set =>
let T := fresh in
let F := fresh "Empty_set_func" in
evar (T : Type);
pose (fun x : E => match x return T with end) as F;
subst T;
clear f; let f' := context G[F] in
assert (f : f') by constructor;
simpl in f
end
end.*)
match type of f with
| focus ?T => let rtn := fresh in pose T as rtn; exact rtn
end.
Defined.
Example Π_F__γ__U_Ex222'''''' := Eval hnf in Π_F__γ__U_Ex222'''''.
Example Π_F__γ__U_Ex222''''''_Obj : Set.
Proof.
assert (f : focus (Π_F__γ__U_Ex222'''''')) by constructor; unfold Π_F__γ__U_Ex222'''''' in f;
revert f; clear; intro f.
unfold F_Functor_Ex22_ObjectOf in *.
match type of f with
| focus { S0 : ?T | _ } => exact T
end.
Defined.
Example Π_F__γ__U_Ex222''''''_Proof (o : Π_F__γ__U_Ex222''''''_Obj) : Prop.
Proof.
assert (f : focus (Π_F__γ__U_Ex222'''''')) by constructor; unfold Π_F__γ__U_Ex222'''''' in f;
hnf in o;
revert f o; clear; intros zf o.
match type of f with
| focus { S0 : ?T | @?Pf' S0 } => exact (Pf' o)
end.
Defined.
Eval hnf in Π_F__γ__U_Ex222''''''_Obj.
Print Π_F__γ__U_Ex222''''''.
Example Π_F__γ__U_Ex222_MorphismOf' (x : D_Objects_Ex22) (m : path D_Edges_Ex22 U_Ex22_D x)
:= Eval hnf in (@MorphismOf _ _ _ _
Π_F__γ
U_Ex22_D
x m).
Example Π_F__γ__U_Ex222_MorphismOf'' x m : typeof (@Π_F__γ__U_Ex222_MorphismOf' x m).
Proof.
assert (f : focus (@Π_F__γ__U_Ex222_MorphismOf' x m)) by constructor;
unfold Π_F__γ__U_Ex222_MorphismOf' in *; revert f; clear; intro f.
simpl in f.
hnf in x, m.
revert
Print Π_F__γ__U_Ex222''''''.
(*
Goal forall x : Π_F__γ__U_Ex222'''', True.
clear.
intro x.
hnf in x.
destruct x.
simpl in *.
match type of x with
| forall c : CommaSpecializedCategory_Object ?A ?B, @?f c =>
assert (x' : forall c : CommaSpecializedCategory_ObjectT A B,
f (Build_CommaSpecializedCategory_Object A B c))
end.
admit.
match type of e with
| forall (c c' : CommaSpecializedCategory_Object ?A ?B) (g : CommaSpecializedCategory_Morphism (CommaSpecializedCategory_Object_Member c)
(CommaSpecializedCategory_Object_Member c')),
@?f c c' g =>
clear e; assert (e : forall (c c' : CommaSpecializedCategory_ObjectT A B) (g : CommaSpecializedCategory_MorphismT c c'),
f (Build_CommaSpecializedCategory_Object A B c) (Build_CommaSpecializedCategory_Object A B c')
(Build_CommaSpecializedCategory_Morphism c c' g)) by admit
end.
match type of x with
| forall c : CommaSpecializedCategory_Object ?A ?B, @?f c =>
match type of e with
| appcontext e'[x] =>
let e'' := context e'[fun c : CommaSpecializedCategory_Object A B => x' (CommaSpecializedCategory_Object_Member c)] in
assert (e''' : e'') by admit
end
end.
clear e.
rename e''' into e'.
simpl in *.
match type of x with
| forall c : CommaSpecializedCategory_Object ?A ?B, @?f c =>
repeat match type of e' with
| appcontext e''[x] =>
let e''' := context e''[fun c : CommaSpecializedCategory_Object A B => x' (CommaSpecializedCategory_Object_Member c)] in
clear e'; assert (e' : e''') by admit
end
end.
clear x.
rename x' into x, e' into e.
simpl in *.
compute in x.
unfold CommaSpecializedCategory_ObjectT in e; simpl in *.
unfold CommaSpecializedCategory_MorphismT in *; simpl in *.
Print existT.
Print exist.
match type of e with
| forall (c c' : { ab : unit * ?A & @?B ab }) (g : { ab : unit * @?C c c' | @?D c c' ab }), @?E c c' g =>
rename e into e'; pose proof (fun (c c' : { a : A & B (tt, a) })
(g : { a : C (existT _ (tt, projT1 c) (projT2 c))
(existT _ (tt, projT1 c') (projT2 c')) |
D (existT _ (tt, projT1 c) (projT2 c))
(existT _ (tt, projT1 c') (projT2 c'))
(tt, a) })
=> e' (existT _ (tt, projT1 c) (projT2 c))
(existT _ (tt, projT1 c') (projT2 c'))
(exist _ (tt, proj1_sig g) (proj2_sig g))) as e; clear e'; simpl in *
end.
match type of x with
| forall (c : { ab : unit * ?A & @?B ab }), _ =>
rename x into x'; pose proof (fun c : { a : A & B (tt, a) } => x' (existT _ (tt, projT1 c) (projT2 c))) as x; simpl in *
end.
assert (H : x' = (fun c => x (existT _ (snd (projT1 c)) (projT2 c)))) by admit;
rewrite H in e; clear H; clear x'; simpl in *.
pose proof (fun ca ce c'a c'e ge gpf => e (existT _ ca (AddEdge NoEdges ce)) (existT _ c'a (AddEdge NoEdges c'e)) (exist _ (AddEdge NoEdges ge) gpf)) as e'; simpl in *.
compute in e'.
clear e.
pose (fun a p => x (existT _ a p)) as x'; simpl in *.
repeat match type of e' with
| appcontext e''[x] =>
let e''' := context e''[fun c => (fun a p => x (existT _ a p)) (projT1 c) (projT2 c)] in
clear e'; assert (e' : e''') by admit;
change (fun a p => x (existT _ a p)) with x' in e'
end.
clearbody x'.
clear x.
compute in *.
rename x' into x, e' into e.
compute in *.
let t := type of x in evar (x' : t).
refine (x' = _).
instantiate (1 := refine _).
refine
pose (fun ca ce => (x ca (AddEdge NoEdges ce))) as f;
simpl in f.
clear f.
change (@AddEdge) with (fun V E s d d' => @AddEdge V E s d d') in e.
match goal with
| [ f := (fun ca ce => x ca (@?p ca ce)) |- _ ] => pose (fun ca ce =>
end.
clear x.
change (x ?ca (AddEdge
pose (fun ap => x (projT1 ap) (projT2 ap)) as x'; simpl in *.
pose (fun a e => x a (AddEdge NoEdges e)) as x'; simpl in *.
let t := type of x in let t' := type of x' in assert (FOOBAR : t).
intro a;
pose (x' a) as x'';
destruct a; simpl;
intro p; try apply (x'' tt); admit.
Show Proof.
Show Proof.
pose
intro p.
intros a p.
pose p as p'.
destruct p as [ p'' | p'' ].
admit.
pose a as a'; destruct a.
destruct
apply (x' a y).
destruct
Ltac rep_con e x x' :=
match e with
| appcontext e'[x] =>
let e'' := context e'[x'] in
match e'' with
| appcontext e'''[AddEdge NoEdges] =>
let e'''' := context e'''[fun u => u] in
rep_con e'''' x x'
end
| _ => e
end.
let e' := type of e in let e'' := rep_con e' x x' in assert (e''' : e'') by admit.
Check x'.
let t := type of x in
assert t.
Goal forall (x' : forall a : C_Objects_Ex22,
match
match a with
| SSN_Ex22_C => SSN_Ex22_D
| FirstName_Ex22_C => FirstName_Ex22_D
| LastName_Ex22_C => LastName_Ex22_D
| Salary_Ex22_C => Salary_Ex22_D
| T1_Ex22_C => U_Ex22_D
| T2_Ex22_C => U_Ex22_D
end
with
| SSN_Ex22_D => unit
| FirstName_Ex22_D => unit
| LastName_Ex22_D => unit
| Salary_Ex22_D => unit
| U_Ex22_D => Empty_set
end ->
match a with
| SSN_Ex22_C => SSN
| FirstName_Ex22_C => FirstName
| LastName_Ex22_C => LastName
| Salary_Ex22_C => Salary
| T1_Ex22_C => T1_Id_Ex222
| T2_Ex22_C => T2_Id_Ex222
end), forall a : C_Objects_Ex22,
path
(fun s d : D_Objects_Ex22 =>
match s with
| SSN_Ex22_D => Empty_set
| FirstName_Ex22_D => Empty_set
| LastName_Ex22_D => Empty_set
| Salary_Ex22_D => Empty_set
| U_Ex22_D =>
match d with
| SSN_Ex22_D => unit
| FirstName_Ex22_D => unit