This PR fixes an issue where uses of 'noncomputable' definitions can get incorrectly compiled, while also removing the use of 'noncomputable' definitions altogether. Some uses of 'noncomputable' definitions (e.g. Classical.propDecidable) do not get compiled correctly by type erasure. Running the optimizer on the result can lead to them being optimized away, eluding the later IR-level check for uses of noncomputable definitions. To fix this, we add a 'noncomputable' check earlier in the erase_irrelevant pass.
20 lines
659 B
Text
20 lines
659 B
Text
open scoped Classical
|
|
|
|
/--
|
|
error: tactic 'native_decide' failed, could not evaluate decidable instance. Error: (interpreter)
|
|
unknown declaration 'ohno._nativeDecide_1'
|
|
---
|
|
error: failed to compile definition, consider marking it as 'noncomputable' because it depends on
|
|
'Classical.propDecidable', which is 'noncomputable'
|
|
-/
|
|
#guard_msgs in
|
|
theorem ohno : False := by
|
|
let f : Nat → Nat := fun n => if n=0 then 0 else
|
|
if (∃ k, n = 2 * k) then n / 2 else 3 * n + 1;
|
|
have h2 : f (f 2) ≠ 4 := by
|
|
native_decide;
|
|
have h2 : f (f 2) = 4 := by
|
|
have : ∃ k, 2 = 2 * k := ⟨1, rfl⟩
|
|
simp +decide +arith [f, this];
|
|
omega
|
|
contradiction
|