openAI-math-dataset / lean /OAI /Computability /DegreeRigidity /Representation /CategoryMachine.lean
Download lean/OAI/Computability/DegreeRigidity/Representation/CategoryMachine.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
- Browser
- Download file 5.46 kB
-
https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Computability/DegreeRigidity/Representation/CategoryMachine.lean
- Command line
-
hf download hf://datasets/roseking/openAI-math-dataset/lean/OAI/Computability/DegreeRigidity/Representation/CategoryMachine.lean
-
curl -L -o CategoryMachine.lean https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Computability/DegreeRigidity/Representation/CategoryMachine.lean
5.46 kB
Lean 4 · 15
declarations statementsfull
def rationalBit (i k : ℕ) : ℕ := if RationalCoding.ltCode k i then 1 else 0 theorem rationalBit_primrec : Primrec₂ rationalBit := proof · 2 lines
Primrec.ite (RationalCoding.ltCode_primrec.comp Primrec.snd Primrec.fst)
(Primrec.const 1) (Primrec.const 0)theorem rationalBit_eq (i k : ℕ) :
Part.some (rationalBit i k) = oracleFunction (cut (rationalEnumeration i : ℝ)) k := by proof · 1 line
simp only [rationalBit,oracleFunction,cut_eq_true,RationalCoding.ltCode_iff]def sample (i j : ℕ) : ℝ × ℝ := (rationalEnumeration i,rationalEnumeration j) def finiteOracle (L : List ℕ) (i j : ℕ) : ℕ →. ℕ := body · 2 lines
partialJoin (partialJoin (BranchMachine.lookup L) (fun k => Part.some (rationalBit i k)))
(fun k => Part.some (rationalBit j k))theorem partialJoin_oracle (A B : Oracle) :
partialJoin (oracleFunction A) (oracleFunction B) = oracleFunction (join A B) := by proof · 2 lines
funext k
cases h : k.bodd <;> simp [partialJoin,oracleFunction,join,h]noncomputable def Avalue (A : Oracle) (k : ℕ) : ℕ := if A k then 1 else 0 theorem finiteOracle_approximates (A : Oracle) (i j k : ℕ) :
Approximates (oracleFunction (pairOracle A (sample i j)) k)
(fun m => finiteOracle (UniformOracle.oraclePrefix (Avalue A) m) i j k) := by proof · 11 lines
have hi : (fun k => Part.some (rationalBit i k)) = oracleFunction (cut (rationalEnumeration i : ℝ)) :=
funext (rationalBit_eq i)
have hj : (fun k => Part.some (rationalBit j k)) = oracleFunction (cut (rationalEnumeration j : ℝ)) :=
funext (rationalBit_eq j)
have h := BranchMachine.partialJoin_approximates
(fun k => BranchMachine.partialJoin_approximates
(UniformOracle.prefix_approximates (Avalue A))
(fun k => Approximates.const (Part.some (rationalBit i k))) k)
(fun k => Approximates.const (Part.some (rationalBit j k))) k
simpa only [finiteOracle,hi,hj,show (fun k => Part.some (Avalue A k)) = oracleFunction A from rfl,
partialJoin_oracle,pairOracle,sample] using hdef inside (l r : ℚ × ℚ) (i j : ℕ) : Prop := body · 2 lines
RationalCoding.ltCode (encode l.1) i ∧ RationalCoding.ltCode i (encode r.1) ∧
RationalCoding.ltCode (encode l.2) j ∧ RationalCoding.ltCode j (encode r.2)instance (l r : ℚ × ℚ) (i j : ℕ) : Decidable (inside l r i j) := inferInstanceAs (Decidable (_ ∧ _)) theorem inside_primrec (l r : ℚ × ℚ) : PrimrecRel (inside l r) := proof · 4 lines
(RationalCoding.ltCode_primrec.comp (Primrec.const (encode l.1)) Primrec.fst).and
((RationalCoding.ltCode_primrec.comp Primrec.fst (Primrec.const (encode r.1))).and
((RationalCoding.ltCode_primrec.comp (Primrec.const (encode l.2)) Primrec.snd).and
(RationalCoding.ltCode_primrec.comp Primrec.snd (Primrec.const (encode r.2)))))theorem inside_iff (l r : ℚ × ℚ) (i j : ℕ) :
inside l r i j ↔ sample i j ∈ rectangle l r := by proof · 1 line
simp [inside,RationalCoding.ltCode_iff,rationalEnumeration,sample,rectangle,and_assoc]def finiteRun (c : OracleCode) (l r : ℚ × ℚ) (L : List ℕ) (w : ℕ) : Part ℕ := body · 4 lines
let i := (Nat.unpair w).1
let j := (Nat.unpair (Nat.unpair w).2).1
let n := (Nat.unpair (Nat.unpair w).2).2
if inside l r i j then OracleCode.eval (finiteOracle L i j) c n else Part.nonetheorem finiteRun_partrec (c : OracleCode) (l r : ℚ × ℚ) : Partrec₂ (finiteRun c l r) := by proof · 25 lines
let α := List ℕ × ℕ × ℕ
have hA : Partrec₂ (fun z : α => BranchMachine.lookup z.1) :=
BranchMachine.lookup_partrec.comp (fst.comp fst) snd
have hi : Partrec₂ (fun z : α => fun k => Part.some (rationalBit z.2.1 k)) :=
(rationalBit_primrec.to_comp.comp (fst.comp (snd.comp fst)) snd)
have hj : Partrec₂ (fun z : α => fun k => Part.some (rationalBit z.2.2 k)) :=
(rationalBit_primrec.to_comp.comp (snd.comp (snd.comp fst)) snd)
have hg : Partrec₂ (fun z : α => finiteOracle z.1 z.2.1 z.2.2) :=
BranchMachine.partialJoin_partrec (BranchMachine.partialJoin_partrec hA hi) hj
have he : Partrec₂ (fun z : α => OracleCode.eval (finiteOracle z.1 z.2.1 z.2.2) c) :=
OracleCode.eval_partrec hg c
have hi' : Computable (fun z : List ℕ × ℕ => (Nat.unpair z.2).1) :=
fst.comp (Computable.unpair.comp snd)
have hj' : Computable (fun z : List ℕ × ℕ => (Nat.unpair (Nat.unpair z.2).2).1) :=
fst.comp (Computable.unpair.comp (snd.comp (Computable.unpair.comp snd)))
have hn' : Computable (fun z : List ℕ × ℕ => (Nat.unpair (Nat.unpair z.2).2).2) :=
snd.comp (Computable.unpair.comp (snd.comp (Computable.unpair.comp snd)))
have hb : Computable (fun z : List ℕ × ℕ => decide (inside l r (Nat.unpair z.2).1
(Nat.unpair (Nat.unpair z.2).2).1)) :=
(inside_primrec l r).decide.to_comp.comp hi' hj'
have hparam : Computable (fun z : List ℕ × ℕ =>
(z.1,(Nat.unpair z.2).1,(Nat.unpair (Nat.unpair z.2).2).1)) :=
fst.pair (hi'.pair hj')
have hr := he.comp hparam hn'
exact (partrec_cond hb hr Partrec.none).of_eq (fun z => by simp [finiteRun])theorem finiteRun_code (c : OracleCode) (l r : ℚ × ℚ) :
∃ d : Nat.Partrec.Code, ∀ L w,
d.eval (Nat.pair (encode L) w) = finiteRun c l r L w := by proof · 2 lines
obtain ⟨d,hd⟩ := partrec_code (finiteRun_partrec c l r)
exact ⟨d,fun L w => hd (L,w)⟩Outline