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

Theorem eucalgval 16786
Description: Euclid's Algorithm eucalg 16791 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 7446 . . 3 ((1st ‘𝑋)𝐸(2nd ‘𝑋)) = (𝐸‘⟨(1st ‘𝑋), (2nd ‘𝑋)⟩)
2 xp1st 8057 . . . 4 (𝑋 ∈ (ℕ0 × ℕ0) → (1st ‘𝑋) ∈ ℕ0)
3 xp2nd 8058 . . . 4 (𝑋 ∈ (ℕ0 × ℕ0) → (2nd ‘𝑋) ∈ ℕ0)
4 eucalgval.1 . . . . 5 𝐸 = (𝑥 ∈ ℕ0, 𝑦 ∈ ℕ0 ↦ if(𝑦 = 0, ⟨𝑥, 𝑦⟩, ⟨𝑦, (𝑥 mod 𝑦)⟩))
54eucalgval2 16785 . . . 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 2812 . 2 (𝑋 ∈ (ℕ0 × ℕ0) → (𝐸‘⟨(1st ‘𝑋), (2nd ‘𝑋)⟩) = if((2nd ‘𝑋) = 0, ⟨(1st ‘𝑋), (2nd ‘𝑋)⟩, ⟨(2nd ‘𝑋), ((1st ‘𝑋) mod (2nd ‘𝑋))⟩))
8 1st2nd2 8064 . . 3 (𝑋 ∈ (ℕ0 × ℕ0) → 𝑋 = ⟨(1st ‘𝑋), (2nd ‘𝑋)⟩)
98fveq2d 6912 . 2 (𝑋 ∈ (ℕ0 × ℕ0) → (𝐸‘𝑋) = (𝐸‘⟨(1st ‘𝑋), (2nd ‘𝑋)⟩))
108fveq2d 6912 . . . . 5 (𝑋 ∈ (ℕ0 × ℕ0) → ( mod ‘𝑋) = ( mod ‘⟨(1st ‘𝑋), (2nd ‘𝑋)⟩))
11 df-ov 7446 . . . . 5 ((1st ‘𝑋) mod (2nd ‘𝑋)) = ( mod ‘⟨(1st ‘𝑋), (2nd ‘𝑋)⟩)
1210, 11eqtr4di 2816 . . . 4 (𝑋 ∈ (ℕ0 × ℕ0) → ( mod ‘𝑋) = ((1st ‘𝑋) mod (2nd ‘𝑋)))
1312opeq2d 4850 . . 3 (𝑋 ∈ (ℕ0 × ℕ0) → ⟨(2nd ‘𝑋), ( mod ‘𝑋)⟩ = ⟨(2nd ‘𝑋), ((1st ‘𝑋) mod (2nd ‘𝑋))⟩)
148, 13ifeq12d 4507 . 2 (𝑋 ∈ (ℕ0 × ℕ0) → if((2nd ‘𝑋) = 0, 𝑋, ⟨(2nd ‘𝑋), ( mod ‘𝑋)⟩) = if((2nd ‘𝑋) = 0, ⟨(1st ‘𝑋), (2nd ‘𝑋)⟩, ⟨(2nd ‘𝑋), ((1st ‘𝑋) mod (2nd ‘𝑋))⟩))
157, 9, 143eqtr4d 2808 1 (𝑋 ∈ (ℕ0 × ℕ0) → (𝐸‘𝑋) = if((2nd ‘𝑋) = 0, 𝑋, ⟨(2nd ‘𝑋), ( mod ‘𝑋)⟩))
Colors of variables:    wff setvar class
This proof depends on syntax axioms:   → wi 4   = wceq 1570   ∈ wcel 2147  ifcif 4485  ⟨cop 4838   × cxp 5653  ‘cfv 6558  (class class class)co 7443   ∈ cmpo 7445  1st c1st 8023  2nd c2nd 8024  0cc0 11227  ℕ0cn0 12633   mod cmo 14036
This proof depends on axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1828  ax-4 1842  ax-5 1945  ax-6 2002  ax-7 2043  ax-8 2149  ax-9 2157  ax-10 2180  ax-11 2197  ax-12 2216  ax-ext 2735  ax-sep 5252  ax-nul 5263  ax-pr 5395  ax-un 7775
This proof depends on definitions:  df-bi 210  df-an 402  df-or 862  df-3an 1105  df-tru 1573  df-fal 1583  df-ex 1813  df-nf 1817  df-sb 2102  df-mo 2567  df-eu 2597  df-clab 2742  df-cleq 2755  df-clel 2839  df-nfc 2913  df-ne 2960  df-ral 3081  df-rex 3091  df-rab 3417  df-v 3456  df-sbc 3743  df-ss 3901  df-dif 4050  df-in 4094  df-un 4154  df-nul 4282  df-if 4486  df-sn 4589  df-pr 4591  df-op 4839  df-uni 4871  df-br 5107  df-opab 5171  df-mpt 5190  df-id 5550  df-xp 5661  df-rel 5662  df-cnv 5663  df-co 5664  df-dm 5665  df-rn 5666  df-iota 6512  df-fun 6560  df-fv 6566  df-ov 7446  df-oprab 7447  df-mpo 7448  df-1st 8025  df-2nd 8026
This theorem is used by:  eucalginv  16788  eucalglt  16789
  Copyright terms: Public domain W3C validator