lean4-htt/tests/lean/run/discrTreeKey.lean
Eric Wieser 9338aabed9
fix: move the monad argument for ForIn, ForIn', and ForM (#10204)
This PR changes the interface of the `ForIn`, `ForIn'`, and `ForM`
typeclasses to not take a `Monad m` parameter. This is a breaking change
for most downstream `instance`s, which will will now need to assume
`[Monad m]`.

The rationale is that if the provider of an instance requires `m` to be
a Monad, they should assume this up front. This makes it possible for
the instanve to assume `LawfulMonad m` or some other stronger
requirement, and also to provided a concrete instance for a particular
`m` without assuming a non-canonical `Monad` structure on it.

Zulip: [#lean4 > Monad assumptions in fields of other typeclasses @
💬](https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/Monad.20assumptions.20in.20fields.20of.20other.20typeclasses/near/537102158)
2025-11-25 12:20:37 +00:00

93 lines
2 KiB
Text

import Init.Data.Nat.Basic
import Init.Data.List.Lemmas
/-!
This file provides examples of use of the commands #discr_tree_key and #discr_tree_simp_key
and guards against any breakage of the commands.
-/
universe u
open Nat List
/-!
We can produce `simp` keys for theorems of the form `=`, `↔`, `¬`, and `≠` by supplying the name
of the declaration.
-/
#check Nat.mul_one
/-- info: @HMul.hMul Nat Nat Nat _ _ 1 -/
#guard_msgs in
#discr_tree_simp_key Nat.mul_one
#check Nat.not_le
/-- info: Not (@LE.le Nat _ _ _) -/
#guard_msgs in
#discr_tree_simp_key Nat.not_le
#check and_not_self
/-- info: And _ (Not _) -/
#guard_msgs in
#discr_tree_simp_key and_not_self
#check Nat.add_one_ne_zero
/-- info: @Eq Nat _ 0 -/
#guard_msgs in
#discr_tree_simp_key Nat.add_one_ne_zero
#check zero_le
#discr_tree_simp_key zero_le
#check succ_eq_add_one
#discr_tree_simp_key succ_eq_add_one
#check Nat.pred_succ
#discr_tree_simp_key Nat.pred_succ
#check getElem?_nil
#discr_tree_simp_key getElem?_nil
#check or_cons
#discr_tree_simp_key or_cons
#check not_mem_nil
#discr_tree_simp_key not_mem_nil
#check mem_cons
#discr_tree_simp_key mem_cons
#check singleton_append
#discr_tree_simp_key singleton_append
#check append_nil
#discr_tree_simp_key append_eq_nil_iff
#check mapM_nil
#discr_tree_simp_key mapM_nil
/-!
We can produce keys for a general declarations by name using the default configuration
for generating keys.
-/
#check Nat.instIdempotentOpGcd
#discr_tree_key Nat.instIdempotentOpGcd
#check List.instDecidableMemOfLawfulBEq
#discr_tree_key List.instDecidableMemOfLawfulBEq
#check List.instForIn'InferInstanceMembershipOfMonad
#discr_tree_key List.instForIn'InferInstanceMembershipOfMonad
/-!
We can also specify a term directly.
-/
def bar (_ _ : Nat) : Nat := default
#discr_tree_key (∀ {a n : Nat}, bar a (OfNat.ofNat n) = default)
#discr_tree_simp_key (∀ {a n : Nat}, bar a (no_index (OfNat.ofNat n)) = default)
#discr_tree_simp_key (∀ m : Nat, ∃ n : Nat, m ≠ n)
#discr_tree_simp_key (∀ m : Nat, m > 0 → m ≠ 0)