@@ -50,6 +50,7 @@ data ProofState = PS { thname :: Name,
51data Tactic = Attack
51data Tactic = Attack
52 | Claim Name Raw
52 | Claim Name Raw
53+ | ClaimFn Name Name Raw
53 | Reorder Name
54 | Reorder Name
54 | Exact Raw
55 | Exact Raw
55 | Fill Raw
56 | Fill Raw
@@ -87,6 +88,7 @@ data Tactic = Attack
87 | MoveLast Name
88 | MoveLast Name
88 | MatchProblems Bool
89 | MatchProblems Bool
89 | UnifyProblems
90 | UnifyProblems
90 | ProofState
92 | ProofState
@@ -340,7 +342,18 @@ claim n ty ctxt env t =
340 lift $ isType ctxt env tyt
342 lift $ isType ctxt env tyt
341 action (\ps -> let (g:gs) = holes ps in
343 action (\ps -> let (g:gs) = holes ps in
342 ps { holes = g : n : gs } )
344 ps { holes = g : n : gs } )
343− return $ Bind n (Hole tyv) t -- (weakenTm 1 t)
345+ return $ Bind n (Hole tyv) t
347+-- If the current goal is 'retty', make a claim which is a function that
348+-- can compute a retty from argty (i.e a claim 'argty -> retty')
349+claimFn :: Name -> Name -> Raw -> RunTactic
350+claimFn n bn argty ctxt env t@(Bind x (Hole retty) sc) =
351+ do (tyv, tyt) <- lift $ check ctxt env argty
352+ lift $ isType ctxt env tyt
353+ action (\ps -> let (g:gs) = holes ps in
354+ ps { holes = g : n : gs } )
355+ return $ Bind n (Hole (Bind bn (Pi Nothing tyv tyt) retty)) t
356+claimFn _ _ _ ctxt env _ = fail "Can't make function type here"
345reorder_claims :: RunTactic
358reorder_claims :: RunTactic
346reorder_claims ctxt env t
359reorder_claims ctxt env t
@@ -440,6 +453,12 @@ regret ctxt env (Bind x (Hole t) sc) | noOccurrence x sc =
440regret ctxt env (Bind x (Hole t) _)
453regret ctxt env (Bind x (Hole t) _)
441 = fail $ show x ++ " : " ++ show t ++ " is not solved..."
454 = fail $ show x ++ " : " ++ show t ++ " is not solved..."
456+unifyGoal :: Raw -> RunTactic
457+unifyGoal tm ctxt env h@(Bind x b sc) =
458+ do (tmv, _) <- lift $ check ctxt env tm
459+ ns' <- unify' ctxt env (binderTy b) tmv
443exact :: Raw -> RunTactic
462exact :: Raw -> RunTactic
444exact guess ctxt env (Bind x (Hole ty) sc) =
463exact guess ctxt env (Bind x (Hole ty) sc) =
445 do (val, valty) <- lift $ check ctxt env guess
464 do (val, valty) <- lift $ check ctxt env guess
@@ -961,6 +980,7 @@ process EndUnify _
961process t h = tactic (Just h) (mktac t)
980process t h = tactic (Just h) (mktac t)
962 where mktac Attack = attack
981 where mktac Attack = attack
963 mktac (Claim n r) = claim n r
982 mktac (Claim n r) = claim n r
983+ mktac (ClaimFn n bn r) = claimFn n bn r
964 mktac (Exact r) = exact r
984 mktac (Exact r) = exact r
965 mktac (Fill r) = fill r
985 mktac (Fill r) = fill r
966 mktac (MatchFill r) = match_fill r
986 mktac (MatchFill r) = match_fill r
@@ -992,3 +1012,4 @@ process t h = tactic (Just h) (mktac t)
992 mktac (AutoArg n) = autoArg n
1012 mktac (AutoArg n) = autoArg n
993 mktac (SetInjective n) = setinj n
1013 mktac (SetInjective n) = setinj n
994 mktac (MoveLast n) = movelast n
1014 mktac (MoveLast n) = movelast n
1015+ mktac (UnifyGoal r) = unifyGoal r