Zulip Chat Archive

Stream: general

Topic: avoid writing (some?) simp-rfl lemmas


Johan Commelin (Nov 27 2018 at 08:09):

I've brought this up before, but I'dd really hope that there is a way to get rid of blocks like this:

section simp

section
variables {X Y : comma L₂ R} {f : X  Y} {l : L₁  L₂}
@[simp] lemma map_left_obj_left  : ((map_left R l).obj X).left  = X.left                := rfl
@[simp] lemma map_left_obj_right : ((map_left R l).obj X).right = X.right               := rfl
@[simp] lemma map_left_obj_hom   : ((map_left R l).obj X).hom   = l.app X.left  X.hom := rfl
@[simp] lemma map_left_map_left  : ((map_left R l).map f).left  = f.left                := rfl
@[simp] lemma map_left_map_right : ((map_left R l).map f).right = f.right               := rfl
end

section
variables {X Y : comma L R₁} {f : X  Y} {r : R₁  R₂}
@[simp] lemma map_right_obj_left  : ((map_right L r).obj X).left  = X.left                 := rfl
@[simp] lemma map_right_obj_right : ((map_right L r).obj X).right = X.right                := rfl
@[simp] lemma map_right_obj_hom   : ((map_right L r).obj X).hom   = X.hom  r.app X.right := rfl
@[simp] lemma map_right_map_left  : ((map_right L r).map f).left  = f.left                 := rfl
@[simp] lemma map_right_map_right : ((map_right L r).map f).right = f.right                := rfl
end

end simp

Johan Commelin (Nov 27 2018 at 08:10):

You define a new category, and afterwards you have to state pages of trivialities. There must be some structure to this, which we can abuse, so that automation just does this for us. Has there been any thought in this direction?

Reid Barton (Nov 27 2018 at 12:36):

You can put @[simp] on the thing you defined (I guess map_left, map_right)

Johan Commelin (Nov 27 2018 at 12:41):

Is that good practice? I thought it was some how considered evil, because it marked too much as simp?

Mario Carneiro (Nov 27 2018 at 12:43):

it's probably not what you want, because then it will unfold even when it is not being projected

Johan Commelin (Nov 27 2018 at 12:45):

Aha, so I want derive simp-projections

Johan Commelin (Nov 27 2018 at 12:45):

Is that possible?

Mario Carneiro (Nov 27 2018 at 12:49):

in theory

Mario Carneiro (Nov 27 2018 at 12:50):

it gets complicated with nested structures, but you could inspect the definition for a structure instance and extract the parts

Mario Carneiro (Nov 27 2018 at 12:50):

this would basically be the same thing that the equation compiler does

Johan Commelin (Nov 27 2018 at 12:54):

I see. I hope someone with a lot of tactic-fu will pop up and write something like this (-;


Last updated: Dec 20 2023 at 11:08 UTC