Compare two inductives by derived flags, params, indices, constructor count, type, then constructors. Includes `is_rec` and `is_unsafe` to prevent alpha-collapse from merging inductives whose derived properties differ — a mismatch in `is_rec` would cause the collapsed representative to silently omit `.brecOn` for aliases that need it (or generate it for aliases that shouldn't have it).
( x: &Ind, y: &Ind, mut_ctx: &MutCtx, cache: &mut BlockCache, stt: &CompileState, )
| 2676 | ) -> Result<(Quotient, ConstantMeta), CompileError> { |
| 2677 | cache.compiling = Some(val.cnst.name.clone()); |
| 2678 | let univ_params = &val.cnst.level_params; |
| 2679 | |
| 2680 | let typ = |
| 2681 | compile_expr(&val.cnst.typ, univ_params, &MutCtx::default(), cache, stt)?; |
| 2682 | let type_root = |
| 2683 | *cache.arena_roots.last().expect("missing quot type arena root"); |
| 2684 | |
| 2685 | // Drain surgery sharing onto this quotient's meta — same reasoning as |
| 2686 | // in compile_axiom / compile_recursor / etc.: keep collapsed args |
| 2687 | // attached to the constant whose compilation produced them. Same for |
| 2688 | // the level-spelling channels (canonicity §10.6). |
| 2689 | let arena = std::mem::take(&mut cache.arena); |
| 2690 | let surgery_sharing = std::mem::take(&mut cache.surgery_sharing); |
| 2691 | let meta_univs: Vec<Arc<Univ>> = |
| 2692 | std::mem::take(&mut cache.meta_univs).into_iter().collect(); |
| 2693 | let univ_patches = std::mem::take(&mut cache.univ_patches); |
| 2694 | cache.arena_roots.clear(); |
| 2695 | cache.exprs.clear(); |
| 2696 | |
| 2697 | let name_addr = compile_name(&val.cnst.name, stt); |
| 2698 | let lvl_addrs: Vec<Address> = |
| 2699 | univ_params.iter().map(|n| compile_name(n, stt)).collect(); |
| 2700 | |
| 2701 | let data = Quotient { kind: val.kind, lvls: univ_params.len() as u64, typ }; |
| 2702 | |
| 2703 | let mut meta = ConstantMeta::new(ConstantMetaInfo::Quot { |
| 2704 | name: name_addr, |
| 2705 | lvls: lvl_addrs, |
| 2706 | arena, |
| 2707 | type_root, |
| 2708 | }); |
| 2709 | meta.meta_sharing = surgery_sharing; |
| 2710 | meta.meta_univs = meta_univs; |
| 2711 | meta.univ_patches = univ_patches; |
| 2712 | |
| 2713 | Ok((data, meta)) |
| 2714 | } |
| 2715 | |
| 2716 | // =========================================================================== |
| 2717 | // Mutual block compilation |
| 2718 | // =========================================================================== |
| 2719 | |
| 2720 | /// Result of compiling a mutual block. |
| 2721 | pub struct CompiledMutualBlock { |
| 2722 | /// The compiled Constant |
| 2723 | pub constant: Constant, |
| 2724 | /// Content-addressed hash |
| 2725 | pub addr: Address, |
| 2726 | /// Hash-consed size (theoretical minimum with perfect DAG sharing) |
| 2727 | pub hash_consed_size: usize, |
| 2728 | /// Serialized size (actual bytes) |
| 2729 | pub serialized_size: usize, |
| 2730 | } |
| 2731 | |
| 2732 | /// Compile a mutual block with block-level sharing. |
no test coverage detected