@@ -10,6 +10,7 @@ public import Init.Classical
1010public import Init.Ext
1111
1212set_option doc.verso true
13+ set_option linter.missingDocs true
1314
1415public section
1516
@@ -352,7 +353,18 @@ In order to allow intrinsic termination proofs when iterating with the `step` fu
352353step object is bundled with a proof that it is a "plausible" step for the given current iterator.
353354-/
354355class Iterator (α : Type w) (m : Type w → Type w') (β : outParam (Type w)) where
356+ /--
357+ The plausibility relation restricts the steps that are allowed from an iterator.
358+
359+ Plausibility relates an iterator to potential steps. Because steps include successor iterators, it
360+ also relates an iterator to its potential successor iterators. This allows the set of potential
361+ steps to be narrowed drastically, which can make many proofs possible.
362+ -/
355363 IsPlausibleStep : IterM (α := α) m β → IterStep (IterM (α := α) m β) β → Prop
364+ /--
365+ Takes a single step of iteration, which either yields a value, skips a step, or terminates
366+ iteration.
367+ -/
356368 step : (it : IterM (α := α) m β) → m (Shrink <| PlausibleIterStep <| IsPlausibleStep it)
357369
358370section Monadic
@@ -449,8 +461,10 @@ number of steps.
449461-/
450462inductive IterM.IsPlausibleIndirectOutput {α β : Type w} {m : Type w → Type w'} [Iterator α m β]
451463 : IterM (α := α) m β → β → Prop where
464+ /-- The output is plausible in the next step of iteration. -/
452465 | direct {it : IterM (α := α) m β} {out : β} : it.IsPlausibleOutput out →
453466 it.IsPlausibleIndirectOutput out
467+ /-- The output is plausible in some future step of iteration. -/
454468 | indirect {it it' : IterM (α := α) m β} {out : β} : it'.IsPlausibleSuccessorOf it →
455469 it'.IsPlausibleIndirectOutput out → it.IsPlausibleIndirectOutput out
456470
@@ -460,7 +474,12 @@ finitely many steps. This relation is reflexive.
460474-/
461475inductive IterM.IsPlausibleIndirectSuccessorOf {α β : Type w} {m : Type w → Type w'}
462476 [Iterator α m β] : IterM (α := α) m β → IterM (α := α) m β → Prop where
477+ /-- Every step is a plausible indirect successor of itself. -/
463478 | refl (it : IterM (α := α) m β) : it.IsPlausibleIndirectSuccessorOf it
479+ /--
480+ Every plausible indirect successor of a plausible successor is itself a plausible indirect
481+ successor.
482+ -/
464483 | cons_right {it'' it' it : IterM (α := α) m β} (h' : it''.IsPlausibleIndirectSuccessorOf it')
465484 (h : it'.IsPlausibleSuccessorOf it) : it''.IsPlausibleIndirectSuccessorOf it
466485
@@ -585,8 +604,10 @@ number of steps.
585604-/
586605inductive Iter.IsPlausibleIndirectOutput {α β : Type w} [Iterator α Id β] :
587606 Iter (α := α) β → β → Prop where
607+ /-- The output is plausible in the next step of iteration. -/
588608 | direct {it : Iter (α := α) β} {out : β} : it.IsPlausibleOutput out →
589609 it.IsPlausibleIndirectOutput out
610+ /-- The output is plausible in some future step of iteration. -/
590611 | indirect {it it' : Iter (α := α) β} {out : β} : it'.IsPlausibleSuccessorOf it →
591612 it'.IsPlausibleIndirectOutput out → it.IsPlausibleIndirectOutput out
592613
@@ -617,7 +638,12 @@ finitely many steps. This relation is reflexive.
617638-/
618639inductive Iter.IsPlausibleIndirectSuccessorOf {α : Type w} {β : Type w} [Iterator α Id β] :
619640 Iter (α := α) β → Iter (α := α) β → Prop where
641+ /-- Every step is a plausible indirect successor of itself. -/
620642 | refl (it : Iter (α := α) β) : IsPlausibleIndirectSuccessorOf it it
643+ /--
644+ Every plausible indirect successor of a plausible successor is itself a plausible indirect
645+ successor.
646+ -/
621647 | cons_right {it'' it' it : Iter (α := α) β} (h' : it''.IsPlausibleIndirectSuccessorOf it')
622648 (h : it'.IsPlausibleSuccessorOf it) : it''.IsPlausibleIndirectSuccessorOf it
623649
@@ -691,6 +717,7 @@ recursion over finite iterators. See also `IterM.finitelyManySteps` and `Iter.fi
691717-/
692718structure IterM.TerminationMeasures.Finite
693719 (α : Type w) (m : Type w → Type w') {β : Type w} [Iterator α m β] where
720+ /-- The wrapped finite iterator that will be used as a termination measure. -/
694721 it : IterM (α := α) m β
695722
696723/--
@@ -816,6 +843,7 @@ recursion over productive iterators. See also `IterM.finitelyManySkips` and `Ite
816843-/
817844structure IterM.TerminationMeasures.Productive
818845 (α : Type w) (m : Type w → Type w') {β : Type w} [Iterator α m β] where
846+ /-- The wrapped productive iterator that will be used as a termination measure. -/
819847 it : IterM (α := α) m β
820848
821849/--
@@ -917,6 +945,7 @@ library.
917945-/
918946class LawfulDeterministicIterator (α : Type w) (m : Type w → Type w') [Iterator α m β]
919947 where
948+ /-- Every iterator state has a unique plausible successor. -/
920949 isPlausibleStep_eq_eq : ∀ it : IterM (α := α) m β, ∃ step, it.IsPlausibleStep = (· = step)
921950
922951end Iterators
0 commit comments