Computability of the Grammar Membership Test #
This file establishes that the grammarTest function is Computable₂.
Key results #
grammarTest_computable₂— the grammar test function isComputable₂
Structure #
Primcodableinstances forsymbolandgrule- Primrec lemmas for symbol constructors and grule field projections
primrec_applyRuleAt—applyRuleAtis primitive recursivecomputable_extractTerminals—extractTerminalsis computableprimrec_applyRuleSeq_step/computable_applyRuleSeq— rule sequence applicationgrammarTest_computable₂— the final result
Primcodable instances #
noncomputable instance
symbolPrimcodable
{T N : Type}
[Primcodable T]
[Primcodable N]
:
Primcodable (symbol T N)
Equations
- symbolPrimcodable = Primcodable.ofEquiv (T ⊕ N) (symbolEquiv T N)
noncomputable instance
grulePrimcodable
{T N : Type}
[Primcodable T]
[Primcodable N]
:
Primcodable (grule T N)
Equations
- grulePrimcodable = Primcodable.ofEquiv (List (symbol T N) × N × List (symbol T N) × List (symbol T N)) (gruleEquiv T N)
Symbol constructors are primrec #
theorem
primrec_symbol_casesOn
{T N σ : Type}
[Primcodable T]
[Primcodable N]
[Primcodable σ]
{α : Type}
[Primcodable α]
{f : α → symbol T N}
{g : α → T → σ}
{h : α → N → σ}
(hf : Primrec f)
(hg : Primrec₂ g)
(hh : Primrec₂ h)
:
Primrec fun (a : α) =>
match f a with
| symbol.terminal t => g a t
| symbol.nonterminal n => h a n
Case analysis on symbol is primrec.
grule field projections are primrec #
theorem
primrec_grule_outputString
{T N : Type}
[Primcodable T]
[Primcodable N]
:
Primrec fun (r : grule T N) => r.output_string
applyRuleAt is primrec #
theorem
primrec_applyRuleAt
{T : Type}
[DecidableEq T]
{N : Type}
[DecidableEq N]
[Primcodable T]
[Primcodable N]
:
extractTerminals is computable #
applyRuleSeq with fixed args is computable #
theorem
primrec_applyRuleSeq_step
{T : Type}
[DecidableEq T]
{N : Type}
[DecidableEq N]
[Primcodable T]
[Primcodable N]
(rules : List (grule T N))
:
theorem
computable_applyRuleSeq
{T : Type}
[DecidableEq T]
{N : Type}
[DecidableEq N]
[Primcodable T]
[Primcodable N]
(rules : List (grule T N))
(init : List (symbol T N))
:
Computable fun (seq : List (ℕ × ℕ)) => applyRuleSeq rules init seq
Main result #
theorem
grammarTest_computable₂
{T : Type}
[DecidableEq T]
(g : grammar T)
[DecidableEq g.nt]
[Primcodable T]
[Primcodable g.nt]
: