Skip to content

Commit

Permalink
Update Diagnose.hs
Browse files Browse the repository at this point in the history
cleaning up code for rule discovery in the diagnose feedback service
  • Loading branch information
Heeren committed Apr 12, 2021
1 parent f84907f commit 8034cd0
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Ideas/Service/Diagnose.hs
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@ diagnose state new motivationId
-- Is the submitted term equivalent?
| not (equivalence ex (stateContext state) new) =
-- Is the rule used discoverable by trying all known buggy rules?
case discovered True False Nothing of
case discovered isBuggy of
Just (r, as) -> Buggy as r -- report the buggy rule
Nothing -> NotEquivalent "" -- compareParts state new

-- Is the used rule that is submitted applied correctly?
| isJust motivationId && isNothing (discovered False False motivationId) =
case discovered False False Nothing of -- search for a "sound" rule
| maybe False (isNothing . discovered . isRuleId) motivationId =
case discovered (not . isBuggy) of -- search for a "sound" rule
Just (r, _) -> WrongRule (finished state) state (Just r)
Nothing ->
case discovered True False Nothing of -- search for buggy rule
case discovered isBuggy of -- search for buggy rule
Just (r, as) ->
Buggy as r -- report the buggy rule
Nothing ->
Expand All @@ -108,15 +108,15 @@ diagnose state new motivationId
-- (this check is performed after "expected by strategy". TODO: fix
-- granularity of some math rules)
| similar =
case discovered False True Nothing of
case discovered (isMinor <&&> (not . isBuggy)) of
Just (r, _) ->
Similar (finished state) state (Just r)
Nothing ->
Similar (finished state) state Nothing

-- Is the rule used discoverable by trying all known rules?
| otherwise =
case discovered False False Nothing of
case discovered (const True) of
Just (r, as) -> -- If yes, report the found rule as a detour
Detour (finished restarted) restarted as r
Nothing -> -- If not, we give up
Expand All @@ -131,12 +131,12 @@ diagnose state new motivationId
p (_, ns) = similarity ex new (stateContext ns) -- use rule recognizer?
listToMaybe (filter p xs)

discovered searchForBuggy searchForMinor searchForRule = listToMaybe
isRuleId n r = n `elem` getId r : ruleSiblings r

discovered condition = listToMaybe
[ (r, env)
| r <- sortBy (ruleOrdering ex) (ruleset ex)
, isBuggy r == searchForBuggy
, isMinor r == searchForMinor
, maybe True (`elem` getId r:ruleSiblings r) searchForRule
, condition r
, (_, env) <- recognizeRule ex r sub1 sub2
]
where
Expand Down

0 comments on commit 8034cd0

Please sign in to comment.