Zulip Chat Archive

Stream: lean4

Topic: how to hide definitions


Jacob Prinz (Nov 21 2025 at 23:42):

is there any way to hide definitions from outside modules in lean?
for example, inside the module i would have:

def a := 10
theorem fact : a > 5 := by repeat constructor

and then outside the module, i would have a : Nat and fact : a > 5, but it should be impossible to prove a = 10.

Aaron Liu (Nov 21 2025 at 23:45):

Maybe make a a public def and fact a public theorem but don't @[expose] the a?

Aaron Liu (Nov 21 2025 at 23:45):

still getting used to this module thing

Jacob Prinz (Nov 21 2025 at 23:56):

that doesn't seem to work, unless i'm misunderstanding how to use modules. i also tried having a second private version of a, and setting the public version to the private version, but this also didn't work. @[irreducible] doesn't seem to help either.

Aaron Liu (Nov 22 2025 at 00:03):

if it doesn't work then I have no more ideas

Aaron Liu (Nov 22 2025 at 00:03):

why doesn't it work?

Jacob Prinz (Nov 22 2025 at 00:05):

none of those strategies stop the proof of a = 10 going through in the other module, so it didn't get hidden.

Aaron Liu (Nov 22 2025 at 00:08):

Did you make it a module?

Aaron Liu (Nov 22 2025 at 00:09):

It be great if you gave some code so I can see what you're doing and maybe reproduce it

Jacob Prinz (Nov 22 2025 at 00:10):

i have a file test1.lean with

module
public def a := 10
public theorem fact : a > 5 := by repeat constructor

and a second file test2.lean with

import Project.test1
theorem test : a = 10 := by
  rfl

the proof goes though, which is what i'm trying to prevent

Aaron Liu (Nov 22 2025 at 00:15):

It only works if you make test2.lean also a module I think

Aaron Liu (Nov 22 2025 at 00:16):

otherwise you can't really hide anything

Jacob Prinz (Nov 22 2025 at 00:16):

thanks! that works


Last updated: Dec 20 2025 at 21:32 UTC