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

Method check_ctor_against_inductive

crates/kernel/src/inductive.rs:327–356  ·  view source on GitHub ↗

Validate a standalone constructor by checking its parent inductive block.

(
    &mut self,
    ctor_id: &KId<M>,
    induct_id: &KId<M>,
  )

Source from the content-addressed store, hash-verified

325 ctors.clone(),
326 block.clone(),
327 is_unsafe,
328 ty.clone(),
329 ),
330 _ => {
331 return Err(TcError::Other("check_inductive: not an inductive".into()));
332 },
333 };
334 let ind_arity = checked_metadata_sum::<M>(
335 "inductive params + indices",
336 &[params, indices],
337 )?;
338
339 // Discover all inductives in the mutual block
340 let block_inds = self.discover_block_inductives(&block)?;
341 let block_addrs: Vec<Address> =
342 block_inds.iter().map(|id| id.addr.clone()).collect();
343
344 // Inductive type must reduce to a Sort after peeling params+indices.
345 // This must be checked even for inductives with no constructors.
346 let ind_level =
347 self.get_result_sort_level(&ty, u64_to_usize(ind_arity)?)?;
348
349 // S3 + S3b: Peer-agreement invariants for mutual inductives.
350 //
351 // S3: all peers live in the same result universe.
352 // S3b: all peers share the same parameter count and parameter-domain
353 // types. Without S3b, `build_rec_type` — which takes the shared
354 // param prefix uniformly from `ind_infos[0]` — would produce a
355 // generated recursor whose param binders misalign with a peer's
356 // ctor arguments, yielding de-Bruijn-shifted iota reductions and,
357 // in the limit, ill-typed stored terms. Enforcing agreement
358 // kernel-side removes the implicit compiler trust.
359 //

Callers

nothing calls this directly

Calls 7

try_get_blockMethod · 0.80
check_inductive_blockMethod · 0.80
try_get_constMethod · 0.45
cloneMethod · 0.45
getMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected