Metamath Proof Explorer


Theorem modval

Description: The value of the modulo operation. The modulo congruence notation of number theory, J == K (modulo N ), can be expressed in our notation as ( J mod N ) = ( K mod N ) . Definition 1 in Knuth,The Art of Computer Programming, Vol. I (1972), p. 38. Knuth uses "mod" for the operation and "modulo" for the congruence. Unlike Knuth, we restrict the second argument to positive reals to simplify certain theorems. (This also gives us future flexibility to extend it to any one of several different conventions for a zero or negative second argument, should there be an advantage in doing so.) (Contributed by NM, 10-Nov-2008) (Revised by Mario Carneiro, 3-Nov-2013)

Ref Expression
Assertion modval ( ( ๐ด โˆˆ โ„ โˆง ๐ต โˆˆ โ„+ ) โ†’ ( ๐ด mod ๐ต ) = ( ๐ด โˆ’ ( ๐ต ยท ( โŒŠ โ€˜ ( ๐ด / ๐ต ) ) ) ) )

Proof

Step Hyp Ref Expression
1 fvoveq1 โŠข ( ๐‘ฅ = ๐ด โ†’ ( โŒŠ โ€˜ ( ๐‘ฅ / ๐‘ฆ ) ) = ( โŒŠ โ€˜ ( ๐ด / ๐‘ฆ ) ) )
2 1 oveq2d โŠข ( ๐‘ฅ = ๐ด โ†’ ( ๐‘ฆ ยท ( โŒŠ โ€˜ ( ๐‘ฅ / ๐‘ฆ ) ) ) = ( ๐‘ฆ ยท ( โŒŠ โ€˜ ( ๐ด / ๐‘ฆ ) ) ) )
3 oveq12 โŠข ( ( ๐‘ฅ = ๐ด โˆง ( ๐‘ฆ ยท ( โŒŠ โ€˜ ( ๐‘ฅ / ๐‘ฆ ) ) ) = ( ๐‘ฆ ยท ( โŒŠ โ€˜ ( ๐ด / ๐‘ฆ ) ) ) ) โ†’ ( ๐‘ฅ โˆ’ ( ๐‘ฆ ยท ( โŒŠ โ€˜ ( ๐‘ฅ / ๐‘ฆ ) ) ) ) = ( ๐ด โˆ’ ( ๐‘ฆ ยท ( โŒŠ โ€˜ ( ๐ด / ๐‘ฆ ) ) ) ) )
4 2 3 mpdan โŠข ( ๐‘ฅ = ๐ด โ†’ ( ๐‘ฅ โˆ’ ( ๐‘ฆ ยท ( โŒŠ โ€˜ ( ๐‘ฅ / ๐‘ฆ ) ) ) ) = ( ๐ด โˆ’ ( ๐‘ฆ ยท ( โŒŠ โ€˜ ( ๐ด / ๐‘ฆ ) ) ) ) )
5 oveq2 โŠข ( ๐‘ฆ = ๐ต โ†’ ( ๐ด / ๐‘ฆ ) = ( ๐ด / ๐ต ) )
6 5 fveq2d โŠข ( ๐‘ฆ = ๐ต โ†’ ( โŒŠ โ€˜ ( ๐ด / ๐‘ฆ ) ) = ( โŒŠ โ€˜ ( ๐ด / ๐ต ) ) )
7 oveq12 โŠข ( ( ๐‘ฆ = ๐ต โˆง ( โŒŠ โ€˜ ( ๐ด / ๐‘ฆ ) ) = ( โŒŠ โ€˜ ( ๐ด / ๐ต ) ) ) โ†’ ( ๐‘ฆ ยท ( โŒŠ โ€˜ ( ๐ด / ๐‘ฆ ) ) ) = ( ๐ต ยท ( โŒŠ โ€˜ ( ๐ด / ๐ต ) ) ) )
8 6 7 mpdan โŠข ( ๐‘ฆ = ๐ต โ†’ ( ๐‘ฆ ยท ( โŒŠ โ€˜ ( ๐ด / ๐‘ฆ ) ) ) = ( ๐ต ยท ( โŒŠ โ€˜ ( ๐ด / ๐ต ) ) ) )
9 8 oveq2d โŠข ( ๐‘ฆ = ๐ต โ†’ ( ๐ด โˆ’ ( ๐‘ฆ ยท ( โŒŠ โ€˜ ( ๐ด / ๐‘ฆ ) ) ) ) = ( ๐ด โˆ’ ( ๐ต ยท ( โŒŠ โ€˜ ( ๐ด / ๐ต ) ) ) ) )
10 df-mod โŠข mod = ( ๐‘ฅ โˆˆ โ„ , ๐‘ฆ โˆˆ โ„+ โ†ฆ ( ๐‘ฅ โˆ’ ( ๐‘ฆ ยท ( โŒŠ โ€˜ ( ๐‘ฅ / ๐‘ฆ ) ) ) ) )
11 ovex โŠข ( ๐ด โˆ’ ( ๐ต ยท ( โŒŠ โ€˜ ( ๐ด / ๐ต ) ) ) ) โˆˆ V
12 4 9 10 11 ovmpo โŠข ( ( ๐ด โˆˆ โ„ โˆง ๐ต โˆˆ โ„+ ) โ†’ ( ๐ด mod ๐ต ) = ( ๐ด โˆ’ ( ๐ต ยท ( โŒŠ โ€˜ ( ๐ด / ๐ต ) ) ) ) )