Skip to content
Snippets Groups Projects
Commit f9bc9466 authored by Ralf Jung's avatar Ralf Jung
Browse files

generalize fixpoint from f^2 contractive to f^k contractive

parent f351a117
No related branches found
No related tags found
No related merge requests found
...@@ -261,44 +261,46 @@ Section fixpoint. ...@@ -261,44 +261,46 @@ Section fixpoint.
Qed. Qed.
End fixpoint. End fixpoint.
(** Fixpoint of f when f^2 is contractive. **) (** Fixpoint of f when f^k is contractive. **)
(* TODO: Generalize 2 to m. *) Definition fixpointK `{Cofe A, Inhabited A} k (f : A A)
Definition fixpoint2 `{Cofe A, Inhabited A} (f : A A) `{!Contractive (Nat.iter k f)} := fixpoint (Nat.iter k f).
`{!Contractive (Nat.iter 2 f)} := fixpoint (Nat.iter 2 f).
Section fixpoint2. Section fixpointK.
Local Set Default Proof Using "Type*". Local Set Default Proof Using "Type*".
Context `{Cofe A, Inhabited A} (f : A A) `{!Contractive (Nat.iter 2 f)}. Context `{Cofe A, Inhabited A} (f : A A) k `{!Contractive (Nat.iter k f)}.
(* TODO: Can we get rid of this assumption, derive it from contractivity? *) (* TODO: Can we get rid of this assumption, derive it from contractivity? *)
Context `{!∀ n, Proper (dist n ==> dist n) f}. Context `{!∀ n, Proper (dist n ==> dist n) f}.
Lemma fixpoint2_unfold : fixpoint2 f f (fixpoint2 f). Lemma fixpointK_unfold : fixpointK k f f (fixpointK k f).
Proof. Proof.
apply equiv_dist=>n. apply equiv_dist=>n.
rewrite /fixpoint2 fixpoint_eq /fixpoint_def (conv_compl n (fixpoint_chain _)) //. rewrite /fixpointK fixpoint_eq /fixpoint_def (conv_compl n (fixpoint_chain _)) //.
induction n as [|n IH]; simpl. induction n as [|n IH]; simpl.
- eapply contractive_0 with (f0 := Nat.iter 2 f). done. - rewrite -Nat_iter_S Nat_iter_S_r. eapply contractive_0; first done.
- eapply contractive_S with (f0 := Nat.iter 2 f); first done. eauto. - rewrite -[f _]Nat_iter_S Nat_iter_S_r. eapply contractive_S; first done. eauto.
Qed. Qed.
Lemma fixpoint2_unique (x : A) : x f x x fixpoint2 f. Lemma fixpointK_unique (x : A) : x f x x fixpointK k f.
Proof. Proof.
intros Hf. apply fixpoint_unique, equiv_dist=>n. eapply equiv_dist in Hf. intros Hf. apply fixpoint_unique, equiv_dist=>n.
rewrite 2!{1}Hf. done. (* Forward reasoning is so annoying... *)
assert (x {n} f x) by by apply equiv_dist.
clear Contractive0. induction k; first done. by rewrite {1}Hf {1}IHn0.
Qed. Qed.
Section fixpoint2_ne. Section fixpointK_ne.
Context (g : A A) `{!Contractive (Nat.iter 2 g), !∀ n, Proper (dist n ==> dist n) g}. Context (g : A A) `{!Contractive (Nat.iter k g), !∀ n, Proper (dist n ==> dist n) g}.
Lemma fixpoint2_ne n : ( z, f z {n} g z) fixpoint2 f {n} fixpoint2 g. Lemma fixpointK_ne n : ( z, f z {n} g z) fixpointK k f {n} fixpointK k g.
Proof. Proof.
rewrite /fixpoint2=>Hne /=. apply fixpoint_ne=>? /=. rewrite !Hne. done. rewrite /fixpointK=>Hne /=. apply fixpoint_ne=>? /=. clear Contractive0 Contractive1.
induction k; first by auto. simpl. rewrite IHn0. apply Hne.
Qed. Qed.
Lemma fixpoint2_proper : ( z, f z g z) fixpoint2 f fixpoint2 g. Lemma fixpointK_proper : ( z, f z g z) fixpointK k f fixpointK k g.
Proof. setoid_rewrite equiv_dist; naive_solver eauto using fixpoint2_ne. Qed. Proof. setoid_rewrite equiv_dist; naive_solver eauto using fixpointK_ne. Qed.
End fixpoint2_ne. End fixpointK_ne.
End fixpoint2. End fixpointK.
(** Mutual fixpoints *) (** Mutual fixpoints *)
Section fixpointAB. Section fixpointAB.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment