Documentation

Fad.«Chapter5-Ex»

@[irreducible]
theorem Chapter5.qsort₀_eq_qsort₁ {a : Type} [h₁ : LT a] [h₂ : DecidableRel fun (x1 x2 : a) => x1 < x2] (xs : List a) :
partial def Chapter5.Quicksort.qsort₃ {α : Type u_1} [LE α] [DecidableRel fun (x1 x2 : α) => x1 x2] (y : List α) :
List α
partial def Chapter5.Quicksort.qsort₃.help {α : Type u_1} [LE α] [DecidableRel fun (x1 x2 : α) => x1 x2] (x : α) (ys us vs : List α) :
List α
partial def Chapter5.Quicksort.help₄ {α : Type u_1} [LE α] [DecidableRel fun (x1 x2 : α) => x1 x2] (x : α) (ys us vs : List α) :
List α
partial def Chapter5.Quicksort.qsort₄ {α : Type u_1} [LE α] [DecidableRel fun (x1 x2 : α) => x1 x2] :
List αList α
@[irreducible]
def Chapter5.Quicksort.help₅ {α : Type u_1} [LE α] [DecidableEq α] [DecidableRel LE.le] (t : ) (x : α) (ys us vs : List α) :
List α
Equations
  • One or more equations did not get rendered due to their size.
Instances For
    @[irreducible]
    def Chapter5.Quicksort.qsort₅ {α : Type u_1} [LE α] [DecidableEq α] [DecidableRel fun (x1 x2 : α) => x1 x2] (n : ) (ys : List α) :
    List α
    Equations
    Instances For
      @[irreducible]
      def Chapter5.T (m n : ) :
      Equations
      Instances For
        def Chapter5.expression₁ {α : Type} :
        List αList α
        Equations
        Instances For
          def Chapter5.expression₂ {α : Type} :
          List αList α
          Equations
          Instances For
            def Chapter5.reverse {α : Type} :
            List αList α
            Equations
            Instances For
              structure Chapter5.Card :

              Exercise 5.11 #

              Instances For
                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  Equations
                  • One or more equations did not get rendered due to their size.
                  @[irreducible]
                  def Chapter5.merge₁ {a : Type u_1} (f : aaOrdering) :
                  List aList aList a

                  Exercise 5.12 #

                  sortBy é uma função de ordenação de listas parametrizada pela função de comparação. Precisamos adaptar merge para então basicamente renomear S52.msort₃ para sortBy parametrizando pela função de comparação.

                  Como em Haskell, compare é definida para todo tipo instância de Ord. A função compareOn é equivalente a comparing do livro.

                  Equations
                  Instances For
                    def Chapter5.sortBy {a : Type} (f : aaOrdering) :
                    List aList a
                    Equations
                    Instances For
                      def Chapter5.sortOn₁ {b : Type u_1} {a : Type} [Ord b] (f : ab) :
                      List aList a
                      Equations
                      Instances For
                        def Chapter5.sortOn₂ {b a : Type} [Ord b] (f : ab) (xs : List a) :
                        Equations
                        Instances For
                          def Chapter5.sortOn₃ {b a : Type} [Ord b] (f : ab) :
                          List aList a
                          Equations
                          Instances For
                            def Chapter5.Heapsort.split {a : Type u_1} [Inhabited a] [LE a] [DecidableRel fun (x1 x2 : a) => x1 x2] :
                            List aa × List a × List a
                            Equations
                            Instances For
                              def Chapter5.Heapsort.split₁ {a : Type u_1} [Inhabited a] [LE a] [DecidableRel fun (x1 x2 : a) => x1 x2] :
                              List aa × List a × List a

                              Nn split₁ the where makes op visible from outside. In split, let is defined only in the second equation of the pattern match. let rec would make op also visible.

                              If op is not visible, in the split_left_le we would need lift_lets ; intro op

                              Equations
                              Instances For
                                def Chapter5.Heapsort.split₁.op {a : Type u_1} [LE a] [DecidableRel fun (x1 x2 : a) => x1 x2] (x : a) (acc : a × List a × List a) :
                                a × List a × List a
                                Equations
                                Instances For
                                  theorem Chapter5.Heapsort.split_left_le {a : Type u_1} [Inhabited a] [LE a] [DecidableRel fun (x1 x2 : a) => x1 x2] (xs : List a) :
                                  partial def Chapter5.Heapsort.mkHeap {a : Type} [Inhabited a] [LE a] [DecidableRel fun (x1 x2 : a) => x1 x2] :
                                  List aTree a
                                  @[irreducible]
                                  Equations
                                  Instances For
                                    @[irreducible]
                                    def Chapter5.Heapsort.mkPair {a : Type} :
                                    List aTree a × List a

                                    this is not necessary. Keeping only to preserve the proofs.

                                    Equations
                                    Instances For
                                      def Chapter5.filter {α : Type u_1} :
                                      (αBool)List αList α
                                      Equations
                                      Instances For
                                        Equations
                                        Instances For
                                          Equations
                                          Instances For