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

Function bad_fun_eta

crates/kernel/src/tutorial/defeq.rs:107–167  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

105 /// BAD: eta should NOT identify functions with different bodies.
106 #[test]
107 fn bad_fun_eta() {
108 let mut env = KEnv::<Meta>::new();
109 add_eq_axioms(&mut env);
110
111 // ∀ (α : Type) (β : Type) (g : α → α) (f : α → β), (fun x => f (g x)) = f
112 // At g_ty position (depth 2): α=var(1), β=var(0)
113 // g : α → α = pi(var(1), var(2)) — inside pi: α shifts from 1→2
114 // At f_ty position (depth 3): α=var(2), β=var(1), g=var(0)
115 // f : α → β = pi(var(2), var(2)) — inside pi: β shifts from 1→2
116 // Inside body (depth 4): f=var(0), g=var(1), β=var(2), α=var(3)
117 // lhs = fun (x : α) => f (g x). α at depth 4 = var(3).
118 // Inside lambda (depth 5): x=var(0), f=var(1), g=var(2), β=var(3), α=var(4)
119 let lhs = nlam("x", var(3), app(var(1), app(var(2), var(0))));
120 // α → β at depth 4: pi(var(3), var(3)) — inside pi β shifts from 2→3
121 let eq_app =
122 apps(cnst("Eq", &[usucc(uzero())]), &[pi(var(3), var(3)), lhs, var(0)]);
123 let ty = npi(
124 "α",
125 sort1(),
126 npi(
127 "β",
128 sort1(),
129 npi(
130 "g",
131 pi(var(1), var(2)), // g : α → α (at depth 2)
132 npi(
133 "f",
134 pi(var(2), var(2)), // f : α → β (at depth 3)
135 eq_app,
136 ),
137 ),
138 ),
139 );
140
141 // fun α β g f => Eq.refl f (bogus: claims f∘g = f)
142 // At depth 4 inside val: f=var(0), g=var(1), β=var(2), α=var(3)
143 let val = nlam(
144 "α",
145 sort1(),
146 nlam(
147 "β",
148 sort1(),
149 nlam(
150 "g",
151 pi(var(1), var(2)),
152 nlam(
153 "f",
154 pi(var(2), var(2)),
155 apps(
156 cnst("Eq.refl", &[usucc(uzero())]),
157 &[pi(var(3), var(3)), var(0)],
158 ),
159 ),
160 ),
161 ),
162 );
163
164 let (id, c) = mk_thm("funEtaBad", 0, vec![], ty, val);

Callers

nothing calls this directly

Calls 15

add_eq_axiomsFunction · 0.85
nlamFunction · 0.85
appsFunction · 0.85
usuccFunction · 0.85
uzeroFunction · 0.85
npiFunction · 0.85
mk_thmFunction · 0.85
check_rejectsFunction · 0.85
varFunction · 0.50
appFunction · 0.50
cnstFunction · 0.50
piFunction · 0.50

Tested by

no test coverage detected