cfgeq-0.1.0.0: Unsound checker for CFG equality
CopyrightChua Hou 2021
LicenseMIT
MaintainerChua Hou <human+github@chuahou.dev>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe-Inferred
LanguageHaskell2010

CFGEq.CNF

Description

Compilation of CFGs from CFG to Chomsky normal form.

Synopsis

Documentation

data CNF v t Source #

CNF v t is the type of Chomsky normal form grammars with variables of type v and terminals of type t.

Constructors

CNF 

Fields

Instances

Instances details
(Show v, Show t) => Show (CNF v t) Source # 
Instance details

Defined in CFGEq.CNF

Methods

showsPrec :: Int -> CNF v t -> ShowS Source #

show :: CNF v t -> String Source #

showList :: [CNF v t] -> ShowS Source #

type CNFProduction v t = Either (v, v) t Source #

The type of productions in a rule for CNF. Does not allow epsilon productions since CNF captures that for the start symbol as a Bool.

compile Source #

Arguments

:: forall v t. (Ord v, Ord t) 
=> (Int -> v)

Fresh variable supplier.

-> CFG v t

Grammar to compile.

-> CNF v t 

Compiles a CFG to CNF. Requires the caller to supply a function that supplies fresh variables of the correct type, that should be guaranteed to return a different variable when given a different Int argument.

enumerate Source #

Arguments

:: forall v t. (Ord v, Ord t) 
=> Int

Maximum length of string to generate.

-> CNF v t

Chomsky normal form grammar to use.

-> Set [t] 

enumerate n c returns the set of all strings generated by c of length n or less.