# 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 ${⊢}\left({A}\in ℝ\wedge {B}\in {ℝ}^{+}\right)\to {A}\mathrm{mod}{B}={A}-{B}⌊\frac{{A}}{{B}}⌋$

### Proof

Step Hyp Ref Expression
1 fvoveq1 ${⊢}{x}={A}\to ⌊\frac{{x}}{{y}}⌋=⌊\frac{{A}}{{y}}⌋$
2 1 oveq2d ${⊢}{x}={A}\to {y}⌊\frac{{x}}{{y}}⌋={y}⌊\frac{{A}}{{y}}⌋$
3 oveq12 ${⊢}\left({x}={A}\wedge {y}⌊\frac{{x}}{{y}}⌋={y}⌊\frac{{A}}{{y}}⌋\right)\to {x}-{y}⌊\frac{{x}}{{y}}⌋={A}-{y}⌊\frac{{A}}{{y}}⌋$
4 2 3 mpdan ${⊢}{x}={A}\to {x}-{y}⌊\frac{{x}}{{y}}⌋={A}-{y}⌊\frac{{A}}{{y}}⌋$
5 oveq2 ${⊢}{y}={B}\to \frac{{A}}{{y}}=\frac{{A}}{{B}}$
6 5 fveq2d ${⊢}{y}={B}\to ⌊\frac{{A}}{{y}}⌋=⌊\frac{{A}}{{B}}⌋$
7 oveq12 ${⊢}\left({y}={B}\wedge ⌊\frac{{A}}{{y}}⌋=⌊\frac{{A}}{{B}}⌋\right)\to {y}⌊\frac{{A}}{{y}}⌋={B}⌊\frac{{A}}{{B}}⌋$
8 6 7 mpdan ${⊢}{y}={B}\to {y}⌊\frac{{A}}{{y}}⌋={B}⌊\frac{{A}}{{B}}⌋$
9 8 oveq2d ${⊢}{y}={B}\to {A}-{y}⌊\frac{{A}}{{y}}⌋={A}-{B}⌊\frac{{A}}{{B}}⌋$
10 df-mod ${⊢}\mathrm{mod}=\left({x}\in ℝ,{y}\in {ℝ}^{+}⟼{x}-{y}⌊\frac{{x}}{{y}}⌋\right)$
11 ovex ${⊢}{A}-{B}⌊\frac{{A}}{{B}}⌋\in \mathrm{V}$
12 4 9 10 11 ovmpo ${⊢}\left({A}\in ℝ\wedge {B}\in {ℝ}^{+}\right)\to {A}\mathrm{mod}{B}={A}-{B}⌊\frac{{A}}{{B}}⌋$