Documentation

Fad.Chapter12

Chapter Info #

In this chapter $ 2 ∈ 3$ we will confine ourselves to just two examples. The first is a simple scheduling problem, while the second involves breaking paragraphs into lines.

@[reducible, inline]

A partition of a list of type [A] has type [[A]], so a list of partitions has type [[[A]]].

Equations
Instances For
    @[reducible, inline]
    Equations
    Instances For
      def Chapter12.splits {a : Type} :
      List aList (List a × List a)
      Equations
      Instances For
        theorem Chapter12.length_lt_of_cons_split {α : Type} (xs ys zs : List α) (h : (ys, zs) splits xs) :
        @[irreducible]
        def Chapter12.parts {a : Type} :
        List aList (Partition a)
        Equations
        Instances For
          def Chapter12.cons {a : Type} (x : a) (p : Partition a) :
          Equations
          Instances For
            def Chapter12.glue {a : Type} (x : a) :
            Equations
            Instances For
              def Chapter12.last {a : Type u_1} [Inhabited a] :
              List aa
              Equations
              Instances For
                def Chapter12.init {a : Type u_1} [Inhabited a] :
                List aList a
                Equations
                Instances For
                  def Chapter12.snoc {a : Type} (x : a) (p : Partition a) :
                  Equations
                  Instances For
                    def Chapter12.bind {a : Type} (x : a) (p : Partition a) :
                    Equations
                    Instances For

                      The major constraint on paragraphs is that all lines have to fit into a specified width. For simplicity, we assume a single globally defined value maxWidth that gives the maximum width a line can possess.

                      Equations
                      Instances For

                        The definition depends on another globally defined constant optWidth, whose value is at most maxWidth and which specifies the optimum width of each line of a paragraph.

                        Equations
                        Instances For
                          @[reducible, inline]

                          It is assumed that a text consists of a nonempty sequence of words, each word being a nonempty sequence of non-space characters. A paragraph therefore consists of at least one line.

                          Equations
                          Instances For
                            @[reducible, inline]
                            Equations
                            Instances For
                              @[reducible, inline]
                              Equations
                              Instances For
                                @[reducible, inline]
                                Equations
                                Instances For
                                  def Chapter12.width (line : Line) :
                                  Equations
                                  Instances For
                                    def Chapter12.aux_add (w : Word) (n : ) :
                                    Equations
                                    Instances For
                                      Equations
                                      Instances For
                                        Equations
                                        Instances For

                                          Cost functions #

                                          Equations
                                          Instances For
                                            def Chapter12.add (p : Para) (w : Word) :

                                            There is an obvious greedy algorithm for the paragraph problem:

                                            Equations
                                            Instances For
                                              def Chapter12.tstep (ps : List Para) (w : Word) (cost : Para) :

                                              Adding cost to the algorithm

                                              Equations
                                              Instances For
                                                def Chapter12.para (ws : Text) (cost : Para) :
                                                Equations
                                                Instances For