@[instance]
Equations
@[instance]
Equations
- pos_num.inhabited = {default := 1}
Equations
@[instance]
Equations
@[instance]
Equations
Equations
Equations
- a.bit0.cmp b.bit0 = a.cmp b
- a.bit0.cmp b.bit1 = (a.cmp b).cases_on ordering.lt ordering.lt ordering.gt
- a.bit0.cmp 1 = ordering.gt
- a.bit1.cmp b.bit0 = (a.cmp b).cases_on ordering.lt ordering.gt ordering.gt
- a.bit1.cmp b.bit1 = a.cmp b
- a.bit1.cmp 1 = ordering.gt
- 1.cmp a.bit0 = ordering.lt
- 1.cmp a.bit1 = ordering.lt
- 1.cmp 1 = ordering.eq
@[instance]
Equations
- pos_num.has_lt = {lt := λ (a b : pos_num), a.cmp b = ordering.lt}
@[instance]
Equations
- pos_num.decidable_lt a b = id (ordering.decidable_eq (a.cmp b) ordering.lt)
@[instance]
Equations
- pos_num.decidable_le a b = id (ne.decidable (b.cmp a) ordering.lt)
Equations
- cast_pos_num a.bit0 = bit0 (cast_pos_num a)
- cast_pos_num a.bit1 = bit1 (cast_pos_num a)
- cast_pos_num 1 = 1
@[instance]
Equations
- pos_num_coe = {coe := cast_pos_num _inst_3}
@[instance]
Equations
- num.has_lt = {lt := λ (a b : num), a.cmp b = ordering.lt}
@[instance]
Equations
- num.decidable_lt a b = id (ordering.decidable_eq (a.cmp b) ordering.lt)
@[instance]
Equations
- num.decidable_le a b = id (ne.decidable (b.cmp a) ordering.lt)
Equations
- (num.pos a).to_znum_neg = znum.neg a
- 0.to_znum_neg = 0
Equations
- num.of_nat' = nat.binary_rec 0 (λ (b : bool) (n : ℕ), cond b num.bit1 num.bit0)
Equations
- znum.of_int' -[1+ n] = (num.of_nat' (n + 1)).to_znum_neg
- znum.of_int' ↑n = (num.of_nat' n).to_znum
Equations
- a.bit0.sub' b.bit0 = (a.sub' b).bit0
- a.bit0.sub' b.bit1 = (a.sub' b).bitm1
- a.bit0.sub' 1 = a.bit0.pred'.to_znum
- a.bit1.sub' b.bit0 = (a.sub' b).bit1
- a.bit1.sub' b.bit1 = (a.sub' b).bit0
- a.bit1.sub' 1 = a.bit1.pred'.to_znum
- 1.sub' a.bit0 = a.bit0.pred'.to_znum_neg
- 1.sub' a.bit1 = a.bit1.pred'.to_znum_neg
- pos_num.one.sub' 1 = pos_num.one.pred'.to_znum
Equations
Equations
- pos_num.of_znum (znum.neg a) = 1
- pos_num.of_znum (znum.pos p) = p
- pos_num.of_znum znum.zero = 1
@[instance]
Equations
Equations
- (num.pos p).ppred = option.some p.pred'
- 0.ppred = option.none
Equations
- num.of_znum' (znum.neg p) = option.none
- num.of_znum' (znum.pos p) = option.some (num.pos p)
- num.of_znum' 0 = option.some 0
Equations
- num.of_znum (znum.neg a) = 0
- num.of_znum (znum.pos p) = num.pos p
- num.of_znum znum.zero = 0
Equations
- (znum.neg a).add (znum.neg b) = znum.neg (a + b)
- (znum.neg a).add (znum.pos b) = b.sub' a
- (znum.neg a).add 0 = znum.neg a
- (znum.pos a).add (znum.neg b) = a.sub' b
- (znum.pos a).add (znum.pos b) = znum.pos (a + b)
- (znum.pos a).add 0 = znum.pos a
- 0.add (znum.neg a) = znum.neg a
- 0.add (znum.pos a) = znum.pos a
- 0.add znum.zero = znum.zero
Equations
- (znum.neg a).mul (znum.neg b) = znum.pos (a * b)
- (znum.neg a).mul (znum.pos b) = znum.neg (a * b)
- (znum.neg a).mul 0 = 0
- (znum.pos a).mul (znum.neg b) = znum.neg (a * b)
- (znum.pos a).mul (znum.pos b) = znum.pos (a * b)
- (znum.pos a).mul 0 = 0
- 0.mul (znum.neg a) = 0
- 0.mul (znum.pos a) = 0
- 0.mul znum.zero = 0
Equations
- (znum.neg a).cmp (znum.neg b) = b.cmp a
- (znum.neg _x).cmp (znum.pos a) = ordering.lt
- (znum.neg _x).cmp znum.zero = ordering.lt
- (znum.pos _x).cmp (znum.neg a) = ordering.gt
- (znum.pos a).cmp (znum.pos b) = a.cmp b
- (znum.pos _x).cmp znum.zero = ordering.gt
- znum.zero.cmp (znum.neg _x) = ordering.gt
- znum.zero.cmp (znum.pos _x) = ordering.lt
- 0.cmp 0 = ordering.eq
@[instance]
Equations
- znum.has_lt = {lt := λ (a b : znum), a.cmp b = ordering.lt}
@[instance]
Equations
- znum.decidable_lt a b = id (ordering.decidable_eq (a.cmp b) ordering.lt)
@[instance]
Equations
- znum.decidable_le a b = id (ne.decidable (b.cmp a) ordering.lt)
Equations
- d.divmod_aux q r = pos_num.divmod_aux._match_1 q r (num.of_znum' (r.sub' (num.pos d)))
- pos_num.divmod_aux._match_1 q r (option.some r') = (q.bit1, r')
- pos_num.divmod_aux._match_1 q r option.none = (q.bit0, r)
Equations
- b.sqrt_aux1 r n = pos_num.sqrt_aux1._match_1 b r n (num.of_znum' (n.sub' (r + num.pos b)))
- pos_num.sqrt_aux1._match_1 b r n (option.some n') = (r.div2 + num.pos b, n')
- pos_num.sqrt_aux1._match_1 b r n option.none = (r.div2, n)
Equations
- b'.bit0.sqrt_aux r n = pos_num.sqrt_aux._match_1 (λ (r' n' : num), b'.sqrt_aux r' n') (b'.bit0.sqrt_aux1 r n)
- b'.bit1.sqrt_aux r n = pos_num.sqrt_aux._match_2 (λ (r' n' : num), b'.sqrt_aux r' n') (b'.bit1.sqrt_aux1 r n)
- 1.sqrt_aux r n = (1.sqrt_aux1 r n).fst
- pos_num.sqrt_aux._match_1 _f_1 (r', n') = _f_1 r' n'
- pos_num.sqrt_aux._match_2 _f_1 (r', n') = _f_1 r' n'
Equations
- num.gcd_aux n.succ (num.pos a) b = num.gcd_aux n (b % num.pos a) (num.pos a)
- num.gcd_aux n.succ 0 b = b
- num.gcd_aux 0 a b = b
Equations
- (znum.neg n).div (znum.neg d) = znum.pos (n.pred' / num.pos d).succ'
- (znum.neg n).div (znum.pos d) = znum.neg (n.pred' / num.pos d).succ'
- (znum.neg a).div 0 = 0
- (znum.pos n).div (znum.neg d) = (n.div' d).to_znum_neg
- (znum.pos n).div (znum.pos d) = (n.div' d).to_znum
- (znum.pos a).div 0 = 0
- 0.div (znum.neg a) = 0
- 0.div (znum.pos a) = 0
- 0.div znum.zero = 0