Skip to content

Make WarnBottomTotalFunction an error #1940

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ License : NCSA

-}

module Kore.Log.WarnBottomTotalFunction
( WarnBottomTotalFunction (..)
, warnBottomTotalFunction
module Kore.Log.ErrorBottomTotalFunction
( ErrorBottomTotalFunction (..)
, errorBottomTotalFunction
) where

import Prelude.Kore
Expand All @@ -29,35 +29,35 @@ import qualified Pretty
import Log
import qualified SQL

newtype WarnBottomTotalFunction =
WarnBottomTotalFunction
newtype ErrorBottomTotalFunction =
ErrorBottomTotalFunction
{ term :: TermLike VariableName
}
deriving (Show)
deriving (GHC.Generic)

instance SOP.Generic WarnBottomTotalFunction
instance SOP.Generic ErrorBottomTotalFunction

instance SOP.HasDatatypeInfo WarnBottomTotalFunction
instance SOP.HasDatatypeInfo ErrorBottomTotalFunction

instance Pretty WarnBottomTotalFunction where
pretty WarnBottomTotalFunction { term } =
instance Pretty ErrorBottomTotalFunction where
pretty ErrorBottomTotalFunction { term } =
Pretty.vsep
[ "Evaluating total function"
, Pretty.indent 4 (unparse term)
, "has resulted in \\bottom."
]

instance Entry WarnBottomTotalFunction where
entrySeverity _ = Warning
helpDoc _ = "warn when a total function is undefined"
instance Entry ErrorBottomTotalFunction where
entrySeverity _ = Error
helpDoc _ = "errors raised when a total function is undefined"

instance SQL.Table WarnBottomTotalFunction
instance SQL.Table ErrorBottomTotalFunction

warnBottomTotalFunction
errorBottomTotalFunction
:: MonadLog logger
=> InternalVariable variable
=> TermLike variable
-> logger ()
warnBottomTotalFunction (mapVariables (pure toVariableName) -> term) =
logEntry WarnBottomTotalFunction { term }
errorBottomTotalFunction (mapVariables (pure toVariableName) -> term) =
logEntry ErrorBottomTotalFunction { term }
8 changes: 4 additions & 4 deletions kore/src/Kore/Log/Registry.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ import Kore.Log.DebugSubstitutionSimplifier
import Kore.Log.DebugUnification
( DebugUnification
)
import Kore.Log.ErrorBottomTotalFunction
( ErrorBottomTotalFunction
)
import Kore.Log.ErrorException
( ErrorException
)
Expand All @@ -77,9 +80,6 @@ import Kore.Log.InfoAttemptUnification
import Kore.Log.InfoReachability
( InfoReachability
)
import Kore.Log.WarnBottomTotalFunction
( WarnBottomTotalFunction
)
import Kore.Log.WarnDecidePredicateUnknown
( WarnDecidePredicateUnknown
)
Expand Down Expand Up @@ -131,7 +131,7 @@ entryHelpDocs :: [Pretty.Doc ()]
, mk $ Proxy @DebugProofState
, mk $ Proxy @DebugAppliedRewriteRules
, mk $ Proxy @DebugSubstitutionSimplifier
, mk $ Proxy @WarnBottomTotalFunction
, mk $ Proxy @ErrorBottomTotalFunction
, mk $ Proxy @WarnDecidePredicateUnknown
, mk $ Proxy @WarnFunctionWithoutEvaluators
, mk $ Proxy @WarnSymbolSMTRepresentation
Expand Down
6 changes: 3 additions & 3 deletions kore/src/Kore/Log/SQLite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import Kore.Log.DebugEvaluateCondition
import Kore.Log.DebugSubstitutionSimplifier
( DebugSubstitutionSimplifier
)
import Kore.Log.WarnBottomTotalFunction
( WarnBottomTotalFunction
import Kore.Log.ErrorBottomTotalFunction
( ErrorBottomTotalFunction
)
import Kore.Log.WarnFunctionWithoutEvaluators
( WarnFunctionWithoutEvaluators
Expand Down Expand Up @@ -127,7 +127,7 @@ foldMapEntries mapEntry =
mconcat
[ mapEntry (Proxy @DebugEvaluateCondition)
, mapEntry (Proxy @DebugSubstitutionSimplifier)
, mapEntry (Proxy @WarnBottomTotalFunction)
, mapEntry (Proxy @ErrorBottomTotalFunction)
, mapEntry (Proxy @WarnFunctionWithoutEvaluators)
, mapEntry (Proxy @WarnSymbolSMTRepresentation)
]
Expand Down
6 changes: 3 additions & 3 deletions kore/src/Kore/Step/Function/Evaluator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ import qualified Kore.Internal.SideCondition.SideCondition as SideCondition
)
import qualified Kore.Internal.Symbol as Symbol
import Kore.Internal.TermLike as TermLike
import Kore.Log.WarnBottomTotalFunction
( warnBottomTotalFunction
import Kore.Log.ErrorBottomTotalFunction
( errorBottomTotalFunction
)
import qualified Kore.Profiler.Profile as Profile
( axiomBranching
Expand Down Expand Up @@ -109,7 +109,7 @@ evaluateApplication
& lift
Foldable.for_ canMemoize (recordOrPattern results)
when (Symbol.isFunctional symbol && isBottom results) $
lift $ warnBottomTotalFunction termLike
lift $ errorBottomTotalFunction termLike
return results
where
finishT :: ExceptT r simplifier r -> simplifier r
Expand Down
20 changes: 20 additions & 0 deletions kore/test/Test/Kore/Log/ErrorBottomTotalFunction.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module Test.Kore.Log.ErrorBottomTotalFunction
( test_instance_Table_ErrorBottomTotalFunction
) where

import Prelude.Kore ()

import Test.Tasty

import Kore.Log.ErrorBottomTotalFunction

import qualified Test.Kore.Step.MockSymbols as Mock
import Test.SQL

test_instance_Table_ErrorBottomTotalFunction :: TestTree
test_instance_Table_ErrorBottomTotalFunction =
testTable @ErrorBottomTotalFunction [warn1, warn2]

warn1, warn2 :: ErrorBottomTotalFunction
warn1 = ErrorBottomTotalFunction Mock.a
warn2 = ErrorBottomTotalFunction Mock.b
20 changes: 0 additions & 20 deletions kore/test/Test/Kore/Log/WarnBottomTotalFunction.hs

This file was deleted.