@@ -178,6 +178,7 @@ import Kore.Step.RulePattern
178
178
( ReachabilityRule (.. )
179
179
, RulePattern (.. )
180
180
, ToRulePattern (.. )
181
+ , rhsToPattern
181
182
)
182
183
import Kore.Step.Simplification.Data
183
184
( MonadSimplify
@@ -186,12 +187,12 @@ import qualified Kore.Step.Strategy as Strategy
186
187
import Kore.Strategies.Goal
187
188
import Kore.Strategies.ProofState
188
189
( ProofStateTransformer (ProofStateTransformer )
190
+ , extractUnproven
189
191
, proofState
190
192
)
191
193
import qualified Kore.Strategies.ProofState as ProofState.DoNotUse
192
194
import Kore.Strategies.Verification
193
195
( CommonProofState
194
- , commonProofStateTransformer
195
196
)
196
197
import Kore.Syntax.Application
197
198
import qualified Kore.Syntax.Id as Id
@@ -248,6 +249,7 @@ replInterpreter0 printAux printKore replCmd = do
248
249
ProveStepsF n -> proveStepsF n $> Continue
249
250
SelectNode i -> selectNode i $> Continue
250
251
ShowConfig mc -> showConfig mc $> Continue
252
+ ShowDest mc -> showDest mc $> Continue
251
253
OmitCell c -> omitCell c $> Continue
252
254
ShowLeafs -> showLeafs $> Continue
253
255
ShowRule mc -> showRule mc $> Continue
@@ -521,14 +523,37 @@ showConfig
521
523
=> Maybe ReplNode
522
524
-- ^ 'Nothing' for current node, or @Just n@ for a specific node identifier
523
525
-> ReplM m ()
524
- showConfig configNode = do
525
- maybeConfig <- getConfigAt configNode
526
- case maybeConfig of
526
+ showConfig =
527
+ showProofStateComponent " Config" getConfiguration
528
+
529
+ -- | Shows destination at node 'n', or current node if 'Nothing' is passed.
530
+ showDest
531
+ :: Monad m
532
+ => Maybe ReplNode
533
+ -- ^ 'Nothing' for current node, or @Just n@ for a specific node identifier
534
+ -> ReplM m ()
535
+ showDest =
536
+ showProofStateComponent " Destination" (rhsToPattern . getDestination)
537
+
538
+ showProofStateComponent
539
+ :: Monad m
540
+ => String
541
+ -- ^ component name
542
+ -> (ReachabilityRule -> Pattern VariableName )
543
+ -> Maybe ReplNode
544
+ -> ReplM m ()
545
+ showProofStateComponent name transformer maybeNode = do
546
+ maybeProofState <- getProofStateAt maybeNode
547
+ case maybeProofState of
527
548
Nothing -> putStrLn' " Invalid node!"
528
549
Just (ReplNode node, config) -> do
529
550
omit <- Lens. use (field @ " omit" )
530
- putStrLn' $ " Config at node " <> show node <> " is:"
531
- tell $ unparseStrategy omit config
551
+ putStrLn' $ name <> " at node " <> show node <> " is:"
552
+ unparseProofStateComponent
553
+ transformer
554
+ omit
555
+ config
556
+ & tell
532
557
533
558
-- | Shows current omit list if passed 'Nothing'. Adds/removes from the list
534
559
-- depending on whether the string already exists in the list or not.
@@ -846,7 +871,7 @@ tryAxiomClaimWorker mode ref = do
846
871
-> ReplM m ()
847
872
showUnificationFailure axiomOrClaim' node = do
848
873
let first = extractLeftPattern axiomOrClaim'
849
- maybeSecond <- getConfigAt (Just node)
874
+ maybeSecond <- getProofStateAt (Just node)
850
875
case maybeSecond of
851
876
Nothing -> putStrLn' " Unexpected error getting current config."
852
877
Just (_, second) ->
@@ -858,7 +883,7 @@ tryAxiomClaimWorker mode ref = do
858
883
, goalRewrittenTransformer = patternUnifier
859
884
, goalStuckTransformer = patternUnifier
860
885
}
861
- second
886
+ (getConfiguration <$> second)
862
887
where
863
888
patternUnifier :: Pattern VariableName -> ReplM m ()
864
889
patternUnifier
@@ -964,30 +989,25 @@ savePartialProof
964
989
-> FilePath
965
990
-> ReplM m ()
966
991
savePartialProof maybeNatural file = do
967
- currentClaim <- Lens. use (field @ " claim" )
968
992
currentIndex <- Lens. use (field @ " claimIndex" )
969
993
claims <- Lens. use (field @ " claims" )
970
994
Config { mainModuleName } <- ask
971
- maybeConfig <- getConfigAt maybeNode
972
- case maybeConfig of
995
+ maybeConfig <- getProofStateAt maybeNode
996
+ case ( fmap . fmap ) extractUnproven maybeConfig of
973
997
Nothing -> putStrLn' " Invalid node!"
974
- Just (currentNode, currentProofState) -> do
975
- let config = unwrapConfig currentProofState
976
- newClaim = createClaim currentClaim config
977
- newTrustedClaims =
998
+ Just (_, Nothing ) -> putStrLn' " Goal is proven."
999
+ Just (currentNode, Just currentGoal) -> do
1000
+ let newTrustedClaims =
978
1001
makeTrusted
979
1002
<$> removeIfRoot currentNode currentIndex claims
980
1003
newDefinition =
981
1004
createNewDefinition
982
1005
mainModuleName
983
1006
(makeModuleName file)
984
- $ newClaim : newTrustedClaims
1007
+ $ currentGoal : newTrustedClaims
985
1008
saveUnparsedDefinitionToFile (unparse newDefinition)
986
1009
putStrLn' " Done."
987
1010
where
988
- unwrapConfig :: CommonProofState -> Pattern VariableName
989
- unwrapConfig = proofState commonProofStateTransformer
990
-
991
1011
saveUnparsedDefinitionToFile
992
1012
:: Pretty. Doc ann
993
1013
-> ReplM m ()
@@ -1203,26 +1223,30 @@ showRewriteRule rule =
1203
1223
<> makeAuxReplOutput (show . Pretty. pretty . from @ _ @ SourceLocation $ rule)
1204
1224
1205
1225
-- | Unparses a strategy node, using an omit list to hide specified children.
1206
- unparseStrategy
1207
- :: Set String
1226
+ unparseProofStateComponent
1227
+ :: (ReachabilityRule -> Pattern VariableName )
1228
+ -> Set String
1208
1229
-- ^ omit list
1209
1230
-> CommonProofState
1210
1231
-- ^ pattern
1211
1232
-> ReplOutput
1212
- unparseStrategy omitList =
1233
+ unparseProofStateComponent transformation omitList =
1213
1234
proofState ProofStateTransformer
1214
- { goalTransformer = makeKoreReplOutput . unparseToString . fmap hide
1215
- , goalRemainderTransformer = \ pat ->
1235
+ { goalTransformer =
1236
+ makeKoreReplOutput . unparseComponent
1237
+ , goalRemainderTransformer = \ goal ->
1216
1238
makeAuxReplOutput " Stuck: \n "
1217
- <> makeKoreReplOutput (unparseToString $ fmap hide pat )
1239
+ <> makeKoreReplOutput (unparseComponent goal )
1218
1240
, goalRewrittenTransformer =
1219
- makeKoreReplOutput . unparseToString . fmap hide
1220
- , goalStuckTransformer = \ pat ->
1241
+ makeKoreReplOutput . unparseComponent
1242
+ , goalStuckTransformer = \ goal ->
1221
1243
makeAuxReplOutput " Stuck: \n "
1222
- <> makeKoreReplOutput (unparseToString $ fmap hide pat )
1244
+ <> makeKoreReplOutput (unparseComponent goal )
1223
1245
, provenValue = makeAuxReplOutput " Reached bottom"
1224
1246
}
1225
1247
where
1248
+ unparseComponent =
1249
+ unparseToString . fmap hide . transformation
1226
1250
hide :: TermLike VariableName -> TermLike VariableName
1227
1251
hide =
1228
1252
Recursive. unfold $ \ termLike ->
0 commit comments