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

Method nat_succ_of

crates/kernel/src/def_eq.rs:926–944  ·  view source on GitHub ↗

If expression is nat-succ, return the predecessor. Matches both `Nat(n+1)` → `Nat(n)` and `Nat.succ e` → `e`.

(&mut self, e: &KExpr<M>)

Source from the content-addressed store, hash-verified

924 return Ok(false);
925 }
926 // Both must have the same type
927 let b_ty = match self.with_infer_only(|tc| tc.infer(b)) {
928 Ok(ty) => ty,
929 Err(_) => return Ok(false),
930 };
931 self.is_def_eq(&a_ty_w, &b_ty)
932 }
933
934 // -----------------------------------------------------------------------
935 // Nat literal ↔ constructor comparison
936 // -----------------------------------------------------------------------
937
938 /// Check if an expression is a nat-like value (literal, Nat.zero, Nat.succ _).
939 fn is_nat_like(&self, e: &KExpr<M>) -> bool {
940 match e.data() {
941 ExprData::Nat(..) => true,
942 ExprData::Const(id, _, _) => id.addr == self.prims.nat_zero.addr,
943 ExprData::App(f, _, _) => {
944 matches!(f.data(), ExprData::Const(id, _, _) if id.addr == self.prims.nat_succ.addr)
945 },
946 _ => false,
947 }

Callers 2

is_def_eq_natMethod · 0.80
try_def_eq_offsetMethod · 0.80

Calls 4

intern_exprMethod · 0.80
natFunction · 0.70
dataMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected