Skip to content

proof(lean4): complete preservation + determinism (Lean parity with Coq) - #40

Merged
hyperpolymath merged 1 commit into
mainfrom
claude/gifted-fermat-EmVcv
Jun 14, 2026
Merged

hyperpolymath merged 1 commit into
mainfrom
claude/gifted-fermat-EmVcv

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

What

Completes the phronesis Lean 4 type-safety proof — clears the two TODO/sorry placeholders (preservation, determinism) and makes the file genuinely compile + verify.

The proofs (ported from the complete Coq ../coq/Phronesis.v)

  • Eval — big-step evaluation relation ValEnv → PhrExpr → PhrValue → Prop (mirrors Coq ρ ⊢ e ⇓ v).
  • preservation — a well-typed closed expression evaluates to a value of its type.
  • determinism — evaluation is deterministic.

Made it actually build (it never had been)

The file imported Mathlib but shipped with no build setup and several core errors, so it had never been checked. Now self-contained on core Lean (proofs use only cases/induction/omega/simp/injection): dropped the unused Mathlib imports; made size/containsDangerous structurally terminate via mutual helpers; dropped the (unused, non-core-derivable) DecidableEq PhrType; fixed le_refl/size annotations. Added lakefile.lean + lean-toolchain (Lean v4.12.0, no deps).

Verification

  • lake build → success (core Lean only; CI needs just the toolchain).
  • #print axioms: determinism depends on NO axioms, preservation only on propext, progress/subtype_trans none — no sorryAx anywhere.

This brings Lean to parity with the Coq development for the core type-safety metatheory. (Remaining phronesis proof scope — consensus/ethics-specific soundness — is separate, per the discussion.)

🤖 Draft opened by Claude Code.

https://claude.ai/code/session_01DQACj3RFmAPZaBPgR9SAaS


Generated by Claude Code

…an on core Lean

Clears the two TODO/sorry placeholders in the Lean 4 type-safety formalization
by porting the big-step evaluation relation + theorems from the complete Coq
development (../coq/Phronesis.v):
  * Eval : ValEnv -> PhrExpr -> PhrValue -> Prop  (big-step, mirrors Coq)
  * preservation : a well-typed closed expr evaluates to a value of its type
  * determinism  : evaluation is deterministic

Also makes the whole file actually compile (it imported Mathlib but had no
build setup and several core errors, so it had never been checked): drops the
unnecessary Mathlib imports (proofs use only core tactics), makes size and
containsDangerous structurally terminate via mutual helpers, drops the
non-core-derivable (unused) DecidableEq on PhrType, fixes le_refl and size
type annotations. Adds lakefile.lean + lean-toolchain (Lean v4.12.0, no deps)
so CI can build with only the toolchain.

Verified: lake build succeeds; '#print axioms' shows determinism depends on NO
axioms and preservation only on propext -- no sorryAx anywhere.

https://claude.ai/code/session_01DQACj3RFmAPZaBPgR9SAaS
@github-actions

Copy link
Copy Markdown

🔍 Hypatia Security Scan

Findings: 30 issues detected

Severity Count
🔴 Critical 0
🟠 High 7
🟡 Medium 23
View findings
[
  {
    "reason": "Action trufflesecurity/trufflehog@main needs attention",
    "type": "unpinned_action",
    "file": "secret-scanner.yml",
    "action": "pin_sha",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Issue in secret-scanner.yml",
    "type": "missing_timeout_minutes",
    "file": "secret-scanner.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in scorecard-enforcer.yml",
    "type": "scorecard_publish_with_run_step",
    "file": "scorecard-enforcer.yml",
    "action": "split_scorecard_publish_job",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "binary_to_term without :safe option -- deserialization attack (1 occurrences, CWE-502)",
    "type": "elixir_send_unsanitised",
    "file": "/home/runner/work/phronesis/phronesis/lib/phronesis/compiler.ex",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "high"
  },
  {
    "reason": "Nominal-only SAST in phronesis: codeql.yml language matrix contains no language present in the repo and lacks `actions`, so CodeQL records zero results on every commit. Remediation: set the CodeQL matrix to `language: actions`.",
    "type": "StaticAnalysis",
    "file": "/home/runner/work/phronesis/phronesis",
    "action": "auto_fix",
    "rule_module": "scorecard",
    "severity": "medium",
    "remediation": "Add CodeQL or equivalent SAST workflow.",
    "scorecard_check": "SAST"
  },
  {
    "reason": "Repository has 3 non-main remote branch(es). Policy: single main branch only.",
    "type": "GS007",
    "file": ".",
    "action": "delete_remote_branches",
    "rule_module": "git_state",
    "severity": "medium"
  },
  {
    "reason": "Code scanning (Hypatia): hypatia/structural_drift/SD007 -- Hypatia structural_drift: SD007 -- 2 day(s) old",
    "type": "CSA001",
    "file": ".claude/CLAUDE.md",
    "action": "review",
    "rule_module": "code_scanning_alerts",
    "severity": "medium"
  },
  {
    "reason": "Code scanning (Hypatia): hypatia/structural_drift/SD007 -- Hypatia structural_drift: SD007 -- 2 day(s) old",
    "type": "CSA001",
    "file": ".claude/CLAUDE.md",
    "action": "review",
    "rule_module": "code_scanning_alerts",
    "severity": "medium"
  },
  {
    "reason": "Code scanning (Hypatia): hypatia/structural_drift/SD007 -- Hypatia structural_drift: SD007 -- 2 day(s) old",
    "type": "CSA001",
    "file": ".claude/CLAUDE.md",
    "action": "review",
    "rule_module": "code_scanning_alerts",
    "severity": "medium"
  },
  {
    "reason": "Code scanning (Hypatia): hypatia/structural_drift/SD007 -- Hypatia structural_drift: SD007 -- 2 day(s) old",
    "type": "CSA001",
    "file": ".claude/CLAUDE.md",
    "action": "review",
    "rule_module": "code_scanning_alerts",
    "severity": "medium"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

@hyperpolymath
hyperpolymath marked this pull request as ready for review June 14, 2026 10:52
@hyperpolymath
hyperpolymath merged commit 89166e9 into main Jun 14, 2026
6 checks passed
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