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

Function cheap_beta_nested_bvar_picks_outer_arg

crates/kernel/src/subst.rs:1253–1266  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1251 let fv1 = AE::fvar(FVarId(1), ());
1252 // Two binders peeled → Var(3) shifts down to Var(1)
1253 let result = instantiate_rev(&mut env, &v3, &[fv0, fv1]);
1254 assert_eq!(result, AE::var(1, ()));
1255 }
1256
1257 #[test]
1258 fn instantiate_rev_under_inner_binder() {
1259 let mut env = InternTable::<Anon>::new();
1260 let nat = AE::cnst(KId::new(mk_addr("Nat"), ()), Box::new([]));
1261 let v0 = AE::var(0, ()); // bound by inner λ
1262 let v1 = AE::var(1, ()); // refers to outer (the peeled binder at depth 0)
1263 let inner = AE::app(v0, v1);
1264 let lam = AE::lam((), (), nat.clone(), inner);
1265 let fv0 = AE::fvar(FVarId(0), ());
1266 let result = instantiate_rev(&mut env, &lam, std::slice::from_ref(&fv0));
1267 // Inside the lambda, Var(0) is still bound, Var(1) becomes fv0.
1268 let expected = AE::lam((), (), nat, AE::app(AE::var(0, ()), fv0));
1269 assert_eq!(result, expected);

Callers

nothing calls this directly

Calls 8

cheap_beta_reduceFunction · 0.85
cnstFunction · 0.70
mk_addrFunction · 0.70
varFunction · 0.70
lamFunction · 0.70
natFunction · 0.70
appFunction · 0.70
cloneMethod · 0.45

Tested by

no test coverage detected