Lean4
/-- Create the congruence hole. Used by `elabCHole`.
Saves the current mvarCounter as a proxy for age. We use this to avoid
reprocessing old congruence holes that happened to leak into the local context. -/
def mkCHole (forLhs : Bool) (val pf : Expr) : MetaM Expr := do
-- Create a metavariable to bump the mvarCounter.
discard <| mkFreshTypeMVar
let d : MData := KVMap.empty |>.insert congrHoleForLhsKey forLhs |>.insert congrHoleIndex (← getMCtx).mvarCounter
return Expr.mdata d <| ← mkAppM ``cHole #[val, pf]