File size: 718 Bytes
d03762b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/- Copyright (c) Kyle Miller, 2023.  All rights reserved. -/
import Mathlib.Lean.Expr.Basic

open Lean in
/-- Set all the binder infos to `default` in a chain of `Exists`s. -/
partial def fixExists (e : Expr) : MetaM (Bool × Expr) := do
  let (`Exists, #[α, .lam x ty body bi]) := e.getAppFnArgs | return (false, e)
  let (changed, body) ← fixExists body
  let changed := changed || bi != .default
  return (changed, mkAppN e.getAppFn #[α, .lam x ty body .default])

open Lean Lean.PrettyPrinter.Delaborator in
@[delab app.Exists]
def withFixedExists : Delab := do
  let (changed, e) ← fixExists (← SubExpr.getExpr)
  unless changed do failure
  withTheReader SubExpr (fun cfg => { cfg with expr := e}) delab