Compare commits
5 Commits
v0.1.7-rc.
...
v0.1.7
Author | SHA1 | Date | |
---|---|---|---|
582b6ade6d
|
|||
e64b2e70de
|
|||
d7e4af98d7
|
|||
a406cb43bd
|
|||
c294a29cb2
|
@@ -1,6 +1,6 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
## 0.1.7 RC 3 (2018-04-07)
|
## 0.1.7 (2018-04-08)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# The MIT License (MIT)
|
# The MIT License (MIT)
|
||||||
|
|
||||||
Copyright © 2016–2017 Patrick Lühne
|
Copyright © 2016–2018 Patrick Lühne
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@@ -70,7 +70,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (version)
|
if (version)
|
||||||
{
|
{
|
||||||
std::cout << "anthem version 0.1.7-rc.3" << std::endl;
|
std::cout << "anthem version 0.1.7" << std::endl;
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,12 +1,9 @@
|
|||||||
colored(V, red) :- vertex(V), not colored(V, green), not colored(V, blue).
|
#external color(1).
|
||||||
colored(V, green) :- vertex(V), not colored(V, red), not colored(V, blue).
|
#external edge(2).
|
||||||
colored(V, blue) :- vertex(V), not colored(V, red), not colored(V, green).
|
#external vertex(1).
|
||||||
|
#show color/2.
|
||||||
|
|
||||||
:- edge(V1, V2), colored(V1, C), colored(V2, C).
|
{color(V,C)} :- vertex(V), color(C).
|
||||||
|
covered(V) :- color(V, _).
|
||||||
vertex(a).
|
:- vertex(V), not covered(V).
|
||||||
vertex(b).
|
:- color(V1,C), color(V2,C), edge(V1,V2).
|
||||||
vertex(c).
|
|
||||||
|
|
||||||
edge(a, b).
|
|
||||||
edge(a, c).
|
|
||||||
|
@@ -59,7 +59,7 @@ bool VariableStack::contains(const VariableDeclaration &variableDeclaration) con
|
|||||||
};
|
};
|
||||||
|
|
||||||
const auto layerContainsVariableDeclaration =
|
const auto layerContainsVariableDeclaration =
|
||||||
[&variableDeclaration, &variableDeclarationMatches](const auto &layer)
|
[&variableDeclarationMatches](const auto &layer)
|
||||||
{
|
{
|
||||||
return (std::find_if(layer->cbegin(), layer->cend(), variableDeclarationMatches) != layer->cend());
|
return (std::find_if(layer->cbegin(), layer->cend(), variableDeclarationMatches) != layer->cend());
|
||||||
};
|
};
|
||||||
|
62
tests/TestPlaceholders.cpp
Normal file
62
tests/TestPlaceholders.cpp
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
#include <catch.hpp>
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
#include <anthem/AST.h>
|
||||||
|
#include <anthem/Context.h>
|
||||||
|
#include <anthem/Translation.h>
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
TEST_CASE("[placeholders] Programs with placeholders are correctly completed", "[placeholders]")
|
||||||
|
{
|
||||||
|
std::stringstream input;
|
||||||
|
std::stringstream output;
|
||||||
|
std::stringstream errors;
|
||||||
|
|
||||||
|
anthem::output::Logger logger(output, errors);
|
||||||
|
anthem::Context context(std::move(logger));
|
||||||
|
context.performSimplification = true;
|
||||||
|
context.performCompletion = true;
|
||||||
|
|
||||||
|
SECTION("no placeholders")
|
||||||
|
{
|
||||||
|
input <<
|
||||||
|
"colored(V, red) :- vertex(V), not colored(V, green), not colored(V, blue).";
|
||||||
|
anthem::translate("input", input, context);
|
||||||
|
|
||||||
|
CHECK(output.str() ==
|
||||||
|
"forall V1, V2 (colored(V1, V2) <-> (V2 = red and vertex(V1) and not colored(V1, green) and not colored(V1, blue)))\n"
|
||||||
|
"forall V3 not vertex(V3)\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("single placeholder")
|
||||||
|
{
|
||||||
|
input <<
|
||||||
|
"#external vertex(1).\n"
|
||||||
|
"colored(V, red) :- vertex(V), not colored(V, green), not colored(V, blue).";
|
||||||
|
anthem::translate("input", input, context);
|
||||||
|
|
||||||
|
CHECK(output.str() ==
|
||||||
|
"forall V1, V2 (colored(V1, V2) <-> (V2 = red and vertex(V1) and not colored(V1, green) and not colored(V1, blue)))\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("complex example: graph coloring")
|
||||||
|
{
|
||||||
|
input <<
|
||||||
|
"#external color(1).\n"
|
||||||
|
"#external edge(2).\n"
|
||||||
|
"#external vertex(1).\n"
|
||||||
|
"#show color/2.\n"
|
||||||
|
"{color(V, C)} :- vertex(V), color(C).\n"
|
||||||
|
"covered(V) :- color(V, _).\n"
|
||||||
|
":- vertex(V), not covered(V).\n"
|
||||||
|
":- color(V1, C), color(V2, C), edge(V1, V2).";
|
||||||
|
anthem::translate("input", input, context);
|
||||||
|
|
||||||
|
CHECK(output.str() ==
|
||||||
|
"forall V1, V2 (color(V1, V2) <-> (vertex(V1) and color(V2) and color(V1, V2)))\n"
|
||||||
|
"forall U1 not (vertex(U1) and not exists U2 color(U1, U2))\n"
|
||||||
|
"forall U3, U4, U5 not (color(U3, U4) and color(U5, U4) and edge(U3, U5))\n");
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user