@@ -21,6 +21,7 @@ import Util.Pretty
22data ProofState = PS { thname :: Name,
22data ProofState = PS { thname :: Name,
23 holes :: [Name], -- holes still to be solved
23 holes :: [Name], -- holes still to be solved
24+ usedns :: [Name], -- used names, don't use again
24 nextname :: Int, -- name supply
25 nextname :: Int, -- name supply
25 pterm :: Term, -- current proof term
26 pterm :: Term, -- current proof term
26 ptype :: Type, -- original goal
27 ptype :: Type, -- original goal
@@ -74,8 +75,8 @@ data Tactic = Attack
74-- Some utilites on proof and tactic states
75-- Some utilites on proof and tactic states
76instance Show ProofState where
77instance Show ProofState where
77− show (PS nm [] _ tm _ _ _ _ _ _ _ _ _ _ _ _) = show nm ++ ": no more goals"
78+ show (PS nm [] _ _ tm _ _ _ _ _ _ _ _ _ _ _ _) = show nm ++ ": no more goals"
78− show (PS nm (h:hs) _ tm _ _ _ _ _ _ i _ _ ctxt _ _)
79+ show (PS nm (h:hs) _ _ tm _ _ _ _ _ _ i _ _ ctxt _ _)
79 = let OK g = goal (Just h) tm
80 = let OK g = goal (Just h) tm
80 wkenv = premises g in
81 wkenv = premises g in
81 "Other goals: " ++ show hs ++ "\n" ++
82 "Other goals: " ++ show hs ++ "\n" ++
@@ -98,12 +99,12 @@ instance Show ProofState where
98 showG ps b = showEnv ps (binderTy b)
99 showG ps b = showEnv ps (binderTy b)
100instance Pretty ProofState where
101instance Pretty ProofState where
101− pretty (PS nm [] _ trm _ _ _ _ _ _ _ _ _ _ _ _) =
102+ pretty (PS nm [] _ _ trm _ _ _ _ _ _ _ _ _ _ _ _) =
102 if size nm > breakingSize then
103 if size nm > breakingSize then
103 pretty nm <> colon $$ nest nestingSize (text " no more goals.")
104 pretty nm <> colon $$ nest nestingSize (text " no more goals.")
105 pretty nm <> colon <+> text " no more goals."
106 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 _ _) =
107 let OK g = goal (Just h) tm in
108 let OK g = goal (Just h) tm in
108 let wkEnv = premises g in
109 let wkEnv = premises g in
109 text "Other goals" <+> colon <+> pretty hs $$
110 text "Other goals" <+> colon <+> pretty hs $$
@@ -171,7 +172,8 @@ addLog str = action (\ps -> ps { plog = plog ps ++ str ++ "\n" })
171newProof :: Name -> Context -> Type -> ProofState
172newProof :: Name -> Context -> Type -> ProofState
172newProof n ctxt ty = let h = holeName 0
173newProof n ctxt ty = let h = holeName 0
173 ty' = vToP ty in
174 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, [])
175 Nothing [] []
177 Nothing [] []
177 Nothing ctxt "" False
179 Nothing ctxt "" False
@@ -505,14 +507,16 @@ dropGiven du (u@(n, _) : us) | n `elem` du = dropGiven du us
505-- dropGiven du (u@(_, P a n ty) : us) | n `elem` du = dropGiven du us
507-- dropGiven du (u@(_, P a n ty) : us) | n `elem` du = dropGiven du us
506dropGiven du (u : us) = u : dropGiven du us
508dropGiven du (u : us) = u : dropGiven du us
510+updateSolved xs x = -- trace ("Updating " ++ show xs ++ " in " ++ show x) $
508−updateSolved xs (Bind n (Hole ty) t)
512+updateSolved' xs (Bind n (Hole ty) t)
509− | Just v <- lookup n xs = instantiate v (pToV n (updateSolved xs t))
513+ | Just v <- lookup n xs = instantiate v (pToV n (updateSolved' xs t))
510−updateSolved xs (Bind n b t)
514+updateSolved' xs (Bind n b t)
511− | otherwise = Bind n (fmap (updateSolved xs) b) (updateSolved xs t)
515+ | otherwise = Bind n (fmap (updateSolved' xs) b) (updateSolved' xs t)
512−updateSolved xs (App f a) = App (updateSolved xs f) (updateSolved xs a)
516+updateSolved' xs (App f a) = App (updateSolved' xs f) (updateSolved' xs a)
513−updateSolved xs (P _ n _)
517+updateSolved' xs (P _ n _)
514 | Just v <- lookup n xs = v
518 | Just v <- lookup n xs = v
515−updateSolved xs t = t
519+updateSolved' xs t = t
517updateProblems ns [] = []
521updateProblems ns [] = []
518updateProblems ns ((x, y, env, err) : ps) =
522updateProblems ns ((x, y, env, err) : ps) =