feat: add replaceFVar
This commit is contained in:
parent
5a08e042df
commit
98e9fc20d5
2 changed files with 10 additions and 4 deletions
|
|
@ -635,6 +635,12 @@ constant abstract (e : @& Expr) (xs : @& Array Expr) : Expr := arbitrary _
|
|||
@[extern "lean_expr_abstract_range"]
|
||||
constant abstractRange (e : @& Expr) (n : @& Nat) (xs : @& Array Expr) : Expr := arbitrary _
|
||||
|
||||
def replaceFVar (e : Expr) (fvar : Expr) (v : Expr) : Expr :=
|
||||
(e.abstract #[fvar]).instantiate1 v
|
||||
|
||||
def replaceFVarId (e : Expr) (fvarId : FVarId) (v : Expr) : Expr :=
|
||||
replaceFVar e (mkFVar fvarId) v
|
||||
|
||||
instance : HasToString Expr :=
|
||||
⟨Expr.dbgToString⟩
|
||||
|
||||
|
|
|
|||
|
|
@ -66,9 +66,9 @@ withMVarContext mvarId $ do
|
|||
pure (fvarSubst, mvarId)
|
||||
};
|
||||
if depElim then do
|
||||
let newType := (type.abstract #[a]).instantiate1 b;
|
||||
let newType := type.replaceFVar a b;
|
||||
reflB ← mkEqRefl b;
|
||||
let newType := (newType.abstract #[h]).instantiate1 reflB;
|
||||
let newType := newType.replaceFVar h reflB;
|
||||
if symm then do
|
||||
motive ← mkLambda #[a, h] type;
|
||||
continue motive newType
|
||||
|
|
@ -82,13 +82,13 @@ withMVarContext mvarId $ do
|
|||
motive ← withLocalDecl `_h hAuxType BinderInfo.default $ fun hAux => do {
|
||||
hAuxSymm ← mkEqSymm hAux;
|
||||
/- replace h in type with hAuxSymm -/
|
||||
let newType := (type.abstract #[h]).instantiate1 hAuxSymm;
|
||||
let newType := type.replaceFVar h hAuxSymm;
|
||||
mkLambda #[a, hAux] newType
|
||||
};
|
||||
continue motive newType
|
||||
else do
|
||||
motive ← mkLambda #[a] type;
|
||||
let newType := (type.abstract #[a]).instantiate1 b;
|
||||
let newType := type.replaceFVar a b;
|
||||
continue motive newType
|
||||
| _ =>
|
||||
throwTacticEx `subst mvarId $
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue