Context-sensitive grammars
DefinitionNonterminal grammar symbols#✓fully proved
Whether a grammar symbol (Mathlib.Computability.Language.Symbol,
shared with the context-free development) is a nonterminal.
StructureUnrestricted grammar#✓fully proved
An unrestricted grammar: a finite list of productions and an initial nonterminal.
structure CSGrammar (T N : Type*) where
/-- The finite list of productions, each a pair of symbol lists. -/
rules : List (List (Symbol T N) × List (Symbol T N))
/-- The initial nonterminal. -/
initial : N
Used by 41
DefinitionOne rewriting step of a grammar#✓fully proved
One rewriting step: apply a production in a sentential form
context. This is the generic Cslib.Decidability.Rewriting.Step at the
grammar's rules, so grammar derivations reuse the string-rewriting API
instead of a second, incompatible copy of it.
def Rewrites {T N : Type*} (g : CSGrammar T N) (u v : List (Symbol T N)) : Prop :=
Cslib.Decidability.Rewriting.Step g.rules u v
structure CSGrammar (T N : Type*) where
/-- The finite list of productions, each a pair of symbol lists. -/
rules : List (List (Symbol T N) × List (Symbol T N))
/-- The initial nonterminal. -/
initial : N
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:54
inductive Step (R : List (Rule α)) : List α → List α → Prop
| mk {l r : List α} (u v : List α) : (l, r) ∈ R → Step R (u ++ l ++ v) (u ++ r ++ v)
CSLibExt/Computability/Decidability/StringRewriting.lean:74
Uses 2 · Used by 1
DefinitionDerivation in an unrestricted grammar#✓fully proved
Derivation: the reflexive-transitive closure of rewriting.
def Derives {T N : Type*} (g : CSGrammar T N) (u v : List (Symbol T N)) : Prop :=
Cslib.Decidability.Rewriting.Derives g.rules u v
structure CSGrammar (T N : Type*) where
/-- The finite list of productions, each a pair of symbol lists. -/
rules : List (List (Symbol T N) × List (Symbol T N))
/-- The initial nonterminal. -/
initial : N
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:54
def Derives (R : List (Rule α)) : List α → List α → Prop := Relation.ReflTransGen (Step R)
CSLibExt/Computability/Decidability/StringRewriting.lean:78
Uses 2 · Used by 25
DefinitionLanguage of an unrestricted grammar#✓fully proved
The language of a grammar: terminal words derived from the initial nonterminal.
def language {T N : Type*} (g : CSGrammar T N) : Set (List T) :=
{w | Derives g [Symbol.nonterminal g.initial] (w.map Symbol.terminal)}
structure CSGrammar (T N : Type*) where
/-- The finite list of productions, each a pair of symbol lists. -/
rules : List (List (Symbol T N) × List (Symbol T N))
/-- The initial nonterminal. -/
initial : N
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:54
def Derives {T N : Type*} (g : CSGrammar T N) (u v : List (Symbol T N)) : Prop :=
Cslib.Decidability.Rewriting.Derives g.rules u v
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:68
Uses 2 · Used by 5
DefinitionContext-sensitive grammar#✓fully proved
A grammar is context-sensitive when every production has a
nonterminal on its left side (so the left side is nonempty and not
terminal-only) and no production shrinks. The standard S → ε
exception is not used here: the aⁿbⁿcⁿ grammar has n ≥ 1.
def IsContextSensitive {T N : Type*} (g : CSGrammar T N) : Prop :=
∀ r ∈ g.rules, r.1.any (·.isNonterminal) = true ∧ r.1.length ≤ r.2.length
structure CSGrammar (T N : Type*) where
/-- The finite list of productions, each a pair of symbol lists. -/
rules : List (List (Symbol T N) × List (Symbol T N))
/-- The initial nonterminal. -/
initial : N
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:54
Uses 2 · Used by 2
InductiveTerminals of the \(a^n b^n c^n\) grammar#✓fully proved
Terminals of the aⁿbⁿcⁿ grammar.
inductive ABC where
| a : ABC
| b : ABC
| c : ABC
deriving DecidableEq, Repr
Used by 16
InductiveNonterminals of the \(a^n b^n c^n\) grammar#✓fully proved
Nonterminals of the aⁿbⁿcⁿ grammar.
inductive ABCNT where
| S : ABCNT
| B : ABCNT
| C : ABCNT
deriving DecidableEq, Repr
Used by 16
DefinitionContext-sensitive grammar for \(a^n b^n c^n\)#✓fully proved
The standard context-sensitive grammar for {aⁿbⁿcⁿ | n ≥ 1}.
def abcGrammar : CSGrammar ABC ABCNT where
rules :=
[ ([.nonterminal .S], [.terminal .a, .nonterminal .S, .nonterminal .B, .nonterminal .C])
, ([.nonterminal .S], [.terminal .a, .nonterminal .B, .nonterminal .C])
, ([.nonterminal .C, .nonterminal .B], [.nonterminal .B, .nonterminal .C])
, ([.terminal .a, .nonterminal .B], [.terminal .a, .terminal .b])
, ([.terminal .b, .nonterminal .B], [.terminal .b, .terminal .b])
, ([.terminal .b, .nonterminal .C], [.terminal .b, .terminal .c])
, ([.terminal .c, .nonterminal .C], [.terminal .c, .terminal .c]) ]
initial := .S
structure CSGrammar (T N : Type*) where
/-- The finite list of productions, each a pair of symbol lists. -/
rules : List (List (Symbol T N) × List (Symbol T N))
/-- The initial nonterminal. -/
initial : N
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:54
inductive ABC where
| a : ABC
| b : ABC
| c : ABC
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:84
inductive ABCNT where
| S : ABCNT
| B : ABCNT
| C : ABCNT
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:91
Uses 3 · Used by 8
TheoremApplying a production in context is a grammar step#✓fully proved
One grammar step: rewrite lhs to rhs in context p, q.
theorem step (lhs rhs p q : List (Symbol ABC ABCNT))
(h : (lhs, rhs) ∈ abcGrammar.rules) :
Derives abcGrammar (p ++ lhs ++ q) (p ++ rhs ++ q)
inductive ABC where
| a : ABC
| b : ABC
| c : ABC
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:84
inductive ABCNT where
| S : ABCNT
| B : ABCNT
| C : ABCNT
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:91
def abcGrammar : CSGrammar ABC ABCNT where
rules :=
[ ([.nonterminal .S], [.terminal .a, .nonterminal .S, .nonterminal .B, .nonterminal .C])
, ([.nonterminal .S], [.terminal .a, .nonterminal .B, .nonterminal .C])
, ([.nonterminal .C, .nonterminal .B], [.nonterminal .B, .nonterminal .C])
, ([.terminal .a, .nonterminal .B], [.terminal .a, .terminal .b])
, ([.terminal .b, .nonterminal .B], [.terminal .b, .terminal .b])
, ([.terminal .b, .nonterminal .C], [.terminal .b, .terminal .c])
, ([.terminal .c, .nonterminal .C], [.terminal .c, .terminal .c]) ]
initial := .S
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:98
def Derives {T N : Type*} (g : CSGrammar T N) (u v : List (Symbol T N)) : Prop :=
Cslib.Decidability.Rewriting.Derives g.rules u v
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:68
TheoremThe \(a^n b^n c^n\) grammar is context-sensitive#✓fully proved
Every production of the aⁿbⁿcⁿ grammar is length-nondecreasing,
so the grammar is context-sensitive.
theorem abcGrammar_contextSensitive : IsContextSensitive abcGrammar
def IsContextSensitive {T N : Type*} (g : CSGrammar T N) : Prop :=
∀ r ∈ g.rules, r.1.any (·.isNonterminal) = true ∧ r.1.length ≤ r.2.length
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:80
def abcGrammar : CSGrammar ABC ABCNT where
rules :=
[ ([.nonterminal .S], [.terminal .a, .nonterminal .S, .nonterminal .B, .nonterminal .C])
, ([.nonterminal .S], [.terminal .a, .nonterminal .B, .nonterminal .C])
, ([.nonterminal .C, .nonterminal .B], [.nonterminal .B, .nonterminal .C])
, ([.terminal .a, .nonterminal .B], [.terminal .a, .terminal .b])
, ([.terminal .b, .nonterminal .B], [.terminal .b, .terminal .b])
, ([.terminal .b, .nonterminal .C], [.terminal .b, .terminal .c])
, ([.terminal .c, .nonterminal .C], [.terminal .c, .terminal .c]) ]
initial := .S
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:98
TheoremThe word abc is generated by the \(a^n b^n c^n\) grammar#✓fully proved
abc is generated.
theorem abc_mem : [ABC.a, ABC.b, ABC.c] ∈ language abcGrammar
inductive ABC where
| a : ABC
| b : ABC
| c : ABC
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:84
def language {T N : Type*} (g : CSGrammar T N) : Set (List T) :=
{w | Derives g [Symbol.nonterminal g.initial] (w.map Symbol.terminal)}
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:73
def abcGrammar : CSGrammar ABC ABCNT where
rules :=
[ ([.nonterminal .S], [.terminal .a, .nonterminal .S, .nonterminal .B, .nonterminal .C])
, ([.nonterminal .S], [.terminal .a, .nonterminal .B, .nonterminal .C])
, ([.nonterminal .C, .nonterminal .B], [.nonterminal .B, .nonterminal .C])
, ([.terminal .a, .nonterminal .B], [.terminal .a, .terminal .b])
, ([.terminal .b, .nonterminal .B], [.terminal .b, .terminal .b])
, ([.terminal .b, .nonterminal .C], [.terminal .b, .terminal .c])
, ([.terminal .c, .nonterminal .C], [.terminal .c, .terminal .c]) ]
initial := .S
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:98
TheoremThe word aabbcc is generated by the \(a^n b^n c^n\) grammar#✓fully proved
aabbcc is generated: grow two a's, shuttle the C's right past
the B's, then convert B's and C's to terminals in order.
theorem aabbcc_mem :
[ABC.a, ABC.a, ABC.b, ABC.b, ABC.c, ABC.c] ∈ language abcGrammar
inductive ABC where
| a : ABC
| b : ABC
| c : ABC
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:84
def language {T N : Type*} (g : CSGrammar T N) : Set (List T) :=
{w | Derives g [Symbol.nonterminal g.initial] (w.map Symbol.terminal)}
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:73
def abcGrammar : CSGrammar ABC ABCNT where
rules :=
[ ([.nonterminal .S], [.terminal .a, .nonterminal .S, .nonterminal .B, .nonterminal .C])
, ([.nonterminal .S], [.terminal .a, .nonterminal .B, .nonterminal .C])
, ([.nonterminal .C, .nonterminal .B], [.nonterminal .B, .nonterminal .C])
, ([.terminal .a, .nonterminal .B], [.terminal .a, .terminal .b])
, ([.terminal .b, .nonterminal .B], [.terminal .b, .terminal .b])
, ([.terminal .b, .nonterminal .C], [.terminal .b, .terminal .c])
, ([.terminal .c, .nonterminal .C], [.terminal .c, .terminal .c]) ]
initial := .S
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:98
DefinitionSymbol count of a sentential form#✓fully proved
Count of the symbol s in a sentential form (terminals a, b,
c, and the "unborn" b/c nonterminals B, C).
def cnt (s : Symbol ABC ABCNT) (u : List (Symbol ABC ABCNT)) : ℕ :=
u.countP (fun t => decide (t = s))
inductive ABC where
| a : ABC
| b : ABC
| c : ABC
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:84
inductive ABCNT where
| S : ABCNT
| B : ABCNT
| C : ABCNT
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:91
Uses 2 · Used by 5
DefinitionCount of a's in a sentential form#✓fully proved
The a-count of a sentential form.
def cntA (u : List (Symbol ABC ABCNT)) : ℕ :=
cnt (.terminal .a) u
inductive ABC where
| a : ABC
| b : ABC
| c : ABC
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:84
inductive ABCNT where
| S : ABCNT
| B : ABCNT
| C : ABCNT
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:91
def cnt (s : Symbol ABC ABCNT) (u : List (Symbol ABC ABCNT)) : ℕ :=
u.countP (fun t => decide (t = s))
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:190
Uses 3 · Used by 4
DefinitionCount of b's in a sentential form#✓fully proved
The b-count: terminal b's plus unborn B's.
def cntB (u : List (Symbol ABC ABCNT)) : ℕ :=
cnt (.terminal .b) u + cnt (.nonterminal .B) u
inductive ABC where
| a : ABC
| b : ABC
| c : ABC
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:84
inductive ABCNT where
| S : ABCNT
| B : ABCNT
| C : ABCNT
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:91
def cnt (s : Symbol ABC ABCNT) (u : List (Symbol ABC ABCNT)) : ℕ :=
u.countP (fun t => decide (t = s))
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:190
Uses 3 · Used by 4
DefinitionCount of c's in a sentential form#✓fully proved
The c-count: terminal c's plus unborn C's.
def cntC (u : List (Symbol ABC ABCNT)) : ℕ :=
cnt (.terminal .c) u + cnt (.nonterminal .C) u
inductive ABC where
| a : ABC
| b : ABC
| c : ABC
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:84
inductive ABCNT where
| S : ABCNT
| B : ABCNT
| C : ABCNT
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:91
def cnt (s : Symbol ABC ABCNT) (u : List (Symbol ABC ABCNT)) : ℕ :=
u.countP (fun t => decide (t = s))
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:190
Uses 3 · Used by 4
DefinitionBalanced sentential form#✓fully proved
A sentential form is balanced when its a-, b- and c-counts
agree.
def Balanced (u : List (Symbol ABC ABCNT)) : Prop :=
cntA u = cntB u ∧ cntB u = cntC u
inductive ABC where
| a : ABC
| b : ABC
| c : ABC
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:84
inductive ABCNT where
| S : ABCNT
| B : ABCNT
| C : ABCNT
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:91
def cntA (u : List (Symbol ABC ABCNT)) : ℕ :=
cnt (.terminal .a) u
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:194
def cntB (u : List (Symbol ABC ABCNT)) : ℕ :=
cnt (.terminal .b) u + cnt (.nonterminal .B) u
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:198
def cntC (u : List (Symbol ABC ABCNT)) : ℕ :=
cnt (.terminal .c) u + cnt (.nonterminal .C) u
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:202
TheoremSymbol counts are additive over concatenation#✓fully proved
Counting over a concatenation of three forms splits additively.
theorem cnt_concat3 (p l q : List (Symbol ABC ABCNT)) (s : Symbol ABC ABCNT) :
cnt s (p ++ l ++ q) = cnt s p + cnt s l + cnt s q
inductive ABC where
| a : ABC
| b : ABC
| c : ABC
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:84
inductive ABCNT where
| S : ABCNT
| B : ABCNT
| C : ABCNT
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:91
def cnt (s : Symbol ABC ABCNT) (u : List (Symbol ABC ABCNT)) : ℕ :=
u.countP (fun t => decide (t = s))
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:190
Uses 3 · Used by 1
TheoremRewriting steps preserve balancedness#✓fully proved
One rewriting step preserves balancedness: every production has the same imbalance on both sides, and the context contributes equally to all three counts.
theorem rewrites_balanced {u v : List (Symbol ABC ABCNT)}
(h : Rewrites abcGrammar u v) (hu : Balanced u) : Balanced v
inductive ABC where
| a : ABC
| b : ABC
| c : ABC
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:84
inductive ABCNT where
| S : ABCNT
| B : ABCNT
| C : ABCNT
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:91
def Rewrites {T N : Type*} (g : CSGrammar T N) (u v : List (Symbol T N)) : Prop :=
Cslib.Decidability.Rewriting.Step g.rules u v
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:64
def abcGrammar : CSGrammar ABC ABCNT where
rules :=
[ ([.nonterminal .S], [.terminal .a, .nonterminal .S, .nonterminal .B, .nonterminal .C])
, ([.nonterminal .S], [.terminal .a, .nonterminal .B, .nonterminal .C])
, ([.nonterminal .C, .nonterminal .B], [.nonterminal .B, .nonterminal .C])
, ([.terminal .a, .nonterminal .B], [.terminal .a, .terminal .b])
, ([.terminal .b, .nonterminal .B], [.terminal .b, .terminal .b])
, ([.terminal .b, .nonterminal .C], [.terminal .b, .terminal .c])
, ([.terminal .c, .nonterminal .C], [.terminal .c, .terminal .c]) ]
initial := .S
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:98
def Balanced (u : List (Symbol ABC ABCNT)) : Prop :=
cntA u = cntB u ∧ cntB u = cntC u
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:207
Uses 13 · Used by 1
TheoremDerivations preserve balancedness#✓fully proved
Derivations preserve balancedness.
theorem derives_balanced {u v : List (Symbol ABC ABCNT)}
(h : Derives abcGrammar u v) (hu : Balanced u) : Balanced v
inductive ABC where
| a : ABC
| b : ABC
| c : ABC
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:84
inductive ABCNT where
| S : ABCNT
| B : ABCNT
| C : ABCNT
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:91
def Derives {T N : Type*} (g : CSGrammar T N) (u v : List (Symbol T N)) : Prop :=
Cslib.Decidability.Rewriting.Derives g.rules u v
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:68
def abcGrammar : CSGrammar ABC ABCNT where
rules :=
[ ([.nonterminal .S], [.terminal .a, .nonterminal .S, .nonterminal .B, .nonterminal .C])
, ([.nonterminal .S], [.terminal .a, .nonterminal .B, .nonterminal .C])
, ([.nonterminal .C, .nonterminal .B], [.nonterminal .B, .nonterminal .C])
, ([.terminal .a, .nonterminal .B], [.terminal .a, .terminal .b])
, ([.terminal .b, .nonterminal .B], [.terminal .b, .terminal .b])
, ([.terminal .b, .nonterminal .C], [.terminal .b, .terminal .c])
, ([.terminal .c, .nonterminal .C], [.terminal .c, .terminal .c]) ]
initial := .S
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:98
def Balanced (u : List (Symbol ABC ABCNT)) : Prop :=
cntA u = cntB u ∧ cntB u = cntC u
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:207
TheoremThe initial sentential form is balanced#✓fully proved
The initial form [S] is balanced, with all counts zero.
theorem balanced_initial : Balanced [Symbol.nonterminal ABCNT.S]
def Balanced (u : List (Symbol ABC ABCNT)) : Prop :=
cntA u = cntB u ∧ cntB u = cntC u
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:207
inductive ABCNT where
| S : ABCNT
| B : ABCNT
| C : ABCNT
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:91
Uses 6 · Used by 1
TheoremGenerated words have equally many a's, b's and c's#✓fully proved
Every generated terminal word has equally many a's, b's and
c's.
theorem language_subset_balanced {w : List ABC} (hw : w ∈ language abcGrammar) :
Balanced (w.map Symbol.terminal)
inductive ABC where
| a : ABC
| b : ABC
| c : ABC
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:84
def language {T N : Type*} (g : CSGrammar T N) : Set (List T) :=
{w | Derives g [Symbol.nonterminal g.initial] (w.map Symbol.terminal)}
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:73
def abcGrammar : CSGrammar ABC ABCNT where
rules :=
[ ([.nonterminal .S], [.terminal .a, .nonterminal .S, .nonterminal .B, .nonterminal .C])
, ([.nonterminal .S], [.terminal .a, .nonterminal .B, .nonterminal .C])
, ([.nonterminal .C, .nonterminal .B], [.nonterminal .B, .nonterminal .C])
, ([.terminal .a, .nonterminal .B], [.terminal .a, .terminal .b])
, ([.terminal .b, .nonterminal .B], [.terminal .b, .terminal .b])
, ([.terminal .b, .nonterminal .C], [.terminal .b, .terminal .c])
, ([.terminal .c, .nonterminal .C], [.terminal .c, .terminal .c]) ]
initial := .S
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:98
def Balanced (u : List (Symbol ABC ABCNT)) : Prop :=
cntA u = cntB u ∧ cntB u = cntC u
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:207
Uses 8 · Used by 1
TheoremThe word aabbc is not generated by the \(a^n b^n c^n\) grammar#✓fully proved
aabbc is not generated: its counts are 2 = 2 ≠ 1.
theorem aabbc_not_mem : [ABC.a, ABC.a, ABC.b, ABC.b, ABC.c] ∉
language abcGrammar
inductive ABC where
| a : ABC
| b : ABC
| c : ABC
deriving DecidableEq, Repr
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:84
def language {T N : Type*} (g : CSGrammar T N) : Set (List T) :=
{w | Derives g [Symbol.nonterminal g.initial] (w.map Symbol.terminal)}
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:73
def abcGrammar : CSGrammar ABC ABCNT where
rules :=
[ ([.nonterminal .S], [.terminal .a, .nonterminal .S, .nonterminal .B, .nonterminal .C])
, ([.nonterminal .S], [.terminal .a, .nonterminal .B, .nonterminal .C])
, ([.nonterminal .C, .nonterminal .B], [.nonterminal .B, .nonterminal .C])
, ([.terminal .a, .nonterminal .B], [.terminal .a, .terminal .b])
, ([.terminal .b, .nonterminal .B], [.terminal .b, .terminal .b])
, ([.terminal .b, .nonterminal .C], [.terminal .b, .terminal .c])
, ([.terminal .c, .nonterminal .C], [.terminal .c, .terminal .c]) ]
initial := .S
CSLibExt/Computability/Languages/ContextSensitive/Basic.lean:98
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.