 Intuitionistic Logic Explorer < Previous   Next > Nearby theorems Mirrors  >  Home  >  ILE Home  >  Th. List  >  eucalginv GIF version

Theorem eucalginv 11583
 Description: The invariant of the step function 𝐸 for Euclid's Algorithm is the gcd operator applied to the state. (Contributed by Paul Chapman, 31-Mar-2011.) (Revised by Mario Carneiro, 29-May-2014.)
Hypothesis
Ref Expression
eucalgval.1 𝐸 = (𝑥 ∈ ℕ0, 𝑦 ∈ ℕ0 ↦ if(𝑦 = 0, ⟨𝑥, 𝑦⟩, ⟨𝑦, (𝑥 mod 𝑦)⟩))
Assertion
Ref Expression
eucalginv (𝑋 ∈ (ℕ0 × ℕ0) → ( gcd ‘(𝐸𝑋)) = ( gcd ‘𝑋))
Distinct variable group:   𝑥,𝑦,𝑋
Allowed substitution hints:   𝐸(𝑥,𝑦)

Proof of Theorem eucalginv
StepHypRef Expression
1 eucalgval.1 . . . 4 𝐸 = (𝑥 ∈ ℕ0, 𝑦 ∈ ℕ0 ↦ if(𝑦 = 0, ⟨𝑥, 𝑦⟩, ⟨𝑦, (𝑥 mod 𝑦)⟩))
21eucalgval 11581 . . 3 (𝑋 ∈ (ℕ0 × ℕ0) → (𝐸𝑋) = if((2nd𝑋) = 0, 𝑋, ⟨(2nd𝑋), ( mod ‘𝑋)⟩))
32fveq2d 5379 . 2 (𝑋 ∈ (ℕ0 × ℕ0) → ( gcd ‘(𝐸𝑋)) = ( gcd ‘if((2nd𝑋) = 0, 𝑋, ⟨(2nd𝑋), ( mod ‘𝑋)⟩)))
4 1st2nd2 6027 . . . . . . . . 9 (𝑋 ∈ (ℕ0 × ℕ0) → 𝑋 = ⟨(1st𝑋), (2nd𝑋)⟩)
54adantr 272 . . . . . . . 8 ((𝑋 ∈ (ℕ0 × ℕ0) ∧ (2nd𝑋) ∈ ℕ) → 𝑋 = ⟨(1st𝑋), (2nd𝑋)⟩)
65fveq2d 5379 . . . . . . 7 ((𝑋 ∈ (ℕ0 × ℕ0) ∧ (2nd𝑋) ∈ ℕ) → ( mod ‘𝑋) = ( mod ‘⟨(1st𝑋), (2nd𝑋)⟩))
7 df-ov 5731 . . . . . . 7 ((1st𝑋) mod (2nd𝑋)) = ( mod ‘⟨(1st𝑋), (2nd𝑋)⟩)
86, 7syl6eqr 2165 . . . . . 6 ((𝑋 ∈ (ℕ0 × ℕ0) ∧ (2nd𝑋) ∈ ℕ) → ( mod ‘𝑋) = ((1st𝑋) mod (2nd𝑋)))
98oveq2d 5744 . . . . 5 ((𝑋 ∈ (ℕ0 × ℕ0) ∧ (2nd𝑋) ∈ ℕ) → ((2nd𝑋) gcd ( mod ‘𝑋)) = ((2nd𝑋) gcd ((1st𝑋) mod (2nd𝑋))))
10 nnz 8977 . . . . . . 7 ((2nd𝑋) ∈ ℕ → (2nd𝑋) ∈ ℤ)
1110adantl 273 . . . . . 6 ((𝑋 ∈ (ℕ0 × ℕ0) ∧ (2nd𝑋) ∈ ℕ) → (2nd𝑋) ∈ ℤ)
12 xp1st 6017 . . . . . . . . . 10 (𝑋 ∈ (ℕ0 × ℕ0) → (1st𝑋) ∈ ℕ0)
1312adantr 272 . . . . . . . . 9 ((𝑋 ∈ (ℕ0 × ℕ0) ∧ (2nd𝑋) ∈ ℕ) → (1st𝑋) ∈ ℕ0)
1413nn0zd 9075 . . . . . . . 8 ((𝑋 ∈ (ℕ0 × ℕ0) ∧ (2nd𝑋) ∈ ℕ) → (1st𝑋) ∈ ℤ)
15 zmodcl 10010 . . . . . . . 8 (((1st𝑋) ∈ ℤ ∧ (2nd𝑋) ∈ ℕ) → ((1st𝑋) mod (2nd𝑋)) ∈ ℕ0)
1614, 15sylancom 414 . . . . . . 7 ((𝑋 ∈ (ℕ0 × ℕ0) ∧ (2nd𝑋) ∈ ℕ) → ((1st𝑋) mod (2nd𝑋)) ∈ ℕ0)
1716nn0zd 9075 . . . . . 6 ((𝑋 ∈ (ℕ0 × ℕ0) ∧ (2nd𝑋) ∈ ℕ) → ((1st𝑋) mod (2nd𝑋)) ∈ ℤ)
18 gcdcom 11510 . . . . . 6 (((2nd𝑋) ∈ ℤ ∧ ((1st𝑋) mod (2nd𝑋)) ∈ ℤ) → ((2nd𝑋) gcd ((1st𝑋) mod (2nd𝑋))) = (((1st𝑋) mod (2nd𝑋)) gcd (2nd𝑋)))
1911, 17, 18syl2anc 406 . . . . 5 ((𝑋 ∈ (ℕ0 × ℕ0) ∧ (2nd𝑋) ∈ ℕ) → ((2nd𝑋) gcd ((1st𝑋) mod (2nd𝑋))) = (((1st𝑋) mod (2nd𝑋)) gcd (2nd𝑋)))
20 modgcd 11527 . . . . . 6 (((1st𝑋) ∈ ℤ ∧ (2nd𝑋) ∈ ℕ) → (((1st𝑋) mod (2nd𝑋)) gcd (2nd𝑋)) = ((1st𝑋) gcd (2nd𝑋)))
2114, 20sylancom 414 . . . . 5 ((𝑋 ∈ (ℕ0 × ℕ0) ∧ (2nd𝑋) ∈ ℕ) → (((1st𝑋) mod (2nd𝑋)) gcd (2nd𝑋)) = ((1st𝑋) gcd (2nd𝑋)))
229, 19, 213eqtrd 2151 . . . 4 ((𝑋 ∈ (ℕ0 × ℕ0) ∧ (2nd𝑋) ∈ ℕ) → ((2nd𝑋) gcd ( mod ‘𝑋)) = ((1st𝑋) gcd (2nd𝑋)))
23 nnne0 8658 . . . . . . . . 9 ((2nd𝑋) ∈ ℕ → (2nd𝑋) ≠ 0)
2423adantl 273 . . . . . . . 8 ((𝑋 ∈ (ℕ0 × ℕ0) ∧ (2nd𝑋) ∈ ℕ) → (2nd𝑋) ≠ 0)
2524neneqd 2303 . . . . . . 7 ((𝑋 ∈ (ℕ0 × ℕ0) ∧ (2nd𝑋) ∈ ℕ) → ¬ (2nd𝑋) = 0)
2625iffalsed 3450 . . . . . 6 ((𝑋 ∈ (ℕ0 × ℕ0) ∧ (2nd𝑋) ∈ ℕ) → if((2nd𝑋) = 0, 𝑋, ⟨(2nd𝑋), ( mod ‘𝑋)⟩) = ⟨(2nd𝑋), ( mod ‘𝑋)⟩)
2726fveq2d 5379 . . . . 5 ((𝑋 ∈ (ℕ0 × ℕ0) ∧ (2nd𝑋) ∈ ℕ) → ( gcd ‘if((2nd𝑋) = 0, 𝑋, ⟨(2nd𝑋), ( mod ‘𝑋)⟩)) = ( gcd ‘⟨(2nd𝑋), ( mod ‘𝑋)⟩))
28 df-ov 5731 . . . . 5 ((2nd𝑋) gcd ( mod ‘𝑋)) = ( gcd ‘⟨(2nd𝑋), ( mod ‘𝑋)⟩)
2927, 28syl6eqr 2165 . . . 4 ((𝑋 ∈ (ℕ0 × ℕ0) ∧ (2nd𝑋) ∈ ℕ) → ( gcd ‘if((2nd𝑋) = 0, 𝑋, ⟨(2nd𝑋), ( mod ‘𝑋)⟩)) = ((2nd𝑋) gcd ( mod ‘𝑋)))
305fveq2d 5379 . . . . 5 ((𝑋 ∈ (ℕ0 × ℕ0) ∧ (2nd𝑋) ∈ ℕ) → ( gcd ‘𝑋) = ( gcd ‘⟨(1st𝑋), (2nd𝑋)⟩))
31 df-ov 5731 . . . . 5 ((1st𝑋) gcd (2nd𝑋)) = ( gcd ‘⟨(1st𝑋), (2nd𝑋)⟩)
3230, 31syl6eqr 2165 . . . 4 ((𝑋 ∈ (ℕ0 × ℕ0) ∧ (2nd𝑋) ∈ ℕ) → ( gcd ‘𝑋) = ((1st𝑋) gcd (2nd𝑋)))
3322, 29, 323eqtr4d 2157 . . 3 ((𝑋 ∈ (ℕ0 × ℕ0) ∧ (2nd𝑋) ∈ ℕ) → ( gcd ‘if((2nd𝑋) = 0, 𝑋, ⟨(2nd𝑋), ( mod ‘𝑋)⟩)) = ( gcd ‘𝑋))
34 iftrue 3445 . . . . 5 ((2nd𝑋) = 0 → if((2nd𝑋) = 0, 𝑋, ⟨(2nd𝑋), ( mod ‘𝑋)⟩) = 𝑋)
3534fveq2d 5379 . . . 4 ((2nd𝑋) = 0 → ( gcd ‘if((2nd𝑋) = 0, 𝑋, ⟨(2nd𝑋), ( mod ‘𝑋)⟩)) = ( gcd ‘𝑋))
3635adantl 273 . . 3 ((𝑋 ∈ (ℕ0 × ℕ0) ∧ (2nd𝑋) = 0) → ( gcd ‘if((2nd𝑋) = 0, 𝑋, ⟨(2nd𝑋), ( mod ‘𝑋)⟩)) = ( gcd ‘𝑋))
37 xp2nd 6018 . . . 4 (𝑋 ∈ (ℕ0 × ℕ0) → (2nd𝑋) ∈ ℕ0)
38 elnn0 8883 . . . 4 ((2nd𝑋) ∈ ℕ0 ↔ ((2nd𝑋) ∈ ℕ ∨ (2nd𝑋) = 0))
3937, 38sylib 121 . . 3 (𝑋 ∈ (ℕ0 × ℕ0) → ((2nd𝑋) ∈ ℕ ∨ (2nd𝑋) = 0))
4033, 36, 39mpjaodan 770 . 2 (𝑋 ∈ (ℕ0 × ℕ0) → ( gcd ‘if((2nd𝑋) = 0, 𝑋, ⟨(2nd𝑋), ( mod ‘𝑋)⟩)) = ( gcd ‘𝑋))
413, 40eqtrd 2147 1 (𝑋 ∈ (ℕ0 × ℕ0) → ( gcd ‘(𝐸𝑋)) = ( gcd ‘𝑋))
 Colors of variables: wff set class Syntax hints:   → wi 4   ∧ wa 103   ∨ wo 680   = wceq 1314   ∈ wcel 1463   ≠ wne 2282  ifcif 3440  ⟨cop 3496   × cxp 4497  ‘cfv 5081  (class class class)co 5728   ∈ cmpo 5730  1st c1st 5990  2nd c2nd 5991  0cc0 7547  ℕcn 8630  ℕ0cn0 8881  ℤcz 8958   mod cmo 9988   gcd cgcd 11483 This theorem was proved from axioms:  ax-1 5  ax-2 6  ax-mp 7  ax-ia1 105  ax-ia2 106  ax-ia3 107  ax-in1 586  ax-in2 587  ax-io 681  ax-5 1406  ax-7 1407  ax-gen 1408  ax-ie1 1452  ax-ie2 1453  ax-8 1465  ax-10 1466  ax-11 1467  ax-i12 1468  ax-bndl 1469  ax-4 1470  ax-13 1474  ax-14 1475  ax-17 1489  ax-i9 1493  ax-ial 1497  ax-i5r 1498  ax-ext 2097  ax-coll 4003  ax-sep 4006  ax-nul 4014  ax-pow 4058  ax-pr 4091  ax-un 4315  ax-setind 4412  ax-iinf 4462  ax-cnex 7636  ax-resscn 7637  ax-1cn 7638  ax-1re 7639  ax-icn 7640  ax-addcl 7641  ax-addrcl 7642  ax-mulcl 7643  ax-mulrcl 7644  ax-addcom 7645  ax-mulcom 7646  ax-addass 7647  ax-mulass 7648  ax-distr 7649  ax-i2m1 7650  ax-0lt1 7651  ax-1rid 7652  ax-0id 7653  ax-rnegex 7654  ax-precex 7655  ax-cnre 7656  ax-pre-ltirr 7657  ax-pre-ltwlin 7658  ax-pre-lttrn 7659  ax-pre-apti 7660  ax-pre-ltadd 7661  ax-pre-mulgt0 7662  ax-pre-mulext 7663  ax-arch 7664  ax-caucvg 7665 This theorem depends on definitions:  df-bi 116  df-stab 799  df-dc 803  df-3or 946  df-3an 947  df-tru 1317  df-fal 1320  df-nf 1420  df-sb 1719  df-eu 1978  df-mo 1979  df-clab 2102  df-cleq 2108  df-clel 2111  df-nfc 2244  df-ne 2283  df-nel 2378  df-ral 2395  df-rex 2396  df-reu 2397  df-rmo 2398  df-rab 2399  df-v 2659  df-sbc 2879  df-csb 2972  df-dif 3039  df-un 3041  df-in 3043  df-ss 3050  df-nul 3330  df-if 3441  df-pw 3478  df-sn 3499  df-pr 3500  df-op 3502  df-uni 3703  df-int 3738  df-iun 3781  df-br 3896  df-opab 3950  df-mpt 3951  df-tr 3987  df-id 4175  df-po 4178  df-iso 4179  df-iord 4248  df-on 4250  df-ilim 4251  df-suc 4253  df-iom 4465  df-xp 4505  df-rel 4506  df-cnv 4507  df-co 4508  df-dm 4509  df-rn 4510  df-res 4511  df-ima 4512  df-iota 5046  df-fun 5083  df-fn 5084  df-f 5085  df-f1 5086  df-fo 5087  df-f1o 5088  df-fv 5089  df-riota 5684  df-ov 5731  df-oprab 5732  df-mpo 5733  df-1st 5992  df-2nd 5993  df-recs 6156  df-frec 6242  df-sup 6823  df-pnf 7726  df-mnf 7727  df-xr 7728  df-ltxr 7729  df-le 7730  df-sub 7858  df-neg 7859  df-reap 8255  df-ap 8262  df-div 8346  df-inn 8631  df-2 8689  df-3 8690  df-4 8691  df-n0 8882  df-z 8959  df-uz 9229  df-q 9314  df-rp 9344  df-fz 9684  df-fzo 9813  df-fl 9936  df-mod 9989  df-seqfrec 10112  df-exp 10186  df-cj 10507  df-re 10508  df-im 10509  df-rsqrt 10662  df-abs 10663  df-dvds 11342  df-gcd 11484 This theorem is referenced by:  eucalg  11586
 Copyright terms: Public domain W3C validator