proof(lean4): complete preservation + determinism (Lean parity with Coq) - #40
Merged
Merged
Conversation
…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
🔍 Hypatia Security ScanFindings: 30 issues detected
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Completes the phronesis Lean 4 type-safety proof — clears the two
TODO/sorryplaceholders (preservation, determinism) and makes the file genuinely compile + verify.The proofs (ported from the complete Coq
../coq/Phronesis.v)Eval— big-step evaluation relationValEnv → 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; madesize/containsDangerousstructurally terminate viamutualhelpers; dropped the (unused, non-core-derivable)DecidableEq PhrType; fixedle_refl/size annotations. Addedlakefile.lean+lean-toolchain(Lean v4.12.0, no deps).Verification
lake build→ success (core Lean only; CI needs just the toolchain).#print axioms:determinismdepends on NO axioms,preservationonly onpropext,progress/subtype_transnone — nosorryAxanywhere.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