The ⊑-driven Param weakening (level navigation) #
ParamLevel.lean supplies the MapClass lattice order ⊑ and the meet. This
module supplies the witness-level counterpart: the function that turns a
synthesized witness at a level into a witness at any lower level the lattice
order permits. This is the mechanism behind "synthesize at the strongest
available level, then use at the minimal level a goal needs" — the downward
(forget) half of the level navigation.
The crux is forgetMapHas: for any m' ⊑ m, a MapHas m R forgets down to a
MapHas m' R, by composing the per-level forgets already proved in
ParamHierarchy.lean (Map4Has.toMap3, Map3Has.toMap2a/toMap2b,
Map2aHas.toMap1/Map2bHas.toMap1, Map1Has.forget). It is a full case
enumeration on the target m' then the source m; the lattice-invalid
pairs are discharged from the hypothesis h : m' ⊑ m, which reduces to
false = true there.
Param.weaken then forgets both directions (forward on fwd, backward on
bwd), giving the lattice's action on annotated relations:
a witness at
(m, n)supplies a witness at every(m', n')withm' ⊑ mandn' ⊑ n.
Navigation and the remaining search #
This completes the lattice navigation: meet (the least common level,
ParamLevel) plus forgetMapHas/Param.weaken (forget down to it). The
remaining piece of the level solver is the upward search — picking which
level to synthesize at, i.e. a MetaM/outParam resolver that reads the
arrowReq/forallReq decision tables (ParamLevel.lean) to choose the
combinator and the minimal feasible level before invoking the synthesizer. That
resolver, resolveParamLevel, is the final step; Param.weaken lets it
synthesize high and land at the lower level a goal uses.
forgetMapHas — forget one direction down the lattice #
Forget down the lattice (one direction). For m' ⊑ m, downgrade a
MapHas m R to a MapHas m' R by composing the per-level forgets from
ParamHierarchy.lean. Full case enumeration on the target m' then the
source m; lattice-invalid pairs (m' ⊑ m is false) are discharged from
h : m' ⊑ m, whose type reduces to false = true.
Equations
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map0 Transfer.Param.MapClass.map0 x_4 x_5 = { }
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map0 Transfer.Param.MapClass.map1 x_4 x_5 = { }
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map0 Transfer.Param.MapClass.map2a x_4 x_5 = { }
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map0 Transfer.Param.MapClass.map2b x_4 x_5 = { }
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map0 Transfer.Param.MapClass.map3 x_4 x_5 = { }
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map0 Transfer.Param.MapClass.map4 x_4 x_5 = { }
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map1 Transfer.Param.MapClass.map0 h x_4 = ⋯.elim
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map1 Transfer.Param.MapClass.map1 x_4 x_5 = x_5
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map1 Transfer.Param.MapClass.map2a x_4 x_5 = Transfer.Param.Map2aHas.toMap1 x_5
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map1 Transfer.Param.MapClass.map2b x_4 x_5 = Transfer.Param.Map2bHas.toMap1 x_5
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map1 Transfer.Param.MapClass.map3 x_4 x_5 = (Transfer.Param.Map3Has.toMap2a x_5).toMap1
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map1 Transfer.Param.MapClass.map4 x_4 x_5 = (Transfer.Param.Map4Has.toMap3 x_5).toMap2a.toMap1
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map2a Transfer.Param.MapClass.map0 h x_4 = ⋯.elim
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map2a Transfer.Param.MapClass.map1 h x_4 = ⋯.elim
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map2a Transfer.Param.MapClass.map2a x_4 x_5 = x_5
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map2a Transfer.Param.MapClass.map2b h x_4 = ⋯.elim
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map2a Transfer.Param.MapClass.map3 x_4 x_5 = Transfer.Param.Map3Has.toMap2a x_5
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map2a Transfer.Param.MapClass.map4 x_4 x_5 = (Transfer.Param.Map4Has.toMap3 x_5).toMap2a
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map2b Transfer.Param.MapClass.map0 h x_4 = ⋯.elim
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map2b Transfer.Param.MapClass.map1 h x_4 = ⋯.elim
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map2b Transfer.Param.MapClass.map2a h x_4 = ⋯.elim
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map2b Transfer.Param.MapClass.map2b x_4 x_5 = x_5
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map2b Transfer.Param.MapClass.map3 x_4 x_5 = Transfer.Param.Map3Has.toMap2b x_5
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map2b Transfer.Param.MapClass.map4 x_4 x_5 = (Transfer.Param.Map4Has.toMap3 x_5).toMap2b
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map3 Transfer.Param.MapClass.map0 h x_4 = ⋯.elim
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map3 Transfer.Param.MapClass.map1 h x_4 = ⋯.elim
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map3 Transfer.Param.MapClass.map2a h x_4 = ⋯.elim
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map3 Transfer.Param.MapClass.map2b h x_4 = ⋯.elim
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map3 Transfer.Param.MapClass.map3 x_4 x_5 = x_5
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map3 Transfer.Param.MapClass.map4 x_4 x_5 = Transfer.Param.Map4Has.toMap3 x_5
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map4 Transfer.Param.MapClass.map0 h x_4 = ⋯.elim
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map4 Transfer.Param.MapClass.map1 h x_4 = ⋯.elim
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map4 Transfer.Param.MapClass.map2a h x_4 = ⋯.elim
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map4 Transfer.Param.MapClass.map2b h x_4 = ⋯.elim
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map4 Transfer.Param.MapClass.map3 h x_4 = ⋯.elim
- Transfer.Param.forgetMapHas Transfer.Param.MapClass.map4 Transfer.Param.MapClass.map4 x_4 x_5 = x_5
Instances For
Param.weaken — the lattice action on annotated relations #
Weaken an annotated relation down the lattice. Given m' ⊑ m and
n' ⊑ n, a Param m n A B forgets to a Param m' n' A B: keep the
relation R, forget the forward witness fwd to level m' and the
backward witness bwd to level n'. This is the "synthesize-high, use-low"
move: the synthesizer may produce at the strongest available level, and
Param.weaken brings it to the minimal level the goal needs.
Equations
- Transfer.Param.Param.weaken hm hn p = { R := p.R, fwd := Transfer.Param.forgetMapHas m' m hm p.fwd, bwd := Transfer.Param.forgetMapHas n' n hn p.bwd }
Instances For
Examples — exercising the weakening on the concrete witnesses #
paramOfEmbedding : Param map3 map0 (graph of an encoder, no decoder) and
paramOfEquiv : Param map3 map2b (left-inverse encoding) are the two concrete
Param constructors in the hierarchy. Every weakening below is a one-liner
Param.weaken (by decide) (by decide) _.
paramOfEmbedding : Param map3 map0 weakens to Param map1 map0
(forward forgets map3 → map1; backward stays map0).
Equations
Instances For
paramOfEmbedding : Param map3 map0 weakens to Param map2a map0
(forward forgets map3 → map2a, the map-with-graph-inclusion).
Equations
Instances For
paramOfEquiv : Param map3 map2b weakens to Param map0 map2b
(forward forgets all the way to map0; backward stays map2b).
Equations
Instances For
paramOfEquiv : Param map3 map2b weakens to Param map1 map0
(forward map3 → map1; backward map2b → map0).
Equations
Instances For
Tie to the minimal-level solver #
The general "synthesize-high, use-low" statement: any witness at (m, n)
supplies one at every lattice-lower target (m', n'). A level resolver thus
synthesizes at the strongest level available and applies Param.weaken to land
at the minimal level a goal requires; the ⊑ premises are decidable
(MapClass.le is Bool-valued), so each landing is a by decide.
Synthesize-high, use-low. Given a witness at (m, n) and any target
(m', n') lattice-below it, Param.weaken supplies the target witness. This
is the downward half of the level solver.