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

Theorem eucalgval 16720
Description: Euclid's Algorithm eucalg 16725 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 7411 . . 3 ((1st ‘𝑋)𝐸(2nd ‘𝑋)) = (𝐸‘⟨(1st ‘𝑋), (2nd ‘𝑋)⟩)
2 xp1st 8016 . . . 4 (𝑋 ∈ (ℕ0 × ℕ0) → (1st ‘𝑋) ∈ ℕ0)
3 xp2nd 8017 . . . 4 (𝑋 ∈ (ℕ0 × ℕ0) → (2nd ‘𝑋) ∈ ℕ0)
4 eucalgval.1 . . . . 5 𝐸 = (𝑥 ∈ ℕ0, 𝑦 ∈ ℕ0 ↦ if(𝑦 = 0, ⟨𝑥, 𝑦⟩, ⟨𝑦, (𝑥 mod 𝑦)⟩))
54eucalgval2 16719 . . . 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 8023 . . 3 (𝑋 ∈ (ℕ0 × ℕ0) → 𝑋 = ⟨(1st ‘𝑋), (2nd ‘𝑋)⟩)
98fveq2d 6877 . 2 (𝑋 ∈ (ℕ0 × ℕ0) → (𝐸‘𝑋) = (𝐸‘⟨(1st ‘𝑋), (2nd ‘𝑋)⟩))
108fveq2d 6877 . . . . 5 (𝑋 ∈ (ℕ0 × ℕ0) → ( mod ‘𝑋) = ( mod ‘⟨(1st ‘𝑋), (2nd ‘𝑋)⟩))
11 df-ov 7411 . . . . 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 1570   ∈ wcel 2145  ifcif 4481  ⟨cop 4589   × cxp 5645  ‘cfv 6527  (class class class)co 7408   ∈ cmpo 7410  1st c1st 7982  2nd c2nd 7983  0cc0 11172  ℕ0cn0 12576   mod cmo 13978
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 1943  ax-6 2000  ax-7 2041  ax-8 2147  ax-9 2155  ax-10 2178  ax-11 2194  ax-12 2213  ax-ext 2732  ax-sep 5248  ax-nul 5259  ax-pr 5390  ax-un 7734
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 2100  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-dif 3901  df-un 3903  df-in 3905  df-ss 3915  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 5542  df-xp 5653  df-rel 5654  df-cnv 5655  df-co 5656  df-dm 5657  df-rn 5658  df-iota 6483  df-fun 6529  df-fv 6535  df-ov 7411  df-oprab 7412  df-mpo 7413  df-1st 7984  df-2nd 7985
This theorem is used by:  eucalginv  16722  eucalglt  16723
  Copyright terms: Public domain W3C validator