Isabelle: Power of a matrix (A^n)?

为君一笑 提交于 2019-12-13 12:21:26

问题


There is a matrix multiplication definition in Cartesian_Euclidean_Space (in directory HOL/Multivariate_Analysis"):

definition matrix_matrix_mult :: "('a::semiring_1) ^'n^'m ⇒ 'a ^'p^'n ⇒ 'a ^ 'p ^'m"
    (infixl "**" 70)
  where "m ** m' == (χ i j. setsum (λk. ((m$i)$k) * ((m'$k)$j)) (UNIV :: 'n set)) ::'a ^ 'p ^'m"

Now the the squared matrix would be A ** A and A^3 would be A ** A ** A.

I couldn't find a powerfunction, to define A^n (i.e., A ** A ** ... ** A n times).

Is there a power function in the library? Is a manual definition needed?


回答1:


I have found the following definition in HOL/Power.thy :

primrec power :: "'a ⇒ nat ⇒ 'a" (infixr "^" 80) where
    power_0: "a ^ 0 = 1"
  | power_Suc: "a ^ Suc n = a * a ^ n"

(Control + Click gets you to the respecitve definition! So I clicked on "^", I just wrote "1 ^ 1 = 1" as a lemma first.

Here is the definition for the power of a matrice. (As I only use square matrices this is fine, but a more general type of ^'n^'m would be nice.)

primrec powerM :: "(('a::semiring_1) ^'n^'n) ⇒ nat ⇒ (('a::semiring_1) ^'n^'n)" 
(infixr "^^^" 80) where
  powerM_0: "A ^^^(0::nat) = mat 1"
| powerM_Suc: "A ^^^(Suc n) = A ** (powerM A n)"


来源:https://stackoverflow.com/questions/20208282/isabelle-power-of-a-matrix-an

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!