计算机科学 ›› 2023, Vol. 50 ›› Issue (6A): 220400108-7.doi: 10.11896/jsjkx.220400108

• 软件&交叉 • 上一篇    下一篇

基于 Coq 的逆矩阵运算的形式化

沈楠, 陈钢   

  1. 南京航空航天大学计算机学院 南京 210000
  • 出版日期:2023-06-10 发布日期:2023-06-12
  • 通讯作者: 陈钢(gangchensh@qq.com)
  • 作者简介:(2257776063@qq.com)

Formalization of Inverse Matrix Operation Based on Coq

SHEN Nan, CHEN Gang   

  1. College of Computer Science and Technology,Nanjing University of Aeronautics and Astronautics,Nanjing 210000,China
  • Online:2023-06-10 Published:2023-06-12
  • About author:SHEN Nan,born in 1998,postgraduate.His main research interests include formal methods and so on. CHEN Gang,born in 1958,Ph.D,professor,is a distinguished member of China Computer Federation.His main research interests include formal methods and so on.

摘要: 矩阵是一种在计算机科学中应用广泛的数据结构,其运算正确性具有重要意义。矩阵求逆在矩阵形式化工作当中缺乏合理且实用的形式化工作。其原因在于,工程中现有的两种常见求逆方法的形式化均存在难点。第一种是基于伴随矩阵求解方法,难点在于无法形式化地表示n*n矩阵的子矩阵,导致构建余子式组成的矩阵十分困难,因此难以实现伴随矩阵求解逆矩阵形式化;第二种称作高斯约旦初等变换求解法,难点在于构造初等矩阵及其操作函数。若使用Coq归纳结构设计操作函数,即采用行优先填充二维表的思想,将舍弃列维度对二维表的描述信息,使得操作函数分支过多,需要设计复杂的归纳结构,导致后续形式化验证无法进行。文中提出了基于记录的矩阵函数构建法,使用行列两种维度同时描述矩阵,使得构造并证明初等矩阵成为可能,在此基础上实现了在Coq系统中基于高斯约旦消元法的矩阵求逆的形式化工作。以一种代价更小且时间复杂度更低的方式,实现了首个形式化验证下的软件逆矩阵函数库。

关键词: 形式化验证, 形式化工程数学, 逆矩阵形式化, Coq, 软件安全

Abstract: Matrix is a data structure widely used in computer science,and its correctness of operation is of great significance.In matrix formalization,there is no reasonable and practical formalization work.The reason lies in the difficulty in formalizing the two common inverse methods in engineering.The first method is based on the adjoint matrix solution method.The difficulty lies in that the submatrices of n*n matrix cannot be formally expressed,which makes it very difficult to construct the matrix composed of cosubformulas.Therefore,it is difficult to achieve the formalization of adjoint matrix inverse solution.The second method is called Gauss-Jordan elementary transformation method,the difficulty lies in the construction of elementary matrix and its operation function.If Coq is used to design the operation function of inductive structure,that is,the idea of filling two-dimensional table with rows first is adopted,the description information of two-dimensional table from column dimension will be discarded,so that the operation function branches too much and complex inductive structure needs to be designed,which leads to the failure of subsequent formal verification.In this paper,a record-based matrix function construction method is proposed,which describes the matrix in both column and column dimensions,making it possible to construct and prove the elementary matrix.On this basis,the formalization of matrix inversion in Coq system based on gaussian-Jordan elimination method is realized.And we implement the first software matrix inversion function library under formal verification in a way with lower cost and time complexity.

Key words: Formal verification, Formal engineering mathematics, Inverse matrix formalization, Coq, Software security

中图分类号: 

  • TP311
[1]CHEN G,QIU Z Y,SONG X Y,et al.A Report from Head Start:Formalizing Engineering Mathematics[J].Communications of China Computer Society,2017:92-93.
[2]ALMEIDA JB,FRADE M J,PINTO J S,et al.An overview of formal methods tools and techniques[C]//Rigorous Software Development.London:Springer,2011:15-44.
[3]HATEL P H,MOREAU L.Formalizing the safety of Java,the Java virtual machine,and Java card[J].ACM Computing Surveys(CSUR),2001,33(4):15-44.
[4]BERTOT Y,CASTERAN P.Interactive Theorem Proving and Program Development[M]//Interactive theorem proving and program development.Coq’Art:The Calculus of Inductive Constructions.Springer,2004.
[5]LI L M,SHI Z P,GUAN Y,et al.Formalizing the Matrix Inversion Based on the Adjugate Matrix in HOL4[C]//8th International Conference on Intelligent Information Processing(IIP).2014:178-186.
[6]MA Z W,CHEN G.Matrix Formalization Based on Coq Record[J].Computer Science,2019,46(7):139-145.
[7]SHI Z P,LIU Z K,GUAN Y,et al.Formalization of FunctionMatrix Theory in HOL[J].Journal of Applied Mathematics,2014,SI(1):1-10.
[8]KANG X N,SHI Z P,YE S W,et al.Formalization of MatrixTransformation Theory in HOL4[J].Computer Simulation,2014(3):1-16.
[9]YANG X M,GUAN Y,SHI Z P,et al.Higher-order Logic Formalization of Function Matrix and its Calculus[J].Computer Science,2016(11):24-29.
[10]BIHA S O.Finite groups representation theory with Coq[C]//8th International Conference on Mathematical Knowledge Mana-gement.Berlin:Spriger,2009:438-452.
[11]HERAS J,POZA M,DÉNÈS M.Incidence Simplicial Matrices Formalized in Coq/SSReflect[M].Spriner_verlag,2011:30-44.
[12]DENES M,BERTOT Y.Experiments with computable matricesin the Coq system[R].France:INRIA,2011:2-27.
[13]BOLDO S,LELAY C,MELQUIOND G.Coquelicot:A User-Friendly Library of Real Analysis for Coq[J].Mathematics in Computer Science,2015,9(1):41-62.
[14]MA Y Y,MA Z W,CHEN G.Formalization of Operations of Block Matrix Based on Coq[J].Ruan Jian Xue Bao/Journal of Software,2021,32(6):1882-1909.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!