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

Function subsumption

crates/kernel/src/level.rs:549–574  ·  view source on GitHub ↗
(acc: &mut NormLevel)

Source from the content-addressed store, hash-verified

547 yi += 1;
548 }
549 if yi >= ys.len() || ys[yi] != x {
550 return false;
551 }
552 yi += 1;
553 }
554 true
555}
556
557fn subsumption(acc: &mut NormLevel) {
558 let snapshot: Vec<_> =
559 acc.iter().map(|(k, v)| (k.clone(), v.clone())).collect();
560
561 for (p1, n1) in acc.iter_mut() {
562 for (p2, n2) in &snapshot {
563 if !is_subset(p2, p1) {
564 continue;
565 }
566 let same = p1.len() == p2.len();
567
568 if n1.constant != 0 {
569 let max_var_offset = n1.var.iter().map(|v| v.offset).max().unwrap_or(0);
570 let keep_const = (same || n1.constant > n2.constant)
571 && (n2.var.is_empty() || n1.constant > max_var_offset + 1);
572 if !keep_const {
573 n1.constant = 0;
574 }
575 }
576
577 if !same && !n2.var.is_empty() {

Callers 1

normalize_levelFunction · 0.85

Calls 7

is_subsetFunction · 0.85
subsume_varsFunction · 0.85
iterMethod · 0.45
cloneMethod · 0.45
lenMethod · 0.45
maxMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected