A lens for zoming into nested expr
applications
A "lens" for looking into the subterms of an expression, tracking where we've been, so that
when we "zoom out" after making a change we know exactly which order of congr_fun
s and
congr_arg
s we need to make things work.
This file defines the expr_lens
inductive type, defines basic operations this type, and defines a
useful map-like function expr.app_map
on expr
s which maps over applications.
This file is for non-tactics.
Tags
expr, expr_lens, congr, environment, meta, metaprogramming, tactic
Declarations about expr_lens
You're supposed to think of an expr_lens
as a big set of nested applications with a single
hole which needs to be filled, either in a function spot or argument spot. expr_lens.fill
can
fill this hole and turn your lens back into a real expr
.
- F : expr_lens.dir
- A : expr_lens.dir
Inductive type with two constructors F
and A
,
that represent the function-part f
and arg-part a
of an application f a
. They specify the
directions in which an expr_lens
should zoom into an expr
.
This type is used in the development of rewriting tactics such as
nth_rewrite
, and rewrite_search
(not currently in mathlib).
String representation of dir
.
Equations
- expr_lens.dir.A.to_string = "A"
- expr_lens.dir.F.to_string = "F"
Equations
Convert an expr_lens
into a list of instructions needed to build it; repeatedly inspecting a
function or its argument a finite number of times.
app_map F e
maps a function F
which understands expr_lens
es over the given e : expr
in the natural way;
that is, make holes in e
everywhere where that is possible (generating expr_lens
es in the
process), and at each stage call the function F
passing both the expr_lens
generated and the
expr
which was removed to make the hole.
At each stage F
returns a list of some type, and app_map
collects these lists together and
returns a concatenation of them all.