Skip to content

Add PySpec to StrataCore translation pipeline#422

Draft
joehendrix wants to merge 1 commit intomainfrom
jhx/pyspec_to_core
Draft

Add PySpec to StrataCore translation pipeline#422
joehendrix wants to merge 1 commit intomainfrom
jhx/pyspec_to_core

Conversation

@joehendrix
Copy link
Contributor

@joehendrix joehendrix commented Feb 13, 2026

Summary

  • Adds end-to-end translation from PySpec (Python type specifications) to StrataCore programs for verification
  • Supports optional types (Union[None, T]StrOrNone/IntOrNone/BoolOrNone), TypedDict → DictStrAny, class declarations → opaque types with method procedures, function signatures → abstract procedures
  • Handles string literal unions, optional list/dict/any/bytes/TypedDict patterns, with precise source location tracking in warnings

New Files

  • Strata/Languages/Python/Specs/ToCore.lean — Main translation logic
  • Strata/Languages/Python/Specs/PySpecM.lean — Monad infrastructure for error tracking

Testing

  • StrataTest/Languages/Python/ToCoreTest.lean — End-to-end tests covering primitive types, complex types (Any, List, Dict, bytes), literal types, optional/union patterns, class and type definitions, keyword-only args, and error cases. All tests use #guard_msgs for exact output matching.

🤖 Generated with Claude Code

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 force-pushed the jhx/pyspec_to_core branch 8 times, most recently from ef48aa3 to f67ee6c Compare February 13, 2026 23:06
Translate PySpec signatures (Python type specifications) to StrataCore
programs, enabling verification of Python APIs.

Details:
- ToCore.lean: translates function signatures, class definitions, and
  type aliases to Core procedures, opaque types, and type synonyms
- PySpecM.lean: monad infrastructure for error-tracked translation
- Handles primitive types, Optional unions (Union[None, T]), TypedDict,
  string literal enums, and generic containers (List, Dict, Any, bytes)
- SourceRange.format: moved from Specs.lean for reuse across modules
- Eliminated sorry in DDM.lean (args.attach.foldl with membership proof)
- Removed debug #eval from CorePrelude.lean
- Moved Core.getProgram from Verifier.lean to Translate.lean
- Enabled #strata_gen Core in Parse.lean
- Added pySpecToCore CLI command in StrataMain.lean

Testing:
- ToCoreTest.lean: end-to-end #guard_msgs tests covering all type
  mappings (primitives, complex types, literals, TypedDict, optional
  patterns, kwonly args), error messages for unsupported types, and
  class/type definition translation

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

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant