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
The number of set bits in a Bitset.
Equations
Instances For
The full set {0, ..., n - 1}.
Instances For
Equations
- ImportGraph.Shake.Bitset.instHasSubset = { Subset := fun (a b : ImportGraph.Shake.Bitset) => a.le b = true }
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
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 #
Regarding idxs : Array Nat as a set of Bitset indices, create a bitset which contains each
idx ∈ idxs.
Equations
- ImportGraph.Shake.Bitset.ofArray idxs = Array.foldl (flip insert) ∅ idxs
Instances For
ForIn #
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
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
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
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.
- toBitset : Bitset
Instances For
Equations
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
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
Equations
Instances For
Equations
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
Equations
- ImportGraph.Shake.Bitset.instToString = { toString := fun (b : ImportGraph.Shake.Bitset) => b.toString }
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
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
Operations #
Equations
- One or more equations did not get rendered due to their size.
- ImportGraph.Shake.Needs.instBEq.beq x✝¹ x✝ = false
Instances For
Equations
Includes i in the field of Needs corresponding to k.
Equations
Instances For
Whether f : Bitset → Bool is true for any of the component bitsets of the given Needs.
Equations
- n.any f = ImportGraph.Shake.NeedsKind.all.any fun (x : ImportGraph.Shake.NeedsKind) => n.applyAt x f
Instances For
Whether f : NeedsKind → Bitset → Bool is true for any of the component bitsets of the given
Needs at the bitset's corresponding NeedsKind.
Equations
- n.anyWithKind f = ImportGraph.Shake.NeedsKind.all.any fun (k : ImportGraph.Shake.NeedsKind) => n.applyAt k (f k)
Instances For
Whether f : Bitset → Bool is true for all of the component bitsets of the given Needs.
Equations
- n.all f = ImportGraph.Shake.NeedsKind.all.all fun (x : ImportGraph.Shake.NeedsKind) => n.applyAt x f
Instances For
Whether f : NeedsKind → Bitset → Bool is true for any of the component bitsets of the given
Needs at the bitset's corresponding NeedsKind.
Equations
- n.allWithKind f = ImportGraph.Shake.NeedsKind.all.all fun (k : ImportGraph.Shake.NeedsKind) => n.applyAt k (f k)
Instances For
Folds f over the bitsets in Needs (in the order of NeedsKind.all).
Equations
- n.fold f init = Array.foldl (fun (a : α) (k : ImportGraph.Shake.NeedsKind) => n.applyAt k (f a)) init ImportGraph.Shake.NeedsKind.all
Instances For
Folds f over the bitsets in Needs at their corresponding NeedsKinds (in the order of
NeedsKind.all).
Equations
- n.foldWithKind f init = Array.foldl (fun (a : α) (k : ImportGraph.Shake.NeedsKind) => n.applyAt k (f a k)) init ImportGraph.Shake.NeedsKind.all
Instances For
Applies f to all component Bitsets of the given Needs.
Equations
- n.map f = { pub := f n.pub, priv := f n.priv, metaPub := f n.metaPub, metaPriv := f n.metaPriv, privOfPriv := f n.privOfPriv, metaPrivOfPriv := f n.metaPrivOfPriv }
Instances For
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
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
Whether all component bitsets are empty.
Equations
- n.isEmpty = n.all fun (x : ImportGraph.Shake.Bitset) => x.isEmpty
Instances For
Whether the component bitset at k : NeedsKind is empty.
Equations
- ImportGraph.Shake.Needs.isEmptyAt k n = (n.get k).isEmpty
Instances For
Equations
- ImportGraph.Shake.Needs.instSDiff = { sdiff := fun (a b : ImportGraph.Shake.Needs) => a.map₂ b fun (x1 x2 : ImportGraph.Shake.Bitset) => x1 \ x2 }
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
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
- ImportGraph.Shake.Needs.toStringAt i n = toString "[" ++ toString (ImportGraph.Shake.Needs.brailleCellAt i n) ++ toString "]"
Instances For
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
Equations
- ImportGraph.Shake.Needs.instToString = { toString := fun (n : ImportGraph.Shake.Needs) => n.toString }
Equations
- One or more equations did not get rendered due to their size.
The NeedsKinds which land (directly) in the private scope.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The NeedsKinds which land (directly) in the public scope.
Equations
Instances For
The NeedsKinds which (directly) demand the private scope.
Equations
Instances For
The NeedsKinds which (directly) demand the public scope.
Equations
Instances For
The NeedsKinds which land (directly) in the given scope.
Equations
Instances For
The NeedsKinds which (directly) demand the given scope.
Equations
Instances For
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.
Instances For
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.
Instances For
The NeedsKinds which demand the private scope after taking into account public ⊆ private
on both ends.
Instances For
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.
Instances For
The scope (directly) demanded by the NeedsKind.
Equations
Instances For
The scope targeted by the NeedsKind.
Equations
Instances For
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
- ImportGraph.Shake.NeedsKind.connects Lean.Environment.Visibility.public Lean.Environment.Visibility.private k = true
- ImportGraph.Shake.NeedsKind.connects Lean.Environment.Visibility.public Lean.Environment.Visibility.public k = k.isExported
- ImportGraph.Shake.NeedsKind.connects Lean.Environment.Visibility.private Lean.Environment.Visibility.private k = k.isAll
- ImportGraph.Shake.NeedsKind.connects Lean.Environment.Visibility.private Lean.Environment.Visibility.public k = false
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
Equations
Instances For
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
- One or more equations did not get rendered due to their size.
- ImportGraph.Shake.NeedsKind.connecting? Lean.Environment.Visibility.private Lean.Environment.Visibility.public isMeta = none