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

Method quick_def_eq

crates/kernel/src/def_eq.rs:557–603  ·  view source on GitHub ↗

Quick structural: same constructor, recursively same children (no WHNF).

(
    &mut self,
    a: &KExpr<M>,
    b: &KExpr<M>,
  )

Source from the content-addressed store, hash-verified

555 if wa_changed || wb_changed {
556 return self.is_def_eq(&wa_core, &wb_core);
557 }
558 let wa = wa_core;
559 let wb = wb_core;
560 if wa.ptr_eq(&wb) {
561 return Ok(true);
562 }
563 if self.quick_def_eq(&wa, &wb)? {
564 return Ok(true);
565 }
566
567 // Tier 4d: app spine comparison (lean4lean isDefEqApp, lean4 type_checker.cpp:1115)
568 if self.try_def_eq_app(&wa, &wb)? {
569 return Ok(true);
570 }
571
572 let result = self.is_def_eq_whnf(&wa, &wb);
573
574 // Tier 5 final-fail trace: when IX_DEF_EQ_TIER5_DUMP is set and the
575 // pair's head names contain the configured substring, dump the
576 // post-whnfCore wa/wb. This is where lazy-delta + Tier 4c gave up.
577 if let Ok(prefix) = crate::env_var("IX_DEF_EQ_TIER5_DUMP")
578 && let Ok(false) = result.as_ref()
579 {
580 let a_match = head_const_name(&wa).is_some_and(|n| n.contains(&prefix));
581 let b_match = head_const_name(&wb).is_some_and(|n| n.contains(&prefix));
582 if prefix.is_empty() || a_match || b_match {
583 log::info!("[deq tier5 fail] depth={}", self.def_eq_depth);
584 log::info!(" wa: {wa}");
585 log::info!(" wb: {wb}");
586 }
587 }
588
589 result
590 }
591
592 /// Quick structural: same constructor, recursively same children (no WHNF).
593 fn quick_def_eq(
594 &mut self,
595 a: &KExpr<M>,
596 b: &KExpr<M>,
597 ) -> Result<bool, TcError<M>> {
598 match (a.data(), b.data()) {
599 (ExprData::Sort(u1, _), ExprData::Sort(u2, _)) => Ok(univ_eq(u1, u2)),
600 (
601 ExprData::Lam(name, bi, ty1, body1, _),
602 ExprData::Lam(_, _, ty2, body2, _),
603 )
604 | (
605 ExprData::All(name, bi, ty1, body1, _),
606 ExprData::All(_, _, ty2, body2, _),

Callers 2

is_def_eq_innerMethod · 0.80

Calls 10

univ_eqFunction · 0.85
internMethod · 0.80
pushMethod · 0.80
truncateMethod · 0.80
instantiate_revFunction · 0.70
dataMethod · 0.45
is_def_eqMethod · 0.45
lenMethod · 0.45
fresh_fvar_idMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected