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

Method build_minor_at_depth

crates/kernel/src/inductive.rs:2597–2807  ·  view source on GitHub ↗

Build minor premise type for a constructor, called while params and motives are already on the context. This makes de Bruijn indices correct. For constructor `C : ∀ params fields, I params indices`: ```text ∀ (f₁ : F₁) ... (fₙ : Fₙ) (ih₁ : ∀ xs, motive(indices(rec_field₁ xs), rec_field₁ xs)) ... (ihₘ : ∀ xs, motive(indices(rec_fieldₘ xs), rec_fieldₘ xs)), motive(ctor_indices, C params f₁...fₙ) ``

(
    &mut self,
    ind_idx: usize,
    ctor_id: &KId<M>,
    member: &FlatBlockMember<M>,
    n_rec_params: usize,
    motive_base: usize, // context level where motives start
    flat: &[FlatBlockM

Source from the content-addressed store, hash-verified

2595 // major scope.
2596 let lift_by = u64_to_usize::<M>(depth)?;
2597 for sp in member.spec_params.iter() {
2598 let lifted = if lift_by > 0 {
2599 lift(&mut self.env.intern, sp, lift_by as u64, 0)
2600 } else {
2601 sp.clone()
2602 };
2603 major_ty = self.intern(KExpr::app(major_ty, lifted));
2604 }
2605 }
2606 // Apply indices (the index binders we're about to wrap around).
2607 for i in 0..n_idx {
2608 let v = self.intern(KExpr::var((n_idx - 1 - i) as u64, anon()));
2609 major_ty = self.intern(KExpr::app(major_ty, v));
2610 }
2611
2612 // Build: ∀ (major : major_ty), Sort elim_level
2613 let sort = self.intern(KExpr::sort(elim_level.clone()));
2614 let mut result =
2615 self.intern(KExpr::all(anon(), bi_default(), major_ty, sort));
2616
2617 // Wrap with index foralls (from inside out).
2618 for i in (0..n_idx).rev() {
2619 result = self.intern(KExpr::all(
2620 anon(),
2621 bi_default(),
2622 index_doms[i].clone(),
2623 result,
2624 ));
2625 }
2626
2627 Ok(result)
2628 }
2629
2630 /// Build minor premise type for a constructor, called while params and motives
2631 /// are already on the context. This makes de Bruijn indices correct.
2632 ///
2633 /// For constructor `C : ∀ params fields, I params indices`:
2634 /// ```text
2635 /// ∀ (f₁ : F₁) ... (fₙ : Fₙ)
2636 /// (ih₁ : ∀ xs, motive(indices(rec_field₁ xs), rec_field₁ xs))
2637 /// ...
2638 /// (ihₘ : ∀ xs, motive(indices(rec_fieldₘ xs), rec_fieldₘ xs)),
2639 /// motive(ctor_indices, C params f₁...fₙ)
2640 /// ```
2641 fn build_minor_at_depth(
2642 &mut self,
2643 ind_idx: usize,
2644 ctor_id: &KId<M>,
2645 member: &FlatBlockMember<M>,
2646 n_rec_params: usize,
2647 motive_base: usize, // context level where motives start
2648 flat: &[FlatBlockMember<M>],
2649 block_addrs: &[Address],
2650 _univ_offset: u64,
2651 ) -> Result<KExpr<M>, TcError<M>> {
2652 let ctor = match self.get_const(ctor_id)? {
2653 KConst::Ctor { ty, lvls, .. } => (ty.clone(), lvls),
2654 _ => {

Callers 1

build_rec_typeMethod · 0.80

Calls 15

liftFunction · 0.85
substFunction · 0.85
collect_app_spineFunction · 0.85
whnfMethod · 0.80
depthMethod · 0.80
pushMethod · 0.80
is_rec_fieldMethod · 0.80
push_fvar_decl_anonMethod · 0.80
build_direct_ihMethod · 0.80
internMethod · 0.80
truncateMethod · 0.80

Tested by

no test coverage detected