diff --git a/src/Lean/Elab/Tactic/Simp.lean b/src/Lean/Elab/Tactic/Simp.lean index 64290cef0a..be6e9e7f69 100644 --- a/src/Lean/Elab/Tactic/Simp.lean +++ b/src/Lean/Elab/Tactic/Simp.lean @@ -23,6 +23,7 @@ def simpTarget (config : Meta.Simp.Config) (simpLemmas : SimpLemmas) : TacticM U -- TODO: improve simpLocalDecl and simpAll -- TODO: issues: self simplification +-- TODO: add new assertion with simplified result and clear old ones after simplifying all locals def simpLocalDeclFVarId (config : Meta.Simp.Config) (simpLemmas : SimpLemmas) (fvarId : FVarId) : TacticM Unit := do let (g, gs) ← getMainGoal diff --git a/src/Lean/Meta/Tactic/Simp/Main.lean b/src/Lean/Meta/Tactic/Simp/Main.lean index a03707b7a5..7476bffccb 100644 --- a/src/Lean/Meta/Tactic/Simp/Main.lean +++ b/src/Lean/Meta/Tactic/Simp/Main.lean @@ -195,8 +195,16 @@ where trace[Meta.Tactic.simp]! "forall {e}" if e.isArrow then simpArrow e + else if (← isProp e) then + withLocalDecl e.bindingName! e.bindingInfo! e.bindingDomain! fun x => withNewLemmas #[x] do + let b := e.bindingBody!.instantiate1 x + let rb ← simp b + let eNew ← mkForallFVars #[x] rb.expr + match rb.proof? with + | none => return { expr := eNew } + | some h => return { expr := eNew, proof? := (← mkForallCongr (← mkLambdaFVars #[x] h)) } else - return { expr := e } -- TODO + return { expr := (← dsimp e) } simpLet (e : Expr) : M σ Result := do if (← getConfig).zeta then diff --git a/tests/lean/run/simp4.lean b/tests/lean/run/simp4.lean index 5c30c8cd06..9046587cbe 100644 --- a/tests/lean/run/simp4.lean +++ b/tests/lean/run/simp4.lean @@ -42,7 +42,7 @@ theorem ex6 theorem ex7 (x : Nat) : (let y := x + 0; y + y) = x + x := by simp -@[simp] theorem impTrue (p : Prop) : (p → True) = True := +@[simp] theorem impTrue (p : Sort u) : (p → True) = True := propext <| Iff.intro (fun _ => trivial) (fun _ _ => trivial) theorem ex8 (y x : Nat) : y = 0 → x + y = 0 → x = 0 := by @@ -58,3 +58,6 @@ theorem ex10 (y x : Nat) : y = 0 → x + 0 = 0 → x = 0 := by simp intro h₁ h₂ simp [h₂] + +theorem ex11 : ∀ x : Nat, 0 + x + 0 = x := by + simp