11/-
22Copyright (c) 2023 Mario Carneiro. All rights reserved.
33Released under Apache 2.0 license as described in the file LICENSE.
4- Authors: Mario Carneiro
4+ Authors: Mario Carneiro, Sebastian Graf
55-/
66module
77
@@ -1639,10 +1639,30 @@ def Fixpoint.chain [OFE α] [Inhabited α] (f : α → α) [Contractive f] : Cha
16391639 intro _ Hm
16401640 exact (IH H).le (Nat.le_of_lt_succ Hm)
16411641
1642+ /-- The chain construction of the Banach fixpoint. `fixpointP` packages it, together with
1643+ its unfolding equation, behind an opaque constant. -/
1644+ def fixpointAux [COFE α] [Inhabited α] (f : α → α) [Contractive f] : α :=
1645+ COFE.compl <| Fixpoint.chain f
1646+
1647+ theorem fixpointAux_unfold [COFE α] [Inhabited α] (f : α -c> α) :
1648+ fixpointAux f ≡ f (fixpointAux f) := by
1649+ refine equiv_dist.mpr fun n => ?_
1650+ apply COFE.conv_compl.trans
1651+ refine .trans ?_ (NonExpansive.ne COFE.conv_compl.symm)
1652+ induction n with
1653+ | zero => exact Contractive.zero f.f
1654+ | succ _ IH => exact (Contractive.succ f.f IH.symm).symm
1655+
1656+ /-- The Banach fixpoint packed together with its unfolding equation as a single opaque
1657+ value. Being opaque, it is a stuck constant for definitional-equality checks in both the
1658+ elaborator and the kernel, which keeps the approximation chain of `fixpointAux` sealed. -/
1659+ opaque fixpointP [COFE α] [Inhabited α] (f : α → α) [Contractive f] : { x : α // x ≡ f x } :=
1660+ ⟨fixpointAux f, fixpointAux_unfold f.toContractiveHom⟩
1661+
16421662/-- Fixpoints inside of a COFE -/
16431663@ [rocq_alias fixpoint]
16441664def fixpoint [COFE α] [Inhabited α] (f : α → α) [Contractive f] : α :=
1645- COFE.compl <| Fixpoint.chain f
1665+ (fixpointP f).val
16461666#rocq_ignore fixpoint_def "Use fixpoint"
16471667#rocq_ignore fixpoint_aux "Use fixpoint"
16481668#rocq_ignore fixpoint_unseal "fixpoint is unsealed by default"
@@ -1651,13 +1671,8 @@ nonrec abbrev OFE.ContractiveHom.fixpoint [COFE α] [Inhabited α] (f : α -c>
16511671
16521672@ [rocq_alias fixpoint_unfold]
16531673theorem fixpoint_unfold [COFE α] [Inhabited α] (f : α -c> α) :
1654- fixpoint f ≡ f (fixpoint f) := by
1655- refine equiv_dist.mpr fun n => ?_
1656- apply COFE.conv_compl.trans
1657- refine .trans ?_ (NonExpansive.ne COFE.conv_compl.symm)
1658- induction n with
1659- | zero => exact Contractive.zero f.f
1660- | succ _ IH => exact (Contractive.succ f.f IH.symm).symm
1674+ fixpoint f ≡ f (fixpoint f) :=
1675+ (fixpointP f).property
16611676
16621677@ [rocq_alias fixpoint_unique]
16631678theorem fixpoint_unique [COFE α] [Inhabited α] {f : α -c> α} {x : α} (H : x ≡ f x) :
@@ -1671,11 +1686,11 @@ theorem fixpoint_unique [COFE α] [Inhabited α] {f : α -c> α} {x : α} (H : x
16711686instance OFE.ContractiveHom.fixpoint_ne [COFE α] [Inhabited α] :
16721687 NonExpansive (ContractiveHom.fixpoint (α := α)) where
16731688 ne n f1 f2 H := by
1674- apply COFE.conv_compl.trans
1675- refine .trans ?_ COFE.conv_compl.symm
16761689 induction n with
1677- | zero => exact H _
1678- | succ _ IH => exact (H _).trans <| Contractive.succ _ <| IH <| Dist.lt H (Nat.lt_add_one _)
1690+ refine (fixpoint_unfold f1).dist.trans <|
1691+ ((H _).trans ?_).trans (fixpoint_unfold f2).dist.symm
1692+ | zero => exact Contractive.zero f2.f
1693+ | succ _ IH => exact Contractive.succ f2.f <| IH <| Dist.lt H (Nat.lt_add_one _)
16791694
16801695@ [elab_as_elim, rocq_alias fixpoint_ind]
16811696theorem OFE.ContractiveHom.fixpoint_ind [COFE α] [Inhabited α] (f : α -c> α)
0 commit comments