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 16337 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 7310 | . . 3 ⊢ ((1st ‘𝑋)𝐸(2nd ‘𝑋)) = (𝐸‘〈(1st ‘𝑋), (2nd ‘𝑋)〉) | |
2 | xp1st 7895 | . . . 4 ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → (1st ‘𝑋) ∈ ℕ0) | |
3 | xp2nd 7896 | . . . 4 ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → (2nd ‘𝑋) ∈ ℕ0) | |
4 | eucalgval.1 | . . . . 5 ⊢ 𝐸 = (𝑥 ∈ ℕ0, 𝑦 ∈ ℕ0 ↦ if(𝑦 = 0, 〈𝑥, 𝑦〉, 〈𝑦, (𝑥 mod 𝑦)〉)) | |
5 | 4 | eucalgval2 16331 | . . . 4 ⊢ (((1st ‘𝑋) ∈ ℕ0 ∧ (2nd ‘𝑋) ∈ ℕ0) → ((1st ‘𝑋)𝐸(2nd ‘𝑋)) = if((2nd ‘𝑋) = 0, 〈(1st ‘𝑋), (2nd ‘𝑋)〉, 〈(2nd ‘𝑋), ((1st ‘𝑋) mod (2nd ‘𝑋))〉)) |
6 | 2, 3, 5 | syl2anc 585 | . . 3 ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → ((1st ‘𝑋)𝐸(2nd ‘𝑋)) = if((2nd ‘𝑋) = 0, 〈(1st ‘𝑋), (2nd ‘𝑋)〉, 〈(2nd ‘𝑋), ((1st ‘𝑋) mod (2nd ‘𝑋))〉)) |
7 | 1, 6 | eqtr3id 2790 | . 2 ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → (𝐸‘〈(1st ‘𝑋), (2nd ‘𝑋)〉) = if((2nd ‘𝑋) = 0, 〈(1st ‘𝑋), (2nd ‘𝑋)〉, 〈(2nd ‘𝑋), ((1st ‘𝑋) mod (2nd ‘𝑋))〉)) |
8 | 1st2nd2 7902 | . . 3 ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → 𝑋 = 〈(1st ‘𝑋), (2nd ‘𝑋)〉) | |
9 | 8 | fveq2d 6808 | . 2 ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → (𝐸‘𝑋) = (𝐸‘〈(1st ‘𝑋), (2nd ‘𝑋)〉)) |
10 | 8 | fveq2d 6808 | . . . . 5 ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → ( mod ‘𝑋) = ( mod ‘〈(1st ‘𝑋), (2nd ‘𝑋)〉)) |
11 | df-ov 7310 | . . . . 5 ⊢ ((1st ‘𝑋) mod (2nd ‘𝑋)) = ( mod ‘〈(1st ‘𝑋), (2nd ‘𝑋)〉) | |
12 | 10, 11 | eqtr4di 2794 | . . . 4 ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → ( mod ‘𝑋) = ((1st ‘𝑋) mod (2nd ‘𝑋))) |
13 | 12 | opeq2d 4816 | . . 3 ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → 〈(2nd ‘𝑋), ( mod ‘𝑋)〉 = 〈(2nd ‘𝑋), ((1st ‘𝑋) mod (2nd ‘𝑋))〉) |
14 | 8, 13 | ifeq12d 4486 | . 2 ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → if((2nd ‘𝑋) = 0, 𝑋, 〈(2nd ‘𝑋), ( mod ‘𝑋)〉) = if((2nd ‘𝑋) = 0, 〈(1st ‘𝑋), (2nd ‘𝑋)〉, 〈(2nd ‘𝑋), ((1st ‘𝑋) mod (2nd ‘𝑋))〉)) |
15 | 7, 9, 14 | 3eqtr4d 2786 | 1 ⊢ (𝑋 ∈ (ℕ0 × ℕ0) → (𝐸‘𝑋) = if((2nd ‘𝑋) = 0, 𝑋, 〈(2nd ‘𝑋), ( mod ‘𝑋)〉)) |
Colors of variables: wff setvar class |
Syntax hints: → wi 4 = wceq 1539 ∈ wcel 2104 ifcif 4465 〈cop 4571 × cxp 5598 ‘cfv 6458 (class class class)co 7307 ∈ cmpo 7309 1st c1st 7861 2nd c2nd 7862 0cc0 10917 ℕ0cn0 12279 mod cmo 13635 |
This theorem was proved from axioms: ax-mp 5 ax-1 6 ax-2 7 ax-3 8 ax-gen 1795 ax-4 1809 ax-5 1911 ax-6 1969 ax-7 2009 ax-8 2106 ax-9 2114 ax-10 2135 ax-11 2152 ax-12 2169 ax-ext 2707 ax-sep 5232 ax-nul 5239 ax-pr 5361 ax-un 7620 |
This theorem depends on definitions: df-bi 206 df-an 398 df-or 846 df-3an 1089 df-tru 1542 df-fal 1552 df-ex 1780 df-nf 1784 df-sb 2066 df-mo 2538 df-eu 2567 df-clab 2714 df-cleq 2728 df-clel 2814 df-nfc 2887 df-ral 3063 df-rex 3072 df-rab 3287 df-v 3439 df-sbc 3722 df-dif 3895 df-un 3897 df-in 3899 df-ss 3909 df-nul 4263 df-if 4466 df-sn 4566 df-pr 4568 df-op 4572 df-uni 4845 df-br 5082 df-opab 5144 df-mpt 5165 df-id 5500 df-xp 5606 df-rel 5607 df-cnv 5608 df-co 5609 df-dm 5610 df-rn 5611 df-iota 6410 df-fun 6460 df-fv 6466 df-ov 7310 df-oprab 7311 df-mpo 7312 df-1st 7863 df-2nd 7864 |
This theorem is referenced by: eucalginv 16334 eucalglt 16335 |
Copyright terms: Public domain | W3C validator |