@@ -72,7 +72,7 @@ data Tactic = Attack
7272 | LetBind Name Raw Raw
7373 | ExpandLet Name Term
7474 | Rewrite Raw
75− | Induction Name
75+ | Induction Raw
7676 | Equiv Raw
7777 | PatVar Name
7878 | PatBind Name
@@ -661,9 +661,9 @@ mkP lt l r (Bind n b sc)
661661 b { binderTy = ty' }
662662mkP lt l r x = x
663663
664−induction :: Name -> RunTactic
665−induction nm ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' = do
666− (tmv, tmt) <- lift $ check ctxt env (Var nm)
664+induction :: Raw -> RunTactic
665+induction tm ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' = do
666+ (tmv, tmt) <- lift $ check ctxt env tm
667667 let tmt' = normalise ctxt env tmt
668668 case unApply tmt' of
669669 (P _ tnm _, tyargs) -> do
@@ -683,7 +683,12 @@ induction nm ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' = do
683683 let indxargs = drop (length restargs - length indicies) $ restargs
684684 let scr = last $ tail args'
685685 let indxnames = makeIndexNames indicies
686− prop <- replaceIndicies indxnames indicies $ Bind nm (Lam tmt') t
686+ currentNames <- query $ allTTNames . pterm
687+ let tmnm = case tm of
688+ Var nm -> uniqueNameCtxt ctxt nm currentNames
689+ _ -> uniqueNameCtxt ctxt (sMN 0 "iv") currentNames
690+ let tmvar = P Bound tmnm tmt'
691+ prop <- replaceIndicies indxnames indicies $ Bind tmnm (Lam tmt') (mkP tmvar tmv tmvar t)
687692 consargs' <- query (\ps -> map (flip (uniqueNameCtxt (context ps)) (holes ps ++ allTTNames (pterm ps)) *** uniqueBindersCtxt (context ps) (holes ps ++ allTTNames (pterm ps))) consargs)
688693 let res = flip (foldr substV) params $ (substV prop $ bindConsArgs consargs' (mkApp (P Ref (SN (ElimN tnm)) (TType (UVal 0)))
689694 (params ++ [prop] ++ map makeConsArg consargs' ++ indicies ++ [tmv])))