-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME_dev.txt
79 lines (64 loc) · 3.75 KB
/
README_dev.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#********************************************************************
# Copyright 2008-2010 Adam Kiezun, Vijay Ganesh
#********************************************************************
# AUTHORS: Adam Kiezun, Vijay Ganesh
#
# BEGIN DATE: October/November 2008
#
# This file belongs to the Hampi string solver project (solver for
# equations over regular expressions)
#
# LICENSE: Please view LICENSE file in the home dir of this Program
#********************************************************************
This file is intended to help in development of Hampi.
It describes to to build and test Hampi, how the solver works, and how the code is structured.
--------------------------------------------------------
How the solver works: Hampi class is the top-level entry point. It calls the
HProgramParser to parse the input and create a HProgram (which
represents the parsed input). The HProgram is then encoded into core
constraints (Constraint) by HConstraintPreparer (this involves
bounding all context-free grammars and changing them to regular
expressions. This is where Hampi often spends the most time). The
Constraint is then passed to STPSolver. The STPSolver checks first if
a simple SAT or UNSAT solution is possible, otherwise STPSolver
encodes the Constraint as list of STPExprs. The encoding writes
regular expression in terms that STP understands (concatenation,
equality, and constants). The encoded STP expressions are put together
in an AndExpr and passed to STP (call to vc.query). Hampi decodes the
solution (i.e., translated bits back to strings).
--------------------------------------------------------
How to build
and test:
./configure
make
make verify
--------------------------------------------------------
How to run Hampi (standalone mode):
./hampi.sh a.hmp
(see README.txt for server mode)
--------------------------------------------------------
Top-level package structure.
hampi: Top-level classes, in particular
Hampi (facade for the solver, both API and file input)
Solution (solution to the constraint problem)
HampiException (wrapper exception for Hampi)
HampiResultException (thrown when a solution is found, to quickly communicate the result)
hampi.constraints: Core constraints. The input language gets translated to those core constraints, and the solving itself works on core constraints. See the paper for another description of the process.
hampi.grammars: TODO
hampi.grammars.apps: Utility classes for grammars, eg
GrammarStringBounder - bounds a context-free grammar, ie, creates a regexp that describes all strings from a grammar that have a specific length
UnreachableNonterminalRemover - removes unreachable nonterminals from a CFG
EpsilonProductionRemover - removes productions A -> \epsilon
(These 3 packages are mostly dead code. I think they are referenced only from tests)
hampi.grammars.cykparser: CYK parser
hampi.grammars.lexer: hand-coded lexer
hampi.grammars.parser: hand-coded parser
hampi.parser: Lexer/Parser classes.
Lexer and Parser are generated by ANTRL.
Files Hampi.g and HampiTree.g are the specification.
Lexer and Parser are made by running MakeLexerParser, and then MakeTree. This will regenerate the Lexer and Parser.
The CFG* classes are for defining context-free grammars. The H* classes are for defining all Hampi constraints. HProgram represents the top-level Hampi input.
NOTE: there's a bit of disoreder about grammars in Hampi. There are 2 packages (hampi.grammars and hampi.parser) - the former represents context-free grammars, the latter represents Hampi's input format. The first should be, in principle, removable. It exists mostly as legacy code.
hampi.stp: Classes the correspond to elements of STP constraints.
hampi.utils: utilities
--------------------------------------------------------