Merge lp:~tapaal-ltl/verifypn/rule-D-fix into lp:verifypn

Proposed by Simon Virenfeldt
Status: Merged
Approved by: Jiri Srba
Approved revision: 241
Merged at revision: 241
Proposed branch: lp:~tapaal-ltl/verifypn/rule-D-fix
Merge into: lp:verifypn
Diff against target: 97 lines (+29/-5)
2 files modified
include/PetriEngine/Reducer.h (+2/-1)
src/PetriEngine/Reducer.cpp (+27/-4)
To merge this branch: bzr merge lp:~tapaal-ltl/verifypn/rule-D-fix
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Peter Gjøl Jensen Approve
Review via email: mp+404512@code.launchpad.net

Commit message

Fix logic error in structural reduction Rule D for LTL and CTL.

Description of the change

Adds a check to the structural reduction rule D if we are in LTL or CTL such that if the weights are not equal and the pre or post places are mentioned in the query we will not remove the transition.

To post a comment you must log in.
Revision history for this message
Peter Gjøl Jensen (peter-gjoel) wrote :

Looks good to me.

review: Approve
Revision history for this message
Peter Gjøl Jensen (peter-gjoel) wrote :

Passes regression on MCC2020 models (changes answer on GlobalResAllocation-COL-09-CTLCardinality-00 on colored nets as intended)

review: Approve
Revision history for this message
Jiri Srba (srba) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/PetriEngine/Reducer.h'
2--- include/PetriEngine/Reducer.h 2021-02-12 12:09:19 +0000
3+++ include/PetriEngine/Reducer.h 2021-06-22 09:27:59 +0000
4@@ -14,6 +14,7 @@
5 #include "NetStructures.h"
6
7 #include <vector>
8+#include <optional>
9
10 namespace PetriEngine {
11
12@@ -131,7 +132,7 @@
13 bool ReducebyRuleA(uint32_t* placeInQuery);
14 bool ReducebyRuleB(uint32_t* placeInQuery, bool remove_deadlocks, bool remove_consumers);
15 bool ReducebyRuleC(uint32_t* placeInQuery);
16- bool ReducebyRuleD(uint32_t* placeInQuery);
17+ bool ReducebyRuleD(uint32_t *placeInQuery, bool remove_consumers);
18 bool ReducebyRuleE(uint32_t* placeInQuery);
19 bool ReducebyRuleI(uint32_t* placeInQuery, bool remove_loops, bool remove_consumers);
20 bool ReducebyRuleF(uint32_t* placeInQuery);
21
22=== modified file 'src/PetriEngine/Reducer.cpp'
23--- src/PetriEngine/Reducer.cpp 2021-03-06 10:56:46 +0000
24+++ src/PetriEngine/Reducer.cpp 2021-06-22 09:27:59 +0000
25@@ -711,7 +711,7 @@
26 return continueReductions;
27 }
28
29- bool Reducer::ReducebyRuleD(uint32_t* placeInQuery) {
30+ bool Reducer::ReducebyRuleD(uint32_t *placeInQuery, bool remove_consumers) {
31 // Rule D - two transitions with the same pre and post and same inhibitor arcs
32 // This does not alter the trace.
33 bool continueReductions = false;
34@@ -742,6 +742,8 @@
35 Transition& tout = getTransition(touter);
36 if (tout.skip) continue;
37
38+
39+
40 // D2. No inhibitors
41 if (tout.inhib) continue;
42
43@@ -799,6 +801,27 @@
44 if (ok == 2) break;
45 else if (ok == 1) continue;
46
47+
48+ // If we are in CTL or LTL and the weights are not the same an additional requirement is needed.
49+ // In this case we cannot reduce if the pre or postset of the transition is in the query.
50+ if (!remove_consumers && mult != 1){
51+ bool has_place_in_query = false;
52+ for (const auto &arc : tout.pre) {
53+ if (placeInQuery[arc.place]) {
54+ has_place_in_query = true;
55+ break;
56+ }
57+ }
58+ if (has_place_in_query) break;
59+ for (const auto &arc : tout.post) {
60+ if (placeInQuery[arc.place]) {
61+ has_place_in_query = true;
62+ break;
63+ }
64+ }
65+ if (has_place_in_query) break;
66+ }
67+
68 // D3. Presets must match
69 for (int i = trans1.pre.size() - 1; i >= 0; --i) {
70 Arc& arc = trans1.pre[i];
71@@ -1620,7 +1643,7 @@
72 if(!next_safe)
73 {
74 while(ReducebyRuleA(context.getQueryPlaceCount())) changed = true;
75- while(ReducebyRuleD(context.getQueryPlaceCount())) changed = true;
76+ while(ReducebyRuleD(context.getQueryPlaceCount(), remove_consumers)) changed = true;
77 while(ReducebyRuleH(context.getQueryPlaceCount())) changed = true;
78 }
79 }
80@@ -1642,7 +1665,7 @@
81 while(ReducebyRuleG(context.getQueryPlaceCount(), remove_loops, remove_consumers)) changed = true;
82 if(!remove_loops)
83 while(ReducebyRuleI(context.getQueryPlaceCount(), remove_loops, remove_consumers)) changed = true;
84- while(ReducebyRuleD(context.getQueryPlaceCount())) changed = true;
85+ while(ReducebyRuleD(context.getQueryPlaceCount(), remove_consumers)) changed = true;
86 //changed |= ReducebyRuleK(context.getQueryPlaceCount(), remove_consumers); //Rule disabled as correctness has not been proved. Experiments indicate that it is not correct for CTL.
87 }
88 } while(changed && !hasTimedout());
89@@ -1704,7 +1727,7 @@
90 while(ReducebyRuleC(context.getQueryPlaceCount())) changed = true;
91 break;
92 case 3:
93- while(ReducebyRuleD(context.getQueryPlaceCount())) changed = true;
94+ while(ReducebyRuleD(context.getQueryPlaceCount(), remove_consumers)) changed = true;
95 break;
96 case 4:
97 while(ReducebyRuleE(context.getQueryPlaceCount())) changed = true;

Subscribers

People subscribed via source and target branches