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

Function syntax_like_rec_binder_count

crates/kernel/src/inductive.rs:5900–5933  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5898
5899 assert_eq!(rules.len(), 2, "Nat.rec should have 2 rules");
5900
5901 // Rule 0 (zero): fields=0
5902 assert_eq!(rules[0].fields, 0);
5903 // rhs = λ (motive) (h_zero) (h_succ), h_zero
5904 // = Lam(_, Lam(_, Lam(_, Var(1))))
5905 // Var(1) = h_zero (2nd from top: Var(0)=h_succ, Var(1)=h_zero)
5906 let _expected_zero = lam(
5907 pi(cnst("Nat", &[]), AE::sort(param(0))), // motive type (placeholder domain)
5908 lam(
5909 app(var(0), cnst("Nat.zero", &[])), // h_zero type (placeholder)
5910 lam(
5911 KExpr::sort(KUniv::zero()), // h_succ type (placeholder, won't be checked structurally)
5912 var(1), // h_zero
5913 ),
5914 ),
5915 );
5916 // Just check the BODY structure — the lambda domains don't matter for iota,
5917 // only the body does. Let's check fields and that the rule is well-formed.
5918 // For now, just verify the rule exists and has the right field count.
5919
5920 // Rule 1 (succ): fields=1
5921 assert_eq!(rules[1].fields, 1);
5922 // rhs body (after applying 3 pmm + 1 field = 4 lambdas):
5923 // h_succ n (Nat.rec motive h_zero h_succ n)
5924 // Check the rhs has the right lambda count
5925 let count_lams = |e: &AE| -> usize {
5926 let mut n = 0;
5927 let mut c = e.clone();
5928 while let ExprData::Lam(_, _, _, body, _) = c.data() {
5929 n += 1;
5930 c = body.clone();
5931 }
5932 n
5933 };
5934 // pmm = 0 params + 1 motive + 2 minors = 3, plus 1 field = 4 lambdas
5935 let n_lams = count_lams(&rules[1].rhs);
5936 assert_eq!(

Callers

nothing calls this directly

Calls 9

syntax_like_envFunction · 0.85
max_rec_fuelFunction · 0.85
check_constMethod · 0.80
mk_idFunction · 0.70
contains_keyMethod · 0.45
getMethod · 0.45
cloneMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected