pub struct ShapeMask(/* private fields */);Expand description
The set of NodeShapes occurring anywhere in a subterm — one u16, computed once at
interning time and answered in O(1) thereafter.
§The Lean design this copies
Lean’s Expr carries a 64-bit Expr.Data word in every node, and four of its bits are
exactly this idea: hasFVar, hasExprMVar, hasLevelMVar, hasLevelParam
(Lean/Expr.lean:121-124). Expr.mkAppData propagates all four with a single OR of the two
children’s words — ((fData ||| aData) &&& (15 <<< 40)) ||| … (Lean/Expr.lean:193) — so an
application’s bits cost one instruction rather than a traversal. What they BUY is visible at
Lean/Expr.lean:1661: let rec visit (e : Expr) := if !e.hasFVar then false else …, a walk
that stops before it starts.
Ours widens the idea from four hand-picked predicates to one bit per node kind, which is what
lets beta_zeta_normal_form decide in O(1) whether a term can hold a redex it does not own.
The cost is the same: one OR per child at interning time, in TermStore::compute_info.
Implementations§
Source§impl ShapeMask
impl ShapeMask
Sourcepub const BETA_ZETA: ShapeMask
pub const BETA_ZETA: ShapeMask
The shapes a term made only of Sort, Var, Global, App, Lambda, Pi and Let
can have — the admissible surface of beta_zeta_normal_form. Its complement is
Const, Match, Fix, MutualFix, Lit, Hole and Bound.