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

Method replace_aux_refs_for_sort

crates/kernel/src/inductive.rs:759–878  ·  view source on GitHub ↗

Rewrite nested occurrences in synthetic aux member/ctor types to the corresponding synthetic aux constants before running `sort_consts` partition refinement. Compile-side `expand_nested_block` does this via its queue pass over all expanded constructors; the kernel has already discovered the flat aux set, so it can rewrite by matching each occurrence against that set.

(
    &mut self,
    e: &KExpr<M>,
    aux: &[FlatBlockMember<M>],
    aux_ids: &[KId<M>],
    block_us: &[KUniv<M>],
    n_block_params: u64,
    local_depth: u64,
  )

Source from the content-addressed store, hash-verified

757 own_params: ext_params,
758 n_indices: ext_indices,
759 ctors: ext_ctors,
760 lvls: ext_lvls,
761 ind_us: aux_us,
762 occurrence_us,
763 });
764 Ok(())
765 })();
766 self.lctx.truncate(saved_lctx);
767 result
768 }
769
770 /// Rewrite nested occurrences in synthetic aux member/ctor types to the
771 /// corresponding synthetic aux constants before running `sort_consts`
772 /// partition refinement. Compile-side `expand_nested_block` does this via
773 /// its queue pass over all expanded constructors; the kernel has already
774 /// discovered the flat aux set, so it can rewrite by matching each
775 /// occurrence against that set.
776 fn replace_aux_refs_for_sort(
777 &mut self,
778 e: &KExpr<M>,
779 aux: &[FlatBlockMember<M>],
780 aux_ids: &[KId<M>],
781 block_us: &[KUniv<M>],
782 n_block_params: u64,
783 local_depth: u64,
784 ) -> Result<KExpr<M>, TcError<M>> {
785 if let Some(replaced) = self.try_replace_aux_ref_for_sort(
786 e,
787 aux,
788 aux_ids,
789 block_us,
790 n_block_params,
791 local_depth,
792 )? {
793 return Ok(replaced);
794 }
795
796 let result = match e.data() {
797 ExprData::App(f, a, _) => {
798 let f2 = self.replace_aux_refs_for_sort(
799 f,
800 aux,
801 aux_ids,
802 block_us,
803 n_block_params,
804 local_depth,
805 )?;
806 let a2 = self.replace_aux_refs_for_sort(
807 a,
808 aux,
809 aux_ids,
810 block_us,
811 n_block_params,
812 local_depth,
813 )?;
814 KExpr::app(f2, a2)
815 },
816 ExprData::Lam(n, bi, ty, body, _) => {

Callers 1

canonical_aux_orderMethod · 0.80

Calls 7

let_Function · 0.85
intern_exprMethod · 0.80
appFunction · 0.70
lamFunction · 0.70
dataMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected