Module Languageops


module Languageops: sig .. end
This module defines operations on Depgraph.lang.


This module defines operations on Depgraph.lang.
exception IllegalLangOp of string
exception LangOpFail of string
val simple_intersect : Depgraph.lang -> Depgraph.lang -> Depgraph.lang
Intersect two languages (used by Languageops.forward_intersect, Languageops.group_intersect, and Languageops.merge_subnfas.
Raises IllegalLangOp if either l1 or l2 is a SuperMachine or a SubMachine
Returns l1 cap l2
l1 : A language
l2 : Another language
val lang_eq : Depgraph.lang -> Depgraph.lang -> bool
Language equality
Raises IllegalLangOp if either l1 or l2 is a SuperMachine or a SubMachine
Returns l1 ?= l2
l1 : A language
l2 : Another language
val gen_strings : Depgraph.lang -> string option
Generate strings from a language
Returns A list of unique strings (length may be less than n)
val lang_subseteq : Depgraph.lang -> Depgraph.lang -> bool
Language subseteq
Raises IllegalLangOp if either l1 or l2 is a SuperMachine or a SubMachine
Returns l1 ?subseteq l2
l1 : A language
l2 : Another language

Forward solving for non-CI-groups

val forward_concat : Depgraph.graph ->
Depgraph.nodeid -> Depgraph.nodeid -> Depgraph.nodeid -> unit
Solve a simple concat constraint

See also: Languageops.group_concat
Raises IllegalLangOp if either lhs or rhs's language is a SuperMachine or SubMachine

graph : A dependency graph
lhs : The node on the left-hand side of the concatenation
rhs : The node on the right-hand side of the concatenation
target : The node that will hold the result of the concatenation; its lang element will be updated.
val forward_intersect : Depgraph.graph -> Depgraph.nodeid -> Depgraph.nodeid -> unit
Solve a simple intersect (i.e., subset) constraint

See also: Languageops.group_intersect
Raises IllegalLangOp If source of target's language is a SuperMachine or SubMachine (raised by Languageops.simple_intersect).

graph : A dependency graph
source : The restricting node
target : The to-be-restricted node

Concat-Intersect Group Operations

val ref_flatten : Depgraph.supermapping list -> Nfa.state list
Given a list of supermapping constraints (i.e., epsilon transitions that represent potential solutions), return a flat list of all states touching those epsilon transitions.
Returns A list of states
l : A list of Depgraph.supermapping entries
val group_concat : Depgraph.graph ->
Depgraph.nodeid -> Depgraph.nodeid -> Depgraph.nodeid -> unit
Solve a concat constraint in a CI-group

See also: Languageops.forward_concat

The operands (i.e., lhs and rhs) are converted to submachines, while target becomes a supermachine. If lhs or rhs was a supermachine, then all its dependent submachines are updated to be submachines of target instead.
Raises

graph : A dependency graph
lhs : Left-hand side of the concatenation
rhs : Right-hand side of the concatenation
val group_intersect : Depgraph.graph -> Depgraph.nodeid -> Depgraph.nodeid -> unit
Solve an intersect (i.e., subset) constraint in a CI-group

See also: Languageops.forward_intersect

graph : A dependency graph
source : The restricting node
target : The node to be restricted

Converting Processed CI-Groups into Assignments


Given a CI-group with SubMachine and SuperMachine language assignments, extract Machine assignments for all nodes of interest
type assignment = (Depgraph.trans_list_id, Depgraph.transition) Hashtbl.t 
An assignment maps each transition list to a single transition (i.e., an elemtent in that list).
val get_assignment : assignment ->
Depgraph.trans_list Pervasives.ref Pervasives.ref ->
Nfa.state -> Depgraph.transition
Get the assignment associated with the given transition list
Returns The value associated with l in a, or a pair (alt, alt) if l not in l
a : Assignment mapping
l : Transition list
alt : Alternative return value if l is not mapped in a
val merge_subnfas : Depgraph.graph ->
assignment -> Depgraph.submapping -> Depgraph.lang
For a SubMachine dependent on multiple SuperMachines, compute and return the intersection of the different subNFAs.

See also: Depgraph.submapping, Depgraph.lang
Raises IllegalLangOp If any of the referenced SuperMachines have not already been converted to plain old NFAs.
Returns The intersected langauge of all sub-NFAs defined by sub using the given assignment a. As a side effect, the NFA representation for the supermachines is updated.

graph : A dependency graph
a : The assignment mapping to use
sub : The list of dependencies that define this submachine
val create_graph : assignment ->
Depgraph.nodeid Hashset.hashset -> Depgraph.graph -> Depgraph.graph
Solving a CI-group ends with the creation of zero or more copies of the dependency graph. This is where we turn Super- and SubMachines back into normal NFAs.
Raises IllegalLangOp If something bad happened
Returns A copy of curgraph containing the requested satisfying assignment for group
assgn : Satisfying assignment to generate
group : A subset of graph nodes that makes up a (fully processed) CI-group
curgraph : A dependency graph