coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Mohit Tekriwal <tmohit AT umich.edu>
- To: coq-club AT inria.fr
- Subject: [Coq-Club] Using mathcomp library
- Date: Wed, 23 Dec 2020 12:31:10 -0500
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=tmohit AT umich.edu; spf=Pass smtp.mailfrom=tmohit AT umich.edu; spf=None smtp.helo=postmaster AT mail-lf1-f47.google.com
- Ironport-phdr: 9a23:KgwtYBO0K7Aal9Xsi0cl6mtUPXoX/o7sNwtQ0KIMzox0Lfv+rarrMEGX3/hxlliBBdydt6sbzbCO7Ou9BSQp2tWoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6nK94iQPFRrhKAF7Ovr6GpLIj8Swyuu+54Dfbx9HiTagY75+Ngu6oRnTu8UZgYZvJbs6xwfUrHdPZ+lY335jK0iJnxb76Mew/Zpj/DpVtvk86cNOUrj0crohQ7BAAzsoL2465MvwtRneVgSP/WcTUn8XkhVTHQfI6gzxU4rrvSv7sup93zSaPdHzQLspVzmu87tnRRn1gyoBKjU38nzYitZoga1UoByvqR9xzZPKbo6JL/dxZL/RcMkASGZdQspcVSpMCZ68YYsVCOoBOP5VoY76p1sOrBu+GRSnCv3xxT9LnH/23KM73P4lEQrb2wEgA9cOsHPUrNX0KKcfSv21zKzJzTrfb/Nawyny55XVch04p/yHQL1/f9bLx0Y1CwPFkkufqZbjPz6N2eoAvGqW4upgWO+tiWMrtR18rzyxysojiITEmJ4Zx1Ta+Clk3os7JcC0RU90bNK5EJVdtSOXOo93T84jTGxltyA3waAFt56jZCUG1ogryhrFZ/GEc4WE+A/vWeeTLDtii39oerSyjAuo/0e60O3zTMy03U5KriVbltnMsWgA1xnJ5ciGTvtx50Oh2TiS2wzK5OFJLkI5mbDUK54mxb4wmZ4TvlrZEiDqn0X2ibeadkQi+ue29+TqeqvqqoOYOoNuiQzzMr4iltG+DOk6KAQDUGqW9fy51LL5/E35RLtKjucxkqncqJ3aOcEbpqm5Aw9UzoYu8Au/DzKn0NsEnXkLNkxKdw+aj4TxIVHBPOj4Deujg1SriDpk2/fGPqT4DprRKnjDjazucK1m609czQoz1cpQ64hVCrEHOvLzW1X+uMbWDh8jYESIxLPsD8w43YcDU0qOBLWYOeXcqwym/OUqdsyLZI4J8ArwKOIk+PfqxSslnFgdfLWBwJ4WY3D+E/h7dRbKKUHwi8sMRD9Z9jE1S/bn3QXbDWxjIk2qVqd53QkVTZq8BN6aFJ2ogbeBmiq3A88OPzEUOhW3CX7tMr68dbIJYSOWLNVml2VdB6WkSoQhkxyiqV2jkuc1Hq/v4iQd8Knb+p116unUz0xg8DV1C4GZ3TjIQT0r2GwPQDAy0eZ0pkkvklo=
Hello,
--
I am trying to use the matrix algebra package in mathcomp and I am having trouble understanding how to instantiate the matrices and prove certain properties on it.
For example, I want to instantiate the matrix:
A= [ 1, 2; 3, 4]
and be able to access any element Aij.
Using the Coquelicot definition of matrix, I can define the matrix as:
Definition A:= mk_matrix 2%nat 2%nat (fun i j=>
if (andb (eqb i 0) (eqb j 0)) then 1 else
if (andb (eqb i 0) (eqb j 1)) then 2 else
if (andb (eqb i 1) (eqb j 0)) then 3 else 4).
if (andb (eqb i 0) (eqb j 0)) then 1 else
if (andb (eqb i 0) (eqb j 1)) then 2 else
if (andb (eqb i 1) (eqb j 0)) then 3 else 4).
To access an element at index (0,1), I can use the following definition:
Definition A01:= coeff_mat 0 A 0%nat 1%nat.
Compute A01.
That gives me 2.
I tried the following in mathcomp:
Definition A1 := @matrix_of_fun _ 2%nat 2%nat matrix_key (fun i j=>
if (andb (eqb i 0) (eqb j 0)) then 1 else
if (andb (eqb i 0) (eqb j 1)) then 2 else
if (andb (eqb i 1) (eqb j 0)) then 3 else 4).
if (andb (eqb i 0) (eqb j 0)) then 1 else
if (andb (eqb i 0) (eqb j 1)) then 2 else
if (andb (eqb i 1) (eqb j 0)) then 3 else 4).
Definition A1_00:= A1 (inord 0) (inord 0).
Compute A1_00.
Compute A1_00.
That gives me:
let......: (fun _ : 'I_2 * 'I_2 => R) (inord 0, inord 0)
instead of 2.
Also, when trying to prove that the trace of A is 5 in mathcomp:
Lemma trace_is_5: mxtrace A1 = 5.
I get the following error message:
The term "A1" has type "'M_2"
while it is expected to have type
"'M_?n".
while it is expected to have type
"'M_?n".
Am I missing something? How do I use the theorems/lemmas defined in mathcomp for specific matrices ?
It would be really nice if someone can provide inputs on this issue.
Thanking you,
Mohit Tekriwal.
Mohit Tekriwal,
PhD Candidate,
Department of Aerospace Engineering,
University of Michigan.
- [Coq-Club] Using mathcomp library, Mohit Tekriwal, 12/23/2020
Archive powered by MHonArc 2.6.19+.