{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveLift #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskellQuotes #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ViewPatterns #-}

-- |
-- Module      :   Grisette.Internal.SymPrim.Prim.Internal.Term
-- Copyright   :   (c) Sirui Lu 2021-2024
-- License     :   BSD-3-Clause (see the LICENSE file)
--
-- Maintainer  :   siruilu@cs.washington.edu
-- Stability   :   Experimental
-- Portability :   GHC only
module Grisette.Internal.SymPrim.Prim.Internal.Term
  ( -- * Supported primitive types
    SupportedPrimConstraint (..),
    SupportedPrim (..),
    SymRep (..),
    ConRep (..),
    LinkedRep (..),

    -- * Partial evaluation for the terms
    UnaryOp (..),
    BinaryOp (..),
    TernaryOp (..),
    PEvalApplyTerm (..),
    PEvalBitwiseTerm (..),
    PEvalShiftTerm (..),
    PEvalRotateTerm (..),
    PEvalNumTerm (..),
    pevalSubNumTerm,
    PEvalOrdTerm (..),
    pevalGtOrdTerm,
    pevalGeOrdTerm,
    pevalNEqTerm,
    PEvalDivModIntegralTerm (..),
    PEvalBitCastTerm (..),
    PEvalBitCastOrTerm (..),
    PEvalBVTerm (..),
    PEvalFractionalTerm (..),
    PEvalFloatingTerm (..),
    PEvalFromIntegralTerm (..),
    PEvalIEEEFPConvertibleTerm (..),

    -- * Typed symbols
    SymbolKind (..),
    TypedSymbol (..),
    TypedConstantSymbol,
    TypedAnySymbol,
    SomeTypedSymbol (..),
    SomeTypedConstantSymbol,
    SomeTypedAnySymbol,
    IsSymbolKind (..),
    showUntyped,
    withSymbolSupported,
    someTypedSymbol,
    eqHeteroSymbol,
    castSomeTypedSymbol,
    withSymbolKind,

    -- * Terms
    FPTrait (..),
    FPUnaryOp (..),
    FPBinaryOp (..),
    FPRoundingUnaryOp (..),
    FPRoundingBinaryOp (..),
    FloatingUnaryOp (..),
    Term (..),
    identity,
    identityWithTypeRep,
    introSupportedPrimConstraint,
    pformatTerm,

    -- * Interning
    UTerm (..),
    prettyPrintTerm,
    forallTerm,
    existsTerm,
    constructUnary,
    constructBinary,
    constructTernary,
    conTerm,
    symTerm,
    ssymTerm,
    isymTerm,
    notTerm,
    orTerm,
    andTerm,
    eqTerm,
    distinctTerm,
    iteTerm,
    addNumTerm,
    negNumTerm,
    mulNumTerm,
    absNumTerm,
    signumNumTerm,
    ltOrdTerm,
    leOrdTerm,
    andBitsTerm,
    orBitsTerm,
    xorBitsTerm,
    complementBitsTerm,
    shiftLeftTerm,
    shiftRightTerm,
    rotateLeftTerm,
    rotateRightTerm,
    bitCastTerm,
    bitCastOrTerm,
    bvconcatTerm,
    bvselectTerm,
    bvextendTerm,
    bvsignExtendTerm,
    bvzeroExtendTerm,
    applyTerm,
    divIntegralTerm,
    modIntegralTerm,
    quotIntegralTerm,
    remIntegralTerm,
    fpTraitTerm,
    fdivTerm,
    recipTerm,
    floatingUnaryTerm,
    powerTerm,
    fpUnaryTerm,
    fpBinaryTerm,
    fpRoundingUnaryTerm,
    fpRoundingBinaryTerm,
    fpFMATerm,
    fromIntegralTerm,
    fromFPOrTerm,
    toFPTerm,

    -- * Support for boolean type
    trueTerm,
    falseTerm,
    pattern BoolConTerm,
    pattern TrueTerm,
    pattern FalseTerm,
    pattern BoolTerm,
    pevalNotTerm,
    pevalOrTerm,
    pevalAndTerm,
    pevalImplyTerm,
    pevalXorTerm,
    pevalITEBasic,
    pevalITEBasicTerm,
    pevalDefaultEqTerm,
    NonFuncPrimConstraint,
    NonFuncSBVRep (..),
    SupportedNonFuncPrim (..),
    SBVRep (..),
    SBVFreshMonad (..),
    translateTypeError,
    parseSMTModelResultError,
    partitionCVArg,
    parseScalarSMTModelResult,
  )
where

#if MIN_VERSION_prettyprinter(1,7,0)
import Prettyprinter
  ( column,
    pageWidth,
    Doc,
    PageWidth(Unbounded, AvailablePerLine),
    Pretty(pretty),
  )
#else
import Data.Text.Prettyprint.Doc
  ( column,
    pageWidth,
    Doc,
    PageWidth(Unbounded, AvailablePerLine),
    Pretty(pretty),
  )
#endif

#if !MIN_VERSION_sbv(10, 0, 0)
#define SMTDefinable Uninterpreted
#endif

import Control.DeepSeq (NFData (rnf))
import Control.Monad (msum)
import Control.Monad.IO.Class (MonadIO)
import Control.Monad.RWS (RWST)
import Control.Monad.Reader (MonadTrans (lift), ReaderT)
import Control.Monad.State (StateT)
import Control.Monad.Trans.Writer (WriterT)
import Data.Array ((!))
import Data.Bits (Bits)
import Data.Function (on)
import qualified Data.HashMap.Strict as M
import Data.Hashable (Hashable (hash, hashWithSalt))
import Data.IORef (atomicModifyIORef')
import Data.Interned
  ( Cache,
    Id,
    Interned (Description, Uninterned, cache, cacheWidth, describe, identify),
  )
import Data.Interned.Internal
  ( Cache (getCache),
    CacheState (CacheState),
  )
import Data.Kind (Constraint, Type)
import Data.List.NonEmpty (NonEmpty ((:|)), toList)
import Data.Maybe (fromMaybe)
import qualified Data.SBV as SBV
import qualified Data.SBV.Dynamic as SBVD
import qualified Data.SBV.Trans as SBVT
import qualified Data.SBV.Trans.Control as SBVTC
import Data.String (IsString (fromString))
import Data.Typeable (Proxy (Proxy), cast)
import GHC.Exts (sortWith)
import GHC.Generics (Generic)
import GHC.IO (unsafeDupablePerformIO)
import GHC.Stack (HasCallStack)
import GHC.TypeNats (KnownNat, Nat, type (+), type (<=))
import Grisette.Internal.Core.Data.Class.BitCast (BitCast, BitCastOr)
import Grisette.Internal.Core.Data.Class.BitVector
  ( SizedBV,
  )
import Grisette.Internal.Core.Data.Class.SymRotate (SymRotate)
import Grisette.Internal.Core.Data.Class.SymShift (SymShift)
import Grisette.Internal.Core.Data.Symbol
  ( Identifier,
    Symbol (IndexedSymbol, SimpleSymbol),
  )
import Grisette.Internal.SymPrim.FP (FP, FPRoundingMode, ValidFP)
import Grisette.Internal.SymPrim.Prim.Internal.Caches
  ( typeMemoizedCache,
  )
import Grisette.Internal.SymPrim.Prim.Internal.Utils
  ( eqHeteroRep,
    eqTypeRepBool,
    pattern Dyn,
  )
import Grisette.Internal.SymPrim.Prim.ModelValue
  ( ModelValue,
    toModelValue,
  )
import Language.Haskell.TH.Syntax (Lift (liftTyped))
import Type.Reflection
  ( SomeTypeRep (SomeTypeRep),
    TypeRep,
    Typeable,
    eqTypeRep,
    someTypeRep,
    typeRep,
    type (:~~:) (HRefl),
  )
import Unsafe.Coerce (unsafeCoerce)

-- $setup
-- >>> import Grisette.Core
-- >>> import Grisette.SymPrim

-- | Monads that supports generating sbv fresh variables.
class (Monad m) => SBVFreshMonad m where
  sbvFresh :: (SBV.SymVal a) => String -> m (SBV.SBV a)

instance (MonadIO m) => SBVFreshMonad (SBVT.SymbolicT m) where
  sbvFresh :: forall a. SymVal a => String -> SymbolicT m (SBV a)
sbvFresh = String -> SymbolicT m (SBV a)
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
forall (m :: * -> *). MonadSymbolic m => String -> m (SBV a)
SBVT.free

instance (MonadIO m) => SBVFreshMonad (SBVTC.QueryT m) where
  sbvFresh :: forall a. SymVal a => String -> QueryT m (SBV a)
sbvFresh = String -> QueryT m (SBV a)
forall a (m :: * -> *).
(MonadIO m, MonadQuery m, SymVal a) =>
String -> m (SBV a)
SBVTC.freshVar

instance (SBVFreshMonad m) => SBVFreshMonad (ReaderT r m) where
  sbvFresh :: forall a. SymVal a => String -> ReaderT r m (SBV a)
sbvFresh = m (SBV a) -> ReaderT r m (SBV a)
forall (m :: * -> *) a. Monad m => m a -> ReaderT r m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (SBV a) -> ReaderT r m (SBV a))
-> (String -> m (SBV a)) -> String -> ReaderT r m (SBV a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> m (SBV a)
forall a. SymVal a => String -> m (SBV a)
forall (m :: * -> *) a.
(SBVFreshMonad m, SymVal a) =>
String -> m (SBV a)
sbvFresh

instance (SBVFreshMonad m, Monoid w) => SBVFreshMonad (WriterT w m) where
  sbvFresh :: forall a. SymVal a => String -> WriterT w m (SBV a)
sbvFresh = m (SBV a) -> WriterT w m (SBV a)
forall (m :: * -> *) a. Monad m => m a -> WriterT w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (SBV a) -> WriterT w m (SBV a))
-> (String -> m (SBV a)) -> String -> WriterT w m (SBV a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> m (SBV a)
forall a. SymVal a => String -> m (SBV a)
forall (m :: * -> *) a.
(SBVFreshMonad m, SymVal a) =>
String -> m (SBV a)
sbvFresh

instance (SBVFreshMonad m, Monoid w) => SBVFreshMonad (RWST r w s m) where
  sbvFresh :: forall a. SymVal a => String -> RWST r w s m (SBV a)
sbvFresh = m (SBV a) -> RWST r w s m (SBV a)
forall (m :: * -> *) a. Monad m => m a -> RWST r w s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (SBV a) -> RWST r w s m (SBV a))
-> (String -> m (SBV a)) -> String -> RWST r w s m (SBV a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> m (SBV a)
forall a. SymVal a => String -> m (SBV a)
forall (m :: * -> *) a.
(SBVFreshMonad m, SymVal a) =>
String -> m (SBV a)
sbvFresh

instance (SBVFreshMonad m) => SBVFreshMonad (StateT s m) where
  sbvFresh :: forall a. SymVal a => String -> StateT s m (SBV a)
sbvFresh = m (SBV a) -> StateT s m (SBV a)
forall (m :: * -> *) a. Monad m => m a -> StateT s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (SBV a) -> StateT s m (SBV a))
-> (String -> m (SBV a)) -> String -> StateT s m (SBV a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> m (SBV a)
forall a. SymVal a => String -> m (SBV a)
forall (m :: * -> *) a.
(SBVFreshMonad m, SymVal a) =>
String -> m (SBV a)
sbvFresh

-- | Error message for unsupported types.
translateTypeError :: (HasCallStack) => Maybe String -> TypeRep a -> b
translateTypeError :: forall a b. HasCallStack => Maybe String -> TypeRep a -> b
translateTypeError Maybe String
Nothing TypeRep a
ta =
  String -> b
forall a. HasCallStack => String -> a
error (String -> b) -> String -> b
forall a b. (a -> b) -> a -> b
$
    String
"Don't know how to translate the type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep a -> String
forall a. Show a => a -> String
show TypeRep a
ta String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" to SMT"
translateTypeError (Just String
reason) TypeRep a
ta =
  String -> b
forall a. HasCallStack => String -> a
error (String -> b) -> String -> b
forall a b. (a -> b) -> a -> b
$
    String
"Don't know how to translate the type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep a -> String
forall a. Show a => a -> String
show TypeRep a
ta String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" to SMT: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
reason

-- | Type class for resolving the base type for the SBV type for the primitive
-- type.
class (SupportedPrim a, Ord a) => NonFuncSBVRep a where
  type NonFuncSBVBaseType a

-- | Type class for resolving the constraint for a supported non-function
-- primitive type.
type NonFuncPrimConstraint a =
  ( SBV.SymVal (NonFuncSBVBaseType a),
    SBV.EqSymbolic (SBVType a),
    SBV.Mergeable (SBVType a),
    SBV.SMTDefinable (SBVType a),
    SBV.Mergeable (SBVType a),
    SBVType a ~ SBV.SBV (NonFuncSBVBaseType a),
    PrimConstraint a
  )

-- | Indicates that a type is supported, can be represented as a symbolic term,
-- is not a function type, and can be lowered to an SBV term.
class (NonFuncSBVRep a) => SupportedNonFuncPrim a where
  conNonFuncSBVTerm :: a -> SBV.SBV (NonFuncSBVBaseType a)
  symNonFuncSBVTerm ::
    (SBVFreshMonad m) => String -> m (SBV.SBV (NonFuncSBVBaseType a))
  withNonFuncPrim :: ((NonFuncPrimConstraint a) => r) -> r

-- | Partition the list of CVs for models for functions.
partitionCVArg ::
  forall a.
  (SupportedNonFuncPrim a) =>
  [([SBVD.CV], SBVD.CV)] ->
  [(a, [([SBVD.CV], SBVD.CV)])]
partitionCVArg :: forall a.
SupportedNonFuncPrim a =>
[([CV], CV)] -> [(a, [([CV], CV)])]
partitionCVArg [([CV], CV)]
cv =
  [(a, [([CV], CV)])] -> [(a, [([CV], CV)])]
forall a.
SupportedNonFuncPrim a =>
[(a, [([CV], CV)])] -> [(a, [([CV], CV)])]
partitionOrdCVArg ([(a, [([CV], CV)])] -> [(a, [([CV], CV)])])
-> [(a, [([CV], CV)])] -> [(a, [([CV], CV)])]
forall a b. (a -> b) -> a -> b
$
    [([CV], CV)] -> [(a, [([CV], CV)])]
forall a.
SupportedNonFuncPrim a =>
[([CV], CV)] -> [(a, [([CV], CV)])]
parseFirstCVArg [([CV], CV)]
cv
  where
    parseFirstCVArg ::
      forall a.
      (SupportedNonFuncPrim a) =>
      [([SBVD.CV], SBVD.CV)] ->
      [(a, [([SBVD.CV], SBVD.CV)])]
    parseFirstCVArg :: forall a.
SupportedNonFuncPrim a =>
[([CV], CV)] -> [(a, [([CV], CV)])]
parseFirstCVArg =
      (([CV], CV) -> (a, [([CV], CV)]))
-> [([CV], CV)] -> [(a, [([CV], CV)])]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
        ( \case
            (CV
x : [CV]
xs, CV
v) ->
              (Int -> ([([CV], CV)], CV) -> a
forall t. SupportedPrim t => Int -> ([([CV], CV)], CV) -> t
parseSMTModelResult Int
0 ([], CV
x), [([CV]
xs, CV
v)])
            ([CV], CV)
_ -> String -> (a, [([CV], CV)])
forall a. HasCallStack => String -> a
error String
"impossible"
        )
    partitionOrdCVArg ::
      forall a.
      (SupportedNonFuncPrim a) =>
      [(a, [([SBVD.CV], SBVD.CV)])] ->
      [(a, [([SBVD.CV], SBVD.CV)])]
    partitionOrdCVArg :: forall a.
SupportedNonFuncPrim a =>
[(a, [([CV], CV)])] -> [(a, [([CV], CV)])]
partitionOrdCVArg [(a, [([CV], CV)])]
v = [(a, [([CV], CV)])] -> [(a, [([CV], CV)])]
forall {a} {a}. Eq a => [(a, [a])] -> [(a, [a])]
go [(a, [([CV], CV)])]
sorted
      where
        sorted :: [(a, [([CV], CV)])]
sorted = ((a, [([CV], CV)]) -> a)
-> [(a, [([CV], CV)])] -> [(a, [([CV], CV)])]
forall b a. Ord b => (a -> b) -> [a] -> [a]
sortWith (a, [([CV], CV)]) -> a
forall a b. (a, b) -> a
fst [(a, [([CV], CV)])]
v :: [(a, [([SBVD.CV], SBVD.CV)])]
        go :: [(a, [a])] -> [(a, [a])]
go ((a, [a])
x : (a, [a])
x1 : [(a, [a])]
xs) =
          if (a, [a]) -> a
forall a b. (a, b) -> a
fst (a, [a])
x a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== (a, [a]) -> a
forall a b. (a, b) -> a
fst (a, [a])
x1
            then [(a, [a])] -> [(a, [a])]
go ([(a, [a])] -> [(a, [a])]) -> [(a, [a])] -> [(a, [a])]
forall a b. (a -> b) -> a -> b
$ ((a, [a]) -> a
forall a b. (a, b) -> a
fst (a, [a])
x, (a, [a]) -> [a]
forall a b. (a, b) -> b
snd (a, [a])
x [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ (a, [a]) -> [a]
forall a b. (a, b) -> b
snd (a, [a])
x1) (a, [a]) -> [(a, [a])] -> [(a, [a])]
forall a. a -> [a] -> [a]
: [(a, [a])]
xs
            else (a, [a])
x (a, [a]) -> [(a, [a])] -> [(a, [a])]
forall a. a -> [a] -> [a]
: [(a, [a])] -> [(a, [a])]
go ((a, [a])
x1 (a, [a]) -> [(a, [a])] -> [(a, [a])]
forall a. a -> [a] -> [a]
: [(a, [a])]
xs)
        go [(a, [a])]
x = [(a, [a])]
x

-- | Parse the scalar model result.
parseScalarSMTModelResult ::
  forall v r.
  (SBV.SatModel r, Typeable v) =>
  (r -> v) ->
  ([([SBVD.CV], SBVD.CV)], SBVD.CV) ->
  v
parseScalarSMTModelResult :: forall v r.
(SatModel r, Typeable v) =>
(r -> v) -> ([([CV], CV)], CV) -> v
parseScalarSMTModelResult r -> v
convert cvs :: ([([CV], CV)], CV)
cvs@([], CV
v) = case [CV] -> Maybe (r, [CV])
forall a. SatModel a => [CV] -> Maybe (a, [CV])
SBV.parseCVs [CV
v] of
  Just (r
x, [CV]
_) -> r -> v
convert r
x
  Maybe (r, [CV])
Nothing -> TypeRep v -> ([([CV], CV)], CV) -> v
forall a. HasCallStack => TypeRep a -> ([([CV], CV)], CV) -> a
parseSMTModelResultError (forall a. Typeable a => TypeRep a
forall {k} (a :: k). Typeable a => TypeRep a
typeRep @v) ([([CV], CV)], CV)
cvs
parseScalarSMTModelResult r -> v
_ ([([CV], CV)], CV)
cv = TypeRep v -> ([([CV], CV)], CV) -> v
forall a. HasCallStack => TypeRep a -> ([([CV], CV)], CV) -> a
parseSMTModelResultError (forall a. Typeable a => TypeRep a
forall {k} (a :: k). Typeable a => TypeRep a
typeRep @v) ([([CV], CV)], CV)
cv

-- | Type class for resolving the SBV type for the primitive type.
class SBVRep t where
  type SBVType t

-- | Type class for resolving the constraint for a supported primitive type.
class SupportedPrimConstraint t where
  type PrimConstraint t :: Constraint
  type PrimConstraint _ = ()

-- | Indicates that a type is supported, can be represented as a symbolic term,
-- and can be lowered to an SBV term.
class
  ( Lift t,
    Typeable t,
    Hashable t,
    Eq t,
    Show t,
    NFData t,
    SupportedPrimConstraint t,
    SBVRep t
  ) =>
  SupportedPrim t
  where
  termCache :: Cache (Term t)
  termCache = Cache (Term t)
forall a. (Interned a, Typeable a) => Cache a
typeMemoizedCache
  pformatCon :: t -> String
  default pformatCon :: (Show t) => t -> String
  pformatCon = t -> String
forall a. Show a => a -> String
show
  pformatSym :: TypedSymbol 'AnyKind t -> String
  pformatSym = TypedSymbol 'AnyKind t -> String
forall (knd :: SymbolKind) t. TypedSymbol knd t -> String
showUntyped
  defaultValue :: t
  defaultValueDynamic :: proxy t -> ModelValue
  defaultValueDynamic proxy t
_ = t -> ModelValue
forall a. (Show a, Eq a, Hashable a, Typeable a) => a -> ModelValue
toModelValue (forall t. SupportedPrim t => t
defaultValue @t)
  pevalITETerm :: Term Bool -> Term t -> Term t -> Term t
  pevalEqTerm :: Term t -> Term t -> Term Bool
  pevalDistinctTerm :: NonEmpty (Term t) -> Term Bool
  conSBVTerm :: t -> SBVType t
  symSBVName :: TypedSymbol 'AnyKind t -> Int -> String
  symSBVTerm :: (SBVFreshMonad m) => String -> m (SBVType t)
  default withPrim ::
    ( PrimConstraint t,
      SBV.SMTDefinable (SBVType t),
      SBV.Mergeable (SBVType t),
      Typeable (SBVType t)
    ) =>
    ( ( PrimConstraint t,
        SBV.SMTDefinable (SBVType t),
        SBV.Mergeable (SBVType t),
        Typeable (SBVType t)
      ) =>
      a
    ) ->
    a
  withPrim ::
    ( ( PrimConstraint t,
        SBV.SMTDefinable (SBVType t),
        SBV.Mergeable (SBVType t),
        Typeable (SBVType t)
      ) =>
      a
    ) ->
    a
  withPrim (PrimConstraint t, SMTDefinable (SBVType t), Mergeable (SBVType t),
 Typeable (SBVType t)) =>
a
i = a
(PrimConstraint t, SMTDefinable (SBVType t), Mergeable (SBVType t),
 Typeable (SBVType t)) =>
a
i
  sbvIte :: SBV.SBV Bool -> SBVType t -> SBVType t -> SBVType t
  sbvIte = forall t a.
SupportedPrim t =>
((PrimConstraint t, SMTDefinable (SBVType t),
  Mergeable (SBVType t), Typeable (SBVType t)) =>
 a)
-> a
withPrim @t SBV Bool -> SBVType t -> SBVType t -> SBVType t
(PrimConstraint t, SMTDefinable (SBVType t), Mergeable (SBVType t),
 Typeable (SBVType t)) =>
SBV Bool -> SBVType t -> SBVType t -> SBVType t
forall a. Mergeable a => SBV Bool -> a -> a -> a
SBV.ite
  sbvEq :: SBVType t -> SBVType t -> SBV.SBV Bool
  default sbvEq ::
    (SBVT.EqSymbolic (SBVType t)) => SBVType t -> SBVType t -> SBV.SBV Bool
  sbvEq = SBVType t -> SBVType t -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
(SBV..==)
  sbvDistinct :: NonEmpty (SBVType t) -> SBV.SBV Bool
  default sbvDistinct ::
    (SBVT.EqSymbolic (SBVType t)) => NonEmpty (SBVType t) -> SBV.SBV Bool
  sbvDistinct = [SBVType t] -> SBV Bool
forall a. EqSymbolic a => [a] -> SBV Bool
SBV.distinct ([SBVType t] -> SBV Bool)
-> (NonEmpty (SBVType t) -> [SBVType t])
-> NonEmpty (SBVType t)
-> SBV Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonEmpty (SBVType t) -> [SBVType t]
forall a. NonEmpty a -> [a]
toList
  parseSMTModelResult :: Int -> ([([SBVD.CV], SBVD.CV)], SBVD.CV) -> t
  castTypedSymbol ::
    (IsSymbolKind knd') => TypedSymbol knd t -> Maybe (TypedSymbol knd' t)
  isFuncType :: Bool
  funcDummyConstraint :: SBVType t -> SBV.SBV Bool

-- | Cast a typed symbol to a different kind. Check if the kind is compatible.
castSomeTypedSymbol ::
  (IsSymbolKind knd') => SomeTypedSymbol knd -> Maybe (SomeTypedSymbol knd')
castSomeTypedSymbol :: forall (knd' :: SymbolKind) (knd :: SymbolKind).
IsSymbolKind knd' =>
SomeTypedSymbol knd -> Maybe (SomeTypedSymbol knd')
castSomeTypedSymbol (SomeTypedSymbol TypeRep t
ty s :: TypedSymbol knd t
s@TypedSymbol {}) =
  TypeRep t -> TypedSymbol knd' t -> SomeTypedSymbol knd'
forall (knd :: SymbolKind) a.
TypeRep a -> TypedSymbol knd a -> SomeTypedSymbol knd
SomeTypedSymbol TypeRep t
ty (TypedSymbol knd' t -> SomeTypedSymbol knd')
-> Maybe (TypedSymbol knd' t) -> Maybe (SomeTypedSymbol knd')
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TypedSymbol knd t -> Maybe (TypedSymbol knd' t)
forall t (knd' :: SymbolKind) (knd :: SymbolKind).
(SupportedPrim t, IsSymbolKind knd') =>
TypedSymbol knd t -> Maybe (TypedSymbol knd' t)
forall (knd' :: SymbolKind) (knd :: SymbolKind).
IsSymbolKind knd' =>
TypedSymbol knd t -> Maybe (TypedSymbol knd' t)
castTypedSymbol TypedSymbol knd t
s

-- | Error message for failure to parse the SBV model result.
parseSMTModelResultError ::
  (HasCallStack) => TypeRep a -> ([([SBVD.CV], SBVD.CV)], SBVD.CV) -> a
parseSMTModelResultError :: forall a. HasCallStack => TypeRep a -> ([([CV], CV)], CV) -> a
parseSMTModelResultError TypeRep a
ty ([([CV], CV)], CV)
cv =
  String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$
    String
"BUG: cannot parse SBV model value \""
      String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ([([CV], CV)], CV) -> String
forall a. Show a => a -> String
show ([([CV], CV)], CV)
cv
      String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"\" to Grisette model value with the type "
      String -> String -> String
forall a. Semigroup a => a -> a -> a
<> TypeRep a -> String
forall a. Show a => a -> String
show TypeRep a
ty

-- | Partial evaluation for inequality terms.
pevalNEqTerm :: (SupportedPrim a) => Term a -> Term a -> Term Bool
pevalNEqTerm :: forall a. SupportedPrim a => Term a -> Term a -> Term Bool
pevalNEqTerm Term a
l Term a
r = Term Bool -> Term Bool
pevalNotTerm (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term a -> Term a -> Term Bool
forall a. SupportedPrim a => Term a -> Term a -> Term Bool
pevalEqTerm Term a
l Term a
r
{-# INLINE pevalNEqTerm #-}

-- | Type family to resolve the concrete type associated with a symbolic type.
class ConRep sym where
  type ConType sym

-- | Type family to resolve the symbolic type associated with a concrete type.
class (SupportedPrim con) => SymRep con where
  type SymType con

-- | One-to-one mapping between symbolic types and concrete types.
class
  (ConRep sym, SymRep con, sym ~ SymType con, con ~ ConType sym) =>
  LinkedRep con sym
    | con -> sym,
      sym -> con
  where
  underlyingTerm :: sym -> Term con
  wrapTerm :: Term con -> sym

-- | Partial evaluation and lowering for function application terms.
class
  (SupportedPrim f, SupportedPrim a, SupportedPrim b) =>
  PEvalApplyTerm f a b
    | f -> a b
  where
  pevalApplyTerm :: Term f -> Term a -> Term b
  sbvApplyTerm :: SBVType f -> SBVType a -> SBVType b

-- | Partial evaluation and lowering for bitwise operation terms.
class (SupportedNonFuncPrim t, Bits t) => PEvalBitwiseTerm t where
  pevalAndBitsTerm :: Term t -> Term t -> Term t
  pevalOrBitsTerm :: Term t -> Term t -> Term t
  pevalXorBitsTerm :: Term t -> Term t -> Term t
  pevalComplementBitsTerm :: Term t -> Term t
  withSbvBitwiseTermConstraint :: (((Bits (SBVType t)) => r)) -> r
  sbvAndBitsTerm :: SBVType t -> SBVType t -> SBVType t
  sbvAndBitsTerm = forall t r. PEvalBitwiseTerm t => (Bits (SBVType t) => r) -> r
withSbvBitwiseTermConstraint @t Bits (SBVType t) => SBVType t -> SBVType t -> SBVType t
SBVType t -> SBVType t -> SBVType t
forall a. Bits a => a -> a -> a
(SBV..&.)
  sbvOrBitsTerm :: SBVType t -> SBVType t -> SBVType t
  sbvOrBitsTerm = forall t r. PEvalBitwiseTerm t => (Bits (SBVType t) => r) -> r
withSbvBitwiseTermConstraint @t Bits (SBVType t) => SBVType t -> SBVType t -> SBVType t
SBVType t -> SBVType t -> SBVType t
forall a. Bits a => a -> a -> a
(SBV..|.)
  sbvXorBitsTerm :: SBVType t -> SBVType t -> SBVType t
  sbvXorBitsTerm = forall t r. PEvalBitwiseTerm t => (Bits (SBVType t) => r) -> r
withSbvBitwiseTermConstraint @t Bits (SBVType t) => SBVType t -> SBVType t -> SBVType t
SBVType t -> SBVType t -> SBVType t
forall a. Bits a => a -> a -> a
SBV.xor
  sbvComplementBitsTerm :: SBVType t -> SBVType t
  sbvComplementBitsTerm = forall t r. PEvalBitwiseTerm t => (Bits (SBVType t) => r) -> r
withSbvBitwiseTermConstraint @t Bits (SBVType t) => SBVType t -> SBVType t
SBVType t -> SBVType t
forall a. Bits a => a -> a
SBV.complement

-- | Partial evaluation and lowering for symbolic shifting terms.
class (SupportedNonFuncPrim t, SymShift t) => PEvalShiftTerm t where
  pevalShiftLeftTerm :: Term t -> Term t -> Term t
  pevalShiftRightTerm :: Term t -> Term t -> Term t
  withSbvShiftTermConstraint ::
    (((SBV.SIntegral (NonFuncSBVBaseType t)) => r)) -> r
  sbvShiftLeftTerm :: SBVType t -> SBVType t -> SBVType t
  sbvShiftLeftTerm SBVType t
l SBVType t
r =
    forall a r.
SupportedNonFuncPrim a =>
(NonFuncPrimConstraint a => r) -> r
withNonFuncPrim @t ((NonFuncPrimConstraint t => SBVType t) -> SBVType t)
-> (NonFuncPrimConstraint t => SBVType t) -> SBVType t
forall a b. (a -> b) -> a -> b
$ forall t r.
PEvalShiftTerm t =>
(SIntegral (NonFuncSBVBaseType t) => r) -> r
withSbvShiftTermConstraint @t ((SIntegral (NonFuncSBVBaseType t) => SBVType t) -> SBVType t)
-> (SIntegral (NonFuncSBVBaseType t) => SBVType t) -> SBVType t
forall a b. (a -> b) -> a -> b
$ SBV (NonFuncSBVBaseType t)
-> SBV (NonFuncSBVBaseType t) -> SBV (NonFuncSBVBaseType t)
forall a b. (SIntegral a, SIntegral b) => SBV a -> SBV b -> SBV a
SBV.sShiftLeft SBV (NonFuncSBVBaseType t)
SBVType t
l SBV (NonFuncSBVBaseType t)
SBVType t
r
  sbvShiftRightTerm :: SBVType t -> SBVType t -> SBVType t
  sbvShiftRightTerm SBVType t
l SBVType t
r =
    forall a r.
SupportedNonFuncPrim a =>
(NonFuncPrimConstraint a => r) -> r
withNonFuncPrim @t ((NonFuncPrimConstraint t => SBVType t) -> SBVType t)
-> (NonFuncPrimConstraint t => SBVType t) -> SBVType t
forall a b. (a -> b) -> a -> b
$ forall t r.
PEvalShiftTerm t =>
(SIntegral (NonFuncSBVBaseType t) => r) -> r
withSbvShiftTermConstraint @t ((SIntegral (NonFuncSBVBaseType t) => SBVType t) -> SBVType t)
-> (SIntegral (NonFuncSBVBaseType t) => SBVType t) -> SBVType t
forall a b. (a -> b) -> a -> b
$ SBV (NonFuncSBVBaseType t)
-> SBV (NonFuncSBVBaseType t) -> SBV (NonFuncSBVBaseType t)
forall a b. (SIntegral a, SIntegral b) => SBV a -> SBV b -> SBV a
SBV.sShiftRight SBV (NonFuncSBVBaseType t)
SBVType t
l SBV (NonFuncSBVBaseType t)
SBVType t
r

-- | Partial evaluation and lowering for symbolic rotate terms.
class (SupportedNonFuncPrim t, SymRotate t) => PEvalRotateTerm t where
  pevalRotateLeftTerm :: Term t -> Term t -> Term t
  pevalRotateRightTerm :: Term t -> Term t -> Term t
  withSbvRotateTermConstraint ::
    (((SBV.SIntegral (NonFuncSBVBaseType t)) => r)) -> r
  sbvRotateLeftTerm :: SBVType t -> SBVType t -> SBVType t
  sbvRotateLeftTerm SBVType t
l SBVType t
r =
    forall a r.
SupportedNonFuncPrim a =>
(NonFuncPrimConstraint a => r) -> r
withNonFuncPrim @t ((NonFuncPrimConstraint t => SBVType t) -> SBVType t)
-> (NonFuncPrimConstraint t => SBVType t) -> SBVType t
forall a b. (a -> b) -> a -> b
$ forall t r.
PEvalRotateTerm t =>
(SIntegral (NonFuncSBVBaseType t) => r) -> r
withSbvRotateTermConstraint @t ((SIntegral (NonFuncSBVBaseType t) => SBVType t) -> SBVType t)
-> (SIntegral (NonFuncSBVBaseType t) => SBVType t) -> SBVType t
forall a b. (a -> b) -> a -> b
$ SBV (NonFuncSBVBaseType t)
-> SBV (NonFuncSBVBaseType t) -> SBV (NonFuncSBVBaseType t)
forall a b. (SIntegral a, SIntegral b) => SBV a -> SBV b -> SBV a
SBV.sRotateLeft SBV (NonFuncSBVBaseType t)
SBVType t
l SBV (NonFuncSBVBaseType t)
SBVType t
r
  sbvRotateRightTerm :: SBVType t -> SBVType t -> SBVType t
  sbvRotateRightTerm SBVType t
l SBVType t
r =
    forall a r.
SupportedNonFuncPrim a =>
(NonFuncPrimConstraint a => r) -> r
withNonFuncPrim @t ((NonFuncPrimConstraint t => SBVType t) -> SBVType t)
-> (NonFuncPrimConstraint t => SBVType t) -> SBVType t
forall a b. (a -> b) -> a -> b
$ forall t r.
PEvalRotateTerm t =>
(SIntegral (NonFuncSBVBaseType t) => r) -> r
withSbvRotateTermConstraint @t ((SIntegral (NonFuncSBVBaseType t) => SBVType t) -> SBVType t)
-> (SIntegral (NonFuncSBVBaseType t) => SBVType t) -> SBVType t
forall a b. (a -> b) -> a -> b
$ SBV (NonFuncSBVBaseType t)
-> SBV (NonFuncSBVBaseType t) -> SBV (NonFuncSBVBaseType t)
forall a b. (SIntegral a, SIntegral b) => SBV a -> SBV b -> SBV a
SBV.sRotateRight SBV (NonFuncSBVBaseType t)
SBVType t
l SBV (NonFuncSBVBaseType t)
SBVType t
r

-- | Partial evaluation and lowering for number terms.
class (SupportedNonFuncPrim t, Num t) => PEvalNumTerm t where
  pevalAddNumTerm :: Term t -> Term t -> Term t
  pevalNegNumTerm :: Term t -> Term t
  pevalMulNumTerm :: Term t -> Term t -> Term t
  pevalAbsNumTerm :: Term t -> Term t
  pevalSignumNumTerm :: Term t -> Term t
  withSbvNumTermConstraint :: (((Num (SBVType t)) => r)) -> r
  sbvAddNumTerm ::
    SBVType t ->
    SBVType t ->
    SBVType t
  sbvAddNumTerm SBVType t
l SBVType t
r = forall t r. PEvalNumTerm t => (Num (SBVType t) => r) -> r
withSbvNumTermConstraint @t ((Num (SBVType t) => SBVType t) -> SBVType t)
-> (Num (SBVType t) => SBVType t) -> SBVType t
forall a b. (a -> b) -> a -> b
$ SBVType t
l SBVType t -> SBVType t -> SBVType t
forall a. Num a => a -> a -> a
+ SBVType t
r
  sbvNegNumTerm ::
    SBVType t ->
    SBVType t
  sbvNegNumTerm SBVType t
l = forall t r. PEvalNumTerm t => (Num (SBVType t) => r) -> r
withSbvNumTermConstraint @t ((Num (SBVType t) => SBVType t) -> SBVType t)
-> (Num (SBVType t) => SBVType t) -> SBVType t
forall a b. (a -> b) -> a -> b
$ -SBVType t
l
  sbvMulNumTerm ::
    SBVType t ->
    SBVType t ->
    SBVType t
  sbvMulNumTerm SBVType t
l SBVType t
r = forall t r. PEvalNumTerm t => (Num (SBVType t) => r) -> r
withSbvNumTermConstraint @t ((Num (SBVType t) => SBVType t) -> SBVType t)
-> (Num (SBVType t) => SBVType t) -> SBVType t
forall a b. (a -> b) -> a -> b
$ SBVType t
l SBVType t -> SBVType t -> SBVType t
forall a. Num a => a -> a -> a
* SBVType t
r
  sbvAbsNumTerm ::
    SBVType t ->
    SBVType t
  sbvAbsNumTerm SBVType t
l = forall t r. PEvalNumTerm t => (Num (SBVType t) => r) -> r
withSbvNumTermConstraint @t ((Num (SBVType t) => SBVType t) -> SBVType t)
-> (Num (SBVType t) => SBVType t) -> SBVType t
forall a b. (a -> b) -> a -> b
$ SBVType t -> SBVType t
forall a. Num a => a -> a
abs SBVType t
l
  sbvSignumNumTerm ::
    SBVType t ->
    SBVType t
  sbvSignumNumTerm SBVType t
l = forall t r. PEvalNumTerm t => (Num (SBVType t) => r) -> r
withSbvNumTermConstraint @t ((Num (SBVType t) => SBVType t) -> SBVType t)
-> (Num (SBVType t) => SBVType t) -> SBVType t
forall a b. (a -> b) -> a -> b
$ SBVType t -> SBVType t
forall a. Num a => a -> a
signum SBVType t
l

-- | Partial evaluation for subtraction terms.
pevalSubNumTerm :: (PEvalNumTerm a) => Term a -> Term a -> Term a
pevalSubNumTerm :: forall a. PEvalNumTerm a => Term a -> Term a -> Term a
pevalSubNumTerm Term a
l Term a
r = Term a -> Term a -> Term a
forall a. PEvalNumTerm a => Term a -> Term a -> Term a
pevalAddNumTerm Term a
l (Term a -> Term a
forall t. PEvalNumTerm t => Term t -> Term t
pevalNegNumTerm Term a
r)

-- | Partial evaluation and lowering for comparison terms.
class (SupportedNonFuncPrim t, Ord t) => PEvalOrdTerm t where
  pevalLtOrdTerm :: Term t -> Term t -> Term Bool
  pevalLeOrdTerm :: Term t -> Term t -> Term Bool
  withSbvOrdTermConstraint :: (((SBV.OrdSymbolic (SBVType t)) => r)) -> r
  sbvLtOrdTerm ::
    SBVType t ->
    SBVType t ->
    SBV.SBV Bool
  sbvLtOrdTerm SBVType t
l SBVType t
r = forall t r. PEvalOrdTerm t => (OrdSymbolic (SBVType t) => r) -> r
withSbvOrdTermConstraint @t ((OrdSymbolic (SBVType t) => SBV Bool) -> SBV Bool)
-> (OrdSymbolic (SBVType t) => SBV Bool) -> SBV Bool
forall a b. (a -> b) -> a -> b
$ SBVType t
l SBVType t -> SBVType t -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
SBV..< SBVType t
r
  sbvLeOrdTerm :: SBVType t -> SBVType t -> SBV.SBV Bool
  sbvLeOrdTerm SBVType t
l SBVType t
r = forall t r. PEvalOrdTerm t => (OrdSymbolic (SBVType t) => r) -> r
withSbvOrdTermConstraint @t ((OrdSymbolic (SBVType t) => SBV Bool) -> SBV Bool)
-> (OrdSymbolic (SBVType t) => SBV Bool) -> SBV Bool
forall a b. (a -> b) -> a -> b
$ SBVType t
l SBVType t -> SBVType t -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
SBV..<= SBVType t
r

-- | Partial evaluation for greater than terms.
pevalGtOrdTerm :: (PEvalOrdTerm a) => Term a -> Term a -> Term Bool
pevalGtOrdTerm :: forall a. PEvalOrdTerm a => Term a -> Term a -> Term Bool
pevalGtOrdTerm = (Term a -> Term a -> Term Bool) -> Term a -> Term a -> Term Bool
forall a b c. (a -> b -> c) -> b -> a -> c
flip Term a -> Term a -> Term Bool
forall a. PEvalOrdTerm a => Term a -> Term a -> Term Bool
pevalLtOrdTerm

-- | Partial evaluation for greater than or equal to terms.
pevalGeOrdTerm :: (PEvalOrdTerm a) => Term a -> Term a -> Term Bool
pevalGeOrdTerm :: forall a. PEvalOrdTerm a => Term a -> Term a -> Term Bool
pevalGeOrdTerm = (Term a -> Term a -> Term Bool) -> Term a -> Term a -> Term Bool
forall a b c. (a -> b -> c) -> b -> a -> c
flip Term a -> Term a -> Term Bool
forall a. PEvalOrdTerm a => Term a -> Term a -> Term Bool
pevalLeOrdTerm

-- | Partial evaluation and lowering for integer division and modulo terms.
class (SupportedNonFuncPrim t, Integral t) => PEvalDivModIntegralTerm t where
  pevalDivIntegralTerm :: Term t -> Term t -> Term t
  pevalModIntegralTerm :: Term t -> Term t -> Term t
  pevalQuotIntegralTerm :: Term t -> Term t -> Term t
  pevalRemIntegralTerm :: Term t -> Term t -> Term t
  withSbvDivModIntegralTermConstraint ::
    (((SBV.SDivisible (SBVType t)) => r)) -> r
  sbvDivIntegralTerm :: SBVType t -> SBVType t -> SBVType t
  sbvDivIntegralTerm SBVType t
l SBVType t
r =
    forall t r.
PEvalDivModIntegralTerm t =>
(SDivisible (SBVType t) => r) -> r
withSbvDivModIntegralTermConstraint @t ((SDivisible (SBVType t) => SBVType t) -> SBVType t)
-> (SDivisible (SBVType t) => SBVType t) -> SBVType t
forall a b. (a -> b) -> a -> b
$ SBVType t
l SBVType t -> SBVType t -> SBVType t
forall a. SDivisible a => a -> a -> a
`SBV.sDiv` SBVType t
r
  sbvModIntegralTerm :: SBVType t -> SBVType t -> SBVType t
  sbvModIntegralTerm SBVType t
l SBVType t
r =
    forall t r.
PEvalDivModIntegralTerm t =>
(SDivisible (SBVType t) => r) -> r
withSbvDivModIntegralTermConstraint @t ((SDivisible (SBVType t) => SBVType t) -> SBVType t)
-> (SDivisible (SBVType t) => SBVType t) -> SBVType t
forall a b. (a -> b) -> a -> b
$ SBVType t
l SBVType t -> SBVType t -> SBVType t
forall a. SDivisible a => a -> a -> a
`SBV.sMod` SBVType t
r
  sbvQuotIntegralTerm :: SBVType t -> SBVType t -> SBVType t
  sbvQuotIntegralTerm SBVType t
l SBVType t
r =
    forall t r.
PEvalDivModIntegralTerm t =>
(SDivisible (SBVType t) => r) -> r
withSbvDivModIntegralTermConstraint @t ((SDivisible (SBVType t) => SBVType t) -> SBVType t)
-> (SDivisible (SBVType t) => SBVType t) -> SBVType t
forall a b. (a -> b) -> a -> b
$ SBVType t
l SBVType t -> SBVType t -> SBVType t
forall a. SDivisible a => a -> a -> a
`SBV.sQuot` SBVType t
r
  sbvRemIntegralTerm :: SBVType t -> SBVType t -> SBVType t
  sbvRemIntegralTerm SBVType t
l SBVType t
r =
    forall t r.
PEvalDivModIntegralTerm t =>
(SDivisible (SBVType t) => r) -> r
withSbvDivModIntegralTermConstraint @t ((SDivisible (SBVType t) => SBVType t) -> SBVType t)
-> (SDivisible (SBVType t) => SBVType t) -> SBVType t
forall a b. (a -> b) -> a -> b
$ SBVType t
l SBVType t -> SBVType t -> SBVType t
forall a. SDivisible a => a -> a -> a
`SBV.sRem` SBVType t
r

-- | Partial evaluation and lowering for bitcast terms.
class
  (SupportedNonFuncPrim a, SupportedNonFuncPrim b, BitCast a b) =>
  PEvalBitCastTerm a b
  where
  pevalBitCastTerm :: Term a -> Term b
  sbvBitCast :: SBVType a -> SBVType b

-- | Partial evaluation and lowering for bitcast or default value terms.
class
  (SupportedNonFuncPrim a, SupportedNonFuncPrim b, BitCastOr a b) =>
  PEvalBitCastOrTerm a b
  where
  pevalBitCastOrTerm :: Term b -> Term a -> Term b
  sbvBitCastOr :: SBVType b -> SBVType a -> SBVType b

-- | Partial evaluation and lowering for bit-vector terms.
class
  ( forall n. (KnownNat n, 1 <= n) => SupportedNonFuncPrim (bv n),
    SizedBV bv,
    Typeable bv
  ) =>
  PEvalBVTerm bv
  where
  pevalBVConcatTerm ::
    (KnownNat l, KnownNat r, 1 <= l, 1 <= r) =>
    Term (bv l) ->
    Term (bv r) ->
    Term (bv (l + r))
  pevalBVExtendTerm ::
    (KnownNat l, KnownNat r, 1 <= l, 1 <= r, l <= r) =>
    Bool ->
    proxy r ->
    Term (bv l) ->
    Term (bv r)
  pevalBVSelectTerm ::
    (KnownNat n, KnownNat ix, KnownNat w, 1 <= n, 1 <= w, ix + w <= n) =>
    p ix ->
    q w ->
    Term (bv n) ->
    Term (bv w)
  sbvBVConcatTerm ::
    (KnownNat l, KnownNat r, 1 <= l, 1 <= r) =>
    p1 l ->
    p2 r ->
    SBVType (bv l) ->
    SBVType (bv r) ->
    SBVType (bv (l + r))
  sbvBVExtendTerm ::
    (KnownNat l, KnownNat r, 1 <= l, 1 <= r, l <= r) =>
    p1 l ->
    p2 r ->
    Bool ->
    SBVType (bv l) ->
    SBVType (bv r)
  sbvBVSelectTerm ::
    ( KnownNat ix,
      KnownNat w,
      KnownNat n,
      1 <= n,
      1 <= w,
      ix + w <= n
    ) =>
    p1 ix ->
    p2 w ->
    p3 n ->
    SBVType (bv n) ->
    SBVType (bv w)

-- | Partial evaluation and lowering for fractional terms.
class (SupportedNonFuncPrim t, Fractional t) => PEvalFractionalTerm t where
  pevalFdivTerm :: Term t -> Term t -> Term t
  pevalRecipTerm :: Term t -> Term t
  withSbvFractionalTermConstraint ::
    (((Fractional (SBVType t)) => r)) ->
    r
  sbvFdivTerm ::
    SBVType t ->
    SBVType t ->
    SBVType t
  sbvFdivTerm SBVType t
l SBVType t
r = forall t r.
PEvalFractionalTerm t =>
(Fractional (SBVType t) => r) -> r
withSbvFractionalTermConstraint @t ((Fractional (SBVType t) => SBVType t) -> SBVType t)
-> (Fractional (SBVType t) => SBVType t) -> SBVType t
forall a b. (a -> b) -> a -> b
$ SBVType t
l SBVType t -> SBVType t -> SBVType t
forall a. Fractional a => a -> a -> a
/ SBVType t
r
  sbvRecipTerm ::
    SBVType t ->
    SBVType t
  sbvRecipTerm SBVType t
l = forall t r.
PEvalFractionalTerm t =>
(Fractional (SBVType t) => r) -> r
withSbvFractionalTermConstraint @t ((Fractional (SBVType t) => SBVType t) -> SBVType t)
-> (Fractional (SBVType t) => SBVType t) -> SBVType t
forall a b. (a -> b) -> a -> b
$ SBVType t -> SBVType t
forall a. Fractional a => a -> a
recip SBVType t
l

-- | Unary floating point operations.
data FloatingUnaryOp
  = FloatingExp
  | FloatingLog
  | FloatingSqrt
  | FloatingSin
  | FloatingCos
  | FloatingTan
  | FloatingAsin
  | FloatingAcos
  | FloatingAtan
  | FloatingSinh
  | FloatingCosh
  | FloatingTanh
  | FloatingAsinh
  | FloatingAcosh
  | FloatingAtanh
  deriving (FloatingUnaryOp -> FloatingUnaryOp -> Bool
(FloatingUnaryOp -> FloatingUnaryOp -> Bool)
-> (FloatingUnaryOp -> FloatingUnaryOp -> Bool)
-> Eq FloatingUnaryOp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FloatingUnaryOp -> FloatingUnaryOp -> Bool
== :: FloatingUnaryOp -> FloatingUnaryOp -> Bool
$c/= :: FloatingUnaryOp -> FloatingUnaryOp -> Bool
/= :: FloatingUnaryOp -> FloatingUnaryOp -> Bool
Eq, Eq FloatingUnaryOp
Eq FloatingUnaryOp =>
(FloatingUnaryOp -> FloatingUnaryOp -> Ordering)
-> (FloatingUnaryOp -> FloatingUnaryOp -> Bool)
-> (FloatingUnaryOp -> FloatingUnaryOp -> Bool)
-> (FloatingUnaryOp -> FloatingUnaryOp -> Bool)
-> (FloatingUnaryOp -> FloatingUnaryOp -> Bool)
-> (FloatingUnaryOp -> FloatingUnaryOp -> FloatingUnaryOp)
-> (FloatingUnaryOp -> FloatingUnaryOp -> FloatingUnaryOp)
-> Ord FloatingUnaryOp
FloatingUnaryOp -> FloatingUnaryOp -> Bool
FloatingUnaryOp -> FloatingUnaryOp -> Ordering
FloatingUnaryOp -> FloatingUnaryOp -> FloatingUnaryOp
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: FloatingUnaryOp -> FloatingUnaryOp -> Ordering
compare :: FloatingUnaryOp -> FloatingUnaryOp -> Ordering
$c< :: FloatingUnaryOp -> FloatingUnaryOp -> Bool
< :: FloatingUnaryOp -> FloatingUnaryOp -> Bool
$c<= :: FloatingUnaryOp -> FloatingUnaryOp -> Bool
<= :: FloatingUnaryOp -> FloatingUnaryOp -> Bool
$c> :: FloatingUnaryOp -> FloatingUnaryOp -> Bool
> :: FloatingUnaryOp -> FloatingUnaryOp -> Bool
$c>= :: FloatingUnaryOp -> FloatingUnaryOp -> Bool
>= :: FloatingUnaryOp -> FloatingUnaryOp -> Bool
$cmax :: FloatingUnaryOp -> FloatingUnaryOp -> FloatingUnaryOp
max :: FloatingUnaryOp -> FloatingUnaryOp -> FloatingUnaryOp
$cmin :: FloatingUnaryOp -> FloatingUnaryOp -> FloatingUnaryOp
min :: FloatingUnaryOp -> FloatingUnaryOp -> FloatingUnaryOp
Ord, (forall x. FloatingUnaryOp -> Rep FloatingUnaryOp x)
-> (forall x. Rep FloatingUnaryOp x -> FloatingUnaryOp)
-> Generic FloatingUnaryOp
forall x. Rep FloatingUnaryOp x -> FloatingUnaryOp
forall x. FloatingUnaryOp -> Rep FloatingUnaryOp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FloatingUnaryOp -> Rep FloatingUnaryOp x
from :: forall x. FloatingUnaryOp -> Rep FloatingUnaryOp x
$cto :: forall x. Rep FloatingUnaryOp x -> FloatingUnaryOp
to :: forall x. Rep FloatingUnaryOp x -> FloatingUnaryOp
Generic, Eq FloatingUnaryOp
Eq FloatingUnaryOp =>
(Int -> FloatingUnaryOp -> Int)
-> (FloatingUnaryOp -> Int) -> Hashable FloatingUnaryOp
Int -> FloatingUnaryOp -> Int
FloatingUnaryOp -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> FloatingUnaryOp -> Int
hashWithSalt :: Int -> FloatingUnaryOp -> Int
$chash :: FloatingUnaryOp -> Int
hash :: FloatingUnaryOp -> Int
Hashable, (forall (m :: * -> *). Quote m => FloatingUnaryOp -> m Exp)
-> (forall (m :: * -> *).
    Quote m =>
    FloatingUnaryOp -> Code m FloatingUnaryOp)
-> Lift FloatingUnaryOp
forall t.
(forall (m :: * -> *). Quote m => t -> m Exp)
-> (forall (m :: * -> *). Quote m => t -> Code m t) -> Lift t
forall (m :: * -> *). Quote m => FloatingUnaryOp -> m Exp
forall (m :: * -> *).
Quote m =>
FloatingUnaryOp -> Code m FloatingUnaryOp
$clift :: forall (m :: * -> *). Quote m => FloatingUnaryOp -> m Exp
lift :: forall (m :: * -> *). Quote m => FloatingUnaryOp -> m Exp
$cliftTyped :: forall (m :: * -> *).
Quote m =>
FloatingUnaryOp -> Code m FloatingUnaryOp
liftTyped :: forall (m :: * -> *).
Quote m =>
FloatingUnaryOp -> Code m FloatingUnaryOp
Lift, FloatingUnaryOp -> ()
(FloatingUnaryOp -> ()) -> NFData FloatingUnaryOp
forall a. (a -> ()) -> NFData a
$crnf :: FloatingUnaryOp -> ()
rnf :: FloatingUnaryOp -> ()
NFData)

instance Show FloatingUnaryOp where
  show :: FloatingUnaryOp -> String
show FloatingUnaryOp
FloatingExp = String
"exp"
  show FloatingUnaryOp
FloatingLog = String
"log"
  show FloatingUnaryOp
FloatingSqrt = String
"sqrt"
  show FloatingUnaryOp
FloatingSin = String
"sin"
  show FloatingUnaryOp
FloatingCos = String
"cos"
  show FloatingUnaryOp
FloatingTan = String
"tan"
  show FloatingUnaryOp
FloatingAsin = String
"asin"
  show FloatingUnaryOp
FloatingAcos = String
"acos"
  show FloatingUnaryOp
FloatingAtan = String
"atan"
  show FloatingUnaryOp
FloatingSinh = String
"sinh"
  show FloatingUnaryOp
FloatingCosh = String
"cosh"
  show FloatingUnaryOp
FloatingTanh = String
"tanh"
  show FloatingUnaryOp
FloatingAsinh = String
"asinh"
  show FloatingUnaryOp
FloatingAcosh = String
"acosh"
  show FloatingUnaryOp
FloatingAtanh = String
"atanh"

-- | Partial evaluation and lowering for floating point terms.
class (SupportedNonFuncPrim t) => PEvalFloatingTerm t where
  pevalFloatingUnaryTerm :: FloatingUnaryOp -> Term t -> Term t
  pevalPowerTerm :: Term t -> Term t -> Term t
  withSbvFloatingTermConstraint ::
    (((Floating (SBVType t)) => r)) ->
    r
  sbvPowerTerm ::
    SBVType t ->
    SBVType t ->
    SBVType t
  sbvPowerTerm = forall t r. PEvalFloatingTerm t => (Floating (SBVType t) => r) -> r
withSbvFloatingTermConstraint @t Floating (SBVType t) => SBVType t -> SBVType t -> SBVType t
SBVType t -> SBVType t -> SBVType t
forall a. Floating a => a -> a -> a
(**)
  sbvFloatingUnaryTerm ::
    FloatingUnaryOp ->
    SBVType t ->
    SBVType t
  sbvFloatingUnaryTerm FloatingUnaryOp
op SBVType t
l =
    forall t r. PEvalFloatingTerm t => (Floating (SBVType t) => r) -> r
withSbvFloatingTermConstraint @t ((Floating (SBVType t) => SBVType t) -> SBVType t)
-> (Floating (SBVType t) => SBVType t) -> SBVType t
forall a b. (a -> b) -> a -> b
$
      case FloatingUnaryOp
op of
        FloatingUnaryOp
FloatingExp -> SBVType t -> SBVType t
forall a. Floating a => a -> a
exp SBVType t
l
        FloatingUnaryOp
FloatingLog -> SBVType t -> SBVType t
forall a. Floating a => a -> a
log SBVType t
l
        FloatingUnaryOp
FloatingSqrt -> SBVType t -> SBVType t
forall a. Floating a => a -> a
sqrt SBVType t
l
        FloatingUnaryOp
FloatingSin -> SBVType t -> SBVType t
forall a. Floating a => a -> a
sin SBVType t
l
        FloatingUnaryOp
FloatingCos -> SBVType t -> SBVType t
forall a. Floating a => a -> a
cos SBVType t
l
        FloatingUnaryOp
FloatingTan -> SBVType t -> SBVType t
forall a. Floating a => a -> a
tan SBVType t
l
        FloatingUnaryOp
FloatingAsin -> SBVType t -> SBVType t
forall a. Floating a => a -> a
asin SBVType t
l
        FloatingUnaryOp
FloatingAcos -> SBVType t -> SBVType t
forall a. Floating a => a -> a
acos SBVType t
l
        FloatingUnaryOp
FloatingAtan -> SBVType t -> SBVType t
forall a. Floating a => a -> a
atan SBVType t
l
        FloatingUnaryOp
FloatingSinh -> SBVType t -> SBVType t
forall a. Floating a => a -> a
sinh SBVType t
l
        FloatingUnaryOp
FloatingCosh -> SBVType t -> SBVType t
forall a. Floating a => a -> a
cosh SBVType t
l
        FloatingUnaryOp
FloatingTanh -> SBVType t -> SBVType t
forall a. Floating a => a -> a
tanh SBVType t
l
        FloatingUnaryOp
FloatingAsinh -> SBVType t -> SBVType t
forall a. Floating a => a -> a
asinh SBVType t
l
        FloatingUnaryOp
FloatingAcosh -> SBVType t -> SBVType t
forall a. Floating a => a -> a
acosh SBVType t
l
        FloatingUnaryOp
FloatingAtanh -> SBVType t -> SBVType t
forall a. Floating a => a -> a
atanh SBVType t
l

-- | Partial evaluation and lowering for integral terms.
class
  ( SupportedNonFuncPrim a,
    SupportedNonFuncPrim b,
    Integral a,
    Num b
  ) =>
  PEvalFromIntegralTerm a b
  where
  pevalFromIntegralTerm :: Term a -> Term b
  sbvFromIntegralTerm :: SBVType a -> SBVType b

-- | Partial evaluation and lowering for converting from and to IEEE floating
-- point terms.
class (SupportedNonFuncPrim a) => PEvalIEEEFPConvertibleTerm a where
  pevalFromFPOrTerm ::
    (ValidFP eb sb) =>
    Term a ->
    Term FPRoundingMode ->
    Term (FP eb sb) ->
    Term a
  pevalToFPTerm ::
    (ValidFP eb sb) => Term FPRoundingMode -> Term a -> Term (FP eb sb)
  sbvFromFPOrTerm ::
    (ValidFP eb sb) =>
    SBVType a ->
    SBVType FPRoundingMode ->
    SBVType (FP eb sb) ->
    SBVType a
  sbvToFPTerm ::
    (ValidFP eb sb) =>
    SBVType FPRoundingMode ->
    SBVType a ->
    SBVType (FP eb sb)

-- | Custom unary operator. Not used by Grisette at this time and do not use it.
class
  (SupportedPrim arg, SupportedPrim t, Lift tag, NFData tag, Show tag, Typeable tag, Eq tag, Hashable tag) =>
  UnaryOp tag arg t
    | tag arg -> t
  where
  pevalUnary :: (Typeable tag, Typeable t) => tag -> Term arg -> Term t
  pformatUnary :: tag -> Term arg -> String

-- | Custom binary operator. Not used by Grisette at this time and do not use it.
class
  ( SupportedPrim arg1,
    SupportedPrim arg2,
    SupportedPrim t,
    Lift tag,
    NFData tag,
    Show tag,
    Typeable tag,
    Eq tag,
    Hashable tag
  ) =>
  BinaryOp tag arg1 arg2 t
    | tag arg1 arg2 -> t
  where
  pevalBinary :: (Typeable tag, Typeable t) => tag -> Term arg1 -> Term arg2 -> Term t
  pformatBinary :: tag -> Term arg1 -> Term arg2 -> String

-- | Custom ternary operator. Not used by Grisette at this time and do not use it.
class
  ( SupportedPrim arg1,
    SupportedPrim arg2,
    SupportedPrim arg3,
    SupportedPrim t,
    Lift tag,
    NFData tag,
    Show tag,
    Typeable tag,
    Eq tag,
    Hashable tag
  ) =>
  TernaryOp tag arg1 arg2 arg3 t
    | tag arg1 arg2 arg3 -> t
  where
  pevalTernary :: (Typeable tag, Typeable t) => tag -> Term arg1 -> Term arg2 -> Term arg3 -> Term t
  pformatTernary :: tag -> Term arg1 -> Term arg2 -> Term arg3 -> String

-- Typed Symbols

-- | The kind of a symbol.
--
-- All symbols are 'AnyKind', and all symbols other than general/tabular
-- functions are 'ConstantKind'.
data SymbolKind = ConstantKind | AnyKind

-- | Decision procedure for symbol kinds.
class IsSymbolKind (ty :: SymbolKind) where
  type SymbolKindConstraint ty :: Type -> Constraint
  decideSymbolKind :: Either (ty :~~: 'ConstantKind) (ty :~~: 'AnyKind)

instance IsSymbolKind 'ConstantKind where
  type SymbolKindConstraint 'ConstantKind = SupportedNonFuncPrim
  decideSymbolKind :: Either
  ('ConstantKind :~~: 'ConstantKind) ('ConstantKind :~~: 'AnyKind)
decideSymbolKind = ('ConstantKind :~~: 'ConstantKind)
-> Either
     ('ConstantKind :~~: 'ConstantKind) ('ConstantKind :~~: 'AnyKind)
forall a b. a -> Either a b
Left 'ConstantKind :~~: 'ConstantKind
forall {k1} (a :: k1). a :~~: a
HRefl

instance IsSymbolKind 'AnyKind where
  type SymbolKindConstraint 'AnyKind = SupportedPrim
  decideSymbolKind :: Either ('AnyKind :~~: 'ConstantKind) ('AnyKind :~~: 'AnyKind)
decideSymbolKind = ('AnyKind :~~: 'AnyKind)
-> Either ('AnyKind :~~: 'ConstantKind) ('AnyKind :~~: 'AnyKind)
forall a b. b -> Either a b
Right 'AnyKind :~~: 'AnyKind
forall {k1} (a :: k1). a :~~: a
HRefl

-- | A typed symbol is a symbol that is associated with a type. Note that the
-- same symbol bodies with different types are considered different symbols
-- and can coexist in a term.
--
-- Simple symbols can be created with the @OverloadedStrings@ extension:
--
-- >>> "a" :: TypedSymbol 'AnyKind Bool
-- a :: Bool
data TypedSymbol (knd :: SymbolKind) t where
  TypedSymbol ::
    ( SupportedPrim t,
      SymbolKindConstraint knd t,
      IsSymbolKind knd
    ) =>
    {forall t (knd :: SymbolKind). TypedSymbol knd t -> Symbol
unTypedSymbol :: Symbol} ->
    TypedSymbol knd t

-- | Constant symbol
type TypedConstantSymbol = TypedSymbol 'ConstantKind

-- | Any symbol
type TypedAnySymbol = TypedSymbol 'AnyKind

instance Eq (TypedSymbol knd t) where
  TypedSymbol Symbol
x == :: TypedSymbol knd t -> TypedSymbol knd t -> Bool
== TypedSymbol Symbol
y = Symbol
x Symbol -> Symbol -> Bool
forall a. Eq a => a -> a -> Bool
== Symbol
y

instance Ord (TypedSymbol knd t) where
  TypedSymbol Symbol
x <= :: TypedSymbol knd t -> TypedSymbol knd t -> Bool
<= TypedSymbol Symbol
y = Symbol
x Symbol -> Symbol -> Bool
forall a. Ord a => a -> a -> Bool
<= Symbol
y

instance Lift (TypedSymbol knd t) where
  liftTyped :: forall (m :: * -> *).
Quote m =>
TypedSymbol knd t -> Code m (TypedSymbol knd t)
liftTyped (TypedSymbol Symbol
x) = [||Symbol -> TypedSymbol knd t
forall t (knd :: SymbolKind).
(SupportedPrim t, SymbolKindConstraint knd t, IsSymbolKind knd) =>
Symbol -> TypedSymbol knd t
TypedSymbol Symbol
x||]

instance Show (TypedSymbol knd t) where
  show :: TypedSymbol knd t -> String
show (TypedSymbol Symbol
symbol) = Symbol -> String
forall a. Show a => a -> String
show Symbol
symbol String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" :: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep t -> String
forall a. Show a => a -> String
show (forall a. Typeable a => TypeRep a
forall {k} (a :: k). Typeable a => TypeRep a
typeRep @t)

-- | Show a typed symbol without the type information.
showUntyped :: TypedSymbol knd t -> String
showUntyped :: forall (knd :: SymbolKind) t. TypedSymbol knd t -> String
showUntyped (TypedSymbol Symbol
symbol) = Symbol -> String
forall a. Show a => a -> String
show Symbol
symbol

instance Hashable (TypedSymbol knd t) where
  Int
s hashWithSalt :: Int -> TypedSymbol knd t -> Int
`hashWithSalt` TypedSymbol Symbol
x = Int
s Int -> Symbol -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Symbol
x

instance NFData (TypedSymbol knd t) where
  rnf :: TypedSymbol knd t -> ()
rnf (TypedSymbol Symbol
str) = Symbol -> ()
forall a. NFData a => a -> ()
rnf Symbol
str

instance
  ( SupportedPrim t,
    SymbolKindConstraint knd t,
    IsSymbolKind knd
  ) =>
  IsString (TypedSymbol knd t)
  where
  fromString :: String -> TypedSymbol knd t
fromString = Symbol -> TypedSymbol knd t
forall t (knd :: SymbolKind).
(SupportedPrim t, SymbolKindConstraint knd t, IsSymbolKind knd) =>
Symbol -> TypedSymbol knd t
TypedSymbol (Symbol -> TypedSymbol knd t)
-> (String -> Symbol) -> String -> TypedSymbol knd t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Symbol
forall a. IsString a => String -> a
fromString

-- | Introduce the 'SupportedPrim' constraint from the t'TypedSymbol'.
withSymbolSupported :: TypedSymbol knd t -> ((SupportedPrim t) => a) -> a
withSymbolSupported :: forall (knd :: SymbolKind) t a.
TypedSymbol knd t -> (SupportedPrim t => a) -> a
withSymbolSupported (TypedSymbol Symbol
_) SupportedPrim t => a
a = a
SupportedPrim t => a
a

-- | Introduce the 'IsSymbolKind' constraint from the t'TypedSymbol'.
withSymbolKind :: TypedSymbol knd t -> ((IsSymbolKind knd) => a) -> a
withSymbolKind :: forall (knd :: SymbolKind) t a.
TypedSymbol knd t -> (IsSymbolKind knd => a) -> a
withSymbolKind (TypedSymbol Symbol
_) IsSymbolKind knd => a
a = a
IsSymbolKind knd => a
a

-- | A non-indexed symbol. Type information are checked at runtime.
data SomeTypedSymbol knd where
  SomeTypedSymbol ::
    forall knd t.
    TypeRep t ->
    TypedSymbol knd t ->
    SomeTypedSymbol knd

-- | Non-indexed constant symbol
type SomeTypedConstantSymbol = SomeTypedSymbol 'ConstantKind

-- | Non-indexed any symbol
type SomeTypedAnySymbol = SomeTypedSymbol 'AnyKind

instance NFData (SomeTypedSymbol knd) where
  rnf :: SomeTypedSymbol knd -> ()
rnf (SomeTypedSymbol TypeRep t
p TypedSymbol knd t
s) = SomeTypeRep -> ()
forall a. NFData a => a -> ()
rnf (TypeRep t -> SomeTypeRep
forall k (a :: k). TypeRep a -> SomeTypeRep
SomeTypeRep TypeRep t
p) () -> () -> ()
forall a b. a -> b -> b
`seq` TypedSymbol knd t -> ()
forall a. NFData a => a -> ()
rnf TypedSymbol knd t
s

instance Eq (SomeTypedSymbol knd) where
  (SomeTypedSymbol TypeRep t
t1 TypedSymbol knd t
s1) == :: SomeTypedSymbol knd -> SomeTypedSymbol knd -> Bool
== (SomeTypedSymbol TypeRep t
t2 TypedSymbol knd t
s2) = case TypeRep t -> TypeRep t -> Maybe (t :~~: t)
forall k1 k2 (a :: k1) (b :: k2).
TypeRep a -> TypeRep b -> Maybe (a :~~: b)
eqTypeRep TypeRep t
t1 TypeRep t
t2 of
    Just t :~~: t
HRefl -> TypedSymbol knd t
s1 TypedSymbol knd t -> TypedSymbol knd t -> Bool
forall a. Eq a => a -> a -> Bool
== TypedSymbol knd t
TypedSymbol knd t
s2
    Maybe (t :~~: t)
_ -> Bool
False

instance Ord (SomeTypedSymbol knd) where
  (SomeTypedSymbol TypeRep t
t1 TypedSymbol knd t
s1) <= :: SomeTypedSymbol knd -> SomeTypedSymbol knd -> Bool
<= (SomeTypedSymbol TypeRep t
t2 TypedSymbol knd t
s2) =
    TypeRep t -> SomeTypeRep
forall k (a :: k). TypeRep a -> SomeTypeRep
SomeTypeRep TypeRep t
t1 SomeTypeRep -> SomeTypeRep -> Bool
forall a. Ord a => a -> a -> Bool
< TypeRep t -> SomeTypeRep
forall k (a :: k). TypeRep a -> SomeTypeRep
SomeTypeRep TypeRep t
t2
      Bool -> Bool -> Bool
|| ( case TypeRep t -> TypeRep t -> Maybe (t :~~: t)
forall k1 k2 (a :: k1) (b :: k2).
TypeRep a -> TypeRep b -> Maybe (a :~~: b)
eqTypeRep TypeRep t
t1 TypeRep t
t2 of
             Just t :~~: t
HRefl -> TypedSymbol knd t
s1 TypedSymbol knd t -> TypedSymbol knd t -> Bool
forall a. Ord a => a -> a -> Bool
<= TypedSymbol knd t
TypedSymbol knd t
s2
             Maybe (t :~~: t)
_ -> Bool
False
         )

instance Hashable (SomeTypedSymbol knd) where
  hashWithSalt :: Int -> SomeTypedSymbol knd -> Int
hashWithSalt Int
s (SomeTypedSymbol TypeRep t
t1 TypedSymbol knd t
s1) = Int
s Int -> TypedSymbol knd t -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` TypedSymbol knd t
s1 Int -> TypeRep t -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` TypeRep t
t1

instance Show (SomeTypedSymbol knd) where
  show :: SomeTypedSymbol knd -> String
show (SomeTypedSymbol TypeRep t
_ TypedSymbol knd t
s) = TypedSymbol knd t -> String
forall a. Show a => a -> String
show TypedSymbol knd t
s

-- | Construct a t'SomeTypedSymbol' from a t'TypedSymbol'.
someTypedSymbol :: forall knd t. TypedSymbol knd t -> SomeTypedSymbol knd
someTypedSymbol :: forall (knd :: SymbolKind) t.
TypedSymbol knd t -> SomeTypedSymbol knd
someTypedSymbol s :: TypedSymbol knd t
s@(TypedSymbol Symbol
_) = TypeRep t -> TypedSymbol knd t -> SomeTypedSymbol knd
forall (knd :: SymbolKind) a.
TypeRep a -> TypedSymbol knd a -> SomeTypedSymbol knd
SomeTypedSymbol (forall a. Typeable a => TypeRep a
forall {k} (a :: k). Typeable a => TypeRep a
typeRep @t) TypedSymbol knd t
s

-- Terms

-- | Traits for IEEE floating point numbers.
data FPTrait
  = FPIsNaN
  | FPIsPositive
  | FPIsNegative
  | FPIsPositiveInfinite
  | FPIsNegativeInfinite
  | FPIsInfinite
  | FPIsPositiveZero
  | FPIsNegativeZero
  | FPIsZero
  | FPIsNormal
  | FPIsSubnormal
  | FPIsPoint
  deriving (FPTrait -> FPTrait -> Bool
(FPTrait -> FPTrait -> Bool)
-> (FPTrait -> FPTrait -> Bool) -> Eq FPTrait
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FPTrait -> FPTrait -> Bool
== :: FPTrait -> FPTrait -> Bool
$c/= :: FPTrait -> FPTrait -> Bool
/= :: FPTrait -> FPTrait -> Bool
Eq, Eq FPTrait
Eq FPTrait =>
(FPTrait -> FPTrait -> Ordering)
-> (FPTrait -> FPTrait -> Bool)
-> (FPTrait -> FPTrait -> Bool)
-> (FPTrait -> FPTrait -> Bool)
-> (FPTrait -> FPTrait -> Bool)
-> (FPTrait -> FPTrait -> FPTrait)
-> (FPTrait -> FPTrait -> FPTrait)
-> Ord FPTrait
FPTrait -> FPTrait -> Bool
FPTrait -> FPTrait -> Ordering
FPTrait -> FPTrait -> FPTrait
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: FPTrait -> FPTrait -> Ordering
compare :: FPTrait -> FPTrait -> Ordering
$c< :: FPTrait -> FPTrait -> Bool
< :: FPTrait -> FPTrait -> Bool
$c<= :: FPTrait -> FPTrait -> Bool
<= :: FPTrait -> FPTrait -> Bool
$c> :: FPTrait -> FPTrait -> Bool
> :: FPTrait -> FPTrait -> Bool
$c>= :: FPTrait -> FPTrait -> Bool
>= :: FPTrait -> FPTrait -> Bool
$cmax :: FPTrait -> FPTrait -> FPTrait
max :: FPTrait -> FPTrait -> FPTrait
$cmin :: FPTrait -> FPTrait -> FPTrait
min :: FPTrait -> FPTrait -> FPTrait
Ord, (forall x. FPTrait -> Rep FPTrait x)
-> (forall x. Rep FPTrait x -> FPTrait) -> Generic FPTrait
forall x. Rep FPTrait x -> FPTrait
forall x. FPTrait -> Rep FPTrait x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FPTrait -> Rep FPTrait x
from :: forall x. FPTrait -> Rep FPTrait x
$cto :: forall x. Rep FPTrait x -> FPTrait
to :: forall x. Rep FPTrait x -> FPTrait
Generic, Eq FPTrait
Eq FPTrait =>
(Int -> FPTrait -> Int) -> (FPTrait -> Int) -> Hashable FPTrait
Int -> FPTrait -> Int
FPTrait -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> FPTrait -> Int
hashWithSalt :: Int -> FPTrait -> Int
$chash :: FPTrait -> Int
hash :: FPTrait -> Int
Hashable, (forall (m :: * -> *). Quote m => FPTrait -> m Exp)
-> (forall (m :: * -> *). Quote m => FPTrait -> Code m FPTrait)
-> Lift FPTrait
forall t.
(forall (m :: * -> *). Quote m => t -> m Exp)
-> (forall (m :: * -> *). Quote m => t -> Code m t) -> Lift t
forall (m :: * -> *). Quote m => FPTrait -> m Exp
forall (m :: * -> *). Quote m => FPTrait -> Code m FPTrait
$clift :: forall (m :: * -> *). Quote m => FPTrait -> m Exp
lift :: forall (m :: * -> *). Quote m => FPTrait -> m Exp
$cliftTyped :: forall (m :: * -> *). Quote m => FPTrait -> Code m FPTrait
liftTyped :: forall (m :: * -> *). Quote m => FPTrait -> Code m FPTrait
Lift, FPTrait -> ()
(FPTrait -> ()) -> NFData FPTrait
forall a. (a -> ()) -> NFData a
$crnf :: FPTrait -> ()
rnf :: FPTrait -> ()
NFData)

instance Show FPTrait where
  show :: FPTrait -> String
show FPTrait
FPIsNaN = String
"is_nan"
  show FPTrait
FPIsPositive = String
"is_pos"
  show FPTrait
FPIsNegative = String
"is_neg"
  show FPTrait
FPIsPositiveInfinite = String
"is_pos_inf"
  show FPTrait
FPIsNegativeInfinite = String
"is_neg_inf"
  show FPTrait
FPIsInfinite = String
"is_inf"
  show FPTrait
FPIsPositiveZero = String
"is_pos_zero"
  show FPTrait
FPIsNegativeZero = String
"is_neg_zero"
  show FPTrait
FPIsZero = String
"is_zero"
  show FPTrait
FPIsNormal = String
"is_normal"
  show FPTrait
FPIsSubnormal = String
"is_subnormal"
  show FPTrait
FPIsPoint = String
"is_point"

-- | Unary floating point operations.
data FPUnaryOp = FPAbs | FPNeg
  deriving (FPUnaryOp -> FPUnaryOp -> Bool
(FPUnaryOp -> FPUnaryOp -> Bool)
-> (FPUnaryOp -> FPUnaryOp -> Bool) -> Eq FPUnaryOp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FPUnaryOp -> FPUnaryOp -> Bool
== :: FPUnaryOp -> FPUnaryOp -> Bool
$c/= :: FPUnaryOp -> FPUnaryOp -> Bool
/= :: FPUnaryOp -> FPUnaryOp -> Bool
Eq, Eq FPUnaryOp
Eq FPUnaryOp =>
(FPUnaryOp -> FPUnaryOp -> Ordering)
-> (FPUnaryOp -> FPUnaryOp -> Bool)
-> (FPUnaryOp -> FPUnaryOp -> Bool)
-> (FPUnaryOp -> FPUnaryOp -> Bool)
-> (FPUnaryOp -> FPUnaryOp -> Bool)
-> (FPUnaryOp -> FPUnaryOp -> FPUnaryOp)
-> (FPUnaryOp -> FPUnaryOp -> FPUnaryOp)
-> Ord FPUnaryOp
FPUnaryOp -> FPUnaryOp -> Bool
FPUnaryOp -> FPUnaryOp -> Ordering
FPUnaryOp -> FPUnaryOp -> FPUnaryOp
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: FPUnaryOp -> FPUnaryOp -> Ordering
compare :: FPUnaryOp -> FPUnaryOp -> Ordering
$c< :: FPUnaryOp -> FPUnaryOp -> Bool
< :: FPUnaryOp -> FPUnaryOp -> Bool
$c<= :: FPUnaryOp -> FPUnaryOp -> Bool
<= :: FPUnaryOp -> FPUnaryOp -> Bool
$c> :: FPUnaryOp -> FPUnaryOp -> Bool
> :: FPUnaryOp -> FPUnaryOp -> Bool
$c>= :: FPUnaryOp -> FPUnaryOp -> Bool
>= :: FPUnaryOp -> FPUnaryOp -> Bool
$cmax :: FPUnaryOp -> FPUnaryOp -> FPUnaryOp
max :: FPUnaryOp -> FPUnaryOp -> FPUnaryOp
$cmin :: FPUnaryOp -> FPUnaryOp -> FPUnaryOp
min :: FPUnaryOp -> FPUnaryOp -> FPUnaryOp
Ord, (forall x. FPUnaryOp -> Rep FPUnaryOp x)
-> (forall x. Rep FPUnaryOp x -> FPUnaryOp) -> Generic FPUnaryOp
forall x. Rep FPUnaryOp x -> FPUnaryOp
forall x. FPUnaryOp -> Rep FPUnaryOp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FPUnaryOp -> Rep FPUnaryOp x
from :: forall x. FPUnaryOp -> Rep FPUnaryOp x
$cto :: forall x. Rep FPUnaryOp x -> FPUnaryOp
to :: forall x. Rep FPUnaryOp x -> FPUnaryOp
Generic, Eq FPUnaryOp
Eq FPUnaryOp =>
(Int -> FPUnaryOp -> Int)
-> (FPUnaryOp -> Int) -> Hashable FPUnaryOp
Int -> FPUnaryOp -> Int
FPUnaryOp -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> FPUnaryOp -> Int
hashWithSalt :: Int -> FPUnaryOp -> Int
$chash :: FPUnaryOp -> Int
hash :: FPUnaryOp -> Int
Hashable, (forall (m :: * -> *). Quote m => FPUnaryOp -> m Exp)
-> (forall (m :: * -> *). Quote m => FPUnaryOp -> Code m FPUnaryOp)
-> Lift FPUnaryOp
forall t.
(forall (m :: * -> *). Quote m => t -> m Exp)
-> (forall (m :: * -> *). Quote m => t -> Code m t) -> Lift t
forall (m :: * -> *). Quote m => FPUnaryOp -> m Exp
forall (m :: * -> *). Quote m => FPUnaryOp -> Code m FPUnaryOp
$clift :: forall (m :: * -> *). Quote m => FPUnaryOp -> m Exp
lift :: forall (m :: * -> *). Quote m => FPUnaryOp -> m Exp
$cliftTyped :: forall (m :: * -> *). Quote m => FPUnaryOp -> Code m FPUnaryOp
liftTyped :: forall (m :: * -> *). Quote m => FPUnaryOp -> Code m FPUnaryOp
Lift, FPUnaryOp -> ()
(FPUnaryOp -> ()) -> NFData FPUnaryOp
forall a. (a -> ()) -> NFData a
$crnf :: FPUnaryOp -> ()
rnf :: FPUnaryOp -> ()
NFData)

instance Show FPUnaryOp where
  show :: FPUnaryOp -> String
show FPUnaryOp
FPAbs = String
"fp.abs"
  show FPUnaryOp
FPNeg = String
"fp.neg"

-- | Binary floating point operations.
data FPBinaryOp
  = FPRem
  | FPMinimum
  | FPMinimumNumber
  | FPMaximum
  | FPMaximumNumber
  deriving (FPBinaryOp -> FPBinaryOp -> Bool
(FPBinaryOp -> FPBinaryOp -> Bool)
-> (FPBinaryOp -> FPBinaryOp -> Bool) -> Eq FPBinaryOp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FPBinaryOp -> FPBinaryOp -> Bool
== :: FPBinaryOp -> FPBinaryOp -> Bool
$c/= :: FPBinaryOp -> FPBinaryOp -> Bool
/= :: FPBinaryOp -> FPBinaryOp -> Bool
Eq, Eq FPBinaryOp
Eq FPBinaryOp =>
(FPBinaryOp -> FPBinaryOp -> Ordering)
-> (FPBinaryOp -> FPBinaryOp -> Bool)
-> (FPBinaryOp -> FPBinaryOp -> Bool)
-> (FPBinaryOp -> FPBinaryOp -> Bool)
-> (FPBinaryOp -> FPBinaryOp -> Bool)
-> (FPBinaryOp -> FPBinaryOp -> FPBinaryOp)
-> (FPBinaryOp -> FPBinaryOp -> FPBinaryOp)
-> Ord FPBinaryOp
FPBinaryOp -> FPBinaryOp -> Bool
FPBinaryOp -> FPBinaryOp -> Ordering
FPBinaryOp -> FPBinaryOp -> FPBinaryOp
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: FPBinaryOp -> FPBinaryOp -> Ordering
compare :: FPBinaryOp -> FPBinaryOp -> Ordering
$c< :: FPBinaryOp -> FPBinaryOp -> Bool
< :: FPBinaryOp -> FPBinaryOp -> Bool
$c<= :: FPBinaryOp -> FPBinaryOp -> Bool
<= :: FPBinaryOp -> FPBinaryOp -> Bool
$c> :: FPBinaryOp -> FPBinaryOp -> Bool
> :: FPBinaryOp -> FPBinaryOp -> Bool
$c>= :: FPBinaryOp -> FPBinaryOp -> Bool
>= :: FPBinaryOp -> FPBinaryOp -> Bool
$cmax :: FPBinaryOp -> FPBinaryOp -> FPBinaryOp
max :: FPBinaryOp -> FPBinaryOp -> FPBinaryOp
$cmin :: FPBinaryOp -> FPBinaryOp -> FPBinaryOp
min :: FPBinaryOp -> FPBinaryOp -> FPBinaryOp
Ord, (forall x. FPBinaryOp -> Rep FPBinaryOp x)
-> (forall x. Rep FPBinaryOp x -> FPBinaryOp) -> Generic FPBinaryOp
forall x. Rep FPBinaryOp x -> FPBinaryOp
forall x. FPBinaryOp -> Rep FPBinaryOp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FPBinaryOp -> Rep FPBinaryOp x
from :: forall x. FPBinaryOp -> Rep FPBinaryOp x
$cto :: forall x. Rep FPBinaryOp x -> FPBinaryOp
to :: forall x. Rep FPBinaryOp x -> FPBinaryOp
Generic, Eq FPBinaryOp
Eq FPBinaryOp =>
(Int -> FPBinaryOp -> Int)
-> (FPBinaryOp -> Int) -> Hashable FPBinaryOp
Int -> FPBinaryOp -> Int
FPBinaryOp -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> FPBinaryOp -> Int
hashWithSalt :: Int -> FPBinaryOp -> Int
$chash :: FPBinaryOp -> Int
hash :: FPBinaryOp -> Int
Hashable, (forall (m :: * -> *). Quote m => FPBinaryOp -> m Exp)
-> (forall (m :: * -> *).
    Quote m =>
    FPBinaryOp -> Code m FPBinaryOp)
-> Lift FPBinaryOp
forall t.
(forall (m :: * -> *). Quote m => t -> m Exp)
-> (forall (m :: * -> *). Quote m => t -> Code m t) -> Lift t
forall (m :: * -> *). Quote m => FPBinaryOp -> m Exp
forall (m :: * -> *). Quote m => FPBinaryOp -> Code m FPBinaryOp
$clift :: forall (m :: * -> *). Quote m => FPBinaryOp -> m Exp
lift :: forall (m :: * -> *). Quote m => FPBinaryOp -> m Exp
$cliftTyped :: forall (m :: * -> *). Quote m => FPBinaryOp -> Code m FPBinaryOp
liftTyped :: forall (m :: * -> *). Quote m => FPBinaryOp -> Code m FPBinaryOp
Lift, FPBinaryOp -> ()
(FPBinaryOp -> ()) -> NFData FPBinaryOp
forall a. (a -> ()) -> NFData a
$crnf :: FPBinaryOp -> ()
rnf :: FPBinaryOp -> ()
NFData)

instance Show FPBinaryOp where
  show :: FPBinaryOp -> String
show FPBinaryOp
FPRem = String
"fp.rem"
  show FPBinaryOp
FPMinimum = String
"fp.minimum"
  show FPBinaryOp
FPMinimumNumber = String
"fp.minimumNumber"
  show FPBinaryOp
FPMaximum = String
"fp.maximum"
  show FPBinaryOp
FPMaximumNumber = String
"fp.maximumNumber"

-- | Unary floating point operations with rounding modes.
data FPRoundingUnaryOp = FPSqrt | FPRoundToIntegral
  deriving (FPRoundingUnaryOp -> FPRoundingUnaryOp -> Bool
(FPRoundingUnaryOp -> FPRoundingUnaryOp -> Bool)
-> (FPRoundingUnaryOp -> FPRoundingUnaryOp -> Bool)
-> Eq FPRoundingUnaryOp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FPRoundingUnaryOp -> FPRoundingUnaryOp -> Bool
== :: FPRoundingUnaryOp -> FPRoundingUnaryOp -> Bool
$c/= :: FPRoundingUnaryOp -> FPRoundingUnaryOp -> Bool
/= :: FPRoundingUnaryOp -> FPRoundingUnaryOp -> Bool
Eq, Eq FPRoundingUnaryOp
Eq FPRoundingUnaryOp =>
(FPRoundingUnaryOp -> FPRoundingUnaryOp -> Ordering)
-> (FPRoundingUnaryOp -> FPRoundingUnaryOp -> Bool)
-> (FPRoundingUnaryOp -> FPRoundingUnaryOp -> Bool)
-> (FPRoundingUnaryOp -> FPRoundingUnaryOp -> Bool)
-> (FPRoundingUnaryOp -> FPRoundingUnaryOp -> Bool)
-> (FPRoundingUnaryOp -> FPRoundingUnaryOp -> FPRoundingUnaryOp)
-> (FPRoundingUnaryOp -> FPRoundingUnaryOp -> FPRoundingUnaryOp)
-> Ord FPRoundingUnaryOp
FPRoundingUnaryOp -> FPRoundingUnaryOp -> Bool
FPRoundingUnaryOp -> FPRoundingUnaryOp -> Ordering
FPRoundingUnaryOp -> FPRoundingUnaryOp -> FPRoundingUnaryOp
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: FPRoundingUnaryOp -> FPRoundingUnaryOp -> Ordering
compare :: FPRoundingUnaryOp -> FPRoundingUnaryOp -> Ordering
$c< :: FPRoundingUnaryOp -> FPRoundingUnaryOp -> Bool
< :: FPRoundingUnaryOp -> FPRoundingUnaryOp -> Bool
$c<= :: FPRoundingUnaryOp -> FPRoundingUnaryOp -> Bool
<= :: FPRoundingUnaryOp -> FPRoundingUnaryOp -> Bool
$c> :: FPRoundingUnaryOp -> FPRoundingUnaryOp -> Bool
> :: FPRoundingUnaryOp -> FPRoundingUnaryOp -> Bool
$c>= :: FPRoundingUnaryOp -> FPRoundingUnaryOp -> Bool
>= :: FPRoundingUnaryOp -> FPRoundingUnaryOp -> Bool
$cmax :: FPRoundingUnaryOp -> FPRoundingUnaryOp -> FPRoundingUnaryOp
max :: FPRoundingUnaryOp -> FPRoundingUnaryOp -> FPRoundingUnaryOp
$cmin :: FPRoundingUnaryOp -> FPRoundingUnaryOp -> FPRoundingUnaryOp
min :: FPRoundingUnaryOp -> FPRoundingUnaryOp -> FPRoundingUnaryOp
Ord, (forall x. FPRoundingUnaryOp -> Rep FPRoundingUnaryOp x)
-> (forall x. Rep FPRoundingUnaryOp x -> FPRoundingUnaryOp)
-> Generic FPRoundingUnaryOp
forall x. Rep FPRoundingUnaryOp x -> FPRoundingUnaryOp
forall x. FPRoundingUnaryOp -> Rep FPRoundingUnaryOp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FPRoundingUnaryOp -> Rep FPRoundingUnaryOp x
from :: forall x. FPRoundingUnaryOp -> Rep FPRoundingUnaryOp x
$cto :: forall x. Rep FPRoundingUnaryOp x -> FPRoundingUnaryOp
to :: forall x. Rep FPRoundingUnaryOp x -> FPRoundingUnaryOp
Generic, Eq FPRoundingUnaryOp
Eq FPRoundingUnaryOp =>
(Int -> FPRoundingUnaryOp -> Int)
-> (FPRoundingUnaryOp -> Int) -> Hashable FPRoundingUnaryOp
Int -> FPRoundingUnaryOp -> Int
FPRoundingUnaryOp -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> FPRoundingUnaryOp -> Int
hashWithSalt :: Int -> FPRoundingUnaryOp -> Int
$chash :: FPRoundingUnaryOp -> Int
hash :: FPRoundingUnaryOp -> Int
Hashable, (forall (m :: * -> *). Quote m => FPRoundingUnaryOp -> m Exp)
-> (forall (m :: * -> *).
    Quote m =>
    FPRoundingUnaryOp -> Code m FPRoundingUnaryOp)
-> Lift FPRoundingUnaryOp
forall t.
(forall (m :: * -> *). Quote m => t -> m Exp)
-> (forall (m :: * -> *). Quote m => t -> Code m t) -> Lift t
forall (m :: * -> *). Quote m => FPRoundingUnaryOp -> m Exp
forall (m :: * -> *).
Quote m =>
FPRoundingUnaryOp -> Code m FPRoundingUnaryOp
$clift :: forall (m :: * -> *). Quote m => FPRoundingUnaryOp -> m Exp
lift :: forall (m :: * -> *). Quote m => FPRoundingUnaryOp -> m Exp
$cliftTyped :: forall (m :: * -> *).
Quote m =>
FPRoundingUnaryOp -> Code m FPRoundingUnaryOp
liftTyped :: forall (m :: * -> *).
Quote m =>
FPRoundingUnaryOp -> Code m FPRoundingUnaryOp
Lift, FPRoundingUnaryOp -> ()
(FPRoundingUnaryOp -> ()) -> NFData FPRoundingUnaryOp
forall a. (a -> ()) -> NFData a
$crnf :: FPRoundingUnaryOp -> ()
rnf :: FPRoundingUnaryOp -> ()
NFData)

instance Show FPRoundingUnaryOp where
  show :: FPRoundingUnaryOp -> String
show FPRoundingUnaryOp
FPSqrt = String
"fp.sqrt"
  show FPRoundingUnaryOp
FPRoundToIntegral = String
"fp.roundToIntegral"

-- | Binary floating point operations with rounding modes.
data FPRoundingBinaryOp = FPAdd | FPSub | FPMul | FPDiv
  deriving (FPRoundingBinaryOp -> FPRoundingBinaryOp -> Bool
(FPRoundingBinaryOp -> FPRoundingBinaryOp -> Bool)
-> (FPRoundingBinaryOp -> FPRoundingBinaryOp -> Bool)
-> Eq FPRoundingBinaryOp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FPRoundingBinaryOp -> FPRoundingBinaryOp -> Bool
== :: FPRoundingBinaryOp -> FPRoundingBinaryOp -> Bool
$c/= :: FPRoundingBinaryOp -> FPRoundingBinaryOp -> Bool
/= :: FPRoundingBinaryOp -> FPRoundingBinaryOp -> Bool
Eq, Eq FPRoundingBinaryOp
Eq FPRoundingBinaryOp =>
(FPRoundingBinaryOp -> FPRoundingBinaryOp -> Ordering)
-> (FPRoundingBinaryOp -> FPRoundingBinaryOp -> Bool)
-> (FPRoundingBinaryOp -> FPRoundingBinaryOp -> Bool)
-> (FPRoundingBinaryOp -> FPRoundingBinaryOp -> Bool)
-> (FPRoundingBinaryOp -> FPRoundingBinaryOp -> Bool)
-> (FPRoundingBinaryOp -> FPRoundingBinaryOp -> FPRoundingBinaryOp)
-> (FPRoundingBinaryOp -> FPRoundingBinaryOp -> FPRoundingBinaryOp)
-> Ord FPRoundingBinaryOp
FPRoundingBinaryOp -> FPRoundingBinaryOp -> Bool
FPRoundingBinaryOp -> FPRoundingBinaryOp -> Ordering
FPRoundingBinaryOp -> FPRoundingBinaryOp -> FPRoundingBinaryOp
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: FPRoundingBinaryOp -> FPRoundingBinaryOp -> Ordering
compare :: FPRoundingBinaryOp -> FPRoundingBinaryOp -> Ordering
$c< :: FPRoundingBinaryOp -> FPRoundingBinaryOp -> Bool
< :: FPRoundingBinaryOp -> FPRoundingBinaryOp -> Bool
$c<= :: FPRoundingBinaryOp -> FPRoundingBinaryOp -> Bool
<= :: FPRoundingBinaryOp -> FPRoundingBinaryOp -> Bool
$c> :: FPRoundingBinaryOp -> FPRoundingBinaryOp -> Bool
> :: FPRoundingBinaryOp -> FPRoundingBinaryOp -> Bool
$c>= :: FPRoundingBinaryOp -> FPRoundingBinaryOp -> Bool
>= :: FPRoundingBinaryOp -> FPRoundingBinaryOp -> Bool
$cmax :: FPRoundingBinaryOp -> FPRoundingBinaryOp -> FPRoundingBinaryOp
max :: FPRoundingBinaryOp -> FPRoundingBinaryOp -> FPRoundingBinaryOp
$cmin :: FPRoundingBinaryOp -> FPRoundingBinaryOp -> FPRoundingBinaryOp
min :: FPRoundingBinaryOp -> FPRoundingBinaryOp -> FPRoundingBinaryOp
Ord, (forall x. FPRoundingBinaryOp -> Rep FPRoundingBinaryOp x)
-> (forall x. Rep FPRoundingBinaryOp x -> FPRoundingBinaryOp)
-> Generic FPRoundingBinaryOp
forall x. Rep FPRoundingBinaryOp x -> FPRoundingBinaryOp
forall x. FPRoundingBinaryOp -> Rep FPRoundingBinaryOp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FPRoundingBinaryOp -> Rep FPRoundingBinaryOp x
from :: forall x. FPRoundingBinaryOp -> Rep FPRoundingBinaryOp x
$cto :: forall x. Rep FPRoundingBinaryOp x -> FPRoundingBinaryOp
to :: forall x. Rep FPRoundingBinaryOp x -> FPRoundingBinaryOp
Generic, Eq FPRoundingBinaryOp
Eq FPRoundingBinaryOp =>
(Int -> FPRoundingBinaryOp -> Int)
-> (FPRoundingBinaryOp -> Int) -> Hashable FPRoundingBinaryOp
Int -> FPRoundingBinaryOp -> Int
FPRoundingBinaryOp -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> FPRoundingBinaryOp -> Int
hashWithSalt :: Int -> FPRoundingBinaryOp -> Int
$chash :: FPRoundingBinaryOp -> Int
hash :: FPRoundingBinaryOp -> Int
Hashable, (forall (m :: * -> *). Quote m => FPRoundingBinaryOp -> m Exp)
-> (forall (m :: * -> *).
    Quote m =>
    FPRoundingBinaryOp -> Code m FPRoundingBinaryOp)
-> Lift FPRoundingBinaryOp
forall t.
(forall (m :: * -> *). Quote m => t -> m Exp)
-> (forall (m :: * -> *). Quote m => t -> Code m t) -> Lift t
forall (m :: * -> *). Quote m => FPRoundingBinaryOp -> m Exp
forall (m :: * -> *).
Quote m =>
FPRoundingBinaryOp -> Code m FPRoundingBinaryOp
$clift :: forall (m :: * -> *). Quote m => FPRoundingBinaryOp -> m Exp
lift :: forall (m :: * -> *). Quote m => FPRoundingBinaryOp -> m Exp
$cliftTyped :: forall (m :: * -> *).
Quote m =>
FPRoundingBinaryOp -> Code m FPRoundingBinaryOp
liftTyped :: forall (m :: * -> *).
Quote m =>
FPRoundingBinaryOp -> Code m FPRoundingBinaryOp
Lift, FPRoundingBinaryOp -> ()
(FPRoundingBinaryOp -> ()) -> NFData FPRoundingBinaryOp
forall a. (a -> ()) -> NFData a
$crnf :: FPRoundingBinaryOp -> ()
rnf :: FPRoundingBinaryOp -> ()
NFData)

instance Show FPRoundingBinaryOp where
  show :: FPRoundingBinaryOp -> String
show FPRoundingBinaryOp
FPAdd = String
"fp.add"
  show FPRoundingBinaryOp
FPSub = String
"fp.sub"
  show FPRoundingBinaryOp
FPMul = String
"fp.mul"
  show FPRoundingBinaryOp
FPDiv = String
"fp.div"

-- | Internal representation for Grisette symbolic terms.
data Term t where
  ConTerm :: (SupportedPrim t) => {-# UNPACK #-} !Id -> !t -> Term t
  SymTerm :: (SupportedPrim t) => {-# UNPACK #-} !Id -> !(TypedSymbol 'AnyKind t) -> Term t
  ForallTerm :: (SupportedNonFuncPrim t) => {-# UNPACK #-} !Id -> !(TypedSymbol 'ConstantKind t) -> !(Term Bool) -> Term Bool
  ExistsTerm :: (SupportedNonFuncPrim t) => {-# UNPACK #-} !Id -> !(TypedSymbol 'ConstantKind t) -> !(Term Bool) -> Term Bool
  UnaryTerm ::
    (UnaryOp tag arg t) =>
    {-# UNPACK #-} !Id ->
    !tag ->
    !(Term arg) ->
    Term t
  BinaryTerm ::
    (BinaryOp tag arg1 arg2 t) =>
    {-# UNPACK #-} !Id ->
    !tag ->
    !(Term arg1) ->
    !(Term arg2) ->
    Term t
  TernaryTerm ::
    (TernaryOp tag arg1 arg2 arg3 t) =>
    {-# UNPACK #-} !Id ->
    !tag ->
    !(Term arg1) ->
    !(Term arg2) ->
    !(Term arg3) ->
    Term t
  NotTerm :: {-# UNPACK #-} !Id -> !(Term Bool) -> Term Bool
  OrTerm :: {-# UNPACK #-} !Id -> !(Term Bool) -> !(Term Bool) -> Term Bool
  AndTerm :: {-# UNPACK #-} !Id -> !(Term Bool) -> !(Term Bool) -> Term Bool
  EqTerm ::
    (SupportedNonFuncPrim t) =>
    {-# UNPACK #-} !Id ->
    !(Term t) ->
    !(Term t) ->
    Term Bool
  DistinctTerm ::
    (SupportedNonFuncPrim t) =>
    {-# UNPACK #-} !Id ->
    !(NonEmpty (Term t)) ->
    Term Bool
  ITETerm ::
    (SupportedPrim t) =>
    {-# UNPACK #-} !Id ->
    !(Term Bool) ->
    !(Term t) ->
    !(Term t) ->
    Term t
  AddNumTerm ::
    (PEvalNumTerm t) =>
    {-# UNPACK #-} !Id ->
    !(Term t) ->
    !(Term t) ->
    Term t
  NegNumTerm ::
    (PEvalNumTerm t) =>
    {-# UNPACK #-} !Id ->
    !(Term t) ->
    Term t
  MulNumTerm ::
    (PEvalNumTerm t) =>
    {-# UNPACK #-} !Id ->
    !(Term t) ->
    !(Term t) ->
    Term t
  AbsNumTerm ::
    (PEvalNumTerm t) => {-# UNPACK #-} !Id -> !(Term t) -> Term t
  SignumNumTerm :: (PEvalNumTerm t) => {-# UNPACK #-} !Id -> !(Term t) -> Term t
  LtOrdTerm ::
    (PEvalOrdTerm t) =>
    {-# UNPACK #-} !Id ->
    !(Term t) ->
    !(Term t) ->
    Term Bool
  LeOrdTerm ::
    (PEvalOrdTerm t) =>
    {-# UNPACK #-} !Id ->
    !(Term t) ->
    !(Term t) ->
    Term Bool
  AndBitsTerm ::
    (PEvalBitwiseTerm t) =>
    {-# UNPACK #-} !Id ->
    !(Term t) ->
    !(Term t) ->
    Term t
  OrBitsTerm ::
    (PEvalBitwiseTerm t) =>
    {-# UNPACK #-} !Id ->
    !(Term t) ->
    !(Term t) ->
    Term t
  XorBitsTerm ::
    (PEvalBitwiseTerm t) =>
    {-# UNPACK #-} !Id ->
    !(Term t) ->
    !(Term t) ->
    Term t
  ComplementBitsTerm ::
    (PEvalBitwiseTerm t) =>
    {-# UNPACK #-} !Id ->
    !(Term t) ->
    Term t
  ShiftLeftTerm ::
    (PEvalShiftTerm t) => {-# UNPACK #-} !Id -> !(Term t) -> !(Term t) -> Term t
  ShiftRightTerm ::
    (PEvalShiftTerm t) => {-# UNPACK #-} !Id -> !(Term t) -> !(Term t) -> Term t
  RotateLeftTerm ::
    (PEvalRotateTerm t) =>
    {-# UNPACK #-} !Id ->
    !(Term t) ->
    !(Term t) ->
    Term t
  RotateRightTerm ::
    (PEvalRotateTerm t) =>
    {-# UNPACK #-} !Id ->
    !(Term t) ->
    !(Term t) ->
    Term t
  BitCastTerm ::
    (PEvalBitCastTerm a b) =>
    {-# UNPACK #-} !Id ->
    !(Term a) ->
    Term b
  BitCastOrTerm ::
    (PEvalBitCastOrTerm a b) =>
    {-# UNPACK #-} !Id ->
    !(Term b) ->
    !(Term a) ->
    Term b
  BVConcatTerm ::
    ( PEvalBVTerm bv,
      KnownNat l,
      KnownNat r,
      KnownNat (l + r),
      1 <= l,
      1 <= r,
      1 <= l + r
    ) =>
    {-# UNPACK #-} !Id ->
    !(Term (bv l)) ->
    !(Term (bv r)) ->
    Term (bv (l + r))
  BVSelectTerm ::
    ( PEvalBVTerm bv,
      KnownNat n,
      KnownNat ix,
      KnownNat w,
      1 <= n,
      1 <= w,
      ix + w <= n
    ) =>
    {-# UNPACK #-} !Id ->
    !(TypeRep ix) ->
    !(TypeRep w) ->
    !(Term (bv n)) ->
    Term (bv w)
  BVExtendTerm ::
    (PEvalBVTerm bv, KnownNat l, KnownNat r, 1 <= l, 1 <= r, l <= r) =>
    {-# UNPACK #-} !Id ->
    !Bool ->
    !(TypeRep r) ->
    !(Term (bv l)) ->
    Term (bv r)
  ApplyTerm ::
    ( SupportedPrim a,
      SupportedPrim b,
      SupportedPrim f,
      PEvalApplyTerm f a b
    ) =>
    {-# UNPACK #-} !Id ->
    !(Term f) ->
    !(Term a) ->
    Term b
  DivIntegralTerm ::
    (PEvalDivModIntegralTerm t) =>
    {-# UNPACK #-} !Id ->
    !(Term t) ->
    !(Term t) ->
    Term t
  ModIntegralTerm ::
    (PEvalDivModIntegralTerm t) =>
    {-# UNPACK #-} !Id ->
    !(Term t) ->
    !(Term t) ->
    Term t
  QuotIntegralTerm ::
    (PEvalDivModIntegralTerm t) =>
    {-# UNPACK #-} !Id ->
    !(Term t) ->
    !(Term t) ->
    Term t
  RemIntegralTerm ::
    (PEvalDivModIntegralTerm t) =>
    {-# UNPACK #-} !Id ->
    !(Term t) ->
    !(Term t) ->
    Term t
  FPTraitTerm ::
    (ValidFP eb sb, SupportedPrim (FP eb sb)) =>
    {-# UNPACK #-} !Id ->
    !FPTrait ->
    !(Term (FP eb sb)) ->
    Term Bool
  FdivTerm ::
    (PEvalFractionalTerm t) =>
    {-# UNPACK #-} !Id ->
    !(Term t) ->
    !(Term t) ->
    Term t
  RecipTerm ::
    (PEvalFractionalTerm t) =>
    {-# UNPACK #-} !Id ->
    !(Term t) ->
    Term t
  FloatingUnaryTerm ::
    (PEvalFloatingTerm t) =>
    {-# UNPACK #-} !Id ->
    !FloatingUnaryOp ->
    !(Term t) ->
    Term t
  PowerTerm ::
    (PEvalFloatingTerm t) =>
    {-# UNPACK #-} !Id ->
    !(Term t) ->
    !(Term t) ->
    Term t
  FPUnaryTerm ::
    (ValidFP eb sb, SupportedPrim (FP eb sb)) =>
    {-# UNPACK #-} !Id ->
    !FPUnaryOp ->
    !(Term (FP eb sb)) ->
    Term (FP eb sb)
  FPBinaryTerm ::
    (ValidFP eb sb, SupportedPrim (FP eb sb)) =>
    {-# UNPACK #-} !Id ->
    !FPBinaryOp ->
    !(Term (FP eb sb)) ->
    !(Term (FP eb sb)) ->
    Term (FP eb sb)
  FPRoundingUnaryTerm ::
    (ValidFP eb sb, SupportedPrim (FP eb sb), SupportedPrim FPRoundingMode) =>
    {-# UNPACK #-} !Id ->
    !FPRoundingUnaryOp ->
    !(Term FPRoundingMode) ->
    !(Term (FP eb sb)) ->
    Term (FP eb sb)
  FPRoundingBinaryTerm ::
    (ValidFP eb sb, SupportedPrim (FP eb sb), SupportedPrim FPRoundingMode) =>
    {-# UNPACK #-} !Id ->
    !FPRoundingBinaryOp ->
    !(Term FPRoundingMode) ->
    !(Term (FP eb sb)) ->
    !(Term (FP eb sb)) ->
    Term (FP eb sb)
  FPFMATerm ::
    (ValidFP eb sb, SupportedPrim (FP eb sb), SupportedPrim FPRoundingMode) =>
    {-# UNPACK #-} !Id ->
    !(Term FPRoundingMode) ->
    !(Term (FP eb sb)) ->
    !(Term (FP eb sb)) ->
    !(Term (FP eb sb)) ->
    Term (FP eb sb)
  FromIntegralTerm ::
    (PEvalFromIntegralTerm a b) =>
    {-# UNPACK #-} !Id ->
    !(Term a) ->
    Term b
  FromFPOrTerm ::
    ( PEvalIEEEFPConvertibleTerm a,
      ValidFP eb sb,
      SupportedPrim (FP eb sb),
      SupportedPrim FPRoundingMode
    ) =>
    {-# UNPACK #-} !Id ->
    !(Term a) ->
    !(Term FPRoundingMode) ->
    !(Term (FP eb sb)) ->
    Term a
  ToFPTerm ::
    ( PEvalIEEEFPConvertibleTerm a,
      ValidFP eb sb,
      SupportedPrim (FP eb sb),
      SupportedPrim FPRoundingMode
    ) =>
    {-# UNPACK #-} !Id ->
    !(Term FPRoundingMode) ->
    !(Term a) ->
    Proxy eb ->
    Proxy sb ->
    Term (FP eb sb)

-- | Return the ID of a term.
identity :: Term t -> Id
identity :: forall t. Term t -> Int
identity = (SomeTypeRep, Int) -> Int
forall a b. (a, b) -> b
snd ((SomeTypeRep, Int) -> Int)
-> (Term t -> (SomeTypeRep, Int)) -> Term t -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term t -> (SomeTypeRep, Int)
forall t. Term t -> (SomeTypeRep, Int)
identityWithTypeRep
{-# INLINE identity #-}

-- | Return the ID and the type representation of a term.
identityWithTypeRep :: forall t. Term t -> (SomeTypeRep, Id)
identityWithTypeRep :: forall t. Term t -> (SomeTypeRep, Int)
identityWithTypeRep (ConTerm Int
i t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (SymTerm Int
i TypedSymbol 'AnyKind t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (ForallTerm Int
i TypedSymbol 'ConstantKind t
_ Term Bool
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (ExistsTerm Int
i TypedSymbol 'ConstantKind t
_ Term Bool
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (UnaryTerm Int
i tag
_ Term arg
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (BinaryTerm Int
i tag
_ Term arg1
_ Term arg2
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (TernaryTerm Int
i tag
_ Term arg1
_ Term arg2
_ Term arg3
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (NotTerm Int
i Term Bool
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (OrTerm Int
i Term Bool
_ Term Bool
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (AndTerm Int
i Term Bool
_ Term Bool
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (EqTerm Int
i Term t
_ Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (DistinctTerm Int
i NonEmpty (Term t)
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (ITETerm Int
i Term Bool
_ Term t
_ Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (AddNumTerm Int
i Term t
_ Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (NegNumTerm Int
i Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (MulNumTerm Int
i Term t
_ Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (AbsNumTerm Int
i Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (SignumNumTerm Int
i Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (LtOrdTerm Int
i Term t
_ Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (LeOrdTerm Int
i Term t
_ Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (AndBitsTerm Int
i Term t
_ Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (OrBitsTerm Int
i Term t
_ Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (XorBitsTerm Int
i Term t
_ Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (ComplementBitsTerm Int
i Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (ShiftLeftTerm Int
i Term t
_ Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (ShiftRightTerm Int
i Term t
_ Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (RotateLeftTerm Int
i Term t
_ Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (RotateRightTerm Int
i Term t
_ Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (BitCastTerm Int
i Term a
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (BitCastOrTerm Int
i Term t
_ Term a
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (BVConcatTerm Int
i Term (bv l)
_ Term (bv r)
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (BVSelectTerm Int
i TypeRep ix
_ TypeRep w
_ Term (bv n)
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (BVExtendTerm Int
i Bool
_ TypeRep r
_ Term (bv l)
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (ApplyTerm Int
i Term f
_ Term a
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (DivIntegralTerm Int
i Term t
_ Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (ModIntegralTerm Int
i Term t
_ Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (QuotIntegralTerm Int
i Term t
_ Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (RemIntegralTerm Int
i Term t
_ Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (FPTraitTerm Int
i FPTrait
_ Term (FP eb sb)
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (FdivTerm Int
i Term t
_ Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (RecipTerm Int
i Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (FloatingUnaryTerm Int
i FloatingUnaryOp
_ Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (PowerTerm Int
i Term t
_ Term t
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (FPUnaryTerm Int
i FPUnaryOp
_ Term (FP eb sb)
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (FPBinaryTerm Int
i FPBinaryOp
_ Term (FP eb sb)
_ Term (FP eb sb)
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (FPRoundingUnaryTerm Int
i FPRoundingUnaryOp
_ Term FPRoundingMode
_ Term (FP eb sb)
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (FPRoundingBinaryTerm Int
i FPRoundingBinaryOp
_ Term FPRoundingMode
_ Term (FP eb sb)
_ Term (FP eb sb)
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (FPFMATerm Int
i Term FPRoundingMode
_ Term (FP eb sb)
_ Term (FP eb sb)
_ Term (FP eb sb)
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (FromIntegralTerm Int
i Term a
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (FromFPOrTerm Int
i Term t
_ Term FPRoundingMode
_ Term (FP eb sb)
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
identityWithTypeRep (ToFPTerm Int
i Term FPRoundingMode
_ Term a
_ Proxy eb
_ Proxy sb
_) = (Proxy t -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @t), Int
i)
{-# INLINE identityWithTypeRep #-}

-- | Introduce the 'SupportedPrim' constraint from a term.
introSupportedPrimConstraint :: forall t a. Term t -> ((SupportedPrim t) => a) -> a
introSupportedPrimConstraint :: forall t a. Term t -> (SupportedPrim t => a) -> a
introSupportedPrimConstraint ConTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint SymTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint ForallTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint ExistsTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint UnaryTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint BinaryTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint TernaryTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint NotTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint OrTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint AndTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint EqTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint DistinctTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint ITETerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint AddNumTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint NegNumTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint MulNumTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint AbsNumTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint SignumNumTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint LtOrdTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint LeOrdTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint AndBitsTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint OrBitsTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint XorBitsTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint ComplementBitsTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint ShiftLeftTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint RotateLeftTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint ShiftRightTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint RotateRightTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint BitCastTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint BitCastOrTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint BVConcatTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint BVSelectTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint BVExtendTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint ApplyTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint DivIntegralTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint ModIntegralTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint QuotIntegralTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint RemIntegralTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint FPTraitTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint FdivTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint RecipTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint FloatingUnaryTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint PowerTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint FPUnaryTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint FPBinaryTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint FPRoundingUnaryTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint FPRoundingBinaryTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint FPFMATerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint FromIntegralTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint FromFPOrTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
introSupportedPrimConstraint ToFPTerm {} SupportedPrim t => a
x = a
SupportedPrim t => a
x
{-# INLINE introSupportedPrimConstraint #-}

-- | Pretty-print a term.
pformatTerm :: forall t. (SupportedPrim t) => Term t -> String
pformatTerm :: forall t. SupportedPrim t => Term t -> String
pformatTerm (ConTerm Int
_ t
t) = t -> String
forall t. SupportedPrim t => t -> String
pformatCon t
t
pformatTerm (SymTerm Int
_ TypedSymbol 'AnyKind t
sym) = TypedSymbol 'AnyKind t -> String
forall t. SupportedPrim t => TypedSymbol 'AnyKind t -> String
pformatSym TypedSymbol 'AnyKind t
sym
pformatTerm (ForallTerm Int
_ TypedSymbol 'ConstantKind t
sym Term Bool
arg) = String
"(forall " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypedSymbol 'ConstantKind t -> String
forall a. Show a => a -> String
show TypedSymbol 'ConstantKind t
sym String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term Bool -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term Bool
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (ExistsTerm Int
_ TypedSymbol 'ConstantKind t
sym Term Bool
arg) = String
"(exists " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypedSymbol 'ConstantKind t -> String
forall a. Show a => a -> String
show TypedSymbol 'ConstantKind t
sym String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term Bool -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term Bool
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (UnaryTerm Int
_ tag
tag Term arg
arg1) = tag -> Term arg -> String
forall tag arg t. UnaryOp tag arg t => tag -> Term arg -> String
pformatUnary tag
tag Term arg
arg1
pformatTerm (BinaryTerm Int
_ tag
tag Term arg1
arg1 Term arg2
arg2) = tag -> Term arg1 -> Term arg2 -> String
forall tag arg1 arg2 t.
BinaryOp tag arg1 arg2 t =>
tag -> Term arg1 -> Term arg2 -> String
pformatBinary tag
tag Term arg1
arg1 Term arg2
arg2
pformatTerm (TernaryTerm Int
_ tag
tag Term arg1
arg1 Term arg2
arg2 Term arg3
arg3) = tag -> Term arg1 -> Term arg2 -> Term arg3 -> String
forall tag arg1 arg2 arg3 t.
TernaryOp tag arg1 arg2 arg3 t =>
tag -> Term arg1 -> Term arg2 -> Term arg3 -> String
pformatTernary tag
tag Term arg1
arg1 Term arg2
arg2 Term arg3
arg3
pformatTerm (NotTerm Int
_ Term Bool
arg) = String
"(! " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term Bool -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term Bool
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (OrTerm Int
_ Term Bool
arg1 Term Bool
arg2) = String
"(|| " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term Bool -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term Bool
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term Bool -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term Bool
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (AndTerm Int
_ Term Bool
arg1 Term Bool
arg2) = String
"(&& " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term Bool -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term Bool
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term Bool -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term Bool
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (EqTerm Int
_ Term t
arg1 Term t
arg2) = String
"(= " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (DistinctTerm Int
_ NonEmpty (Term t)
args) = String
"(distinct " String -> String -> String
forall a. [a] -> [a] -> [a]
++ [String] -> String
unwords ((Term t -> String) -> [Term t] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm ([Term t] -> [String]) -> [Term t] -> [String]
forall a b. (a -> b) -> a -> b
$ NonEmpty (Term t) -> [Term t]
forall a. NonEmpty a -> [a]
toList NonEmpty (Term t)
args) String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (ITETerm Int
_ Term Bool
cond Term t
arg1 Term t
arg2) = String
"(ite " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term Bool -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term Bool
cond String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (AddNumTerm Int
_ Term t
arg1 Term t
arg2) = String
"(+ " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (NegNumTerm Int
_ Term t
arg) = String
"(- " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (MulNumTerm Int
_ Term t
arg1 Term t
arg2) = String
"(* " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (AbsNumTerm Int
_ Term t
arg) = String
"(abs " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (SignumNumTerm Int
_ Term t
arg) = String
"(signum " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (LtOrdTerm Int
_ Term t
arg1 Term t
arg2) = String
"(< " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (LeOrdTerm Int
_ Term t
arg1 Term t
arg2) = String
"(<= " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (AndBitsTerm Int
_ Term t
arg1 Term t
arg2) = String
"(& " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (OrBitsTerm Int
_ Term t
arg1 Term t
arg2) = String
"(| " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (XorBitsTerm Int
_ Term t
arg1 Term t
arg2) = String
"(^ " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (ComplementBitsTerm Int
_ Term t
arg) = String
"(~ " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (ShiftLeftTerm Int
_ Term t
arg Term t
n) = String
"(shl " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
n String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (ShiftRightTerm Int
_ Term t
arg Term t
n) = String
"(shr " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
n String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (RotateLeftTerm Int
_ Term t
arg Term t
n) = String
"(rotl " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
n String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (RotateRightTerm Int
_ Term t
arg Term t
n) = String
"(rotr " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
n String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (BitCastTerm Int
_ Term a
arg) = String
"(bitcast " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term a -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term a
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (BitCastOrTerm Int
_ Term t
d Term a
arg) = String
"(bitcast_or " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
d String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term a -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term a
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (BVConcatTerm Int
_ Term (bv l)
arg1 Term (bv r)
arg2) = String
"(bvconcat " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (bv l) -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term (bv l)
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (bv r) -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term (bv r)
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (BVSelectTerm Int
_ TypeRep ix
ix TypeRep w
w Term (bv n)
arg) = String
"(bvselect " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep ix -> String
forall a. Show a => a -> String
show TypeRep ix
ix String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep w -> String
forall a. Show a => a -> String
show TypeRep w
w String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (bv n) -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term (bv n)
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (BVExtendTerm Int
_ Bool
signed TypeRep r
n Term (bv l)
arg) =
  (if Bool
signed then String
"(bvsext " else String
"(bvzext ") String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep r -> String
forall a. Show a => a -> String
show TypeRep r
n String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (bv l) -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term (bv l)
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (ApplyTerm Int
_ Term f
func Term a
arg) = String
"(apply " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term f -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term f
func String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term a -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term a
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (DivIntegralTerm Int
_ Term t
arg1 Term t
arg2) = String
"(div " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (ModIntegralTerm Int
_ Term t
arg1 Term t
arg2) = String
"(mod " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (QuotIntegralTerm Int
_ Term t
arg1 Term t
arg2) = String
"(quot " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (RemIntegralTerm Int
_ Term t
arg1 Term t
arg2) = String
"(rem " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (FPTraitTerm Int
_ FPTrait
trait Term (FP eb sb)
arg) = String
"(" String -> String -> String
forall a. [a] -> [a] -> [a]
++ FPTrait -> String
forall a. Show a => a -> String
show FPTrait
trait String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (FP eb sb) -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term (FP eb sb)
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (FdivTerm Int
_ Term t
arg1 Term t
arg2) = String
"(fdiv " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (RecipTerm Int
_ Term t
arg) = String
"(recip " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (FloatingUnaryTerm Int
_ FloatingUnaryOp
op Term t
arg) = String
"(" String -> String -> String
forall a. [a] -> [a] -> [a]
++ FloatingUnaryOp -> String
forall a. Show a => a -> String
show FloatingUnaryOp
op String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (PowerTerm Int
_ Term t
arg1 Term t
arg2) = String
"(** " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (FPUnaryTerm Int
_ FPUnaryOp
op Term (FP eb sb)
arg) = String
"(" String -> String -> String
forall a. [a] -> [a] -> [a]
++ FPUnaryOp -> String
forall a. Show a => a -> String
show FPUnaryOp
op String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (FP eb sb) -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term (FP eb sb)
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (FPBinaryTerm Int
_ FPBinaryOp
op Term (FP eb sb)
arg1 Term (FP eb sb)
arg2) = String
"(" String -> String -> String
forall a. [a] -> [a] -> [a]
++ FPBinaryOp -> String
forall a. Show a => a -> String
show FPBinaryOp
op String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (FP eb sb) -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term (FP eb sb)
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (FP eb sb) -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term (FP eb sb)
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (FPRoundingUnaryTerm Int
_ FPRoundingUnaryOp
op Term FPRoundingMode
mode Term (FP eb sb)
arg) = String
"(" String -> String -> String
forall a. [a] -> [a] -> [a]
++ FPRoundingUnaryOp -> String
forall a. Show a => a -> String
show FPRoundingUnaryOp
op String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term FPRoundingMode -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term FPRoundingMode
mode String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (FP eb sb) -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term (FP eb sb)
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (FPRoundingBinaryTerm Int
_ FPRoundingBinaryOp
op Term FPRoundingMode
mode Term (FP eb sb)
arg1 Term (FP eb sb)
arg2) =
  String
"(" String -> String -> String
forall a. [a] -> [a] -> [a]
++ FPRoundingBinaryOp -> String
forall a. Show a => a -> String
show FPRoundingBinaryOp
op String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term FPRoundingMode -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term FPRoundingMode
mode String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (FP eb sb) -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term (FP eb sb)
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (FP eb sb) -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term (FP eb sb)
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (FPFMATerm Int
_ Term FPRoundingMode
mode Term (FP eb sb)
arg1 Term (FP eb sb)
arg2 Term (FP eb sb)
arg3) =
  String
"(fp.fma " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term FPRoundingMode -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term FPRoundingMode
mode String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (FP eb sb) -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term (FP eb sb)
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (FP eb sb) -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term (FP eb sb)
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (FP eb sb) -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term (FP eb sb)
arg3 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (FromIntegralTerm Int
_ Term a
arg) = String
"(from_integral " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term a -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term a
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (FromFPOrTerm Int
_ Term t
d Term FPRoundingMode
r Term (FP eb sb)
arg) = String
"(from_fp_or " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
d String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term FPRoundingMode -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term FPRoundingMode
r String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (FP eb sb) -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term (FP eb sb)
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
pformatTerm (ToFPTerm Int
_ Term FPRoundingMode
r Term a
arg Proxy eb
_ Proxy sb
_) = String
"(to_fp " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term FPRoundingMode -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term FPRoundingMode
r String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term a -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term a
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
{-# INLINE pformatTerm #-}

instance NFData (Term a) where
  rnf :: Term a -> ()
rnf Term a
i = Term a -> Int
forall t. Term t -> Int
identity Term a
i Int -> () -> ()
forall a b. a -> b -> b
`seq` ()

instance Lift (Term t) where
  liftTyped :: forall (m :: * -> *). Quote m => Term t -> Code m (Term t)
liftTyped (ConTerm Int
_ t
i) = [||t -> Term t
forall t.
(SupportedPrim t, Typeable t, Hashable t, Eq t, Show t) =>
t -> Term t
conTerm t
i||]
  liftTyped (SymTerm Int
_ TypedSymbol 'AnyKind t
sym) = [||Symbol -> Term t
forall t. (SupportedPrim t, Typeable t) => Symbol -> Term t
symTerm (TypedSymbol knd t -> Symbol
forall t (knd :: SymbolKind). TypedSymbol knd t -> Symbol
unTypedSymbol TypedSymbol 'AnyKind t
sym)||]
  liftTyped (ForallTerm Int
_ TypedSymbol 'ConstantKind t
sym Term Bool
arg) = [||TypedSymbol 'ConstantKind t -> Term Bool -> Term Bool
forall t.
(SupportedNonFuncPrim t, Typeable t) =>
TypedSymbol 'ConstantKind t -> Term Bool -> Term Bool
forallTerm TypedSymbol 'ConstantKind t
sym Term Bool
arg||]
  liftTyped (ExistsTerm Int
_ TypedSymbol 'ConstantKind t
sym Term Bool
arg) = [||TypedSymbol 'ConstantKind t -> Term Bool -> Term Bool
forall t.
(SupportedNonFuncPrim t, Typeable t) =>
TypedSymbol 'ConstantKind t -> Term Bool -> Term Bool
existsTerm TypedSymbol 'ConstantKind t
sym Term Bool
arg||]
  liftTyped (UnaryTerm Int
_ tag
tag Term arg
arg) = [||tag -> Term arg -> Term t
forall tag arg t.
(SupportedPrim t, UnaryOp tag arg t, Typeable tag, Typeable t,
 Show tag) =>
tag -> Term arg -> Term t
constructUnary tag
tag Term arg
arg||]
  liftTyped (BinaryTerm Int
_ tag
tag Term arg1
arg1 Term arg2
arg2) = [||tag -> Term arg1 -> Term arg2 -> Term t
forall tag arg1 arg2 t.
(SupportedPrim t, BinaryOp tag arg1 arg2 t, Typeable tag,
 Typeable t, Show tag) =>
tag -> Term arg1 -> Term arg2 -> Term t
constructBinary tag
tag Term arg1
arg1 Term arg2
arg2||]
  liftTyped (TernaryTerm Int
_ tag
tag Term arg1
arg1 Term arg2
arg2 Term arg3
arg3) =
    [||tag -> Term arg1 -> Term arg2 -> Term arg3 -> Term t
forall tag arg1 arg2 arg3 t.
(SupportedPrim t, TernaryOp tag arg1 arg2 arg3 t, Typeable tag,
 Typeable t, Show tag) =>
tag -> Term arg1 -> Term arg2 -> Term arg3 -> Term t
constructTernary tag
tag Term arg1
arg1 Term arg2
arg2 Term arg3
arg3||]
  liftTyped (NotTerm Int
_ Term Bool
arg) = [||Term Bool -> Term Bool
notTerm Term Bool
arg||]
  liftTyped (OrTerm Int
_ Term Bool
arg1 Term Bool
arg2) = [||Term Bool -> Term Bool -> Term Bool
orTerm Term Bool
arg1 Term Bool
arg2||]
  liftTyped (AndTerm Int
_ Term Bool
arg1 Term Bool
arg2) = [||Term Bool -> Term Bool -> Term Bool
andTerm Term Bool
arg1 Term Bool
arg2||]
  liftTyped (EqTerm Int
_ Term t
arg1 Term t
arg2) = [||Term a -> Term a -> Term Bool
forall a. SupportedNonFuncPrim a => Term a -> Term a -> Term Bool
eqTerm Term t
arg1 Term t
arg2||]
  liftTyped (DistinctTerm Int
_ NonEmpty (Term t)
args) = [||NonEmpty (Term a) -> Term Bool
forall a. SupportedNonFuncPrim a => NonEmpty (Term a) -> Term Bool
distinctTerm NonEmpty (Term t)
args||]
  liftTyped (ITETerm Int
_ Term Bool
cond Term t
arg1 Term t
arg2) = [||Term Bool -> Term a -> Term a -> Term a
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
iteTerm Term Bool
cond Term t
arg1 Term t
arg2||]
  liftTyped (AddNumTerm Int
_ Term t
arg1 Term t
arg2) = [||Term a -> Term a -> Term a
forall a. PEvalNumTerm a => Term a -> Term a -> Term a
addNumTerm Term t
arg1 Term t
arg2||]
  liftTyped (NegNumTerm Int
_ Term t
arg) = [||Term a -> Term a
forall t. PEvalNumTerm t => Term t -> Term t
negNumTerm Term t
arg||]
  liftTyped (MulNumTerm Int
_ Term t
arg1 Term t
arg2) = [||Term a -> Term a -> Term a
forall a. PEvalNumTerm a => Term a -> Term a -> Term a
mulNumTerm Term t
arg1 Term t
arg2||]
  liftTyped (AbsNumTerm Int
_ Term t
arg) = [||Term a -> Term a
forall t. PEvalNumTerm t => Term t -> Term t
absNumTerm Term t
arg||]
  liftTyped (SignumNumTerm Int
_ Term t
arg) = [||Term a -> Term a
forall t. PEvalNumTerm t => Term t -> Term t
signumNumTerm Term t
arg||]
  liftTyped (LtOrdTerm Int
_ Term t
arg1 Term t
arg2) = [||Term a -> Term a -> Term Bool
forall a. PEvalOrdTerm a => Term a -> Term a -> Term Bool
ltOrdTerm Term t
arg1 Term t
arg2||]
  liftTyped (LeOrdTerm Int
_ Term t
arg1 Term t
arg2) = [||Term a -> Term a -> Term Bool
forall a. PEvalOrdTerm a => Term a -> Term a -> Term Bool
leOrdTerm Term t
arg1 Term t
arg2||]
  liftTyped (AndBitsTerm Int
_ Term t
arg1 Term t
arg2) = [||Term a -> Term a -> Term a
forall a. PEvalBitwiseTerm a => Term a -> Term a -> Term a
andBitsTerm Term t
arg1 Term t
arg2||]
  liftTyped (OrBitsTerm Int
_ Term t
arg1 Term t
arg2) = [||Term a -> Term a -> Term a
forall a. PEvalBitwiseTerm a => Term a -> Term a -> Term a
orBitsTerm Term t
arg1 Term t
arg2||]
  liftTyped (XorBitsTerm Int
_ Term t
arg1 Term t
arg2) = [||Term a -> Term a -> Term a
forall a. PEvalBitwiseTerm a => Term a -> Term a -> Term a
xorBitsTerm Term t
arg1 Term t
arg2||]
  liftTyped (ComplementBitsTerm Int
_ Term t
arg) = [||Term a -> Term a
forall a. PEvalBitwiseTerm a => Term a -> Term a
complementBitsTerm Term t
arg||]
  liftTyped (ShiftLeftTerm Int
_ Term t
arg Term t
n) = [||Term a -> Term a -> Term a
forall a. PEvalShiftTerm a => Term a -> Term a -> Term a
shiftLeftTerm Term t
arg Term t
n||]
  liftTyped (ShiftRightTerm Int
_ Term t
arg Term t
n) = [||Term a -> Term a -> Term a
forall a. PEvalShiftTerm a => Term a -> Term a -> Term a
shiftRightTerm Term t
arg Term t
n||]
  liftTyped (RotateLeftTerm Int
_ Term t
arg Term t
n) = [||Term a -> Term a -> Term a
forall a. PEvalRotateTerm a => Term a -> Term a -> Term a
rotateLeftTerm Term t
arg Term t
n||]
  liftTyped (RotateRightTerm Int
_ Term t
arg Term t
n) = [||Term a -> Term a -> Term a
forall a. PEvalRotateTerm a => Term a -> Term a -> Term a
rotateRightTerm Term t
arg Term t
n||]
  liftTyped (BitCastTerm Int
_ Term a
v) = [||Term a -> Term b
forall a b. PEvalBitCastTerm a b => Term a -> Term b
bitCastTerm Term a
v||]
  liftTyped (BitCastOrTerm Int
_ Term t
d Term a
v) = [||Term b -> Term a -> Term b
forall a b. PEvalBitCastOrTerm a b => Term b -> Term a -> Term b
bitCastOrTerm Term t
d Term a
v||]
  liftTyped (BVConcatTerm Int
_ Term (bv l)
arg1 Term (bv r)
arg2) = [||Term (bv l) -> Term (bv r) -> Term (bv (l + r))
forall (bv :: Natural -> *) (l :: Natural) (r :: Natural).
(PEvalBVTerm bv, KnownNat l, KnownNat r, KnownNat (l + r), 1 <= l,
 1 <= r, 1 <= (l + r)) =>
Term (bv l) -> Term (bv r) -> Term (bv (l + r))
bvconcatTerm Term (bv l)
arg1 Term (bv r)
arg2||]
  liftTyped (BVSelectTerm Int
_ (TypeRep ix
_ :: TypeRep ix) (TypeRep w
_ :: TypeRep w) Term (bv n)
arg) =
    [||p ix -> q w -> Term (bv n) -> Term (bv w)
forall (bv :: Natural -> *) (n :: Natural) (ix :: Natural)
       (w :: Natural) (p :: Natural -> *) (q :: Natural -> *).
(PEvalBVTerm bv, KnownNat n, KnownNat ix, KnownNat w, 1 <= n,
 1 <= w, (ix + w) <= n) =>
p ix -> q w -> Term (bv n) -> Term (bv w)
bvselectTerm (forall (t :: k). Proxy t
forall {k} (t :: k). Proxy t
Proxy @ix) (forall (t :: k). Proxy t
forall {k} (t :: k). Proxy t
Proxy @w) Term (bv n)
arg||]
  liftTyped (BVExtendTerm Int
_ Bool
signed (TypeRep r
_ :: TypeRep n) Term (bv l)
arg) =
    [||Bool -> proxy r -> Term (bv l) -> Term (bv r)
forall (bv :: Natural -> *) (l :: Natural) (r :: Natural)
       (proxy :: Natural -> *).
(PEvalBVTerm bv, KnownNat l, KnownNat r, 1 <= l, 1 <= r, l <= r) =>
Bool -> proxy r -> Term (bv l) -> Term (bv r)
bvextendTerm Bool
signed (forall (t :: k). Proxy t
forall {k} (t :: k). Proxy t
Proxy @n) Term (bv l)
arg||]
  liftTyped (ApplyTerm Int
_ Term f
f Term a
arg) = [||Term f -> Term a -> Term b
forall a b f.
(SupportedPrim a, SupportedPrim b, SupportedPrim f,
 PEvalApplyTerm f a b) =>
Term f -> Term a -> Term b
applyTerm Term f
f Term a
arg||]
  liftTyped (DivIntegralTerm Int
_ Term t
arg1 Term t
arg2) = [||Term a -> Term a -> Term a
forall a. PEvalDivModIntegralTerm a => Term a -> Term a -> Term a
divIntegralTerm Term t
arg1 Term t
arg2||]
  liftTyped (ModIntegralTerm Int
_ Term t
arg1 Term t
arg2) = [||Term a -> Term a -> Term a
forall a. PEvalDivModIntegralTerm a => Term a -> Term a -> Term a
modIntegralTerm Term t
arg1 Term t
arg2||]
  liftTyped (QuotIntegralTerm Int
_ Term t
arg1 Term t
arg2) = [||Term a -> Term a -> Term a
forall a. PEvalDivModIntegralTerm a => Term a -> Term a -> Term a
quotIntegralTerm Term t
arg1 Term t
arg2||]
  liftTyped (RemIntegralTerm Int
_ Term t
arg1 Term t
arg2) = [||Term a -> Term a -> Term a
forall a. PEvalDivModIntegralTerm a => Term a -> Term a -> Term a
remIntegralTerm Term t
arg1 Term t
arg2||]
  liftTyped (FPTraitTerm Int
_ FPTrait
trait Term (FP eb sb)
arg) = [||FPTrait -> Term (FP eb sb) -> Term Bool
forall (eb :: Natural) (sb :: Natural).
(ValidFP eb sb, SupportedPrim (FP eb sb)) =>
FPTrait -> Term (FP eb sb) -> Term Bool
fpTraitTerm FPTrait
trait Term (FP eb sb)
arg||]
  liftTyped (FdivTerm Int
_ Term t
arg1 Term t
arg2) = [||Term a -> Term a -> Term a
forall a. PEvalFractionalTerm a => Term a -> Term a -> Term a
fdivTerm Term t
arg1 Term t
arg2||]
  liftTyped (RecipTerm Int
_ Term t
arg) = [||Term a -> Term a
forall a. PEvalFractionalTerm a => Term a -> Term a
recipTerm Term t
arg||]
  liftTyped (FloatingUnaryTerm Int
_ FloatingUnaryOp
op Term t
arg) = [||FloatingUnaryOp -> Term a -> Term a
forall a.
PEvalFloatingTerm a =>
FloatingUnaryOp -> Term a -> Term a
floatingUnaryTerm FloatingUnaryOp
op Term t
arg||]
  liftTyped (PowerTerm Int
_ Term t
arg1 Term t
arg2) = [||Term a -> Term a -> Term a
forall a. PEvalFloatingTerm a => Term a -> Term a -> Term a
powerTerm Term t
arg1 Term t
arg2||]
  liftTyped (FPUnaryTerm Int
_ FPUnaryOp
op Term (FP eb sb)
arg) = [||FPUnaryOp -> Term (FP eb sb) -> Term (FP eb sb)
forall (eb :: Natural) (sb :: Natural).
(ValidFP eb sb, SupportedPrim (FP eb sb)) =>
FPUnaryOp -> Term (FP eb sb) -> Term (FP eb sb)
fpUnaryTerm FPUnaryOp
op Term (FP eb sb)
arg||]
  liftTyped (FPBinaryTerm Int
_ FPBinaryOp
op Term (FP eb sb)
arg1 Term (FP eb sb)
arg2) = [||FPBinaryOp -> Term (FP eb sb) -> Term (FP eb sb) -> Term (FP eb sb)
forall (eb :: Natural) (sb :: Natural).
(ValidFP eb sb, SupportedPrim (FP eb sb)) =>
FPBinaryOp -> Term (FP eb sb) -> Term (FP eb sb) -> Term (FP eb sb)
fpBinaryTerm FPBinaryOp
op Term (FP eb sb)
arg1 Term (FP eb sb)
arg2||]
  liftTyped (FPRoundingUnaryTerm Int
_ FPRoundingUnaryOp
op Term FPRoundingMode
mode Term (FP eb sb)
arg) = [||FPRoundingUnaryOp
-> Term FPRoundingMode -> Term (FP eb sb) -> Term (FP eb sb)
forall (eb :: Natural) (sb :: Natural).
(ValidFP eb sb, SupportedPrim (FP eb sb),
 SupportedPrim FPRoundingMode) =>
FPRoundingUnaryOp
-> Term FPRoundingMode -> Term (FP eb sb) -> Term (FP eb sb)
fpRoundingUnaryTerm FPRoundingUnaryOp
op Term FPRoundingMode
mode Term (FP eb sb)
arg||]
  liftTyped (FPRoundingBinaryTerm Int
_ FPRoundingBinaryOp
op Term FPRoundingMode
mode Term (FP eb sb)
arg1 Term (FP eb sb)
arg2) = [||FPRoundingBinaryOp
-> Term FPRoundingMode
-> Term (FP eb sb)
-> Term (FP eb sb)
-> Term (FP eb sb)
forall (eb :: Natural) (sb :: Natural).
(ValidFP eb sb, SupportedPrim (FP eb sb),
 SupportedPrim FPRoundingMode) =>
FPRoundingBinaryOp
-> Term FPRoundingMode
-> Term (FP eb sb)
-> Term (FP eb sb)
-> Term (FP eb sb)
fpRoundingBinaryTerm FPRoundingBinaryOp
op Term FPRoundingMode
mode Term (FP eb sb)
arg1 Term (FP eb sb)
arg2||]
  liftTyped (FPFMATerm Int
_ Term FPRoundingMode
mode Term (FP eb sb)
arg1 Term (FP eb sb)
arg2 Term (FP eb sb)
arg3) = [||Term FPRoundingMode
-> Term (FP eb sb)
-> Term (FP eb sb)
-> Term (FP eb sb)
-> Term (FP eb sb)
forall (eb :: Natural) (sb :: Natural).
(ValidFP eb sb, SupportedPrim (FP eb sb),
 SupportedPrim FPRoundingMode) =>
Term FPRoundingMode
-> Term (FP eb sb)
-> Term (FP eb sb)
-> Term (FP eb sb)
-> Term (FP eb sb)
fpFMATerm Term FPRoundingMode
mode Term (FP eb sb)
arg1 Term (FP eb sb)
arg2 Term (FP eb sb)
arg3||]
  liftTyped (FromIntegralTerm Int
_ Term a
arg) = [||Term a -> Term b
forall a b. PEvalFromIntegralTerm a b => Term a -> Term b
fromIntegralTerm Term a
arg||]
  liftTyped (FromFPOrTerm Int
_ Term t
d Term FPRoundingMode
r Term (FP eb sb)
arg) = [||Term a -> Term FPRoundingMode -> Term (FP eb sb) -> Term a
forall a (eb :: Natural) (sb :: Natural).
(PEvalIEEEFPConvertibleTerm a, ValidFP eb sb,
 SupportedPrim FPRoundingMode, SupportedPrim (FP eb sb)) =>
Term a -> Term FPRoundingMode -> Term (FP eb sb) -> Term a
fromFPOrTerm Term t
d Term FPRoundingMode
r Term (FP eb sb)
arg||]
  liftTyped (ToFPTerm Int
_ Term FPRoundingMode
r Term a
arg Proxy eb
_ Proxy sb
_) = [||Term FPRoundingMode -> Term a -> Term (FP eb sb)
forall a (eb :: Natural) (sb :: Natural).
(PEvalIEEEFPConvertibleTerm a, ValidFP eb sb,
 SupportedPrim FPRoundingMode, SupportedPrim (FP eb sb)) =>
Term FPRoundingMode -> Term a -> Term (FP eb sb)
toFPTerm Term FPRoundingMode
r Term a
arg||]

instance Show (Term ty) where
  show :: Term ty -> String
show (ConTerm Int
i ty
v) = String
"ConTerm{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", v=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ ty -> String
forall a. Show a => a -> String
show ty
v String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (SymTerm Int
i TypedSymbol 'AnyKind ty
name) =
    String
"SymTerm{id="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", name="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypedSymbol 'AnyKind ty -> String
forall a. Show a => a -> String
show TypedSymbol 'AnyKind ty
name
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", type="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep ty -> String
forall a. Show a => a -> String
show (forall a. Typeable a => TypeRep a
forall {k} (a :: k). Typeable a => TypeRep a
typeRep @ty)
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (ForallTerm Int
i TypedSymbol 'ConstantKind t
sym Term Bool
arg) = String
"Forall{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", sym=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypedSymbol 'ConstantKind t -> String
forall a. Show a => a -> String
show TypedSymbol 'ConstantKind t
sym String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term Bool -> String
forall a. Show a => a -> String
show Term Bool
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (ExistsTerm Int
i TypedSymbol 'ConstantKind t
sym Term Bool
arg) = String
"Exists{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", sym=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypedSymbol 'ConstantKind t -> String
forall a. Show a => a -> String
show TypedSymbol 'ConstantKind t
sym String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term Bool -> String
forall a. Show a => a -> String
show Term Bool
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (UnaryTerm Int
i tag
tag Term arg
arg) = String
"Unary{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", tag=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ tag -> String
forall a. Show a => a -> String
show tag
tag String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term arg -> String
forall a. Show a => a -> String
show Term arg
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (BinaryTerm Int
i tag
tag Term arg1
arg1 Term arg2
arg2) =
    String
"Binary{id="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", tag="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ tag -> String
forall a. Show a => a -> String
show tag
tag
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg1="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term arg1 -> String
forall a. Show a => a -> String
show Term arg1
arg1
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg2="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term arg2 -> String
forall a. Show a => a -> String
show Term arg2
arg2
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (TernaryTerm Int
i tag
tag Term arg1
arg1 Term arg2
arg2 Term arg3
arg3) =
    String
"Ternary{id="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", tag="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ tag -> String
forall a. Show a => a -> String
show tag
tag
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg1="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term arg1 -> String
forall a. Show a => a -> String
show Term arg1
arg1
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg2="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term arg2 -> String
forall a. Show a => a -> String
show Term arg2
arg2
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg3="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term arg3 -> String
forall a. Show a => a -> String
show Term arg3
arg3
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (NotTerm Int
i Term Bool
arg) = String
"Not{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term Bool -> String
forall a. Show a => a -> String
show Term Bool
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (OrTerm Int
i Term Bool
arg1 Term Bool
arg2) = String
"Or{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg1=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term Bool -> String
forall a. Show a => a -> String
show Term Bool
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg2=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term Bool -> String
forall a. Show a => a -> String
show Term Bool
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (AndTerm Int
i Term Bool
arg1 Term Bool
arg2) = String
"And{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg1=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term Bool -> String
forall a. Show a => a -> String
show Term Bool
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg2=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term Bool -> String
forall a. Show a => a -> String
show Term Bool
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (EqTerm Int
i Term t
arg1 Term t
arg2) = String
"Eqv{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg1=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall a. Show a => a -> String
show Term t
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg2=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall a. Show a => a -> String
show Term t
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (DistinctTerm Int
i NonEmpty (Term t)
args) = String
"Distinct{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", args=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NonEmpty (Term t) -> String
forall a. Show a => a -> String
show NonEmpty (Term t)
args String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (ITETerm Int
i Term Bool
cond Term ty
l Term ty
r) =
    String
"ITE{id="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", cond="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term Bool -> String
forall a. Show a => a -> String
show Term Bool
cond
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", then="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
l
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", else="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
r
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (AddNumTerm Int
i Term ty
arg1 Term ty
arg2) = String
"AddNum{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg1=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg2=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (NegNumTerm Int
i Term ty
arg) = String
"NegNum{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (MulNumTerm Int
i Term ty
arg1 Term ty
arg2) = String
"MulNum{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg1=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg2=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (AbsNumTerm Int
i Term ty
arg) = String
"AbsNum{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (SignumNumTerm Int
i Term ty
arg) = String
"SignumNum{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (LtOrdTerm Int
i Term t
arg1 Term t
arg2) = String
"LTNum{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg1=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall a. Show a => a -> String
show Term t
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg2=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall a. Show a => a -> String
show Term t
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (LeOrdTerm Int
i Term t
arg1 Term t
arg2) = String
"LENum{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg1=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall a. Show a => a -> String
show Term t
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg2=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term t -> String
forall a. Show a => a -> String
show Term t
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (AndBitsTerm Int
i Term ty
arg1 Term ty
arg2) = String
"AndBits{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg1=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg2=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (OrBitsTerm Int
i Term ty
arg1 Term ty
arg2) = String
"OrBits{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg1=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg2=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (XorBitsTerm Int
i Term ty
arg1 Term ty
arg2) = String
"XorBits{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg1=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg2=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (ComplementBitsTerm Int
i Term ty
arg) = String
"ComplementBits{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (ShiftLeftTerm Int
i Term ty
arg Term ty
n) = String
"ShiftLeft{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", n=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
n String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (ShiftRightTerm Int
i Term ty
arg Term ty
n) = String
"ShiftRight{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", n=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
n String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (RotateLeftTerm Int
i Term ty
arg Term ty
n) = String
"RotateLeft{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", n=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
n String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (RotateRightTerm Int
i Term ty
arg Term ty
n) = String
"RotateRight{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", n=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
n String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (BitCastTerm Int
i Term a
arg) = String
"BitCast{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term a -> String
forall a. Show a => a -> String
show Term a
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (BitCastOrTerm Int
i Term ty
d Term a
arg) = String
"BitCastOr{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", default=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
d String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term a -> String
forall a. Show a => a -> String
show Term a
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (BVConcatTerm Int
i Term (bv l)
arg1 Term (bv r)
arg2) = String
"BVConcat{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg1=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (bv l) -> String
forall a. Show a => a -> String
show Term (bv l)
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg2=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (bv r) -> String
forall a. Show a => a -> String
show Term (bv r)
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (BVSelectTerm Int
i TypeRep ix
ix TypeRep w
w Term (bv n)
arg) =
    String
"BVSelect{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", ix=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep ix -> String
forall a. Show a => a -> String
show TypeRep ix
ix String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", w=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep w -> String
forall a. Show a => a -> String
show TypeRep w
w String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (bv n) -> String
forall a. Show a => a -> String
show Term (bv n)
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (BVExtendTerm Int
i Bool
signed TypeRep r
n Term (bv l)
arg) =
    String
"BVExtend{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", signed=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Bool -> String
forall a. Show a => a -> String
show Bool
signed String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", n=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep r -> String
forall a. Show a => a -> String
show TypeRep r
n String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (bv l) -> String
forall a. Show a => a -> String
show Term (bv l)
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (ApplyTerm Int
i Term f
f Term a
arg) =
    String
"Apply{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", f=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term f -> String
forall a. Show a => a -> String
show Term f
f String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term a -> String
forall a. Show a => a -> String
show Term a
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (DivIntegralTerm Int
i Term ty
arg1 Term ty
arg2) =
    String
"DivIntegral{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg1=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg2=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (ModIntegralTerm Int
i Term ty
arg1 Term ty
arg2) =
    String
"ModIntegral{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg1=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg2=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (QuotIntegralTerm Int
i Term ty
arg1 Term ty
arg2) =
    String
"QuotIntegral{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg1=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg2=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (RemIntegralTerm Int
i Term ty
arg1 Term ty
arg2) =
    String
"RemIntegral{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg1=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg2=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (FPTraitTerm Int
i FPTrait
trait Term (FP eb sb)
arg) =
    String
"FPTrait{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", trait=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ FPTrait -> String
forall a. Show a => a -> String
show FPTrait
trait String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (FP eb sb) -> String
forall a. Show a => a -> String
show Term (FP eb sb)
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (FdivTerm Int
i Term ty
arg1 Term ty
arg2) = String
"Fdiv{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg1=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg2=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (RecipTerm Int
i Term ty
arg) = String
"Recip{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (FloatingUnaryTerm Int
i FloatingUnaryOp
op Term ty
arg) = String
"FloatingUnary{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", op=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ FloatingUnaryOp -> String
forall a. Show a => a -> String
show FloatingUnaryOp
op String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (PowerTerm Int
i Term ty
arg1 Term ty
arg2) = String
"Power{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg1=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg2=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (FPUnaryTerm Int
i FPUnaryOp
op Term (FP eb sb)
arg) = String
"FPUnary{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", op=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ FPUnaryOp -> String
forall a. Show a => a -> String
show FPUnaryOp
op String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (FP eb sb) -> String
forall a. Show a => a -> String
show Term (FP eb sb)
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (FPBinaryTerm Int
i FPBinaryOp
op Term (FP eb sb)
arg1 Term (FP eb sb)
arg2) =
    String
"FPBinary{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", op=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ FPBinaryOp -> String
forall a. Show a => a -> String
show FPBinaryOp
op String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg1=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (FP eb sb) -> String
forall a. Show a => a -> String
show Term (FP eb sb)
arg1 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg2=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (FP eb sb) -> String
forall a. Show a => a -> String
show Term (FP eb sb)
arg2 String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (FPRoundingUnaryTerm Int
i FPRoundingUnaryOp
op Term FPRoundingMode
mode Term (FP eb sb)
arg) =
    String
"FPRoundingUnary{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", op=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ FPRoundingUnaryOp -> String
forall a. Show a => a -> String
show FPRoundingUnaryOp
op String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", mode=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term FPRoundingMode -> String
forall a. Show a => a -> String
show Term FPRoundingMode
mode String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (FP eb sb) -> String
forall a. Show a => a -> String
show Term (FP eb sb)
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (FPRoundingBinaryTerm Int
i FPRoundingBinaryOp
op Term FPRoundingMode
mode Term (FP eb sb)
arg1 Term (FP eb sb)
arg2) =
    String
"FPRoundingBinary{id="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", op="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ FPRoundingBinaryOp -> String
forall a. Show a => a -> String
show FPRoundingBinaryOp
op
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", mode="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term FPRoundingMode -> String
forall a. Show a => a -> String
show Term FPRoundingMode
mode
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg1="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (FP eb sb) -> String
forall a. Show a => a -> String
show Term (FP eb sb)
arg1
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg2="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (FP eb sb) -> String
forall a. Show a => a -> String
show Term (FP eb sb)
arg2
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (FPFMATerm Int
i Term FPRoundingMode
mode Term (FP eb sb)
arg1 Term (FP eb sb)
arg2 Term (FP eb sb)
arg3) =
    String
"FPFMA{id="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", mode="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term FPRoundingMode -> String
forall a. Show a => a -> String
show Term FPRoundingMode
mode
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg1="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (FP eb sb) -> String
forall a. Show a => a -> String
show Term (FP eb sb)
arg1
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg2="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (FP eb sb) -> String
forall a. Show a => a -> String
show Term (FP eb sb)
arg2
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg3="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (FP eb sb) -> String
forall a. Show a => a -> String
show Term (FP eb sb)
arg3
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (FromIntegralTerm Int
i Term a
arg) =
    String
"FromIntegral{id=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term a -> String
forall a. Show a => a -> String
show Term a
arg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (FromFPOrTerm Int
i Term ty
d Term FPRoundingMode
mode Term (FP eb sb)
arg) =
    String
"FromFPTerm{id="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", default="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term ty -> String
forall a. Show a => a -> String
show Term ty
d
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", mode="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term FPRoundingMode -> String
forall a. Show a => a -> String
show Term FPRoundingMode
mode
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term (FP eb sb) -> String
forall a. Show a => a -> String
show Term (FP eb sb)
arg
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  show (ToFPTerm Int
i Term FPRoundingMode
mode Term a
arg Proxy eb
_ Proxy sb
_) =
    String
"ToFPTerm{id="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", mode="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term FPRoundingMode -> String
forall a. Show a => a -> String
show Term FPRoundingMode
mode
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", arg="
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ Term a -> String
forall a. Show a => a -> String
show Term a
arg
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}"
  {-# INLINE show #-}

-- | Pretty-print a term, possibly eliding parts of it.
prettyPrintTerm :: Term t -> Doc ann
prettyPrintTerm :: forall t ann. Term t -> Doc ann
prettyPrintTerm Term t
v =
  (Int -> Doc ann) -> Doc ann
forall ann. (Int -> Doc ann) -> Doc ann
column
    ( \Int
c ->
        (PageWidth -> Doc ann) -> Doc ann
forall ann. (PageWidth -> Doc ann) -> Doc ann
pageWidth ((PageWidth -> Doc ann) -> Doc ann)
-> (PageWidth -> Doc ann) -> Doc ann
forall a b. (a -> b) -> a -> b
$ \case
          AvailablePerLine Int
i Double
r ->
            if Int -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int
c Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
len) Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
> Int -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
r
              then Doc ann
"..."
              else String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
formatted
          PageWidth
Unbounded -> String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
formatted
    )
  where
    formatted :: String
formatted = Term t -> (SupportedPrim t => String) -> String
forall t a. Term t -> (SupportedPrim t => a) -> a
introSupportedPrimConstraint Term t
v ((SupportedPrim t => String) -> String)
-> (SupportedPrim t => String) -> String
forall a b. (a -> b) -> a -> b
$ Term t -> String
forall t. SupportedPrim t => Term t -> String
pformatTerm Term t
v
    len :: Int
len = String -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length String
formatted

instance (SupportedPrim t) => Eq (Term t) where
  == :: Term t -> Term t -> Bool
(==) = Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
(==) (Int -> Int -> Bool) -> (Term t -> Int) -> Term t -> Term t -> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` Term t -> Int
forall t. Term t -> Int
identity

instance (SupportedPrim t) => Hashable (Term t) where
  hashWithSalt :: Int -> Term t -> Int
hashWithSalt Int
s Term t
t = Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
s (Int -> Int) -> Int -> Int
forall a b. (a -> b) -> a -> b
$ Term t -> Int
forall t. Term t -> Int
identity Term t
t

-- | Term without identity (before internalizing).
data UTerm t where
  UConTerm :: (SupportedPrim t) => !t -> UTerm t
  USymTerm :: (SupportedPrim t) => !(TypedSymbol 'AnyKind t) -> UTerm t
  UForallTerm :: (SupportedNonFuncPrim t) => !(TypedSymbol 'ConstantKind t) -> !(Term Bool) -> UTerm Bool
  UExistsTerm :: (SupportedNonFuncPrim t) => !(TypedSymbol 'ConstantKind t) -> !(Term Bool) -> UTerm Bool
  UUnaryTerm :: (UnaryOp tag arg t) => !tag -> !(Term arg) -> UTerm t
  UBinaryTerm ::
    (BinaryOp tag arg1 arg2 t) =>
    !tag ->
    !(Term arg1) ->
    !(Term arg2) ->
    UTerm t
  UTernaryTerm ::
    (TernaryOp tag arg1 arg2 arg3 t) =>
    !tag ->
    !(Term arg1) ->
    !(Term arg2) ->
    !(Term arg3) ->
    UTerm t
  UNotTerm :: !(Term Bool) -> UTerm Bool
  UOrTerm :: !(Term Bool) -> !(Term Bool) -> UTerm Bool
  UAndTerm :: !(Term Bool) -> !(Term Bool) -> UTerm Bool
  UEqTerm :: (SupportedNonFuncPrim t) => !(Term t) -> !(Term t) -> UTerm Bool
  UDistinctTerm :: (SupportedNonFuncPrim t) => !(NonEmpty (Term t)) -> UTerm Bool
  UITETerm ::
    (SupportedPrim t) =>
    !(Term Bool) ->
    !(Term t) ->
    !(Term t) ->
    UTerm t
  UAddNumTerm :: (PEvalNumTerm t) => !(Term t) -> !(Term t) -> UTerm t
  UNegNumTerm :: (PEvalNumTerm t) => !(Term t) -> UTerm t
  UMulNumTerm :: (PEvalNumTerm t) => !(Term t) -> !(Term t) -> UTerm t
  UAbsNumTerm :: (PEvalNumTerm t) => !(Term t) -> UTerm t
  USignumNumTerm :: (PEvalNumTerm t) => !(Term t) -> UTerm t
  ULtOrdTerm :: (PEvalOrdTerm t) => !(Term t) -> !(Term t) -> UTerm Bool
  ULeOrdTerm :: (PEvalOrdTerm t) => !(Term t) -> !(Term t) -> UTerm Bool
  UAndBitsTerm :: (PEvalBitwiseTerm t) => !(Term t) -> !(Term t) -> UTerm t
  UOrBitsTerm :: (PEvalBitwiseTerm t) => !(Term t) -> !(Term t) -> UTerm t
  UXorBitsTerm :: (PEvalBitwiseTerm t) => !(Term t) -> !(Term t) -> UTerm t
  UComplementBitsTerm :: (PEvalBitwiseTerm t) => !(Term t) -> UTerm t
  UShiftLeftTerm :: (PEvalShiftTerm t) => !(Term t) -> !(Term t) -> UTerm t
  UShiftRightTerm :: (PEvalShiftTerm t) => !(Term t) -> !(Term t) -> UTerm t
  URotateLeftTerm :: (PEvalRotateTerm t) => !(Term t) -> !(Term t) -> UTerm t
  URotateRightTerm :: (PEvalRotateTerm t) => !(Term t) -> !(Term t) -> UTerm t
  UBitCastTerm ::
    (PEvalBitCastTerm a b) =>
    !(Term a) ->
    UTerm b
  UBitCastOrTerm ::
    (PEvalBitCastOrTerm a b) =>
    !(Term b) ->
    !(Term a) ->
    UTerm b
  UBVConcatTerm ::
    ( PEvalBVTerm bv,
      KnownNat l,
      KnownNat r,
      KnownNat (l + r),
      1 <= l,
      1 <= r,
      1 <= l + r
    ) =>
    !(Term (bv l)) ->
    !(Term (bv r)) ->
    UTerm (bv (l + r))
  UBVSelectTerm ::
    ( PEvalBVTerm bv,
      KnownNat n,
      KnownNat ix,
      KnownNat w,
      1 <= n,
      1 <= w,
      ix + w <= n
    ) =>
    !(TypeRep ix) ->
    !(TypeRep w) ->
    !(Term (bv n)) ->
    UTerm (bv w)
  UBVExtendTerm ::
    (PEvalBVTerm bv, KnownNat l, KnownNat r, 1 <= l, 1 <= r, l <= r) =>
    !Bool ->
    !(TypeRep r) ->
    !(Term (bv l)) ->
    UTerm (bv r)
  UApplyTerm ::
    ( SupportedPrim a,
      SupportedPrim b,
      SupportedPrim f,
      PEvalApplyTerm f a b
    ) =>
    Term f ->
    Term a ->
    UTerm b
  UDivIntegralTerm ::
    (PEvalDivModIntegralTerm t) => !(Term t) -> !(Term t) -> UTerm t
  UModIntegralTerm ::
    (PEvalDivModIntegralTerm t) => !(Term t) -> !(Term t) -> UTerm t
  UQuotIntegralTerm ::
    (PEvalDivModIntegralTerm t) => !(Term t) -> !(Term t) -> UTerm t
  URemIntegralTerm ::
    (PEvalDivModIntegralTerm t) => !(Term t) -> !(Term t) -> UTerm t
  UFPTraitTerm ::
    (ValidFP eb sb, SupportedPrim (FP eb sb)) =>
    !FPTrait ->
    !(Term (FP eb sb)) ->
    UTerm Bool
  UFdivTerm :: (PEvalFractionalTerm t) => !(Term t) -> !(Term t) -> UTerm t
  URecipTerm :: (PEvalFractionalTerm t) => !(Term t) -> UTerm t
  UFloatingUnaryTerm :: (PEvalFloatingTerm t) => !FloatingUnaryOp -> !(Term t) -> UTerm t
  UPowerTerm :: (PEvalFloatingTerm t) => !(Term t) -> !(Term t) -> UTerm t
  UFPUnaryTerm ::
    (ValidFP eb sb, SupportedPrim (FP eb sb)) =>
    !FPUnaryOp ->
    !(Term (FP eb sb)) ->
    UTerm (FP eb sb)
  UFPBinaryTerm ::
    (ValidFP eb sb, SupportedPrim (FP eb sb)) =>
    !FPBinaryOp ->
    !(Term (FP eb sb)) ->
    !(Term (FP eb sb)) ->
    UTerm (FP eb sb)
  UFPRoundingUnaryTerm ::
    (ValidFP eb sb, SupportedPrim (FP eb sb), SupportedPrim FPRoundingMode) =>
    !FPRoundingUnaryOp ->
    !(Term FPRoundingMode) ->
    !(Term (FP eb sb)) ->
    UTerm (FP eb sb)
  UFPRoundingBinaryTerm ::
    (ValidFP eb sb, SupportedPrim (FP eb sb), SupportedPrim FPRoundingMode) =>
    !FPRoundingBinaryOp ->
    !(Term FPRoundingMode) ->
    !(Term (FP eb sb)) ->
    !(Term (FP eb sb)) ->
    UTerm (FP eb sb)
  UFPFMATerm ::
    (ValidFP eb sb, SupportedPrim (FP eb sb), SupportedPrim FPRoundingMode) =>
    !(Term FPRoundingMode) ->
    !(Term (FP eb sb)) ->
    !(Term (FP eb sb)) ->
    !(Term (FP eb sb)) ->
    UTerm (FP eb sb)
  UFromIntegralTerm ::
    (PEvalFromIntegralTerm a b) =>
    !(Term a) ->
    UTerm b
  UFromFPOrTerm ::
    ( PEvalIEEEFPConvertibleTerm a,
      ValidFP eb sb,
      SupportedPrim FPRoundingMode,
      SupportedPrim (FP eb sb)
    ) =>
    Term a ->
    !(Term FPRoundingMode) ->
    !(Term (FP eb sb)) ->
    UTerm a
  UToFPTerm ::
    ( PEvalIEEEFPConvertibleTerm a,
      ValidFP eb sb,
      SupportedPrim FPRoundingMode,
      SupportedPrim (FP eb sb)
    ) =>
    !(Term FPRoundingMode) ->
    !(Term a) ->
    Proxy eb ->
    Proxy sb ->
    UTerm (FP eb sb)

eqTypedId :: (TypeRep a, Id) -> (TypeRep b, Id) -> Bool
eqTypedId :: forall a b. (TypeRep a, Int) -> (TypeRep b, Int) -> Bool
eqTypedId (TypeRep a
a, Int
i1) (TypeRep b
b, Int
i2) = Int
i1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
i2 Bool -> Bool -> Bool
&& TypeRep a -> TypeRep b -> Bool
forall ka kb (a :: ka) (b :: kb). TypeRep a -> TypeRep b -> Bool
eqTypeRepBool TypeRep a
a TypeRep b
b
{-# INLINE eqTypedId #-}

eqHeteroTag :: (Eq a) => (TypeRep a, a) -> (TypeRep b, b) -> Bool
eqHeteroTag :: forall a b. Eq a => (TypeRep a, a) -> (TypeRep b, b) -> Bool
eqHeteroTag (TypeRep a
tpa, a
taga) (TypeRep b
tpb, b
tagb) = TypeRep a -> TypeRep b -> a -> b -> Bool
forall a b. Eq a => TypeRep a -> TypeRep b -> a -> b -> Bool
eqHeteroRep TypeRep a
tpa TypeRep b
tpb a
taga b
tagb
{-# INLINE eqHeteroTag #-}

-- | Compare two t'TypedSymbol's for equality.
eqHeteroSymbol :: forall ta a tb b. TypedSymbol ta a -> TypedSymbol tb b -> Bool
eqHeteroSymbol :: forall (ta :: SymbolKind) a (tb :: SymbolKind) b.
TypedSymbol ta a -> TypedSymbol tb b -> Bool
eqHeteroSymbol (TypedSymbol Symbol
taga) (TypedSymbol Symbol
tagb) =
  case TypeRep a -> TypeRep b -> Maybe (a :~~: b)
forall k1 k2 (a :: k1) (b :: k2).
TypeRep a -> TypeRep b -> Maybe (a :~~: b)
eqTypeRep (forall a. Typeable a => TypeRep a
forall {k} (a :: k). Typeable a => TypeRep a
typeRep @a) (forall a. Typeable a => TypeRep a
forall {k} (a :: k). Typeable a => TypeRep a
typeRep @b) of
    Just a :~~: b
HRefl -> Symbol
taga Symbol -> Symbol -> Bool
forall a. Eq a => a -> a -> Bool
== Symbol
tagb
    Maybe (a :~~: b)
Nothing -> Bool
False
{-# INLINE eqHeteroSymbol #-}

eqHeteroSymbol0 :: (TypeRep a, TypedSymbol ta a) -> (TypeRep b, TypedSymbol tb b) -> Bool
eqHeteroSymbol0 :: forall a (ta :: SymbolKind) b (tb :: SymbolKind).
(TypeRep a, TypedSymbol ta a)
-> (TypeRep b, TypedSymbol tb b) -> Bool
eqHeteroSymbol0 (TypeRep a
tpa, TypedSymbol ta a
taga) (TypeRep b
tpb, TypedSymbol tb b
tagb) = case TypeRep b -> TypeRep a -> Maybe (b :~~: a)
forall k1 k2 (a :: k1) (b :: k2).
TypeRep a -> TypeRep b -> Maybe (a :~~: b)
eqTypeRep TypeRep b
tpb TypeRep a
tpa of
  Just b :~~: a
HRefl -> TypedSymbol ta a -> Symbol
forall t (knd :: SymbolKind). TypedSymbol knd t -> Symbol
unTypedSymbol TypedSymbol ta a
taga Symbol -> Symbol -> Bool
forall a. Eq a => a -> a -> Bool
== TypedSymbol tb b -> Symbol
forall t (knd :: SymbolKind). TypedSymbol knd t -> Symbol
unTypedSymbol TypedSymbol tb b
tagb
  Maybe (b :~~: a)
Nothing -> Bool
False
{-# INLINE eqHeteroSymbol0 #-}

instance (SupportedPrim t) => Interned (Term t) where
  type Uninterned (Term t) = UTerm t
  data Description (Term t) where
    DConTerm :: t -> Description (Term t)
    DSymTerm :: TypedSymbol 'AnyKind t -> Description (Term t)
    DForallTerm :: {-# UNPACK #-} !(TypeRep t, TypedSymbol 'ConstantKind t) -> {-# UNPACK #-} !Id -> Description (Term Bool)
    DExistsTerm :: {-# UNPACK #-} !(TypeRep t, TypedSymbol 'ConstantKind t) -> {-# UNPACK #-} !Id -> Description (Term Bool)
    DUnaryTerm ::
      (Eq tag, Hashable tag) =>
      {-# UNPACK #-} !(TypeRep tag, tag) ->
      {-# UNPACK #-} !(TypeRep arg, Id) ->
      Description (Term t)
    DBinaryTerm ::
      (Eq tag, Hashable tag) =>
      {-# UNPACK #-} !(TypeRep tag, tag) ->
      {-# UNPACK #-} !(TypeRep arg1, Id) ->
      {-# UNPACK #-} !(TypeRep arg2, Id) ->
      Description (Term t)
    DTernaryTerm ::
      (Eq tag, Hashable tag) =>
      {-# UNPACK #-} !(TypeRep tag, tag) ->
      {-# UNPACK #-} !(TypeRep arg1, Id) ->
      {-# UNPACK #-} !(TypeRep arg2, Id) ->
      {-# UNPACK #-} !(TypeRep arg3, Id) ->
      Description (Term t)
    DNotTerm :: {-# UNPACK #-} !Id -> Description (Term Bool)
    DOrTerm :: {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term Bool)
    DAndTerm :: {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term Bool)
    DEqTerm :: TypeRep args -> {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term Bool)
    DDistinctTerm :: TypeRep args -> !(NonEmpty Id) -> Description (Term Bool)
    DITETerm :: {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term t)
    DAddNumTerm :: {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term t)
    DNegNumTerm :: {-# UNPACK #-} !Id -> Description (Term t)
    DMulNumTerm :: {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term t)
    DAbsNumTerm :: {-# UNPACK #-} !Id -> Description (Term t)
    DSignumNumTerm :: {-# UNPACK #-} !Id -> Description (Term t)
    DLtOrdTerm :: TypeRep args -> {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term Bool)
    DLeOrdTerm :: TypeRep args -> {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term Bool)
    DAndBitsTerm :: {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term t)
    DOrBitsTerm :: {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term t)
    DXorBitsTerm :: {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term t)
    DComplementBitsTerm :: {-# UNPACK #-} !Id -> Description (Term t)
    DShiftLeftTerm :: {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term t)
    DShiftRightTerm :: {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term t)
    DRotateLeftTerm :: {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term t)
    DRotateRightTerm :: {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term t)
    DBVConcatTerm :: TypeRep bv1 -> TypeRep bv2 -> {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term t)
    DBitCastTerm ::
      !(TypeRep a, Id) ->
      Description (Term b)
    DBitCastOrTerm ::
      Id ->
      !(TypeRep a, Id) ->
      Description (Term b)
    DBVSelectTerm ::
      forall bv (n :: Nat) (w :: Nat) (ix :: Nat).
      !(TypeRep ix) ->
      !(TypeRep (bv n), Id) ->
      Description (Term (bv w))
    DBVExtendTerm ::
      forall bv (l :: Nat) (r :: Nat).
      !Bool ->
      !(TypeRep r) ->
      {-# UNPACK #-} !(TypeRep (bv l), Id) ->
      Description (Term (bv r))
    DApplyTerm ::
      ( PEvalApplyTerm f a b
      ) =>
      {-# UNPACK #-} !(TypeRep f, Id) ->
      {-# UNPACK #-} !(TypeRep a, Id) ->
      Description (Term b)
    DDivIntegralTerm :: {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term a)
    DModIntegralTerm :: {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term a)
    DQuotIntegralTerm :: {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term a)
    DRemIntegralTerm :: {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term a)
    DFPTraitTerm ::
      (ValidFP eb sb, SupportedPrim (FP eb sb)) =>
      FPTrait ->
      {-# UNPACK #-} !(TypeRep (FP eb sb), Id) ->
      Description (Term Bool)
    DFdivTerm :: {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term a)
    DRecipTerm :: {-# UNPACK #-} !Id -> Description (Term a)
    DFloatingUnaryTerm :: FloatingUnaryOp -> {-# UNPACK #-} !Id -> Description (Term a)
    DPowerTerm :: {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term a)
    DFPUnaryTerm :: FPUnaryOp -> {-# UNPACK #-} !Id -> Description (Term (FP eb sb))
    DFPBinaryTerm :: FPBinaryOp -> {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term (FP eb sb))
    DFPRoundingUnaryTerm :: FPRoundingUnaryOp -> {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term (FP eb sb))
    DFPRoundingBinaryTerm :: FPRoundingBinaryOp -> {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term (FP eb sb))
    DFPFMATerm :: {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> {-# UNPACK #-} !Id -> Description (Term (FP eb sb))
    DFromIntegralTerm ::
      (PEvalFromIntegralTerm a b) =>
      !(TypeRep a, Id) ->
      Description (Term b)
    DFromFPOrTerm ::
      (PEvalIEEEFPConvertibleTerm a, ValidFP eb sb) =>
      {-# UNPACK #-} !Id ->
      {-# UNPACK #-} !Id ->
      !(TypeRep (FP eb sb), Id) ->
      Description (Term a)
    DToFPTerm ::
      (PEvalIEEEFPConvertibleTerm a, ValidFP eb sb) =>
      {-# UNPACK #-} !Id ->
      !(TypeRep a, Id) ->
      Description (Term (FP eb sb))

  describe :: Uninterned (Term t) -> Description (Term t)
describe (UConTerm t
v) = t -> Description (Term t)
forall t. t -> Description (Term t)
DConTerm t
v
  describe ((USymTerm TypedSymbol 'AnyKind t
name) :: UTerm t) = forall t. TypedSymbol 'AnyKind t -> Description (Term t)
DSymTerm @t TypedSymbol 'AnyKind t
name
  describe (UForallTerm (TypedSymbol 'ConstantKind t
sym :: TypedSymbol 'ConstantKind arg) Term Bool
arg) =
    (TypeRep t, TypedSymbol 'ConstantKind t)
-> Int -> Description (Term Bool)
forall a.
(TypeRep a, TypedSymbol 'ConstantKind a)
-> Int -> Description (Term Bool)
DForallTerm (TypeRep t
forall {k} (a :: k). Typeable a => TypeRep a
typeRep :: TypeRep arg, TypedSymbol 'ConstantKind t
sym) (Term Bool -> Int
forall t. Term t -> Int
identity Term Bool
arg)
  describe (UExistsTerm (TypedSymbol 'ConstantKind t
sym :: TypedSymbol 'ConstantKind arg) Term Bool
arg) =
    (TypeRep t, TypedSymbol 'ConstantKind t)
-> Int -> Description (Term Bool)
forall a.
(TypeRep a, TypedSymbol 'ConstantKind a)
-> Int -> Description (Term Bool)
DExistsTerm (TypeRep t
forall {k} (a :: k). Typeable a => TypeRep a
typeRep :: TypeRep arg, TypedSymbol 'ConstantKind t
sym) (Term Bool -> Int
forall t. Term t -> Int
identity Term Bool
arg)
  describe ((UUnaryTerm (tag
tag :: tagt) (Term arg
tm :: Term arg)) :: UTerm t) =
    (TypeRep tag, tag) -> (TypeRep arg, Int) -> Description (Term t)
forall a eb t.
(Eq a, Hashable a) =>
(TypeRep a, a) -> (TypeRep eb, Int) -> Description (Term t)
DUnaryTerm (TypeRep tag
forall {k} (a :: k). Typeable a => TypeRep a
typeRep, tag
tag) (TypeRep arg
forall {k} (a :: k). Typeable a => TypeRep a
typeRep :: TypeRep arg, Term arg -> Int
forall t. Term t -> Int
identity Term arg
tm)
  describe ((UBinaryTerm (tag
tag :: tagt) (Term arg1
tm1 :: Term arg1) (Term arg2
tm2 :: Term arg2)) :: UTerm t) =
    forall a eb sb t.
(Eq a, Hashable a) =>
(TypeRep a, a)
-> (TypeRep eb, Int) -> (TypeRep sb, Int) -> Description (Term t)
DBinaryTerm @tagt @arg1 @arg2 @t (TypeRep tag
forall {k} (a :: k). Typeable a => TypeRep a
typeRep, tag
tag) (TypeRep arg1
forall {k} (a :: k). Typeable a => TypeRep a
typeRep, Term arg1 -> Int
forall t. Term t -> Int
identity Term arg1
tm1) (TypeRep arg2
forall {k} (a :: k). Typeable a => TypeRep a
typeRep, Term arg2 -> Int
forall t. Term t -> Int
identity Term arg2
tm2)
  describe ((UTernaryTerm (tag
tag :: tagt) (Term arg1
tm1 :: Term arg1) (Term arg2
tm2 :: Term arg2) (Term arg3
tm3 :: Term arg3)) :: UTerm t) =
    forall a eb sb w t.
(Eq a, Hashable a) =>
(TypeRep a, a)
-> (TypeRep eb, Int)
-> (TypeRep sb, Int)
-> (TypeRep w, Int)
-> Description (Term t)
DTernaryTerm @tagt @arg1 @arg2 @arg3 @t
      (TypeRep tag
forall {k} (a :: k). Typeable a => TypeRep a
typeRep, tag
tag)
      (TypeRep arg1
forall {k} (a :: k). Typeable a => TypeRep a
typeRep, Term arg1 -> Int
forall t. Term t -> Int
identity Term arg1
tm1)
      (TypeRep arg2
forall {k} (a :: k). Typeable a => TypeRep a
typeRep, Term arg2 -> Int
forall t. Term t -> Int
identity Term arg2
tm2)
      (TypeRep arg3
forall {k} (a :: k). Typeable a => TypeRep a
typeRep, Term arg3 -> Int
forall t. Term t -> Int
identity Term arg3
tm3)
  describe (UNotTerm Term Bool
arg) = Int -> Description (Term Bool)
DNotTerm (Term Bool -> Int
forall t. Term t -> Int
identity Term Bool
arg)
  describe (UOrTerm Term Bool
arg1 Term Bool
arg2) = Int -> Int -> Description (Term Bool)
DOrTerm (Term Bool -> Int
forall t. Term t -> Int
identity Term Bool
arg1) (Term Bool -> Int
forall t. Term t -> Int
identity Term Bool
arg2)
  describe (UAndTerm Term Bool
arg1 Term Bool
arg2) = Int -> Int -> Description (Term Bool)
DAndTerm (Term Bool -> Int
forall t. Term t -> Int
identity Term Bool
arg1) (Term Bool -> Int
forall t. Term t -> Int
identity Term Bool
arg2)
  describe (UEqTerm (Term t
arg1 :: Term arg) Term t
arg2) = TypeRep t -> Int -> Int -> Description (Term Bool)
forall a. TypeRep a -> Int -> Int -> Description (Term Bool)
DEqTerm (TypeRep t
forall {k} (a :: k). Typeable a => TypeRep a
typeRep :: TypeRep arg) (Term t -> Int
forall t. Term t -> Int
identity Term t
arg1) (Term t -> Int
forall t. Term t -> Int
identity Term t
arg2)
  describe (UDistinctTerm args :: NonEmpty (Term t)
args@((Term t
_ :: Term arg) :| [Term t]
_)) =
    TypeRep t -> NonEmpty Int -> Description (Term Bool)
forall a. TypeRep a -> NonEmpty Int -> Description (Term Bool)
DDistinctTerm (TypeRep t
forall {k} (a :: k). Typeable a => TypeRep a
typeRep :: TypeRep arg) (Term t -> Int
forall t. Term t -> Int
identity (Term t -> Int) -> NonEmpty (Term t) -> NonEmpty Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NonEmpty (Term t)
args)
  describe (UITETerm Term Bool
cond (Term t
l :: Term arg) Term t
r) = Int -> Int -> Int -> Description (Term t)
forall t. Int -> Int -> Int -> Description (Term t)
DITETerm (Term Bool -> Int
forall t. Term t -> Int
identity Term Bool
cond) (Term t -> Int
forall t. Term t -> Int
identity Term t
l) (Term t -> Int
forall t. Term t -> Int
identity Term t
r)
  describe (UAddNumTerm Term t
arg1 Term t
arg2) = Int -> Int -> Description (Term t)
forall t. Int -> Int -> Description (Term t)
DAddNumTerm (Term t -> Int
forall t. Term t -> Int
identity Term t
arg1) (Term t -> Int
forall t. Term t -> Int
identity Term t
arg2)
  describe (UNegNumTerm Term t
arg) = Int -> Description (Term t)
forall t. Int -> Description (Term t)
DNegNumTerm (Term t -> Int
forall t. Term t -> Int
identity Term t
arg)
  describe (UMulNumTerm Term t
arg1 Term t
arg2) = Int -> Int -> Description (Term t)
forall t. Int -> Int -> Description (Term t)
DMulNumTerm (Term t -> Int
forall t. Term t -> Int
identity Term t
arg1) (Term t -> Int
forall t. Term t -> Int
identity Term t
arg2)
  describe (UAbsNumTerm Term t
arg) = Int -> Description (Term t)
forall t. Int -> Description (Term t)
DAbsNumTerm (Term t -> Int
forall t. Term t -> Int
identity Term t
arg)
  describe (USignumNumTerm Term t
arg) = Int -> Description (Term t)
forall t. Int -> Description (Term t)
DSignumNumTerm (Term t -> Int
forall t. Term t -> Int
identity Term t
arg)
  describe (ULtOrdTerm (Term t
arg1 :: arg) Term t
arg2) = TypeRep (Term t) -> Int -> Int -> Description (Term Bool)
forall a. TypeRep a -> Int -> Int -> Description (Term Bool)
DLtOrdTerm (TypeRep (Term t)
forall {k} (a :: k). Typeable a => TypeRep a
typeRep :: TypeRep arg) (Term t -> Int
forall t. Term t -> Int
identity Term t
arg1) (Term t -> Int
forall t. Term t -> Int
identity Term t
arg2)
  describe (ULeOrdTerm (Term t
arg1 :: arg) Term t
arg2) = TypeRep (Term t) -> Int -> Int -> Description (Term Bool)
forall a. TypeRep a -> Int -> Int -> Description (Term Bool)
DLeOrdTerm (TypeRep (Term t)
forall {k} (a :: k). Typeable a => TypeRep a
typeRep :: TypeRep arg) (Term t -> Int
forall t. Term t -> Int
identity Term t
arg1) (Term t -> Int
forall t. Term t -> Int
identity Term t
arg2)
  describe (UAndBitsTerm Term t
arg1 Term t
arg2) = Int -> Int -> Description (Term t)
forall t. Int -> Int -> Description (Term t)
DAndBitsTerm (Term t -> Int
forall t. Term t -> Int
identity Term t
arg1) (Term t -> Int
forall t. Term t -> Int
identity Term t
arg2)
  describe (UOrBitsTerm Term t
arg1 Term t
arg2) = Int -> Int -> Description (Term t)
forall t. Int -> Int -> Description (Term t)
DOrBitsTerm (Term t -> Int
forall t. Term t -> Int
identity Term t
arg1) (Term t -> Int
forall t. Term t -> Int
identity Term t
arg2)
  describe (UXorBitsTerm Term t
arg1 Term t
arg2) = Int -> Int -> Description (Term t)
forall t. Int -> Int -> Description (Term t)
DXorBitsTerm (Term t -> Int
forall t. Term t -> Int
identity Term t
arg1) (Term t -> Int
forall t. Term t -> Int
identity Term t
arg2)
  describe (UComplementBitsTerm Term t
arg) = Int -> Description (Term t)
forall t. Int -> Description (Term t)
DComplementBitsTerm (Term t -> Int
forall t. Term t -> Int
identity Term t
arg)
  describe (UShiftLeftTerm Term t
arg Term t
n) = Int -> Int -> Description (Term t)
forall t. Int -> Int -> Description (Term t)
DShiftLeftTerm (Term t -> Int
forall t. Term t -> Int
identity Term t
arg) (Term t -> Int
forall t. Term t -> Int
identity Term t
n)
  describe (UShiftRightTerm Term t
arg Term t
n) = Int -> Int -> Description (Term t)
forall t. Int -> Int -> Description (Term t)
DShiftRightTerm (Term t -> Int
forall t. Term t -> Int
identity Term t
arg) (Term t -> Int
forall t. Term t -> Int
identity Term t
n)
  describe (URotateLeftTerm Term t
arg Term t
n) = Int -> Int -> Description (Term t)
forall t. Int -> Int -> Description (Term t)
DRotateLeftTerm (Term t -> Int
forall t. Term t -> Int
identity Term t
arg) (Term t -> Int
forall t. Term t -> Int
identity Term t
n)
  describe (URotateRightTerm Term t
arg Term t
n) = Int -> Int -> Description (Term t)
forall t. Int -> Int -> Description (Term t)
DRotateRightTerm (Term t -> Int
forall t. Term t -> Int
identity Term t
arg) (Term t -> Int
forall t. Term t -> Int
identity Term t
n)
  describe (UBitCastTerm (Term a
arg :: Term a)) = (TypeRep a, Int) -> Description (Term t)
forall a b. (TypeRep a, Int) -> Description (Term b)
DBitCastTerm (TypeRep a
forall {k} (a :: k). Typeable a => TypeRep a
typeRep :: TypeRep a, Term a -> Int
forall t. Term t -> Int
identity Term a
arg)
  describe (UBitCastOrTerm Term t
d (Term a
arg :: Term a)) = Int -> (TypeRep a, Int) -> Description (Term t)
forall a b. Int -> (TypeRep a, Int) -> Description (Term b)
DBitCastOrTerm (Term t -> Int
forall t. Term t -> Int
identity Term t
d) (TypeRep a
forall {k} (a :: k). Typeable a => TypeRep a
typeRep :: TypeRep a, Term a -> Int
forall t. Term t -> Int
identity Term a
arg)
  describe (UBVConcatTerm (Term (bv l)
arg1 :: bv1) (Term (bv r)
arg2 :: bv2)) =
    TypeRep (Term (bv l))
-> TypeRep (Term (bv r)) -> Int -> Int -> Description (Term t)
forall a eb t.
TypeRep a -> TypeRep eb -> Int -> Int -> Description (Term t)
DBVConcatTerm (TypeRep (Term (bv l))
forall {k} (a :: k). Typeable a => TypeRep a
typeRep :: TypeRep bv1) (TypeRep (Term (bv r))
forall {k} (a :: k). Typeable a => TypeRep a
typeRep :: TypeRep bv2) (Term (bv l) -> Int
forall t. Term t -> Int
identity Term (bv l)
arg1) (Term (bv r) -> Int
forall t. Term t -> Int
identity Term (bv r)
arg2)
  describe (UBVSelectTerm (TypeRep ix
ix :: TypeRep ix) TypeRep w
_ (Term (bv n)
arg :: Term arg)) =
    TypeRep ix -> (TypeRep (bv n), Int) -> Description (Term (bv w))
forall (a :: Natural -> *) (eb :: Natural) (sb :: Natural)
       (w :: Natural).
TypeRep w -> (TypeRep (a eb), Int) -> Description (Term (a sb))
DBVSelectTerm TypeRep ix
ix (TypeRep (bv n)
forall {k} (a :: k). Typeable a => TypeRep a
typeRep :: TypeRep arg, Term (bv n) -> Int
forall t. Term t -> Int
identity Term (bv n)
arg)
  describe (UBVExtendTerm Bool
signed (TypeRep r
n :: TypeRep n) (Term (bv l)
arg :: Term arg)) =
    Bool
-> TypeRep r -> (TypeRep (bv l), Int) -> Description (Term (bv r))
forall (a :: Natural -> *) (eb :: Natural) (sb :: Natural).
Bool
-> TypeRep sb -> (TypeRep (a eb), Int) -> Description (Term (a sb))
DBVExtendTerm Bool
signed TypeRep r
n (TypeRep (bv l)
forall {k} (a :: k). Typeable a => TypeRep a
typeRep :: TypeRep arg, Term (bv l) -> Int
forall t. Term t -> Int
identity Term (bv l)
arg)
  describe (UApplyTerm (Term f
f :: Term f) (Term a
arg :: Term a)) =
    (TypeRep f, Int) -> (TypeRep a, Int) -> Description (Term t)
forall a eb b.
PEvalApplyTerm a eb b =>
(TypeRep a, Int) -> (TypeRep eb, Int) -> Description (Term b)
DApplyTerm (TypeRep f
forall {k} (a :: k). Typeable a => TypeRep a
typeRep :: TypeRep f, Term f -> Int
forall t. Term t -> Int
identity Term f
f) (TypeRep a
forall {k} (a :: k). Typeable a => TypeRep a
typeRep :: TypeRep a, Term a -> Int
forall t. Term t -> Int
identity Term a
arg)
  describe (UDivIntegralTerm Term t
arg1 Term t
arg2) = Int -> Int -> Description (Term t)
forall t. Int -> Int -> Description (Term t)
DDivIntegralTerm (Term t -> Int
forall t. Term t -> Int
identity Term t
arg1) (Term t -> Int
forall t. Term t -> Int
identity Term t
arg2)
  describe (UModIntegralTerm Term t
arg1 Term t
arg2) = Int -> Int -> Description (Term t)
forall t. Int -> Int -> Description (Term t)
DModIntegralTerm (Term t -> Int
forall t. Term t -> Int
identity Term t
arg1) (Term t -> Int
forall t. Term t -> Int
identity Term t
arg2)
  describe (UQuotIntegralTerm Term t
arg1 Term t
arg2) = Int -> Int -> Description (Term t)
forall t. Int -> Int -> Description (Term t)
DRemIntegralTerm (Term t -> Int
forall t. Term t -> Int
identity Term t
arg1) (Term t -> Int
forall t. Term t -> Int
identity Term t
arg2)
  describe (URemIntegralTerm Term t
arg1 Term t
arg2) = Int -> Int -> Description (Term t)
forall t. Int -> Int -> Description (Term t)
DQuotIntegralTerm (Term t -> Int
forall t. Term t -> Int
identity Term t
arg1) (Term t -> Int
forall t. Term t -> Int
identity Term t
arg2)
  describe (UFPTraitTerm FPTrait
trait (Term (FP eb sb)
arg :: Term arg)) =
    FPTrait -> (TypeRep (FP eb sb), Int) -> Description (Term Bool)
forall (a :: Natural) (eb :: Natural).
(ValidFP a eb, SupportedPrim (FP a eb)) =>
FPTrait -> (TypeRep (FP a eb), Int) -> Description (Term Bool)
DFPTraitTerm FPTrait
trait (TypeRep (FP eb sb)
forall {k} (a :: k). Typeable a => TypeRep a
typeRep :: TypeRep arg, Term (FP eb sb) -> Int
forall t. Term t -> Int
identity Term (FP eb sb)
arg)
  describe (UFdivTerm Term t
arg1 Term t
arg2) = Int -> Int -> Description (Term t)
forall t. Int -> Int -> Description (Term t)
DFdivTerm (Term t -> Int
forall t. Term t -> Int
identity Term t
arg1) (Term t -> Int
forall t. Term t -> Int
identity Term t
arg2)
  describe (URecipTerm Term t
arg) = Int -> Description (Term t)
forall t. Int -> Description (Term t)
DRecipTerm (Term t -> Int
forall t. Term t -> Int
identity Term t
arg)
  describe (UFloatingUnaryTerm FloatingUnaryOp
op Term t
arg) = FloatingUnaryOp -> Int -> Description (Term t)
forall a. FloatingUnaryOp -> Int -> Description (Term a)
DFloatingUnaryTerm FloatingUnaryOp
op (Term t -> Int
forall t. Term t -> Int
identity Term t
arg)
  describe (UPowerTerm Term t
arg1 Term t
arg2) = Int -> Int -> Description (Term t)
forall t. Int -> Int -> Description (Term t)
DPowerTerm (Term t -> Int
forall t. Term t -> Int
identity Term t
arg1) (Term t -> Int
forall t. Term t -> Int
identity Term t
arg2)
  describe (UFPUnaryTerm FPUnaryOp
op Term (FP eb sb)
arg) = FPUnaryOp -> Int -> Description (Term (FP eb sb))
forall (a :: Natural) (eb :: Natural).
FPUnaryOp -> Int -> Description (Term (FP a eb))
DFPUnaryTerm FPUnaryOp
op (Term (FP eb sb) -> Int
forall t. Term t -> Int
identity Term (FP eb sb)
arg)
  describe (UFPBinaryTerm FPBinaryOp
op Term (FP eb sb)
arg1 Term (FP eb sb)
arg2) = FPBinaryOp -> Int -> Int -> Description (Term (FP eb sb))
forall (a :: Natural) (eb :: Natural).
FPBinaryOp -> Int -> Int -> Description (Term (FP a eb))
DFPBinaryTerm FPBinaryOp
op (Term (FP eb sb) -> Int
forall t. Term t -> Int
identity Term (FP eb sb)
arg1) (Term (FP eb sb) -> Int
forall t. Term t -> Int
identity Term (FP eb sb)
arg2)
  describe (UFPRoundingUnaryTerm FPRoundingUnaryOp
op Term FPRoundingMode
mode Term (FP eb sb)
arg) = FPRoundingUnaryOp -> Int -> Int -> Description (Term (FP eb sb))
forall (a :: Natural) (eb :: Natural).
FPRoundingUnaryOp -> Int -> Int -> Description (Term (FP a eb))
DFPRoundingUnaryTerm FPRoundingUnaryOp
op (Term FPRoundingMode -> Int
forall t. Term t -> Int
identity Term FPRoundingMode
mode) (Term (FP eb sb) -> Int
forall t. Term t -> Int
identity Term (FP eb sb)
arg)
  describe (UFPRoundingBinaryTerm FPRoundingBinaryOp
op Term FPRoundingMode
mode Term (FP eb sb)
arg1 Term (FP eb sb)
arg2) = FPRoundingBinaryOp
-> Int -> Int -> Int -> Description (Term (FP eb sb))
forall (a :: Natural) (eb :: Natural).
FPRoundingBinaryOp
-> Int -> Int -> Int -> Description (Term (FP a eb))
DFPRoundingBinaryTerm FPRoundingBinaryOp
op (Term FPRoundingMode -> Int
forall t. Term t -> Int
identity Term FPRoundingMode
mode) (Term (FP eb sb) -> Int
forall t. Term t -> Int
identity Term (FP eb sb)
arg1) (Term (FP eb sb) -> Int
forall t. Term t -> Int
identity Term (FP eb sb)
arg2)
  describe (UFPFMATerm Term FPRoundingMode
mode Term (FP eb sb)
arg1 Term (FP eb sb)
arg2 Term (FP eb sb)
arg3) = Int -> Int -> Int -> Int -> Description (Term (FP eb sb))
forall (a :: Natural) (eb :: Natural).
Int -> Int -> Int -> Int -> Description (Term (FP a eb))
DFPFMATerm (Term FPRoundingMode -> Int
forall t. Term t -> Int
identity Term FPRoundingMode
mode) (Term (FP eb sb) -> Int
forall t. Term t -> Int
identity Term (FP eb sb)
arg1) (Term (FP eb sb) -> Int
forall t. Term t -> Int
identity Term (FP eb sb)
arg2) (Term (FP eb sb) -> Int
forall t. Term t -> Int
identity Term (FP eb sb)
arg3)
  describe (UFromIntegralTerm (Term a
arg :: Term a)) = (TypeRep a, Int) -> Description (Term t)
forall a b.
PEvalFromIntegralTerm a b =>
(TypeRep a, Int) -> Description (Term b)
DFromIntegralTerm (TypeRep a
forall {k} (a :: k). Typeable a => TypeRep a
typeRep :: TypeRep a, Term a -> Int
forall t. Term t -> Int
identity Term a
arg)
  describe (UFromFPOrTerm Term t
d Term FPRoundingMode
mode (Term (FP eb sb)
arg :: Term a)) =
    Int -> Int -> (TypeRep (FP eb sb), Int) -> Description (Term t)
forall a (a :: Natural) (eb :: Natural).
(PEvalIEEEFPConvertibleTerm a, ValidFP a eb) =>
Int -> Int -> (TypeRep (FP a eb), Int) -> Description (Term a)
DFromFPOrTerm (Term t -> Int
forall t. Term t -> Int
identity Term t
d) (Term FPRoundingMode -> Int
forall t. Term t -> Int
identity Term FPRoundingMode
mode) (TypeRep (FP eb sb)
forall {k} (a :: k). Typeable a => TypeRep a
typeRep :: TypeRep a, Term (FP eb sb) -> Int
forall t. Term t -> Int
identity Term (FP eb sb)
arg)
  describe (UToFPTerm Term FPRoundingMode
mode (Term a
arg :: Term a) Proxy eb
_ Proxy sb
_) =
    Int -> (TypeRep a, Int) -> Description (Term (FP eb sb))
forall a (eb :: Natural) (sb :: Natural).
(PEvalIEEEFPConvertibleTerm a, ValidFP eb sb) =>
Int -> (TypeRep a, Int) -> Description (Term (FP eb sb))
DToFPTerm (Term FPRoundingMode -> Int
forall t. Term t -> Int
identity Term FPRoundingMode
mode) (TypeRep a
forall {k} (a :: k). Typeable a => TypeRep a
typeRep :: TypeRep a, Term a -> Int
forall t. Term t -> Int
identity Term a
arg)

  identify :: Int -> Uninterned (Term t) -> Term t
identify Int
i = Uninterned (Term t) -> Term t
UTerm t -> Term t
go
    where
      go :: UTerm t -> Term t
go (UConTerm t
v) = Int -> t -> Term t
forall t. SupportedPrim t => Int -> t -> Term t
ConTerm Int
i t
v
      go (USymTerm TypedSymbol 'AnyKind t
v) = Int -> TypedSymbol 'AnyKind t -> Term t
forall t.
SupportedPrim t =>
Int -> TypedSymbol 'AnyKind t -> Term t
SymTerm Int
i TypedSymbol 'AnyKind t
v
      go (UForallTerm TypedSymbol 'ConstantKind t
sym Term Bool
arg) = Int -> TypedSymbol 'ConstantKind t -> Term Bool -> Term Bool
forall a.
SupportedNonFuncPrim a =>
Int -> TypedSymbol 'ConstantKind a -> Term Bool -> Term Bool
ForallTerm Int
i TypedSymbol 'ConstantKind t
sym Term Bool
arg
      go (UExistsTerm TypedSymbol 'ConstantKind t
sym Term Bool
arg) = Int -> TypedSymbol 'ConstantKind t -> Term Bool -> Term Bool
forall a.
SupportedNonFuncPrim a =>
Int -> TypedSymbol 'ConstantKind a -> Term Bool -> Term Bool
ExistsTerm Int
i TypedSymbol 'ConstantKind t
sym Term Bool
arg
      go (UUnaryTerm tag
tag Term arg
tm) = Int -> tag -> Term arg -> Term t
forall a eb t. UnaryOp a eb t => Int -> a -> Term eb -> Term t
UnaryTerm Int
i tag
tag Term arg
tm
      go (UBinaryTerm tag
tag Term arg1
tm1 Term arg2
tm2) = Int -> tag -> Term arg1 -> Term arg2 -> Term t
forall a eb sb t.
BinaryOp a eb sb t =>
Int -> a -> Term eb -> Term sb -> Term t
BinaryTerm Int
i tag
tag Term arg1
tm1 Term arg2
tm2
      go (UTernaryTerm tag
tag Term arg1
tm1 Term arg2
tm2 Term arg3
tm3) = Int -> tag -> Term arg1 -> Term arg2 -> Term arg3 -> Term t
forall a eb sb w t.
TernaryOp a eb sb w t =>
Int -> a -> Term eb -> Term sb -> Term w -> Term t
TernaryTerm Int
i tag
tag Term arg1
tm1 Term arg2
tm2 Term arg3
tm3
      go (UNotTerm Term Bool
arg) = Int -> Term Bool -> Term Bool
NotTerm Int
i Term Bool
arg
      go (UOrTerm Term Bool
arg1 Term Bool
arg2) = Int -> Term Bool -> Term Bool -> Term Bool
OrTerm Int
i Term Bool
arg1 Term Bool
arg2
      go (UAndTerm Term Bool
arg1 Term Bool
arg2) = Int -> Term Bool -> Term Bool -> Term Bool
AndTerm Int
i Term Bool
arg1 Term Bool
arg2
      go (UEqTerm Term t
arg1 Term t
arg2) = Int -> Term t -> Term t -> Term Bool
forall a.
SupportedNonFuncPrim a =>
Int -> Term a -> Term a -> Term Bool
EqTerm Int
i Term t
arg1 Term t
arg2
      go (UDistinctTerm NonEmpty (Term t)
args) = Int -> NonEmpty (Term t) -> Term Bool
forall a.
SupportedNonFuncPrim a =>
Int -> NonEmpty (Term a) -> Term Bool
DistinctTerm Int
i NonEmpty (Term t)
args
      go (UITETerm Term Bool
cond Term t
l Term t
r) = Int -> Term Bool -> Term t -> Term t -> Term t
forall t.
SupportedPrim t =>
Int -> Term Bool -> Term t -> Term t -> Term t
ITETerm Int
i Term Bool
cond Term t
l Term t
r
      go (UAddNumTerm Term t
arg1 Term t
arg2) = Int -> Term t -> Term t -> Term t
forall t. PEvalNumTerm t => Int -> Term t -> Term t -> Term t
AddNumTerm Int
i Term t
arg1 Term t
arg2
      go (UNegNumTerm Term t
arg) = Int -> Term t -> Term t
forall t. PEvalNumTerm t => Int -> Term t -> Term t
NegNumTerm Int
i Term t
arg
      go (UMulNumTerm Term t
arg1 Term t
arg2) = Int -> Term t -> Term t -> Term t
forall t. PEvalNumTerm t => Int -> Term t -> Term t -> Term t
MulNumTerm Int
i Term t
arg1 Term t
arg2
      go (UAbsNumTerm Term t
arg) = Int -> Term t -> Term t
forall t. PEvalNumTerm t => Int -> Term t -> Term t
AbsNumTerm Int
i Term t
arg
      go (USignumNumTerm Term t
arg) = Int -> Term t -> Term t
forall t. PEvalNumTerm t => Int -> Term t -> Term t
SignumNumTerm Int
i Term t
arg
      go (ULtOrdTerm Term t
arg1 Term t
arg2) = Int -> Term t -> Term t -> Term Bool
forall a. PEvalOrdTerm a => Int -> Term a -> Term a -> Term Bool
LtOrdTerm Int
i Term t
arg1 Term t
arg2
      go (ULeOrdTerm Term t
arg1 Term t
arg2) = Int -> Term t -> Term t -> Term Bool
forall a. PEvalOrdTerm a => Int -> Term a -> Term a -> Term Bool
LeOrdTerm Int
i Term t
arg1 Term t
arg2
      go (UAndBitsTerm Term t
arg1 Term t
arg2) = Int -> Term t -> Term t -> Term t
forall t. PEvalBitwiseTerm t => Int -> Term t -> Term t -> Term t
AndBitsTerm Int
i Term t
arg1 Term t
arg2
      go (UOrBitsTerm Term t
arg1 Term t
arg2) = Int -> Term t -> Term t -> Term t
forall t. PEvalBitwiseTerm t => Int -> Term t -> Term t -> Term t
OrBitsTerm Int
i Term t
arg1 Term t
arg2
      go (UXorBitsTerm Term t
arg1 Term t
arg2) = Int -> Term t -> Term t -> Term t
forall t. PEvalBitwiseTerm t => Int -> Term t -> Term t -> Term t
XorBitsTerm Int
i Term t
arg1 Term t
arg2
      go (UComplementBitsTerm Term t
arg) = Int -> Term t -> Term t
forall t. PEvalBitwiseTerm t => Int -> Term t -> Term t
ComplementBitsTerm Int
i Term t
arg
      go (UShiftLeftTerm Term t
arg Term t
n) = Int -> Term t -> Term t -> Term t
forall t. PEvalShiftTerm t => Int -> Term t -> Term t -> Term t
ShiftLeftTerm Int
i Term t
arg Term t
n
      go (UShiftRightTerm Term t
arg Term t
n) = Int -> Term t -> Term t -> Term t
forall t. PEvalShiftTerm t => Int -> Term t -> Term t -> Term t
ShiftRightTerm Int
i Term t
arg Term t
n
      go (URotateLeftTerm Term t
arg Term t
n) = Int -> Term t -> Term t -> Term t
forall t. PEvalRotateTerm t => Int -> Term t -> Term t -> Term t
RotateLeftTerm Int
i Term t
arg Term t
n
      go (URotateRightTerm Term t
arg Term t
n) = Int -> Term t -> Term t -> Term t
forall t. PEvalRotateTerm t => Int -> Term t -> Term t -> Term t
RotateRightTerm Int
i Term t
arg Term t
n
      go (UBitCastTerm Term a
arg) = Int -> Term a -> Term t
forall a b. PEvalBitCastTerm a b => Int -> Term a -> Term b
BitCastTerm Int
i Term a
arg
      go (UBitCastOrTerm Term t
d Term a
arg) = Int -> Term t -> Term a -> Term t
forall a b.
PEvalBitCastOrTerm a b =>
Int -> Term b -> Term a -> Term b
BitCastOrTerm Int
i Term t
d Term a
arg
      go (UBVConcatTerm Term (bv l)
arg1 Term (bv r)
arg2) = Int -> Term (bv l) -> Term (bv r) -> Term (bv (l + r))
forall (a :: Natural -> *) (eb :: Natural) (sb :: Natural).
(PEvalBVTerm a, KnownNat eb, KnownNat sb, KnownNat (eb + sb),
 1 <= eb, 1 <= sb, 1 <= (eb + sb)) =>
Int -> Term (a eb) -> Term (a sb) -> Term (a (eb + sb))
BVConcatTerm Int
i Term (bv l)
arg1 Term (bv r)
arg2
      go (UBVSelectTerm TypeRep ix
ix TypeRep w
w Term (bv n)
arg) = Int -> TypeRep ix -> TypeRep w -> Term (bv n) -> Term (bv w)
forall (a :: Natural -> *) (eb :: Natural) (sb :: Natural)
       (w :: Natural).
(PEvalBVTerm a, KnownNat eb, KnownNat sb, KnownNat w, 1 <= eb,
 1 <= w, (sb + w) <= eb) =>
Int -> TypeRep sb -> TypeRep w -> Term (a eb) -> Term (a w)
BVSelectTerm Int
i TypeRep ix
ix TypeRep w
w Term (bv n)
arg
      go (UBVExtendTerm Bool
signed TypeRep r
n Term (bv l)
arg) = Int -> Bool -> TypeRep r -> Term (bv l) -> Term (bv r)
forall (a :: Natural -> *) (eb :: Natural) (sb :: Natural).
(PEvalBVTerm a, KnownNat eb, KnownNat sb, 1 <= eb, 1 <= sb,
 eb <= sb) =>
Int -> Bool -> TypeRep sb -> Term (a eb) -> Term (a sb)
BVExtendTerm Int
i Bool
signed TypeRep r
n Term (bv l)
arg
      go (UApplyTerm Term f
f Term a
arg) = Int -> Term f -> Term a -> Term t
forall a b eb.
(SupportedPrim a, SupportedPrim b, SupportedPrim eb,
 PEvalApplyTerm eb a b) =>
Int -> Term eb -> Term a -> Term b
ApplyTerm Int
i Term f
f Term a
arg
      go (UDivIntegralTerm Term t
arg1 Term t
arg2) = Int -> Term t -> Term t -> Term t
forall t.
PEvalDivModIntegralTerm t =>
Int -> Term t -> Term t -> Term t
DivIntegralTerm Int
i Term t
arg1 Term t
arg2
      go (UModIntegralTerm Term t
arg1 Term t
arg2) = Int -> Term t -> Term t -> Term t
forall t.
PEvalDivModIntegralTerm t =>
Int -> Term t -> Term t -> Term t
ModIntegralTerm Int
i Term t
arg1 Term t
arg2
      go (UQuotIntegralTerm Term t
arg1 Term t
arg2) = Int -> Term t -> Term t -> Term t
forall t.
PEvalDivModIntegralTerm t =>
Int -> Term t -> Term t -> Term t
QuotIntegralTerm Int
i Term t
arg1 Term t
arg2
      go (URemIntegralTerm Term t
arg1 Term t
arg2) = Int -> Term t -> Term t -> Term t
forall t.
PEvalDivModIntegralTerm t =>
Int -> Term t -> Term t -> Term t
RemIntegralTerm Int
i Term t
arg1 Term t
arg2
      go (UFPTraitTerm FPTrait
trait Term (FP eb sb)
arg) = Int -> FPTrait -> Term (FP eb sb) -> Term Bool
forall (a :: Natural) (eb :: Natural).
(ValidFP a eb, SupportedPrim (FP a eb)) =>
Int -> FPTrait -> Term (FP a eb) -> Term Bool
FPTraitTerm Int
i FPTrait
trait Term (FP eb sb)
arg
      go (UFdivTerm Term t
arg1 Term t
arg2) = Int -> Term t -> Term t -> Term t
forall t.
PEvalFractionalTerm t =>
Int -> Term t -> Term t -> Term t
FdivTerm Int
i Term t
arg1 Term t
arg2
      go (URecipTerm Term t
arg) = Int -> Term t -> Term t
forall t. PEvalFractionalTerm t => Int -> Term t -> Term t
RecipTerm Int
i Term t
arg
      go (UFloatingUnaryTerm FloatingUnaryOp
op Term t
arg) = Int -> FloatingUnaryOp -> Term t -> Term t
forall t.
PEvalFloatingTerm t =>
Int -> FloatingUnaryOp -> Term t -> Term t
FloatingUnaryTerm Int
i FloatingUnaryOp
op Term t
arg
      go (UPowerTerm Term t
arg1 Term t
arg2) = Int -> Term t -> Term t -> Term t
forall t. PEvalFloatingTerm t => Int -> Term t -> Term t -> Term t
PowerTerm Int
i Term t
arg1 Term t
arg2
      go (UFPUnaryTerm FPUnaryOp
op Term (FP eb sb)
arg) = Int -> FPUnaryOp -> Term (FP eb sb) -> Term (FP eb sb)
forall (a :: Natural) (eb :: Natural).
(ValidFP a eb, SupportedPrim (FP a eb)) =>
Int -> FPUnaryOp -> Term (FP a eb) -> Term (FP a eb)
FPUnaryTerm Int
i FPUnaryOp
op Term (FP eb sb)
arg
      go (UFPBinaryTerm FPBinaryOp
op Term (FP eb sb)
arg1 Term (FP eb sb)
arg2) = Int
-> FPBinaryOp
-> Term (FP eb sb)
-> Term (FP eb sb)
-> Term (FP eb sb)
forall (a :: Natural) (eb :: Natural).
(ValidFP a eb, SupportedPrim (FP a eb)) =>
Int
-> FPBinaryOp -> Term (FP a eb) -> Term (FP a eb) -> Term (FP a eb)
FPBinaryTerm Int
i FPBinaryOp
op Term (FP eb sb)
arg1 Term (FP eb sb)
arg2
      go (UFPRoundingUnaryTerm FPRoundingUnaryOp
op Term FPRoundingMode
mode Term (FP eb sb)
arg) = Int
-> FPRoundingUnaryOp
-> Term FPRoundingMode
-> Term (FP eb sb)
-> Term (FP eb sb)
forall (a :: Natural) (eb :: Natural).
(ValidFP a eb, SupportedPrim (FP a eb),
 SupportedPrim FPRoundingMode) =>
Int
-> FPRoundingUnaryOp
-> Term FPRoundingMode
-> Term (FP a eb)
-> Term (FP a eb)
FPRoundingUnaryTerm Int
i FPRoundingUnaryOp
op Term FPRoundingMode
mode Term (FP eb sb)
arg
      go (UFPRoundingBinaryTerm FPRoundingBinaryOp
op Term FPRoundingMode
mode Term (FP eb sb)
arg1 Term (FP eb sb)
arg2) = Int
-> FPRoundingBinaryOp
-> Term FPRoundingMode
-> Term (FP eb sb)
-> Term (FP eb sb)
-> Term (FP eb sb)
forall (a :: Natural) (eb :: Natural).
(ValidFP a eb, SupportedPrim (FP a eb),
 SupportedPrim FPRoundingMode) =>
Int
-> FPRoundingBinaryOp
-> Term FPRoundingMode
-> Term (FP a eb)
-> Term (FP a eb)
-> Term (FP a eb)
FPRoundingBinaryTerm Int
i FPRoundingBinaryOp
op Term FPRoundingMode
mode Term (FP eb sb)
arg1 Term (FP eb sb)
arg2
      go (UFPFMATerm Term FPRoundingMode
mode Term (FP eb sb)
arg1 Term (FP eb sb)
arg2 Term (FP eb sb)
arg3) = Int
-> Term FPRoundingMode
-> Term (FP eb sb)
-> Term (FP eb sb)
-> Term (FP eb sb)
-> Term (FP eb sb)
forall (a :: Natural) (eb :: Natural).
(ValidFP a eb, SupportedPrim (FP a eb),
 SupportedPrim FPRoundingMode) =>
Int
-> Term FPRoundingMode
-> Term (FP a eb)
-> Term (FP a eb)
-> Term (FP a eb)
-> Term (FP a eb)
FPFMATerm Int
i Term FPRoundingMode
mode Term (FP eb sb)
arg1 Term (FP eb sb)
arg2 Term (FP eb sb)
arg3
      go (UFromIntegralTerm Term a
arg) = Int -> Term a -> Term t
forall a b. PEvalFromIntegralTerm a b => Int -> Term a -> Term b
FromIntegralTerm Int
i Term a
arg
      go (UFromFPOrTerm Term t
d Term FPRoundingMode
mode Term (FP eb sb)
arg) = Int -> Term t -> Term FPRoundingMode -> Term (FP eb sb) -> Term t
forall a (a :: Natural) (eb :: Natural).
(PEvalIEEEFPConvertibleTerm a, ValidFP a eb,
 SupportedPrim (FP a eb), SupportedPrim FPRoundingMode) =>
Int -> Term a -> Term FPRoundingMode -> Term (FP a eb) -> Term a
FromFPOrTerm Int
i Term t
d Term FPRoundingMode
mode Term (FP eb sb)
arg
      go (UToFPTerm Term FPRoundingMode
mode Term a
arg Proxy eb
eb Proxy sb
sb) = Int
-> Term FPRoundingMode
-> Term a
-> Proxy eb
-> Proxy sb
-> Term (FP eb sb)
forall a (eb :: Natural) (sb :: Natural).
(PEvalIEEEFPConvertibleTerm a, ValidFP eb sb,
 SupportedPrim (FP eb sb), SupportedPrim FPRoundingMode) =>
Int
-> Term FPRoundingMode
-> Term a
-> Proxy eb
-> Proxy sb
-> Term (FP eb sb)
ToFPTerm Int
i Term FPRoundingMode
mode Term a
arg Proxy eb
eb Proxy sb
sb
  cache :: Cache (Term t)
cache = Cache (Term t)
forall t. SupportedPrim t => Cache (Term t)
termCache

instance (SupportedPrim t) => Eq (Description (Term t)) where
  DConTerm (t
l :: tyl) == :: Description (Term t) -> Description (Term t) -> Bool
== DConTerm (t
r :: tyr) = forall a b. (Typeable a, Typeable b) => a -> Maybe b
cast @tyl @tyr t
l Maybe t -> Maybe t -> Bool
forall a. Eq a => a -> a -> Bool
== t -> Maybe t
forall a. a -> Maybe a
Just t
r
  DSymTerm TypedSymbol 'AnyKind t
ls == DSymTerm TypedSymbol 'AnyKind t
rs = TypedSymbol 'AnyKind t
ls TypedSymbol 'AnyKind t -> TypedSymbol 'AnyKind t -> Bool
forall a. Eq a => a -> a -> Bool
== TypedSymbol 'AnyKind t
rs
  DForallTerm (TypeRep t, TypedSymbol 'ConstantKind t)
ls Int
li == DForallTerm (TypeRep t, TypedSymbol 'ConstantKind t)
rs Int
ri = (TypeRep t, TypedSymbol 'ConstantKind t)
-> (TypeRep t, TypedSymbol 'ConstantKind t) -> Bool
forall a (ta :: SymbolKind) b (tb :: SymbolKind).
(TypeRep a, TypedSymbol ta a)
-> (TypeRep b, TypedSymbol tb b) -> Bool
eqHeteroSymbol0 (TypeRep t, TypedSymbol 'ConstantKind t)
ls (TypeRep t, TypedSymbol 'ConstantKind t)
rs Bool -> Bool -> Bool
&& Int
li Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri
  DExistsTerm (TypeRep t, TypedSymbol 'ConstantKind t)
ls Int
li == DExistsTerm (TypeRep t, TypedSymbol 'ConstantKind t)
rs Int
ri = (TypeRep t, TypedSymbol 'ConstantKind t)
-> (TypeRep t, TypedSymbol 'ConstantKind t) -> Bool
forall a (ta :: SymbolKind) b (tb :: SymbolKind).
(TypeRep a, TypedSymbol ta a)
-> (TypeRep b, TypedSymbol tb b) -> Bool
eqHeteroSymbol0 (TypeRep t, TypedSymbol 'ConstantKind t)
ls (TypeRep t, TypedSymbol 'ConstantKind t)
rs Bool -> Bool -> Bool
&& Int
li Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri
  DUnaryTerm ((TypeRep tag, tag)
tagl :: tagl) (TypeRep arg, Int)
li == DUnaryTerm ((TypeRep tag, tag)
tagr :: tagr) (TypeRep arg, Int)
ri = (TypeRep tag, tag) -> (TypeRep tag, tag) -> Bool
forall a b. Eq a => (TypeRep a, a) -> (TypeRep b, b) -> Bool
eqHeteroTag (TypeRep tag, tag)
tagl (TypeRep tag, tag)
tagr Bool -> Bool -> Bool
&& (TypeRep arg, Int) -> (TypeRep arg, Int) -> Bool
forall a b. (TypeRep a, Int) -> (TypeRep b, Int) -> Bool
eqTypedId (TypeRep arg, Int)
li (TypeRep arg, Int)
ri
  DBinaryTerm ((TypeRep tag, tag)
tagl :: tagl) (TypeRep arg1, Int)
li1 (TypeRep arg2, Int)
li2 == DBinaryTerm ((TypeRep tag, tag)
tagr :: tagr) (TypeRep arg1, Int)
ri1 (TypeRep arg2, Int)
ri2 =
    (TypeRep tag, tag) -> (TypeRep tag, tag) -> Bool
forall a b. Eq a => (TypeRep a, a) -> (TypeRep b, b) -> Bool
eqHeteroTag (TypeRep tag, tag)
tagl (TypeRep tag, tag)
tagr Bool -> Bool -> Bool
&& (TypeRep arg1, Int) -> (TypeRep arg1, Int) -> Bool
forall a b. (TypeRep a, Int) -> (TypeRep b, Int) -> Bool
eqTypedId (TypeRep arg1, Int)
li1 (TypeRep arg1, Int)
ri1 Bool -> Bool -> Bool
&& (TypeRep arg2, Int) -> (TypeRep arg2, Int) -> Bool
forall a b. (TypeRep a, Int) -> (TypeRep b, Int) -> Bool
eqTypedId (TypeRep arg2, Int)
li2 (TypeRep arg2, Int)
ri2
  DTernaryTerm ((TypeRep tag, tag)
tagl :: tagl) (TypeRep arg1, Int)
li1 (TypeRep arg2, Int)
li2 (TypeRep arg3, Int)
li3 == DTernaryTerm ((TypeRep tag, tag)
tagr :: tagr) (TypeRep arg1, Int)
ri1 (TypeRep arg2, Int)
ri2 (TypeRep arg3, Int)
ri3 =
    (TypeRep tag, tag) -> (TypeRep tag, tag) -> Bool
forall a b. Eq a => (TypeRep a, a) -> (TypeRep b, b) -> Bool
eqHeteroTag (TypeRep tag, tag)
tagl (TypeRep tag, tag)
tagr Bool -> Bool -> Bool
&& (TypeRep arg1, Int) -> (TypeRep arg1, Int) -> Bool
forall a b. (TypeRep a, Int) -> (TypeRep b, Int) -> Bool
eqTypedId (TypeRep arg1, Int)
li1 (TypeRep arg1, Int)
ri1 Bool -> Bool -> Bool
&& (TypeRep arg2, Int) -> (TypeRep arg2, Int) -> Bool
forall a b. (TypeRep a, Int) -> (TypeRep b, Int) -> Bool
eqTypedId (TypeRep arg2, Int)
li2 (TypeRep arg2, Int)
ri2 Bool -> Bool -> Bool
&& (TypeRep arg3, Int) -> (TypeRep arg3, Int) -> Bool
forall a b. (TypeRep a, Int) -> (TypeRep b, Int) -> Bool
eqTypedId (TypeRep arg3, Int)
li3 (TypeRep arg3, Int)
ri3
  DNotTerm Int
li == DNotTerm Int
ri = Int
li Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri
  DOrTerm Int
li1 Int
li2 == DOrTerm Int
ri1 Int
ri2 = Int
li1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri1 Bool -> Bool -> Bool
&& Int
li2 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri2
  DAndTerm Int
li1 Int
li2 == DAndTerm Int
ri1 Int
ri2 = Int
li1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri1 Bool -> Bool -> Bool
&& Int
li2 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri2
  DEqTerm TypeRep args
lrep Int
li1 Int
li2 == DEqTerm TypeRep args
rrep Int
ri1 Int
ri2 = TypeRep args -> TypeRep args -> Bool
forall ka kb (a :: ka) (b :: kb). TypeRep a -> TypeRep b -> Bool
eqTypeRepBool TypeRep args
lrep TypeRep args
rrep Bool -> Bool -> Bool
&& Int
li1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri1 Bool -> Bool -> Bool
&& Int
li2 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri2
  DDistinctTerm TypeRep args
lrep NonEmpty Int
li == DDistinctTerm TypeRep args
rrep NonEmpty Int
ri = TypeRep args -> TypeRep args -> Bool
forall ka kb (a :: ka) (b :: kb). TypeRep a -> TypeRep b -> Bool
eqTypeRepBool TypeRep args
lrep TypeRep args
rrep Bool -> Bool -> Bool
&& NonEmpty Int
li NonEmpty Int -> NonEmpty Int -> Bool
forall a. Eq a => a -> a -> Bool
== NonEmpty Int
ri
  DITETerm Int
lc Int
li1 Int
li2 == DITETerm Int
rc Int
ri1 Int
ri2 = Int
lc Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
rc Bool -> Bool -> Bool
&& Int
li1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri1 Bool -> Bool -> Bool
&& Int
li2 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri2
  DAddNumTerm Int
li1 Int
li2 == DAddNumTerm Int
ri1 Int
ri2 = Int
li1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri1 Bool -> Bool -> Bool
&& Int
li2 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri2
  DNegNumTerm Int
li == DNegNumTerm Int
ri = Int
li Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri
  DMulNumTerm Int
li1 Int
li2 == DMulNumTerm Int
ri1 Int
ri2 = Int
li1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri1 Bool -> Bool -> Bool
&& Int
li2 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri2
  DAbsNumTerm Int
li == DAbsNumTerm Int
ri = Int
li Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri
  DSignumNumTerm Int
li == DSignumNumTerm Int
ri = Int
li Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri
  DLtOrdTerm TypeRep args
lrep Int
li1 Int
li2 == DLtOrdTerm TypeRep args
rrep Int
ri1 Int
ri2 = TypeRep args -> TypeRep args -> Bool
forall ka kb (a :: ka) (b :: kb). TypeRep a -> TypeRep b -> Bool
eqTypeRepBool TypeRep args
lrep TypeRep args
rrep Bool -> Bool -> Bool
&& Int
li1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri1 Bool -> Bool -> Bool
&& Int
li2 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri2
  DLeOrdTerm TypeRep args
lrep Int
li1 Int
li2 == DLeOrdTerm TypeRep args
rrep Int
ri1 Int
ri2 = TypeRep args -> TypeRep args -> Bool
forall ka kb (a :: ka) (b :: kb). TypeRep a -> TypeRep b -> Bool
eqTypeRepBool TypeRep args
lrep TypeRep args
rrep Bool -> Bool -> Bool
&& Int
li1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri1 Bool -> Bool -> Bool
&& Int
li2 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri2
  DAndBitsTerm Int
li1 Int
li2 == DAndBitsTerm Int
ri1 Int
ri2 = Int
li1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri1 Bool -> Bool -> Bool
&& Int
li2 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri2
  DOrBitsTerm Int
li1 Int
li2 == DOrBitsTerm Int
ri1 Int
ri2 = Int
li1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri1 Bool -> Bool -> Bool
&& Int
li2 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri2
  DXorBitsTerm Int
li1 Int
li2 == DXorBitsTerm Int
ri1 Int
ri2 = Int
li1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri1 Bool -> Bool -> Bool
&& Int
li2 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri2
  DComplementBitsTerm Int
li == DComplementBitsTerm Int
ri = Int
li Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri
  DShiftLeftTerm Int
li Int
ln == DShiftLeftTerm Int
ri Int
rn = Int
li Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri Bool -> Bool -> Bool
&& Int
ln Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
rn
  DShiftRightTerm Int
li Int
ln == DShiftRightTerm Int
ri Int
rn = Int
li Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri Bool -> Bool -> Bool
&& Int
ln Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
rn
  DRotateLeftTerm Int
li Int
ln == DRotateLeftTerm Int
ri Int
rn = Int
li Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri Bool -> Bool -> Bool
&& Int
ln Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
rn
  DRotateRightTerm Int
li Int
ln == DRotateRightTerm Int
ri Int
rn = Int
li Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri Bool -> Bool -> Bool
&& Int
ln Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
rn
  DBitCastTerm (TypeRep a, Int)
li == DBitCastTerm (TypeRep a, Int)
ri = (TypeRep a, Int) -> (TypeRep a, Int) -> Bool
forall a b. (TypeRep a, Int) -> (TypeRep b, Int) -> Bool
eqTypedId (TypeRep a, Int)
li (TypeRep a, Int)
ri
  DBitCastOrTerm Int
ld (TypeRep a, Int)
li == DBitCastOrTerm Int
rd (TypeRep a, Int)
ri = Int
ld Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
rd Bool -> Bool -> Bool
&& (TypeRep a, Int) -> (TypeRep a, Int) -> Bool
forall a b. (TypeRep a, Int) -> (TypeRep b, Int) -> Bool
eqTypedId (TypeRep a, Int)
li (TypeRep a, Int)
ri
  DBVConcatTerm TypeRep bv1
lrep1 TypeRep bv2
lrep2 Int
li1 Int
li2 == DBVConcatTerm TypeRep bv1
rrep1 TypeRep bv2
rrep2 Int
ri1 Int
ri2 =
    TypeRep bv1 -> TypeRep bv1 -> Bool
forall ka kb (a :: ka) (b :: kb). TypeRep a -> TypeRep b -> Bool
eqTypeRepBool TypeRep bv1
lrep1 TypeRep bv1
rrep1 Bool -> Bool -> Bool
&& TypeRep bv2 -> TypeRep bv2 -> Bool
forall ka kb (a :: ka) (b :: kb). TypeRep a -> TypeRep b -> Bool
eqTypeRepBool TypeRep bv2
lrep2 TypeRep bv2
rrep2 Bool -> Bool -> Bool
&& Int
li1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri1 Bool -> Bool -> Bool
&& Int
li2 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri2
  DBVSelectTerm TypeRep ix
lix (TypeRep (bv n), Int)
li == DBVSelectTerm TypeRep ix
rix (TypeRep (bv n), Int)
ri =
    TypeRep ix -> TypeRep ix -> Bool
forall ka kb (a :: ka) (b :: kb). TypeRep a -> TypeRep b -> Bool
eqTypeRepBool TypeRep ix
lix TypeRep ix
rix Bool -> Bool -> Bool
&& (TypeRep (bv n), Int) -> (TypeRep (bv n), Int) -> Bool
forall a b. (TypeRep a, Int) -> (TypeRep b, Int) -> Bool
eqTypedId (TypeRep (bv n), Int)
li (TypeRep (bv n), Int)
ri
  DBVExtendTerm Bool
lIsSigned TypeRep r
ln (TypeRep (bv l), Int)
li == DBVExtendTerm Bool
rIsSigned TypeRep r
rn (TypeRep (bv l), Int)
ri =
    Bool
lIsSigned Bool -> Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Bool
rIsSigned
      Bool -> Bool -> Bool
&& TypeRep r -> TypeRep r -> Bool
forall ka kb (a :: ka) (b :: kb). TypeRep a -> TypeRep b -> Bool
eqTypeRepBool TypeRep r
ln TypeRep r
rn
      Bool -> Bool -> Bool
&& (TypeRep (bv l), Int) -> (TypeRep (bv l), Int) -> Bool
forall a b. (TypeRep a, Int) -> (TypeRep b, Int) -> Bool
eqTypedId (TypeRep (bv l), Int)
li (TypeRep (bv l), Int)
ri
  DApplyTerm (TypeRep f, Int)
lf (TypeRep a, Int)
li == DApplyTerm (TypeRep f, Int)
rf (TypeRep a, Int)
ri = (TypeRep f, Int) -> (TypeRep f, Int) -> Bool
forall a b. (TypeRep a, Int) -> (TypeRep b, Int) -> Bool
eqTypedId (TypeRep f, Int)
lf (TypeRep f, Int)
rf Bool -> Bool -> Bool
&& (TypeRep a, Int) -> (TypeRep a, Int) -> Bool
forall a b. (TypeRep a, Int) -> (TypeRep b, Int) -> Bool
eqTypedId (TypeRep a, Int)
li (TypeRep a, Int)
ri
  DDivIntegralTerm Int
li1 Int
li2 == DDivIntegralTerm Int
ri1 Int
ri2 = Int
li1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri1 Bool -> Bool -> Bool
&& Int
li2 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri2
  DModIntegralTerm Int
li1 Int
li2 == DModIntegralTerm Int
ri1 Int
ri2 = Int
li1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri1 Bool -> Bool -> Bool
&& Int
li2 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri2
  DQuotIntegralTerm Int
li1 Int
li2 == DQuotIntegralTerm Int
ri1 Int
ri2 = Int
li1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri1 Bool -> Bool -> Bool
&& Int
li2 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri2
  DRemIntegralTerm Int
li1 Int
li2 == DRemIntegralTerm Int
ri1 Int
ri2 = Int
li1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri1 Bool -> Bool -> Bool
&& Int
li2 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri2
  DFPTraitTerm FPTrait
lt (TypeRep (FP eb sb), Int)
li == DFPTraitTerm FPTrait
rt (TypeRep (FP eb sb), Int)
ri = FPTrait
lt FPTrait -> FPTrait -> Bool
forall a. Eq a => a -> a -> Bool
== FPTrait
rt Bool -> Bool -> Bool
&& (TypeRep (FP eb sb), Int) -> (TypeRep (FP eb sb), Int) -> Bool
forall a b. (TypeRep a, Int) -> (TypeRep b, Int) -> Bool
eqTypedId (TypeRep (FP eb sb), Int)
li (TypeRep (FP eb sb), Int)
ri
  DFdivTerm Int
li1 Int
li2 == DFdivTerm Int
ri1 Int
ri2 = Int
li1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri1 Bool -> Bool -> Bool
&& Int
li2 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri2
  DRecipTerm Int
li == DRecipTerm Int
ri = Int
li Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri
  DFloatingUnaryTerm FloatingUnaryOp
lop Int
li == DFloatingUnaryTerm FloatingUnaryOp
rop Int
ri = FloatingUnaryOp
lop FloatingUnaryOp -> FloatingUnaryOp -> Bool
forall a. Eq a => a -> a -> Bool
== FloatingUnaryOp
rop Bool -> Bool -> Bool
&& Int
li Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri
  DPowerTerm Int
li1 Int
li2 == DPowerTerm Int
ri1 Int
ri2 = Int
li1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri1 Bool -> Bool -> Bool
&& Int
li2 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri2
  DFPUnaryTerm FPUnaryOp
lop Int
li == DFPUnaryTerm FPUnaryOp
rop Int
ri = FPUnaryOp
lop FPUnaryOp -> FPUnaryOp -> Bool
forall a. Eq a => a -> a -> Bool
== FPUnaryOp
rop Bool -> Bool -> Bool
&& Int
li Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri
  DFPBinaryTerm FPBinaryOp
lop Int
li1 Int
li2 == DFPBinaryTerm FPBinaryOp
rop Int
ri1 Int
ri2 = FPBinaryOp
lop FPBinaryOp -> FPBinaryOp -> Bool
forall a. Eq a => a -> a -> Bool
== FPBinaryOp
rop Bool -> Bool -> Bool
&& Int
li1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri1 Bool -> Bool -> Bool
&& Int
li2 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri2
  DFPRoundingUnaryTerm FPRoundingUnaryOp
lop Int
lmode Int
li == DFPRoundingUnaryTerm FPRoundingUnaryOp
rop Int
rmode Int
ri =
    FPRoundingUnaryOp
lop FPRoundingUnaryOp -> FPRoundingUnaryOp -> Bool
forall a. Eq a => a -> a -> Bool
== FPRoundingUnaryOp
rop Bool -> Bool -> Bool
&& Int
lmode Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
rmode Bool -> Bool -> Bool
&& Int
li Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri
  DFPRoundingBinaryTerm FPRoundingBinaryOp
lop Int
lmode Int
li1 Int
li2 == DFPRoundingBinaryTerm FPRoundingBinaryOp
rop Int
rmode Int
ri1 Int
ri2 =
    FPRoundingBinaryOp
lop FPRoundingBinaryOp -> FPRoundingBinaryOp -> Bool
forall a. Eq a => a -> a -> Bool
== FPRoundingBinaryOp
rop Bool -> Bool -> Bool
&& Int
lmode Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
rmode Bool -> Bool -> Bool
&& Int
li1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri1 Bool -> Bool -> Bool
&& Int
li2 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri2
  DFPFMATerm Int
lmode Int
li1 Int
li2 Int
li3 == DFPFMATerm Int
rmode Int
ri1 Int
ri2 Int
ri3 =
    Int
lmode Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
rmode Bool -> Bool -> Bool
&& Int
li1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri1 Bool -> Bool -> Bool
&& Int
li2 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri2 Bool -> Bool -> Bool
&& Int
li3 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri3
  DFromIntegralTerm (TypeRep a, Int)
li == DFromIntegralTerm (TypeRep a, Int)
ri = (TypeRep a, Int) -> (TypeRep a, Int) -> Bool
forall a b. (TypeRep a, Int) -> (TypeRep b, Int) -> Bool
eqTypedId (TypeRep a, Int)
li (TypeRep a, Int)
ri
  DFromFPOrTerm Int
ld Int
li (TypeRep (FP eb sb), Int)
lai == DFromFPOrTerm Int
rd Int
ri (TypeRep (FP eb sb), Int)
rai = Int
ld Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
rd Bool -> Bool -> Bool
&& Int
li Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri Bool -> Bool -> Bool
&& (TypeRep (FP eb sb), Int) -> (TypeRep (FP eb sb), Int) -> Bool
forall a b. (TypeRep a, Int) -> (TypeRep b, Int) -> Bool
eqTypedId (TypeRep (FP eb sb), Int)
lai (TypeRep (FP eb sb), Int)
rai
  DToFPTerm Int
li (TypeRep a, Int)
lai == DToFPTerm Int
ri (TypeRep a, Int)
rai = Int
li Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ri Bool -> Bool -> Bool
&& (TypeRep a, Int) -> (TypeRep a, Int) -> Bool
forall a b. (TypeRep a, Int) -> (TypeRep b, Int) -> Bool
eqTypedId (TypeRep a, Int)
lai (TypeRep a, Int)
rai
  Description (Term t)
_ == Description (Term t)
_ = Bool
False

instance (SupportedPrim t) => Hashable (Description (Term t)) where
  hashWithSalt :: Int -> Description (Term t) -> Int
hashWithSalt Int
s (DConTerm t
c) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
0 :: Int) Int -> t -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` t
c
  hashWithSalt Int
s (DSymTerm TypedSymbol 'AnyKind t
name) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
1 :: Int) Int -> TypedSymbol 'AnyKind t -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` TypedSymbol 'AnyKind t
name
  hashWithSalt Int
s (DForallTerm (TypeRep t, TypedSymbol 'ConstantKind t)
sym Int
id) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
48 :: Int) Int -> (TypeRep t, TypedSymbol 'ConstantKind t) -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (TypeRep t, TypedSymbol 'ConstantKind t)
sym Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id
  hashWithSalt Int
s (DExistsTerm (TypeRep t, TypedSymbol 'ConstantKind t)
sym Int
id) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
49 :: Int) Int -> (TypeRep t, TypedSymbol 'ConstantKind t) -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (TypeRep t, TypedSymbol 'ConstantKind t)
sym Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id
  hashWithSalt Int
s (DUnaryTerm (TypeRep tag, tag)
tag (TypeRep arg, Int)
id1) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
2 :: Int) Int -> (TypeRep tag, tag) -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (TypeRep tag, tag)
tag Int -> (TypeRep arg, Int) -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (TypeRep arg, Int)
id1
  hashWithSalt Int
s (DBinaryTerm (TypeRep tag, tag)
tag (TypeRep arg1, Int)
id1 (TypeRep arg2, Int)
id2) =
    Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
3 :: Int) Int -> (TypeRep tag, tag) -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (TypeRep tag, tag)
tag Int -> (TypeRep arg1, Int) -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (TypeRep arg1, Int)
id1 Int -> (TypeRep arg2, Int) -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (TypeRep arg2, Int)
id2
  hashWithSalt Int
s (DTernaryTerm (TypeRep tag, tag)
tag (TypeRep arg1, Int)
id1 (TypeRep arg2, Int)
id2 (TypeRep arg3, Int)
id3) =
    Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
4 :: Int) Int -> (TypeRep tag, tag) -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (TypeRep tag, tag)
tag Int -> (TypeRep arg1, Int) -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (TypeRep arg1, Int)
id1 Int -> (TypeRep arg2, Int) -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (TypeRep arg2, Int)
id2 Int -> (TypeRep arg3, Int) -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (TypeRep arg3, Int)
id3
  hashWithSalt Int
s (DNotTerm Int
id1) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
5 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1
  hashWithSalt Int
s (DOrTerm Int
id1 Int
id2) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
6 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id2
  hashWithSalt Int
s (DAndTerm Int
id1 Int
id2) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
7 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id2
  hashWithSalt Int
s (DEqTerm TypeRep args
rep Int
id1 Int
id2) =
    Int
s
      Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
8 :: Int)
      Int -> TypeRep args -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` TypeRep args
rep
      Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1
      Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id2
  hashWithSalt Int
s (DDistinctTerm TypeRep args
rep NonEmpty Int
ids) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
54 :: Int) Int -> TypeRep args -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` TypeRep args
rep Int -> NonEmpty Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` NonEmpty Int
ids
  hashWithSalt Int
s (DITETerm Int
idc Int
id1 Int
id2) =
    Int
s
      Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
9 :: Int)
      Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
idc
      Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1
      Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id2
  hashWithSalt Int
s (DAddNumTerm Int
id1 Int
id2) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
10 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id2
  hashWithSalt Int
s (DNegNumTerm Int
id1) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
11 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1
  hashWithSalt Int
s (DMulNumTerm Int
id1 Int
id2) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
12 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id2
  hashWithSalt Int
s (DAbsNumTerm Int
id1) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
13 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1
  hashWithSalt Int
s (DSignumNumTerm Int
id1) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
14 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1
  hashWithSalt Int
s (DLtOrdTerm TypeRep args
rep Int
id1 Int
id2) =
    Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
15 :: Int) Int -> TypeRep args -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` TypeRep args
rep Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id2
  hashWithSalt Int
s (DLeOrdTerm TypeRep args
rep Int
id1 Int
id2) =
    Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
16 :: Int) Int -> TypeRep args -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` TypeRep args
rep Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id2
  hashWithSalt Int
s (DAndBitsTerm Int
id1 Int
id2) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
17 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id2
  hashWithSalt Int
s (DOrBitsTerm Int
id1 Int
id2) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
18 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id2
  hashWithSalt Int
s (DXorBitsTerm Int
id1 Int
id2) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
19 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id2
  hashWithSalt Int
s (DComplementBitsTerm Int
id1) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
20 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1
  hashWithSalt Int
s (DShiftLeftTerm Int
id1 Int
idn) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
38 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
idn
  hashWithSalt Int
s (DShiftRightTerm Int
id1 Int
idn) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
39 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
idn
  hashWithSalt Int
s (DRotateLeftTerm Int
id1 Int
idn) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
40 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
idn
  hashWithSalt Int
s (DRotateRightTerm Int
id1 Int
idn) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
41 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
idn
  hashWithSalt Int
s (DBitCastTerm (TypeRep a, Int)
id) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
49 :: Int) Int -> (TypeRep a, Int) -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (TypeRep a, Int)
id
  hashWithSalt Int
s (DBitCastOrTerm Int
did (TypeRep a, Int)
id) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
50 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
did Int -> (TypeRep a, Int) -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (TypeRep a, Int)
id
  hashWithSalt Int
s (DBVConcatTerm TypeRep bv1
rep1 TypeRep bv2
rep2 Int
id1 Int
id2) =
    Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
25 :: Int) Int -> TypeRep bv1 -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` TypeRep bv1
rep1 Int -> TypeRep bv2 -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` TypeRep bv2
rep2 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id2
  hashWithSalt Int
s (DBVSelectTerm TypeRep ix
ix (TypeRep (bv n), Int)
id1) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
26 :: Int) Int -> TypeRep ix -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` TypeRep ix
ix Int -> (TypeRep (bv n), Int) -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (TypeRep (bv n), Int)
id1
  hashWithSalt Int
s (DBVExtendTerm Bool
signed TypeRep r
n (TypeRep (bv l), Int)
id1) =
    Int
s
      Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
27 :: Int)
      Int -> Bool -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Bool
signed
      Int -> TypeRep r -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` TypeRep r
n
      Int -> (TypeRep (bv l), Int) -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (TypeRep (bv l), Int)
id1
  hashWithSalt Int
s (DDivIntegralTerm Int
id1 Int
id2) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
30 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id2
  hashWithSalt Int
s (DModIntegralTerm Int
id1 Int
id2) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
31 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id2
  hashWithSalt Int
s (DQuotIntegralTerm Int
id1 Int
id2) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
32 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id2
  hashWithSalt Int
s (DRemIntegralTerm Int
id1 Int
id2) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
33 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id2
  hashWithSalt Int
s (DApplyTerm (TypeRep f, Int)
id1 (TypeRep a, Int)
id2) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
38 :: Int) Int -> (TypeRep f, Int) -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (TypeRep f, Int)
id1 Int -> (TypeRep a, Int) -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (TypeRep a, Int)
id2
  hashWithSalt Int
s (DFPTraitTerm FPTrait
trait (TypeRep (FP eb sb), Int)
id1) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
39 :: Int) Int -> FPTrait -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` FPTrait
trait Int -> (TypeRep (FP eb sb), Int) -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (TypeRep (FP eb sb), Int)
id1
  hashWithSalt Int
s (DFdivTerm Int
id1 Int
id2) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
40 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id2
  hashWithSalt Int
s (DRecipTerm Int
id1) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
41 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1
  hashWithSalt Int
s (DFloatingUnaryTerm FloatingUnaryOp
op Int
id1) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
42 :: Int) Int -> FloatingUnaryOp -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` FloatingUnaryOp
op Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1
  hashWithSalt Int
s (DPowerTerm Int
id1 Int
id2) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
48 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id2
  hashWithSalt Int
s (DFPUnaryTerm FPUnaryOp
op Int
id1) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
43 :: Int) Int -> FPUnaryOp -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` FPUnaryOp
op Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1
  hashWithSalt Int
s (DFPBinaryTerm FPBinaryOp
op Int
id1 Int
id2) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
44 :: Int) Int -> FPBinaryOp -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` FPBinaryOp
op Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id2
  hashWithSalt Int
s (DFPRoundingUnaryTerm FPRoundingUnaryOp
op Int
mode Int
id1) =
    Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
45 :: Int) Int -> FPRoundingUnaryOp -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` FPRoundingUnaryOp
op Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
mode Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1
  hashWithSalt Int
s (DFPRoundingBinaryTerm FPRoundingBinaryOp
op Int
mode Int
id1 Int
id2) =
    Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
46 :: Int) Int -> FPRoundingBinaryOp -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` FPRoundingBinaryOp
op Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
mode Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id2
  hashWithSalt Int
s (DFPFMATerm Int
mode Int
id1 Int
id2 Int
id3) =
    Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
47 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
mode Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id2 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id3
  hashWithSalt Int
s (DFromIntegralTerm (TypeRep a, Int)
id0) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
51 :: Int) Int -> (TypeRep a, Int) -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (TypeRep a, Int)
id0
  hashWithSalt Int
s (DFromFPOrTerm Int
id0 Int
id1 (TypeRep (FP eb sb), Int)
id2) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
52 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id0 Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id1 Int -> (TypeRep (FP eb sb), Int) -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (TypeRep (FP eb sb), Int)
id2
  hashWithSalt Int
s (DToFPTerm Int
id0 (TypeRep a, Int)
id1) = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
53 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
id0 Int -> (TypeRep a, Int) -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (TypeRep a, Int)
id1

internTerm :: forall t. (SupportedPrim t) => Uninterned (Term t) -> Term t
internTerm :: forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm !Uninterned (Term t)
bt = IO (Term t) -> Term t
forall a. IO a -> a
unsafeDupablePerformIO (IO (Term t) -> Term t) -> IO (Term t) -> Term t
forall a b. (a -> b) -> a -> b
$ IORef (CacheState (Term t))
-> (CacheState (Term t) -> (CacheState (Term t), Term t))
-> IO (Term t)
forall a b. IORef a -> (a -> (a, b)) -> IO b
atomicModifyIORef' IORef (CacheState (Term t))
slot CacheState (Term t) -> (CacheState (Term t), Term t)
go
  where
    slot :: IORef (CacheState (Term t))
slot = Cache (Term t) -> Array Int (IORef (CacheState (Term t)))
forall t. Cache t -> Array Int (IORef (CacheState t))
getCache Cache (Term t)
forall t. Interned t => Cache t
cache Array Int (IORef (CacheState (Term t)))
-> Int -> IORef (CacheState (Term t))
forall i e. Ix i => Array i e -> i -> e
! Int
r
    !dt :: Description (Term t)
dt = Uninterned (Term t) -> Description (Term t)
forall t. Interned t => Uninterned t -> Description t
describe Uninterned (Term t)
bt
    !hdt :: Int
hdt = Description (Term t) -> Int
forall a. Hashable a => a -> Int
hash Description (Term t)
dt
    !wid :: Int
wid = Description (Term t) -> Int
forall t (p :: * -> *). Interned t => p t -> Int
forall (p :: * -> *). p (Term t) -> Int
cacheWidth Description (Term t)
dt
    r :: Int
r = Int
hdt Int -> Int -> Int
forall a. Integral a => a -> a -> a
`mod` Int
wid
    go :: CacheState (Term t) -> (CacheState (Term t), Term t)
go (CacheState Int
i HashMap (Description (Term t)) (Term t)
m) = case Description (Term t)
-> HashMap (Description (Term t)) (Term t) -> Maybe (Term t)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup Description (Term t)
dt HashMap (Description (Term t)) (Term t)
m of
      Maybe (Term t)
Nothing -> let t :: Term t
t = Int -> Uninterned (Term t) -> Term t
forall t. Interned t => Int -> Uninterned t -> t
identify (Int
wid Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
r) Uninterned (Term t)
bt in (Int
-> HashMap (Description (Term t)) (Term t) -> CacheState (Term t)
forall t. Int -> HashMap (Description t) t -> CacheState t
CacheState (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) (Description (Term t)
-> Term t
-> HashMap (Description (Term t)) (Term t)
-> HashMap (Description (Term t)) (Term t)
forall k v.
(Eq k, Hashable k) =>
k -> v -> HashMap k v -> HashMap k v
M.insert Description (Term t)
dt Term t
t HashMap (Description (Term t)) (Term t)
m), Term t
t)
      Just Term t
t -> (Int
-> HashMap (Description (Term t)) (Term t) -> CacheState (Term t)
forall t. Int -> HashMap (Description t) t -> CacheState t
CacheState Int
i HashMap (Description (Term t)) (Term t)
m, Term t
t)

-- | Construct and internalizing a 'UnaryTerm'.
constructUnary ::
  forall tag arg t.
  (SupportedPrim t, UnaryOp tag arg t, Typeable tag, Typeable t, Show tag) =>
  tag ->
  Term arg ->
  Term t
constructUnary :: forall tag arg t.
(SupportedPrim t, UnaryOp tag arg t, Typeable tag, Typeable t,
 Show tag) =>
tag -> Term arg -> Term t
constructUnary tag
tag Term arg
tm = let x :: Term t
x = Uninterned (Term t) -> Term t
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term t) -> Term t) -> Uninterned (Term t) -> Term t
forall a b. (a -> b) -> a -> b
$ tag -> Term arg -> UTerm t
forall a eb t. UnaryOp a eb t => a -> Term eb -> UTerm t
UUnaryTerm tag
tag Term arg
tm in Term t
x
{-# INLINE constructUnary #-}

-- | Construct and internalizing a 'BinaryTerm'.
constructBinary ::
  forall tag arg1 arg2 t.
  (SupportedPrim t, BinaryOp tag arg1 arg2 t, Typeable tag, Typeable t, Show tag) =>
  tag ->
  Term arg1 ->
  Term arg2 ->
  Term t
constructBinary :: forall tag arg1 arg2 t.
(SupportedPrim t, BinaryOp tag arg1 arg2 t, Typeable tag,
 Typeable t, Show tag) =>
tag -> Term arg1 -> Term arg2 -> Term t
constructBinary tag
tag Term arg1
tm1 Term arg2
tm2 = Uninterned (Term t) -> Term t
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term t) -> Term t) -> Uninterned (Term t) -> Term t
forall a b. (a -> b) -> a -> b
$ tag -> Term arg1 -> Term arg2 -> UTerm t
forall a eb sb t.
BinaryOp a eb sb t =>
a -> Term eb -> Term sb -> UTerm t
UBinaryTerm tag
tag Term arg1
tm1 Term arg2
tm2
{-# INLINE constructBinary #-}

-- | Construct and internalizing a 'TernaryTerm'.
constructTernary ::
  forall tag arg1 arg2 arg3 t.
  (SupportedPrim t, TernaryOp tag arg1 arg2 arg3 t, Typeable tag, Typeable t, Show tag) =>
  tag ->
  Term arg1 ->
  Term arg2 ->
  Term arg3 ->
  Term t
constructTernary :: forall tag arg1 arg2 arg3 t.
(SupportedPrim t, TernaryOp tag arg1 arg2 arg3 t, Typeable tag,
 Typeable t, Show tag) =>
tag -> Term arg1 -> Term arg2 -> Term arg3 -> Term t
constructTernary tag
tag Term arg1
tm1 Term arg2
tm2 Term arg3
tm3 = Uninterned (Term t) -> Term t
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term t) -> Term t) -> Uninterned (Term t) -> Term t
forall a b. (a -> b) -> a -> b
$ tag -> Term arg1 -> Term arg2 -> Term arg3 -> UTerm t
forall a eb sb w t.
TernaryOp a eb sb w t =>
a -> Term eb -> Term sb -> Term w -> UTerm t
UTernaryTerm tag
tag Term arg1
tm1 Term arg2
tm2 Term arg3
tm3
{-# INLINE constructTernary #-}

-- | Construct and internalizing a 'ConTerm'.
conTerm :: (SupportedPrim t, Typeable t, Hashable t, Eq t, Show t) => t -> Term t
conTerm :: forall t.
(SupportedPrim t, Typeable t, Hashable t, Eq t, Show t) =>
t -> Term t
conTerm t
t = Uninterned (Term t) -> Term t
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term t) -> Term t) -> Uninterned (Term t) -> Term t
forall a b. (a -> b) -> a -> b
$ t -> UTerm t
forall t. SupportedPrim t => t -> UTerm t
UConTerm t
t
{-# INLINE conTerm #-}

-- | Construct and internalizing a 'SymTerm'.
symTerm :: forall t. (SupportedPrim t, Typeable t) => Symbol -> Term t
symTerm :: forall t. (SupportedPrim t, Typeable t) => Symbol -> Term t
symTerm Symbol
t = Uninterned (Term t) -> Term t
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term t) -> Term t) -> Uninterned (Term t) -> Term t
forall a b. (a -> b) -> a -> b
$ TypedSymbol 'AnyKind t -> UTerm t
forall t. SupportedPrim t => TypedSymbol 'AnyKind t -> UTerm t
USymTerm (TypedSymbol 'AnyKind t -> UTerm t)
-> TypedSymbol 'AnyKind t -> UTerm t
forall a b. (a -> b) -> a -> b
$ Symbol -> TypedSymbol 'AnyKind t
forall t (knd :: SymbolKind).
(SupportedPrim t, SymbolKindConstraint knd t, IsSymbolKind knd) =>
Symbol -> TypedSymbol knd t
TypedSymbol Symbol
t
{-# INLINE symTerm #-}

-- | Construct and internalizing a 'ForallTerm'.
forallTerm :: (SupportedNonFuncPrim t, Typeable t) => TypedSymbol 'ConstantKind t -> Term Bool -> Term Bool
forallTerm :: forall t.
(SupportedNonFuncPrim t, Typeable t) =>
TypedSymbol 'ConstantKind t -> Term Bool -> Term Bool
forallTerm TypedSymbol 'ConstantKind t
sym Term Bool
arg = Uninterned (Term Bool) -> Term Bool
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term Bool) -> Term Bool)
-> Uninterned (Term Bool) -> Term Bool
forall a b. (a -> b) -> a -> b
$ TypedSymbol 'ConstantKind t -> Term Bool -> UTerm Bool
forall a.
SupportedNonFuncPrim a =>
TypedSymbol 'ConstantKind a -> Term Bool -> UTerm Bool
UForallTerm TypedSymbol 'ConstantKind t
sym Term Bool
arg
{-# INLINE forallTerm #-}

-- | Construct and internalizing a 'ExistsTerm'.
existsTerm :: (SupportedNonFuncPrim t, Typeable t) => TypedSymbol 'ConstantKind t -> Term Bool -> Term Bool
existsTerm :: forall t.
(SupportedNonFuncPrim t, Typeable t) =>
TypedSymbol 'ConstantKind t -> Term Bool -> Term Bool
existsTerm TypedSymbol 'ConstantKind t
sym Term Bool
arg = Uninterned (Term Bool) -> Term Bool
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term Bool) -> Term Bool)
-> Uninterned (Term Bool) -> Term Bool
forall a b. (a -> b) -> a -> b
$ TypedSymbol 'ConstantKind t -> Term Bool -> UTerm Bool
forall a.
SupportedNonFuncPrim a =>
TypedSymbol 'ConstantKind a -> Term Bool -> UTerm Bool
UExistsTerm TypedSymbol 'ConstantKind t
sym Term Bool
arg
{-# INLINE existsTerm #-}

-- | Construct and internalizing a 'SymTerm' with an identifier, using simple
-- symbols.
ssymTerm :: (SupportedPrim t, Typeable t) => Identifier -> Term t
ssymTerm :: forall t. (SupportedPrim t, Typeable t) => Identifier -> Term t
ssymTerm = Symbol -> Term t
forall t. (SupportedPrim t, Typeable t) => Symbol -> Term t
symTerm (Symbol -> Term t)
-> (Identifier -> Symbol) -> Identifier -> Term t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Identifier -> Symbol
SimpleSymbol
{-# INLINE ssymTerm #-}

-- | Construct and internalizing a 'SymTerm' with an identifier and an index,
-- using indexed symbols.
isymTerm :: (SupportedPrim t, Typeable t) => Identifier -> Int -> Term t
isymTerm :: forall t.
(SupportedPrim t, Typeable t) =>
Identifier -> Int -> Term t
isymTerm Identifier
str Int
idx = Symbol -> Term t
forall t. (SupportedPrim t, Typeable t) => Symbol -> Term t
symTerm (Symbol -> Term t) -> Symbol -> Term t
forall a b. (a -> b) -> a -> b
$ Identifier -> Int -> Symbol
IndexedSymbol Identifier
str Int
idx
{-# INLINE isymTerm #-}

-- | Construct and internalizing a 'NotTerm'.
notTerm :: Term Bool -> Term Bool
notTerm :: Term Bool -> Term Bool
notTerm = Uninterned (Term Bool) -> Term Bool
UTerm Bool -> Term Bool
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (UTerm Bool -> Term Bool)
-> (Term Bool -> UTerm Bool) -> Term Bool -> Term Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term Bool -> UTerm Bool
UNotTerm
{-# INLINE notTerm #-}

-- | Construct and internalizing a 'OrTerm'.
orTerm :: Term Bool -> Term Bool -> Term Bool
orTerm :: Term Bool -> Term Bool -> Term Bool
orTerm Term Bool
l Term Bool
r = Uninterned (Term Bool) -> Term Bool
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term Bool) -> Term Bool)
-> Uninterned (Term Bool) -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> UTerm Bool
UOrTerm Term Bool
l Term Bool
r
{-# INLINE orTerm #-}

-- | Construct and internalizing a 'AndTerm'.
andTerm :: Term Bool -> Term Bool -> Term Bool
andTerm :: Term Bool -> Term Bool -> Term Bool
andTerm Term Bool
l Term Bool
r = Uninterned (Term Bool) -> Term Bool
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term Bool) -> Term Bool)
-> Uninterned (Term Bool) -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> UTerm Bool
UAndTerm Term Bool
l Term Bool
r
{-# INLINE andTerm #-}

-- | Construct and internalizing a 'EqTerm'.
eqTerm :: (SupportedNonFuncPrim a) => Term a -> Term a -> Term Bool
eqTerm :: forall a. SupportedNonFuncPrim a => Term a -> Term a -> Term Bool
eqTerm Term a
l Term a
r = Uninterned (Term Bool) -> Term Bool
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term Bool) -> Term Bool)
-> Uninterned (Term Bool) -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term a -> Term a -> UTerm Bool
forall a. SupportedNonFuncPrim a => Term a -> Term a -> UTerm Bool
UEqTerm Term a
l Term a
r
{-# INLINE eqTerm #-}

-- | Construct and internalizing a 'DistinctTerm'.
distinctTerm :: (SupportedNonFuncPrim a) => NonEmpty (Term a) -> Term Bool
distinctTerm :: forall a. SupportedNonFuncPrim a => NonEmpty (Term a) -> Term Bool
distinctTerm NonEmpty (Term a)
args = Uninterned (Term Bool) -> Term Bool
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term Bool) -> Term Bool)
-> Uninterned (Term Bool) -> Term Bool
forall a b. (a -> b) -> a -> b
$ NonEmpty (Term a) -> UTerm Bool
forall a. SupportedNonFuncPrim a => NonEmpty (Term a) -> UTerm Bool
UDistinctTerm NonEmpty (Term a)
args
{-# INLINE distinctTerm #-}

-- | Construct and internalizing a 'ITETerm'.
iteTerm :: (SupportedPrim a) => Term Bool -> Term a -> Term a -> Term a
iteTerm :: forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
iteTerm Term Bool
c Term a
l Term a
r = Uninterned (Term a) -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term a) -> Term a) -> Uninterned (Term a) -> Term a
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term a -> Term a -> UTerm a
forall t.
SupportedPrim t =>
Term Bool -> Term t -> Term t -> UTerm t
UITETerm Term Bool
c Term a
l Term a
r
{-# INLINE iteTerm #-}

-- | Construct and internalizing a 'AddNumTerm'.
addNumTerm :: (PEvalNumTerm a) => Term a -> Term a -> Term a
addNumTerm :: forall a. PEvalNumTerm a => Term a -> Term a -> Term a
addNumTerm Term a
l Term a
r = Uninterned (Term a) -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term a) -> Term a) -> Uninterned (Term a) -> Term a
forall a b. (a -> b) -> a -> b
$ Term a -> Term a -> UTerm a
forall t. PEvalNumTerm t => Term t -> Term t -> UTerm t
UAddNumTerm Term a
l Term a
r
{-# INLINE addNumTerm #-}

-- | Construct and internalizing a 'NegNumTerm'.
negNumTerm :: (PEvalNumTerm a) => Term a -> Term a
negNumTerm :: forall t. PEvalNumTerm t => Term t -> Term t
negNumTerm = Uninterned (Term a) -> Term a
UTerm a -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (UTerm a -> Term a) -> (Term a -> UTerm a) -> Term a -> Term a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term a -> UTerm a
forall t. PEvalNumTerm t => Term t -> UTerm t
UNegNumTerm
{-# INLINE negNumTerm #-}

-- | Construct and internalizing a 'MulNumTerm'.
mulNumTerm :: (PEvalNumTerm a) => Term a -> Term a -> Term a
mulNumTerm :: forall a. PEvalNumTerm a => Term a -> Term a -> Term a
mulNumTerm Term a
l Term a
r = Uninterned (Term a) -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term a) -> Term a) -> Uninterned (Term a) -> Term a
forall a b. (a -> b) -> a -> b
$ Term a -> Term a -> UTerm a
forall t. PEvalNumTerm t => Term t -> Term t -> UTerm t
UMulNumTerm Term a
l Term a
r
{-# INLINE mulNumTerm #-}

-- | Construct and internalizing a 'AbsNumTerm'.
absNumTerm :: (PEvalNumTerm a) => Term a -> Term a
absNumTerm :: forall t. PEvalNumTerm t => Term t -> Term t
absNumTerm = Uninterned (Term a) -> Term a
UTerm a -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (UTerm a -> Term a) -> (Term a -> UTerm a) -> Term a -> Term a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term a -> UTerm a
forall t. PEvalNumTerm t => Term t -> UTerm t
UAbsNumTerm
{-# INLINE absNumTerm #-}

-- | Construct and internalizing a 'SignumNumTerm'.
signumNumTerm :: (PEvalNumTerm a) => Term a -> Term a
signumNumTerm :: forall t. PEvalNumTerm t => Term t -> Term t
signumNumTerm = Uninterned (Term a) -> Term a
UTerm a -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (UTerm a -> Term a) -> (Term a -> UTerm a) -> Term a -> Term a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term a -> UTerm a
forall t. PEvalNumTerm t => Term t -> UTerm t
USignumNumTerm
{-# INLINE signumNumTerm #-}

-- | Construct and internalizing a 'LtOrdTerm'.
ltOrdTerm :: (PEvalOrdTerm a) => Term a -> Term a -> Term Bool
ltOrdTerm :: forall a. PEvalOrdTerm a => Term a -> Term a -> Term Bool
ltOrdTerm Term a
l Term a
r = Uninterned (Term Bool) -> Term Bool
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term Bool) -> Term Bool)
-> Uninterned (Term Bool) -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term a -> Term a -> UTerm Bool
forall a. PEvalOrdTerm a => Term a -> Term a -> UTerm Bool
ULtOrdTerm Term a
l Term a
r
{-# INLINE ltOrdTerm #-}

-- | Construct and internalizing a 'LeOrdTerm'.
leOrdTerm :: (PEvalOrdTerm a) => Term a -> Term a -> Term Bool
leOrdTerm :: forall a. PEvalOrdTerm a => Term a -> Term a -> Term Bool
leOrdTerm Term a
l Term a
r = Uninterned (Term Bool) -> Term Bool
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term Bool) -> Term Bool)
-> Uninterned (Term Bool) -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term a -> Term a -> UTerm Bool
forall a. PEvalOrdTerm a => Term a -> Term a -> UTerm Bool
ULeOrdTerm Term a
l Term a
r
{-# INLINE leOrdTerm #-}

-- | Construct and internalizing a 'AndBitsTerm'.
andBitsTerm :: (PEvalBitwiseTerm a) => Term a -> Term a -> Term a
andBitsTerm :: forall a. PEvalBitwiseTerm a => Term a -> Term a -> Term a
andBitsTerm Term a
l Term a
r = Uninterned (Term a) -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term a) -> Term a) -> Uninterned (Term a) -> Term a
forall a b. (a -> b) -> a -> b
$ Term a -> Term a -> UTerm a
forall t. PEvalBitwiseTerm t => Term t -> Term t -> UTerm t
UAndBitsTerm Term a
l Term a
r
{-# INLINE andBitsTerm #-}

-- | Construct and internalizing a 'OrBitsTerm'.
orBitsTerm :: (PEvalBitwiseTerm a) => Term a -> Term a -> Term a
orBitsTerm :: forall a. PEvalBitwiseTerm a => Term a -> Term a -> Term a
orBitsTerm Term a
l Term a
r = Uninterned (Term a) -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term a) -> Term a) -> Uninterned (Term a) -> Term a
forall a b. (a -> b) -> a -> b
$ Term a -> Term a -> UTerm a
forall t. PEvalBitwiseTerm t => Term t -> Term t -> UTerm t
UOrBitsTerm Term a
l Term a
r
{-# INLINE orBitsTerm #-}

-- | Construct and internalizing a 'XorBitsTerm'.
xorBitsTerm :: (PEvalBitwiseTerm a) => Term a -> Term a -> Term a
xorBitsTerm :: forall a. PEvalBitwiseTerm a => Term a -> Term a -> Term a
xorBitsTerm Term a
l Term a
r = Uninterned (Term a) -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term a) -> Term a) -> Uninterned (Term a) -> Term a
forall a b. (a -> b) -> a -> b
$ Term a -> Term a -> UTerm a
forall t. PEvalBitwiseTerm t => Term t -> Term t -> UTerm t
UXorBitsTerm Term a
l Term a
r
{-# INLINE xorBitsTerm #-}

-- | Construct and internalizing a 'ComplementBitsTerm'.
complementBitsTerm :: (PEvalBitwiseTerm a) => Term a -> Term a
complementBitsTerm :: forall a. PEvalBitwiseTerm a => Term a -> Term a
complementBitsTerm = Uninterned (Term a) -> Term a
UTerm a -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (UTerm a -> Term a) -> (Term a -> UTerm a) -> Term a -> Term a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term a -> UTerm a
forall t. PEvalBitwiseTerm t => Term t -> UTerm t
UComplementBitsTerm
{-# INLINE complementBitsTerm #-}

-- | Construct and internalizing a 'ShiftLeftTerm'.
shiftLeftTerm :: (PEvalShiftTerm a) => Term a -> Term a -> Term a
shiftLeftTerm :: forall a. PEvalShiftTerm a => Term a -> Term a -> Term a
shiftLeftTerm Term a
t Term a
n = Uninterned (Term a) -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term a) -> Term a) -> Uninterned (Term a) -> Term a
forall a b. (a -> b) -> a -> b
$ Term a -> Term a -> UTerm a
forall t. PEvalShiftTerm t => Term t -> Term t -> UTerm t
UShiftLeftTerm Term a
t Term a
n
{-# INLINE shiftLeftTerm #-}

-- | Construct and internalizing a 'ShiftRightTerm'.
shiftRightTerm :: (PEvalShiftTerm a) => Term a -> Term a -> Term a
shiftRightTerm :: forall a. PEvalShiftTerm a => Term a -> Term a -> Term a
shiftRightTerm Term a
t Term a
n = Uninterned (Term a) -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term a) -> Term a) -> Uninterned (Term a) -> Term a
forall a b. (a -> b) -> a -> b
$ Term a -> Term a -> UTerm a
forall t. PEvalShiftTerm t => Term t -> Term t -> UTerm t
UShiftRightTerm Term a
t Term a
n
{-# INLINE shiftRightTerm #-}

-- | Construct and internalizing a 'RotateLeftTerm'.
rotateLeftTerm :: (PEvalRotateTerm a) => Term a -> Term a -> Term a
rotateLeftTerm :: forall a. PEvalRotateTerm a => Term a -> Term a -> Term a
rotateLeftTerm Term a
t Term a
n = Uninterned (Term a) -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term a) -> Term a) -> Uninterned (Term a) -> Term a
forall a b. (a -> b) -> a -> b
$ Term a -> Term a -> UTerm a
forall t. PEvalRotateTerm t => Term t -> Term t -> UTerm t
URotateLeftTerm Term a
t Term a
n
{-# INLINE rotateLeftTerm #-}

-- | Construct and internalizing a 'RotateRightTerm'.
rotateRightTerm :: (PEvalRotateTerm a) => Term a -> Term a -> Term a
rotateRightTerm :: forall a. PEvalRotateTerm a => Term a -> Term a -> Term a
rotateRightTerm Term a
t Term a
n = Uninterned (Term a) -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term a) -> Term a) -> Uninterned (Term a) -> Term a
forall a b. (a -> b) -> a -> b
$ Term a -> Term a -> UTerm a
forall t. PEvalRotateTerm t => Term t -> Term t -> UTerm t
URotateRightTerm Term a
t Term a
n
{-# INLINE rotateRightTerm #-}

-- | Construct and internalizing a 'BitCastTerm'.
bitCastTerm ::
  (PEvalBitCastTerm a b) =>
  Term a ->
  Term b
bitCastTerm :: forall a b. PEvalBitCastTerm a b => Term a -> Term b
bitCastTerm = Uninterned (Term b) -> Term b
UTerm b -> Term b
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (UTerm b -> Term b) -> (Term a -> UTerm b) -> Term a -> Term b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term a -> UTerm b
forall a b. PEvalBitCastTerm a b => Term a -> UTerm b
UBitCastTerm

-- | Construct and internalizing a 'BitCastOrTerm'.
bitCastOrTerm ::
  (PEvalBitCastOrTerm a b) =>
  Term b ->
  Term a ->
  Term b
bitCastOrTerm :: forall a b. PEvalBitCastOrTerm a b => Term b -> Term a -> Term b
bitCastOrTerm Term b
d = Uninterned (Term b) -> Term b
UTerm b -> Term b
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (UTerm b -> Term b) -> (Term a -> UTerm b) -> Term a -> Term b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term b -> Term a -> UTerm b
forall a b. PEvalBitCastOrTerm a b => Term b -> Term a -> UTerm b
UBitCastOrTerm Term b
d

-- | Construct and internalizing a 'BVConcatTerm'.
bvconcatTerm ::
  ( PEvalBVTerm bv,
    KnownNat l,
    KnownNat r,
    KnownNat (l + r),
    1 <= l,
    1 <= r,
    1 <= l + r
  ) =>
  Term (bv l) ->
  Term (bv r) ->
  Term (bv (l + r))
bvconcatTerm :: forall (bv :: Natural -> *) (l :: Natural) (r :: Natural).
(PEvalBVTerm bv, KnownNat l, KnownNat r, KnownNat (l + r), 1 <= l,
 1 <= r, 1 <= (l + r)) =>
Term (bv l) -> Term (bv r) -> Term (bv (l + r))
bvconcatTerm Term (bv l)
l Term (bv r)
r = Uninterned (Term (bv (l + r))) -> Term (bv (l + r))
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term (bv (l + r))) -> Term (bv (l + r)))
-> Uninterned (Term (bv (l + r))) -> Term (bv (l + r))
forall a b. (a -> b) -> a -> b
$ Term (bv l) -> Term (bv r) -> UTerm (bv (l + r))
forall (a :: Natural -> *) (eb :: Natural) (sb :: Natural).
(PEvalBVTerm a, KnownNat eb, KnownNat sb, KnownNat (eb + sb),
 1 <= eb, 1 <= sb, 1 <= (eb + sb)) =>
Term (a eb) -> Term (a sb) -> UTerm (a (eb + sb))
UBVConcatTerm Term (bv l)
l Term (bv r)
r
{-# INLINE bvconcatTerm #-}

-- | Construct and internalizing a 'BVSelectTerm'.
bvselectTerm ::
  forall bv n ix w p q.
  ( PEvalBVTerm bv,
    KnownNat n,
    KnownNat ix,
    KnownNat w,
    1 <= n,
    1 <= w,
    ix + w <= n
  ) =>
  p ix ->
  q w ->
  Term (bv n) ->
  Term (bv w)
bvselectTerm :: forall (bv :: Natural -> *) (n :: Natural) (ix :: Natural)
       (w :: Natural) (p :: Natural -> *) (q :: Natural -> *).
(PEvalBVTerm bv, KnownNat n, KnownNat ix, KnownNat w, 1 <= n,
 1 <= w, (ix + w) <= n) =>
p ix -> q w -> Term (bv n) -> Term (bv w)
bvselectTerm p ix
_ q w
_ Term (bv n)
v = Uninterned (Term (bv w)) -> Term (bv w)
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term (bv w)) -> Term (bv w))
-> Uninterned (Term (bv w)) -> Term (bv w)
forall a b. (a -> b) -> a -> b
$ TypeRep ix -> TypeRep w -> Term (bv n) -> UTerm (bv w)
forall (a :: Natural -> *) (eb :: Natural) (sb :: Natural)
       (w :: Natural).
(PEvalBVTerm a, KnownNat eb, KnownNat sb, KnownNat w, 1 <= eb,
 1 <= w, (sb + w) <= eb) =>
TypeRep sb -> TypeRep w -> Term (a eb) -> UTerm (a w)
UBVSelectTerm (forall (a :: Natural). Typeable a => TypeRep a
forall {k} (a :: k). Typeable a => TypeRep a
typeRep @ix) (forall (a :: Natural). Typeable a => TypeRep a
forall {k} (a :: k). Typeable a => TypeRep a
typeRep @w) Term (bv n)
v
{-# INLINE bvselectTerm #-}

-- | Construct and internalizing a 'BVExtendTerm'.
bvextendTerm ::
  forall bv l r proxy.
  (PEvalBVTerm bv, KnownNat l, KnownNat r, 1 <= l, 1 <= r, l <= r) =>
  Bool ->
  proxy r ->
  Term (bv l) ->
  Term (bv r)
bvextendTerm :: forall (bv :: Natural -> *) (l :: Natural) (r :: Natural)
       (proxy :: Natural -> *).
(PEvalBVTerm bv, KnownNat l, KnownNat r, 1 <= l, 1 <= r, l <= r) =>
Bool -> proxy r -> Term (bv l) -> Term (bv r)
bvextendTerm Bool
signed proxy r
_ Term (bv l)
v = Uninterned (Term (bv r)) -> Term (bv r)
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term (bv r)) -> Term (bv r))
-> Uninterned (Term (bv r)) -> Term (bv r)
forall a b. (a -> b) -> a -> b
$ Bool -> TypeRep r -> Term (bv l) -> UTerm (bv r)
forall (a :: Natural -> *) (eb :: Natural) (sb :: Natural).
(PEvalBVTerm a, KnownNat eb, KnownNat sb, 1 <= eb, 1 <= sb,
 eb <= sb) =>
Bool -> TypeRep sb -> Term (a eb) -> UTerm (a sb)
UBVExtendTerm Bool
signed (forall (a :: Natural). Typeable a => TypeRep a
forall {k} (a :: k). Typeable a => TypeRep a
typeRep @r) Term (bv l)
v
{-# INLINE bvextendTerm #-}

-- | Construct and internalizing a 'BVExtendTerm' with sign extension.
bvsignExtendTerm ::
  forall bv l r proxy.
  (PEvalBVTerm bv, KnownNat l, KnownNat r, 1 <= l, 1 <= r, l <= r) =>
  proxy r ->
  Term (bv l) ->
  Term (bv r)
bvsignExtendTerm :: forall (bv :: Natural -> *) (l :: Natural) (r :: Natural)
       (proxy :: Natural -> *).
(PEvalBVTerm bv, KnownNat l, KnownNat r, 1 <= l, 1 <= r, l <= r) =>
proxy r -> Term (bv l) -> Term (bv r)
bvsignExtendTerm proxy r
_ Term (bv l)
v = Uninterned (Term (bv r)) -> Term (bv r)
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term (bv r)) -> Term (bv r))
-> Uninterned (Term (bv r)) -> Term (bv r)
forall a b. (a -> b) -> a -> b
$ Bool -> TypeRep r -> Term (bv l) -> UTerm (bv r)
forall (a :: Natural -> *) (eb :: Natural) (sb :: Natural).
(PEvalBVTerm a, KnownNat eb, KnownNat sb, 1 <= eb, 1 <= sb,
 eb <= sb) =>
Bool -> TypeRep sb -> Term (a eb) -> UTerm (a sb)
UBVExtendTerm Bool
True (forall (a :: Natural). Typeable a => TypeRep a
forall {k} (a :: k). Typeable a => TypeRep a
typeRep @r) Term (bv l)
v
{-# INLINE bvsignExtendTerm #-}

-- | Construct and internalizing a 'BVExtendTerm' with zero extension.
bvzeroExtendTerm ::
  forall bv l r proxy.
  (PEvalBVTerm bv, KnownNat l, KnownNat r, 1 <= l, 1 <= r, l <= r) =>
  proxy r ->
  Term (bv l) ->
  Term (bv r)
bvzeroExtendTerm :: forall (bv :: Natural -> *) (l :: Natural) (r :: Natural)
       (proxy :: Natural -> *).
(PEvalBVTerm bv, KnownNat l, KnownNat r, 1 <= l, 1 <= r, l <= r) =>
proxy r -> Term (bv l) -> Term (bv r)
bvzeroExtendTerm proxy r
_ Term (bv l)
v = Uninterned (Term (bv r)) -> Term (bv r)
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term (bv r)) -> Term (bv r))
-> Uninterned (Term (bv r)) -> Term (bv r)
forall a b. (a -> b) -> a -> b
$ Bool -> TypeRep r -> Term (bv l) -> UTerm (bv r)
forall (a :: Natural -> *) (eb :: Natural) (sb :: Natural).
(PEvalBVTerm a, KnownNat eb, KnownNat sb, 1 <= eb, 1 <= sb,
 eb <= sb) =>
Bool -> TypeRep sb -> Term (a eb) -> UTerm (a sb)
UBVExtendTerm Bool
False (forall (a :: Natural). Typeable a => TypeRep a
forall {k} (a :: k). Typeable a => TypeRep a
typeRep @r) Term (bv l)
v
{-# INLINE bvzeroExtendTerm #-}

-- | Construct and internalizing a 'ApplyTerm'.
applyTerm ::
  (SupportedPrim a, SupportedPrim b, SupportedPrim f, PEvalApplyTerm f a b) =>
  Term f ->
  Term a ->
  Term b
applyTerm :: forall a b f.
(SupportedPrim a, SupportedPrim b, SupportedPrim f,
 PEvalApplyTerm f a b) =>
Term f -> Term a -> Term b
applyTerm Term f
f Term a
a = Uninterned (Term b) -> Term b
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term b) -> Term b) -> Uninterned (Term b) -> Term b
forall a b. (a -> b) -> a -> b
$ Term f -> Term a -> UTerm b
forall a b eb.
(SupportedPrim a, SupportedPrim b, SupportedPrim eb,
 PEvalApplyTerm eb a b) =>
Term eb -> Term a -> UTerm b
UApplyTerm Term f
f Term a
a
{-# INLINE applyTerm #-}

-- | Construct and internalizing a 'DivIntegralTerm'.
divIntegralTerm :: (PEvalDivModIntegralTerm a) => Term a -> Term a -> Term a
divIntegralTerm :: forall a. PEvalDivModIntegralTerm a => Term a -> Term a -> Term a
divIntegralTerm Term a
l Term a
r = Uninterned (Term a) -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term a) -> Term a) -> Uninterned (Term a) -> Term a
forall a b. (a -> b) -> a -> b
$ Term a -> Term a -> UTerm a
forall t. PEvalDivModIntegralTerm t => Term t -> Term t -> UTerm t
UDivIntegralTerm Term a
l Term a
r
{-# INLINE divIntegralTerm #-}

-- | Construct and internalizing a 'ModIntegralTerm'.
modIntegralTerm :: (PEvalDivModIntegralTerm a) => Term a -> Term a -> Term a
modIntegralTerm :: forall a. PEvalDivModIntegralTerm a => Term a -> Term a -> Term a
modIntegralTerm Term a
l Term a
r = Uninterned (Term a) -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term a) -> Term a) -> Uninterned (Term a) -> Term a
forall a b. (a -> b) -> a -> b
$ Term a -> Term a -> UTerm a
forall t. PEvalDivModIntegralTerm t => Term t -> Term t -> UTerm t
UModIntegralTerm Term a
l Term a
r
{-# INLINE modIntegralTerm #-}

-- | Construct and internalizing a 'QuotIntegralTerm'.
quotIntegralTerm :: (PEvalDivModIntegralTerm a) => Term a -> Term a -> Term a
quotIntegralTerm :: forall a. PEvalDivModIntegralTerm a => Term a -> Term a -> Term a
quotIntegralTerm Term a
l Term a
r = Uninterned (Term a) -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term a) -> Term a) -> Uninterned (Term a) -> Term a
forall a b. (a -> b) -> a -> b
$ Term a -> Term a -> UTerm a
forall t. PEvalDivModIntegralTerm t => Term t -> Term t -> UTerm t
UQuotIntegralTerm Term a
l Term a
r
{-# INLINE quotIntegralTerm #-}

-- | Construct and internalizing a 'RemIntegralTerm'.
remIntegralTerm :: (PEvalDivModIntegralTerm a) => Term a -> Term a -> Term a
remIntegralTerm :: forall a. PEvalDivModIntegralTerm a => Term a -> Term a -> Term a
remIntegralTerm Term a
l Term a
r = Uninterned (Term a) -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term a) -> Term a) -> Uninterned (Term a) -> Term a
forall a b. (a -> b) -> a -> b
$ Term a -> Term a -> UTerm a
forall t. PEvalDivModIntegralTerm t => Term t -> Term t -> UTerm t
URemIntegralTerm Term a
l Term a
r
{-# INLINE remIntegralTerm #-}

-- | Construct and internalizing a 'FPTraitTerm'.
fpTraitTerm ::
  (ValidFP eb sb, SupportedPrim (FP eb sb)) =>
  FPTrait ->
  Term (FP eb sb) ->
  Term Bool
fpTraitTerm :: forall (eb :: Natural) (sb :: Natural).
(ValidFP eb sb, SupportedPrim (FP eb sb)) =>
FPTrait -> Term (FP eb sb) -> Term Bool
fpTraitTerm FPTrait
trait Term (FP eb sb)
v = Uninterned (Term Bool) -> Term Bool
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term Bool) -> Term Bool)
-> Uninterned (Term Bool) -> Term Bool
forall a b. (a -> b) -> a -> b
$ FPTrait -> Term (FP eb sb) -> UTerm Bool
forall (a :: Natural) (eb :: Natural).
(ValidFP a eb, SupportedPrim (FP a eb)) =>
FPTrait -> Term (FP a eb) -> UTerm Bool
UFPTraitTerm FPTrait
trait Term (FP eb sb)
v

-- | Construct and internalizing a 'FdivTerm'.
fdivTerm :: (PEvalFractionalTerm a) => Term a -> Term a -> Term a
fdivTerm :: forall a. PEvalFractionalTerm a => Term a -> Term a -> Term a
fdivTerm Term a
l Term a
r = Uninterned (Term a) -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term a) -> Term a) -> Uninterned (Term a) -> Term a
forall a b. (a -> b) -> a -> b
$ Term a -> Term a -> UTerm a
forall t. PEvalFractionalTerm t => Term t -> Term t -> UTerm t
UFdivTerm Term a
l Term a
r
{-# INLINE fdivTerm #-}

-- | Construct and internalizing a 'RecipTerm'.
recipTerm :: (PEvalFractionalTerm a) => Term a -> Term a
recipTerm :: forall a. PEvalFractionalTerm a => Term a -> Term a
recipTerm = Uninterned (Term a) -> Term a
UTerm a -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (UTerm a -> Term a) -> (Term a -> UTerm a) -> Term a -> Term a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term a -> UTerm a
forall t. PEvalFractionalTerm t => Term t -> UTerm t
URecipTerm
{-# INLINE recipTerm #-}

-- | Construct and internalizing a 'FloatingUnaryTerm'.
floatingUnaryTerm :: (PEvalFloatingTerm a) => FloatingUnaryOp -> Term a -> Term a
floatingUnaryTerm :: forall a.
PEvalFloatingTerm a =>
FloatingUnaryOp -> Term a -> Term a
floatingUnaryTerm FloatingUnaryOp
op = Uninterned (Term a) -> Term a
UTerm a -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (UTerm a -> Term a) -> (Term a -> UTerm a) -> Term a -> Term a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FloatingUnaryOp -> Term a -> UTerm a
forall t.
PEvalFloatingTerm t =>
FloatingUnaryOp -> Term t -> UTerm t
UFloatingUnaryTerm FloatingUnaryOp
op
{-# INLINE floatingUnaryTerm #-}

-- | Construct and internalizing a 'PowerTerm'.
powerTerm :: (PEvalFloatingTerm a) => Term a -> Term a -> Term a
powerTerm :: forall a. PEvalFloatingTerm a => Term a -> Term a -> Term a
powerTerm Term a
l Term a
r = Uninterned (Term a) -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term a) -> Term a) -> Uninterned (Term a) -> Term a
forall a b. (a -> b) -> a -> b
$ Term a -> Term a -> UTerm a
forall t. PEvalFloatingTerm t => Term t -> Term t -> UTerm t
UPowerTerm Term a
l Term a
r
{-# INLINE powerTerm #-}

-- | Construct and internalizing a 'FPUnaryTerm'.
fpUnaryTerm ::
  (ValidFP eb sb, SupportedPrim (FP eb sb)) =>
  FPUnaryOp ->
  Term (FP eb sb) ->
  Term (FP eb sb)
fpUnaryTerm :: forall (eb :: Natural) (sb :: Natural).
(ValidFP eb sb, SupportedPrim (FP eb sb)) =>
FPUnaryOp -> Term (FP eb sb) -> Term (FP eb sb)
fpUnaryTerm FPUnaryOp
op Term (FP eb sb)
v = Uninterned (Term (FP eb sb)) -> Term (FP eb sb)
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term (FP eb sb)) -> Term (FP eb sb))
-> Uninterned (Term (FP eb sb)) -> Term (FP eb sb)
forall a b. (a -> b) -> a -> b
$ FPUnaryOp -> Term (FP eb sb) -> UTerm (FP eb sb)
forall (a :: Natural) (eb :: Natural).
(ValidFP a eb, SupportedPrim (FP a eb)) =>
FPUnaryOp -> Term (FP a eb) -> UTerm (FP a eb)
UFPUnaryTerm FPUnaryOp
op Term (FP eb sb)
v

-- | Construct and internalizing a 'FPBinaryTerm'.
fpBinaryTerm ::
  (ValidFP eb sb, SupportedPrim (FP eb sb)) =>
  FPBinaryOp ->
  Term (FP eb sb) ->
  Term (FP eb sb) ->
  Term (FP eb sb)
fpBinaryTerm :: forall (eb :: Natural) (sb :: Natural).
(ValidFP eb sb, SupportedPrim (FP eb sb)) =>
FPBinaryOp -> Term (FP eb sb) -> Term (FP eb sb) -> Term (FP eb sb)
fpBinaryTerm FPBinaryOp
op Term (FP eb sb)
l Term (FP eb sb)
r = Uninterned (Term (FP eb sb)) -> Term (FP eb sb)
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term (FP eb sb)) -> Term (FP eb sb))
-> Uninterned (Term (FP eb sb)) -> Term (FP eb sb)
forall a b. (a -> b) -> a -> b
$ FPBinaryOp
-> Term (FP eb sb) -> Term (FP eb sb) -> UTerm (FP eb sb)
forall (a :: Natural) (eb :: Natural).
(ValidFP a eb, SupportedPrim (FP a eb)) =>
FPBinaryOp -> Term (FP a eb) -> Term (FP a eb) -> UTerm (FP a eb)
UFPBinaryTerm FPBinaryOp
op Term (FP eb sb)
l Term (FP eb sb)
r

-- | Construct and internalizing a 'FPRoundingUnaryTerm'.
fpRoundingUnaryTerm ::
  (ValidFP eb sb, SupportedPrim (FP eb sb), SupportedPrim FPRoundingMode) =>
  FPRoundingUnaryOp ->
  Term FPRoundingMode ->
  Term (FP eb sb) ->
  Term (FP eb sb)
fpRoundingUnaryTerm :: forall (eb :: Natural) (sb :: Natural).
(ValidFP eb sb, SupportedPrim (FP eb sb),
 SupportedPrim FPRoundingMode) =>
FPRoundingUnaryOp
-> Term FPRoundingMode -> Term (FP eb sb) -> Term (FP eb sb)
fpRoundingUnaryTerm FPRoundingUnaryOp
op Term FPRoundingMode
mode Term (FP eb sb)
v = Uninterned (Term (FP eb sb)) -> Term (FP eb sb)
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term (FP eb sb)) -> Term (FP eb sb))
-> Uninterned (Term (FP eb sb)) -> Term (FP eb sb)
forall a b. (a -> b) -> a -> b
$ FPRoundingUnaryOp
-> Term FPRoundingMode -> Term (FP eb sb) -> UTerm (FP eb sb)
forall (a :: Natural) (eb :: Natural).
(ValidFP a eb, SupportedPrim (FP a eb),
 SupportedPrim FPRoundingMode) =>
FPRoundingUnaryOp
-> Term FPRoundingMode -> Term (FP a eb) -> UTerm (FP a eb)
UFPRoundingUnaryTerm FPRoundingUnaryOp
op Term FPRoundingMode
mode Term (FP eb sb)
v

-- | Construct and internalizing a 'FPRoundingBinaryTerm'.
fpRoundingBinaryTerm ::
  (ValidFP eb sb, SupportedPrim (FP eb sb), SupportedPrim FPRoundingMode) =>
  FPRoundingBinaryOp ->
  Term FPRoundingMode ->
  Term (FP eb sb) ->
  Term (FP eb sb) ->
  Term (FP eb sb)
fpRoundingBinaryTerm :: forall (eb :: Natural) (sb :: Natural).
(ValidFP eb sb, SupportedPrim (FP eb sb),
 SupportedPrim FPRoundingMode) =>
FPRoundingBinaryOp
-> Term FPRoundingMode
-> Term (FP eb sb)
-> Term (FP eb sb)
-> Term (FP eb sb)
fpRoundingBinaryTerm FPRoundingBinaryOp
op Term FPRoundingMode
mode Term (FP eb sb)
l Term (FP eb sb)
r = Uninterned (Term (FP eb sb)) -> Term (FP eb sb)
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term (FP eb sb)) -> Term (FP eb sb))
-> Uninterned (Term (FP eb sb)) -> Term (FP eb sb)
forall a b. (a -> b) -> a -> b
$ FPRoundingBinaryOp
-> Term FPRoundingMode
-> Term (FP eb sb)
-> Term (FP eb sb)
-> UTerm (FP eb sb)
forall (a :: Natural) (eb :: Natural).
(ValidFP a eb, SupportedPrim (FP a eb),
 SupportedPrim FPRoundingMode) =>
FPRoundingBinaryOp
-> Term FPRoundingMode
-> Term (FP a eb)
-> Term (FP a eb)
-> UTerm (FP a eb)
UFPRoundingBinaryTerm FPRoundingBinaryOp
op Term FPRoundingMode
mode Term (FP eb sb)
l Term (FP eb sb)
r

-- | Construct and internalizing a 'FPFMATerm'.
fpFMATerm ::
  (ValidFP eb sb, SupportedPrim (FP eb sb), SupportedPrim FPRoundingMode) =>
  Term FPRoundingMode ->
  Term (FP eb sb) ->
  Term (FP eb sb) ->
  Term (FP eb sb) ->
  Term (FP eb sb)
fpFMATerm :: forall (eb :: Natural) (sb :: Natural).
(ValidFP eb sb, SupportedPrim (FP eb sb),
 SupportedPrim FPRoundingMode) =>
Term FPRoundingMode
-> Term (FP eb sb)
-> Term (FP eb sb)
-> Term (FP eb sb)
-> Term (FP eb sb)
fpFMATerm Term FPRoundingMode
mode Term (FP eb sb)
l Term (FP eb sb)
r Term (FP eb sb)
s = Uninterned (Term (FP eb sb)) -> Term (FP eb sb)
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term (FP eb sb)) -> Term (FP eb sb))
-> Uninterned (Term (FP eb sb)) -> Term (FP eb sb)
forall a b. (a -> b) -> a -> b
$ Term FPRoundingMode
-> Term (FP eb sb)
-> Term (FP eb sb)
-> Term (FP eb sb)
-> UTerm (FP eb sb)
forall (a :: Natural) (eb :: Natural).
(ValidFP a eb, SupportedPrim (FP a eb),
 SupportedPrim FPRoundingMode) =>
Term FPRoundingMode
-> Term (FP a eb)
-> Term (FP a eb)
-> Term (FP a eb)
-> UTerm (FP a eb)
UFPFMATerm Term FPRoundingMode
mode Term (FP eb sb)
l Term (FP eb sb)
r Term (FP eb sb)
s

-- | Construct and internalizing a 'FromIntegralTerm'.
fromIntegralTerm :: (PEvalFromIntegralTerm a b) => Term a -> Term b
fromIntegralTerm :: forall a b. PEvalFromIntegralTerm a b => Term a -> Term b
fromIntegralTerm = Uninterned (Term b) -> Term b
UTerm b -> Term b
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (UTerm b -> Term b) -> (Term a -> UTerm b) -> Term a -> Term b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term a -> UTerm b
forall a b. PEvalFromIntegralTerm a b => Term a -> UTerm b
UFromIntegralTerm

-- | Construct and internalizing a 'FromFPOrTerm'.
fromFPOrTerm ::
  ( PEvalIEEEFPConvertibleTerm a,
    ValidFP eb sb,
    SupportedPrim FPRoundingMode,
    SupportedPrim (FP eb sb)
  ) =>
  Term a ->
  Term FPRoundingMode ->
  Term (FP eb sb) ->
  Term a
fromFPOrTerm :: forall a (eb :: Natural) (sb :: Natural).
(PEvalIEEEFPConvertibleTerm a, ValidFP eb sb,
 SupportedPrim FPRoundingMode, SupportedPrim (FP eb sb)) =>
Term a -> Term FPRoundingMode -> Term (FP eb sb) -> Term a
fromFPOrTerm Term a
d Term FPRoundingMode
r Term (FP eb sb)
f = Uninterned (Term a) -> Term a
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term a) -> Term a) -> Uninterned (Term a) -> Term a
forall a b. (a -> b) -> a -> b
$ Term a -> Term FPRoundingMode -> Term (FP eb sb) -> UTerm a
forall a (a :: Natural) (eb :: Natural).
(PEvalIEEEFPConvertibleTerm a, ValidFP a eb,
 SupportedPrim FPRoundingMode, SupportedPrim (FP a eb)) =>
Term a -> Term FPRoundingMode -> Term (FP a eb) -> UTerm a
UFromFPOrTerm Term a
d Term FPRoundingMode
r Term (FP eb sb)
f

-- | Construct and internalizing a 'ToFPTerm'.
toFPTerm ::
  forall a eb sb.
  ( PEvalIEEEFPConvertibleTerm a,
    ValidFP eb sb,
    SupportedPrim FPRoundingMode,
    SupportedPrim (FP eb sb)
  ) =>
  Term FPRoundingMode ->
  Term a ->
  Term (FP eb sb)
toFPTerm :: forall a (eb :: Natural) (sb :: Natural).
(PEvalIEEEFPConvertibleTerm a, ValidFP eb sb,
 SupportedPrim FPRoundingMode, SupportedPrim (FP eb sb)) =>
Term FPRoundingMode -> Term a -> Term (FP eb sb)
toFPTerm Term FPRoundingMode
r Term a
f = Uninterned (Term (FP eb sb)) -> Term (FP eb sb)
forall t. SupportedPrim t => Uninterned (Term t) -> Term t
internTerm (Uninterned (Term (FP eb sb)) -> Term (FP eb sb))
-> Uninterned (Term (FP eb sb)) -> Term (FP eb sb)
forall a b. (a -> b) -> a -> b
$ Term FPRoundingMode
-> Term a -> Proxy eb -> Proxy sb -> UTerm (FP eb sb)
forall a (eb :: Natural) (sb :: Natural).
(PEvalIEEEFPConvertibleTerm a, ValidFP eb sb,
 SupportedPrim FPRoundingMode, SupportedPrim (FP eb sb)) =>
Term FPRoundingMode
-> Term a -> Proxy eb -> Proxy sb -> UTerm (FP eb sb)
UToFPTerm Term FPRoundingMode
r Term a
f (forall (t :: Natural). Proxy t
forall {k} (t :: k). Proxy t
Proxy @eb) (forall (t :: Natural). Proxy t
forall {k} (t :: k). Proxy t
Proxy @sb)

-- Support for boolean type
defaultValueForBool :: Bool
defaultValueForBool :: Bool
defaultValueForBool = Bool
False

defaultValueForBoolDyn :: ModelValue
defaultValueForBoolDyn :: ModelValue
defaultValueForBoolDyn = Bool -> ModelValue
forall a. (Show a, Eq a, Hashable a, Typeable a) => a -> ModelValue
toModelValue Bool
defaultValueForBool

-- | Construct and internalizing 'True' term.
trueTerm :: Term Bool
trueTerm :: Term Bool
trueTerm = Bool -> Term Bool
forall t.
(SupportedPrim t, Typeable t, Hashable t, Eq t, Show t) =>
t -> Term t
conTerm Bool
True
{-# INLINE trueTerm #-}

-- | Construct and internalizing 'False' term.
falseTerm :: Term Bool
falseTerm :: Term Bool
falseTerm = Bool -> Term Bool
forall t.
(SupportedPrim t, Typeable t, Hashable t, Eq t, Show t) =>
t -> Term t
conTerm Bool
False
{-# INLINE falseTerm #-}

boolConTermView :: forall a. Term a -> Maybe Bool
boolConTermView :: forall a. Term a -> Maybe Bool
boolConTermView (ConTerm Int
_ a
b) = a -> Maybe Bool
forall a b. (Typeable a, Typeable b) => a -> Maybe b
cast a
b
boolConTermView Term a
_ = Maybe Bool
forall a. Maybe a
Nothing
{-# INLINE boolConTermView #-}

-- | Pattern matcher for concrete 'Bool' terms.
pattern BoolConTerm :: Bool -> Term a
pattern $mBoolConTerm :: forall {r} {a}. Term a -> (Bool -> r) -> ((# #) -> r) -> r
BoolConTerm b <- (boolConTermView -> Just b)

-- | Pattern matcher for 'True' term.
pattern TrueTerm :: Term a
pattern $mTrueTerm :: forall {r} {a}. Term a -> ((# #) -> r) -> ((# #) -> r) -> r
TrueTerm <- BoolConTerm True

-- | Pattern matcher for 'False' term.
pattern FalseTerm :: Term a
pattern $mFalseTerm :: forall {r} {a}. Term a -> ((# #) -> r) -> ((# #) -> r) -> r
FalseTerm <- BoolConTerm False

boolTermView :: forall a. Term a -> Maybe (Term Bool)
boolTermView :: forall a. Term a -> Maybe (Term Bool)
boolTermView Term a
t = Term a
-> (SupportedPrim a => Maybe (Term Bool)) -> Maybe (Term Bool)
forall t a. Term t -> (SupportedPrim t => a) -> a
introSupportedPrimConstraint Term a
t ((SupportedPrim a => Maybe (Term Bool)) -> Maybe (Term Bool))
-> (SupportedPrim a => Maybe (Term Bool)) -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term a -> Maybe (Term Bool)
forall a b. (Typeable a, Typeable b) => a -> Maybe b
cast Term a
t
{-# INLINE boolTermView #-}

-- | Pattern matcher for 'Bool' terms.
pattern BoolTerm :: Term Bool -> Term a
pattern $mBoolTerm :: forall {r} {a}. Term a -> (Term Bool -> r) -> ((# #) -> r) -> r
BoolTerm b <- (boolTermView -> Just b)

-- | Partial evaluation for not terms.
pevalNotTerm :: Term Bool -> Term Bool
pevalNotTerm :: Term Bool -> Term Bool
pevalNotTerm (NotTerm Int
_ Term Bool
tm) = Term Bool
tm
pevalNotTerm (ConTerm Int
_ Bool
a) = if Bool
a then Term Bool
falseTerm else Term Bool
trueTerm
pevalNotTerm (OrTerm Int
_ (NotTerm Int
_ Term Bool
n1) Term Bool
n2) = Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
n1 (Term Bool -> Term Bool
pevalNotTerm Term Bool
n2)
pevalNotTerm (OrTerm Int
_ (DistinctTerm Int
_ (Term t
n1 :| [Term t
n2])) Term Bool
n3) =
  Term Bool -> Term Bool -> Term Bool
pevalAndTerm (Term t -> Term t -> Term Bool
forall a. SupportedPrim a => Term a -> Term a -> Term Bool
pevalEqTerm Term t
n1 Term t
n2) (Term Bool -> Term Bool
pevalNotTerm Term Bool
n3)
pevalNotTerm (OrTerm Int
_ Term Bool
n1 (NotTerm Int
_ Term Bool
n2)) = Term Bool -> Term Bool -> Term Bool
pevalAndTerm (Term Bool -> Term Bool
pevalNotTerm Term Bool
n1) Term Bool
n2
pevalNotTerm (OrTerm Int
_ Term Bool
n1 (DistinctTerm Int
_ (Term t
n2 :| [Term t
n3]))) =
  Term Bool -> Term Bool -> Term Bool
pevalAndTerm (Term Bool -> Term Bool
pevalNotTerm Term Bool
n1) (Term t -> Term t -> Term Bool
forall a. SupportedPrim a => Term a -> Term a -> Term Bool
pevalEqTerm Term t
n2 Term t
n3)
pevalNotTerm (AndTerm Int
_ (NotTerm Int
_ Term Bool
n1) Term Bool
n2) = Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
n1 (Term Bool -> Term Bool
pevalNotTerm Term Bool
n2)
pevalNotTerm (AndTerm Int
_ (DistinctTerm Int
_ (Term t
n1 :| [Term t
n2])) Term Bool
n3) =
  Term Bool -> Term Bool -> Term Bool
pevalOrTerm (Term t -> Term t -> Term Bool
forall a. SupportedPrim a => Term a -> Term a -> Term Bool
pevalEqTerm Term t
n1 Term t
n2) (Term Bool -> Term Bool
pevalNotTerm Term Bool
n3)
pevalNotTerm (AndTerm Int
_ Term Bool
n1 (NotTerm Int
_ Term Bool
n2)) = Term Bool -> Term Bool -> Term Bool
pevalOrTerm (Term Bool -> Term Bool
pevalNotTerm Term Bool
n1) Term Bool
n2
pevalNotTerm (AndTerm Int
_ Term Bool
n1 (DistinctTerm Int
_ (Term t
n2 :| [Term t
n3]))) =
  Term Bool -> Term Bool -> Term Bool
pevalOrTerm (Term Bool -> Term Bool
pevalNotTerm Term Bool
n1) (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term t -> Term t -> Term Bool
forall a. SupportedPrim a => Term a -> Term a -> Term Bool
pevalEqTerm Term t
n2 Term t
n3
pevalNotTerm (EqTerm Int
_ Term t
a Term t
b) = NonEmpty (Term t) -> Term Bool
forall a. SupportedNonFuncPrim a => NonEmpty (Term a) -> Term Bool
distinctTerm (NonEmpty (Term t) -> Term Bool) -> NonEmpty (Term t) -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term t
a Term t -> [Term t] -> NonEmpty (Term t)
forall a. a -> [a] -> NonEmpty a
:| [Term t
b]
pevalNotTerm (DistinctTerm Int
_ (Term t
a :| [Term t
b])) = Term t -> Term t -> Term Bool
forall a. SupportedNonFuncPrim a => Term a -> Term a -> Term Bool
eqTerm Term t
a Term t
b
pevalNotTerm Term Bool
tm = Term Bool -> Term Bool
notTerm Term Bool
tm
{-# INLINEABLE pevalNotTerm #-}

orEqFirst :: Term Bool -> Term Bool -> Bool
orEqFirst :: Term Bool -> Term Bool -> Bool
orEqFirst Term Bool
_ (ConTerm Int
_ Bool
False) = Bool
True
orEqFirst
  (DistinctTerm Int
_ ((Term t
e1 :: Term a) :| [ec1 :: Term t
ec1@(ConTerm Int
_ t
_) :: Term b]))
  (EqTerm Int
_ (Dyn (Term t
e2 :: Term a)) (Dyn (ec2 :: Term t
ec2@(ConTerm Int
_ t
_) :: Term b)))
    | Term t
e1 Term t -> Term t -> Bool
forall a. Eq a => a -> a -> Bool
== Term t
e2 Bool -> Bool -> Bool
&& Term t
ec1 Term t -> Term t -> Bool
forall a. Eq a => a -> a -> Bool
/= Term t
ec2 = Bool
True
-- orEqFirst
--   (NotTerm _ (EqTerm _ (e1 :: Term a) (ec1@(ConTerm _ _) :: Term b)))
--   (EqTerm _ (Dyn (e2 :: Term a)) (Dyn (ec2@(ConTerm _ _) :: Term b)))
--     | e1 == e2 && ec1 /= ec2 = True
orEqFirst Term Bool
x Term Bool
y
  | Term Bool
x Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
y = Bool
True
  | Bool
otherwise = Bool
False
{-# INLINE orEqFirst #-}

orEqTrue :: Term Bool -> Term Bool -> Bool
orEqTrue :: Term Bool -> Term Bool -> Bool
orEqTrue (ConTerm Int
_ Bool
True) Term Bool
_ = Bool
True
orEqTrue Term Bool
_ (ConTerm Int
_ Bool
True) = Bool
True
-- orEqTrue (NotTerm _ e1) (NotTerm _ e2) = andEqFalse e1 e2
orEqTrue
  (DistinctTerm Int
_ ((Term t
e1 :: Term a) :| [ec1 :: Term t
ec1@(ConTerm Int
_ t
_) :: Term b]))
  (DistinctTerm Int
_ ((Dyn (Term t
e2 :: Term a)) :| [Dyn (ec2 :: Term t
ec2@(ConTerm Int
_ t
_) :: Term b)]))
    | Term t
e1 Term t -> Term t -> Bool
forall a. Eq a => a -> a -> Bool
== Term t
e2 Bool -> Bool -> Bool
&& Term t
ec1 Term t -> Term t -> Bool
forall a. Eq a => a -> a -> Bool
/= Term t
ec2 = Bool
True
-- orEqTrue
--   (NotTerm _ (EqTerm _ (e1 :: Term a) (ec1@(ConTerm _ _) :: Term b)))
--   (NotTerm _ (EqTerm _ (Dyn (e2 :: Term a)) (Dyn (ec2@(ConTerm _ _) :: Term b))))
--     | e1 == e2 && ec1 /= ec2 = True
orEqTrue (NotTerm Int
_ Term Bool
l) Term Bool
r | Term Bool
l Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
r = Bool
True
orEqTrue Term Bool
l (NotTerm Int
_ Term Bool
r) | Term Bool
l Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
r = Bool
True
orEqTrue Term Bool
_ Term Bool
_ = Bool
False
{-# INLINE orEqTrue #-}

andEqFirst :: Term Bool -> Term Bool -> Bool
andEqFirst :: Term Bool -> Term Bool -> Bool
andEqFirst Term Bool
_ (ConTerm Int
_ Bool
True) = Bool
True
-- andEqFirst x (NotTerm _ y) = andEqFalse x y
andEqFirst
  (EqTerm Int
_ (Term t
e1 :: Term a) (ec1 :: Term t
ec1@(ConTerm Int
_ t
_) :: Term b))
  (DistinctTerm Int
_ ((Dyn (Term t
e2 :: Term a)) :| [Dyn (ec2 :: Term t
ec2@(ConTerm Int
_ t
_) :: Term b)]))
    | Term t
e1 Term t -> Term t -> Bool
forall a. Eq a => a -> a -> Bool
== Term t
e2 Bool -> Bool -> Bool
&& Term t
ec1 Term t -> Term t -> Bool
forall a. Eq a => a -> a -> Bool
/= Term t
ec2 = Bool
True
-- andEqFirst
--   (EqTerm _ (e1 :: Term a) (ec1@(ConTerm _ _) :: Term b))
--   (NotTerm _ (EqTerm _ (Dyn (e2 :: Term a)) (Dyn (ec2@(ConTerm _ _) :: Term b))))
--     | e1 == e2 && ec1 /= ec2 = True
andEqFirst Term Bool
x Term Bool
y
  | Term Bool
x Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
y = Bool
True
  | Bool
otherwise = Bool
False
{-# INLINE andEqFirst #-}

andEqFalse :: Term Bool -> Term Bool -> Bool
andEqFalse :: Term Bool -> Term Bool -> Bool
andEqFalse (ConTerm Int
_ Bool
False) Term Bool
_ = Bool
True
andEqFalse Term Bool
_ (ConTerm Int
_ Bool
False) = Bool
True
-- andEqFalse (NotTerm _ e1) (NotTerm _ e2) = orEqTrue e1 e2
andEqFalse
  (EqTerm Int
_ (Term t
e1 :: Term a) (ec1 :: Term t
ec1@(ConTerm Int
_ t
_) :: Term b))
  (EqTerm Int
_ (Dyn (Term t
e2 :: Term a)) (Dyn (ec2 :: Term t
ec2@(ConTerm Int
_ t
_) :: Term b)))
    | Term t
e1 Term t -> Term t -> Bool
forall a. Eq a => a -> a -> Bool
== Term t
e2 Bool -> Bool -> Bool
&& Term t
ec1 Term t -> Term t -> Bool
forall a. Eq a => a -> a -> Bool
/= Term t
ec2 = Bool
True
andEqFalse (NotTerm Int
_ Term Bool
x) Term Bool
y | Term Bool
x Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
y = Bool
True
andEqFalse Term Bool
x (NotTerm Int
_ Term Bool
y) | Term Bool
x Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
y = Bool
True
andEqFalse Term Bool
_ Term Bool
_ = Bool
False
{-# INLINE andEqFalse #-}

-- | Partial evaluation for or terms.
pevalOrTerm :: Term Bool -> Term Bool -> Term Bool
pevalOrTerm :: Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
l Term Bool
r
  | Term Bool -> Term Bool -> Bool
orEqTrue Term Bool
l Term Bool
r = Term Bool
trueTerm
  | Term Bool -> Term Bool -> Bool
orEqFirst Term Bool
l Term Bool
r = Term Bool
l
  | Term Bool -> Term Bool -> Bool
orEqFirst Term Bool
r Term Bool
l = Term Bool
r
pevalOrTerm Term Bool
l r :: Term Bool
r@(OrTerm Int
_ Term Bool
r1 Term Bool
r2)
  | Term Bool -> Term Bool -> Bool
orEqTrue Term Bool
l Term Bool
r1 = Term Bool
trueTerm
  | Term Bool -> Term Bool -> Bool
orEqTrue Term Bool
l Term Bool
r2 = Term Bool
trueTerm
  | Term Bool -> Term Bool -> Bool
orEqFirst Term Bool
r1 Term Bool
l = Term Bool
r
  | Term Bool -> Term Bool -> Bool
orEqFirst Term Bool
r2 Term Bool
l = Term Bool
r
  | Term Bool -> Term Bool -> Bool
orEqFirst Term Bool
l Term Bool
r1 = Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
l Term Bool
r2
  | Term Bool -> Term Bool -> Bool
orEqFirst Term Bool
l Term Bool
r2 = Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
l Term Bool
r1
pevalOrTerm l :: Term Bool
l@(OrTerm Int
_ Term Bool
l1 Term Bool
l2) Term Bool
r
  | Term Bool -> Term Bool -> Bool
orEqTrue Term Bool
l1 Term Bool
r = Term Bool
trueTerm
  | Term Bool -> Term Bool -> Bool
orEqTrue Term Bool
l2 Term Bool
r = Term Bool
trueTerm
  | Term Bool -> Term Bool -> Bool
orEqFirst Term Bool
l1 Term Bool
r = Term Bool
l
  | Term Bool -> Term Bool -> Bool
orEqFirst Term Bool
l2 Term Bool
r = Term Bool
l
  | Term Bool -> Term Bool -> Bool
orEqFirst Term Bool
r Term Bool
l1 = Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
l2 Term Bool
r
  | Term Bool -> Term Bool -> Bool
orEqFirst Term Bool
r Term Bool
l2 = Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
l1 Term Bool
r
pevalOrTerm Term Bool
l (AndTerm Int
_ Term Bool
r1 Term Bool
r2)
  | Term Bool -> Term Bool -> Bool
orEqFirst Term Bool
l Term Bool
r1 = Term Bool
l
  | Term Bool -> Term Bool -> Bool
orEqFirst Term Bool
l Term Bool
r2 = Term Bool
l
  | Term Bool -> Term Bool -> Bool
orEqTrue Term Bool
l Term Bool
r1 = Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
l Term Bool
r2
  | Term Bool -> Term Bool -> Bool
orEqTrue Term Bool
l Term Bool
r2 = Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
l Term Bool
r1
pevalOrTerm (AndTerm Int
_ Term Bool
l1 Term Bool
l2) Term Bool
r
  | Term Bool -> Term Bool -> Bool
orEqFirst Term Bool
r Term Bool
l1 = Term Bool
r
  | Term Bool -> Term Bool -> Bool
orEqFirst Term Bool
r Term Bool
l2 = Term Bool
r
  | Term Bool -> Term Bool -> Bool
orEqTrue Term Bool
l1 Term Bool
r = Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
l2 Term Bool
r
  | Term Bool -> Term Bool -> Bool
orEqTrue Term Bool
l2 Term Bool
r = Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
l1 Term Bool
r
pevalOrTerm
  (AndTerm Int
_ nl1 :: Term Bool
nl1@(NotTerm Int
_ Term Bool
l1) Term Bool
l2)
  (EqTerm Int
_ (Dyn (Term Bool
e1 :: Term Bool)) (Dyn (Term Bool
e2 :: Term Bool)))
    | Term Bool
l1 Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
e1 Bool -> Bool -> Bool
&& Term Bool
l2 Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
e2 = Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
nl1 Term Bool
l2
pevalOrTerm (NotTerm Int
_ Term Bool
nl) (NotTerm Int
_ Term Bool
nr) = Term Bool -> Term Bool
pevalNotTerm (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
nl Term Bool
nr
pevalOrTerm Term Bool
l Term Bool
r = Term Bool -> Term Bool -> Term Bool
orTerm Term Bool
l Term Bool
r
{-# INLINEABLE pevalOrTerm #-}

-- | Partial evaluation for and terms.
pevalAndTerm :: Term Bool -> Term Bool -> Term Bool
pevalAndTerm :: Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
l Term Bool
r
  | Term Bool -> Term Bool -> Bool
andEqFalse Term Bool
l Term Bool
r = Term Bool
falseTerm
  | Term Bool -> Term Bool -> Bool
andEqFirst Term Bool
l Term Bool
r = Term Bool
l
  | Term Bool -> Term Bool -> Bool
andEqFirst Term Bool
r Term Bool
l = Term Bool
r
pevalAndTerm Term Bool
l r :: Term Bool
r@(AndTerm Int
_ Term Bool
r1 Term Bool
r2)
  | Term Bool -> Term Bool -> Bool
andEqFalse Term Bool
l Term Bool
r1 = Term Bool
falseTerm
  | Term Bool -> Term Bool -> Bool
andEqFalse Term Bool
l Term Bool
r2 = Term Bool
falseTerm
  | Term Bool -> Term Bool -> Bool
andEqFirst Term Bool
r1 Term Bool
l = Term Bool
r
  | Term Bool -> Term Bool -> Bool
andEqFirst Term Bool
r2 Term Bool
l = Term Bool
r
  | Term Bool -> Term Bool -> Bool
andEqFirst Term Bool
l Term Bool
r1 = Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
l Term Bool
r2
  | Term Bool -> Term Bool -> Bool
andEqFirst Term Bool
l Term Bool
r2 = Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
l Term Bool
r1
pevalAndTerm l :: Term Bool
l@(AndTerm Int
_ Term Bool
l1 Term Bool
l2) Term Bool
r
  | Term Bool -> Term Bool -> Bool
andEqFalse Term Bool
l1 Term Bool
r = Term Bool
falseTerm
  | Term Bool -> Term Bool -> Bool
andEqFalse Term Bool
l2 Term Bool
r = Term Bool
falseTerm
  | Term Bool -> Term Bool -> Bool
andEqFirst Term Bool
l1 Term Bool
r = Term Bool
l
  | Term Bool -> Term Bool -> Bool
andEqFirst Term Bool
l2 Term Bool
r = Term Bool
l
  | Term Bool -> Term Bool -> Bool
andEqFirst Term Bool
r Term Bool
l1 = Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
l2 Term Bool
r
  | Term Bool -> Term Bool -> Bool
andEqFirst Term Bool
r Term Bool
l2 = Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
l1 Term Bool
r
pevalAndTerm Term Bool
l (OrTerm Int
_ Term Bool
r1 Term Bool
r2)
  | Term Bool -> Term Bool -> Bool
andEqFirst Term Bool
l Term Bool
r1 = Term Bool
l
  | Term Bool -> Term Bool -> Bool
andEqFirst Term Bool
l Term Bool
r2 = Term Bool
l
  | Term Bool -> Term Bool -> Bool
andEqFalse Term Bool
l Term Bool
r1 = Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
l Term Bool
r2
  | Term Bool -> Term Bool -> Bool
andEqFalse Term Bool
l Term Bool
r2 = Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
l Term Bool
r1
pevalAndTerm (OrTerm Int
_ Term Bool
l1 Term Bool
l2) Term Bool
r
  | Term Bool -> Term Bool -> Bool
andEqFirst Term Bool
r Term Bool
l1 = Term Bool
r
  | Term Bool -> Term Bool -> Bool
andEqFirst Term Bool
r Term Bool
l2 = Term Bool
r
  | Term Bool -> Term Bool -> Bool
andEqFalse Term Bool
l1 Term Bool
r = Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
l2 Term Bool
r
  | Term Bool -> Term Bool -> Bool
andEqFalse Term Bool
l2 Term Bool
r = Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
l1 Term Bool
r
pevalAndTerm
  (OrTerm Int
_ Term Bool
l1 nl2 :: Term Bool
nl2@(NotTerm Int
_ Term Bool
l2))
  (NotTerm Int
_ (EqTerm Int
_ (Dyn (Term Bool
e1 :: Term Bool)) (Dyn (Term Bool
e2 :: Term Bool))))
    | Term Bool
l1 Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
e1 Bool -> Bool -> Bool
&& Term Bool
l2 Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
e2 = Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
l1 Term Bool
nl2
pevalAndTerm (NotTerm Int
_ Term Bool
nl) (NotTerm Int
_ Term Bool
nr) = Term Bool -> Term Bool
pevalNotTerm (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
nl Term Bool
nr
pevalAndTerm Term Bool
l Term Bool
r = Term Bool -> Term Bool -> Term Bool
andTerm Term Bool
l Term Bool
r
{-# INLINEABLE pevalAndTerm #-}

-- | Partial evaluation for imply terms.
pevalImplyTerm :: Term Bool -> Term Bool -> Term Bool
pevalImplyTerm :: Term Bool -> Term Bool -> Term Bool
pevalImplyTerm Term Bool
l = Term Bool -> Term Bool -> Term Bool
pevalOrTerm (Term Bool -> Term Bool
pevalNotTerm Term Bool
l)

-- | Partial evaluation for xor terms.
pevalXorTerm :: Term Bool -> Term Bool -> Term Bool
pevalXorTerm :: Term Bool -> Term Bool -> Term Bool
pevalXorTerm Term Bool
l Term Bool
r = Term Bool -> Term Bool -> Term Bool
pevalOrTerm (Term Bool -> Term Bool -> Term Bool
pevalAndTerm (Term Bool -> Term Bool
pevalNotTerm Term Bool
l) Term Bool
r) (Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
l (Term Bool -> Term Bool
pevalNotTerm Term Bool
r))

pevalImpliesTerm :: Term Bool -> Term Bool -> Bool
pevalImpliesTerm :: Term Bool -> Term Bool -> Bool
pevalImpliesTerm (ConTerm Int
_ Bool
False) Term Bool
_ = Bool
True
pevalImpliesTerm Term Bool
_ (ConTerm Int
_ Bool
True) = Bool
True
pevalImpliesTerm
  (EqTerm Int
_ (Term t
e1 :: Term a) (ec1 :: Term t
ec1@(ConTerm Int
_ t
_) :: Term b))
  (DistinctTerm Int
_ ((Dyn (Term t
e2 :: Term a)) :| [(Dyn (ec2 :: Term t
ec2@(ConTerm Int
_ t
_) :: Term b))]))
    | Term t
e1 Term t -> Term t -> Bool
forall a. Eq a => a -> a -> Bool
== Term t
e2 Bool -> Bool -> Bool
&& Term t
ec1 Term t -> Term t -> Bool
forall a. Eq a => a -> a -> Bool
/= Term t
ec2 = Bool
True
-- pevalImpliesTerm
--   (EqTerm _ (e1 :: Term a) (ec1@(ConTerm _ _) :: Term b))
--   (NotTerm _ (EqTerm _ (Dyn (e2 :: Term a)) (Dyn (ec2@(ConTerm _ _) :: Term b))))
--     | e1 == e2 && ec1 /= ec2 = True
pevalImpliesTerm Term Bool
a Term Bool
b
  | Term Bool
a Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
b = Bool
True
  | Bool
otherwise = Bool
False
{-# INLINE pevalImpliesTerm #-}

pevalITEBoolLeftNot :: Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolLeftNot :: Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolLeftNot Term Bool
cond Term Bool
nIfTrue Term Bool
ifFalse
  -- need test
  | Term Bool
cond Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
nIfTrue = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalAndTerm (Term Bool -> Term Bool
pevalNotTerm Term Bool
cond) Term Bool
ifFalse
  | Bool
otherwise = case Term Bool
nIfTrue of
      AndTerm Int
_ Term Bool
nt1 Term Bool
nt2 -> Maybe (Term Bool)
ra
        where
          ra :: Maybe (Term Bool)
ra
            | Term Bool -> Term Bool -> Bool
pevalImpliesTerm Term Bool
cond Term Bool
nt1 =
                Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool -> Term Bool
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cond (Term Bool -> Term Bool
pevalNotTerm Term Bool
nt2) Term Bool
ifFalse
            | Term Bool -> Term Bool -> Bool
pevalImpliesTerm Term Bool
cond Term Bool
nt2 =
                Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool -> Term Bool
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cond (Term Bool -> Term Bool
pevalNotTerm Term Bool
nt1) Term Bool
ifFalse
            | Term Bool -> Term Bool -> Bool
pevalImpliesTerm Term Bool
cond (Term Bool -> Term Bool
pevalNotTerm Term Bool
nt1)
                Bool -> Bool -> Bool
|| Term Bool -> Term Bool -> Bool
pevalImpliesTerm Term Bool
cond (Term Bool -> Term Bool
pevalNotTerm Term Bool
nt2) =
                Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
cond Term Bool
ifFalse
            | Bool
otherwise = Maybe (Term Bool)
forall a. Maybe a
Nothing
      OrTerm Int
_ Term Bool
nt1 Term Bool
nt2 -> Maybe (Term Bool)
ra
        where
          ra :: Maybe (Term Bool)
ra
            | Term Bool -> Term Bool -> Bool
pevalImpliesTerm Term Bool
cond Term Bool
nt1 Bool -> Bool -> Bool
|| Term Bool -> Term Bool -> Bool
pevalImpliesTerm Term Bool
cond Term Bool
nt2 =
                Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalAndTerm (Term Bool -> Term Bool
pevalNotTerm Term Bool
cond) Term Bool
ifFalse
            | Term Bool -> Term Bool -> Bool
pevalImpliesTerm Term Bool
cond (Term Bool -> Term Bool
pevalNotTerm Term Bool
nt1) =
                Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool -> Term Bool
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cond (Term Bool -> Term Bool
pevalNotTerm Term Bool
nt2) Term Bool
ifFalse
            | Term Bool -> Term Bool -> Bool
pevalImpliesTerm Term Bool
cond (Term Bool -> Term Bool
pevalNotTerm Term Bool
nt2) =
                Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool -> Term Bool
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cond (Term Bool -> Term Bool
pevalNotTerm Term Bool
nt1) Term Bool
ifFalse
            | Bool
otherwise = Maybe (Term Bool)
forall a. Maybe a
Nothing
      Term Bool
_ -> Maybe (Term Bool)
forall a. Maybe a
Nothing

pevalITEBoolBothNot :: Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolBothNot :: Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolBothNot Term Bool
cond Term Bool
nIfTrue Term Bool
nIfFalse =
  Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool
pevalNotTerm (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool -> Term Bool
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cond Term Bool
nIfTrue Term Bool
nIfFalse

pevalITEBoolRightNot :: Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolRightNot :: Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolRightNot Term Bool
cond Term Bool
ifTrue Term Bool
nIfFalse
  -- need test
  | Term Bool
cond Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
nIfFalse = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalOrTerm (Term Bool -> Term Bool
pevalNotTerm Term Bool
cond) Term Bool
ifTrue
  | Bool
otherwise = Maybe (Term Bool)
forall a. Maybe a
Nothing -- need work

pevalInferImplies :: Term Bool -> Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalInferImplies :: Term Bool
-> Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalInferImplies Term Bool
cond (NotTerm Int
_ Term Bool
nt1) Term Bool
_ Term Bool
falseRes
  | Term Bool
cond Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
nt1 = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just Term Bool
falseRes
  | Bool
otherwise = Maybe (Term Bool)
forall a. Maybe a
Nothing
-- \| otherwise = case (cond, nt1) of
--     ( EqTerm _ (e1 :: Term a) (ec1@(ConTerm _ _) :: Term b),
--       EqTerm _ (Dyn (e2 :: Term a)) (Dyn (ec2@(ConTerm _ _) :: Term b))
--       )
--         | e1 == e2 && ec1 /= ec2 -> Just trueRes
--     _ -> Nothing
pevalInferImplies
  (EqTerm Int
_ (Term t
e1 :: Term a) (ec1 :: Term t
ec1@(ConTerm Int
_ t
_) :: Term b))
  (DistinctTerm Int
_ ((Dyn (Term t
e2 :: Term a)) :| [Dyn (ec2 :: Term t
ec2@(ConTerm Int
_ t
_) :: Term b)]))
  Term Bool
trueRes
  Term Bool
_
    | Term t
e1 Term t -> Term t -> Bool
forall a. Eq a => a -> a -> Bool
== Term t
e2 Bool -> Bool -> Bool
&& Term t
ec1 Term t -> Term t -> Bool
forall a. Eq a => a -> a -> Bool
/= Term t
ec2 = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just Term Bool
trueRes
pevalInferImplies
  (EqTerm Int
_ (Term t
e1 :: Term a) (ec1 :: Term t
ec1@(ConTerm Int
_ t
_) :: Term b))
  (EqTerm Int
_ (Dyn (Term t
e2 :: Term a)) (Dyn (ec2 :: Term t
ec2@(ConTerm Int
_ t
_) :: Term b)))
  Term Bool
_
  Term Bool
falseRes
    | Term t
e1 Term t -> Term t -> Bool
forall a. Eq a => a -> a -> Bool
== Term t
e2 Bool -> Bool -> Bool
&& Term t
ec1 Term t -> Term t -> Bool
forall a. Eq a => a -> a -> Bool
/= Term t
ec2 = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just Term Bool
falseRes
pevalInferImplies Term Bool
_ Term Bool
_ Term Bool
_ Term Bool
_ = Maybe (Term Bool)
forall a. Maybe a
Nothing

pevalITEBoolLeftAnd :: Term Bool -> Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolLeftAnd :: Term Bool
-> Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolLeftAnd Term Bool
cond Term Bool
t1 Term Bool
t2 Term Bool
ifFalse
  | Term Bool
t1 Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
ifFalse = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
t1 (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalImplyTerm Term Bool
cond Term Bool
t2
  | Term Bool
t2 Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
ifFalse = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
t2 (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalImplyTerm Term Bool
cond Term Bool
t1
  | Term Bool
cond Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
t1 = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool -> Term Bool
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cond Term Bool
t2 Term Bool
ifFalse
  | Term Bool
cond Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
t2 = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool -> Term Bool
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cond Term Bool
t1 Term Bool
ifFalse
  | Bool
otherwise =
      [Maybe (Term Bool)] -> Maybe (Term Bool)
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
        [ Term Bool
-> Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalInferImplies Term Bool
cond Term Bool
t1 (Term Bool -> Term Bool -> Term Bool -> Term Bool
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cond Term Bool
t2 Term Bool
ifFalse) (Term Bool -> Term Bool -> Term Bool
pevalAndTerm (Term Bool -> Term Bool
pevalNotTerm Term Bool
cond) Term Bool
ifFalse),
          Term Bool
-> Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalInferImplies Term Bool
cond Term Bool
t2 (Term Bool -> Term Bool -> Term Bool -> Term Bool
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cond Term Bool
t1 Term Bool
ifFalse) (Term Bool -> Term Bool -> Term Bool
pevalAndTerm (Term Bool -> Term Bool
pevalNotTerm Term Bool
cond) Term Bool
ifFalse)
        ]

pevalITEBoolBothAnd :: Term Bool -> Term Bool -> Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolBothAnd :: Term Bool
-> Term Bool
-> Term Bool
-> Term Bool
-> Term Bool
-> Maybe (Term Bool)
pevalITEBoolBothAnd Term Bool
cond Term Bool
t1 Term Bool
t2 Term Bool
f1 Term Bool
f2
  | Term Bool
t1 Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
f1 = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
t1 (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool -> Term Bool
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cond Term Bool
t2 Term Bool
f2
  | Term Bool
t1 Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
f2 = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
t1 (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool -> Term Bool
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cond Term Bool
t2 Term Bool
f1
  | Term Bool
t2 Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
f1 = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
t2 (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool -> Term Bool
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cond Term Bool
t1 Term Bool
f2
  | Term Bool
t2 Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
f2 = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
t2 (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool -> Term Bool
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cond Term Bool
t1 Term Bool
f1
  | Bool
otherwise = Maybe (Term Bool)
forall a. Maybe a
Nothing

pevalITEBoolRightAnd :: Term Bool -> Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolRightAnd :: Term Bool
-> Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolRightAnd Term Bool
cond Term Bool
ifTrue Term Bool
f1 Term Bool
f2
  | Term Bool
f1 Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
ifTrue = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
f1 (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
cond Term Bool
f2
  | Term Bool
f2 Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
ifTrue = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
f2 (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
cond Term Bool
f1
  | Bool
otherwise = Maybe (Term Bool)
forall a. Maybe a
Nothing

pevalITEBoolLeftOr :: Term Bool -> Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolLeftOr :: Term Bool
-> Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolLeftOr Term Bool
cond Term Bool
t1 Term Bool
t2 Term Bool
ifFalse
  | Term Bool
t1 Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
ifFalse = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
t1 (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
cond Term Bool
t2
  | Term Bool
t2 Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
ifFalse = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
t2 (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
cond Term Bool
t1
  | Term Bool
cond Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
t1 = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
cond Term Bool
ifFalse
  | Term Bool
cond Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
t2 = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
cond Term Bool
ifFalse
  | Bool
otherwise =
      [Maybe (Term Bool)] -> Maybe (Term Bool)
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
        [ Term Bool
-> Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalInferImplies Term Bool
cond Term Bool
t1 (Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
cond Term Bool
ifFalse) (Term Bool -> Term Bool -> Term Bool -> Term Bool
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cond Term Bool
t2 Term Bool
ifFalse),
          Term Bool
-> Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalInferImplies Term Bool
cond Term Bool
t2 (Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
cond Term Bool
ifFalse) (Term Bool -> Term Bool -> Term Bool -> Term Bool
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cond Term Bool
t1 Term Bool
ifFalse)
        ]

pevalITEBoolBothOr :: Term Bool -> Term Bool -> Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolBothOr :: Term Bool
-> Term Bool
-> Term Bool
-> Term Bool
-> Term Bool
-> Maybe (Term Bool)
pevalITEBoolBothOr Term Bool
cond Term Bool
t1 Term Bool
t2 Term Bool
f1 Term Bool
f2
  | Term Bool
t1 Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
f1 = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
t1 (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool -> Term Bool
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cond Term Bool
t2 Term Bool
f2
  | Term Bool
t1 Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
f2 = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
t1 (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool -> Term Bool
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cond Term Bool
t2 Term Bool
f1
  | Term Bool
t2 Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
f1 = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
t2 (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool -> Term Bool
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cond Term Bool
t1 Term Bool
f2
  | Term Bool
t2 Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
f2 = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
t2 (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool -> Term Bool
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cond Term Bool
t1 Term Bool
f1
  | Bool
otherwise = Maybe (Term Bool)
forall a. Maybe a
Nothing

pevalITEBoolRightOr :: Term Bool -> Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolRightOr :: Term Bool
-> Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolRightOr Term Bool
cond Term Bool
ifTrue Term Bool
f1 Term Bool
f2
  | Term Bool
f1 Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
ifTrue = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
f1 (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalAndTerm (Term Bool -> Term Bool
pevalNotTerm Term Bool
cond) Term Bool
f2
  | Term Bool
f2 Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
ifTrue = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
f2 (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalAndTerm (Term Bool -> Term Bool
pevalNotTerm Term Bool
cond) Term Bool
f1
  | Bool
otherwise = Maybe (Term Bool)
forall a. Maybe a
Nothing

pevalITEBoolLeft :: Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolLeft :: Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolLeft Term Bool
cond (AndTerm Int
_ Term Bool
t1 Term Bool
t2) Term Bool
ifFalse =
  [Maybe (Term Bool)] -> Maybe (Term Bool)
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
    [ Term Bool
-> Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolLeftAnd Term Bool
cond Term Bool
t1 Term Bool
t2 Term Bool
ifFalse,
      case Term Bool
ifFalse of
        AndTerm Int
_ Term Bool
f1 Term Bool
f2 -> Term Bool
-> Term Bool
-> Term Bool
-> Term Bool
-> Term Bool
-> Maybe (Term Bool)
pevalITEBoolBothAnd Term Bool
cond Term Bool
t1 Term Bool
t2 Term Bool
f1 Term Bool
f2
        Term Bool
_ -> Maybe (Term Bool)
forall a. Maybe a
Nothing
    ]
pevalITEBoolLeft Term Bool
cond (OrTerm Int
_ Term Bool
t1 Term Bool
t2) Term Bool
ifFalse =
  [Maybe (Term Bool)] -> Maybe (Term Bool)
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
    [ Term Bool
-> Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolLeftOr Term Bool
cond Term Bool
t1 Term Bool
t2 Term Bool
ifFalse,
      case Term Bool
ifFalse of
        OrTerm Int
_ Term Bool
f1 Term Bool
f2 -> Term Bool
-> Term Bool
-> Term Bool
-> Term Bool
-> Term Bool
-> Maybe (Term Bool)
pevalITEBoolBothOr Term Bool
cond Term Bool
t1 Term Bool
t2 Term Bool
f1 Term Bool
f2
        Term Bool
_ -> Maybe (Term Bool)
forall a. Maybe a
Nothing
    ]
pevalITEBoolLeft Term Bool
cond (NotTerm Int
_ Term Bool
nIfTrue) Term Bool
ifFalse =
  [Maybe (Term Bool)] -> Maybe (Term Bool)
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
    [ Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolLeftNot Term Bool
cond Term Bool
nIfTrue Term Bool
ifFalse,
      case Term Bool
ifFalse of
        NotTerm Int
_ Term Bool
nIfFalse ->
          Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolBothNot Term Bool
cond Term Bool
nIfTrue Term Bool
nIfFalse
        Term Bool
_ -> Maybe (Term Bool)
forall a. Maybe a
Nothing
    ]
pevalITEBoolLeft Term Bool
_ Term Bool
_ Term Bool
_ = Maybe (Term Bool)
forall a. Maybe a
Nothing

pevalITEBoolNoLeft :: Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolNoLeft :: Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolNoLeft Term Bool
cond Term Bool
ifTrue (AndTerm Int
_ Term Bool
f1 Term Bool
f2) = Term Bool
-> Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolRightAnd Term Bool
cond Term Bool
ifTrue Term Bool
f1 Term Bool
f2
pevalITEBoolNoLeft Term Bool
cond Term Bool
ifTrue (OrTerm Int
_ Term Bool
f1 Term Bool
f2) = Term Bool
-> Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolRightOr Term Bool
cond Term Bool
ifTrue Term Bool
f1 Term Bool
f2
pevalITEBoolNoLeft Term Bool
cond Term Bool
ifTrue (NotTerm Int
_ Term Bool
nIfFalse) = Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolRightNot Term Bool
cond Term Bool
ifTrue Term Bool
nIfFalse
pevalITEBoolNoLeft Term Bool
_ Term Bool
_ Term Bool
_ = Maybe (Term Bool)
forall a. Maybe a
Nothing

-- | Basic partial evaluation for ITE terms.
pevalITEBasic :: (SupportedPrim a) => Term Bool -> Term a -> Term a -> Maybe (Term a)
pevalITEBasic :: forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Maybe (Term a)
pevalITEBasic (ConTerm Int
_ Bool
True) Term a
ifTrue Term a
_ = Term a -> Maybe (Term a)
forall a. a -> Maybe a
Just Term a
ifTrue
pevalITEBasic (ConTerm Int
_ Bool
False) Term a
_ Term a
ifFalse = Term a -> Maybe (Term a)
forall a. a -> Maybe a
Just Term a
ifFalse
pevalITEBasic (NotTerm Int
_ Term Bool
ncond) Term a
ifTrue Term a
ifFalse = Term a -> Maybe (Term a)
forall a. a -> Maybe a
Just (Term a -> Maybe (Term a)) -> Term a -> Maybe (Term a)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term a -> Term a -> Term a
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
ncond Term a
ifFalse Term a
ifTrue
pevalITEBasic Term Bool
_ Term a
ifTrue Term a
ifFalse | Term a
ifTrue Term a -> Term a -> Bool
forall a. Eq a => a -> a -> Bool
== Term a
ifFalse = Term a -> Maybe (Term a)
forall a. a -> Maybe a
Just Term a
ifTrue
pevalITEBasic (ITETerm Int
_ Term Bool
cc Term Bool
ct Term Bool
cf) (ITETerm Int
_ Term Bool
tc Term a
tt Term a
tf) (ITETerm Int
_ Term Bool
fc Term a
ft Term a
ff) -- later
  | Term Bool
cc Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
tc Bool -> Bool -> Bool
&& Term Bool
cc Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
fc = Term a -> Maybe (Term a)
forall a. a -> Maybe a
Just (Term a -> Maybe (Term a)) -> Term a -> Maybe (Term a)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term a -> Term a -> Term a
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cc (Term Bool -> Term a -> Term a -> Term a
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
ct Term a
tt Term a
ft) (Term Bool -> Term a -> Term a -> Term a
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cf Term a
tf Term a
ff)
pevalITEBasic Term Bool
cond (ITETerm Int
_ Term Bool
tc Term a
tt Term a
tf) Term a
ifFalse -- later
  | Term Bool
cond Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
tc = Term a -> Maybe (Term a)
forall a. a -> Maybe a
Just (Term a -> Maybe (Term a)) -> Term a -> Maybe (Term a)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term a -> Term a -> Term a
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cond Term a
tt Term a
ifFalse
  | Term a
tt Term a -> Term a -> Bool
forall a. Eq a => a -> a -> Bool
== Term a
ifFalse = Term a -> Maybe (Term a)
forall a. a -> Maybe a
Just (Term a -> Maybe (Term a)) -> Term a -> Maybe (Term a)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term a -> Term a -> Term a
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm (Term Bool -> Term Bool -> Term Bool
pevalOrTerm (Term Bool -> Term Bool
pevalNotTerm Term Bool
cond) Term Bool
tc) Term a
tt Term a
tf
  | Term a
tf Term a -> Term a -> Bool
forall a. Eq a => a -> a -> Bool
== Term a
ifFalse = Term a -> Maybe (Term a)
forall a. a -> Maybe a
Just (Term a -> Maybe (Term a)) -> Term a -> Maybe (Term a)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term a -> Term a -> Term a
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm (Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
cond Term Bool
tc) Term a
tt Term a
tf
pevalITEBasic Term Bool
cond Term a
ifTrue (ITETerm Int
_ Term Bool
fc Term a
ft Term a
ff) -- later
  | Term a
ifTrue Term a -> Term a -> Bool
forall a. Eq a => a -> a -> Bool
== Term a
ft = Term a -> Maybe (Term a)
forall a. a -> Maybe a
Just (Term a -> Maybe (Term a)) -> Term a -> Maybe (Term a)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term a -> Term a -> Term a
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm (Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
cond Term Bool
fc) Term a
ifTrue Term a
ff
  | Term a
ifTrue Term a -> Term a -> Bool
forall a. Eq a => a -> a -> Bool
== Term a
ff = Term a -> Maybe (Term a)
forall a. a -> Maybe a
Just (Term a -> Maybe (Term a)) -> Term a -> Maybe (Term a)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term a -> Term a -> Term a
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm (Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
cond (Term Bool -> Term Bool
pevalNotTerm Term Bool
fc)) Term a
ifTrue Term a
ft
  | Term Bool -> Term Bool -> Bool
pevalImpliesTerm Term Bool
fc Term Bool
cond = Term a -> Maybe (Term a)
forall a. a -> Maybe a
Just (Term a -> Maybe (Term a)) -> Term a -> Maybe (Term a)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term a -> Term a -> Term a
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITETerm Term Bool
cond Term a
ifTrue Term a
ff
pevalITEBasic Term Bool
_ Term a
_ Term a
_ = Maybe (Term a)
forall a. Maybe a
Nothing

pevalITEBoolBasic :: Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolBasic :: Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolBasic Term Bool
cond Term Bool
ifTrue Term Bool
ifFalse
  | Term Bool
cond Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
ifTrue = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
cond Term Bool
ifFalse
  | Term Bool
cond Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term Bool
ifFalse = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
cond Term Bool
ifTrue
pevalITEBoolBasic Term Bool
cond (ConTerm Int
_ Bool
v) Term Bool
ifFalse
  | Bool
v = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
cond Term Bool
ifFalse
  | Bool
otherwise = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalAndTerm (Term Bool -> Term Bool
pevalNotTerm Term Bool
cond) Term Bool
ifFalse
pevalITEBoolBasic Term Bool
cond Term Bool
ifTrue (ConTerm Int
_ Bool
v)
  | Bool
v = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalOrTerm (Term Bool -> Term Bool
pevalNotTerm Term Bool
cond) Term Bool
ifTrue
  | Bool
otherwise = Term Bool -> Maybe (Term Bool)
forall a. a -> Maybe a
Just (Term Bool -> Maybe (Term Bool)) -> Term Bool -> Maybe (Term Bool)
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
pevalAndTerm Term Bool
cond Term Bool
ifTrue
pevalITEBoolBasic Term Bool
_ Term Bool
_ Term Bool
_ = Maybe (Term Bool)
forall a. Maybe a
Nothing

pevalITEBool :: Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBool :: Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBool Term Bool
cond Term Bool
ifTrue Term Bool
ifFalse =
  [Maybe (Term Bool)] -> Maybe (Term Bool)
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
    [ Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Maybe (Term a)
pevalITEBasic Term Bool
cond Term Bool
ifTrue Term Bool
ifFalse,
      Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolBasic Term Bool
cond Term Bool
ifTrue Term Bool
ifFalse,
      Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolLeft Term Bool
cond Term Bool
ifTrue Term Bool
ifFalse,
      Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBoolNoLeft Term Bool
cond Term Bool
ifTrue Term Bool
ifFalse
    ]

-- | Basic partial evaluation for ITE terms.
pevalITEBasicTerm :: (SupportedPrim a) => Term Bool -> Term a -> Term a -> Term a
pevalITEBasicTerm :: forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
pevalITEBasicTerm Term Bool
cond Term a
ifTrue Term a
ifFalse =
  Term a -> Maybe (Term a) -> Term a
forall a. a -> Maybe a -> a
fromMaybe (Term Bool -> Term a -> Term a -> Term a
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
iteTerm Term Bool
cond Term a
ifTrue Term a
ifFalse) (Maybe (Term a) -> Term a) -> Maybe (Term a) -> Term a
forall a b. (a -> b) -> a -> b
$
    Term Bool -> Term a -> Term a -> Maybe (Term a)
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Maybe (Term a)
pevalITEBasic Term Bool
cond Term a
ifTrue Term a
ifFalse

-- | Default partial evaluation for equality terms.
pevalDefaultEqTerm :: (SupportedNonFuncPrim a) => Term a -> Term a -> Term Bool
pevalDefaultEqTerm :: forall a. SupportedNonFuncPrim a => Term a -> Term a -> Term Bool
pevalDefaultEqTerm l :: Term a
l@ConTerm {} r :: Term a
r@ConTerm {} = Bool -> Term Bool
forall t.
(SupportedPrim t, Typeable t, Hashable t, Eq t, Show t) =>
t -> Term t
conTerm (Bool -> Term Bool) -> Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term a
l Term a -> Term a -> Bool
forall a. Eq a => a -> a -> Bool
== Term a
r
pevalDefaultEqTerm l :: Term a
l@ConTerm {} Term a
r = Term a -> Term a -> Term Bool
forall a. SupportedNonFuncPrim a => Term a -> Term a -> Term Bool
pevalDefaultEqTerm Term a
r Term a
l
pevalDefaultEqTerm Term a
l (BoolConTerm Bool
rv) =
  if Bool
rv
    then Term a -> Term Bool
forall a b. a -> b
unsafeCoerce Term a
l
    else Term Bool -> Term Bool
pevalNotTerm (Term a -> Term Bool
forall a b. a -> b
unsafeCoerce Term a
l)
pevalDefaultEqTerm (NotTerm Int
_ Term Bool
lv) Term a
r
  | Term Bool
lv Term Bool -> Term Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Term a
Term Bool
r = Term Bool
falseTerm
pevalDefaultEqTerm Term a
l (NotTerm Int
_ Term Bool
rv)
  | Term a
l Term a -> Term a -> Bool
forall a. Eq a => a -> a -> Bool
== Term a
Term Bool
rv = Term Bool
falseTerm
pevalDefaultEqTerm (AddNumTerm Int
_ (ConTerm Int
_ a
c) Term a
v) (ConTerm Int
_ a
c2) =
  Term a -> Term a -> Term Bool
forall a. SupportedNonFuncPrim a => Term a -> Term a -> Term Bool
pevalDefaultEqTerm Term a
v (a -> Term a
forall t.
(SupportedPrim t, Typeable t, Hashable t, Eq t, Show t) =>
t -> Term t
conTerm (a -> Term a) -> a -> Term a
forall a b. (a -> b) -> a -> b
$ a
c2 a -> a -> a
forall a. Num a => a -> a -> a
- a
c)
pevalDefaultEqTerm Term a
l (ITETerm Int
_ Term Bool
c Term a
t Term a
f)
  | Term a
l Term a -> Term a -> Bool
forall a. Eq a => a -> a -> Bool
== Term a
t = Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
c (Term a -> Term a -> Term Bool
forall a. SupportedNonFuncPrim a => Term a -> Term a -> Term Bool
pevalDefaultEqTerm Term a
l Term a
f)
  | Term a
l Term a -> Term a -> Bool
forall a. Eq a => a -> a -> Bool
== Term a
f = Term Bool -> Term Bool -> Term Bool
pevalOrTerm (Term Bool -> Term Bool
pevalNotTerm Term Bool
c) (Term a -> Term a -> Term Bool
forall a. SupportedNonFuncPrim a => Term a -> Term a -> Term Bool
pevalDefaultEqTerm Term a
l Term a
t)
pevalDefaultEqTerm (ITETerm Int
_ Term Bool
c Term a
t Term a
f) Term a
r
  | Term a
t Term a -> Term a -> Bool
forall a. Eq a => a -> a -> Bool
== Term a
r = Term Bool -> Term Bool -> Term Bool
pevalOrTerm Term Bool
c (Term a -> Term a -> Term Bool
forall a. SupportedNonFuncPrim a => Term a -> Term a -> Term Bool
pevalDefaultEqTerm Term a
f Term a
r)
  | Term a
f Term a -> Term a -> Bool
forall a. Eq a => a -> a -> Bool
== Term a
r = Term Bool -> Term Bool -> Term Bool
pevalOrTerm (Term Bool -> Term Bool
pevalNotTerm Term Bool
c) (Term a -> Term a -> Term Bool
forall a. SupportedNonFuncPrim a => Term a -> Term a -> Term Bool
pevalDefaultEqTerm Term a
t Term a
r)
pevalDefaultEqTerm Term a
l Term a
r
  | Term a
l Term a -> Term a -> Bool
forall a. Eq a => a -> a -> Bool
== Term a
r = Term Bool
trueTerm
  | Bool
otherwise = Term a -> Term a -> Term Bool
forall a. SupportedNonFuncPrim a => Term a -> Term a -> Term Bool
eqTerm Term a
l Term a
r
{-# INLINEABLE pevalDefaultEqTerm #-}

instance SBVRep Bool where
  type SBVType Bool = SBV.SBV Bool

instance SupportedPrimConstraint Bool

instance SupportedPrim Bool where
  pformatCon :: Bool -> String
pformatCon Bool
True = String
"true"
  pformatCon Bool
False = String
"false"
  defaultValue :: Bool
defaultValue = Bool
defaultValueForBool
  defaultValueDynamic :: forall (proxy :: * -> *). proxy Bool -> ModelValue
defaultValueDynamic proxy Bool
_ = ModelValue
defaultValueForBoolDyn
  pevalITETerm :: Term Bool -> Term Bool -> Term Bool -> Term Bool
pevalITETerm Term Bool
cond Term Bool
ifTrue Term Bool
ifFalse =
    Term Bool -> Maybe (Term Bool) -> Term Bool
forall a. a -> Maybe a -> a
fromMaybe (Term Bool -> Term Bool -> Term Bool -> Term Bool
forall a.
SupportedPrim a =>
Term Bool -> Term a -> Term a -> Term a
iteTerm Term Bool
cond Term Bool
ifTrue Term Bool
ifFalse) (Maybe (Term Bool) -> Term Bool) -> Maybe (Term Bool) -> Term Bool
forall a b. (a -> b) -> a -> b
$
      Term Bool -> Term Bool -> Term Bool -> Maybe (Term Bool)
pevalITEBool Term Bool
cond Term Bool
ifTrue Term Bool
ifFalse
  pevalEqTerm :: Term Bool -> Term Bool -> Term Bool
pevalEqTerm = Term Bool -> Term Bool -> Term Bool
forall a. SupportedNonFuncPrim a => Term a -> Term a -> Term Bool
pevalDefaultEqTerm
  pevalDistinctTerm :: NonEmpty (Term Bool) -> Term Bool
pevalDistinctTerm (Term Bool
_ :| []) = Bool -> Term Bool
forall t.
(SupportedPrim t, Typeable t, Hashable t, Eq t, Show t) =>
t -> Term t
conTerm Bool
True
  pevalDistinctTerm (Term Bool
a :| [Term Bool
b]) = Term Bool -> Term Bool
pevalNotTerm (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool -> Term Bool
forall a. SupportedPrim a => Term a -> Term a -> Term Bool
pevalEqTerm Term Bool
a Term Bool
b
  pevalDistinctTerm NonEmpty (Term Bool)
_ = Bool -> Term Bool
forall t.
(SupportedPrim t, Typeable t, Hashable t, Eq t, Show t) =>
t -> Term t
conTerm Bool
False
  conSBVTerm :: Bool -> SBVType Bool
conSBVTerm Bool
n = if Bool
n then SBV Bool
SBVType Bool
SBV.sTrue else SBV Bool
SBVType Bool
SBV.sFalse
  symSBVName :: TypedSymbol 'AnyKind Bool -> Int -> String
symSBVName TypedSymbol 'AnyKind Bool
symbol Int
_ = TypedSymbol 'AnyKind Bool -> String
forall a. Show a => a -> String
show TypedSymbol 'AnyKind Bool
symbol
  symSBVTerm :: forall (m :: * -> *). SBVFreshMonad m => String -> m (SBVType Bool)
symSBVTerm = String -> m (SBV Bool)
String -> m (SBVType Bool)
forall a. SymVal a => String -> m (SBV a)
forall (m :: * -> *) a.
(SBVFreshMonad m, SymVal a) =>
String -> m (SBV a)
sbvFresh
  withPrim :: forall a.
((PrimConstraint Bool, SMTDefinable (SBVType Bool),
  Mergeable (SBVType Bool), Typeable (SBVType Bool)) =>
 a)
-> a
withPrim (PrimConstraint Bool, SMTDefinable (SBVType Bool),
 Mergeable (SBVType Bool), Typeable (SBVType Bool)) =>
a
r = a
(PrimConstraint Bool, SMTDefinable (SBVType Bool),
 Mergeable (SBVType Bool), Typeable (SBVType Bool)) =>
a
r
  parseSMTModelResult :: Int -> ([([CV], CV)], CV) -> Bool
parseSMTModelResult Int
_ = (Bool -> Bool) -> ([([CV], CV)], CV) -> Bool
forall v r.
(SatModel r, Typeable v) =>
(r -> v) -> ([([CV], CV)], CV) -> v
parseScalarSMTModelResult Bool -> Bool
forall a. a -> a
id
  castTypedSymbol ::
    forall knd knd'.
    (IsSymbolKind knd') =>
    TypedSymbol knd Bool ->
    Maybe (TypedSymbol knd' Bool)
  castTypedSymbol :: forall (knd :: SymbolKind) (knd' :: SymbolKind).
IsSymbolKind knd' =>
TypedSymbol knd Bool -> Maybe (TypedSymbol knd' Bool)
castTypedSymbol (TypedSymbol Symbol
s) =
    case forall (ty :: SymbolKind).
IsSymbolKind ty =>
Either (ty :~~: 'ConstantKind) (ty :~~: 'AnyKind)
decideSymbolKind @knd' of
      Left knd' :~~: 'ConstantKind
HRefl -> TypedSymbol knd' Bool -> Maybe (TypedSymbol knd' Bool)
forall a. a -> Maybe a
Just (TypedSymbol knd' Bool -> Maybe (TypedSymbol knd' Bool))
-> TypedSymbol knd' Bool -> Maybe (TypedSymbol knd' Bool)
forall a b. (a -> b) -> a -> b
$ Symbol -> TypedSymbol knd' Bool
forall t (knd :: SymbolKind).
(SupportedPrim t, SymbolKindConstraint knd t, IsSymbolKind knd) =>
Symbol -> TypedSymbol knd t
TypedSymbol Symbol
s
      Right knd' :~~: 'AnyKind
HRefl -> TypedSymbol knd' Bool -> Maybe (TypedSymbol knd' Bool)
forall a. a -> Maybe a
Just (TypedSymbol knd' Bool -> Maybe (TypedSymbol knd' Bool))
-> TypedSymbol knd' Bool -> Maybe (TypedSymbol knd' Bool)
forall a b. (a -> b) -> a -> b
$ Symbol -> TypedSymbol knd' Bool
forall t (knd :: SymbolKind).
(SupportedPrim t, SymbolKindConstraint knd t, IsSymbolKind knd) =>
Symbol -> TypedSymbol knd t
TypedSymbol Symbol
s
  isFuncType :: Bool
isFuncType = Bool
False
  funcDummyConstraint :: SBVType Bool -> SBV Bool
funcDummyConstraint SBVType Bool
_ = SBV Bool
SBV.sTrue

instance NonFuncSBVRep Bool where
  type NonFuncSBVBaseType Bool = Bool

instance SupportedNonFuncPrim Bool where
  conNonFuncSBVTerm :: Bool -> SBV (NonFuncSBVBaseType Bool)
conNonFuncSBVTerm = Bool -> SBV (NonFuncSBVBaseType Bool)
Bool -> SBVType Bool
forall t. SupportedPrim t => t -> SBVType t
conSBVTerm
  symNonFuncSBVTerm :: forall (m :: * -> *).
SBVFreshMonad m =>
String -> m (SBV (NonFuncSBVBaseType Bool))
symNonFuncSBVTerm = forall t (m :: * -> *).
(SupportedPrim t, SBVFreshMonad m) =>
String -> m (SBVType t)
symSBVTerm @Bool
  withNonFuncPrim :: forall r. (NonFuncPrimConstraint Bool => r) -> r
withNonFuncPrim NonFuncPrimConstraint Bool => r
r = r
NonFuncPrimConstraint Bool => r
r