Leonardo de Moura
|
4c9601e60f
|
feat: support for injective functions in grind (#10483)
This PR completes support for injective functions in grind. See
examples:
```lean
/-! Add some injectivity theorems. -/
def double (x : Nat) := 2*x
@[grind inj] theorem double_inj : Function.Injective double := by
grind [Function.Injective, double]
structure InjFn (α : Type) (β : Type) where
f : α → β
h : Function.Injective f
instance : CoeFun (InjFn α β) (fun _ => α → β) where
coe s := s.f
@[grind inj] theorem fn_inj (F : InjFn α β) : Function.Injective (F : α → β) := by
grind [Function.Injective, cases InjFn]
def toList (a : α) : List α := [a]
@[grind inj] theorem toList_inj : Function.Injective (toList : α → List α) := by
grind [Function.Injective, toList]
/-! Examples -/
example (x y : Nat) : toList (double x) = toList (double y) → x = y := by
grind
example (f : InjFn (List Nat) α) (x y z : Nat)
: f (toList (double x)) = f (toList y) →
y = double z →
x = z := by
grind
```
|
2025-09-21 06:31:46 +00:00 |
|