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

Method compute_k_target

crates/kernel/src/inductive.rs:4456–4494  ·  view source on GitHub ↗

S1: Compute K-target flag constructively. K-like reduction is sound iff: 1. Single inductive (not part of a mutual block with >1 inductive) 2. Result universe is Prop (level is zero) 3. Exactly one constructor with zero non-param fields

(&mut self, ind_id: &KId<M>)

Source from the content-addressed store, hash-verified

4454 };
4455 field_domains.push(lifted_dom);
4456 minor_cur = b.clone();
4457 },
4458 _ => break,
4459 }
4460 }
4461 // Wrap in reverse: last field innermost, first field outermost.
4462 // This ensures Var(n_fields-1) = first field, Var(0) = last field,
4463 // matching the body's de Bruijn indexing.
4464 for i in (0..field_domains.len()).rev() {
4465 body = self.intern(KExpr::lam(
4466 anon(),
4467 bi_default(),
4468 field_domains[i].clone(),
4469 body,
4470 ));
4471 }
4472
4473 // PMM lambdas: extract actual domains from the peer recursor's type.
4474 // The recursor type has the shape:
4475 // ∀ (params...) (motives...) (minors...) (indices...) (major), ret
4476 // We need the first pmm domains for the rule's leading lambdas.
4477 // Do NOT instantiate universe params: the rule RHS and recursor type share
4478 // the same Param references. The stored rule was built by Lean with the same
4479 // Param indices as the recursor type.
4480 let mut pmm_domains: Vec<KExpr<M>> = Vec::with_capacity(pmm);
4481 let mut rec_ty_cur = rec_ty_for_member.clone();
4482 for _ in 0..pmm {
4483 let w = self.whnf(&rec_ty_cur)?;
4484 match w.data() {
4485 ExprData::All(_, _, dom, b, _) => {
4486 pmm_domains.push(dom.clone());
4487 rec_ty_cur = b.clone();
4488 },
4489 _ => {
4490 // Fallback to placeholder if recursor type is shorter than expected
4491 pmm_domains.push(KExpr::sort(KUniv::zero()));
4492 break;
4493 },
4494 }
4495 }
4496 // Wrap body in PMM lambdas (inside-out: minors, then motives, then params)
4497 // pmm_domains is [p0, ..., pk, m0, ..., ml, min0, ..., minr]

Callers 2

check_recursor_memberMethod · 0.80

Calls 7

u64_to_usizeFunction · 0.85
univ_eqFunction · 0.85
get_result_sort_levelMethod · 0.80
try_get_constMethod · 0.45
cloneMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected