Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif()

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Project Definition
set(VERIFYPN_NAME "verifypn")
set(VERIFYPN_VERSION 4.4.2)
Expand Down
66 changes: 66 additions & 0 deletions boost_tests/explicit_engine_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "utils.h"
#include "PetriEngine/ExplicitColored/ExplicitColoredModelChecker.h"
#include "PetriEngine/ExplicitColored/ExpressionCompilers/ExplicitQueryPropositionCompiler.h"

using namespace PetriEngine;
using namespace PetriEngine::ExplicitColored;
Expand Down Expand Up @@ -48,3 +49,68 @@ BOOST_AUTO_TEST_CASE(KBound, * utf::timeout(5)) {
"FORMULA Ten voting tokens are reachable FALSE");
test_explicit_engine("referendum_colored_subtraction", ExplicitColoredModelChecker::Result::SATISFIED, 1, 10);
}

BOOST_AUTO_TEST_CASE(ColoredQueryFromXml, * utf::timeout(5)) {
auto [queries, querynames, sset, options] = load_explicit(
"/models/explicit-engine/referendum_colored_subtraction.pnml",
"/models/explicit-engine/referendum_color_query.xml",
{0}
);
ExplicitColoredModelChecker checker(sset, std::cout);
BOOST_TEST(checker.checkQuery(queries[0], options) == ExplicitColoredModelChecker::Result::SATISFIED);
}

BOOST_AUTO_TEST_CASE(PhilosophersColoredQueryFromXml, * utf::timeout(5)) {
auto [queries, querynames, sset, options] = load_explicit(
"/models/explicit-engine/philosophers_color_query.pnml",
"/models/explicit-engine/philosophers_color_query.xml",
{0}
);
options.trace = TraceLevel::None;
ExplicitColoredModelChecker checker(sset, std::cout);
BOOST_TEST(checker.checkQuery(queries[0], options) == ExplicitColoredModelChecker::Result::SATISFIED);
}

BOOST_AUTO_TEST_CASE(TokenRingColoredQueryFromXml, * utf::timeout(5)) {
auto [queries, querynames, sset, options] = load_explicit(
"/models/explicit-engine/token_ring_color_query.pnml",
"/models/explicit-engine/token_ring_color_query.xml",
{0}
);
options.trace = TraceLevel::None;
ExplicitColoredModelChecker checker(sset, std::cout);
BOOST_TEST(checker.checkQuery(queries[0], options) == ExplicitColoredModelChecker::Result::SATISFIED);
}

BOOST_AUTO_TEST_CASE(ColoredQueryUsesExplicitTupleEncoding) {
Colored::ColorType first{"first"};
first.addColor("a0");
first.addColor("a1");
Colored::ColorType second{"second"};
second.addColor("b0");
second.addColor("b1");
second.addColor("b2");
Colored::ProductType product{"product"};
product.addType(&first);
product.addType(&second);

ExplicitColoredPetriNetBuilder builder;
builder.addColorType("product", &product);
Colored::Multiset marking;
const auto* selected = product.getColor(std::vector<uint32_t>{1, 0});
marking[selected] = 4;
builder.addPlace("P", &product, std::move(marking), 0, 0);

auto net = builder.takeNet();
ColoredSuccessorGenerator successorGenerator{net};
ExplicitQueryPropositionCompiler compiler{
net, builder.getPlaceIndices(), builder.getTransitionIndices(), successorGenerator
};
auto query = std::make_shared<PQL::EqualCondition>(
std::make_shared<PQL::UnfoldedIdentifierExpr>(std::make_shared<const_string>("P_1")),
std::make_shared<PQL::LiteralExpr>(4)
);

const auto proposition = compiler.compile(query);
BOOST_TEST(proposition->eval(successorGenerator, net.initial(), 0));
}
34 changes: 34 additions & 0 deletions boost_tests/models/explicit-engine/philosophers_color_query.pnml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<pnml>
<net id="ComposedModel" type="P/T net">
<declaration><structure><declarations>
<namedsort id="dot" name="dot"><dot/></namedsort>
<namedsort id="Philo" name="Philo"><cyclicenumeration><feconstant id="Id1" name="Philo"/><feconstant id="Id2" name="Philo"/><feconstant id="Id3" name="Philo"/><feconstant id="Id4" name="Philo"/><feconstant id="Id5" name="Philo"/></cyclicenumeration></namedsort>
<variabledecl id="x" name="x"><usersort declaration="Philo"/></variabledecl>
</declarations></structure></declaration>
<place id="Philosophers_dash_COL_dash_000005__think" name="Philosophers_dash_COL_dash_000005__think" initialMarking="5"><type><text>Philo</text><structure><usersort declaration="Philo"/></structure></type><hlinitialMarking><text>1'Id1 + 1'Id2 + 1'Id3 + 1'Id4 + 1'Id5</text><structure><add><subterm><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><useroperator declaration="Id1"/></subterm></numberof></subterm><subterm><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><useroperator declaration="Id2"/></subterm></numberof></subterm><subterm><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><useroperator declaration="Id3"/></subterm></numberof></subterm><subterm><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><useroperator declaration="Id4"/></subterm></numberof></subterm><subterm><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><useroperator declaration="Id5"/></subterm></numberof></subterm></add></structure></hlinitialMarking></place>
<place id="Philosophers_dash_COL_dash_000005__fork" name="Philosophers_dash_COL_dash_000005__fork" initialMarking="5"><type><text>Philo</text><structure><usersort declaration="Philo"/></structure></type><hlinitialMarking><text>1'Id1 + 1'Id2 + 1'Id3 + 1'Id4 + 1'Id5</text><structure><add><subterm><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><useroperator declaration="Id1"/></subterm></numberof></subterm><subterm><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><useroperator declaration="Id2"/></subterm></numberof></subterm><subterm><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><useroperator declaration="Id3"/></subterm></numberof></subterm><subterm><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><useroperator declaration="Id4"/></subterm></numberof></subterm><subterm><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><useroperator declaration="Id5"/></subterm></numberof></subterm></add></structure></hlinitialMarking></place>
<place id="Philosophers_dash_COL_dash_000005__catch1" name="Philosophers_dash_COL_dash_000005__catch1" initialMarking="0"><type><text>Philo</text><structure><usersort declaration="Philo"/></structure></type></place>
<place id="Philosophers_dash_COL_dash_000005__catch2" name="Philosophers_dash_COL_dash_000005__catch2" initialMarking="0"><type><text>Philo</text><structure><usersort declaration="Philo"/></structure></type></place>
<place id="Philosophers_dash_COL_dash_000005__eat" name="Philosophers_dash_COL_dash_000005__eat" initialMarking="0"><type><text>Philo</text><structure><usersort declaration="Philo"/></structure></type></place>
<transition player="0" id="Philosophers_dash_COL_dash_000005__ff1a" name="Philosophers_dash_COL_dash_000005__ff1a"><placeHolder/></transition>
<transition player="0" id="Philosophers_dash_COL_dash_000005__ff1b" name="Philosophers_dash_COL_dash_000005__ff1b"><placeHolder/></transition>
<transition player="0" id="Philosophers_dash_COL_dash_000005__ff2a" name="Philosophers_dash_COL_dash_000005__ff2a"><placeHolder/></transition>
<transition player="0" id="Philosophers_dash_COL_dash_000005__ff2b" name="Philosophers_dash_COL_dash_000005__ff2b"><placeHolder/></transition>
<transition player="0" id="Philosophers_dash_COL_dash_000005__end" name="Philosophers_dash_COL_dash_000005__end"><placeHolder/></transition>
<inputArc source="Philosophers_dash_COL_dash_000005__think" target="Philosophers_dash_COL_dash_000005__ff1a"><inscription><value>1</value></inscription><hlinscription><text>1'x</text><structure><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><variable refvariable="x"/></subterm></numberof></structure></hlinscription></inputArc>
<inputArc source="Philosophers_dash_COL_dash_000005__think" target="Philosophers_dash_COL_dash_000005__ff1b"><inscription><value>1</value></inscription><hlinscription><text>1'x</text><structure><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><variable refvariable="x"/></subterm></numberof></structure></hlinscription></inputArc>
<inputArc source="Philosophers_dash_COL_dash_000005__fork" target="Philosophers_dash_COL_dash_000005__ff1b"><inscription><value>1</value></inscription><hlinscription><text>1'x</text><structure><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><variable refvariable="x"/></subterm></numberof></structure></hlinscription></inputArc>
<inputArc source="Philosophers_dash_COL_dash_000005__fork" target="Philosophers_dash_COL_dash_000005__ff1a"><inscription><value>1</value></inscription><hlinscription><text>1'x--</text><structure><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><predecessor><subterm><variable refvariable="x"/></subterm></predecessor></subterm></numberof></structure></hlinscription></inputArc>
<inputArc source="Philosophers_dash_COL_dash_000005__fork" target="Philosophers_dash_COL_dash_000005__ff2b"><inscription><value>1</value></inscription><hlinscription><text>1'x--</text><structure><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><predecessor><subterm><variable refvariable="x"/></subterm></predecessor></subterm></numberof></structure></hlinscription></inputArc>
<inputArc source="Philosophers_dash_COL_dash_000005__fork" target="Philosophers_dash_COL_dash_000005__ff2a"><inscription><value>1</value></inscription><hlinscription><text>1'x</text><structure><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><variable refvariable="x"/></subterm></numberof></structure></hlinscription></inputArc>
<inputArc source="Philosophers_dash_COL_dash_000005__catch1" target="Philosophers_dash_COL_dash_000005__ff2a"><inscription><value>1</value></inscription><hlinscription><text>1'x</text><structure><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><variable refvariable="x"/></subterm></numberof></structure></hlinscription></inputArc>
<inputArc source="Philosophers_dash_COL_dash_000005__catch2" target="Philosophers_dash_COL_dash_000005__ff2b"><inscription><value>1</value></inscription><hlinscription><text>1'x</text><structure><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><variable refvariable="x"/></subterm></numberof></structure></hlinscription></inputArc>
<inputArc source="Philosophers_dash_COL_dash_000005__eat" target="Philosophers_dash_COL_dash_000005__end"><inscription><value>1</value></inscription><hlinscription><text>1'x</text><structure><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><variable refvariable="x"/></subterm></numberof></structure></hlinscription></inputArc>
<outputArc source="Philosophers_dash_COL_dash_000005__end" target="Philosophers_dash_COL_dash_000005__think"><inscription><value>1</value></inscription><hlinscription><text>1'x</text><structure><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><variable refvariable="x"/></subterm></numberof></structure></hlinscription></outputArc>
<outputArc source="Philosophers_dash_COL_dash_000005__ff1a" target="Philosophers_dash_COL_dash_000005__catch1"><inscription><value>1</value></inscription><hlinscription><text>1'x</text><structure><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><variable refvariable="x"/></subterm></numberof></structure></hlinscription></outputArc>
<outputArc source="Philosophers_dash_COL_dash_000005__ff1b" target="Philosophers_dash_COL_dash_000005__catch2"><inscription><value>1</value></inscription><hlinscription><text>1'x</text><structure><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><variable refvariable="x"/></subterm></numberof></structure></hlinscription></outputArc>
<outputArc source="Philosophers_dash_COL_dash_000005__ff2a" target="Philosophers_dash_COL_dash_000005__eat"><inscription><value>1</value></inscription><hlinscription><text>1'x</text><structure><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><variable refvariable="x"/></subterm></numberof></structure></hlinscription></outputArc>
<outputArc source="Philosophers_dash_COL_dash_000005__ff2b" target="Philosophers_dash_COL_dash_000005__eat"><inscription><value>1</value></inscription><hlinscription><text>1'x</text><structure><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><variable refvariable="x"/></subterm></numberof></structure></hlinscription></outputArc>
<outputArc source="Philosophers_dash_COL_dash_000005__end" target="Philosophers_dash_COL_dash_000005__fork"><inscription><value>1</value></inscription><hlinscription><text>1'x + 1'x--</text><structure><add><subterm><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><variable refvariable="x"/></subterm></numberof></subterm><subterm><numberof><subterm><numberconstant value="1"><positive/></numberconstant></subterm><subterm><predecessor><subterm><variable refvariable="x"/></subterm></predecessor></subterm></numberof></subterm></add></structure></hlinscription></outputArc>
</net>
</pnml>
32 changes: 32 additions & 0 deletions boost_tests/models/explicit-engine/philosophers_color_query.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<property-set xmlns="http://tapaal.net/">
<property>
<id>Can this state be reached?</id>
<description>Can this state be reached?</description>
<formula>
<exists-path>
<finally>
<conjunction>
<integer-eq><tokens-count><place>
Philosophers_dash_COL_dash_000005__catch2
<color-expression><color id="Id1"/></color-expression>
</place></tokens-count><integer-constant>1</integer-constant></integer-eq>
<integer-eq><tokens-count><place>
Philosophers_dash_COL_dash_000005__catch2
<color-expression><color id="Id5"/></color-expression>
</place></tokens-count><integer-constant>1</integer-constant></integer-eq>
<integer-eq><tokens-count><place>
Philosophers_dash_COL_dash_000005__think
<color-expression><color id="Id2"/></color-expression>
</place></tokens-count><integer-constant>1</integer-constant></integer-eq>
<integer-eq><tokens-count><place>Philosophers_dash_COL_dash_000005__eat</place></tokens-count><integer-constant>1</integer-constant></integer-eq>
<integer-eq><tokens-count><place>
Philosophers_dash_COL_dash_000005__catch1
<color-expression><color id="Id3"/></color-expression>
</place></tokens-count><integer-constant>1</integer-constant></integer-eq>
</conjunction>
</finally>
</exists-path>
</formula>
</property>
</property-set>
19 changes: 19 additions & 0 deletions boost_tests/models/explicit-engine/referendum_color_query.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<property-set xmlns="http://tapaal.net/">
<property>
<id>Selected voter reaches voting</id>
<description>Selected voter reaches voting</description>
<formula>
<exists-path>
<finally>
<integer-eq>
<tokens-count>
<place>Referendum_colored_voting<color-expression><color id="Voters1"/></color-expression></place>
</tokens-count>
<integer-constant>1</integer-constant>
</integer-eq>
</finally>
</exists-path>
</formula>
</property>
</property-set>
Loading
Loading