Skip to content

Use entire goal in proof strategy #1936

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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
02dda6d
Breadth limit: handle for prove
ana-pantilie Jun 26, 2020
95e35f4
Strategy.Verification: replace Pattern with OrPattern
ana-pantilie Jun 26, 2020
b3dafc3
Remove redundant constraints
ana-pantilie Jun 26, 2020
ccfe7c3
Remove unused import
ana-pantilie Jun 26, 2020
9af74e2
Fix tests
ana-pantilie Jun 26, 2020
8e1b5da
Remove unused imports
ana-pantilie Jun 26, 2020
9dc7176
Add unit tests
ana-pantilie Jun 29, 2020
cc650ff
Add integration tests
ana-pantilie Jun 29, 2020
95cc0b7
Clean-up
ana-pantilie Jun 29, 2020
2613fab
Address review comments
ana-pantilie Jun 30, 2020
ccfb60a
Merge branch 'master' into breadth-limit-prove
ana-pantilie Jun 30, 2020
cc36c4e
Regenerate golden file
ana-pantilie Jun 30, 2020
3ff1bc9
Strategies.Verification: replace (Pattern Variable) with Reachability…
ana-pantilie Jun 30, 2020
c3d85cf
Merge remote-tracking branch 'upstream/master' into use-entire-goal-i…
ana-pantilie Jun 30, 2020
468791d
kore-repl: keep entire goal in execution graph
ana-pantilie Jun 30, 2020
3d780e8
Strategies.Verification: remove redundant function
ana-pantilie Jun 30, 2020
b0f950b
Repl: use stored goal instead of generating claims
ana-pantilie Jul 1, 2020
458c4fd
Clean-up
ana-pantilie Jul 1, 2020
9c77dd4
Clean-up
ana-pantilie Jul 1, 2020
9be12ba
Repl: add dest (destination) command
ana-pantilie Jul 1, 2020
ff830e2
Clean-up
ana-pantilie Jul 1, 2020
7e19e66
Address review comment
ana-pantilie Jul 2, 2020
63a4240
Address review comments
ana-pantilie Jul 2, 2020
0ff5bc1
Revert + fix
ana-pantilie Jul 2, 2020
ae469d1
Merge remote-tracking branch 'upstream/master' into use-entire-goal-i…
ana-pantilie Jul 3, 2020
3e373c7
Merge remote-tracking branch 'upstream/master' into use-entire-goal-i…
ana-pantilie Jul 8, 2020
c448b00
Verification.verifyClaimStep: remove target argument
ana-pantilie Jul 8, 2020
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
7 changes: 3 additions & 4 deletions kore/src/Kore/Repl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,18 @@ runRepl
firstClaimExecutionGraph = emptyExecutionGraph firstClaim

stepper0
:: ReachabilityRule
-> [ReachabilityRule]
:: [ReachabilityRule]
-> [Axiom]
-> ExecutionGraph Axiom
-> ReplNode
-> m (ExecutionGraph Axiom)
stepper0 claim claims axioms graph rnode = do
stepper0 claims axioms graph rnode = do
let node = unReplNode rnode
if Graph.outdeg (Strategy.graph graph) node == 0
then
catchEverything graph
$ catchInterruptWithDefault graph
$ verifyClaimStep claim claims axioms graph node
$ verifyClaimStep claims axioms graph node
else pure graph

catchInterruptWithDefault :: a -> m a -> m a
Expand Down
9 changes: 6 additions & 3 deletions kore/src/Kore/Repl/Data.hs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ data ReplCommand
-- ^ Select a different node in the graph.
| ShowConfig !(Maybe ReplNode)
-- ^ Show the configuration from the current node.
| ShowDest !(Maybe ReplNode)
-- ^ Show the destination from the current node.
| OmitCell !(Maybe String)
-- ^ Adds or removes cell to omit list, or shows current omit list.
| ShowLeafs
Expand Down Expand Up @@ -334,6 +336,8 @@ helpText =
\select <n> select node id 'n' from the graph\n\
\config [n] shows the config for node 'n'\
\ (defaults to current node)\n\
\dest [n] shows the destination for node 'n'\
\ (defaults to current node)\n\
\omit [cell] adds or removes cell to omit list\
\ (defaults to showing the omit\
\ list)\n\
Expand Down Expand Up @@ -493,13 +497,12 @@ data ReplState = ReplState
-- | Configuration environment for the repl.
data Config m = Config
{ stepper
:: Claim
-> [Claim]
:: [Claim]
-> [Axiom]
-> ExecutionGraph Axiom
-> ReplNode
-> m (ExecutionGraph Axiom)
-- ^ Stepper function, it is a partially applied 'verifyClaimStep'
-- ^ Stepper function
, unifier
:: SideCondition VariableName
-> TermLike VariableName
Expand Down
80 changes: 52 additions & 28 deletions kore/src/Kore/Repl/Interpreter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ import Kore.Step.RulePattern
( ReachabilityRule (..)
, RulePattern (..)
, ToRulePattern (..)
, rhsToPattern
)
import Kore.Step.Simplification.Data
( MonadSimplify
Expand All @@ -186,12 +187,12 @@ import qualified Kore.Step.Strategy as Strategy
import Kore.Strategies.Goal
import Kore.Strategies.ProofState
( ProofStateTransformer (ProofStateTransformer)
, extractUnproven
, proofState
)
import qualified Kore.Strategies.ProofState as ProofState.DoNotUse
import Kore.Strategies.Verification
( CommonProofState
, commonProofStateTransformer
)
import Kore.Syntax.Application
import qualified Kore.Syntax.Id as Id
Expand Down Expand Up @@ -248,6 +249,7 @@ replInterpreter0 printAux printKore replCmd = do
ProveStepsF n -> proveStepsF n $> Continue
SelectNode i -> selectNode i $> Continue
ShowConfig mc -> showConfig mc $> Continue
ShowDest mc -> showDest mc $> Continue
OmitCell c -> omitCell c $> Continue
ShowLeafs -> showLeafs $> Continue
ShowRule mc -> showRule mc $> Continue
Expand Down Expand Up @@ -521,14 +523,37 @@ showConfig
=> Maybe ReplNode
-- ^ 'Nothing' for current node, or @Just n@ for a specific node identifier
-> ReplM m ()
showConfig configNode = do
maybeConfig <- getConfigAt configNode
case maybeConfig of
showConfig =
showProofStateComponent "Config" getConfiguration

-- | Shows destination at node 'n', or current node if 'Nothing' is passed.
showDest
:: Monad m
=> Maybe ReplNode
-- ^ 'Nothing' for current node, or @Just n@ for a specific node identifier
-> ReplM m ()
showDest =
showProofStateComponent "Destination" (rhsToPattern . getDestination)

showProofStateComponent
:: Monad m
=> String
-- ^ component name
-> (ReachabilityRule -> Pattern VariableName)
-> Maybe ReplNode
-> ReplM m ()
showProofStateComponent name transformer maybeNode = do
maybeProofState <- getProofStateAt maybeNode
case maybeProofState of
Nothing -> putStrLn' "Invalid node!"
Just (ReplNode node, config) -> do
omit <- Lens.use (field @"omit")
putStrLn' $ "Config at node " <> show node <> " is:"
tell $ unparseStrategy omit config
putStrLn' $ name <> " at node " <> show node <> " is:"
unparseProofStateComponent
transformer
omit
config
& tell

-- | Shows current omit list if passed 'Nothing'. Adds/removes from the list
-- depending on whether the string already exists in the list or not.
Expand Down Expand Up @@ -846,7 +871,7 @@ tryAxiomClaimWorker mode ref = do
-> ReplM m ()
showUnificationFailure axiomOrClaim' node = do
let first = extractLeftPattern axiomOrClaim'
maybeSecond <- getConfigAt (Just node)
maybeSecond <- getProofStateAt (Just node)
case maybeSecond of
Nothing -> putStrLn' "Unexpected error getting current config."
Just (_, second) ->
Expand All @@ -858,7 +883,7 @@ tryAxiomClaimWorker mode ref = do
, goalRewrittenTransformer = patternUnifier
, goalStuckTransformer = patternUnifier
}
second
(getConfiguration <$> second)
where
patternUnifier :: Pattern VariableName -> ReplM m ()
patternUnifier
Expand Down Expand Up @@ -964,30 +989,25 @@ savePartialProof
-> FilePath
-> ReplM m ()
savePartialProof maybeNatural file = do
currentClaim <- Lens.use (field @"claim")
currentIndex <- Lens.use (field @"claimIndex")
claims <- Lens.use (field @"claims")
Config { mainModuleName } <- ask
maybeConfig <- getConfigAt maybeNode
case maybeConfig of
maybeConfig <- getProofStateAt maybeNode
case (fmap . fmap) extractUnproven maybeConfig of
Nothing -> putStrLn' "Invalid node!"
Just (currentNode, currentProofState) -> do
let config = unwrapConfig currentProofState
newClaim = createClaim currentClaim config
newTrustedClaims =
Just (_, Nothing) -> putStrLn' "Goal is proven."
Just (currentNode, Just currentGoal) -> do
let newTrustedClaims =
makeTrusted
<$> removeIfRoot currentNode currentIndex claims
newDefinition =
createNewDefinition
mainModuleName
(makeModuleName file)
$ newClaim : newTrustedClaims
$ currentGoal : newTrustedClaims
saveUnparsedDefinitionToFile (unparse newDefinition)
putStrLn' "Done."
where
unwrapConfig :: CommonProofState -> Pattern VariableName
unwrapConfig = proofState commonProofStateTransformer

saveUnparsedDefinitionToFile
:: Pretty.Doc ann
-> ReplM m ()
Expand Down Expand Up @@ -1203,26 +1223,30 @@ showRewriteRule rule =
<> makeAuxReplOutput (show . Pretty.pretty . from @_ @SourceLocation $ rule)

-- | Unparses a strategy node, using an omit list to hide specified children.
unparseStrategy
:: Set String
unparseProofStateComponent
:: (ReachabilityRule -> Pattern VariableName)
-> Set String
-- ^ omit list
-> CommonProofState
-- ^ pattern
-> ReplOutput
unparseStrategy omitList =
unparseProofStateComponent transformation omitList =
proofState ProofStateTransformer
{ goalTransformer = makeKoreReplOutput . unparseToString . fmap hide
, goalRemainderTransformer = \pat ->
{ goalTransformer =
makeKoreReplOutput . unparseComponent
, goalRemainderTransformer = \goal ->
makeAuxReplOutput "Stuck: \n"
<> makeKoreReplOutput (unparseToString $ fmap hide pat)
<> makeKoreReplOutput (unparseComponent goal)
, goalRewrittenTransformer =
makeKoreReplOutput . unparseToString . fmap hide
, goalStuckTransformer = \pat ->
makeKoreReplOutput . unparseComponent
, goalStuckTransformer = \goal ->
makeAuxReplOutput "Stuck: \n"
<> makeKoreReplOutput (unparseToString $ fmap hide pat)
<> makeKoreReplOutput (unparseComponent goal)
, provenValue = makeAuxReplOutput "Reached bottom"
}
where
unparseComponent =
unparseToString . fmap hide . transformation
hide :: TermLike VariableName -> TermLike VariableName
hide =
Recursive.unfold $ \termLike ->
Expand Down
6 changes: 6 additions & 0 deletions kore/src/Kore/Repl/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ nonRecursiveCommand =
, proveSteps
, selectNode
, showConfig
, showDest
, omitCell
, showLeafs
, showRule
Expand Down Expand Up @@ -188,6 +189,11 @@ showConfig = do
dec <- literal "config" *> maybeDecimal
return $ ShowConfig (fmap ReplNode dec)

showDest :: Parser ReplCommand
showDest = do
dec <- literal "dest" *> maybeDecimal
return $ ShowDest (fmap ReplNode dec)

omitCell :: Parser ReplCommand
omitCell = OmitCell <$$> literal "omit" *> maybeWord

Expand Down
Loading