Skip to content

Commit 88d2412

Browse files
committed
Translate arg function
1 parent 451a720 commit 88d2412

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎RandomDo/Tactic/Computable/Deriving.lean‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ partial def translate (σ : FVarSubst) (e : Expr) : MetaM Expr :=
8383
let x := xs[0]!.fvarId!
8484
withLocalDeclD (← x.getUserName) (← translate σ (← x.getType)) fun y ↦ do
8585
mkLambdaFVars #[y] (← translate (σ.insert x y) body)
86+
| .forallE .. => forallBoundedTelescope e (some 1) fun xs body ↦ do
87+
let x := xs[0]!.fvarId!
88+
withLocalDeclD (← x.getUserName) (← translate σ (← x.getType)) fun y ↦ do
89+
mkForallFVars #[y] (← translate (σ.insert x y) body)
8690
| .letE n t v b _ => withLetDecl n t v fun x ↦ do
8791
withLetDecl n (← translate σ t) (← translate σ v) fun y ↦ do
8892
mkLetFVars #[y] (← translate (σ.insert x.fvarId! y) (b.instantiate1 x))
@@ -91,6 +95,8 @@ partial def translate (σ : FVarSubst) (e : Expr) : MetaM Expr :=
9195
/-- Rebuild an application from the counterpart of its head; where nothing known about that head
9296
fits, look through it and read its body in its place. -/
9397
partial def translateApp (σ : FVarSubst) (e : Expr) : MetaM Expr := do
98+
if e.getAppFn.isFVar then
99+
return mkAppN (← translate σ e.getAppFn) (← e.getAppArgs.mapM (translate σ))
94100
if e.getAppFn.isLambda then return ← translate σ e.headBeta
95101
let .const declName _ := e.getAppFn | throwError "`computable`: cannot translate{indentExpr e}"
96102
let counterpart? ← computableAs? declName

0 commit comments

Comments
 (0)