@@ -50,6 +50,7 @@ data ProofState = PS { thname :: Name,
5050
5151data Tactic = Attack
5252 | Claim Name Raw
53+ | ClaimFn Name Name Raw
5354 | Reorder Name
5455 | Exact Raw
5556 | Fill Raw
@@ -87,6 +88,7 @@ data Tactic = Attack
8788 | MoveLast Name
8889 | MatchProblems Bool
8990 | UnifyProblems
91+ | UnifyGoal Raw
9092 | ProofState
9193 | Undo
9294 | QED
@@ -340,7 +342,18 @@ claim n ty ctxt env t =
340342 lift $ isType ctxt env tyt
341343 action (\ps -> let (g:gs) = holes ps in
342344 ps { holes = g : n : gs } )
343− return $ Bind n (Hole tyv) t -- (weakenTm 1 t)
345+ return $ Bind n (Hole tyv) t
346+
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"
344357
345358reorder_claims :: RunTactic
346359reorder_claims ctxt env t
@@ -440,6 +453,12 @@ regret ctxt env (Bind x (Hole t) sc) | noOccurrence x sc =
440453regret ctxt env (Bind x (Hole t) _)
441454 = fail $ show x ++ " : " ++ show t ++ " is not solved..."
442455
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
460+ return h
461+
443462exact :: Raw -> RunTactic
444463exact guess ctxt env (Bind x (Hole ty) sc) =
445464 do (val, valty) <- lift $ check ctxt env guess
@@ -961,6 +980,7 @@ process EndUnify _
961980process t h = tactic (Just h) (mktac t)
962981 where mktac Attack = attack
963982 mktac (Claim n r) = claim n r
983+ mktac (ClaimFn n bn r) = claimFn n bn r
964984 mktac (Exact r) = exact r
965985 mktac (Fill r) = fill r
966986 mktac (MatchFill r) = match_fill r
@@ -992,3 +1012,4 @@ process t h = tactic (Just h) (mktac t)
9921012 mktac (AutoArg n) = autoArg n
9931013 mktac (SetInjective n) = setinj n
9941014 mktac (MoveLast n) = movelast n
1015+ mktac (UnifyGoal r) = unifyGoal r