MCPcopy Create free account
hub / github.com/argumentcomputer/ix / ordered_insert

Function ordered_insert

crates/kernel/src/level.rs:354–363  ·  view source on GitHub ↗

Insert into a sorted list, returning `None` if already present.

(a: u64, list: &[u64])

Source from the content-addressed store, hash-verified

352
353/// Insert `(idx, k)` into the var list at `path`, taking the max of offsets
354/// when `idx` is already present. Mirrors Lean4Lean's
355/// `NormLevel.addNode v k path'` (`refs/lean4lean/Lean4Lean/Level.lean:92`);
356/// `k` must be the current succ-accumulator from `normalize_aux`.
357///
358/// An earlier port of this function dropped `k` and always inserted
359/// `(idx, 0)`, which silently mis-normalized `Succ^n(imax(u, Param v))`
360/// shapes for `n > 0`. Keep the `k` parameter.
361fn norm_add_node(s: &mut NormLevel, idx: u64, k: u64, path: &[u64]) {
362 s.entry(path.to_vec()).or_default().add_var(idx, k);
363}
364
365fn norm_add_const(s: &mut NormLevel, k: u64, path: &[u64]) {
366 if k == 0 || (k == 1 && !path.is_empty()) {

Callers 2

normalize_auxFunction · 0.85
normalize_imax_dispatchFunction · 0.85

Calls 1

insertMethod · 0.45

Tested by

no test coverage detected