Documentation

ImportGraph.Shake.Basic

Utilities for Shake types #

This file provides basic API for Needs, NeedsKind, and Bitset.

Counts the number of set bits in the binary representation of n.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    @[inline]

    The number of set bits in a Bitset.

    Equations
    Instances For
      @[inline]

      Whether the Bitset contains any elements.

      Equations
      Instances For
        @[inline]

        The minimum size of the ambient index set necessary to hold Bitset.

        Equations
        Instances For
          @[inline]

          The full set {0, ..., n - 1}.

          Equations
          Instances For
            @[inline]

            The set s without the element i.

            Equations
            Instances For
              @[inline]

              The highest set bit of a Bitset, if there is one.

              Equations
              Instances For
                @[inline]

                The lowest set bit of a Bitset, if there is one.

                Equations
                Instances For
                  @[inline]

                  a.le b iff every bit set in a is also set in b.

                  Equations
                  Instances For
                    @[inline]

                    a.le b iff every bit set in a is also set in b, and b is not equal to a.

                    Equations
                    Instances For
                      @[instance_reducible]
                      Equations
                      @[instance_reducible]
                      Equations
                      @[specialize #[]]
                      def ImportGraph.Shake.Bitset.foldr {α : Type} (s : Bitset) (init : α) (f : α → Nat → α) :
                      α

                      Fold over the set bit indices in a Bitset from high to low. This is more efficient for large bitsets than Bitset.foldl.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        @[specialize #[]]
                        def ImportGraph.Shake.Bitset.foldl {α : Type} (s : Bitset) (init : α) (f : α → Nat → α) :
                        α

                        Fold over the set bit indices in a Bitset from low to high. This is less efficient for large bitsets than Bitset.foldr.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For

                          Array #

                          @[inline]

                          Regarding idxs : Array Nat as a set of Bitset indices, create a bitset which contains each idx ∈ idxs.

                          Equations
                          Instances For
                            @[inline]

                            The set bit indices of a Bitset in order from low to high.

                            Equations
                            Instances For
                              @[inline]

                              The set bit indices of a Bitset in order from high to low.

                              Equations
                              Instances For

                                ForIn #

                                @[specialize #[]]
                                def ImportGraph.Shake.Bitset.forInRev {m : Type → Type u_1} [Monad m] {β : Type} (s : Bitset) (init : β) (f : Nat → β → m (ForInStep β)) :
                                m (ForInStep β)

                                Iterates through the set bit indices of a Bitset from high to low.

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For

                                  A Bitset with a ForIn instance that traverses the bitset's indices from the highest index to the lowest. This is the most efficient traversal of a bitset for large bitsets.

                                  Instances For
                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    Instances For
                                      @[inline]

                                      A Bitset with a ForIn instance that traverses the bitset's indices from the highest index to the lowest. This is the most efficient traversal of a bitset for large bitsets.

                                      Equations
                                      Instances For
                                        @[instance_reducible]
                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        @[specialize #[]]
                                        def ImportGraph.Shake.Bitset.forIn {m : Type → Type u_1} [Monad m] {β : Type} (s : Bitset) (init : β) (f : Nat → β → m (ForInStep β)) :
                                        m (ForInStep β)
                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        Instances For

                                          A Bitset with a ForIn instance that traverses the bitset's indices from the highest index to the lowest. Bitset.HighToLow (Bitset.highToLow) is more efficient for large Bitsets.

                                          Instances For
                                            Equations
                                            • One or more equations did not get rendered due to their size.
                                            Instances For
                                              @[inline]

                                              A Bitset with a ForIn instance that traverses the bitset's indices from the highest index to the lowest. Bitset.HighToLow (Bitset.highToLow) is more efficient for large Bitsets.

                                              Equations
                                              Instances For
                                                @[instance_reducible]
                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                @[specialize #[]]

                                                Whether f returns true for all elements of the Bitset.

                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                Instances For
                                                  @[specialize #[]]

                                                  Whether f returns true for any elements of the Bitset.

                                                  Equations
                                                  • One or more equations did not get rendered due to their size.
                                                  Instances For

                                                    Extract the elements of a : Array α occurring at the indices specified in b : Bitset. Ignores elements of b that index outside the array.

                                                    Equations
                                                    • One or more equations did not get rendered due to their size.
                                                    Instances For

                                                      Representations #

                                                      Equations
                                                      • One or more equations did not get rendered due to their size.
                                                      Instances For

                                                        Converts a Bitset to a string of the form "◻◼◻◻◻◼◻◼◼◻◻◼", where indices run left-to-right from 0 and ◻ represents absence at that index, while ◼ represents presence.

                                                        By default, this shows only as many squares as necessary (or "◻" for an empty bitset), and so in the nonempty case the last square will always be ◼. Instead, univSize? : Option Nat can be provided to set the total number of indices, and will either truncate (even if higher bits are set) or pad with ◻ as appropriate.

                                                        Equations
                                                        • One or more equations did not get rendered due to their size.
                                                        Instances For

                                                          ForIn #

                                                          @[specialize #[]]
                                                          def ImportGraph.Shake.Needs.forInRev {m : Type → Type u_1} [Monad m] {β : Type} (n : Needs) (init : β) (f : NeedsKind × Nat → β → m (ForInStep β)) :
                                                          m (ForInStep β)

                                                          Iterates through NeedsKinds.all, and for each NeedsKind, iterates through the set bit indices of the corresponding Bitset from highest to lowest.

                                                          Equations
                                                          • One or more equations did not get rendered due to their size.
                                                          Instances For

                                                            A Needs with a ForIn instance that traverses the component bitset's indices from the highest index to the lowest. This is the most efficient traversal of a bitset. Does not actually reverse the indices in the bitsets.

                                                            Instances For

                                                              A Needs with a ForIn instance that traverses the component bitset's indices from the highest index to the lowest. This is the most efficient traversal of a bitset. Does not actually reverse the indices in the bitsets.

                                                              Equations
                                                              Instances For
                                                                @[instance_reducible]
                                                                Equations
                                                                • One or more equations did not get rendered due to their size.
                                                                @[specialize #[]]
                                                                def ImportGraph.Shake.Needs.forIn {m : Type → Type u_1} [Monad m] {β : Type} (n : Needs) (init : β) (f : NeedsKind × Nat → β → m (ForInStep β)) :
                                                                m (ForInStep β)

                                                                Iterates through NeedsKinds.all, and for each NeedsKind, iterates through the set bit indices of the corresponding Bitset from lowest to highest.

                                                                Equations
                                                                • One or more equations did not get rendered due to their size.
                                                                Instances For

                                                                  A Needs with a ForIn instance that traverses the component bitset's indices from the lowest index to the highest. b.highToLow is more efficient.

                                                                  Instances For

                                                                    A Needs with a ForIn instance that traverses the component bitset's indices from the lowest index to the highest. b.highToLow is more efficient.

                                                                    Equations
                                                                    Instances For
                                                                      @[instance_reducible]
                                                                      Equations
                                                                      • One or more equations did not get rendered due to their size.

                                                                      Operations #

                                                                      Equations
                                                                      • One or more equations did not get rendered due to their size.
                                                                      Instances For

                                                                        Includes i in the field of Needs corresponding to k.

                                                                        Equations
                                                                        Instances For
                                                                          @[inline]
                                                                          def ImportGraph.Shake.Needs.applyAt {β : Sort u_1} (n : Needs) (k : NeedsKind) (f : Bitset → β) :
                                                                          β

                                                                          Apply f to the component bitset of n : Needs at the given NeedsKind. Rephrasing of f (n.get k) for readability.

                                                                          Equations
                                                                          Instances For
                                                                            @[inline]

                                                                            Whether f : Bitset → Bool is true for any of the component bitsets of the given Needs.

                                                                            Equations
                                                                            Instances For
                                                                              @[inline]

                                                                              Whether f : NeedsKind → Bitset → Bool is true for any of the component bitsets of the given Needs at the bitset's corresponding NeedsKind.

                                                                              Equations
                                                                              Instances For
                                                                                @[inline]

                                                                                Whether f : Bitset → Bool is true for all of the component bitsets of the given Needs.

                                                                                Equations
                                                                                Instances For
                                                                                  @[inline]

                                                                                  Whether f : NeedsKind → Bitset → Bool is true for any of the component bitsets of the given Needs at the bitset's corresponding NeedsKind.

                                                                                  Equations
                                                                                  Instances For
                                                                                    @[inline]
                                                                                    def ImportGraph.Shake.Needs.fold {α : Type u_1} (n : Needs) (f : α → Bitset → α) (init : α) :
                                                                                    α

                                                                                    Folds f over the bitsets in Needs (in the order of NeedsKind.all).

                                                                                    Equations
                                                                                    Instances For
                                                                                      @[inline]
                                                                                      def ImportGraph.Shake.Needs.foldWithKind {α : Type u_1} (n : Needs) (f : α → NeedsKind → Bitset → α) (init : α) :
                                                                                      α

                                                                                      Folds f over the bitsets in Needs at their corresponding NeedsKinds (in the order of NeedsKind.all).

                                                                                      Equations
                                                                                      Instances For

                                                                                        The union of all bitsets in a Needs

                                                                                        Equations
                                                                                        Instances For
                                                                                          @[specialize #[1]]

                                                                                          Applies f to all component Bitsets of the given Needs.

                                                                                          Equations
                                                                                          Instances For
                                                                                            @[specialize #[1]]

                                                                                            Applies f to all component Bitsets of the given Needs at their corresponding NeedsKinds.

                                                                                            Equations
                                                                                            • One or more equations did not get rendered due to their size.
                                                                                            Instances For
                                                                                              @[specialize #[2]]

                                                                                              Applies f "pointwise" to the pairs of bitsets at each given NeedsKind. f (n₁.get k) (n₂.get k) = (n₁.map₂ n₂ f).get k for all k : NeedsKind.

                                                                                              Equations
                                                                                              • One or more equations did not get rendered due to their size.
                                                                                              Instances For
                                                                                                @[specialize #[2]]

                                                                                                Applies f "pointwise" to the pairs of bitsets at each given NeedsKind. f k (n₁.get k) (n₂.get k) = (n₁.mapWithKind₂ n₂ f).get k for all k : NeedsKind.

                                                                                                Equations
                                                                                                • One or more equations did not get rendered due to their size.
                                                                                                Instances For
                                                                                                  @[inline]

                                                                                                  Whether all component bitsets are empty.

                                                                                                  Equations
                                                                                                  Instances For
                                                                                                    @[inline]

                                                                                                    Whether the component bitset at k : NeedsKind is empty.

                                                                                                    Equations
                                                                                                    Instances For
                                                                                                      @[inline]

                                                                                                      The minimum size of the ambient index set necessary to hold every component Bitset.

                                                                                                      Equations
                                                                                                      Instances For
                                                                                                        @[instance_reducible]
                                                                                                        Equations
                                                                                                        @[inline]

                                                                                                        Whether each field of the first Needs is contained within the corresponding field of the second. Use with caution: this does not necessarily indicate that one Needs subsumes another. See also Needs.coveredBy for testing against an import hierarchy.

                                                                                                        Equations
                                                                                                        Instances For

                                                                                                          Representations #

                                                                                                          A braille cell depicting the set of NeedsKinds of n at index i. The left column holds non-meta needs, and the right column meta needs; the top row holds public needs, the middle row private, and the bottom row private-of-private.

                                                                                                          Equations
                                                                                                          • One or more equations did not get rendered due to their size.
                                                                                                          Instances For
                                                                                                            @[inline]

                                                                                                            A braille cell in brackets depicting the set of NeedsKinds of n at index i. The left column holds non-meta needs, and the right column meta needs; the top row holds public needs, the middle row private, and the bottom row private-of-private.

                                                                                                            For the braille cell character without brackets, see Needs.brailleCellAt.

                                                                                                            Equations
                                                                                                            Instances For
                                                                                                              def ImportGraph.Shake.Needs.toString (n : Needs) (univSize? : Option Nat := none) (dividers : Bool := true) :

                                                                                                              Represents a Needs as a string of the form e.g. │⠇│⠑│⠁│⠝│, where each braille cell represents the set of NeedsKinds expressed by a single "column" of the Needs (i.e. at a given index). The left column of each Braille cell are non-meta needs, and the right column holds meta needs; the top row holds public needs, the middle private, and the bottom private-of-private.

                                                                                                              By default, shows dividers (│) between each braille cell; dividers := false omits dividers.

                                                                                                              By default this shows only as many cells as necessary, or a single empty cell for an empty Needs. Instead, univSize? : Option Nat can be provided to set the total number of indices, and will either truncate (even if higher indices are set) or pad with empty cells as appropriate.

                                                                                                              Equations
                                                                                                              • One or more equations did not get rendered due to their size.
                                                                                                              Instances For
                                                                                                                @[instance_reducible]
                                                                                                                Equations
                                                                                                                • One or more equations did not get rendered due to their size.

                                                                                                                The prefix to the import command corresponding to the import. If clarifyPriv is true, (default false), we include "private" in front of private imports. This is useful in display situations, even though it is not a valid form of import.

                                                                                                                Equations
                                                                                                                Instances For
                                                                                                                  @[inline]

                                                                                                                  The NeedsKinds which land (directly) in the private scope.

                                                                                                                  Equations
                                                                                                                  • One or more equations did not get rendered due to their size.
                                                                                                                  Instances For
                                                                                                                    @[inline]

                                                                                                                    The NeedsKinds which land in the private scope after taking into account public ⊆ private on both ends. This is simply NeedsKind.all, but can help record why we're using it.

                                                                                                                    Equations
                                                                                                                    Instances For
                                                                                                                      @[inline]

                                                                                                                      The NeedsKinds which land in the public scope after taking into account public ⊆ private on both ends. This is simply toPublic, but can help record why we're using it.

                                                                                                                      Equations
                                                                                                                      Instances For
                                                                                                                        @[inline]

                                                                                                                        The NeedsKinds which demand the private scope after taking into account public ⊆ private on both ends.

                                                                                                                        Equations
                                                                                                                        Instances For
                                                                                                                          @[inline]

                                                                                                                          The NeedsKinds which demand the public scope after taking into account public ⊆ private on both ends. This is simply NeedsKind.all, but can help record why we're using it.

                                                                                                                          Equations
                                                                                                                          Instances For
                                                                                                                            @[inline]

                                                                                                                            Whether k places the src in the tgt visibility, after taking into account public ⊆ private on both ends. Note that we abstractly consider NeedsKind to be a single arrow between scopes (i.e. privOfPriv only relates the private scope to the private scope), but in this function we allow linearization (i.e. composition with public ↪ private)

                                                                                                                            Equations
                                                                                                                            Instances For

                                                                                                                              Whether k yields something in the scope tgt. This is always true when tgt is .private thanks to public ⊆ private on the target side, and is k.isExported when .public.

                                                                                                                              Equations
                                                                                                                              Instances For

                                                                                                                                Whether k demands something in the scope src. This is always true when src is .public thanks to public ⊆ private on the source side, and is k.isAll when .private.

                                                                                                                                Equations
                                                                                                                                Instances For
                                                                                                                                  def ImportGraph.Shake.NeedsKind.andThen (k₁ k₂ : NeedsKind) (connectable : k₁.target = k₂.source := by grind) :
                                                                                                                                  Equations
                                                                                                                                  Instances For
                                                                                                                                    @[simp]
                                                                                                                                    theorem ImportGraph.Shake.NeedsKind.target_andThen_eq_right_target (k₁ k₂ : NeedsKind) (connectable : k₁.target = k₂.source) :
                                                                                                                                    (k₁.andThen k₂ ⋯).target = k₂.target
                                                                                                                                    @[simp]
                                                                                                                                    theorem ImportGraph.Shake.NeedsKind.source_andThen_eq_left_source (k₁ k₂ : NeedsKind) (connectable : k₁.target = k₂.source) :
                                                                                                                                    (k₁.andThen k₂ ⋯).source = k₁.source
                                                                                                                                    @[simp]
                                                                                                                                    theorem ImportGraph.Shake.NeedsKind.andThen_assoc (k₁ k₂ k₃ : NeedsKind) (connectable₁₂ : k₁.target = k₂.source) (connectable₂₃ : k₂.target = k₃.source) :
                                                                                                                                    (k₁.andThen k₂ ⋯).andThen k₃ ⋯ = k₁.andThen (k₂.andThen k₃ ⋯) ⋯

                                                                                                                                    The NeedsKind that represents a connection from src to tgt, with tgt the importing file. E.g., connecting? .public .private is the NeedsKind that imports a public scope into a private scope.

                                                                                                                                    Equations
                                                                                                                                    Instances For
                                                                                                                                      @[inline]

                                                                                                                                      Intersects each field of two Provides.

                                                                                                                                      Generally, intersection is not meaningful on a bare Needs, but is meaningful on a transitively closed and linearized Provides.

                                                                                                                                      We avoid making this an instance of Inter to avoid a ∩ b succeeding on Needs.

                                                                                                                                      Equations
                                                                                                                                      Instances For