You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
syntax "my_trans" term : tactic
macro_rules
| `(tactic| my_trans $e) => `(tactic| with_reducible apply Nat.lt_trans (m := $e))
macro_rules
| `(tactic| my_trans $e) => `(tactic| with_reducible apply Nat.le_trans (m := $e))
variable (a b c : Nat)
example (h0 : a < b) (h1 : b < c) : a < c := by
my_trans b <;> assumption
example (h0 : a ≤ b) (h1 : b ≤ c) : a ≤ c := by
my_trans b <;> assumption
The text was updated successfully, but these errors were encountered:
An ugly but important detail of Lean 4 metaprogramming is that any given expression does not have a single normal form. Rather, it has a normal form up to a given transparency.
A transparency is a value of Lean.Meta.TransparencyMode, an enumeration with four values: reducible, instances, default and all. Any MetaM computation has access to an ambient TransparencyMode which can be obtained with Lean.Meta.getTransparency.
The current transparency determines which constants get unfolded during normalisation, e.g. by reduce. (To unfold a constant means to replace it with its definition.) The four settings unfold progressively more constants:
macro_rules でタクティクを定義しようとして失敗する例
Zulip: https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/.60apply.20Nat.2Ele_trans.60.20succeed.20for.20.60a.20.3C.20c.60.20unexpectedly
以下の例は
with_reducible
がないと失敗するThe text was updated successfully, but these errors were encountered: