Skip to content

Commit 83c2127

Browse files
committed
Add productiveness relation for the ordinary zipper
1 parent e14d54c commit 83c2127

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/Std/Data/DTreeMap/Internal/Slice.lean

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ theorem Zipper.prependMap_size (t : Impl α β) (it : Zipper α β) : (Zipper.pr
213213
case case2 size k v l r it ih =>
214214
simp only [ih, Zipper.size, Impl.treeSize, ← Nat.add_assoc, Nat.add_comm]
215215

216-
217216
public def Zipper.step : Zipper α β → IterStep (IterM (α := Zipper α β) Id ((a : α) × β a)) ((a : α) × β a)
218217
| .done => .done
219218
| .cons k v t it=>
@@ -364,6 +363,23 @@ decreasing_by
364363
simp only [Zipper.prependMap_size, Impl.treeSize, Nat.add_lt_add_iff_right, Nat.lt_add_left_iff_pos,
365364
Nat.lt_add_one]
366365

366+
def Zipper.instProductivenessRelation : ProductivenessRelation (Zipper α β) Id where
367+
rel x x' := x.1.size < x'.1.size
368+
wf := by
369+
apply InvImage.wf
370+
exact Nat.lt_wfRel.wf
371+
subrelation {it it'} h := by
372+
simp [IterM.IsPlausibleSkipSuccessorOf, IterM.IsPlausibleStep, Iterator.IsPlausibleStep] at h
373+
have := @Zipper.step_eq_match α β ⟨it.1
374+
simp [IterM.step, Iterator.step] at this
375+
injections val_eq
376+
rw [h] at val_eq
377+
split at val_eq <;> contradiction
378+
379+
@[no_expose]
380+
public instance instProductive : Productive (Zipper α β) Id :=
381+
.of_productivenessRelation Zipper.instProductivenessRelation
382+
367383
public theorem Zipper.val_step_map_Zipper_eq_match {α β γ} {f : (a : α) × β a → γ}
368384
{it : Iter (α := Zipper α β) (Sigma β)} :
369385
(it.map f).step.val =

0 commit comments

Comments
 (0)