Parikh images and semilinear sets
DefinitionParikh vector of a word#βfully proved
The Parikh vector of a word: the function counting, for each letter, how many times it occurs in the word.
def parikhVector (w : List T) [DecidableEq T] : T β β :=
fun a => w.count a
Sources
- Parikh, "On context-free languages", Journal of the ACM 13 (1966), 570-581.
DefinitionParikh image of a language#βfully proved
The Parikh image of a language: the set of Parikh vectors of its words.
def parikhImage (L : Language T) [DecidableEq T] : Set (T β β) :=
(fun w => parikhVector w) '' L
def parikhVector (w : List T) [DecidableEq T] : T β β :=
fun a => w.count a
CSLibExt/Computability/Languages/ContextFree/Parikh.lean:54
Sources
- Parikh, "On context-free languages", Journal of the ACM 13 (1966), 570-581.
Uses 1 Β· Used by 3
TheoremParikh vector of the empty word is zero#βfully proved
The Parikh vector of the empty word is zero.
theorem parikhVector_nil [DecidableEq T] : parikhVector ([] : List T) = 0
def parikhVector (w : List T) [DecidableEq T] : T β β :=
fun a => w.count a
CSLibExt/Computability/Languages/ContextFree/Parikh.lean:54
Sources
- Parikh, "On context-free languages", Journal of the ACM 13 (1966), 570-581.
Uses 1
TheoremParikh vectors add over concatenation#βfully proved
Parikh vectors add over concatenation.
theorem parikhVector_append [DecidableEq T] (u v : List T) :
parikhVector (u ++ v) = parikhVector u + parikhVector v
def parikhVector (w : List T) [DecidableEq T] : T β β :=
fun a => w.count a
CSLibExt/Computability/Languages/ContextFree/Parikh.lean:54
Sources
- Parikh, "On context-free languages", Journal of the ACM 13 (1966), 570-581.
Uses 1
TheoremParikh image of a union of languages#βfully proved
The Parikh image of a union is the union of the Parikh images.
theorem parikhImage_union [DecidableEq T] (L M : Language T) :
parikhImage (L + M) = parikhImage L βͺ parikhImage M
def parikhImage (L : Language T) [DecidableEq T] : Set (T β β) :=
(fun w => parikhVector w) '' L
CSLibExt/Computability/Languages/ContextFree/Parikh.lean:61
Sources
- Parikh, "On context-free languages", Journal of the ACM 13 (1966), 570-581.
Uses 2
TheoremParikh image of the empty language is empty#βfully proved
The Parikh image of the empty language is empty.
theorem parikhImage_empty [DecidableEq T] :
parikhImage (0 : Language T) = β
def parikhImage (L : Language T) [DecidableEq T] : Set (T β β) :=
(fun w => parikhVector w) '' L
CSLibExt/Computability/Languages/ContextFree/Parikh.lean:61
Sources
- Parikh, "On context-free languages", Journal of the ACM 13 (1966), 570-581.
Uses 2
TheoremParikh image of a singleton language#βfully proved
The Parikh image of a singleton language is the singleton of the Parikh vector.
theorem parikhImage_singleton [DecidableEq T] (w : List T) :
parikhImage ({w} : Language T) = {parikhVector w}
def parikhImage (L : Language T) [DecidableEq T] : Set (T β β) :=
(fun w => parikhVector w) '' L
CSLibExt/Computability/Languages/ContextFree/Parikh.lean:61
def parikhVector (w : List T) [DecidableEq T] : T β β :=
fun a => w.count a
CSLibExt/Computability/Languages/ContextFree/Parikh.lean:54
Sources
- Parikh, "On context-free languages", Journal of the ACM 13 (1966), 570-581.
Uses 2
DefinitionLinear combination of period vectors#βfully proved
The linear combination of a list of period vectors with a
coefficient list c: pair the two lists position by position and
sum the scaled periods, and reject mismatched lengths by
returning 0 (the length guard is checked up front, before the
recursion, so a shorter coefficient list cannot silently truncate
and a longer one cannot silently drop coefficients). Coefficients
are indexed by position in P, not by period value, so duplicate
periods get independent coefficients: for P = [p, p],
linComb P [1, 0] = p, not 2 β’ p.
def linComb (P : List (T β β)) (c : List β) : T β β :=
if P.length = c.length then linCombAux P c else 0
where
/-- The unguarded recursion behind `linComb`: pair the two lists
position by position. Used only behind the length guard in
`linComb`, so the two lists have equal length here. -/
linCombAux : List (T β β) β List β β T β β
| [], _ => 0
| _, [] => 0
| p :: P, n :: c => n β’ p + linCombAux P c
Sources
- Parikh, "On context-free languages", Journal of the ACM 13 (1966), 570-581.
TheoremUnguarded linear combination agrees on equal lengths#βfully proved
The unguarded recursion agrees with linComb on equal-length
inputs.
theorem linComb_eq_aux_of_length_eq {P : List (T β β)} {c : List β}
(h : P.length = c.length) : linComb P c = linComb.linCombAux P c
def linComb (P : List (T β β)) (c : List β) : T β β :=
if P.length = c.length then linCombAux P c else 0
where
/-- The unguarded recursion behind `linComb`: pair the two lists
position by position. Used only behind the length guard in
`linComb`, so the two lists have equal length here. -/
linCombAux : List (T β β) β List β β T β β
| [], _ => 0
| _, [] => 0
| p :: P, n :: c => n β’ p + linCombAux P c
CSLibExt/Computability/Languages/ContextFree/Parikh.lean:126
Sources
- Parikh, "On context-free languages", Journal of the ACM 13 (1966), 570-581.
Uses 1 Β· Used by 1
TheoremLinear combination with too few coefficients is zero#βfully proved
Mismatched lengths are rejected: a shorter coefficient list does not silently truncate.
theorem linComb_eq_zero_of_length_lt {P : List (T β β)} {c : List β}
(h : c.length < P.length) : linComb P c = 0
def linComb (P : List (T β β)) (c : List β) : T β β :=
if P.length = c.length then linCombAux P c else 0
where
/-- The unguarded recursion behind `linComb`: pair the two lists
position by position. Used only behind the length guard in
`linComb`, so the two lists have equal length here. -/
linCombAux : List (T β β) β List β β T β β
| [], _ => 0
| _, [] => 0
| p :: P, n :: c => n β’ p + linCombAux P c
CSLibExt/Computability/Languages/ContextFree/Parikh.lean:126
Sources
- Parikh, "On context-free languages", Journal of the ACM 13 (1966), 570-581.
Uses 1
TheoremLinear combination with too many coefficients is zero#βfully proved
Mismatched lengths are rejected: a longer coefficient list does not silently drop coefficients.
theorem linComb_eq_zero_of_length_gt {P : List (T β β)} {c : List β}
(h : P.length < c.length) : linComb P c = 0
def linComb (P : List (T β β)) (c : List β) : T β β :=
if P.length = c.length then linCombAux P c else 0
where
/-- The unguarded recursion behind `linComb`: pair the two lists
position by position. Used only behind the length guard in
`linComb`, so the two lists have equal length here. -/
linCombAux : List (T β β) β List β β T β β
| [], _ => 0
| _, [] => 0
| p :: P, n :: c => n β’ p + linCombAux P c
CSLibExt/Computability/Languages/ContextFree/Parikh.lean:126
Sources
- Parikh, "On context-free languages", Journal of the ACM 13 (1966), 570-581.
Uses 1
TheoremDuplicate periods get independent coefficients#βfully proved
Duplicate periods get independent coefficients: with
P = [p, p], the coefficients (1, 0) give p.
theorem linComb_dup (p : T β β) : linComb [p, p] [1, 0] = p
def linComb (P : List (T β β)) (c : List β) : T β β :=
if P.length = c.length then linCombAux P c else 0
where
/-- The unguarded recursion behind `linComb`: pair the two lists
position by position. Used only behind the length guard in
`linComb`, so the two lists have equal length here. -/
linCombAux : List (T β β) β List β β T β β
| [], _ => 0
| _, [] => 0
| p :: P, n :: c => n β’ p + linCombAux P c
CSLibExt/Computability/Languages/ContextFree/Parikh.lean:126
Sources
- Parikh, "On context-free languages", Journal of the ACM 13 (1966), 570-581.
Uses 2
DefinitionLinear set of vectors#βfully proved
A set of vectors is linear when it consists of a base vector plus arbitrary nonnegative combinations of finitely many period vectors, with one coefficient per position in the period list.
def IsLinear (S : Set (T β β)) : Prop :=
β (b : T β β) (P : List (T β β)),
S = {v | β c : List β, c.length = P.length β§ v = b + linComb P c}
def linComb (P : List (T β β)) (c : List β) : T β β :=
if P.length = c.length then linCombAux P c else 0
where
/-- The unguarded recursion behind `linComb`: pair the two lists
position by position. Used only behind the length guard in
`linComb`, so the two lists have equal length here. -/
linCombAux : List (T β β) β List β β T β β
| [], _ => 0
| _, [] => 0
| p :: P, n :: c => n β’ p + linCombAux P c
CSLibExt/Computability/Languages/ContextFree/Parikh.lean:126
Sources
- Parikh, "On context-free languages", Journal of the ACM 13 (1966), 570-581.
Uses 1 Β· Used by 5
DefinitionSemilinear set of vectors#βfully proved
A set of vectors is semilinear when it is a finite union of linear sets.
def IsSemilinear (S : Set (T β β)) : Prop :=
β (F : Finset (Set (T β β))), (β S' β F, IsLinear S') β§ ββ F = S
def IsLinear (S : Set (T β β)) : Prop :=
β (b : T β β) (P : List (T β β)),
S = {v | β c : List β, c.length = P.length β§ v = b + linComb P c}
CSLibExt/Computability/Languages/ContextFree/Parikh.lean:179
Sources
- Parikh, "On context-free languages", Journal of the ACM 13 (1966), 570-581.
Uses 1 Β· Used by 4
TheoremA singleton set of vectors is linear#βfully proved
A singleton set of vectors is linear, with no periods.
theorem isLinear_singleton (b : T β β) : IsLinear ({b} : Set (T β β))
def IsLinear (S : Set (T β β)) : Prop :=
β (b : T β β) (P : List (T β β)),
S = {v | β c : List β, c.length = P.length β§ v = b + linComb P c}
CSLibExt/Computability/Languages/ContextFree/Parikh.lean:179
Sources
- Parikh, "On context-free languages", Journal of the ACM 13 (1966), 570-581.
Uses 2 Β· Used by 1
TheoremLinear sets are semilinear#βfully proved
Linear sets are semilinear.
theorem IsLinear.isSemilinear {S : Set (T β β)} (hS : IsLinear S) :
IsSemilinear S
def IsLinear (S : Set (T β β)) : Prop :=
β (b : T β β) (P : List (T β β)),
S = {v | β c : List β, c.length = P.length β§ v = b + linComb P c}
CSLibExt/Computability/Languages/ContextFree/Parikh.lean:179
def IsSemilinear (S : Set (T β β)) : Prop :=
β (F : Finset (Set (T β β))), (β S' β F, IsLinear S') β§ ββ F = S
CSLibExt/Computability/Languages/ContextFree/Parikh.lean:187
Sources
- Parikh, "On context-free languages", Journal of the ACM 13 (1966), 570-581.
Uses 2 Β· Used by 1
TheoremThe empty set is semilinear#βfully proved
The empty set of vectors is semilinear.
theorem isSemilinear_empty : IsSemilinear (β
: Set (T β β))
def IsSemilinear (S : Set (T β β)) : Prop :=
β (F : Finset (Set (T β β))), (β S' β F, IsLinear S') β§ ββ F = S
CSLibExt/Computability/Languages/ContextFree/Parikh.lean:187
Sources
- Parikh, "On context-free languages", Journal of the ACM 13 (1966), 570-581.
Uses 2
TheoremA singleton set of vectors is semilinear#βfully proved
A singleton set of vectors is semilinear.
theorem isSemilinear_singleton (b : T β β) :
IsSemilinear ({b} : Set (T β β))
def IsSemilinear (S : Set (T β β)) : Prop :=
β (F : Finset (Set (T β β))), (β S' β F, IsLinear S') β§ ββ F = S
CSLibExt/Computability/Languages/ContextFree/Parikh.lean:187
Sources
- Parikh, "On context-free languages", Journal of the ACM 13 (1966), 570-581.
Uses 3
TheoremSemilinear sets are closed under union#βfully proved
Semilinear sets are closed under union.
theorem IsSemilinear.union {S S' : Set (T β β)}
(hS : IsSemilinear S) (hS' : IsSemilinear S') :
IsSemilinear (S βͺ S')
def IsSemilinear (S : Set (T β β)) : Prop :=
β (F : Finset (Set (T β β))), (β S' β F, IsLinear S') β§ ββ F = S
CSLibExt/Computability/Languages/ContextFree/Parikh.lean:187
Sources
- Parikh, "On context-free languages", Journal of the ACM 13 (1966), 570-581.
Uses 2
Loading dependency explorerβ¦
The dependency explorer needs JavaScript and its graph data.