Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
afd6322
Remove _PREDICATE sort (#2604)
Boarders May 25, 2021
27cca02
Kore.Repl.Interpreter: Unparse \bottom with variable sort
ttuegel Jun 26, 2021
7668b69
Kore.Exec: Unparse \bottom with variable sort
ttuegel Jun 26, 2021
bcab28c
Test.Kore.ASTVerifier.DefinitionVerifier.Imports: Use explicit sorts
ttuegel Jun 26, 2021
25457c7
Test.Kore.Step.Simplification.Forall: Use explicit sorts
ttuegel Jun 26, 2021
20fb406
Test.Kore.Step.Simplification.InternalList: Use explicit sorts
ttuegel Jun 26, 2021
35ecdf0
Test.Kore.Step.Simplification.InternalMap: Use explicit sorts
ttuegel Jun 26, 2021
8592b92
Test.Kore.Step.Simplification.InternalSet: Use explicit sorts
ttuegel Jun 26, 2021
86dcdb6
Test.Kore.Step.Simplification.Top: Use explicit sorts
ttuegel Jun 26, 2021
c3881c3
Test.Kore.Step.Simplification.Bottom: Use explicit sorts
ttuegel Jun 26, 2021
5c06061
NotSimplifier: Use Not.simplify
ttuegel Jun 26, 2021
2468aae
Test.Kore.Step.Simplification: Use explicit sorts
ttuegel Jun 26, 2021
6232819
Test.Kore.Step.Simplification.Floor: Use explicit sorts
ttuegel Jun 27, 2021
e49b86e
Test.Kore.Step.Simplification.Equals: Use explicit sorts
ttuegel Jun 27, 2021
8bb8a19
Add instance Pretty (Pattern _)
ttuegel Jun 27, 2021
b07a43b
Test.Kore.Step.Simplification.AndTerms: Use explicit sorts
ttuegel Jun 27, 2021
96d2b4c
Test.Kore.Builtin.Int: Use explicit sorts
ttuegel Jun 27, 2021
41ff9fa
Test.Kore.Exec: Use explicit sorts
ttuegel Jun 27, 2021
29e6322
Test.Kore.Internal.Pattern: Use explicit sorts
ttuegel Jun 27, 2021
2427530
Test.Kore.Equation.Application: Use explicit sorts
ttuegel Jun 27, 2021
8ee4b65
Test.Kore.Internal.OrPattern: Use explicit sorts
ttuegel Jun 27, 2021
0f29ed6
Test.Kore.Builtin.KEqual: Use explicit sorts
ttuegel Jun 27, 2021
35121a4
Test.Kore.Builtin.List: Use explicit sorts
ttuegel Jun 27, 2021
69cb850
Test.Kore.Builtin.Map: Use explicit sorts
ttuegel Jun 27, 2021
fe6a55f
Test.Kore.Builtin.Set: Use explicit sorts
ttuegel Jun 27, 2021
ec6d1c6
Test.Kore.Builtin.String: Use explicit sorts
ttuegel Jun 27, 2021
21b019e
Test.Kore.Internal.Predicate: Use explicit sorts
ttuegel Jun 27, 2021
bb25388
Test.Kore.Internal.SideCondition: Use explicit sorts
ttuegel Jun 27, 2021
16e5599
Test.Kore.Reachability.Claim: Use explicit sorts
ttuegel Jun 27, 2021
f6ee902
Test.Kore.Reachability.OnePathStrategy: Use explicit sorts
ttuegel Jun 27, 2021
320f387
Test.Kore.Reachability.Prove: Use explicit sorts
ttuegel Jun 27, 2021
40da7a5
Test.Kore.Repl.Interpreter: Use explicit sorts
ttuegel Jun 27, 2021
c23b8df
Test.Kore.Step.AntiLeft: Use explicit sorts
ttuegel Jun 27, 2021
5565017
Test.Kore.Step.Axiom.Identifier: Use explicit sorts
ttuegel Jun 27, 2021
024defa
Test.Kore.Step.Axiom.Matcher: Use explicit sorts
ttuegel Jun 27, 2021
0856714
Test.Kore.Step.Axiom.Registry: Use explicit sorts
ttuegel Jun 27, 2021
e56a2e0
Test.Kore.Step.Function.Integration: Use explicit sorts
ttuegel Jun 27, 2021
eedec71
Test.Kore.Step.Function.Implication: Use explicit sorts
ttuegel Jun 27, 2021
9b9b08c
Test.Kore.Step.RewriteStep: Use explicit sorts
ttuegel Jun 27, 2021
962bd4a
Test.Kore.Step.Rule: Use explicit sorts
ttuegel Jun 27, 2021
f459087
Test.Kore.Step.Rule.Combine: Use explicit sorts
ttuegel Jun 27, 2021
ce423fb
Test.Kore.Step.Simplification.And: Use explicit sorts
ttuegel Jun 27, 2021
75ef6f1
Fix some tests
andreiburdusa Jul 20, 2021
cbb7bf3
Merge remote-tracking branch 'origin/master' into remove-predicate-sort
andreiburdusa Jul 20, 2021
40b98cd
Format with fourmolu
invalid-email-address Jul 20, 2021
679f58b
Merge remote-tracking branch 'origin/master' into remove-predicate-sort
andreiburdusa Jul 21, 2021
3ce5bd1
Fix test
andreiburdusa Jul 21, 2021
aac3660
Use child sort in predicate forall simplifier
andreiburdusa Jul 21, 2021
e11caaf
Apply suggestions given by pedantic
andreiburdusa Jul 21, 2021
e99d9a3
Apply hlint
andreiburdusa Jul 21, 2021
6ea4244
Fix one more test
andreiburdusa Jul 22, 2021
439fe97
Merge remote-tracking branch 'origin/master' into remove-predicate-sort
andreiburdusa Jul 28, 2021
7a5bb52
Use bool's sort in unifyIntEq and unifyStringEq
andreiburdusa Aug 2, 2021
cc86ca5
Merge remote-tracking branch 'origin/master' into remove-predicate-sort
andreiburdusa Aug 2, 2021
bd842f4
Fix tests broken because incorrect merge with master
andreiburdusa Aug 2, 2021
636b466
Merge remote-tracking branch 'origin/master' into remove-predicate-sort
andreiburdusa Aug 3, 2021
1b2a36f
Use bool's sort in unifyKequalsEq's eraseTerm
andreiburdusa Aug 4, 2021
b98aa8b
Use initialSort instead of "R" dummy sort for exec's result
andreiburdusa Aug 5, 2021
0ce2c4d
Merge remote-tracking branch 'origin/master' into remove-predicate-sort
andreiburdusa Aug 6, 2021
437fcb2
Fix the left unit tests
andreiburdusa Aug 10, 2021
8b3b0be
Merge remote-tracking branch 'origin/master' into remove-predicate-sort
andreiburdusa Aug 10, 2021
78ad73b
Do some cleanup
andreiburdusa Aug 11, 2021
82e679c
Validate.hs Cleanup: Use types to suggest that the sort variable "_" …
andreiburdusa Aug 11, 2021
56e2545
Add TODO for implementing Predicate.mapVariables without converting t…
andreiburdusa Aug 11, 2021
d8fded7
Rename OrPattern.top to OrPattern.topOf and fix documentation
andreiburdusa Aug 11, 2021
e904c2a
Equals.makeEvaluate: don't replace second term
andreiburdusa Aug 11, 2021
199b0ab
Merge remote-tracking branch 'origin/master' into remove-predicate-sort
andreiburdusa Aug 11, 2021
4014b1f
Remove unused module and clean Forall.hs's export list
andreiburdusa Aug 11, 2021
084ebe8
Remove redundant parentheses
andreiburdusa Aug 11, 2021
4cc8973
Remove redundant do
andreiburdusa Aug 11, 2021
0222742
Use "_" sort variable instead of Mock.testSort for pretty printing
andreiburdusa Aug 11, 2021
394831b
Address some comments
andreiburdusa Aug 16, 2021
6fb683a
Remove Sort parameter from Top.simplify
andreiburdusa Aug 16, 2021
a978cf8
Remove Sort parameter from InternalSet.simplify
andreiburdusa Aug 16, 2021
26415a9
Use pattern sort in Or.hs if available
andreiburdusa Aug 16, 2021
d422354
Address Raoul's comments
andreiburdusa Aug 16, 2021
281cdc8
Merge remote-tracking branch 'origin/master' into remove-predicate-sort
andreiburdusa Aug 16, 2021
18b05e9
Format with fourmolu
invalid-email-address Aug 16, 2021
574844a
Rebuild
andreiburdusa Aug 16, 2021
5e0be13
Use sameSort with different sorts
andreiburdusa Aug 16, 2021
2262f72
Address comments
andreiburdusa Aug 17, 2021
43766a9
Format with fourmolu
invalid-email-address Aug 17, 2021
aa25723
Rebuild
andreiburdusa Aug 17, 2021
55ffe77
Merge branch 'master' into remove-predicate-sort
rv-jenkins Aug 17, 2021
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
25 changes: 15 additions & 10 deletions kore/app/exec/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,13 @@ import Kore.Reachability (
SomeClaim,
StuckClaim (..),
getConfiguration,
lensClaimPattern,
)
import qualified Kore.Reachability.Claim as Claim
import Kore.Rewrite
import Kore.Rewrite.ClaimPattern (
getClaimPatternSort,
)
import Kore.Rewrite.RewritingVariable
import Kore.Rewrite.RulePattern (
mapRuleVariables,
Expand All @@ -113,9 +117,6 @@ import Kore.Syntax.Definition (
Sentence (..),
)
import qualified Kore.Syntax.Definition as Definition.DoNotUse
import Kore.TopBottom (
isTop,
)
import Kore.Unparser (
unparse,
)
Expand Down Expand Up @@ -714,18 +715,22 @@ koreProve execOptions proveOptions = do
maybeAlreadyProvenModule

let ProveClaimsResult{stuckClaims, provenClaims} = proveResult
let (exitCode, final)
| noStuckClaims = success
| otherwise =
stuckPatterns
& OrPattern.toTermLike
& failure
let (exitCode, final) =
case foldFirst stuckClaims of
Nothing -> success -- stuckClaims is empty
Just claim ->
stuckPatterns
& OrPattern.toTermLike (getClaimPatternSort $ claimPattern claim)
& failure
where
noStuckClaims = isTop stuckClaims
stuckPatterns =
OrPattern.fromPatterns (MultiAnd.map getStuckConfig stuckClaims)
getStuckConfig =
getRewritingPattern . getConfiguration . getStuckClaim
claimPattern claim =
claim
& getStuckClaim
& Lens.view lensClaimPattern
lift $ for_ saveProofs $ saveProven specModule provenClaims
lift $ renderResult execOptions (unparse final)
return (kFileLocations definition, exitCode)
Expand Down
6 changes: 5 additions & 1 deletion kore/src/Kore/Builtin/AssociativeCommutative.hs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ import Kore.Rewrite.RewritingVariable (
import Kore.Simplify.Simplify as Simplifier
import Kore.Sort (
Sort,
sameSort,
)
import Kore.Syntax.Variable
import Kore.Unification.Unify (
Expand Down Expand Up @@ -1400,7 +1401,10 @@ unifyEqualsElementLists

let remainder2Terms = map fromConcreteOrWithVariable remainder2

case elementListAsInternal tools (termLikeSort first) remainder2Terms of
case elementListAsInternal
tools
(sameSort (termLikeSort first) (termLikeSort second))
remainder2Terms of
Nothing ->
debugUnifyBottomAndReturnBottom
"Duplicated element in unification results"
Expand Down
9 changes: 1 addition & 8 deletions kore/src/Kore/Builtin/Builtin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ import Kore.Simplify.Simplify (
import qualified Kore.Simplify.Simplify as AttemptedAxiomResults (
AttemptedAxiomResults (..),
)
import Kore.Sort (
predicateSort,
)
import Kore.Unparser
import Prelude.Kore

Expand Down Expand Up @@ -448,19 +445,15 @@ isSymbol builtinName Symbol{symbolAttributes = Attribute.Symbol{hook}} =

{- | Is the given sort hooked to the named builtin?

Returns Nothing if the sort is unknown (i.e. the _PREDICATE sort).
Returns Just False if the sort is a variable.
Returns Nothing if the sort is a variable.
-}
isSort :: Text -> SmtMetadataTools attr -> Sort -> Maybe Bool
isSort builtinName tools sort
| isPredicateSort = Nothing
| SortVariableSort _ <- sort = Nothing
| otherwise =
let MetadataTools{sortAttributes} = tools
Attribute.Sort{hook} = sortAttributes sort
in Just (getHook hook == Just builtinName)
where
isPredicateSort = sort == predicateSort

-- | Run a function evaluator that can terminate early.
getAttemptedAxiom ::
Expand Down
12 changes: 7 additions & 5 deletions kore/src/Kore/Builtin/EqTerm.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ module Kore.Builtin.EqTerm (
) where

import qualified Control.Monad as Monad
import Kore.Internal.ApplicationSorts (applicationSortsResult)
import qualified Kore.Internal.MultiOr as MultiOr
import qualified Kore.Internal.OrPattern as OrPattern
import Kore.Internal.Pattern (
Pattern,
)
import qualified Kore.Internal.Pattern as Pattern
import qualified Kore.Internal.SideCondition as SideCondition
import Kore.Internal.TermLike as TermLike
import Kore.Rewrite.RewritingVariable (
Expand Down Expand Up @@ -48,7 +48,6 @@ matchEqTerm selectSymbol (App_ symbol [operand1, operand2]) = do
matchEqTerm _ _ = Nothing

{- | Unification for an equality-like symbol.

This function is suitable only for equality simplification.
-}
unifyEqTerm ::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did this go?

Expand All @@ -63,8 +62,11 @@ unifyEqTerm unifyChildren (NotSimplifier notSimplifier) eqTerm value =
do
solution <- unifyChildren operand1 operand2 & OrPattern.gather
let solution' = MultiOr.map eraseTerm solution
(if value then pure else notSimplifier SideCondition.top) solution'
(if value then pure else mkNotSimplified) solution'
>>= Unify.scatter
where
EqTerm{operand1, operand2} = eqTerm
eraseTerm = Pattern.fromCondition_ . Pattern.withoutTerm
EqTerm{symbol, operand1, operand2} = eqTerm
eqSort = applicationSortsResult . symbolSorts $ symbol
eraseTerm conditional = conditional $> (mkTop eqSort)
mkNotSimplified notChild =
notSimplifier SideCondition.top Not{notSort = eqSort, notChild}
10 changes: 7 additions & 3 deletions kore/src/Kore/Builtin/Int.hs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ import Kore.Internal.Predicate (
)
import qualified Kore.Internal.SideCondition as SideCondition
import Kore.Internal.Symbol (
applicationSortsResult,
symbolHook,
)
import Kore.Internal.TermLike as TermLike
Expand Down Expand Up @@ -524,10 +525,13 @@ unifyIntEq unifyChildren (NotSimplifier notSimplifier) unifyData =
MultiOr.map eraseTerm solution
& if internalBoolValue internalBool
then pure
else notSimplifier SideCondition.top
else mkNotSimplified
scattered <- Unify.scatter solution'
return scattered{term = mkInternalBool internalBool}
where
UnifyIntEq{eqTerm, internalBool} = unifyData
EqTerm{operand1, operand2} = eqTerm
eraseTerm = Pattern.fromCondition_ . Pattern.withoutTerm
EqTerm{symbol, operand1, operand2} = eqTerm
eqSort = applicationSortsResult . symbolSorts $ symbol
eraseTerm conditional = conditional $> (mkTop eqSort)
mkNotSimplified notChild =
notSimplifier SideCondition.top Not{notSort = eqSort, notChild}
2 changes: 1 addition & 1 deletion kore/src/Kore/Builtin/Int/Int.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ asPartialPattern ::
Maybe Integer ->
Pattern variable
asPartialPattern resultSort =
maybe Pattern.bottom (asPattern resultSort)
maybe (Pattern.bottomOf resultSort) (asPattern resultSort)

randKey :: IsString s => s
randKey = "INT.rand"
Expand Down
9 changes: 6 additions & 3 deletions kore/src/Kore/Builtin/KEqual.hs
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,16 @@ unifyKequalsEq unifyChildren (NotSimplifier notSimplifier) unifyData =
MultiOr.map eraseTerm solution
& if internalBoolValue internalBool
then pure
else notSimplifier SideCondition.top
else mkNotSimplified
scattered <- Unify.scatter solution'
return (scattered :: Pattern RewritingVariableName){term = mkInternalBool internalBool}
where
UnifyKequalsEq{eqTerm, internalBool} = unifyData
EqTerm{operand1, operand2} = eqTerm
eraseTerm = Pattern.fromCondition_ . Pattern.withoutTerm
EqTerm{symbol, operand1, operand2} = eqTerm
eqSort = applicationSortsResult . symbolSorts $ symbol
eraseTerm conditional = conditional $> (mkTop eqSort)
mkNotSimplified notChild =
notSimplifier SideCondition.top Not{notSort = eqSort, notChild}

-- | The @KEQUAL.ite@ hooked symbol applied to @term@-type arguments.
data IfThenElse term = IfThenElse
Expand Down
4 changes: 2 additions & 2 deletions kore/src/Kore/Builtin/List.hs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ evalGet _ resultSort [_list, _ix] = do
emptyList <|> bothConcrete
where
maybeBottom =
maybe Pattern.bottom Pattern.fromTermLike
maybe (Pattern.bottomOf resultSort) Pattern.fromTermLike
evalGet _ _ _ = Builtin.wrongArity getKey

evalUpdate :: Builtin.Function
Expand Down Expand Up @@ -629,7 +629,7 @@ unifyEquals
"Cannot unify lists of different length."
term1
term2
return Pattern.bottom
return (Pattern.bottomOf $ termLikeSort term1)

unifyEqualsFramedRightRight ::
TermLike.Symbol ->
Expand Down
21 changes: 12 additions & 9 deletions kore/src/Kore/Builtin/Map.hs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import Kore.Internal.Symbol (
)
import Kore.Internal.TermLike (
Key,
Not (..),
TermLike,
retractKey,
termLikeSort,
Expand Down Expand Up @@ -707,13 +708,14 @@ matchUnifyNotInKeys first second
unifyNotInKeys ::
forall unifier.
MonadUnify unifier =>
Sort ->
TermSimplifier RewritingVariableName unifier ->
NotSimplifier unifier ->
UnifyNotInKeysResult ->
unifier (Pattern RewritingVariableName)
unifyNotInKeys unifyChildren (NotSimplifier notSimplifier) unifyData =
unifyNotInKeys resultSort unifyChildren (NotSimplifier notSimplifier) unifyData =
case unifyData of
NullKeysNullOpaques -> return Pattern.top
NullKeysNullOpaques -> return (Pattern.topOf resultSort)
NonNullKeysOrMultipleOpaques unifyData' ->
do
-- Concrete keys are constructor-like, therefore they are defined
Expand Down Expand Up @@ -750,18 +752,19 @@ unifyNotInKeys unifyChildren (NotSimplifier notSimplifier) unifyData =
>>= Unify.scatter

eraseTerm =
Pattern.fromCondition_ . Pattern.withoutTerm
Pattern.fromCondition resultSort . Pattern.withoutTerm

unifyAndNegate t1 t2 =
do
-- Erasing the unified term is valid here because
-- the terms are all wrapped in \ceil below.
unificationSolutions <-
fmap eraseTerm
<$> Unify.gather (unifyChildren t1 t2)
notSimplifier
SideCondition.top
(OrPattern.fromPatterns unificationSolutions)
fmap eraseTerm <$> Unify.gather (unifyChildren t1 t2)
(notSimplifier SideCondition.top)
Not
{ notSort = resultSort
, notChild = OrPattern.fromPatterns unificationSolutions
}
>>= Unify.scatter

collectConditions terms = fold terms & Pattern.fromCondition_
collectConditions terms = fold terms & Pattern.fromCondition resultSort
9 changes: 6 additions & 3 deletions kore/src/Kore/Builtin/String.hs
Original file line number Diff line number Diff line change
Expand Up @@ -574,10 +574,13 @@ unifyStringEq unifyChildren (NotSimplifier notSimplifier) unifyData =
MultiOr.map eraseTerm solution
& if internalBoolValue internalBool
then pure
else notSimplifier SideCondition.top
else mkNotSimplified
scattered <- Unify.scatter solution'
return scattered{term = mkInternalBool internalBool}
where
UnifyStringEq{eqTerm, internalBool} = unifyData
EqTerm{operand1, operand2} = eqTerm
eraseTerm = Pattern.fromCondition_ . Pattern.withoutTerm
EqTerm{symbol, operand1, operand2} = eqTerm
eqSort = applicationSortsResult . symbolSorts $ symbol
eraseTerm conditional = conditional $> (mkTop eqSort)
mkNotSimplified notChild =
notSimplifier SideCondition.top Not{notSort = eqSort, notChild}
2 changes: 1 addition & 1 deletion kore/src/Kore/Builtin/String/String.hs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ asPartialPattern ::
Maybe Text ->
Pattern variable
asPartialPattern resultSort =
maybe Pattern.bottom (asPattern resultSort)
maybe (Pattern.bottomOf resultSort) (asPattern resultSort)

eqKey :: IsString s => s
eqKey = "STRING.eq"
Expand Down
48 changes: 37 additions & 11 deletions kore/src/Kore/Equation/Validate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import qualified Data.Functor.Foldable as Recursive
import Data.Text (
pack,
)
import Kore.AST.AstWithLocation
import Kore.AST.Error
import Kore.Attribute.Axiom (
Assoc (..),
Expand All @@ -36,11 +37,18 @@ import Kore.Equation.Sentence (
fromSentenceAxiom,
)
import Kore.Internal.Predicate (
Predicate,
pattern PredicateCeil,
pattern PredicateIn,
)
import qualified Kore.Internal.Predicate as Predicate
import qualified Kore.Internal.Symbol as Symbol
import Kore.Internal.TermLike (
AstLocation,
InternalVariable,
TermLike,
mkSortVariable,
)
import qualified Kore.Internal.TermLike as TermLike
import Kore.Syntax.Definition
import Kore.Syntax.Variable
Expand All @@ -50,6 +58,7 @@ import Kore.Unparser (
import Kore.Validate.Verifier
import qualified Kore.Verified as Verified
import Prelude.Kore
import Pretty (Doc)
import qualified Pretty

validateAxiom ::
Expand Down Expand Up @@ -121,25 +130,42 @@ validateAxiom attrs verified =
failOnJust
eq
"Expected variable, but found:"
$ asum $ getNotVar <$> termLikeF
(fmap unparseWithLocation $ asum $ getNotVar <$> termLikeF)

getNotVar (TermLike.Var_ _) = Nothing
getNotVar term = Just term

unparseWithLocation ::
AstWithLocation variable =>
InternalVariable variable =>
TermLike variable ->
(Doc ann, AstLocation)
unparseWithLocation t = (unparse t, locationFromAst t)

checkArg _ Nothing = return ()
checkArg eq (Just arg) =
traverse_
( failOnJust eq "Found invalid subterm in argument of function equation:"
. checkArgIn
. checkArgInAndUnparse
)
$ Predicate.getMultiAndPredicate arg
where
checkArgIn (PredicateIn (TermLike.Var_ _) term) =
findBadArgSubterm term
checkArgIn (PredicateCeil (TermLike.And_ _ (TermLike.Var_ _) term)) =
findBadArgSubterm term
checkArgIn badArg = Just $ Predicate.fromPredicate_ badArg

checkArgInAndUnparse ::
AstWithLocation variable =>
InternalVariable variable =>
Predicate variable ->
Maybe (Doc ann, AstLocation)
checkArgInAndUnparse predicate =
checkArgIn predicate <&> unparseWithLocation
where
checkArgIn (PredicateIn (TermLike.Var_ _) term) =
findBadArgSubterm term
checkArgIn (PredicateCeil (TermLike.And_ _ (TermLike.Var_ _) term)) =
findBadArgSubterm term
checkArgIn badArg =
-- use dummy sort variable for pretty printing inside failOnJust
-- the term's AstLocation will be AstLocationNone
Just $ Predicate.fromPredicate (mkSortVariable "_") badArg
findBadArgSubterm term = case term of
_
| TermLike.isConstructorLike term -> descend
Expand Down Expand Up @@ -175,14 +201,14 @@ validateAxiom attrs verified =
descend = asum $ findBadArgSubterm <$> termF

failOnJust _ _ Nothing = return ()
failOnJust eq errorMessage (Just term) =
failOnJust eq errorMessage (Just (term, location)) =
koreFailWithLocations
[term]
[location]
( pack $
show $
Pretty.vsep
[ errorMessage
, Pretty.indent 4 $ unparse term
, Pretty.indent 4 term
, "The equation that the above occurs in is:"
, Pretty.indent 4 $ Pretty.pretty eq
]
Expand Down
Loading