Fold-and-reorder theory for iterated single-pair gluing #
Iterated single-pair gluing over a list of pairs, with a well-formedness predicate (all 2n components pairwise distinct) and a reorder theorem: the result is invariant under permutation of the pair list, up to fragment equivalence composed with the canonical relabelling.
Well-formedness of pair lists #
All 2n components of a list of pairs are pairwise distinct.
Equations
- RS.Fragment.PairsWF ps = (List.flatMap (fun (p : α × α) => [p.1, p.2]) ps).Nodup
Instances For
The flat surviving subtype #
The vacuous surviving equivalence for the empty list.
Equations
- RS.Fragment.foldSurvivingNilEquiv = { toFun := fun (x : RS.Fragment.FoldSurviving α []) => ↑x, invFun := fun (x : α) => ⟨x, ⋯⟩, left_inv := ⋯, right_inv := ⋯ }
Instances For
The surviving-set equivalence induced by a permutation of pairs: the membership condition is ∀-quantified over ∈, so a permutation preserving membership gives an equivalence.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Coercing tail pairs into the surviving-label subtype #
The separation hypothesis for coercing pairs.
Equations
- RS.Fragment.PairsSep i j ps = ∀ q ∈ ps, RS.PairDisjoint q (i, j)
Instances For
Coerce a well-formed tail into pairs of surviving labels.
Equations
Instances For
Length of coercePairsList equals the original list length.
The val-projection of the flattened coerced list equals the original flattened list.
Well-formedness of the coerced pairs.
Each element of coercePairsList comes from an element of ps.
The flattening equivalence #
The canonical equivalence between the nested surviving type (first remove i, j from α to get SurvivingLabel; then remove the coerced tail pairs) and the flat surviving type (remove (i, j) :: ps at once).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The fold: iterated single-pair gluing #
Fold a well-formed pair list using a bound on its length as structural fuel.
Equations
- RS.Fragment.glueListAux x✝² x✝ [] x_8 x_9 = x✝.relabel RS.Fragment.foldSurvivingNilEquiv.symm
- RS.Fragment.glueListAux n.succ x✝ ((i, j) :: ps) h hlen = (RS.Fragment.glueListAux n (x✝.gluePair i j ⋯) (RS.Fragment.coercePairsList i j ps ⋯) ⋯ ⋯).relabel (RS.Fragment.foldFlatten i j ps ⋯)
Instances For
Iterated single-pair gluing along a list of distinct pairs. Glues each pair in order; the result is labelled by the elements of α not appearing in any pair.
Equations
- W.glueList ps h = RS.Fragment.glueListAux ps.length W ps h ⋯
Instances For
Congruence: glueList respects fragment equivalence #
Transport a bounded pair-list fold along an equivalence of input fragments.
Equations
- One or more equations did not get rendered due to their size.
Instances For
glueList respects fragment equivalence: equivalent inputs
produce equivalent outputs.
Equations
- RS.Fragment.glueListCongr he ps h = RS.Fragment.glueListCongrAux ps.length he ps h ⋯
Instances For
Relabelling commutes with the fold #
The canonical equivalence on FoldSurviving induced by a label equivalence.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The surviving-label equivalence induced by a label equiv.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Casting a glueList result along a list equality: relabelling
by the induced foldSurvivingPermEquiv bridges the type change.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Iterated gluing commutes with relabelling: gluing the mapped pairs in the relabelled fragment is the original fold, relabelled by the induced surviving-label equivalence.
Equations
- W.glueListRelabel e ps hp = ⋯.some
Instances For
Concatenation: folding in two stages #
The separation of the second block from the first.
Equations
- RS.Fragment.PairsSepAll ps qs = ∀ q ∈ qs, ∀ p ∈ ps, RS.PairDisjoint q p
Instances For
Pairs avoiding an earlier pair list lift into its surviving labels.
Equations
Instances For
The separation hypothesis of a well-formed concatenation.
The val-projection of the flattened lifted list is the original flattened list.
The lifted second block is well-formed.
Each lifted pair comes from an original pair.
The two-stage surviving labels flatten to the concatenation's surviving labels.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Two-stage folding: gluing a concatenation of pair lists is gluing the first block, then the lifted second block, up to the flattening of survivors.
Equations
- W.glueListAppend ps qs h = ⋯.some
Instances For
Disjoint-union embedding: left #
The surviving-label equivalence for left-embedded pairs: inl-labels survive iff they survive the original list; all inr-labels survive.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Disjoint-union embedding: right #
The surviving-label equivalence for right-embedded pairs: inr-labels survive iff they survive the original list; all inl-labels survive.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Helpers for disjoint-union embedding proofs #
Disjoint-union left: main induction #
Iterated left-side gluing commutes with disjoint
union: gluing the inlPairs-embedded pair list in the
disjoint union is equivalent to gluing W₁ alone and
then taking the disjoint union with W₂, up to the
canonical label isomorphism inlFoldEquiv.
Equations
- W₁.glueListDisjUnionLeft W₂ ps hp = ⋯.some
Instances For
Iterated right-side gluing commutes with disjoint
union: gluing the inrPairs-embedded pair list in the
disjoint union is equivalent to gluing W₂ alone and
then taking the disjoint union with W₁, up to the
canonical label isomorphism inrFoldEquiv.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The swap-components fold lemma #
Gluing a pair list is symmetric in each pair's
components: swapping every (i,j) to (j,i) yields
an equivalent fold, up to the canonical
swapFoldEquiv.
Equations
- W.glueListSwap ps hp = ⋯.some
Instances For
The reorder theorem #
The reorder theorem: gluing along a permuted pair list yields an equivalent fragment (up to the canonical relabelling of survivors).
Equations
- W.glueListPerm hperm hp = ⋯.some