Documentation

Std.Data.Iterators.Lemmas.Equivalence.Basic

structure Std.BundledIterM (m : Type w → Type w') (β : Type w) :
Type (max (w + 1) w')

A type with an iterator typeclass and an inhabitant bundled together. This represents an arbitrarily typed iterator. It only exists for the construction of the equivalence relation on iterators.

This type is not meant to be used in executable code. Unbundled Iter or IterM iterators of a specific type have better library support and are more efficient.

Instances For
    @[reducible, inline]
    abbrev Std.BundledIterM.ofIterM {m : Type u_1 → Type u_2} {β α : Type u_1} [Iterator α m β] (it : IterM m β) :
    Instances For
      @[simp]
      theorem Std.BundledIterM.iterator_ofIterM {m : Type u_1 → Type u_2} {β α : Type u_1} [Iterator α m β] (it : IterM m β) :
      @[simp]
      theorem Std.BundledIterM.α_ofIterM {m : Type u_1 → Type u_2} {β α : Type u_1} [Iterator α m β] {it : IterM m β} :
      (ofIterM it).α = α
      @[implicit_reducible]
      instance Std.instIteratorα {m : Type u_1 → Type u_2} {β : Type u_1} (bit : BundledIterM m β) :
      Iterator bit.α m β
      noncomputable def Std.IterM.stepAsHetT {α : Type u_1} {m : Type u_1 → Type u_2} {β : Type u_1} [Iterator α m β] [Monad m] (it : IterM m β) :

      A noncomputable variant of IterM.step using the HetT monad. It is used in the definition of the equivalence relations on iterators, namely IterM.Equiv and Iter.Equiv.

      Instances For
        noncomputable def Std.BundledIterM.step {β : Type w} {m : Type w → Type w'} [Monad m] [LawfulMonad m] (it : BundledIterM m β) :
        Instances For
          @[irreducible]
          def Std.BundledIterM.Equiv (m : Type w → Type w') (β : Type w) [Monad m] [LawfulMonad m] (ita itb : BundledIterM m β) :

          Equivalence relation on bundled iterators.

          Two bundled iterators are equivalent if they have the same Iterator.IsPlausibleStep relation and their step functions are the same up to equivalence of the successor iterators. This coinductive definition captures the idea that the only relevant feature of an iterator is its step function. Other information retrievable from the iterator -- for example, whether it is a list iterator or an array iterator -- is totally irrelevant for the equivalence judgement.

          Instances For
            @[simp]
            theorem Std.Equivalence.prun_liftInner_step {α : Type u_1} {m : Type u_1 → Type u_2} {β : Type u_1} {n : Type u_1 → Type u_3} {γ : Type u_1} [Iterator α m β] [Monad m] [Monad n] [MonadLiftT m n] [LawfulMonad m] [LawfulMonad n] [LawfulMonadLiftT m n] {it : IterM m β} {f : (step : IterStep (IterM m β) β) → (Iterators.HetT.liftInner n it.stepAsHetT).Property stepn γ} :
            (Iterators.HetT.liftInner n it.stepAsHetT).prun f = do let stepliftM it.step f step.inflate.val
            @[simp]
            theorem Std.Equivalence.property_step {α : Type u_1} {m : Type u_1 → Type u_2} {β : Type u_1} [Iterator α m β] [Monad m] [LawfulMonad m] {it : IterM m β} :
            @[simp]
            theorem Std.Equivalence.prun_step {α : Type u_1} {m : Type u_1 → Type u_2} {β γ : Type u_1} [Iterator α m β] [Monad m] [LawfulMonad m] {it : IterM m β} {f : (step : IterStep (IterM m β) β) → it.stepAsHetT.Property stepm γ} :
            it.stepAsHetT.prun f = do let stepit.step f step.inflate.val
            noncomputable def Std.BundledIterM.stepOnQuotient {β : Type w} {m : Type w → Type w'} [Monad m] [LawfulMonad m] :
            Quot (Equiv m β)Iterators.HetT m (IterStep (Quot (Equiv m β)) β)

            Like BundledIterM.step, but takes and returns iterators modulo BundledIterM.Equiv.

            Instances For
              theorem Std.BundledIterM.Equiv.exact {m : Type w → Type w'} {β : Type w} [Monad m] [LawfulMonad m] (ita itb : BundledIterM m β) :
              Quot.mk (Equiv m β) ita = Quot.mk (Equiv m β) itbEquiv m β ita itb
              theorem Std.BundledIterM.Equiv.quotMk_eq_iff {m : Type w → Type w'} {β : Type w} [Monad m] [LawfulMonad m] (ita itb : BundledIterM m β) :
              Quot.mk (Equiv m β) ita = Quot.mk (Equiv m β) itb Equiv m β ita itb
              theorem Std.BundledIterM.Equiv.refl {m : Type w → Type w'} {β : Type w} [Monad m] [LawfulMonad m] (it : BundledIterM m β) :
              Equiv m β it it
              theorem Std.BundledIterM.Equiv.symm {m : Type w → Type w'} {β : Type w} [Monad m] [LawfulMonad m] {ita itb : BundledIterM m β} (h : Equiv m β ita itb) :
              Equiv m β itb ita
              theorem Std.BundledIterM.Equiv.trans {m : Type w → Type w'} {β : Type w} [Monad m] [LawfulMonad m] {ita itb itc : BundledIterM m β} (hab : Equiv m β ita itb) (hbc : Equiv m β itb itc) :
              Equiv m β ita itc
              def Std.IterM.Equiv {m : Type w → Type w'} [Monad m] [LawfulMonad m] {β α₁ α₂ : Type w} [Iterator α₁ m β] [Iterator α₂ m β] (ita : IterM m β) (itb : IterM m β) :

              Equivalence relation on monadic iterators. Equivalent iterators behave the same as long as the internal state of them is not directly inspected.

              Two iterators (possibly of different types) are equivalent if they have the same Iterator.IsPlausibleStep relation and their step functions are the same up to equivalence of the successor iterators. This coinductive definition captures the idea that the only relevant feature of an iterator is its step function. Other information retrievable from the iterator -- for example, whether it is a list iterator or an array iterator -- is totally irrelevant for the equivalence judgement.

              Instances For
                def Std.Iter.Equiv {α₁ α₂ β : Type u_1} [Iterator α₁ Id β] [Iterator α₂ Id β] (ita : Iter β) (itb : Iter β) :

                Equivalence relation on iterators. Equivalent iterators behave the same as long as the internal state of them is not directly inspected.

                Two iterators (possibly of different types) are equivalent if they have the same Iterator.IsPlausibleStep relation and their step functions are the same up to equivalence of the successor iterators. This coinductive definition captures the idea that the only relevant feature of an iterator is its step function. Other information retrievable from the iterator -- for example, whether it is a list iterator or an array iterator -- is totally irrelevant for the equivalence judgement.

                Instances For
                  theorem Std.Iter.Equiv.toIterM {α₁ α₂ β : Type u_1} [Iterator α₁ Id β] [Iterator α₂ Id β] {ita : Iter β} {itb : Iter β} (h : ita.Equiv itb) :
                  theorem Std.IterM.Equiv.toIter {α₁ α₂ β : Type u_1} [Iterator α₁ Id β] [Iterator α₂ Id β] {ita : IterM Id β} {itb : IterM Id β} (h : ita.Equiv itb) :
                  theorem Std.IterM.Equiv.refl {m : Type w → Type w'} {β : Type w} [Monad m] [LawfulMonad m] {α : Type w} [Iterator α m β] (it : IterM m β) :
                  it.Equiv it
                  theorem Std.IterM.Equiv.symm {m : Type w → Type w'} {α₁ α₂ β : Type w} [Monad m] [LawfulMonad m] [Iterator α₁ m β] [Iterator α₂ m β] {ita : IterM m β} {itb : IterM m β} (h : ita.Equiv itb) :
                  itb.Equiv ita
                  theorem Std.IterM.Equiv.trans {m : Type w → Type w'} {α₁ α₂ α₃ β : Type w} [Monad m] [LawfulMonad m] [Iterator α₁ m β] [Iterator α₂ m β] [Iterator α₃ m β] {ita : IterM m β} {itb : IterM m β} {itc : IterM m β} (hab : ita.Equiv itb) (hbc : itb.Equiv itc) :
                  ita.Equiv itc
                  theorem Std.Iter.Equiv.refl {β α : Type w} [Iterator α Id β] (it : Iter β) :
                  it.Equiv it
                  theorem Std.Iter.Equiv.symm {α₁ α₂ β : Type w} [Iterator α₁ Id β] [Iterator α₂ Id β] {ita : Iter β} {itb : Iter β} (h : ita.Equiv itb) :
                  itb.Equiv ita
                  theorem Std.Iter.Equiv.trans {α₁ α₂ α₃ β : Type w} [Iterator α₁ Id β] [Iterator α₂ Id β] [Iterator α₃ Id β] {ita : Iter β} {itb : Iter β} {itc : Iter β} (hab : ita.Equiv itb) (hbc : itb.Equiv itc) :
                  ita.Equiv itc
                  theorem Std.IterM.Equiv.of_morphism {α₁ α₂ : Type w} {m : Type w → Type w'} [Monad m] [LawfulMonad m] {β : Type w} [Iterator α₁ m β] [Iterator α₂ m β] (ita : IterM m β) (f : IterM m βIterM m β) (h : ∀ (it : IterM m β), (f it).stepAsHetT = IterStep.mapIterator f <$> it.stepAsHetT) :
                  ita.Equiv (f ita)