@@ -160,27 +160,27 @@ def haltCfg (tm : SingleTapeTM Symbol) (s : List Symbol) : tm.Cfg := ⟨none, Bi
160160/--
161161The space used by a configuration is the space used by its tape.
162162-/
163- def Cfg.space_used (tm : SingleTapeTM Symbol) (cfg : tm.Cfg) : ℕ := cfg.BiTape.space_used
163+ def Cfg.spaceUsed (tm : SingleTapeTM Symbol) (cfg : tm.Cfg) : ℕ := cfg.BiTape.spaceUsed
164164
165165@ [scoped grind =]
166- lemma Cfg.space_used_initCfg (tm : SingleTapeTM Symbol) (s : List Symbol) :
167- (tm.initCfg s).space_used = max 1 s.length := BiTape.space_used_mk ₁ s
166+ lemma Cfg.spaceUsed_initCfg (tm : SingleTapeTM Symbol) (s : List Symbol) :
167+ (tm.initCfg s).spaceUsed = max 1 s.length := BiTape.spaceUsed_mk ₁ s
168168
169169@ [scoped grind =]
170- lemma Cfg.space_used_haltCfg (tm : SingleTapeTM Symbol) (s : List Symbol) :
171- (tm.haltCfg s).space_used = max 1 s.length := BiTape.space_used_mk ₁ s
170+ lemma Cfg.spaceUsed_haltCfg (tm : SingleTapeTM Symbol) (s : List Symbol) :
171+ (tm.haltCfg s).spaceUsed = max 1 s.length := BiTape.spaceUsed_mk ₁ s
172172
173- lemma Cfg.space_used_step {tm : SingleTapeTM Symbol} (cfg cfg' : tm.Cfg)
174- (hstep : tm.step cfg = some cfg') : cfg'.space_used ≤ cfg.space_used + 1 := by
173+ lemma Cfg.spaceUsed_step {tm : SingleTapeTM Symbol} (cfg cfg' : tm.Cfg)
174+ (hstep : tm.step cfg = some cfg') : cfg'.spaceUsed ≤ cfg.spaceUsed + 1 := by
175175 obtain ⟨_ | q, tape⟩ := cfg
176176 · simp [step] at hstep
177177 · simp only [step] at hstep
178178 generalize hM : tm.tr q tape.head = result at hstep
179179 obtain ⟨⟨wr, dir⟩, q''⟩ := result
180180 cases hstep; cases dir with
181- | none => simp [Cfg.space_used , BiTape.optionMove, BiTape.space_used_write , hM]
182- | some d => simpa [Cfg.space_used , BiTape.optionMove, BiTape.space_used_write , hM] using
183- BiTape.space_used_move (tape.write wr) d
181+ | none => simp [Cfg.spaceUsed , BiTape.optionMove, BiTape.spaceUsed_write , hM]
182+ | some d => simpa [Cfg.spaceUsed , BiTape.optionMove, BiTape.spaceUsed_write , hM] using
183+ BiTape.spaceUsed_move (tape.write wr) d
184184
185185end Cfg
186186
@@ -215,8 +215,8 @@ lemma output_length_le_input_length_add_time (tm : SingleTapeTM Symbol) (l l' :
215215 (h : tm.OutputsWithinTime l l' t) :
216216 l'.length ≤ max 1 l.length + t := by
217217 obtain ⟨steps, hsteps_le, hevals⟩ := h
218- grind [hevals.apply_le_apply_add (Cfg.space_used tm)
219- fun a b hstep ↦ Cfg.space_used_step a b (Option.mem_def.mp hstep)]
218+ grind [hevals.apply_le_apply_add (Cfg.spaceUsed tm)
219+ fun a b hstep ↦ Cfg.spaceUsed_step a b (Option.mem_def.mp hstep)]
220220
221221section Computers
222222
@@ -392,15 +392,15 @@ structure TimeComputable (f : List Symbol → List Symbol) where
392392 /-- the underlying bundled SingleTapeTM -/
393393 tm : SingleTapeTM Symbol
394394 /-- a bound on runtime -/
395- time_bound : ℕ → ℕ
396- /-- proof this machine outputs `f` in at most `time_bound (input.length)` steps -/
397- outputsFunInTime (a) : tm.OutputsWithinTime a (f a) (time_bound a.length)
395+ timeBound : ℕ → ℕ
396+ /-- proof this machine outputs `f` in at most `timeBound (input.length)` steps -/
397+ outputsFunInTime (a) : tm.OutputsWithinTime a (f a) (timeBound a.length)
398398
399399
400400/-- The identity map on Symbol is computable in constant time. -/
401401def TimeComputable.id : TimeComputable (Symbol := Symbol) id where
402402 tm := idComputer
403- time_bound _ := 1
403+ timeBound _ := 1
404404 outputsFunInTime _ := ⟨1 , le_rfl, RelatesInSteps.single rfl⟩
405405
406406/--
@@ -419,36 +419,36 @@ then the time bound for the second machine still holds for that shorter input to
419419-/
420420def TimeComputable.comp {f g : List Symbol → List Symbol}
421421 (hf : TimeComputable f) (hg : TimeComputable g)
422- (h_mono : Monotone hg.time_bound ) :
422+ (h_mono : Monotone hg.timeBound ) :
423423 (TimeComputable (g ∘ f)) where
424424 tm := compComputer hf.tm hg.tm
425425 -- perhaps it would be good to track the blow up separately?
426- time_bound l := (hf.time_bound l) + hg.time_bound (max 1 l + hf.time_bound l)
426+ timeBound l := (hf.timeBound l) + hg.timeBound (max 1 l + hf.timeBound l)
427427 outputsFunInTime a := by
428428 have hf_outputsFun := hf.outputsFunInTime a
429429 have hg_outputsFun := hg.outputsFunInTime (f a)
430430 simp only [OutputsWithinTime, initCfg, compComputer_q₀_eq, Function.comp_apply,
431431 haltCfg] at hg_outputsFun hf_outputsFun ⊢
432- -- The computer reduces a to f a in time hf.time_bound a.length
432+ -- The computer reduces a to f a in time hf.timeBound a.length
433433 have h_a_reducesTo_f_a :
434434 RelatesWithinSteps (compComputer hf.tm hg.tm).TransitionRelation
435435 (initialCfg hf.tm hg.tm a)
436436 (intermediateCfg hf.tm hg.tm (f a))
437- (hf.time_bound a.length) :=
437+ (hf.timeBound a.length) :=
438438 comp_left_relatesWithinSteps hf.tm hg.tm a (f a)
439- (hf.time_bound a.length) hf_outputsFun
440- -- The computer reduces f a to g (f a) in time hg.time_bound (f a).length
439+ (hf.timeBound a.length) hf_outputsFun
440+ -- The computer reduces f a to g (f a) in time hg.timeBound (f a).length
441441 have h_f_a_reducesTo_g_f_a :
442442 RelatesWithinSteps (compComputer hf.tm hg.tm).TransitionRelation
443443 (intermediateCfg hf.tm hg.tm (f a))
444444 (finalCfg hf.tm hg.tm (g (f a)))
445- (hg.time_bound (f a).length) :=
445+ (hg.timeBound (f a).length) :=
446446 comp_right_relatesWithinSteps hf.tm hg.tm (f a) (g (f a))
447- (hg.time_bound (f a).length) hg_outputsFun
447+ (hg.timeBound (f a).length) hg_outputsFun
448448 -- Therefore, the computer reduces a to g (f a) in the sum of those times.
449449 have h_a_reducesTo_g_f_a := RelatesWithinSteps.trans h_a_reducesTo_f_a h_f_a_reducesTo_g_f_a
450450 apply RelatesWithinSteps.of_le h_a_reducesTo_g_f_a
451- refine Nat.add_le_add_left ?_ (hf.time_bound a.length)
451+ refine Nat.add_le_add_left ?_ (hf.timeBound a.length)
452452 · apply h_mono
453453 -- Use the lemma about output length being bounded by input length + time
454454 exact output_length_le_input_length_add_time hf.tm _ _ _ (hf.outputsFunInTime a)
@@ -478,7 +478,7 @@ structure PolyTimeComputable (f : List Symbol → List Symbol) extends TimeCompu
478478 /-- a polynomial time bound -/
479479 poly : Polynomial ℕ
480480 /-- proof that this machine outputs `f` in at most `time(input.length)` steps -/
481- bounds : ∀ n, time_bound n ≤ poly.eval n
481+ bounds : ∀ n, timeBound n ≤ poly.eval n
482482
483483/-- A proof that the identity map on Symbol is computable in polytime. -/
484484noncomputable def PolyTimeComputable.id : PolyTimeComputable (Symbol := Symbol) id where
@@ -493,7 +493,7 @@ A proof that the composition of two polytime computable functions is polytime co
493493-/
494494noncomputable def PolyTimeComputable.comp {f g : List Symbol → List Symbol}
495495 (hf : PolyTimeComputable f) (hg : PolyTimeComputable g)
496- (h_mono : Monotone hg.time_bound ) :
496+ (h_mono : Monotone hg.timeBound ) :
497497 PolyTimeComputable (g ∘ f) where
498498 toTimeComputable := TimeComputable.comp hf.toTimeComputable hg.toTimeComputable h_mono
499499 poly := hf.poly + hg.poly.comp (1 + X + hf.poly)
0 commit comments