Metamath Proof Explorer |
< Previous
Next >
Nearby theorems |
||
Mirrors > Home > MPE Home > Th. List > eucalgval | Structured version Visualization version GIF version |
Description: Euclid's Algorithm eucalg 16273 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.) |
Ref | Expression |
---|---|
eucalgval.1 | ⊢ 𝐸 = (𝑥 ∈ ℕ0, 𝑦 ∈ ℕ0 ↦ if(𝑦 = 0, 〈𝑥, 𝑦〉, 〈𝑦, (𝑥 mod 𝑦)〉)) |
Ref | Expression |
---|---|
eucalgval | ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → (𝐸‘𝑋) = if((2nd ‘𝑋) = 0, 𝑋, 〈(2nd ‘𝑋), ( mod ‘𝑋)〉)) |
Step | Hyp | Ref | Expression |
---|---|---|---|
1 | df-ov 7271 | . . 3 ⊢ ((1st ‘𝑋)𝐸(2nd ‘𝑋)) = (𝐸‘〈(1st ‘𝑋), (2nd ‘𝑋)〉) | |
2 | xp1st 7849 | . . . 4 ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → (1st ‘𝑋) ∈ ℕ0) | |
3 | xp2nd 7850 | . . . 4 ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → (2nd ‘𝑋) ∈ ℕ0) | |
4 | eucalgval.1 | . . . . 5 ⊢ 𝐸 = (𝑥 ∈ ℕ0, 𝑦 ∈ ℕ0 ↦ if(𝑦 = 0, 〈𝑥, 𝑦〉, 〈𝑦, (𝑥 mod 𝑦)〉)) | |
5 | 4 | eucalgval2 16267 | . . . 4 ⊢ (((1st ‘𝑋) ∈ ℕ0 ∧ (2nd ‘𝑋) ∈ ℕ0) → ((1st ‘𝑋)𝐸(2nd ‘𝑋)) = if((2nd ‘𝑋) = 0, 〈(1st ‘𝑋), (2nd ‘𝑋)〉, 〈(2nd ‘𝑋), ((1st ‘𝑋) mod (2nd ‘𝑋))〉)) |
6 | 2, 3, 5 | syl2anc 583 | . . 3 ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → ((1st ‘𝑋)𝐸(2nd ‘𝑋)) = if((2nd ‘𝑋) = 0, 〈(1st ‘𝑋), (2nd ‘𝑋)〉, 〈(2nd ‘𝑋), ((1st ‘𝑋) mod (2nd ‘𝑋))〉)) |
7 | 1, 6 | eqtr3id 2793 | . 2 ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → (𝐸‘〈(1st ‘𝑋), (2nd ‘𝑋)〉) = if((2nd ‘𝑋) = 0, 〈(1st ‘𝑋), (2nd ‘𝑋)〉, 〈(2nd ‘𝑋), ((1st ‘𝑋) mod (2nd ‘𝑋))〉)) |
8 | 1st2nd2 7856 | . . 3 ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → 𝑋 = 〈(1st ‘𝑋), (2nd ‘𝑋)〉) | |
9 | 8 | fveq2d 6772 | . 2 ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → (𝐸‘𝑋) = (𝐸‘〈(1st ‘𝑋), (2nd ‘𝑋)〉)) |
10 | 8 | fveq2d 6772 | . . . . 5 ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → ( mod ‘𝑋) = ( mod ‘〈(1st ‘𝑋), (2nd ‘𝑋)〉)) |
11 | df-ov 7271 | . . . . 5 ⊢ ((1st ‘𝑋) mod (2nd ‘𝑋)) = ( mod ‘〈(1st ‘𝑋), (2nd ‘𝑋)〉) | |
12 | 10, 11 | eqtr4di 2797 | . . . 4 ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → ( mod ‘𝑋) = ((1st ‘𝑋) mod (2nd ‘𝑋))) |
13 | 12 | opeq2d 4816 | . . 3 ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → 〈(2nd ‘𝑋), ( mod ‘𝑋)〉 = 〈(2nd ‘𝑋), ((1st ‘𝑋) mod (2nd ‘𝑋))〉) |
14 | 8, 13 | ifeq12d 4485 | . 2 ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → if((2nd ‘𝑋) = 0, 𝑋, 〈(2nd ‘𝑋), ( mod ‘𝑋)〉) = if((2nd ‘𝑋) = 0, 〈(1st ‘𝑋), (2nd ‘𝑋)〉, 〈(2nd ‘𝑋), ((1st ‘𝑋) mod (2nd ‘𝑋))〉)) |
15 | 7, 9, 14 | 3eqtr4d 2789 | 1 ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → (𝐸‘𝑋) = if((2nd ‘𝑋) = 0, 𝑋, 〈(2nd ‘𝑋), ( mod ‘𝑋)〉)) |
Colors of variables: wff setvar class |
Syntax hints: → wi 4 = wceq 1541 ∈ wcel 2109 ifcif 4464 〈cop 4572 × cxp 5586 ‘cfv 6430 (class class class)co 7268 ∈ cmpo 7270 1st c1st 7815 2nd c2nd 7816 0cc0 10855 ℕ0cn0 12216 mod cmo 13570 |
This theorem was proved from axioms: ax-mp 5 ax-1 6 ax-2 7 ax-3 8 ax-gen 1801 ax-4 1815 ax-5 1916 ax-6 1974 ax-7 2014 ax-8 2111 ax-9 2119 ax-10 2140 ax-11 2157 ax-12 2174 ax-ext 2710 ax-sep 5226 ax-nul 5233 ax-pr 5355 ax-un 7579 |
This theorem depends on definitions: df-bi 206 df-an 396 df-or 844 df-3an 1087 df-tru 1544 df-fal 1554 df-ex 1786 df-nf 1790 df-sb 2071 df-mo 2541 df-eu 2570 df-clab 2717 df-cleq 2731 df-clel 2817 df-nfc 2890 df-ne 2945 df-ral 3070 df-rex 3071 df-rab 3074 df-v 3432 df-sbc 3720 df-dif 3894 df-un 3896 df-in 3898 df-ss 3908 df-nul 4262 df-if 4465 df-sn 4567 df-pr 4569 df-op 4573 df-uni 4845 df-br 5079 df-opab 5141 df-mpt 5162 df-id 5488 df-xp 5594 df-rel 5595 df-cnv 5596 df-co 5597 df-dm 5598 df-rn 5599 df-iota 6388 df-fun 6432 df-fv 6438 df-ov 7271 df-oprab 7272 df-mpo 7273 df-1st 7817 df-2nd 7818 |
This theorem is referenced by: eucalginv 16270 eucalglt 16271 |
Copyright terms: Public domain | W3C validator |