The areas / V32. Logic, model theory and computability
Mathlib.Computability.StateTransition
52 declarations. Mathlib docs · Source
theorem StateTransition.Respects.match_1.congr_eq_2 E1 #
∀ {σ₁ : Type u_1} (motive : Option σ₁ → Sort u_2) (x : Option σ₁) (h_1 : (b₁ : σ₁) → motive (some b₁))
(h_2 : Unit → motive none),
x = none →
(match x with
| some b₁ => h_1 b₁
| none => h_2 ()) ≍
h_2 ()
def StateTransition.EvalsTo.ctorIdx E1 #
{σ : Type u_1} → {f : σ → Option σ} → {a : σ} → {b : Option σ} → StateTransition.EvalsTo f a b → ℕ
theorem StateTransition.EvalsToInTime.mk.inj E1 #
∀ {σ : Type u_1} {f : σ → Option σ} {a : σ} {b : Option σ} {m : ℕ} {toEvalsTo : StateTransition.EvalsTo f a b}
{steps_le_m : toEvalsTo.steps ≤ m} {toEvalsTo_1 : StateTransition.EvalsTo f a b}
{steps_le_m_1 : toEvalsTo_1.steps ≤ m},
{ toEvalsTo := toEvalsTo, steps_le_m := steps_le_m } = { toEvalsTo := toEvalsTo_1, steps_le_m := steps_le_m_1 } →
toEvalsTo = toEvalsTo_1
theorem StateTransition.EvalsToInTime.mk.injEq E0 #
∀ {σ : Type u_1} {f : σ → Option σ} {a : σ} {b : Option σ} {m : ℕ} (toEvalsTo : StateTransition.EvalsTo f a b)
(steps_le_m : toEvalsTo.steps ≤ m) (toEvalsTo_1 : StateTransition.EvalsTo f a b)
(steps_le_m_1 : toEvalsTo_1.steps ≤ m),
({ toEvalsTo := toEvalsTo, steps_le_m := steps_le_m } = { toEvalsTo := toEvalsTo_1, steps_le_m := steps_le_m_1 }) =
(toEvalsTo = toEvalsTo_1)
theorem StateTransition.Respects.match_1.congr_eq_1 E1 #
∀ {σ₁ : Type u_1} (motive : Option σ₁ → Sort u_2) (x : Option σ₁) (h_1 : (b₁ : σ₁) → motive (some b₁))
(h_2 : Unit → motive none) (b₁ : σ₁),
x = some b₁ →
(match x with
| some b₁ => h_1 b₁
| none => h_2 ()) ≍
h_1 b₁
def StateTransition.EvalsToInTime.ctorIdx E1 #
{σ : Type u_1} → {f : σ → Option σ} → {a : σ} → {b : Option σ} → {m : ℕ} → StateTransition.EvalsToInTime f a b m → ℕ
theorem StateTransition.EvalsTo.mk.inj E1 #
∀ {σ : Type u_1} {f : σ → Option σ} {a : σ} {b : Option σ} {steps : ℕ}
{evals_in_steps : (flip bind f)^[steps] (some a) = b} {steps_1 : ℕ}
{evals_in_steps_1 : (flip bind f)^[steps_1] (some a) = b},
{ steps := steps, evals_in_steps := evals_in_steps } = { steps := steps_1, evals_in_steps := evals_in_steps_1 } →
steps = steps_1
theorem StateTransition.EvalsTo.mk.injEq E0 #
∀ {σ : Type u_1} {f : σ → Option σ} {a : σ} {b : Option σ} (steps : ℕ)
(evals_in_steps : (flip bind f)^[steps] (some a) = b) (steps_1 : ℕ)
(evals_in_steps_1 : (flip bind f)^[steps_1] (some a) = b),
({ steps := steps, evals_in_steps := evals_in_steps } = { steps := steps_1, evals_in_steps := evals_in_steps_1 }) =
(steps = steps_1)
def StateTransition.eval E1 #
{σ : Type u_1} → (σ → Option σ) → σ → Part σ
Run a state transition function σ → Option σ "to completion". The return value is the last
state returned before a none result. If the state transition function always returns some,
then the computation diverges, returning Part.none.
def StateTransition.Reaches E1 #
{σ : Type u_1} → (σ → Option σ) → σ → σ → Prop
The reflexive transitive closure of a state transition function. Reaches f a b means
there is a finite sequence of steps f a = some a₁, f a₁ = some a₂, ... such that aₙ = b.
This relation permits zero steps of the state transition function.
def StateTransition.Reaches₁ E1 #
{σ : Type u_1} → (σ → Option σ) → σ → σ → Prop
The transitive closure of a state transition function. Reaches₁ f a b means there is a
nonempty finite sequence of steps f a = some a₁, f a₁ = some a₂, ... such that aₙ = b.
This relation does not permit zero steps of the state transition function.
theorem StateTransition.reaches₁_eq E0 #
∀ {σ : Type u_1} {f : σ → Option σ} {a b c : σ},
f a = f b → (StateTransition.Reaches₁ f a c ↔ StateTransition.Reaches₁ f b c)
theorem StateTransition.reaches_total E1 #
∀ {σ : Type u_1} {f : σ → Option σ} {a b c : σ},
StateTransition.Reaches f a b →
StateTransition.Reaches f a c → StateTransition.Reaches f b c ∨ StateTransition.Reaches f c b
theorem StateTransition.reaches₁_fwd E1 #
∀ {σ : Type u_1} {f : σ → Option σ} {a b c : σ},
StateTransition.Reaches₁ f a c → b ∈ f a → StateTransition.Reaches f b c
def StateTransition.Reaches₀ E1 #
{σ : Type u_1} → (σ → Option σ) → σ → σ → Prop
A variation on Reaches. Reaches₀ f a b holds if whenever Reaches₁ f b c then
Reaches₁ f a c. This is a weaker property than Reaches and is useful for replacing states with
equivalent states without taking a step.
theorem StateTransition.Reaches₀.trans E1 #
∀ {σ : Type u_1} {f : σ → Option σ} {a b c : σ},
StateTransition.Reaches₀ f a b → StateTransition.Reaches₀ f b c → StateTransition.Reaches₀ f a c
theorem StateTransition.Reaches₀.refl E1 #
∀ {σ : Type u_1} {f : σ → Option σ} (a : σ), StateTransition.Reaches₀ f a a
theorem StateTransition.Reaches₀.single E1 #
∀ {σ : Type u_1} {f : σ → Option σ} {a b : σ}, b ∈ f a → StateTransition.Reaches₀ f a b
theorem StateTransition.Reaches₀.head E1 #
∀ {σ : Type u_1} {f : σ → Option σ} {a b c : σ},
b ∈ f a → StateTransition.Reaches₀ f b c → StateTransition.Reaches₀ f a c
theorem StateTransition.Reaches₀.tail E1 #
∀ {σ : Type u_1} {f : σ → Option σ} {a b c : σ},
StateTransition.Reaches₀ f a b → c ∈ f b → StateTransition.Reaches₀ f a c
theorem StateTransition.reaches₀_eq E0 #
∀ {σ : Type u_1} {f : σ → Option σ} {a b : σ}, f a = f b → StateTransition.Reaches₀ f a b
theorem StateTransition.Reaches₁.to₀ E1 #
∀ {σ : Type u_1} {f : σ → Option σ} {a b : σ}, StateTransition.Reaches₁ f a b → StateTransition.Reaches₀ f a b
theorem StateTransition.Reaches.to₀ E1 #
∀ {σ : Type u_1} {f : σ → Option σ} {a b : σ}, StateTransition.Reaches f a b → StateTransition.Reaches₀ f a b
theorem StateTransition.Reaches₀.tail' E1 #
∀ {σ : Type u_1} {f : σ → Option σ} {a b c : σ},
StateTransition.Reaches₀ f a b → c ∈ f b → StateTransition.Reaches₁ f a c
def StateTransition.evalInduction E1 #
{σ : Type u_2} →
{f : σ → Option σ} →
{b : σ} →
{C : σ → Sort u_1} →
{a : σ} →
b ∈ StateTransition.eval f a →
((a : σ) → b ∈ StateTransition.eval f a → ((a' : σ) → f a = some a' → C a') → C a) → C a
(co-)Induction principle for eval. If a property C holds of any point a evaluating to b
which is either terminal (meaning a = b) or where the next point also satisfies C, then it
holds of any point where eval f a evaluates to b. This formalizes the notion that if
eval f a evaluates to b then it reaches terminal state b in finitely many steps.
theorem StateTransition.mem_eval E0 #
∀ {σ : Type u_1} {f : σ → Option σ} {a b : σ}, b ∈ StateTransition.eval f a ↔ StateTransition.Reaches f a b ∧ f b = none
theorem StateTransition.eval_maximal₁ E1 #
∀ {σ : Type u_1} {f : σ → Option σ} {a b : σ}, b ∈ StateTransition.eval f a → ∀ (c : σ), ¬StateTransition.Reaches₁ f b c
theorem StateTransition.eval_maximal E1 #
∀ {σ : Type u_1} {f : σ → Option σ} {a b : σ},
b ∈ StateTransition.eval f a → ∀ {c : σ}, StateTransition.Reaches f b c ↔ c = b
theorem StateTransition.reaches_eval E1 #
∀ {σ : Type u_1} {f : σ → Option σ} {a b : σ},
StateTransition.Reaches f a b → StateTransition.eval f a = StateTransition.eval f b
def StateTransition.Respects E1 #
{σ₁ : Type u_1} → {σ₂ : Type u_2} → (σ₁ → Option σ₁) → (σ₂ → Option σ₂) → (σ₁ → σ₂ → Prop) → Prop
Given a relation tr : σ₁ → σ₂ → Prop between state spaces, and state transition functions
f₁ : σ₁ → Option σ₁ and f₂ : σ₂ → Option σ₂, Respects f₁ f₂ tr means that if tr a₁ a₂ holds
initially and f₁ takes a step to a₂ then f₂ will take one or more steps before reaching a
state b₂ satisfying tr a₂ b₂, and if f₁ a₁ terminates then f₂ a₂ also terminates.
Such a relation tr is also known as a refinement.
theorem StateTransition.tr_reaches₁ E1 #
∀ {σ₁ : Type u_1} {σ₂ : Type u_2} {f₁ : σ₁ → Option σ₁} {f₂ : σ₂ → Option σ₂} {tr : σ₁ → σ₂ → Prop},
StateTransition.Respects f₁ f₂ tr →
∀ {a₁ : σ₁} {a₂ : σ₂},
tr a₁ a₂ → ∀ {b₁ : σ₁}, StateTransition.Reaches₁ f₁ a₁ b₁ → ∃ b₂, tr b₁ b₂ ∧ StateTransition.Reaches₁ f₂ a₂ b₂
theorem StateTransition.tr_reaches E1 #
∀ {σ₁ : Type u_1} {σ₂ : Type u_2} {f₁ : σ₁ → Option σ₁} {f₂ : σ₂ → Option σ₂} {tr : σ₁ → σ₂ → Prop},
StateTransition.Respects f₁ f₂ tr →
∀ {a₁ : σ₁} {a₂ : σ₂},
tr a₁ a₂ → ∀ {b₁ : σ₁}, StateTransition.Reaches f₁ a₁ b₁ → ∃ b₂, tr b₁ b₂ ∧ StateTransition.Reaches f₂ a₂ b₂
theorem StateTransition.tr_reaches_rev E1 #
∀ {σ₁ : Type u_1} {σ₂ : Type u_2} {f₁ : σ₁ → Option σ₁} {f₂ : σ₂ → Option σ₂} {tr : σ₁ → σ₂ → Prop},
StateTransition.Respects f₁ f₂ tr →
∀ {a₁ : σ₁} {a₂ : σ₂},
tr a₁ a₂ →
∀ {b₂ : σ₂},
StateTransition.Reaches f₂ a₂ b₂ →
∃ c₁ c₂, StateTransition.Reaches f₂ b₂ c₂ ∧ tr c₁ c₂ ∧ StateTransition.Reaches f₁ a₁ c₁
theorem StateTransition.tr_eval E1 #
∀ {σ₁ : Type u_1} {σ₂ : Type u_2} {f₁ : σ₁ → Option σ₁} {f₂ : σ₂ → Option σ₂} {tr : σ₁ → σ₂ → Prop},
StateTransition.Respects f₁ f₂ tr →
∀ {a₁ b₁ : σ₁} {a₂ : σ₂},
tr a₁ a₂ → b₁ ∈ StateTransition.eval f₁ a₁ → ∃ b₂, tr b₁ b₂ ∧ b₂ ∈ StateTransition.eval f₂ a₂
theorem StateTransition.tr_eval_rev E1 #
∀ {σ₁ : Type u_1} {σ₂ : Type u_2} {f₁ : σ₁ → Option σ₁} {f₂ : σ₂ → Option σ₂} {tr : σ₁ → σ₂ → Prop},
StateTransition.Respects f₁ f₂ tr →
∀ {a₁ : σ₁} {b₂ a₂ : σ₂},
tr a₁ a₂ → b₂ ∈ StateTransition.eval f₂ a₂ → ∃ b₁, tr b₁ b₂ ∧ b₁ ∈ StateTransition.eval f₁ a₁
theorem StateTransition.tr_eval_dom E1 #
∀ {σ₁ : Type u_1} {σ₂ : Type u_2} {f₁ : σ₁ → Option σ₁} {f₂ : σ₂ → Option σ₂} {tr : σ₁ → σ₂ → Prop},
StateTransition.Respects f₁ f₂ tr →
∀ {a₁ : σ₁} {a₂ : σ₂}, tr a₁ a₂ → ((StateTransition.eval f₂ a₂).Dom ↔ (StateTransition.eval f₁ a₁).Dom)
def StateTransition.FRespects E1 #
{σ₁ : Type u_1} → {σ₂ : Type u_2} → (σ₂ → Option σ₂) → (σ₁ → σ₂) → σ₂ → Option σ₁ → Prop
A simpler version of Respects when the state transition relation tr is a function.
theorem StateTransition.frespects_eq E0 #
∀ {σ₁ : Type u_1} {σ₂ : Type u_2} {f₂ : σ₂ → Option σ₂} {tr : σ₁ → σ₂} {a₂ b₂ : σ₂},
f₂ a₂ = f₂ b₂ → ∀ {b₁ : Option σ₁}, StateTransition.FRespects f₂ tr a₂ b₁ ↔ StateTransition.FRespects f₂ tr b₂ b₁
theorem StateTransition.fun_respects E1 #
∀ {σ₁ : Type u_1} {σ₂ : Type u_2} {f₁ : σ₁ → Option σ₁} {f₂ : σ₂ → Option σ₂} {tr : σ₁ → σ₂},
(StateTransition.Respects f₁ f₂ fun a b ↦ tr a = b) ↔ ∀ ⦃a₁ : σ₁⦄, StateTransition.FRespects f₂ tr (tr a₁) (f₁ a₁)
theorem StateTransition.tr_eval' E1 #
∀ {σ₁ σ₂ : Type u_1} (f₁ : σ₁ → Option σ₁) (f₂ : σ₂ → Option σ₂) (tr : σ₁ → σ₂),
(StateTransition.Respects f₁ f₂ fun a b ↦ tr a = b) →
∀ (a₁ : σ₁), StateTransition.eval f₂ (tr a₁) = tr <$> StateTransition.eval f₁ a₁
structure StateTransition.EvalsTo E1 #
{σ : Type u_1} → (σ → Option σ) → σ → Option σ → Type
A "proof" of the fact that f eventually reaches b when repeatedly evaluated on a,
remembering the number of steps it takes.
ctor StateTransition.EvalsTo.mk E0 #
{σ : Type u_1} →
{f : σ → Option σ} →
{a : σ} → {b : Option σ} → (steps : ℕ) → (flip bind f)^[steps] (some a) = b → StateTransition.EvalsTo f a b
abbrev StateTransition.EvalsTo.steps E1 #
{σ : Type u_1} → {f : σ → Option σ} → {a : σ} → {b : Option σ} → StateTransition.EvalsTo f a b → ℕ
number of steps taken
theorem StateTransition.EvalsTo.evals_in_steps E1 #
∀ {σ : Type u_1} {f : σ → Option σ} {a : σ} {b : Option σ} (self : StateTransition.EvalsTo f a b),
(flip bind f)^[self.steps] (some a) = b
structure StateTransition.EvalsToInTime E1 #
{σ : Type u_1} → (σ → Option σ) → σ → Option σ → ℕ → Type
A "proof" of the fact that f eventually reaches b in at most m steps when repeatedly
evaluated on a, remembering the number of steps it takes.
ctor StateTransition.EvalsToInTime.mk E0 #
{σ : Type u_1} →
{f : σ → Option σ} →
{a : σ} →
{b : Option σ} →
{m : ℕ} →
(toEvalsTo : StateTransition.EvalsTo f a b) → toEvalsTo.steps ≤ m → StateTransition.EvalsToInTime f a b m
abbrev StateTransition.EvalsToInTime.toEvalsTo E1 #
{σ : Type u_1} →
{f : σ → Option σ} →
{a : σ} → {b : Option σ} → {m : ℕ} → StateTransition.EvalsToInTime f a b m → StateTransition.EvalsTo f a b
theorem StateTransition.EvalsToInTime.steps_le_m E1 #
∀ {σ : Type u_1} {f : σ → Option σ} {a : σ} {b : Option σ} {m : ℕ} (self : StateTransition.EvalsToInTime f a b m),
self.steps ≤ m
def StateTransition.EvalsTo.refl E1 #
{σ : Type u_1} → (f : σ → Option σ) → (a : σ) → StateTransition.EvalsTo f a (some a)
Reflexivity of EvalsTo in 0 steps.
def StateTransition.EvalsTo.trans E1 #
{σ : Type u_1} →
(f : σ → Option σ) →
(a b : σ) →
(c : Option σ) →
StateTransition.EvalsTo f a (some b) → StateTransition.EvalsTo f b c → StateTransition.EvalsTo f a c
Transitivity of EvalsTo in the sum of the numbers of steps.
def StateTransition.EvalsToInTime.refl E1 #
{σ : Type u_1} → (f : σ → Option σ) → (a : σ) → StateTransition.EvalsToInTime f a (some a) 0
Reflexivity of EvalsToInTime in 0 steps.
def StateTransition.EvalsToInTime.trans E1 #
{σ : Type u_1} →
(f : σ → Option σ) →
(m₁ m₂ : ℕ) →
(a b : σ) →
(c : Option σ) →
StateTransition.EvalsToInTime f a (some b) m₁ →
StateTransition.EvalsToInTime f b c m₂ → StateTransition.EvalsToInTime f a c (m₂ + m₁)
Transitivity of EvalsToInTime in the sum of the numbers of steps.