Skip to content

Fix namespace declarations and add missing type annotations in Lean files#45

Open
ib823 wants to merge 1 commit intomainfrom
claude/fix-lean-build-modules-AhiO8
Open

Fix namespace declarations and add missing type annotations in Lean files#45
ib823 wants to merge 1 commit intomainfrom
claude/fix-lean-build-modules-AhiO8

Conversation

@ib823
Copy link
Owner

@ib823 ib823 commented Mar 19, 2026

Summary

This PR fixes namespace declarations across all generated Lean files to use fully qualified paths (e.g., RIINA.Compliance.VerifiedCompliance instead of just RIINA), adds missing type annotations to structure fields and function definitions, and improves documentation consistency.

Changes

  • Namespace fixes: Updated all 30+ Lean files to use fully qualified namespace paths matching their file structure, preventing namespace collisions and improving code organization
  • Type annotations: Added explicit type parameters to previously untyped List and Option fields in structures:
    • PersonalData.pd_value: List Nat
    • DataStore.store_data: List PersonalData
    • PHI.phi_data: List Nat, phi_accessed_by: List Nat
    • CardholderData.chd_pan: List Nat
    • ControlMapping.mapping_proof_ref: Option Nat
    • CompliancePolicy.policy_controls: List Control, policy_mappings: List ControlMapping
    • EvidenceChain.evidence_items: List Nat, evidence_signature: List Nat
    • GapAnalysis.gap_detected: List Control
  • New helper definitions: Added Nat.eqb, In, filter functions and type aliases (DataSubjectId, CDE, NonCDE) for Coq compatibility
  • Documentation improvements: Capitalized "List" in docstrings for consistency (e.g., "List universal predicate" instead of "list universal predicate")
  • Syntax modernization: Updated record field access from store.(store_compliant) to store.store_compliant notation in definitions

Type

  • Refactor

Testing

  • Lean type checking will validate all type annotations are correct
  • Namespace changes are structural and don't affect runtime behavior
  • No new tests required as this is a code generation fix

Checklist

  • No external dependencies added
  • No unsafe code
  • Coq compatibility maintained through helper definitions
  • Generated files follow consistent patterns

https://claude.ai/code/session_013ojS8MBYuZsS7exH3AAnzd

…ileOS (+1092 theorems)

Fix transpiler-generated Lean 4 files to compile when imported together:

- Namespace collision: Change each file from `namespace RIINA` to unique
  sub-namespace (e.g., RIINA.Industries.IndustryAgriculture) to avoid
  duplicate shim definitions when multiple files are imported
- Bare `List`/`Option` types: Add type parameters (List Nat, Option Nat)
- Coq syntax: Fix field access obj.(field) → obj.field, operators
  /\ → ∧, \/ → ∨, ~ → ¬, <> → ≠, Z.to_nat N%Z → N
- Lowercase types: nat → Nat, bool → Bool, list → List, string → String
- Add compatibility shims: In, filter, map, fold_left, nth_error, plus,
  Nat.eqb, Nat.leb, Nat.ltb, pair_in_list
- Fix truncated dependent types in structures (e.g., farm_area_valid)
- Fix undefined types in VerifiedCompliance (DataSubjectId, CDE, NonCDE)
- Re-enable imports in RIINA.lean

Theorem counts: Industries 375, Compliance 108, MobileOS 609 = 1092 new

https://claude.ai/code/session_013ojS8MBYuZsS7exH3AAnzd
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