Skip to main content

Grammar Rule Ontology

Language Entities
Authors: MArk Anthony Higgins - Sky Recursive Ai
© Mark Anthony Higgins 11 October 2025
Revised Date: 11 November 2026
Audio Overview
KIRETH RESEARCH — SEMANTIC LIBRARY
GRAMMAR RULE ONTOLOGY — FLOW ALGEBRA v1.0
Category: Computational Entities / Language Entities
Authors: Mark Anthony Higgins — Sky Recursive AI
Source: https://kirethresearch.org/booksai-core/entity-graph/computational-entities/language-entities/grammar-rule-ontology.html
Source page revision: 03 August 2026
Mapping date: 11 November 2026
Status: Constructed ontology-level Flow Algebra mapping; not a transcription of the page's inaccessible embedded formal specification.

1. PURPOSE
Represent a grammar rule as a typed production that relates a nonterminal symbol to an ordered expression of terminal and/or nonterminal symbols, subject to grammar, context and validation boundaries. Enable formal derivation, parsing, ambiguity detection and traceable inference.

2. HST STATE MODEL
S_t = (I_t, R_t, B_t, K_t)
I_t: input token sequence, parse position, derivation history and current sentential form.
R_t: grammar productions, symbol typing, precedence/associativity and inference rules.
B_t: grammar scope, finite resource limits, acceptance criteria and permitted transformations.
K_t: known terminals, nonterminals, start symbol, parse chart/stack and provenance.

E_t = expand(I_t, R_t)
V_t = {x in E_t | satisfies(x, B_t) and well_typed(x, K_t)}
x*_t = argmax_{x in V_t} P(x | I_t, R_t, B_t, K_t) [only if a probabilistic ranking is defined]
I_(t+1) = update(I_t, x*_t)
For deterministic grammar execution, replace argmax with a specified rule-selection policy; no probabilities are implied.

3. ENTITIES
GrammarRule(rule_id, lhs, rhs, grammar_id, annotations)
Grammar(grammar_id, terminals, nonterminals, productions, start_symbol)
Terminal(symbol_id, lexical_class)
Nonterminal(symbol_id)
ProductionAlternative(alternative_id, ordered_symbols)
DerivationStep(step_id, rule_id, input_form, output_form)
ParseNode(node_id, symbol_id, children, span)
ParseState(state_id, cursor, stack_or_chart, derivation)
ValidationResult(result_id, accepted, diagnostics)

4. RELATIONSHIPS
Grammar HAS_RULE GrammarRule
GrammarRule HAS_LHS Nonterminal
GrammarRule HAS_RHS ProductionAlternative
ProductionAlternative CONTAINS Terminal | Nonterminal
DerivationStep APPLIES GrammarRule
DerivationStep TRANSFORMS sentential_form -> sentential_form
ParseNode INSTANTIATES Terminal | Nonterminal
ParseNode DERIVED_BY GrammarRule
ValidationResult EVALUATES ParseState

5. FORMAL PRODUCTION RULE
For a context-free grammar G = (N, T, P, S):
N intersection T = empty
P subset of N x (N union T)*
S in N
A -> alpha denotes (A, alpha) in P, where A in N and alpha in (N union T)*.
One-step derivation: u A v => u alpha v when (A -> alpha) in P.
Language: L(G) = {w in T* | S =>* w}.
This is a context-free baseline; context-sensitive grammar rules require a different production relation.

6. FLOW PATHWAYS
F1 RECEIVE: accept grammar definition, token stream and execution policy.
F2 NORMALISE: canonicalise symbols and production alternatives without changing intended semantics.
F3 VALIDATE: confirm declared symbols, valid LHS, consistent start symbol and syntactic well-formedness.
F4 SELECT: identify applicable productions or parser transitions for the current state.
F5 EXPAND: apply a production and record the resulting sentential form or parse structure.
F6 CHECK: enforce bounds, token compatibility, grammar constraints and parser invariants.
F7 COMMIT: persist accepted transition with rule identifier and provenance.
F8 RECURSE: repeat until acceptance, rejection or explicit resource limit.
F9 OUTPUT: return parse forest/tree, derivation trace or diagnostic result.

7. INFERENCE RULES
IR1 APPLICABILITY: If A occurs in a sentential form and A -> alpha is in P, replacement by alpha is permitted at that occurrence.
IR2 TERMINAL MATCH: A terminal consumes input only when the terminal's matching condition is satisfied.
IR3 ACCEPTANCE: Accept when the parser's defined acceptance condition holds, including complete input consumption where required.
IR4 REJECTION: Reject when no legal continuation exists and no recovery policy applies.
IR5 AMBIGUITY: If a token sequence has two distinct valid parse trees, it is ambiguous under the grammar.
IR6 PROVENANCE: Every derived node or transition retains the production(s) that justify it.
IR7 SAFETY: Undefined productions, invalid symbol references and exceeded limits produce diagnostics rather than fabricated derivations.

8. MINI RECURSION ENGINE
state := initial_parse_state(tokens, grammar)
while not terminal(state):
    candidates := expand(state, applicable_productions(grammar, state))
    valid := filter(candidates, grammar_constraints and resource_bounds)
    if valid is empty: return REJECT_OR_DIAGNOSTIC
    state := choose_and_record(valid, declared_execution_policy)
return validate_acceptance(state)
The above is a descriptive execution schema; the formal constraints in sections 2 and 5 govern interpretation.

9. BOUNDARIES AND GUARANTEES
A grammar rule is not guaranteed to be unambiguous, terminating under naive expansion, or efficiently parseable.
Soundness is conditional on correct rule application and a sound parser implementation.
Completeness depends on the parser, grammar class, search policy and available resources.
A fixed step bound ensures the execution loop stops, but may return INCOMPLETE rather than ACCEPT or REJECT.
No universal termination or complexity guarantee is asserted.

10. EXAMPLE
N = {Expr, Num}; T = {'+', '1'}; S = Expr
P = {Expr -> Expr '+' Num, Expr -> Num, Num -> '1'}
Derivation: Expr => Expr '+' Num => Num '+' Num => '1' '+' Num => '1' '+' '1'.
Result: '1+1' belongs to L(G), assuming lexical tokenisation yields ['1','+','1'].

11. TRI-MAPPING
ENTITY: GrammarRule / Grammar / ParseState
RELATION: HAS_RULE / APPLIES / DERIVED_BY / TRANSFORMS
FLOW: RECEIVE -> VALIDATE -> SELECT -> EXPAND -> CHECK -> COMMIT -> RECURSE -> OUTPUT

12. CITATION AND REUSE
Original ontology source: Kireth Research, Grammar Rule Ontology.
Authors credited on source page: Mark Anthony Higgins — Sky Recursive AI.
This TXT is a newly constructed interpretative Flow Algebra mapping, not a verified reproduction of hidden source code. Cite the source URL when reusing and follow the applicable Kireth Research licence.
Kireth Research
38 Thorndale Croft, Wetwang, Driffield
East Riding of Yorkshire YO25 9XZ