Commit Graph

138 Commits

Author SHA1 Message Date
4a57a9e502
Prefix integer variables with “N”
Instead of suffixing integer variables with “i,” this prefixes them with
“N” instead to make it consistent with common mathematical notations.
2018-04-22 21:10:20 +02:00
ea885f5fdb
Fix integer detection
Clingo treats operations that were assumed to be “invalid” not as
processing errors but as operations returning an empty set.

This changes how formulas have to be evaluated. This commit implements
an explicit function for retrieving the return type of an expression,
that is, both the domain of the result as well as whether it’s an empty,
unit, or general set with multiple values.
2018-04-22 17:04:15 +02:00
92cd114cf8
Rename “general” domain to “noninteger”
The “general” domain wasn’t really about general variables, but meant as
a distinction from integer variables. For this reason, this commit
renames the “general” domain to “noninteger.”
2018-04-22 14:57:16 +02:00
2b62c6227d
Move Domain class to Utils header 2018-04-22 14:56:58 +02:00
97190ace71
Add integer check
This adds a function to check whether a term evaluates to a singular
integer.
2018-04-21 18:12:06 +02:00
d6a811e363
Move arithmetic check to separate header
Checking whether terms are arithmetic will be used not just in integer
variable detection but also in simplifying formulas with integer
variables. For this purpose, the arithmetic check is moved to a commonly
accessible header file.
2018-04-21 17:59:05 +02:00
b1ca027de5
Consolidate commonly used enum classes
This moves the commonly enum classes EvaluationResult, OperationResult,
and Tristate to the Utils header file to avoid code duplication.

Additionally, the SimplificationResult class is replaced by the
semantically similar OperationResult.
2018-04-21 17:34:52 +02:00
d1ee6eca19
Add suffix to variables with known domain
This adds suffixes to integer and general variables, where the domain is
explicitly known.
2018-04-20 16:37:49 +02:00
aedb7e9bbd
Add option to turn on integer variable detection 2018-04-20 16:37:49 +02:00
8b8dd1b57e
Minor refactoring 2018-04-20 16:37:49 +02:00
7bde7c498f
Represent predicate parameters explicitly
This adds a vector of Parameter structs to PredicateDeclaration. In this
way, the domain of each parameter can be tracked individually.
2018-04-20 16:37:48 +02:00
159717f51c
Support declaring functions as integer
This adds a new syntax for declaring functions integer:

    #external integer(<function name>(<arity)).

If a function is declared integer, it may enable some variables to be
detected as integer as well.
2018-04-20 16:37:48 +02:00
89aec98942
Minor refactoring 2018-04-20 16:37:48 +02:00
55f7fd4ff3
Minor refactoring 2018-04-20 16:37:48 +02:00
ae918a0846
Moved Domain enum to separate header
For clarity, this moves the Domain enum class to a separate header,
because it’s not just variable-specific but also applicable to
functions, for example.
2018-04-20 16:37:48 +02:00
f48802842e
Split functions from their declaration
This splits occurrences of functions from their declaration. This is
necessary to flag integer functions consistently and not just single
occurrences.
2018-04-20 16:37:48 +02:00
b5b05b766c
Remove Constant class
Constants are not a construct present in Clingo’s AST and were
unintentionally made part of anthem’s AST. This removes the unused
classes for clarity.
2018-04-20 16:37:48 +02:00
165f6ac059
Implement basic integer variable detection
This adds initial support for detecting integer variables in formulas.
The scope is somewhat limited in that variables matching predicate
parameters with known integer type aren’t propagated to be integer as
well yet. Also, the use of constants and functions prevents variables
from being detected as integer, because they have to be assumed to be
externally defined in such a way that they evaluate to general values
and not necessarily integers.
2018-04-20 16:37:48 +02:00
504f7da4c3
Add unknown variable domain
Before being able to tell whether a variable’s domain is general or
integer, it is necessary to flag it as “unknown.”
2018-04-20 16:37:48 +02:00
d2b48f9679
Move Tristate class to separate header
The Tristate class (representing truth values that are either true,
false, or unknown) is used at multiple ends. This moves it to a separate
header for reusing it properly.
2018-04-20 16:37:48 +02:00
2372eb24c4
Refactor predicate representation
This refactoring separates predicates from their declarations. The
purpose of this is to avoid duplicating properties specific to the
predicate declaration and not its occurrences in the program.
2018-04-20 16:37:47 +02:00
87dcd6ee93
Add domain specifier to variable declarations
With this change, the domain of variable declarations can be specified.
While the default is the general domain of all precomputed value, this
adds support for integer variables, for which advanced simplification
rules apply.
2018-04-20 16:37:47 +02:00
04094eee23
Remove unnecessary parentheses
The unary modulus operation does not require extra parentheses to be
printed in cases like “|X + Y|”. This adds a new option to the printing
routine to omit parentheses in cases where the parent expression already
defines a parenthesis-like scope (currently only with unary operations).
2018-04-12 00:59:03 +02:00
8c250f5c59
Support modulus operation (absolute value)
This adds support for computing the absolute value of a term along with
an according unit test.
2018-04-12 00:38:48 +02:00
6d7b91c391
Add new simplification rule
This adds the rule “(F <-> (F and G)) === (F -> G)” to the
simplification rule tableau.
2018-04-10 22:34:47 +02:00
b88393655a
Iteratively apply simplification tableau rules
With this change, the tableau rules for simplifying formula are applied
iteratively until a fixpoint is reached.
2018-04-10 22:34:47 +02:00
eaabeb0c55
Support exponentiation operator
Because of a bug in the Clingo API, the exponentation operator was not
properly exposed to anthem. This updates Clingo to a version with a
fixed API and adds proper support for exponentation within anthem along
with a matching unit test.
2018-04-10 22:29:55 +02:00
c294a29cb2
Support placeholders with #external declarations
This adds support for declaring predicates as placeholders through the
“#external” directive in the input language of clingo.

Placeholders are not subject to completion. This prevents predicates
that represent instance-specific facts from being assumed as universally
false by default negation when translating an encoding.

This stretches clingo’s usual syntax a bit to make the implementation
lightweight. In order to declare a predicate with a specific arity as a
placeholder, the following statement needs to be added to the program:

    #external <predicate name>(<arity>).

Multiple unit tests cover cases where placeholders are used or not as
well as a more complex graph coloring example.
2018-04-08 20:28:57 +02:00
22238bb398
Switch to C++17
With C++17, optionals, an experimental language feature, were moved to
the “std” namespace. This makes C++17 mandatory and drops the now
obsolete “experimental” namespace.
2018-03-24 16:09:52 +01:00
cbe87d8cb7
Fixed issue with simplifying binary operations in arguments. 2017-06-09 22:00:00 +02:00
9d1a1249d3
Removed obsolete to-do. 2017-06-09 20:19:46 +02:00
bbbd0b65a4
Added new option --parentheses=full to make parsing the output easier. 2017-06-06 02:02:26 +02:00
0285c1cbbb
Renamed internal variables for clarity. 2017-06-06 01:44:44 +02:00
14abc37116
Implemented #show statements for completed output. 2017-06-05 03:02:22 +02:00
b4c8ce3dc4
Extended AST visitors with optional return type. 2017-06-04 21:59:19 +02:00
4ed4458f1b
Fixed typos in error messages. 2017-06-04 04:43:07 +02:00
64bd1c17e3
Improved debug output. 2017-06-02 14:59:13 +02:00
2bc60d3eea
Started implementing support for #show statements. 2017-06-01 04:05:11 +02:00
663c59c470
Removed unused function. 2017-06-01 03:43:18 +02:00
85614296e2
Improved debug message. 2017-06-01 03:32:19 +02:00
cdcee897ec
Added missing error message when input file does not exist. 2017-06-01 03:29:09 +02:00
4baed6fbc6
Added back completion support. 2017-06-01 02:37:45 +02:00
c47bd3c934
Noted to-do. 2017-06-01 02:32:45 +02:00
b918da3c49
Minor formatting. 2017-06-01 00:19:09 +02:00
e998c5b7be
Removed unused variable. 2017-06-01 00:16:02 +02:00
957457939c
Minor formatting. 2017-06-01 00:15:48 +02:00
4f003a8730
Noted to-do. 2017-05-31 18:12:24 +02:00
830b8846d6
Added more constructor options for exceptions. 2017-05-31 18:10:55 +02:00
193b7f5c91
Noted to-do. 2017-05-31 18:07:27 +02:00
0d8b1e94da
Refactored error handling. 2017-05-31 18:03:19 +02:00