-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCategory.v
96 lines (72 loc) · 3.06 KB
/
Category.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
Require Export SpecializedCategory.
Require Import Common.
Set Implicit Arguments.
Generalizable All Variables.
Set Asymmetric Patterns.
Set Universe Polymorphism.
Record > Category := {
CObject : Type;
UnderlyingCategory :> @SpecializedCategory CObject
}.
Record > SmallCategory := {
SObject : Set;
SUnderlyingCategory :> @SmallSpecializedCategory SObject
}.
Record > LocallySmallCategory := {
LSObject : Type;
LSUnderlyingCategory :> @LocallySmallSpecializedCategory LSObject
}.
Bind Scope category_scope with Category.
Bind Scope category_scope with SmallCategory.
Bind Scope category_scope with LocallySmallCategory.
(** * The saturation prover: up to some bound on number of steps, consider all ways to extend equivalences with pre- or post-composition. *)
(** The main tactic, which tries a single round of making deductions from hypotheses that exist at the start of the round.
Only variables in the goal are chosen to compose. *)
Ltac saturate := repeat match goal with
| [ H : @eq (Morphism _ _ _) ?M ?N |- _ ] =>
let tryIt G :=
match goal with
| [ _ : G |- _ ] => fail 1
| [ |- context[G] ] => fail 1
| _ => let H' := fresh "H" in assert (H' : G) by eauto; generalize dependent H'
end in
repeat match goal with
| [ m : Morphism _ _ _ |- _ ] =>
tryIt (Compose M m = Compose N m)
| [ m : Morphism _ _ _ |- _ ] =>
tryIt (Compose m M = Compose m N)
end; generalize dependent H
end; intros; autorewrite with core in *.
(** To be sure that all relevant terms are represented as variables, we use this tactic to create variables for
all non-[Compose] subterms of a morphism expression. *)
Ltac extractMorphisms G :=
match G with
| Compose ?G1 ?G2 =>
extractMorphisms G1;
extractMorphisms G2
| _ =>
match goal with
| [ x := G |- _ ] => idtac
| [ x : _ |- _ ] =>
match x with
| G => idtac
end
| _ => pose G
end
end.
(** This tactic calls the above on two morphisms being compared for equivalence in the goal. *)
Ltac createVariables :=
match goal with
| [ |- @eq (Morphism _ _ _) ?X ?Y ] =>
extractMorphisms X;
extractMorphisms Y
end.
(** After we are done with our variable-related hijinks, we can clean up by removing the new variables,
replacing them by their definitions. *)
Ltac removeVariables :=
repeat match goal with
| [ x := _ |- _ ] => subst x
end.
(** This notation ties it all together, taking as argument the number of [saturate] rounds to run. *)
Tactic Notation "morphisms" integer(numSaturations) :=
t; createVariables; do numSaturations saturate; removeVariables; eauto 3.