This PR adds `foo.fun_cases`, an automatically generated theorem that splits the goal according to the branching structure of `foo`, much like the Functional Induction Principle, but for all functions (not just recursive ones), and without providing inductive hypotheses. The design isn't quite final yet as to which function parameters should become targets of the motive, and which parameters of the theorem, but the current version is already proven to be useful, so start with this and iterate later.
32 lines
1.5 KiB
Text
32 lines
1.5 KiB
Text
/--
|
||
info: Option.map.fun_cases.{u_1, u_2} (motive : {α : Type u_1} → {β : Type u_2} → (α → β) → Option α → Prop)
|
||
(case1 : ∀ {α : Type u_1} {β : Type u_2} (f : α → β) (x : α), motive f (some x))
|
||
(case2 : ∀ {α : Type u_1} {β : Type u_2} (f : α → β), motive f none) {α : Type u_1} {β : Type u_2} (f : α → β)
|
||
(x✝ : Option α) : motive f x✝
|
||
-/
|
||
#guard_msgs in
|
||
#check Option.map.fun_cases
|
||
|
||
example (x : Option Nat) (f : Nat → Nat) : (x.map f).isSome = x.isSome := by
|
||
cases f, x using Option.map.fun_cases
|
||
case case1 x => simp [-Option.isSome_map']
|
||
case case2 => simp [-Option.isSome_map']
|
||
|
||
/--
|
||
info: List.map.fun_cases.{u, v} (motive : {α : Type u} → {β : Type v} → (α → β) → List α → Prop)
|
||
(case1 : ∀ {α : Type u} {β : Type v} (f : α → β), motive f [])
|
||
(case2 : ∀ {α : Type u} {β : Type v} (f : α → β) (a : α) (as : List α), motive f (a :: as)) {α : Type u} {β : Type v}
|
||
(f : α → β) (x✝ : List α) : motive f x✝
|
||
-/
|
||
#guard_msgs in
|
||
#check List.map.fun_cases
|
||
|
||
/--
|
||
info: List.find?.fun_cases.{u} (motive : {α : Type u} → (α → Bool) → List α → Prop)
|
||
(case1 : ∀ {α : Type u} (p : α → Bool), motive p [])
|
||
(case2 : ∀ {α : Type u} (p : α → Bool) (a : α) (as : List α), p a = true → motive p (a :: as))
|
||
(case3 : ∀ {α : Type u} (p : α → Bool) (a : α) (as : List α), p a = false → motive p (a :: as)) {α : Type u}
|
||
(p : α → Bool) (x✝ : List α) : motive p x✝
|
||
-/
|
||
#guard_msgs in
|
||
#check List.find?.fun_cases
|