Skip to content
Snippets Groups Projects
Commit b22e6980 authored by Jacques-Henri Jourdan's avatar Jacques-Henri Jourdan
Browse files

Coinduction principle on fixpoints.

parent ef6de2f9
No related branches found
No related tags found
No related merge requests found
...@@ -231,6 +231,24 @@ Section fixpoint. ...@@ -231,6 +231,24 @@ Section fixpoint.
Lemma fixpoint_proper (g : A A) `{!Contractive g} : Lemma fixpoint_proper (g : A A) `{!Contractive g} :
( x, f x g x) fixpoint f fixpoint g. ( x, f x g x) fixpoint f fixpoint g.
Proof. setoid_rewrite equiv_dist; naive_solver eauto using fixpoint_ne. Qed. Proof. setoid_rewrite equiv_dist; naive_solver eauto using fixpoint_ne. Qed.
Lemma fixpoint_ind (P : A Prop) :
Proper (() ==> iff) P
( x, P x) ( x, P x P (f x))
( (c : chain A), ( n, P (c n)) P (compl c))
P (fixpoint f).
Proof.
intros ? [x Hx] Hincr Hlim. set (chcar i := Nat.iter (S i) f x).
assert (Hcauch : n i : nat, n i chcar i {n} chcar n).
{ intros n. induction n as [|n IH]=> -[|i] //= ?; try omega.
- apply (contractive_0 f).
- apply (contractive_S f), IH; auto with omega. }
set (fp2 := compl {| chain_cauchy := Hcauch |}).
rewrite -(fixpoint_unique fp2); first by apply Hlim; induction n; apply Hincr.
apply equiv_dist=>n.
rewrite /fp2 (conv_compl n) /= /chcar.
induction n as [|n IH]; simpl; eauto using contractive_0, contractive_S.
Qed.
End fixpoint. End fixpoint.
(** Mutual fixpoints *) (** Mutual fixpoints *)
...@@ -863,7 +881,7 @@ Section later. ...@@ -863,7 +881,7 @@ Section later.
Program Definition later_chain (c : chain laterC) : chain A := Program Definition later_chain (c : chain laterC) : chain A :=
{| chain_car n := later_car (c (S n)) |}. {| chain_car n := later_car (c (S n)) |}.
Next Obligation. intros c n i ?; apply (chain_cauchy c (S n)); lia. Qed. Next Obligation. intros c n i ?; apply (chain_cauchy c (S n)); lia. Qed.
Global Program Instance later_cofe `{Cofe A} : Cofe laterC := Global Program Instance later_cofe `{Cofe A} : Cofe laterC :=
{ compl c := Next (compl (later_chain c)) }. { compl c := Next (compl (later_chain c)) }.
Next Obligation. Next Obligation.
intros ? [|n] c; [done|by apply (conv_compl n (later_chain c))]. intros ? [|n] c; [done|by apply (conv_compl n (later_chain c))].
......
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