1
- From Equations Require Import Equations.
2
- Set Equations With UIP.
3
-
4
1
Require Import Category.Lib.
5
2
Require Import Category.Theory.Category.
3
+ Require Import Category.Structure .Cartesian.
6
4
Require Import Category.Solver.Expr.
7
5
Require Import Category.Solver.Denote.
8
6
Require Import Category.Solver.Reify.
@@ -12,7 +10,7 @@ Generalizable All Variables.
12
10
13
11
Section Decide.
14
12
15
- Context `{Env }.
13
+ Context `{Arrows }.
16
14
17
15
(** This code is from Certified Programming with Dependent Types (CPDT). *)
18
16
@@ -34,89 +32,74 @@ Notation "'Reduce' v" := (if v then Yes else No) (at level 100) : partial_scope.
34
32
Notation "x || y" := (if x then Yes else Reduce y) : partial_scope.
35
33
Notation "x && y" := (if x then Reduce y else No) : partial_scope.
36
34
37
- Program Fixpoint sexpr_forward (t : SExpr ) (hyp : SExpr )
38
- (cont : [sexprD t]) :
39
- [sexprD hyp → sexprD t] :=
35
+ Program Fixpoint expr_forward (t : Expr ) (hyp : Expr )
36
+ (cont : [exprD t]) :
37
+ [exprD hyp → exprD t] :=
40
38
match hyp with
41
- | STop => Reduce cont
42
- | SBottom => Yes
43
- | SEquiv x y f g => Reduce cont
44
- | SAnd p q => Reduce cont
45
- | SOr p q => if sexpr_forward t p cont
46
- then Reduce (sexpr_forward t q cont)
47
- else No
48
- | SImpl _ _ => Reduce cont
39
+ | Top => Reduce cont
40
+ | Bottom => Yes
41
+ | Equiv x y f g => Reduce cont
42
+ | And p q => Reduce cont
43
+ | Or p q => if expr_forward t p cont
44
+ then Reduce (expr_forward t q cont)
45
+ else No
46
+ | Impl _ _ => Reduce cont
49
47
end .
50
48
Next Obligation . tauto. Defined .
51
- Next Obligation . intuition. Defined .
52
49
53
- Program Fixpoint sexpr_backward (t : SExpr) {measure t SExpr_subterm} :
54
- [sexprD t] :=
50
+ #[local] Obligation Tactic := cat_simpl; intuition.
51
+
52
+ Program Fixpoint expr_backward (t : Expr) {measure t Expr_subterm} :
53
+ [exprD t] :=
55
54
match t with
56
- | STop => Yes
57
- | SBottom => No
58
- | SEquiv x y f g => _
59
- | SAnd p q =>
60
- match sexpr_backward p with
61
- | Proved _ _ => Reduce (sexpr_backward q)
62
- | Uncertain _ => No
63
- end
64
- | SOr p q =>
65
- match sexpr_backward p with
66
- | Proved _ _ => Yes
67
- | Uncertain _ => Reduce (sexpr_backward q)
68
- end
69
- | SImpl p q =>
70
- sexpr_forward q p (sexpr_backward q)
55
+ | Top => Yes
56
+ | Bottom => No
57
+ | Equiv x y f g => _
58
+ | And p q => expr_backward p && expr_backward q
59
+ | Or p q => expr_backward p || expr_backward q
60
+ | Impl p q => expr_forward q p (expr_backward q)
71
61
end .
72
62
Next Obligation .
73
- destruct (list_eqdec _ (sindices f) (sindices g)) eqn:?;
63
+ destruct (morphism_eq_dec (to_morphism f) (to_morphism g)) eqn:?;
74
64
[|apply Uncertain].
75
- destruct (Pos_to_fin _); [|apply Uncertain].
76
- destruct (Pos_to_fin _); [|apply Uncertain].
77
- destruct (stermD _ _ f) eqn:?; [|apply Uncertain].
78
- destruct (stermD _ _ g) eqn:?; [|apply Uncertain].
65
+ destruct (termD _ _ f) eqn:?; [|apply Uncertain].
66
+ destruct (termD _ _ g) eqn:?; [|apply Uncertain].
79
67
apply Proved.
80
- apply unsindices_sindices_r in Heqo.
81
- apply unsindices_sindices_r in Heqo0.
68
+ apply from_morphism_to_morphism_r in Heqo.
69
+ apply from_morphism_to_morphism_r in Heqo0.
82
70
rewrite e in Heqo.
83
71
rewrite Heqo in Heqo0.
84
72
now simpl in Heqo0.
85
73
Defined .
86
- Next Obligation . intuition. Defined .
87
- Next Obligation . intuition. Defined .
88
- Next Obligation . intuition. Defined .
89
- Next Obligation . intuition. Defined .
90
- Next Obligation . intuition. Defined .
91
- Next Obligation . apply well_founded_SExpr_subterm. Defined .
74
+ Next Obligation . apply well_founded_Expr_subterm. Defined .
92
75
93
- Definition sexpr_tauto : ∀ t, [sexprD t].
94
- Proof . intros; refine (Reduce (sexpr_backward t)); auto. Defined .
76
+ Definition expr_tauto : ∀ t, [exprD t].
77
+ Proof . intros; refine (Reduce (expr_backward t)); auto. Defined .
95
78
96
- Lemma sexpr_sound t :
97
- (if sexpr_tauto t then True else False) → sexprD t.
98
- Proof . unfold sexpr_tauto ; destruct t, (sexpr_backward _); tauto. Qed .
79
+ Lemma expr_sound t :
80
+ (if expr_tauto t then True else False) → exprD t.
81
+ Proof . unfold expr_tauto ; destruct t, (expr_backward _); tauto. Qed .
99
82
100
83
End Decide.
101
84
102
85
Ltac categorical := reify_terms_and_then
103
86
ltac:(fun env g =>
104
- change (@sexprD env g);
105
- apply sexpr_sound ;
87
+ change (@exprD env g);
88
+ apply expr_sound ;
106
89
now vm_compute).
107
90
108
- Example sample_1 :
109
- ∀ (C : Category) (x y z w : C) ( f : z ~> w) (g : y ~> z) (h : x ~> y) (i : x ~> z),
110
- g ∘ id ∘ id ∘ id ∘ h ≈ i ->
111
- g ∘ id ∘ id ∘ id ∘ h ≈ g ∘ h ->
112
- g ∘ id ∘ id ∘ id ∘ h ≈ g ∘ h ->
113
- g ∘ id ∘ id ∘ id ∘ h ≈ g ∘ h ->
114
- g ∘ id ∘ id ∘ id ∘ h ≈ g ∘ h ->
115
- g ∘ id ∘ id ∘ id ∘ h ≈ g ∘ h ->
116
- g ∘ id ∘ id ∘ id ∘ h ≈ g ∘ h ->
117
- g ∘ id ∘ id ∘ id ∘ h ≈ g ∘ h ->
118
- g ∘ h ≈ i ->
119
- f ∘ (id ∘ g ∘ h) ≈ (f ∘ g) ∘ h.
91
+ Example ex_categorical (C : Category) `{@Cartesian C} (x y z w : C)
92
+ ( f : z ~> w) (g : y ~> z) (h : x ~> y) (i : x ~> z) :
93
+ g ∘ id ∘ id ∘ id ∘ h ≈ i ->
94
+ g ∘ id ∘ id ∘ id ∘ h ≈ g ∘ h ->
95
+ g ∘ id ∘ id ∘ id ∘ h ≈ g ∘ h ->
96
+ g ∘ id ∘ id ∘ id ∘ h ≈ g ∘ h ->
97
+ g ∘ id ∘ id ∘ id ∘ h ≈ g ∘ h ->
98
+ g ∘ id ∘ id ∘ id ∘ h ≈ g ∘ h ->
99
+ g ∘ id ∘ id ∘ id ∘ h ≈ g ∘ h ->
100
+ g ∘ id ∘ id ∘ id ∘ h ≈ g ∘ h ->
101
+ g ∘ h ≈ i ->
102
+ f ∘ (id ∘ g ∘ h) ≈ (f ∘ g) ∘ h.
120
103
Proof .
121
104
intros.
122
105
now categorical.
0 commit comments