Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modules #274

Merged
merged 122 commits into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from 121 commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
fc3ff0d
gradle: Introduce submodules
lorenzleutgeb Oct 27, 2020
ab5d5bf
core: Move ANTLR sources
lorenzleutgeb Oct 27, 2020
f93ab16
cli: Move resources
lorenzleutgeb Oct 27, 2020
89dcda4
git: Ignore */build
lorenzleutgeb Oct 27, 2020
1dfa72a
WIP: Extract interfaces
lorenzleutgeb Oct 27, 2020
2ae8d14
intermediate commit
madmike200590 Dec 4, 2020
725f45e
WIP: separate inheritance hierarchies for core- and api-types
madmike200590 Dec 14, 2020
af4d78c
WIP: let core components only depend on core API (not dependent on pu…
madmike200590 Dec 18, 2020
2a45628
adapt module names, add module alpha-solver
madmike200590 Dec 19, 2020
60c1bcf
adapt package names in alpha-core
madmike200590 Dec 19, 2020
fdf165f
WIP: decouple core/public API
madmike200590 Dec 19, 2020
0fbd63e
WIP: design published API
madmike200590 Jan 4, 2021
5e38c33
WIP: make parser conform to public API
madmike200590 Jan 22, 2021
a91b282
WIP: ParseTreeVisitor and Alpha conforming to new public API
madmike200590 Jan 23, 2021
e75f694
globally use interface types for API constructs
madmike200590 Jan 29, 2021
848ad7c
extract all interfaces, make it compile
madmike200590 Jan 29, 2021
131a5c8
fix build errors
madmike200590 Jan 29, 2021
84f537c
WIP: fix tests
madmike200590 Jan 29, 2021
61b1bb3
WIP: fix tests
madmike200590 Jan 29, 2021
ba43d48
WIP: adapt unit tests to modularized setup
madmike200590 Feb 5, 2021
f250c24
modularize and fix compilation errors in unit tests
madmike200590 Feb 8, 2021
f5e165a
tests for core module fixed
madmike200590 Feb 12, 2021
4c333fb
fix unit tests in all modules
madmike200590 Feb 12, 2021
6c60b89
WIP: deploy jar files to local maven cache
madmike200590 Feb 16, 2021
6ef295e
ignore junit log
madmike200590 Feb 16, 2021
3000fde
new module alpha-commons
madmike200590 Feb 17, 2021
9c57339
WIP: move terms to commons module
madmike200590 Feb 23, 2021
1b4f116
hide implementation details for VariableTerm, change implementation t…
madmike200590 Feb 23, 2021
7ac24aa
hide implementation details for FunctionTerm, change implementation t…
madmike200590 Feb 23, 2021
e3ca893
hide implementation details for ArithmeticTerm, change implementation…
madmike200590 Feb 23, 2021
82ad457
separate package for terms in alpha-commons
madmike200590 Feb 23, 2021
fe97209
fix checkstyle errors
madmike200590 Feb 23, 2021
171f6b3
WIP: move AggregateAtom to alpha-commons
madmike200590 Apr 1, 2021
95ddd72
hide implementation for AggregateAtom
madmike200590 Apr 3, 2021
833ffed
fix ChoiceAtom and RuleAtom
madmike200590 Apr 3, 2021
bf992f6
hide implementation for ComparisonAtom, fix EnumerationAtom
madmike200590 Apr 3, 2021
7632b97
Hide implementation for ExternalAtom
madmike200590 Apr 3, 2021
400732f
fix IntervalAtom
madmike200590 Apr 3, 2021
120bfca
moved literal implementations to commons module
madmike200590 Apr 3, 2021
347be4a
fix unit tests
madmike200590 Apr 3, 2021
f1c23d7
introduce interfaces NormalProgram and NormalRule
madmike200590 Apr 7, 2021
24e4a77
WIP: remove direct compile dependencies from alpha-cli-app to alpha-core
madmike200590 Apr 10, 2021
d7d3495
remove direct compile-time dependencies from alpha-cli-app to alpha-core
madmike200590 Apr 16, 2021
08419ba
WIP: refactor debug output workflow for CLI app
madmike200590 Apr 16, 2021
1ce5f0b
implement InternalProgram#toNormalProgram, add missing override annot…
madmike200590 Apr 23, 2021
ef14b0f
adapt CLI app to use single debug flag for preprocessing debug options
madmike200590 Apr 24, 2021
57dcad0
remove interfaces specific to internal grounder workings from public API
madmike200590 Apr 24, 2021
6f0605f
include runtime dependencies for application jar
madmike200590 Apr 24, 2021
82fbc6d
merge master into branch modules
madmike200590 Apr 24, 2021
c7b9b64
update appveyor config
madmike200590 Apr 24, 2021
6c41d24
clean up public API
madmike200590 Aug 26, 2021
788c0dc
clean up public API package structure
madmike200590 Aug 26, 2021
e7401ae
fix cehckstyle warnings
madmike200590 Aug 26, 2021
dd390a8
merge changes from master
madmike200590 Sep 8, 2021
432a04c
adapt antlr folder structure to new reflect module name
madmike200590 Sep 9, 2021
8b042c4
correct antlr path in build file
madmike200590 Sep 9, 2021
7211edb
fix packages to conform to antlr-generated folder structure
madmike200590 Sep 9, 2021
1ab79e4
create separate package for heads in api module
madmike200590 Sep 9, 2021
034621d
hide implementation details for rule heads
madmike200590 Sep 14, 2021
f6876f0
merge upstream changes from master
madmike200590 Sep 20, 2021
c746f2b
merge upstream changes from master
madmike200590 Sep 20, 2021
d918830
clean up test package structure
madmike200590 Sep 20, 2021
d8ff66d
delete obsolete files
madmike200590 Oct 6, 2021
3447d10
merge changes from master into 'modules'
madmike200590 Oct 12, 2021
b13060c
remove unneeded dependencies
madmike200590 Oct 14, 2021
e161e84
add global junit5 dependency, get rid of junit4 leftovers
madmike200590 Oct 14, 2021
619adcd
repo: Ignore junit.log
lorenzleutgeb Oct 18, 2021
6c24d02
api: Remove TODO that mentions class from core
lorenzleutgeb Oct 18, 2021
a7c800e
repo: Move publishing configuration to convention
lorenzleutgeb Oct 18, 2021
c27f435
repo: Remove source JARs
lorenzleutgeb Oct 18, 2021
ab956a6
gradle: 7.0 -> 7.2
lorenzleutgeb Oct 18, 2021
4975f63
gradle: Migrate to KotlinScript
lorenzleutgeb Oct 18, 2021
8b5dde2
gradle: Fix compileClasspath to contain ANTLR
lorenzleutgeb Oct 18, 2021
8f82812
core: Remove Rete
lorenzleutgeb Oct 20, 2021
1f0359f
gradle: Use stringtemplateVersion
lorenzleutgeb Oct 20, 2021
a0e6fb1
gradle: Remove unnecessary `it`
lorenzleutgeb Oct 20, 2021
e45cbec
gradle: Fix use of mainClassName
lorenzleutgeb Oct 20, 2021
2ab14ec
gradle: Rename LICENSE/NOTICE in Kotlin
lorenzleutgeb Oct 21, 2021
14a7417
commons: Suppres warning about varargs
lorenzleutgeb Oct 21, 2021
4e43015
api: Convert TODOs to issues
lorenzleutgeb Oct 21, 2021
513e485
api: remove obsolete TODOs
madmike200590 Oct 21, 2021
b63eeb1
AbstractTerm: remove obsolete TODO
madmike200590 Oct 21, 2021
50a854b
commons: address TODOs, added to refactoring suggestions in #300
madmike200590 Oct 21, 2021
2ab3038
core: remove obsolete TODO
madmike200590 Oct 21, 2021
8702ecb
WIP: address TODOs
madmike200590 Oct 21, 2021
54922dd
gradle: Clean up dependency declarations
lorenzleutgeb Oct 26, 2021
797a871
doc: Remove reference to Externals from Predicate annotation
lorenzleutgeb Oct 26, 2021
0a7d5aa
Merge remote-tracking branch 'refs/remotes/origin/modules' into modules
madmike200590 Nov 5, 2021
8be4abc
WIP: api: javadoc
madmike200590 Nov 5, 2021
1a61d0b
api: javadoc for Alpha and related types
madmike200590 Nov 8, 2021
3c807ed
api: javadoc for configs
madmike200590 Nov 8, 2021
b3d0fe5
api: javadoc for public interfaces
madmike200590 Nov 8, 2021
e246463
api: javadocs for programs and graphs
madmike200590 Nov 9, 2021
f218181
api: javadoc for program building blocks
madmike200590 Nov 9, 2021
b1c51d7
remove deprecated method Alpha#getConfig
madmike200590 Nov 9, 2021
31e6cab
AnswerSetQuery: remove superfluous public modifiers
madmike200590 Nov 9, 2021
64d03b7
gradle: 7.0 -> 7.3
lorenzleutgeb Nov 10, 2021
bdbeeaf
Merge pull request #312 from alpha-asp/gradle-7.3
madmike200590 Nov 15, 2021
b186d30
Update alpha-api/src/main/java/at/ac/tuwien/kr/alpha/api/programs/Nor…
madmike200590 Nov 18, 2021
fcadbda
Update alpha-api/src/main/java/at/ac/tuwien/kr/alpha/api/programs/Pre…
madmike200590 Nov 18, 2021
619ad8c
Update alpha-api/src/main/java/at/ac/tuwien/kr/alpha/api/programs/ana…
madmike200590 Nov 18, 2021
69b4a1e
Update alpha-api/src/main/java/at/ac/tuwien/kr/alpha/api/programs/ato…
madmike200590 Nov 18, 2021
7912765
Update alpha-api/src/main/java/at/ac/tuwien/kr/alpha/api/terms/Arithm…
madmike200590 Nov 18, 2021
49c69ac
Update alpha-api/src/main/java/at/ac/tuwien/kr/alpha/api/programs/Pre…
madmike200590 Nov 18, 2021
f93fc2d
Reduce sources of compiler warnings.
AntoniusW Nov 19, 2021
b88b290
gradle: Fix indentation characters
lorenzleutgeb Nov 22, 2021
b07a088
gradle: Fix bundledJar and release docs
lorenzleutgeb Nov 22, 2021
073da17
cli: Add logging library
lorenzleutgeb Nov 22, 2021
d18bc72
Update alpha-commons/src/main/java/at/ac/tuwien/kr/alpha/commons/atom…
lorenzleutgeb Nov 22, 2021
1205889
Update alpha-cli-app/build.gradle.kts
lorenzleutgeb Nov 23, 2021
77474e9
Update alpha-commons/src/main/java/at/ac/tuwien/kr/alpha/commons/comp…
lorenzleutgeb Nov 24, 2021
33b8c12
core: Ignore ANTLR generated classes from coverage
lorenzleutgeb Nov 24, 2021
bb43ee1
Update alpha-core/src/test/java/at/ac/tuwien/kr/alpha/core/test/util/…
lorenzleutgeb Nov 28, 2021
f5fb4c8
Update alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/grounder/I…
lorenzleutgeb Nov 28, 2021
ae9b9ec
Update alpha-api/src/main/java/at/ac/tuwien/kr/alpha/api/Alpha.java
lorenzleutgeb Nov 28, 2021
900684e
Update alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/programs/t…
lorenzleutgeb Nov 28, 2021
42502bf
Update alpha-core/src/test/java/at/ac/tuwien/kr/alpha/core/test/util/…
lorenzleutgeb Nov 28, 2021
4fa05fc
Update alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/solver/Def…
lorenzleutgeb Nov 28, 2021
83c07e1
Add/Improve documentation of StatisticsReportingSolver and BinaryNoGo…
AntoniusW Nov 29, 2021
c65b8ea
Merge branch 'master' into modules
lorenzleutgeb Nov 29, 2021
d7f7189
core, commons: Remove dead code and TODOs
lorenzleutgeb Dec 1, 2021
bddb5d6
cli: Fix counting LICENSE files
lorenzleutgeb Dec 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

# Temporary/Generated Files
/out/
*/build

# Log files
junit.log

# Created by https://www.gitignore.io/api/java,gradle,eclipse

Expand Down Expand Up @@ -97,8 +101,9 @@ gradle-app.setting

### Custom additions ###
/.checkstyle
/junit.log
*/junit.log
.idea/modules/*.iml
*.tokens
/.dbeaver
/Scripts
/.vscode/
8 changes: 4 additions & 4 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ as JAR files and two scripts to run Alpha on Unix-like and Windows respectively.
To generate `alpha.jar`:

```bash
$ ./gradlew bundledJar
$ cp build/libs/alpha-bundled.jar alpha.jar
$ ./gradlew alpha-cli-app:bundledJar
$ cp alpha-cli-app/build/libs/alpha-cli*-bundled.jar alpha.jar
```

To generate `alpha.zip`:

```bash
$ ./gradlew distZip
$ cp build/distributions/alpha.zip alpha.zip
$ ./gradlew alpha-cli-app:distZip
$ cp alpha-cli-app/build/distributions/*.zip alpha.zip
```

Attach the two files to the release on GitHub, then publish the release. Lastly, check that everything is fine,
Expand Down
1 change: 1 addition & 0 deletions alpha-api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build/
3 changes: 3 additions & 0 deletions alpha-api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins {
id("alpha.java-library-conventions")
}
149 changes: 149 additions & 0 deletions alpha-api/src/main/java/at/ac/tuwien/kr/alpha/api/Alpha.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
package at.ac.tuwien.kr.alpha.api;

import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;

import at.ac.tuwien.kr.alpha.api.common.fixedinterpretations.PredicateInterpretation;
import at.ac.tuwien.kr.alpha.api.config.InputConfig;
import at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program;
import at.ac.tuwien.kr.alpha.api.programs.NormalProgram;
import at.ac.tuwien.kr.alpha.api.programs.Predicate;

/**
* Main API entry point for the Alpha ASP system. Provides facilities for parsing, normalizing and solving ASP programs.
*
* Copyright (c) 2021, the Alpha Team.
*/
public interface Alpha {

/**
* Reads an ASP program using the configuration and sources specified in a given {@link InputConfig}.
*
* @param cfg and {@link InputConfig} specifying program sources (strings, files) as well as config metadata (e.g. literate program,
* external atoms, etc)
* @return an {@link ASPCore2Program} representing the parsed ASP code from all sources referenced in the given {@link InputConfig}
* @throws IOException in case one or more program sources (e.g. files) cannot be read, or parsing fails
*/
ASPCore2Program readProgram(InputConfig cfg) throws IOException;

/**
* Reads and parses an {@link ASPCore2Program} from a list of {@link String}s representing paths.
*
* @param literate flag indicating whether ASP code should be treated as "literate".
* @param externals Custom {@link PredicateInterpretation}s for user-defined external atoms
* @param paths a list of {@link String}s representing paths containing all sources from which ASP code should be read
* @return an {@link ASPCore2Program} representing the parsed ASP code from all given path strings
* @throws IOException in case one or more program sources cannot be read, or parsing fails
*/
ASPCore2Program readProgramFiles(boolean literate, Map<String, PredicateInterpretation> externals, List<String> paths) throws IOException;

/**
* see {@link Alpha#readProgramFiles(boolean, Map, List)}
*/
ASPCore2Program readProgramFiles(boolean literate, Map<String, PredicateInterpretation> externals, Path... paths) throws IOException;

/**
* Parses a given String into an {@link ASPCore2Program}, using a map of custom {@link PredicateInterpretation}s to resolve external atoms
* in ASP code.
*
* @param aspString a string representing a valid ASP-Core2 program
* @param externals a map of custom {@link PredicateInterpretation}s against which external atoms in the given code are resolved
* @return an {@link ASPCore2Program} representing the parsed ASP code
*/
ASPCore2Program readProgramString(String aspString, Map<String, PredicateInterpretation> externals);

/**
* Convenience method to parse ASP strings not containing any user-defined external atoms, see {@link Alpha#readProgramString(String, Map)}.
*/
ASPCore2Program readProgramString(String aspString);

/**
* Prepares a {@link DebugSolvingContext} for the given {@link ASPCore2Program} to debug program preprocessing.
*
* @return a {@link DebugSolvingContext} holding debug information for the given program
*/
DebugSolvingContext prepareDebugSolve(final ASPCore2Program program);

/**
* Prepares a {@link DebugSolvingContext} for the given {@link NormalProgram} to debug program preprocessing.
*
* @return a {@link DebugSolvingContext} holding debug information for the given program
*/
DebugSolvingContext prepareDebugSolve(final NormalProgram program);

/**
* Prepares a {@link DebugSolvingContext} for the given {@link ASPCore2Program} to debug program preprocessing.
*
* @param filter a {@link java.util.function.Predicate} against which {@link Predicate}s of answer sets are tested.
* @return a {@link DebugSolvingContext} holding debug information for the given program
*/
DebugSolvingContext prepareDebugSolve(final ASPCore2Program program, java.util.function.Predicate<Predicate> filter);

/**
* Prepares a {@link DebugSolvingContext} for the given {@link NormalProgram} to debug program preprocessing.
*
* @param filter a {@link java.util.function.Predicate} against which {@link Predicate}s of answer sets are tested.
* @return a {@link DebugSolvingContext} holding debug information for the given program
*/
DebugSolvingContext prepareDebugSolve(final NormalProgram program, java.util.function.Predicate<Predicate> filter);

/**
* Solves the given {@link ASPCore2Program}.
* @param program an input program
* @return a {@link Stream} of {@link AnswerSet}s of the given program
*/
Stream<AnswerSet> solve(ASPCore2Program program);

/**
* Solves the given {@link ASPCore2Program}.
* @param program an input program
* @param filter a {@link java.util.function.Predicate} against which {@link Predicate}s of answer sets are tested.
* @return a {@link Stream} of {@link AnswerSet}s of the given program
*/
Stream<AnswerSet> solve(ASPCore2Program program, java.util.function.Predicate<Predicate> filter);

/**
* Solves the given {@link NormalProgram}.
* @param program an input program
* @return a {@link Stream} of {@link AnswerSet}s of the given program
*/
Stream<AnswerSet> solve(NormalProgram program);

/**
* Solves the given {@link NormalProgram}.
* @param program an input program
* @param filter a {@link java.util.function.Predicate} against which {@link Predicate}s of answer sets are tested.
* @return a {@link Stream} of {@link AnswerSet}s of the given program
*/
Stream<AnswerSet> solve(NormalProgram program, java.util.function.Predicate<Predicate> filter);

/**
* Normalizes a program, i.e. rewrites all syntax constructs not natively supported by Alphas back-end into semantically equivalent ASP code.
* See {@link NormalProgram},
* @param program An {@link ASPCore2Program} to normalize
* @return a {@link NormalProgram} that is a semantic equivalent to the given input program
*/
NormalProgram normalizeProgram(ASPCore2Program program);

/**
* Constructs a @{link Solver} pre-loaded with the given {@link ASPCore2Program} from which {@link AnswerSet}s can be obtained via {@link Solver#stream()}.
*
* @param program the program to solve
* @param filter a {@link java.util.function.Predicate} against which {@link Predicate}s of answer sets are tested.
* @return a {@link Solver} pre-loaded withthe given program
*/
Solver prepareSolverFor(ASPCore2Program program, java.util.function.Predicate<Predicate> filter);

/**
* Constructs a @{link Solver} pre-loaded with the given {@link NormalProgram} from which {@link AnswerSet}s can be obtained via {@link Solver#stream()}.
*
* @param program the program to solve
* @param filter a {@link java.util.function.Predicate} against which {@link Predicate}s of answer sets are tested.
* @return a {@link Solver} pre-loaded withthe given program
*/
Solver prepareSolverFor(NormalProgram program, java.util.function.Predicate<Predicate> filter);

}
35 changes: 35 additions & 0 deletions alpha-api/src/main/java/at/ac/tuwien/kr/alpha/api/AnswerSet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package at.ac.tuwien.kr.alpha.api;

import java.util.List;
import java.util.SortedSet;

import at.ac.tuwien.kr.alpha.api.programs.Predicate;
import at.ac.tuwien.kr.alpha.api.programs.atoms.Atom;

/**
* API representation of an answer set, i.e. a set of atoms that is a model of an ASP program.
*
* Copyright (c) 2021, the Alpha Team.
*/
public interface AnswerSet extends Comparable<AnswerSet> {

/**
* The set of all predicates contained in the answer set.
*/
SortedSet<Predicate> getPredicates();

/**
* All instances of the given predicate within the answer set.
*/
SortedSet<Atom> getPredicateInstances(Predicate predicate);

/**
* Boolean flag indicating whether this {@link AnswerSet} represents the empty set.
*/
boolean isEmpty();

/**
* List {@link Atom}s in this answer set satisfying the given {@link AnswerSetQuery}.
*/
List<Atom> query(AnswerSetQuery query);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package at.ac.tuwien.kr.alpha.api;

import java.util.List;

import at.ac.tuwien.kr.alpha.api.programs.atoms.Atom;
import at.ac.tuwien.kr.alpha.api.terms.Term;

/**
* A {@link java.util.function.Predicate} testing {@link Atom}s in order to query {@link AnswerSet}s for {@link Atom}s satisfying a specific
* query.
*
* Copyright (c) 2021, the Alpha Team.
*/
public interface AnswerSetQuery extends java.util.function.Predicate<Atom> {

/**
* Adds a filter predicate to apply on terms at the given index position.
*
* @param termIdx the term index on which to apply the new filter
* @param filter a filter predicate
* @return this answer set query withthe given filter added
*/
AnswerSetQuery withFilter(int termIdx, java.util.function.Predicate<Term> filter);

/**
* Convenience method - adds a filter to match names of symbolic constants against a string.
*
* @param termIdx
* @param str
* @return
*/
AnswerSetQuery withConstantEquals(int termIdx, String str);

/**
* Convenience method - adds a filter to match values of constant terms against a string.
*
* @param termIdx
* @param str
* @return
*/
AnswerSetQuery withStringEquals(int termIdx, String str);

/**
* Convenience method - adds a filter to check for function terms with a given function symbol and arity.
*
* @param termIdx
* @param funcSymbol
* @param funcArity
* @return
*/
AnswerSetQuery withFunctionTerm(int termIdx, String funcSymbol, int funcArity);

/**
* Convenience method - adds a filter to check whether a term is equal to a given term.
*
* @param termIdx
* @param otherTerm
* @return
*/
AnswerSetQuery withTermEquals(int termIdx, Term otherTerm);

/**
* Applies this query to an atom. Filters are worked off in
* order of ascending term index in a conjunctive fashion, i.e. for an atom
* to match the query, all of its terms must satisfy all filters on these
* terms
*
* @param atom the atom to which to apply the query
* @return true iff the atom satisfies the query
*/
@Override
boolean test(Atom atom);

/**
* Applies this query to an {@link AnswerSet}.
*
* @param as
* @return
*/
List<Atom> applyTo(AnswerSet as);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package at.ac.tuwien.kr.alpha.api;

import at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program;
import at.ac.tuwien.kr.alpha.api.programs.Predicate;
import at.ac.tuwien.kr.alpha.api.terms.Term;

/**
* A comparison operator that can be used in {@link ASPCore2Program}s.
*
* Copyright (c) 2021, the Alpha Team.
*/
public interface ComparisonOperator {

/**
* The operator symbol, i.e. the operator's string representation.
*/
String getSymbol();

/**
* The {@link Predicate} associated with this operator.
*/
Predicate toPredicate();

/**
* The inverse of this operator (e.g. the inverse of "=" is "!=")
*/
ComparisonOperator negate();

/**
* Tests whether two terms are in the relation defined by this operator.
*/
boolean compare(Term t1, Term t2);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package at.ac.tuwien.kr.alpha.api;

import at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program;
import at.ac.tuwien.kr.alpha.api.programs.NormalProgram;
import at.ac.tuwien.kr.alpha.api.programs.analysis.ComponentGraph;
import at.ac.tuwien.kr.alpha.api.programs.analysis.DependencyGraph;

/**
* Wrapper object for debug information on program preprocessing produced by {@link Alpha}.
*
* Copyright (c) 2021, the Alpha Team.
*/
public interface DebugSolvingContext {

/**
* The normalized version of the {@link ASPCore2Program} that is being solved.
* See {@link Alpha#normalizeProgram(ASPCore2Program)}.
*/
NormalProgram getNormalizedProgram();

/**
* The fully preprocessed version of the {@link ASPCore2Program} that is being solved.
* This differs from the value of {@link DebugSolvingContext#getNormalizedProgram()} in the stratified part of the normalized program may
* already be evaluated depending on the respective configuration of {@link Alpha}.
*/
NormalProgram getPreprocessedProgram();

/**
* The {@link DependencyGraph} of the program being solved.
*/
DependencyGraph getDependencyGraph();

/**
* The {@link ComponentGraph} of the program being solved.
*/
ComponentGraph getComponentGraph();

/**
* A {@link Solver} instance pre-loaded with the program being solved, from which {@link AnswerSet}s can be streamed.
*/
Solver getSolver();

}
Loading