Zulip Chat Archive

Stream: general

Topic: Transparent definition and rw


Patrick Johnson (Apr 05 2022 at 20:20):

Which tags have to be added to T.len and T.push such that the example proof works without simp_rw [T.len]? In other words, how to introduce a definition that can be automatically unfolded by rw?

import tactic

structure T :=
(s : list )

@[reducible, inline]
def T.len (t : T) :  := t.s.length

@[reducible, inline]
def T.push (t : T) (n : ) : T := t.s ++ [n]⟩

lemma length_push {α : Type*} {xs : list α} {x : α} :
  (xs ++ [x]).length = xs.length + 1 :=
list.length_append _ _

example {t : T} : t.len < (t.push 0).len :=
begin
  -- simp_rw [T.len],
  rw length_push,
  apply lt_add_one,
end

Kevin Buzzard (Apr 05 2022 at 20:34):

Does abbreviation work?

Patrick Johnson (Apr 05 2022 at 20:37):

No. With abbreviations, we still have to change list.length _ < list.length _ before rw.

Eric Wieser (Apr 05 2022 at 20:42):

abbreviation doesn't generate equation lemmas


Last updated: Dec 20 2023 at 11:08 UTC