@@ -5,7 +5,8 @@
55 evaluation/checking inside the proof system, etc. --}
66
77module Core.ProofState(ProofState(..), newProof, envAtFocus, goalAtFocus,
8− Tactic(..), Goal(..), processTactic, dropGiven) where
8+ Tactic(..), Goal(..), processTactic,
9+ dropGiven, keepGiven) where
910
1011import Core.Typecheck
1112import Core.Evaluate
@@ -27,6 +28,7 @@ data ProofState = PS { thname :: Name,
2728 ptype :: Type, -- original goal
2829 dontunify :: [Name], -- explicitly given by programmer, leave it
2930 unified :: (Name, [(Name, Term)]),
31+ notunified :: [(Name, Term)],
3032 solved :: Maybe (Name, Term),
3133 problems :: Fails,
3234 injective :: [Name],
@@ -78,8 +80,8 @@ data Tactic = Attack
7880-- Some utilites on proof and tactic states
7981
8082instance Show ProofState where
81− show (PS nm [] _ _ tm _ _ _ _ _ _ _ _ _ _ _ _) = show nm ++ ": no more goals"
82− show (PS nm (h:hs) _ _ tm _ _ _ _ _ _ i _ _ ctxt _ _)
83+ show (PS nm [] _ _ tm _ _ _ _ _ _ _ _ _ _ _ _ _) = show nm ++ ": no more goals"
84+ show (PS nm (h:hs) _ _ tm _ _ _ _ _ _ _ i _ _ ctxt _ _)
8385 = let OK g = goal (Just h) tm
8486 wkenv = premises g in
8587 "Other goals: " ++ show hs ++ "\n" ++
@@ -102,12 +104,12 @@ instance Show ProofState where
102104 showG ps b = showEnv ps (binderTy b)
103105
104106instance Pretty ProofState where
105− pretty (PS nm [] _ _ trm _ _ _ _ _ _ _ _ _ _ _ _) =
107+ pretty (PS nm [] _ _ trm _ _ _ _ _ _ _ _ _ _ _ _ _) =
106108 if size nm > breakingSize then
107109 pretty nm <> colon $$ nest nestingSize (text " no more goals.")
108110 else
109111 pretty nm <> colon <+> text " no more goals."
110− pretty p@(PS nm (h:hs) _ _ tm _ _ _ _ _ _ i _ _ ctxt _ _) =
112+ pretty p@(PS nm (h:hs) _ _ tm _ _ _ _ _ _ _ i _ _ ctxt _ _) =
111113 let OK g = goal (Just h) tm in
112114 let wkEnv = premises g in
113115 text "Other goals" <+> colon <+> pretty hs $$
@@ -194,7 +196,7 @@ newProof :: Name -> Context -> Type -> ProofState
194196newProof n ctxt ty = let h = holeName 0
195197 ty' = vToP ty in
196198 PS n [h] [] 1 (Bind h (Hole ty')
197− (P Bound h ty')) ty [] (h, [])
199+ (P Bound h ty')) ty [] (h, []) []
198200 Nothing [] []
199201 [] []
200202 Nothing ctxt "" False
@@ -387,10 +389,19 @@ complete_fill ctxt env (Bind x (Guess ty val) sc) =
387389 return $ Bind x (Guess ty val) sc
388390complete_fill ctxt env t = fail $ "Can't complete fill at " ++ show t
389391
392+-- When solving something in the 'dont unify' set, we should check
393+-- that the guess we are solving it with unifies with the thing unification
394+-- found for it, if anything.
395+
390396solve :: RunTactic
391397solve ctxt env (Bind x (Guess ty val) sc)
392398 | True = do ps <- get
393399 let (uh, uns) = unified ps
400+ case lookup x (notunified ps) of
401+ Just tm -> do -- trace ("AVOIDED " ++ show (x, tm, val)) $
402+ -- return []
403+ unify' ctxt env tm val
404+ _ -> return []
394405 action (\ps -> ps { holes = holes ps \\ [x],
395406 solved = Just (x, val),
396407-- problems = solveInProblems
@@ -565,6 +576,15 @@ dropGiven du (u@(n, _) : us) hs
565576-- dropGiven du (u@(_, P a n ty) : us) | n `elem` du = dropGiven du us
566577dropGiven du (u : us) hs = u : dropGiven du us hs
567578
579+keepGiven du [] hs = []
580+keepGiven du ((n, P Bound t ty) : us) hs
581+ | n `elem` du && not (t `elem` du)
582+ && n `elem` hs && t `elem` hs
583+ = keepGiven du us hs
584+keepGiven du (u@(n, _) : us) hs
585+ | n `elem` du = u : keepGiven du us hs
586+keepGiven du (u : us) hs = keepGiven du us hs
587+
568588updateSolved xs x = -- trace ("Updating " ++ show xs ++ " in " ++ show x) $
569589 updateSolved' xs x
570590updateSolved' xs (Bind n (Hole ty) t)
@@ -618,7 +638,7 @@ processTactic EndUnify ps
618638 ns' = map (\ (n, t) -> (n, updateSolved ns t)) ns
619639 (ns'', probs') = updateProblems (context ps) ns' (problems ps)
620640 (injective ps) (holes ps)
621− tm' = -- trace ("Updating " ++ show ns' ++ "\n" ++ show ns'') $ -- ++ " in " ++ show (pterm ps)) $
641+ tm' = -- trace ("Updating " ++ show ns_in ++ "\n" ++ show ns'') $ -- ++ " in " ++ show (pterm ps)) $
622642 updateSolved ns'' (pterm ps) in
623643 return (ps { pterm = tm',
624644 unified = (h, []),