HomeHome Metamath Proof Explorer
Theorem List (p. 142 of 379)
< Previous  Next >
Browser slow? Try the
Unicode version.

Mirrors  >  Metamath Home Page  >  MPE Home Page  >  Theorem List Contents  >  Recent Proofs       This page: Page List

Color key:    Metamath Proof Explorer  Metamath Proof Explorer
(1-25813)
  Hilbert Space Explorer  Hilbert Space Explorer
(25814-27338)
  Users' Mathboxes  Users' Mathboxes
(27339-37825)
 

Theorem List for Metamath Proof Explorer - 14101-14200   *Has distinct variable group(s)
TypeLabelDescription
Statement
 
Theoremsadid2 14101 The adder sequence function has a right identity, the empty set, which is the representation of the integer zero. (Contributed by Mario Carneiro, 9-Sep-2016.)
 |-  ( A  C_  NN0  ->  ( (/) sadd  A )  =  A )
 
Theoremsadasslem 14102 Lemma for sadass 14103. (Contributed by Mario Carneiro, 9-Sep-2016.)
 |-  ( ph  ->  A  C_ 
 NN0 )   &    |-  ( ph  ->  B 
 C_  NN0 )   &    |-  ( ph  ->  C 
 C_  NN0 )   &    |-  ( ph  ->  N  e.  NN0 )   =>    |-  ( ph  ->  (
 ( ( A sadd  B ) sadd  C )  i^i  (
 0..^ N ) )  =  ( ( A sadd 
 ( B sadd  C )
 )  i^i  ( 0..^ N ) ) )
 
Theoremsadass 14103 Sequence addition is associative. (Contributed by Mario Carneiro, 9-Sep-2016.)
 |-  ( ( A  C_  NN0  /\  B  C_  NN0  /\  C  C_ 
 NN0 )  ->  (
 ( A sadd  B ) sadd  C )  =  ( A sadd 
 ( B sadd  C )
 ) )
 
Theoremsadeq 14104 Any element of a sequence sum only depends on the values of the argument sequences up to and including that point. (Contributed by Mario Carneiro, 9-Sep-2016.)
 |-  ( ph  ->  A  C_ 
 NN0 )   &    |-  ( ph  ->  B 
 C_  NN0 )   &    |-  ( ph  ->  N  e.  NN0 )   =>    |-  ( ph  ->  (
 ( A sadd  B )  i^i  ( 0..^ N ) )  =  ( ( ( A  i^i  (
 0..^ N ) ) sadd 
 ( B  i^i  (
 0..^ N ) ) )  i^i  ( 0..^ N ) ) )
 
Theorembitsres 14105 Restrict the bits of a number to an upper integer set. (Contributed by Mario Carneiro, 5-Sep-2016.)
 |-  ( ( A  e.  ZZ  /\  N  e.  NN0 )  ->  ( (bits `  A )  i^i  ( ZZ>= `  N ) )  =  (bits `  ( ( |_ `  ( A  /  ( 2 ^ N ) ) )  x.  ( 2 ^ N ) ) ) )
 
Theorembitsuz 14106 The bits of a number are all at least  N iff the number is divisible by  2 ^ N. (Contributed by Mario Carneiro, 21-Sep-2016.)
 |-  ( ( A  e.  ZZ  /\  N  e.  NN0 )  ->  ( ( 2 ^ N )  ||  A 
 <->  (bits `  A )  C_  ( ZZ>= `  N )
 ) )
 
Theorembitsshft 14107* Shifting a bit sequence to the left (toward the more significant bits) causes the number to be multiplied by a power of two. (Contributed by Mario Carneiro, 22-Sep-2016.)
 |-  ( ( A  e.  ZZ  /\  N  e.  NN0 )  ->  { n  e. 
 NN0  |  ( n  -  N )  e.  (bits `  A ) }  =  (bits `  ( A  x.  ( 2 ^ N ) ) ) )
 
Definitiondf-smu 14108* Define the multiplication of two bit sequences, using repeated sequence addition. (Contributed by Mario Carneiro, 9-Sep-2016.)
 |- smul  =  ( x  e.  ~P NN0
 ,  y  e.  ~P NN0  |->  { k  e.  NN0  |  k  e.  (  seq 0 ( ( p  e.  ~P NN0 ,  m  e.  NN0  |->  ( p sadd  { n  e.  NN0  |  ( m  e.  x  /\  ( n  -  m )  e.  y ) } ) ) ,  ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) ) `  (
 k  +  1 ) ) } )
 
Theoremsmufval 14109* Define the addition of two bit sequences, using df-had 1435 and df-cad 1436 bit operations. (Contributed by Mario Carneiro, 9-Sep-2016.)
 |-  ( ph  ->  A  C_ 
 NN0 )   &    |-  ( ph  ->  B 
 C_  NN0 )   &    |-  P  =  seq 0 ( ( p  e.  ~P NN0 ,  m  e.  NN0  |->  ( p sadd  { n  e.  NN0  |  ( m  e.  A  /\  ( n  -  m )  e.  B ) } ) ) ,  ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) )   =>    |-  ( ph  ->  ( A smul  B )  =  {
 k  e.  NN0  |  k  e.  ( P `  ( k  +  1 ) ) } )
 
Theoremsmupf 14110* The sequence of partial sums of the sequence multiplication. (Contributed by Mario Carneiro, 9-Sep-2016.)
 |-  ( ph  ->  A  C_ 
 NN0 )   &    |-  ( ph  ->  B 
 C_  NN0 )   &    |-  P  =  seq 0 ( ( p  e.  ~P NN0 ,  m  e.  NN0  |->  ( p sadd  { n  e.  NN0  |  ( m  e.  A  /\  ( n  -  m )  e.  B ) } ) ) ,  ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) )   =>    |-  ( ph  ->  P : NN0 --> ~P NN0 )
 
Theoremsmup0 14111* The initial element of the partial sum sequence. (Contributed by Mario Carneiro, 9-Sep-2016.)
 |-  ( ph  ->  A  C_ 
 NN0 )   &    |-  ( ph  ->  B 
 C_  NN0 )   &    |-  P  =  seq 0 ( ( p  e.  ~P NN0 ,  m  e.  NN0  |->  ( p sadd  { n  e.  NN0  |  ( m  e.  A  /\  ( n  -  m )  e.  B ) } ) ) ,  ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) )   =>    |-  ( ph  ->  ( P `  0 )  =  (/) )
 
Theoremsmupp1 14112* The initial element of the partial sum sequence. (Contributed by Mario Carneiro, 9-Sep-2016.)
 |-  ( ph  ->  A  C_ 
 NN0 )   &    |-  ( ph  ->  B 
 C_  NN0 )   &    |-  P  =  seq 0 ( ( p  e.  ~P NN0 ,  m  e.  NN0  |->  ( p sadd  { n  e.  NN0  |  ( m  e.  A  /\  ( n  -  m )  e.  B ) } ) ) ,  ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) )   &    |-  ( ph  ->  N  e.  NN0 )   =>    |-  ( ph  ->  ( P `  ( N  +  1 ) )  =  ( ( P `  N ) sadd  { n  e. 
 NN0  |  ( N  e.  A  /\  ( n  -  N )  e.  B ) } )
 )
 
Theoremsmuval 14113* Define the addition of two bit sequences, using df-had 1435 and df-cad 1436 bit operations. (Contributed by Mario Carneiro, 9-Sep-2016.)
 |-  ( ph  ->  A  C_ 
 NN0 )   &    |-  ( ph  ->  B 
 C_  NN0 )   &    |-  P  =  seq 0 ( ( p  e.  ~P NN0 ,  m  e.  NN0  |->  ( p sadd  { n  e.  NN0  |  ( m  e.  A  /\  ( n  -  m )  e.  B ) } ) ) ,  ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) )   &    |-  ( ph  ->  N  e.  NN0 )   =>    |-  ( ph  ->  ( N  e.  ( A smul  B )  <->  N  e.  ( P `  ( N  +  1 ) ) ) )
 
Theoremsmuval2 14114* The partial sum sequence stabilizes at  N after the  N  +  1-th element of the sequence; this stable value is the value of the sequence multiplication. (Contributed by Mario Carneiro, 9-Sep-2016.)
 |-  ( ph  ->  A  C_ 
 NN0 )   &    |-  ( ph  ->  B 
 C_  NN0 )   &    |-  P  =  seq 0 ( ( p  e.  ~P NN0 ,  m  e.  NN0  |->  ( p sadd  { n  e.  NN0  |  ( m  e.  A  /\  ( n  -  m )  e.  B ) } ) ) ,  ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) )   &    |-  ( ph  ->  N  e.  NN0 )   &    |-  ( ph  ->  M  e.  ( ZZ>= `  ( N  +  1 )
 ) )   =>    |-  ( ph  ->  ( N  e.  ( A smul  B )  <->  N  e.  ( P `  M ) ) )
 
Theoremsmupvallem 14115* If  A only has elements less than  N, then all elements of the partial sum sequence past  N already equal the final value. (Contributed by Mario Carneiro, 20-Sep-2016.)
 |-  ( ph  ->  A  C_ 
 NN0 )   &    |-  ( ph  ->  B 
 C_  NN0 )   &    |-  P  =  seq 0 ( ( p  e.  ~P NN0 ,  m  e.  NN0  |->  ( p sadd  { n  e.  NN0  |  ( m  e.  A  /\  ( n  -  m )  e.  B ) } ) ) ,  ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) )   &    |-  ( ph  ->  N  e.  NN0 )   &    |-  ( ph  ->  A 
 C_  ( 0..^ N ) )   &    |-  ( ph  ->  M  e.  ( ZZ>= `  N ) )   =>    |-  ( ph  ->  ( P `  M )  =  ( A smul  B ) )
 
Theoremsmucl 14116 The product of two sequences is a sequence. (Contributed by Mario Carneiro, 19-Sep-2016.)
 |-  ( ( A  C_  NN0  /\  B  C_  NN0 )  ->  ( A smul  B )  C_  NN0 )
 
Theoremsmu01lem 14117* Lemma for smu01 14118 and smu02 14119. (Contributed by Mario Carneiro, 19-Sep-2016.)
 |-  ( ph  ->  A  C_ 
 NN0 )   &    |-  ( ph  ->  B 
 C_  NN0 )   &    |-  ( ( ph  /\  ( k  e.  NN0  /\  n  e.  NN0 )
 )  ->  -.  (
 k  e.  A  /\  ( n  -  k
 )  e.  B ) )   =>    |-  ( ph  ->  ( A smul  B )  =  (/) )
 
Theoremsmu01 14118 Multiplication of a sequence by  0 on the right. (Contributed by Mario Carneiro, 19-Sep-2016.)
 |-  ( A  C_  NN0  ->  ( A smul  (/) )  =  (/) )
 
Theoremsmu02 14119 Multiplication of a sequence by  0 on the left. (Contributed by Mario Carneiro, 9-Sep-2016.)
 |-  ( A  C_  NN0  ->  ( (/) smul  A )  =  (/) )
 
Theoremsmupval 14120* Rewrite the elements of the partial sum sequence in terms of sequence multiplication. (Contributed by Mario Carneiro, 20-Sep-2016.)
 |-  ( ph  ->  A  C_ 
 NN0 )   &    |-  ( ph  ->  B 
 C_  NN0 )   &    |-  P  =  seq 0 ( ( p  e.  ~P NN0 ,  m  e.  NN0  |->  ( p sadd  { n  e.  NN0  |  ( m  e.  A  /\  ( n  -  m )  e.  B ) } ) ) ,  ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) )   &    |-  ( ph  ->  N  e.  NN0 )   =>    |-  ( ph  ->  ( P `  N )  =  ( ( A  i^i  ( 0..^ N ) ) smul 
 B ) )
 
Theoremsmup1 14121* Rewrite smupp1 14112 using only smul instead of the internal recursive function  P. (Contributed by Mario Carneiro, 20-Sep-2016.)
 |-  ( ph  ->  A  C_ 
 NN0 )   &    |-  ( ph  ->  B 
 C_  NN0 )   &    |-  ( ph  ->  N  e.  NN0 )   =>    |-  ( ph  ->  (
 ( A  i^i  (
 0..^ ( N  +  1 ) ) ) smul 
 B )  =  ( ( ( A  i^i  ( 0..^ N ) ) smul 
 B ) sadd  { n  e.  NN0  |  ( N  e.  A  /\  ( n  -  N )  e.  B ) } )
 )
 
Theoremsmueqlem 14122* Any element of a sequence multiplication only depends on the values of the argument sequences up to and including that point. (Contributed by Mario Carneiro, 20-Sep-2016.)
 |-  ( ph  ->  A  C_ 
 NN0 )   &    |-  ( ph  ->  B 
 C_  NN0 )   &    |-  ( ph  ->  N  e.  NN0 )   &    |-  P  =  seq 0 ( ( p  e.  ~P NN0 ,  m  e.  NN0  |->  ( p sadd  { n  e.  NN0  |  ( m  e.  A  /\  ( n  -  m )  e.  B ) } ) ) ,  ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) )   &    |-  Q  =  seq 0 ( ( p  e.  ~P NN0 ,  m  e.  NN0  |->  ( p sadd  { n  e.  NN0  |  ( m  e.  A  /\  ( n  -  m )  e.  ( B  i^i  ( 0..^ N ) ) ) } )
 ) ,  ( n  e.  NN0  |->  if ( n  =  0 ,  (/)
 ,  ( n  -  1 ) ) ) )   =>    |-  ( ph  ->  (
 ( A smul  B )  i^i  ( 0..^ N ) )  =  ( ( ( A  i^i  (
 0..^ N ) ) smul 
 ( B  i^i  (
 0..^ N ) ) )  i^i  ( 0..^ N ) ) )
 
Theoremsmueq 14123 Any element of a sequence multiplication only depends on the values of the argument sequences up to and including that point. (Contributed by Mario Carneiro, 20-Sep-2016.)
 |-  ( ph  ->  A  C_ 
 NN0 )   &    |-  ( ph  ->  B 
 C_  NN0 )   &    |-  ( ph  ->  N  e.  NN0 )   =>    |-  ( ph  ->  (
 ( A smul  B )  i^i  ( 0..^ N ) )  =  ( ( ( A  i^i  (
 0..^ N ) ) smul 
 ( B  i^i  (
 0..^ N ) ) )  i^i  ( 0..^ N ) ) )
 
Theoremsmumullem 14124 Lemma for smumul 14125. (Contributed by Mario Carneiro, 22-Sep-2016.)
 |-  ( ph  ->  A  e.  ZZ )   &    |-  ( ph  ->  B  e.  ZZ )   &    |-  ( ph  ->  N  e.  NN0 )   =>    |-  ( ph  ->  (
 ( (bits `  A )  i^i  ( 0..^ N ) ) smul  (bits `  B ) )  =  (bits `  ( ( A  mod  ( 2 ^ N ) )  x.  B ) ) )
 
Theoremsmumul 14125 For sequences that correspond to valid integers, the sequence multiplication function produces the sequence for the product. This is effectively a proof of the correctness of the multiplication process, implemented in terms of logic gates for df-sad 14083, whose correctness is verified in sadadd 14099.

Outside this range, the sequences cannot be representing integers, but the smul function still "works". This extended function is best interpreted in terms of the ring structure of the 2-adic integers. (Contributed by Mario Carneiro, 22-Sep-2016.)

 |-  ( ( A  e.  ZZ  /\  B  e.  ZZ )  ->  ( (bits `  A ) smul  (bits `  B ) )  =  (bits `  ( A  x.  B ) ) )
 
6.1.6  The greatest common divisor operator
 
Syntaxcgcd 14126 Extend the definition of a class to include the greatest common divisor operator.
 class  gcd
 
Definitiondf-gcd 14127* Define the  gcd operator. (Contributed by Paul Chapman, 21-Mar-2011.)
 |- 
 gcd  =  ( x  e.  ZZ ,  y  e. 
 ZZ  |->  if ( ( x  =  0  /\  y  =  0 ) ,  0 ,  sup ( { n  e.  ZZ  |  ( n  ||  x  /\  n  ||  y ) } ,  RR ,  <  ) ) )
 
Theoremgcdval 14128* The value of the  gcd operator.  ( M  gcd  N ) is the greatest common divisor of  M and  N. If  M and  N are both  0, the result is defined conventionally as  0. (Contributed by Paul Chapman, 21-Mar-2011.) (Revised by Mario Carneiro, 10-Nov-2013.)
 |-  ( ( M  e.  ZZ  /\  N  e.  ZZ )  ->  ( M  gcd  N )  =  if (
 ( M  =  0 
 /\  N  =  0 ) ,  0 , 
 sup ( { n  e.  ZZ  |  ( n 
 ||  M  /\  n  ||  N ) } ,  RR ,  <  ) ) )
 
Theoremgcd0val 14129 The value, by convention, of the 
gcd operator when both operands are 0. (Contributed by Paul Chapman, 21-Mar-2011.)
 |-  ( 0  gcd  0
 )  =  0
 
Theoremgcdn0val 14130* The value of the  gcd operator when at least one operand is nonzero. (Contributed by Paul Chapman, 21-Mar-2011.)
 |-  ( ( ( M  e.  ZZ  /\  N  e.  ZZ )  /\  -.  ( M  =  0  /\  N  =  0 ) )  ->  ( M  gcd  N )  =  sup ( { n  e.  ZZ  |  ( n  ||  M  /\  n  ||  N ) } ,  RR ,  <  ) )
 
Theoremgcdcllem1 14131* Lemma for gcdn0cl 14134, gcddvds 14135 and dvdslegcd 14136. (Contributed by Paul Chapman, 21-Mar-2011.)
 |-  S  =  { z  e.  ZZ  |  A. n  e.  A  z  ||  n }   =>    |-  ( ( A  C_  ZZ  /\  E. n  e.  A  n  =/=  0
 )  ->  ( S  =/= 
 (/)  /\  E. x  e. 
 ZZ  A. y  e.  S  y  <_  x ) )
 
Theoremgcdcllem2 14132* Lemma for gcdn0cl 14134, gcddvds 14135 and dvdslegcd 14136. (Contributed by Paul Chapman, 21-Mar-2011.)
 |-  S  =  { z  e.  ZZ  |  A. n  e.  { M ,  N } z  ||  n }   &    |-  R  =  { z  e.  ZZ  |  ( z  ||  M  /\  z  ||  N ) }   =>    |-  ( ( M  e.  ZZ  /\  N  e.  ZZ )  ->  R  =  S )
 
Theoremgcdcllem3 14133* Lemma for gcdn0cl 14134, gcddvds 14135 and dvdslegcd 14136. (Contributed by Paul Chapman, 21-Mar-2011.)
 |-  S  =  { z  e.  ZZ  |  A. n  e.  { M ,  N } z  ||  n }   &    |-  R  =  { z  e.  ZZ  |  ( z  ||  M  /\  z  ||  N ) }   =>    |-  ( ( ( M  e.  ZZ  /\  N  e.  ZZ )  /\  -.  ( M  =  0  /\  N  =  0 ) )  ->  ( sup ( R ,  RR ,  <  )  e.  NN  /\  ( sup ( R ,  RR ,  <  )  ||  M  /\  sup ( R ,  RR ,  <  ) 
 ||  N )  /\  ( ( K  e.  ZZ  /\  K  ||  M  /\  K  ||  N )  ->  K  <_  sup ( R ,  RR ,  <  ) ) ) )
 
Theoremgcdn0cl 14134 Closure of the  gcd operator. (Contributed by Paul Chapman, 21-Mar-2011.)
 |-  ( ( ( M  e.  ZZ  /\  N  e.  ZZ )  /\  -.  ( M  =  0  /\  N  =  0 ) )  ->  ( M  gcd  N )  e.  NN )
 
Theoremgcddvds 14135 The gcd of two integers divides each of them. (Contributed by Paul Chapman, 21-Mar-2011.)
 |-  ( ( M  e.  ZZ  /\  N  e.  ZZ )  ->  ( ( M 
 gcd  N )  ||  M  /\  ( M  gcd  N )  ||  N ) )
 
Theoremdvdslegcd 14136 An integer which divides both operands of the  gcd operator is bounded by it. (Contributed by Paul Chapman, 21-Mar-2011.)
 |-  ( ( ( K  e.  ZZ  /\  M  e.  ZZ  /\  N  e.  ZZ )  /\  -.  ( M  =  0  /\  N  =  0 )
 )  ->  ( ( K  ||  M  /\  K  ||  N )  ->  K  <_  ( M  gcd  N ) ) )
 
Theoremgcdcl 14137 Closure of the  gcd operator. (Contributed by Paul Chapman, 21-Mar-2011.)
 |-  ( ( M  e.  ZZ  /\  N  e.  ZZ )  ->  ( M  gcd  N )  e.  NN0 )
 
Theoremgcdcld 14138 Closure of the  gcd operator. (Contributed by Mario Carneiro, 29-May-2016.)
 |-  ( ph  ->  M  e.  ZZ )   &    |-  ( ph  ->  N  e.  ZZ )   =>    |-  ( ph  ->  ( M  gcd  N )  e.  NN0 )
 
Theoremgcdf 14139 Domain and codomain of the  gcd operator. (Contributed by Paul Chapman, 31-Mar-2011.) (Revised by Mario Carneiro, 16-Nov-2013.)
 |- 
 gcd  : ( ZZ  X.  ZZ ) --> NN0
 
Theoremgcdcom 14140 The  gcd operator is commutative. (Contributed by Paul Chapman, 21-Mar-2011.)
 |-  ( ( M  e.  ZZ  /\  N  e.  ZZ )  ->  ( M  gcd  N )  =  ( N 
 gcd  M ) )
 
Theoremgcdeq0 14141 The gcd of two integers is zero iff they are both zero. (Contributed by Paul Chapman, 21-Mar-2011.)
 |-  ( ( M  e.  ZZ  /\  N  e.  ZZ )  ->  ( ( M 
 gcd  N )  =  0  <-> 
 ( M  =  0 
 /\  N  =  0 ) ) )
 
Theoremgcdn0gt0 14142 The gcd of two integers is positive (nonzero) iff they are not both zero. (Contributed by Paul Chapman, 22-Jun-2011.)
 |-  ( ( M  e.  ZZ  /\  N  e.  ZZ )  ->  ( -.  ( M  =  0  /\  N  =  0 )  <->  0  <  ( M  gcd  N ) ) )
 
Theoremgcd0id 14143 The gcd of 0 and an integer is the integer's absolute value. (Contributed by Paul Chapman, 21-Mar-2011.)
 |-  ( N  e.  ZZ  ->  ( 0  gcd  N )  =  ( abs `  N ) )
 
Theoremgcdid0 14144 The gcd of an integer and 0 is the integer's absolute value. (Contributed by Paul Chapman, 31-Mar-2011.)
 |-  ( N  e.  ZZ  ->  ( N  gcd  0
 )  =  ( abs `  N ) )
 
Theoremnn0gcdid0 14145 The gcd of a nonnegative integer with 0 is itself. (Contributed by Paul Chapman, 31-Mar-2011.)
 |-  ( N  e.  NN0  ->  ( N  gcd  0 )  =  N )
 
Theoremgcdneg 14146 Negating one operand of the  gcd operator does not alter the result. (Contributed by Paul Chapman, 21-Mar-2011.)
 |-  ( ( M  e.  ZZ  /\  N  e.  ZZ )  ->  ( M  gcd  -u N )  =  ( M  gcd  N ) )
 
Theoremneggcd 14147 Negating one operand of the  gcd operator does not alter the result. (Contributed by Paul Chapman, 22-Jun-2011.)
 |-  ( ( M  e.  ZZ  /\  N  e.  ZZ )  ->  ( -u M  gcd  N )  =  ( M  gcd  N ) )
 
Theoremgcdaddmlem 14148 Lemma for gcdaddm 14149. (Contributed by Paul Chapman, 31-Mar-2011.)
 |-  K  e.  ZZ   &    |-  M  e.  ZZ   &    |-  N  e.  ZZ   =>    |-  ( M  gcd  N )  =  ( M  gcd  (
 ( K  x.  M )  +  N )
 )
 
Theoremgcdaddm 14149 Adding a multiple of one operand of the  gcd operator to the other does not alter the result. (Contributed by Paul Chapman, 31-Mar-2011.)
 |-  ( ( K  e.  ZZ  /\  M  e.  ZZ  /\  N  e.  ZZ )  ->  ( M  gcd  N )  =  ( M  gcd  ( N  +  ( K  x.  M ) ) ) )
 
Theoremgcdadd 14150 The GCD of two numbers is the same as the GCD of the left and their sum. (Contributed by Scott Fenton, 20-Apr-2014.)
 |-  ( ( M  e.  ZZ  /\  N  e.  ZZ )  ->  ( M  gcd  N )  =  ( M 
 gcd  ( N  +  M ) ) )
 
Theoremgcdid 14151 The gcd of a number and itself is its absolute value. (Contributed by Paul Chapman, 31-Mar-2011.)
 |-  ( N  e.  ZZ  ->  ( N  gcd  N )  =  ( abs `  N ) )
 
Theoremgcd1 14152 The gcd of a number with 1 is 1. (Contributed by Mario Carneiro, 19-Feb-2014.)
 |-  ( M  e.  ZZ  ->  ( M  gcd  1
 )  =  1 )
 
Theoremgcdabs 14153 The gcd of two integers is the same as that of their absolute values. (Contributed by Paul Chapman, 31-Mar-2011.)
 |-  ( ( M  e.  ZZ  /\  N  e.  ZZ )  ->  ( ( abs `  M )  gcd  ( abs `  N ) )  =  ( M  gcd  N ) )
 
Theoremgcdabs1 14154  gcd of the absolute value of the first operator. (Contributed by Scott Fenton, 2-Apr-2014.) (Revised by Mario Carneiro, 19-Apr-2014.)
 |-  ( ( N  e.  ZZ  /\  M  e.  ZZ )  ->  ( ( abs `  N )  gcd  M )  =  ( N  gcd  M ) )
 
Theoremgcdabs2 14155  gcd of the absolute value of the second operator. (Contributed by Scott Fenton, 2-Apr-2014.) (Revised by Mario Carneiro, 19-Apr-2014.)
 |-  ( ( N  e.  ZZ  /\  M  e.  ZZ )  ->  ( N  gcd  ( abs `  M )
 )  =  ( N 
 gcd  M ) )
 
Theoremmodgcd 14156 The gcd remains unchanged if one operand is replaced with its remainder modulo the other. (Contributed by Paul Chapman, 31-Mar-2011.)
 |-  ( ( M  e.  ZZ  /\  N  e.  NN )  ->  ( ( M 
 mod  N )  gcd  N )  =  ( M  gcd  N ) )
 
Theorem1gcd 14157 The GCD of one and an integer is one. (Contributed by Scott Fenton, 17-Apr-2014.) (Revised by Mario Carneiro, 19-Apr-2014.)
 |-  ( M  e.  ZZ  ->  ( 1  gcd  M )  =  1 )
 
6.1.7  Bézout's identity
 
Theorembezoutlem1 14158* Lemma for bezout 14162. (Contributed by Mario Carneiro, 15-Mar-2014.)
 |-  M  =  { z  e.  NN  |  E. x  e.  ZZ  E. y  e. 
 ZZ  z  =  ( ( A  x.  x )  +  ( B  x.  y ) ) }   &    |-  ( ph  ->  A  e.  ZZ )   &    |-  ( ph  ->  B  e.  ZZ )   =>    |-  ( ph  ->  ( A  =/=  0  ->  ( abs `  A )  e.  M ) )
 
Theorembezoutlem2 14159* Lemma for bezout 14162. (Contributed by Mario Carneiro, 15-Mar-2014.)
 |-  M  =  { z  e.  NN  |  E. x  e.  ZZ  E. y  e. 
 ZZ  z  =  ( ( A  x.  x )  +  ( B  x.  y ) ) }   &    |-  ( ph  ->  A  e.  ZZ )   &    |-  ( ph  ->  B  e.  ZZ )   &    |-  G  =  sup ( M ,  RR ,  `'  <  )   &    |-  ( ph  ->  -.  ( A  =  0 
 /\  B  =  0 ) )   =>    |-  ( ph  ->  G  e.  M )
 
Theorembezoutlem3 14160* Lemma for bezout 14162. (Contributed by Mario Carneiro, 22-Feb-2014.)
 |-  M  =  { z  e.  NN  |  E. x  e.  ZZ  E. y  e. 
 ZZ  z  =  ( ( A  x.  x )  +  ( B  x.  y ) ) }   &    |-  ( ph  ->  A  e.  ZZ )   &    |-  ( ph  ->  B  e.  ZZ )   &    |-  G  =  sup ( M ,  RR ,  `'  <  )   &    |-  ( ph  ->  -.  ( A  =  0 
 /\  B  =  0 ) )   =>    |-  ( ph  ->  ( C  e.  M  ->  G 
 ||  C ) )
 
Theorembezoutlem4 14161* Lemma for bezout 14162. (Contributed by Mario Carneiro, 22-Feb-2014.)
 |-  M  =  { z  e.  NN  |  E. x  e.  ZZ  E. y  e. 
 ZZ  z  =  ( ( A  x.  x )  +  ( B  x.  y ) ) }   &    |-  ( ph  ->  A  e.  ZZ )   &    |-  ( ph  ->  B  e.  ZZ )   &    |-  G  =  sup ( M ,  RR ,  `'  <  )   &    |-  ( ph  ->  -.  ( A  =  0 
 /\  B  =  0 ) )   =>    |-  ( ph  ->  ( A  gcd  B )  e.  M )
 
Theorembezout 14162* Bézout's identity: For any integers  A and 
B, there are integers  x ,  y such that  ( A  gcd  B )  =  A  x.  x  +  B  x.  y. This is Metamath 100 proof #60. (Contributed by Mario Carneiro, 22-Feb-2014.)
 |-  ( ( A  e.  ZZ  /\  B  e.  ZZ )  ->  E. x  e.  ZZ  E. y  e.  ZZ  ( A  gcd  B )  =  ( ( A  x.  x )  +  ( B  x.  y ) ) )
 
Theoremdvdsgcd 14163 An integer which divides each of two others also divides their gcd. (Contributed by Paul Chapman, 22-Jun-2011.) (Revised by Mario Carneiro, 30-May-2014.)
 |-  ( ( K  e.  ZZ  /\  M  e.  ZZ  /\  N  e.  ZZ )  ->  ( ( K  ||  M  /\  K  ||  N )  ->  K  ||  ( M  gcd  N ) ) )
 
Theoremdvdsgcdb 14164 Biconditional form of dvdsgcd 14163. (Contributed by Scott Fenton, 2-Apr-2014.) (Revised by Mario Carneiro, 19-Apr-2014.)
 |-  ( ( K  e.  ZZ  /\  M  e.  ZZ  /\  N  e.  ZZ )  ->  ( ( K  ||  M  /\  K  ||  N ) 
 <->  K  ||  ( M  gcd  N ) ) )
 
Theoremgcdass 14165 Associative law for  gcd operator. (Contributed by Scott Fenton, 2-Apr-2014.) (Revised by Mario Carneiro, 19-Apr-2014.)
 |-  ( ( N  e.  ZZ  /\  M  e.  ZZ  /\  P  e.  ZZ )  ->  ( ( N  gcd  M )  gcd  P )  =  ( N  gcd  ( M  gcd  P ) ) )
 
Theoremmulgcd 14166 Distribute multiplication by a nonnegative integer over gcd. (Contributed by Paul Chapman, 22-Jun-2011.) (Proof shortened by Mario Carneiro, 30-May-2014.)
 |-  ( ( K  e.  NN0  /\  M  e.  ZZ  /\  N  e.  ZZ )  ->  ( ( K  x.  M )  gcd  ( K  x.  N ) )  =  ( K  x.  ( M  gcd  N ) ) )
 
Theoremabsmulgcd 14167 Distribute absolute value of multiplication over gcd. (Contributed by Paul Chapman, 22-Jun-2011.)
 |-  ( ( K  e.  ZZ  /\  M  e.  ZZ  /\  N  e.  ZZ )  ->  ( ( K  x.  M )  gcd  ( K  x.  N ) )  =  ( abs `  ( K  x.  ( M  gcd  N ) ) ) )
 
Theoremmulgcdr 14168 Reverse distribution law for the 
gcd operator. (Contributed by Scott Fenton, 2-Apr-2014.) (Revised by Mario Carneiro, 19-Apr-2014.)
 |-  ( ( A  e.  ZZ  /\  B  e.  ZZ  /\  C  e.  NN0 )  ->  ( ( A  x.  C )  gcd  ( B  x.  C ) )  =  ( ( A 
 gcd  B )  x.  C ) )
 
Theoremgcddiv 14169 Division law for GCD. (Contributed by Scott Fenton, 18-Apr-2014.) (Revised by Mario Carneiro, 19-Apr-2014.)
 |-  ( ( ( A  e.  ZZ  /\  B  e.  ZZ  /\  C  e.  NN )  /\  ( C 
 ||  A  /\  C  ||  B ) )  ->  ( ( A  gcd  B )  /  C )  =  ( ( A 
 /  C )  gcd  ( B  /  C ) ) )
 
Theoremgcdmultiple 14170 The GCD of a multiple of a number is the number itself. (Contributed by Scott Fenton, 12-Apr-2014.) (Revised by Mario Carneiro, 19-Apr-2014.)
 |-  ( ( M  e.  NN  /\  N  e.  NN )  ->  ( M  gcd  ( M  x.  N ) )  =  M )
 
Theoremgcdmultiplez 14171 Extend gcdmultiple 14170 so  N can be an integer. (Contributed by Scott Fenton, 18-Apr-2014.) (Revised by Mario Carneiro, 19-Apr-2014.)
 |-  ( ( M  e.  NN  /\  N  e.  ZZ )  ->  ( M  gcd  ( M  x.  N ) )  =  M )
 
Theoremgcdeq 14172  A is equal to its gcd with  B if and only if  A divides  B. (Contributed by Mario Carneiro, 23-Feb-2014.)
 |-  ( ( A  e.  NN  /\  B  e.  NN )  ->  ( ( A 
 gcd  B )  =  A  <->  A 
 ||  B ) )
 
Theoremdvdssqim 14173 Unidirectional form of dvdssq 14180. (Contributed by Scott Fenton, 19-Apr-2014.)
 |-  ( ( M  e.  ZZ  /\  N  e.  ZZ )  ->  ( M  ||  N  ->  ( M ^
 2 )  ||  ( N ^ 2 ) ) )
 
Theoremdvdsmulgcd 14174 A divisibility equivalent for odmulg 16557. (Contributed by Stefan O'Rear, 6-Sep-2015.)
 |-  ( ( B  e.  ZZ  /\  C  e.  ZZ )  ->  ( A  ||  ( B  x.  C ) 
 <->  A  ||  ( B  x.  ( C  gcd  A ) ) ) )
 
Theoremrpmulgcd 14175 If  K and  M are relatively prime, then the GCD of  K and  M  x.  N is the GCD of  K and  N. (Contributed by Scott Fenton, 12-Apr-2014.) (Revised by Mario Carneiro, 19-Apr-2014.)
 |-  ( ( ( K  e.  NN  /\  M  e.  NN  /\  N  e.  NN )  /\  ( K 
 gcd  M )  =  1 )  ->  ( K  gcd  ( M  x.  N ) )  =  ( K  gcd  N ) )
 
Theoremrplpwr 14176 If  A and  B are relatively prime, then so are  A ^ N and  B. (Contributed by Scott Fenton, 12-Apr-2014.) (Revised by Mario Carneiro, 19-Apr-2014.)
 |-  ( ( A  e.  NN  /\  B  e.  NN  /\  N  e.  NN )  ->  ( ( A  gcd  B )  =  1  ->  ( ( A ^ N )  gcd  B )  =  1 ) )
 
Theoremrppwr 14177 If  A and  B are relatively prime, then so are  A ^ N and  B ^ N. (Contributed by Scott Fenton, 12-Apr-2014.) (Revised by Mario Carneiro, 19-Apr-2014.)
 |-  ( ( A  e.  NN  /\  B  e.  NN  /\  N  e.  NN )  ->  ( ( A  gcd  B )  =  1  ->  ( ( A ^ N )  gcd  ( B ^ N ) )  =  1 ) )
 
Theoremsqgcd 14178 Square distributes over GCD. (Contributed by Scott Fenton, 18-Apr-2014.) (Revised by Mario Carneiro, 19-Apr-2014.)
 |-  ( ( M  e.  NN  /\  N  e.  NN )  ->  ( ( M 
 gcd  N ) ^ 2
 )  =  ( ( M ^ 2 ) 
 gcd  ( N ^
 2 ) ) )
 
Theoremdvdssqlem 14179 Lemma for dvdssq 14180. (Contributed by Scott Fenton, 18-Apr-2014.) (Revised by Mario Carneiro, 19-Apr-2014.)
 |-  ( ( M  e.  NN  /\  N  e.  NN )  ->  ( M  ||  N 
 <->  ( M ^ 2
 )  ||  ( N ^ 2 ) ) )
 
Theoremdvdssq 14180 Two numbers are divisible iff their squares are. (Contributed by Scott Fenton, 18-Apr-2014.) (Revised by Mario Carneiro, 19-Apr-2014.)
 |-  ( ( M  e.  ZZ  /\  N  e.  ZZ )  ->  ( M  ||  N 
 <->  ( M ^ 2
 )  ||  ( N ^ 2 ) ) )
 
6.1.8  Algorithms
 
Theoremnn0seqcvgd 14181* A strictly-decreasing nonnegative integer sequence with initial term  N reaches zero by the  N th term. Deduction version. (Contributed by Paul Chapman, 31-Mar-2011.)
 |-  ( ph  ->  F : NN0 --> NN0 )   &    |-  ( ph  ->  N  =  ( F `  0 ) )   &    |-  (
 ( ph  /\  k  e. 
 NN0 )  ->  (
 ( F `  (
 k  +  1 ) )  =/=  0  ->  ( F `  ( k  +  1 ) )  <  ( F `  k ) ) )   =>    |-  ( ph  ->  ( F `  N )  =  0 )
 
Theoremseq1st 14182 A sequence whose iteration function ignores the second argument is only affected by the first point of the initial value function. (Contributed by Mario Carneiro, 11-Feb-2015.)
 |-  Z  =  ( ZZ>= `  M )   &    |-  R  =  seq M ( ( F  o.  1st ) ,  ( Z  X.  { A }
 ) )   =>    |-  ( ( M  e.  ZZ  /\  A  e.  V )  ->  R  =  seq M ( ( F  o.  1st ) ,  { <. M ,  A >. } )
 )
 
Theoremalgr0 14183 The value of the algorithm iterator 
R at  0 is the initial state  A. (Contributed by Paul Chapman, 31-Mar-2011.) (Revised by Mario Carneiro, 28-May-2014.)
 |-  Z  =  ( ZZ>= `  M )   &    |-  R  =  seq M ( ( F  o.  1st ) ,  ( Z  X.  { A }
 ) )   &    |-  ( ph  ->  M  e.  ZZ )   &    |-  ( ph  ->  A  e.  S )   =>    |-  ( ph  ->  ( R `  M )  =  A )
 
Theoremalgrf 14184 An algorithm is step a function  F : S --> S on a state space  S. An algorithm acts on an initial state  A  e.  S by iteratively applying  F to give  A,  ( F `
 A ),  ( F `  ( F `
 A ) ) and so on. An algorithm is said to halt if a fixed point of  F is reached after a finite number of iterations.

The algorithm iterator  R : NN0 --> S "runs" the algorithm  F so that  ( R `  k ) is the state after  k iterations of  F on the initial state  A.

Domain and codomain of the algorithm iterator  R. (Contributed by Paul Chapman, 31-Mar-2011.) (Revised by Mario Carneiro, 28-May-2014.)

 |-  Z  =  ( ZZ>= `  M )   &    |-  R  =  seq M ( ( F  o.  1st ) ,  ( Z  X.  { A }
 ) )   &    |-  ( ph  ->  M  e.  ZZ )   &    |-  ( ph  ->  A  e.  S )   &    |-  ( ph  ->  F : S --> S )   =>    |-  ( ph  ->  R : Z --> S )
 
Theoremalgrp1 14185 The value of the algorithm iterator 
R at  ( K  + 
1 ). (Contributed by Paul Chapman, 31-Mar-2011.) (Revised by Mario Carneiro, 27-Dec-2014.)
 |-  Z  =  ( ZZ>= `  M )   &    |-  R  =  seq M ( ( F  o.  1st ) ,  ( Z  X.  { A }
 ) )   &    |-  ( ph  ->  M  e.  ZZ )   &    |-  ( ph  ->  A  e.  S )   &    |-  ( ph  ->  F : S --> S )   =>    |-  ( ( ph  /\  K  e.  Z ) 
 ->  ( R `  ( K  +  1 )
 )  =  ( F `
  ( R `  K ) ) )
 
Theoremalginv 14186* If  I is an invariant of  F, its value is unchanged after any number of iterations of  F. (Contributed by Paul Chapman, 31-Mar-2011.)
 |-  R  =  seq 0
 ( ( F  o.  1st ) ,  ( NN0  X. 
 { A } )
 )   &    |-  F : S --> S   &    |-  I  Fn  S   &    |-  ( x  e.  S  ->  ( I `  ( F `  x ) )  =  ( I `  x ) )   =>    |-  ( ( A  e.  S  /\  K  e.  NN0 )  ->  ( I `  ( R `  K ) )  =  ( I `
  ( R `  0 ) ) )
 
Theoremalgcvg 14187* One way to prove that an algorithm halts is to construct a countdown function  C : S --> NN0 whose value is guaranteed to decrease for each iteration of  F until it reaches  0. That is, if  X  e.  S is not a fixed point of  F, then  ( C `  ( F `  X ) )  <  ( C `
 X ).

If  C is a countdown function for algorithm  F, the sequence  ( C `  ( R `  k ) ) reaches  0 after at most  N steps, where  N is the value of  C for the initial state  A. (Contributed by Paul Chapman, 22-Jun-2011.)

 |-  F : S --> S   &    |-  R  =  seq 0 ( ( F  o.  1st ) ,  ( NN0  X.  { A } ) )   &    |-  C : S --> NN0   &    |-  ( z  e.  S  ->  ( ( C `  ( F `  z ) )  =/=  0  ->  ( C `  ( F `
  z ) )  <  ( C `  z ) ) )   &    |-  N  =  ( C `  A )   =>    |-  ( A  e.  S  ->  ( C `  ( R `  N ) )  =  0 )
 
Theoremalgcvgblem 14188 Lemma for algcvgb 14189. (Contributed by Paul Chapman, 31-Mar-2011.)
 |-  ( ( M  e.  NN0  /\  N  e.  NN0 )  ->  ( ( N  =/=  0  ->  N  <  M ) 
 <->  ( ( M  =/=  0  ->  N  <  M )  /\  ( M  =  0  ->  N  =  0 ) ) ) )
 
Theoremalgcvgb 14189 Two ways of expressing that  C is a countdown function for algorithm  F. The first is used in these theorems. The second states the condition more intuitively as a conjunction: if the countdown function's value is currently non-zero, it must decrease at the next step; if it has reached zero, it must remain zero at the next step. (Contributed by Paul Chapman, 31-Mar-2011.)
 |-  F : S --> S   &    |-  C : S --> NN0   =>    |-  ( X  e.  S  ->  ( ( ( C `
  ( F `  X ) )  =/=  0  ->  ( C `  ( F `  X ) )  <  ( C `
  X ) )  <-> 
 ( ( ( C `
  X )  =/=  0  ->  ( C `  ( F `  X ) )  <  ( C `
  X ) ) 
 /\  ( ( C `
  X )  =  0  ->  ( C `  ( F `  X ) )  =  0
 ) ) ) )
 
Theoremalgcvga 14190* The countdown function  C remains  0 after  N steps. (Contributed by Paul Chapman, 22-Jun-2011.)
 |-  F : S --> S   &    |-  R  =  seq 0 ( ( F  o.  1st ) ,  ( NN0  X.  { A } ) )   &    |-  C : S --> NN0   &    |-  ( z  e.  S  ->  ( ( C `  ( F `  z ) )  =/=  0  ->  ( C `  ( F `
  z ) )  <  ( C `  z ) ) )   &    |-  N  =  ( C `  A )   =>    |-  ( A  e.  S  ->  ( K  e.  ( ZZ>=
 `  N )  ->  ( C `  ( R `
  K ) )  =  0 ) )
 
Theoremalgfx 14191* If  F reaches a fixed point when the countdown function 
C reaches  0,  F remains fixed after  N steps. (Contributed by Paul Chapman, 22-Jun-2011.)
 |-  F : S --> S   &    |-  R  =  seq 0 ( ( F  o.  1st ) ,  ( NN0  X.  { A } ) )   &    |-  C : S --> NN0   &    |-  ( z  e.  S  ->  ( ( C `  ( F `  z ) )  =/=  0  ->  ( C `  ( F `
  z ) )  <  ( C `  z ) ) )   &    |-  N  =  ( C `  A )   &    |-  ( z  e.  S  ->  ( ( C `  z )  =  0  ->  ( F `  z )  =  z ) )   =>    |-  ( A  e.  S  ->  ( K  e.  ( ZZ>=
 `  N )  ->  ( R `  K )  =  ( R `  N ) ) )
 
6.1.9  Euclid's Algorithm
 
Theoremeucalgval2 14192* The value of the step function  E for Euclid's Algorithm on an ordered pair. (Contributed by Paul Chapman, 31-Mar-2011.) (Revised by Mario Carneiro, 28-May-2014.)
 |-  E  =  ( x  e.  NN0 ,  y  e. 
 NN0  |->  if ( y  =  0 ,  <. x ,  y >. ,  <. y ,  ( x  mod  y
 ) >. ) )   =>    |-  ( ( M  e.  NN0  /\  N  e.  NN0 )  ->  ( M E N )  =  if ( N  =  0 ,  <. M ,  N >. ,  <. N ,  ( M  mod  N ) >. ) )
 
Theoremeucalgval 14193* Euclid's Algorithm eucalg 14198 computes the greatest common divisor of two nonnegative integers by repeatedly replacing the larger of them with its remainder modulo the smaller until the remainder is 0.

The value of the step function  E for Euclid's Algorithm. (Contributed by Paul Chapman, 31-Mar-2011.) (Revised by Mario Carneiro, 28-May-2014.)

 |-  E  =  ( x  e.  NN0 ,  y  e. 
 NN0  |->  if ( y  =  0 ,  <. x ,  y >. ,  <. y ,  ( x  mod  y
 ) >. ) )   =>    |-  ( X  e.  ( NN0  X.  NN0 )  ->  ( E `  X )  =  if (
 ( 2nd `  X )  =  0 ,  X ,  <. ( 2nd `  X ) ,  (  mod  `  X ) >. ) )
 
Theoremeucalgf 14194* Domain and codomain of the step function  E for Euclid's Algorithm. (Contributed by Paul Chapman, 31-Mar-2011.) (Revised by Mario Carneiro, 28-May-2014.)
 |-  E  =  ( x  e.  NN0 ,  y  e. 
 NN0  |->  if ( y  =  0 ,  <. x ,  y >. ,  <. y ,  ( x  mod  y
 ) >. ) )   =>    |-  E : (
 NN0  X.  NN0 ) --> ( NN0  X. 
 NN0 )
 
Theoremeucalginv 14195* The invariant of the step function 
E for Euclid's Algorithm is the  gcd operator applied to the state. (Contributed by Paul Chapman, 31-Mar-2011.) (Revised by Mario Carneiro, 29-May-2014.)
 |-  E  =  ( x  e.  NN0 ,  y  e. 
 NN0  |->  if ( y  =  0 ,  <. x ,  y >. ,  <. y ,  ( x  mod  y
 ) >. ) )   =>    |-  ( X  e.  ( NN0  X.  NN0 )  ->  (  gcd  `  ( E `  X ) )  =  (  gcd  `  X ) )
 
Theoremeucalglt 14196* The second member of the state decreases with each iteration of the step function  E for Euclid's Algorithm. (Contributed by Paul Chapman, 31-Mar-2011.) (Revised by Mario Carneiro, 29-May-2014.)
 |-  E  =  ( x  e.  NN0 ,  y  e. 
 NN0  |->  if ( y  =  0 ,  <. x ,  y >. ,  <. y ,  ( x  mod  y
 ) >. ) )   =>    |-  ( X  e.  ( NN0  X.  NN0 )  ->  ( ( 2nd `  ( E `  X ) )  =/=  0  ->  ( 2nd `  ( E `  X ) )  < 
 ( 2nd `  X )
 ) )
 
Theoremeucalgcvga 14197* Once Euclid's Algorithm halts after 
N steps, the second element of the state remains 0 . (Contributed by Paul Chapman, 22-Jun-2011.) (Revised by Mario Carneiro, 29-May-2014.)
 |-  E  =  ( x  e.  NN0 ,  y  e. 
 NN0  |->  if ( y  =  0 ,  <. x ,  y >. ,  <. y ,  ( x  mod  y
 ) >. ) )   &    |-  R  =  seq 0 ( ( E  o.  1st ) ,  ( NN0  X.  { A } ) )   &    |-  N  =  ( 2nd `  A )   =>    |-  ( A  e.  ( NN0  X.  NN0 )  ->  ( K  e.  ( ZZ>= `  N )  ->  ( 2nd `  ( R `  K ) )  =  0
 ) )
 
Theoremeucalg 14198* Euclid's Algorithm computes the greatest common divisor of two nonnegative integers by repeatedly replacing the larger of them with its remainder modulo the smaller until the remainder is 0.

Upon halting, the 1st member of the final state  ( R `  N ) is equal to the gcd of the values comprising the input state  <. M ,  N >.. This is Metamath 100 proof #69 (greatest common divisor algorithm). (Contributed by Paul Chapman, 31-Mar-2011.) (Proof shortened by Mario Carneiro, 29-May-2014.)

 |-  E  =  ( x  e.  NN0 ,  y  e. 
 NN0  |->  if ( y  =  0 ,  <. x ,  y >. ,  <. y ,  ( x  mod  y
 ) >. ) )   &    |-  R  =  seq 0 ( ( E  o.  1st ) ,  ( NN0  X.  { A } ) )   &    |-  A  =  <. M ,  N >.   =>    |-  ( ( M  e.  NN0  /\  N  e.  NN0 )  ->  ( 1st `  ( R `  N ) )  =  ( M  gcd  N ) )
 
6.2  Elementary prime number theory
 
6.2.1  Elementary properties
 
Syntaxcprime 14199 Extend the definition of a class to include the set of prime numbers.
 class  Prime
 
Definitiondf-prm 14200* Define the set of prime numbers. (Contributed by Paul Chapman, 22-Jun-2011.)
 |- 
 Prime  =  { p  e.  NN  |  { n  e.  NN  |  n  ||  p }  ~~  2o }
    < Previous  Next >

Page List
Jump to page: Contents  1 1-100 2 101-200 3 201-300 4 301-400 5 401-500 6 501-600 7 601-700 8 701-800 9 801-900 10 901-1000 11 1001-1100 12 1101-1200 13 1201-1300 14 1301-1400 15 1401-1500 16 1501-1600 17 1601-1700 18 1701-1800 19 1801-1900 20 1901-2000 21 2001-2100 22 2101-2200 23 2201-2300 24 2301-2400 25 2401-2500 26 2501-2600 27 2601-2700 28 2701-2800 29 2801-2900 30 2901-3000 31 3001-3100 32 3101-3200 33 3201-3300 34 3301-3400 35 3401-3500 36 3501-3600 37 3601-3700 38 3701-3800 39 3801-3900 40 3901-4000 41 4001-4100 42 4101-4200 43 4201-4300 44 4301-4400 45 4401-4500 46 4501-4600 47 4601-4700 48 4701-4800 49 4801-4900 50 4901-5000 51 5001-5100 52 5101-5200 53 5201-5300 54 5301-5400 55 5401-5500 56 5501-5600 57 5601-5700 58 5701-5800 59 5801-5900 60 5901-6000 61 6001-6100 62 6101-6200 63 6201-6300 64 6301-6400 65 6401-6500 66 6501-6600 67 6601-6700 68 6701-6800 69 6801-6900 70 6901-7000 71 7001-7100 72 7101-7200 73 7201-7300 74 7301-7400 75 7401-7500 76 7501-7600 77 7601-7700 78 7701-7800 79 7801-7900 80 7901-8000 81 8001-8100 82 8101-8200 83 8201-8300 84 8301-8400 85 8401-8500 86 8501-8600 87 8601-8700 88 8701-8800 89 8801-8900 90 8901-9000 91 9001-9100 92 9101-9200 93 9201-9300 94 9301-9400 95 9401-9500 96 9501-9600 97 9601-9700 98 9701-9800 99 9801-9900 100 9901-10000 101 10001-10100 102 10101-10200 103 10201-10300 104 10301-10400 105 10401-10500 106 10501-10600 107 10601-10700 108 10701-10800 109 10801-10900 110 10901-11000 111 11001-11100 112 11101-11200 113 11201-11300 114 11301-11400 115 11401-11500 116 11501-11600 117 11601-11700 118 11701-11800 119 11801-11900 120 11901-12000 121 12001-12100 122 12101-12200 123 12201-12300 124 12301-12400 125 12401-12500 126 12501-12600 127 12601-12700 128 12701-12800 129 12801-12900 130 12901-13000 131 13001-13100 132 13101-13200 133 13201-13300 134 13301-13400 135 13401-13500 136 13501-13600 137 13601-13700 138 13701-13800 139 13801-13900 140 13901-14000 141 14001-14100 142 14101-14200 143 14201-14300 144 14301-14400 145 14401-14500 146 14501-14600 147 14601-14700 148 14701-14800 149 14801-14900 150 14901-15000 151 15001-15100 152 15101-15200 153 15201-15300 154 15301-15400 155 15401-15500 156 15501-15600 157 15601-15700 158 15701-15800 159 15801-15900 160 15901-16000 161 16001-16100 162 16101-16200 163 16201-16300 164 16301-16400 165 16401-16500 166 16501-16600 167 16601-16700 168 16701-16800 169 16801-16900 170 16901-17000 171 17001-17100 172 17101-17200 173 17201-17300 174 17301-17400 175 17401-17500 176 17501-17600 177 17601-17700 178 17701-17800 179 17801-17900 180 17901-18000 181 18001-18100 182 18101-18200 183 18201-18300 184 18301-18400 185 18401-18500 186 18501-18600 187 18601-18700 188 18701-18800 189 18801-18900 190 18901-19000 191 19001-19100 192 19101-19200 193 19201-19300 194 19301-19400 195 19401-19500 196 19501-19600 197 19601-19700 198 19701-19800 199 19801-19900 200 19901-20000 201 20001-20100 202 20101-20200 203 20201-20300 204 20301-20400 205 20401-20500 206 20501-20600 207 20601-20700 208 20701-20800 209 20801-20900 210 20901-21000 211 21001-21100 212 21101-21200 213 21201-21300 214 21301-21400 215 21401-21500 216 21501-21600 217 21601-21700 218 21701-21800 219 21801-21900 220 21901-22000 221 22001-22100 222 22101-22200 223 22201-22300 224 22301-22400 225 22401-22500 226 22501-22600 227 22601-22700 228 22701-22800 229 22801-22900 230 22901-23000 231 23001-23100 232 23101-23200 233 23201-23300 234 23301-23400 235 23401-23500 236 23501-23600 237 23601-23700 238 23701-23800 239 23801-23900 240 23901-24000 241 24001-24100 242 24101-24200 243 24201-24300 244 24301-24400 245 24401-24500 246 24501-24600 247 24601-24700 248 24701-24800 249 24801-24900 250 24901-25000 251 25001-25100 252 25101-25200 253 25201-25300 254 25301-25400 255 25401-25500 256 25501-25600 257 25601-25700 258 25701-25800 259 25801-25900 260 25901-26000 261 26001-26100 262 26101-26200 263 26201-26300 264 26301-26400 265 26401-26500 266 26501-26600 267 26601-26700 268 26701-26800 269 26801-26900 270 26901-27000 271 27001-27100 272 27101-27200 273 27201-27300 274 27301-27400 275 27401-27500 276 27501-27600 277 27601-27700 278 27701-27800 279 27801-27900 280 27901-28000 281 28001-28100 282 28101-28200 283 28201-28300 284 28301-28400 285 28401-28500 286 28501-28600 287 28601-28700 288 28701-28800 289 28801-28900 290 28901-29000 291 29001-29100 292 29101-29200 293 29201-29300 294 29301-29400 295 29401-29500 296 29501-29600 297 29601-29700 298 29701-29800 299 29801-29900 300 29901-30000 301 30001-30100 302 30101-30200 303 30201-30300 304 30301-30400 305 30401-30500 306 30501-30600 307 30601-30700 308 30701-30800 309 30801-30900 310 30901-31000 311 31001-31100 312 31101-31200 313 31201-31300 314 31301-31400 315 31401-31500 316 31501-31600 317 31601-31700 318 31701-31800 319 31801-31900 320 31901-32000 321 32001-32100 322 32101-32200 323 32201-32300 324 32301-32400 325 32401-32500 326 32501-32600 327 32601-32700 328 32701-32800 329 32801-32900 330 32901-33000 331 33001-33100 332 33101-33200 333 33201-33300 334 33301-33400 335 33401-33500 336 33501-33600 337 33601-33700 338 33701-33800 339 33801-33900 340 33901-34000 341 34001-34100 342 34101-34200 343 34201-34300 344 34301-34400 345 34401-34500 346 34501-34600 347 34601-34700 348 34701-34800 349 34801-34900 350 34901-35000 351 35001-35100 352 35101-35200 353 35201-35300 354 35301-35400 355 35401-35500 356 35501-35600 357 35601-35700 358 35701-35800 359 35801-35900 360 35901-36000 361 36001-36100 362 36101-36200 363 36201-36300 364 36301-36400 365 36401-36500 366 36501-36600 367 36601-36700 368 36701-36800 369 36801-36900 370 36901-37000 371 37001-37100 372 37101-37200 373 37201-37300 374 37301-37400 375 37401-37500 376 37501-37600 377 37601-37700 378 37701-37800 379 37801-37825
  Copyright terms: Public domain < Previous  Next >