Skip to content

Commit feb64cd

Browse files
emarzionttuegelandreiburdusa
authored
Adding missing location information to various warnings (#2377)
* adds new module Kore.Log.WarnBoundedModelChecker * adds location info + klabel info to WarnFunctionWithoutEvaluators * adds SomeClaim field to WarnStuckClaimState * adds claim field to CheckResult * moves stuck claim state warnings from Kore.Reachability.Claim to Kore.Reachability.Prove Co-authored-by: emarzion <emarzion@users.noreply.github.com> Co-authored-by: Thomas Tuegel <thomas.tuegel@runtimeverification.com> Co-authored-by: Andrei Burdușa <53746396+andreiburdusa@users.noreply.github.com>
1 parent d18be99 commit feb64cd

File tree

17 files changed

+160
-57
lines changed

17 files changed

+160
-57
lines changed

kore/app/exec/Main.hs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,16 @@ import Kore.Log
118118
, SomeEntry (..)
119119
, WithLog
120120
, logEntry
121-
, logWarning
122121
, parseKoreLogOptions
123122
, runKoreLog
124123
, unparseKoreLogOptions
125124
)
126125
import Kore.Log.ErrorException
127126
( errorException
128127
)
128+
import Kore.Log.WarnBoundedModelChecker
129+
( warnBoundedModelChecker
130+
)
129131
import Kore.Log.WarnIfLowProductivity
130132
( warnIfLowProductivity
131133
)
@@ -770,8 +772,8 @@ koreBmc execOptions proveOptions = do
770772
graphSearch
771773
case checkResult of
772774
Bounded.Proved -> return success
773-
Bounded.Unknown -> do
774-
logWarning "The pattern does not terminate within the bound."
775+
Bounded.Unknown claim -> do
776+
warnBoundedModelChecker claim
775777
return success
776778
Bounded.Failed final -> return (failure final)
777779
lift $ renderResult execOptions (unparse final)

kore/kore.cabal

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cabal-version: 2.2
44
--
55
-- see: https://github.com/sol/hpack
66
--
7-
-- hash: 7e4a37b77d7b81a22960b085c7c033ee8536b5990c1d4567ffca224c79a1e2aa
7+
-- hash: c7335f234ff802f2b2d42c8970fd41a6fa133676b9afa09d411e6222e1120d42
88

99
name: kore
1010
version: 0.39.0.0
@@ -223,6 +223,7 @@ library
223223
Kore.Log.KoreLogOptions
224224
Kore.Log.Registry
225225
Kore.Log.SQLite
226+
Kore.Log.WarnBoundedModelChecker
226227
Kore.Log.WarnFunctionWithoutEvaluators
227228
Kore.Log.WarnIfLowProductivity
228229
Kore.Log.WarnRetrySolverQuery

kore/src/Kore/ASTVerifier/AttributesVerifier.hs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import Kore.AST.AstWithLocation
4242
( locationFromAst
4343
)
4444
import qualified Kore.Attribute.Parser as Attribute.Parser
45-
import qualified Kore.Attribute.Symbol as Attribute
45+
import qualified Kore.Attribute.Symbol as Attribute.Symbol
4646
import Kore.Error
4747
import Kore.IndexedModule.IndexedModule
4848
import Kore.IndexedModule.Resolvers
@@ -149,7 +149,7 @@ verifyNoHookAttribute attributes = do
149149

150150
verifyNoHookedSupersort
151151
:: MonadError (Error VerifyError) error
152-
=> IndexedModule Verified.Pattern Attribute.Symbol attrs
152+
=> IndexedModule Verified.Pattern Attribute.Symbol.Symbol attrs
153153
-> Attribute.Axiom SymbolOrAlias VariableName
154154
-> [Subsort.Subsort]
155155
-> error ()
@@ -176,7 +176,7 @@ verifyNoHookedSupersort indexedModule axiom subsorts = do
176176
verifyAxiomAttributes
177177
:: forall error attrs
178178
. MonadError (Error VerifyError) error
179-
=> IndexedModule Verified.Pattern Attribute.Symbol attrs
179+
=> IndexedModule Verified.Pattern Attribute.Symbol.Symbol attrs
180180
-> Attribute.Axiom SymbolOrAlias VariableName
181181
-> error (Attribute.Axiom Internal.Symbol.Symbol VariableName)
182182
verifyAxiomAttributes indexedModule axiom = do
@@ -214,15 +214,15 @@ verifyAxiomAttributes indexedModule axiom = do
214214
verifySymbolAttributes
215215
:: forall error a
216216
. MonadError (Error VerifyError) error
217-
=> IndexedModule Verified.Pattern Attribute.Symbol a
218-
-> Attribute.Symbol
219-
-> error Attribute.Symbol
217+
=> IndexedModule Verified.Pattern Attribute.Symbol.Symbol a
218+
-> Attribute.Symbol.Symbol
219+
-> error Attribute.Symbol.Symbol
220220
verifySymbolAttributes _ attrs = return attrs
221221

222222
verifySortAttributes
223223
:: forall error a
224224
. MonadError (Error VerifyError) error
225-
=> IndexedModule Verified.Pattern Attribute.Symbol a
226-
-> Attribute.Symbol
227-
-> error Attribute.Symbol
225+
=> IndexedModule Verified.Pattern Attribute.Symbol.Symbol a
226+
-> Attribute.Symbol.Symbol
227+
-> error Attribute.Symbol.Symbol
228228
verifySortAttributes _ attrs = return attrs

kore/src/Kore/ASTVerifier/DefinitionVerifier.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import Kore.ASTVerifier.ModuleVerifier
4444
import Kore.ASTVerifier.Verifier
4545
import qualified Kore.Attribute.Axiom as Attribute
4646
import Kore.Attribute.Parser as Attribute.Parser
47-
import qualified Kore.Attribute.Symbol as Attribute
47+
import qualified Kore.Attribute.Symbol as Attribute.Symbol
4848
import qualified Kore.Builtin as Builtin
4949
import Kore.Error
5050
import Kore.IndexedModule.IndexedModule
@@ -91,7 +91,7 @@ verifyAndIndexDefinition
9191
-> ParsedDefinition
9292
-> Either
9393
(Error VerifyError)
94-
(Map.Map ModuleName (VerifiedModule Attribute.Symbol))
94+
(Map.Map ModuleName (VerifiedModule Attribute.Symbol.Symbol))
9595
verifyAndIndexDefinition builtinVerifiers definition = do
9696
(indexedModules, _defaultNames) <-
9797
verifyAndIndexDefinitionWithBase
@@ -127,7 +127,7 @@ verifyAndIndexDefinitionWithBase
127127
implicitModule
128128
:: ImplicitIndexedModule
129129
Verified.Pattern
130-
Attribute.Symbol
130+
Attribute.Symbol.Symbol
131131
(Attribute.Axiom Internal.Symbol.Symbol VariableName)
132132
implicitModule = ImplicitIndexedModule implicitIndexedModule
133133
parsedModules = modulesByName (definitionModules definition)

kore/src/Kore/Attribute/Symbol.hs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ import Kore.Attribute.Parser
8383
import Kore.Attribute.Smthook
8484
import Kore.Attribute.Smtlib
8585
import Kore.Attribute.SortInjection
86+
import Kore.Attribute.SourceLocation
8687
import Kore.Attribute.Symbol.Anywhere
8788
import Kore.Attribute.Symbol.Klabel
8889
import Kore.Attribute.Symbol.Memo
@@ -119,6 +120,8 @@ data Symbol =
119120
, klabel :: !Klabel
120121
, symbolKywd :: !SymbolKywd
121122
, noEvaluators :: !NoEvaluators
123+
, sourceLocation :: !SourceLocation
124+
-- ^ Location in the original (source) file.
122125
}
123126
deriving (Eq, Ord, Show)
124127
deriving (GHC.Generic)
@@ -145,6 +148,7 @@ instance ParseAttributes Symbol where
145148
>=> typed @Klabel (parseAttribute attr)
146149
>=> typed @SymbolKywd (parseAttribute attr)
147150
>=> typed @NoEvaluators (parseAttribute attr)
151+
>=> typed @SourceLocation (parseAttribute attr)
148152

149153
instance From Symbol Attributes where
150154
from =
@@ -162,26 +166,28 @@ instance From Symbol Attributes where
162166
, from . klabel
163167
, from . symbolKywd
164168
, from . noEvaluators
169+
, from . sourceLocation
165170
]
166171

167172
type StepperAttributes = Symbol
168173

169174
defaultSymbolAttributes :: Symbol
170175
defaultSymbolAttributes =
171176
Symbol
172-
{ function = def
173-
, functional = def
174-
, constructor = def
175-
, injective = def
176-
, sortInjection = def
177-
, anywhere = def
178-
, hook = def
179-
, smtlib = def
180-
, smthook = def
181-
, memo = def
182-
, klabel = def
183-
, symbolKywd = def
184-
, noEvaluators = def
177+
{ function = def
178+
, functional = def
179+
, constructor = def
180+
, injective = def
181+
, sortInjection = def
182+
, anywhere = def
183+
, hook = def
184+
, smtlib = def
185+
, smthook = def
186+
, memo = def
187+
, klabel = def
188+
, symbolKywd = def
189+
, noEvaluators = def
190+
, sourceLocation = def
185191
}
186192

187193
-- | See also: 'defaultSymbolAttributes'

kore/src/Kore/Attribute/Symbol/Klabel.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import qualified GHC.Generics as GHC
1919

2020
import Kore.Attribute.Parser as Parser
2121
import Kore.Debug
22+
import Pretty
2223

2324
-- | @Klabel@ represents the @klabel@ attribute for symbols.
2425
newtype Klabel = Klabel { getKlabel :: Maybe Text }
@@ -31,6 +32,10 @@ newtype Klabel = Klabel { getKlabel :: Maybe Text }
3132
instance Default Klabel where
3233
def = Klabel Nothing
3334

35+
instance Pretty Klabel where
36+
pretty (Klabel (Just text)) = pretty text
37+
pretty (Klabel Nothing) = "<no label>"
38+
3439
-- | Kore identifier representing the @klabel@ attribute symbol.
3540
klabelId :: Id
3641
klabelId = "klabel"

kore/src/Kore/Exec.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ boundedModelCheck
532532
-> VerifiedModule StepperAttributes
533533
-- ^ The spec module
534534
-> Strategy.GraphSearchOrder
535-
-> smt (Bounded.CheckResult (TermLike VariableName))
535+
-> smt (Bounded.CheckResult (TermLike VariableName) (ImplicationRule VariableName))
536536
boundedModelCheck breadthLimit depthLimit definitionModule specModule searchOrder =
537537
evalSimplifier definitionModule $ do
538538
initialized <- initializeAndSimplify definitionModule

kore/src/Kore/Log/Registry.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ import Kore.Log.InfoProofDepth
110110
import Kore.Log.InfoReachability
111111
( InfoReachability
112112
)
113+
import Kore.Log.WarnBoundedModelChecker
114+
( WarnBoundedModelChecker
115+
)
113116
import Kore.Log.WarnFunctionWithoutEvaluators
114117
( WarnFunctionWithoutEvaluators
115118
)
@@ -178,6 +181,7 @@ entryHelpDocsErr, entryHelpDocsNoErr :: [Pretty.Doc ()]
178181
, mk $ Proxy @WarnFunctionWithoutEvaluators
179182
, mk $ Proxy @WarnSymbolSMTRepresentation
180183
, mk $ Proxy @WarnStuckClaimState
184+
, mk $ Proxy @WarnBoundedModelChecker
181185
, mk $ Proxy @WarnIfLowProductivity
182186
, mk $ Proxy @WarnTrivialClaim
183187
, mk $ Proxy @WarnRetrySolverQuery
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{- |
2+
Copyright : (c) Runtime Verification, 2021
3+
License : NCSA
4+
5+
-}
6+
7+
module Kore.Log.WarnBoundedModelChecker
8+
( WarnBoundedModelChecker (..)
9+
, warnBoundedModelChecker
10+
) where
11+
12+
import Prelude.Kore
13+
14+
import Kore.Attribute.SourceLocation
15+
import Kore.Internal.TermLike
16+
import Kore.Step.RulePattern
17+
( ImplicationRule
18+
)
19+
import Log
20+
import Pretty
21+
( Pretty
22+
)
23+
import qualified Pretty
24+
25+
newtype WarnBoundedModelChecker
26+
= WarnBoundedModelChecker (ImplicationRule VariableName)
27+
deriving Show
28+
29+
instance Pretty WarnBoundedModelChecker where
30+
pretty (WarnBoundedModelChecker claim) =
31+
Pretty.hsep
32+
[ "The claim was not proven within the bound:"
33+
, Pretty.pretty (from @_ @SourceLocation claim)
34+
]
35+
36+
instance Entry WarnBoundedModelChecker where
37+
entrySeverity _ = Warning
38+
helpDoc _ = "warn when the bounded model checker does not terminate within the given bound"
39+
40+
warnBoundedModelChecker
41+
:: MonadLog log
42+
=> ImplicationRule VariableName
43+
-> log ()
44+
warnBoundedModelChecker claim =
45+
logEntry (WarnBoundedModelChecker claim)

kore/src/Kore/Log/WarnFunctionWithoutEvaluators.hs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ import Prelude.Kore
1313

1414
import qualified Generics.SOP as SOP
1515
import qualified GHC.Generics as GHC
16-
16+
import qualified Kore.Attribute.Symbol as Attribute
17+
( Symbol (..)
18+
)
1719
import Kore.Internal.Symbol
18-
( Symbol
20+
( Symbol (..)
1921
, noEvaluators
2022
)
2123
import Kore.Unparser
@@ -44,9 +46,18 @@ instance SOP.HasDatatypeInfo WarnFunctionWithoutEvaluators
4446

4547
instance Pretty WarnFunctionWithoutEvaluators where
4648
pretty WarnFunctionWithoutEvaluators { symbol } =
49+
let Symbol { symbolAttributes } = symbol in
50+
let Attribute.Symbol { klabel, sourceLocation } = symbolAttributes in
4751
Pretty.vsep
4852
[ "No evaluators for function symbol:"
49-
, Pretty.indent 4 (unparse symbol)
53+
, Pretty.indent 4 $ Pretty.hsep
54+
[ unparse symbol
55+
, Pretty.parens $ Pretty.pretty klabel
56+
]
57+
, Pretty.hsep
58+
[ "defined at:"
59+
, Pretty.pretty sourceLocation
60+
]
5061
]
5162

5263
instance Entry WarnFunctionWithoutEvaluators where

0 commit comments

Comments
 (0)