:: MATRIX_2 semantic presentation

definition
let c1, c2 be Nat;
let c3 be set ;
func c1,c2 --> c3 -> tabular FinSequence equals :: MATRIX_2:def 1
a1 |-> (a2 |-> a3);
coherence
c1 |-> (c2 |-> c3) is tabular FinSequence
by MATRIX_1:2;
end;

:: deftheorem Def1 defines --> MATRIX_2:def 1 :
for b1, b2 being Nat
for b3 being set holds b1,b2 --> b3 = b1 |-> (b2 |-> b3);

definition
let c1 be non empty set ;
let c2, c3 be Nat;
let c4 be Element of c1;
redefine func --> as c2,c3 --> c4 -> Matrix of a2,a3,a1;
coherence
c2,c3 --> c4 is Matrix of c2,c3,c1
by MATRIX_1:10;
end;

theorem Th1: :: MATRIX_2:1
for b1, b2, b3, b4 being Nat
for b5 being non empty set
for b6 being Element of b5 st [b1,b2] in Indices (b3,b4 --> b6) holds
(b3,b4 --> b6) * b1,b2 = b6
proof end;

theorem Th2: :: MATRIX_2:2
for b1 being Nat
for b2 being Field
for b3, b4 being Element of b2 holds (b1,b1 --> b3) + (b1,b1 --> b4) = b1,b1 --> (b3 + b4)
proof end;

definition
let c1, c2, c3, c4 be set ;
func c1,c2 ][ c3,c4 -> tabular FinSequence equals :: MATRIX_2:def 2
<*<*a1,a2*>,<*a3,a4*>*>;
correctness
coherence
<*<*c1,c2*>,<*c3,c4*>*> is tabular FinSequence
;
proof end;
end;

:: deftheorem Def2 defines ][ MATRIX_2:def 2 :
for b1, b2, b3, b4 being set holds b1,b2 ][ b3,b4 = <*<*b1,b2*>,<*b3,b4*>*>;

theorem Th3: :: MATRIX_2:3
for b1, b2, b3, b4 being set holds
( len (b1,b2 ][ b3,b4) = 2 & width (b1,b2 ][ b3,b4) = 2 & Indices (b1,b2 ][ b3,b4) = [:(Seg 2),(Seg 2):] )
proof end;

theorem Th4: :: MATRIX_2:4
for b1, b2, b3, b4 being set holds
( [1,1] in Indices (b1,b2 ][ b3,b4) & [1,2] in Indices (b1,b2 ][ b3,b4) & [2,1] in Indices (b1,b2 ][ b3,b4) & [2,2] in Indices (b1,b2 ][ b3,b4) )
proof end;

definition
let c1 be non empty set ;
let c2 be Element of c1;
redefine func <* as <*c2*> -> Element of 1 -tuples_on a1;
coherence
<*c2*> is Element of 1 -tuples_on c1
by FINSEQ_2:118;
end;

definition
let c1 be non empty set ;
let c2 be Nat;
let c3 be Element of c2 -tuples_on c1;
redefine func <* as <*c3*> -> Matrix of 1,a2,a1;
coherence
<*c3*> is Matrix of 1,c2,c1
proof end;
end;

theorem Th5: :: MATRIX_2:5
for b1 being non empty set
for b2 being Element of b1 holds
( [1,1] in Indices <*<*b2*>*> & <*<*b2*>*> * 1,1 = b2 )
proof end;

definition
let c1 be non empty set ;
let c2, c3, c4, c5 be Element of c1;
redefine func ][ as c2,c3 ][ c4,c5 -> Matrix of 2,a1;
coherence
c2,c3 ][ c4,c5 is Matrix of 2,c1
by MATRIX_1:19;
end;

theorem Th6: :: MATRIX_2:6
for b1 being non empty set
for b2, b3, b4, b5 being Element of b1 holds
( (b2,b3 ][ b4,b5) * 1,1 = b2 & (b2,b3 ][ b4,b5) * 1,2 = b3 & (b2,b3 ][ b4,b5) * 2,1 = b4 & (b2,b3 ][ b4,b5) * 2,2 = b5 )
proof end;

definition
let c1 be Nat;
let c2 be Field;
mode Upper_Triangular_Matrix of c1,c2 -> Matrix of a1,a2 means :: MATRIX_2:def 3
for b1, b2 being Nat st [b1,b2] in Indices a3 & b1 > b2 holds
a3 * b1,b2 = 0. a2;
existence
ex b1 being Matrix of c1,c2 st
for b2, b3 being Nat st [b2,b3] in Indices b1 & b2 > b3 holds
b1 * b2,b3 = 0. c2
proof end;
end;

:: deftheorem Def3 defines Upper_Triangular_Matrix MATRIX_2:def 3 :
for b1 being Nat
for b2 being Field
for b3 being Matrix of b1,b2 holds
( b3 is Upper_Triangular_Matrix of b1,b2 iff for b4, b5 being Nat st [b4,b5] in Indices b3 & b4 > b5 holds
b3 * b4,b5 = 0. b2 );

definition
let c1 be Nat;
let c2 be Field;
mode Lower_Triangular_Matrix of c1,c2 -> Matrix of a1,a2 means :: MATRIX_2:def 4
for b1, b2 being Nat st [b1,b2] in Indices a3 & b1 < b2 holds
a3 * b1,b2 = 0. a2;
existence
ex b1 being Matrix of c1,c2 st
for b2, b3 being Nat st [b2,b3] in Indices b1 & b2 < b3 holds
b1 * b2,b3 = 0. c2
proof end;
end;

:: deftheorem Def4 defines Lower_Triangular_Matrix MATRIX_2:def 4 :
for b1 being Nat
for b2 being Field
for b3 being Matrix of b1,b2 holds
( b3 is Lower_Triangular_Matrix of b1,b2 iff for b4, b5 being Nat st [b4,b5] in Indices b3 & b4 < b5 holds
b3 * b4,b5 = 0. b2 );

theorem Th7: :: MATRIX_2:7
for b1 being Nat
for b2 being non empty set
for b3 being Matrix of b2 st len b3 = b1 holds
b3 is Matrix of b1, width b3,b2
proof end;

theorem Th8: :: MATRIX_2:8
canceled;

theorem Th9: :: MATRIX_2:9
canceled;

theorem Th10: :: MATRIX_2:10
for b1, b2 being Nat
for b3 being Field
for b4 being Matrix of b1,b2,b3
for b5 being Nat st b5 in Seg b1 holds
b4 . b5 = Line b4,b5
proof end;

definition
let c1 be Nat;
let c2 be Field;
let c3 be Matrix of c2;
canceled;
assume E5: c1 in Seg (width c3) ;
func DelCol c3,c1 -> Matrix of a2 means :: MATRIX_2:def 6
( len a4 = len a3 & ( for b1 being Nat st b1 in dom a3 holds
a4 . b1 = Del (Line a3,b1),a1 ) );
existence
ex b1 being Matrix of c2 st
( len b1 = len c3 & ( for b2 being Nat st b2 in dom c3 holds
b1 . b2 = Del (Line c3,b2),c1 ) )
proof end;
uniqueness
for b1, b2 being Matrix of c2 st len b1 = len c3 & ( for b3 being Nat st b3 in dom c3 holds
b1 . b3 = Del (Line c3,b3),c1 ) & len b2 = len c3 & ( for b3 being Nat st b3 in dom c3 holds
b2 . b3 = Del (Line c3,b3),c1 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def5 MATRIX_2:def 5 :
canceled;

:: deftheorem Def6 defines DelCol MATRIX_2:def 6 :
for b1 being Nat
for b2 being Field
for b3 being Matrix of b2 st b1 in Seg (width b3) holds
for b4 being Matrix of b2 holds
( b4 = DelCol b3,b1 iff ( len b4 = len b3 & ( for b5 being Nat st b5 in dom b3 holds
b4 . b5 = Del (Line b3,b5),b1 ) ) );

theorem Th11: :: MATRIX_2:11
for b1 being non empty set
for b2, b3 being Matrix of b1 st b2 @ = b3 @ & len b2 = len b3 holds
b2 = b3
proof end;

theorem Th12: :: MATRIX_2:12
for b1 being non empty set
for b2 being Matrix of b1 st width b2 > 0 holds
( len (b2 @ ) = width b2 & width (b2 @ ) = len b2 )
proof end;

theorem Th13: :: MATRIX_2:13
for b1 being non empty set
for b2, b3 being Matrix of b1 st width b2 > 0 & width b3 > 0 & b2 @ = b3 @ & width (b2 @ ) = width (b3 @ ) holds
b2 = b3
proof end;

theorem Th14: :: MATRIX_2:14
for b1 being non empty set
for b2, b3 being Matrix of b1 st width b2 > 0 & width b3 > 0 holds
( b2 = b3 iff ( b2 @ = b3 @ & width b2 = width b3 ) )
proof end;

theorem Th15: :: MATRIX_2:15
for b1 being non empty set
for b2 being Matrix of b1 st len b2 > 0 & width b2 > 0 holds
(b2 @ ) @ = b2
proof end;

theorem Th16: :: MATRIX_2:16
for b1 being non empty set
for b2 being Matrix of b1
for b3 being Nat st b3 in dom b2 holds
Line b2,b3 = Col (b2 @ ),b3
proof end;

theorem Th17: :: MATRIX_2:17
for b1 being non empty set
for b2 being Matrix of b1
for b3 being Nat st b3 in Seg (width b2) holds
Line (b2 @ ),b3 = Col b2,b3
proof end;

theorem Th18: :: MATRIX_2:18
for b1 being non empty set
for b2 being Matrix of b1
for b3 being Nat st b3 in dom b2 holds
b2 . b3 = Line b2,b3
proof end;

definition
let c1 be Nat;
let c2 be Field;
let c3 be Matrix of c2;
assume E12: ( c1 in dom c3 & width c3 > 0 ) ;
func DelLine c3,c1 -> Matrix of a2 means :: MATRIX_2:def 7
a4 = {} if len a3 = 1
otherwise ( width a4 = width a3 & ( for b1 being Nat st b1 in Seg (width a3) holds
Col a4,b1 = Del (Col a3,b1),a1 ) );
existence
( ( len c3 = 1 implies ex b1 being Matrix of c2 st b1 = {} ) & ( not len c3 = 1 implies ex b1 being Matrix of c2 st
( width b1 = width c3 & ( for b2 being Nat st b2 in Seg (width c3) holds
Col b1,b2 = Del (Col c3,b2),c1 ) ) ) )
proof end;
uniqueness
for b1, b2 being Matrix of c2 holds
( ( len c3 = 1 & b1 = {} & b2 = {} implies b1 = b2 ) & ( not len c3 = 1 & width b1 = width c3 & ( for b3 being Nat st b3 in Seg (width c3) holds
Col b1,b3 = Del (Col c3,b3),c1 ) & width b2 = width c3 & ( for b3 being Nat st b3 in Seg (width c3) holds
Col b2,b3 = Del (Col c3,b3),c1 ) implies b1 = b2 ) )
proof end;
consistency
for b1 being Matrix of c2 holds verum
;
end;

:: deftheorem Def7 defines DelLine MATRIX_2:def 7 :
for b1 being Nat
for b2 being Field
for b3 being Matrix of b2 st b1 in dom b3 & width b3 > 0 holds
for b4 being Matrix of b2 holds
( ( len b3 = 1 implies ( b4 = DelLine b3,b1 iff b4 = {} ) ) & ( not len b3 = 1 implies ( b4 = DelLine b3,b1 iff ( width b4 = width b3 & ( for b5 being Nat st b5 in Seg (width b3) holds
Col b4,b5 = Del (Col b3,b5),b1 ) ) ) ) );

definition
let c1, c2, c3 be Nat;
let c4 be Field;
let c5 be Matrix of c3,c4;
func Deleting c5,c1,c2 -> Matrix of a4 equals :: MATRIX_2:def 8
{} if a3 = 1
otherwise DelCol (DelLine a5,a1),a2;
coherence
( ( c3 = 1 implies {} is Matrix of c4 ) & ( not c3 = 1 implies DelCol (DelLine c5,c1),c2 is Matrix of c4 ) )
by MATRIX_1:13;
consistency
for b1 being Matrix of c4 holds verum
;
end;

:: deftheorem Def8 defines Deleting MATRIX_2:def 8 :
for b1, b2, b3 being Nat
for b4 being Field
for b5 being Matrix of b3,b4 holds
( ( b3 = 1 implies Deleting b5,b1,b2 = {} ) & ( not b3 = 1 implies Deleting b5,b1,b2 = DelCol (DelLine b5,b1),b2 ) );

definition
let c1 be set ;
attr a1 is permutational means :Def9: :: MATRIX_2:def 9
ex b1 being Nat st
for b2 being set st b2 in a1 holds
b2 is Permutation of Seg b1;
end;

:: deftheorem Def9 defines permutational MATRIX_2:def 9 :
for b1 being set holds
( b1 is permutational iff ex b2 being Nat st
for b3 being set st b3 in b1 holds
b3 is Permutation of Seg b2 );

registration
cluster non empty permutational set ;
existence
ex b1 being set st
( b1 is permutational & not b1 is empty )
proof end;
end;

definition
let c1 be non empty permutational set ;
func len c1 -> Nat means :Def10: :: MATRIX_2:def 10
ex b1 being FinSequence st
( b1 in a1 & a2 = len b1 );
existence
ex b1 being Natex b2 being FinSequence st
( b2 in c1 & b1 = len b2 )
proof end;
uniqueness
for b1, b2 being Nat st ex b3 being FinSequence st
( b3 in c1 & b1 = len b3 ) & ex b3 being FinSequence st
( b3 in c1 & b2 = len b3 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def10 defines len MATRIX_2:def 10 :
for b1 being non empty permutational set
for b2 being Nat holds
( b2 = len b1 iff ex b3 being FinSequence st
( b3 in b1 & b2 = len b3 ) );

definition
let c1 be non empty permutational set ;
redefine mode Element as Element of c1 -> Permutation of Seg (len a1);
coherence
for b1 being Element of c1 holds b1 is Permutation of Seg (len c1)
proof end;
end;

theorem Th19: :: MATRIX_2:19
for b1 being Nat ex b2 being non empty permutational set st len b2 = b1
proof end;

definition
let c1 be Nat;
func Permutations c1 -> set means :Def11: :: MATRIX_2:def 11
for b1 being set holds
( b1 in a2 iff b1 is Permutation of Seg a1 );
existence
ex b1 being set st
for b2 being set holds
( b2 in b1 iff b2 is Permutation of Seg c1 )
proof end;
uniqueness
for b1, b2 being set st ( for b3 being set holds
( b3 in b1 iff b3 is Permutation of Seg c1 ) ) & ( for b3 being set holds
( b3 in b2 iff b3 is Permutation of Seg c1 ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def11 defines Permutations MATRIX_2:def 11 :
for b1 being Nat
for b2 being set holds
( b2 = Permutations b1 iff for b3 being set holds
( b3 in b2 iff b3 is Permutation of Seg b1 ) );

registration
let c1 be Nat;
cluster Permutations a1 -> non empty permutational ;
coherence
( Permutations c1 is permutational & not Permutations c1 is empty )
proof end;
end;

theorem Th20: :: MATRIX_2:20
for b1 being Nat holds len (Permutations b1) = b1
proof end;

theorem Th21: :: MATRIX_2:21
Permutations 1 = {(idseq 1)}
proof end;

definition
let c1 be Nat;
let c2 be Element of Permutations c1;
func len c2 -> Nat means :Def12: :: MATRIX_2:def 12
ex b1 being FinSequence st
( b1 = a2 & a3 = len b1 );
existence
ex b1 being Natex b2 being FinSequence st
( b2 = c2 & b1 = len b2 )
proof end;
uniqueness
for b1, b2 being Nat st ex b3 being FinSequence st
( b3 = c2 & b1 = len b3 ) & ex b3 being FinSequence st
( b3 = c2 & b2 = len b3 ) holds
b1 = b2
;
end;

:: deftheorem Def12 defines len MATRIX_2:def 12 :
for b1 being Nat
for b2 being Element of Permutations b1
for b3 being Nat holds
( b3 = len b2 iff ex b4 being FinSequence st
( b4 = b2 & b3 = len b4 ) );

theorem Th22: :: MATRIX_2:22
for b1 being Nat
for b2 being Element of Permutations b1 holds len b2 = b1
proof end;

definition
let c1 be Nat;
func Group_of_Perm c1 -> strict HGrStr means :Def13: :: MATRIX_2:def 13
( the carrier of a2 = Permutations a1 & ( for b1, b2 being Element of Permutations a1 holds the mult of a2 . b1,b2 = b2 * b1 ) );
existence
ex b1 being strict HGrStr st
( the carrier of b1 = Permutations c1 & ( for b2, b3 being Element of Permutations c1 holds the mult of b1 . b2,b3 = b3 * b2 ) )
proof end;
uniqueness
for b1, b2 being strict HGrStr st the carrier of b1 = Permutations c1 & ( for b3, b4 being Element of Permutations c1 holds the mult of b1 . b3,b4 = b4 * b3 ) & the carrier of b2 = Permutations c1 & ( for b3, b4 being Element of Permutations c1 holds the mult of b2 . b3,b4 = b4 * b3 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def13 defines Group_of_Perm MATRIX_2:def 13 :
for b1 being Nat
for b2 being strict HGrStr holds
( b2 = Group_of_Perm b1 iff ( the carrier of b2 = Permutations b1 & ( for b3, b4 being Element of Permutations b1 holds the mult of b2 . b3,b4 = b4 * b3 ) ) );

registration
let c1 be Nat;
cluster Group_of_Perm a1 -> non empty strict ;
coherence
not Group_of_Perm c1 is empty
proof end;
end;

theorem Th23: :: MATRIX_2:23
for b1 being Nat holds idseq b1 is Element of (Group_of_Perm b1)
proof end;

theorem Th24: :: MATRIX_2:24
for b1 being Nat
for b2 being Element of Permutations b1 holds
( b2 * (idseq b1) = b2 & (idseq b1) * b2 = b2 )
proof end;

theorem Th25: :: MATRIX_2:25
for b1 being Nat
for b2 being Element of Permutations b1 holds
( b2 * (b2 " ) = idseq b1 & (b2 " ) * b2 = idseq b1 )
proof end;

theorem Th26: :: MATRIX_2:26
for b1 being Nat
for b2 being Element of Permutations b1 holds b2 " is Element of (Group_of_Perm b1)
proof end;

definition
let c1 be Nat;
mode permutation of a1 is Element of Permutations a1;
end;

registration
let c1 be Nat;
cluster Group_of_Perm a1 -> non empty strict Group-like associative ;
coherence
( Group_of_Perm c1 is associative & Group_of_Perm c1 is Group-like )
proof end;
end;

theorem Th27: :: MATRIX_2:27
canceled;

theorem Th28: :: MATRIX_2:28
for b1 being Nat holds idseq b1 = 1. (Group_of_Perm b1)
proof end;

definition
let c1 be Nat;
let c2 be Permutation of Seg c1;
attr a2 is being_transposition means :: MATRIX_2:def 14
ex b1, b2 being Nat st
( b1 in dom a2 & b2 in dom a2 & b1 <> b2 & a2 . b1 = b2 & a2 . b2 = b1 & ( for b3 being Nat st b3 <> b1 & b3 <> b2 & b3 in dom a2 holds
a2 . b3 = b3 ) );
end;

:: deftheorem Def14 defines being_transposition MATRIX_2:def 14 :
for b1 being Nat
for b2 being Permutation of Seg b1 holds
( b2 is being_transposition iff ex b3, b4 being Nat st
( b3 in dom b2 & b4 in dom b2 & b3 <> b4 & b2 . b3 = b4 & b2 . b4 = b3 & ( for b5 being Nat st b5 <> b3 & b5 <> b4 & b5 in dom b2 holds
b2 . b5 = b5 ) ) );

notation
let c1 be Nat;
let c2 be Permutation of Seg c1;
synonym c2 is_transposition for being_transposition c2;
end;

definition
let c1 be Nat;
let c2 be Permutation of Seg c1;
attr a2 is even means :Def15: :: MATRIX_2:def 15
ex b1 being FinSequence of the carrier of (Group_of_Perm a1) st
( (len b1) mod 2 = 0 & a2 = Product b1 & ( for b2 being Nat st b2 in dom b1 holds
ex b3 being Element of Permutations a1 st
( b1 . b2 = b3 & b3 is_transposition ) ) );
end;

:: deftheorem Def15 defines even MATRIX_2:def 15 :
for b1 being Nat
for b2 being Permutation of Seg b1 holds
( b2 is even iff ex b3 being FinSequence of the carrier of (Group_of_Perm b1) st
( (len b3) mod 2 = 0 & b2 = Product b3 & ( for b4 being Nat st b4 in dom b3 holds
ex b5 being Element of Permutations b1 st
( b3 . b4 = b5 & b5 is_transposition ) ) ) );

notation
let c1 be Nat;
let c2 be Permutation of Seg c1;
antonym odd c2 for even c2;
end;

theorem Th29: :: MATRIX_2:29
for b1 being Nat holds id (Seg b1) is even
proof end;

definition
let c1 be Field;
let c2 be Nat;
let c3 be Element of c1;
let c4 be Element of Permutations c2;
func - c3,c4 -> Element of a1 equals :: MATRIX_2:def 16
a3 if a4 is even
otherwise - a3;
correctness
coherence
( ( c4 is even implies c3 is Element of c1 ) & ( not c4 is even implies - c3 is Element of c1 ) )
;
consistency
for b1 being Element of c1 holds verum
;
;
end;

:: deftheorem Def16 defines - MATRIX_2:def 16 :
for b1 being Field
for b2 being Nat
for b3 being Element of b1
for b4 being Element of Permutations b2 holds
( ( b4 is even implies - b3,b4 = b3 ) & ( not b4 is even implies - b3,b4 = - b3 ) );

definition
let c1 be set ;
assume E23: c1 is finite ;
func FinOmega c1 -> Element of Fin a1 equals :: MATRIX_2:def 17
a1;
coherence
c1 is Element of Fin c1
by E23, FINSUB_1:def 5;
end;

:: deftheorem Def17 defines FinOmega MATRIX_2:def 17 :
for b1 being set st b1 is finite holds
FinOmega b1 = b1;

theorem Th30: :: MATRIX_2:30
for b1 being Nat holds Permutations b1 is finite
proof end;