Documentation

Hale.Base.Data.Newtype

structure Data.Dual (α : Type u) :

Dual α reverses the Append (semigroup) operation:

$$\text{Dual}(a) \mathbin{++} \text{Dual}(b) = \text{Dual}(b \mathbin{++} a)$$

If $(S, \diamond)$ is a semigroup, then $(\text{Dual}\;S,\, \diamond^{\text{op}})$ is the opposite semigroup where $a \diamond^{\text{op}} b = b \diamond a$.

  • getDual : α
Instances For
    def Data.instBEqDual.beq {α✝ : Type u_1} [BEq α✝] :
    Dual α✝Dual α✝Bool
    Equations
    Instances For
      @[implicit_reducible]
      instance Data.instBEqDual {α✝ : Type u_1} [BEq α✝] :
      BEq (Dual α✝)
      Equations
      def Data.instOrdDual.ord {α✝ : Type u_1} [Ord α✝] :
      Dual α✝Dual α✝Ordering
      Equations
      Instances For
        @[implicit_reducible]
        instance Data.instOrdDual {α✝ : Type u_1} [Ord α✝] :
        Ord (Dual α✝)
        Equations
        @[implicit_reducible]
        instance Data.instReprDual {α✝ : Type u_1} [Repr α✝] :
        Repr (Dual α✝)
        Equations
        def Data.instReprDual.repr {α✝ : Type u_1} [Repr α✝] :
        Dual α✝NatStd.Format
        Equations
        Instances For
          def Data.instHashableDual.hash {α✝ : Type u_1} [Hashable α✝] :
          Dual α✝UInt64
          Equations
          Instances For
            @[implicit_reducible]
            instance Data.instHashableDual {α✝ : Type u_1} [Hashable α✝] :
            Hashable (Dual α✝)
            Equations
            @[implicit_reducible]
            instance Data.instToStringDual {α : Type u_1} [ToString α] :

            ToString instance for Dual α, displaying as Dual(...).

            Equations
            @[implicit_reducible]
            instance Data.instAppendDual {α : Type u_1} [Append α] :

            Append instance for Dual α — reverses the underlying operation: $\text{Dual}(a) \mathbin{++} \text{Dual}(b) = \text{Dual}(b \mathbin{++} a)$.

            Equations
            theorem Data.Dual.append_assoc {α : Type u_1} [Append α] [h : Std.Associative fun (x1 x2 : α) => x1 ++ x2] (a b c : Dual α) :
            a ++ b ++ c = a ++ (b ++ c)

            Associativity of the dual semigroup. Given associativity of $(++)$ on $\alpha$:

            $$(\text{Dual}\;a \mathbin{++} \text{Dual}\;b) \mathbin{++} \text{Dual}\;c = \text{Dual}\;a \mathbin{++} (\text{Dual}\;b \mathbin{++} \text{Dual}\;c)$$

            structure Data.Endo (α : Type u) :

            Endo α wraps endomorphisms $\alpha \to \alpha$. Forms a monoid under function composition:

            • Operation: $\text{Endo}(f) \mathbin{++} \text{Endo}(g) = \text{Endo}(f \circ g)$
            • Identity: $\text{Endo}(\text{id})$

            $$(\text{Endo}\;f \mathbin{++} \text{Endo}\;g)(x) = f(g(x))$$

            • appEndo : αα
            Instances For
              @[implicit_reducible]
              instance Data.instAppendEndo {α : Type u_1} :

              Append instance for Endo α via function composition: $\text{Endo}(f) \mathbin{++} \text{Endo}(g) = \text{Endo}(f \circ g)$.

              Equations
              theorem Data.Endo.append_assoc {α : Type u_1} (a b c : Endo α) :
              a ++ b ++ c = a ++ (b ++ c)

              Associativity of endomorphism composition. Since $(f \circ g) \circ h = f \circ (g \circ h)$ holds definitionally, this is rfl.

              structure Data.First (α : Type u) :

              First α keeps the leftmost some value under Append:

              $$\text{First}(x) \mathbin{++} \text{First}(y) = \text{First}(x \mathbin{<|>} y)$$

              • $\text{First}(\text{some}\;a) \mathbin{++} \_ = \text{First}(\text{some}\;a)$
              • $\text{First}(\text{none}) \mathbin{++} y = y$

              Identity element: $\text{First}(\text{none})$.

              Instances For
                def Data.instBEqFirst.beq {α✝ : Type u_1} [BEq α✝] :
                First α✝First α✝Bool
                Equations
                Instances For
                  @[implicit_reducible]
                  instance Data.instBEqFirst {α✝ : Type u_1} [BEq α✝] :
                  BEq (First α✝)
                  Equations
                  @[implicit_reducible]
                  instance Data.instReprFirst {α✝ : Type u_1} [Repr α✝] :
                  Repr (First α✝)
                  Equations
                  def Data.instReprFirst.repr {α✝ : Type u_1} [Repr α✝] :
                  First α✝NatStd.Format
                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    @[implicit_reducible]
                    instance Data.instToStringFirst {α : Type u_1} [ToString α] :

                    ToString instance for First α, displaying as First(...).

                    Equations
                    @[implicit_reducible]
                    instance Data.instAppendFirst {α : Type u_1} :

                    Append instance for First α — keeps the leftmost some.

                    Equations
                    theorem Data.First.append_assoc {α : Type u_1} (a b c : First α) :
                    a ++ b ++ c = a ++ (b ++ c)

                    Associativity of First: $((a \mathbin{++} b) \mathbin{++} c) = (a \mathbin{++} (b \mathbin{++} c))$.

                    Follows from the associativity of Option's <|> (left-biased choice).

                    structure Data.Last (α : Type u) :

                    Last α keeps the rightmost some value under Append:

                    $$\text{Last}(x) \mathbin{++} \text{Last}(y) = \text{Last}(y \mathbin{<|>} x)$$

                    • $\_ \mathbin{++} \text{Last}(\text{some}\;b) = \text{Last}(\text{some}\;b)$
                    • $x \mathbin{++} \text{Last}(\text{none}) = x$

                    Identity element: $\text{Last}(\text{none})$.

                    Instances For
                      @[implicit_reducible]
                      instance Data.instBEqLast {α✝ : Type u_1} [BEq α✝] :
                      BEq (Last α✝)
                      Equations
                      def Data.instBEqLast.beq {α✝ : Type u_1} [BEq α✝] :
                      Last α✝Last α✝Bool
                      Equations
                      Instances For
                        @[implicit_reducible]
                        instance Data.instReprLast {α✝ : Type u_1} [Repr α✝] :
                        Repr (Last α✝)
                        Equations
                        def Data.instReprLast.repr {α✝ : Type u_1} [Repr α✝] :
                        Last α✝NatStd.Format
                        Equations
                        Instances For
                          @[implicit_reducible]
                          instance Data.instToStringLast {α : Type u_1} [ToString α] :

                          ToString instance for Last α, displaying as Last(...).

                          Equations
                          @[implicit_reducible]
                          instance Data.instAppendLast {α : Type u_1} :

                          Append instance for Last α — keeps the rightmost some.

                          Equations
                          theorem Data.Last.append_assoc {α : Type u_1} (a b c : Last α) :
                          a ++ b ++ c = a ++ (b ++ c)

                          Associativity of Last: $((a \mathbin{++} b) \mathbin{++} c) = (a \mathbin{++} (b \mathbin{++} c))$.

                          Follows from the associativity of right-biased <|> on Option.

                          structure Data.Sum (α : Type u) :

                          Sum α is a monoid wrapper under addition:

                          • Operation: $\text{Sum}(a) \mathbin{++} \text{Sum}(b) = \text{Sum}(a + b)$
                          • Identity: $\text{Sum}(0)$

                          $$\text{Sum}(a) \mathbin{++} \text{Sum}(b) = \text{Sum}(a + b)$$

                          • getSum : α
                          Instances For
                            def Data.instBEqSum.beq {α✝ : Type u_1} [BEq α✝] :
                            Sum α✝Sum α✝Bool
                            Equations
                            Instances For
                              @[implicit_reducible]
                              instance Data.instBEqSum {α✝ : Type u_1} [BEq α✝] :
                              BEq (Sum α✝)
                              Equations
                              def Data.instOrdSum.ord {α✝ : Type u_1} [Ord α✝] :
                              Sum α✝Sum α✝Ordering
                              Equations
                              Instances For
                                @[implicit_reducible]
                                instance Data.instOrdSum {α✝ : Type u_1} [Ord α✝] :
                                Ord (Sum α✝)
                                Equations
                                @[implicit_reducible]
                                instance Data.instReprSum {α✝ : Type u_1} [Repr α✝] :
                                Repr (Sum α✝)
                                Equations
                                def Data.instReprSum.repr {α✝ : Type u_1} [Repr α✝] :
                                Sum α✝NatStd.Format
                                Equations
                                Instances For
                                  @[implicit_reducible]
                                  instance Data.instHashableSum {α✝ : Type u_1} [Hashable α✝] :
                                  Hashable (Sum α✝)
                                  Equations
                                  def Data.instHashableSum.hash {α✝ : Type u_1} [Hashable α✝] :
                                  Sum α✝UInt64
                                  Equations
                                  Instances For
                                    @[implicit_reducible]
                                    instance Data.instToStringSum {α : Type u_1} [ToString α] :

                                    ToString instance for Sum α, displaying as Sum(...).

                                    Equations
                                    @[implicit_reducible]
                                    instance Data.instAppendSumOfAdd {α : Type u_1} [Add α] :
                                    Append (Sum α)

                                    Append instance for Sum α — delegates to Add: $\text{Sum}(a) \mathbin{++} \text{Sum}(b) = \text{Sum}(a + b)$.

                                    Equations
                                    theorem Data.Sum.append_assoc {α : Type u_1} [Add α] [h : Std.Associative fun (x1 x2 : α) => x1 + x2] (a b c : Sum α) :
                                    a ++ b ++ c = a ++ (b ++ c)

                                    Associativity of Sum, given associativity of $(+)$ on $\alpha$:

                                    $$(a + b) + c = a + (b + c) \;\implies\; \text{Sum}(a) \mathbin{++} \text{Sum}(b) \mathbin{++} \text{Sum}(c) = \text{Sum}(a) \mathbin{++} (\text{Sum}(b) \mathbin{++} \text{Sum}(c))$$

                                    structure Data.Product (α : Type u) :

                                    Product α is a monoid wrapper under multiplication:

                                    • Operation: $\text{Product}(a) \mathbin{++} \text{Product}(b) = \text{Product}(a \times b)$
                                    • Identity: $\text{Product}(1)$

                                    $$\text{Product}(a) \mathbin{++} \text{Product}(b) = \text{Product}(a \times b)$$

                                    • getProduct : α
                                    Instances For
                                      def Data.instBEqProduct.beq {α✝ : Type u_1} [BEq α✝] :
                                      Product α✝Product α✝Bool
                                      Equations
                                      Instances For
                                        @[implicit_reducible]
                                        instance Data.instBEqProduct {α✝ : Type u_1} [BEq α✝] :
                                        BEq (Product α✝)
                                        Equations
                                        def Data.instOrdProduct.ord {α✝ : Type u_1} [Ord α✝] :
                                        Product α✝Product α✝Ordering
                                        Equations
                                        Instances For
                                          @[implicit_reducible]
                                          instance Data.instOrdProduct {α✝ : Type u_1} [Ord α✝] :
                                          Ord (Product α✝)
                                          Equations
                                          def Data.instReprProduct.repr {α✝ : Type u_1} [Repr α✝] :
                                          Product α✝NatStd.Format
                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For
                                            @[implicit_reducible]
                                            instance Data.instReprProduct {α✝ : Type u_1} [Repr α✝] :
                                            Repr (Product α✝)
                                            Equations
                                            @[implicit_reducible]
                                            instance Data.instHashableProduct {α✝ : Type u_1} [Hashable α✝] :
                                            Equations
                                            def Data.instHashableProduct.hash {α✝ : Type u_1} [Hashable α✝] :
                                            Product α✝UInt64
                                            Equations
                                            Instances For
                                              @[implicit_reducible]
                                              instance Data.instToStringProduct {α : Type u_1} [ToString α] :

                                              ToString instance for Product α, displaying as Product(...).

                                              Equations
                                              @[implicit_reducible]
                                              instance Data.instAppendProductOfMul {α : Type u_1} [Mul α] :

                                              Append instance for Product α — delegates to Mul: $\text{Product}(a) \mathbin{++} \text{Product}(b) = \text{Product}(a \times b)$.

                                              Equations
                                              theorem Data.Product.append_assoc {α : Type u_1} [Mul α] [h : Std.Associative fun (x1 x2 : α) => x1 * x2] (a b c : Product α) :
                                              a ++ b ++ c = a ++ (b ++ c)

                                              Associativity of Product, given associativity of $(\times)$ on $\alpha$:

                                              $$(a \times b) \times c = a \times (b \times c) \;\implies\; \text{Product}(a) \mathbin{++} \text{Product}(b) \mathbin{++} \text{Product}(c) = \text{Product}(a) \mathbin{++} (\text{Product}(b) \mathbin{++} \text{Product}(c))$$

                                              structure Data.All :

                                              All is the boolean monoid under conjunction $(\wedge)$:

                                              • Operation: $\text{All}(a) \mathbin{++} \text{All}(b) = \text{All}(a \wedge b)$
                                              • Identity: $\text{All}(\text{true})$

                                              $$\text{All}(a) \mathbin{++} \text{All}(b) = \text{All}(a \mathbin{\&\&} b)$$

                                              Instances For
                                                Equations
                                                Instances For
                                                  @[implicit_reducible]
                                                  Equations
                                                  @[implicit_reducible]
                                                  Equations
                                                  Equations
                                                  Instances For
                                                    @[implicit_reducible]
                                                    Equations
                                                    Equations
                                                    Instances For
                                                      @[implicit_reducible]

                                                      ToString instance for All, displaying as All(...).

                                                      Equations
                                                      @[implicit_reducible]

                                                      Append instance for All — boolean conjunction: $\text{All}(a) \mathbin{++} \text{All}(b) = \text{All}(a \mathbin{\&\&} b)$.

                                                      Equations
                                                      theorem Data.All.append_assoc (a b c : All) :
                                                      a ++ b ++ c = a ++ (b ++ c)

                                                      Associativity of All:

                                                      $$(a \mathbin{\&\&} b) \mathbin{\&\&} c = a \mathbin{\&\&} (b \mathbin{\&\&} c)$$

                                                      Proved by case analysis on $a$.

                                                      structure Data.Any :

                                                      Any is the boolean monoid under disjunction $(\vee)$:

                                                      • Operation: $\text{Any}(a) \mathbin{++} \text{Any}(b) = \text{Any}(a \vee b)$
                                                      • Identity: $\text{Any}(\text{false})$

                                                      $$\text{Any}(a) \mathbin{++} \text{Any}(b) = \text{Any}(a \mathbin{||} b)$$

                                                      Instances For
                                                        @[implicit_reducible]
                                                        Equations
                                                        Equations
                                                        Instances For
                                                          @[implicit_reducible]
                                                          Equations
                                                          Equations
                                                          Instances For
                                                            @[implicit_reducible]
                                                            Equations
                                                            Equations
                                                            Instances For
                                                              @[implicit_reducible]

                                                              ToString instance for Any, displaying as Any(...).

                                                              Equations
                                                              @[implicit_reducible]

                                                              Append instance for Any — boolean disjunction: $\text{Any}(a) \mathbin{++} \text{Any}(b) = \text{Any}(a \mathbin{||} b)$.

                                                              Equations
                                                              theorem Data.Any.append_assoc (a b c : Any) :
                                                              a ++ b ++ c = a ++ (b ++ c)

                                                              Associativity of Any:

                                                              $$(a \mathbin{||} b) \mathbin{||} c = a \mathbin{||} (b \mathbin{||} c)$$

                                                              Proved by case analysis on $a$.