Zulip Chat Archive

Stream: mathlib4

Topic: ComputablePred from Nat to α


SnO2WMaN (Aug 09 2025 at 11:07):

Recently I formalized the mathematical logic fact stated that "if there is a set s.t. recursive enumerable but not recursive (computable), then implies Gödel's first incompleteness theorem." (https://github.com/FormalizedFormalLogic/Foundation/blob/master/Foundation/FirstOrder/Incompleteness/Halting.lean)

We can take a set like that as halting_problem in mathlib4, but some issue about type.
I proved the fact on predicate on Nat. but halting_problem on Code, so cannot use directly.
I need these lemma (or similar else), but I don't these are correct and how to prove.

lemma REPred.iff_decoded_pred {A : α  Prop} [Primcodable α] : REPred A  REPred λ n :   match Encodable.decode n with | some a => A a | none => False := by
  sorry;

lemma ComputablePred.iff_decoded_pred {A : α  Prop} [h : Primcodable α] : ComputablePred A  ComputablePred λ n :   match Encodable.decode n with | some a => A a | none => False := by
  sorry;

Robin Arnez (Aug 09 2025 at 11:54):

The first one is true:

import Mathlib

@[congr]
lemma Part.assert_congr {p₁ p₂ : Prop} {f₁ : p₁  Part α} {f₂ : p₂  Part α}
    (hp : p₁ = p₂) (hf :  h, f₁ (hp.mpr_prop h) = f₂ h) :
    Part.assert p₁ f₁ = Part.assert p₂ f₂ := by
  cases hp
  cases funext hf
  rfl

@[simp]
lemma Part.assert_false (f : False  Part α) : Part.assert False f = Part.none := by
  simp only [assert_neg, not_false_eq_true]

@[simp]
lemma Part.assert_true (f : True  Part α) : Part.assert True f = f trivial := by
  simp only [assert_pos]

lemma REPred.iff_decoded_pred {A : α  Prop} [Primcodable α] :
    REPred A  REPred fun n :    a, Encodable.decode n = some a  A a := by
  simp only [REPred, Partrec, Encodable.decode_nat, Part.coe_some, Part.bind_some]
  apply propext_iff.mp
  congr 1
  funext n
  cases (Encodable.decode n : Option α) <;> simp

(the first three lemmas should probably be in mathlib somewhere)

Robin Arnez (Aug 09 2025 at 11:54):

I am inclined to believe the second one is too but I'm unsure

SnO2WMaN (Aug 09 2025 at 12:40):

It's nice! Thanks

SnO2WMaN (Aug 09 2025 at 14:47):

I tracked this issue: https://github.com/FormalizedFormalLogic/Foundation/pull/508

Wuyang (Aug 11 2025 at 19:08):

Great to see the REPred.iff_decoded_pred proof clarified. Curious to see if the ComputablePred case works out similarly. You can find related Lean formalizations with LeanFinder (www.leanfinder.org).

Wuyang (Aug 11 2025 at 19:08):

@leanfinder REPred and ComputablePred equivalence with decoded predicates in Lean mathlib4

leanfinder (Aug 11 2025 at 19:08):

Here’s what I found:


Last updated: Dec 20 2025 at 21:32 UTC