Edges of a word #
An Edge is an end of a word, left for its beginning and right for its end. The same two
values name a scan by the end it starts from, and a side of a position by the end it faces. This
file gives the length-k part of a word at an edge, the positions within a distance of a target
on one side, and the reverse conjugation that exchanges the two edges on string functions.
Main definitions #
Edge,Edge.swap: the left or right end of a word, and the other one.Edge.takeAt: the length-kprefix or suffix of a word.Edge.window: the positions not far from a target on one side.List.revConj: conjugation of a string function by reversal.
An Edge is an end of a word, left for its beginning and right for its end. A scan is
named by the edge it starts from, so the left scan reads a word from its beginning and the
right scan from its end. The two scans give function classes that are mirror images under
reversal but differ as classes of functions on unreversed strings.
Instances For
Equations
- instDecidableEqEdge x✝ y✝ = if h : x✝.ctorIdx = y✝.ctorIdx then isTrue ⋯ else isFalse ⋯
Equations
- instReprEdge = { reprPrec := instReprEdge.repr }
Equations
- instReprEdge.repr Edge.left prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Edge.left")).group prec✝
- instReprEdge.repr Edge.right prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Edge.right")).group prec✝
Instances For
Equations
- instFintypeEdge = { elems := { val := ↑Edge.enumList, nodup := Edge.enumList_nodup }, complete := instFintypeEdge._proof_1 }
The other edge.
Equations
Instances For
Edge substrings #
The length-k part of xs at an edge, its prefix List.take at the left and its suffix
List.rtake at the right. A word shorter than k is returned in full.
Equations
- Edge.left.takeAt k xs = List.take k xs
- Edge.right.takeAt k xs = xs.rtake k
Instances For
An edge substring has length min k xs.length.
For a short string the edge substring is the whole string.
Over a finite alphabet there are finitely many edge substrings of a given length.
Windows #
The input positions not d-far from the target i on the side of an edge.
Equations
- Edge.left.window x✝¹ x✝ = Set.Ici (x✝¹ - x✝)
- Edge.right.window x✝¹ x✝ = Set.Iic (x✝¹ + x✝)
Instances For
Reverse conjugation #
Exchanging the two edges acts on string functions by reverse conjugation. The right-scan function
classes are the List.revConj-images of the left-scan ones, so their theory transports along the
involution.
Conjugation by List.reverse computes on the reversed input and reverses the result.
Equations
- List.revConj f xs = (f xs.reverse).reverse
Instances For
Pulling a language back along a reverse-conjugate reverses the pullback of the reversed language.