fix: leave the export of realizations to #16623

This reverts "fix: export theorems realized inside proofs as axioms" and its test. Since #16623, a constant realized only inside a proof is not exported at all, which covers the same case.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
diff --git a/src/Lean/Environment.lean b/src/Lean/Environment.lean
index 44495d2..0da2702 100644
--- a/src/Lean/Environment.lean
+++ b/src/Lean/Environment.lean
@@ -661,8 +661,7 @@
   akin to how `checked` collects all declarations. We only use it as a fallback in
   `findAsyncCore?`/`getState`; see there.
   -/
-  private allRealizations : Task (VisibilityMap (NameMap AsyncConst)) :=
-    .pure { «private» := {}, «public» := {} }
+  private allRealizations : Task (NameMap AsyncConst) := .pure {}
   /--
   Indicates whether the environment is being used in an exported context, i.e. whether it should
   provide access to only the data to be imported by other modules participating in the module
@@ -921,17 +920,6 @@
 @[extern "lean_is_reserved_name"]
 private opaque isReservedName (env : Environment) (name : Name) : Bool
 
-/--
-Looks up a realized constant in the value of `allRealizations`. A constant that is not exported is
-found in the public scope as well, in its private form.
--/
-private def findRealization? (env : Environment)
-    (allRealizations : VisibilityMap (NameMap AsyncConst)) (n : Name) : Option AsyncConst :=
-  if env.isExporting then
-    allRealizations.public.find? n <|> allRealizations.private.find? n
-  else
-    allRealizations.private.find? n
-
 @[inline] private def findAsyncConst? (env : Environment) (n : Name) (skipRealize := false) :
     Option AsyncConst := do
   if let some c := env.asyncConsts.find? n then
@@ -942,7 +930,7 @@
     -- Constant generated in a different environment branch
     return c
   if !skipRealize && isReservedName env n then
-    if let some c := findRealization? env env.allRealizations.get n then
+    if let some c := env.allRealizations.get.find? n then
       return c
   -- Not in the kernel environment nor in the name prefix of a known environment branch: undefined
   -- by `addDeclCore` invariant.
@@ -971,7 +959,7 @@
   | _ => Id.run do
     if isReservedName env n && !skipRealize then
       return env.allRealizations.map (sync := true) fun allRealizations => do
-        if let some c := findRealization? env allRealizations n then
+        if let some c := allRealizations.find? n then
           return c.constInfo
         none
     -- see `findAsyncCore?`
@@ -1164,7 +1152,7 @@
   private sigPromise : IO.Promise ConstantVal
   private constPromise : IO.Promise ConstPromiseVal
   private checkedEnvPromise : IO.Promise Kernel.Environment
-  private allRealizationsPromise : IO.Promise (VisibilityMap (NameMap AsyncConst))
+  private allRealizationsPromise : IO.Promise (NameMap AsyncConst)
 
 /-- Creates fallback info to be used in case promises are dropped unfulfilled. -/
 private def mkFallbackConstInfo (constName : Name) (kind : ConstantKind) : ConstantInfo :=
@@ -1805,7 +1793,7 @@
         return ext.getStateImpl exts.get
       -- NOTE: if `exts?` is `none`, we should *not* try the following, more expensive branches that
       -- will just come to the same conclusion
-    else if let some c := env.allRealizations.get.private.find? asyncDecl then
+    else if let some c := env.allRealizations.get.find? asyncDecl then
       if let some exts := c.exts? then
         return ext.getStateImpl exts.get
     -- fallback; we could enforce that `asyncDecl` and its extension state always exist but the
@@ -3021,14 +3009,6 @@
 private def throwUnexpectedType {α} (typeName : Name) (constName : Name) : ExceptT String Id α :=
   throw ("unexpected type at '" ++ toString constName ++ "', `" ++ toString typeName ++ "` expected")
 
-/-- Adds the given realized constants to the value of `Environment.allRealizations`. -/
-private def addRealizations (allRealizations : VisibilityMap (NameMap AsyncConst))
-    (newConsts : VisibilityMap (List AsyncConst)) : VisibilityMap (NameMap AsyncConst) where
-  «private» := newConsts.private.foldl (init := allRealizations.private) fun m c =>
-    m.insert c.constInfo.name c
-  «public» := newConsts.public.foldl (init := allRealizations.public) fun m c =>
-    m.insert c.constInfo.name c
-
 /--
 Replays the difference between `newEnv` and `oldEnv` onto `dest`: the set of constants in `newEnv`
 but not `oldEnv` and the environment extension state for extensions defining `replay?`. If
@@ -3059,8 +3039,9 @@
       oldEnv.checked.bind (sync := true) fun oldKEnv =>
         newEnv.checked.map fun newKEnv =>
           replayKernel oldKEnv newKEnv exts newPrivateConsts kenv |>.toOption.getD kenv
-    allRealizations := dest.allRealizations.map (sync := true)
-      (addRealizations · { «private» := newPrivateConsts, «public» := newPublicConsts })
+    allRealizations := dest.allRealizations.map (sync := true) fun allRealizations =>
+      newPrivateConsts.foldl (init := allRealizations) fun allRealizations c =>
+        allRealizations.insert c.constInfo.name c
   }
 where
   /--
@@ -3321,7 +3302,9 @@
         | .error e => do
           exPromise.resolve e
           return kenv)
-    allRealizations := env.allRealizations.map (sync := true) (addRealizations · res.newConsts)
+    allRealizations := env.allRealizations.map (sync := true) fun allRealizations =>
+      res.newConsts.private.foldl (init := allRealizations) fun allRealizations c =>
+        allRealizations.insert c.constInfo.name c
   }
   return (env, exPromise.result?, res.dyn)
 
diff --git a/tests/elab/realizedThmExportedKind.lean b/tests/elab/realizedThmExportedKind.lean
deleted file mode 100644
index 8dc497d..0000000
--- a/tests/elab/realizedThmExportedKind.lean
+++ /dev/null
@@ -1,37 +0,0 @@
-module
-public meta import Lean.Elab.Command
-
-/-!
-Tests that the exported view of a theorem that was realized only inside a proof is an axiom, as it is
-for a theorem realized on the main environment branch.
--/
-
-open Lean Elab Command
-
-/-- Logs the kind of the exported view of the given declaration. -/
-elab "#exported_kind " id:ident : command => do
-  let env := (← getEnv).setExporting true
-  let some info := env.find? id.getId
-    | throwError "`{id.getId}` is not exported"
-  logInfo m!"{if info.isAxiom then "axiom" else if info.isTheorem then "theorem" else "other"}"
-
-public def f (n : Nat) (_h : n > 0) : Nat := n
-
--- `simp` realizes `f.congr_simp` here
-public theorem foo (a : Nat) (h : a + 0 > 0) : f (a + 0) h = f a (by simpa using h) := by
-  simp
-
-/-- info: axiom -/
-#guard_msgs in
-#exported_kind f.congr_simp
-
-set_option Elab.async false in
-public def g (n : Nat) (_h : n > 0) : Nat := n
-
-set_option Elab.async false in
-public theorem bar (a : Nat) (h : a + 0 > 0) : g (a + 0) h = g a (by simpa using h) := by
-  simp
-
-/-- info: axiom -/
-#guard_msgs in
-#exported_kind g.congr_simp