{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -Wno-orphans #-}
{-|
    Module      :  AERN2.MP.Ball.Tests
    Description :  Tests for operations on arbitrary precision balls
    Copyright   :  (c) Michal Konecny
    License     :  BSD3

    Maintainer  :  mikkonecny@gmail.com
    Stability   :  experimental
    Portability :  portable

    Tests for operations on arbitrary precision balls.

    To run the tests using stack, execute:

    @
    stack test aern2-mp --test-arguments "-a 1000 -m MPBall"
    @
-}
module AERN2.MP.Ball.Tests
  (
    specMPBall, tMPBall
  )
where

import MixedTypesNumPrelude
-- import qualified Prelude as P
-- import Data.Ratio
-- import Text.Printf

import Test.Hspec
import Test.QuickCheck
-- import qualified Test.Hspec.SmallCheck as SC

-- import AERN2.Norm
import AERN2.MP.Precision

import AERN2.MP.Ball.Type
-- import AERN2.MP.Ball.Conversions ()
import AERN2.MP.Ball.Comparisons ()
import AERN2.MP.Ball.Field ()
import AERN2.MP.Ball.Elementary ()

instance Arbitrary MPBall where
  arbitrary :: Gen MPBall
arbitrary =
    do
      MPFloat
c <- Gen MPFloat
finiteMPFloat
      ErrorBound
e <- Gen ErrorBound
smallEB
      MPBall -> Gen MPBall
forall (m :: * -> *) a. Monad m => a -> m a
return (MPBall -> MPBall
reducePrecionIfInaccurate (MPBall -> MPBall) -> MPBall -> MPBall
forall a b. (a -> b) -> a -> b
$ MPFloat -> ErrorBound -> MPBall
MPBall MPFloat
c ErrorBound
e)
    where
      smallEB :: Gen ErrorBound
smallEB =
        do
          ErrorBound
e <- Gen ErrorBound
forall a. Arbitrary a => Gen a
arbitrary
          if (ErrorBound -> MPBall
forall t. CanBeMPBall t => t -> MPBall
mpBall ErrorBound
e) MPBall -> Integer -> Bool
forall a b. HasOrderCertainlyAsymmetric a b => a -> b -> Bool
!<! Integer
10
            then ErrorBound -> Gen ErrorBound
forall (m :: * -> *) a. Monad m => a -> m a
return ErrorBound
e
            else Gen ErrorBound
smallEB
      finiteMPFloat :: Gen MPFloat
finiteMPFloat =
        do
          MPFloat
x <- Gen MPFloat
forall a. Arbitrary a => Gen a
arbitrary
          if MPFloat -> Bool
forall t. CanTestFinite t => t -> Bool
isFinite MPFloat
x
            then MPFloat -> Gen MPFloat
forall (m :: * -> *) a. Monad m => a -> m a
return MPFloat
x
            else Gen MPFloat
finiteMPFloat

{-|
  A runtime representative of type @MPBall@.
  Used for specialising polymorphic tests to concrete types.
-}
tMPBall :: T MPBall
tMPBall :: T MPBall
tMPBall = String -> T MPBall
forall t. String -> T t
T String
"MPBall"

-- tCNMPBall :: T (CN MPBall)
-- tCNMPBall = T "(CN MPBall)"

specMPBall :: Spec
specMPBall :: Spec
specMPBall =
  String -> Spec -> Spec
forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe (String
"MPBall") (Spec -> Spec) -> Spec -> Spec
forall a b. (a -> b) -> a -> b
$ do
    T MPBall -> (MPBall -> MPBall -> Property) -> Spec
forall t prop.
(HasPrecision t, CanSetPrecision t, CanTestFinite t, Arbitrary t,
 Show t, Testable prop) =>
T t -> (t -> t -> prop) -> Spec
specCanSetPrecision T MPBall
tMPBall (String
-> (MPBall -> MPBall -> Bool) -> MPBall -> MPBall -> Property
forall prop a b.
(Testable prop, Show a, Show b) =>
String -> (a -> b -> prop) -> a -> b -> Property
printArgsIfFails2 String
"`contains`" MPBall -> MPBall -> Bool
forall dom e. CanTestContains dom e => dom -> e -> Bool
contains)
    T Integer
-> T MPBall -> (Integer -> MPBall) -> (MPBall -> Integer) -> Spec
forall t1 t2.
(Arbitrary t1, Show t1, HasEqCertainly t1 t1) =>
T t1 -> T t2 -> (t1 -> t2) -> (t2 -> t1) -> Spec
specConversion T Integer
tInteger T MPBall
tMPBall Integer -> MPBall
forall t. CanBeMPBall t => t -> MPBall
mpBall ((Integer, Integer) -> Integer
forall a b. (a, b) -> a
fst ((Integer, Integer) -> Integer)
-> (MPBall -> (Integer, Integer)) -> MPBall -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MPBall -> (Integer, Integer)
forall t. HasIntegerBounds t => t -> (Integer, Integer)
integerBounds)
    String -> Spec -> Spec
forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe String
"order" (Spec -> Spec) -> Spec -> Spec
forall a b. (a -> b) -> a -> b
$ do
      T MPBall -> Spec
forall t.
(Arbitrary t, Show t, CanTestCertainly (EqCompareType t t),
 CanTestCertainly
   (AndOrType (EqCompareType t t) (EqCompareType t t)),
 HasEqAsymmetric t t) =>
T t -> Spec
specHasEqNotMixed T MPBall
tMPBall
      T Int -> T MPBall -> T Rational -> Spec
forall t1 t2 t3.
(Arbitrary t1, Arbitrary t2, Arbitrary t3, Show t1, Show t2,
 Show t3, CanTestCertainly (EqCompareType t1 t1),
 CanTestCertainly (EqCompareType t1 t2),
 CanTestCertainly (EqCompareType t2 t1),
 CanTestCertainly
   (AndOrType (EqCompareType t1 t2) (EqCompareType t2 t3)),
 CanTestCertainly (EqCompareType t2 t3), HasEqAsymmetric t1 t1,
 HasEqAsymmetric t1 t2, HasEqAsymmetric t2 t1,
 HasEqAsymmetric t2 t3,
 CanAndOrAsymmetric (EqCompareType t1 t2) (EqCompareType t2 t3)) =>
T t1 -> T t2 -> T t3 -> Spec
specHasEq T Int
tInt T MPBall
tMPBall T Rational
tRational
      T MPBall -> Spec
forall t.
(CanTestZero t, ConvertibleExactly Integer t) =>
T t -> Spec
specCanTestZero T MPBall
tMPBall
      T MPBall -> Spec
forall t.
(Arbitrary t, Show t, CanTestCertainly (OrderCompareType t t),
 CanTestCertainly
   (AndOrType (OrderCompareType t t) (OrderCompareType t t)),
 HasOrderAsymmetric t t) =>
T t -> Spec
specHasOrderNotMixed T MPBall
tMPBall
      T Int -> T MPBall -> T Rational -> Spec
forall t1 t2 t3.
(Arbitrary t1, Arbitrary t2, Arbitrary t3, Show t1, Show t2,
 Show t3, CanTestCertainly (OrderCompareType t1 t1),
 CanTestCertainly (OrderCompareType t1 t2),
 CanTestCertainly (OrderCompareType t2 t1),
 CanTestCertainly
   (AndOrType (OrderCompareType t1 t2) (OrderCompareType t2 t3)),
 CanTestCertainly (OrderCompareType t2 t3),
 HasOrderAsymmetric t1 t1, HasOrderAsymmetric t1 t2,
 HasOrderAsymmetric t2 t1, HasOrderAsymmetric t2 t3,
 CanAndOrAsymmetric
   (OrderCompareType t1 t2) (OrderCompareType t2 t3)) =>
T t1 -> T t2 -> T t3 -> Spec
specHasOrder T Int
tInt T MPBall
tMPBall T Rational
tRational
    String -> Spec -> Spec
forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe String
"min/max/abs" (Spec -> Spec) -> Spec -> Spec
forall a b. (a -> b) -> a -> b
$ do
      T MPBall -> Spec
forall t.
(Arbitrary t, Show t, Show (NegType (NegType t)),
 HasEqAsymmetric t t, HasEqAsymmetric (NegType (NegType t)) t,
 HasEqAsymmetric (NegType t) t,
 CanTestCertainly (EqCompareType t t),
 CanTestCertainly (EqCompareType (NegType (NegType t)) t),
 CanTestCertainly (EqCompareType (NegType t) t), CanTestFinite t,
 CanTestPosNeg t, CanTestPosNeg (NegType t),
 ConvertibleExactly Integer t, CanNeg (NegType t), CanNeg t) =>
T t -> Spec
specCanNegNum T MPBall
tMPBall
      T MPBall -> Spec
forall t.
(Arbitrary t, CanAbs (AbsType t), CanAbs t, CanTestFinite t,
 HasEqAsymmetric (AbsType (AbsType t)) (AbsType t),
 HasEqAsymmetric t t, HasEqAsymmetric t (AbsType t),
 HasEqAsymmetric (NegType t) (AbsType t),
 CanTestCertainly (EqCompareType t t),
 CanTestCertainly (EqCompareType (AbsType (AbsType t)) (AbsType t)),
 CanTestCertainly (EqCompareType t (AbsType t)),
 CanTestCertainly (EqCompareType (NegType t) (AbsType t)), Show t,
 Show (AbsType (AbsType t)), Show (AbsType t), Show (NegType t),
 CanTestPosNeg t, CanTestPosNeg (AbsType t), CanNeg t) =>
T t -> Spec
specCanAbs T MPBall
tMPBall
      T MPBall -> Spec
forall t.
(HasOrderAsymmetric (MinMaxType t t) t, Arbitrary t,
 CanTestFinite t, HasEqAsymmetric (MinMaxType t t) t,
 HasEqAsymmetric (MinMaxType t t) (MinMaxType t t),
 HasEqAsymmetric
   (MinMaxType t (MinMaxType t t)) (MinMaxType (MinMaxType t t) t),
 CanTestCertainly (OrderCompareType (MinMaxType t t) t),
 CanTestCertainly (EqCompareType (MinMaxType t t) t),
 CanTestCertainly (EqCompareType (MinMaxType t t) (MinMaxType t t)),
 CanTestCertainly
   (EqCompareType
      (MinMaxType t (MinMaxType t t)) (MinMaxType (MinMaxType t t) t)),
 Show t, Show (MinMaxType t t),
 Show (MinMaxType t (MinMaxType t t)),
 Show (MinMaxType (MinMaxType t t) t), CanMinMaxAsymmetric t t,
 CanMinMaxAsymmetric t (MinMaxType t t),
 CanMinMaxAsymmetric (MinMaxType t t) t) =>
T t -> Spec
specCanMinMaxNotMixed T MPBall
tMPBall
      T MPBall -> T Integer -> T MPBall -> Spec
forall t1 t2 t3.
(HasOrderAsymmetric (MinMaxType t1 t2) t2,
 HasOrderAsymmetric (MinMaxType t1 t2) t1, Arbitrary t1,
 Arbitrary t2, Arbitrary t3, CanTestFinite t1, CanTestFinite t2,
 CanTestFinite t3, HasEqAsymmetric (MinMaxType t1 t1) t1,
 HasEqAsymmetric (MinMaxType t1 t2) (MinMaxType t2 t1),
 HasEqAsymmetric
   (MinMaxType t1 (MinMaxType t2 t3))
   (MinMaxType (MinMaxType t1 t2) t3),
 CanTestCertainly (OrderCompareType (MinMaxType t1 t2) t2),
 CanTestCertainly (OrderCompareType (MinMaxType t1 t2) t1),
 CanTestCertainly (EqCompareType (MinMaxType t1 t1) t1),
 CanTestCertainly
   (EqCompareType (MinMaxType t1 t2) (MinMaxType t2 t1)),
 CanTestCertainly
   (EqCompareType
      (MinMaxType t1 (MinMaxType t2 t3))
      (MinMaxType (MinMaxType t1 t2) t3)),
 Show t1, Show t2, Show (MinMaxType t1 t2), Show (MinMaxType t1 t1),
 Show (MinMaxType t2 t1), Show t3,
 Show (MinMaxType t1 (MinMaxType t2 t3)),
 Show (MinMaxType (MinMaxType t1 t2) t3), CanMinMaxAsymmetric t1 t2,
 CanMinMaxAsymmetric t1 t1,
 CanMinMaxAsymmetric t1 (MinMaxType t2 t3),
 CanMinMaxAsymmetric t2 t1, CanMinMaxAsymmetric t2 t3,
 CanMinMaxAsymmetric (MinMaxType t1 t2) t3) =>
T t1 -> T t2 -> T t3 -> Spec
specCanMinMax T MPBall
tMPBall T Integer
tInteger T MPBall
tMPBall
    String -> Spec -> Spec
forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe String
"ring" (Spec -> Spec) -> Spec -> Spec
forall a b. (a -> b) -> a -> b
$ do
      T MPBall -> Spec
forall t.
(Arbitrary t, HasEqAsymmetric (AddType t t) t,
 HasEqAsymmetric (AddType t t) (AddType t t),
 HasEqAsymmetric
   (AddType t (AddType t t)) (AddType (AddType t t) t),
 Show t, Show (AddType t t), Show (AddType t (AddType t t)),
 Show (AddType (AddType t t) t), CanAddAsymmetric t t,
 CanAddAsymmetric t (AddType t t), CanAddAsymmetric (AddType t t) t,
 CanTestPosNeg t, HasOrderAsymmetric (AddType t t) t,
 CanTestCertainly (EqCompareType (AddType t t) t),
 CanTestCertainly (EqCompareType (AddType t t) (AddType t t)),
 CanTestCertainly
   (EqCompareType
      (AddType t (AddType t t)) (AddType (AddType t t) t)),
 CanTestCertainly (OrderCompareType (AddType t t) t),
 ConvertibleExactly Integer t) =>
T t -> Spec
specCanAddNotMixed T MPBall
tMPBall
      T MPBall -> Spec
forall t.
(ConvertibleExactly Integer t, Show t, HasEqCertainly t t,
 CanAddSameType t) =>
T t -> Spec
specCanAddSameType T MPBall
tMPBall
      T Int -> T MPBall -> T Rational -> Spec
forall t1 t2 t3.
(Arbitrary t1, Arbitrary t2, Arbitrary t3,
 HasEqAsymmetric (AddType t1 t1) t1,
 HasEqAsymmetric (AddType t1 t2) (AddType t2 t1),
 HasEqAsymmetric
   (AddType t1 (AddType t2 t3)) (AddType (AddType t1 t2) t3),
 Show t1, Show (AddType t1 t1), Show t2, Show (AddType t1 t2),
 Show (AddType t2 t1), Show t3, Show (AddType t1 (AddType t2 t3)),
 Show (AddType (AddType t1 t2) t3), CanAddAsymmetric t1 t1,
 CanAddAsymmetric t1 t2, CanAddAsymmetric t1 (AddType t2 t3),
 CanAddAsymmetric t2 t1, CanAddAsymmetric t2 t3,
 CanAddAsymmetric (AddType t1 t2) t3, CanTestPosNeg t1,
 HasOrderAsymmetric (AddType t1 t2) t2,
 CanTestCertainly (EqCompareType (AddType t1 t1) t1),
 CanTestCertainly (EqCompareType (AddType t1 t2) (AddType t2 t1)),
 CanTestCertainly
   (EqCompareType
      (AddType t1 (AddType t2 t3)) (AddType (AddType t1 t2) t3)),
 CanTestCertainly (OrderCompareType (AddType t1 t2) t2),
 ConvertibleExactly Integer t1) =>
T t1 -> T t2 -> T t3 -> Spec
specCanAdd T Int
tInt T MPBall
tMPBall T Rational
tRational
      T Integer -> T MPBall -> T Int -> Spec
forall t1 t2 t3.
(Arbitrary t1, Arbitrary t2, Arbitrary t3,
 HasEqAsymmetric (AddType t1 t1) t1,
 HasEqAsymmetric (AddType t1 t2) (AddType t2 t1),
 HasEqAsymmetric
   (AddType t1 (AddType t2 t3)) (AddType (AddType t1 t2) t3),
 Show t1, Show (AddType t1 t1), Show t2, Show (AddType t1 t2),
 Show (AddType t2 t1), Show t3, Show (AddType t1 (AddType t2 t3)),
 Show (AddType (AddType t1 t2) t3), CanAddAsymmetric t1 t1,
 CanAddAsymmetric t1 t2, CanAddAsymmetric t1 (AddType t2 t3),
 CanAddAsymmetric t2 t1, CanAddAsymmetric t2 t3,
 CanAddAsymmetric (AddType t1 t2) t3, CanTestPosNeg t1,
 HasOrderAsymmetric (AddType t1 t2) t2,
 CanTestCertainly (EqCompareType (AddType t1 t1) t1),
 CanTestCertainly (EqCompareType (AddType t1 t2) (AddType t2 t1)),
 CanTestCertainly
   (EqCompareType
      (AddType t1 (AddType t2 t3)) (AddType (AddType t1 t2) t3)),
 CanTestCertainly (OrderCompareType (AddType t1 t2) t2),
 ConvertibleExactly Integer t1) =>
T t1 -> T t2 -> T t3 -> Spec
specCanAdd T Integer
tInteger T MPBall
tMPBall T Int
tInt
      T MPBall -> Spec
forall t.
(Arbitrary t, HasEqAsymmetric (SubType t t) t,
 HasEqAsymmetric (SubType t t) (AddType t (NegType t)),
 CanTestCertainly (EqCompareType (SubType t t) t),
 CanTestCertainly
   (EqCompareType (SubType t t) (AddType t (NegType t))),
 Show t, Show (SubType t t), Show (AddType t (NegType t)),
 CanSub t t, CanAddAsymmetric t (NegType t),
 ConvertibleExactly Integer t, CanNeg t) =>
T t -> Spec
specCanSubNotMixed T MPBall
tMPBall
      T MPBall -> T Integer -> Spec
forall t1 t2.
(Arbitrary t1, Arbitrary t2, HasEqAsymmetric (SubType t1 t1) t1,
 HasEqAsymmetric (SubType t1 t2) (AddType t1 (NegType t2)),
 CanTestCertainly (EqCompareType (SubType t1 t1) t1),
 CanTestCertainly
   (EqCompareType (SubType t1 t2) (AddType t1 (NegType t2))),
 Show t1, Show (SubType t1 t1), Show t2, Show (SubType t1 t2),
 Show (AddType t1 (NegType t2)), CanSub t1 t1, CanSub t1 t2,
 CanAddAsymmetric t1 (NegType t2), ConvertibleExactly Integer t1,
 CanNeg t2) =>
T t1 -> T t2 -> Spec
specCanSub T MPBall
tMPBall T Integer
tInteger
      T Integer -> T MPBall -> Spec
forall t1 t2.
(Arbitrary t1, Arbitrary t2, HasEqAsymmetric (SubType t1 t1) t1,
 HasEqAsymmetric (SubType t1 t2) (AddType t1 (NegType t2)),
 CanTestCertainly (EqCompareType (SubType t1 t1) t1),
 CanTestCertainly
   (EqCompareType (SubType t1 t2) (AddType t1 (NegType t2))),
 Show t1, Show (SubType t1 t1), Show t2, Show (SubType t1 t2),
 Show (AddType t1 (NegType t2)), CanSub t1 t1, CanSub t1 t2,
 CanAddAsymmetric t1 (NegType t2), ConvertibleExactly Integer t1,
 CanNeg t2) =>
T t1 -> T t2 -> Spec
specCanSub T Integer
tInteger T MPBall
tMPBall
      T MPBall -> T Int -> Spec
forall t1 t2.
(Arbitrary t1, Arbitrary t2, HasEqAsymmetric (SubType t1 t1) t1,
 HasEqAsymmetric (SubType t1 t2) (AddType t1 (NegType t2)),
 CanTestCertainly (EqCompareType (SubType t1 t1) t1),
 CanTestCertainly
   (EqCompareType (SubType t1 t2) (AddType t1 (NegType t2))),
 Show t1, Show (SubType t1 t1), Show t2, Show (SubType t1 t2),
 Show (AddType t1 (NegType t2)), CanSub t1 t1, CanSub t1 t2,
 CanAddAsymmetric t1 (NegType t2), ConvertibleExactly Integer t1,
 CanNeg t2) =>
T t1 -> T t2 -> Spec
specCanSub T MPBall
tMPBall T Int
tInt
      T Int -> T MPBall -> Spec
forall t1 t2.
(Arbitrary t1, Arbitrary t2, HasEqAsymmetric (SubType t1 t1) t1,
 HasEqAsymmetric (SubType t1 t2) (AddType t1 (NegType t2)),
 CanTestCertainly (EqCompareType (SubType t1 t1) t1),
 CanTestCertainly
   (EqCompareType (SubType t1 t2) (AddType t1 (NegType t2))),
 Show t1, Show (SubType t1 t1), Show t2, Show (SubType t1 t2),
 Show (AddType t1 (NegType t2)), CanSub t1 t1, CanSub t1 t2,
 CanAddAsymmetric t1 (NegType t2), ConvertibleExactly Integer t1,
 CanNeg t2) =>
T t1 -> T t2 -> Spec
specCanSub T Int
tInt T MPBall
tMPBall
      T MPBall -> Spec
forall t.
(Arbitrary t, HasEqAsymmetric (MulType t t) t,
 HasEqAsymmetric (MulType t t) (MulType t t),
 HasEqAsymmetric
   (MulType t (MulType t t)) (MulType (MulType t t) t),
 HasEqAsymmetric
   (MulType t (AddType t t)) (AddType (MulType t t) (MulType t t)),
 CanTestCertainly (EqCompareType (MulType t t) t),
 CanTestCertainly (EqCompareType (MulType t t) (MulType t t)),
 CanTestCertainly
   (EqCompareType
      (MulType t (MulType t t)) (MulType (MulType t t) t)),
 CanTestCertainly
   (EqCompareType
      (MulType t (AddType t t)) (AddType (MulType t t) (MulType t t))),
 Show t, Show (MulType t t), Show (MulType t (MulType t t)),
 Show (MulType (MulType t t) t), Show (MulType t (AddType t t)),
 Show (AddType (MulType t t) (MulType t t)), CanAddAsymmetric t t,
 CanAddAsymmetric (MulType t t) (MulType t t),
 CanMulAsymmetric (MulType t t) t, CanMulAsymmetric t t,
 CanMulAsymmetric t (MulType t t), CanMulAsymmetric t (AddType t t),
 ConvertibleExactly Integer t) =>
T t -> Spec
specCanMulNotMixed T MPBall
tMPBall
      T MPBall -> Spec
forall t.
(Show t, ConvertibleExactly Integer t,
 CanTestCertainly (EqCompareType t t), HasEqAsymmetric t t,
 CanMulAsymmetric t t, MulType t t ~ t) =>
T t -> Spec
specCanMulSameType T MPBall
tMPBall
      T Int -> T MPBall -> T Rational -> Spec
forall t1 t2 t3.
(Arbitrary t1, Arbitrary t2, Arbitrary t3,
 HasEqAsymmetric (MulType t1 t2) t1,
 HasEqAsymmetric (MulType t1 t2) (MulType t2 t1),
 HasEqAsymmetric
   (MulType t1 (MulType t2 t3)) (MulType (MulType t1 t2) t3),
 HasEqAsymmetric
   (MulType t1 (AddType t2 t3))
   (AddType (MulType t1 t2) (MulType t1 t3)),
 CanTestCertainly (EqCompareType (MulType t1 t2) t1),
 CanTestCertainly (EqCompareType (MulType t1 t2) (MulType t2 t1)),
 CanTestCertainly
   (EqCompareType
      (MulType t1 (MulType t2 t3)) (MulType (MulType t1 t2) t3)),
 CanTestCertainly
   (EqCompareType
      (MulType t1 (AddType t2 t3))
      (AddType (MulType t1 t2) (MulType t1 t3))),
 Show t1, Show (MulType t1 t2), Show t2, Show (MulType t2 t1),
 Show t3, Show (MulType t1 (MulType t2 t3)),
 Show (MulType (MulType t1 t2) t3),
 Show (MulType t1 (AddType t2 t3)),
 Show (AddType (MulType t1 t2) (MulType t1 t3)),
 CanAddAsymmetric t2 t3,
 CanAddAsymmetric (MulType t1 t2) (MulType t1 t3),
 CanMulAsymmetric t2 t1, CanMulAsymmetric t2 t3,
 CanMulAsymmetric (MulType t1 t2) t3, CanMulAsymmetric t1 t2,
 CanMulAsymmetric t1 (MulType t2 t3),
 CanMulAsymmetric t1 (AddType t2 t3), CanMulAsymmetric t1 t3,
 ConvertibleExactly Integer t2) =>
T t1 -> T t2 -> T t3 -> Spec
specCanMul T Int
tInt T MPBall
tMPBall T Rational
tRational
      -- specCanPow tMPBall tInteger
    String -> Spec -> Spec
forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe String
"field" (Spec -> Spec) -> Spec -> Spec
forall a b. (a -> b) -> a -> b
$ do
      T MPBall -> Spec
forall t.
(CanDiv t t, CanDiv Integer t, CanDiv Integer (DivType Integer t),
 Arbitrary t, CanTestZero t, CanTestZero (DivType Integer t),
 HasEqAsymmetric (DivType Integer (DivType Integer t)) t,
 HasEqAsymmetric (DivType t t) t,
 HasEqAsymmetric (DivType t t) (MulType t (DivType t t)),
 CanTestCertainly
   (EqCompareType (DivType Integer (DivType Integer t)) t),
 CanTestCertainly (EqCompareType (DivType t t) t),
 CanTestCertainly
   (EqCompareType (DivType t t) (MulType t (DivType t t))),
 Show t, Show (DivType Integer (DivType Integer t)),
 Show (DivType t t), Show (MulType t (DivType t t)),
 CanMulAsymmetric t (DivType t t), ConvertibleExactly Integer t) =>
T t -> Spec
specCanDivNotMixed T MPBall
tMPBall
      T Integer -> T MPBall -> Spec
forall t1 t2.
(CanDiv t1 t2, CanDiv t1 t1, CanDiv Integer t1,
 CanDiv Integer (DivType Integer t1), Arbitrary t1, Arbitrary t2,
 CanTestZero t1, CanTestZero (DivType Integer t1), CanTestZero t2,
 HasEqAsymmetric (DivType Integer (DivType Integer t1)) t1,
 HasEqAsymmetric (DivType t1 t1) t1,
 HasEqAsymmetric (DivType t1 t2) t1,
 HasEqAsymmetric (DivType t1 t2) (MulType t1 (DivType t1 t2)),
 CanTestCertainly
   (EqCompareType (DivType Integer (DivType Integer t1)) t1),
 CanTestCertainly (EqCompareType (DivType t1 t2) t1),
 CanTestCertainly (EqCompareType (DivType t1 t1) t1),
 CanTestCertainly
   (EqCompareType (DivType t1 t2) (MulType t1 (DivType t1 t2))),
 Show t1, Show (DivType Integer (DivType Integer t1)),
 Show (DivType t1 t2), Show (DivType t1 t1), Show t2,
 Show (MulType t1 (DivType t1 t2)),
 CanMulAsymmetric t1 (DivType t1 t2), ConvertibleExactly Integer t2,
 ConvertibleExactly Integer t1) =>
T t1 -> T t2 -> Spec
specCanDiv T Integer
tInteger T MPBall
tMPBall
      T MPBall -> T Int -> Spec
forall t1 t2.
(CanDiv t1 t2, CanDiv t1 t1, CanDiv Integer t1,
 CanDiv Integer (DivType Integer t1), Arbitrary t1, Arbitrary t2,
 CanTestZero t1, CanTestZero (DivType Integer t1), CanTestZero t2,
 HasEqAsymmetric (DivType Integer (DivType Integer t1)) t1,
 HasEqAsymmetric (DivType t1 t1) t1,
 HasEqAsymmetric (DivType t1 t2) t1,
 HasEqAsymmetric (DivType t1 t2) (MulType t1 (DivType t1 t2)),
 CanTestCertainly
   (EqCompareType (DivType Integer (DivType Integer t1)) t1),
 CanTestCertainly (EqCompareType (DivType t1 t2) t1),
 CanTestCertainly (EqCompareType (DivType t1 t1) t1),
 CanTestCertainly
   (EqCompareType (DivType t1 t2) (MulType t1 (DivType t1 t2))),
 Show t1, Show (DivType Integer (DivType Integer t1)),
 Show (DivType t1 t2), Show (DivType t1 t1), Show t2,
 Show (MulType t1 (DivType t1 t2)),
 CanMulAsymmetric t1 (DivType t1 t2), ConvertibleExactly Integer t2,
 ConvertibleExactly Integer t1) =>
T t1 -> T t2 -> Spec
specCanDiv T MPBall
tMPBall T Int
tInt
      T MPBall -> T Rational -> Spec
forall t1 t2.
(CanDiv t1 t2, CanDiv t1 t1, CanDiv Integer t1,
 CanDiv Integer (DivType Integer t1), Arbitrary t1, Arbitrary t2,
 CanTestZero t1, CanTestZero (DivType Integer t1), CanTestZero t2,
 HasEqAsymmetric (DivType Integer (DivType Integer t1)) t1,
 HasEqAsymmetric (DivType t1 t1) t1,
 HasEqAsymmetric (DivType t1 t2) t1,
 HasEqAsymmetric (DivType t1 t2) (MulType t1 (DivType t1 t2)),
 CanTestCertainly
   (EqCompareType (DivType Integer (DivType Integer t1)) t1),
 CanTestCertainly (EqCompareType (DivType t1 t2) t1),
 CanTestCertainly (EqCompareType (DivType t1 t1) t1),
 CanTestCertainly
   (EqCompareType (DivType t1 t2) (MulType t1 (DivType t1 t2))),
 Show t1, Show (DivType Integer (DivType Integer t1)),
 Show (DivType t1 t2), Show (DivType t1 t1), Show t2,
 Show (MulType t1 (DivType t1 t2)),
 CanMulAsymmetric t1 (DivType t1 t2), ConvertibleExactly Integer t2,
 ConvertibleExactly Integer t1) =>
T t1 -> T t2 -> Spec
specCanDiv T MPBall
tMPBall T Rational
tRational
    String -> Spec -> Spec
forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe String
"elementary" (Spec -> Spec) -> Spec -> Spec
forall a b. (a -> b) -> a -> b
$ do
      T MPBall -> Spec
forall t.
(CanSub t t, CanSub t Integer, CanSub Integer t, Arbitrary t,
 CanAddAsymmetric t t, CanAddAsymmetric t Integer,
 CanAddAsymmetric Integer t, CanAbs t, CanDivIMod t t,
 HasOrderAsymmetric t t, HasOrderAsymmetric (ExpType t) Integer,
 CanExp t, CanExp (NegType t), CanDiv t Integer,
 CanDiv Integer (ExpType t),
 HasEqAsymmetric
   (ExpType (NegType t)) (DivType Integer (ExpType t)),
 HasEqAsymmetric (ExpType t) (MulType (ExpType t) (ExpType t)),
 CanTestCertainly (OrderCompareType t t),
 CanTestCertainly (OrderCompareType (ExpType t) Integer),
 CanTestCertainly
   (EqCompareType
      (ExpType (NegType t)) (DivType Integer (ExpType t))),
 CanTestCertainly
   (EqCompareType (ExpType t) (MulType (ExpType t) (ExpType t))),
 Show t, Show (ExpType t), Show (ExpType (NegType t)),
 Show (DivType Integer (ExpType t)),
 Show (MulType (ExpType t) (ExpType t)), CanMulAsymmetric t Integer,
 CanMulAsymmetric (ExpType t) (ExpType t),
 CanMulAsymmetric Integer t, ConvertibleExactly Integer t, CanNeg t,
 SubType Integer t ~ t, SubType t t ~ t, DivType t Integer ~ t,
 AddType t t ~ t, AbsType t ~ t, SubType t Integer ~ t,
 DivIType t t ~ Integer, MulType t Integer ~ t,
 MulType t Integer ~ MulType Integer t, AddType t Integer ~ t,
 AddType t Integer ~ AddType Integer t, ModType t t ~ t) =>
T t -> Spec
specCanExpReal T MPBall
tMPBall
      T MPBall -> Spec
forall t.
(CanSub t t, CanSub t Integer, CanSub Integer t, Arbitrary t,
 CanAbs t, CanDivIMod t t, CanDiv t Integer, CanDiv Integer t,
 CanMulAsymmetric t t, CanMulAsymmetric t Integer,
 CanMulAsymmetric Integer t, CanAddAsymmetric t t,
 CanAddAsymmetric t Integer,
 CanAddAsymmetric (LogType t) (LogType t),
 CanAddAsymmetric Integer t, CanExp t, HasOrderAsymmetric t t,
 HasOrderAsymmetric t Integer,
 HasOrderAsymmetric (DivType Integer t) Integer,
 HasOrderAsymmetric (MulType t t) Integer,
 HasOrderAsymmetric (ExpType t) Integer,
 HasEqAsymmetric
   (LogType (DivType Integer t)) (NegType (LogType t)),
 HasEqAsymmetric
   (LogType (MulType t t)) (AddType (LogType t) (LogType t)),
 HasEqAsymmetric (LogType (ExpType t)) t,
 CanTestCertainly (OrderCompareType t t),
 CanTestCertainly (OrderCompareType t Integer),
 CanTestCertainly (OrderCompareType (DivType Integer t) Integer),
 CanTestCertainly
   (EqCompareType
      (LogType (DivType Integer t)) (NegType (LogType t))),
 CanTestCertainly (OrderCompareType (MulType t t) Integer),
 CanTestCertainly
   (EqCompareType
      (LogType (MulType t t)) (AddType (LogType t) (LogType t))),
 CanTestCertainly (OrderCompareType (ExpType t) Integer),
 CanTestCertainly (EqCompareType (LogType (ExpType t)) t), Show t,
 Show (LogType (DivType Integer t)), Show (NegType (LogType t)),
 Show (LogType (MulType t t)),
 Show (AddType (LogType t) (LogType t)), Show (LogType (ExpType t)),
 CanLog (DivType Integer t), CanLog t, CanLog (MulType t t),
 CanLog (ExpType t), ConvertibleExactly Integer t,
 CanNeg (LogType t), AddType t t ~ t, SubType Integer t ~ t,
 SubType t t ~ t, DivType t Integer ~ t, AddType t Integer ~ t,
 AddType t Integer ~ AddType Integer t, AbsType t ~ t,
 DivIType t t ~ Integer, MulType t Integer ~ t,
 MulType t Integer ~ MulType Integer t, SubType t Integer ~ t,
 ModType t t ~ t) =>
T t -> Spec
specCanLogReal T MPBall
tMPBall
      T MPBall -> Spec
forall t.
(Arbitrary t, CanTestPosNeg t,
 HasOrderAsymmetric (SqrtType t) Integer, CanSqrt t,
 HasEqAsymmetric (PowType (SqrtType t) Integer) t,
 CanTestCertainly (OrderCompareType (SqrtType t) Integer),
 CanTestCertainly (EqCompareType (PowType (SqrtType t) Integer) t),
 Show t, Show (SqrtType t), Show (PowType (SqrtType t) Integer),
 CanPow (SqrtType t) Integer) =>
T t -> Spec
specCanSqrtReal T MPBall
tMPBall
      T MPBall -> Spec
forall t.
(Arbitrary t, CanPow (SinCosType t) Integer, CanSinCos t,
 CanSinCos (SubType t t), CanSub t t,
 CanSub
   (MulType (SinCosType t) (SinCosType t))
   (MulType (SinCosType t) (SinCosType t)),
 CanMulAsymmetric (SinCosType t) (SinCosType t),
 HasEqAsymmetric
   (AddType
      (PowType (SinCosType t) Integer) (PowType (SinCosType t) Integer))
   Integer,
 HasEqAsymmetric
   (SinCosType (SubType t t))
   (SubType
      (MulType (SinCosType t) (SinCosType t))
      (MulType (SinCosType t) (SinCosType t))),
 HasEqAsymmetric
   (SinCosType (SubType t t))
   (AddType
      (MulType (SinCosType t) (SinCosType t))
      (MulType (SinCosType t) (SinCosType t))),
 CanAddAsymmetric
   (PowType (SinCosType t) Integer) (PowType (SinCosType t) Integer),
 CanAddAsymmetric
   (MulType (SinCosType t) (SinCosType t))
   (MulType (SinCosType t) (SinCosType t)),
 HasOrderAsymmetric (SinCosType t) t,
 HasOrderAsymmetric (SinCosType t) Integer,
 HasOrderAsymmetric t (DivType (SinCosType t) (SinCosType t)),
 HasOrderAsymmetric t Rational, HasOrderAsymmetric t Integer,
 HasOrderAsymmetric Integer (SinCosType t),
 CanTestCertainly (OrderCompareType Integer (SinCosType t)),
 CanTestCertainly (OrderCompareType (SinCosType t) Integer),
 CanTestCertainly
   (EqCompareType
      (AddType
         (PowType (SinCosType t) Integer) (PowType (SinCosType t) Integer))
      Integer),
 CanTestCertainly
   (EqCompareType
      (SinCosType (SubType t t))
      (SubType
         (MulType (SinCosType t) (SinCosType t))
         (MulType (SinCosType t) (SinCosType t)))),
 CanTestCertainly
   (EqCompareType
      (SinCosType (SubType t t))
      (AddType
         (MulType (SinCosType t) (SinCosType t))
         (MulType (SinCosType t) (SinCosType t)))),
 CanTestCertainly (OrderCompareType t Integer),
 CanTestCertainly (OrderCompareType t Rational),
 CanTestCertainly (OrderCompareType (SinCosType t) t),
 CanTestCertainly
   (OrderCompareType t (DivType (SinCosType t) (SinCosType t))),
 Show t, Show (SinCosType t),
 Show
   (AddType
      (PowType (SinCosType t) Integer) (PowType (SinCosType t) Integer)),
 Show (SinCosType (SubType t t)),
 Show
   (SubType
      (MulType (SinCosType t) (SinCosType t))
      (MulType (SinCosType t) (SinCosType t))),
 Show
   (AddType
      (MulType (SinCosType t) (SinCosType t))
      (MulType (SinCosType t) (SinCosType t))),
 Show (DivType (SinCosType t) (SinCosType t)),
 CanDiv (SinCosType t) (SinCosType t)) =>
T t -> Spec
specCanSinCosReal T MPBall
tMPBall