feat: simpForall

This commit is contained in:
Leonardo de Moura 2021-01-01 17:24:56 -08:00
parent 244b72befd
commit e517d72bee
3 changed files with 14 additions and 2 deletions

View file

@ -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

View file

@ -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

View file

@ -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