MPE Home Metamath Proof Explorer < Previous   Next >
Nearby theorems
Mirrors  >  Home  >  MPE Home  >  Th. List  >  eucalgval Structured version   Visualization version   GIF version

Theorem eucalgval 16805
Description: Euclid's Algorithm eucalg 16810 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 𝐸 for Euclid's Algorithm. (Contributed by Paul Chapman, 31-Mar-2011.) (Revised by Mario Carneiro, 28-May-2014.)

Hypothesis
Ref Expression
eucalgval.1 𝐸 = (𝑥 ∈ ℕ0, 𝑦 ∈ ℕ0 ↦ if(𝑦 = 0, ⟨𝑥, 𝑦⟩, ⟨𝑦, (𝑥 mod 𝑦)⟩))
Assertion
Ref Expression
eucalgval (𝑋 ∈ (ℕ0 × ℕ0) → (𝐸‘𝑋) = if((2nd ‘𝑋) = 0, 𝑋, ⟨(2nd ‘𝑋), ( mod ‘𝑋)⟩))
Distinct variable group:   𝑥,𝑦,𝑋
Allowed substitution hints:   𝐸(𝑥, 𝑦)

Proof of Theorem eucalgval
StepHypRef Expression
1 df-ov 7458 . . 3 ((1st ‘𝑋)𝐸(2nd ‘𝑋)) = (𝐸‘⟨(1st ‘𝑋), (2nd ‘𝑋)⟩)
2 xp1st 8071 . . . 4 (𝑋 ∈ (ℕ0 × ℕ0) → (1st ‘𝑋) ∈ ℕ0)
3 xp2nd 8072 . . . 4 (𝑋 ∈ (ℕ0 × ℕ0) → (2nd ‘𝑋) ∈ ℕ0)
4 eucalgval.1 . . . . 5 𝐸 = (𝑥 ∈ ℕ0, 𝑦 ∈ ℕ0 ↦ if(𝑦 = 0, ⟨𝑥, 𝑦⟩, ⟨𝑦, (𝑥 mod 𝑦)⟩))
54eucalgval2 16804 . . . 4 (((1st ‘𝑋) ∈ ℕ0 ∧ (2nd ‘𝑋) ∈ ℕ0) → ((1st ‘𝑋)𝐸(2nd ‘𝑋)) = if((2nd ‘𝑋) = 0, ⟨(1st ‘𝑋), (2nd ‘𝑋)⟩, ⟨(2nd ‘𝑋), ((1st ‘𝑋) mod (2nd ‘𝑋))⟩))
62, 3, 5syl2anc 596 . . 3 (𝑋 ∈ (ℕ0 × ℕ0) → ((1st ‘𝑋)𝐸(2nd ‘𝑋)) = if((2nd ‘𝑋) = 0, ⟨(1st ‘𝑋), (2nd ‘𝑋)⟩, ⟨(2nd ‘𝑋), ((1st ‘𝑋) mod (2nd ‘𝑋))⟩))
71, 6eqtr3id 2818 . 2 (𝑋 ∈ (ℕ0 × ℕ0) → (𝐸‘⟨(1st ‘𝑋), (2nd ‘𝑋)⟩) = if((2nd ‘𝑋) = 0, ⟨(1st ‘𝑋), (2nd ‘𝑋)⟩, ⟨(2nd ‘𝑋), ((1st ‘𝑋) mod (2nd ‘𝑋))⟩))
8 1st2nd2 8078 . . 3 (𝑋 ∈ (ℕ0 × ℕ0) → 𝑋 = ⟨(1st ‘𝑋), (2nd ‘𝑋)⟩)
98fveq2d 6924 . 2 (𝑋 ∈ (ℕ0 × ℕ0) → (𝐸‘𝑋) = (𝐸‘⟨(1st ‘𝑋), (2nd ‘𝑋)⟩))
108fveq2d 6924 . . . . 5 (𝑋 ∈ (ℕ0 × ℕ0) → ( mod ‘𝑋) = ( mod ‘⟨(1st ‘𝑋), (2nd ‘𝑋)⟩))
11 df-ov 7458 . . . . 5 ((1st ‘𝑋) mod (2nd ‘𝑋)) = ( mod ‘⟨(1st ‘𝑋), (2nd ‘𝑋)⟩)
1210, 11eqtr4di 2822 . . . 4 (𝑋 ∈ (ℕ0 × ℕ0) → ( mod ‘𝑋) = ((1st ‘𝑋) mod (2nd ‘𝑋)))
1312opeq2d 4855 . . 3 (𝑋 ∈ (ℕ0 × ℕ0) → ⟨(2nd ‘𝑋), ( mod ‘𝑋)⟩ = ⟨(2nd ‘𝑋), ((1st ‘𝑋) mod (2nd ‘𝑋))⟩)
148, 13ifeq12d 4509 . 2 (𝑋 ∈ (ℕ0 × ℕ0) → if((2nd ‘𝑋) = 0, 𝑋, ⟨(2nd ‘𝑋), ( mod ‘𝑋)⟩) = if((2nd ‘𝑋) = 0, ⟨(1st ‘𝑋), (2nd ‘𝑋)⟩, ⟨(2nd ‘𝑋), ((1st ‘𝑋) mod (2nd ‘𝑋))⟩))
157, 9, 143eqtr4d 2814 1 (𝑋 ∈ (ℕ0 × ℕ0) → (𝐸‘𝑋) = if((2nd ‘𝑋) = 0, 𝑋, ⟨(2nd ‘𝑋), ( mod ‘𝑋)⟩))
Colors of variables:    wff setvar class
This proof depends on syntax axioms:   → wi 4   = wceq 1572   ∈ wcel 2151  ifcif 4487  ⟨cop 4843   × cxp 5659  ‘cfv 6570  (class class class)co 7455   ∈ cmpo 7457  1st c1st 8037  2nd c2nd 8038  0cc0 11243  ℕ0cn0 12650   mod cmo 14053
This proof depends on axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1830  ax-4 1844  ax-5 1947  ax-6 2004  ax-7 2045  ax-8 2153  ax-9 2161  ax-10 2184  ax-11 2201  ax-12 2220  ax-ext 2741  ax-sep 5258  ax-nul 5269  ax-pr 5401  ax-un 7787
This proof depends on definitions:  df-bi 210  df-an 402  df-or 862  df-3an 1106  df-tru 1575  df-fal 1585  df-ex 1815  df-nf 1819  df-sb 2105  df-mo 2571  df-eu 2601  df-clab 2748  df-cleq 2761  df-clel 2845  df-nfc 2919  df-ne 2966  df-ral 3087  df-rex 3097  df-rab 3419  df-v 3458  df-sbc 3745  df-ss 3903  df-dif 4052  df-in 4096  df-un 4156  df-nul 4284  df-if 4488  df-sn 4591  df-pr 4593  df-op 4844  df-uni 4876  df-br 5112  df-opab 5177  df-mpt 5196  df-id 5556  df-xp 5667  df-rel 5668  df-cnv 5669  df-co 5670  df-dm 5671  df-rn 5672  df-iota 6524  df-fun 6572  df-fv 6578  df-ov 7458  df-oprab 7459  df-mpo 7460  df-1st 8039  df-2nd 8040
This theorem is used by:  eucalginv  16807  eucalglt  16808
  Copyright terms: Public domain W3C validator