Skip to content

Commit e79e182

Browse files
committed
updated
1 parent 3d9ff2d commit e79e182

File tree

1 file changed

+160
-199
lines changed

1 file changed

+160
-199
lines changed

theories/PostsProblem/lowness.v

Lines changed: 160 additions & 199 deletions
Original file line numberDiff line numberDiff line change
@@ -84,225 +84,186 @@ Section Requirements_Meet.
8484

8585
Hypothesis wall_spec: forall e L n, φ (λ x, Dec (In x L)) e e n ≤ wall e L n.
8686

87+
Definition use := λ e n, φ (χ n) e e n.
88+
89+
Lemma eventally_greater_than_use_gen e:
90+
(∃ n, (∀ e', e' < e → ∀ n', n < n' → ¬ (recv_att wall) e' n')) →
91+
(∞∀ s, ∀ x, extendP (P_func s) s x → use e s < x).
92+
Proof.
93+
intros Hc. destruct Hc as [s Hs].
94+
exists (S s). intros m Hm x [e_ [He_ He_']].
95+
destruct (Dec (e_ < e)) as [E|E].
96+
{ exfalso. enough (recv_att wall e_ m).
97+
unshelve eapply (Hs e_ _ m); eauto; lia.
98+
split; first lia. destruct He_' as [H _].
99+
apply H. }
100+
assert (e ≤ e_) by lia; clear E.
101+
destruct He_', H1, H1, H1, H1, H3.
102+
specialize(H5 e H).
103+
enough (use e m <= wall e (P_func m) m) by lia.
104+
apply wall_spec.
105+
Qed.
106+
107+
Lemma eventally_greater_than_use_classically e:
108+
¬¬ (∞∀ s, ∀ x, extendP (P_func s) s x → use e s < x).
109+
Proof.
110+
intros H_. eapply (@recv_at_most_once_bound_classically wall e).
111+
intros H'. apply H_.
112+
by apply eventally_greater_than_use_gen.
113+
Qed.
87114

88115

89-
(*
90-
Lemma N_requirements e : (∞∀ n, P_Ω e n ↓) ∨ (∞∀ n, ¬ P_Ω e n ↓).
116+
Fact wall_convergence_gen e :
117+
(∃ N, (∀ s, N ≤ s → ∀ x, extendP (P_func s) s x → use e s < x)
118+
∧ pdec (∃ x, N ≤ x ∧ use e x ≠ 0)) ->
119+
(∃ b n: nat, ∀ m : nat, n ≤ m → use e m = b).
91120
Proof.
92-
destruct (@eventally_greater_than_wall e) as [N HN].
93-
assert (pdec (∃ k, N ≤ k ∧ P_Ω e k ↓)) as [[k [Hk HNk]]|H'] by (apply assume_Σ_1_lem; eauto).
94-
- left. exists k. intros n Hm.
95-
induction Hm; first done.
96-
unfold P_Ω, Ω, Φ_ in *.
97-
destruct (φ (χ m) e e m) eqn: E.
98-
{ eapply φ_spec0' in E. congruence. }
99-
(* Check φ_spec2. *)
100-
eapply (@φ_spec2 χ _ ); eauto.
101-
intros x Hx; split.
121+
intros (N & HN & Hp).
122+
assert (∀ m, dec (use e m = 0)) as HD by eauto.
123+
destruct Hp as [H'|H'].
124+
- enough (∃ x, N ≤ x ∧ use e x ≠ 0) as H''.
125+
clear H'. destruct H'' as [x [H1 H2]].
126+
destruct (use e x) as [|k] eqn: H; first done; clear H2.
127+
exists (S k), x. intros t Ht. induction Ht; first done.
128+
rewrite <- (@φ_spec1 χ _ _ _ _ IHHt).
129+
reflexivity.
130+
intros; split.
102131
+ intros K%Dec_true. apply Dec_auto.
103132
enough (incl (F_func (simple_extension wall) m) (F_func (simple_extension wall) (S m))).
104133
eauto. eapply F_mono; [apply F_func_correctness|apply F_func_correctness|lia].
105134
+ intros K%Dec_true. specialize (F_func_correctness (simple_extension wall) (S m)) as HE.
106135
inv HE.
107-
* assert (wall e (P_func m) m < a).
108-
{ eapply HN. lia. enough (P_func m = l) as ->. apply H2.
109-
eapply F_uni; [apply F_func_correctness|apply H1]. }
110-
assert (wall e (P_func m) m ≥ S n). {
111-
rewrite <-E. apply wall_spec. }
112-
destruct (Dec (a = x)).
113-
lia. apply Dec_auto. rewrite <- H0 in K.
136+
* assert (use e m < a).
137+
{ eapply HN. lia. enough (P_func m = l) as ->. apply H5.
138+
eapply F_uni; [apply F_func_correctness|apply H4]. }
139+
assert (wall e (P_func m) m ≥ S k). { rewrite <-IHHt.
140+
unfold use. unfold χ, the_priority_method.χ.
141+
specialize (wall_spec e (F_func (simple_extension wall) m) m).
142+
eapply wall_spec. }
143+
destruct (Dec (a = x0)).
144+
lia. apply Dec_auto. rewrite <- H3 in K.
114145
destruct K; first done.
115146
enough ((F_func (simple_extension wall) m) = l) as -> by done.
116-
eapply F_uni; last apply H1; apply F_func_correctness.
147+
eapply F_uni; last apply H4; apply F_func_correctness.
117148
* apply Dec_auto.
118149
enough (F_func (simple_extension wall) m = F_func (simple_extension wall) (S m)) as -> by eauto.
119150
eapply F_uni; first apply F_func_correctness.
120-
assumption.
121-
- right. exists N. intros m Hm.
122-
destruct (Dec (P_Ω e m ↓)); eauto.
123-
Qed. *)
124-
125-
126-
Definition use := λ e n, φ (χ n) e e n.
127-
128-
Lemma eventally_greater_than_use_gen e:
129-
(∃ n, (∀ e', e' < e → ∀ n', n < n' → ¬ (recv_att wall) e' n')) →
130-
(∞∀ s, ∀ x, extendP (P_func s) s x → use e s < x).
131-
Proof.
132-
intros Hc. destruct Hc as [s Hs].
133-
exists (S s). intros m Hm x [e_ [He_ He_']].
134-
destruct (Dec (e_ < e)) as [E|E].
135-
{ exfalso. enough (recv_att wall e_ m).
136-
unshelve eapply (Hs e_ _ m); eauto; lia.
137-
split; first lia. destruct He_' as [H _].
138-
apply H. }
139-
assert (e ≤ e_) by lia; clear E.
140-
destruct He_', H1, H1, H1, H1, H3.
141-
specialize(H5 e H).
142-
enough (use e m <= wall e (P_func m) m) by lia.
143-
apply wall_spec.
144-
Qed.
145-
146-
Lemma eventally_greater_than_use_classically e:
147-
¬¬ (∞∀ s, ∀ x, extendP (P_func s) s x → use e s < x).
148-
Proof.
149-
intros H_. eapply (@recv_at_most_once_bound_classically wall e).
150-
intros H'. apply H_.
151-
by apply eventally_greater_than_use_gen.
152-
Qed.
153-
154-
155-
Fact wall_convergence_gen e :
156-
(∃ N, (∀ s, N ≤ s → ∀ x, extendP (P_func s) s x → use e s < x)
157-
∧ pdec (∃ x, N ≤ x ∧ use e x ≠ 0)) ->
158-
(∃ b n: nat, ∀ m : nat, n ≤ m → use e m = b).
159-
Proof.
160-
intros (N & HN & Hp).
161-
assert (∀ m, dec (use e m = 0)) as HD by eauto.
162-
destruct Hp as [H'|H'].
163-
- enough (∃ x, N ≤ x ∧ use e x ≠ 0) as H''.
164-
clear H'. destruct H'' as [x [H1 H2]].
165-
destruct (use e x) as [|k] eqn: H; first done; clear H2.
166-
exists (S k), x. intros t Ht. induction Ht; first done.
167-
rewrite <- (@φ_spec1 χ _ _ _ _ IHHt).
168-
reflexivity.
169-
intros; split.
170-
+ intros K%Dec_true. apply Dec_auto.
171-
enough (incl (F_func (simple_extension wall) m) (F_func (simple_extension wall) (S m))).
172-
eauto. eapply F_mono; [apply F_func_correctness|apply F_func_correctness|lia].
173-
+ intros K%Dec_true. specialize (F_func_correctness (simple_extension wall) (S m)) as HE.
174-
inv HE.
175-
* assert (use e m < a).
176-
{ eapply HN. lia. enough (P_func m = l) as ->. apply H5.
177-
eapply F_uni; [apply F_func_correctness|apply H4]. }
178-
assert (wall e (P_func m) m ≥ S k). { rewrite <-IHHt.
179-
unfold use. unfold χ, the_priority_method.χ.
180-
specialize (wall_spec e (F_func (simple_extension wall) m) m).
181-
eapply wall_spec. }
182-
destruct (Dec (a = x0)).
183-
lia. apply Dec_auto. rewrite <- H3 in K.
184-
destruct K; first done.
185-
enough ((F_func (simple_extension wall) m) = l) as -> by done.
186-
eapply F_uni; last apply H4; apply F_func_correctness.
187-
* apply Dec_auto.
188-
enough (F_func (simple_extension wall) m = F_func (simple_extension wall) (S m)) as -> by eauto.
189-
eapply F_uni; first apply F_func_correctness.
190-
assumption.
191-
+ apply H'.
192-
- exists 0. exists N. intros.
193-
destruct (use e m) eqn: E; first done.
194-
exfalso. apply H'. exists m. split; first done.
195-
congruence.
196-
Qed.
197-
198-
199-
Fact wall_convergence_classically e : ¬¬ ∃ b n: nat, ∀ m : nat, n ≤ m → use e m = b.
200-
Proof.
201-
intros H. eapply (eventally_greater_than_use_classically). intros [N HN].
202-
assert (¬¬ pdec (∃ x, N ≤ x ∧ use e x ≠ 0)).
203-
{ ccase (∃ x, N ≤ x ∧ use e x ≠ 0) as [H_|H'_]; eauto.
204-
- intros Hp. apply Hp. left. done.
205-
- intros Hp. apply Hp. right. done. }
206-
apply H0. intros H0'.
207-
apply H, wall_convergence_gen.
208-
exists N; eauto.
209-
Qed.
151+
assumption.
152+
+ apply H'.
153+
- exists 0. exists N. intros.
154+
destruct (use e m) eqn: E; first done.
155+
exfalso. apply H'. exists m. split; first done.
156+
congruence.
157+
Qed.
210158

211-
Hypothesis Σ_1_lem: LEM_Σ 1.
212159

213-
Lemma attention_bound:
214-
∀ k, ∃ s, ∀ e, e < k → ∀ s', s < s' → ~ recv_att wall e s'.
215-
Proof. by apply recv_at_most_once_bound. Qed.
160+
Fact wall_convergence_classically e : ¬¬ ∃ b n: nat, ∀ m : nat, n ≤ m → use e m = b.
161+
Proof.
162+
intros H. eapply (eventally_greater_than_use_classically). intros [N HN].
163+
assert (¬¬ pdec (∃ x, N ≤ x ∧ use e x ≠ 0)).
164+
{ ccase (∃ x, N ≤ x ∧ use e x ≠ 0) as [H_|H'_]; eauto.
165+
- intros Hp. apply Hp. left. done.
166+
- intros Hp. apply Hp. right. done. }
167+
apply H0. intros H0'.
168+
apply H, wall_convergence_gen.
169+
exists N; eauto.
170+
Qed.
216171

217-
Lemma eventally_greater_than_use e:
218-
(∞∀ s, ∀ x, extendP (P_func s) s x → use e s < x).
219-
Proof. apply eventally_greater_than_use_gen, attention_bound. Qed.
172+
Hypothesis Σ_1_lem: LEM_Σ 1.
220173

221-
Fact wall_convergence e : ∃ b n: nat, ∀ m : nat, n ≤ m → use e m = b.
222-
Proof.
223-
apply wall_convergence_gen.
224-
destruct (eventally_greater_than_use e) as [N HN].
225-
exists N. split; first done.
226-
destruct level1 as (_&h2&_).
227-
rewrite h2 in Σ_1_lem.
228-
unfold principles.LPO in *.
229-
destruct (@Σ_1_lem (λ x, Dec (N ≤ x ∧ use e x ≠ 0))) as [[N' HN']|].
230-
left. exists N'. eauto.
231-
right. intros [x Hx]. apply H. exists x. eauto.
232-
Qed.
174+
Lemma attention_bound:
175+
∀ k, ∃ s, ∀ e, e < k → ∀ s', s < s' → ~ recv_att wall e s'.
176+
Proof. by apply recv_at_most_once_bound. Qed.
233177

234-
Corollary N_requirements e : ((∞∀ n, P_Ω e n ↓) ∨ (∞∀ n, ¬ P_Ω e n ↓)).
235-
Proof.
236-
destruct (wall_convergence e) as (b&n&Hn).
237-
destruct b.
238-
- right. exists n. intros.
239-
enough(P_Ω e m = None) by congruence.
240-
unfold P_Ω, Ω.
241-
apply φ_spec0'.
242-
by apply Hn.
243-
- left. exists n. intros.
244-
unfold P_Ω, Ω.
245-
apply φ_spec0_1.
246-
unfold use in Hn.
247-
by rewrite (Hn m H).
248-
Qed.
178+
Lemma eventally_greater_than_use e:
179+
(∞∀ s, ∀ x, extendP (P_func s) s x → use e s < x).
180+
Proof. apply eventally_greater_than_use_gen, attention_bound. Qed.
249181

250-
Lemma eventally_greater_than_wall e:
251-
(∞∀ s, ∀ x, extendP (P_func s) s x → wall e (P_func s) s < x).
252-
Proof.
253-
destruct (@attention_bound (S e)) as [s Hs].
254-
exists (S s). intros m Hm x [e_ [He_ He_']].
255-
destruct (Dec (e_ < e)) as [E|E].
256-
{ exfalso. enough (recv_att wall e_ m).
257-
unshelve eapply (Hs e_ _ m); eauto; lia.
258-
split; first lia. destruct He_' as [H _].
259-
apply H. }
260-
assert (e ≤ e_) by lia; clear E.
261-
destruct He_', H1, H1, H1, H1, H3.
262-
by eapply H5.
263-
Qed.
264-
265-
Lemma step_ex_spec: ∀ e, (∞∃ n, P_Ω e n ↓) → Ξ e (char_rel P) e.
266-
Proof.
267-
intros e He.
268-
destruct (eventally_greater_than_wall e) as [N HN].
269-
destruct (wall_convergence e) as [B [b Hb]].
270-
set (M := max N b). destruct (He M) as [k [Hk Hk']].
271-
eapply (@φ_spec χ e e k); first apply Hk'.
272-
intros x Hx. unfold P, simpleness.P.
273-
rewrite F_with_top. split.
274-
- intros (L & m & HL & HLs &HP).
275-
assert (L = P_func m) as E. { eapply F_uni. apply HL. apply F_func_correctness. }
276-
assert (x::L = P_func (S m)) as E'. { eapply F_uni. apply HLs. apply F_func_correctness. }
277-
apply Dec_auto. destruct (Dec (S m ≤ k)) as [E_|E_].
278-
enough (incl (P_func (S m)) (P_func k)). rewrite <-E' in H.
279-
eauto. eapply F_mono; last apply E_; apply F_func_correctness.
280-
assert (N ≤ m) as Em by lia. rewrite E in HP. specialize (HN m Em x HP).
281-
assert (k ≤ m) as Ek by lia.
282-
enough (x ≤ φ (χ m) e e m).
283-
exfalso. assert (φ (χ m) e e m < x).
284-
assert(φ (χ m) e e m ≤ wall e (P_func m) m).
285-
{ specialize (wall_spec e (F_func (simple_extension wall) m) m).
286-
unfold χ, the_priority_method.χ.
287-
by rewrite wall_spec. }
288-
lia.
289-
enough (φ (χ m) e e m = φ (χ k) e e k) by lia.
290-
assert (φ (χ m) e e m = B).
291-
{ rewrite <- (Hb m). reflexivity. lia. }
292-
assert (φ (χ k) e e k = B).
293-
{ rewrite <- (Hb k). reflexivity. lia. }
182+
Fact wall_convergence e : ∃ b n: nat, ∀ m : nat, n ≤ m → use e m = b.
183+
Proof.
184+
apply wall_convergence_gen.
185+
destruct (eventally_greater_than_use e) as [N HN].
186+
exists N. split; first done.
187+
destruct level1 as (_&h2&_).
188+
rewrite h2 in Σ_1_lem.
189+
unfold principles.LPO in *.
190+
destruct (@Σ_1_lem (λ x, Dec (N ≤ x ∧ use e x ≠ 0))) as [[N' HN']|].
191+
left. exists N'. eauto.
192+
right. intros [x Hx]. apply H. exists x. eauto.
193+
Qed.
194+
195+
Corollary N_requirements e : ((∞∀ n, P_Ω e n ↓) ∨ (∞∀ n, ¬ P_Ω e n ↓)).
196+
Proof.
197+
destruct (wall_convergence e) as (b&n&Hn).
198+
destruct b.
199+
- right. exists n. intros.
200+
enough(P_Ω e m = None) by congruence.
201+
unfold P_Ω, Ω.
202+
apply φ_spec0'.
203+
by apply Hn.
204+
- left. exists n. intros.
205+
unfold P_Ω, Ω.
206+
apply φ_spec0_1.
207+
unfold use in Hn.
208+
by rewrite (Hn m H).
209+
Qed.
210+
211+
Lemma eventally_greater_than_wall e:
212+
(∞∀ s, ∀ x, extendP (P_func s) s x → wall e (P_func s) s < x).
213+
Proof.
214+
destruct (@attention_bound (S e)) as [s Hs].
215+
exists (S s). intros m Hm x [e_ [He_ He_']].
216+
destruct (Dec (e_ < e)) as [E|E].
217+
{ exfalso. enough (recv_att wall e_ m).
218+
unshelve eapply (Hs e_ _ m); eauto; lia.
219+
split; first lia. destruct He_' as [H _].
220+
apply H. }
221+
assert (e ≤ e_) by lia; clear E.
222+
destruct He_', H1, H1, H1, H1, H3.
223+
by eapply H5.
224+
Qed.
225+
226+
Lemma step_ex_spec: ∀ e, (∞∃ n, P_Ω e n ↓) → Ξ e (char_rel P) e.
227+
Proof.
228+
intros e He.
229+
destruct (eventally_greater_than_wall e) as [N HN].
230+
destruct (wall_convergence e) as [B [b Hb]].
231+
set (M := max N b). destruct (He M) as [k [Hk Hk']].
232+
eapply (@φ_spec χ e e k); first apply Hk'.
233+
intros x Hx. unfold P, simpleness.P.
234+
rewrite F_with_top. split.
235+
- intros (L & m & HL & HLs &HP).
236+
assert (L = P_func m) as E. { eapply F_uni. apply HL. apply F_func_correctness. }
237+
assert (x::L = P_func (S m)) as E'. { eapply F_uni. apply HLs. apply F_func_correctness. }
238+
apply Dec_auto. destruct (Dec (S m ≤ k)) as [E_|E_].
239+
enough (incl (P_func (S m)) (P_func k)). rewrite <-E' in H.
240+
eauto. eapply F_mono; last apply E_; apply F_func_correctness.
241+
assert (N ≤ m) as Em by lia. rewrite E in HP. specialize (HN m Em x HP).
242+
assert (k ≤ m) as Ek by lia.
243+
enough (x ≤ φ (χ m) e e m).
244+
exfalso. assert (φ (χ m) e e m < x).
245+
assert(φ (χ m) e e m ≤ wall e (P_func m) m).
246+
{ specialize (wall_spec e (F_func (simple_extension wall) m) m).
247+
unfold χ, the_priority_method.χ.
248+
by rewrite wall_spec. }
249+
lia.
250+
enough (φ (χ m) e e m = φ (χ k) e e k) by lia.
251+
assert (φ (χ m) e e m = B).
252+
{ rewrite <- (Hb m). reflexivity. lia. }
253+
assert (φ (χ k) e e k = B).
254+
{ rewrite <- (Hb k). reflexivity. lia. }
255+
lia.
256+
enough (φ (χ m) e e m = φ (χ k) e e k) by lia.
257+
assert (φ (χ m) e e m = B).
258+
{ rewrite <- (Hb m). reflexivity. lia. }
259+
assert (φ (χ k) e e k = B).
260+
{ rewrite <- (Hb k). reflexivity. lia. }
294261
lia.
295-
enough (φ (χ m) e e m = φ (χ k) e e k) by lia.
296-
assert (φ (χ m) e e m = B).
297-
{ rewrite <- (Hb m). reflexivity. lia. }
298-
assert (φ (χ k) e e k = B).
299-
{ rewrite <- (Hb k). reflexivity. lia. }
300-
lia.
301-
- intros H%Dec_true.
302-
eapply F_with_top.
303-
exists (F_func _ k), k; split; eauto.
304-
eapply F_func_correctness.
305-
Qed.
262+
- intros H%Dec_true.
263+
eapply F_with_top.
264+
exists (F_func _ k), k; split; eauto.
265+
eapply F_func_correctness.
266+
Qed.
306267

307268
End wall_greater_than_use.
308269

0 commit comments

Comments
 (0)