LDL++ Demo Programs
A sample of LDL++ programs grouped by their
most significant traits:
Knowledge-Based Programming
Recursion Classics
- Processing recursive structures: appending, merging, and sorting
lists, Fibonacci, Ackerman, Hanoi and other Prolog favorites: programs.
- Relations by blood, marriage, by transitive closure and beyond
(same-generation, and blue-bloded Frenchmen): programs, facts..
- BOM examples. Materials
program, and
facts, and the bike
program and
facts.
Connecting to External Databases
- A travel-agent program on an internal database:
program, and
facts.
- The same rules on external databases:
program
(including Sybase,
Ingres, and those
satisfying interchange standards such as
RDA, SQLink, and
ESS)
-
Other connections to outside databases: family relations stored
in Sybase family.syb
-
Offloading aggregates to external SQL DBs:
query forms,
rules, and
schemas for DB2,
Sybase,
and Oracle.
Using C++ Functions
Metalevel predicates
Metafamily relations: meta_family.prg
Extensible Aggregates
- The program agg_ex1.prg returns averages every 5
records. Test it on the data
agg_ex1.fac you will get the result
agg_ex1.out
- The program agg_ex2.prg returns sum value until it
exceed 100. Test it on the data
agg_ex2.fac you will get the result
agg_ex2.out
- On-line Average Estimation: this program
agg_ex3.prg returns an estimated average of the underlying
database: agg_ex3.fac. The program will stop if the
estimated value is within a close interval to the exact average. The
result agg_ex3.out
- On-line Median Estimation: this program agg_ex4.prg returns an estimated median
value of the underlying database: agg_ex4.fac. The program will construct a
tree to compute medians, and the estimated median is on the top of the
tree. See the result
agg_ex4.out
- Temporal Projection: this program agg_tmp_proj.prg will coalesce the
time-iterval in the relation when applied to test data agg_tmp_proj.fac and give out the following
result agg_tmp_proj.out.
- Data Cube Aggregates: The program
agg_cube.prg demonstrates how to aggregate data on serveral
dimesnions simultaneously. Given the sales data sorted on year,
quarter, month, day ( agg_cube.fac) , the result
agg_cube.out shows the aggregate sales for each time interal.
Monotonic Aggregates
- Join the Party Problem: We have a party where a person will
come to the party if at least K friends will come. The program agg_mono1.prg defines
a monotonic aggregate mcount. Given the extensional data (agg_mono1.fac), the
result is
agg_mono1.out.
- Least-Distance Problem: Given a graph g(X,Y,C)
(defined in agg_mono2.fac), where C is the cost
of an edge from node X to node Y. The monotonic
aggregates defined in
agg_mono2.prg will find the least cost distance between any two
nodes.
- Company-Control Problem: owns(C1,C2,Per) denotes the
percentage of shares of corporation C2 owned by corporation
C1. Then C1 controls C2 if it owns more than, say
49% of its shares. The monotonic aggregates defined in agg_mono3.prg will
decide the transitive ownership and control between corporations.
- Bill-of-Materials (BoM) Problem: Monotonic aggregates are
defined in agg_mono4.prg to solve BoM problems based
on the facts provided in agg_mono4.fac.
XY-Stratification
Return to main page