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

Theorem eucalgval 16758
Description: Euclid's Algorithm eucalg 16763 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 7423 . . 3 ((1st ‘𝑋)𝐸(2nd ‘𝑋)) = (𝐸‘⟨(1st ‘𝑋), (2nd ‘𝑋)⟩)
2 xp1st 8033 . . . 4 (𝑋 ∈ (ℕ0 × ℕ0) → (1st ‘𝑋) ∈ ℕ0)
3 xp2nd 8034 . . . 4 (𝑋 ∈ (ℕ0 × ℕ0) → (2nd ‘𝑋) ∈ ℕ0)
4 eucalgval.1 . . . . 5 𝐸 = (𝑥 ∈ ℕ0, 𝑦 ∈ ℕ0 ↦ if(𝑦 = 0, ⟨𝑥, 𝑦⟩, ⟨𝑦, (𝑥 mod 𝑦)⟩))
54eucalgval2 16757 . . . 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 2809 . 2 (𝑋 ∈ (ℕ0 × ℕ0) → (𝐸‘⟨(1st ‘𝑋), (2nd ‘𝑋)⟩) = if((2nd ‘𝑋) = 0, ⟨(1st ‘𝑋), (2nd ‘𝑋)⟩, ⟨(2nd ‘𝑋), ((1st ‘𝑋) mod (2nd ‘𝑋))⟩))
8 1st2nd2 8040 . . 3 (𝑋 ∈ (ℕ0 × ℕ0) → 𝑋 = ⟨(1st ‘𝑋), (2nd ‘𝑋)⟩)
98fveq2d 6889 . 2 (𝑋 ∈ (ℕ0 × ℕ0) → (𝐸‘𝑋) = (𝐸‘⟨(1st ‘𝑋), (2nd ‘𝑋)⟩))
108fveq2d 6889 . . . . 5 (𝑋 ∈ (ℕ0 × ℕ0) → ( mod ‘𝑋) = ( mod ‘⟨(1st ‘𝑋), (2nd ‘𝑋)⟩))
11 df-ov 7423 . . . . 5 ((1st ‘𝑋) mod (2nd ‘𝑋)) = ( mod ‘⟨(1st ‘𝑋), (2nd ‘𝑋)⟩)
1210, 11eqtr4di 2813 . . . 4 (𝑋 ∈ (ℕ0 × ℕ0) → ( mod ‘𝑋) = ((1st ‘𝑋) mod (2nd ‘𝑋)))
1312opeq2d 4839 . . 3 (𝑋 ∈ (ℕ0 × ℕ0) → ⟨(2nd ‘𝑋), ( mod ‘𝑋)⟩ = ⟨(2nd ‘𝑋), ((1st ‘𝑋) mod (2nd ‘𝑋))⟩)
148, 13ifeq12d 4503 . 2 (𝑋 ∈ (ℕ0 × ℕ0) → if((2nd ‘𝑋) = 0, 𝑋, ⟨(2nd ‘𝑋), ( mod ‘𝑋)⟩) = if((2nd ‘𝑋) = 0, ⟨(1st ‘𝑋), (2nd ‘𝑋)⟩, ⟨(2nd ‘𝑋), ((1st ‘𝑋) mod (2nd ‘𝑋))⟩))
157, 9, 143eqtr4d 2805 1 (𝑋 ∈ (ℕ0 × ℕ0) → (𝐸‘𝑋) = if((2nd ‘𝑋) = 0, 𝑋, ⟨(2nd ‘𝑋), ( mod ‘𝑋)⟩))
Colors of variables:    wff setvar class
This proof depends on syntax axioms:   → wi 4   = wceq 1569   ∈ wcel 2144  ifcif 4481  ⟨cop 4589   × cxp 5648  ‘cfv 6538  (class class class)co 7420   ∈ cmpo 7422  1st c1st 7999  2nd c2nd 8000  0cc0 11201  ℕ0cn0 12607   mod cmo 14010
This proof depends on axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1827  ax-4 1841  ax-5 1942  ax-6 1999  ax-7 2040  ax-8 2146  ax-9 2154  ax-10 2177  ax-11 2193  ax-12 2212  ax-ext 2732  ax-sep 5248  ax-nul 5259  ax-pr 5390  ax-un 7751
This proof depends on definitions:  df-bi 210  df-an 402  df-or 862  df-3an 1105  df-tru 1572  df-fal 1582  df-ex 1812  df-nf 1816  df-sb 2099  df-mo 2564  df-eu 2594  df-clab 2739  df-cleq 2752  df-clel 2835  df-nfc 2909  df-ne 2956  df-ral 3077  df-rex 3087  df-rab 3413  df-v 3452  df-sbc 3739  df-ss 3896  df-dif 4047  df-in 4091  df-un 4151  df-nul 4279  df-if 4482  df-sn 4584  df-pr 4586  df-op 4590  df-uni 4867  df-br 5103  df-opab 5167  df-mpt 5186  df-id 5545  df-xp 5656  df-rel 5657  df-cnv 5658  df-co 5659  df-dm 5660  df-rn 5661  df-iota 6494  df-fun 6540  df-fv 6546  df-ov 7423  df-oprab 7424  df-mpo 7425  df-1st 8001  df-2nd 8002
This theorem is used by:  eucalginv  16760  eucalglt  16761
  Copyright terms: Public domain W3C validator