Table of ContentsTable of Contents Mathbox for Paul Chapman < Previous   Next >
Related theorems
Unicode version

Theorem eucalgval 13749
Description: 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.

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

Hypothesis
Ref Expression
eucalgval.1 |- E = {<.x, y>. | (x e. (NN0 X. NN0) /\ y = if((2nd` x) = 0, x, <.(2nd` x), ( mod ` x)>.))}
Assertion
Ref Expression
eucalgval |- (X e. (NN0 X. NN0) -> (E` X) = if((2nd`
X) = 0, X, <.(2nd` X), ( mod ` X)>.))
Distinct variable group:   x,y

Proof of Theorem eucalgval
StepHypRef Expression
1 opex 3527 . . 3 |- <.(2nd` X), ( mod ` X)>. e. _V
2 ifexg 13599 . . 3 |- ((X e. (NN0 X. NN0) /\ <.(2nd` X), ( mod ` X)>. e. _V) -> if((2nd` X) = 0, X, <.(2nd` X), ( mod ` X)>.) e. _V)
31, 2mpan2 760 . 2 |- (X e. (NN0 X. NN0) -> if((2nd` X) = 0, X, <.(2nd` X), ( mod ` X)>.) e. _V)
4 fveq2 4681 . . . . 5 |- (m = X -> (2nd` m) = (2nd`
X))
54eqeq1d 1892 . . . 4 |- (m = X -> ((2nd` m) = 0 <-> (2nd` X) = 0))
6 id 73 . . . 4 |- (m = X -> m = X)
7 fveq2 4681 . . . . 5 |- (m = X -> ( mod ` m) = ( mod `
X))
84, 7opeq12d 3166 . . . 4 |- (m = X -> <.(2nd` m), ( mod ` m)>. = <.(2nd` X), ( mod ` X)>.)
95, 6, 8ifbieq12d 2998 . . 3 |- (m = X -> if((2nd`
m) = 0, m, <.(2nd` m), ( mod ` m)>.) = if((2nd`
X) = 0, X, <.(2nd` X), ( mod ` X)>.))
10 eucalgval.1 . . . 4 |- E = {<.x, y>. | (x e. (NN0 X. NN0) /\ y = if((2nd` x) = 0, x, <.(2nd` x), ( mod ` x)>.))}
11 eleq1 1957 . . . . . . 7 |- (x = m -> (x e. (NN0 X. NN0) <-> m e. (NN0 X. NN0)))
1211adantr 425 . . . . . 6 |- ((x = m /\ y = n) -> (x e. (NN0 X. NN0) <-> m e. (NN0 X. NN0)))
13 simpr 350 . . . . . . 7 |- ((x = m /\ y = n) -> y = n)
14 fveq2 4681 . . . . . . . . . 10 |- (x = m -> (2nd` x) = (2nd`
m))
1514eqeq1d 1892 . . . . . . . . 9 |- (x = m -> ((2nd` x) = 0 <-> (2nd` m) = 0))
16 id 73 . . . . . . . . 9 |- (x = m -> x = m)
17 fveq2 4681 . . . . . . . . . 10 |- (x = m -> ( mod ` x) = ( mod `
m))
1814, 17opeq12d 3166 . . . . . . . . 9 |- (x = m -> <.(2nd` x), ( mod ` x)>. = <.(2nd` m), ( mod ` m)>.)
1915, 16, 18ifbieq12d 2998 . . . . . . . 8 |- (x = m -> if((2nd`
x) = 0, x, <.(2nd` x), ( mod ` x)>.) = if((2nd`
m) = 0, m, <.(2nd` m), ( mod ` m)>.))
2019adantr 425 . . . . . . 7 |- ((x = m /\ y = n) -> if((2nd` x) = 0, x, <.(2nd` x), ( mod ` x)>.) = if((2nd` m) = 0, m, <.(2nd` m), ( mod ` m)>.))
2113, 20eqeq12d 1899 . . . . . 6 |- ((x = m /\ y = n) -> (y = if((2nd` x) = 0, x, <.(2nd`
x), ( mod ` x)>.) <-> n = if((2nd`
m) = 0, m, <.(2nd` m), ( mod ` m)>.)))
2212, 21anbi12d 690 . . . . 5 |- ((x = m /\ y = n) -> ((x e. (NN0 X. NN0) /\ y = if((2nd` x) = 0, x, <.(2nd` x), ( mod ` x)>.)) <-> (m e. (NN0 X. NN0) /\ n = if((2nd` m) = 0, m, <.(2nd` m), ( mod ` m)>.))))
2322cbvopabv 3404 . . . 4 |- {<.x, y>. | (x e. (NN0 X. NN0) /\ y = if((2nd`
x) = 0, x, <.(2nd` x), ( mod ` x)>.))} = {<.m, n>. | (m e. (NN0 X. NN0) /\ n = if((2nd`
m) = 0, m, <.(2nd` m), ( mod ` m)>.))}
2410, 23eqtri 1908 . . 3 |- E = {<.m, n>. | (m e. (NN0 X. NN0) /\ n = if((2nd` m) = 0, m, <.(2nd` m), ( mod ` m)>.))}
259, 24fvopab4g 4742 . 2 |- ((X e. (NN0 X. NN0) /\ if((2nd`
X) = 0, X, <.(2nd` X), ( mod ` X)>.) e. _V) -> (E` X) = if((2nd`
X) = 0, X, <.(2nd` X), ( mod ` X)>.))
263, 25mpdan 768 1 |- (X e. (NN0 X. NN0) -> (E` X) = if((2nd`
X) = 0, X, <.(2nd` X), ( mod ` X)>.))
Colors of variables: wff set class
Syntax hints:   -> wi 3   <-> wb 163   /\ wa 240   = wceq 1298   e. wcel 1300  _Vcvv 2292  ifcif 2982  <.cop 3046  {copab 3395   X. cxp 3984  ` cfv 3998  2ndc2nd 5019  0cc0 6386  NN0cn0 6450   mod cmo 7499
This theorem is referenced by:  eucalgval2 13750  mulgcdlem2 13757  mulgcdlem5 13760
This theorem was proved from axioms:  ax-1 4  ax-2 5  ax-3 6  ax-mp 7  ax-7 1304  ax-gen 1305  ax-8 1306  ax-9 1307  ax-10 1308  ax-11 1309  ax-12 1310  ax-14 1312  ax-17 1317  ax-4 1319  ax-5o 1321  ax-6o 1324  ax-9o 1481  ax-10o 1500  ax-16 1580  ax-11o 1588  ax-ext 1865  ax-sep 3438  ax-nul 3445  ax-pow 3481  ax-pr 3524
This theorem depends on definitions:  df-bi 164  df-or 241  df-an 242  df-ex 1327  df-sb 1536  df-eu 1775  df-mo 1776  df-clab 1872  df-cleq 1877  df-clel 1880  df-ne 2019  df-ral 2109  df-rex 2110  df-v 2294  df-dif 2597  df-un 2600  df-in 2603  df-ss 2605  df-nul 2876  df-if 2983  df-pw 3035  df-sn 3049  df-pr 3050  df-op 3053  df-uni 3178  df-br 3339  df-opab 3396  df-id 3586  df-xp 4000  df-rel 4001  df-cnv 4002  df-co 4003  df-dm 4004  df-rn 4005  df-res 4006  df-ima 4007  df-fun 4008  df-fv 4014
Copyright terms: Public domain