@@ -21,6 +21,7 @@ import Util.Pretty
2121
2222data ProofState = PS { thname :: Name,
2323 holes :: [Name], -- holes still to be solved
24+ usedns :: [Name], -- used names, don't use again
2425 nextname :: Int, -- name supply
2526 pterm :: Term, -- current proof term
2627 ptype :: Type, -- original goal
@@ -74,8 +75,8 @@ data Tactic = Attack
7475-- Some utilites on proof and tactic states
7576
7677instance Show ProofState where
77− show (PS nm [] _ tm _ _ _ _ _ _ _ _ _ _ _ _) = show nm ++ ": no more goals"
78− show (PS nm (h:hs) _ tm _ _ _ _ _ _ i _ _ ctxt _ _)
78+ show (PS nm [] _ _ tm _ _ _ _ _ _ _ _ _ _ _ _) = show nm ++ ": no more goals"
79+ show (PS nm (h:hs) _ _ tm _ _ _ _ _ _ i _ _ ctxt _ _)
7980 = let OK g = goal (Just h) tm
8081 wkenv = premises g in
8182 "Other goals: " ++ show hs ++ "\n" ++
@@ -98,12 +99,12 @@ instance Show ProofState where
9899 showG ps b = showEnv ps (binderTy b)
99100
100101instance Pretty ProofState where
101− pretty (PS nm [] _ trm _ _ _ _ _ _ _ _ _ _ _ _) =
102+ pretty (PS nm [] _ _ trm _ _ _ _ _ _ _ _ _ _ _ _) =
102103 if size nm > breakingSize then
103104 pretty nm <> colon $$ nest nestingSize (text " no more goals.")
104105 else
105106 pretty nm <> colon <+> text " no more goals."
106− pretty p@(PS nm (h:hs) _ tm _ _ _ _ _ _ i _ _ ctxt _ _) =
107+ pretty p@(PS nm (h:hs) _ _ tm _ _ _ _ _ _ i _ _ ctxt _ _) =
107108 let OK g = goal (Just h) tm in
108109 let wkEnv = premises g in
109110 text "Other goals" <+> colon <+> pretty hs $$
@@ -171,7 +172,8 @@ addLog str = action (\ps -> ps { plog = plog ps ++ str ++ "\n" })
171172newProof :: Name -> Context -> Type -> ProofState
172173newProof n ctxt ty = let h = holeName 0
173174 ty' = vToP ty in
174− PS n [h] 1 (Bind h (Hole ty') (P Bound h ty')) ty [] (h, [])
175+ PS n [h] [] 1 (Bind h (Hole ty')
176+ (P Bound h ty')) ty [] (h, [])
175177 Nothing [] []
176178 [] []
177179 Nothing ctxt "" False
@@ -505,14 +507,16 @@ dropGiven du (u@(n, _) : us) | n `elem` du = dropGiven du us
505507-- dropGiven du (u@(_, P a n ty) : us) | n `elem` du = dropGiven du us
506508dropGiven du (u : us) = u : dropGiven du us
507509
508−updateSolved xs (Bind n (Hole ty) t)
509− | Just v <- lookup n xs = instantiate v (pToV n (updateSolved xs t))
510−updateSolved xs (Bind n b t)
511− | otherwise = Bind n (fmap (updateSolved xs) b) (updateSolved xs t)
512−updateSolved xs (App f a) = App (updateSolved xs f) (updateSolved xs a)
513−updateSolved xs (P _ n _)
510+updateSolved xs x = -- trace ("Updating " ++ show xs ++ " in " ++ show x) $
511+ updateSolved' xs x
512+updateSolved' xs (Bind n (Hole ty) t)
513+ | Just v <- lookup n xs = instantiate v (pToV n (updateSolved' xs t))
514+updateSolved' xs (Bind n b t)
515+ | otherwise = Bind n (fmap (updateSolved' xs) b) (updateSolved' xs t)
516+updateSolved' xs (App f a) = App (updateSolved' xs f) (updateSolved' xs a)
517+updateSolved' xs (P _ n _)
514518 | Just v <- lookup n xs = v
515−updateSolved xs t = t
519+updateSolved' xs t = t
516520
517521updateProblems ns [] = []
518522updateProblems ns ((x, y, env, err) : ps) =