Basic Bignum Definitions #
This file contains the fundamental definitions for bignums in Lean, ported from s2n-bignum/common/bignum.ml
Main Definitions #
bigdigit n i- Extracts the i-th 64-bit digit from natural number nhighdigits n i- Returns the high part: n DIV (2^(64*i))lowdigits n i- Returns the low part: n MOD (2^(64*i))
References #
Source: s2n-bignum/common/bignum.ml (lines 11-77)
Extract the i-th 64-bit digit from a natural number n.
This corresponds to HOL Light's definition:
let bigdigit = new_definition
`bigdigit n i = (n DIV (2 EXP (64 * i))) MOD (2 EXP 64)`;;
Source: s2n-bignum/common/bignum.ml:11-12
Instances For
Extract the high digits of n starting from position i. Essentially n DIV (2^(64*i)).
This corresponds to HOL Light's definition:
let highdigits = new_definition
`highdigits n i = n DIV (2 EXP (64 * i))`;;
Source: s2n-bignum/common/bignum.ml:73-74
Equations
- Bignum.highdigits n i = n / 2 ^ (64 * i)
Instances For
Extract the low digits of n up to position i. Essentially n MOD (2^(64*i)).
This corresponds to HOL Light's definition:
let lowdigits = new_definition
`lowdigits n i = n MOD (2 EXP (64 * i))`;;
Source: s2n-bignum/common/bignum.ml:76-77
Equations
- Bignum.lowdigits n i = n % 2 ^ (64 * i)
Instances For
bigdigit of 0 is always 0.
Corresponds to HOL Light theorem:
let BIGDIGIT_0 = prove
(`!i. bigdigit 0 i = 0`, ...);;
Source: s2n-bignum/common/bignum.ml:33-35
lowdigits of 0 is always 0.
Corresponds to HOL Light theorem:
let LOWDIGITS_0 = prove
(`!n. lowdigits n 0 = 0`, ...);;
Source: s2n-bignum/common/bignum.ml:121-123
highdigits of n at position 0 is n itself.
Corresponds to HOL Light theorem:
let HIGHDIGITS_0 = prove
(`!n. highdigits n 0 = n`, ...);;
Source: s2n-bignum/common/bignum.ml:109-111