lean4-htt/tests/lean/run/Decidable-decide-erasure.lean
Henrik Böving 5ce756f350
refactor: introduce a phase separation to the IR (#12214)
This PR introduces a phase separation to the LCNF IR. This is a
preparation for the merge of
the old `Lean.Compiler.IR` and the new `Lean.Compiler.LCNF` framework.

The change parametrizes all relevant `LCNF` data structures over a
`Purity` parameter and
additionally carries around proofs that the `Purity` has certain values,
depending on what's
required. This is done as opposed to indexing the types over `Purity`
because we do (almost) never
have to store the `Purity` value for phase generic structures this way.
2026-01-30 09:42:29 +00:00

23 lines
621 B
Text

import Lean.Compiler
import Lean.Compiler.LCNF.Probing
open Lean.Compiler.LCNF
def f (a : Nat) : Bool :=
decide (a = 1)
-- This is only required until the new code generator is enabled.
run_meta Lean.Compiler.compile #[``f]
def countCalls : Probe (Decl .pure) Nat :=
Probe.getLetValues .pure >=>
Probe.filter (fun e => return e matches .const `Decidable.decide ..) >=>
Probe.count
#eval do
let numCalls <- Probe.runOnDeclsNamed #[`f] (phase := .base) <| countCalls
assert! numCalls == #[1]
#eval do
let numCalls <- Probe.runOnDeclsNamed #[`f] (phase := .mono) <| countCalls
assert! numCalls == #[0]