Source code on Github
{-# OPTIONS --safe --without-K #-}
--------------------------------------------------------------------------------
-- intro, intros: introduce one or many variables & continue with another tactic
--------------------------------------------------------------------------------

module Tactic.Intro where

open import Meta.Prelude
open import Meta.Init

open import Class.Monad
open import Class.MonadTC.Instances

open import Reflection.Tactic
open import Reflection.Utils.TCI

private
  introHelper : ITactic  TC   ITactic
  introHelper tac fail = do
    hole  goalHole
    ty  inferType hole
    case ty of λ where
      (pi argTy@(arg (arg-info v _) _) (abs x ty′))  do
        hole′  extendContext (x , argTy) (newMeta ty′)
        unifyStrict (hole , ty) (lam v (abs "_" hole′))
        extendContext (x , argTy) (runWithHole hole′ tac)
      _  fail

intro : ITactic  ITactic
intro tac = inDebugPath "intro" (introHelper tac (error1 "intro: not a pi type"))

intros :   ITactic  ITactic
intros 0       tac = error1 "intros: no more fuel"
intros (suc k) tac = inDebugPath "intros" (introHelper (intros k tac) tac)

private
  open import Tactic.Assumption
  open import Tactic.Defaults

  macro
    intro→fill :  TCOptions   Tactic
    intro→fill = initTac  defaultTCOptionsI  $ intro assumption'

    intros→fill :  TCOptions   Tactic
    intros→fill = initTac  defaultTCOptionsI  $ intros 5 assumption'

  _ :   
  _ = intro→fill

  _ :  (n : )  
  _ = intro→fill

  _ :  {n : }  
  _ = intros→fill

  _ :   n :    
  _ = intros→fill

  _ : Bool  Bool
  _ = intro→fill

  _ :  (n : Bool)  Bool
  _ = intro→fill

  _ :  {n : Bool}  Bool
  _ = intros→fill

  _ :   Bool  
  _ = intros→fill

  _ : Bool    
  _ = intros→fill

  _ : (n : )  Bool  
  _ = intros→fill

  _ :   (b : Bool)  
  _ = intros→fill

  _ : (n : ) (b : Bool)  
  _ = intros→fill

  _ : (n : ) {b : Bool}  
  _ = intros→fill

  _ : {n : } {b : Bool}  
  _ = intros→fill

  _ :  {n : Bool}  Bool
  _ = intros→fill

  _ : {n : } (b : Bool)  Bool
  _ = intros→fill

  _ : (n : )  Bool  Bool
  _ = intros→fill

  _ : {b : Bool} {n : }  
  _ = intros→fill

  _ : (b : Bool) {n : }  
  _ = intros→fill

  _ :  {b : Bool} (n : )  
  _ = intros→fill

  _ :  (b : Bool) (n : )  Bool
  _ = intros→fill

  open import Data.List.Membership.Propositional

  _ :  {x : } {xs}  x  xs  x  xs
  _ = intro→fill

  _ :  {x y : } {xs ys}  x  xs  y  ys  x  xs
  _ = intros→fill

  _ :  {x y : } {xs}  x  xs  y  xs  y  xs
  _ = intros→fill