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
|- ( ( A e. RR /\ B e. RR+ ) -> ( A mod B ) = ( A - ( B x. ( |_ ` ( A / B ) ) ) ) )

Proof

Step Hyp Ref Expression
1 fvoveq1
 |-  ( x = A -> ( |_ ` ( x / y ) ) = ( |_ ` ( A / y ) ) )
2 1 oveq2d
 |-  ( x = A -> ( y x. ( |_ ` ( x / y ) ) ) = ( y x. ( |_ ` ( A / y ) ) ) )
3 oveq12
 |-  ( ( x = A /\ ( y x. ( |_ ` ( x / y ) ) ) = ( y x. ( |_ ` ( A / y ) ) ) ) -> ( x - ( y x. ( |_ ` ( x / y ) ) ) ) = ( A - ( y x. ( |_ ` ( A / y ) ) ) ) )
4 2 3 mpdan
 |-  ( x = A -> ( x - ( y x. ( |_ ` ( x / y ) ) ) ) = ( A - ( y x. ( |_ ` ( A / y ) ) ) ) )
5 oveq2
 |-  ( y = B -> ( A / y ) = ( A / B ) )
6 5 fveq2d
 |-  ( y = B -> ( |_ ` ( A / y ) ) = ( |_ ` ( A / B ) ) )
7 oveq12
 |-  ( ( y = B /\ ( |_ ` ( A / y ) ) = ( |_ ` ( A / B ) ) ) -> ( y x. ( |_ ` ( A / y ) ) ) = ( B x. ( |_ ` ( A / B ) ) ) )
8 6 7 mpdan
 |-  ( y = B -> ( y x. ( |_ ` ( A / y ) ) ) = ( B x. ( |_ ` ( A / B ) ) ) )
9 8 oveq2d
 |-  ( y = B -> ( A - ( y x. ( |_ ` ( A / y ) ) ) ) = ( A - ( B x. ( |_ ` ( A / B ) ) ) ) )
10 df-mod
 |-  mod = ( x e. RR , y e. RR+ |-> ( x - ( y x. ( |_ ` ( x / y ) ) ) ) )
11 ovex
 |-  ( A - ( B x. ( |_ ` ( A / B ) ) ) ) e. _V
12 4 9 10 11 ovmpo
 |-  ( ( A e. RR /\ B e. RR+ ) -> ( A mod B ) = ( A - ( B x. ( |_ ` ( A / B ) ) ) ) )