Skip to content

Commit 6f7ecd8

Browse files
v0.8.0 (#95)
* Fix some source warnings. * Bump to v0.8.0. * Tweaks/fixes to docs. * Update Dockerfile. * Apply Google Java format.
1 parent fca9f19 commit 6f7ecd8

File tree

13 files changed

+103
-40
lines changed

13 files changed

+103
-40
lines changed

Dockerfile

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1+
# To upload the Docker images to Dockerhub, log into the Docker console, and then run
2+
#
3+
# docker buildx build --push --platform linux/amd64,linux/arm64 -t aaronbembenek/formulog:vX.Y.Z .
4+
#
5+
# (with the appropriate version number substituted for X.Y.Z).
6+
17
FROM maven:3.8.6-openjdk-11 AS build
28
WORKDIR /root/formulog/
39
COPY src src
410
COPY pom.xml pom.xml
511
RUN mvn package -DskipTests
612

713
FROM ubuntu:23.04
8-
WORKDIR /root/formulog/
9-
ARG version=0.7.0-SNAPSHOT
14+
ARG version=0.8.0-SNAPSHOT
15+
WORKDIR /root/
1016
RUN apt-get update \
1117
&& DEBIAN_FRONTEND=noninteractive \
1218
apt-get install -y \
@@ -28,13 +34,15 @@ RUN apt-get update \
2834
make \
2935
mcpp \
3036
python3 \
31-
sqlite \
32-
zlib1g-dev
33-
COPY --from=build /root/formulog/target/formulog-${version}-jar-with-dependencies.jar formulog.jar
34-
COPY examples examples
35-
RUN git clone https://github.com/souffle-lang/souffle.git \
37+
sqlite3 \
38+
zlib1g-dev \
39+
# Install modified Souffle
40+
&& git clone --branch eager-eval https://github.com/aaronbembenek/souffle.git \
3641
&& cd souffle \
37-
&& cmake -S . -B build \
38-
&& cmake --build build --target install -j 4 \
39-
&& cd .. \
40-
&& rm -rf souffle
42+
&& cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DSOUFFLE_ENABLE_TESTING=OFF \
43+
&& cmake --build build -j$(nproc) \
44+
&& cmake --build build --target install \
45+
&& cmake --build build --target clean
46+
WORKDIR /root/formulog/
47+
COPY --from=build /root/formulog/target/formulog-${version}-jar-with-dependencies.jar formulog.jar
48+
COPY examples examples

changelog.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [0.8.0] - 2024-10-18
6+
7+
### Added
8+
9+
- Support for eager evaluation in both interpreter (`--eager-eval` option) and compiler.
10+
- Reorganized documentation and added a lot of new material, including a tutorial.
11+
- Apply Google Java format with Maven.
12+
- Various improvements to the code generator.
13+
14+
### Changed
15+
16+
- Better error reporting for type arity mismatch.
17+
- Clean up CI.
18+
- Better, more consistent CLI options for interpreter and generated code.
19+
20+
### Fixed
21+
22+
- Lexing of arithmetic expressions without spaces.
23+
- Various (rare) interpreter bugs.
24+
- Various bugs in the C++ runtime and generated code.
25+
526
## [0.7.0] - 2023-02-14
627

728
### Added

docs/eval_modes/compile.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Within this directory you can use `cmake` to compile the generated code into a b
1414
For example, to compile and execute the `greeting.flg` program from above, you can use these steps:
1515

1616
```
17-
java -jar formulog.jar -c greeting.flg && \
17+
java -jar formulog.jar -c examples/greeting.flg && \
1818
cd codegen && \
1919
cmake -B build -S . && \
2020
cmake --build build -j && \

docs/eval_modes/eager.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ When you configure `cmake` on the generated code, you need to add `-DFLG_EAGER_E
1616
For example, to build a version of the greeting program that uses eager evaluation, use these commands:
1717

1818
```
19-
java -jar formulog.jar -c greeting.flg && \
19+
java -jar formulog.jar -c examples/greeting.flg && \
2020
cd codegen && \
2121
cmake -B build -S . -DFLG_EAGER_EVAL=On && \
2222
cmake --build build -j && \

docs/starting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ There are three main ways to set up Formulog (listed in increasing order of numb
1919

2020
### Use the Docker image
2121

22-
Prebuilt images are available on [Docker Hub](https://hub.docker.com/r/aaronbembenek/formulog).
22+
Prebuilt images are available on [Docker Hub](https://hub.docker.com/r/aaronbembenek/formulog/tags).
2323
If you have Docker installed, you can spin up an Ubuntu container with Formulog, our custom version of Soufflé, and some example programs by running this command (replace `X.Y.Z` with the latest version):
2424

2525
```bash

docs/tutorial/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Our typical approach when implementing an analysis in Formulog is thus to try to
3535

3636
This is the approach we will follow in this tutorial: directly translate the formalism of JV as we encounter it, and then go back to patch our implementation as necessary.
3737
Concretely, we will work our way through JV Sections 3.1 and 3.2.
38-
For the full, final code, see [tutorial.flg](https://github.com/HarvardPL/formulog/blob/master/docs/tutorial/tutorial.flg).
38+
For the full, final code, see [tutorial.flg](https://github.com/HarvardPL/formulog/blob/master/examples/tutorial.flg).
3939

4040
## Definitions
4141

docs/tutorial/tutorial.flg renamed to examples/tutorial.flg

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
(***
2+
3+
This is the full code listing for the Formulog tutorial, which is available at
4+
<https://harvardpl.github.io/formulog/tutorial/>.
5+
6+
***)
7+
18
(*******************************************************************************
29
DEFINITIONS
310
*******************************************************************************)

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>edu.harvard.seas.pl</groupId>
66
<artifactId>formulog</artifactId>
7-
<version>0.7.0-SNAPSHOT</version>
7+
<version>0.8.0-SNAPSHOT</version>
88
<name>formulog</name>
99
<properties>
1010
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

src/main/java/edu/harvard/seas/pl/formulog/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
@Command(
7070
name = "formulog",
7171
mixinStandardHelpOptions = true,
72-
version = "Formulog 0.7.0",
72+
version = "Formulog 0.8.0",
7373
description = "Runs Formulog.")
7474
public final class Main implements Callable<Integer> {
7575

src/main/java/edu/harvard/seas/pl/formulog/ast/Var.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import java.util.Set;
2929
import java.util.concurrent.atomic.AtomicInteger;
3030

31-
public class Var extends AbstractTerm implements Term {
31+
public class Var extends AbstractTerm {
3232

3333
static final AtomicInteger cnt = new AtomicInteger();
3434

src/main/java/edu/harvard/seas/pl/formulog/db/SortedIndexedFactDb.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,19 @@
2727
import edu.harvard.seas.pl.formulog.symbols.SymbolComparator;
2828
import edu.harvard.seas.pl.formulog.util.Pair;
2929
import edu.harvard.seas.pl.formulog.util.Util;
30-
import java.util.*;
30+
import java.lang.reflect.InvocationTargetException;
31+
import java.util.ArrayList;
32+
import java.util.Arrays;
33+
import java.util.Collections;
34+
import java.util.Comparator;
35+
import java.util.HashMap;
36+
import java.util.HashSet;
37+
import java.util.LinkedHashMap;
38+
import java.util.List;
39+
import java.util.Map;
3140
import java.util.Map.Entry;
41+
import java.util.NavigableSet;
42+
import java.util.Set;
3243
import java.util.concurrent.ConcurrentSkipListSet;
3344
import java.util.concurrent.atomic.AtomicInteger;
3445
import java.util.stream.Collectors;
@@ -511,7 +522,12 @@ private static IndexedFactSet make(List<Integer> order) {
511522
if (Configuration.genComparators) {
512523
try {
513524
cmp = gen.generate(a);
514-
} catch (InstantiationException | IllegalAccessException e) {
525+
} catch (InstantiationException
526+
| IllegalAccessException
527+
| IllegalArgumentException
528+
| InvocationTargetException
529+
| NoSuchMethodException
530+
| SecurityException e) {
515531
throw new AssertionError(e);
516532
}
517533
} else {

src/main/java/edu/harvard/seas/pl/formulog/db/TupleComparatorGenerator.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import edu.harvard.seas.pl.formulog.ast.Term;
2323
import edu.harvard.seas.pl.formulog.util.IntArrayWrapper;
2424
import edu.harvard.seas.pl.formulog.util.Pair;
25+
import java.lang.reflect.InvocationTargetException;
2526
import java.util.Comparator;
2627
import java.util.Map;
2728
import java.util.concurrent.ConcurrentHashMap;
@@ -52,7 +53,12 @@ public class TupleComparatorGenerator extends ClassLoader {
5253
private Map<IntArrayWrapper, Comparator<Term[]>> memo = new ConcurrentHashMap<>();
5354

5455
public Comparator<Term[]> generate(int[] accessPat)
55-
throws InstantiationException, IllegalAccessException {
56+
throws InstantiationException,
57+
IllegalAccessException,
58+
IllegalArgumentException,
59+
InvocationTargetException,
60+
NoSuchMethodException,
61+
SecurityException {
5662
IntArrayWrapper key = new IntArrayWrapper(accessPat);
5763
Comparator<Term[]> cmp = memo.get(key);
5864
if (cmp == null) {
@@ -67,7 +73,12 @@ public Comparator<Term[]> generate(int[] accessPat)
6773

6874
@SuppressWarnings("unchecked")
6975
public Comparator<Term[]> generate1(int[] accessPat)
70-
throws InstantiationException, IllegalAccessException {
76+
throws InstantiationException,
77+
IllegalAccessException,
78+
IllegalArgumentException,
79+
InvocationTargetException,
80+
NoSuchMethodException,
81+
SecurityException {
7182
String className = "edu.harvard.seas.pl.formulog.db.CustomComparator" + cnt.getAndIncrement();
7283
ClassGen classGen =
7384
new ClassGen(
@@ -82,7 +93,7 @@ public Comparator<Term[]> generate1(int[] accessPat)
8293

8394
byte[] data = classGen.getJavaClass().getBytes();
8495
Class<?> c = defineClass(className, data, 0, data.length);
85-
return (Comparator<Term[]>) c.newInstance();
96+
return (Comparator<Term[]>) c.getDeclaredConstructor().newInstance();
8697
}
8798

8899
private void addCompareMethod(ClassGen cg, int[] accessPat) {

src/main/java/edu/harvard/seas/pl/formulog/validating/ValidRule.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,23 @@ public static void order(
9797
atoms.addAll(newList);
9898
}
9999

100-
private static Set<Var> checkBody(Rule<UserPredicate, ComplexLiteral> rule)
101-
throws InvalidProgramException {
102-
Set<Var> boundVars = new HashSet<>();
103-
Map<Var, Integer> varCounts = rule.countVariables();
104-
for (ComplexLiteral lit : rule) {
105-
if (!Unification.canBindVars(lit, boundVars, varCounts)) {
106-
throw new InvalidProgramException(
107-
"Rule cannot be evaluated given the supplied order.\n"
108-
+ "The problematic rule is:\n"
109-
+ rule
110-
+ "\nThe problematic literal is: "
111-
+ lit);
112-
}
113-
boundVars.addAll(lit.varSet());
114-
}
115-
return boundVars;
116-
}
100+
// private static Set<Var> checkBody(Rule<UserPredicate, ComplexLiteral> rule)
101+
// throws InvalidProgramException {
102+
// Set<Var> boundVars = new HashSet<>();
103+
// Map<Var, Integer> varCounts = rule.countVariables();
104+
// for (ComplexLiteral lit : rule) {
105+
// if (!Unification.canBindVars(lit, boundVars, varCounts)) {
106+
// throw new InvalidProgramException(
107+
// "Rule cannot be evaluated given the supplied order.\n"
108+
// + "The problematic rule is:\n"
109+
// + rule
110+
// + "\nThe problematic literal is: "
111+
// + lit);
112+
// }
113+
// boundVars.addAll(lit.varSet());
114+
// }
115+
// return boundVars;
116+
// }
117117

118118
private ValidRule(UserPredicate head, List<ComplexLiteral> body) {
119119
super(head, body);

0 commit comments

Comments
 (0)