lean4-htt/tests/elab/injective.lean
Garmelon 08eb78a5b2
chore: switch to new test/bench suite (#12590)
This PR sets up the new integrated test/bench suite. It then migrates
all benchmarks and some related tests to the new suite. There's also
some documentation and some linting.

For now, a lot of the old tests are left alone so this PR doesn't become
even larger than it already is. Eventually, all tests should be migrated
to the new suite though so there isn't a confusing mix of two systems.
2026-02-25 13:51:53 +00:00

39 lines
844 B
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

universe u v
structure InjectiveFunction (α : Type u) (β : Type v) where
fn : α → β
inj : ∀ a b, fn a = fn b → a = b
def add1 : InjectiveFunction Nat Nat where
fn a := a + 1
inj a b h := by injection h
instance : CoeFun (InjectiveFunction α β) (fun _ => α → β) where
coe s := s.fn
#guard add1 10 == 11
def mapAdd1 (xs : List Nat) : List Nat :=
xs.map add1
#guard mapAdd1 [1, 2] = [2, 3]
def foo : InjectiveFunction Bool (Nat → Nat) where
fn
| true, a => a + 1
| false, a => a
inj a b h := by
cases a
cases b; rfl; injection (congrFun h 0)
cases b; injection (congrFun h 0); rfl
theorem ex1 (x : Nat) : foo true x = x + 1 :=
rfl
theorem ex2 (x : Nat) : foo false x = x :=
rfl
#guard foo true 10 == 11
#guard foo false 20 == 20
#guard [1, 2, 3].map (foo true) = [2, 3, 4]