lean4-htt/tests/lean/run/grind_diseq_api.lean
Sebastian Ullrich 719765ec5c
feat: overhaul meta system (#10362)
This PR refines and clarifies the `meta` phase distinction in the module
system.

* `meta import A` without `public` now has the clarified meaning of
"enable compile-time evaluation of declarations in or above `A` in the
current module, but not downstream". This is now checked statically by
enforcing that public meta defs, which therefore may be referenced from
outside, can only use public meta imports, and that global evaluating
attributes such as `@[term_parser]` can only be applied to public meta
defs.
* `meta def`s may no longer reference non-meta defs even when in the
same module. This clarifies the meta distinction as well as improves
locality of (new) error messages.
* parser references in `syntax` are now also properly tracked as meta
references.
* A `meta import` of an `import` now properly loads only the `.ir` of
the nested module for the purposes of execution instead of also making
its declarations available for general elaboration.
* `initialize` is now no longer being run on import under the module
system, which is now covered by `meta initialize`.
2025-09-17 21:04:29 +00:00

81 lines
2.5 KiB
Text

module
meta import Lean
opaque a : Nat
opaque b : Nat
-- Prints the equivalence class containing a `f` application
open Lean Meta Grind in
meta def fallback : Fallback := do
let a ← shareCommon <| mkConst ``a
let b ← shareCommon <| mkConst ``b
let some h ← mkDiseqProof? a b |
throwError "terms are not diseq"
check h
trace[Meta.debug] "{h} : {← inferType h}"
assert! (← isDiseq a b)
assert! (← isDiseq b a)
let some h' ← mkDiseqProof? b a |
throwError "terms are not diseq"
let h' ← mkAppM ``Ne.symm #[h']
assert! (← isDefEq h h')
(← get).mvarId.admit
set_option trace.Meta.debug true
/--
trace: [Meta.debug] Lean.Grind.ne_of_ne_of_eq_right h_2 (Lean.Grind.ne_of_ne_of_eq_left h (Ne.symm h_1)) : a ≠ b
-/
#guard_msgs (trace) in
example (x y : Nat) : a = x → y ≠ x → b = y → False := by
grind on_failure fallback
/--
trace: [Meta.debug] Lean.Grind.ne_of_ne_of_eq_right h_2 (Lean.Grind.ne_of_ne_of_eq_left h h_1) : a ≠ b
-/
#guard_msgs (trace) in
example (x y : Nat) : a = x → x ≠ y → b = y → False := by
grind on_failure fallback
/--
trace: [Meta.debug] Lean.Grind.ne_of_ne_of_eq_right h_3 (Lean.Grind.ne_of_ne_of_eq_left (Eq.trans h (Eq.symm h_1)) h_2) : a ≠ b
-/
#guard_msgs (trace) in
example (x y z : Nat) : a = x → z = x → z ≠ y → b = y → False := by
grind on_failure fallback
/-- trace: [Meta.debug] Lean.Grind.ne_of_ne_of_eq_left h (Ne.symm h_1) : a ≠ b -/
#guard_msgs (trace) in
example (x : Nat) : a = x → b ≠ x → False := by
grind on_failure fallback
/-- trace: [Meta.debug] Lean.Grind.ne_of_ne_of_eq_left h h_1 : a ≠ b -/
#guard_msgs (trace) in
example (x : Nat) : a = x → x ≠ b → False := by
grind on_failure fallback
/-- trace: [Meta.debug] Lean.Grind.ne_of_ne_of_eq_right h h_1 : a ≠ b -/
#guard_msgs (trace) in
example (x : Nat) : b = x → a ≠ x → False := by
grind on_failure fallback
/-- trace: [Meta.debug] Lean.Grind.ne_of_ne_of_eq_right h (Ne.symm h_1) : a ≠ b -/
#guard_msgs (trace) in
example (x : Nat) : b = x → x ≠ a → False := by
grind on_failure fallback
/-- trace: [Meta.debug] Lean.Grind.ne_of_ne_of_eq_left h (Ne.symm h_1) : a ≠ b -/
#guard_msgs (trace) in
example (x : Nat) : a = x → b ≠ x → False := by
grind on_failure fallback
/-- trace: [Meta.debug] h : ¬a = b -/
#guard_msgs (trace) in
example : a ≠ b → False := by
grind on_failure fallback
/-- trace: [Meta.debug] Ne.symm h : a ≠ b -/
#guard_msgs (trace) in
example : b ≠ a → False := by
grind on_failure fallback