← Back to Pull requests

feat(Computability): semilattice instance on Turing degrees #34937

Closed
unknown closed this pull request without merging on Mar 23, 2026 22:19 UTC
View on GitHub
unknown unknown commented on Feb 07, 2026 02:34 UTC
Author

This PR equips TuringDegree with a SemilatticeSup structure by introducing the Turing join, proving usual least-upper-bound properties, and lifting these to degrees (quotients). In support of this, it extends the existing RecursiveIn API with some lemmas used in the degree theory.

The main contribution is the SemilatticeSup instance on TuringDegree. We define the Turing join as follows

turingJoin (f g) : ℕ → ℕ   -- notation: f ⊕ g

and prove it is a least upper bound:

left_le_join, right_le_join
join_le

  • monotonicity and congruence lemmas (join_mono, join_congr)
  • We lift this to degrees in TuringDegree.sup, TuringDegree.le_sup_left, TuringDegree.le_sup_right, and TuringDegree.sup_le

    instance : SemilatticeSup TuringDegree
    

    New additions to RecursiveIn.lean:

  • liftPrim, liftPrimrec, RecursiveIn', ComputableIn, ComputableIn₂: Encodes partial/total functions between Primcodable types as ℕ →. ℕ, analogous to Partrec/Computable.
  • of_eq, of_eq_tot, of_primrec, some, none, mono, subst: Standard closure properties for RecursiveIn.
  • cond_const, cond_core_rfind, cond, ComputableIn.cond: Shows RecursiveIn is closed under conditionals when the guard is absolutely computable
  • Nat.Partrec.recursiveIn, Computable.computableIn: Every partrec/computable function is recursive in any oracle set.
  • Small addition to Partrec

    we add to Mathlib.Computability.Partrec a small helper def (Partrec.kronecker and related rfind lemmas) representing the function that returns 1 if its two (unpaired) arguments are equal, and 0 otherwise, which is used in the proof of cond

    TODO


    Some current RecursiveIn proofs such as cond_core_rfind still work directly with the inductive constructors and are thus very long. A follow up could add a combinator-style closure library by essentially relativizing all the results and lemmas in Partrec, and proofs could be golfed heavily as they are in Partrec

    Note: AI Usage

    Aleph prover was allowed to prove an earlier version of cond_core_rfind, which included stating and proving the lemma cond_const but the proofs have since been iterated on manually

    Cursor was allowed to run git commands and edit docstrings/headers, and was used in setting up the module structure of the files

    Diff: 306 lines (+229 / -77) across 3 files Reviewer: tannerduve Review duration: 64545m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.40) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 306 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.343
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #34937"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.2% (MEDIUM) · Higher = larger blast radius
    40.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.4% · Safe to merge
    17.4%