Skip to content

Conversation

@joehendrix
Copy link
Contributor

@joehendrix joehendrix commented Feb 9, 2026

Converts Python/Specs files to use Lean 4.27 module system.

Files converted

  • PythonDialect.lean: Added @[expose] to keyword.value
  • ReadPython.lean: Marked helpers private
  • Specs/DDM.lean: Added docstrings
  • Specs.lean: Marked public API explicitly (8 items below)

Public API of Specs.lean

Types: EventType, SpecError, ModuleName, FileMaps
Functions: ofString, strataFileName, translateFile, translateModule

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 marked this pull request as ready for review February 9, 2026 21:38
@joehendrix joehendrix requested a review from a team as a code owner February 9, 2026 21:38
MikaelMayer
MikaelMayer previously approved these changes Feb 10, 2026
joehendrix and others added 6 commits February 10, 2026 16:39
Converts the Python specifications infrastructure to use Lean 4.27's
module system instead of namespace-based organization:

- Add module keyword and public sections to all Python Specs files
- Mark keyword helper functions with @[expose] for visibility
- Use import all for Fin utilities to access Fin.range
- Add necessary imports for generated dialect code (OfAstM, BoolConv, etc.)

Files converted:
- Strata/Languages/Python/PythonDialect.lean
- Strata/Languages/Python/ReadPython.lean
- Strata/Languages/Python/Specs/DDM.lean
- Strata/Languages/Python/Specs.lean

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Mark internal implementation details as private to reduce the public
API surface:

ReadPython.lean:
- readPythonStrataBytes: Internal helper for reading Ion format
- formatParseFailureStderr: Internal error formatting helper

Specs/DDM.lean:
- All toDDM/fromDDM conversion functions: Internal serialization helpers
- toDDMInt, DDM.Int.ofDDM: Internal type conversion utilities

These functions are implementation details not intended for external use.
Public APIs (pythonToStrata, readPythonStrata, readDDM, writeDDM, toDDMProgram)
remain accessible.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Privacy improvements:
- Type translation helpers: pySpecType, pySpecValue, pyKeywordValue
- Argument processing: pySpecArg, pyDefaultValue
- Value translation: translateConstant, translateSubscript, translateDictKey, translateCall
- Type translators: fixedTranslator, unionTranslator, literalTranslator, metadataProcessor
- Type utilities: valueAsType, checkEq
- State management: getNameValue?, setNameValue, recordTypeDef, recordTypeRef
- Signature management: pushSignature, pushSignatures

Changed PySpecMClass from export to open to reduce exported surface.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
With the change from export to open for PySpecMClass, several more
internal helper functions can now be marked private:

- transPred: Internal predicate translation helper
- logEvent: Internal logging utility
- ModuleName.ofStringAux: Internal parser helper
- Pred.not: Internal predicate negation helper

All functions are only used within the module implementation.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Major refactoring to use module-level privacy by default:

Import changes:
- Removed public section wrapper
- Changed most public imports to regular imports
- Only re-export necessary types: Lean.Data.Position, Std.Data.HashSet.Basic,
  Strata.DDM.Util.SourceRange, and Strata.Languages.Python.Specs.Decls

Public API (explicitly marked):
- Types: EventType, SpecError, ModuleName, FileMaps
- Functions: ModuleName.ofString, ModuleName.strataFileName, translateFile, translateModule
- Re-exported from DDM: readDDM, writeDDM, toDDMProgram (via Specs.DDM import)

All other declarations (100+) are now implicitly private, including:
- Internal helper functions (logEvent, transPred, pySpecValue, etc.)
- Type translators (fixedTranslator, unionTranslator, literalTranslator)
- State management (PySpecM, PySpecMClass, getNameValue?, setNameValue)
- Translation helpers (translate, translateModuleAux, resolveModule)

This drastically reduces the exported API surface while maintaining all
necessary functionality for external consumers (StrataMain, tests).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
BoolConv.lean was consolidated into OfAstM.lean in main branch.
Since we already import OfAstM, the BoolConv import is no longer needed.
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.

2 participants