Documentation

CslibFrontier.Foundations.Data.List.ColorPath

Chains of matching entry and exit colors #

Identity-colored seams can be removed when joining paths, including empty interiors. For additive colors, the differences along an exact path telescope to its endpoint difference.

theorem List.isChain_remove_identity {β : Type u_1} {left right : List (β × β)} {b : β} (h : IsChain (fun (p q : β × β) => p.2 = q.1) (left ++ (b, b) :: right)) :
IsChain (fun (p q : β × β) => p.2 = q.1) (left ++ right)

Deleting an identity entry preserves a chain of matching entry/exit colors.

theorem List.isChain_colorPairs_append {β : Type u_1} {left right : List (β × β)} {a b c : β} (hl : IsChain (fun (p q : β × β) => p.2 = q.1) ((a, a) :: left ++ [(b, b)])) (hr : IsChain (fun (p q : β × β) => p.2 = q.1) ((b, b) :: right ++ [(c, c)])) :
IsChain (fun (p q : β × β) => p.2 = q.1) ((a, a) :: (left ++ right) ++ [(c, c)])

Concatenate two exact corner-color paths and erase their common identity seam. Either interior word may be empty.

theorem List.isChain_colorPairs_flatMap {β : Type u_1} {α : Type u_2} (outer : List α) (blocks : α → List (β × β)) (entry exit : α → β) {a b : β} (houter : IsChain (fun (p q : β × β) => p.2 = q.1) ((a, a) :: map (fun (s : α) => (entry s, exit s)) outer ++ [(b, b)])) (hblocks : ∀ s ∈ outer, IsChain (fun (p q : β × β) => p.2 = q.1) ((entry s, entry s) :: blocks s ++ [(exit s, exit s)])) :
IsChain (fun (p q : β × β) => p.2 = q.1) ((a, a) :: flatMap blocks outer ++ [(b, b)])

Substitute complete entry/exit paths into a path of matching endpoint pairs. Empty interiors are allowed in any positions, including every substituted block.

theorem List.sum_sub_eq_of_isChain_colorPairs {β : Type u_1} [AddCommGroup β] {word : List (β × β)} {a b : β} (h : IsChain (fun (p q : β × β) => p.2 = q.1) ((a, a) :: word ++ [(b, b)])) :
(map (fun (p : β × β) => p.2 - p.1) word).sum = b - a

Differences along matching entry/exit pairs telescope to the endpoint difference, including a path with no interior pairs.