Skip to content

Commit 8673f70

Browse files
author
ahrens
committed
notation for constr in prop_untyped
1 parent 3df38df commit 8673f70

File tree

4 files changed

+80
-57
lines changed

4 files changed

+80
-57
lines changed

PROP_untyped/arities.v

+12-9
Original file line numberDiff line numberDiff line change
@@ -319,17 +319,21 @@ Inductive prod_mod_c (V : TYPE) : [nat] -> Type :=
319319
| CONSTR : forall b bs,
320320
M (V ** b)-> prod_mod_c V bs -> prod_mod_c V (b::bs) .
321321

322+
Notation "a -:- b" := (CONSTR a b) (at level 60).
323+
322324
Lemma CONSTR_eq (V : TYPE) (b : nat) (bs : [nat])
323325
(elem elem' : M (V ** b))
324326
(elems elems' : prod_mod_c V bs) :
325327
elem = elem' -> elems = elems' ->
326-
CONSTR elem elems = CONSTR elem' elems'.
328+
elem -:- elems = elem' -:- elems'.
327329
Proof.
328330
intros; subst; auto.
329331
Qed.
330332

331333
End prod_mod_built_from_scratch_carrier.
332334

335+
Notation "a -:- b" := (CONSTR a b) (at level 60).
336+
333337
(** if [T : TYPE -> PO] and [nl] a list of naturals,
334338
then there is a natural order on [prod_mod_c T nl]:
335339
- any two empty lists are related
@@ -345,7 +349,7 @@ Inductive prod_mod_c_rel (V : TYPE) : forall n, relation (prod_mod_c M V n) :=
345349
| CONSTR_rel : forall n l, forall x y : M (V ** n),
346350
forall a b : prod_mod_c M V l,
347351
x << y -> prod_mod_c_rel a b ->
348-
prod_mod_c_rel (CONSTR x a) (CONSTR y b).
352+
prod_mod_c_rel (x -:- a) (y -:- b).
349353

350354
(** this product order is indeed a preorder. proof uses dependent induction/destruction,
351355
hence axioms *)
@@ -394,14 +398,11 @@ Fixpoint pm_mkl l V W (f : Delta V ---> P W)
394398
(X : prod_mod_c (fun V => M V) V l) : prod_mod_c _ W l :=
395399
match X in prod_mod_c _ _ l return prod_mod_c (fun V => M V) W l with
396400
| TTT => TTT _ W
397-
| CONSTR b bs elem elems =>
398-
CONSTR (V:=W)
399-
(rmkleisli (RModule_struct := M) (lshift _ f) elem)
400-
(pm_mkl f elems)
401+
| (*CONSTR b bs*) elem -:- elems =>
402+
rmkleisli (RModule_struct := M) (lshift _ f) elem -:- pm_mkl f elems
401403
end.
402404

403405

404-
405406
Program Instance pm_mkl_struct l V W (f : Delta V ---> P W) :
406407
PO_mor_struct (a := prod_mod_po M V l)
407408
(b := prod_mod_po M W l)
@@ -499,6 +500,8 @@ End arity_rep.
499500

500501
End pow_and_product.
501502

503+
Notation "a -:- b" := (CONSTR a b) (at level 60).
504+
502505
(** the type of representations associated to a signature *)
503506

504507
Section signature_rep.
@@ -565,8 +568,8 @@ Fixpoint Prod_mor_c (l : [nat]) (V : TYPE) (X : prod_mod_c (fun V => P V) V l) :
565568
match X in prod_mod_c _ _ l
566569
return f* (prod_mod Q l) V with
567570
| TTT => TTT _ _
568-
| CONSTR b bs elem elems =>
569-
CONSTR (f _ elem) (Prod_mor_c elems)
571+
| (*CONSTR b bs*) elem -:- elems =>
572+
f _ elem -:- Prod_mor_c elems
570573
end.
571574

572575
(** this function is obviously monotone *)

PROP_untyped/initial.v

+51-30
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Unset Automatic Introduction.
4343

4444

4545
(** afterwards we prove that an initial object exists in the category of representations
46-
associated to a signature [Sig]. this result is actually the same (via an adjunction)
46+
associated to a signature [S]. this result is actually the same (via an adjunction)
4747
as the one proved in ../STS (even for simply--typed syntax *)
4848
(** only in the next file ./prop_arities.v will we talk about propositional arities.
4949
we still need initiality for the empty set of prop. arities, since the order
@@ -54,13 +54,13 @@ Section initial_type.
5454

5555
Ltac fin := simpl in *; intros; autorewrite with fin; auto with fin.
5656

57-
Variable Sig : Signature.
57+
Variable S : Signature.
5858
Notation "V '" := (option V).
5959
Notation "V ** l" := (pow l V) (at level 10).
6060
Notation "f ^^ l" := (pow_map (l:=l) f) (at level 10).
6161
Notation "^ f" := (lift (M:= option_monad) f) (at level 5).
6262
Notation "[ T ]" := (list T) (at level 5).
63-
63+
Notation "a -:- b" := (CONSTR a b) (at level 60).
6464

6565
(** UTS will be the (carrier of the) initial monad, UTS_list represents the arguments of
6666
a constructor *)
@@ -73,16 +73,18 @@ Notation "[ T ]" := (list T) (at level 5).
7373
- the diagonal, yielding the initial representation without any inequations
7474
- the preorder induced by a set of inequations A (cf. file ./prop_arities.v) *)
7575

76+
Reserved Notation "a -::- b" (at level 65).
7677

7778
Inductive UTS (V : TYPE) : TYPE :=
7879
| Var : V -> UTS V
79-
| Build : forall (i : sig_index Sig),
80+
| Build : forall (i : sig_index S),
8081
UTS_list V (sig i) -> UTS V
8182
with
8283
UTS_list (V : TYPE) : [nat] -> Type :=
8384
| TT : UTS_list V nil
8485
| constr : forall b bs,
8586
UTS (V ** b) -> UTS_list V bs -> UTS_list V (b::bs).
87+
Notation "a -::- b" := (constr a b).
8688

8789
(** at first the diagonal preorder *)
8890

@@ -99,9 +101,9 @@ Scheme UTSrect := Induction for UTS Sort Type with
99101
UTSlistrect := Induction for UTS_list Sort Type.
100102

101103
Lemma constr_eq : forall (V : TYPE) (b : nat)
102-
(bs : [nat]) (x y : UTS _ )
104+
(bs : [nat]) (x y : UTS (V**b) )
103105
(v w : UTS_list V bs),
104-
x = y -> v = w -> constr (b:=b) x v = constr y w.
106+
x = y -> v = w -> x -::- v = y -::- w.
105107
Proof.
106108
intros; subst; auto.
107109
Qed.
@@ -119,6 +121,22 @@ Reserved Notation "x //-- f" (at level 42, left associativity).
119121

120122
(** renaming is a mutually recursive function *)
121123

124+
Fixpoint rename (V W: TYPE ) (f : V ---> W) (v : UTS V):=
125+
match v in UTS _ return UTS W with
126+
| Var v => Var (f v)
127+
| Build i l => Build (*i:=i*) (l //-- f)
128+
end
129+
with
130+
list_rename V t (l : UTS_list V t) W (f : V ---> W) : UTS_list W t :=
131+
match l in UTS_list _ t return UTS_list W t with
132+
| TT => TT W
133+
| constr b bs elem elems =>
134+
elem //- f ^^ b -::- elems //-- f
135+
end
136+
where "x //- f" := (rename f x)
137+
and "x //-- f" := (list_rename x f).
138+
139+
(*
122140
Fixpoint rename (V W: TYPE ) (f : V ---> W) (v : UTS V):=
123141
match v in UTS _ return UTS W with
124142
| Var v => Var (f v)
@@ -134,11 +152,12 @@ with
134152
end
135153
where "x //- f" := (rename f x)
136154
and "x //-- f" := (list_rename x f).
155+
*)
137156

138157
Definition rename_sm V W (f : V ---> W) :
139158
UTS_sm V ---> UTS_sm W := #Delta (rename f).
140159

141-
(** functoriality of renaming for STS *)
160+
(** functoriality of renaming for UTS *)
142161

143162
Hint Extern 1 (_ = _) => apply f_equal.
144163

@@ -231,13 +250,13 @@ Definition _shift (V W : TYPE ) (f : V ---> UTS W) :
231250
end.
232251

233252
Notation "x >- f" := (_shift f x) (at level 40).
234-
253+
Locate S.
235254
(** same for lshift, being given a list of object language types *)
236255
Fixpoint _lshift (l : nat) (V W : TYPE) (f : V ---> UTS W) :
237256
V ** l ---> UTS (W ** l) :=
238257
match l return V ** l ---> UTS (W**l) with
239258
| 0 => f
240-
| S n' => @_lshift n' _ _ (_shift f)
259+
| Datatypes.S n' => @_lshift n' _ _ (_shift f)
241260
end.
242261

243262
(*Implicit Arguments shift_l [V W t].*)
@@ -260,15 +279,17 @@ with
260279
list_subst V W t (l : UTS_list V t) (f : V ---> UTS W) : UTS_list W t :=
261280
match l in UTS_list _ t return UTS_list W t with
262281
| TT => TT W
263-
| constr b bs elem elems =>
264-
constr (elem >== (_lshift f)) (elems >>== f)
282+
| (*constr b bs*) elem -::- elems =>
283+
elem >== _lshift f -::- elems >>== f
265284
end
266285
where "x >== f" := (subst f x)
267286
and "x >>== f" := (list_subst x f).
268287

288+
(*
269289
Definition subst_sm (V W : TYPE) (f : Delta V ---> UTS_sm W) :
270290
UTS_sm V ---> UTS_sm W := #Delta (subst f).
271-
291+
*)
292+
272293
(** substitution of one variable only *)
273294

274295
Definition substar (V : TYPE) (M : UTS V ) :
@@ -565,7 +586,7 @@ Obligation Tactic := unfold Proper, respectful; fin.
565586

566587
Program Instance UTS_sm_rmonad : RMonad_struct Delta UTS_sm := {
567588
rweta c := #Delta (@Var c);
568-
rkleisli := subst_sm
589+
rkleisli a b f := #Delta (subst f)
569590
}.
570591

571592
Canonical Structure UTSM := Build_RMonad UTS_sm_rmonad.
@@ -579,15 +600,15 @@ Fixpoint UTSl_f_pm l V (x : prod_mod_c (fun V => UTS V) V l)
579600
: UTS_list V l :=
580601
match x in prod_mod_c _ _ l return UTS_list V l with
581602
| TTT => TT V
582-
| CONSTR b bs e el => constr e (UTSl_f_pm el)
603+
| (*CONSTR b bs*) e -:- el => e -::- UTSl_f_pm el
583604
end.
584605

585606
Fixpoint pm_f_UTSl l V (v : UTS_list V l) :
586607
prod_mod_c (fun V => UTS V) V l :=
587608
match v in UTS_list _ l return prod_mod_c _ V l with
588609
| TT => TTT _ _
589-
| constr b bs elem elems =>
590-
CONSTR elem (pm_f_UTSl elems)
610+
| elem -::- elems =>
611+
elem -:- pm_f_UTSl elems
591612
end.
592613

593614
Lemma one_way l V (v : UTS_list V l) :
@@ -626,7 +647,7 @@ we establish some equalities *)
626647

627648
Hint Rewrite subst_eq_rename : fin.
628649

629-
(** shift = opt_inj STS *)
650+
(** shift = opt_inj UTS *)
630651

631652
Notation "x >>- f" := (shift_not f x) (at level 50).
632653
Notation "x >-- f" := (lshift _ f x) (at level 50).
@@ -655,7 +676,7 @@ Proof.
655676
fin.
656677
Qed.
657678

658-
(** STSl_f_pm ;; list_subst = mkleisli ;; STSl_f_pm *)
679+
(** UTSl_f_pm ;; list_subst = mkleisli ;; UTSl_f_pm *)
659680

660681
Hint Resolve _lshift_lshift_eq : fin.
661682

@@ -714,36 +735,37 @@ Qed.
714735
Obligation Tactic := unfold Proper, respectful; intros; simpl;
715736
repeat (match goal with [H:_|-_]=>rewrite (diag_preorder_prod_imp_eq H) end); constructor.
716737

717-
Program Instance UTS_arity_rep_po (i : sig_index Sig) V : PO_mor_struct
738+
Program Instance UTS_arity_rep_po (i : sig_index S) V : PO_mor_struct
718739
(a:= prod_mod UTSM (sig i) V)
719740
(b:= UTSM V)
720741
(fun (X : prod_mod_c _ V (sig i)) => Build (i:=i) (UTSl_f_pm (V:=V) X)).
721742

722743
Obligation Tactic := t5.
723744

724-
Program Instance UTS_arity_rep (i : sig_index Sig) :
745+
Program Instance UTS_arity_rep (i : sig_index S) :
725746
RModule_Hom_struct
726747
(M := prod_mod UTSM (sig i))
727748
(N := UTSM)
728749
(fun V => Build_PO_mor (UTS_arity_rep_po i V)).
729750

730751

731-
(** STS has a structure as a representation of Sig *)
752+
(** UTS has a structure as a representation of S *)
732753

733-
Canonical Structure UTSrepr : Repr Sig UTSM :=
754+
Canonical Structure UTSrepr : Repr S UTSM :=
734755
fun i => Build_RModule_Hom (UTS_arity_rep i).
735756

736-
Canonical Structure UTSRepr : REP Sig :=
757+
Canonical Structure UTSRepr : REP S :=
737758
Build_Representation (@UTSrepr).
738759

739760
(** ** INITIALITY
740761
the representation [UTSRepr] we've just defined is initial: *)
741762

742763
Section initiality.
743764

744-
Variable R : REP Sig.
765+
Variable R : REP S.
766+
767+
(** the initial morphism UTS -> R *)
745768

746-
(** the initial morphism STS -> R *)
747769

748770
Fixpoint init V (v : UTS V) : R V :=
749771
match v in UTS _ return R V with
@@ -754,8 +776,7 @@ with
754776
init_list l (V : TYPE) (s : UTS_list V l) : prod_mod R l V :=
755777
match s in UTS_list _ l return prod_mod R l V with
756778
| TT => TTT _ _
757-
| constr b bs elem elems =>
758-
CONSTR (init elem) (init_list elems)
779+
| elem -::- elems => init elem -:- init_list elems
759780
end.
760781

761782
(** *** [init] commutes with renaming, substitution
@@ -885,7 +906,7 @@ init is not only (the carrier of) a monad morphism, but even (of) a morphism of
885906
(** prod_ind_mod_mor INIT = init_list (up to bijection) *)
886907

887908

888-
Lemma prod_mor_eq_init_list (i : sig_index Sig) V
909+
Lemma prod_mor_eq_init_list (i : sig_index S) V
889910
(x : prod_mod_c UTS_sm V (sig i)) :
890911
Prod_mor_c init_mon x = init_list (UTSl_f_pm x).
891912
Proof.
@@ -899,7 +920,7 @@ Program Instance init_representic : Representation_Hom_struct
899920

900921
Definition init_rep := Build_Representation_Hom init_representic.
901922

902-
(** ** INITIALITY of STSRepr with init *)
923+
(** ** INITIALITY of UTSRepr with init *)
903924

904925
Section init.
905926

@@ -958,7 +979,7 @@ Obligation Tactic := fin.
958979

959980
(** ** Initiality *)
960981

961-
Program Instance UTS_initial : Initial (REP Sig) := {
982+
Program Instance UTS_initial : Initial (REP S) := {
962983
Init := UTSRepr ;
963984
InitMor R := init_rep R }.
964985

0 commit comments

Comments
 (0)