A tactic for normalizing casts inside expressions #
This tactic normalizes casts inside expressions. It can be thought of as a call to the simplifier with a specific set of lemmas to move casts upwards in the expression. It has special handling of numerals and a simple heuristic to help moving casts "past" binary operators. Contrary to simp, it should be safe to use as a non-terminating tactic.
The algorithm implemented here is described in the paper https://lean-forward.github.io/norm_cast/norm_cast.pdf.
Important definitions #
- elim : norm_cast.label
- move : norm_cast.label
- squash : norm_cast.label
label
is a type used to classify norm_cast
lemmas.
- elim lemma: LHS has 0 head coes and ≥ 1 internal coe
- move lemma: LHS has 1 head coe and 0 internal coes, RHS has 0 head coes and ≥ 1 internal coes
- squash lemma: LHS has ≥ 1 head coes and 0 internal coes, RHS has fewer head coes
@[protected]
Convert label
into string
.
Equations
- norm_cast.label.squash.to_string = "squash"
- norm_cast.label.move.to_string = "move"
- norm_cast.label.elim.to_string = "elim"
@[protected, instance]
Equations
@[protected, instance]
Equations
Convert string
into label
.
Equations
The following auxiliary functions are used to handle numerals.