Skip to content

Add PySpec to StrataCore translation pipeline#422

Draft
joehendrix wants to merge 3 commits intomainfrom
jhx/pyspec_to_core
Draft

Add PySpec to StrataCore translation pipeline#422
joehendrix wants to merge 3 commits 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 9 times, most recently from f67ee6c to 45e183f Compare February 14, 2026 02:05
joehendrix and others added 3 commits February 16, 2026 15:39
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>
…module support

Parse.lean is now a Lean 4 module with public imports and a public section
for #strata_gen. The mkScopedIdent function in Gen.lean is updated to handle
module files by using mkPrivateName for the pre-resolution hint when not in
a public section. Removed duplicate scopedIdent/currScopedIdent/arrayLit
definitions from Util/Lean.lean.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add support for Union[None, float], Union[None, Literal[int]],
all-int-literal unions, and all-TypedDict unions. Eliminates 3,406
translation warnings across 409 AWS services (3,354 TypedDict dedup,
48 float, 4 int literal).

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