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

Method inductive_app_is_prop

crates/kernel/src/infer.rs:486–518  ·  view source on GitHub ↗
(
    &mut self,
    ind_id: &KId<M>,
    levels: &[KUniv<M>],
    binders: usize,
  )

Source from the content-addressed store, hash-verified

484
485 fn inductive_app_is_prop(
486 &mut self,
487 ind_id: &KId<M>,
488 levels: &[KUniv<M>],
489 binders: usize,
490 ) -> Result<bool, TcError<M>> {
491 use super::level::{KUniv, univ_eq};
492
493 let ind_ty = match self.try_get_const(ind_id)? {
494 Some(KConst::Indc { ty, .. }) => ty,
495 _ => {
496 return Err(TcError::Other("projection: not an inductive type".into()));
497 },
498 };
499 let levels_vec: Vec<_> = levels.to_vec();
500 let mut r = self.instantiate_univ_params(&ind_ty, &levels_vec)?;
501 for _ in 0..binders {
502 let wr = self.whnf(&r)?;
503 match wr.data() {
504 ExprData::All(_, _, _, body, _) => {
505 r = body.clone();
506 },
507 _ => {
508 return Err(TcError::Other(
509 "projection: expected forall in inductive type".into(),
510 ));
511 },
512 }
513 }
514 let sort_ty = self.whnf(&r)?;
515 let level = self.ensure_sort(&sort_ty)?;
516 Ok(univ_eq(&level, &KUniv::zero()))
517 }
518}
519
520fn compact_expr<M: KernelMode>(e: &KExpr<M>) -> String {
521 compact_expr_deep(e, 1)

Callers 1

infer_projMethod · 0.80

Calls 7

univ_eqFunction · 0.85
whnfMethod · 0.80
ensure_sortMethod · 0.80
try_get_constMethod · 0.45
dataMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected