Zulip Chat Archive

Stream: general

Topic: curly begin end blocks


Mario Carneiro (Jun 09 2021 at 01:31):

Here's a lean grammar fact I just learned while reading the code: { tacs } can be used to start a tactic block without by or begin after have and show:

example := show 1 + 1 = 2, { exact rfl }
example := have 1 + 1 = 2, { exact rfl }, trivial

Gihan Marasingha (Jun 11 2021 at 00:02):

Awesome! I'll never use begin again.

import data.vector

def myseq : Π (k : ), vector  k  vector  (k+1) :=
show Π (k : ), vector  k  vector  (k+1),
{ intro k,
  refine nat.rec_on k _ _,
  { intro am, exact ⟨[1], rfl⟩, },
  { intros m h am,
    refine nat.rec_on m _ _,
    { exact ⟨[1, 1], rfl },
    { intros c ac, exact vector.cons (ac.head + ac.tail.head) ac }, }, }

Last updated: Dec 20 2023 at 11:08 UTC