Skip to content

Convert Strata/DL/ files to Lean modules#523

Merged
joehendrix merged 2 commits intomainfrom
jhx/dl_modules
Mar 6, 2026
Merged

Convert Strata/DL/ files to Lean modules#523
joehendrix merged 2 commits intomainfrom
jhx/dl_modules

Conversation

@joehendrix
Copy link
Contributor

@joehendrix joehendrix commented Mar 5, 2026

Summary

Convert 65 of 66 files under Strata/DL/ (plus 10 supporting files outside
DL) to Lean modules. This is the first step toward making Strata.SimpleAPI
fully modular.

Details

  • Visibility. Each converted file wraps its declarations in
    public section/end so importers see them. Imports that appear in
    public signatures become public import; internal-only imports stay
    private.
  • Namespace extensions kept private. Definitions that extend Lean or
    library namespaces (e.g. BitVec.width, List.dedup) stay private by
    default so Strata does not conflict with Batteries or Mathlib.
    Consumers that need these use import all to opt in explicitly.
  • Type aliases need @[expose]. Lean's module system requires
    @[expose] on abbrev definitions whose underlying type must be
    visible to importers (e.g. abbrev Map α β := List (α × β)).
    Without it, compilation fails with a "type differs" error.
  • Match-pattern defs need @[expose, match_pattern]. Definitions
    used in pattern matching (e.g. LMonoTy.bool, LExpr.boolConst)
    must be both exposed and marked as match patterns.
  • Proof unfolding across module boundaries. When a proof in module A
    needs to simp/unfold a private definition from module B, we add
    import all B alongside the regular import. This is used for
    Counter, StringGen, Init.Data.Repr, and several Lambda modules.
  • Meta imports. Files with elab or macro definitions use
    public meta import for Lean metaprogramming libraries. Meta helper
    functions called by elab macros cannot be private because
    downstream non-module files would not see them.
  • GOTO backend files converted. Imperative/ToCProverGOTO imports
    GOTO backend types, so 6 files under Backends/CBMC/GOTO/ were also
    converted. Target changed from a def with manual instances to
    @[expose] abbrev Target := Nat, which removes boilerplate and makes
    the type transparent. InstToJson drops the now-unnecessary
    .toNat call.
  • TestGen excluded. Lambda/TestGen.lean depends on Plausible
    (not yet a module) and is left unconverted. Only test files import it.
  • No behavioral changes. All existing tests pass.

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your choice.

@joehendrix joehendrix requested a review from a team March 5, 2026 23:10
Convert 65 of 66 files under Strata/DL/ (plus 10 supporting files outside
DL) to Lean modules. This is the first step toward making Strata.SimpleAPI
fully modular.

- Each converted file wraps its declarations in public section/end so
  importers see them. Imports that appear in public signatures become
  public import; internal-only imports stay private.
- Type aliases use @[expose] so the underlying type is visible to
  importers. Definitions used in pattern matching use
  @[expose, match_pattern].
- When a proof needs to simp/unfold a private definition from another
  module, import all is added alongside the regular import.
- Files with elab or macro definitions use public meta import for Lean
  metaprogramming libraries. Meta helpers called by elab macros cannot
  be private because downstream non-module files would not see them.
- 6 files under Backends/CBMC/GOTO/ were also converted because
  Imperative/ToCProverGOTO imports them. Target changed from a def with
  manual instances to @[expose] abbrev Target := Nat.
- Lambda/TestGen.lean is excluded because it depends on Plausible (not
  yet a module). Only test files import it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Contributor

@shigoel shigoel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@joehendrix joehendrix enabled auto-merge March 6, 2026 01:04
Copy link
Contributor

@keyboardDrummer keyboardDrummer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet!

@keyboardDrummer
Copy link
Contributor

How practical is the use of public section ... end ? From a declaration signature you can't easily see whether it's located in a public section or not. It seems more explicit to me to specify on a per declaration basis whether it needs to be public or not.

@joehendrix joehendrix added this pull request to the merge queue Mar 6, 2026
Merged via the queue into main with commit c9d9f5a Mar 6, 2026
15 checks passed
@joehendrix joehendrix deleted the jhx/dl_modules branch March 6, 2026 15:56
MikaelMayer added a commit that referenced this pull request Mar 6, 2026
Resolve conflicts with module conversion (#523) and GOTO backend (#289):
- Convert TypeConstructor.lean to module with public section
- Fix namespace resolution for TypeConstructor across module boundaries
- Add typeDecl case to ToCProverGOTO
- Remove unused mkParamName, deduplicate typeConArgsToCST
- Address PR review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants