data.qpf.multivariate.constructions.cofix
⟷
Mathlib.Data.QPF.Multivariate.Constructions.Cofix
The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(last sync)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -4,9 +4,9 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Simon Hudon
-/
import Control.Functor.Multivariate
-import Data.Pfunctor.Multivariate.Basic
-import Data.Pfunctor.Multivariate.M
-import Data.Qpf.Multivariate.Basic
+import Data.PFunctor.Multivariate.Basic
+import Data.PFunctor.Multivariate.M
+import Data.QPF.Multivariate.Basic
#align_import data.qpf.multivariate.constructions.cofix from "leanprover-community/mathlib"@"1a51edf13debfcbe223fa06b1cb353b9ed9751cc"
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -463,7 +463,7 @@ theorem liftR_map_last' [LawfulMvFunctor F] {α : TypeVec n} {ι} (R : ι → ι
(f : ι → ι) (hh : ∀ x : ι, R (f x) x) : LiftR' (RelLast' _ R) ((id ::: f) <$$> x) x :=
by
have := liftr_map_last R x f id hh
- rwa [append_fun_id_id, MvFunctor.id_map] at this
+ rwa [append_fun_id_id, MvFunctor.id_map] at this
#align mvqpf.liftr_map_last' MvQPF.liftR_map_last'
-/
@@ -475,7 +475,7 @@ theorem Cofix.abs_repr {α} (x : Cofix F α) : Quot.mk _ (Cofix.repr x) = x :=
by
let R := fun x y : cofix F α => cofix.abs (cofix.repr y) = x
refine' cofix.bisim₂ R _ _ _ rfl
- clear x; rintro x y h; dsimp [R] at h ; subst h
+ clear x; rintro x y h; dsimp [R] at h; subst h
dsimp [cofix.dest, cofix.abs]
induction y using Quot.ind
simp only [cofix.repr, M.dest_corec, abs_map, abs_repr]
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,10 +3,10 @@ Copyright (c) 2018 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Simon Hudon
-/
-import Mathbin.Control.Functor.Multivariate
-import Mathbin.Data.Pfunctor.Multivariate.Basic
-import Mathbin.Data.Pfunctor.Multivariate.M
-import Mathbin.Data.Qpf.Multivariate.Basic
+import Control.Functor.Multivariate
+import Data.Pfunctor.Multivariate.Basic
+import Data.Pfunctor.Multivariate.M
+import Data.Qpf.Multivariate.Basic
#align_import data.qpf.multivariate.constructions.cofix from "leanprover-community/mathlib"@"1a51edf13debfcbe223fa06b1cb353b9ed9751cc"
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,17 +2,14 @@
Copyright (c) 2018 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Simon Hudon
-
-! This file was ported from Lean 3 source module data.qpf.multivariate.constructions.cofix
-! leanprover-community/mathlib commit 1a51edf13debfcbe223fa06b1cb353b9ed9751cc
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Control.Functor.Multivariate
import Mathbin.Data.Pfunctor.Multivariate.Basic
import Mathbin.Data.Pfunctor.Multivariate.M
import Mathbin.Data.Qpf.Multivariate.Basic
+#align_import data.qpf.multivariate.constructions.cofix from "leanprover-community/mathlib"@"1a51edf13debfcbe223fa06b1cb353b9ed9751cc"
+
/-!
# The final co-algebra of a multivariate qpf is again a qpf.
mathlib commit https://github.com/leanprover-community/mathlib/commit/1a51edf13debfcbe223fa06b1cb353b9ed9751cc
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Simon Hudon
! This file was ported from Lean 3 source module data.qpf.multivariate.constructions.cofix
-! leanprover-community/mathlib commit f694c7dead66f5d4c80f446c796a5aad14707f0e
+! leanprover-community/mathlib commit 1a51edf13debfcbe223fa06b1cb353b9ed9751cc
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -16,6 +16,9 @@ import Mathbin.Data.Qpf.Multivariate.Basic
/-!
# The final co-algebra of a multivariate qpf is again a qpf.
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
For a `(n+1)`-ary QPF `F (α₀,..,αₙ)`, we take the least fixed point of `F` with
regards to its last argument `αₙ`. The result is a `n`-ary functor: `fix F (α₀,..,αₙ₋₁)`.
Making `fix F` into a functor allows us to take the fixed point, compose with other functors
mathlib commit https://github.com/leanprover-community/mathlib/commit/9240e8be927a0955b9a82c6c85ef499ee3a626b8
@@ -56,18 +56,23 @@ open MvFunctor (Liftp Liftr)
variable {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [MvFunctor F] [q : MvQPF F]
+#print MvQPF.corecF /-
/-- `corecF` is used as a basis for defining the corecursor of `cofix F α`. `corecF`
uses corecursion to construct the M-type generated by `q.P` and uses function on `F`
as a corecursive step -/
def corecF {α : TypeVec n} {β : Type _} (g : β → F (α.append1 β)) : β → q.p.M α :=
M.corec _ fun x => repr (g x)
#align mvqpf.corecF MvQPF.corecF
+-/
+#print MvQPF.corecF_eq /-
theorem corecF_eq {α : TypeVec n} {β : Type _} (g : β → F (α.append1 β)) (x : β) :
M.dest q.p (corecF g x) = appendFun id (corecF g) <$$> repr (g x) := by
rw [corecF, M.dest_corec]
#align mvqpf.corecF_eq MvQPF.corecF_eq
+-/
+#print MvQPF.IsPrecongr /-
/-- Characterization of desirable equivalence relations on M-types -/
def IsPrecongr {α : TypeVec n} (r : q.p.M α → q.p.M α → Prop) : Prop :=
∀ ⦃x y⦄,
@@ -75,12 +80,16 @@ def IsPrecongr {α : TypeVec n} (r : q.p.M α → q.p.M α → Prop) : Prop :=
abs (appendFun id (Quot.mk r) <$$> M.dest q.p x) =
abs (appendFun id (Quot.mk r) <$$> M.dest q.p y)
#align mvqpf.is_precongr MvQPF.IsPrecongr
+-/
+#print MvQPF.Mcongr /-
/-- Equivalence relation on M-types representing a value of type `cofix F` -/
def Mcongr {α : TypeVec n} (x y : q.p.M α) : Prop :=
∃ r, IsPrecongr r ∧ r x y
#align mvqpf.Mcongr MvQPF.Mcongr
+-/
+#print MvQPF.Cofix /-
/-- Greatest fixed point of functor F. The result is a functor with one fewer parameters
than the input. For `F a b c` a ternary functor, fix F is a binary functor such that
@@ -91,16 +100,20 @@ cofix F a b = F a b (cofix F a b)
def Cofix (F : TypeVec (n + 1) → Type u) [MvFunctor F] [q : MvQPF F] (α : TypeVec n) :=
Quot (@Mcongr _ F _ q α)
#align mvqpf.cofix MvQPF.Cofix
+-/
instance {α : TypeVec n} [Inhabited q.p.A] [∀ i : Fin2 n, Inhabited (α i)] :
Inhabited (Cofix F α) :=
⟨Quot.mk _ default⟩
+#print MvQPF.mRepr /-
/-- maps every element of the W type to a canonical representative -/
-def mrepr {α : TypeVec n} : q.p.M α → q.p.M α :=
+def mRepr {α : TypeVec n} : q.p.M α → q.p.M α :=
corecF (abs ∘ M.dest q.p)
-#align mvqpf.Mrepr MvQPF.mrepr
+#align mvqpf.Mrepr MvQPF.mRepr
+-/
+#print MvQPF.Cofix.map /-
/-- the map function for the functor `cofix F` -/
def Cofix.map {α β : TypeVec n} (g : α ⟹ β) : Cofix F α → Cofix F β :=
Quot.lift (fun x : q.p.M α => Quot.mk Mcongr (g <$$> x))
@@ -119,15 +132,21 @@ def Cofix.map {α β : TypeVec n} (g : α ⟹ β) : Cofix F α → Cofix F β :=
rw [q.P.comp_map, q.P.comp_map, abs_map, pr ra₁a₂, ← abs_map]
show r' (g <$$> aa₁) (g <$$> aa₂); exact ⟨aa₁, aa₂, ra₁a₂, rfl, rfl⟩)
#align mvqpf.cofix.map MvQPF.Cofix.map
+-/
+#print MvQPF.Cofix.mvfunctor /-
instance Cofix.mvfunctor : MvFunctor (Cofix F) where map := @Cofix.map _ _ _ _
#align mvqpf.cofix.mvfunctor MvQPF.Cofix.mvfunctor
+-/
+#print MvQPF.Cofix.corec /-
/-- Corecursor for `cofix F` -/
def Cofix.corec {α : TypeVec n} {β : Type u} (g : β → F (α.append1 β)) : β → Cofix F α := fun x =>
Quot.mk _ (corecF g x)
#align mvqpf.cofix.corec MvQPF.Cofix.corec
+-/
+#print MvQPF.Cofix.dest /-
/-- Destructor for `cofix F` -/
def Cofix.dest {α : TypeVec n} : Cofix F α → F (α.append1 (Cofix F α)) :=
Quot.lift (fun x => appendFun id (Quot.mk Mcongr) <$$> abs (M.dest q.p x))
@@ -140,26 +159,34 @@ def Cofix.dest {α : TypeVec n} : Cofix F α → F (α.append1 (Cofix F α)) :=
rw [append_fun_comp_id, comp_map, ← abs_map, pr rxy, abs_map, ← comp_map, ←
append_fun_comp_id])
#align mvqpf.cofix.dest MvQPF.Cofix.dest
+-/
+#print MvQPF.Cofix.abs /-
/-- Abstraction function for `cofix F α` -/
def Cofix.abs {α} : q.p.M α → Cofix F α :=
Quot.mk _
#align mvqpf.cofix.abs MvQPF.Cofix.abs
+-/
+#print MvQPF.Cofix.repr /-
/-- Representation function for `cofix F α` -/
def Cofix.repr {α} : Cofix F α → q.p.M α :=
M.corec _ <| repr ∘ Cofix.dest
#align mvqpf.cofix.repr MvQPF.Cofix.repr
+-/
+#print MvQPF.Cofix.corec'₁ /-
/-- Corecursor for `cofix F` -/
def Cofix.corec'₁ {α : TypeVec n} {β : Type u} (g : ∀ {X}, (β → X) → F (α.append1 X)) (x : β) :
Cofix F α :=
Cofix.corec (fun x => g id) x
#align mvqpf.cofix.corec'₁ MvQPF.Cofix.corec'₁
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print MvQPF.Cofix.corec' /-
/-- More flexible corecursor for `cofix F`. Allows the return of a fully formed
value instead of making a recursive call -/
def Cofix.corec' {α : TypeVec n} {β : Type u} (g : β → F (α.append1 (Sum (Cofix F α) β))) (x : β) :
@@ -167,15 +194,19 @@ def Cofix.corec' {α : TypeVec n} {β : Type u} (g : β → F (α.append1 (Sum (
let f : (α ::: Cofix F α) ⟹ (α ::: Sum (Cofix F α) β) := id ::: Sum.inl
Cofix.corec (Sum.elim (MvFunctor.map f ∘ Cofix.dest) g) (Sum.inr x : Sum (Cofix F α) β)
#align mvqpf.cofix.corec' MvQPF.Cofix.corec'
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print MvQPF.Cofix.corec₁ /-
/-- Corecursor for `cofix F`. The shape allows recursive calls to
look like recursive calls. -/
def Cofix.corec₁ {α : TypeVec n} {β : Type u}
(g : ∀ {X}, (Cofix F α → X) → (β → X) → β → F (α ::: X)) (x : β) : Cofix F α :=
Cofix.corec' (fun x => g Sum.inl Sum.inr x) x
#align mvqpf.cofix.corec₁ MvQPF.Cofix.corec₁
+-/
+#print MvQPF.Cofix.dest_corec /-
theorem Cofix.dest_corec {α : TypeVec n} {β : Type u} (g : β → F (α.append1 β)) (x : β) :
Cofix.dest (Cofix.corec g x) = appendFun id (Cofix.corec g) <$$> g x :=
by
@@ -185,11 +216,14 @@ theorem Cofix.dest_corec {α : TypeVec n} {β : Type u} (g : β → F (α.append
dsimp
rw [corecF_eq, abs_map, abs_repr, ← comp_map, ← append_fun_comp]; rfl
#align mvqpf.cofix.dest_corec MvQPF.Cofix.dest_corec
+-/
+#print MvQPF.Cofix.mk /-
/-- constructor for `cofix F` -/
def Cofix.mk {α : TypeVec n} : F (α.append1 <| Cofix F α) → Cofix F α :=
Cofix.corec fun x => (appendFun id fun i : Cofix F α => Cofix.dest.{u} i) <$$> x
#align mvqpf.cofix.mk MvQPF.Cofix.mk
+-/
/-!
## Bisimulation principles for `cofix F`
@@ -237,6 +271,7 @@ private theorem cofix.bisim_aux {α : TypeVec n} (r : Cofix F α → Cofix F α
h₀]
refine' ⟨r', this, rxy⟩
+#print MvQPF.Cofix.bisim_rel /-
/-- Bisimulation principle using `map` and `quot.mk` to match and relate children of two trees. -/
theorem Cofix.bisim_rel {α : TypeVec n} (r : Cofix F α → Cofix F α → Prop)
(h :
@@ -258,7 +293,9 @@ theorem Cofix.bisim_rel {α : TypeVec n} (r : Cofix F α → Cofix F α → Prop
rw [h _ _ r'xy]
right; exact rxy
#align mvqpf.cofix.bisim_rel MvQPF.Cofix.bisim_rel
+-/
+#print MvQPF.Cofix.bisim /-
/-- Bisimulation principle using `liftr` to match and relate children of two trees. -/
theorem Cofix.bisim {α : TypeVec n} (r : Cofix F α → Cofix F α → Prop)
(h : ∀ x y, r x y → LiftR (RelLast α r) (Cofix.dest x) (Cofix.dest y)) : ∀ x y, r x y → x = y :=
@@ -274,16 +311,20 @@ theorem Cofix.bisim {α : TypeVec n} (r : Cofix F α → Cofix F α → Prop)
· apply Quot.sound; apply h' _ j
· change f₀ _ j = f₁ _ j; apply h' _ j
#align mvqpf.cofix.bisim MvQPF.Cofix.bisim
+-/
open MvFunctor
+#print MvQPF.Cofix.bisim₂ /-
/-- Bisimulation principle using `liftr'` to match and relate children of two trees. -/
theorem Cofix.bisim₂ {α : TypeVec n} (r : Cofix F α → Cofix F α → Prop)
(h : ∀ x y, r x y → LiftR' (RelLast' α r) (Cofix.dest x) (Cofix.dest y)) :
∀ x y, r x y → x = y :=
Cofix.bisim _ <| by intros <;> rw [← liftr_last_rel_iff] <;> apply h <;> assumption
#align mvqpf.cofix.bisim₂ MvQPF.Cofix.bisim₂
+-/
+#print MvQPF.Cofix.bisim' /-
/-- Bisimulation principle the values `⟨a,f⟩` of the polynomial functor representing
`cofix F α` as well as an invariant `Q : β → Prop` and a state `β` generating the
left-hand side and right-hand side of the equality through functions `u v : β → cofix F α` -/
@@ -310,7 +351,9 @@ theorem Cofix.bisim' {α : TypeVec n} {β : Type _} (Q : β → Prop) (u v : β
· intro j; apply Eq.refl)
_ _ ⟨x, Qx, rfl, rfl⟩
#align mvqpf.cofix.bisim' MvQPF.Cofix.bisim'
+-/
+#print MvQPF.Cofix.mk_dest /-
theorem Cofix.mk_dest {α : TypeVec n} (x : Cofix F α) : Cofix.mk (Cofix.dest x) = x :=
by
apply cofix.bisim_rel (fun x y : cofix F α => x = cofix.mk (cofix.dest y)) _ _ _ rfl; dsimp
@@ -325,7 +368,9 @@ theorem Cofix.mk_dest {α : TypeVec n} (x : Cofix F α) : Cofix.mk (Cofix.dest x
rw [← comp_map, ← append_fun_comp, id_comp, ← cofix.mk]
congr 2 with u; apply Quot.sound; rfl
#align mvqpf.cofix.mk_dest MvQPF.Cofix.mk_dest
+-/
+#print MvQPF.Cofix.dest_mk /-
theorem Cofix.dest_mk {α : TypeVec n} (x : F (α.append1 <| Cofix F α)) :
Cofix.dest (Cofix.mk x) = x :=
by
@@ -333,15 +378,20 @@ theorem Cofix.dest_mk {α : TypeVec n} (x : F (α.append1 <| Cofix F α)) :
rw [cofix.mk, cofix.dest_corec, ← comp_map, ← cofix.mk, ← append_fun_comp, this, id_comp,
append_fun_id_id, MvFunctor.id_map]
#align mvqpf.cofix.dest_mk MvQPF.Cofix.dest_mk
+-/
+#print MvQPF.Cofix.ext /-
theorem Cofix.ext {α : TypeVec n} (x y : Cofix F α) (h : x.dest = y.dest) : x = y := by
rw [← cofix.mk_dest x, h, cofix.mk_dest]
#align mvqpf.cofix.ext MvQPF.Cofix.ext
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print MvQPF.Cofix.ext_mk /-
theorem Cofix.ext_mk {α : TypeVec n} (x y : F (α ::: Cofix F α)) (h : Cofix.mk x = Cofix.mk y) :
x = y := by rw [← cofix.dest_mk x, h, cofix.dest_mk]
#align mvqpf.cofix.ext_mk MvQPF.Cofix.ext_mk
+-/
/-!
`liftr_map`, `liftr_map_last` and `liftr_map_last'` are useful for reasoning about
@@ -351,7 +401,8 @@ the induction step in bisimulation proofs.
section LiftrMap
-theorem liftr_map {α β : TypeVec n} {F' : TypeVec n → Type u} [MvFunctor F'] [LawfulMvFunctor F']
+#print MvQPF.liftR_map /-
+theorem liftR_map {α β : TypeVec n} {F' : TypeVec n → Type u} [MvFunctor F'] [LawfulMvFunctor F']
(R : β ⊗ β ⟹ repeat n Prop) (x : F' α) (f g : α ⟹ β) (h : α ⟹ Subtype_ R)
(hh : subtypeVal _ ⊚ h = (f ⊗' g) ⊚ prod.diag) : LiftR' R (f <$$> x) (g <$$> x) :=
by
@@ -360,7 +411,8 @@ theorem liftr_map {α β : TypeVec n} {F' : TypeVec n → Type u} [MvFunctor F']
rw [MvFunctor.map_map, comp_assoc, hh, ← comp_assoc, fst_prod_mk, comp_assoc, fst_diag]
rw [MvFunctor.map_map, comp_assoc, hh, ← comp_assoc, snd_prod_mk, comp_assoc, snd_diag]
dsimp [liftr']; constructor <;> rfl
-#align mvqpf.liftr_map MvQPF.liftr_map
+#align mvqpf.liftr_map MvQPF.liftR_map
+-/
open Function
@@ -374,7 +426,8 @@ open Function
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem liftr_map_last [LawfulMvFunctor F] {α : TypeVec n} {ι ι'} (R : ι' → ι' → Prop)
+#print MvQPF.liftR_map_last /-
+theorem liftR_map_last [LawfulMvFunctor F] {α : TypeVec n} {ι ι'} (R : ι' → ι' → Prop)
(x : F (α ::: ι)) (f g : ι → ι') (hh : ∀ x : ι, R (f x) (g x)) :
LiftR' (RelLast' _ R) ((id ::: f) <$$> x) ((id ::: g) <$$> x) :=
let h : ι → { x : ι' × ι' // uncurry R x } := fun x => ⟨(f x, g x), hh x⟩
@@ -399,21 +452,25 @@ theorem liftr_map_last [LawfulMvFunctor F] {α : TypeVec n} {ι ι'} (R : ι'
simp only [h, last_fun_from_append1_drop_last, last_fun_to_subtype, last_fun_append_fun,
last_fun_subtype_val, comp.left_id, last_fun_comp, last_fun_prod]
dsimp; ext1; rfl
- liftr_map _ _ _ _ (toSubtype _ ⊚ fromAppend1DropLast ⊚ c ⊚ b) hh
-#align mvqpf.liftr_map_last MvQPF.liftr_map_last
+ liftR_map _ _ _ _ (toSubtype _ ⊚ fromAppend1DropLast ⊚ c ⊚ b) hh
+#align mvqpf.liftr_map_last MvQPF.liftR_map_last
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem liftr_map_last' [LawfulMvFunctor F] {α : TypeVec n} {ι} (R : ι → ι → Prop) (x : F (α ::: ι))
+#print MvQPF.liftR_map_last' /-
+theorem liftR_map_last' [LawfulMvFunctor F] {α : TypeVec n} {ι} (R : ι → ι → Prop) (x : F (α ::: ι))
(f : ι → ι) (hh : ∀ x : ι, R (f x) x) : LiftR' (RelLast' _ R) ((id ::: f) <$$> x) x :=
by
have := liftr_map_last R x f id hh
rwa [append_fun_id_id, MvFunctor.id_map] at this
-#align mvqpf.liftr_map_last' MvQPF.liftr_map_last'
+#align mvqpf.liftr_map_last' MvQPF.liftR_map_last'
+-/
end LiftrMap
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print MvQPF.Cofix.abs_repr /-
theorem Cofix.abs_repr {α} (x : Cofix F α) : Quot.mk _ (Cofix.repr x) = x :=
by
let R := fun x y : cofix F α => cofix.abs (cofix.repr y) = x
@@ -442,6 +499,7 @@ theorem Cofix.abs_repr {α} (x : Cofix F α) : Quot.mk _ (Cofix.repr x) = x :=
dsimp [rel_last', split_fun, Function.uncurry, R]
rfl
#align mvqpf.cofix.abs_repr MvQPF.Cofix.abs_repr
+-/
section Tactic
@@ -483,6 +541,7 @@ end Tactic
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print MvQPF.corec_roll /-
theorem corec_roll {α : TypeVec n} {X Y} {x₀ : X} (f : X → Y) (g : Y → F (α ::: X)) :
Cofix.corec (g ∘ f) x₀ = Cofix.corec (MvFunctor.map (id ::: f) ∘ g) (f x₀) :=
by
@@ -492,7 +551,9 @@ theorem corec_roll {α : TypeVec n} {X Y} {x₀ : X} (f : X → Y) (g : Y → F
refine' liftr_map_last _ _ _ _ _
intro a; refine' ⟨a, rfl, rfl⟩
#align mvqpf.corec_roll MvQPF.corec_roll
+-/
+#print MvQPF.Cofix.dest_corec' /-
theorem Cofix.dest_corec' {α : TypeVec n} {β : Type u} (g : β → F (α.append1 (Sum (Cofix F α) β)))
(x : β) :
Cofix.dest (Cofix.corec' g x) = appendFun id (Sum.elim id (Cofix.corec' g)) <$$> g x :=
@@ -505,8 +566,10 @@ theorem Cofix.dest_corec' {α : TypeVec n} {β : Type u} (g : β → F (α.appen
apply liftr_map_last'; dsimp [(· ∘ ·), R]; intros; exact ⟨_, rfl, rfl⟩
· congr with y; erw [append_fun_id_id]; simp [MvFunctor.id_map]
#align mvqpf.cofix.dest_corec' MvQPF.Cofix.dest_corec'
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print MvQPF.Cofix.dest_corec₁ /-
theorem Cofix.dest_corec₁ {α : TypeVec n} {β : Type u}
(g : ∀ {X}, (Cofix F α → X) → (β → X) → β → F (α.append1 X)) (x : β)
(h :
@@ -515,7 +578,9 @@ theorem Cofix.dest_corec₁ {α : TypeVec n} {β : Type u}
Cofix.dest (Cofix.corec₁ (@g) x) = g id (Cofix.corec₁ @g) x := by
rw [cofix.corec₁, cofix.dest_corec', ← h] <;> rfl
#align mvqpf.cofix.dest_corec₁ MvQPF.Cofix.dest_corec₁
+-/
+#print MvQPF.mvqpfCofix /-
instance mvqpfCofix : MvQPF (Cofix F) where
p := q.p.mp
abs α := Quot.mk Mcongr
@@ -523,6 +588,7 @@ instance mvqpfCofix : MvQPF (Cofix F) where
abs_repr α := Cofix.abs_repr
abs_map α β g x := rfl
#align mvqpf.mvqpf_cofix MvQPF.mvqpfCofix
+-/
end MvQPF
mathlib commit https://github.com/leanprover-community/mathlib/commit/2a0ce625dbb0ffbc7d1316597de0b25c1ec75303
@@ -394,7 +394,7 @@ theorem liftr_map_last [LawfulMvFunctor F] {α : TypeVec n} {ι ι'} (R : ι'
drop_fun_to_subtype]
erw [to_subtype_of_subtype_assoc, id_comp]
clear * -
- ext (i x) : 2; induction i
+ ext i x : 2; induction i
rfl; apply i_ih
simp only [h, last_fun_from_append1_drop_last, last_fun_to_subtype, last_fun_append_fun,
last_fun_subtype_val, comp.left_id, last_fun_comp, last_fun_prod]
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -56,8 +56,6 @@ open MvFunctor (Liftp Liftr)
variable {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [MvFunctor F] [q : MvQPF F]
-include q
-
/-- `corecF` is used as a basis for defining the corecursor of `cofix F α`. `corecF`
uses corecursion to construct the M-type generated by `q.P` and uses function on `F`
as a corecursive step -/
@@ -353,8 +351,6 @@ the induction step in bisimulation proofs.
section LiftrMap
-omit q
-
theorem liftr_map {α β : TypeVec n} {F' : TypeVec n → Type u} [MvFunctor F'] [LawfulMvFunctor F']
(R : β ⊗ β ⟹ repeat n Prop) (x : F' α) (f g : α ⟹ β) (h : α ⟹ Subtype_ R)
(hh : subtypeVal _ ⊚ h = (f ⊗' g) ⊚ prod.diag) : LiftR' R (f <$$> x) (g <$$> x) :=
@@ -452,8 +448,6 @@ section Tactic
/- ./././Mathport/Syntax/Translate/Tactic/Mathlib/Core.lean:38:34: unsupported: setup_tactic_parser -/
open Tactic
-omit q
-
/-- tactic for proof by bisimulation -/
unsafe def mv_bisim (e : parse texpr) (ids : parse with_ident_list) : tactic Unit := do
let e ← to_expr e
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -412,7 +412,7 @@ theorem liftr_map_last' [LawfulMvFunctor F] {α : TypeVec n} {ι} (R : ι → ι
(f : ι → ι) (hh : ∀ x : ι, R (f x) x) : LiftR' (RelLast' _ R) ((id ::: f) <$$> x) x :=
by
have := liftr_map_last R x f id hh
- rwa [append_fun_id_id, MvFunctor.id_map] at this
+ rwa [append_fun_id_id, MvFunctor.id_map] at this
#align mvqpf.liftr_map_last' MvQPF.liftr_map_last'
end LiftrMap
@@ -422,7 +422,7 @@ theorem Cofix.abs_repr {α} (x : Cofix F α) : Quot.mk _ (Cofix.repr x) = x :=
by
let R := fun x y : cofix F α => cofix.abs (cofix.repr y) = x
refine' cofix.bisim₂ R _ _ _ rfl
- clear x; rintro x y h; dsimp [R] at h; subst h
+ clear x; rintro x y h; dsimp [R] at h ; subst h
dsimp [cofix.dest, cofix.abs]
induction y using Quot.ind
simp only [cofix.repr, M.dest_corec, abs_map, abs_repr]
@@ -508,7 +508,7 @@ theorem Cofix.dest_corec' {α : TypeVec n} {β : Type u} (g : β → F (α.appen
· mv_bisim i
rw [Ha, Hb, cofix.dest_corec]; dsimp [(· ∘ ·)]
repeat' rw [MvFunctor.map_map, ← append_fun_comp_id]
- apply liftr_map_last'; dsimp [(· ∘ ·), R]; intros ; exact ⟨_, rfl, rfl⟩
+ apply liftr_map_last'; dsimp [(· ∘ ·), R]; intros; exact ⟨_, rfl, rfl⟩
· congr with y; erw [append_fun_id_id]; simp [MvFunctor.id_map]
#align mvqpf.cofix.dest_corec' MvQPF.Cofix.dest_corec'
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -46,7 +46,7 @@ We define the relation `Mcongr` and take its quotient as the definition of `cofi
universe u
-open MvFunctor
+open scoped MvFunctor
namespace MvQPF
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -114,14 +114,8 @@ def Cofix.map {α β : TypeVec n} (g : α ⟹ β) : Cofix F α → Cofix F β :=
rintro b₁ b₂ ⟨a₁, a₂, ra₁a₂, b₁eq, b₂eq⟩
let u : Quot r → Quot r' :=
Quot.lift (fun x : q.P.M α => Quot.mk r' (g <$$> x))
- (by
- intro a₁ a₂ ra₁a₂
- apply Quot.sound
- exact ⟨a₁, a₂, ra₁a₂, rfl, rfl⟩)
- have hu : (Quot.mk r' ∘ fun x : q.P.M α => g <$$> x) = u ∘ Quot.mk r :=
- by
- ext x
- rfl
+ (by intro a₁ a₂ ra₁a₂; apply Quot.sound; exact ⟨a₁, a₂, ra₁a₂, rfl, rfl⟩)
+ have hu : (Quot.mk r' ∘ fun x : q.P.M α => g <$$> x) = u ∘ Quot.mk r := by ext x; rfl
rw [b₁eq, b₂eq, M.dest_map, M.dest_map, ← q.P.comp_map, ← q.P.comp_map]
rw [← append_fun_comp, id_comp, hu, hu, ← comp_id g, append_fun_comp]
rw [q.P.comp_map, q.P.comp_map, abs_map, pr ra₁a₂, ← abs_map]
@@ -140,13 +134,9 @@ def Cofix.corec {α : TypeVec n} {β : Type u} (g : β → F (α.append1 β)) :
def Cofix.dest {α : TypeVec n} : Cofix F α → F (α.append1 (Cofix F α)) :=
Quot.lift (fun x => appendFun id (Quot.mk Mcongr) <$$> abs (M.dest q.p x))
(by
- rintro x y ⟨r, pr, rxy⟩
- dsimp
- have : ∀ x y, r x y → Mcongr x y := by
- intro x y h
- exact ⟨r, pr, h⟩
- rw [← Quot.factor_mk_eq _ _ this]
- dsimp
+ rintro x y ⟨r, pr, rxy⟩; dsimp
+ have : ∀ x y, r x y → Mcongr x y := by intro x y h; exact ⟨r, pr, h⟩
+ rw [← Quot.factor_mk_eq _ _ this]; dsimp
conv =>
lhs
rw [append_fun_comp_id, comp_map, ← abs_map, pr rxy, abs_map, ← comp_map, ←
@@ -225,12 +215,8 @@ private theorem cofix.bisim_aux {α : TypeVec n} (r : Cofix F α → Cofix F α
r x y →
appendFun id (Quot.mk r) <$$> Cofix.dest x = appendFun id (Quot.mk r) <$$> Cofix.dest y) :
∀ x y, r x y → x = y := by
- intro x
- apply Quot.inductionOn x
- clear x
- intro x y
- apply Quot.inductionOn y
- clear y
+ intro x; apply Quot.inductionOn x; clear x
+ intro x y; apply Quot.inductionOn y; clear y
intro y rxy
apply Quot.sound
let r' x y := r (Quot.mk _ x) (Quot.mk _ y)
@@ -240,13 +226,8 @@ private theorem cofix.bisim_aux {α : TypeVec n} (r : Cofix F α → Cofix F α
append_fun id (Quot.mk r ∘ Quot.mk Mcongr) <$$> abs (M.dest q.P a) =
append_fun id (Quot.mk r ∘ Quot.mk Mcongr) <$$> abs (M.dest q.P b) :=
by rw [append_fun_comp_id, comp_map, comp_map] <;> exact h _ _ r'ab
- have h₁ : ∀ u v : q.P.M α, Mcongr u v → Quot.mk r' u = Quot.mk r' v :=
- by
- intro u v cuv
- apply Quot.sound
- dsimp [r']
- rw [Quot.sound cuv]
- apply h'
+ have h₁ : ∀ u v : q.P.M α, Mcongr u v → Quot.mk r' u = Quot.mk r' v := by intro u v cuv;
+ apply Quot.sound; dsimp [r']; rw [Quot.sound cuv]; apply h'
let f : Quot r → Quot r' :=
Quot.lift (Quot.lift (Quot.mk r') h₁)
(by
@@ -268,15 +249,11 @@ theorem Cofix.bisim_rel {α : TypeVec n} (r : Cofix F α → Cofix F α → Prop
let r' (x y) := x = y ∨ r x y
intro x y rxy
apply cofix.bisim_aux r'
- · intro x
- left
- rfl
+ · intro x; left; rfl
· intro x y r'xy
- cases r'xy
- · rw [r'xy]
+ cases r'xy; · rw [r'xy]
have : ∀ x y, r x y → r' x y := fun x y h => Or.inr h
- rw [← Quot.factor_mk_eq _ _ this]
- dsimp
+ rw [← Quot.factor_mk_eq _ _ this]; dsimp
rw [append_fun_comp_id, append_fun_comp_id]
rw [@comp_map _ _ _ q _ _ _ (append_fun id (Quot.mk r)),
@comp_map _ _ _ q _ _ _ (append_fun id (Quot.mk r))]
@@ -296,10 +273,8 @@ theorem Cofix.bisim {α : TypeVec n} (r : Cofix F α → Cofix F α → Prop)
rw [append_fun_comp_split_fun, append_fun_comp_split_fun]
rw [id_comp, id_comp]
congr 2 with (i j); cases' i with _ i <;> dsimp
- · apply Quot.sound
- apply h' _ j
- · change f₀ _ j = f₁ _ j
- apply h' _ j
+ · apply Quot.sound; apply h' _ j
+ · change f₀ _ j = f₁ _ j; apply h' _ j
#align mvqpf.cofix.bisim MvQPF.Cofix.bisim
open MvFunctor
@@ -334,8 +309,7 @@ theorem Cofix.bisim' {α : TypeVec n} {β : Type _} (Q : β → Prop) (u v : β
yeq.symm ▸ vx'eq, _⟩
intro i; cases i
· apply h'
- · intro j
- apply Eq.refl)
+ · intro j; apply Eq.refl)
_ _ ⟨x, Qx, rfl, rfl⟩
#align mvqpf.cofix.bisim' MvQPF.Cofix.bisim'
@@ -424,15 +398,11 @@ theorem liftr_map_last [LawfulMvFunctor F] {α : TypeVec n} {ι ι'} (R : ι'
drop_fun_to_subtype]
erw [to_subtype_of_subtype_assoc, id_comp]
clear * -
- ext (i x) : 2
- induction i
- rfl
- apply i_ih
+ ext (i x) : 2; induction i
+ rfl; apply i_ih
simp only [h, last_fun_from_append1_drop_last, last_fun_to_subtype, last_fun_append_fun,
last_fun_subtype_val, comp.left_id, last_fun_comp, last_fun_prod]
- dsimp
- ext1
- rfl
+ dsimp; ext1; rfl
liftr_map _ _ _ _ (toSubtype _ ⊚ fromAppend1DropLast ⊚ c ⊚ b) hh
#align mvqpf.liftr_map_last MvQPF.liftr_map_last
@@ -466,8 +436,7 @@ theorem Cofix.abs_repr {α} (x : Cofix F α) : Quot.mk _ (Cofix.repr x) = x :=
refine' liftr_map _ _ _ _ f _
· simp only [← append_prod_append_fun, prod_map_id]
apply eq_of_drop_last_eq
- · dsimp
- simp only [drop_fun_diag]
+ · dsimp; simp only [drop_fun_diag]
erw [subtype_val_diag_sub]
ext1
simp only [cofix.abs, Prod.mk.inj_iff, Prod_map, Function.comp_apply, last_fun_append_fun,
@@ -537,16 +506,10 @@ theorem Cofix.dest_corec' {α : TypeVec n} {β : Type u} (g : β → F (α.appen
rw [cofix.corec', cofix.dest_corec]; dsimp
congr with (i | i) <;> rw [corec_roll] <;> dsimp [cofix.corec']
· mv_bisim i
- rw [Ha, Hb, cofix.dest_corec]
- dsimp [(· ∘ ·)]
+ rw [Ha, Hb, cofix.dest_corec]; dsimp [(· ∘ ·)]
repeat' rw [MvFunctor.map_map, ← append_fun_comp_id]
- apply liftr_map_last'
- dsimp [(· ∘ ·), R]
- intros
- exact ⟨_, rfl, rfl⟩
- · congr with y
- erw [append_fun_id_id]
- simp [MvFunctor.id_map]
+ apply liftr_map_last'; dsimp [(· ∘ ·), R]; intros ; exact ⟨_, rfl, rfl⟩
+ · congr with y; erw [append_fun_id_id]; simp [MvFunctor.id_map]
#align mvqpf.cofix.dest_corec' MvQPF.Cofix.dest_corec'
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -257,7 +257,6 @@ private theorem cofix.bisim_aux {α : TypeVec n} (r : Cofix F α → Cofix F α
rw [← this, append_fun_comp_id, q.P.comp_map, q.P.comp_map, abs_map, abs_map, abs_map, abs_map,
h₀]
refine' ⟨r', this, rxy⟩
-#align mvqpf.cofix.bisim_aux mvqpf.cofix.bisim_aux
/-- Bisimulation principle using `map` and `quot.mk` to match and relate children of two trees. -/
theorem Cofix.bisim_rel {α : TypeVec n} (r : Cofix F α → Cofix F α → Prop)
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
@@ -232,7 +232,7 @@ private theorem Cofix.bisim_aux {α : TypeVec n} (r : Cofix F α → Cofix F α
have h₁ : ∀ u v : q.P.M α, Mcongr u v → Quot.mk r' u = Quot.mk r' v := by
intro u v cuv
apply Quot.sound
- dsimp [hr']
+ dsimp [r', hr']
rw [Quot.sound cuv]
apply h'
let f : Quot r → Quot r' :=
@@ -272,7 +272,7 @@ theorem Cofix.bisim_rel {α : TypeVec n} (r : Cofix F α → Cofix F α → Prop
| inr r'xy =>
have : ∀ x y, r x y → r' x y := fun x y h => Or.inr h
rw [← Quot.factor_mk_eq _ _ this]
- dsimp
+ dsimp [r']
rw [appendFun_comp_id]
rw [@comp_map _ _ _ q _ _ _ (appendFun id (Quot.mk r)),
@comp_map _ _ _ q _ _ _ (appendFun id (Quot.mk r))]
@@ -400,7 +400,7 @@ theorem liftR_map_last [lawful : LawfulMvFunctor F]
have hh :
subtypeVal _ ⊚ toSubtype _ ⊚ fromAppend1DropLast ⊚ c ⊚ b =
((id ::: f) ⊗' (id ::: g)) ⊚ prod.diag := by
- dsimp
+ dsimp [b]
apply eq_of_drop_last_eq
· dsimp
simp only [prod_map_id, dropFun_prod, dropFun_appendFun, dropFun_diag, TypeVec.id_comp,
refine
s (#10762)
I replaced a few "terminal" refine/refine'
s with exact
.
The strategy was very simple-minded: essentially any refine
whose following line had smaller indentation got replaced by exact
and then I cleaned up the mess.
This PR certainly leaves some further terminal refine
s, but maybe the current change is beneficial.
@@ -252,7 +252,7 @@ private theorem Cofix.bisim_aux {α : TypeVec n} (r : Cofix F α → Cofix F α
have : f ∘ Quot.mk r ∘ Quot.mk Mcongr = Quot.mk r' := rfl
rw [← this, appendFun_comp_id, q.P.comp_map, q.P.comp_map, abs_map, abs_map, abs_map, abs_map,
h₀]
- refine' ⟨r', this, rxy⟩
+ exact ⟨r', this, rxy⟩
/-- Bisimulation principle using `map` and `Quot.mk` to match and relate children of two trees. -/
theorem Cofix.bisim_rel {α : TypeVec n} (r : Cofix F α → Cofix F α → Prop)
Function.left_id
and Function.comp.left_id
into Function.id_comp
.Function.right_id
and Function.comp.right_id
into Function.comp_id
.Function.comp_const_right
and Function.comp_const
into Function.comp_const
, use explicit arguments.Function.const_comp
to Mathlib.Init.Function
, use explicit arguments.@@ -403,9 +403,9 @@ theorem liftR_map_last [lawful : LawfulMvFunctor F]
dsimp
apply eq_of_drop_last_eq
· dsimp
- simp only [prod_map_id, dropFun_prod, dropFun_appendFun, dropFun_diag, id_comp,
+ simp only [prod_map_id, dropFun_prod, dropFun_appendFun, dropFun_diag, TypeVec.id_comp,
dropFun_toSubtype]
- erw [toSubtype_of_subtype_assoc, id_comp]
+ erw [toSubtype_of_subtype_assoc, TypeVec.id_comp]
clear liftR_map_last q mvf lawful F x R f g hh h b c
ext (i x) : 2
induction i with
@@ -413,7 +413,7 @@ theorem liftR_map_last [lawful : LawfulMvFunctor F]
| fs _ ih =>
apply ih
simp only [lastFun_from_append1_drop_last, lastFun_toSubtype, lastFun_appendFun,
- lastFun_subtypeVal, comp.left_id, lastFun_comp, lastFun_prod]
+ lastFun_subtypeVal, Function.id_comp, lastFun_comp, lastFun_prod]
ext1
rfl
liftR_map _ _ _ _ (toSubtype _ ⊚ fromAppend1DropLast ⊚ c ⊚ b) hh
cases x with | ...
instead of cases x; case => ...
(#9321)
This converts usages of the pattern
cases h
case inl h' => ...
case inr h' => ...
which derive from mathported code, to the "structured cases
" syntax:
cases h with
| inl h' => ...
| inr h' => ...
The case where the subgoals are handled with ·
instead of case
is more contentious (and much more numerous) so I left those alone. This pattern also appears with cases'
, induction
, induction'
, and rcases
. Furthermore, there is a similar transformation for by_cases
:
by_cases h : cond
case pos => ...
case neg => ...
is replaced by:
if h : cond then
...
else
...
Co-authored-by: Mario Carneiro <di.gama@gmail.com>
@@ -266,10 +266,10 @@ theorem Cofix.bisim_rel {α : TypeVec n} (r : Cofix F α → Cofix F α → Prop
left
rfl
· intro x y r'xy
- cases r'xy
- case inl h =>
+ cases r'xy with
+ | inl h =>
rw [h]
- case inr r'xy =>
+ | inr r'xy =>
have : ∀ x y, r x y → r' x y := fun x y h => Or.inr h
rw [← Quot.factor_mk_eq _ _ this]
dsimp
@@ -442,7 +442,7 @@ theorem Cofix.abs_repr {α} (x : Cofix F α) : Quot.mk _ (Cofix.repr x) = x := b
congr
rfl
rw [Cofix.dest]
- rw [MvFunctor.map_map, MvFunctor.map_map, ←appendFun_comp_id, ←appendFun_comp_id]
+ rw [MvFunctor.map_map, MvFunctor.map_map, ← appendFun_comp_id, ← appendFun_comp_id]
apply liftR_map_last
intros
rfl
This is the supremum of
along with some minor fixes from failures on nightly-testing as Mathlib master
is merged into it.
Note that some PRs for changes that are already compatible with the current toolchain and will be necessary have already been split out: #8380.
I am hopeful that in future we will be able to progressively merge adaptation PRs into a bump/v4.X.0
branch, so we never end up with a "big merge" like this. However one of these adaptation PRs (#8056) predates my new scheme for combined CI, and it wasn't possible to keep that PR viable in the meantime.
In particular this includes adjustments for the Lean PRs
We can get rid of all the
local macro_rules | `($x ^ $y) => `(HPow.hPow $x $y) -- Porting note: See issue [lean4#2220](https://github.com/leanprover/lean4/pull/2220)
macros across Mathlib (and in any projects that want to write natural number powers of reals).
Changes the default behaviour of simp
to (config := {decide := false})
. This makes simp
(and consequentially norm_num
) less powerful, but also more consistent, and less likely to blow up in long failures. This requires a variety of changes: changing some previously by simp
or norm_num
to decide
or rfl
, or adding (config := {decide := true})
.
This changed the behaviour of simp
so that simp [f]
will only unfold "fully applied" occurrences of f
. The old behaviour can be recovered with simp (config := { unfoldPartialApp := true })
. We may in future add a syntax for this, e.g. simp [!f]
; please provide feedback! In the meantime, we have made the following changes:
(config := { unfoldPartialApp := true })
in some places, to recover the old behaviour@[eqns]
to manually adjust the equation lemmas for a particular definition, recovering the old behaviour just for that definition. See #8371, where we do this for Function.comp
and Function.flip
.This change in Lean may require further changes down the line (e.g. adding the !f
syntax, and/or upstreaming the special treatment for Function.comp
and Function.flip
, and/or removing this special treatment). Please keep an open and skeptical mind about these changes!
Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Mauricio Collares <mauricio@collares.org>
@@ -534,10 +534,10 @@ theorem Cofix.dest_corec' {α : TypeVec.{u} n} {β : Type u}
congr!; ext (i | i) <;> erw [corec_roll] <;> dsimp [Cofix.corec']
· mv_bisim i with R a b x Ha Hb
rw [Ha, Hb, Cofix.dest_corec]
- dsimp [Function.comp]
+ dsimp [Function.comp_def]
repeat rw [MvFunctor.map_map, ← appendFun_comp_id]
apply liftR_map_last'
- dsimp [Function.comp]
+ dsimp [Function.comp_def]
intros
exact ⟨_, rfl, rfl⟩
· congr with y
@@ -387,7 +387,7 @@ theorem liftR_map {α β : TypeVec n} {F' : TypeVec n → Type u} [MvFunctor F']
open Function
-theorem liftR_map_last [lawful: LawfulMvFunctor F]
+theorem liftR_map_last [lawful : LawfulMvFunctor F]
{α : TypeVec n} {ι ι'} (R : ι' → ι' → Prop)
(x : F (α ::: ι)) (f g : ι → ι') (hh : ∀ x : ι, R (f x) (g x)) :
LiftR' (RelLast' _ R) ((id ::: f) <$$> x) ((id ::: g) <$$> x) :=
@@ -168,10 +168,10 @@ def Cofix.corec'₁ {α : TypeVec n} {β : Type u} (g : ∀ {X}, (β → X) →
/-- More flexible corecursor for `Cofix F`. Allows the return of a fully formed
value instead of making a recursive call -/
-def Cofix.corec' {α : TypeVec n} {β : Type u} (g : β → F (α.append1 (Sum (Cofix F α) β))) (x : β) :
+def Cofix.corec' {α : TypeVec n} {β : Type u} (g : β → F (α.append1 (Cofix F α ⊕ β))) (x : β) :
Cofix F α :=
- let f : (α ::: Cofix F α) ⟹ (α ::: Sum (Cofix F α) β) := id ::: Sum.inl
- Cofix.corec (Sum.elim (MvFunctor.map f ∘ Cofix.dest) g) (Sum.inr x : Sum (Cofix F α) β)
+ let f : (α ::: Cofix F α) ⟹ (α ::: (Cofix F α ⊕ β)) := id ::: Sum.inl
+ Cofix.corec (Sum.elim (MvFunctor.map f ∘ Cofix.dest) g) (Sum.inr x : Cofix F α ⊕ β)
#align mvqpf.cofix.corec' MvQPF.Cofix.corec'
/-- Corecursor for `Cofix F`. The shape allows recursive calls to
@@ -527,7 +527,7 @@ theorem corec_roll {α : TypeVec n} {X Y} {x₀ : X} (f : X → Y) (g : Y → F
#align mvqpf.corec_roll MvQPF.corec_roll
theorem Cofix.dest_corec' {α : TypeVec.{u} n} {β : Type u}
- (g : β → F (α.append1 (Sum (Cofix F α) β))) (x : β) :
+ (g : β → F (α.append1 (Cofix F α ⊕ β))) (x : β) :
Cofix.dest (Cofix.corec' g x) =
appendFun id (Sum.elim _root_.id (Cofix.corec' g)) <$$> g x := by
rw [Cofix.corec', Cofix.dest_corec]; dsimp
Type _
before the colon (#7718)
We have turned to Type*
instead of Type _
, but many of them remained in mathlib because the straight replacement did not work. In general, having Type _
before the colon is a code smell, though, as it hides which types should be in the same universe and which shouldn't, and is not very robust.
This PR replaces most of the remaining Type _
before the colon (except those in category theory) by Type*
or Type u
. This has uncovered a few bugs (where declarations were not as polymorphic as they should be).
I had to increase heartbeats at two places when replacing Type _
by Type*
, but I think it's worth it as it's really more robust.
@@ -56,12 +56,12 @@ variable {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [mvf : MvFunctor F] [q :
/-- `corecF` is used as a basis for defining the corecursor of `Cofix F α`. `corecF`
uses corecursion to construct the M-type generated by `q.P` and uses function on `F`
as a corecursive step -/
-def corecF {α : TypeVec n} {β : Type _} (g : β → F (α.append1 β)) : β → q.P.M α :=
+def corecF {α : TypeVec n} {β : Type u} (g : β → F (α.append1 β)) : β → q.P.M α :=
M.corec _ fun x => repr (g x)
set_option linter.uppercaseLean3 false in
#align mvqpf.corecF MvQPF.corecF
-theorem corecF_eq {α : TypeVec n} {β : Type _} (g : β → F (α.append1 β)) (x : β) :
+theorem corecF_eq {α : TypeVec n} {β : Type u} (g : β → F (α.append1 β)) (x : β) :
M.dest q.P (corecF g x) = appendFun id (corecF g) <$$> repr (g x) := by
rw [corecF, M.dest_corec]
set_option linter.uppercaseLean3 false in
@@ -282,7 +282,7 @@ theorem Cofix.bisim_rel {α : TypeVec n} (r : Cofix F α → Cofix F α → Prop
/-- Bisimulation principle using `LiftR` to match and relate children of two trees. -/
theorem Cofix.bisim {α : TypeVec n} (r : Cofix F α → Cofix F α → Prop)
- (h : ∀ x y, r x y → LiftR (RelLast α r (i:=_)) (Cofix.dest x) (Cofix.dest y)) :
+ (h : ∀ x y, r x y → LiftR (RelLast α r (i := _)) (Cofix.dest x) (Cofix.dest y)) :
∀ x y, r x y → x = y := by
apply Cofix.bisim_rel
intro x y rxy
@@ -222,7 +222,7 @@ private theorem Cofix.bisim_aux {α : TypeVec n} (r : Cofix F α → Cofix F α
intro rxy
apply Quot.sound
let r' := fun x y => r (Quot.mk _ x) (Quot.mk _ y)
- have hr' : r' = fun x y => r (Quot.mk _ x) (Quot.mk _ y) := by rfl
+ have hr' : r' = fun x y => r (Quot.mk _ x) (Quot.mk _ y) := rfl
have : IsPrecongr r' := by
intro a b r'ab
have h₀ :
@@ -144,7 +144,6 @@ def Cofix.dest {α : TypeVec n} : Cofix F α → F (α.append1 (Cofix F α)) :=
intro x y h
exact ⟨r, pr, h⟩
rw [← Quot.factor_mk_eq _ _ this]
- dsimp
conv =>
lhs
rw [appendFun_comp_id, comp_map, ← abs_map, pr rxy, abs_map, ← comp_map,
@@ -415,7 +414,6 @@ theorem liftR_map_last [lawful: LawfulMvFunctor F]
apply ih
simp only [lastFun_from_append1_drop_last, lastFun_toSubtype, lastFun_appendFun,
lastFun_subtypeVal, comp.left_id, lastFun_comp, lastFun_prod]
- dsimp
ext1
rfl
liftR_map _ _ _ _ (toSubtype _ ⊚ fromAppend1DropLast ⊚ c ⊚ b) hh
Type _
and Sort _
(#6499)
We remove all possible occurences of Type _
and Sort _
in favor of Type*
and Sort*
.
This has nice performance benefits.
@@ -312,7 +312,7 @@ theorem Cofix.bisim₂ {α : TypeVec n} (r : Cofix F α → Cofix F α → Prop)
/-- Bisimulation principle the values `⟨a,f⟩` of the polynomial functor representing
`Cofix F α` as well as an invariant `Q : β → Prop` and a state `β` generating the
left-hand side and right-hand side of the equality through functions `u v : β → Cofix F α` -/
-theorem Cofix.bisim' {α : TypeVec n} {β : Type _} (Q : β → Prop) (u v : β → Cofix F α)
+theorem Cofix.bisim' {α : TypeVec n} {β : Type*} (Q : β → Prop) (u v : β → Cofix F α)
(h : ∀ x, Q x → ∃ a f' f₀ f₁,
Cofix.dest (u x) = q.abs ⟨a, q.P.appendContents f' f₀⟩ ∧
Cofix.dest (v x) = q.abs ⟨a, q.P.appendContents f' f₁⟩ ∧
@@ -14,7 +14,7 @@ import Mathlib.Data.QPF.Multivariate.Basic
# The final co-algebra of a multivariate qpf is again a qpf.
For a `(n+1)`-ary QPF `F (α₀,..,αₙ)`, we take the least fixed point of `F` with
-regards to its last argument `αₙ`. The result is a `n`-ary functor: `Fix F (α₀,..,αₙ₋₁)`.
+regards to its last argument `αₙ`. The result is an `n`-ary functor: `Fix F (α₀,..,αₙ₋₁)`.
Making `Fix F` into a functor allows us to take the fixed point, compose with other functors
and take a fixed point again.
@@ -2,17 +2,14 @@
Copyright (c) 2018 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Simon Hudon
-
-! This file was ported from Lean 3 source module data.qpf.multivariate.constructions.cofix
-! leanprover-community/mathlib commit f694c7dead66f5d4c80f446c796a5aad14707f0e
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.Control.Functor.Multivariate
import Mathlib.Data.PFunctor.Multivariate.Basic
import Mathlib.Data.PFunctor.Multivariate.M
import Mathlib.Data.QPF.Multivariate.Basic
+#align_import data.qpf.multivariate.constructions.cofix from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e"
+
/-!
# The final co-algebra of a multivariate qpf is again a qpf.
The unported dependencies are