Quick structural: same constructor, recursively same children (no WHNF).
(
&mut self,
a: &KExpr<M>,
b: &KExpr<M>,
)
| 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, _), |
no test coverage detected