(
&mut self,
root: &KExpr<M>,
root_depth: u64,
lvl_bound: usize,
mut timing: Option<&mut ValidationTiming>,
)
| 498 | ) -> Result<Option<KId<M>>, TcError<M>> { |
| 499 | match c { |
| 500 | KConst::Defn { block, .. } => { |
| 501 | self.coordinated_block_if_kind(block, CheckBlockKind::Defn) |
| 502 | }, |
| 503 | KConst::Indc { block, .. } => { |
| 504 | self.coordinated_block_if_kind(block, CheckBlockKind::Inductive) |
| 505 | }, |
| 506 | KConst::Ctor { induct, .. } => { |
| 507 | let Some(parent) = self.try_get_const(induct)? else { |
| 508 | return Ok(None); |
| 509 | }; |
| 510 | match parent { |
| 511 | KConst::Indc { block, .. } => { |
| 512 | self.coordinated_block_if_kind(&block, CheckBlockKind::Inductive) |
| 513 | }, |
| 514 | _ => Ok(None), |
| 515 | } |
| 516 | }, |
| 517 | KConst::Recr { block, .. } => { |
| 518 | self.coordinated_block_if_kind(block, CheckBlockKind::Recursor) |
| 519 | }, |
| 520 | KConst::Axio { .. } | KConst::Quot { .. } => Ok(None), |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | fn coordinated_block_if_kind( |
| 525 | &mut self, |
| 526 | block: &KId<M>, |
| 527 | expected: CheckBlockKind, |
| 528 | ) -> Result<Option<KId<M>>, TcError<M>> { |
| 529 | let Some(members) = self.try_get_block(block)? else { |
| 530 | return Ok(None); |
| 531 | }; |
| 532 | match self.classify_block(&members) { |
| 533 | Ok(kind) if kind == expected => Ok(Some(block.clone())), |
| 534 | Ok(_) | Err(_) => Ok(None), |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | fn classify_block( |
| 539 | &mut self, |
| 540 | members: &[KId<M>], |
| 541 | ) -> Result<CheckBlockKind, TcError<M>> { |
| 542 | if members.is_empty() { |
| 543 | return Err(TcError::Other("empty check block".into())); |
| 544 | } |
| 545 | |
| 546 | let mut saw_defn = false; |
| 547 | let mut saw_recr = false; |
| 548 | let mut saw_inductive_like = false; |
| 549 | for member in members { |
| 550 | match self.get_const(member)? { |
| 551 | KConst::Defn { .. } => saw_defn = true, |
| 552 | KConst::Recr { .. } => saw_recr = true, |
| 553 | KConst::Indc { .. } | KConst::Ctor { .. } => { |
| 554 | saw_inductive_like = true; |
| 555 | }, |
| 556 | KConst::Axio { .. } | KConst::Quot { .. } => { |
| 557 | return Err(TcError::Other(format!( |
no test coverage detected