Compile a batch of regenerated `MutConst`s as a mutual block (mirroring `compile_aux_block`), then decompile each member with original metadata from `named.original` to restore binder names. Returns a map from constant name to decompiled `LeanConstantInfo`. Constructor entries from inductives are included under their own names. `orig_env` is the immutable original Lean environment from the compi
( consts: &[LeanMutConst], generated_consts: &FxHashMap<Name, LeanConstantInfo>, orig_env: Option<&LeanEnv>, stt: &CompileState, dstt: &DecompileState, )
| 2404 | |
| 2405 | /// Convert a `BRecOnDef` to a `LeanConstantInfo`. |
| 2406 | /// |
| 2407 | /// Replicates Lean's `Lean/Meta/Constructions/BRecOn.lean` per-kind decisions: |
| 2408 | /// |
| 2409 | /// | Shape | Emits | Hints | |
| 2410 | /// |-----------------------|--------------------------|----------| |
| 2411 | /// | `.brecOn` (Prop, safe) | `ThmInfo` | — | |
| 2412 | /// | `.brecOn` (Prop, unsafe) | `DefnInfo` (`Unsafe`) | `Opaque` | |
| 2413 | /// | `.brecOn` (Type) | `DefnInfo` (`Safe`/`Unsafe`) | `Abbrev` | |
| 2414 | /// | `.brecOn.go` | `DefnInfo` (`Safe`/`Unsafe`) | `Abbrev` | |
| 2415 | /// | `.brecOn.eq` (safe) | `ThmInfo` | — | |
| 2416 | /// | `.brecOn.eq` (unsafe) | `DefnInfo` (`Unsafe`) | `Opaque` | |
| 2417 | /// |
| 2418 | /// The unsafe-`.eq` flip mirrors Lean's `mkThmOrUnsafeDef` |
| 2419 | /// (`Lean/Environment.lean:2797`), which replaces a theorem with an unsafe |
| 2420 | /// definition whenever `env.hasUnsafe` fires on the type or value. |
| 2421 | fn brecon_def_to_lean( |
| 2422 | def: &crate::compile::aux_gen::brecon::BRecOnDef, |
| 2423 | ) -> LeanConstantInfo { |
| 2424 | let cnst = ConstantVal { |
| 2425 | name: def.name.clone(), |
| 2426 | level_params: def.level_params.clone(), |
| 2427 | typ: def.typ.clone(), |
| 2428 | }; |
| 2429 | |
| 2430 | let is_eq = def.name.last_str() == Some("eq"); |
| 2431 | // Emit `ThmInfo` when Lean would have emitted `.thmDecl`: Prop-level |
| 2432 | // `.brecOn` or safe Type-level `.brecOn.eq`. Unsafe cases always flatten |
| 2433 | // into an unsafe `DefnInfo` with opaque reducibility. |
| 2434 | let as_theorem = (def.is_prop || is_eq) && !def.is_unsafe; |
| 2435 | |
| 2436 | if as_theorem { |
| 2437 | LeanConstantInfo::ThmInfo(TheoremVal { |
| 2438 | cnst, |
| 2439 | value: def.value.clone(), |
| 2440 | all: vec![def.name.clone()], |
| 2441 | }) |
| 2442 | } else { |
| 2443 | // Hints: `.opaque` matches Lean's `mkThmOrUnsafeDef` for the unsafe-eq |
| 2444 | // flip (and unsafe Prop-level `.brecOn`, which in practice never |
| 2445 | // happens — Lean forbids `unsafe` in Prop — but we honor the flag). |
| 2446 | // `.abbrev` matches `mkDefinitionValInferringUnsafe … .abbrev` for |
| 2447 | // `.brecOn` / `.brecOn.go`. |
| 2448 | let hints = if def.is_unsafe && (def.is_prop || is_eq) { |
| 2449 | ReducibilityHints::Opaque |
| 2450 | } else { |
| 2451 | ReducibilityHints::Abbrev |
| 2452 | }; |
| 2453 | LeanConstantInfo::DefnInfo(DefinitionVal { |
| 2454 | cnst, |
| 2455 | value: def.value.clone(), |
| 2456 | hints, |
| 2457 | safety: def_safety(def.is_unsafe), |
| 2458 | all: vec![def.name.clone()], |
| 2459 | }) |
| 2460 | } |
| 2461 | } |
| 2462 | |
| 2463 | fn ci_kind(ci: &LeanConstantInfo) -> &'static str { |
no test coverage detected