@@ -50,13 +50,23 @@ Lemma bunch_decomp_complete Δ Π Δ' :
5050 bunch_decomp Δ Π Δ'.
5151Proof . intros <-. apply bunch_decomp_complete'. Qed .
5252
53+ Lemma bunch_decomp_iff Δ Π Δ' :
54+ (fill Π Δ' = Δ) ↔ bunch_decomp Δ Π Δ'.
55+ Proof .
56+ split.
57+ - apply bunch_decomp_complete.
58+ - by symmetry; apply bunch_decomp_correct.
59+ Qed .
60+
61+ (** * Properties of bunched contexts *)
62+ (** We prove several useful properties using the inductive system defined above. *)
63+
5364Lemma fill_is_frml Π Δ ϕ :
5465 fill Π Δ = frml ϕ →
5566 Π = [] ∧ Δ = frml ϕ.
5667Proof .
57- revert Δ. induction Π as [| F C IH]=>Δ; first by eauto.
58- destruct F ; simpl ; intros H1 ;
59- destruct (IH _ H1) as [HC HΔ] ; by simplify_eq/=.
68+ intros H%bunch_decomp_iff.
69+ inversion H; eauto.
6070Qed .
6171
6272Lemma bunch_decomp_app C C0 Δ Δ0 :
@@ -72,72 +82,70 @@ Proof.
7282 apply IHC. destruct F; simpl; by econstructor.
7383Qed .
7484
75- Lemma bunch_decomp_ctx C C ' Δ ϕ :
76- bunch_decomp (fill C Δ) C ' (frml ϕ) →
77- ((∃ C0 , bunch_decomp Δ C0 (frml ϕ) ∧ C ' = C0 ++ C ) ∨
78- (∃ (C0 C1 : bunch → bunch_ctx),
79- (∀ Δ Δ', fill (C0 Δ) Δ' = fill (C1 Δ') Δ) ∧
80- (∀ Δ', fill (C1 Δ') Δ = fill C ' Δ') ∧
81- (∀ A, bunch_decomp (fill C A) (C0 A) (frml ϕ)))).
85+ Lemma bunch_decomp_ctx Π Π ' Δ ϕ :
86+ bunch_decomp (fill Π Δ) Π ' (frml ϕ) →
87+ ((∃ Π0 , bunch_decomp Δ Π0 (frml ϕ) ∧ Π ' = Π0 ++ Π ) ∨
88+ (∃ (Π0 Π1 : bunch → bunch_ctx),
89+ (∀ Δ Δ', fill (Π0 Δ) Δ' = fill (Π1 Δ') Δ) ∧
90+ (∀ Δ', fill (Π1 Δ') Δ = fill Π ' Δ') ∧
91+ (∀ A, bunch_decomp (fill Π A) (Π0 A) (frml ϕ)))).
8292Proof .
83- revert Δ C '.
84- induction C as [|F C ]=>Δ C '; simpl.
93+ revert Δ Π '.
94+ induction Π as [|F Π ]=>Δ Π '; simpl.
8595 { remember (frml ϕ) as Γ1. intros Hdec.
8696 left. eexists. rewrite right_id. split; done. }
8797 simpl. intros Hdec.
88- destruct (IHC _ _ Hdec) as [IH|IH].
89- - destruct IH as [C0 [HC0 HC ]].
98+ destruct (IHΠ _ _ Hdec) as [IH|IH].
99+ - destruct IH as [Π0 [HΠ0 HΠ ]].
90100 destruct F; simpl in *.
91- + inversion HC0 ; simplify_eq/=.
101+ + inversion HΠ0 ; simplify_eq/=.
92102 * left. eexists; split; eauto.
93103 rewrite -assoc //.
94104 * right.
95- exists (λ A, (Π ++ [CtxCommaR A]) ++ C ).
96- exists (λ A, ([CtxCommaL (fill Π A)] ++ C )).
105+ exists (λ A, (Π1 ++ [CtxCommaR A]) ++ Π ).
106+ exists (λ A, ([CtxCommaL (fill Π1 A)] ++ Π )).
97107 repeat split.
98- { intros A B. by rewrite /= -!assoc /= !fill_app. }
99- { intros A. by rewrite /= -!assoc /= !fill_app. }
108+ { intros A B. by rewrite /= -!assoc /= !fill_app /= . }
109+ { intros A. by rewrite /= -!assoc /= !fill_app /= . }
100110 { intros A. apply bunch_decomp_app. by econstructor. }
101- + inversion HC0 ; simplify_eq/=.
111+ + inversion HΠ0 ; simplify_eq/=.
102112 * right.
103- exists (λ A, (Π ++ [CtxCommaL A]) ++ C ).
104- exists (λ A, ([CtxCommaR (fill Π A)] ++ C )).
113+ exists (λ A, (Π1 ++ [CtxCommaL A]) ++ Π ).
114+ exists (λ A, ([CtxCommaR (fill Π1 A)] ++ Π )).
105115 repeat split.
106116 { intros A B. by rewrite /= -!assoc /= !fill_app. }
107117 { intros A. by rewrite /= -!assoc /= !fill_app. }
108118 { intros A. apply bunch_decomp_app. by econstructor. }
109119 * left. eexists; split; eauto.
110120 rewrite -assoc //.
111- + inversion HC0 ; simplify_eq/=.
121+ + inversion HΠ0 ; simplify_eq/=.
112122 * left. eexists; split; eauto.
113123 rewrite -assoc //.
114124 * right.
115- exists (λ A, (Π ++ [CtxSemicR A]) ++ C ).
116- exists (λ A, ([CtxSemicL (fill Π A)] ++ C )).
125+ exists (λ A, (Π1 ++ [CtxSemicR A]) ++ Π ).
126+ exists (λ A, ([CtxSemicL (fill Π1 A)] ++ Π )).
117127 repeat split.
118128 { intros A B. by rewrite /= -!assoc /= !fill_app. }
119129 { intros A. by rewrite /= -!assoc /= !fill_app. }
120130 { intros A. apply bunch_decomp_app. by econstructor. }
121- + inversion HC0 ; simplify_eq/=.
131+ + inversion HΠ0 ; simplify_eq/=.
122132 * right.
123- exists (λ A, (Π ++ [CtxSemicL A]) ++ C ).
124- exists (λ A, ([CtxSemicR (fill Π A)] ++ C )).
133+ exists (λ A, (Π1 ++ [CtxSemicL A]) ++ Π ).
134+ exists (λ A, ([CtxSemicR (fill Π1 A)] ++ Π )).
125135 repeat split.
126136 { intros A B. by rewrite /= -!assoc /= !fill_app. }
127137 { intros A. by rewrite /= -!assoc /= !fill_app. }
128138 { intros A. apply bunch_decomp_app. by econstructor. }
129139 * left. eexists; split; eauto.
130140 rewrite -assoc //.
131141 - right.
132- destruct IH as (C0 & C1 & HC0 & HC1 & HC ).
133- exists (λ A, C0 (fill_item F A)), (λ A, F::C1 A). repeat split.
134- { intros A B. simpl. rewrite -HC0 //. }
135- { intros B. rewrite -HC1 //. }
136- intros A. apply HC .
142+ destruct IH as (Π0 & Π1 & HΠ0 & HΠ1 & HΠ ).
143+ exists (λ A, Π0 (fill_item F A)), (λ A, F::Π1 A). repeat split.
144+ { intros A B. simpl. rewrite -HΠ0 //. }
145+ { intros B. rewrite -HΠ1 //. }
146+ intros A. apply HΠ .
137147Qed .
138148
139-
140- (* facts about terms *)
141149Lemma bterm_ctx_act_decomp `{!EqDecision V, !Countable V} (T : bterm V)
142150 (Δs : V → bunch) ϕ Π :
143151 linear_bterm T →
0 commit comments