Documentation

CslibFrontier.Foundations.Analysis.ODE.StateSpace

Continuous-time LTI state-space systems: forced response and impulse response #

A finite-dimensional real continuous-time linear time-invariant system ẋ = A x + B u, y = C x + D u with state index n, input index m and output index p is an LTISystem n m p: the four real matrices A : n × n, B : n × m, C : p × n, D : p × m. States, inputs and outputs are coordinate vectors n → ℝ, m → ℝ, p → ℝ; no norm is used.

Admissible inputs and solutions #

The admissible inputs on a time set [0, T] or [0, ∞) are the functions u : ℝ → m → ℝ that are continuous there; their values at negative times are never used, and an input need not be bounded on [0, ∞). A state curve x is a solution on the time set s (LTISystem.IsSolutionOn) when it has derivative A x t + B u t within s at each t ∈ s: one-sided derivatives at the endpoints of [0, T] and at the initial time 0 of [0, ∞). Such a curve is continuous on s. The homogeneous case u = 0 is ContinuousLinearMap.IsTrajectoryOn of Matrix.toEuclideanCLM A, through Matrix.isTrajectoryOn_toEuclideanCLM_iff.

For every initial state x₀ and admissible input the unique solution is x t = exp (t • A) *ᵥ x₀ + ∫ s in 0..t, exp ((t - s) • A) *ᵥ (B *ᵥ u s) (LTISystem.isSolutionOn_Icc, LTISystem.IsSolutionOn.eq_Icc and their Ici versions), with no stability, minimality, controllability, observability or diagonalizability assumption.

Impulse response and direct feedthrough #

The response kernel is h t = C * exp (t • A) * B (LTISystem.responseKernel, with defining equation LTISystem.responseKernel_eq); its time-zero value is h 0 = C * B. Every solution has output (LTISystem.IsSolutionOn.output_eq, LTISystem.IsSolutionOn.output_eq_Ici) y t = C *ᵥ (exp (t • A) *ᵥ x 0) + D *ᵥ u t + ∫ s in 0..t, h (t - s) *ᵥ u s for t ≥ 0: the zero-input response from the initial state, plus the zero-state input/output response D u + h ∗ u. This is derived from the state equation, not from a transfer function.

The informal impulse response D δ₀ + h of a system with direct feedthrough is never formed: there is no Dirac delta here, and the system's input/output behaviour is described by the pair (D, h) through the formula above. For D = 0 the causal extension (Set.Ici 0).indicator h is the ordinary impulse-response function: the zero-state output is its convolution over ℝ with the causal extension of the input (LTISystem.IsSolutionOn.output_eq_integral_indicator). An impulse v δ₀ is given state-jump semantics: it moves the state from 0 to B *ᵥ v, after which the unforced output is h t *ᵥ v for t ≥ 0 (LTISystem.responseKernel_mulVec_eq).

Certifying closed forms #

A proposed closed form of h, for instance from an untrusted symbolic tool, is certified from a state-space realization of the proposal, without computing a matrix exponential: if a matrix curve X satisfies X 0 = B and X' = A * X columnwise on [0, ∞), then h t = C * X t for t ≥ 0 (LTISystem.responseKernel_eq_of_hasDerivWithinAt, from Matrix.exp_smul_mul_eq_of_hasDerivWithinAt). The obligations are an initial value and ordinary derivatives, discharged with Mathlib's calculus API. This module is the only import needed from the ODE layer; a client also imports the Mathlib HasDerivAt rules (for Real.exp, Real.sin, products, ...) that its closed form uses.

Realizations of other models #

The theorems here concern the matrices A, B, C, D. A model of another kind, such as a circuit with selected input and output ports, has these responses only through a proof that its input/output behaviour for the admissible inputs is that of an LTISystem: its outputs, after subtracting the equilibrium output and input, agree with C *ᵥ x t + D *ᵥ u t along solutions, including the feedthrough D. By LTISystem.IsSolutionOn.output_eq the zero-state behaviour is determined by (D, h), and LTISystem.responseKernel_similar shows that a change of state coordinates does not change it. An elimination that makes the state depend on derivatives of the input does not produce a system of this form.

Main definitions #

Main results #

References #

theorem Matrix.continuous_exp_smul_apply {n : Type u_1} [Fintype n] [DecidableEq n] (A : Matrix n n ℝ) (i j : n) :
Continuous fun (t : ℝ) => NormedSpace.exp (t • A) i j

The entries of the real flow t ↦ exp (t • A) are continuous in time, for all real t.

structure LTISystem (n : Type u_1) (m : Type u_2) (p : Type u_3) :
Type (max (max u_1 u_2) u_3)

A finite-dimensional real continuous-time linear time-invariant state-space system ẋ = A x + B u, y = C x + D u, with state index n, input index m and output index p.

  • A : Matrix n n ℝ

    The state matrix, n × n.

  • B : Matrix n m ℝ

    The input matrix, n × m.

  • C : Matrix p n ℝ

    The output matrix, p × n.

  • D : Matrix p m ℝ

    The direct-feedthrough matrix, p × m.

The response kernel #

noncomputable def LTISystem.responseKernel {n : Type u_1} {m : Type u_2} {p : Type u_3} [Fintype n] [DecidableEq n] (S : LTISystem n m p) (t : ℝ) :

The response kernel h t = C * exp (t • A) * B. For t ≥ 0 it is the regular part of the impulse response, and the whole impulse response when D = 0.

theorem LTISystem.responseKernel_eq {n : Type u_1} {m : Type u_2} {p : Type u_3} [Fintype n] [DecidableEq n] (S : LTISystem n m p) (t : ℝ) :

The defining equation of the response kernel, for every t : ℝ.

@[simp]
theorem LTISystem.responseKernel_zero {n : Type u_1} {m : Type u_2} {p : Type u_3} [Fintype n] [DecidableEq n] (S : LTISystem n m p) :
S.responseKernel 0 = S.C * S.B

The time-zero value of the response kernel is C * B.

theorem LTISystem.continuous_responseKernel_apply {n : Type u_1} {m : Type u_2} {p : Type u_3} [Fintype n] [DecidableEq n] (S : LTISystem n m p) (i : p) (j : m) :
Continuous fun (t : ℝ) => S.responseKernel t i j

Every entry of the response kernel is continuous in time, for all real t.

theorem LTISystem.responseKernel_eq_of_hasDerivWithinAt {n : Type u_1} {m : Type u_2} {p : Type u_3} [Fintype n] [DecidableEq n] {S : LTISystem n m p} {X : ℝ → Matrix n m ℝ} (hX : ∀ (j : m), ∀ t ∈ Set.Ici 0, HasDerivWithinAt (fun (τ : ℝ) => (X τ).transpose j) (S.A.mulVec ((X t).transpose j)) (Set.Ici 0) t) (hX₀ : X 0 = S.B) {t : ℝ} (ht : 0 ≤ t) :
S.responseKernel t = S.C * X t

Certifying a closed form of the response kernel. If the columns of a matrix curve X : ℝ → Matrix n m ℝ solve x' = A *ᵥ x on [0, ∞) and X 0 = B, then h t = C * X t for t ≥ 0. No matrix exponential is computed: the obligations are an initial value and ordinary derivatives.

theorem LTISystem.responseKernel_similar {n : Type u_1} {m : Type u_2} {p : Type u_3} [Fintype n] [DecidableEq n] {S : LTISystem n m p} {T : Matrix n n ℝ} (hT : IsUnit T) (t : ℝ) :
{ A := T * S.A * T⁻¹, B := T * S.B, C := S.C * T⁻¹, D := S.D }.responseKernel t = S.responseKernel t

Similar realizations have the same response kernel. The change of state coordinates x ↦ T x by an invertible T maps (A, B, C, D) to (T A T⁻¹, T B, C T⁻¹, D) and preserves the response kernel; the feedthrough D is unchanged.

Solutions of the state equation #

def LTISystem.IsSolutionOn {n : Type u_1} {m : Type u_2} {p : Type u_3} [Fintype n] (S : LTISystem n m p) [Fintype m] (u : ℝ → m → ℝ) (x : ℝ → n → ℝ) (s : Set ℝ) :

The state curve x : ℝ → n → ℝ solves the state equation ẋ = A x + B u of S with input u on the time set s: at every t ∈ s its derivative within s is A *ᵥ x t + B *ᵥ u t.

theorem LTISystem.IsSolutionOn.mono {n : Type u_1} {m : Type u_2} {p : Type u_3} [Fintype n] {S : LTISystem n m p} [Fintype m] {u : ℝ → m → ℝ} {x : ℝ → n → ℝ} {s s' : Set ℝ} (hx : S.IsSolutionOn u x s) (h : s' ⊆ s) :
S.IsSolutionOn u x s'

Transport to EuclideanSpace #

Existence and uniqueness: variation of constants #

theorem LTISystem.isSolutionOn_Icc {n : Type u_1} {m : Type u_2} {p : Type u_3} [Fintype n] [DecidableEq n] {S : LTISystem n m p} [Fintype m] {u : ℝ → m → ℝ} (x₀ : n → ℝ) {T : ℝ} (hu : ContinuousOn u (Set.Icc 0 T)) :
S.IsSolutionOn u (fun (t : ℝ) => (NormedSpace.exp (t • S.A)).mulVec x₀ + ∫ (s : ℝ) in 0..t, (NormedSpace.exp ((t - s) • S.A)).mulVec (S.B.mulVec (u s))) (Set.Icc 0 T)

Existence on [0, T]. For an input continuous on [0, T] and any initial state x₀, the variation-of-constants curve is a solution on [0, T].

theorem LTISystem.isSolutionOn_Ici {n : Type u_1} {m : Type u_2} {p : Type u_3} [Fintype n] [DecidableEq n] {S : LTISystem n m p} [Fintype m] {u : ℝ → m → ℝ} (x₀ : n → ℝ) (hu : ContinuousOn u (Set.Ici 0)) :
S.IsSolutionOn u (fun (t : ℝ) => (NormedSpace.exp (t • S.A)).mulVec x₀ + ∫ (s : ℝ) in 0..t, (NormedSpace.exp ((t - s) • S.A)).mulVec (S.B.mulVec (u s))) (Set.Ici 0)

Existence on [0, ∞). For an input continuous on [0, ∞) and any initial state x₀, the variation-of-constants curve is a solution on [0, ∞).

theorem LTISystem.IsSolutionOn.eq_Icc {n : Type u_1} {m : Type u_2} {p : Type u_3} [Fintype n] [DecidableEq n] {S : LTISystem n m p} [Fintype m] {u : ℝ → m → ℝ} {x : ℝ → n → ℝ} {T : ℝ} (hx : S.IsSolutionOn u x (Set.Icc 0 T)) (hu : ContinuousOn u (Set.Icc 0 T)) {t : ℝ} (ht : t ∈ Set.Icc 0 T) :
x t = (NormedSpace.exp (t • S.A)).mulVec (x 0) + ∫ (s : ℝ) in 0..t, (NormedSpace.exp ((t - s) • S.A)).mulVec (S.B.mulVec (u s))

Uniqueness on [0, T]. For an input continuous on [0, T], every solution on [0, T] is the variation-of-constants curve of its initial state: x t = exp (t • A) *ᵥ x 0 + ∫ s in 0..t, exp ((t - s) • A) *ᵥ (B *ᵥ u s).

theorem LTISystem.IsSolutionOn.eq_Ici {n : Type u_1} {m : Type u_2} {p : Type u_3} [Fintype n] [DecidableEq n] {S : LTISystem n m p} [Fintype m] {u : ℝ → m → ℝ} {x : ℝ → n → ℝ} (hx : S.IsSolutionOn u x (Set.Ici 0)) (hu : ContinuousOn u (Set.Ici 0)) {t : ℝ} (ht : 0 ≤ t) :
x t = (NormedSpace.exp (t • S.A)).mulVec (x 0) + ∫ (s : ℝ) in 0..t, (NormedSpace.exp ((t - s) • S.A)).mulVec (S.B.mulVec (u s))

Uniqueness on [0, ∞). For an input continuous on [0, ∞), every solution on [0, ∞) is the variation-of-constants curve of its initial state.

The output: feedthrough and convolution #

theorem LTISystem.IsSolutionOn.output_eq {n : Type u_1} {m : Type u_2} {p : Type u_3} [Fintype n] [DecidableEq n] {S : LTISystem n m p} [Fintype m] {u : ℝ → m → ℝ} {x : ℝ → n → ℝ} [Fintype p] {T : ℝ} (hx : S.IsSolutionOn u x (Set.Icc 0 T)) (hu : ContinuousOn u (Set.Icc 0 T)) {t : ℝ} (ht : t ∈ Set.Icc 0 T) :
S.C.mulVec (x t) + S.D.mulVec (u t) = S.C.mulVec ((NormedSpace.exp (t • S.A)).mulVec (x 0)) + S.D.mulVec (u t) + ∫ (s : ℝ) in 0..t, (S.responseKernel (t - s)).mulVec (u s)

Output formula. For an input continuous on [0, T], every solution on [0, T] has output y t = C x t + D u t = C *ᵥ (exp (t • A) *ᵥ x 0) + D *ᵥ u t + ∫ s in 0..t, h (t - s) *ᵥ u s for t ∈ [0, T], where h is the response kernel. The first term is the zero-input response of the initial state; the other two are the zero-state response, with the direct feedthrough D u kept separate from the convolution with h.

theorem LTISystem.IsSolutionOn.output_eq_Ici {n : Type u_1} {m : Type u_2} {p : Type u_3} [Fintype n] [DecidableEq n] {S : LTISystem n m p} [Fintype m] {u : ℝ → m → ℝ} {x : ℝ → n → ℝ} [Fintype p] (hx : S.IsSolutionOn u x (Set.Ici 0)) (hu : ContinuousOn u (Set.Ici 0)) {t : ℝ} (ht : 0 ≤ t) :
S.C.mulVec (x t) + S.D.mulVec (u t) = S.C.mulVec ((NormedSpace.exp (t • S.A)).mulVec (x 0)) + S.D.mulVec (u t) + ∫ (s : ℝ) in 0..t, (S.responseKernel (t - s)).mulVec (u s)

Output formula on [0, ∞). For an input continuous on [0, ∞), every solution on [0, ∞) has output y t = C *ᵥ (exp (t • A) *ᵥ x 0) + D *ᵥ u t + ∫ s in 0..t, h (t - s) *ᵥ u s for t ≥ 0.

theorem LTISystem.IsSolutionOn.output_eq_integral_indicator {n : Type u_1} {m : Type u_2} {p : Type u_3} [Fintype n] [DecidableEq n] {S : LTISystem n m p} [Fintype m] {u : ℝ → m → ℝ} {x : ℝ → n → ℝ} [Fintype p] (hx : S.IsSolutionOn u x (Set.Ici 0)) (hu : ContinuousOn u (Set.Ici 0)) (hx₀ : x 0 = 0) (hD : S.D = 0) {t : ℝ} (ht : 0 ≤ t) :
S.C.mulVec (x t) + S.D.mulVec (u t) = ∫ (s : ℝ), ((Set.Ici 0).indicator S.responseKernel (t - s)).mulVec ((Set.Ici 0).indicator u s)

The impulse-response theorem for D = 0. With no direct feedthrough and zero initial state, the output of every solution on [0, ∞) driven by an input continuous on [0, ∞) is the convolution over ℝ of the causal kernel (Set.Ici 0).indicator h with the causal input (Set.Ici 0).indicator u: y t = ∫ s, h⁺ (t - s) *ᵥ u⁺ s for t ≥ 0.

Impulses and certified closed forms #

theorem LTISystem.responseKernel_mulVec_eq {n : Type u_1} {m : Type u_2} {p : Type u_3} [Fintype n] [DecidableEq n] {S : LTISystem n m p} [Fintype m] {x : ℝ → n → ℝ} (hx : S.IsSolutionOn 0 x (Set.Ici 0)) {v : m → ℝ} (hx₀ : x 0 = S.B.mulVec v) {t : ℝ} (ht : 0 ≤ t) :
(S.responseKernel t).mulVec v = S.C.mulVec (x t)

State-jump semantics of an impulse. An impulse v δ₀ moves the state from 0 to B *ᵥ v. The unforced solution from that state has output C *ᵥ x t = h t *ᵥ v for t ≥ 0. This also certifies a closed form of h t *ᵥ v from a state curve x.