@@ -179,7 +179,6 @@ match_unify' :: Context -> Env ->
179match_unify' ctxt env (topx, xfrom) (topy, yfrom) =
179match_unify' ctxt env (topx, xfrom) (topy, yfrom) =
180 do ps <- get
180 do ps <- get
181 let while = while_elaborating ps
181 let while = while_elaborating ps
182− let dont = dontunify ps
183 let inj = injective ps
182 let inj = injective ps
184 traceWhen (unifylog ps)
183 traceWhen (unifylog ps)
185 ("Matching " ++ show (topx, topy) ++
184 ("Matching " ++ show (topx, topy) ++
@@ -492,15 +491,6 @@ deferType n fty_in args ctxt env (Bind x (Hole t) (P nt x' ty)) | x == x' =
492 Nothing -> error ("deferType can't find " ++ show n)
491 Nothing -> error ("deferType can't find " ++ show n)
493deferType _ _ _ _ _ _ = fail "Can't defer a non-hole focus."
492deferType _ _ _ _ _ _ = fail "Can't defer a non-hole focus."
496−regret ctxt env (Bind x (Hole t) sc) | noOccurrence x sc =
497− do action (\ps -> let hs = holes ps in
498− ps { holes = hs \\ [x] })
500−regret ctxt env (Bind x (Hole t) _)
501− = fail $ show x ++ " : " ++ show t ++ " is not solved..."
502−regret _ _ _ = fail "The current focus is not a hole."
504unifyGoal :: Raw -> RunTactic
494unifyGoal :: Raw -> RunTactic
505unifyGoal tm ctxt env h@(Bind x b sc) =
495unifyGoal tm ctxt env h@(Bind x b sc) =
506 do (tmv, _) <- lift $ check ctxt env tm
496 do (tmv, _) <- lift $ check ctxt env tm
@@ -527,14 +517,8 @@ exact _ _ _ _ = fail "Can't fill here."
527fill :: Raw -> RunTactic
517fill :: Raw -> RunTactic
528fill guess ctxt env (Bind x (Hole ty) sc) =
518fill guess ctxt env (Bind x (Hole ty) sc) =
529 do (val, valty) <- lift $ check ctxt env guess
519 do (val, valty) <- lift $ check ctxt env guess
530−-- let valtyn = normalise ctxt env valty
531−-- let tyn = normalise ctxt env ty
532− ns <- unify' ctxt env (valty, Just $ SourceTerm val)
520+ unify' ctxt env (valty, Just $ SourceTerm val)
533− (ty, Just (chkPurpose val ty))
521+ (ty, Just (chkPurpose val ty))
535− let (uh, uns) = unified ps
536−-- put (ps { unified = (uh, uns ++ ns) })
537−-- addLog (show (uh, uns ++ ns))
538 return $ Bind x (Guess ty val) sc
522 return $ Bind x (Guess ty val) sc
540 -- some expected types show up commonly in errors and indicate a
524 -- some expected types show up commonly in errors and indicate a
@@ -550,14 +534,8 @@ fill _ _ _ _ = fail "Can't fill here."
550match_fill :: Raw -> RunTactic
534match_fill :: Raw -> RunTactic
551match_fill guess ctxt env (Bind x (Hole ty) sc) =
535match_fill guess ctxt env (Bind x (Hole ty) sc) =
552 do (val, valty) <- lift $ check ctxt env guess
536 do (val, valty) <- lift $ check ctxt env guess
553−-- let valtyn = normalise ctxt env valty
554−-- let tyn = normalise ctxt env ty
555− ns <- match_unify' ctxt env (valty, Just $ SourceTerm val)
537+ match_unify' ctxt env (valty, Just $ SourceTerm val)
556− (ty, Just ExpectedType)
538+ (ty, Just ExpectedType)
558− let (uh, uns) = unified ps
559−-- put (ps { unified = (uh, uns ++ ns) })
560−-- addLog (show (uh, uns ++ ns))
561 return $ Bind x (Guess ty val) sc
539 return $ Bind x (Guess ty val) sc
562match_fill _ _ _ _ = fail "Can't fill here."
540match_fill _ _ _ _ = fail "Can't fill here."
@@ -571,11 +549,8 @@ complete_fill :: RunTactic
571complete_fill ctxt env (Bind x (Guess ty val) sc) =
549complete_fill ctxt env (Bind x (Guess ty val) sc) =
572 do let guess = forget val
550 do let guess = forget val
573 (val', valty) <- lift $ check ctxt env guess
551 (val', valty) <- lift $ check ctxt env guess
574− ns <- unify' ctxt env (valty, Just $ SourceTerm val')
552+ unify' ctxt env (valty, Just $ SourceTerm val')
575− (ty, Just ExpectedType)
553+ (ty, Just ExpectedType)
577− let (uh, uns) = unified ps
578−-- put (ps { unified = (uh, uns ++ ns) })
579 return $ Bind x (Guess ty val) sc
554 return $ Bind x (Guess ty val) sc
580complete_fill ctxt env t = fail $ "Can't complete fill at " ++ show t
555complete_fill ctxt env t = fail $ "Can't complete fill at " ++ show t
@@ -586,7 +561,6 @@ complete_fill ctxt env t = fail $ "Can't complete fill at " ++ show t
586solve :: RunTactic
561solve :: RunTactic
587solve ctxt env (Bind x (Guess ty val) sc)
562solve ctxt env (Bind x (Guess ty val) sc)
588 = do ps <- get
563 = do ps <- get
589− let (uh, uns) = unified ps
590 dropdots <-
564 dropdots <-
591 case lookup x (notunified ps) of
565 case lookup x (notunified ps) of
592 Just tm -> -- trace ("NEED MATCH: " ++ show (x, tm, val) ++ "\nIN " ++ show (pterm ps)) $
566 Just tm -> -- trace ("NEED MATCH: " ++ show (x, tm, val) ++ "\nIN " ++ show (pterm ps)) $
@@ -603,7 +577,7 @@ solve ctxt env (Bind x (Guess ty val) sc)
603 recents = x : recents ps,
577 recents = x : recents ps,
604 implementations = implementations ps \\ [x],
578 implementations = implementations ps \\ [x],
605 dotted = dropUnified dropdots (dotted ps) })
579 dotted = dropUnified dropdots (dotted ps) })
606− let (locked, did) = tryLock (holes ps \\ [x]) (updsubst x val sc) in
580+ let (locked, _) = tryLock (holes ps \\ [x]) (updsubst x val sc) in
607 return locked
581 return locked
608 where dropUnified ddots [] = []
582 where dropUnified ddots [] = []
609 dropUnified ddots ((x, es) : ds)
583 dropUnified ddots ((x, es) : ds)
@@ -628,7 +602,6 @@ solve ctxt env (Bind x (Guess ty val) sc)
628 (Bind n (Let ty' val') sc', tyl && vall && scl)
602 (Bind n (Let ty' val') sc', tyl && vall && scl)
629 tryLock hs t@(Bind n b sc)
603 tryLock hs t@(Bind n b sc)
630 = let (bt', btl) = tryLock hs (binderTy b)
604 = let (bt', btl) = tryLock hs (binderTy b)
631− (val', vall) = tryLock hs val
632 (sc', scl) = tryLock hs sc in
605 (sc', scl) = tryLock hs sc in
633 (Bind n (b { binderTy = bt' }) sc', btl && scl)
606 (Bind n (b { binderTy = bt' }) sc', btl && scl)
634 tryLock hs t = (t, True)
607 tryLock hs t = (t, True)
@@ -654,13 +627,9 @@ introTy ty mn ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' =
654 x@(Bind y (Pi _ _ s _) _) -> x
627 x@(Bind y (Pi _ _ s _) _) -> x
655 _ -> normalise ctxt env t
628 _ -> normalise ctxt env t
656 (tyv, tyt) <- lift $ check ctxt env ty
629 (tyv, tyt) <- lift $ check ctxt env ty
657−-- ns <- lift $ unify ctxt env tyv t'
658 case t' of
630 case t' of
659 Bind y (Pi rig _ s _) t -> let t' = updsubst y (P Bound n s) t in
631 Bind y (Pi rig _ s _) t -> let t' = updsubst y (P Bound n s) t in
660− do ns <- unify' ctxt env (s, Nothing) (tyv, Nothing)
632+ do unify' ctxt env (s, Nothing) (tyv, Nothing)
662− let (uh, uns) = unified ps
663−-- put (ps { unified = (uh, uns ++ ns) })
664 return $ Bind n (Lam rig tyv) (Bind x (Hole t') (P Bound x t'))
633 return $ Bind n (Lam rig tyv) (Bind x (Hole t') (P Bound x t'))
665 _ -> lift $ tfail $ CantIntroduce t'
634 _ -> lift $ tfail $ CantIntroduce t'
666introTy ty n ctxt env _ = fail "Can't introduce here."
635introTy ty n ctxt env _ = fail "Can't introduce here."
@@ -758,7 +727,7 @@ casetac :: Raw -> Bool -> RunTactic
758casetac tm induction ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' = do
727casetac tm induction ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' = do
759 (tmv, tmt) <- lift $ check ctxt env tm
728 (tmv, tmt) <- lift $ check ctxt env tm
760 let tmt' = normalise ctxt env tmt
729 let tmt' = normalise ctxt env tmt
761− let (tacn, tacstr, tactt) = if induction
730+ let (tacn, tacstr, _) = if induction
762 then (ElimN, "eliminator", "Induction")
731 then (ElimN, "eliminator", "Induction")
763 else (CaseN (FC' emptyFC), "case analysis", "Case analysis")
732 else (CaseN (FC' emptyFC), "case analysis", "Case analysis")
764 case unApply tmt' of
733 case unApply tmt' of
@@ -771,13 +740,9 @@ casetac tm induction ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' = do
771 _ -> return []
740 _ -> return []
772 let (params, indicies) = splitTyArgs param_pos tyargs
741 let (params, indicies) = splitTyArgs param_pos tyargs
773 let args = getArgTys elimTy
742 let args = getArgTys elimTy
774− let pmargs = take (length params) args
775 let args' = drop (length params) args
743 let args' = drop (length params) args
776− let propTy = head args'
777 let restargs = init $ tail args'
744 let restargs = init $ tail args'
778 let consargs = take (length restargs - length indicies) restargs
745 let consargs = take (length restargs - length indicies) restargs
779− let indxargs = drop (length restargs - length indicies) restargs
780− let scr = last $ tail args'
781 let indxnames = makeIndexNames indicies
746 let indxnames = makeIndexNames indicies
782 currentNames <- query $ allTTNames . getProofTerm . pterm
747 currentNames <- query $ allTTNames . getProofTerm . pterm
783 let tmnm = case tm of
748 let tmnm = case tm of
@@ -799,8 +764,7 @@ casetac tm induction ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' = do
799 xs -> lift $ tfail $ Msg $ "Multiple definitions found when searching for " ++ tacstr ++ "of " ++ show tnm
764 xs -> lift $ tfail $ Msg $ "Multiple definitions found when searching for " ++ tacstr ++ "of " ++ show tnm
800 _ -> lift $ tfail $ NoEliminator (if induction then "induction" else "case analysis")
765 _ -> lift $ tfail $ NoEliminator (if induction then "induction" else "case analysis")
802− where scname = sMN 0 "scarg"
803− makeConsArg (nm, ty) = P Bound nm ty
767+ where makeConsArg (nm, ty) = P Bound nm ty
804 bindConsArgs ((nm, ty):args) v = Bind nm (Hole ty) $ bindConsArgs args v
768 bindConsArgs ((nm, ty):args) v = Bind nm (Hole ty) $ bindConsArgs args v
805 bindConsArgs [] v = v
769 bindConsArgs [] v = v
806 addConsHole (nm, ty) =
770 addConsHole (nm, ty) =
@@ -879,8 +843,6 @@ start_unify :: Name -> RunTactic
879start_unify n ctxt env tm = do -- action (\ps -> ps { unified = (n, []) })
843start_unify n ctxt env tm = do -- action (\ps -> ps { unified = (n, []) })
880 return tm
844 return tm
882−tmap f (a, b, c) = (f a, b, c)
884solve_unified :: RunTactic
846solve_unified :: RunTactic
885solve_unified ctxt env tm =
847solve_unified ctxt env tm =
886 do ps <- get
848 do ps <- get
@@ -929,14 +891,6 @@ updateError ns (CantUnify b (l,lp) (r,rp) e xs sc)
929 (updateSolvedTerm ns r, fmap (updateProv ns) rp) (updateError ns e) xs sc
891 (updateSolvedTerm ns r, fmap (updateProv ns) rp) (updateError ns e) xs sc
930updateError ns e = e
892updateError ns e = e
933−updateRes ns ((x, t) : ts) = (x, updateSolvedTerm ns t) : updateRes ns ts
935−solveInProblems x val [] = []
936−solveInProblems x val ((l, r, env, err) : ps)
937− = ((psubst x val l, psubst x val r,
938− updateEnv [(x, val)] env, err) : solveInProblems x val ps)
940mergeNotunified :: Env -> [Name] -> [(Name, Term)] -> ([(Name, Term)], Fails)
894mergeNotunified :: Env -> [Name] -> [(Name, Term)] -> ([(Name, Term)], Fails)
941mergeNotunified env holes ns = mnu ns [] [] where
895mergeNotunified env holes ns = mnu ns [] [] where
942 mnu [] ns_acc ps_acc = (reverse ns_acc, reverse ps_acc)
896 mnu [] ns_acc ps_acc = (reverse ns_acc, reverse ps_acc)