import Mathlib.Computability.StateTransition /-! # General timed state-transition helpers These definitions mention only Mathlib's state-transition model, with no machine or complexity-class assumptions. Their proposed upstream home is `Mathlib/Computability/StateTransition.lean`, beside `EvalsToInTime.refl` and `EvalsToInTime.trans`. `EvalsToInTime` stores a run and its step count as data, so the constructors below are definitions rather than propositions. -/ universe u namespace StateTransition /-- A computation within `m` steps is also a computation within any larger bound. This preserves both the recorded run and its exact step count. -/ def EvalsToInTime.mono {σ : Type u} {f : σ → Option σ} {a : σ} {b : Option σ} {m m' : ℕ} (h : EvalsToInTime f a b m) (hm : m ≤ m') : EvalsToInTime f a b m' := ⟨h.toEvalsTo, le_trans h.steps_le_m hm⟩ /-- A single transition, including a transition to `none`, gives a one-step run. The resulting witness records exactly one step. -/ def EvalsToInTime.of_step {σ : Type u} {f : σ → Option σ} {a : σ} {b : Option σ} (h : f a = b) : EvalsToInTime f a b 1 := { steps := 1 evals_in_steps := by simpa [flip, Option.bind] using h steps_le_m := le_rfl } end StateTransition