Skip to content

Natural division bug #5704

Open
Open
@etorreborre

Description

@etorreborre

The following property does not hold when the Natural n is 17621823851506098539

n ^ 2 / n == n

This can be shown by uncommenting the ensureWith comment currently in base:

lib.base.math.Natural.pow.tests.quotient : [Result]
  lib.base.math.Natural.pow.tests.quotient = 
    base.test.prop 10 cases
      n ->
        use Nat -
        use Natural + pow
        use Random natIn
        x = Random.natural() + Natural.one
        b = natIn 1 3
        a = natIn b 3
        xa = pow x a
        xb = pow x b
        match toOptional! do div.aborting xa xb with
          None -> ensureWith "failed division" false
          Some lhs ->
            rhs = pow x (a - b)
            _ =
              "this test does not pass for now: ensureWith (x, a, b, xa, xb, lhs, rhs) (lhs == rhs)"
            ()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions