diff --git a/Makefile b/Makefile index 5815d1c748738f337647b12d7b3f41ba92e545c0..eadb0c2a48fda95d9627b27866cad7550d91dbc1 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ JAVA_DEPENDENCIES= :btypes.jar CPP_CODE_GEN_FLAGS=-l cpp -mc true CPPC ?= clang++ CPPFLAGS ?= -std=c++14 -O1 -flto +RS_CODE_GEN_FLAGS=-l rs -mc true STRATEGY=mixed THREADS=1 CACHING=false @@ -42,6 +43,13 @@ ifeq ($(LANGUAGE), cpp) $(CPPC) $(CPPFLAGS) -o $@.exec $@.cpp ./$@.exec $(STRATEGY) $(THREADS) $(CACHING) endif +ifneq (,$(findstring $(LANGUAGE), rs|RS|rust|Rust)) +%: + java -jar B2Program-all-0.1.0-SNAPSHOT.jar $(RS_CODE_GEN_FLAGS) -f $(DIRECTORY)/$@.mch + mv $(DIRECTORY)/$@.rs ./btypes_primitives/src/main/rust/bmachine/src/main.rs + mv $(DIRECTORY)/*.rs ./btypes_primitives/src/main/rust/bmachine/src/ + cargo run --release --manifest-path ./btypes_primitives/src/main/rust/bmachine/Cargo.toml -- $(STRATEGY) $(THREADS) $(CACHING) +endif endif # Usage: diff --git a/README.md b/README.md index 03b389fe419fb226da7b9837107fc7d07b8484c0..5a73cfc77e1b007733bf4e2497024965362fb68f 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ P is a conjunction of n conjuncts where the i-th conjunct must constraint xi for | Predicate | Meaning | |-----------------------|------------| | E = F | equality | -| E \= F | inequality | +| E \\= F | inequality | ### Booleans: @@ -141,7 +141,7 @@ P is a conjunction of n conjuncts where the i-th conjunct must constraint xi for | {} | Empty Set | | {E} | Singleton Set | | {E,F,...} | Set Enumeration | -| {x1,...,xn\ |P} | Set Comprehension | +| {x1,...,xn|P} | Set Comprehension | | POW(S) | Power Set | | POW1(S) | Set of Non-Empty Subsets | | FIN(S) | Set of All Finite Subsets | @@ -234,18 +234,18 @@ Restriction: Set of Relation mostly grows up very fast. They are only supported ### Functions: -| Function Expression | Meaning | -|---------------------|-----------------------------------| -| S +-> T | Partial Function | -| S --> T | Total Function | -| S +->> T | Partial Surjection | -| S -->> T | Total Surjection | -| S >+> T | Partial Injection | -| S >+>> T | Partial Bijection | -| S >->> T | Total Bijection | -| %(x1,...,xn).(P\|E) | Lambda Abstraction | -| f(E) | Function Application | -| f(E1,...,EN) | Function Application with Couples | +| Function Expression | Meaning | +|--------------------------|-----------------------------------| +| S +-> T | Partial Function | +| S --> T | Total Function | +| S +->> T | Partial Surjection | +| S -->> T | Total Surjection | +| S >+> T | Partial Injection | +| S >+>> T | Partial Bijection | +| S >->> T | Total Bijection | +| %(x1,...,xn).(P|E) | Lambda Abstraction | +| f(E) | Function Application | +| f(E1,...,EN) | Function Application with Couples | Restriction: Lambda expressions are quantified constructs. The predicate P must be a conjunction where the first n conjuncts must constraint the bounded variables. The i-th conjunct must constraint xi for each i in {1,...,n}. diff --git a/benchmarks/average_benchmark_results.py b/benchmarks/average_benchmark_results.py new file mode 100644 index 0000000000000000000000000000000000000000..1dc064f31ba71af39e5d18ec44378045bbe1dbca --- /dev/null +++ b/benchmarks/average_benchmark_results.py @@ -0,0 +1,53 @@ +import statistics +import sys +from datetime import timedelta + +file = sys.argv[1] +print('opening file: ', file) + +# {machine: { (mode: str, threads: int, caching: bool): {times: [], memory: []} }} +data = {} + +with open(file, 'r') as lines: + for line in lines: + #print('parsing line: ', line) + stripped_line = line.strip() + if stripped_line == '' or stripped_line.startswith('-'): + continue + machine, mode, threads, caching, time, memory = stripped_line.split(' ') + if machine not in data: + data[machine] = {} + params = (mode, int(threads), caching == 'true') + if params not in data[machine]: + data[machine][params] = {'times': [], 'memory': []} + data[machine][params]['times'] += [time] + data[machine][params]['memory'] += [int(memory)] + +for machine in data.keys(): + for params in data[machine]: + times = data[machine][params]['times'] + avg_time = timedelta() + number_of_datapoints = 0 + + for time in times: + number_of_datapoints += 1 + minutes = 0 + if ':' in time: + split = time.split(':') + minutes = int(split[0]) + time = split[1] + + millis = 0 + if '.' in time: + split = time.split('.') + millis = int(split[1].ljust(3, '0')) + time = split[0] + + seconds = int(time) + avg_time += timedelta(minutes=minutes, seconds=seconds, milliseconds=millis) + if number_of_datapoints > 0: + avg_time /= number_of_datapoints + + memories = data[machine][params]['memory'] + + print(f'{machine} {params[0]} {params[1]} {params[2]} {round(avg_time.total_seconds(), 2)} {round(statistics.fmean(memories))}') diff --git a/benchmarks/model_checking/Java/CAN_BUS_tlc.java b/benchmarks/model_checking/Java/CAN_BUS_tlc.java index 884724bf9b3fe0cde5f7efdb932d49bdef28dd68..7d97e0a9bdbcfb23a4a4cb5987f0982a1f153fa2 100644 --- a/benchmarks/model_checking/Java/CAN_BUS_tlc.java +++ b/benchmarks/model_checking/Java/CAN_BUS_tlc.java @@ -13,6 +13,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.Future; import java.util.concurrent.Executors; @@ -46,6 +47,12 @@ public class CAN_BUS_tlc { MIXED } + public CAN_BUS_tlc parent; + public Set<String> dependentGuard = new HashSet<>(); + public PersistentHashMap guardCache = PersistentHashMap.EMPTY; + public Set<String> dependentInvariant = new HashSet<>(); + public String stateAccessedVia; + private static BSet<BInteger> NATSET; @@ -164,6 +171,7 @@ public class CAN_BUS_tlc { T2_mode = T2mode.T2MODE_SENSE; } + public CAN_BUS_tlc(BSet<BInteger> NATSET, BInteger BUSpriority, BInteger BUSvalue, BRelation<BInteger, BInteger> BUSwrite, T1state T1_state, BInteger T1_timer, BInteger T1_writevalue, T2mode T2_mode, BInteger T2_readpriority, BInteger T2_readvalue, T2state T2_state, BInteger T2_timer, BInteger T2_writevalue, BInteger T2v, BBoolean T3_enabled, BBoolean T3_evaluated, BInteger T3_readpriority, BInteger T3_readvalue, T3state T3_state) { this.NATSET = NATSET; this.BUSpriority = BUSpriority; @@ -186,6 +194,7 @@ public class CAN_BUS_tlc { this.T3_state = T3_state; } + public void T1Evaluate() { T1_timer = new BInteger(0); T1_state = T1state.T1_CALC; @@ -754,1197 +763,1078 @@ public class CAN_BUS_tlc { return String.join("\n", "_get_BUSpriority: " + (this._get_BUSpriority()).toString(), "_get_BUSvalue: " + (this._get_BUSvalue()).toString(), "_get_BUSwrite: " + (this._get_BUSwrite()).toString(), "_get_T1_state: " + (this._get_T1_state()).toString(), "_get_T1_timer: " + (this._get_T1_timer()).toString(), "_get_T1_writevalue: " + (this._get_T1_writevalue()).toString(), "_get_T2_mode: " + (this._get_T2_mode()).toString(), "_get_T2_readpriority: " + (this._get_T2_readpriority()).toString(), "_get_T2_readvalue: " + (this._get_T2_readvalue()).toString(), "_get_T2_state: " + (this._get_T2_state()).toString(), "_get_T2_timer: " + (this._get_T2_timer()).toString(), "_get_T2_writevalue: " + (this._get_T2_writevalue()).toString(), "_get_T2v: " + (this._get_T2v()).toString(), "_get_T3_enabled: " + (this._get_T3_enabled()).toString(), "_get_T3_evaluated: " + (this._get_T3_evaluated()).toString(), "_get_T3_readpriority: " + (this._get_T3_readpriority()).toString(), "_get_T3_readvalue: " + (this._get_T3_readvalue()).toString(), "_get_T3_state: " + (this._get_T3_state()).toString()); } - @SuppressWarnings("unchecked") - private static Set<CAN_BUS_tlc> generateNextStates(Object guardLock, CAN_BUS_tlc state, boolean isCaching, Map<String, Set<String>> invariantDependency, Map<CAN_BUS_tlc, Set<String>> dependentInvariant, Map<String, Set<String>> guardDependency, Map<CAN_BUS_tlc, Set<String>> dependentGuard, Map<CAN_BUS_tlc, PersistentHashMap> guardCache, Map<CAN_BUS_tlc, CAN_BUS_tlc> parents, Map<CAN_BUS_tlc, String> stateAccessedVia, AtomicInteger transitions) { - Set<CAN_BUS_tlc> result = new HashSet<>(); - if(isCaching) { - PersistentHashMap parentsGuard = guardCache.get(parents.get(state)); - PersistentHashMap newCache = parentsGuard == null ? PersistentHashMap.EMPTY : parentsGuard; - Set<String> dependentGuardsOfState = dependentGuard.get(state); - Object cachedValue = null; - boolean dependentGuardsBoolean = true; - boolean _trid_1; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_T1Evaluate"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_T1Evaluate"); + + private static class ModelChecker { + private final Type type; + private final int threads; + private final boolean isCaching; + private final boolean isDebug; + + private final LinkedList<CAN_BUS_tlc> unvisitedStates = new LinkedList<>(); + private final Set<CAN_BUS_tlc> states = ConcurrentHashMap.newKeySet(); + private AtomicInteger transitions = new AtomicInteger(0); + private ThreadPoolExecutor threadPool; + private Object waitLock = new Object(); + + private AtomicBoolean invariantViolated = new AtomicBoolean(false); + private AtomicBoolean deadlockDetected = new AtomicBoolean(false); + private CAN_BUS_tlc counterExampleState = null; + + private final Map<String, Set<String>> invariantDependency = new HashMap<>(); + private final Map<String, Set<String>> guardDependency = new HashMap<>(); + + public ModelChecker(final Type type, final int threads, final boolean isCaching, final boolean isDebug) { + this.type = type; + this.threads = threads; + this.isCaching = isCaching; + this.isDebug = isDebug; + } + + public void modelCheck() { + if (isDebug) { + System.out.println("Starting Modelchecking, STRATEGY=" + type + ", THREADS=" + threads + ", CACHING=" + isCaching); } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_1 = state._tr_T1Evaluate(); + if (threads <= 1) { + modelCheckSingleThreaded(); } else { - _trid_1 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T1Evaluate", _trid_1); - if(_trid_1) { - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T1Evaluate(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("T1Evaluate")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("T1Evaluate")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T1Evaluate"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BInteger> _trid_2; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_T1Calculate"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_T1Calculate"); + this.threadPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(threads-1); + modelCheckMultiThreaded(); } + } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_2 = state._tr_T1Calculate(); - } else { - _trid_2 = (BSet<BInteger>) cachedValue; + private void modelCheckSingleThreaded() { + CAN_BUS_tlc machine = new CAN_BUS_tlc(); + states.add(machine); // TODO: store hashes instead of machine? + unvisitedStates.add(machine); + + if(isCaching) { + initCache(machine); } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T1Calculate", _trid_2); - for(BInteger param : _trid_2) { - BInteger _tmp_1 = param; - - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T1Calculate(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("T1Calculate")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("T1Calculate")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T1Calculate"); + + while(!unvisitedStates.isEmpty()) { + CAN_BUS_tlc state = next(); + + Set<CAN_BUS_tlc> nextStates = generateNextStates(state); + + nextStates.forEach(nextState -> { + if(!states.contains(nextState)) { + states.add(nextState); + unvisitedStates.add(nextState); + if(states.size() % 50000 == 0 && isDebug) { + System.out.println("VISITED STATES: " + states.size()); + System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); + System.out.println("-------------------"); + } } + }); + + if(invariantViolated(state)) { + invariantViolated.set(true); + counterExampleState = state; + break; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<BInteger, BInteger>> _trid_3; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_T1SendResult"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_T1SendResult"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_3 = state._tr_T1SendResult(); - } else { - _trid_3 = (BSet<BTuple<BInteger, BInteger>>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T1SendResult", _trid_3); - for(BTuple<BInteger, BInteger> param : _trid_3) { - BInteger _tmp_1 = param.projection2(); - BInteger _tmp_2 = param.projection1(); - - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T1SendResult(_tmp_2, _tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("T1SendResult")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("T1SendResult")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T1SendResult"); - } + if(nextStates.isEmpty()) { + deadlockDetected.set(true); + counterExampleState = state; + break; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BInteger> _trid_4; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_T1Wait"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_T1Wait"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_4 = state._tr_T1Wait(); - } else { - _trid_4 = (BSet<BInteger>) cachedValue; } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T1Wait", _trid_4); - for(BInteger param : _trid_4) { - BInteger _tmp_1 = param; - - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T1Wait(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("T1Wait")); + printResult(states.size(), transitions.get()); + } + + private void modelCheckMultiThreaded() { + CAN_BUS_tlc machine = new CAN_BUS_tlc(); + states.add(machine); + unvisitedStates.add(machine); + + AtomicBoolean stopThreads = new AtomicBoolean(false); + AtomicInteger possibleQueueChanges = new AtomicInteger(0); + + if(isCaching) { + initCache(machine); + } + + while(!unvisitedStates.isEmpty() && !stopThreads.get()) { + possibleQueueChanges.incrementAndGet(); + CAN_BUS_tlc state = next(); + Runnable task = () -> { + Set<CAN_BUS_tlc> nextStates = generateNextStates(state); + + nextStates.forEach(nextState -> { + if(states.add(nextState)) { + synchronized (unvisitedStates) { + unvisitedStates.add(nextState); + } + if(states.size() % 50000 == 0 && isDebug) { + System.out.println("VISITED STATES: " + states.size()); + System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); + System.out.println("-------------------"); + } + } + }); + + synchronized (unvisitedStates) { + int running = possibleQueueChanges.decrementAndGet(); + if (!unvisitedStates.isEmpty() || running == 0) { + synchronized (waitLock) { + waitLock.notify(); + } + } } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("T1Wait")); + + if(invariantViolated(state)) { + invariantViolated.set(true); + counterExampleState = state; + stopThreads.set(true); } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); + + if(nextStates.isEmpty()) { + deadlockDetected.set(true); + counterExampleState = state; + stopThreads.set(true); } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T1Wait"); + }; + threadPool.submit(task); + synchronized(waitLock) { + if (unvisitedStates.isEmpty() && possibleQueueChanges.get() > 0) { + try { + waitLock.wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } } } - result.add(copiedState); - transitions.getAndIncrement(); } - boolean _trid_5; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_T2Evaluate"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_T2Evaluate"); + threadPool.shutdown(); + try { + threadPool.awaitTermination(24, TimeUnit.HOURS); + } catch (InterruptedException e) { + e.printStackTrace(); } + printResult(states.size(), transitions.get()); + } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_5 = state._tr_T2Evaluate(); - } else { - _trid_5 = (boolean) cachedValue; + private void initCache(final CAN_BUS_tlc machine) { + invariantDependency.put("T1Wait", new HashSet<>(Arrays.asList("_check_inv_10", "_check_inv_4"))); + invariantDependency.put("T1Calculate", new HashSet<>(Arrays.asList("_check_inv_7", "_check_inv_4"))); + invariantDependency.put("T1SendResult", new HashSet<>(Arrays.asList("_check_inv_18", "_check_inv_19", "_check_inv_20", "_check_inv_4"))); + invariantDependency.put("T2ReadBus", new HashSet<>(Arrays.asList("_check_inv_17", "_check_inv_5", "_check_inv_9"))); + invariantDependency.put("T2Reset", new HashSet<>(Arrays.asList("_check_inv_1", "_check_inv_5", "_check_inv_8", "_check_inv_12"))); + invariantDependency.put("T2Complete", new HashSet<>(Arrays.asList("_check_inv_5", "_check_inv_12"))); + invariantDependency.put("T2Evaluate", new HashSet<>(Arrays.asList("_check_inv_5", "_check_inv_11"))); + invariantDependency.put("T3Evaluate", new HashSet<>(Arrays.asList("_check_inv_6"))); + invariantDependency.put("T3ReleaseBus", new HashSet<>(Arrays.asList("_check_inv_18", "_check_inv_19", "_check_inv_6", "_check_inv_20"))); + invariantDependency.put("T1Evaluate", new HashSet<>(Arrays.asList("_check_inv_10", "_check_inv_4"))); + invariantDependency.put("T3Initiate", new HashSet<>(Arrays.asList("_check_inv_3", "_check_inv_6"))); + invariantDependency.put("T3ReEnableWait", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_3", "_check_inv_6"))); + invariantDependency.put("T3writebus", new HashSet<>(Arrays.asList("_check_inv_18", "_check_inv_19", "_check_inv_6", "_check_inv_20"))); + invariantDependency.put("Update", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_10", "_check_inv_14", "_check_inv_13", "_check_inv_11"))); + invariantDependency.put("T2ReleaseBus", new HashSet<>(Arrays.asList("_check_inv_18", "_check_inv_19", "_check_inv_20", "_check_inv_5"))); + invariantDependency.put("T2Wait", new HashSet<>(Arrays.asList("_check_inv_5", "_check_inv_11"))); + invariantDependency.put("T3Poll", new HashSet<>(Arrays.asList("_check_inv_6"))); + invariantDependency.put("T2Calculate", new HashSet<>(Arrays.asList("_check_inv_1", "_check_inv_5"))); + invariantDependency.put("T3Read", new HashSet<>(Arrays.asList("_check_inv_16", "_check_inv_15", "_check_inv_6"))); + invariantDependency.put("T3Wait", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_6"))); + invariantDependency.put("T2WriteBus", new HashSet<>(Arrays.asList("_check_inv_18", "_check_inv_19", "_check_inv_20", "_check_inv_5"))); + guardDependency.put("T1Wait", new HashSet<>(Arrays.asList("_tr_T1Evaluate", "_tr_Update", "_tr_T1SendResult", "_tr_T1Calculate", "_tr_T1Wait"))); + guardDependency.put("T1Calculate", new HashSet<>(Arrays.asList("_tr_T1Evaluate", "_tr_T1SendResult", "_tr_T1Calculate", "_tr_T1Wait"))); + guardDependency.put("T1SendResult", new HashSet<>(Arrays.asList("_tr_T1Evaluate", "_tr_T2ReleaseBus", "_tr_Update", "_tr_T1SendResult", "_tr_T1Calculate", "_tr_T1Wait"))); + guardDependency.put("T2ReadBus", new HashSet<>(Arrays.asList("_tr_T2Reset", "_tr_T2ReleaseBus", "_tr_T2Complete", "_tr_T2Calculate", "_tr_T2Evaluate", "_tr_T2ReadBus", "_tr_T2WriteBus", "_tr_T2Wait"))); + guardDependency.put("T2Reset", new HashSet<>(Arrays.asList("_tr_T2Reset", "_tr_T2ReleaseBus", "_tr_T2Complete", "_tr_T2Calculate", "_tr_T2Evaluate", "_tr_T2ReadBus", "_tr_T2WriteBus", "_tr_T2Wait"))); + guardDependency.put("T2Complete", new HashSet<>(Arrays.asList("_tr_T2Reset", "_tr_T2ReleaseBus", "_tr_T2Complete", "_tr_T2Calculate", "_tr_T2Evaluate", "_tr_T2ReadBus", "_tr_T2WriteBus", "_tr_T2Wait"))); + guardDependency.put("T2Evaluate", new HashSet<>(Arrays.asList("_tr_T2Reset", "_tr_T2ReleaseBus", "_tr_T2Complete", "_tr_T2Calculate", "_tr_T2Evaluate", "_tr_Update", "_tr_T2ReadBus", "_tr_T2WriteBus", "_tr_T2Wait"))); + guardDependency.put("T3Evaluate", new HashSet<>(Arrays.asList("_tr_T3writebus", "_tr_T3Read", "_tr_T3ReleaseBus", "_tr_T3Poll", "_tr_T3ReEnableWait", "_tr_T3Evaluate", "_tr_T3Wait", "_tr_T3Initiate"))); + guardDependency.put("T3ReleaseBus", new HashSet<>(Arrays.asList("_tr_T2ReleaseBus", "_tr_T3writebus", "_tr_T3Read", "_tr_T3ReleaseBus", "_tr_T3Poll", "_tr_Update", "_tr_T3ReEnableWait", "_tr_T3Evaluate", "_tr_T3Wait", "_tr_T3Initiate"))); + guardDependency.put("T1Evaluate", new HashSet<>(Arrays.asList("_tr_T1Evaluate", "_tr_Update", "_tr_T1SendResult", "_tr_T1Calculate", "_tr_T1Wait"))); + guardDependency.put("T3Initiate", new HashSet<>(Arrays.asList("_tr_T3writebus", "_tr_T3Read", "_tr_T3ReleaseBus", "_tr_T3Poll", "_tr_Update", "_tr_T3ReEnableWait", "_tr_T3Evaluate", "_tr_T3Wait", "_tr_T3Initiate"))); + guardDependency.put("T3ReEnableWait", new HashSet<>(Arrays.asList("_tr_T3writebus", "_tr_T3Read", "_tr_T3ReleaseBus", "_tr_T3Poll", "_tr_Update", "_tr_T3ReEnableWait", "_tr_T3Evaluate", "_tr_T3Wait", "_tr_T3Initiate"))); + guardDependency.put("T3writebus", new HashSet<>(Arrays.asList("_tr_T2ReleaseBus", "_tr_T3writebus", "_tr_T3Read", "_tr_T3ReleaseBus", "_tr_T3Poll", "_tr_Update", "_tr_T3ReEnableWait", "_tr_T3Evaluate", "_tr_T3Wait", "_tr_T3Initiate"))); + guardDependency.put("Update", new HashSet<>(Arrays.asList("_tr_T1Evaluate", "_tr_T3Read", "_tr_T2Evaluate", "_tr_Update", "_tr_T2ReadBus", "_tr_T3Evaluate", "_tr_T3Initiate"))); + guardDependency.put("T2ReleaseBus", new HashSet<>(Arrays.asList("_tr_T2Reset", "_tr_T2ReleaseBus", "_tr_T2Complete", "_tr_T2Calculate", "_tr_T2Evaluate", "_tr_Update", "_tr_T2ReadBus", "_tr_T2WriteBus", "_tr_T2Wait"))); + guardDependency.put("T2Wait", new HashSet<>(Arrays.asList("_tr_T2Reset", "_tr_T2ReleaseBus", "_tr_T2Complete", "_tr_T2Calculate", "_tr_T2Evaluate", "_tr_Update", "_tr_T2ReadBus", "_tr_T2WriteBus", "_tr_T2Wait"))); + guardDependency.put("T3Poll", new HashSet<>(Arrays.asList("_tr_T3writebus", "_tr_T3Read", "_tr_T3ReleaseBus", "_tr_T3Poll", "_tr_T3ReEnableWait", "_tr_T3Evaluate", "_tr_T3Wait", "_tr_T3Initiate"))); + guardDependency.put("T2Calculate", new HashSet<>(Arrays.asList("_tr_T2Reset", "_tr_T2ReleaseBus", "_tr_T2Complete", "_tr_T2Calculate", "_tr_T2Evaluate", "_tr_T2ReadBus", "_tr_T2WriteBus", "_tr_T2Wait"))); + guardDependency.put("T3Read", new HashSet<>(Arrays.asList("_tr_T3writebus", "_tr_T3Read", "_tr_T3ReleaseBus", "_tr_T3Poll", "_tr_T3ReEnableWait", "_tr_T3Evaluate", "_tr_T3Wait", "_tr_T3Initiate"))); + guardDependency.put("T3Wait", new HashSet<>(Arrays.asList("_tr_T3writebus", "_tr_T3Read", "_tr_T3ReleaseBus", "_tr_T3Poll", "_tr_Update", "_tr_T3ReEnableWait", "_tr_T3Evaluate", "_tr_T3Wait", "_tr_T3Initiate"))); + guardDependency.put("T2WriteBus", new HashSet<>(Arrays.asList("_tr_T2Reset", "_tr_T2ReleaseBus", "_tr_T2Complete", "_tr_T2Calculate", "_tr_T2Evaluate", "_tr_Update", "_tr_T2ReadBus", "_tr_T2WriteBus", "_tr_T2Wait"))); + } + + private CAN_BUS_tlc next() { + synchronized(this.unvisitedStates) { + return switch(type) { + case BFS -> this.unvisitedStates.removeFirst(); + case DFS -> this.unvisitedStates.removeLast(); + case MIXED -> this.unvisitedStates.size() % 2 == 0 ? this.unvisitedStates.removeFirst() : this.unvisitedStates.removeLast(); + }; } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T2Evaluate", _trid_5); - if(_trid_5) { - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T2Evaluate(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("T2Evaluate")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("T2Evaluate")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T2Evaluate"); - } + } + + @SuppressWarnings("unchecked") + private Set<CAN_BUS_tlc> generateNextStates(final CAN_BUS_tlc state) { + Set<CAN_BUS_tlc> result = new HashSet<>(); + if(isCaching) { + PersistentHashMap parentsGuard = state.guardCache; + PersistentHashMap newCache = parentsGuard == null ? PersistentHashMap.EMPTY : parentsGuard; + Object cachedValue = null; + boolean dependentGuardsBoolean = true; + boolean _trid_1; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_T1Evaluate"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_T1Evaluate"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<BInteger, BInteger>> _trid_6; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_T2ReadBus"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_T2ReadBus"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_6 = state._tr_T2ReadBus(); - } else { - _trid_6 = (BSet<BTuple<BInteger, BInteger>>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T2ReadBus", _trid_6); - for(BTuple<BInteger, BInteger> param : _trid_6) { - BInteger _tmp_1 = param.projection2(); - BInteger _tmp_2 = param.projection1(); - - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T2ReadBus(_tmp_2, _tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("T2ReadBus")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("T2ReadBus")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T2ReadBus"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_1 = state._tr_T1Evaluate(); + } else { + _trid_1 = (boolean) cachedValue; + } + + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T1Evaluate", _trid_1); + if(_trid_1) { + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T1Evaluate(); + copiedState.parent = state; + addCachedInfos("T1Evaluate", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<BInteger> _trid_2; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_T1Calculate"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_T1Calculate"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_7; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_T2Reset"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_T2Reset"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_7 = state._tr_T2Reset(); - } else { - _trid_7 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T2Reset", _trid_7); - if(_trid_7) { - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T2Reset(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("T2Reset")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("T2Reset")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T2Reset"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_2 = state._tr_T1Calculate(); + } else { + _trid_2 = (BSet<BInteger>) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_8; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_T2Complete"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_T2Complete"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T1Calculate", _trid_2); + for(BInteger param : _trid_2) { + BInteger _tmp_1 = param; + + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T1Calculate(_tmp_1); + copiedState.parent = state; + addCachedInfos("T1Calculate", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_8 = state._tr_T2Complete(); - } else { - _trid_8 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T2Complete", _trid_8); - if(_trid_8) { - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T2Complete(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("T2Complete")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("T2Complete")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T2Complete"); - } } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BInteger> _trid_9; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_T2ReleaseBus"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_T2ReleaseBus"); - } + BSet<BTuple<BInteger, BInteger>> _trid_3; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_T1SendResult"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_T1SendResult"); + } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_9 = state._tr_T2ReleaseBus(); - } else { - _trid_9 = (BSet<BInteger>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T2ReleaseBus", _trid_9); - for(BInteger param : _trid_9) { - BInteger _tmp_1 = param; - - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T2ReleaseBus(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("T2ReleaseBus")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("T2ReleaseBus")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T2ReleaseBus"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_3 = state._tr_T1SendResult(); + } else { + _trid_3 = (BSet<BTuple<BInteger, BInteger>>) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_10; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_T2Calculate"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_T2Calculate"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T1SendResult", _trid_3); + for(BTuple<BInteger, BInteger> param : _trid_3) { + BInteger _tmp_1 = param.projection2(); + BInteger _tmp_2 = param.projection1(); + + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T1SendResult(_tmp_2, _tmp_1); + copiedState.parent = state; + addCachedInfos("T1SendResult", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_10 = state._tr_T2Calculate(); - } else { - _trid_10 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T2Calculate", _trid_10); - if(_trid_10) { - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T2Calculate(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("T2Calculate")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("T2Calculate")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T2Calculate"); - } } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<BInteger, BInteger>> _trid_11; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_T2WriteBus"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_T2WriteBus"); - } + BSet<BInteger> _trid_4; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_T1Wait"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_T1Wait"); + } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_11 = state._tr_T2WriteBus(); - } else { - _trid_11 = (BSet<BTuple<BInteger, BInteger>>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T2WriteBus", _trid_11); - for(BTuple<BInteger, BInteger> param : _trid_11) { - BInteger _tmp_1 = param.projection2(); - BInteger _tmp_2 = param.projection1(); - - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T2WriteBus(_tmp_2, _tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("T2WriteBus")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("T2WriteBus")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T2WriteBus"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_4 = state._tr_T1Wait(); + } else { + _trid_4 = (BSet<BInteger>) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BInteger> _trid_12; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_T2Wait"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_T2Wait"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T1Wait", _trid_4); + for(BInteger param : _trid_4) { + BInteger _tmp_1 = param; + + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T1Wait(_tmp_1); + copiedState.parent = state; + addCachedInfos("T1Wait", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_12 = state._tr_T2Wait(); - } else { - _trid_12 = (BSet<BInteger>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T2Wait", _trid_12); - for(BInteger param : _trid_12) { - BInteger _tmp_1 = param; - - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T2Wait(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("T2Wait")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("T2Wait")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T2Wait"); - } } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_13; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_T3Initiate"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_T3Initiate"); - } + boolean _trid_5; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_T2Evaluate"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_T2Evaluate"); + } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_13 = state._tr_T3Initiate(); - } else { - _trid_13 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T3Initiate", _trid_13); - if(_trid_13) { - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T3Initiate(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("T3Initiate")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("T3Initiate")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T3Initiate"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_5 = state._tr_T2Evaluate(); + } else { + _trid_5 = (boolean) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_14; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_T3Evaluate"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_T3Evaluate"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_14 = state._tr_T3Evaluate(); - } else { - _trid_14 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T3Evaluate", _trid_14); - if(_trid_14) { - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T3Evaluate(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("T3Evaluate")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("T3Evaluate")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T3Evaluate"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T2Evaluate", _trid_5); + if(_trid_5) { + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T2Evaluate(); + copiedState.parent = state; + addCachedInfos("T2Evaluate", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<BTuple<BInteger, BInteger>> _trid_6; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_T2ReadBus"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_T2ReadBus"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<BInteger, BInteger>> _trid_15; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_T3writebus"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_T3writebus"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_15 = state._tr_T3writebus(); - } else { - _trid_15 = (BSet<BTuple<BInteger, BInteger>>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T3writebus", _trid_15); - for(BTuple<BInteger, BInteger> param : _trid_15) { - BInteger _tmp_1 = param.projection2(); - BInteger _tmp_2 = param.projection1(); - - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T3writebus(_tmp_2, _tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("T3writebus")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("T3writebus")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T3writebus"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_6 = state._tr_T2ReadBus(); + } else { + _trid_6 = (BSet<BTuple<BInteger, BInteger>>) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<BInteger, BInteger>> _trid_16; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_T3Read"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_T3Read"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T2ReadBus", _trid_6); + for(BTuple<BInteger, BInteger> param : _trid_6) { + BInteger _tmp_1 = param.projection2(); + BInteger _tmp_2 = param.projection1(); + + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T2ReadBus(_tmp_2, _tmp_1); + copiedState.parent = state; + addCachedInfos("T2ReadBus", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_16 = state._tr_T3Read(); - } else { - _trid_16 = (BSet<BTuple<BInteger, BInteger>>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T3Read", _trid_16); - for(BTuple<BInteger, BInteger> param : _trid_16) { - BInteger _tmp_1 = param.projection2(); - BInteger _tmp_2 = param.projection1(); - - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T3Read(_tmp_2, _tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("T3Read")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("T3Read")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T3Read"); - } } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_17; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_T3Poll"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_T3Poll"); - } + boolean _trid_7; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_T2Reset"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_T2Reset"); + } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_17 = state._tr_T3Poll(); - } else { - _trid_17 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T3Poll", _trid_17); - if(_trid_17) { - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T3Poll(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("T3Poll")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("T3Poll")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T3Poll"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_7 = state._tr_T2Reset(); + } else { + _trid_7 = (boolean) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BInteger> _trid_18; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_T3ReleaseBus"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_T3ReleaseBus"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_18 = state._tr_T3ReleaseBus(); - } else { - _trid_18 = (BSet<BInteger>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T3ReleaseBus", _trid_18); - for(BInteger param : _trid_18) { - BInteger _tmp_1 = param; - - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T3ReleaseBus(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("T3ReleaseBus")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("T3ReleaseBus")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T3ReleaseBus"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T2Reset", _trid_7); + if(_trid_7) { + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T2Reset(); + copiedState.parent = state; + addCachedInfos("T2Reset", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_8; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_T2Complete"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_T2Complete"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_19; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_T3Wait"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_T3Wait"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_19 = state._tr_T3Wait(); - } else { - _trid_19 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T3Wait", _trid_19); - if(_trid_19) { - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T3Wait(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("T3Wait")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("T3Wait")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T3Wait"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_8 = state._tr_T2Complete(); + } else { + _trid_8 = (boolean) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_20; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_T3ReEnableWait"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_T3ReEnableWait"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_20 = state._tr_T3ReEnableWait(); - } else { - _trid_20 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T3ReEnableWait", _trid_20); - if(_trid_20) { - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T3ReEnableWait(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("T3ReEnableWait")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("T3ReEnableWait")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T3ReEnableWait"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T2Complete", _trid_8); + if(_trid_8) { + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T2Complete(); + copiedState.parent = state; + addCachedInfos("T2Complete", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<BInteger> _trid_9; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_T2ReleaseBus"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_T2ReleaseBus"); + } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_9 = state._tr_T2ReleaseBus(); + } else { + _trid_9 = (BSet<BInteger>) cachedValue; + } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T2ReleaseBus", _trid_9); + for(BInteger param : _trid_9) { + BInteger _tmp_1 = param; + + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T2ReleaseBus(_tmp_1); + copiedState.parent = state; + addCachedInfos("T2ReleaseBus", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_10; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_T2Calculate"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_T2Calculate"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BInteger> _trid_21; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_Update"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_Update"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_21 = state._tr_Update(); + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_10 = state._tr_T2Calculate(); + } else { + _trid_10 = (boolean) cachedValue; + } + + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T2Calculate", _trid_10); + if(_trid_10) { + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T2Calculate(); + copiedState.parent = state; + addCachedInfos("T2Calculate", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<BTuple<BInteger, BInteger>> _trid_11; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_T2WriteBus"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_T2WriteBus"); + } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_11 = state._tr_T2WriteBus(); + } else { + _trid_11 = (BSet<BTuple<BInteger, BInteger>>) cachedValue; + } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T2WriteBus", _trid_11); + for(BTuple<BInteger, BInteger> param : _trid_11) { + BInteger _tmp_1 = param.projection2(); + BInteger _tmp_2 = param.projection1(); + + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T2WriteBus(_tmp_2, _tmp_1); + copiedState.parent = state; + addCachedInfos("T2WriteBus", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<BInteger> _trid_12; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_T2Wait"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_T2Wait"); + } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_12 = state._tr_T2Wait(); + } else { + _trid_12 = (BSet<BInteger>) cachedValue; + } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T2Wait", _trid_12); + for(BInteger param : _trid_12) { + BInteger _tmp_1 = param; + + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T2Wait(_tmp_1); + copiedState.parent = state; + addCachedInfos("T2Wait", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_13; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_T3Initiate"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_T3Initiate"); + } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_13 = state._tr_T3Initiate(); + } else { + _trid_13 = (boolean) cachedValue; + } + + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T3Initiate", _trid_13); + if(_trid_13) { + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T3Initiate(); + copiedState.parent = state; + addCachedInfos("T3Initiate", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_14; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_T3Evaluate"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_T3Evaluate"); + } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_14 = state._tr_T3Evaluate(); + } else { + _trid_14 = (boolean) cachedValue; + } + + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T3Evaluate", _trid_14); + if(_trid_14) { + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T3Evaluate(); + copiedState.parent = state; + addCachedInfos("T3Evaluate", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<BTuple<BInteger, BInteger>> _trid_15; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_T3writebus"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_T3writebus"); + } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_15 = state._tr_T3writebus(); + } else { + _trid_15 = (BSet<BTuple<BInteger, BInteger>>) cachedValue; + } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T3writebus", _trid_15); + for(BTuple<BInteger, BInteger> param : _trid_15) { + BInteger _tmp_1 = param.projection2(); + BInteger _tmp_2 = param.projection1(); + + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T3writebus(_tmp_2, _tmp_1); + copiedState.parent = state; + addCachedInfos("T3writebus", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<BTuple<BInteger, BInteger>> _trid_16; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_T3Read"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_T3Read"); + } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_16 = state._tr_T3Read(); + } else { + _trid_16 = (BSet<BTuple<BInteger, BInteger>>) cachedValue; + } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T3Read", _trid_16); + for(BTuple<BInteger, BInteger> param : _trid_16) { + BInteger _tmp_1 = param.projection2(); + BInteger _tmp_2 = param.projection1(); + + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T3Read(_tmp_2, _tmp_1); + copiedState.parent = state; + addCachedInfos("T3Read", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_17; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_T3Poll"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_T3Poll"); + } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_17 = state._tr_T3Poll(); + } else { + _trid_17 = (boolean) cachedValue; + } + + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T3Poll", _trid_17); + if(_trid_17) { + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T3Poll(); + copiedState.parent = state; + addCachedInfos("T3Poll", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<BInteger> _trid_18; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_T3ReleaseBus"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_T3ReleaseBus"); + } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_18 = state._tr_T3ReleaseBus(); + } else { + _trid_18 = (BSet<BInteger>) cachedValue; + } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T3ReleaseBus", _trid_18); + for(BInteger param : _trid_18) { + BInteger _tmp_1 = param; + + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T3ReleaseBus(_tmp_1); + copiedState.parent = state; + addCachedInfos("T3ReleaseBus", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_19; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_T3Wait"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_T3Wait"); + } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_19 = state._tr_T3Wait(); + } else { + _trid_19 = (boolean) cachedValue; + } + + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T3Wait", _trid_19); + if(_trid_19) { + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T3Wait(); + copiedState.parent = state; + addCachedInfos("T3Wait", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_20; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_T3ReEnableWait"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_T3ReEnableWait"); + } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_20 = state._tr_T3ReEnableWait(); + } else { + _trid_20 = (boolean) cachedValue; + } + + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_T3ReEnableWait", _trid_20); + if(_trid_20) { + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T3ReEnableWait(); + copiedState.parent = state; + addCachedInfos("T3ReEnableWait", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<BInteger> _trid_21; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_Update"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_Update"); + } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_21 = state._tr_Update(); + } else { + _trid_21 = (BSet<BInteger>) cachedValue; + } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_Update", _trid_21); + for(BInteger param : _trid_21) { + BInteger _tmp_1 = param; + + CAN_BUS_tlc copiedState = state._copy(); + copiedState.Update(_tmp_1); + copiedState.parent = state; + addCachedInfos("Update", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + + state.guardCache = newCache; } else { - _trid_21 = (BSet<BInteger>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_Update", _trid_21); - for(BInteger param : _trid_21) { - BInteger _tmp_1 = param; - - CAN_BUS_tlc copiedState = state._copy(); - copiedState.Update(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("Update")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("Update")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "Update"); - } + if(state._tr_T1Evaluate()) { + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T1Evaluate(); + copiedState.parent = state; + addCachedInfos("T1Evaluate", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<BInteger> _trid_2 = state._tr_T1Calculate(); + for(BInteger param : _trid_2) { + BInteger _tmp_1 = param; + + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T1Calculate(_tmp_1); + copiedState.parent = state; + addCachedInfos("T1Calculate", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<BTuple<BInteger, BInteger>> _trid_3 = state._tr_T1SendResult(); + for(BTuple<BInteger, BInteger> param : _trid_3) { + BInteger _tmp_1 = param.projection2(); + BInteger _tmp_2 = param.projection1(); + + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T1SendResult(_tmp_2, _tmp_1); + copiedState.parent = state; + addCachedInfos("T1SendResult", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<BInteger> _trid_4 = state._tr_T1Wait(); + for(BInteger param : _trid_4) { + BInteger _tmp_1 = param; + + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T1Wait(_tmp_1); + copiedState.parent = state; + addCachedInfos("T1Wait", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + if(state._tr_T2Evaluate()) { + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T2Evaluate(); + copiedState.parent = state; + addCachedInfos("T2Evaluate", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<BTuple<BInteger, BInteger>> _trid_6 = state._tr_T2ReadBus(); + for(BTuple<BInteger, BInteger> param : _trid_6) { + BInteger _tmp_1 = param.projection2(); + BInteger _tmp_2 = param.projection1(); + + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T2ReadBus(_tmp_2, _tmp_1); + copiedState.parent = state; + addCachedInfos("T2ReadBus", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + if(state._tr_T2Reset()) { + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T2Reset(); + copiedState.parent = state; + addCachedInfos("T2Reset", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + if(state._tr_T2Complete()) { + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T2Complete(); + copiedState.parent = state; + addCachedInfos("T2Complete", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<BInteger> _trid_9 = state._tr_T2ReleaseBus(); + for(BInteger param : _trid_9) { + BInteger _tmp_1 = param; + + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T2ReleaseBus(_tmp_1); + copiedState.parent = state; + addCachedInfos("T2ReleaseBus", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + if(state._tr_T2Calculate()) { + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T2Calculate(); + copiedState.parent = state; + addCachedInfos("T2Calculate", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<BTuple<BInteger, BInteger>> _trid_11 = state._tr_T2WriteBus(); + for(BTuple<BInteger, BInteger> param : _trid_11) { + BInteger _tmp_1 = param.projection2(); + BInteger _tmp_2 = param.projection1(); + + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T2WriteBus(_tmp_2, _tmp_1); + copiedState.parent = state; + addCachedInfos("T2WriteBus", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<BInteger> _trid_12 = state._tr_T2Wait(); + for(BInteger param : _trid_12) { + BInteger _tmp_1 = param; + + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T2Wait(_tmp_1); + copiedState.parent = state; + addCachedInfos("T2Wait", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); - } + if(state._tr_T3Initiate()) { + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T3Initiate(); + copiedState.parent = state; + addCachedInfos("T3Initiate", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + if(state._tr_T3Evaluate()) { + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T3Evaluate(); + copiedState.parent = state; + addCachedInfos("T3Evaluate", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<BTuple<BInteger, BInteger>> _trid_15 = state._tr_T3writebus(); + for(BTuple<BInteger, BInteger> param : _trid_15) { + BInteger _tmp_1 = param.projection2(); + BInteger _tmp_2 = param.projection1(); + + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T3writebus(_tmp_2, _tmp_1); + copiedState.parent = state; + addCachedInfos("T3writebus", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<BTuple<BInteger, BInteger>> _trid_16 = state._tr_T3Read(); + for(BTuple<BInteger, BInteger> param : _trid_16) { + BInteger _tmp_1 = param.projection2(); + BInteger _tmp_2 = param.projection1(); + + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T3Read(_tmp_2, _tmp_1); + copiedState.parent = state; + addCachedInfos("T3Read", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - synchronized(guardLock) { - guardCache.put(state, newCache); - } - } else { - if(state._tr_T1Evaluate()) { - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T1Evaluate(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T1Evaluate"); - } } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BInteger> _trid_2 = state._tr_T1Calculate(); - for(BInteger param : _trid_2) { - BInteger _tmp_1 = param; - - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T1Calculate(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T1Calculate"); - } + if(state._tr_T3Poll()) { + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T3Poll(); + copiedState.parent = state; + addCachedInfos("T3Poll", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<BInteger, BInteger>> _trid_3 = state._tr_T1SendResult(); - for(BTuple<BInteger, BInteger> param : _trid_3) { - BInteger _tmp_1 = param.projection2(); - BInteger _tmp_2 = param.projection1(); - - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T1SendResult(_tmp_2, _tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T1SendResult"); - } + BSet<BInteger> _trid_18 = state._tr_T3ReleaseBus(); + for(BInteger param : _trid_18) { + BInteger _tmp_1 = param; + + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T3ReleaseBus(_tmp_1); + copiedState.parent = state; + addCachedInfos("T3ReleaseBus", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BInteger> _trid_4 = state._tr_T1Wait(); - for(BInteger param : _trid_4) { - BInteger _tmp_1 = param; - - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T1Wait(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T1Wait"); - } + if(state._tr_T3Wait()) { + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T3Wait(); + copiedState.parent = state; + addCachedInfos("T3Wait", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_T2Evaluate()) { - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T2Evaluate(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T2Evaluate"); - } + if(state._tr_T3ReEnableWait()) { + CAN_BUS_tlc copiedState = state._copy(); + copiedState.T3ReEnableWait(); + copiedState.parent = state; + addCachedInfos("T3ReEnableWait", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<BInteger, BInteger>> _trid_6 = state._tr_T2ReadBus(); - for(BTuple<BInteger, BInteger> param : _trid_6) { - BInteger _tmp_1 = param.projection2(); - BInteger _tmp_2 = param.projection1(); - - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T2ReadBus(_tmp_2, _tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T2ReadBus"); - } + BSet<BInteger> _trid_21 = state._tr_Update(); + for(BInteger param : _trid_21) { + BInteger _tmp_1 = param; + + CAN_BUS_tlc copiedState = state._copy(); + copiedState.Update(_tmp_1); + copiedState.parent = state; + addCachedInfos("Update", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); + } - if(state._tr_T2Reset()) { - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T2Reset(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T2Reset"); + return result; + } + + private boolean invariantViolated(final CAN_BUS_tlc state) { + if(isCaching) { + if(state.dependentInvariant.contains("_check_inv_1")) { + if(!state._check_inv_1()) { + return true; } } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_T2Complete()) { - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T2Complete(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T2Complete"); + if(state.dependentInvariant.contains("_check_inv_2")) { + if(!state._check_inv_2()) { + return true; } } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BInteger> _trid_9 = state._tr_T2ReleaseBus(); - for(BInteger param : _trid_9) { - BInteger _tmp_1 = param; - - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T2ReleaseBus(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T2ReleaseBus"); + if(state.dependentInvariant.contains("_check_inv_3")) { + if(!state._check_inv_3()) { + return true; } } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_T2Calculate()) { - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T2Calculate(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T2Calculate"); + if(state.dependentInvariant.contains("_check_inv_4")) { + if(!state._check_inv_4()) { + return true; } } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<BInteger, BInteger>> _trid_11 = state._tr_T2WriteBus(); - for(BTuple<BInteger, BInteger> param : _trid_11) { - BInteger _tmp_1 = param.projection2(); - BInteger _tmp_2 = param.projection1(); - - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T2WriteBus(_tmp_2, _tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T2WriteBus"); + if(state.dependentInvariant.contains("_check_inv_5")) { + if(!state._check_inv_5()) { + return true; } } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BInteger> _trid_12 = state._tr_T2Wait(); - for(BInteger param : _trid_12) { - BInteger _tmp_1 = param; - - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T2Wait(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T2Wait"); + if(state.dependentInvariant.contains("_check_inv_6")) { + if(!state._check_inv_6()) { + return true; } } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_T3Initiate()) { - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T3Initiate(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T3Initiate"); + if(state.dependentInvariant.contains("_check_inv_7")) { + if(!state._check_inv_7()) { + return true; } } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_T3Evaluate()) { - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T3Evaluate(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T3Evaluate"); + if(state.dependentInvariant.contains("_check_inv_8")) { + if(!state._check_inv_8()) { + return true; } } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<BInteger, BInteger>> _trid_15 = state._tr_T3writebus(); - for(BTuple<BInteger, BInteger> param : _trid_15) { - BInteger _tmp_1 = param.projection2(); - BInteger _tmp_2 = param.projection1(); - - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T3writebus(_tmp_2, _tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T3writebus"); + if(state.dependentInvariant.contains("_check_inv_9")) { + if(!state._check_inv_9()) { + return true; } } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<BInteger, BInteger>> _trid_16 = state._tr_T3Read(); - for(BTuple<BInteger, BInteger> param : _trid_16) { - BInteger _tmp_1 = param.projection2(); - BInteger _tmp_2 = param.projection1(); - - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T3Read(_tmp_2, _tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T3Read"); + if(state.dependentInvariant.contains("_check_inv_10")) { + if(!state._check_inv_10()) { + return true; } } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_T3Poll()) { - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T3Poll(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); + if(state.dependentInvariant.contains("_check_inv_11")) { + if(!state._check_inv_11()) { + return true; } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T3Poll"); + } + if(state.dependentInvariant.contains("_check_inv_12")) { + if(!state._check_inv_12()) { + return true; } } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BInteger> _trid_18 = state._tr_T3ReleaseBus(); - for(BInteger param : _trid_18) { - BInteger _tmp_1 = param; - - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T3ReleaseBus(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); + if(state.dependentInvariant.contains("_check_inv_13")) { + if(!state._check_inv_13()) { + return true; } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T3ReleaseBus"); + } + if(state.dependentInvariant.contains("_check_inv_14")) { + if(!state._check_inv_14()) { + return true; } } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_T3Wait()) { - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T3Wait(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); + if(state.dependentInvariant.contains("_check_inv_15")) { + if(!state._check_inv_15()) { + return true; } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T3Wait"); + } + if(state.dependentInvariant.contains("_check_inv_16")) { + if(!state._check_inv_16()) { + return true; } } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_T3ReEnableWait()) { - CAN_BUS_tlc copiedState = state._copy(); - copiedState.T3ReEnableWait(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); + if(state.dependentInvariant.contains("_check_inv_17")) { + if(!state._check_inv_17()) { + return true; } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "T3ReEnableWait"); + } + if(state.dependentInvariant.contains("_check_inv_18")) { + if(!state._check_inv_18()) { + return true; } } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BInteger> _trid_21 = state._tr_Update(); - for(BInteger param : _trid_21) { - BInteger _tmp_1 = param; - - CAN_BUS_tlc copiedState = state._copy(); - copiedState.Update(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); + if(state.dependentInvariant.contains("_check_inv_19")) { + if(!state._check_inv_19()) { + return true; } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "Update"); + } + if(state.dependentInvariant.contains("_check_inv_20")) { + if(!state._check_inv_20()) { + return true; } } - result.add(copiedState); - transitions.getAndIncrement(); + return false; } - + return !(state._check_inv_1() && state._check_inv_2() && state._check_inv_3() && state._check_inv_4() && state._check_inv_5() && state._check_inv_6() && state._check_inv_7() && state._check_inv_8() && state._check_inv_9() && state._check_inv_10() && state._check_inv_11() && state._check_inv_12() && state._check_inv_13() && state._check_inv_14() && state._check_inv_15() && state._check_inv_16() && state._check_inv_17() && state._check_inv_18() && state._check_inv_19() && state._check_inv_20()); } - return result; - } - - public static boolean checkInvariants(Object guardLock, CAN_BUS_tlc state, boolean isCaching, Map<CAN_BUS_tlc, Set<String>> dependentInvariant) { - if(isCaching) { - Set<String> dependentInvariantsOfState; - synchronized(guardLock) { - dependentInvariantsOfState = dependentInvariant.get(state); - } - if(dependentInvariantsOfState.contains("_check_inv_1")) { - if(!state._check_inv_1()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_2")) { - if(!state._check_inv_2()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_3")) { - if(!state._check_inv_3()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_4")) { - if(!state._check_inv_4()) { - return false; - } + private void addCachedInfos(final String operation, final CAN_BUS_tlc state, final CAN_BUS_tlc copiedState) { + if(isCaching) { + copiedState.dependentInvariant = invariantDependency.get(operation); + copiedState.dependentGuard = guardDependency.get(operation); } - if(dependentInvariantsOfState.contains("_check_inv_5")) { - if(!state._check_inv_5()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_6")) { - if(!state._check_inv_6()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_7")) { - if(!state._check_inv_7()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_8")) { - if(!state._check_inv_8()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_9")) { - if(!state._check_inv_9()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_10")) { - if(!state._check_inv_10()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_11")) { - if(!state._check_inv_11()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_12")) { - if(!state._check_inv_12()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_13")) { - if(!state._check_inv_13()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_14")) { - if(!state._check_inv_14()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_15")) { - if(!state._check_inv_15()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_16")) { - if(!state._check_inv_16()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_17")) { - if(!state._check_inv_17()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_18")) { - if(!state._check_inv_18()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_19")) { - if(!state._check_inv_19()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_20")) { - if(!state._check_inv_20()) { - return false; - } - } - return true; + copiedState.stateAccessedVia = operation; } - return !(!state._check_inv_1() || !state._check_inv_2() || !state._check_inv_3() || !state._check_inv_4() || !state._check_inv_5() || !state._check_inv_6() || !state._check_inv_7() || !state._check_inv_8() || !state._check_inv_9() || !state._check_inv_10() || !state._check_inv_11() || !state._check_inv_12() || !state._check_inv_13() || !state._check_inv_14() || !state._check_inv_15() || !state._check_inv_16() || !state._check_inv_17() || !state._check_inv_18() || !state._check_inv_19() || !state._check_inv_20()); - } - private static void printResult(int states, int transitions, boolean deadlockDetected, boolean invariantViolated, List<CAN_BUS_tlc> counterExampleState, Map<CAN_BUS_tlc, CAN_BUS_tlc> parents, Map<CAN_BUS_tlc, String> stateAccessedVia) { + private void printResult(final int states, final int transitions) { + if (invariantViolated.get() || deadlockDetected.get()) { + if (deadlockDetected.get()) { + System.out.println("DEADLOCK DETECTED"); + } else { + System.out.println("INVARIANT VIOLATED"); + } - if(invariantViolated || deadlockDetected) { - if(deadlockDetected) { - System.out.println("DEADLOCK DETECTED"); - } - if(invariantViolated) { - System.out.println("INVARIANT VIOLATED"); - } - System.out.println("COUNTER EXAMPLE TRACE: "); - StringBuilder sb = new StringBuilder(); - if(counterExampleState.size() >= 1) { - CAN_BUS_tlc currentState = counterExampleState.get(0); - while(currentState != null) { - sb.insert(0, currentState.toString()); + System.out.println("COUNTER EXAMPLE TRACE: "); + StringBuilder sb = new StringBuilder(); + while (counterExampleState != null) { + sb.insert(0, counterExampleState); sb.insert(0, "\n"); - sb.insert(0, stateAccessedVia.get(currentState)); + if (counterExampleState.stateAccessedVia != null) { + sb.insert(0, counterExampleState.stateAccessedVia); + } sb.insert(0, "\n\n"); - currentState = parents.get(currentState); + counterExampleState = counterExampleState.parent; } + System.out.println(sb); + } else { + System.out.println("MODEL CHECKING SUCCESSFUL"); } - System.out.println(sb.toString()); + System.out.println("Number of States: " + states); + System.out.println("Number of Transitions: " + transitions); } - if(!deadlockDetected && !invariantViolated) { - System.out.println("MODEL CHECKING SUCCESSFUL"); - } - System.out.println("Number of States: " + states); - System.out.println("Number of Transitions: " + transitions); } private static CAN_BUS_tlc next(LinkedList<CAN_BUS_tlc> collection, Object lock, Type type) { @@ -2146,7 +2036,6 @@ public class CAN_BUS_tlc { AtomicInteger transitions = new AtomicInteger(0); while(!collection.isEmpty() && !stopThreads.get()) { - possibleQueueChanges.incrementAndGet(); CAN_BUS_tlc state = next(collection, lock, type); Runnable task = () -> { @@ -2212,51 +2101,59 @@ public class CAN_BUS_tlc { public static void main(String[] args) { - if(args.length != 3) { - System.out.println("Number of arguments errorneous"); - return; - } - String strategy = args[0]; - String numberThreads = args[1]; - String caching = args[2]; - - Type type; - - if("mixed".equals(strategy)) { - type = Type.MIXED; - } else if("bf".equals(strategy)) { - type = Type.BFS; - } else if ("df".equals(strategy)) { - type = Type.DFS; - } else { - System.out.println("Input for strategy is wrong."); + if(args.length > 4) { + System.out.println("Expecting 3 command-line arguments: STRATEGY THREADS CACHING DEBUG"); return; } - + Type type = Type.MIXED; int threads = 0; - try { - threads = Integer.parseInt(numberThreads); - } catch(NumberFormatException e) { - System.out.println("Input for number of threads is wrong."); - return; + boolean isCaching = false; + boolean isDebug = false; + + if(args.length > 0) { + if("mixed".equals(args[0])) { + type = Type.MIXED; + } else if("bf".equals(args[0])) { + type = Type.BFS; + } else if ("df".equals(args[0])) { + type = Type.DFS; + } else { + System.out.println("Value for command-line argument STRATEGY is wrong."); + System.out.println("Expecting mixed, bf or df."); + return; + } } - if(threads <= 0) { - System.out.println("Input for number of threads is wrong."); - return; + if(args.length > 1) { + try { + threads = Integer.parseInt(args[1]); + } catch(NumberFormatException e) { + System.out.println("Value for command-line argument THREADS is not a number."); + return; + } + if(threads <= 0) { + System.out.println("Value for command-line argument THREADS must be positive."); + return; + } } - - boolean isCaching = true; - try { - isCaching = Boolean.parseBoolean(caching); - } catch(Exception e) { - System.out.println("Input for caching is wrong."); - return; + if(args.length > 2) { + try { + isCaching = Boolean.parseBoolean(args[2]); + } catch(Exception e) { + System.out.println("Value for command-line argument CACHING is not a boolean."); + return; + } } - if(threads == 1) { - modelCheckSingleThreaded(type, isCaching); - } else { - modelCheckMultiThreaded(type, threads, isCaching); + if(args.length > 3) { + try { + isDebug = Boolean.parseBoolean(args[3]); + } catch(Exception e) { + System.out.println("Value for command-line argument DEBUG is not a boolean."); + return; + } } + + ModelChecker modelchecker = new ModelChecker(type, threads, isCaching, isDebug); + modelchecker.modelCheck(); } diff --git a/benchmarks/model_checking/Java/Cruise_finite1_deterministic_MC.java b/benchmarks/model_checking/Java/Cruise_finite1_deterministic_MC.java index 1dfdbfb6ea0b0995eed689b006fbb953ec64d8ff..abbe26defc61237e102cbfa5054632ca166dc51d 100644 --- a/benchmarks/model_checking/Java/Cruise_finite1_deterministic_MC.java +++ b/benchmarks/model_checking/Java/Cruise_finite1_deterministic_MC.java @@ -12,6 +12,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.Future; import java.util.concurrent.Executors; @@ -813,7 +814,7 @@ public class Cruise_finite1_deterministic_MC { private final boolean isDebug; private final LinkedList<Cruise_finite1_deterministic_MC> unvisitedStates = new LinkedList<>(); - private final Set<Cruise_finite1_deterministic_MC> states = new HashSet<>(); + private final Set<Cruise_finite1_deterministic_MC> states = ConcurrentHashMap.newKeySet(); private AtomicInteger transitions = new AtomicInteger(0); private ThreadPoolExecutor threadPool; private Object waitLock = new Object(); @@ -906,17 +907,14 @@ public class Cruise_finite1_deterministic_MC { Set<Cruise_finite1_deterministic_MC> nextStates = generateNextStates(state); nextStates.forEach(nextState -> { - synchronized (states) { - if(!states.contains(nextState)) { - states.add(nextState); - synchronized (unvisitedStates) { - unvisitedStates.add(nextState); - } - if(states.size() % 50000 == 0 && isDebug) { - System.out.println("VISITED STATES: " + states.size()); - System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); - System.out.println("-------------------"); - } + if(states.add(nextState)) { + synchronized (unvisitedStates) { + unvisitedStates.add(nextState); + } + if(states.size() % 50000 == 0 && isDebug) { + System.out.println("VISITED STATES: " + states.size()); + System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); + System.out.println("-------------------"); } } }); @@ -2169,7 +2167,7 @@ public class Cruise_finite1_deterministic_MC { boolean isCaching = false; boolean isDebug = false; - if(args.length > 0) { + if(args.length > 0) { if("mixed".equals(args[0])) { type = Type.MIXED; } else if("bf".equals(args[0])) { @@ -2182,7 +2180,7 @@ public class Cruise_finite1_deterministic_MC { return; } } - if(args.length > 1) { + if(args.length > 1) { try { threads = Integer.parseInt(args[1]); } catch(NumberFormatException e) { @@ -2194,7 +2192,7 @@ public class Cruise_finite1_deterministic_MC { return; } } - if(args.length > 2) { + if(args.length > 2) { try { isCaching = Boolean.parseBoolean(args[2]); } catch(Exception e) { @@ -2202,7 +2200,7 @@ public class Cruise_finite1_deterministic_MC { return; } } - if(args.length > 3) { + if(args.length > 3) { try { isDebug = Boolean.parseBoolean(args[3]); } catch(Exception e) { diff --git a/benchmarks/model_checking/Java/LandingGear_R6.java b/benchmarks/model_checking/Java/LandingGear_R6.java index 35ad70d09672de086a4b5fab394e1f4c95e2674b..6f20f3b90ac2622c8150050b487004deb4fe0c76 100644 --- a/benchmarks/model_checking/Java/LandingGear_R6.java +++ b/benchmarks/model_checking/Java/LandingGear_R6.java @@ -12,6 +12,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.Future; import java.util.concurrent.Executors; @@ -45,6 +46,12 @@ public class LandingGear_R6 { MIXED } + public LandingGear_R6 parent; + public Set<String> dependentGuard = new HashSet<>(); + public PersistentHashMap guardCache = PersistentHashMap.EMPTY; + public Set<String> dependentInvariant = new HashSet<>(); + public String stateAccessedVia; + @@ -191,6 +198,7 @@ public class LandingGear_R6 { door = DOOR_STATE.closed; } + public LandingGear_R6(SWITCH_STATE analogical_switch, BBoolean general_EV, VALVE_STATE general_valve, BBoolean handle_move, BBoolean close_EV, BBoolean extend_EV, BBoolean open_EV, BBoolean retract_EV, PLANE_STATE shock_absorber, VALVE_STATE valve_close_door, VALVE_STATE valve_extend_gear, VALVE_STATE valve_open_door, VALVE_STATE valve_retract_gear, BRelation<POSITION, DOOR_STATE> doors, BRelation<POSITION, GEAR_STATE> gears, HANDLE_STATE handle, DOOR_STATE door, GEAR_STATE gear) { this.analogical_switch = analogical_switch; this.general_EV = general_EV; @@ -212,6 +220,7 @@ public class LandingGear_R6 { this.gear = gear; } + public void begin_flying() { shock_absorber = PLANE_STATE.flight; @@ -927,2378 +936,1715 @@ public class LandingGear_R6 { return String.join("\n", "_get_analogical_switch: " + (this._get_analogical_switch()).toString(), "_get_general_EV: " + (this._get_general_EV()).toString(), "_get_general_valve: " + (this._get_general_valve()).toString(), "_get_handle_move: " + (this._get_handle_move()).toString(), "_get_close_EV: " + (this._get_close_EV()).toString(), "_get_extend_EV: " + (this._get_extend_EV()).toString(), "_get_open_EV: " + (this._get_open_EV()).toString(), "_get_retract_EV: " + (this._get_retract_EV()).toString(), "_get_shock_absorber: " + (this._get_shock_absorber()).toString(), "_get_valve_close_door: " + (this._get_valve_close_door()).toString(), "_get_valve_extend_gear: " + (this._get_valve_extend_gear()).toString(), "_get_valve_open_door: " + (this._get_valve_open_door()).toString(), "_get_valve_retract_gear: " + (this._get_valve_retract_gear()).toString(), "_get_doors: " + (this._get_doors()).toString(), "_get_gears: " + (this._get_gears()).toString(), "_get_handle: " + (this._get_handle()).toString(), "_get_door: " + (this._get_door()).toString(), "_get_gear: " + (this._get_gear()).toString()); } - @SuppressWarnings("unchecked") - private static Set<LandingGear_R6> generateNextStates(Object guardLock, LandingGear_R6 state, boolean isCaching, Map<String, Set<String>> invariantDependency, Map<LandingGear_R6, Set<String>> dependentInvariant, Map<String, Set<String>> guardDependency, Map<LandingGear_R6, Set<String>> dependentGuard, Map<LandingGear_R6, PersistentHashMap> guardCache, Map<LandingGear_R6, LandingGear_R6> parents, Map<LandingGear_R6, String> stateAccessedVia, AtomicInteger transitions) { - Set<LandingGear_R6> result = new HashSet<>(); - if(isCaching) { - PersistentHashMap parentsGuard = guardCache.get(parents.get(state)); - PersistentHashMap newCache = parentsGuard == null ? PersistentHashMap.EMPTY : parentsGuard; - Set<String> dependentGuardsOfState = dependentGuard.get(state); - Object cachedValue = null; - boolean dependentGuardsBoolean = true; - boolean _trid_1; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_begin_flying"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_begin_flying"); + + private static class ModelChecker { + private final Type type; + private final int threads; + private final boolean isCaching; + private final boolean isDebug; + + private final LinkedList<LandingGear_R6> unvisitedStates = new LinkedList<>(); + private final Set<LandingGear_R6> states = ConcurrentHashMap.newKeySet(); + private AtomicInteger transitions = new AtomicInteger(0); + private ThreadPoolExecutor threadPool; + private Object waitLock = new Object(); + + private AtomicBoolean invariantViolated = new AtomicBoolean(false); + private AtomicBoolean deadlockDetected = new AtomicBoolean(false); + private LandingGear_R6 counterExampleState = null; + + private final Map<String, Set<String>> invariantDependency = new HashMap<>(); + private final Map<String, Set<String>> guardDependency = new HashMap<>(); + + public ModelChecker(final Type type, final int threads, final boolean isCaching, final boolean isDebug) { + this.type = type; + this.threads = threads; + this.isCaching = isCaching; + this.isDebug = isDebug; + } + + public void modelCheck() { + if (isDebug) { + System.out.println("Starting Modelchecking, STRATEGY=" + type + ", THREADS=" + threads + ", CACHING=" + isCaching); } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_1 = state._tr_begin_flying(); + if (threads <= 1) { + modelCheckSingleThreaded(); } else { - _trid_1 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_begin_flying", _trid_1); - if(_trid_1) { - LandingGear_R6 copiedState = state._copy(); - copiedState.begin_flying(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("begin_flying")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("begin_flying")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "begin_flying"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_2; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_land_plane"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_land_plane"); + this.threadPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(threads-1); + modelCheckMultiThreaded(); } + } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_2 = state._tr_land_plane(); - } else { - _trid_2 = (boolean) cachedValue; + private void modelCheckSingleThreaded() { + LandingGear_R6 machine = new LandingGear_R6(); + states.add(machine); // TODO: store hashes instead of machine? + unvisitedStates.add(machine); + + if(isCaching) { + initCache(machine); } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_land_plane", _trid_2); - if(_trid_2) { - LandingGear_R6 copiedState = state._copy(); - copiedState.land_plane(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("land_plane")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("land_plane")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "land_plane"); + + while(!unvisitedStates.isEmpty()) { + LandingGear_R6 state = next(); + + Set<LandingGear_R6> nextStates = generateNextStates(state); + + nextStates.forEach(nextState -> { + if(!states.contains(nextState)) { + states.add(nextState); + unvisitedStates.add(nextState); + if(states.size() % 50000 == 0 && isDebug) { + System.out.println("VISITED STATES: " + states.size()); + System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); + System.out.println("-------------------"); + } } + }); + + if(invariantViolated(state)) { + invariantViolated.set(true); + counterExampleState = state; + break; } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_3; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_open_valve_door_open"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_open_valve_door_open"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_3 = state._tr_open_valve_door_open(); - } else { - _trid_3 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_open_valve_door_open", _trid_3); - if(_trid_3) { - LandingGear_R6 copiedState = state._copy(); - copiedState.open_valve_door_open(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("open_valve_door_open")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("open_valve_door_open")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "open_valve_door_open"); - } + if(nextStates.isEmpty()) { + deadlockDetected.set(true); + counterExampleState = state; + break; } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_4; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_close_valve_door_open"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_close_valve_door_open"); + } + printResult(states.size(), transitions.get()); + } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_4 = state._tr_close_valve_door_open(); - } else { - _trid_4 = (boolean) cachedValue; + private void modelCheckMultiThreaded() { + LandingGear_R6 machine = new LandingGear_R6(); + states.add(machine); + unvisitedStates.add(machine); + + AtomicBoolean stopThreads = new AtomicBoolean(false); + AtomicInteger possibleQueueChanges = new AtomicInteger(0); + + if(isCaching) { + initCache(machine); } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_close_valve_door_open", _trid_4); - if(_trid_4) { - LandingGear_R6 copiedState = state._copy(); - copiedState.close_valve_door_open(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("close_valve_door_open")); + + while(!unvisitedStates.isEmpty() && !stopThreads.get()) { + possibleQueueChanges.incrementAndGet(); + LandingGear_R6 state = next(); + Runnable task = () -> { + Set<LandingGear_R6> nextStates = generateNextStates(state); + + nextStates.forEach(nextState -> { + if(states.add(nextState)) { + synchronized (unvisitedStates) { + unvisitedStates.add(nextState); + } + if(states.size() % 50000 == 0 && isDebug) { + System.out.println("VISITED STATES: " + states.size()); + System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); + System.out.println("-------------------"); + } + } + }); + + synchronized (unvisitedStates) { + int running = possibleQueueChanges.decrementAndGet(); + if (!unvisitedStates.isEmpty() || running == 0) { + synchronized (waitLock) { + waitLock.notify(); + } + } } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("close_valve_door_open")); + + if(invariantViolated(state)) { + invariantViolated.set(true); + counterExampleState = state; + stopThreads.set(true); } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); + + if(nextStates.isEmpty()) { + deadlockDetected.set(true); + counterExampleState = state; + stopThreads.set(true); } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "close_valve_door_open"); + }; + threadPool.submit(task); + synchronized(waitLock) { + if (unvisitedStates.isEmpty() && possibleQueueChanges.get() > 0) { + try { + waitLock.wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } } } - result.add(copiedState); - transitions.getAndIncrement(); } - boolean _trid_5; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_open_valve_door_close"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_open_valve_door_close"); + threadPool.shutdown(); + try { + threadPool.awaitTermination(24, TimeUnit.HOURS); + } catch (InterruptedException e) { + e.printStackTrace(); } + printResult(states.size(), transitions.get()); + } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_5 = state._tr_open_valve_door_close(); - } else { - _trid_5 = (boolean) cachedValue; + private void initCache(final LandingGear_R6 machine) { + invariantDependency.put("close_valve_door_close", new HashSet<>(Arrays.asList("_check_inv_10"))); + invariantDependency.put("close_valve_retract_gear", new HashSet<>(Arrays.asList("_check_inv_13"))); + invariantDependency.put("con_stimulate_open_door_valve", new HashSet<>(Arrays.asList("_check_inv_18", "_check_inv_17", "_check_inv_7"))); + invariantDependency.put("env_close_door", new HashSet<>(Arrays.asList("_check_inv_15", "_check_inv_21", "_check_inv_20", "_check_inv_25", "_check_inv_22"))); + invariantDependency.put("env_start_close_door", new HashSet<>(Arrays.asList("_check_inv_15", "_check_inv_21", "_check_inv_20", "_check_inv_25", "_check_inv_22"))); + invariantDependency.put("toggle_handle_up", new HashSet<>(Arrays.asList("_check_inv_4", "_check_inv_14"))); + invariantDependency.put("toggle_handle_down", new HashSet<>(Arrays.asList("_check_inv_4", "_check_inv_14"))); + invariantDependency.put("open_valve_door_open", new HashSet<>(Arrays.asList("_check_inv_12"))); + invariantDependency.put("env_retract_gear_last", new HashSet<>(Arrays.asList("_check_inv_16", "_check_inv_19", "_check_inv_25", "_check_inv_24", "_check_inv_23"))); + invariantDependency.put("env_open_door_last", new HashSet<>(Arrays.asList("_check_inv_15", "_check_inv_21", "_check_inv_20", "_check_inv_25", "_check_inv_22"))); + invariantDependency.put("con_stop_stimulate_retract_gear_valve", new HashSet<>(Arrays.asList("_check_inv_17", "_check_inv_8"))); + invariantDependency.put("env_close_door_skip", new HashSet<>(Arrays.asList("_check_inv_21", "_check_inv_20", "_check_inv_22"))); + invariantDependency.put("con_stop_stimulate_close_door_valve", new HashSet<>(Arrays.asList("_check_inv_18", "_check_inv_17", "_check_inv_5"))); + invariantDependency.put("env_open_analogical_switch", new HashSet<>(Arrays.asList("_check_inv_1"))); + invariantDependency.put("con_stop_stimulate_general_valve", new HashSet<>(Arrays.asList("_check_inv_17", "_check_inv_2", "_check_inv_4"))); + invariantDependency.put("env_extend_gear_last", new HashSet<>(Arrays.asList("_check_inv_16", "_check_inv_19", "_check_inv_25", "_check_inv_24", "_check_inv_23"))); + invariantDependency.put("evn_open_general_valve", new HashSet<>(Arrays.asList("_check_inv_3"))); + invariantDependency.put("land_plane", new HashSet<>(Arrays.asList("_check_inv_9"))); + invariantDependency.put("con_stimulate_retract_gear_valve", new HashSet<>(Arrays.asList("_check_inv_17", "_check_inv_8"))); + invariantDependency.put("con_stimulate_general_valve", new HashSet<>(Arrays.asList("_check_inv_17", "_check_inv_2"))); + invariantDependency.put("env_start_retracting_first", new HashSet<>(Arrays.asList("_check_inv_16", "_check_inv_19", "_check_inv_25", "_check_inv_24", "_check_inv_23"))); + invariantDependency.put("env_retract_gear_skip", new HashSet<>(Arrays.asList("_check_inv_19", "_check_inv_24", "_check_inv_23"))); + invariantDependency.put("open_valve_extend_gear", new HashSet<>(Arrays.asList("_check_inv_11"))); + invariantDependency.put("begin_flying", new HashSet<>(Arrays.asList("_check_inv_9"))); + invariantDependency.put("open_valve_retract_gear", new HashSet<>(Arrays.asList("_check_inv_13"))); + invariantDependency.put("env_close_analogical_switch", new HashSet<>(Arrays.asList("_check_inv_1"))); + invariantDependency.put("env_start_extending", new HashSet<>(Arrays.asList("_check_inv_16", "_check_inv_19", "_check_inv_25", "_check_inv_24", "_check_inv_23"))); + invariantDependency.put("open_valve_door_close", new HashSet<>(Arrays.asList("_check_inv_10"))); + invariantDependency.put("con_stop_stimulate_open_door_valve", new HashSet<>(Arrays.asList("_check_inv_18", "_check_inv_17", "_check_inv_7"))); + invariantDependency.put("con_stop_stimulate_extend_gear_valve", new HashSet<>(Arrays.asList("_check_inv_17", "_check_inv_6"))); + invariantDependency.put("evn_close_general_valve", new HashSet<>(Arrays.asList("_check_inv_3"))); + invariantDependency.put("close_valve_extend_gear", new HashSet<>(Arrays.asList("_check_inv_11"))); + invariantDependency.put("con_stimulate_extend_gear_valve", new HashSet<>(Arrays.asList("_check_inv_17", "_check_inv_6"))); + invariantDependency.put("close_valve_door_open", new HashSet<>(Arrays.asList("_check_inv_12"))); + invariantDependency.put("con_stimulate_close_door_valve", new HashSet<>(Arrays.asList("_check_inv_18", "_check_inv_17", "_check_inv_5"))); + invariantDependency.put("env_extend_gear_skip", new HashSet<>(Arrays.asList("_check_inv_19", "_check_inv_24", "_check_inv_23"))); + invariantDependency.put("env_open_door_skip", new HashSet<>(Arrays.asList("_check_inv_21", "_check_inv_20", "_check_inv_22"))); + invariantDependency.put("env_start_open_door", new HashSet<>(Arrays.asList("_check_inv_15", "_check_inv_21", "_check_inv_20", "_check_inv_25", "_check_inv_22"))); + guardDependency.put("close_valve_door_close", new HashSet<>(Arrays.asList("_tr_open_valve_door_close", "_tr_env_close_door_skip", "_tr_env_start_close_door", "_tr_env_close_door", "_tr_close_valve_door_close"))); + guardDependency.put("close_valve_retract_gear", new HashSet<>(Arrays.asList("_tr_close_valve_retract_gear", "_tr_open_valve_retract_gear", "_tr_env_start_retracting_first"))); + guardDependency.put("con_stimulate_open_door_valve", new HashSet<>(Arrays.asList("_tr_open_valve_door_open", "_tr_con_stimulate_extend_gear_valve", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stimulate_open_door_valve", "_tr_close_valve_door_open"))); + guardDependency.put("env_close_door", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); + guardDependency.put("env_start_close_door", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); + guardDependency.put("toggle_handle_up", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_close_analogical_switch", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip", "_tr_con_stimulate_general_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_toggle_handle_down", "_tr_env_open_door_last", "_tr_toggle_handle_up", "_tr_env_start_close_door", "_tr_con_stop_stimulate_close_door_valve"))); + guardDependency.put("toggle_handle_down", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_close_analogical_switch", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip", "_tr_con_stimulate_general_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_toggle_handle_down", "_tr_env_open_door_last", "_tr_toggle_handle_up", "_tr_env_start_close_door", "_tr_con_stop_stimulate_close_door_valve"))); + guardDependency.put("open_valve_door_open", new HashSet<>(Arrays.asList("_tr_open_valve_door_open", "_tr_env_open_door_last", "_tr_env_start_open_door", "_tr_env_open_door_skip", "_tr_close_valve_door_open"))); + guardDependency.put("env_retract_gear_last", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); + guardDependency.put("env_open_door_last", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); + guardDependency.put("con_stop_stimulate_retract_gear_valve", new HashSet<>(Arrays.asList("_tr_close_valve_retract_gear", "_tr_con_stimulate_extend_gear_valve", "_tr_open_valve_retract_gear", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_retract_gear_valve"))); + guardDependency.put("env_close_door_skip", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); + guardDependency.put("con_stop_stimulate_close_door_valve", new HashSet<>(Arrays.asList("_tr_open_valve_door_close", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_close_valve_door_close"))); + guardDependency.put("env_open_analogical_switch", new HashSet<>(Arrays.asList("_tr_env_open_analogical_switch", "_tr_evn_open_general_valve", "_tr_env_close_analogical_switch", "_tr_evn_close_general_valve"))); + guardDependency.put("con_stop_stimulate_general_valve", new HashSet<>(Arrays.asList("_tr_con_stimulate_extend_gear_valve", "_tr_con_stimulate_general_valve", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_evn_open_general_valve", "_tr_env_close_analogical_switch", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_evn_close_general_valve", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve"))); + guardDependency.put("env_extend_gear_last", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); + guardDependency.put("evn_open_general_valve", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_env_close_door_skip", "_tr_evn_open_general_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_evn_close_general_valve", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); + guardDependency.put("land_plane", new HashSet<>(Arrays.asList("_tr_land_plane", "_tr_begin_flying", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_close_door"))); + guardDependency.put("con_stimulate_retract_gear_valve", new HashSet<>(Arrays.asList("_tr_close_valve_retract_gear", "_tr_con_stimulate_extend_gear_valve", "_tr_open_valve_retract_gear", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_retract_gear_valve"))); + guardDependency.put("con_stimulate_general_valve", new HashSet<>(Arrays.asList("_tr_con_stimulate_extend_gear_valve", "_tr_con_stimulate_general_valve", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_evn_open_general_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_evn_close_general_valve", "_tr_con_stop_stimulate_retract_gear_valve"))); + guardDependency.put("env_start_retracting_first", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); + guardDependency.put("env_retract_gear_skip", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); + guardDependency.put("open_valve_extend_gear", new HashSet<>(Arrays.asList("_tr_close_valve_extend_gear", "_tr_open_valve_extend_gear", "_tr_env_start_extending"))); + guardDependency.put("begin_flying", new HashSet<>(Arrays.asList("_tr_land_plane", "_tr_begin_flying", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_close_door"))); + guardDependency.put("open_valve_retract_gear", new HashSet<>(Arrays.asList("_tr_close_valve_retract_gear", "_tr_open_valve_retract_gear", "_tr_env_start_retracting_first"))); + guardDependency.put("env_close_analogical_switch", new HashSet<>(Arrays.asList("_tr_env_open_analogical_switch", "_tr_evn_open_general_valve", "_tr_env_close_analogical_switch", "_tr_evn_close_general_valve"))); + guardDependency.put("env_start_extending", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); + guardDependency.put("open_valve_door_close", new HashSet<>(Arrays.asList("_tr_open_valve_door_close", "_tr_env_close_door_skip", "_tr_env_start_close_door", "_tr_env_close_door", "_tr_close_valve_door_close"))); + guardDependency.put("con_stop_stimulate_open_door_valve", new HashSet<>(Arrays.asList("_tr_open_valve_door_open", "_tr_con_stimulate_extend_gear_valve", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stimulate_open_door_valve", "_tr_close_valve_door_open"))); + guardDependency.put("con_stop_stimulate_extend_gear_valve", new HashSet<>(Arrays.asList("_tr_con_stimulate_extend_gear_valve", "_tr_close_valve_extend_gear", "_tr_con_stop_stimulate_open_door_valve", "_tr_open_valve_extend_gear", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_extend_gear_valve"))); + guardDependency.put("evn_close_general_valve", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_env_close_door_skip", "_tr_evn_open_general_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_evn_close_general_valve", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); + guardDependency.put("close_valve_extend_gear", new HashSet<>(Arrays.asList("_tr_close_valve_extend_gear", "_tr_open_valve_extend_gear", "_tr_env_start_extending"))); + guardDependency.put("con_stimulate_extend_gear_valve", new HashSet<>(Arrays.asList("_tr_con_stimulate_extend_gear_valve", "_tr_close_valve_extend_gear", "_tr_con_stop_stimulate_open_door_valve", "_tr_open_valve_extend_gear", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_extend_gear_valve"))); + guardDependency.put("close_valve_door_open", new HashSet<>(Arrays.asList("_tr_open_valve_door_open", "_tr_env_open_door_last", "_tr_env_start_open_door", "_tr_env_open_door_skip", "_tr_close_valve_door_open"))); + guardDependency.put("con_stimulate_close_door_valve", new HashSet<>(Arrays.asList("_tr_open_valve_door_close", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_close_valve_door_close"))); + guardDependency.put("env_extend_gear_skip", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); + guardDependency.put("env_open_door_skip", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); + guardDependency.put("env_start_open_door", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); + } + + private LandingGear_R6 next() { + synchronized(this.unvisitedStates) { + return switch(type) { + case BFS -> this.unvisitedStates.removeFirst(); + case DFS -> this.unvisitedStates.removeLast(); + case MIXED -> this.unvisitedStates.size() % 2 == 0 ? this.unvisitedStates.removeFirst() : this.unvisitedStates.removeLast(); + }; } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_open_valve_door_close", _trid_5); - if(_trid_5) { - LandingGear_R6 copiedState = state._copy(); - copiedState.open_valve_door_close(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("open_valve_door_close")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("open_valve_door_close")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "open_valve_door_close"); - } + } + + @SuppressWarnings("unchecked") + private Set<LandingGear_R6> generateNextStates(final LandingGear_R6 state) { + Set<LandingGear_R6> result = new HashSet<>(); + if(isCaching) { + PersistentHashMap parentsGuard = state.guardCache; + PersistentHashMap newCache = parentsGuard == null ? PersistentHashMap.EMPTY : parentsGuard; + Object cachedValue = null; + boolean dependentGuardsBoolean = true; + boolean _trid_1; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_begin_flying"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_begin_flying"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_6; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_close_valve_door_close"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_close_valve_door_close"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_6 = state._tr_close_valve_door_close(); - } else { - _trid_6 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_close_valve_door_close", _trid_6); - if(_trid_6) { - LandingGear_R6 copiedState = state._copy(); - copiedState.close_valve_door_close(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("close_valve_door_close")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("close_valve_door_close")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "close_valve_door_close"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_1 = state._tr_begin_flying(); + } else { + _trid_1 = (boolean) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_7; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_open_valve_retract_gear"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_open_valve_retract_gear"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_7 = state._tr_open_valve_retract_gear(); - } else { - _trid_7 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_open_valve_retract_gear", _trid_7); - if(_trid_7) { - LandingGear_R6 copiedState = state._copy(); - copiedState.open_valve_retract_gear(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("open_valve_retract_gear")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("open_valve_retract_gear")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "open_valve_retract_gear"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_begin_flying", _trid_1); + if(_trid_1) { + LandingGear_R6 copiedState = state._copy(); + copiedState.begin_flying(); + copiedState.parent = state; + addCachedInfos("begin_flying", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_2; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_land_plane"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_land_plane"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_8; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_close_valve_retract_gear"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_close_valve_retract_gear"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_8 = state._tr_close_valve_retract_gear(); - } else { - _trid_8 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_close_valve_retract_gear", _trid_8); - if(_trid_8) { - LandingGear_R6 copiedState = state._copy(); - copiedState.close_valve_retract_gear(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("close_valve_retract_gear")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("close_valve_retract_gear")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "close_valve_retract_gear"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_2 = state._tr_land_plane(); + } else { + _trid_2 = (boolean) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_9; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_open_valve_extend_gear"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_open_valve_extend_gear"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_9 = state._tr_open_valve_extend_gear(); - } else { - _trid_9 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_open_valve_extend_gear", _trid_9); - if(_trid_9) { - LandingGear_R6 copiedState = state._copy(); - copiedState.open_valve_extend_gear(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("open_valve_extend_gear")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("open_valve_extend_gear")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "open_valve_extend_gear"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_land_plane", _trid_2); + if(_trid_2) { + LandingGear_R6 copiedState = state._copy(); + copiedState.land_plane(); + copiedState.parent = state; + addCachedInfos("land_plane", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_3; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_open_valve_door_open"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_open_valve_door_open"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_10; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_close_valve_extend_gear"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_close_valve_extend_gear"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_10 = state._tr_close_valve_extend_gear(); - } else { - _trid_10 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_close_valve_extend_gear", _trid_10); - if(_trid_10) { - LandingGear_R6 copiedState = state._copy(); - copiedState.close_valve_extend_gear(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("close_valve_extend_gear")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("close_valve_extend_gear")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "close_valve_extend_gear"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_3 = state._tr_open_valve_door_open(); + } else { + _trid_3 = (boolean) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_11; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_con_stimulate_open_door_valve"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_con_stimulate_open_door_valve"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_11 = state._tr_con_stimulate_open_door_valve(); - } else { - _trid_11 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_con_stimulate_open_door_valve", _trid_11); - if(_trid_11) { - LandingGear_R6 copiedState = state._copy(); - copiedState.con_stimulate_open_door_valve(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("con_stimulate_open_door_valve")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("con_stimulate_open_door_valve")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "con_stimulate_open_door_valve"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_open_valve_door_open", _trid_3); + if(_trid_3) { + LandingGear_R6 copiedState = state._copy(); + copiedState.open_valve_door_open(); + copiedState.parent = state; + addCachedInfos("open_valve_door_open", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_4; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_close_valve_door_open"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_close_valve_door_open"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_12; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_con_stop_stimulate_open_door_valve"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_con_stop_stimulate_open_door_valve"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_12 = state._tr_con_stop_stimulate_open_door_valve(); - } else { - _trid_12 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_con_stop_stimulate_open_door_valve", _trid_12); - if(_trid_12) { - LandingGear_R6 copiedState = state._copy(); - copiedState.con_stop_stimulate_open_door_valve(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("con_stop_stimulate_open_door_valve")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("con_stop_stimulate_open_door_valve")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "con_stop_stimulate_open_door_valve"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_4 = state._tr_close_valve_door_open(); + } else { + _trid_4 = (boolean) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_13; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_con_stimulate_close_door_valve"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_con_stimulate_close_door_valve"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_13 = state._tr_con_stimulate_close_door_valve(); - } else { - _trid_13 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_con_stimulate_close_door_valve", _trid_13); - if(_trid_13) { - LandingGear_R6 copiedState = state._copy(); - copiedState.con_stimulate_close_door_valve(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("con_stimulate_close_door_valve")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("con_stimulate_close_door_valve")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "con_stimulate_close_door_valve"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_close_valve_door_open", _trid_4); + if(_trid_4) { + LandingGear_R6 copiedState = state._copy(); + copiedState.close_valve_door_open(); + copiedState.parent = state; + addCachedInfos("close_valve_door_open", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_5; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_open_valve_door_close"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_open_valve_door_close"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_14; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_con_stop_stimulate_close_door_valve"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_con_stop_stimulate_close_door_valve"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_14 = state._tr_con_stop_stimulate_close_door_valve(); - } else { - _trid_14 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_con_stop_stimulate_close_door_valve", _trid_14); - if(_trid_14) { - LandingGear_R6 copiedState = state._copy(); - copiedState.con_stop_stimulate_close_door_valve(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("con_stop_stimulate_close_door_valve")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("con_stop_stimulate_close_door_valve")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "con_stop_stimulate_close_door_valve"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_5 = state._tr_open_valve_door_close(); + } else { + _trid_5 = (boolean) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_15; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_con_stimulate_retract_gear_valve"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_con_stimulate_retract_gear_valve"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_15 = state._tr_con_stimulate_retract_gear_valve(); - } else { - _trid_15 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_con_stimulate_retract_gear_valve", _trid_15); - if(_trid_15) { - LandingGear_R6 copiedState = state._copy(); - copiedState.con_stimulate_retract_gear_valve(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("con_stimulate_retract_gear_valve")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("con_stimulate_retract_gear_valve")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "con_stimulate_retract_gear_valve"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_open_valve_door_close", _trid_5); + if(_trid_5) { + LandingGear_R6 copiedState = state._copy(); + copiedState.open_valve_door_close(); + copiedState.parent = state; + addCachedInfos("open_valve_door_close", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_6; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_close_valve_door_close"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_close_valve_door_close"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_16; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_con_stop_stimulate_retract_gear_valve"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_con_stop_stimulate_retract_gear_valve"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_16 = state._tr_con_stop_stimulate_retract_gear_valve(); - } else { - _trid_16 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_con_stop_stimulate_retract_gear_valve", _trid_16); - if(_trid_16) { - LandingGear_R6 copiedState = state._copy(); - copiedState.con_stop_stimulate_retract_gear_valve(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("con_stop_stimulate_retract_gear_valve")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("con_stop_stimulate_retract_gear_valve")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "con_stop_stimulate_retract_gear_valve"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_6 = state._tr_close_valve_door_close(); + } else { + _trid_6 = (boolean) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_17; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_con_stimulate_extend_gear_valve"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_con_stimulate_extend_gear_valve"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_17 = state._tr_con_stimulate_extend_gear_valve(); - } else { - _trid_17 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_con_stimulate_extend_gear_valve", _trid_17); - if(_trid_17) { - LandingGear_R6 copiedState = state._copy(); - copiedState.con_stimulate_extend_gear_valve(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("con_stimulate_extend_gear_valve")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("con_stimulate_extend_gear_valve")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "con_stimulate_extend_gear_valve"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_close_valve_door_close", _trid_6); + if(_trid_6) { + LandingGear_R6 copiedState = state._copy(); + copiedState.close_valve_door_close(); + copiedState.parent = state; + addCachedInfos("close_valve_door_close", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_7; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_open_valve_retract_gear"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_open_valve_retract_gear"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_18; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_con_stop_stimulate_extend_gear_valve"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_con_stop_stimulate_extend_gear_valve"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_18 = state._tr_con_stop_stimulate_extend_gear_valve(); - } else { - _trid_18 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_con_stop_stimulate_extend_gear_valve", _trid_18); - if(_trid_18) { - LandingGear_R6 copiedState = state._copy(); - copiedState.con_stop_stimulate_extend_gear_valve(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("con_stop_stimulate_extend_gear_valve")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("con_stop_stimulate_extend_gear_valve")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "con_stop_stimulate_extend_gear_valve"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_7 = state._tr_open_valve_retract_gear(); + } else { + _trid_7 = (boolean) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_19; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_env_start_retracting_first"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_env_start_retracting_first"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_19 = state._tr_env_start_retracting_first(); - } else { - _trid_19 = (BSet<POSITION>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_start_retracting_first", _trid_19); - for(POSITION param : _trid_19) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_start_retracting_first(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("env_start_retracting_first")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("env_start_retracting_first")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_start_retracting_first"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_open_valve_retract_gear", _trid_7); + if(_trid_7) { + LandingGear_R6 copiedState = state._copy(); + copiedState.open_valve_retract_gear(); + copiedState.parent = state; + addCachedInfos("open_valve_retract_gear", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_8; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_close_valve_retract_gear"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_close_valve_retract_gear"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_20; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_env_retract_gear_skip"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_env_retract_gear_skip"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_20 = state._tr_env_retract_gear_skip(); - } else { - _trid_20 = (BSet<POSITION>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_retract_gear_skip", _trid_20); - for(POSITION param : _trid_20) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_retract_gear_skip(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("env_retract_gear_skip")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("env_retract_gear_skip")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_retract_gear_skip"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_8 = state._tr_close_valve_retract_gear(); + } else { + _trid_8 = (boolean) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_21; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_env_retract_gear_last"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_env_retract_gear_last"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_21 = state._tr_env_retract_gear_last(); - } else { - _trid_21 = (BSet<POSITION>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_retract_gear_last", _trid_21); - for(POSITION param : _trid_21) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_retract_gear_last(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("env_retract_gear_last")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("env_retract_gear_last")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_retract_gear_last"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_close_valve_retract_gear", _trid_8); + if(_trid_8) { + LandingGear_R6 copiedState = state._copy(); + copiedState.close_valve_retract_gear(); + copiedState.parent = state; + addCachedInfos("close_valve_retract_gear", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_9; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_open_valve_extend_gear"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_open_valve_extend_gear"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_22; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_env_start_extending"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_env_start_extending"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_22 = state._tr_env_start_extending(); - } else { - _trid_22 = (BSet<POSITION>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_start_extending", _trid_22); - for(POSITION param : _trid_22) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_start_extending(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("env_start_extending")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("env_start_extending")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_start_extending"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_9 = state._tr_open_valve_extend_gear(); + } else { + _trid_9 = (boolean) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_23; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_env_extend_gear_last"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_env_extend_gear_last"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_23 = state._tr_env_extend_gear_last(); - } else { - _trid_23 = (BSet<POSITION>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_extend_gear_last", _trid_23); - for(POSITION param : _trid_23) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_extend_gear_last(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("env_extend_gear_last")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("env_extend_gear_last")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_extend_gear_last"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_open_valve_extend_gear", _trid_9); + if(_trid_9) { + LandingGear_R6 copiedState = state._copy(); + copiedState.open_valve_extend_gear(); + copiedState.parent = state; + addCachedInfos("open_valve_extend_gear", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_10; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_close_valve_extend_gear"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_close_valve_extend_gear"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_24; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_env_extend_gear_skip"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_env_extend_gear_skip"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_24 = state._tr_env_extend_gear_skip(); - } else { - _trid_24 = (BSet<POSITION>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_extend_gear_skip", _trid_24); - for(POSITION param : _trid_24) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_extend_gear_skip(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("env_extend_gear_skip")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("env_extend_gear_skip")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_extend_gear_skip"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_10 = state._tr_close_valve_extend_gear(); + } else { + _trid_10 = (boolean) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_25; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_env_start_open_door"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_env_start_open_door"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_25 = state._tr_env_start_open_door(); - } else { - _trid_25 = (BSet<POSITION>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_start_open_door", _trid_25); - for(POSITION param : _trid_25) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_start_open_door(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("env_start_open_door")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("env_start_open_door")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_start_open_door"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_close_valve_extend_gear", _trid_10); + if(_trid_10) { + LandingGear_R6 copiedState = state._copy(); + copiedState.close_valve_extend_gear(); + copiedState.parent = state; + addCachedInfos("close_valve_extend_gear", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_11; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_con_stimulate_open_door_valve"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_con_stimulate_open_door_valve"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_26; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_env_open_door_last"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_env_open_door_last"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_26 = state._tr_env_open_door_last(); - } else { - _trid_26 = (BSet<POSITION>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_open_door_last", _trid_26); - for(POSITION param : _trid_26) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_open_door_last(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("env_open_door_last")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("env_open_door_last")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_open_door_last"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_11 = state._tr_con_stimulate_open_door_valve(); + } else { + _trid_11 = (boolean) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_27; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_env_open_door_skip"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_env_open_door_skip"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_27 = state._tr_env_open_door_skip(); - } else { - _trid_27 = (BSet<POSITION>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_open_door_skip", _trid_27); - for(POSITION param : _trid_27) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_open_door_skip(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("env_open_door_skip")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("env_open_door_skip")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_open_door_skip"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_con_stimulate_open_door_valve", _trid_11); + if(_trid_11) { + LandingGear_R6 copiedState = state._copy(); + copiedState.con_stimulate_open_door_valve(); + copiedState.parent = state; + addCachedInfos("con_stimulate_open_door_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_12; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_con_stop_stimulate_open_door_valve"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_con_stop_stimulate_open_door_valve"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_28; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_env_start_close_door"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_env_start_close_door"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_28 = state._tr_env_start_close_door(); - } else { - _trid_28 = (BSet<POSITION>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_start_close_door", _trid_28); - for(POSITION param : _trid_28) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_start_close_door(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("env_start_close_door")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("env_start_close_door")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_start_close_door"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_12 = state._tr_con_stop_stimulate_open_door_valve(); + } else { + _trid_12 = (boolean) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_29; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_env_close_door"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_env_close_door"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_29 = state._tr_env_close_door(); - } else { - _trid_29 = (BSet<POSITION>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_close_door", _trid_29); - for(POSITION param : _trid_29) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_close_door(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("env_close_door")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("env_close_door")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_close_door"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_con_stop_stimulate_open_door_valve", _trid_12); + if(_trid_12) { + LandingGear_R6 copiedState = state._copy(); + copiedState.con_stop_stimulate_open_door_valve(); + copiedState.parent = state; + addCachedInfos("con_stop_stimulate_open_door_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_13; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_con_stimulate_close_door_valve"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_con_stimulate_close_door_valve"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_30; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_env_close_door_skip"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_env_close_door_skip"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_30 = state._tr_env_close_door_skip(); - } else { - _trid_30 = (BSet<POSITION>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_close_door_skip", _trid_30); - for(POSITION param : _trid_30) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_close_door_skip(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("env_close_door_skip")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("env_close_door_skip")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_close_door_skip"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_13 = state._tr_con_stimulate_close_door_valve(); + } else { + _trid_13 = (boolean) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_31; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_toggle_handle_up"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_toggle_handle_up"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_31 = state._tr_toggle_handle_up(); - } else { - _trid_31 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_toggle_handle_up", _trid_31); - if(_trid_31) { - LandingGear_R6 copiedState = state._copy(); - copiedState.toggle_handle_up(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("toggle_handle_up")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("toggle_handle_up")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "toggle_handle_up"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_con_stimulate_close_door_valve", _trid_13); + if(_trid_13) { + LandingGear_R6 copiedState = state._copy(); + copiedState.con_stimulate_close_door_valve(); + copiedState.parent = state; + addCachedInfos("con_stimulate_close_door_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_14; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_con_stop_stimulate_close_door_valve"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_con_stop_stimulate_close_door_valve"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_32; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_toggle_handle_down"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_toggle_handle_down"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_32 = state._tr_toggle_handle_down(); - } else { - _trid_32 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_toggle_handle_down", _trid_32); - if(_trid_32) { - LandingGear_R6 copiedState = state._copy(); - copiedState.toggle_handle_down(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("toggle_handle_down")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("toggle_handle_down")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "toggle_handle_down"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_14 = state._tr_con_stop_stimulate_close_door_valve(); + } else { + _trid_14 = (boolean) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_33; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_con_stimulate_general_valve"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_con_stimulate_general_valve"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_33 = state._tr_con_stimulate_general_valve(); - } else { - _trid_33 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_con_stimulate_general_valve", _trid_33); - if(_trid_33) { - LandingGear_R6 copiedState = state._copy(); - copiedState.con_stimulate_general_valve(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("con_stimulate_general_valve")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("con_stimulate_general_valve")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "con_stimulate_general_valve"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_con_stop_stimulate_close_door_valve", _trid_14); + if(_trid_14) { + LandingGear_R6 copiedState = state._copy(); + copiedState.con_stop_stimulate_close_door_valve(); + copiedState.parent = state; + addCachedInfos("con_stop_stimulate_close_door_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_15; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_con_stimulate_retract_gear_valve"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_con_stimulate_retract_gear_valve"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_34; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_con_stop_stimulate_general_valve"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_con_stop_stimulate_general_valve"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_34 = state._tr_con_stop_stimulate_general_valve(); - } else { - _trid_34 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_con_stop_stimulate_general_valve", _trid_34); - if(_trid_34) { - LandingGear_R6 copiedState = state._copy(); - copiedState.con_stop_stimulate_general_valve(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("con_stop_stimulate_general_valve")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("con_stop_stimulate_general_valve")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "con_stop_stimulate_general_valve"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_15 = state._tr_con_stimulate_retract_gear_valve(); + } else { + _trid_15 = (boolean) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_35; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_evn_open_general_valve"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_evn_open_general_valve"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_35 = state._tr_evn_open_general_valve(); - } else { - _trid_35 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_evn_open_general_valve", _trid_35); - if(_trid_35) { - LandingGear_R6 copiedState = state._copy(); - copiedState.evn_open_general_valve(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("evn_open_general_valve")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("evn_open_general_valve")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "evn_open_general_valve"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_con_stimulate_retract_gear_valve", _trid_15); + if(_trid_15) { + LandingGear_R6 copiedState = state._copy(); + copiedState.con_stimulate_retract_gear_valve(); + copiedState.parent = state; + addCachedInfos("con_stimulate_retract_gear_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_16; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_con_stop_stimulate_retract_gear_valve"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_con_stop_stimulate_retract_gear_valve"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_36; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_evn_close_general_valve"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_evn_close_general_valve"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_36 = state._tr_evn_close_general_valve(); - } else { - _trid_36 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_evn_close_general_valve", _trid_36); - if(_trid_36) { - LandingGear_R6 copiedState = state._copy(); - copiedState.evn_close_general_valve(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("evn_close_general_valve")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("evn_close_general_valve")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "evn_close_general_valve"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_16 = state._tr_con_stop_stimulate_retract_gear_valve(); + } else { + _trid_16 = (boolean) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_37; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_env_close_analogical_switch"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_env_close_analogical_switch"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_37 = state._tr_env_close_analogical_switch(); - } else { - _trid_37 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_close_analogical_switch", _trid_37); - if(_trid_37) { - LandingGear_R6 copiedState = state._copy(); - copiedState.env_close_analogical_switch(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("env_close_analogical_switch")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("env_close_analogical_switch")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_close_analogical_switch"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_con_stop_stimulate_retract_gear_valve", _trid_16); + if(_trid_16) { + LandingGear_R6 copiedState = state._copy(); + copiedState.con_stop_stimulate_retract_gear_valve(); + copiedState.parent = state; + addCachedInfos("con_stop_stimulate_retract_gear_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + boolean _trid_17; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_con_stimulate_extend_gear_valve"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_con_stimulate_extend_gear_valve"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_38; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_env_open_analogical_switch"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_env_open_analogical_switch"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_38 = state._tr_env_open_analogical_switch(); - } else { - _trid_38 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_open_analogical_switch", _trid_38); - if(_trid_38) { - LandingGear_R6 copiedState = state._copy(); - copiedState.env_open_analogical_switch(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("env_open_analogical_switch")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("env_open_analogical_switch")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_open_analogical_switch"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_17 = state._tr_con_stimulate_extend_gear_valve(); + } else { + _trid_17 = (boolean) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - synchronized(guardLock) { - guardCache.put(state, newCache); - } - } else { - if(state._tr_begin_flying()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.begin_flying(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "begin_flying"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_con_stimulate_extend_gear_valve", _trid_17); + if(_trid_17) { + LandingGear_R6 copiedState = state._copy(); + copiedState.con_stimulate_extend_gear_valve(); + copiedState.parent = state; + addCachedInfos("con_stimulate_extend_gear_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_land_plane()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.land_plane(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "land_plane"); - } + boolean _trid_18; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_con_stop_stimulate_extend_gear_valve"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_con_stop_stimulate_extend_gear_valve"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_open_valve_door_open()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.open_valve_door_open(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "open_valve_door_open"); - } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_18 = state._tr_con_stop_stimulate_extend_gear_valve(); + } else { + _trid_18 = (boolean) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_close_valve_door_open()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.close_valve_door_open(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "close_valve_door_open"); - } + + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_con_stop_stimulate_extend_gear_valve", _trid_18); + if(_trid_18) { + LandingGear_R6 copiedState = state._copy(); + copiedState.con_stop_stimulate_extend_gear_valve(); + copiedState.parent = state; + addCachedInfos("con_stop_stimulate_extend_gear_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_open_valve_door_close()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.open_valve_door_close(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "open_valve_door_close"); - } + BSet<POSITION> _trid_19; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_env_start_retracting_first"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_env_start_retracting_first"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_close_valve_door_close()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.close_valve_door_close(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "close_valve_door_close"); - } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_19 = state._tr_env_start_retracting_first(); + } else { + _trid_19 = (BSet<POSITION>) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_open_valve_retract_gear()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.open_valve_retract_gear(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "open_valve_retract_gear"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_start_retracting_first", _trid_19); + for(POSITION param : _trid_19) { + POSITION _tmp_1 = param; + + LandingGear_R6 copiedState = state._copy(); + copiedState.env_start_retracting_first(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_start_retracting_first", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_close_valve_retract_gear()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.close_valve_retract_gear(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "close_valve_retract_gear"); - } + BSet<POSITION> _trid_20; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_env_retract_gear_skip"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_env_retract_gear_skip"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_open_valve_extend_gear()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.open_valve_extend_gear(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "open_valve_extend_gear"); - } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_20 = state._tr_env_retract_gear_skip(); + } else { + _trid_20 = (BSet<POSITION>) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_close_valve_extend_gear()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.close_valve_extend_gear(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "close_valve_extend_gear"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_retract_gear_skip", _trid_20); + for(POSITION param : _trid_20) { + POSITION _tmp_1 = param; + + LandingGear_R6 copiedState = state._copy(); + copiedState.env_retract_gear_skip(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_retract_gear_skip", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_con_stimulate_open_door_valve()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.con_stimulate_open_door_valve(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "con_stimulate_open_door_valve"); - } + BSet<POSITION> _trid_21; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_env_retract_gear_last"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_env_retract_gear_last"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_con_stop_stimulate_open_door_valve()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.con_stop_stimulate_open_door_valve(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "con_stop_stimulate_open_door_valve"); - } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_21 = state._tr_env_retract_gear_last(); + } else { + _trid_21 = (BSet<POSITION>) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_con_stimulate_close_door_valve()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.con_stimulate_close_door_valve(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "con_stimulate_close_door_valve"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_retract_gear_last", _trid_21); + for(POSITION param : _trid_21) { + POSITION _tmp_1 = param; + + LandingGear_R6 copiedState = state._copy(); + copiedState.env_retract_gear_last(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_retract_gear_last", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_con_stop_stimulate_close_door_valve()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.con_stop_stimulate_close_door_valve(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "con_stop_stimulate_close_door_valve"); - } + BSet<POSITION> _trid_22; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_env_start_extending"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_env_start_extending"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_con_stimulate_retract_gear_valve()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.con_stimulate_retract_gear_valve(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "con_stimulate_retract_gear_valve"); - } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_22 = state._tr_env_start_extending(); + } else { + _trid_22 = (BSet<POSITION>) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_con_stop_stimulate_retract_gear_valve()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.con_stop_stimulate_retract_gear_valve(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "con_stop_stimulate_retract_gear_valve"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_start_extending", _trid_22); + for(POSITION param : _trid_22) { + POSITION _tmp_1 = param; + + LandingGear_R6 copiedState = state._copy(); + copiedState.env_start_extending(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_start_extending", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_con_stimulate_extend_gear_valve()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.con_stimulate_extend_gear_valve(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "con_stimulate_extend_gear_valve"); - } + BSet<POSITION> _trid_23; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_env_extend_gear_last"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_env_extend_gear_last"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_con_stop_stimulate_extend_gear_valve()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.con_stop_stimulate_extend_gear_valve(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "con_stop_stimulate_extend_gear_valve"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_19 = state._tr_env_start_retracting_first(); - for(POSITION param : _trid_19) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_start_retracting_first(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_start_retracting_first"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_20 = state._tr_env_retract_gear_skip(); - for(POSITION param : _trid_20) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_retract_gear_skip(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_retract_gear_skip"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_21 = state._tr_env_retract_gear_last(); - for(POSITION param : _trid_21) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_retract_gear_last(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_retract_gear_last"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_22 = state._tr_env_start_extending(); - for(POSITION param : _trid_22) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_start_extending(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_start_extending"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_23 = state._tr_env_extend_gear_last(); - for(POSITION param : _trid_23) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_extend_gear_last(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_extend_gear_last"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_24 = state._tr_env_extend_gear_skip(); - for(POSITION param : _trid_24) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_extend_gear_skip(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_extend_gear_skip"); - } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_23 = state._tr_env_extend_gear_last(); + } else { + _trid_23 = (BSet<POSITION>) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_25 = state._tr_env_start_open_door(); - for(POSITION param : _trid_25) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_start_open_door(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_start_open_door"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_extend_gear_last", _trid_23); + for(POSITION param : _trid_23) { + POSITION _tmp_1 = param; + + LandingGear_R6 copiedState = state._copy(); + copiedState.env_extend_gear_last(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_extend_gear_last", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_26 = state._tr_env_open_door_last(); - for(POSITION param : _trid_26) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_open_door_last(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_open_door_last"); - } + BSet<POSITION> _trid_24; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_env_extend_gear_skip"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_env_extend_gear_skip"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_27 = state._tr_env_open_door_skip(); - for(POSITION param : _trid_27) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_open_door_skip(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_open_door_skip"); - } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_24 = state._tr_env_extend_gear_skip(); + } else { + _trid_24 = (BSet<POSITION>) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_28 = state._tr_env_start_close_door(); - for(POSITION param : _trid_28) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_start_close_door(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_start_close_door"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_extend_gear_skip", _trid_24); + for(POSITION param : _trid_24) { + POSITION _tmp_1 = param; + + LandingGear_R6 copiedState = state._copy(); + copiedState.env_extend_gear_skip(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_extend_gear_skip", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_29 = state._tr_env_close_door(); - for(POSITION param : _trid_29) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_close_door(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_close_door"); - } + BSet<POSITION> _trid_25; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_env_start_open_door"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_env_start_open_door"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<POSITION> _trid_30 = state._tr_env_close_door_skip(); - for(POSITION param : _trid_30) { - POSITION _tmp_1 = param; - - LandingGear_R6 copiedState = state._copy(); - copiedState.env_close_door_skip(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_close_door_skip"); - } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_25 = state._tr_env_start_open_door(); + } else { + _trid_25 = (BSet<POSITION>) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_toggle_handle_up()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.toggle_handle_up(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "toggle_handle_up"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_start_open_door", _trid_25); + for(POSITION param : _trid_25) { + POSITION _tmp_1 = param; + + LandingGear_R6 copiedState = state._copy(); + copiedState.env_start_open_door(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_start_open_door", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_toggle_handle_down()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.toggle_handle_down(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "toggle_handle_down"); - } + BSet<POSITION> _trid_26; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_env_open_door_last"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_env_open_door_last"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_con_stimulate_general_valve()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.con_stimulate_general_valve(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "con_stimulate_general_valve"); - } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_26 = state._tr_env_open_door_last(); + } else { + _trid_26 = (BSet<POSITION>) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_con_stop_stimulate_general_valve()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.con_stop_stimulate_general_valve(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "con_stop_stimulate_general_valve"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_open_door_last", _trid_26); + for(POSITION param : _trid_26) { + POSITION _tmp_1 = param; + + LandingGear_R6 copiedState = state._copy(); + copiedState.env_open_door_last(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_open_door_last", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_evn_open_general_valve()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.evn_open_general_valve(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "evn_open_general_valve"); - } + BSet<POSITION> _trid_27; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_env_open_door_skip"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_env_open_door_skip"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_evn_close_general_valve()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.evn_close_general_valve(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "evn_close_general_valve"); - } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_27 = state._tr_env_open_door_skip(); + } else { + _trid_27 = (BSet<POSITION>) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_env_close_analogical_switch()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.env_close_analogical_switch(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_close_analogical_switch"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_open_door_skip", _trid_27); + for(POSITION param : _trid_27) { + POSITION _tmp_1 = param; + + LandingGear_R6 copiedState = state._copy(); + copiedState.env_open_door_skip(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_open_door_skip", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_env_open_analogical_switch()) { - LandingGear_R6 copiedState = state._copy(); - copiedState.env_open_analogical_switch(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "env_open_analogical_switch"); - } + BSet<POSITION> _trid_28; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_env_start_close_door"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_env_start_close_door"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - } - return result; - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_28 = state._tr_env_start_close_door(); + } else { + _trid_28 = (BSet<POSITION>) cachedValue; + } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_start_close_door", _trid_28); + for(POSITION param : _trid_28) { + POSITION _tmp_1 = param; + LandingGear_R6 copiedState = state._copy(); + copiedState.env_start_close_door(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_start_close_door", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - public static boolean checkInvariants(Object guardLock, LandingGear_R6 state, boolean isCaching, Map<LandingGear_R6, Set<String>> dependentInvariant) { - if(isCaching) { - Set<String> dependentInvariantsOfState; - synchronized(guardLock) { - dependentInvariantsOfState = dependentInvariant.get(state); - } - if(dependentInvariantsOfState.contains("_check_inv_1")) { - if(!state._check_inv_1()) { - return false; } - } - if(dependentInvariantsOfState.contains("_check_inv_2")) { - if(!state._check_inv_2()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_3")) { - if(!state._check_inv_3()) { - return false; + BSet<POSITION> _trid_29; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_env_close_door"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_env_close_door"); } - } - if(dependentInvariantsOfState.contains("_check_inv_4")) { - if(!state._check_inv_4()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_5")) { - if(!state._check_inv_5()) { - return false; + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_29 = state._tr_env_close_door(); + } else { + _trid_29 = (BSet<POSITION>) cachedValue; } - } - if(dependentInvariantsOfState.contains("_check_inv_6")) { - if(!state._check_inv_6()) { - return false; + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_close_door", _trid_29); + for(POSITION param : _trid_29) { + POSITION _tmp_1 = param; + + LandingGear_R6 copiedState = state._copy(); + copiedState.env_close_door(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_close_door", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - } - if(dependentInvariantsOfState.contains("_check_inv_7")) { - if(!state._check_inv_7()) { - return false; + BSet<POSITION> _trid_30; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_env_close_door_skip"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_env_close_door_skip"); } - } - if(dependentInvariantsOfState.contains("_check_inv_8")) { - if(!state._check_inv_8()) { - return false; + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_30 = state._tr_env_close_door_skip(); + } else { + _trid_30 = (BSet<POSITION>) cachedValue; } - } - if(dependentInvariantsOfState.contains("_check_inv_9")) { - if(!state._check_inv_9()) { - return false; + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_close_door_skip", _trid_30); + for(POSITION param : _trid_30) { + POSITION _tmp_1 = param; + + LandingGear_R6 copiedState = state._copy(); + copiedState.env_close_door_skip(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_close_door_skip", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - } - if(dependentInvariantsOfState.contains("_check_inv_10")) { - if(!state._check_inv_10()) { - return false; + boolean _trid_31; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_toggle_handle_up"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_toggle_handle_up"); } - } - if(dependentInvariantsOfState.contains("_check_inv_11")) { - if(!state._check_inv_11()) { - return false; + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_31 = state._tr_toggle_handle_up(); + } else { + _trid_31 = (boolean) cachedValue; } - } - if(dependentInvariantsOfState.contains("_check_inv_12")) { - if(!state._check_inv_12()) { - return false; + + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_toggle_handle_up", _trid_31); + if(_trid_31) { + LandingGear_R6 copiedState = state._copy(); + copiedState.toggle_handle_up(); + copiedState.parent = state; + addCachedInfos("toggle_handle_up", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - } - if(dependentInvariantsOfState.contains("_check_inv_13")) { - if(!state._check_inv_13()) { - return false; + boolean _trid_32; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_toggle_handle_down"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_toggle_handle_down"); } - } - if(dependentInvariantsOfState.contains("_check_inv_14")) { - if(!state._check_inv_14()) { - return false; + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_32 = state._tr_toggle_handle_down(); + } else { + _trid_32 = (boolean) cachedValue; } - } - if(dependentInvariantsOfState.contains("_check_inv_15")) { - if(!state._check_inv_15()) { - return false; + + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_toggle_handle_down", _trid_32); + if(_trid_32) { + LandingGear_R6 copiedState = state._copy(); + copiedState.toggle_handle_down(); + copiedState.parent = state; + addCachedInfos("toggle_handle_down", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - } - if(dependentInvariantsOfState.contains("_check_inv_16")) { - if(!state._check_inv_16()) { - return false; + boolean _trid_33; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_con_stimulate_general_valve"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_con_stimulate_general_valve"); } - } - if(dependentInvariantsOfState.contains("_check_inv_17")) { - if(!state._check_inv_17()) { - return false; + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_33 = state._tr_con_stimulate_general_valve(); + } else { + _trid_33 = (boolean) cachedValue; } - } - if(dependentInvariantsOfState.contains("_check_inv_18")) { - if(!state._check_inv_18()) { - return false; + + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_con_stimulate_general_valve", _trid_33); + if(_trid_33) { + LandingGear_R6 copiedState = state._copy(); + copiedState.con_stimulate_general_valve(); + copiedState.parent = state; + addCachedInfos("con_stimulate_general_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - } - if(dependentInvariantsOfState.contains("_check_inv_19")) { - if(!state._check_inv_19()) { - return false; + boolean _trid_34; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_con_stop_stimulate_general_valve"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_con_stop_stimulate_general_valve"); } - } - if(dependentInvariantsOfState.contains("_check_inv_20")) { - if(!state._check_inv_20()) { - return false; + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_34 = state._tr_con_stop_stimulate_general_valve(); + } else { + _trid_34 = (boolean) cachedValue; } - } - if(dependentInvariantsOfState.contains("_check_inv_21")) { - if(!state._check_inv_21()) { - return false; + + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_con_stop_stimulate_general_valve", _trid_34); + if(_trid_34) { + LandingGear_R6 copiedState = state._copy(); + copiedState.con_stop_stimulate_general_valve(); + copiedState.parent = state; + addCachedInfos("con_stop_stimulate_general_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - } - if(dependentInvariantsOfState.contains("_check_inv_22")) { - if(!state._check_inv_22()) { - return false; + boolean _trid_35; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_evn_open_general_valve"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_evn_open_general_valve"); } - } - if(dependentInvariantsOfState.contains("_check_inv_23")) { - if(!state._check_inv_23()) { - return false; + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_35 = state._tr_evn_open_general_valve(); + } else { + _trid_35 = (boolean) cachedValue; } - } - if(dependentInvariantsOfState.contains("_check_inv_24")) { - if(!state._check_inv_24()) { - return false; + + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_evn_open_general_valve", _trid_35); + if(_trid_35) { + LandingGear_R6 copiedState = state._copy(); + copiedState.evn_open_general_valve(); + copiedState.parent = state; + addCachedInfos("evn_open_general_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - } - if(dependentInvariantsOfState.contains("_check_inv_25")) { - if(!state._check_inv_25()) { - return false; + boolean _trid_36; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_evn_close_general_valve"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_evn_close_general_valve"); } - } - return true; - } - return !(!state._check_inv_1() || !state._check_inv_2() || !state._check_inv_3() || !state._check_inv_4() || !state._check_inv_5() || !state._check_inv_6() || !state._check_inv_7() || !state._check_inv_8() || !state._check_inv_9() || !state._check_inv_10() || !state._check_inv_11() || !state._check_inv_12() || !state._check_inv_13() || !state._check_inv_14() || !state._check_inv_15() || !state._check_inv_16() || !state._check_inv_17() || !state._check_inv_18() || !state._check_inv_19() || !state._check_inv_20() || !state._check_inv_21() || !state._check_inv_22() || !state._check_inv_23() || !state._check_inv_24() || !state._check_inv_25()); - } - - private static void printResult(int states, int transitions, boolean deadlockDetected, boolean invariantViolated, List<LandingGear_R6> counterExampleState, Map<LandingGear_R6, LandingGear_R6> parents, Map<LandingGear_R6, String> stateAccessedVia) { - if(invariantViolated || deadlockDetected) { - if(deadlockDetected) { - System.out.println("DEADLOCK DETECTED"); - } - if(invariantViolated) { - System.out.println("INVARIANT VIOLATED"); - } - System.out.println("COUNTER EXAMPLE TRACE: "); - StringBuilder sb = new StringBuilder(); - if(counterExampleState.size() >= 1) { - LandingGear_R6 currentState = counterExampleState.get(0); - while(currentState != null) { - sb.insert(0, currentState.toString()); - sb.insert(0, "\n"); - sb.insert(0, stateAccessedVia.get(currentState)); - sb.insert(0, "\n\n"); - currentState = parents.get(currentState); + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_36 = state._tr_evn_close_general_valve(); + } else { + _trid_36 = (boolean) cachedValue; } - } - System.out.println(sb.toString()); - } - if(!deadlockDetected && !invariantViolated) { - System.out.println("MODEL CHECKING SUCCESSFUL"); - } - System.out.println("Number of States: " + states); - System.out.println("Number of Transitions: " + transitions); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_evn_close_general_valve", _trid_36); + if(_trid_36) { + LandingGear_R6 copiedState = state._copy(); + copiedState.evn_close_general_valve(); + copiedState.parent = state; + addCachedInfos("evn_close_general_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - private static LandingGear_R6 next(LinkedList<LandingGear_R6> collection, Object lock, Type type) { - synchronized(lock) { - return switch(type) { - case BFS -> collection.removeFirst(); - case DFS -> collection.removeLast(); - case MIXED -> collection.size() % 2 == 0 ? collection.removeFirst() : collection.removeLast(); - }; - } - } + } + boolean _trid_37; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_env_close_analogical_switch"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_env_close_analogical_switch"); + } - private static void modelCheckSingleThreaded(Type type, boolean isCaching) { - Object lock = new Object(); - Object guardLock = new Object(); + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_37 = state._tr_env_close_analogical_switch(); + } else { + _trid_37 = (boolean) cachedValue; + } - LandingGear_R6 machine = new LandingGear_R6(); + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_close_analogical_switch", _trid_37); + if(_trid_37) { + LandingGear_R6 copiedState = state._copy(); + copiedState.env_close_analogical_switch(); + copiedState.parent = state; + addCachedInfos("env_close_analogical_switch", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } + boolean _trid_38; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_env_open_analogical_switch"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_env_open_analogical_switch"); + } - AtomicBoolean invariantViolated = new AtomicBoolean(false); - AtomicBoolean deadlockDetected = new AtomicBoolean(false); - AtomicBoolean stopThreads = new AtomicBoolean(false); + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_38 = state._tr_env_open_analogical_switch(); + } else { + _trid_38 = (boolean) cachedValue; + } - Set<LandingGear_R6> states = new HashSet<>(); - states.add(machine); - AtomicInteger numberStates = new AtomicInteger(1); + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_env_open_analogical_switch", _trid_38); + if(_trid_38) { + LandingGear_R6 copiedState = state._copy(); + copiedState.env_open_analogical_switch(); + copiedState.parent = state; + addCachedInfos("env_open_analogical_switch", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - LinkedList<LandingGear_R6> collection = new LinkedList<>(); - collection.add(machine); + } - Map<String, Set<String>> invariantDependency = new HashMap<>(); - Map<String, Set<String>> guardDependency = new HashMap<>(); - Map<LandingGear_R6, Set<String>> dependentInvariant = new HashMap<>(); - Map<LandingGear_R6, Set<String>> dependentGuard = new HashMap<>(); - Map<LandingGear_R6, PersistentHashMap> guardCache = new HashMap<>(); - Map<LandingGear_R6, LandingGear_R6> parents = new HashMap<>(); - Map<LandingGear_R6, String> stateAccessedVia = new HashMap<>(); - if(isCaching) { - invariantDependency.put("close_valve_door_close", new HashSet<>(Arrays.asList("_check_inv_10"))); - invariantDependency.put("close_valve_retract_gear", new HashSet<>(Arrays.asList("_check_inv_13"))); - invariantDependency.put("con_stimulate_open_door_valve", new HashSet<>(Arrays.asList("_check_inv_18", "_check_inv_17", "_check_inv_7"))); - invariantDependency.put("env_close_door", new HashSet<>(Arrays.asList("_check_inv_15", "_check_inv_21", "_check_inv_20", "_check_inv_25", "_check_inv_22"))); - invariantDependency.put("env_start_close_door", new HashSet<>(Arrays.asList("_check_inv_15", "_check_inv_21", "_check_inv_20", "_check_inv_25", "_check_inv_22"))); - invariantDependency.put("toggle_handle_up", new HashSet<>(Arrays.asList("_check_inv_4", "_check_inv_14"))); - invariantDependency.put("toggle_handle_down", new HashSet<>(Arrays.asList("_check_inv_4", "_check_inv_14"))); - invariantDependency.put("open_valve_door_open", new HashSet<>(Arrays.asList("_check_inv_12"))); - invariantDependency.put("env_retract_gear_last", new HashSet<>(Arrays.asList("_check_inv_16", "_check_inv_19", "_check_inv_25", "_check_inv_24", "_check_inv_23"))); - invariantDependency.put("env_open_door_last", new HashSet<>(Arrays.asList("_check_inv_15", "_check_inv_21", "_check_inv_20", "_check_inv_25", "_check_inv_22"))); - invariantDependency.put("con_stop_stimulate_retract_gear_valve", new HashSet<>(Arrays.asList("_check_inv_17", "_check_inv_8"))); - invariantDependency.put("env_close_door_skip", new HashSet<>(Arrays.asList("_check_inv_21", "_check_inv_20", "_check_inv_22"))); - invariantDependency.put("con_stop_stimulate_close_door_valve", new HashSet<>(Arrays.asList("_check_inv_18", "_check_inv_17", "_check_inv_5"))); - invariantDependency.put("env_open_analogical_switch", new HashSet<>(Arrays.asList("_check_inv_1"))); - invariantDependency.put("con_stop_stimulate_general_valve", new HashSet<>(Arrays.asList("_check_inv_17", "_check_inv_2", "_check_inv_4"))); - invariantDependency.put("env_extend_gear_last", new HashSet<>(Arrays.asList("_check_inv_16", "_check_inv_19", "_check_inv_25", "_check_inv_24", "_check_inv_23"))); - invariantDependency.put("evn_open_general_valve", new HashSet<>(Arrays.asList("_check_inv_3"))); - invariantDependency.put("land_plane", new HashSet<>(Arrays.asList("_check_inv_9"))); - invariantDependency.put("con_stimulate_retract_gear_valve", new HashSet<>(Arrays.asList("_check_inv_17", "_check_inv_8"))); - invariantDependency.put("con_stimulate_general_valve", new HashSet<>(Arrays.asList("_check_inv_17", "_check_inv_2"))); - invariantDependency.put("env_start_retracting_first", new HashSet<>(Arrays.asList("_check_inv_16", "_check_inv_19", "_check_inv_25", "_check_inv_24", "_check_inv_23"))); - invariantDependency.put("env_retract_gear_skip", new HashSet<>(Arrays.asList("_check_inv_19", "_check_inv_24", "_check_inv_23"))); - invariantDependency.put("open_valve_extend_gear", new HashSet<>(Arrays.asList("_check_inv_11"))); - invariantDependency.put("begin_flying", new HashSet<>(Arrays.asList("_check_inv_9"))); - invariantDependency.put("open_valve_retract_gear", new HashSet<>(Arrays.asList("_check_inv_13"))); - invariantDependency.put("env_close_analogical_switch", new HashSet<>(Arrays.asList("_check_inv_1"))); - invariantDependency.put("env_start_extending", new HashSet<>(Arrays.asList("_check_inv_16", "_check_inv_19", "_check_inv_25", "_check_inv_24", "_check_inv_23"))); - invariantDependency.put("open_valve_door_close", new HashSet<>(Arrays.asList("_check_inv_10"))); - invariantDependency.put("con_stop_stimulate_open_door_valve", new HashSet<>(Arrays.asList("_check_inv_18", "_check_inv_17", "_check_inv_7"))); - invariantDependency.put("con_stop_stimulate_extend_gear_valve", new HashSet<>(Arrays.asList("_check_inv_17", "_check_inv_6"))); - invariantDependency.put("evn_close_general_valve", new HashSet<>(Arrays.asList("_check_inv_3"))); - invariantDependency.put("close_valve_extend_gear", new HashSet<>(Arrays.asList("_check_inv_11"))); - invariantDependency.put("con_stimulate_extend_gear_valve", new HashSet<>(Arrays.asList("_check_inv_17", "_check_inv_6"))); - invariantDependency.put("close_valve_door_open", new HashSet<>(Arrays.asList("_check_inv_12"))); - invariantDependency.put("con_stimulate_close_door_valve", new HashSet<>(Arrays.asList("_check_inv_18", "_check_inv_17", "_check_inv_5"))); - invariantDependency.put("env_extend_gear_skip", new HashSet<>(Arrays.asList("_check_inv_19", "_check_inv_24", "_check_inv_23"))); - invariantDependency.put("env_open_door_skip", new HashSet<>(Arrays.asList("_check_inv_21", "_check_inv_20", "_check_inv_22"))); - invariantDependency.put("env_start_open_door", new HashSet<>(Arrays.asList("_check_inv_15", "_check_inv_21", "_check_inv_20", "_check_inv_25", "_check_inv_22"))); - guardDependency.put("close_valve_door_close", new HashSet<>(Arrays.asList("_tr_open_valve_door_close", "_tr_env_close_door_skip", "_tr_env_start_close_door", "_tr_env_close_door", "_tr_close_valve_door_close"))); - guardDependency.put("close_valve_retract_gear", new HashSet<>(Arrays.asList("_tr_close_valve_retract_gear", "_tr_open_valve_retract_gear", "_tr_env_start_retracting_first"))); - guardDependency.put("con_stimulate_open_door_valve", new HashSet<>(Arrays.asList("_tr_open_valve_door_open", "_tr_con_stimulate_extend_gear_valve", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stimulate_open_door_valve", "_tr_close_valve_door_open"))); - guardDependency.put("env_close_door", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("env_start_close_door", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("toggle_handle_up", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_close_analogical_switch", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip", "_tr_con_stimulate_general_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_toggle_handle_down", "_tr_env_open_door_last", "_tr_toggle_handle_up", "_tr_env_start_close_door", "_tr_con_stop_stimulate_close_door_valve"))); - guardDependency.put("toggle_handle_down", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_close_analogical_switch", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip", "_tr_con_stimulate_general_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_toggle_handle_down", "_tr_env_open_door_last", "_tr_toggle_handle_up", "_tr_env_start_close_door", "_tr_con_stop_stimulate_close_door_valve"))); - guardDependency.put("open_valve_door_open", new HashSet<>(Arrays.asList("_tr_open_valve_door_open", "_tr_env_open_door_last", "_tr_env_start_open_door", "_tr_env_open_door_skip", "_tr_close_valve_door_open"))); - guardDependency.put("env_retract_gear_last", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("env_open_door_last", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("con_stop_stimulate_retract_gear_valve", new HashSet<>(Arrays.asList("_tr_close_valve_retract_gear", "_tr_con_stimulate_extend_gear_valve", "_tr_open_valve_retract_gear", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_retract_gear_valve"))); - guardDependency.put("env_close_door_skip", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("con_stop_stimulate_close_door_valve", new HashSet<>(Arrays.asList("_tr_open_valve_door_close", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_close_valve_door_close"))); - guardDependency.put("env_open_analogical_switch", new HashSet<>(Arrays.asList("_tr_env_open_analogical_switch", "_tr_evn_open_general_valve", "_tr_env_close_analogical_switch", "_tr_evn_close_general_valve"))); - guardDependency.put("con_stop_stimulate_general_valve", new HashSet<>(Arrays.asList("_tr_con_stimulate_extend_gear_valve", "_tr_con_stimulate_general_valve", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_evn_open_general_valve", "_tr_env_close_analogical_switch", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_evn_close_general_valve", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve"))); - guardDependency.put("env_extend_gear_last", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("evn_open_general_valve", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_env_close_door_skip", "_tr_evn_open_general_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_evn_close_general_valve", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("land_plane", new HashSet<>(Arrays.asList("_tr_land_plane", "_tr_begin_flying", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_close_door"))); - guardDependency.put("con_stimulate_retract_gear_valve", new HashSet<>(Arrays.asList("_tr_close_valve_retract_gear", "_tr_con_stimulate_extend_gear_valve", "_tr_open_valve_retract_gear", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_retract_gear_valve"))); - guardDependency.put("con_stimulate_general_valve", new HashSet<>(Arrays.asList("_tr_con_stimulate_extend_gear_valve", "_tr_con_stimulate_general_valve", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_evn_open_general_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_evn_close_general_valve", "_tr_con_stop_stimulate_retract_gear_valve"))); - guardDependency.put("env_start_retracting_first", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("env_retract_gear_skip", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("open_valve_extend_gear", new HashSet<>(Arrays.asList("_tr_close_valve_extend_gear", "_tr_open_valve_extend_gear", "_tr_env_start_extending"))); - guardDependency.put("begin_flying", new HashSet<>(Arrays.asList("_tr_land_plane", "_tr_begin_flying", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_close_door"))); - guardDependency.put("open_valve_retract_gear", new HashSet<>(Arrays.asList("_tr_close_valve_retract_gear", "_tr_open_valve_retract_gear", "_tr_env_start_retracting_first"))); - guardDependency.put("env_close_analogical_switch", new HashSet<>(Arrays.asList("_tr_env_open_analogical_switch", "_tr_evn_open_general_valve", "_tr_env_close_analogical_switch", "_tr_evn_close_general_valve"))); - guardDependency.put("env_start_extending", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("open_valve_door_close", new HashSet<>(Arrays.asList("_tr_open_valve_door_close", "_tr_env_close_door_skip", "_tr_env_start_close_door", "_tr_env_close_door", "_tr_close_valve_door_close"))); - guardDependency.put("con_stop_stimulate_open_door_valve", new HashSet<>(Arrays.asList("_tr_open_valve_door_open", "_tr_con_stimulate_extend_gear_valve", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stimulate_open_door_valve", "_tr_close_valve_door_open"))); - guardDependency.put("con_stop_stimulate_extend_gear_valve", new HashSet<>(Arrays.asList("_tr_con_stimulate_extend_gear_valve", "_tr_close_valve_extend_gear", "_tr_con_stop_stimulate_open_door_valve", "_tr_open_valve_extend_gear", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_extend_gear_valve"))); - guardDependency.put("evn_close_general_valve", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_env_close_door_skip", "_tr_evn_open_general_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_evn_close_general_valve", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("close_valve_extend_gear", new HashSet<>(Arrays.asList("_tr_close_valve_extend_gear", "_tr_open_valve_extend_gear", "_tr_env_start_extending"))); - guardDependency.put("con_stimulate_extend_gear_valve", new HashSet<>(Arrays.asList("_tr_con_stimulate_extend_gear_valve", "_tr_close_valve_extend_gear", "_tr_con_stop_stimulate_open_door_valve", "_tr_open_valve_extend_gear", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_extend_gear_valve"))); - guardDependency.put("close_valve_door_open", new HashSet<>(Arrays.asList("_tr_open_valve_door_open", "_tr_env_open_door_last", "_tr_env_start_open_door", "_tr_env_open_door_skip", "_tr_close_valve_door_open"))); - guardDependency.put("con_stimulate_close_door_valve", new HashSet<>(Arrays.asList("_tr_open_valve_door_close", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_close_valve_door_close"))); - guardDependency.put("env_extend_gear_skip", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("env_open_door_skip", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("env_start_open_door", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - dependentInvariant.put(machine, new HashSet<>()); - } - List<LandingGear_R6> counterExampleState = new ArrayList<>(); - parents.put(machine, null); + state.guardCache = newCache; + } else { + if(state._tr_begin_flying()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.begin_flying(); + copiedState.parent = state; + addCachedInfos("begin_flying", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + if(state._tr_land_plane()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.land_plane(); + copiedState.parent = state; + addCachedInfos("land_plane", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + if(state._tr_open_valve_door_open()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.open_valve_door_open(); + copiedState.parent = state; + addCachedInfos("open_valve_door_open", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + if(state._tr_close_valve_door_open()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.close_valve_door_open(); + copiedState.parent = state; + addCachedInfos("close_valve_door_open", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + if(state._tr_open_valve_door_close()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.open_valve_door_close(); + copiedState.parent = state; + addCachedInfos("open_valve_door_close", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + if(state._tr_close_valve_door_close()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.close_valve_door_close(); + copiedState.parent = state; + addCachedInfos("close_valve_door_close", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + if(state._tr_open_valve_retract_gear()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.open_valve_retract_gear(); + copiedState.parent = state; + addCachedInfos("open_valve_retract_gear", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + if(state._tr_close_valve_retract_gear()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.close_valve_retract_gear(); + copiedState.parent = state; + addCachedInfos("close_valve_retract_gear", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + if(state._tr_open_valve_extend_gear()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.open_valve_extend_gear(); + copiedState.parent = state; + addCachedInfos("open_valve_extend_gear", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + if(state._tr_close_valve_extend_gear()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.close_valve_extend_gear(); + copiedState.parent = state; + addCachedInfos("close_valve_extend_gear", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + if(state._tr_con_stimulate_open_door_valve()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.con_stimulate_open_door_valve(); + copiedState.parent = state; + addCachedInfos("con_stimulate_open_door_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + if(state._tr_con_stop_stimulate_open_door_valve()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.con_stop_stimulate_open_door_valve(); + copiedState.parent = state; + addCachedInfos("con_stop_stimulate_open_door_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + if(state._tr_con_stimulate_close_door_valve()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.con_stimulate_close_door_valve(); + copiedState.parent = state; + addCachedInfos("con_stimulate_close_door_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + if(state._tr_con_stop_stimulate_close_door_valve()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.con_stop_stimulate_close_door_valve(); + copiedState.parent = state; + addCachedInfos("con_stop_stimulate_close_door_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + if(state._tr_con_stimulate_retract_gear_valve()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.con_stimulate_retract_gear_valve(); + copiedState.parent = state; + addCachedInfos("con_stimulate_retract_gear_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + if(state._tr_con_stop_stimulate_retract_gear_valve()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.con_stop_stimulate_retract_gear_valve(); + copiedState.parent = state; + addCachedInfos("con_stop_stimulate_retract_gear_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + if(state._tr_con_stimulate_extend_gear_valve()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.con_stimulate_extend_gear_valve(); + copiedState.parent = state; + addCachedInfos("con_stimulate_extend_gear_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + if(state._tr_con_stop_stimulate_extend_gear_valve()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.con_stop_stimulate_extend_gear_valve(); + copiedState.parent = state; + addCachedInfos("con_stop_stimulate_extend_gear_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<POSITION> _trid_19 = state._tr_env_start_retracting_first(); + for(POSITION param : _trid_19) { + POSITION _tmp_1 = param; + + LandingGear_R6 copiedState = state._copy(); + copiedState.env_start_retracting_first(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_start_retracting_first", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<POSITION> _trid_20 = state._tr_env_retract_gear_skip(); + for(POSITION param : _trid_20) { + POSITION _tmp_1 = param; + + LandingGear_R6 copiedState = state._copy(); + copiedState.env_retract_gear_skip(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_retract_gear_skip", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<POSITION> _trid_21 = state._tr_env_retract_gear_last(); + for(POSITION param : _trid_21) { + POSITION _tmp_1 = param; + + LandingGear_R6 copiedState = state._copy(); + copiedState.env_retract_gear_last(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_retract_gear_last", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<POSITION> _trid_22 = state._tr_env_start_extending(); + for(POSITION param : _trid_22) { + POSITION _tmp_1 = param; + + LandingGear_R6 copiedState = state._copy(); + copiedState.env_start_extending(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_start_extending", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<POSITION> _trid_23 = state._tr_env_extend_gear_last(); + for(POSITION param : _trid_23) { + POSITION _tmp_1 = param; + + LandingGear_R6 copiedState = state._copy(); + copiedState.env_extend_gear_last(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_extend_gear_last", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<POSITION> _trid_24 = state._tr_env_extend_gear_skip(); + for(POSITION param : _trid_24) { + POSITION _tmp_1 = param; + + LandingGear_R6 copiedState = state._copy(); + copiedState.env_extend_gear_skip(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_extend_gear_skip", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - AtomicInteger transitions = new AtomicInteger(0); + } + BSet<POSITION> _trid_25 = state._tr_env_start_open_door(); + for(POSITION param : _trid_25) { + POSITION _tmp_1 = param; + + LandingGear_R6 copiedState = state._copy(); + copiedState.env_start_open_door(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_start_open_door", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<POSITION> _trid_26 = state._tr_env_open_door_last(); + for(POSITION param : _trid_26) { + POSITION _tmp_1 = param; + + LandingGear_R6 copiedState = state._copy(); + copiedState.env_open_door_last(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_open_door_last", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<POSITION> _trid_27 = state._tr_env_open_door_skip(); + for(POSITION param : _trid_27) { + POSITION _tmp_1 = param; + + LandingGear_R6 copiedState = state._copy(); + copiedState.env_open_door_skip(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_open_door_skip", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + + } + BSet<POSITION> _trid_28 = state._tr_env_start_close_door(); + for(POSITION param : _trid_28) { + POSITION _tmp_1 = param; + + LandingGear_R6 copiedState = state._copy(); + copiedState.env_start_close_door(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_start_close_door", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - while(!collection.isEmpty() && !stopThreads.get()) { - LandingGear_R6 state = next(collection, lock, type); + } + BSet<POSITION> _trid_29 = state._tr_env_close_door(); + for(POSITION param : _trid_29) { + POSITION _tmp_1 = param; - Set<LandingGear_R6> nextStates = generateNextStates(guardLock, state, isCaching, invariantDependency, dependentInvariant, guardDependency, dependentGuard, guardCache, parents, stateAccessedVia, transitions); + LandingGear_R6 copiedState = state._copy(); + copiedState.env_close_door(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_close_door", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - nextStates.forEach(nextState -> { - if(!states.contains(nextState)) { - numberStates.getAndIncrement(); - states.add(nextState); - collection.add(nextState); - if(numberStates.get() % 50000 == 0) { - System.out.println("VISITED STATES: " + numberStates.get()); - System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); - System.out.println("-------------------"); - } } - }); + BSet<POSITION> _trid_30 = state._tr_env_close_door_skip(); + for(POSITION param : _trid_30) { + POSITION _tmp_1 = param; - if(!checkInvariants(guardLock, state, isCaching, dependentInvariant)) { - invariantViolated.set(true); - stopThreads.set(true); - counterExampleState.add(state); - } + LandingGear_R6 copiedState = state._copy(); + copiedState.env_close_door_skip(_tmp_1); + copiedState.parent = state; + addCachedInfos("env_close_door_skip", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - if(nextStates.isEmpty()) { - deadlockDetected.set(true); - stopThreads.set(true); - } + } + if(state._tr_toggle_handle_up()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.toggle_handle_up(); + copiedState.parent = state; + addCachedInfos("toggle_handle_up", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - } - printResult(numberStates.get(), transitions.get(), deadlockDetected.get(), invariantViolated.get(), counterExampleState, parents, stateAccessedVia); - } + } + if(state._tr_toggle_handle_down()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.toggle_handle_down(); + copiedState.parent = state; + addCachedInfos("toggle_handle_down", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } + if(state._tr_con_stimulate_general_valve()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.con_stimulate_general_valve(); + copiedState.parent = state; + addCachedInfos("con_stimulate_general_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - private static void modelCheckMultiThreaded(Type type, int threads, boolean isCaching) { - Object lock = new Object(); - Object guardLock = new Object(); - Object waitLock = new Object(); - ThreadPoolExecutor threadPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(threads); + } + if(state._tr_con_stop_stimulate_general_valve()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.con_stop_stimulate_general_valve(); + copiedState.parent = state; + addCachedInfos("con_stop_stimulate_general_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - LandingGear_R6 machine = new LandingGear_R6(); + } + if(state._tr_evn_open_general_valve()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.evn_open_general_valve(); + copiedState.parent = state; + addCachedInfos("evn_open_general_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } + if(state._tr_evn_close_general_valve()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.evn_close_general_valve(); + copiedState.parent = state; + addCachedInfos("evn_close_general_valve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - AtomicBoolean invariantViolated = new AtomicBoolean(false); - AtomicBoolean deadlockDetected = new AtomicBoolean(false); - AtomicBoolean stopThreads = new AtomicBoolean(false); - AtomicInteger possibleQueueChanges = new AtomicInteger(0); + } + if(state._tr_env_close_analogical_switch()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.env_close_analogical_switch(); + copiedState.parent = state; + addCachedInfos("env_close_analogical_switch", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - Set<LandingGear_R6> states = new HashSet<>(); - states.add(machine); - AtomicInteger numberStates = new AtomicInteger(1); + } + if(state._tr_env_open_analogical_switch()) { + LandingGear_R6 copiedState = state._copy(); + copiedState.env_open_analogical_switch(); + copiedState.parent = state; + addCachedInfos("env_open_analogical_switch", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - LinkedList<LandingGear_R6> collection = new LinkedList<>(); - collection.add(machine); + } - Map<String, Set<String>> invariantDependency = new HashMap<>(); - Map<String, Set<String>> guardDependency = new HashMap<>(); - Map<LandingGear_R6, Set<String>> dependentInvariant = new HashMap<>(); - Map<LandingGear_R6, Set<String>> dependentGuard = new HashMap<>(); - Map<LandingGear_R6, PersistentHashMap> guardCache = new HashMap<>(); - Map<LandingGear_R6, LandingGear_R6> parents = new HashMap<>(); - Map<LandingGear_R6, String> stateAccessedVia = new HashMap<>(); - if(isCaching) { - invariantDependency.put("close_valve_door_close", new HashSet<>(Arrays.asList("_check_inv_10"))); - invariantDependency.put("close_valve_retract_gear", new HashSet<>(Arrays.asList("_check_inv_13"))); - invariantDependency.put("con_stimulate_open_door_valve", new HashSet<>(Arrays.asList("_check_inv_18", "_check_inv_17", "_check_inv_7"))); - invariantDependency.put("env_close_door", new HashSet<>(Arrays.asList("_check_inv_15", "_check_inv_21", "_check_inv_20", "_check_inv_25", "_check_inv_22"))); - invariantDependency.put("env_start_close_door", new HashSet<>(Arrays.asList("_check_inv_15", "_check_inv_21", "_check_inv_20", "_check_inv_25", "_check_inv_22"))); - invariantDependency.put("toggle_handle_up", new HashSet<>(Arrays.asList("_check_inv_4", "_check_inv_14"))); - invariantDependency.put("toggle_handle_down", new HashSet<>(Arrays.asList("_check_inv_4", "_check_inv_14"))); - invariantDependency.put("open_valve_door_open", new HashSet<>(Arrays.asList("_check_inv_12"))); - invariantDependency.put("env_retract_gear_last", new HashSet<>(Arrays.asList("_check_inv_16", "_check_inv_19", "_check_inv_25", "_check_inv_24", "_check_inv_23"))); - invariantDependency.put("env_open_door_last", new HashSet<>(Arrays.asList("_check_inv_15", "_check_inv_21", "_check_inv_20", "_check_inv_25", "_check_inv_22"))); - invariantDependency.put("con_stop_stimulate_retract_gear_valve", new HashSet<>(Arrays.asList("_check_inv_17", "_check_inv_8"))); - invariantDependency.put("env_close_door_skip", new HashSet<>(Arrays.asList("_check_inv_21", "_check_inv_20", "_check_inv_22"))); - invariantDependency.put("con_stop_stimulate_close_door_valve", new HashSet<>(Arrays.asList("_check_inv_18", "_check_inv_17", "_check_inv_5"))); - invariantDependency.put("env_open_analogical_switch", new HashSet<>(Arrays.asList("_check_inv_1"))); - invariantDependency.put("con_stop_stimulate_general_valve", new HashSet<>(Arrays.asList("_check_inv_17", "_check_inv_2", "_check_inv_4"))); - invariantDependency.put("env_extend_gear_last", new HashSet<>(Arrays.asList("_check_inv_16", "_check_inv_19", "_check_inv_25", "_check_inv_24", "_check_inv_23"))); - invariantDependency.put("evn_open_general_valve", new HashSet<>(Arrays.asList("_check_inv_3"))); - invariantDependency.put("land_plane", new HashSet<>(Arrays.asList("_check_inv_9"))); - invariantDependency.put("con_stimulate_retract_gear_valve", new HashSet<>(Arrays.asList("_check_inv_17", "_check_inv_8"))); - invariantDependency.put("con_stimulate_general_valve", new HashSet<>(Arrays.asList("_check_inv_17", "_check_inv_2"))); - invariantDependency.put("env_start_retracting_first", new HashSet<>(Arrays.asList("_check_inv_16", "_check_inv_19", "_check_inv_25", "_check_inv_24", "_check_inv_23"))); - invariantDependency.put("env_retract_gear_skip", new HashSet<>(Arrays.asList("_check_inv_19", "_check_inv_24", "_check_inv_23"))); - invariantDependency.put("open_valve_extend_gear", new HashSet<>(Arrays.asList("_check_inv_11"))); - invariantDependency.put("begin_flying", new HashSet<>(Arrays.asList("_check_inv_9"))); - invariantDependency.put("open_valve_retract_gear", new HashSet<>(Arrays.asList("_check_inv_13"))); - invariantDependency.put("env_close_analogical_switch", new HashSet<>(Arrays.asList("_check_inv_1"))); - invariantDependency.put("env_start_extending", new HashSet<>(Arrays.asList("_check_inv_16", "_check_inv_19", "_check_inv_25", "_check_inv_24", "_check_inv_23"))); - invariantDependency.put("open_valve_door_close", new HashSet<>(Arrays.asList("_check_inv_10"))); - invariantDependency.put("con_stop_stimulate_open_door_valve", new HashSet<>(Arrays.asList("_check_inv_18", "_check_inv_17", "_check_inv_7"))); - invariantDependency.put("con_stop_stimulate_extend_gear_valve", new HashSet<>(Arrays.asList("_check_inv_17", "_check_inv_6"))); - invariantDependency.put("evn_close_general_valve", new HashSet<>(Arrays.asList("_check_inv_3"))); - invariantDependency.put("close_valve_extend_gear", new HashSet<>(Arrays.asList("_check_inv_11"))); - invariantDependency.put("con_stimulate_extend_gear_valve", new HashSet<>(Arrays.asList("_check_inv_17", "_check_inv_6"))); - invariantDependency.put("close_valve_door_open", new HashSet<>(Arrays.asList("_check_inv_12"))); - invariantDependency.put("con_stimulate_close_door_valve", new HashSet<>(Arrays.asList("_check_inv_18", "_check_inv_17", "_check_inv_5"))); - invariantDependency.put("env_extend_gear_skip", new HashSet<>(Arrays.asList("_check_inv_19", "_check_inv_24", "_check_inv_23"))); - invariantDependency.put("env_open_door_skip", new HashSet<>(Arrays.asList("_check_inv_21", "_check_inv_20", "_check_inv_22"))); - invariantDependency.put("env_start_open_door", new HashSet<>(Arrays.asList("_check_inv_15", "_check_inv_21", "_check_inv_20", "_check_inv_25", "_check_inv_22"))); - guardDependency.put("close_valve_door_close", new HashSet<>(Arrays.asList("_tr_open_valve_door_close", "_tr_env_close_door_skip", "_tr_env_start_close_door", "_tr_env_close_door", "_tr_close_valve_door_close"))); - guardDependency.put("close_valve_retract_gear", new HashSet<>(Arrays.asList("_tr_close_valve_retract_gear", "_tr_open_valve_retract_gear", "_tr_env_start_retracting_first"))); - guardDependency.put("con_stimulate_open_door_valve", new HashSet<>(Arrays.asList("_tr_open_valve_door_open", "_tr_con_stimulate_extend_gear_valve", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stimulate_open_door_valve", "_tr_close_valve_door_open"))); - guardDependency.put("env_close_door", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("env_start_close_door", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("toggle_handle_up", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_close_analogical_switch", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip", "_tr_con_stimulate_general_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_toggle_handle_down", "_tr_env_open_door_last", "_tr_toggle_handle_up", "_tr_env_start_close_door", "_tr_con_stop_stimulate_close_door_valve"))); - guardDependency.put("toggle_handle_down", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_close_analogical_switch", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip", "_tr_con_stimulate_general_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_toggle_handle_down", "_tr_env_open_door_last", "_tr_toggle_handle_up", "_tr_env_start_close_door", "_tr_con_stop_stimulate_close_door_valve"))); - guardDependency.put("open_valve_door_open", new HashSet<>(Arrays.asList("_tr_open_valve_door_open", "_tr_env_open_door_last", "_tr_env_start_open_door", "_tr_env_open_door_skip", "_tr_close_valve_door_open"))); - guardDependency.put("env_retract_gear_last", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("env_open_door_last", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("con_stop_stimulate_retract_gear_valve", new HashSet<>(Arrays.asList("_tr_close_valve_retract_gear", "_tr_con_stimulate_extend_gear_valve", "_tr_open_valve_retract_gear", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_retract_gear_valve"))); - guardDependency.put("env_close_door_skip", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("con_stop_stimulate_close_door_valve", new HashSet<>(Arrays.asList("_tr_open_valve_door_close", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_close_valve_door_close"))); - guardDependency.put("env_open_analogical_switch", new HashSet<>(Arrays.asList("_tr_env_open_analogical_switch", "_tr_evn_open_general_valve", "_tr_env_close_analogical_switch", "_tr_evn_close_general_valve"))); - guardDependency.put("con_stop_stimulate_general_valve", new HashSet<>(Arrays.asList("_tr_con_stimulate_extend_gear_valve", "_tr_con_stimulate_general_valve", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_evn_open_general_valve", "_tr_env_close_analogical_switch", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_evn_close_general_valve", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve"))); - guardDependency.put("env_extend_gear_last", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("evn_open_general_valve", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_env_close_door_skip", "_tr_evn_open_general_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_evn_close_general_valve", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("land_plane", new HashSet<>(Arrays.asList("_tr_land_plane", "_tr_begin_flying", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_close_door"))); - guardDependency.put("con_stimulate_retract_gear_valve", new HashSet<>(Arrays.asList("_tr_close_valve_retract_gear", "_tr_con_stimulate_extend_gear_valve", "_tr_open_valve_retract_gear", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_retract_gear_valve"))); - guardDependency.put("con_stimulate_general_valve", new HashSet<>(Arrays.asList("_tr_con_stimulate_extend_gear_valve", "_tr_con_stimulate_general_valve", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_evn_open_general_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_evn_close_general_valve", "_tr_con_stop_stimulate_retract_gear_valve"))); - guardDependency.put("env_start_retracting_first", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("env_retract_gear_skip", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("open_valve_extend_gear", new HashSet<>(Arrays.asList("_tr_close_valve_extend_gear", "_tr_open_valve_extend_gear", "_tr_env_start_extending"))); - guardDependency.put("begin_flying", new HashSet<>(Arrays.asList("_tr_land_plane", "_tr_begin_flying", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_close_door"))); - guardDependency.put("open_valve_retract_gear", new HashSet<>(Arrays.asList("_tr_close_valve_retract_gear", "_tr_open_valve_retract_gear", "_tr_env_start_retracting_first"))); - guardDependency.put("env_close_analogical_switch", new HashSet<>(Arrays.asList("_tr_env_open_analogical_switch", "_tr_evn_open_general_valve", "_tr_env_close_analogical_switch", "_tr_evn_close_general_valve"))); - guardDependency.put("env_start_extending", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("open_valve_door_close", new HashSet<>(Arrays.asList("_tr_open_valve_door_close", "_tr_env_close_door_skip", "_tr_env_start_close_door", "_tr_env_close_door", "_tr_close_valve_door_close"))); - guardDependency.put("con_stop_stimulate_open_door_valve", new HashSet<>(Arrays.asList("_tr_open_valve_door_open", "_tr_con_stimulate_extend_gear_valve", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stimulate_open_door_valve", "_tr_close_valve_door_open"))); - guardDependency.put("con_stop_stimulate_extend_gear_valve", new HashSet<>(Arrays.asList("_tr_con_stimulate_extend_gear_valve", "_tr_close_valve_extend_gear", "_tr_con_stop_stimulate_open_door_valve", "_tr_open_valve_extend_gear", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_extend_gear_valve"))); - guardDependency.put("evn_close_general_valve", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_env_close_door_skip", "_tr_evn_open_general_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_evn_close_general_valve", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("close_valve_extend_gear", new HashSet<>(Arrays.asList("_tr_close_valve_extend_gear", "_tr_open_valve_extend_gear", "_tr_env_start_extending"))); - guardDependency.put("con_stimulate_extend_gear_valve", new HashSet<>(Arrays.asList("_tr_con_stimulate_extend_gear_valve", "_tr_close_valve_extend_gear", "_tr_con_stop_stimulate_open_door_valve", "_tr_open_valve_extend_gear", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_extend_gear_valve"))); - guardDependency.put("close_valve_door_open", new HashSet<>(Arrays.asList("_tr_open_valve_door_open", "_tr_env_open_door_last", "_tr_env_start_open_door", "_tr_env_open_door_skip", "_tr_close_valve_door_open"))); - guardDependency.put("con_stimulate_close_door_valve", new HashSet<>(Arrays.asList("_tr_open_valve_door_close", "_tr_con_stimulate_close_door_valve", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_close_valve_door_close"))); - guardDependency.put("env_extend_gear_skip", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_con_stop_stimulate_extend_gear_valve", "_tr_env_start_retracting_first", "_tr_con_stop_stimulate_retract_gear_valve", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("env_open_door_skip", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - guardDependency.put("env_start_open_door", new HashSet<>(Arrays.asList("_tr_env_retract_gear_last", "_tr_con_stimulate_extend_gear_valve", "_tr_env_close_door_skip", "_tr_con_stop_stimulate_open_door_valve", "_tr_con_stimulate_retract_gear_valve", "_tr_con_stimulate_close_door_valve", "_tr_env_retract_gear_skip", "_tr_env_start_open_door", "_tr_env_close_door", "_tr_env_start_retracting_first", "_tr_env_extend_gear_skip", "_tr_env_open_door_last", "_tr_env_start_close_door", "_tr_con_stop_stimulate_general_valve", "_tr_con_stop_stimulate_close_door_valve", "_tr_con_stimulate_open_door_valve", "_tr_env_start_extending", "_tr_env_extend_gear_last", "_tr_env_open_door_skip"))); - dependentInvariant.put(machine, new HashSet<>()); + } + return result; } - List<LandingGear_R6> counterExampleState = new ArrayList<>(); - parents.put(machine, null); - stateAccessedVia.put(machine, null); - - AtomicInteger transitions = new AtomicInteger(0); - while(!collection.isEmpty() && !stopThreads.get()) { - possibleQueueChanges.incrementAndGet(); - LandingGear_R6 state = next(collection, lock, type); - Runnable task = () -> { - Set<LandingGear_R6> nextStates = generateNextStates(guardLock, state, isCaching, invariantDependency, dependentInvariant, guardDependency, dependentGuard, guardCache, parents, stateAccessedVia, transitions); - - nextStates.forEach(nextState -> { - synchronized(lock) { - if(!states.contains(nextState)) { - numberStates.getAndIncrement(); - states.add(nextState); - collection.add(nextState); - if(numberStates.get() % 50000 == 0) { - System.out.println("VISITED STATES: " + numberStates.get()); - System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); - System.out.println("-------------------"); - } - } + private boolean invariantViolated(final LandingGear_R6 state) { + if(isCaching) { + if(state.dependentInvariant.contains("_check_inv_1")) { + if(!state._check_inv_1()) { + return true; } - }); - - synchronized (lock) { - int running = possibleQueueChanges.decrementAndGet(); - if (!collection.isEmpty() || running == 0) { - synchronized (waitLock) { - waitLock.notify(); - } + } + if(state.dependentInvariant.contains("_check_inv_2")) { + if(!state._check_inv_2()) { + return true; } } - - if(nextStates.isEmpty()) { - deadlockDetected.set(true); - stopThreads.set(true); + if(state.dependentInvariant.contains("_check_inv_3")) { + if(!state._check_inv_3()) { + return true; + } } - - if(!checkInvariants(guardLock, state, isCaching, dependentInvariant)) { - invariantViolated.set(true); - stopThreads.set(true); - counterExampleState.add(state); + if(state.dependentInvariant.contains("_check_inv_4")) { + if(!state._check_inv_4()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_5")) { + if(!state._check_inv_5()) { + return true; + } } + if(state.dependentInvariant.contains("_check_inv_6")) { + if(!state._check_inv_6()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_7")) { + if(!state._check_inv_7()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_8")) { + if(!state._check_inv_8()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_9")) { + if(!state._check_inv_9()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_10")) { + if(!state._check_inv_10()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_11")) { + if(!state._check_inv_11()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_12")) { + if(!state._check_inv_12()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_13")) { + if(!state._check_inv_13()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_14")) { + if(!state._check_inv_14()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_15")) { + if(!state._check_inv_15()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_16")) { + if(!state._check_inv_16()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_17")) { + if(!state._check_inv_17()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_18")) { + if(!state._check_inv_18()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_19")) { + if(!state._check_inv_19()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_20")) { + if(!state._check_inv_20()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_21")) { + if(!state._check_inv_21()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_22")) { + if(!state._check_inv_22()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_23")) { + if(!state._check_inv_23()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_24")) { + if(!state._check_inv_24()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_25")) { + if(!state._check_inv_25()) { + return true; + } + } + return false; + } + return !(state._check_inv_1() && state._check_inv_2() && state._check_inv_3() && state._check_inv_4() && state._check_inv_5() && state._check_inv_6() && state._check_inv_7() && state._check_inv_8() && state._check_inv_9() && state._check_inv_10() && state._check_inv_11() && state._check_inv_12() && state._check_inv_13() && state._check_inv_14() && state._check_inv_15() && state._check_inv_16() && state._check_inv_17() && state._check_inv_18() && state._check_inv_19() && state._check_inv_20() && state._check_inv_21() && state._check_inv_22() && state._check_inv_23() && state._check_inv_24() && state._check_inv_25()); + } + private void addCachedInfos(final String operation, final LandingGear_R6 state, final LandingGear_R6 copiedState) { + if(isCaching) { + copiedState.dependentInvariant = invariantDependency.get(operation); + copiedState.dependentGuard = guardDependency.get(operation); + } + copiedState.stateAccessedVia = operation; + } + + private void printResult(final int states, final int transitions) { + if(invariantViolated.get() || deadlockDetected.get()) { + if(deadlockDetected.get()) { + System.out.println("DEADLOCK DETECTED"); + } else { + System.out.println("INVARIANT VIOLATED"); + } - }; - threadPool.submit(task); - synchronized(waitLock) { - if (collection.isEmpty() && possibleQueueChanges.get() > 0) { - try { - waitLock.wait(); - } catch (InterruptedException e) { - e.printStackTrace(); + System.out.println("COUNTER EXAMPLE TRACE: "); + StringBuilder sb = new StringBuilder(); + while(counterExampleState != null) { + sb.insert(0, counterExampleState); + sb.insert(0, "\n"); + if(counterExampleState.stateAccessedVia != null) { + sb.insert(0, counterExampleState.stateAccessedVia); } + sb.insert(0, "\n\n"); + counterExampleState = counterExampleState.parent; } + System.out.println(sb); + } else { + System.out.println("MODEL CHECKING SUCCESSFUL"); } + System.out.println("Number of States: " + states); + System.out.println("Number of Transitions: " + transitions); } - threadPool.shutdown(); - try { - threadPool.awaitTermination(5, TimeUnit.SECONDS); - } catch (InterruptedException e) { - e.printStackTrace(); - } - printResult(numberStates.get(), transitions.get(), deadlockDetected.get(), invariantViolated.get(), counterExampleState, parents, stateAccessedVia); } public static void main(String[] args) { - if(args.length != 3) { - System.out.println("Number of arguments errorneous"); - return; - } - String strategy = args[0]; - String numberThreads = args[1]; - String caching = args[2]; - - Type type; - - if("mixed".equals(strategy)) { - type = Type.MIXED; - } else if("bf".equals(strategy)) { - type = Type.BFS; - } else if ("df".equals(strategy)) { - type = Type.DFS; - } else { - System.out.println("Input for strategy is wrong."); + if(args.length > 4) { + System.out.println("Expecting 3 command-line arguments: STRATEGY THREADS CACHING DEBUG"); return; } - + Type type = Type.MIXED; int threads = 0; - try { - threads = Integer.parseInt(numberThreads); - } catch(NumberFormatException e) { - System.out.println("Input for number of threads is wrong."); - return; + boolean isCaching = false; + boolean isDebug = false; + + if(args.length > 0) { + if("mixed".equals(args[0])) { + type = Type.MIXED; + } else if("bf".equals(args[0])) { + type = Type.BFS; + } else if ("df".equals(args[0])) { + type = Type.DFS; + } else { + System.out.println("Value for command-line argument STRATEGY is wrong."); + System.out.println("Expecting mixed, bf or df."); + return; + } } - if(threads <= 0) { - System.out.println("Input for number of threads is wrong."); - return; + if(args.length > 1) { + try { + threads = Integer.parseInt(args[1]); + } catch(NumberFormatException e) { + System.out.println("Value for command-line argument THREADS is not a number."); + return; + } + if(threads <= 0) { + System.out.println("Value for command-line argument THREADS must be positive."); + return; + } } - - boolean isCaching = true; - try { - isCaching = Boolean.parseBoolean(caching); - } catch(Exception e) { - System.out.println("Input for caching is wrong."); - return; + if(args.length > 2) { + try { + isCaching = Boolean.parseBoolean(args[2]); + } catch(Exception e) { + System.out.println("Value for command-line argument CACHING is not a boolean."); + return; + } } - if(threads == 1) { - modelCheckSingleThreaded(type, isCaching); - } else { - modelCheckMultiThreaded(type, threads, isCaching); + if(args.length > 3) { + try { + isDebug = Boolean.parseBoolean(args[3]); + } catch(Exception e) { + System.out.println("Value for command-line argument DEBUG is not a boolean."); + return; + } } + + ModelChecker modelchecker = new ModelChecker(type, threads, isCaching, isDebug); + modelchecker.modelCheck(); } diff --git a/benchmarks/model_checking/Java/Lift_MC_Large.java b/benchmarks/model_checking/Java/Lift_MC_Large.java index f042c054c128b09666af79f0744a3dec26370bf0..48548b0bea846061a628c4e9af8e685c521857f7 100644 --- a/benchmarks/model_checking/Java/Lift_MC_Large.java +++ b/benchmarks/model_checking/Java/Lift_MC_Large.java @@ -10,6 +10,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.Future; import java.util.concurrent.Executors; @@ -141,7 +142,7 @@ public class Lift_MC_Large { private final boolean isDebug; private final LinkedList<Lift_MC_Large> unvisitedStates = new LinkedList<>(); - private final Set<Lift_MC_Large> states = new HashSet<>(); + private final Set<Lift_MC_Large> states = ConcurrentHashMap.newKeySet(); private AtomicInteger transitions = new AtomicInteger(0); private ThreadPoolExecutor threadPool; private Object waitLock = new Object(); @@ -234,17 +235,14 @@ public class Lift_MC_Large { Set<Lift_MC_Large> nextStates = generateNextStates(state); nextStates.forEach(nextState -> { - synchronized (states) { - if(!states.contains(nextState)) { - states.add(nextState); - synchronized (unvisitedStates) { - unvisitedStates.add(nextState); - } - if(states.size() % 50000 == 0 && isDebug) { - System.out.println("VISITED STATES: " + states.size()); - System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); - System.out.println("-------------------"); - } + if(states.add(nextState)) { + synchronized (unvisitedStates) { + unvisitedStates.add(nextState); + } + if(states.size() % 50000 == 0 && isDebug) { + System.out.println("VISITED STATES: " + states.size()); + System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); + System.out.println("-------------------"); } } }); diff --git a/benchmarks/model_checking/Java/QueensWithEvents_4.java b/benchmarks/model_checking/Java/QueensWithEvents_4.java index bd05a7153e99da54c5682db102ee018b71a5d49e..3fa65e1c2b28fd6d02e48cb02cbc66918d33c39a 100644 --- a/benchmarks/model_checking/Java/QueensWithEvents_4.java +++ b/benchmarks/model_checking/Java/QueensWithEvents_4.java @@ -12,6 +12,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.Future; import java.util.concurrent.Executors; @@ -45,6 +46,12 @@ public class QueensWithEvents_4 { MIXED } + public QueensWithEvents_4 parent; + public Set<String> dependentGuard = new HashSet<>(); + public PersistentHashMap guardCache = PersistentHashMap.EMPTY; + public Set<String> dependentInvariant = new HashSet<>(); + public String stateAccessedVia; + private static BInteger n; @@ -66,6 +73,7 @@ public class QueensWithEvents_4 { queens = new BRelation<BInteger, BInteger>(); } + public QueensWithEvents_4(BInteger n, BSet<BInteger> interval, BSet<BRelation<BInteger, BInteger>> allFields, BRelation<BInteger, BInteger> queens) { this.n = n; this.interval = interval; @@ -73,6 +81,7 @@ public class QueensWithEvents_4 { this.queens = queens; } + public void Solve(BRelation<BInteger, BInteger> solution) { queens = solution; @@ -189,313 +198,275 @@ public class QueensWithEvents_4 { return String.join("\n", "_get_queens: " + (this._get_queens()).toString()); } - @SuppressWarnings("unchecked") - private static Set<QueensWithEvents_4> generateNextStates(Object guardLock, QueensWithEvents_4 state, boolean isCaching, Map<String, Set<String>> invariantDependency, Map<QueensWithEvents_4, Set<String>> dependentInvariant, Map<String, Set<String>> guardDependency, Map<QueensWithEvents_4, Set<String>> dependentGuard, Map<QueensWithEvents_4, PersistentHashMap> guardCache, Map<QueensWithEvents_4, QueensWithEvents_4> parents, Map<QueensWithEvents_4, String> stateAccessedVia, AtomicInteger transitions) { - Set<QueensWithEvents_4> result = new HashSet<>(); - if(isCaching) { - PersistentHashMap parentsGuard = guardCache.get(parents.get(state)); - PersistentHashMap newCache = parentsGuard == null ? PersistentHashMap.EMPTY : parentsGuard; - Set<String> dependentGuardsOfState = dependentGuard.get(state); - Object cachedValue = null; - boolean dependentGuardsBoolean = true; - BSet<BRelation<BInteger, BInteger>> _trid_1; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_Solve"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_Solve"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_1 = state._tr_Solve(); - } else { - _trid_1 = (BSet<BRelation<BInteger, BInteger>>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_Solve", _trid_1); - for(BRelation<BInteger, BInteger> param : _trid_1) { - BRelation<BInteger, BInteger> _tmp_1 = param; - - QueensWithEvents_4 copiedState = state._copy(); - copiedState.Solve(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("Solve")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("Solve")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "Solve"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } + private static class ModelChecker { + private final Type type; + private final int threads; + private final boolean isCaching; + private final boolean isDebug; - synchronized(guardLock) { - guardCache.put(state, newCache); - } - } else { - BSet<BRelation<BInteger, BInteger>> _trid_1 = state._tr_Solve(); - for(BRelation<BInteger, BInteger> param : _trid_1) { - BRelation<BInteger, BInteger> _tmp_1 = param; - - QueensWithEvents_4 copiedState = state._copy(); - copiedState.Solve(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "Solve"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } + private final LinkedList<QueensWithEvents_4> unvisitedStates = new LinkedList<>(); + private final Set<QueensWithEvents_4> states = ConcurrentHashMap.newKeySet(); + private AtomicInteger transitions = new AtomicInteger(0); + private ThreadPoolExecutor threadPool; + private Object waitLock = new Object(); - } - return result; - } + private AtomicBoolean invariantViolated = new AtomicBoolean(false); + private AtomicBoolean deadlockDetected = new AtomicBoolean(false); + private QueensWithEvents_4 counterExampleState = null; + private final Map<String, Set<String>> invariantDependency = new HashMap<>(); + private final Map<String, Set<String>> guardDependency = new HashMap<>(); - public static boolean checkInvariants(Object guardLock, QueensWithEvents_4 state, boolean isCaching, Map<QueensWithEvents_4, Set<String>> dependentInvariant) { - if(isCaching) { - Set<String> dependentInvariantsOfState; - synchronized(guardLock) { - dependentInvariantsOfState = dependentInvariant.get(state); + public ModelChecker(final Type type, final int threads, final boolean isCaching, final boolean isDebug) { + this.type = type; + this.threads = threads; + this.isCaching = isCaching; + this.isDebug = isDebug; + } + + public void modelCheck() { + if (isDebug) { + System.out.println("Starting Modelchecking, STRATEGY=" + type + ", THREADS=" + threads + ", CACHING=" + isCaching); } - if(dependentInvariantsOfState.contains("_check_inv_1")) { - if(!state._check_inv_1()) { - return false; - } + + if (threads <= 1) { + modelCheckSingleThreaded(); + } else { + this.threadPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(threads-1); + modelCheckMultiThreaded(); } - return true; } - return !(!state._check_inv_1()); - } - private static void printResult(int states, int transitions, boolean deadlockDetected, boolean invariantViolated, List<QueensWithEvents_4> counterExampleState, Map<QueensWithEvents_4, QueensWithEvents_4> parents, Map<QueensWithEvents_4, String> stateAccessedVia) { + private void modelCheckSingleThreaded() { + QueensWithEvents_4 machine = new QueensWithEvents_4(); + states.add(machine); // TODO: store hashes instead of machine? + unvisitedStates.add(machine); - if(invariantViolated || deadlockDetected) { - if(deadlockDetected) { - System.out.println("DEADLOCK DETECTED"); + if(isCaching) { + initCache(machine); } - if(invariantViolated) { - System.out.println("INVARIANT VIOLATED"); - } - System.out.println("COUNTER EXAMPLE TRACE: "); - StringBuilder sb = new StringBuilder(); - if(counterExampleState.size() >= 1) { - QueensWithEvents_4 currentState = counterExampleState.get(0); - while(currentState != null) { - sb.insert(0, currentState.toString()); - sb.insert(0, "\n"); - sb.insert(0, stateAccessedVia.get(currentState)); - sb.insert(0, "\n\n"); - currentState = parents.get(currentState); - } - } - System.out.println(sb.toString()); - } - if(!deadlockDetected && !invariantViolated) { - System.out.println("MODEL CHECKING SUCCESSFUL"); - } - System.out.println("Number of States: " + states); - System.out.println("Number of Transitions: " + transitions); - } + while(!unvisitedStates.isEmpty()) { + QueensWithEvents_4 state = next(); - private static QueensWithEvents_4 next(LinkedList<QueensWithEvents_4> collection, Object lock, Type type) { - synchronized(lock) { - return switch(type) { - case BFS -> collection.removeFirst(); - case DFS -> collection.removeLast(); - case MIXED -> collection.size() % 2 == 0 ? collection.removeFirst() : collection.removeLast(); - }; - } - } + Set<QueensWithEvents_4> nextStates = generateNextStates(state); - private static void modelCheckSingleThreaded(Type type, boolean isCaching, boolean isDebug) { - Object lock = new Object(); - Object guardLock = new Object(); + nextStates.forEach(nextState -> { + if(!states.contains(nextState)) { + states.add(nextState); + unvisitedStates.add(nextState); + if(states.size() % 50000 == 0 && isDebug) { + System.out.println("VISITED STATES: " + states.size()); + System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); + System.out.println("-------------------"); + } + } + }); - QueensWithEvents_4 machine = new QueensWithEvents_4(); + if(invariantViolated(state)) { + invariantViolated.set(true); + counterExampleState = state; + break; + } + if(nextStates.isEmpty()) { + deadlockDetected.set(true); + counterExampleState = state; + break; + } - AtomicBoolean invariantViolated = new AtomicBoolean(false); - AtomicBoolean deadlockDetected = new AtomicBoolean(false); - AtomicBoolean stopThreads = new AtomicBoolean(false); + } + printResult(states.size(), transitions.get()); + } - Set<QueensWithEvents_4> states = new HashSet<>(); - states.add(machine); - AtomicInteger numberStates = new AtomicInteger(1); + private void modelCheckMultiThreaded() { + QueensWithEvents_4 machine = new QueensWithEvents_4(); + states.add(machine); + unvisitedStates.add(machine); - LinkedList<QueensWithEvents_4> collection = new LinkedList<>(); - collection.add(machine); + AtomicBoolean stopThreads = new AtomicBoolean(false); + AtomicInteger possibleQueueChanges = new AtomicInteger(0); - Map<String, Set<String>> invariantDependency = new HashMap<>(); - Map<String, Set<String>> guardDependency = new HashMap<>(); - Map<QueensWithEvents_4, Set<String>> dependentInvariant = new HashMap<>(); - Map<QueensWithEvents_4, Set<String>> dependentGuard = new HashMap<>(); - Map<QueensWithEvents_4, PersistentHashMap> guardCache = new HashMap<>(); - Map<QueensWithEvents_4, QueensWithEvents_4> parents = new HashMap<>(); - Map<QueensWithEvents_4, String> stateAccessedVia = new HashMap<>(); - if(isCaching) { - invariantDependency.put("Solve", new HashSet<>(Arrays.asList("_check_inv_1"))); - guardDependency.put("Solve", new HashSet<>(Arrays.asList("_tr_Solve"))); - dependentInvariant.put(machine, new HashSet<>()); - } - List<QueensWithEvents_4> counterExampleState = new ArrayList<>(); - parents.put(machine, null); + if(isCaching) { + initCache(machine); + } - AtomicInteger transitions = new AtomicInteger(0); + while(!unvisitedStates.isEmpty() && !stopThreads.get()) { + possibleQueueChanges.incrementAndGet(); + QueensWithEvents_4 state = next(); + Runnable task = () -> { + Set<QueensWithEvents_4> nextStates = generateNextStates(state); - while(!collection.isEmpty() && !stopThreads.get()) { - QueensWithEvents_4 state = next(collection, lock, type); + nextStates.forEach(nextState -> { + if(states.add(nextState)) { + synchronized (unvisitedStates) { + unvisitedStates.add(nextState); + } + if(states.size() % 50000 == 0 && isDebug) { + System.out.println("VISITED STATES: " + states.size()); + System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); + System.out.println("-------------------"); + } + } + }); - Set<QueensWithEvents_4> nextStates = generateNextStates(guardLock, state, isCaching, invariantDependency, dependentInvariant, guardDependency, dependentGuard, guardCache, parents, stateAccessedVia, transitions); + synchronized (unvisitedStates) { + int running = possibleQueueChanges.decrementAndGet(); + if (!unvisitedStates.isEmpty() || running == 0) { + synchronized (waitLock) { + waitLock.notify(); + } + } + } - nextStates.forEach(nextState -> { - if(!states.contains(nextState)) { - numberStates.getAndIncrement(); - states.add(nextState); - collection.add(nextState); - if(numberStates.get() % 5000 == 0) { - System.out.println("VISITED STATES: " + numberStates.get()); - System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); - System.out.println("-------------------"); + if(invariantViolated(state)) { + invariantViolated.set(true); + counterExampleState = state; + stopThreads.set(true); } - } - }); - if(!checkInvariants(guardLock, state, isCaching, dependentInvariant)) { - invariantViolated.set(true); - stopThreads.set(true); - counterExampleState.add(state); + if(nextStates.isEmpty()) { + deadlockDetected.set(true); + counterExampleState = state; + stopThreads.set(true); + } + }; + threadPool.submit(task); + synchronized(waitLock) { + if (unvisitedStates.isEmpty() && possibleQueueChanges.get() > 0) { + try { + waitLock.wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } } - - if(nextStates.isEmpty()) { - deadlockDetected.set(true); - stopThreads.set(true); + threadPool.shutdown(); + try { + threadPool.awaitTermination(24, TimeUnit.HOURS); + } catch (InterruptedException e) { + e.printStackTrace(); } - + printResult(states.size(), transitions.get()); } - printResult(numberStates.get(), transitions.get(), deadlockDetected.get(), invariantViolated.get(), counterExampleState, parents, stateAccessedVia); - } - - private static void modelCheckMultiThreaded(Type type, int threads, boolean isCaching, boolean isDebug) { - Object lock = new Object(); - Object guardLock = new Object(); - Object waitLock = new Object(); - ThreadPoolExecutor threadPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(threads); + private void initCache(final QueensWithEvents_4 machine) { + invariantDependency.put("Solve", new HashSet<>(Arrays.asList("_check_inv_1"))); + guardDependency.put("Solve", new HashSet<>(Arrays.asList("_tr_Solve"))); + } - QueensWithEvents_4 machine = new QueensWithEvents_4(); + private QueensWithEvents_4 next() { + synchronized(this.unvisitedStates) { + return switch(type) { + case BFS -> this.unvisitedStates.removeFirst(); + case DFS -> this.unvisitedStates.removeLast(); + case MIXED -> this.unvisitedStates.size() % 2 == 0 ? this.unvisitedStates.removeFirst() : this.unvisitedStates.removeLast(); + }; + } + } + @SuppressWarnings("unchecked") + private Set<QueensWithEvents_4> generateNextStates(final QueensWithEvents_4 state) { + Set<QueensWithEvents_4> result = new HashSet<>(); + if(isCaching) { + PersistentHashMap parentsGuard = state.guardCache; + PersistentHashMap newCache = parentsGuard == null ? PersistentHashMap.EMPTY : parentsGuard; + Object cachedValue = null; + boolean dependentGuardsBoolean = true; + BSet<BRelation<BInteger, BInteger>> _trid_1; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_Solve"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_Solve"); + } - AtomicBoolean invariantViolated = new AtomicBoolean(false); - AtomicBoolean deadlockDetected = new AtomicBoolean(false); - AtomicBoolean stopThreads = new AtomicBoolean(false); - AtomicInteger possibleQueueChanges = new AtomicInteger(0); + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_1 = state._tr_Solve(); + } else { + _trid_1 = (BSet<BRelation<BInteger, BInteger>>) cachedValue; + } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_Solve", _trid_1); + for(BRelation<BInteger, BInteger> param : _trid_1) { + BRelation<BInteger, BInteger> _tmp_1 = param; - Set<QueensWithEvents_4> states = new HashSet<>(); - states.add(machine); - AtomicInteger numberStates = new AtomicInteger(1); + QueensWithEvents_4 copiedState = state._copy(); + copiedState.Solve(_tmp_1); + copiedState.parent = state; + addCachedInfos("Solve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - LinkedList<QueensWithEvents_4> collection = new LinkedList<>(); - collection.add(machine); + } - Map<String, Set<String>> invariantDependency = new HashMap<>(); - Map<String, Set<String>> guardDependency = new HashMap<>(); - Map<QueensWithEvents_4, Set<String>> dependentInvariant = new HashMap<>(); - Map<QueensWithEvents_4, Set<String>> dependentGuard = new HashMap<>(); - Map<QueensWithEvents_4, PersistentHashMap> guardCache = new HashMap<>(); - Map<QueensWithEvents_4, QueensWithEvents_4> parents = new HashMap<>(); - Map<QueensWithEvents_4, String> stateAccessedVia = new HashMap<>(); - if(isCaching) { - invariantDependency.put("Solve", new HashSet<>(Arrays.asList("_check_inv_1"))); - guardDependency.put("Solve", new HashSet<>(Arrays.asList("_tr_Solve"))); - dependentInvariant.put(machine, new HashSet<>()); - } - List<QueensWithEvents_4> counterExampleState = new ArrayList<>(); - parents.put(machine, null); - stateAccessedVia.put(machine, null); + state.guardCache = newCache; + } else { + BSet<BRelation<BInteger, BInteger>> _trid_1 = state._tr_Solve(); + for(BRelation<BInteger, BInteger> param : _trid_1) { + BRelation<BInteger, BInteger> _tmp_1 = param; - AtomicInteger transitions = new AtomicInteger(0); + QueensWithEvents_4 copiedState = state._copy(); + copiedState.Solve(_tmp_1); + copiedState.parent = state; + addCachedInfos("Solve", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - while(!collection.isEmpty() && !stopThreads.get()) { - possibleQueueChanges.incrementAndGet(); - QueensWithEvents_4 state = next(collection, lock, type); - Runnable task = () -> { - Set<QueensWithEvents_4> nextStates = generateNextStates(guardLock, state, isCaching, invariantDependency, dependentInvariant, guardDependency, dependentGuard, guardCache, parents, stateAccessedVia, transitions); + } - nextStates.forEach(nextState -> { - synchronized(lock) { - if(!states.contains(nextState)) { - numberStates.getAndIncrement(); - states.add(nextState); - collection.add(nextState); - if(numberStates.get() % 5000 == 0) { - if( isDebug || numberStates.get() % 50000 == 0) { - System.out.println("VISITED STATES: " + numberStates.get()); - System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); - System.out.println("-------------------"); - } - } - } - } - }); + } + return result; + } - synchronized (lock) { - int running = possibleQueueChanges.decrementAndGet(); - if (!collection.isEmpty() || running == 0) { - synchronized (waitLock) { - waitLock.notify(); - } + private boolean invariantViolated(final QueensWithEvents_4 state) { + if(isCaching) { + if(state.dependentInvariant.contains("_check_inv_1")) { + if(!state._check_inv_1()) { + return true; } } + return false; + } + return !(state._check_inv_1()); + } - if(nextStates.isEmpty()) { - deadlockDetected.set(true); - stopThreads.set(true); - } + private void addCachedInfos(final String operation, final QueensWithEvents_4 state, final QueensWithEvents_4 copiedState) { + if(isCaching) { + copiedState.dependentInvariant = invariantDependency.get(operation); + copiedState.dependentGuard = guardDependency.get(operation); + } + copiedState.stateAccessedVia = operation; + } - if(!checkInvariants(guardLock, state, isCaching, dependentInvariant)) { - invariantViolated.set(true); - stopThreads.set(true); - counterExampleState.add(state); + private void printResult(final int states, final int transitions) { + if(invariantViolated.get() || deadlockDetected.get()) { + if(deadlockDetected.get()) { + System.out.println("DEADLOCK DETECTED"); + } else { + System.out.println("INVARIANT VIOLATED"); } - - }; - threadPool.submit(task); - synchronized(waitLock) { - if (collection.isEmpty() && possibleQueueChanges.get() > 0) { - try { - waitLock.wait(); - } catch (InterruptedException e) { - e.printStackTrace(); + System.out.println("COUNTER EXAMPLE TRACE: "); + StringBuilder sb = new StringBuilder(); + while(counterExampleState != null) { + sb.insert(0, counterExampleState); + sb.insert(0, "\n"); + if(counterExampleState.stateAccessedVia != null) { + sb.insert(0, counterExampleState.stateAccessedVia); } + sb.insert(0, "\n\n"); + counterExampleState = counterExampleState.parent; } + System.out.println(sb); + } else { + System.out.println("MODEL CHECKING SUCCESSFUL"); } + System.out.println("Number of States: " + states); + System.out.println("Number of Transitions: " + transitions); } - threadPool.shutdown(); - try { - threadPool.awaitTermination(5, TimeUnit.SECONDS); - } catch (InterruptedException e) { - e.printStackTrace(); - } - printResult(numberStates.get(), transitions.get(), deadlockDetected.get(), invariantViolated.get(), counterExampleState, parents, stateAccessedVia); } - public static void debugPrint (String msg, Boolean isDebug) { - if (isDebug) { - System.out.println(msg); - } - } public static void main(String[] args) { if(args.length > 4) { @@ -549,12 +520,8 @@ public class QueensWithEvents_4 { } } - debugPrint("Starting Modelchecking, STRATEGY=" + type + "THREADS=" + threads + ", CACHING=" + isCaching, isDebug); - if(threads == 1) { - modelCheckSingleThreaded(type, isCaching, isDebug); - } else { - modelCheckMultiThreaded(type, threads, isCaching, isDebug); - } + ModelChecker modelchecker = new ModelChecker(type, threads, isCaching, isDebug); + modelchecker.modelCheck(); } diff --git a/benchmarks/model_checking/Java/Train1_Lukas_POR_v3.java b/benchmarks/model_checking/Java/Train1_Lukas_POR_v3.java index 166ad325e6118978e8df07f02ae1a43eef63b8ff..7410558decbf5995b313f600364975817c094a4f 100644 --- a/benchmarks/model_checking/Java/Train1_Lukas_POR_v3.java +++ b/benchmarks/model_checking/Java/Train1_Lukas_POR_v3.java @@ -12,6 +12,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.Future; import java.util.concurrent.Executors; @@ -45,6 +46,12 @@ public class Train1_Lukas_POR_v3 { MIXED } + public Train1_Lukas_POR_v3 parent; + public Set<String> dependentGuard = new HashSet<>(); + public PersistentHashMap guardCache = PersistentHashMap.EMPTY; + public Set<String> dependentInvariant = new HashSet<>(); + public String stateAccessedVia; + private static BRelation<ROUTES, BLOCKS> fst; @@ -104,9 +111,9 @@ public class Train1_Lukas_POR_v3 { private BRelation<BLOCKS, ROUTES> rsrtbl; static { + nxt = new BRelation<ROUTES, BRelation<BLOCKS, BLOCKS>>(new BTuple<>(ROUTES.R1, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.A, BLOCKS.B), new BTuple<>(BLOCKS.B, BLOCKS.C))), new BTuple<>(ROUTES.R2, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.A, BLOCKS.B), new BTuple<>(BLOCKS.B, BLOCKS.D), new BTuple<>(BLOCKS.D, BLOCKS.E), new BTuple<>(BLOCKS.E, BLOCKS.F))), new BTuple<>(ROUTES.R3, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.H, BLOCKS.G), new BTuple<>(BLOCKS.G, BLOCKS.E), new BTuple<>(BLOCKS.E, BLOCKS.F))), new BTuple<>(ROUTES.R4, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.I, BLOCKS.G), new BTuple<>(BLOCKS.G, BLOCKS.E), new BTuple<>(BLOCKS.E, BLOCKS.F))), new BTuple<>(ROUTES.R5, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.C, BLOCKS.B), new BTuple<>(BLOCKS.B, BLOCKS.A))), new BTuple<>(ROUTES.R6, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.F, BLOCKS.E), new BTuple<>(BLOCKS.E, BLOCKS.D), new BTuple<>(BLOCKS.D, BLOCKS.B), new BTuple<>(BLOCKS.B, BLOCKS.A))), new BTuple<>(ROUTES.R7, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.F, BLOCKS.E), new BTuple<>(BLOCKS.E, BLOCKS.G), new BTuple<>(BLOCKS.G, BLOCKS.H))), new BTuple<>(ROUTES.R8, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.F, BLOCKS.E), new BTuple<>(BLOCKS.E, BLOCKS.G), new BTuple<>(BLOCKS.G, BLOCKS.I)))); fst = new BRelation<ROUTES, BLOCKS>(new BTuple<>(ROUTES.R1, BLOCKS.A), new BTuple<>(ROUTES.R2, BLOCKS.A), new BTuple<>(ROUTES.R3, BLOCKS.H), new BTuple<>(ROUTES.R4, BLOCKS.I), new BTuple<>(ROUTES.R5, BLOCKS.C), new BTuple<>(ROUTES.R6, BLOCKS.F), new BTuple<>(ROUTES.R7, BLOCKS.F), new BTuple<>(ROUTES.R8, BLOCKS.F)); lst = new BRelation<ROUTES, BLOCKS>(new BTuple<>(ROUTES.R1, BLOCKS.C), new BTuple<>(ROUTES.R2, BLOCKS.F), new BTuple<>(ROUTES.R3, BLOCKS.F), new BTuple<>(ROUTES.R4, BLOCKS.F), new BTuple<>(ROUTES.R5, BLOCKS.A), new BTuple<>(ROUTES.R6, BLOCKS.A), new BTuple<>(ROUTES.R7, BLOCKS.H), new BTuple<>(ROUTES.R8, BLOCKS.I)); - nxt = new BRelation<ROUTES, BRelation<BLOCKS, BLOCKS>>(new BTuple<>(ROUTES.R1, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.A, BLOCKS.B), new BTuple<>(BLOCKS.B, BLOCKS.C))), new BTuple<>(ROUTES.R2, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.A, BLOCKS.B), new BTuple<>(BLOCKS.B, BLOCKS.D), new BTuple<>(BLOCKS.D, BLOCKS.E), new BTuple<>(BLOCKS.E, BLOCKS.F))), new BTuple<>(ROUTES.R3, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.H, BLOCKS.G), new BTuple<>(BLOCKS.G, BLOCKS.E), new BTuple<>(BLOCKS.E, BLOCKS.F))), new BTuple<>(ROUTES.R4, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.I, BLOCKS.G), new BTuple<>(BLOCKS.G, BLOCKS.E), new BTuple<>(BLOCKS.E, BLOCKS.F))), new BTuple<>(ROUTES.R5, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.C, BLOCKS.B), new BTuple<>(BLOCKS.B, BLOCKS.A))), new BTuple<>(ROUTES.R6, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.F, BLOCKS.E), new BTuple<>(BLOCKS.E, BLOCKS.D), new BTuple<>(BLOCKS.D, BLOCKS.B), new BTuple<>(BLOCKS.B, BLOCKS.A))), new BTuple<>(ROUTES.R7, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.F, BLOCKS.E), new BTuple<>(BLOCKS.E, BLOCKS.G), new BTuple<>(BLOCKS.G, BLOCKS.H))), new BTuple<>(ROUTES.R8, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.F, BLOCKS.E), new BTuple<>(BLOCKS.E, BLOCKS.G), new BTuple<>(BLOCKS.G, BLOCKS.I)))); rtbl = new BRelation<BLOCKS, ROUTES>(new BTuple<>(BLOCKS.A, ROUTES.R1), new BTuple<>(BLOCKS.A, ROUTES.R2), new BTuple<>(BLOCKS.A, ROUTES.R5), new BTuple<>(BLOCKS.A, ROUTES.R6), new BTuple<>(BLOCKS.B, ROUTES.R1), new BTuple<>(BLOCKS.B, ROUTES.R2), new BTuple<>(BLOCKS.B, ROUTES.R5), new BTuple<>(BLOCKS.B, ROUTES.R6), new BTuple<>(BLOCKS.C, ROUTES.R1), new BTuple<>(BLOCKS.C, ROUTES.R5), new BTuple<>(BLOCKS.D, ROUTES.R2), new BTuple<>(BLOCKS.D, ROUTES.R6), new BTuple<>(BLOCKS.E, ROUTES.R2), new BTuple<>(BLOCKS.E, ROUTES.R3), new BTuple<>(BLOCKS.E, ROUTES.R4), new BTuple<>(BLOCKS.E, ROUTES.R6), new BTuple<>(BLOCKS.E, ROUTES.R7), new BTuple<>(BLOCKS.E, ROUTES.R8), new BTuple<>(BLOCKS.F, ROUTES.R2), new BTuple<>(BLOCKS.F, ROUTES.R3), new BTuple<>(BLOCKS.F, ROUTES.R4), new BTuple<>(BLOCKS.F, ROUTES.R6), new BTuple<>(BLOCKS.F, ROUTES.R7), new BTuple<>(BLOCKS.F, ROUTES.R8), new BTuple<>(BLOCKS.G, ROUTES.R3), new BTuple<>(BLOCKS.G, ROUTES.R4), new BTuple<>(BLOCKS.G, ROUTES.R4), new BTuple<>(BLOCKS.G, ROUTES.R7), new BTuple<>(BLOCKS.G, ROUTES.R8), new BTuple<>(BLOCKS.H, ROUTES.R3), new BTuple<>(BLOCKS.H, ROUTES.R7), new BTuple<>(BLOCKS.I, ROUTES.R4), new BTuple<>(BLOCKS.I, ROUTES.R8)); } @@ -120,6 +127,7 @@ public class Train1_Lukas_POR_v3 { LBT = new BSet<BLOCKS>(); } + public Train1_Lukas_POR_v3(BRelation<ROUTES, BLOCKS> fst, BRelation<ROUTES, BLOCKS> lst, BRelation<ROUTES, BRelation<BLOCKS, BLOCKS>> nxt, BRelation<BLOCKS, ROUTES> rtbl, BSet<BLOCKS> LBT, BRelation<BLOCKS, BLOCKS> TRK, BSet<ROUTES> frm, BSet<BLOCKS> OCC, BSet<BLOCKS> resbl, BSet<ROUTES> resrt, BRelation<BLOCKS, ROUTES> rsrtbl) { this.fst = fst; this.lst = lst; @@ -134,6 +142,7 @@ public class Train1_Lukas_POR_v3 { this.rsrtbl = rsrtbl; } + public void route_reservation(ROUTES r) { BSet<ROUTES> _ld_resrt = resrt; BRelation<BLOCKS, ROUTES> _ld_rsrtbl = rsrtbl; @@ -515,793 +524,644 @@ public class Train1_Lukas_POR_v3 { return String.join("\n", "_get_LBT: " + (this._get_LBT()).toString(), "_get_TRK: " + (this._get_TRK()).toString(), "_get_frm: " + (this._get_frm()).toString(), "_get_OCC: " + (this._get_OCC()).toString(), "_get_resbl: " + (this._get_resbl()).toString(), "_get_resrt: " + (this._get_resrt()).toString(), "_get_rsrtbl: " + (this._get_rsrtbl()).toString()); } - @SuppressWarnings("unchecked") - private static Set<Train1_Lukas_POR_v3> generateNextStates(Object guardLock, Train1_Lukas_POR_v3 state, boolean isCaching, Map<String, Set<String>> invariantDependency, Map<Train1_Lukas_POR_v3, Set<String>> dependentInvariant, Map<String, Set<String>> guardDependency, Map<Train1_Lukas_POR_v3, Set<String>> dependentGuard, Map<Train1_Lukas_POR_v3, PersistentHashMap> guardCache, Map<Train1_Lukas_POR_v3, Train1_Lukas_POR_v3> parents, Map<Train1_Lukas_POR_v3, String> stateAccessedVia, AtomicInteger transitions) { - Set<Train1_Lukas_POR_v3> result = new HashSet<>(); - if(isCaching) { - PersistentHashMap parentsGuard = guardCache.get(parents.get(state)); - PersistentHashMap newCache = parentsGuard == null ? PersistentHashMap.EMPTY : parentsGuard; - Set<String> dependentGuardsOfState = dependentGuard.get(state); - Object cachedValue = null; - boolean dependentGuardsBoolean = true; - BSet<ROUTES> _trid_1; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_route_reservation"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_route_reservation"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_1 = state._tr_route_reservation(); - } else { - _trid_1 = (BSet<ROUTES>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_route_reservation", _trid_1); - for(ROUTES param : _trid_1) { - ROUTES _tmp_1 = param; - - Train1_Lukas_POR_v3 copiedState = state._copy(); - copiedState.route_reservation(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("route_reservation")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("route_reservation")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "route_reservation"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<ROUTES> _trid_2; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_route_freeing"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_route_freeing"); - } + private static class ModelChecker { + private final Type type; + private final int threads; + private final boolean isCaching; + private final boolean isDebug; - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_2 = state._tr_route_freeing(); - } else { - _trid_2 = (BSet<ROUTES>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_route_freeing", _trid_2); - for(ROUTES param : _trid_2) { - ROUTES _tmp_1 = param; - - Train1_Lukas_POR_v3 copiedState = state._copy(); - copiedState.route_freeing(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("route_freeing")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("route_freeing")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "route_freeing"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<ROUTES> _trid_3; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_FRONT_MOVE_1"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_FRONT_MOVE_1"); - } + private final LinkedList<Train1_Lukas_POR_v3> unvisitedStates = new LinkedList<>(); + private final Set<Train1_Lukas_POR_v3> states = ConcurrentHashMap.newKeySet(); + private AtomicInteger transitions = new AtomicInteger(0); + private ThreadPoolExecutor threadPool; + private Object waitLock = new Object(); - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_3 = state._tr_FRONT_MOVE_1(); - } else { - _trid_3 = (BSet<ROUTES>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_FRONT_MOVE_1", _trid_3); - for(ROUTES param : _trid_3) { - ROUTES _tmp_1 = param; - - Train1_Lukas_POR_v3 copiedState = state._copy(); - copiedState.FRONT_MOVE_1(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("FRONT_MOVE_1")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("FRONT_MOVE_1")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "FRONT_MOVE_1"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BLOCKS> _trid_4; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_FRONT_MOVE_2"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_FRONT_MOVE_2"); - } + private AtomicBoolean invariantViolated = new AtomicBoolean(false); + private AtomicBoolean deadlockDetected = new AtomicBoolean(false); + private Train1_Lukas_POR_v3 counterExampleState = null; - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_4 = state._tr_FRONT_MOVE_2(); - } else { - _trid_4 = (BSet<BLOCKS>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_FRONT_MOVE_2", _trid_4); - for(BLOCKS param : _trid_4) { - BLOCKS _tmp_1 = param; - - Train1_Lukas_POR_v3 copiedState = state._copy(); - copiedState.FRONT_MOVE_2(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("FRONT_MOVE_2")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("FRONT_MOVE_2")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "FRONT_MOVE_2"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BLOCKS> _trid_5; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_BACK_MOVE_1"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_BACK_MOVE_1"); - } + private final Map<String, Set<String>> invariantDependency = new HashMap<>(); + private final Map<String, Set<String>> guardDependency = new HashMap<>(); - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_5 = state._tr_BACK_MOVE_1(); - } else { - _trid_5 = (BSet<BLOCKS>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_BACK_MOVE_1", _trid_5); - for(BLOCKS param : _trid_5) { - BLOCKS _tmp_1 = param; - - Train1_Lukas_POR_v3 copiedState = state._copy(); - copiedState.BACK_MOVE_1(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("BACK_MOVE_1")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("BACK_MOVE_1")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "BACK_MOVE_1"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BLOCKS> _trid_6; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_BACK_MOVE_2"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_BACK_MOVE_2"); + public ModelChecker(final Type type, final int threads, final boolean isCaching, final boolean isDebug) { + this.type = type; + this.threads = threads; + this.isCaching = isCaching; + this.isDebug = isDebug; + } + + public void modelCheck() { + if (isDebug) { + System.out.println("Starting Modelchecking, STRATEGY=" + type + ", THREADS=" + threads + ", CACHING=" + isCaching); } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_6 = state._tr_BACK_MOVE_2(); + if (threads <= 1) { + modelCheckSingleThreaded(); } else { - _trid_6 = (BSet<BLOCKS>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_BACK_MOVE_2", _trid_6); - for(BLOCKS param : _trid_6) { - BLOCKS _tmp_1 = param; - - Train1_Lukas_POR_v3 copiedState = state._copy(); - copiedState.BACK_MOVE_2(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("BACK_MOVE_2")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("BACK_MOVE_2")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "BACK_MOVE_2"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<ROUTES> _trid_7; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_point_positionning"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_point_positionning"); + this.threadPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(threads-1); + modelCheckMultiThreaded(); } + } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_7 = state._tr_point_positionning(); - } else { - _trid_7 = (BSet<ROUTES>) cachedValue; + private void modelCheckSingleThreaded() { + Train1_Lukas_POR_v3 machine = new Train1_Lukas_POR_v3(); + states.add(machine); // TODO: store hashes instead of machine? + unvisitedStates.add(machine); + + if(isCaching) { + initCache(machine); } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_point_positionning", _trid_7); - for(ROUTES param : _trid_7) { - ROUTES _tmp_1 = param; - - Train1_Lukas_POR_v3 copiedState = state._copy(); - copiedState.point_positionning(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("point_positionning")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("point_positionning")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "point_positionning"); + + while(!unvisitedStates.isEmpty()) { + Train1_Lukas_POR_v3 state = next(); + + Set<Train1_Lukas_POR_v3> nextStates = generateNextStates(state); + + nextStates.forEach(nextState -> { + if(!states.contains(nextState)) { + states.add(nextState); + unvisitedStates.add(nextState); + if(states.size() % 50000 == 0 && isDebug) { + System.out.println("VISITED STATES: " + states.size()); + System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); + System.out.println("-------------------"); + } } + }); + + if(invariantViolated(state)) { + invariantViolated.set(true); + counterExampleState = state; + break; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<ROUTES> _trid_8; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_route_formation"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_route_formation"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_8 = state._tr_route_formation(); - } else { - _trid_8 = (BSet<ROUTES>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_route_formation", _trid_8); - for(ROUTES param : _trid_8) { - ROUTES _tmp_1 = param; - - Train1_Lukas_POR_v3 copiedState = state._copy(); - copiedState.route_formation(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("route_formation")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("route_formation")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "route_formation"); - } + if(nextStates.isEmpty()) { + deadlockDetected.set(true); + counterExampleState = state; + break; } - result.add(copiedState); - transitions.getAndIncrement(); + } + printResult(states.size(), transitions.get()); + } + + private void modelCheckMultiThreaded() { + Train1_Lukas_POR_v3 machine = new Train1_Lukas_POR_v3(); + states.add(machine); + unvisitedStates.add(machine); - synchronized(guardLock) { - guardCache.put(state, newCache); + AtomicBoolean stopThreads = new AtomicBoolean(false); + AtomicInteger possibleQueueChanges = new AtomicInteger(0); + + if(isCaching) { + initCache(machine); } - } else { - BSet<ROUTES> _trid_1 = state._tr_route_reservation(); - for(ROUTES param : _trid_1) { - ROUTES _tmp_1 = param; - - Train1_Lukas_POR_v3 copiedState = state._copy(); - copiedState.route_reservation(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); + + while(!unvisitedStates.isEmpty() && !stopThreads.get()) { + possibleQueueChanges.incrementAndGet(); + Train1_Lukas_POR_v3 state = next(); + Runnable task = () -> { + Set<Train1_Lukas_POR_v3> nextStates = generateNextStates(state); + + nextStates.forEach(nextState -> { + if(states.add(nextState)) { + synchronized (unvisitedStates) { + unvisitedStates.add(nextState); + } + if(states.size() % 50000 == 0 && isDebug) { + System.out.println("VISITED STATES: " + states.size()); + System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); + System.out.println("-------------------"); + } + } + }); + + synchronized (unvisitedStates) { + int running = possibleQueueChanges.decrementAndGet(); + if (!unvisitedStates.isEmpty() || running == 0) { + synchronized (waitLock) { + waitLock.notify(); + } + } } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "route_reservation"); + + if(invariantViolated(state)) { + invariantViolated.set(true); + counterExampleState = state; + stopThreads.set(true); } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<ROUTES> _trid_2 = state._tr_route_freeing(); - for(ROUTES param : _trid_2) { - ROUTES _tmp_1 = param; - - Train1_Lukas_POR_v3 copiedState = state._copy(); - copiedState.route_freeing(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); + + if(nextStates.isEmpty()) { + deadlockDetected.set(true); + counterExampleState = state; + stopThreads.set(true); } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "route_freeing"); + }; + threadPool.submit(task); + synchronized(waitLock) { + if (unvisitedStates.isEmpty() && possibleQueueChanges.get() > 0) { + try { + waitLock.wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } } } - result.add(copiedState); - transitions.getAndIncrement(); } - BSet<ROUTES> _trid_3 = state._tr_FRONT_MOVE_1(); - for(ROUTES param : _trid_3) { - ROUTES _tmp_1 = param; - - Train1_Lukas_POR_v3 copiedState = state._copy(); - copiedState.FRONT_MOVE_1(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "FRONT_MOVE_1"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); + threadPool.shutdown(); + try { + threadPool.awaitTermination(24, TimeUnit.HOURS); + } catch (InterruptedException e) { + e.printStackTrace(); } - BSet<BLOCKS> _trid_4 = state._tr_FRONT_MOVE_2(); - for(BLOCKS param : _trid_4) { - BLOCKS _tmp_1 = param; - - Train1_Lukas_POR_v3 copiedState = state._copy(); - copiedState.FRONT_MOVE_2(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "FRONT_MOVE_2"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); + printResult(states.size(), transitions.get()); + } + + private void initCache(final Train1_Lukas_POR_v3 machine) { + invariantDependency.put("point_positionning", new HashSet<>(Arrays.asList("_check_inv_3", "_check_inv_1", "_check_inv_4"))); + invariantDependency.put("route_reservation", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_6", "_check_inv_10", "_check_inv_7", "_check_inv_4", "_check_inv_8", "_check_inv_12", "_check_inv_9", "_check_inv_11"))); + invariantDependency.put("FRONT_MOVE_1", new HashSet<>(Arrays.asList("_check_inv_6", "_check_inv_10", "_check_inv_5", "_check_inv_12", "_check_inv_9"))); + invariantDependency.put("BACK_MOVE_1", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_6", "_check_inv_10", "_check_inv_7", "_check_inv_4", "_check_inv_5", "_check_inv_8", "_check_inv_12", "_check_inv_9"))); + invariantDependency.put("FRONT_MOVE_2", new HashSet<>(Arrays.asList("_check_inv_10", "_check_inv_5", "_check_inv_12", "_check_inv_9"))); + invariantDependency.put("route_formation", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_4", "_check_inv_12", "_check_inv_11"))); + invariantDependency.put("route_freeing", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_7", "_check_inv_4", "_check_inv_12", "_check_inv_11"))); + invariantDependency.put("BACK_MOVE_2", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_6", "_check_inv_10", "_check_inv_7", "_check_inv_4", "_check_inv_5", "_check_inv_8", "_check_inv_12", "_check_inv_9"))); + guardDependency.put("point_positionning", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_BACK_MOVE_1", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); + guardDependency.put("route_reservation", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); + guardDependency.put("FRONT_MOVE_1", new HashSet<>(Arrays.asList("_tr_FRONT_MOVE_1", "_tr_BACK_MOVE_1", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); + guardDependency.put("BACK_MOVE_1", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); + guardDependency.put("FRONT_MOVE_2", new HashSet<>(Arrays.asList("_tr_FRONT_MOVE_1", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); + guardDependency.put("route_formation", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_point_positionning"))); + guardDependency.put("route_freeing", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); + guardDependency.put("BACK_MOVE_2", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); + } + + private Train1_Lukas_POR_v3 next() { + synchronized(this.unvisitedStates) { + return switch(type) { + case BFS -> this.unvisitedStates.removeFirst(); + case DFS -> this.unvisitedStates.removeLast(); + case MIXED -> this.unvisitedStates.size() % 2 == 0 ? this.unvisitedStates.removeFirst() : this.unvisitedStates.removeLast(); + }; } - BSet<BLOCKS> _trid_5 = state._tr_BACK_MOVE_1(); - for(BLOCKS param : _trid_5) { - BLOCKS _tmp_1 = param; - - Train1_Lukas_POR_v3 copiedState = state._copy(); - copiedState.BACK_MOVE_1(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "BACK_MOVE_1"); - } + } + + @SuppressWarnings("unchecked") + private Set<Train1_Lukas_POR_v3> generateNextStates(final Train1_Lukas_POR_v3 state) { + Set<Train1_Lukas_POR_v3> result = new HashSet<>(); + if(isCaching) { + PersistentHashMap parentsGuard = state.guardCache; + PersistentHashMap newCache = parentsGuard == null ? PersistentHashMap.EMPTY : parentsGuard; + Object cachedValue = null; + boolean dependentGuardsBoolean = true; + BSet<ROUTES> _trid_1; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_route_reservation"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_route_reservation"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BLOCKS> _trid_6 = state._tr_BACK_MOVE_2(); - for(BLOCKS param : _trid_6) { - BLOCKS _tmp_1 = param; - - Train1_Lukas_POR_v3 copiedState = state._copy(); - copiedState.BACK_MOVE_2(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "BACK_MOVE_2"); - } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_1 = state._tr_route_reservation(); + } else { + _trid_1 = (BSet<ROUTES>) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<ROUTES> _trid_7 = state._tr_point_positionning(); - for(ROUTES param : _trid_7) { - ROUTES _tmp_1 = param; - - Train1_Lukas_POR_v3 copiedState = state._copy(); - copiedState.point_positionning(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "point_positionning"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_route_reservation", _trid_1); + for(ROUTES param : _trid_1) { + ROUTES _tmp_1 = param; + + Train1_Lukas_POR_v3 copiedState = state._copy(); + copiedState.route_reservation(_tmp_1); + copiedState.parent = state; + addCachedInfos("route_reservation", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<ROUTES> _trid_8 = state._tr_route_formation(); - for(ROUTES param : _trid_8) { - ROUTES _tmp_1 = param; - - Train1_Lukas_POR_v3 copiedState = state._copy(); - copiedState.route_formation(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "route_formation"); - } + BSet<ROUTES> _trid_2; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_route_freeing"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_route_freeing"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - } - return result; - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_2 = state._tr_route_freeing(); + } else { + _trid_2 = (BSet<ROUTES>) cachedValue; + } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_route_freeing", _trid_2); + for(ROUTES param : _trid_2) { + ROUTES _tmp_1 = param; + Train1_Lukas_POR_v3 copiedState = state._copy(); + copiedState.route_freeing(_tmp_1); + copiedState.parent = state; + addCachedInfos("route_freeing", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - public static boolean checkInvariants(Object guardLock, Train1_Lukas_POR_v3 state, boolean isCaching, Map<Train1_Lukas_POR_v3, Set<String>> dependentInvariant) { - if(isCaching) { - Set<String> dependentInvariantsOfState; - synchronized(guardLock) { - dependentInvariantsOfState = dependentInvariant.get(state); - } - if(dependentInvariantsOfState.contains("_check_inv_1")) { - if(!state._check_inv_1()) { - return false; } - } - if(dependentInvariantsOfState.contains("_check_inv_2")) { - if(!state._check_inv_2()) { - return false; + BSet<ROUTES> _trid_3; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_FRONT_MOVE_1"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_FRONT_MOVE_1"); } - } - if(dependentInvariantsOfState.contains("_check_inv_3")) { - if(!state._check_inv_3()) { - return false; + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_3 = state._tr_FRONT_MOVE_1(); + } else { + _trid_3 = (BSet<ROUTES>) cachedValue; } - } - if(dependentInvariantsOfState.contains("_check_inv_4")) { - if(!state._check_inv_4()) { - return false; + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_FRONT_MOVE_1", _trid_3); + for(ROUTES param : _trid_3) { + ROUTES _tmp_1 = param; + + Train1_Lukas_POR_v3 copiedState = state._copy(); + copiedState.FRONT_MOVE_1(_tmp_1); + copiedState.parent = state; + addCachedInfos("FRONT_MOVE_1", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - } - if(dependentInvariantsOfState.contains("_check_inv_5")) { - if(!state._check_inv_5()) { - return false; + BSet<BLOCKS> _trid_4; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_FRONT_MOVE_2"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_FRONT_MOVE_2"); } - } - if(dependentInvariantsOfState.contains("_check_inv_6")) { - if(!state._check_inv_6()) { - return false; + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_4 = state._tr_FRONT_MOVE_2(); + } else { + _trid_4 = (BSet<BLOCKS>) cachedValue; } - } - if(dependentInvariantsOfState.contains("_check_inv_7")) { - if(!state._check_inv_7()) { - return false; + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_FRONT_MOVE_2", _trid_4); + for(BLOCKS param : _trid_4) { + BLOCKS _tmp_1 = param; + + Train1_Lukas_POR_v3 copiedState = state._copy(); + copiedState.FRONT_MOVE_2(_tmp_1); + copiedState.parent = state; + addCachedInfos("FRONT_MOVE_2", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - } - if(dependentInvariantsOfState.contains("_check_inv_8")) { - if(!state._check_inv_8()) { - return false; + BSet<BLOCKS> _trid_5; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_BACK_MOVE_1"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_BACK_MOVE_1"); } - } - if(dependentInvariantsOfState.contains("_check_inv_9")) { - if(!state._check_inv_9()) { - return false; + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_5 = state._tr_BACK_MOVE_1(); + } else { + _trid_5 = (BSet<BLOCKS>) cachedValue; } - } - if(dependentInvariantsOfState.contains("_check_inv_10")) { - if(!state._check_inv_10()) { - return false; + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_BACK_MOVE_1", _trid_5); + for(BLOCKS param : _trid_5) { + BLOCKS _tmp_1 = param; + + Train1_Lukas_POR_v3 copiedState = state._copy(); + copiedState.BACK_MOVE_1(_tmp_1); + copiedState.parent = state; + addCachedInfos("BACK_MOVE_1", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - } - if(dependentInvariantsOfState.contains("_check_inv_11")) { - if(!state._check_inv_11()) { - return false; + BSet<BLOCKS> _trid_6; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_BACK_MOVE_2"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_BACK_MOVE_2"); } - } - if(dependentInvariantsOfState.contains("_check_inv_12")) { - if(!state._check_inv_12()) { - return false; + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_6 = state._tr_BACK_MOVE_2(); + } else { + _trid_6 = (BSet<BLOCKS>) cachedValue; } - } - return true; - } - return !(!state._check_inv_1() || !state._check_inv_2() || !state._check_inv_3() || !state._check_inv_4() || !state._check_inv_5() || !state._check_inv_6() || !state._check_inv_7() || !state._check_inv_8() || !state._check_inv_9() || !state._check_inv_10() || !state._check_inv_11() || !state._check_inv_12()); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_BACK_MOVE_2", _trid_6); + for(BLOCKS param : _trid_6) { + BLOCKS _tmp_1 = param; - private static void printResult(int states, int transitions, boolean deadlockDetected, boolean invariantViolated, List<Train1_Lukas_POR_v3> counterExampleState, Map<Train1_Lukas_POR_v3, Train1_Lukas_POR_v3> parents, Map<Train1_Lukas_POR_v3, String> stateAccessedVia) { + Train1_Lukas_POR_v3 copiedState = state._copy(); + copiedState.BACK_MOVE_2(_tmp_1); + copiedState.parent = state; + addCachedInfos("BACK_MOVE_2", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - if(invariantViolated || deadlockDetected) { - if(deadlockDetected) { - System.out.println("DEADLOCK DETECTED"); - } - if(invariantViolated) { - System.out.println("INVARIANT VIOLATED"); - } - System.out.println("COUNTER EXAMPLE TRACE: "); - StringBuilder sb = new StringBuilder(); - if(counterExampleState.size() >= 1) { - Train1_Lukas_POR_v3 currentState = counterExampleState.get(0); - while(currentState != null) { - sb.insert(0, currentState.toString()); - sb.insert(0, "\n"); - sb.insert(0, stateAccessedVia.get(currentState)); - sb.insert(0, "\n\n"); - currentState = parents.get(currentState); } - } - System.out.println(sb.toString()); + BSet<ROUTES> _trid_7; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_point_positionning"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_point_positionning"); + } - } - if(!deadlockDetected && !invariantViolated) { - System.out.println("MODEL CHECKING SUCCESSFUL"); - } - System.out.println("Number of States: " + states); - System.out.println("Number of Transitions: " + transitions); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_7 = state._tr_point_positionning(); + } else { + _trid_7 = (BSet<ROUTES>) cachedValue; + } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_point_positionning", _trid_7); + for(ROUTES param : _trid_7) { + ROUTES _tmp_1 = param; - private static Train1_Lukas_POR_v3 next(LinkedList<Train1_Lukas_POR_v3> collection, Object lock, Type type) { - synchronized(lock) { - return switch(type) { - case BFS -> collection.removeFirst(); - case DFS -> collection.removeLast(); - case MIXED -> collection.size() % 2 == 0 ? collection.removeFirst() : collection.removeLast(); - }; - } - } + Train1_Lukas_POR_v3 copiedState = state._copy(); + copiedState.point_positionning(_tmp_1); + copiedState.parent = state; + addCachedInfos("point_positionning", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - private static void modelCheckSingleThreaded(Type type, boolean isCaching) { - Object lock = new Object(); - Object guardLock = new Object(); + } + BSet<ROUTES> _trid_8; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_route_formation"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_route_formation"); + } - Train1_Lukas_POR_v3 machine = new Train1_Lukas_POR_v3(); + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_8 = state._tr_route_formation(); + } else { + _trid_8 = (BSet<ROUTES>) cachedValue; + } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_route_formation", _trid_8); + for(ROUTES param : _trid_8) { + ROUTES _tmp_1 = param; + Train1_Lukas_POR_v3 copiedState = state._copy(); + copiedState.route_formation(_tmp_1); + copiedState.parent = state; + addCachedInfos("route_formation", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - AtomicBoolean invariantViolated = new AtomicBoolean(false); - AtomicBoolean deadlockDetected = new AtomicBoolean(false); - AtomicBoolean stopThreads = new AtomicBoolean(false); + } - Set<Train1_Lukas_POR_v3> states = new HashSet<>(); - states.add(machine); - AtomicInteger numberStates = new AtomicInteger(1); + state.guardCache = newCache; + } else { + BSet<ROUTES> _trid_1 = state._tr_route_reservation(); + for(ROUTES param : _trid_1) { + ROUTES _tmp_1 = param; - LinkedList<Train1_Lukas_POR_v3> collection = new LinkedList<>(); - collection.add(machine); + Train1_Lukas_POR_v3 copiedState = state._copy(); + copiedState.route_reservation(_tmp_1); + copiedState.parent = state; + addCachedInfos("route_reservation", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - Map<String, Set<String>> invariantDependency = new HashMap<>(); - Map<String, Set<String>> guardDependency = new HashMap<>(); - Map<Train1_Lukas_POR_v3, Set<String>> dependentInvariant = new HashMap<>(); - Map<Train1_Lukas_POR_v3, Set<String>> dependentGuard = new HashMap<>(); - Map<Train1_Lukas_POR_v3, PersistentHashMap> guardCache = new HashMap<>(); - Map<Train1_Lukas_POR_v3, Train1_Lukas_POR_v3> parents = new HashMap<>(); - Map<Train1_Lukas_POR_v3, String> stateAccessedVia = new HashMap<>(); - if(isCaching) { - invariantDependency.put("point_positionning", new HashSet<>(Arrays.asList("_check_inv_3", "_check_inv_1", "_check_inv_4"))); - invariantDependency.put("route_reservation", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_6", "_check_inv_10", "_check_inv_7", "_check_inv_4", "_check_inv_8", "_check_inv_12", "_check_inv_9", "_check_inv_11"))); - invariantDependency.put("FRONT_MOVE_1", new HashSet<>(Arrays.asList("_check_inv_6", "_check_inv_10", "_check_inv_5", "_check_inv_12", "_check_inv_9"))); - invariantDependency.put("BACK_MOVE_1", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_6", "_check_inv_10", "_check_inv_7", "_check_inv_4", "_check_inv_5", "_check_inv_8", "_check_inv_12", "_check_inv_9"))); - invariantDependency.put("FRONT_MOVE_2", new HashSet<>(Arrays.asList("_check_inv_10", "_check_inv_5", "_check_inv_12", "_check_inv_9"))); - invariantDependency.put("route_formation", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_4", "_check_inv_12", "_check_inv_11"))); - invariantDependency.put("route_freeing", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_7", "_check_inv_4", "_check_inv_12", "_check_inv_11"))); - invariantDependency.put("BACK_MOVE_2", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_6", "_check_inv_10", "_check_inv_7", "_check_inv_4", "_check_inv_5", "_check_inv_8", "_check_inv_12", "_check_inv_9"))); - guardDependency.put("point_positionning", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_BACK_MOVE_1", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - guardDependency.put("route_reservation", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - guardDependency.put("FRONT_MOVE_1", new HashSet<>(Arrays.asList("_tr_FRONT_MOVE_1", "_tr_BACK_MOVE_1", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - guardDependency.put("BACK_MOVE_1", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - guardDependency.put("FRONT_MOVE_2", new HashSet<>(Arrays.asList("_tr_FRONT_MOVE_1", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - guardDependency.put("route_formation", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_point_positionning"))); - guardDependency.put("route_freeing", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - guardDependency.put("BACK_MOVE_2", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - dependentInvariant.put(machine, new HashSet<>()); - } - List<Train1_Lukas_POR_v3> counterExampleState = new ArrayList<>(); - parents.put(machine, null); + } + BSet<ROUTES> _trid_2 = state._tr_route_freeing(); + for(ROUTES param : _trid_2) { + ROUTES _tmp_1 = param; - AtomicInteger transitions = new AtomicInteger(0); + Train1_Lukas_POR_v3 copiedState = state._copy(); + copiedState.route_freeing(_tmp_1); + copiedState.parent = state; + addCachedInfos("route_freeing", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - while(!collection.isEmpty() && !stopThreads.get()) { - Train1_Lukas_POR_v3 state = next(collection, lock, type); + } + BSet<ROUTES> _trid_3 = state._tr_FRONT_MOVE_1(); + for(ROUTES param : _trid_3) { + ROUTES _tmp_1 = param; - Set<Train1_Lukas_POR_v3> nextStates = generateNextStates(guardLock, state, isCaching, invariantDependency, dependentInvariant, guardDependency, dependentGuard, guardCache, parents, stateAccessedVia, transitions); + Train1_Lukas_POR_v3 copiedState = state._copy(); + copiedState.FRONT_MOVE_1(_tmp_1); + copiedState.parent = state; + addCachedInfos("FRONT_MOVE_1", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - nextStates.forEach(nextState -> { - if(!states.contains(nextState)) { - numberStates.getAndIncrement(); - states.add(nextState); - collection.add(nextState); - if(numberStates.get() % 50000 == 0) { - System.out.println("VISITED STATES: " + numberStates.get()); - System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); - System.out.println("-------------------"); - } } - }); + BSet<BLOCKS> _trid_4 = state._tr_FRONT_MOVE_2(); + for(BLOCKS param : _trid_4) { + BLOCKS _tmp_1 = param; - if(!checkInvariants(guardLock, state, isCaching, dependentInvariant)) { - invariantViolated.set(true); - stopThreads.set(true); - counterExampleState.add(state); - } + Train1_Lukas_POR_v3 copiedState = state._copy(); + copiedState.FRONT_MOVE_2(_tmp_1); + copiedState.parent = state; + addCachedInfos("FRONT_MOVE_2", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - if(nextStates.isEmpty()) { - deadlockDetected.set(true); - stopThreads.set(true); - } + } + BSet<BLOCKS> _trid_5 = state._tr_BACK_MOVE_1(); + for(BLOCKS param : _trid_5) { + BLOCKS _tmp_1 = param; - } - printResult(numberStates.get(), transitions.get(), deadlockDetected.get(), invariantViolated.get(), counterExampleState, parents, stateAccessedVia); - } + Train1_Lukas_POR_v3 copiedState = state._copy(); + copiedState.BACK_MOVE_1(_tmp_1); + copiedState.parent = state; + addCachedInfos("BACK_MOVE_1", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } + BSet<BLOCKS> _trid_6 = state._tr_BACK_MOVE_2(); + for(BLOCKS param : _trid_6) { + BLOCKS _tmp_1 = param; - private static void modelCheckMultiThreaded(Type type, int threads, boolean isCaching) { - Object lock = new Object(); - Object guardLock = new Object(); - Object waitLock = new Object(); - ThreadPoolExecutor threadPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(threads); + Train1_Lukas_POR_v3 copiedState = state._copy(); + copiedState.BACK_MOVE_2(_tmp_1); + copiedState.parent = state; + addCachedInfos("BACK_MOVE_2", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - Train1_Lukas_POR_v3 machine = new Train1_Lukas_POR_v3(); + } + BSet<ROUTES> _trid_7 = state._tr_point_positionning(); + for(ROUTES param : _trid_7) { + ROUTES _tmp_1 = param; + Train1_Lukas_POR_v3 copiedState = state._copy(); + copiedState.point_positionning(_tmp_1); + copiedState.parent = state; + addCachedInfos("point_positionning", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - AtomicBoolean invariantViolated = new AtomicBoolean(false); - AtomicBoolean deadlockDetected = new AtomicBoolean(false); - AtomicBoolean stopThreads = new AtomicBoolean(false); - AtomicInteger possibleQueueChanges = new AtomicInteger(0); + } + BSet<ROUTES> _trid_8 = state._tr_route_formation(); + for(ROUTES param : _trid_8) { + ROUTES _tmp_1 = param; - Set<Train1_Lukas_POR_v3> states = new HashSet<>(); - states.add(machine); - AtomicInteger numberStates = new AtomicInteger(1); + Train1_Lukas_POR_v3 copiedState = state._copy(); + copiedState.route_formation(_tmp_1); + copiedState.parent = state; + addCachedInfos("route_formation", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - LinkedList<Train1_Lukas_POR_v3> collection = new LinkedList<>(); - collection.add(machine); + } - Map<String, Set<String>> invariantDependency = new HashMap<>(); - Map<String, Set<String>> guardDependency = new HashMap<>(); - Map<Train1_Lukas_POR_v3, Set<String>> dependentInvariant = new HashMap<>(); - Map<Train1_Lukas_POR_v3, Set<String>> dependentGuard = new HashMap<>(); - Map<Train1_Lukas_POR_v3, PersistentHashMap> guardCache = new HashMap<>(); - Map<Train1_Lukas_POR_v3, Train1_Lukas_POR_v3> parents = new HashMap<>(); - Map<Train1_Lukas_POR_v3, String> stateAccessedVia = new HashMap<>(); - if(isCaching) { - invariantDependency.put("point_positionning", new HashSet<>(Arrays.asList("_check_inv_3", "_check_inv_1", "_check_inv_4"))); - invariantDependency.put("route_reservation", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_6", "_check_inv_10", "_check_inv_7", "_check_inv_4", "_check_inv_8", "_check_inv_12", "_check_inv_9", "_check_inv_11"))); - invariantDependency.put("FRONT_MOVE_1", new HashSet<>(Arrays.asList("_check_inv_6", "_check_inv_10", "_check_inv_5", "_check_inv_12", "_check_inv_9"))); - invariantDependency.put("BACK_MOVE_1", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_6", "_check_inv_10", "_check_inv_7", "_check_inv_4", "_check_inv_5", "_check_inv_8", "_check_inv_12", "_check_inv_9"))); - invariantDependency.put("FRONT_MOVE_2", new HashSet<>(Arrays.asList("_check_inv_10", "_check_inv_5", "_check_inv_12", "_check_inv_9"))); - invariantDependency.put("route_formation", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_4", "_check_inv_12", "_check_inv_11"))); - invariantDependency.put("route_freeing", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_7", "_check_inv_4", "_check_inv_12", "_check_inv_11"))); - invariantDependency.put("BACK_MOVE_2", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_6", "_check_inv_10", "_check_inv_7", "_check_inv_4", "_check_inv_5", "_check_inv_8", "_check_inv_12", "_check_inv_9"))); - guardDependency.put("point_positionning", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_BACK_MOVE_1", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - guardDependency.put("route_reservation", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - guardDependency.put("FRONT_MOVE_1", new HashSet<>(Arrays.asList("_tr_FRONT_MOVE_1", "_tr_BACK_MOVE_1", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - guardDependency.put("BACK_MOVE_1", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - guardDependency.put("FRONT_MOVE_2", new HashSet<>(Arrays.asList("_tr_FRONT_MOVE_1", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - guardDependency.put("route_formation", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_point_positionning"))); - guardDependency.put("route_freeing", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - guardDependency.put("BACK_MOVE_2", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - dependentInvariant.put(machine, new HashSet<>()); + } + return result; } - List<Train1_Lukas_POR_v3> counterExampleState = new ArrayList<>(); - parents.put(machine, null); - stateAccessedVia.put(machine, null); - - AtomicInteger transitions = new AtomicInteger(0); - while(!collection.isEmpty() && !stopThreads.get()) { - possibleQueueChanges.incrementAndGet(); - Train1_Lukas_POR_v3 state = next(collection, lock, type); - Runnable task = () -> { - Set<Train1_Lukas_POR_v3> nextStates = generateNextStates(guardLock, state, isCaching, invariantDependency, dependentInvariant, guardDependency, dependentGuard, guardCache, parents, stateAccessedVia, transitions); - - nextStates.forEach(nextState -> { - synchronized(lock) { - if(!states.contains(nextState)) { - numberStates.getAndIncrement(); - states.add(nextState); - collection.add(nextState); - if(numberStates.get() % 50000 == 0) { - System.out.println("VISITED STATES: " + numberStates.get()); - System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); - System.out.println("-------------------"); - } - } + private boolean invariantViolated(final Train1_Lukas_POR_v3 state) { + if(isCaching) { + if(state.dependentInvariant.contains("_check_inv_1")) { + if(!state._check_inv_1()) { + return true; } - }); - - synchronized (lock) { - int running = possibleQueueChanges.decrementAndGet(); - if (!collection.isEmpty() || running == 0) { - synchronized (waitLock) { - waitLock.notify(); - } + } + if(state.dependentInvariant.contains("_check_inv_2")) { + if(!state._check_inv_2()) { + return true; } } - - if(nextStates.isEmpty()) { - deadlockDetected.set(true); - stopThreads.set(true); + if(state.dependentInvariant.contains("_check_inv_3")) { + if(!state._check_inv_3()) { + return true; + } } - - if(!checkInvariants(guardLock, state, isCaching, dependentInvariant)) { - invariantViolated.set(true); - stopThreads.set(true); - counterExampleState.add(state); + if(state.dependentInvariant.contains("_check_inv_4")) { + if(!state._check_inv_4()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_5")) { + if(!state._check_inv_5()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_6")) { + if(!state._check_inv_6()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_7")) { + if(!state._check_inv_7()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_8")) { + if(!state._check_inv_8()) { + return true; + } } + if(state.dependentInvariant.contains("_check_inv_9")) { + if(!state._check_inv_9()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_10")) { + if(!state._check_inv_10()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_11")) { + if(!state._check_inv_11()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_12")) { + if(!state._check_inv_12()) { + return true; + } + } + return false; + } + return !(state._check_inv_1() && state._check_inv_2() && state._check_inv_3() && state._check_inv_4() && state._check_inv_5() && state._check_inv_6() && state._check_inv_7() && state._check_inv_8() && state._check_inv_9() && state._check_inv_10() && state._check_inv_11() && state._check_inv_12()); + } + private void addCachedInfos(final String operation, final Train1_Lukas_POR_v3 state, final Train1_Lukas_POR_v3 copiedState) { + if(isCaching) { + copiedState.dependentInvariant = invariantDependency.get(operation); + copiedState.dependentGuard = guardDependency.get(operation); + } + copiedState.stateAccessedVia = operation; + } + + private void printResult(final int states, final int transitions) { + if(invariantViolated.get() || deadlockDetected.get()) { + if(deadlockDetected.get()) { + System.out.println("DEADLOCK DETECTED"); + } else { + System.out.println("INVARIANT VIOLATED"); + } - }; - threadPool.submit(task); - synchronized(waitLock) { - if (collection.isEmpty() && possibleQueueChanges.get() > 0) { - try { - waitLock.wait(); - } catch (InterruptedException e) { - e.printStackTrace(); + System.out.println("COUNTER EXAMPLE TRACE: "); + StringBuilder sb = new StringBuilder(); + while(counterExampleState != null) { + sb.insert(0, counterExampleState); + sb.insert(0, "\n"); + if(counterExampleState.stateAccessedVia != null) { + sb.insert(0, counterExampleState.stateAccessedVia); } + sb.insert(0, "\n\n"); + counterExampleState = counterExampleState.parent; } + System.out.println(sb); + } else { + System.out.println("MODEL CHECKING SUCCESSFUL"); } + System.out.println("Number of States: " + states); + System.out.println("Number of Transitions: " + transitions); } - threadPool.shutdown(); - try { - threadPool.awaitTermination(5, TimeUnit.SECONDS); - } catch (InterruptedException e) { - e.printStackTrace(); - } - printResult(numberStates.get(), transitions.get(), deadlockDetected.get(), invariantViolated.get(), counterExampleState, parents, stateAccessedVia); } public static void main(String[] args) { - if(args.length != 3) { - System.out.println("Number of arguments errorneous"); + if(args.length > 4) { + System.out.println("Expecting 3 command-line arguments: STRATEGY THREADS CACHING DEBUG"); return; } - String strategy = args[0]; - String numberThreads = args[1]; - String caching = args[2]; - - Type type; - - if("mixed".equals(strategy)) { - type = Type.MIXED; - } else if("bf".equals(strategy)) { - type = Type.BFS; - } else if ("df".equals(strategy)) { - type = Type.DFS; - } else { - System.out.println("Input for strategy is wrong."); - return; - } - + Type type = Type.MIXED; int threads = 0; - try { - threads = Integer.parseInt(numberThreads); - } catch(NumberFormatException e) { - System.out.println("Input for number of threads is wrong."); - return; + boolean isCaching = false; + boolean isDebug = false; + + if(args.length > 0) { + if("mixed".equals(args[0])) { + type = Type.MIXED; + } else if("bf".equals(args[0])) { + type = Type.BFS; + } else if ("df".equals(args[0])) { + type = Type.DFS; + } else { + System.out.println("Value for command-line argument STRATEGY is wrong."); + System.out.println("Expecting mixed, bf or df."); + return; + } } - if(threads <= 0) { - System.out.println("Input for number of threads is wrong."); - return; + if(args.length > 1) { + try { + threads = Integer.parseInt(args[1]); + } catch(NumberFormatException e) { + System.out.println("Value for command-line argument THREADS is not a number."); + return; + } + if(threads <= 0) { + System.out.println("Value for command-line argument THREADS must be positive."); + return; + } } - - boolean isCaching = true; - try { - isCaching = Boolean.parseBoolean(caching); - } catch(Exception e) { - System.out.println("Input for caching is wrong."); - return; + if(args.length > 2) { + try { + isCaching = Boolean.parseBoolean(args[2]); + } catch(Exception e) { + System.out.println("Value for command-line argument CACHING is not a boolean."); + return; + } } - if(threads == 1) { - modelCheckSingleThreaded(type, isCaching); - } else { - modelCheckMultiThreaded(type, threads, isCaching); + if(args.length > 3) { + try { + isDebug = Boolean.parseBoolean(args[3]); + } catch(Exception e) { + System.out.println("Value for command-line argument DEBUG is not a boolean."); + return; + } } + + ModelChecker modelchecker = new ModelChecker(type, threads, isCaching, isDebug); + modelchecker.modelCheck(); } diff --git a/benchmarks/model_checking/Java/Train_1_beebook_deterministic_MC_POR_v2.java b/benchmarks/model_checking/Java/Train_1_beebook_deterministic_MC_POR_v2.java index e194591b56c9425b1359d40713ca9be592dd2641..4a0afd7f98788c7b84e3af84362d05f3cce5e1bb 100644 --- a/benchmarks/model_checking/Java/Train_1_beebook_deterministic_MC_POR_v2.java +++ b/benchmarks/model_checking/Java/Train_1_beebook_deterministic_MC_POR_v2.java @@ -12,6 +12,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.Future; import java.util.concurrent.Executors; @@ -45,6 +46,12 @@ public class Train_1_beebook_deterministic_MC_POR_v2 { MIXED } + public Train_1_beebook_deterministic_MC_POR_v2 parent; + public Set<String> dependentGuard = new HashSet<>(); + public PersistentHashMap guardCache = PersistentHashMap.EMPTY; + public Set<String> dependentInvariant = new HashSet<>(); + public String stateAccessedVia; + private static BRelation<ROUTES, BLOCKS> fst; @@ -111,9 +118,9 @@ public class Train_1_beebook_deterministic_MC_POR_v2 { private BRelation<BLOCKS, ROUTES> rsrtbl; static { + nxt = new BRelation<ROUTES, BRelation<BLOCKS, BLOCKS>>(new BTuple<>(ROUTES.R1, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.L, BLOCKS.A), new BTuple<>(BLOCKS.A, BLOCKS.B), new BTuple<>(BLOCKS.B, BLOCKS.C))), new BTuple<>(ROUTES.R2, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.L, BLOCKS.A), new BTuple<>(BLOCKS.A, BLOCKS.B), new BTuple<>(BLOCKS.B, BLOCKS.D), new BTuple<>(BLOCKS.D, BLOCKS.E), new BTuple<>(BLOCKS.E, BLOCKS.F), new BTuple<>(BLOCKS.F, BLOCKS.G))), new BTuple<>(ROUTES.R3, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.L, BLOCKS.A), new BTuple<>(BLOCKS.A, BLOCKS.B), new BTuple<>(BLOCKS.B, BLOCKS.D), new BTuple<>(BLOCKS.D, BLOCKS.K), new BTuple<>(BLOCKS.K, BLOCKS.J), new BTuple<>(BLOCKS.J, BLOCKS.N))), new BTuple<>(ROUTES.R4, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.M, BLOCKS.H), new BTuple<>(BLOCKS.H, BLOCKS.I), new BTuple<>(BLOCKS.I, BLOCKS.K), new BTuple<>(BLOCKS.K, BLOCKS.F), new BTuple<>(BLOCKS.F, BLOCKS.G))), new BTuple<>(ROUTES.R5, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.M, BLOCKS.H), new BTuple<>(BLOCKS.H, BLOCKS.I), new BTuple<>(BLOCKS.I, BLOCKS.J), new BTuple<>(BLOCKS.J, BLOCKS.N))), new BTuple<>(ROUTES.R6, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.C, BLOCKS.B), new BTuple<>(BLOCKS.B, BLOCKS.A), new BTuple<>(BLOCKS.A, BLOCKS.L))), new BTuple<>(ROUTES.R7, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.G, BLOCKS.F), new BTuple<>(BLOCKS.F, BLOCKS.E), new BTuple<>(BLOCKS.E, BLOCKS.D), new BTuple<>(BLOCKS.D, BLOCKS.B), new BTuple<>(BLOCKS.B, BLOCKS.A), new BTuple<>(BLOCKS.A, BLOCKS.L))), new BTuple<>(ROUTES.R8, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.N, BLOCKS.J), new BTuple<>(BLOCKS.J, BLOCKS.K), new BTuple<>(BLOCKS.K, BLOCKS.D), new BTuple<>(BLOCKS.D, BLOCKS.B), new BTuple<>(BLOCKS.B, BLOCKS.A), new BTuple<>(BLOCKS.A, BLOCKS.L))), new BTuple<>(ROUTES.R9, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.G, BLOCKS.F), new BTuple<>(BLOCKS.F, BLOCKS.K), new BTuple<>(BLOCKS.K, BLOCKS.I), new BTuple<>(BLOCKS.I, BLOCKS.H), new BTuple<>(BLOCKS.H, BLOCKS.M))), new BTuple<>(ROUTES.R10, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.N, BLOCKS.J), new BTuple<>(BLOCKS.J, BLOCKS.I), new BTuple<>(BLOCKS.I, BLOCKS.H), new BTuple<>(BLOCKS.H, BLOCKS.M)))); fst = new BRelation<ROUTES, BLOCKS>(new BTuple<>(ROUTES.R1, BLOCKS.L), new BTuple<>(ROUTES.R2, BLOCKS.L), new BTuple<>(ROUTES.R3, BLOCKS.L), new BTuple<>(ROUTES.R4, BLOCKS.M), new BTuple<>(ROUTES.R5, BLOCKS.M), new BTuple<>(ROUTES.R6, BLOCKS.C), new BTuple<>(ROUTES.R7, BLOCKS.G), new BTuple<>(ROUTES.R8, BLOCKS.N), new BTuple<>(ROUTES.R9, BLOCKS.G), new BTuple<>(ROUTES.R10, BLOCKS.N)); lst = new BRelation<ROUTES, BLOCKS>(new BTuple<>(ROUTES.R1, BLOCKS.C), new BTuple<>(ROUTES.R2, BLOCKS.G), new BTuple<>(ROUTES.R3, BLOCKS.N), new BTuple<>(ROUTES.R4, BLOCKS.G), new BTuple<>(ROUTES.R5, BLOCKS.N), new BTuple<>(ROUTES.R6, BLOCKS.L), new BTuple<>(ROUTES.R7, BLOCKS.L), new BTuple<>(ROUTES.R8, BLOCKS.L), new BTuple<>(ROUTES.R9, BLOCKS.M), new BTuple<>(ROUTES.R10, BLOCKS.M)); - nxt = new BRelation<ROUTES, BRelation<BLOCKS, BLOCKS>>(new BTuple<>(ROUTES.R1, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.L, BLOCKS.A), new BTuple<>(BLOCKS.A, BLOCKS.B), new BTuple<>(BLOCKS.B, BLOCKS.C))), new BTuple<>(ROUTES.R2, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.L, BLOCKS.A), new BTuple<>(BLOCKS.A, BLOCKS.B), new BTuple<>(BLOCKS.B, BLOCKS.D), new BTuple<>(BLOCKS.D, BLOCKS.E), new BTuple<>(BLOCKS.E, BLOCKS.F), new BTuple<>(BLOCKS.F, BLOCKS.G))), new BTuple<>(ROUTES.R3, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.L, BLOCKS.A), new BTuple<>(BLOCKS.A, BLOCKS.B), new BTuple<>(BLOCKS.B, BLOCKS.D), new BTuple<>(BLOCKS.D, BLOCKS.K), new BTuple<>(BLOCKS.K, BLOCKS.J), new BTuple<>(BLOCKS.J, BLOCKS.N))), new BTuple<>(ROUTES.R4, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.M, BLOCKS.H), new BTuple<>(BLOCKS.H, BLOCKS.I), new BTuple<>(BLOCKS.I, BLOCKS.K), new BTuple<>(BLOCKS.K, BLOCKS.F), new BTuple<>(BLOCKS.F, BLOCKS.G))), new BTuple<>(ROUTES.R5, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.M, BLOCKS.H), new BTuple<>(BLOCKS.H, BLOCKS.I), new BTuple<>(BLOCKS.I, BLOCKS.J), new BTuple<>(BLOCKS.J, BLOCKS.N))), new BTuple<>(ROUTES.R6, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.C, BLOCKS.B), new BTuple<>(BLOCKS.B, BLOCKS.A), new BTuple<>(BLOCKS.A, BLOCKS.L))), new BTuple<>(ROUTES.R7, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.G, BLOCKS.F), new BTuple<>(BLOCKS.F, BLOCKS.E), new BTuple<>(BLOCKS.E, BLOCKS.D), new BTuple<>(BLOCKS.D, BLOCKS.B), new BTuple<>(BLOCKS.B, BLOCKS.A), new BTuple<>(BLOCKS.A, BLOCKS.L))), new BTuple<>(ROUTES.R8, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.N, BLOCKS.J), new BTuple<>(BLOCKS.J, BLOCKS.K), new BTuple<>(BLOCKS.K, BLOCKS.D), new BTuple<>(BLOCKS.D, BLOCKS.B), new BTuple<>(BLOCKS.B, BLOCKS.A), new BTuple<>(BLOCKS.A, BLOCKS.L))), new BTuple<>(ROUTES.R9, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.G, BLOCKS.F), new BTuple<>(BLOCKS.F, BLOCKS.K), new BTuple<>(BLOCKS.K, BLOCKS.I), new BTuple<>(BLOCKS.I, BLOCKS.H), new BTuple<>(BLOCKS.H, BLOCKS.M))), new BTuple<>(ROUTES.R10, new BRelation<BLOCKS, BLOCKS>(new BTuple<>(BLOCKS.N, BLOCKS.J), new BTuple<>(BLOCKS.J, BLOCKS.I), new BTuple<>(BLOCKS.I, BLOCKS.H), new BTuple<>(BLOCKS.H, BLOCKS.M)))); BRelation<BLOCKS, ROUTES> _ic_set_0 = new BRelation<BLOCKS, ROUTES>(); for(BLOCKS _ic_b_1 : _BLOCKS) { for(ROUTES _ic_r_1 : _ROUTES) { @@ -137,6 +144,7 @@ public class Train_1_beebook_deterministic_MC_POR_v2 { LBT = new BSet<BLOCKS>(); } + public Train_1_beebook_deterministic_MC_POR_v2(BRelation<ROUTES, BLOCKS> fst, BRelation<ROUTES, BLOCKS> lst, BRelation<ROUTES, BRelation<BLOCKS, BLOCKS>> nxt, BRelation<BLOCKS, ROUTES> rtbl, BSet<BLOCKS> LBT, BRelation<BLOCKS, BLOCKS> TRK, BSet<ROUTES> frm, BSet<BLOCKS> OCC, BSet<BLOCKS> resbl, BSet<ROUTES> resrt, BRelation<BLOCKS, ROUTES> rsrtbl) { this.fst = fst; this.lst = lst; @@ -151,6 +159,7 @@ public class Train_1_beebook_deterministic_MC_POR_v2 { this.rsrtbl = rsrtbl; } + public void route_reservation(ROUTES r) { BSet<ROUTES> _ld_resrt = resrt; BRelation<BLOCKS, ROUTES> _ld_rsrtbl = rsrtbl; @@ -532,795 +541,644 @@ public class Train_1_beebook_deterministic_MC_POR_v2 { return String.join("\n", "_get_LBT: " + (this._get_LBT()).toString(), "_get_TRK: " + (this._get_TRK()).toString(), "_get_frm: " + (this._get_frm()).toString(), "_get_OCC: " + (this._get_OCC()).toString(), "_get_resbl: " + (this._get_resbl()).toString(), "_get_resrt: " + (this._get_resrt()).toString(), "_get_rsrtbl: " + (this._get_rsrtbl()).toString()); } - @SuppressWarnings("unchecked") - private static Set<Train_1_beebook_deterministic_MC_POR_v2> generateNextStates(Object guardLock, Train_1_beebook_deterministic_MC_POR_v2 state, boolean isCaching, Map<String, Set<String>> invariantDependency, Map<Train_1_beebook_deterministic_MC_POR_v2, Set<String>> dependentInvariant, Map<String, Set<String>> guardDependency, Map<Train_1_beebook_deterministic_MC_POR_v2, Set<String>> dependentGuard, Map<Train_1_beebook_deterministic_MC_POR_v2, PersistentHashMap> guardCache, Map<Train_1_beebook_deterministic_MC_POR_v2, Train_1_beebook_deterministic_MC_POR_v2> parents, Map<Train_1_beebook_deterministic_MC_POR_v2, String> stateAccessedVia, AtomicInteger transitions) { - Set<Train_1_beebook_deterministic_MC_POR_v2> result = new HashSet<>(); - if(isCaching) { - PersistentHashMap parentsGuard = guardCache.get(parents.get(state)); - PersistentHashMap newCache = parentsGuard == null ? PersistentHashMap.EMPTY : parentsGuard; - Set<String> dependentGuardsOfState = dependentGuard.get(state); - Object cachedValue = null; - boolean dependentGuardsBoolean = true; - BSet<ROUTES> _trid_1; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_route_reservation"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_route_reservation"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_1 = state._tr_route_reservation(); - } else { - _trid_1 = (BSet<ROUTES>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_route_reservation", _trid_1); - for(ROUTES param : _trid_1) { - ROUTES _tmp_1 = param; - - Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); - copiedState.route_reservation(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("route_reservation")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("route_reservation")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "route_reservation"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<ROUTES> _trid_2; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_route_freeing"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_route_freeing"); - } + private static class ModelChecker { + private final Type type; + private final int threads; + private final boolean isCaching; + private final boolean isDebug; - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_2 = state._tr_route_freeing(); - } else { - _trid_2 = (BSet<ROUTES>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_route_freeing", _trid_2); - for(ROUTES param : _trid_2) { - ROUTES _tmp_1 = param; - - Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); - copiedState.route_freeing(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("route_freeing")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("route_freeing")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "route_freeing"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<ROUTES> _trid_3; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_FRONT_MOVE_1"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_FRONT_MOVE_1"); - } + private final LinkedList<Train_1_beebook_deterministic_MC_POR_v2> unvisitedStates = new LinkedList<>(); + private final Set<Train_1_beebook_deterministic_MC_POR_v2> states = ConcurrentHashMap.newKeySet(); + private AtomicInteger transitions = new AtomicInteger(0); + private ThreadPoolExecutor threadPool; + private Object waitLock = new Object(); - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_3 = state._tr_FRONT_MOVE_1(); - } else { - _trid_3 = (BSet<ROUTES>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_FRONT_MOVE_1", _trid_3); - for(ROUTES param : _trid_3) { - ROUTES _tmp_1 = param; - - Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); - copiedState.FRONT_MOVE_1(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("FRONT_MOVE_1")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("FRONT_MOVE_1")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "FRONT_MOVE_1"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BLOCKS> _trid_4; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_FRONT_MOVE_2"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_FRONT_MOVE_2"); - } + private AtomicBoolean invariantViolated = new AtomicBoolean(false); + private AtomicBoolean deadlockDetected = new AtomicBoolean(false); + private Train_1_beebook_deterministic_MC_POR_v2 counterExampleState = null; - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_4 = state._tr_FRONT_MOVE_2(); - } else { - _trid_4 = (BSet<BLOCKS>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_FRONT_MOVE_2", _trid_4); - for(BLOCKS param : _trid_4) { - BLOCKS _tmp_1 = param; - - Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); - copiedState.FRONT_MOVE_2(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("FRONT_MOVE_2")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("FRONT_MOVE_2")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "FRONT_MOVE_2"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BLOCKS> _trid_5; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_BACK_MOVE_1"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_BACK_MOVE_1"); - } + private final Map<String, Set<String>> invariantDependency = new HashMap<>(); + private final Map<String, Set<String>> guardDependency = new HashMap<>(); - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_5 = state._tr_BACK_MOVE_1(); - } else { - _trid_5 = (BSet<BLOCKS>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_BACK_MOVE_1", _trid_5); - for(BLOCKS param : _trid_5) { - BLOCKS _tmp_1 = param; - - Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); - copiedState.BACK_MOVE_1(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("BACK_MOVE_1")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("BACK_MOVE_1")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "BACK_MOVE_1"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BLOCKS> _trid_6; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_BACK_MOVE_2"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_BACK_MOVE_2"); + public ModelChecker(final Type type, final int threads, final boolean isCaching, final boolean isDebug) { + this.type = type; + this.threads = threads; + this.isCaching = isCaching; + this.isDebug = isDebug; + } + + public void modelCheck() { + if (isDebug) { + System.out.println("Starting Modelchecking, STRATEGY=" + type + ", THREADS=" + threads + ", CACHING=" + isCaching); } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_6 = state._tr_BACK_MOVE_2(); + if (threads <= 1) { + modelCheckSingleThreaded(); } else { - _trid_6 = (BSet<BLOCKS>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_BACK_MOVE_2", _trid_6); - for(BLOCKS param : _trid_6) { - BLOCKS _tmp_1 = param; - - Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); - copiedState.BACK_MOVE_2(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("BACK_MOVE_2")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("BACK_MOVE_2")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "BACK_MOVE_2"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<ROUTES> _trid_7; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_point_positionning"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_point_positionning"); + this.threadPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(threads-1); + modelCheckMultiThreaded(); } + } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_7 = state._tr_point_positionning(); - } else { - _trid_7 = (BSet<ROUTES>) cachedValue; + private void modelCheckSingleThreaded() { + Train_1_beebook_deterministic_MC_POR_v2 machine = new Train_1_beebook_deterministic_MC_POR_v2(); + states.add(machine); // TODO: store hashes instead of machine? + unvisitedStates.add(machine); + + if(isCaching) { + initCache(machine); } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_point_positionning", _trid_7); - for(ROUTES param : _trid_7) { - ROUTES _tmp_1 = param; - - Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); - copiedState.point_positionning(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("point_positionning")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("point_positionning")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "point_positionning"); + + while(!unvisitedStates.isEmpty()) { + Train_1_beebook_deterministic_MC_POR_v2 state = next(); + + Set<Train_1_beebook_deterministic_MC_POR_v2> nextStates = generateNextStates(state); + + nextStates.forEach(nextState -> { + if(!states.contains(nextState)) { + states.add(nextState); + unvisitedStates.add(nextState); + if(states.size() % 50000 == 0 && isDebug) { + System.out.println("VISITED STATES: " + states.size()); + System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); + System.out.println("-------------------"); + } } + }); + + if(invariantViolated(state)) { + invariantViolated.set(true); + counterExampleState = state; + break; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<ROUTES> _trid_8; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_route_formation"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_route_formation"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_8 = state._tr_route_formation(); - } else { - _trid_8 = (BSet<ROUTES>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_route_formation", _trid_8); - for(ROUTES param : _trid_8) { - ROUTES _tmp_1 = param; - - Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); - copiedState.route_formation(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("route_formation")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("route_formation")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "route_formation"); - } + if(nextStates.isEmpty()) { + deadlockDetected.set(true); + counterExampleState = state; + break; } - result.add(copiedState); - transitions.getAndIncrement(); + } + printResult(states.size(), transitions.get()); + } + + private void modelCheckMultiThreaded() { + Train_1_beebook_deterministic_MC_POR_v2 machine = new Train_1_beebook_deterministic_MC_POR_v2(); + states.add(machine); + unvisitedStates.add(machine); - synchronized(guardLock) { - guardCache.put(state, newCache); + AtomicBoolean stopThreads = new AtomicBoolean(false); + AtomicInteger possibleQueueChanges = new AtomicInteger(0); + + if(isCaching) { + initCache(machine); } - } else { - BSet<ROUTES> _trid_1 = state._tr_route_reservation(); - for(ROUTES param : _trid_1) { - ROUTES _tmp_1 = param; - - Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); - copiedState.route_reservation(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); + + while(!unvisitedStates.isEmpty() && !stopThreads.get()) { + possibleQueueChanges.incrementAndGet(); + Train_1_beebook_deterministic_MC_POR_v2 state = next(); + Runnable task = () -> { + Set<Train_1_beebook_deterministic_MC_POR_v2> nextStates = generateNextStates(state); + + nextStates.forEach(nextState -> { + if(states.add(nextState)) { + synchronized (unvisitedStates) { + unvisitedStates.add(nextState); + } + if(states.size() % 50000 == 0 && isDebug) { + System.out.println("VISITED STATES: " + states.size()); + System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); + System.out.println("-------------------"); + } + } + }); + + synchronized (unvisitedStates) { + int running = possibleQueueChanges.decrementAndGet(); + if (!unvisitedStates.isEmpty() || running == 0) { + synchronized (waitLock) { + waitLock.notify(); + } + } } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "route_reservation"); + + if(invariantViolated(state)) { + invariantViolated.set(true); + counterExampleState = state; + stopThreads.set(true); } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<ROUTES> _trid_2 = state._tr_route_freeing(); - for(ROUTES param : _trid_2) { - ROUTES _tmp_1 = param; - - Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); - copiedState.route_freeing(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); + + if(nextStates.isEmpty()) { + deadlockDetected.set(true); + counterExampleState = state; + stopThreads.set(true); } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "route_freeing"); + }; + threadPool.submit(task); + synchronized(waitLock) { + if (unvisitedStates.isEmpty() && possibleQueueChanges.get() > 0) { + try { + waitLock.wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } } } - result.add(copiedState); - transitions.getAndIncrement(); } - BSet<ROUTES> _trid_3 = state._tr_FRONT_MOVE_1(); - for(ROUTES param : _trid_3) { - ROUTES _tmp_1 = param; - - Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); - copiedState.FRONT_MOVE_1(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "FRONT_MOVE_1"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); + threadPool.shutdown(); + try { + threadPool.awaitTermination(24, TimeUnit.HOURS); + } catch (InterruptedException e) { + e.printStackTrace(); } - BSet<BLOCKS> _trid_4 = state._tr_FRONT_MOVE_2(); - for(BLOCKS param : _trid_4) { - BLOCKS _tmp_1 = param; - - Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); - copiedState.FRONT_MOVE_2(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "FRONT_MOVE_2"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); + printResult(states.size(), transitions.get()); + } + + private void initCache(final Train_1_beebook_deterministic_MC_POR_v2 machine) { + invariantDependency.put("point_positionning", new HashSet<>(Arrays.asList("_check_inv_3", "_check_inv_1", "_check_inv_4"))); + invariantDependency.put("route_reservation", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_6", "_check_inv_10", "_check_inv_7", "_check_inv_4", "_check_inv_8", "_check_inv_12", "_check_inv_9", "_check_inv_11"))); + invariantDependency.put("FRONT_MOVE_1", new HashSet<>(Arrays.asList("_check_inv_6", "_check_inv_10", "_check_inv_5", "_check_inv_12", "_check_inv_9"))); + invariantDependency.put("BACK_MOVE_1", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_6", "_check_inv_10", "_check_inv_7", "_check_inv_4", "_check_inv_5", "_check_inv_8", "_check_inv_12", "_check_inv_9"))); + invariantDependency.put("FRONT_MOVE_2", new HashSet<>(Arrays.asList("_check_inv_10", "_check_inv_5", "_check_inv_12", "_check_inv_9"))); + invariantDependency.put("route_formation", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_4", "_check_inv_12", "_check_inv_11"))); + invariantDependency.put("route_freeing", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_7", "_check_inv_4", "_check_inv_12", "_check_inv_11"))); + invariantDependency.put("BACK_MOVE_2", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_6", "_check_inv_10", "_check_inv_7", "_check_inv_4", "_check_inv_5", "_check_inv_8", "_check_inv_12", "_check_inv_9"))); + guardDependency.put("point_positionning", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_BACK_MOVE_1", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); + guardDependency.put("route_reservation", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_BACK_MOVE_2"))); + guardDependency.put("FRONT_MOVE_1", new HashSet<>(Arrays.asList("_tr_FRONT_MOVE_1", "_tr_BACK_MOVE_1", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); + guardDependency.put("BACK_MOVE_1", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); + guardDependency.put("FRONT_MOVE_2", new HashSet<>(Arrays.asList("_tr_FRONT_MOVE_1", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); + guardDependency.put("route_formation", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_point_positionning"))); + guardDependency.put("route_freeing", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_BACK_MOVE_2"))); + guardDependency.put("BACK_MOVE_2", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); + } + + private Train_1_beebook_deterministic_MC_POR_v2 next() { + synchronized(this.unvisitedStates) { + return switch(type) { + case BFS -> this.unvisitedStates.removeFirst(); + case DFS -> this.unvisitedStates.removeLast(); + case MIXED -> this.unvisitedStates.size() % 2 == 0 ? this.unvisitedStates.removeFirst() : this.unvisitedStates.removeLast(); + }; } - BSet<BLOCKS> _trid_5 = state._tr_BACK_MOVE_1(); - for(BLOCKS param : _trid_5) { - BLOCKS _tmp_1 = param; - - Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); - copiedState.BACK_MOVE_1(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "BACK_MOVE_1"); - } + } + + @SuppressWarnings("unchecked") + private Set<Train_1_beebook_deterministic_MC_POR_v2> generateNextStates(final Train_1_beebook_deterministic_MC_POR_v2 state) { + Set<Train_1_beebook_deterministic_MC_POR_v2> result = new HashSet<>(); + if(isCaching) { + PersistentHashMap parentsGuard = state.guardCache; + PersistentHashMap newCache = parentsGuard == null ? PersistentHashMap.EMPTY : parentsGuard; + Object cachedValue = null; + boolean dependentGuardsBoolean = true; + BSet<ROUTES> _trid_1; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_route_reservation"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_route_reservation"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BLOCKS> _trid_6 = state._tr_BACK_MOVE_2(); - for(BLOCKS param : _trid_6) { - BLOCKS _tmp_1 = param; - - Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); - copiedState.BACK_MOVE_2(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "BACK_MOVE_2"); - } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_1 = state._tr_route_reservation(); + } else { + _trid_1 = (BSet<ROUTES>) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<ROUTES> _trid_7 = state._tr_point_positionning(); - for(ROUTES param : _trid_7) { - ROUTES _tmp_1 = param; - - Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); - copiedState.point_positionning(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "point_positionning"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_route_reservation", _trid_1); + for(ROUTES param : _trid_1) { + ROUTES _tmp_1 = param; + + Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); + copiedState.route_reservation(_tmp_1); + copiedState.parent = state; + addCachedInfos("route_reservation", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<ROUTES> _trid_8 = state._tr_route_formation(); - for(ROUTES param : _trid_8) { - ROUTES _tmp_1 = param; - - Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); - copiedState.route_formation(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "route_formation"); - } + BSet<ROUTES> _trid_2; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_route_freeing"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_route_freeing"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - } - return result; - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_2 = state._tr_route_freeing(); + } else { + _trid_2 = (BSet<ROUTES>) cachedValue; + } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_route_freeing", _trid_2); + for(ROUTES param : _trid_2) { + ROUTES _tmp_1 = param; + Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); + copiedState.route_freeing(_tmp_1); + copiedState.parent = state; + addCachedInfos("route_freeing", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - public static boolean checkInvariants(Object guardLock, Train_1_beebook_deterministic_MC_POR_v2 state, boolean isCaching, Map<Train_1_beebook_deterministic_MC_POR_v2, Set<String>> dependentInvariant) { - if(isCaching) { - Set<String> dependentInvariantsOfState; - synchronized(guardLock) { - dependentInvariantsOfState = dependentInvariant.get(state); - } - if(dependentInvariantsOfState.contains("_check_inv_1")) { - if(!state._check_inv_1()) { - return false; } - } - if(dependentInvariantsOfState.contains("_check_inv_2")) { - if(!state._check_inv_2()) { - return false; + BSet<ROUTES> _trid_3; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_FRONT_MOVE_1"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_FRONT_MOVE_1"); } - } - if(dependentInvariantsOfState.contains("_check_inv_3")) { - if(!state._check_inv_3()) { - return false; + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_3 = state._tr_FRONT_MOVE_1(); + } else { + _trid_3 = (BSet<ROUTES>) cachedValue; } - } - if(dependentInvariantsOfState.contains("_check_inv_4")) { - if(!state._check_inv_4()) { - return false; + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_FRONT_MOVE_1", _trid_3); + for(ROUTES param : _trid_3) { + ROUTES _tmp_1 = param; + + Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); + copiedState.FRONT_MOVE_1(_tmp_1); + copiedState.parent = state; + addCachedInfos("FRONT_MOVE_1", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - } - if(dependentInvariantsOfState.contains("_check_inv_5")) { - if(!state._check_inv_5()) { - return false; + BSet<BLOCKS> _trid_4; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_FRONT_MOVE_2"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_FRONT_MOVE_2"); } - } - if(dependentInvariantsOfState.contains("_check_inv_6")) { - if(!state._check_inv_6()) { - return false; + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_4 = state._tr_FRONT_MOVE_2(); + } else { + _trid_4 = (BSet<BLOCKS>) cachedValue; } - } - if(dependentInvariantsOfState.contains("_check_inv_7")) { - if(!state._check_inv_7()) { - return false; + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_FRONT_MOVE_2", _trid_4); + for(BLOCKS param : _trid_4) { + BLOCKS _tmp_1 = param; + + Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); + copiedState.FRONT_MOVE_2(_tmp_1); + copiedState.parent = state; + addCachedInfos("FRONT_MOVE_2", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - } - if(dependentInvariantsOfState.contains("_check_inv_8")) { - if(!state._check_inv_8()) { - return false; + BSet<BLOCKS> _trid_5; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_BACK_MOVE_1"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_BACK_MOVE_1"); } - } - if(dependentInvariantsOfState.contains("_check_inv_9")) { - if(!state._check_inv_9()) { - return false; + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_5 = state._tr_BACK_MOVE_1(); + } else { + _trid_5 = (BSet<BLOCKS>) cachedValue; } - } - if(dependentInvariantsOfState.contains("_check_inv_10")) { - if(!state._check_inv_10()) { - return false; + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_BACK_MOVE_1", _trid_5); + for(BLOCKS param : _trid_5) { + BLOCKS _tmp_1 = param; + + Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); + copiedState.BACK_MOVE_1(_tmp_1); + copiedState.parent = state; + addCachedInfos("BACK_MOVE_1", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - } - if(dependentInvariantsOfState.contains("_check_inv_11")) { - if(!state._check_inv_11()) { - return false; + BSet<BLOCKS> _trid_6; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_BACK_MOVE_2"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_BACK_MOVE_2"); } - } - if(dependentInvariantsOfState.contains("_check_inv_12")) { - if(!state._check_inv_12()) { - return false; + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_6 = state._tr_BACK_MOVE_2(); + } else { + _trid_6 = (BSet<BLOCKS>) cachedValue; } - } - return true; - } - return !(!state._check_inv_1() || !state._check_inv_2() || !state._check_inv_3() || !state._check_inv_4() || !state._check_inv_5() || !state._check_inv_6() || !state._check_inv_7() || !state._check_inv_8() || !state._check_inv_9() || !state._check_inv_10() || !state._check_inv_11() || !state._check_inv_12()); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_BACK_MOVE_2", _trid_6); + for(BLOCKS param : _trid_6) { + BLOCKS _tmp_1 = param; - private static void printResult(int states, int transitions, boolean deadlockDetected, boolean invariantViolated, List<Train_1_beebook_deterministic_MC_POR_v2> counterExampleState, Map<Train_1_beebook_deterministic_MC_POR_v2, Train_1_beebook_deterministic_MC_POR_v2> parents, Map<Train_1_beebook_deterministic_MC_POR_v2, String> stateAccessedVia) { + Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); + copiedState.BACK_MOVE_2(_tmp_1); + copiedState.parent = state; + addCachedInfos("BACK_MOVE_2", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - if(invariantViolated || deadlockDetected) { - if(deadlockDetected) { - System.out.println("DEADLOCK DETECTED"); - } - if(invariantViolated) { - System.out.println("INVARIANT VIOLATED"); - } - System.out.println("COUNTER EXAMPLE TRACE: "); - StringBuilder sb = new StringBuilder(); - if(counterExampleState.size() >= 1) { - Train_1_beebook_deterministic_MC_POR_v2 currentState = counterExampleState.get(0); - while(currentState != null) { - sb.insert(0, currentState.toString()); - sb.insert(0, "\n"); - sb.insert(0, stateAccessedVia.get(currentState)); - sb.insert(0, "\n\n"); - currentState = parents.get(currentState); } - } - System.out.println(sb.toString()); + BSet<ROUTES> _trid_7; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_point_positionning"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_point_positionning"); + } - } - if(!deadlockDetected && !invariantViolated) { - System.out.println("MODEL CHECKING SUCCESSFUL"); - } - System.out.println("Number of States: " + states); - System.out.println("Number of Transitions: " + transitions); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_7 = state._tr_point_positionning(); + } else { + _trid_7 = (BSet<ROUTES>) cachedValue; + } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_point_positionning", _trid_7); + for(ROUTES param : _trid_7) { + ROUTES _tmp_1 = param; - private static Train_1_beebook_deterministic_MC_POR_v2 next(LinkedList<Train_1_beebook_deterministic_MC_POR_v2> collection, Object lock, Type type) { - synchronized(lock) { - return switch(type) { - case BFS -> collection.removeFirst(); - case DFS -> collection.removeLast(); - case MIXED -> collection.size() % 2 == 0 ? collection.removeFirst() : collection.removeLast(); - }; - } - } + Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); + copiedState.point_positionning(_tmp_1); + copiedState.parent = state; + addCachedInfos("point_positionning", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - private static void modelCheckSingleThreaded(Type type, boolean isCaching) { - Object lock = new Object(); - Object guardLock = new Object(); + } + BSet<ROUTES> _trid_8; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_route_formation"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_route_formation"); + } - Train_1_beebook_deterministic_MC_POR_v2 machine = new Train_1_beebook_deterministic_MC_POR_v2(); + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_8 = state._tr_route_formation(); + } else { + _trid_8 = (BSet<ROUTES>) cachedValue; + } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_route_formation", _trid_8); + for(ROUTES param : _trid_8) { + ROUTES _tmp_1 = param; + Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); + copiedState.route_formation(_tmp_1); + copiedState.parent = state; + addCachedInfos("route_formation", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - AtomicBoolean invariantViolated = new AtomicBoolean(false); - AtomicBoolean deadlockDetected = new AtomicBoolean(false); - AtomicBoolean stopThreads = new AtomicBoolean(false); + } - Set<Train_1_beebook_deterministic_MC_POR_v2> states = new HashSet<>(); - states.add(machine); - AtomicInteger numberStates = new AtomicInteger(1); + state.guardCache = newCache; + } else { + BSet<ROUTES> _trid_1 = state._tr_route_reservation(); + for(ROUTES param : _trid_1) { + ROUTES _tmp_1 = param; - LinkedList<Train_1_beebook_deterministic_MC_POR_v2> collection = new LinkedList<>(); - collection.add(machine); + Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); + copiedState.route_reservation(_tmp_1); + copiedState.parent = state; + addCachedInfos("route_reservation", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - Map<String, Set<String>> invariantDependency = new HashMap<>(); - Map<String, Set<String>> guardDependency = new HashMap<>(); - Map<Train_1_beebook_deterministic_MC_POR_v2, Set<String>> dependentInvariant = new HashMap<>(); - Map<Train_1_beebook_deterministic_MC_POR_v2, Set<String>> dependentGuard = new HashMap<>(); - Map<Train_1_beebook_deterministic_MC_POR_v2, PersistentHashMap> guardCache = new HashMap<>(); - Map<Train_1_beebook_deterministic_MC_POR_v2, Train_1_beebook_deterministic_MC_POR_v2> parents = new HashMap<>(); - Map<Train_1_beebook_deterministic_MC_POR_v2, String> stateAccessedVia = new HashMap<>(); - if(isCaching) { - invariantDependency.put("point_positionning", new HashSet<>(Arrays.asList("_check_inv_3", "_check_inv_1", "_check_inv_4"))); - invariantDependency.put("route_reservation", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_6", "_check_inv_10", "_check_inv_7", "_check_inv_4", "_check_inv_8", "_check_inv_12", "_check_inv_9", "_check_inv_11"))); - invariantDependency.put("FRONT_MOVE_1", new HashSet<>(Arrays.asList("_check_inv_6", "_check_inv_10", "_check_inv_5", "_check_inv_12", "_check_inv_9"))); - invariantDependency.put("BACK_MOVE_1", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_6", "_check_inv_10", "_check_inv_7", "_check_inv_4", "_check_inv_5", "_check_inv_8", "_check_inv_12", "_check_inv_9"))); - invariantDependency.put("FRONT_MOVE_2", new HashSet<>(Arrays.asList("_check_inv_10", "_check_inv_5", "_check_inv_12", "_check_inv_9"))); - invariantDependency.put("route_formation", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_4", "_check_inv_12", "_check_inv_11"))); - invariantDependency.put("route_freeing", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_7", "_check_inv_4", "_check_inv_12", "_check_inv_11"))); - invariantDependency.put("BACK_MOVE_2", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_6", "_check_inv_10", "_check_inv_7", "_check_inv_4", "_check_inv_5", "_check_inv_8", "_check_inv_12", "_check_inv_9"))); - guardDependency.put("point_positionning", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_BACK_MOVE_1", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - guardDependency.put("route_reservation", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_BACK_MOVE_2"))); - guardDependency.put("FRONT_MOVE_1", new HashSet<>(Arrays.asList("_tr_FRONT_MOVE_1", "_tr_BACK_MOVE_1", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - guardDependency.put("BACK_MOVE_1", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - guardDependency.put("FRONT_MOVE_2", new HashSet<>(Arrays.asList("_tr_FRONT_MOVE_1", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - guardDependency.put("route_formation", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_point_positionning"))); - guardDependency.put("route_freeing", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_BACK_MOVE_2"))); - guardDependency.put("BACK_MOVE_2", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - dependentInvariant.put(machine, new HashSet<>()); - } - List<Train_1_beebook_deterministic_MC_POR_v2> counterExampleState = new ArrayList<>(); - parents.put(machine, null); + } + BSet<ROUTES> _trid_2 = state._tr_route_freeing(); + for(ROUTES param : _trid_2) { + ROUTES _tmp_1 = param; - AtomicInteger transitions = new AtomicInteger(0); + Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); + copiedState.route_freeing(_tmp_1); + copiedState.parent = state; + addCachedInfos("route_freeing", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - while(!collection.isEmpty() && !stopThreads.get()) { - Train_1_beebook_deterministic_MC_POR_v2 state = next(collection, lock, type); + } + BSet<ROUTES> _trid_3 = state._tr_FRONT_MOVE_1(); + for(ROUTES param : _trid_3) { + ROUTES _tmp_1 = param; - Set<Train_1_beebook_deterministic_MC_POR_v2> nextStates = generateNextStates(guardLock, state, isCaching, invariantDependency, dependentInvariant, guardDependency, dependentGuard, guardCache, parents, stateAccessedVia, transitions); + Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); + copiedState.FRONT_MOVE_1(_tmp_1); + copiedState.parent = state; + addCachedInfos("FRONT_MOVE_1", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - nextStates.forEach(nextState -> { - if(!states.contains(nextState)) { - numberStates.getAndIncrement(); - states.add(nextState); - collection.add(nextState); - if(numberStates.get() % 50000 == 0) { - System.out.println("VISITED STATES: " + numberStates.get()); - System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); - System.out.println("-------------------"); - } } - }); + BSet<BLOCKS> _trid_4 = state._tr_FRONT_MOVE_2(); + for(BLOCKS param : _trid_4) { + BLOCKS _tmp_1 = param; - if(!checkInvariants(guardLock, state, isCaching, dependentInvariant)) { - invariantViolated.set(true); - stopThreads.set(true); - counterExampleState.add(state); - } + Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); + copiedState.FRONT_MOVE_2(_tmp_1); + copiedState.parent = state; + addCachedInfos("FRONT_MOVE_2", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - if(nextStates.isEmpty()) { - deadlockDetected.set(true); - stopThreads.set(true); - } + } + BSet<BLOCKS> _trid_5 = state._tr_BACK_MOVE_1(); + for(BLOCKS param : _trid_5) { + BLOCKS _tmp_1 = param; - } - printResult(numberStates.get(), transitions.get(), deadlockDetected.get(), invariantViolated.get(), counterExampleState, parents, stateAccessedVia); - } + Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); + copiedState.BACK_MOVE_1(_tmp_1); + copiedState.parent = state; + addCachedInfos("BACK_MOVE_1", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } + BSet<BLOCKS> _trid_6 = state._tr_BACK_MOVE_2(); + for(BLOCKS param : _trid_6) { + BLOCKS _tmp_1 = param; - private static void modelCheckMultiThreaded(Type type, int threads, boolean isCaching) { - Object lock = new Object(); - Object guardLock = new Object(); - Object waitLock = new Object(); - ThreadPoolExecutor threadPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(threads); + Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); + copiedState.BACK_MOVE_2(_tmp_1); + copiedState.parent = state; + addCachedInfos("BACK_MOVE_2", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - Train_1_beebook_deterministic_MC_POR_v2 machine = new Train_1_beebook_deterministic_MC_POR_v2(); + } + BSet<ROUTES> _trid_7 = state._tr_point_positionning(); + for(ROUTES param : _trid_7) { + ROUTES _tmp_1 = param; + Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); + copiedState.point_positionning(_tmp_1); + copiedState.parent = state; + addCachedInfos("point_positionning", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - AtomicBoolean invariantViolated = new AtomicBoolean(false); - AtomicBoolean deadlockDetected = new AtomicBoolean(false); - AtomicBoolean stopThreads = new AtomicBoolean(false); - AtomicInteger possibleQueueChanges = new AtomicInteger(0); + } + BSet<ROUTES> _trid_8 = state._tr_route_formation(); + for(ROUTES param : _trid_8) { + ROUTES _tmp_1 = param; - Set<Train_1_beebook_deterministic_MC_POR_v2> states = new HashSet<>(); - states.add(machine); - AtomicInteger numberStates = new AtomicInteger(1); + Train_1_beebook_deterministic_MC_POR_v2 copiedState = state._copy(); + copiedState.route_formation(_tmp_1); + copiedState.parent = state; + addCachedInfos("route_formation", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - LinkedList<Train_1_beebook_deterministic_MC_POR_v2> collection = new LinkedList<>(); - collection.add(machine); + } - Map<String, Set<String>> invariantDependency = new HashMap<>(); - Map<String, Set<String>> guardDependency = new HashMap<>(); - Map<Train_1_beebook_deterministic_MC_POR_v2, Set<String>> dependentInvariant = new HashMap<>(); - Map<Train_1_beebook_deterministic_MC_POR_v2, Set<String>> dependentGuard = new HashMap<>(); - Map<Train_1_beebook_deterministic_MC_POR_v2, PersistentHashMap> guardCache = new HashMap<>(); - Map<Train_1_beebook_deterministic_MC_POR_v2, Train_1_beebook_deterministic_MC_POR_v2> parents = new HashMap<>(); - Map<Train_1_beebook_deterministic_MC_POR_v2, String> stateAccessedVia = new HashMap<>(); - if(isCaching) { - invariantDependency.put("point_positionning", new HashSet<>(Arrays.asList("_check_inv_3", "_check_inv_1", "_check_inv_4"))); - invariantDependency.put("route_reservation", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_6", "_check_inv_10", "_check_inv_7", "_check_inv_4", "_check_inv_8", "_check_inv_12", "_check_inv_9", "_check_inv_11"))); - invariantDependency.put("FRONT_MOVE_1", new HashSet<>(Arrays.asList("_check_inv_6", "_check_inv_10", "_check_inv_5", "_check_inv_12", "_check_inv_9"))); - invariantDependency.put("BACK_MOVE_1", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_6", "_check_inv_10", "_check_inv_7", "_check_inv_4", "_check_inv_5", "_check_inv_8", "_check_inv_12", "_check_inv_9"))); - invariantDependency.put("FRONT_MOVE_2", new HashSet<>(Arrays.asList("_check_inv_10", "_check_inv_5", "_check_inv_12", "_check_inv_9"))); - invariantDependency.put("route_formation", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_4", "_check_inv_12", "_check_inv_11"))); - invariantDependency.put("route_freeing", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_7", "_check_inv_4", "_check_inv_12", "_check_inv_11"))); - invariantDependency.put("BACK_MOVE_2", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_6", "_check_inv_10", "_check_inv_7", "_check_inv_4", "_check_inv_5", "_check_inv_8", "_check_inv_12", "_check_inv_9"))); - guardDependency.put("point_positionning", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_BACK_MOVE_1", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - guardDependency.put("route_reservation", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_BACK_MOVE_2"))); - guardDependency.put("FRONT_MOVE_1", new HashSet<>(Arrays.asList("_tr_FRONT_MOVE_1", "_tr_BACK_MOVE_1", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - guardDependency.put("BACK_MOVE_1", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - guardDependency.put("FRONT_MOVE_2", new HashSet<>(Arrays.asList("_tr_FRONT_MOVE_1", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - guardDependency.put("route_formation", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_point_positionning"))); - guardDependency.put("route_freeing", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_BACK_MOVE_2"))); - guardDependency.put("BACK_MOVE_2", new HashSet<>(Arrays.asList("_tr_route_formation", "_tr_FRONT_MOVE_1", "_tr_route_reservation", "_tr_route_freeing", "_tr_BACK_MOVE_1", "_tr_point_positionning", "_tr_FRONT_MOVE_2", "_tr_BACK_MOVE_2"))); - dependentInvariant.put(machine, new HashSet<>()); + } + return result; } - List<Train_1_beebook_deterministic_MC_POR_v2> counterExampleState = new ArrayList<>(); - parents.put(machine, null); - stateAccessedVia.put(machine, null); - - AtomicInteger transitions = new AtomicInteger(0); - while(!collection.isEmpty() && !stopThreads.get()) { - possibleQueueChanges.incrementAndGet(); - Train_1_beebook_deterministic_MC_POR_v2 state = next(collection, lock, type); - Runnable task = () -> { - Set<Train_1_beebook_deterministic_MC_POR_v2> nextStates = generateNextStates(guardLock, state, isCaching, invariantDependency, dependentInvariant, guardDependency, dependentGuard, guardCache, parents, stateAccessedVia, transitions); - - nextStates.forEach(nextState -> { - synchronized(lock) { - if(!states.contains(nextState)) { - numberStates.getAndIncrement(); - states.add(nextState); - collection.add(nextState); - if(numberStates.get() % 50000 == 0) { - System.out.println("VISITED STATES: " + numberStates.get()); - System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); - System.out.println("-------------------"); - } - } + private boolean invariantViolated(final Train_1_beebook_deterministic_MC_POR_v2 state) { + if(isCaching) { + if(state.dependentInvariant.contains("_check_inv_1")) { + if(!state._check_inv_1()) { + return true; } - }); - - synchronized (lock) { - int running = possibleQueueChanges.decrementAndGet(); - if (!collection.isEmpty() || running == 0) { - synchronized (waitLock) { - waitLock.notify(); - } + } + if(state.dependentInvariant.contains("_check_inv_2")) { + if(!state._check_inv_2()) { + return true; } } - - if(nextStates.isEmpty()) { - deadlockDetected.set(true); - stopThreads.set(true); + if(state.dependentInvariant.contains("_check_inv_3")) { + if(!state._check_inv_3()) { + return true; + } } - - - if (!checkInvariants(guardLock, state, isCaching, dependentInvariant)) { - invariantViolated.set(true); - stopThreads.set(true); - counterExampleState.add(state); + if(state.dependentInvariant.contains("_check_inv_4")) { + if(!state._check_inv_4()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_5")) { + if(!state._check_inv_5()) { + return true; + } } + if(state.dependentInvariant.contains("_check_inv_6")) { + if(!state._check_inv_6()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_7")) { + if(!state._check_inv_7()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_8")) { + if(!state._check_inv_8()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_9")) { + if(!state._check_inv_9()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_10")) { + if(!state._check_inv_10()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_11")) { + if(!state._check_inv_11()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_12")) { + if(!state._check_inv_12()) { + return true; + } + } + return false; + } + return !(state._check_inv_1() && state._check_inv_2() && state._check_inv_3() && state._check_inv_4() && state._check_inv_5() && state._check_inv_6() && state._check_inv_7() && state._check_inv_8() && state._check_inv_9() && state._check_inv_10() && state._check_inv_11() && state._check_inv_12()); + } + private void addCachedInfos(final String operation, final Train_1_beebook_deterministic_MC_POR_v2 state, final Train_1_beebook_deterministic_MC_POR_v2 copiedState) { + if(isCaching) { + copiedState.dependentInvariant = invariantDependency.get(operation); + copiedState.dependentGuard = guardDependency.get(operation); + } + copiedState.stateAccessedVia = operation; + } + private void printResult(final int states, final int transitions) { + if(invariantViolated.get() || deadlockDetected.get()) { + if(deadlockDetected.get()) { + System.out.println("DEADLOCK DETECTED"); + } else { + System.out.println("INVARIANT VIOLATED"); + } - }; - threadPool.submit(task); - synchronized(waitLock) { - if (collection.isEmpty() && possibleQueueChanges.get() > 0) { - try { - waitLock.wait(); - } catch (InterruptedException e) { - e.printStackTrace(); + System.out.println("COUNTER EXAMPLE TRACE: "); + StringBuilder sb = new StringBuilder(); + while(counterExampleState != null) { + sb.insert(0, counterExampleState); + sb.insert(0, "\n"); + if(counterExampleState.stateAccessedVia != null) { + sb.insert(0, counterExampleState.stateAccessedVia); } + sb.insert(0, "\n\n"); + counterExampleState = counterExampleState.parent; } + System.out.println(sb); + } else { + System.out.println("MODEL CHECKING SUCCESSFUL"); } + System.out.println("Number of States: " + states); + System.out.println("Number of Transitions: " + transitions); } - threadPool.shutdown(); - try { - threadPool.awaitTermination(5, TimeUnit.SECONDS); - } catch (InterruptedException e) { - e.printStackTrace(); - } - printResult(numberStates.get(), transitions.get(), deadlockDetected.get(), invariantViolated.get(), counterExampleState, parents, stateAccessedVia); } public static void main(String[] args) { - if(args.length != 3) { - System.out.println("Number of arguments errorneous"); + if(args.length > 4) { + System.out.println("Expecting 3 command-line arguments: STRATEGY THREADS CACHING DEBUG"); return; } - String strategy = args[0]; - String numberThreads = args[1]; - String caching = args[2]; - - Type type; - - if("mixed".equals(strategy)) { - type = Type.MIXED; - } else if("bf".equals(strategy)) { - type = Type.BFS; - } else if ("df".equals(strategy)) { - type = Type.DFS; - } else { - System.out.println("Input for strategy is wrong."); - return; - } - + Type type = Type.MIXED; int threads = 0; - try { - threads = Integer.parseInt(numberThreads); - } catch(NumberFormatException e) { - System.out.println("Input for number of threads is wrong."); - return; + boolean isCaching = false; + boolean isDebug = false; + + if(args.length > 0) { + if("mixed".equals(args[0])) { + type = Type.MIXED; + } else if("bf".equals(args[0])) { + type = Type.BFS; + } else if ("df".equals(args[0])) { + type = Type.DFS; + } else { + System.out.println("Value for command-line argument STRATEGY is wrong."); + System.out.println("Expecting mixed, bf or df."); + return; + } } - if(threads <= 0) { - System.out.println("Input for number of threads is wrong."); - return; + if(args.length > 1) { + try { + threads = Integer.parseInt(args[1]); + } catch(NumberFormatException e) { + System.out.println("Value for command-line argument THREADS is not a number."); + return; + } + if(threads <= 0) { + System.out.println("Value for command-line argument THREADS must be positive."); + return; + } } - - boolean isCaching = true; - try { - isCaching = Boolean.parseBoolean(caching); - } catch(Exception e) { - System.out.println("Input for caching is wrong."); - return; + if(args.length > 2) { + try { + isCaching = Boolean.parseBoolean(args[2]); + } catch(Exception e) { + System.out.println("Value for command-line argument CACHING is not a boolean."); + return; + } } - if(threads == 1) { - modelCheckSingleThreaded(type, isCaching); - } else { - modelCheckMultiThreaded(type, threads, isCaching); + if(args.length > 3) { + try { + isDebug = Boolean.parseBoolean(args[3]); + } catch(Exception e) { + System.out.println("Value for command-line argument DEBUG is not a boolean."); + return; + } } + + ModelChecker modelchecker = new ModelChecker(type, threads, isCaching, isDebug); + modelchecker.modelCheck(); } diff --git a/benchmarks/model_checking/Java/nota_v2.java b/benchmarks/model_checking/Java/nota_v2.java index 2026fd0bc9bdf01422defb4763d80fc4146ae113..589ca00372ba202e8bd5722b119f477157dadfa9 100644 --- a/benchmarks/model_checking/Java/nota_v2.java +++ b/benchmarks/model_checking/Java/nota_v2.java @@ -14,6 +14,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.Future; import java.util.concurrent.Executors; @@ -47,104 +48,110 @@ public class nota_v2 { MIXED } + public nota_v2 parent; + public Set<String> dependentGuard = new HashSet<>(); + public PersistentHashMap guardCache = PersistentHashMap.EMPTY; + public Set<String> dependentInvariant = new HashSet<>(); + public String stateAccessedVia; - public static class _Struct1 extends BStruct { - private BSet<SID> sid; - private RM_ERROR_CODES err; - public _Struct1(BSet<SID> sid, RM_ERROR_CODES err) { - this.sid = sid; + public static class _Struct5 extends BStruct { + private BSet<SOCKET> soc; + private IN_ERROR_CODES err; + + public _Struct5(BSet<SOCKET> soc, IN_ERROR_CODES err) { + this.soc = soc; this.err = err; } - public BSet<SID> get_sid() { - return this.sid; + public BSet<SOCKET> get_soc() { + return this.soc; } - public RM_ERROR_CODES get_err() { + public IN_ERROR_CODES get_err() { return this.err; } - public _Struct1 override_sid(BSet<SID> sid) { - return new _Struct1(sid, err); + public _Struct5 override_soc(BSet<SOCKET> soc) { + return new _Struct5(soc, err); } - public _Struct1 override_err(RM_ERROR_CODES err) { - return new _Struct1(sid, err); + public _Struct5 override_err(IN_ERROR_CODES err) { + return new _Struct5(soc, err); } - public BBoolean equal(_Struct1 o) { - return new BBoolean(this.sid == o.sid && this.err == o.err); + public BBoolean equal(_Struct5 o) { + return new BBoolean(this.soc == o.soc && this.err == o.err); } - public BBoolean unequal(_Struct1 o) { - return new BBoolean(this.sid != o.sid || this.err != o.err); + public BBoolean unequal(_Struct5 o) { + return new BBoolean(this.soc != o.soc || this.err != o.err); } public String toString() { - return "(" + "sid : " + this.sid + "," + "err : " + this.err + ")"; + return "(" + "soc : " + this.soc + "," + "err : " + this.err + ")"; } public boolean equals(Object other) { - if(!(other instanceof _Struct1)) { + if(!(other instanceof _Struct5)) { return false; } - _Struct1 o = (_Struct1) other; - return this.sid == o.sid && this.err == o.err; + _Struct5 o = (_Struct5) other; + return this.soc == o.soc && this.err == o.err; } public int hashCode() { - return Objects.hash(sid, err); + return Objects.hash(soc, err); } } - public static class _Struct5 extends BStruct { - private BSet<SOCKET> soc; - private IN_ERROR_CODES err; + public static class _Struct1 extends BStruct { + private BSet<SID> sid; + private RM_ERROR_CODES err; - public _Struct5(BSet<SOCKET> soc, IN_ERROR_CODES err) { - this.soc = soc; + public _Struct1(BSet<SID> sid, RM_ERROR_CODES err) { + this.sid = sid; this.err = err; } - public BSet<SOCKET> get_soc() { - return this.soc; + public BSet<SID> get_sid() { + return this.sid; } - public IN_ERROR_CODES get_err() { + public RM_ERROR_CODES get_err() { return this.err; } - public _Struct5 override_soc(BSet<SOCKET> soc) { - return new _Struct5(soc, err); + public _Struct1 override_sid(BSet<SID> sid) { + return new _Struct1(sid, err); } - public _Struct5 override_err(IN_ERROR_CODES err) { - return new _Struct5(soc, err); + public _Struct1 override_err(RM_ERROR_CODES err) { + return new _Struct1(sid, err); } - public BBoolean equal(_Struct5 o) { - return new BBoolean(this.soc == o.soc && this.err == o.err); + public BBoolean equal(_Struct1 o) { + return new BBoolean(this.sid == o.sid && this.err == o.err); } - public BBoolean unequal(_Struct5 o) { - return new BBoolean(this.soc != o.soc || this.err != o.err); + public BBoolean unequal(_Struct1 o) { + return new BBoolean(this.sid != o.sid || this.err != o.err); } public String toString() { - return "(" + "soc : " + this.soc + "," + "err : " + this.err + ")"; + return "(" + "sid : " + this.sid + "," + "err : " + this.err + ")"; } public boolean equals(Object other) { - if(!(other instanceof _Struct5)) { + if(!(other instanceof _Struct1)) { return false; } - _Struct5 o = (_Struct5) other; - return this.soc == o.soc && this.err == o.err; + _Struct1 o = (_Struct1) other; + return this.sid == o.sid && this.err == o.err; } public int hashCode() { - return Objects.hash(soc, err); + return Objects.hash(sid, err); } } @@ -343,6 +350,7 @@ public class nota_v2 { svc_registered = new BRelation<SERVICE, BBoolean>(); } + public nota_v2(BSet<INTERCONNECTNODE> interconnectNodes, BSet<SOCKET> sockets, BSet<SERVICE> services, BSet<RESOURCEMANAGER> resourceManagers, BSet<SID> sids, BRelation<RESOURCEMANAGER, BSet<SERVICE>> rm_services, BRelation<SERVICE, SID> rm_sids, BRelation<SID, INTERCONNECTNODE> in_localServices, BRelation<SOCKET, INTERCONNECTNODE> in_sockets, BRelation<INTERCONNECTNODE, BSet<RESOURCEMANAGER>> in_resourceManager, BRelation<SOCKET, SID> soc_to, BRelation<SOCKET, SID> soc_from, BRelation<SERVICE, SID> svc_serviceID, BRelation<SERVICE, BSet<SOCKET>> svc_sockets, BRelation<SERVICE, INTERCONNECTNODE> svc_ICNode, BRelation<SERVICE, BBoolean> svc_registered) { this.interconnectNodes = interconnectNodes; this.sockets = sockets; @@ -362,6 +370,7 @@ public class nota_v2 { this.svc_registered = svc_registered; } + public INTERCONNECTNODE constructor_interconnectNode(INTERCONNECTNODE newic) { INTERCONNECTNODE oid = null; BSet<INTERCONNECTNODE> _ld_interconnectNodes = interconnectNodes; @@ -914,1183 +923,911 @@ public class nota_v2 { return String.join("\n", "_get_interconnectNodes: " + (this._get_interconnectNodes()).toString(), "_get_sockets: " + (this._get_sockets()).toString(), "_get_services: " + (this._get_services()).toString(), "_get_resourceManagers: " + (this._get_resourceManagers()).toString(), "_get_sids: " + (this._get_sids()).toString(), "_get_rm_services: " + (this._get_rm_services()).toString(), "_get_rm_sids: " + (this._get_rm_sids()).toString(), "_get_in_localServices: " + (this._get_in_localServices()).toString(), "_get_in_sockets: " + (this._get_in_sockets()).toString(), "_get_in_resourceManager: " + (this._get_in_resourceManager()).toString(), "_get_soc_to: " + (this._get_soc_to()).toString(), "_get_soc_from: " + (this._get_soc_from()).toString(), "_get_svc_serviceID: " + (this._get_svc_serviceID()).toString(), "_get_svc_sockets: " + (this._get_svc_sockets()).toString(), "_get_svc_ICNode: " + (this._get_svc_ICNode()).toString(), "_get_svc_registered: " + (this._get_svc_registered()).toString()); } - @SuppressWarnings("unchecked") - private static Set<nota_v2> generateNextStates(Object guardLock, nota_v2 state, boolean isCaching, Map<String, Set<String>> invariantDependency, Map<nota_v2, Set<String>> dependentInvariant, Map<String, Set<String>> guardDependency, Map<nota_v2, Set<String>> dependentGuard, Map<nota_v2, PersistentHashMap> guardCache, Map<nota_v2, nota_v2> parents, Map<nota_v2, String> stateAccessedVia, AtomicInteger transitions) { - Set<nota_v2> result = new HashSet<>(); - if(isCaching) { - PersistentHashMap parentsGuard = guardCache.get(parents.get(state)); - PersistentHashMap newCache = parentsGuard == null ? PersistentHashMap.EMPTY : parentsGuard; - Set<String> dependentGuardsOfState = dependentGuard.get(state); - Object cachedValue = null; - boolean dependentGuardsBoolean = true; - BSet<INTERCONNECTNODE> _trid_1; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_constructor_interconnectNode"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_constructor_interconnectNode"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_1 = state._tr_constructor_interconnectNode(); - } else { - _trid_1 = (BSet<INTERCONNECTNODE>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_constructor_interconnectNode", _trid_1); - for(INTERCONNECTNODE param : _trid_1) { - INTERCONNECTNODE _tmp_1 = param; - - nota_v2 copiedState = state._copy(); - copiedState.constructor_interconnectNode(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("constructor_interconnectNode")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("constructor_interconnectNode")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "constructor_interconnectNode"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<RESOURCEMANAGER> _trid_2; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_constructor_resourceManager"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_constructor_resourceManager"); - } + private static class ModelChecker { + private final Type type; + private final int threads; + private final boolean isCaching; + private final boolean isDebug; - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_2 = state._tr_constructor_resourceManager(); - } else { - _trid_2 = (BSet<RESOURCEMANAGER>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_constructor_resourceManager", _trid_2); - for(RESOURCEMANAGER param : _trid_2) { - RESOURCEMANAGER _tmp_1 = param; - - nota_v2 copiedState = state._copy(); - copiedState.constructor_resourceManager(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("constructor_resourceManager")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("constructor_resourceManager")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "constructor_resourceManager"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<INTERCONNECTNODE, SERVICE>> _trid_3; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_constructor_service"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_constructor_service"); - } + private final LinkedList<nota_v2> unvisitedStates = new LinkedList<>(); + private final Set<nota_v2> states = ConcurrentHashMap.newKeySet(); + private AtomicInteger transitions = new AtomicInteger(0); + private ThreadPoolExecutor threadPool; + private Object waitLock = new Object(); - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_3 = state._tr_constructor_service(); - } else { - _trid_3 = (BSet<BTuple<INTERCONNECTNODE, SERVICE>>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_constructor_service", _trid_3); - for(BTuple<INTERCONNECTNODE, SERVICE> param : _trid_3) { - SERVICE _tmp_1 = param.projection2(); - INTERCONNECTNODE _tmp_2 = param.projection1(); - - nota_v2 copiedState = state._copy(); - copiedState.constructor_service(_tmp_2, _tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("constructor_service")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("constructor_service")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "constructor_service"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<BTuple<BTuple<INTERCONNECTNODE, SID>, SID>, SOCKET>> _trid_4; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_constructor_socket"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_constructor_socket"); - } + private AtomicBoolean invariantViolated = new AtomicBoolean(false); + private AtomicBoolean deadlockDetected = new AtomicBoolean(false); + private nota_v2 counterExampleState = null; - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_4 = state._tr_constructor_socket(); - } else { - _trid_4 = (BSet<BTuple<BTuple<BTuple<INTERCONNECTNODE, SID>, SID>, SOCKET>>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_constructor_socket", _trid_4); - for(BTuple<BTuple<BTuple<INTERCONNECTNODE, SID>, SID>, SOCKET> param : _trid_4) { - SOCKET _tmp_1 = param.projection2(); - BTuple<BTuple<INTERCONNECTNODE, SID>, SID> _tmp_2 = param.projection1(); - SID _tmp_3 = _tmp_2.projection2(); - BTuple<INTERCONNECTNODE, SID> _tmp_4 = _tmp_2.projection1(); - SID _tmp_5 = _tmp_4.projection2(); - INTERCONNECTNODE _tmp_6 = _tmp_4.projection1(); - - nota_v2 copiedState = state._copy(); - copiedState.constructor_socket(_tmp_6, _tmp_5, _tmp_3, _tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("constructor_socket")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("constructor_socket")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "constructor_socket"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<BTuple<RESOURCEMANAGER, SERVICE>, INTERCONNECTNODE>> _trid_5; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_rm_register"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_rm_register"); - } + private final Map<String, Set<String>> invariantDependency = new HashMap<>(); + private final Map<String, Set<String>> guardDependency = new HashMap<>(); - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_5 = state._tr_rm_register(); - } else { - _trid_5 = (BSet<BTuple<BTuple<RESOURCEMANAGER, SERVICE>, INTERCONNECTNODE>>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_rm_register", _trid_5); - for(BTuple<BTuple<RESOURCEMANAGER, SERVICE>, INTERCONNECTNODE> param : _trid_5) { - INTERCONNECTNODE _tmp_1 = param.projection2(); - BTuple<RESOURCEMANAGER, SERVICE> _tmp_2 = param.projection1(); - SERVICE _tmp_3 = _tmp_2.projection2(); - RESOURCEMANAGER _tmp_4 = _tmp_2.projection1(); - - nota_v2 copiedState = state._copy(); - copiedState.rm_register(_tmp_4, _tmp_3, _tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("rm_register")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("rm_register")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "rm_register"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<BTuple<RESOURCEMANAGER, SERVICE>, INTERCONNECTNODE>> _trid_6; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_rm_deregister"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_rm_deregister"); - } + public ModelChecker(final Type type, final int threads, final boolean isCaching, final boolean isDebug) { + this.type = type; + this.threads = threads; + this.isCaching = isCaching; + this.isDebug = isDebug; + } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_6 = state._tr_rm_deregister(); - } else { - _trid_6 = (BSet<BTuple<BTuple<RESOURCEMANAGER, SERVICE>, INTERCONNECTNODE>>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_rm_deregister", _trid_6); - for(BTuple<BTuple<RESOURCEMANAGER, SERVICE>, INTERCONNECTNODE> param : _trid_6) { - INTERCONNECTNODE _tmp_1 = param.projection2(); - BTuple<RESOURCEMANAGER, SERVICE> _tmp_2 = param.projection1(); - SERVICE _tmp_3 = _tmp_2.projection2(); - RESOURCEMANAGER _tmp_4 = _tmp_2.projection1(); - - nota_v2 copiedState = state._copy(); - copiedState.rm_deregister(_tmp_4, _tmp_3, _tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("rm_deregister")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("rm_deregister")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "rm_deregister"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<RESOURCEMANAGER, SERVICE>> _trid_7; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_rm_getSid"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_rm_getSid"); + public void modelCheck() { + if (isDebug) { + System.out.println("Starting Modelchecking, STRATEGY=" + type + ", THREADS=" + threads + ", CACHING=" + isCaching); } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_7 = state._tr_rm_getSid(); + if (threads <= 1) { + modelCheckSingleThreaded(); } else { - _trid_7 = (BSet<BTuple<RESOURCEMANAGER, SERVICE>>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_rm_getSid", _trid_7); - for(BTuple<RESOURCEMANAGER, SERVICE> param : _trid_7) { - SERVICE _tmp_1 = param.projection2(); - RESOURCEMANAGER _tmp_2 = param.projection1(); - - nota_v2 copiedState = state._copy(); - copiedState.rm_getSid(_tmp_2, _tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("rm_getSid")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("rm_getSid")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "rm_getSid"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<RESOURCEMANAGER, SERVICE>> _trid_8; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_rm_getSid_Not_Found"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_rm_getSid_Not_Found"); + this.threadPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(threads-1); + modelCheckMultiThreaded(); } + } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_8 = state._tr_rm_getSid_Not_Found(); - } else { - _trid_8 = (BSet<BTuple<RESOURCEMANAGER, SERVICE>>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_rm_getSid_Not_Found", _trid_8); - for(BTuple<RESOURCEMANAGER, SERVICE> param : _trid_8) { - SERVICE _tmp_1 = param.projection2(); - RESOURCEMANAGER _tmp_2 = param.projection1(); - - nota_v2 copiedState = state._copy(); - copiedState.rm_getSid_Not_Found(_tmp_2, _tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("rm_getSid_Not_Found")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("rm_getSid_Not_Found")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "rm_getSid_Not_Found"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<INTERCONNECTNODE, RESOURCEMANAGER>> _trid_9; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_in_announceResourceManager"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_in_announceResourceManager"); - } + private void modelCheckSingleThreaded() { + nota_v2 machine = new nota_v2(); + states.add(machine); // TODO: store hashes instead of machine? + unvisitedStates.add(machine); - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_9 = state._tr_in_announceResourceManager(); - } else { - _trid_9 = (BSet<BTuple<INTERCONNECTNODE, RESOURCEMANAGER>>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_in_announceResourceManager", _trid_9); - for(BTuple<INTERCONNECTNODE, RESOURCEMANAGER> param : _trid_9) { - RESOURCEMANAGER _tmp_1 = param.projection2(); - INTERCONNECTNODE _tmp_2 = param.projection1(); - - nota_v2 copiedState = state._copy(); - copiedState.in_announceResourceManager(_tmp_2, _tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("in_announceResourceManager")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("in_announceResourceManager")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "in_announceResourceManager"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<BTuple<INTERCONNECTNODE, SERVICE>, SID>> _trid_10; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_in_register_success"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_in_register_success"); + if(isCaching) { + initCache(machine); } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_10 = state._tr_in_register_success(); - } else { - _trid_10 = (BSet<BTuple<BTuple<INTERCONNECTNODE, SERVICE>, SID>>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_in_register_success", _trid_10); - for(BTuple<BTuple<INTERCONNECTNODE, SERVICE>, SID> param : _trid_10) { - SID _tmp_1 = param.projection2(); - BTuple<INTERCONNECTNODE, SERVICE> _tmp_2 = param.projection1(); - SERVICE _tmp_3 = _tmp_2.projection2(); - INTERCONNECTNODE _tmp_4 = _tmp_2.projection1(); - - nota_v2 copiedState = state._copy(); - copiedState.in_register_success(_tmp_4, _tmp_3, _tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("in_register_success")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("in_register_success")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "in_register_success"); + while(!unvisitedStates.isEmpty()) { + nota_v2 state = next(); + + Set<nota_v2> nextStates = generateNextStates(state); + + nextStates.forEach(nextState -> { + if(!states.contains(nextState)) { + states.add(nextState); + unvisitedStates.add(nextState); + if(states.size() % 50000 == 0 && isDebug) { + System.out.println("VISITED STATES: " + states.size()); + System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); + System.out.println("-------------------"); + } } + }); + + if(invariantViolated(state)) { + invariantViolated.set(true); + counterExampleState = state; + break; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<INTERCONNECTNODE, SERVICE>> _trid_11; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_in_register_failed"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_in_register_failed"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_11 = state._tr_in_register_failed(); - } else { - _trid_11 = (BSet<BTuple<INTERCONNECTNODE, SERVICE>>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_in_register_failed", _trid_11); - for(BTuple<INTERCONNECTNODE, SERVICE> param : _trid_11) { - SERVICE _tmp_1 = param.projection2(); - INTERCONNECTNODE _tmp_2 = param.projection1(); - - nota_v2 copiedState = state._copy(); - copiedState.in_register_failed(_tmp_2, _tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("in_register_failed")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("in_register_failed")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "in_register_failed"); - } + if(nextStates.isEmpty()) { + deadlockDetected.set(true); + counterExampleState = state; + break; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID>, SOCKET>> _trid_12; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_in_requestTargetSocket_Granted"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_in_requestTargetSocket_Granted"); + } + printResult(states.size(), transitions.get()); + } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_12 = state._tr_in_requestTargetSocket_Granted(); - } else { - _trid_12 = (BSet<BTuple<BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID>, SOCKET>>) cachedValue; + private void modelCheckMultiThreaded() { + nota_v2 machine = new nota_v2(); + states.add(machine); + unvisitedStates.add(machine); + + AtomicBoolean stopThreads = new AtomicBoolean(false); + AtomicInteger possibleQueueChanges = new AtomicInteger(0); + + if(isCaching) { + initCache(machine); } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_in_requestTargetSocket_Granted", _trid_12); - for(BTuple<BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID>, SOCKET> param : _trid_12) { - SOCKET _tmp_1 = param.projection2(); - BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID> _tmp_2 = param.projection1(); - SID _tmp_3 = _tmp_2.projection2(); - BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID> _tmp_4 = _tmp_2.projection1(); - SID _tmp_5 = _tmp_4.projection2(); - BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET> _tmp_6 = _tmp_4.projection1(); - SOCKET _tmp_7 = _tmp_6.projection2(); - BTuple<INTERCONNECTNODE, INTERCONNECTNODE> _tmp_8 = _tmp_6.projection1(); - INTERCONNECTNODE _tmp_9 = _tmp_8.projection2(); - INTERCONNECTNODE _tmp_10 = _tmp_8.projection1(); - - nota_v2 copiedState = state._copy(); - copiedState.in_requestTargetSocket_Granted(_tmp_10, _tmp_9, _tmp_7, _tmp_5, _tmp_3, _tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("in_requestTargetSocket_Granted")); + + while(!unvisitedStates.isEmpty() && !stopThreads.get()) { + possibleQueueChanges.incrementAndGet(); + nota_v2 state = next(); + Runnable task = () -> { + Set<nota_v2> nextStates = generateNextStates(state); + + nextStates.forEach(nextState -> { + if(states.add(nextState)) { + synchronized (unvisitedStates) { + unvisitedStates.add(nextState); + } + if(states.size() % 50000 == 0 && isDebug) { + System.out.println("VISITED STATES: " + states.size()); + System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); + System.out.println("-------------------"); + } + } + }); + + synchronized (unvisitedStates) { + int running = possibleQueueChanges.decrementAndGet(); + if (!unvisitedStates.isEmpty() || running == 0) { + synchronized (waitLock) { + waitLock.notify(); + } + } } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("in_requestTargetSocket_Granted")); + + if(invariantViolated(state)) { + invariantViolated.set(true); + counterExampleState = state; + stopThreads.set(true); } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); + + if(nextStates.isEmpty()) { + deadlockDetected.set(true); + counterExampleState = state; + stopThreads.set(true); } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "in_requestTargetSocket_Granted"); + }; + threadPool.submit(task); + synchronized(waitLock) { + if (unvisitedStates.isEmpty() && possibleQueueChanges.get() > 0) { + try { + waitLock.wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } } } - result.add(copiedState); - transitions.getAndIncrement(); } - BSet<BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID>> _trid_13; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_in_requestTargetSocket_NotGranted"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_in_requestTargetSocket_NotGranted"); + threadPool.shutdown(); + try { + threadPool.awaitTermination(24, TimeUnit.HOURS); + } catch (InterruptedException e) { + e.printStackTrace(); } + printResult(states.size(), transitions.get()); + } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_13 = state._tr_in_requestTargetSocket_NotGranted(); - } else { - _trid_13 = (BSet<BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID>>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_in_requestTargetSocket_NotGranted", _trid_13); - for(BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID> param : _trid_13) { - SID _tmp_1 = param.projection2(); - BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID> _tmp_2 = param.projection1(); - SID _tmp_3 = _tmp_2.projection2(); - BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET> _tmp_4 = _tmp_2.projection1(); - SOCKET _tmp_5 = _tmp_4.projection2(); - BTuple<INTERCONNECTNODE, INTERCONNECTNODE> _tmp_6 = _tmp_4.projection1(); - INTERCONNECTNODE _tmp_7 = _tmp_6.projection2(); - INTERCONNECTNODE _tmp_8 = _tmp_6.projection1(); - - nota_v2 copiedState = state._copy(); - copiedState.in_requestTargetSocket_NotGranted(_tmp_8, _tmp_7, _tmp_5, _tmp_3, _tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("in_requestTargetSocket_NotGranted")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("in_requestTargetSocket_NotGranted")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "in_requestTargetSocket_NotGranted"); - } + private void initCache(final nota_v2 machine) { + invariantDependency.put("in_register_success", new HashSet<>(Arrays.asList("_check_inv_5", "_check_inv_14", "_check_inv_13", "_check_inv_8", "_check_inv_12", "_check_inv_9"))); + invariantDependency.put("in_announceResourceManager", new HashSet<>(Arrays.asList("_check_inv_11"))); + invariantDependency.put("in_requestTargetSocket_Granted", new HashSet<>(Arrays.asList("_check_inv_15", "_check_inv_2", "_check_inv_10", "_check_inv_13", "_check_inv_12"))); + invariantDependency.put("constructor_service", new HashSet<>(Arrays.asList("_check_inv_17", "_check_inv_16", "_check_inv_15", "_check_inv_3", "_check_inv_6", "_check_inv_14", "_check_inv_8"))); + invariantDependency.put("constructor_socket", new HashSet<>(Arrays.asList("_check_inv_15", "_check_inv_2", "_check_inv_10", "_check_inv_13", "_check_inv_12"))); + invariantDependency.put("in_requestTargetSocket_NotGranted", new HashSet<>(Arrays.asList())); + invariantDependency.put("constructor_interconnectNode", new HashSet<>(Arrays.asList("_check_inv_16", "_check_inv_1", "_check_inv_10", "_check_inv_9", "_check_inv_11"))); + invariantDependency.put("rm_getSid", new HashSet<>(Arrays.asList())); + invariantDependency.put("rm_deregister", new HashSet<>(Arrays.asList())); + invariantDependency.put("constructor_resourceManager", new HashSet<>(Arrays.asList("_check_inv_18", "_check_inv_6", "_check_inv_7", "_check_inv_4", "_check_inv_11"))); + invariantDependency.put("in_register_failed", new HashSet<>(Arrays.asList())); + invariantDependency.put("rm_register", new HashSet<>(Arrays.asList())); + invariantDependency.put("rm_getSid_Not_Found", new HashSet<>(Arrays.asList())); + invariantDependency.put("svc_register", new HashSet<>(Arrays.asList("_check_inv_17"))); + guardDependency.put("in_register_success", new HashSet<>(Arrays.asList("_tr_in_register_success", "_tr_in_requestTargetSocket_Granted", "_tr_in_requestTargetSocket_NotGranted", "_tr_constructor_socket"))); + guardDependency.put("in_announceResourceManager", new HashSet<>(Arrays.asList("_tr_in_announceResourceManager"))); + guardDependency.put("in_requestTargetSocket_Granted", new HashSet<>(Arrays.asList("_tr_in_requestTargetSocket_Granted", "_tr_in_requestTargetSocket_NotGranted", "_tr_constructor_socket"))); + guardDependency.put("constructor_service", new HashSet<>(Arrays.asList("_tr_constructor_service", "_tr_rm_getSid", "_tr_in_register_success", "_tr_svc_register", "_tr_in_register_failed", "_tr_rm_register", "_tr_rm_getSid_Not_Found", "_tr_rm_deregister"))); + guardDependency.put("constructor_socket", new HashSet<>(Arrays.asList("_tr_in_requestTargetSocket_Granted", "_tr_in_requestTargetSocket_NotGranted", "_tr_constructor_socket"))); + guardDependency.put("in_requestTargetSocket_NotGranted", new HashSet<>(Arrays.asList())); + guardDependency.put("constructor_interconnectNode", new HashSet<>(Arrays.asList("_tr_constructor_service", "_tr_in_register_success", "_tr_in_requestTargetSocket_Granted", "_tr_in_register_failed", "_tr_rm_register", "_tr_in_requestTargetSocket_NotGranted", "_tr_constructor_socket", "_tr_rm_deregister", "_tr_constructor_interconnectNode", "_tr_in_announceResourceManager"))); + guardDependency.put("rm_getSid", new HashSet<>(Arrays.asList())); + guardDependency.put("rm_deregister", new HashSet<>(Arrays.asList())); + guardDependency.put("constructor_resourceManager", new HashSet<>(Arrays.asList("_tr_rm_getSid", "_tr_constructor_resourceManager", "_tr_rm_register", "_tr_rm_getSid_Not_Found", "_tr_rm_deregister", "_tr_in_announceResourceManager"))); + guardDependency.put("in_register_failed", new HashSet<>(Arrays.asList())); + guardDependency.put("rm_register", new HashSet<>(Arrays.asList())); + guardDependency.put("rm_getSid_Not_Found", new HashSet<>(Arrays.asList())); + guardDependency.put("svc_register", new HashSet<>(Arrays.asList("_tr_svc_register"))); + } + + private nota_v2 next() { + synchronized(this.unvisitedStates) { + return switch(type) { + case BFS -> this.unvisitedStates.removeFirst(); + case DFS -> this.unvisitedStates.removeLast(); + case MIXED -> this.unvisitedStates.size() % 2 == 0 ? this.unvisitedStates.removeFirst() : this.unvisitedStates.removeLast(); + }; + } + } + + @SuppressWarnings("unchecked") + private Set<nota_v2> generateNextStates(final nota_v2 state) { + Set<nota_v2> result = new HashSet<>(); + if(isCaching) { + PersistentHashMap parentsGuard = state.guardCache; + PersistentHashMap newCache = parentsGuard == null ? PersistentHashMap.EMPTY : parentsGuard; + Object cachedValue = null; + boolean dependentGuardsBoolean = true; + BSet<INTERCONNECTNODE> _trid_1; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_constructor_interconnectNode"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_constructor_interconnectNode"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<SERVICE> _trid_14; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_svc_register"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_svc_register"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_14 = state._tr_svc_register(); - } else { - _trid_14 = (BSet<SERVICE>) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_svc_register", _trid_14); - for(SERVICE param : _trid_14) { - SERVICE _tmp_1 = param; - - nota_v2 copiedState = state._copy(); - copiedState.svc_register(_tmp_1); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("svc_register")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("svc_register")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "svc_register"); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_1 = state._tr_constructor_interconnectNode(); + } else { + _trid_1 = (BSet<INTERCONNECTNODE>) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_constructor_interconnectNode", _trid_1); + for(INTERCONNECTNODE param : _trid_1) { + INTERCONNECTNODE _tmp_1 = param; + + nota_v2 copiedState = state._copy(); + copiedState.constructor_interconnectNode(_tmp_1); + copiedState.parent = state; + addCachedInfos("constructor_interconnectNode", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - synchronized(guardLock) { - guardCache.put(state, newCache); - } - } else { - BSet<INTERCONNECTNODE> _trid_1 = state._tr_constructor_interconnectNode(); - for(INTERCONNECTNODE param : _trid_1) { - INTERCONNECTNODE _tmp_1 = param; - - nota_v2 copiedState = state._copy(); - copiedState.constructor_interconnectNode(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "constructor_interconnectNode"); - } } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<RESOURCEMANAGER> _trid_2 = state._tr_constructor_resourceManager(); - for(RESOURCEMANAGER param : _trid_2) { - RESOURCEMANAGER _tmp_1 = param; - - nota_v2 copiedState = state._copy(); - copiedState.constructor_resourceManager(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "constructor_resourceManager"); - } + BSet<RESOURCEMANAGER> _trid_2; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_constructor_resourceManager"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_constructor_resourceManager"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<INTERCONNECTNODE, SERVICE>> _trid_3 = state._tr_constructor_service(); - for(BTuple<INTERCONNECTNODE, SERVICE> param : _trid_3) { - SERVICE _tmp_1 = param.projection2(); - INTERCONNECTNODE _tmp_2 = param.projection1(); - - nota_v2 copiedState = state._copy(); - copiedState.constructor_service(_tmp_2, _tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "constructor_service"); - } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_2 = state._tr_constructor_resourceManager(); + } else { + _trid_2 = (BSet<RESOURCEMANAGER>) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<BTuple<BTuple<INTERCONNECTNODE, SID>, SID>, SOCKET>> _trid_4 = state._tr_constructor_socket(); - for(BTuple<BTuple<BTuple<INTERCONNECTNODE, SID>, SID>, SOCKET> param : _trid_4) { - SOCKET _tmp_1 = param.projection2(); - BTuple<BTuple<INTERCONNECTNODE, SID>, SID> _tmp_2 = param.projection1(); - SID _tmp_3 = _tmp_2.projection2(); - BTuple<INTERCONNECTNODE, SID> _tmp_4 = _tmp_2.projection1(); - SID _tmp_5 = _tmp_4.projection2(); - INTERCONNECTNODE _tmp_6 = _tmp_4.projection1(); - - nota_v2 copiedState = state._copy(); - copiedState.constructor_socket(_tmp_6, _tmp_5, _tmp_3, _tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "constructor_socket"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_constructor_resourceManager", _trid_2); + for(RESOURCEMANAGER param : _trid_2) { + RESOURCEMANAGER _tmp_1 = param; + + nota_v2 copiedState = state._copy(); + copiedState.constructor_resourceManager(_tmp_1); + copiedState.parent = state; + addCachedInfos("constructor_resourceManager", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<BTuple<RESOURCEMANAGER, SERVICE>, INTERCONNECTNODE>> _trid_5 = state._tr_rm_register(); - for(BTuple<BTuple<RESOURCEMANAGER, SERVICE>, INTERCONNECTNODE> param : _trid_5) { - INTERCONNECTNODE _tmp_1 = param.projection2(); - BTuple<RESOURCEMANAGER, SERVICE> _tmp_2 = param.projection1(); - SERVICE _tmp_3 = _tmp_2.projection2(); - RESOURCEMANAGER _tmp_4 = _tmp_2.projection1(); - - nota_v2 copiedState = state._copy(); - copiedState.rm_register(_tmp_4, _tmp_3, _tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "rm_register"); - } + BSet<BTuple<INTERCONNECTNODE, SERVICE>> _trid_3; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_constructor_service"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_constructor_service"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<BTuple<RESOURCEMANAGER, SERVICE>, INTERCONNECTNODE>> _trid_6 = state._tr_rm_deregister(); - for(BTuple<BTuple<RESOURCEMANAGER, SERVICE>, INTERCONNECTNODE> param : _trid_6) { - INTERCONNECTNODE _tmp_1 = param.projection2(); - BTuple<RESOURCEMANAGER, SERVICE> _tmp_2 = param.projection1(); - SERVICE _tmp_3 = _tmp_2.projection2(); - RESOURCEMANAGER _tmp_4 = _tmp_2.projection1(); - - nota_v2 copiedState = state._copy(); - copiedState.rm_deregister(_tmp_4, _tmp_3, _tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "rm_deregister"); - } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_3 = state._tr_constructor_service(); + } else { + _trid_3 = (BSet<BTuple<INTERCONNECTNODE, SERVICE>>) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<RESOURCEMANAGER, SERVICE>> _trid_7 = state._tr_rm_getSid(); - for(BTuple<RESOURCEMANAGER, SERVICE> param : _trid_7) { - SERVICE _tmp_1 = param.projection2(); - RESOURCEMANAGER _tmp_2 = param.projection1(); - - nota_v2 copiedState = state._copy(); - copiedState.rm_getSid(_tmp_2, _tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "rm_getSid"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_constructor_service", _trid_3); + for(BTuple<INTERCONNECTNODE, SERVICE> param : _trid_3) { + SERVICE _tmp_1 = param.projection2(); + INTERCONNECTNODE _tmp_2 = param.projection1(); + + nota_v2 copiedState = state._copy(); + copiedState.constructor_service(_tmp_2, _tmp_1); + copiedState.parent = state; + addCachedInfos("constructor_service", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<RESOURCEMANAGER, SERVICE>> _trid_8 = state._tr_rm_getSid_Not_Found(); - for(BTuple<RESOURCEMANAGER, SERVICE> param : _trid_8) { - SERVICE _tmp_1 = param.projection2(); - RESOURCEMANAGER _tmp_2 = param.projection1(); - - nota_v2 copiedState = state._copy(); - copiedState.rm_getSid_Not_Found(_tmp_2, _tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "rm_getSid_Not_Found"); - } + BSet<BTuple<BTuple<BTuple<INTERCONNECTNODE, SID>, SID>, SOCKET>> _trid_4; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_constructor_socket"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_constructor_socket"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<INTERCONNECTNODE, RESOURCEMANAGER>> _trid_9 = state._tr_in_announceResourceManager(); - for(BTuple<INTERCONNECTNODE, RESOURCEMANAGER> param : _trid_9) { - RESOURCEMANAGER _tmp_1 = param.projection2(); - INTERCONNECTNODE _tmp_2 = param.projection1(); - - nota_v2 copiedState = state._copy(); - copiedState.in_announceResourceManager(_tmp_2, _tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "in_announceResourceManager"); - } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_4 = state._tr_constructor_socket(); + } else { + _trid_4 = (BSet<BTuple<BTuple<BTuple<INTERCONNECTNODE, SID>, SID>, SOCKET>>) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<BTuple<INTERCONNECTNODE, SERVICE>, SID>> _trid_10 = state._tr_in_register_success(); - for(BTuple<BTuple<INTERCONNECTNODE, SERVICE>, SID> param : _trid_10) { - SID _tmp_1 = param.projection2(); - BTuple<INTERCONNECTNODE, SERVICE> _tmp_2 = param.projection1(); - SERVICE _tmp_3 = _tmp_2.projection2(); - INTERCONNECTNODE _tmp_4 = _tmp_2.projection1(); - - nota_v2 copiedState = state._copy(); - copiedState.in_register_success(_tmp_4, _tmp_3, _tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "in_register_success"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_constructor_socket", _trid_4); + for(BTuple<BTuple<BTuple<INTERCONNECTNODE, SID>, SID>, SOCKET> param : _trid_4) { + SOCKET _tmp_1 = param.projection2(); + BTuple<BTuple<INTERCONNECTNODE, SID>, SID> _tmp_2 = param.projection1(); + SID _tmp_3 = _tmp_2.projection2(); + BTuple<INTERCONNECTNODE, SID> _tmp_4 = _tmp_2.projection1(); + SID _tmp_5 = _tmp_4.projection2(); + INTERCONNECTNODE _tmp_6 = _tmp_4.projection1(); + + nota_v2 copiedState = state._copy(); + copiedState.constructor_socket(_tmp_6, _tmp_5, _tmp_3, _tmp_1); + copiedState.parent = state; + addCachedInfos("constructor_socket", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<INTERCONNECTNODE, SERVICE>> _trid_11 = state._tr_in_register_failed(); - for(BTuple<INTERCONNECTNODE, SERVICE> param : _trid_11) { - SERVICE _tmp_1 = param.projection2(); - INTERCONNECTNODE _tmp_2 = param.projection1(); - - nota_v2 copiedState = state._copy(); - copiedState.in_register_failed(_tmp_2, _tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "in_register_failed"); - } + BSet<BTuple<BTuple<RESOURCEMANAGER, SERVICE>, INTERCONNECTNODE>> _trid_5; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_rm_register"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_rm_register"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID>, SOCKET>> _trid_12 = state._tr_in_requestTargetSocket_Granted(); - for(BTuple<BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID>, SOCKET> param : _trid_12) { - SOCKET _tmp_1 = param.projection2(); - BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID> _tmp_2 = param.projection1(); - SID _tmp_3 = _tmp_2.projection2(); - BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID> _tmp_4 = _tmp_2.projection1(); - SID _tmp_5 = _tmp_4.projection2(); - BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET> _tmp_6 = _tmp_4.projection1(); - SOCKET _tmp_7 = _tmp_6.projection2(); - BTuple<INTERCONNECTNODE, INTERCONNECTNODE> _tmp_8 = _tmp_6.projection1(); - INTERCONNECTNODE _tmp_9 = _tmp_8.projection2(); - INTERCONNECTNODE _tmp_10 = _tmp_8.projection1(); - - nota_v2 copiedState = state._copy(); - copiedState.in_requestTargetSocket_Granted(_tmp_10, _tmp_9, _tmp_7, _tmp_5, _tmp_3, _tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "in_requestTargetSocket_Granted"); - } + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_5 = state._tr_rm_register(); + } else { + _trid_5 = (BSet<BTuple<BTuple<RESOURCEMANAGER, SERVICE>, INTERCONNECTNODE>>) cachedValue; } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID>> _trid_13 = state._tr_in_requestTargetSocket_NotGranted(); - for(BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID> param : _trid_13) { - SID _tmp_1 = param.projection2(); - BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID> _tmp_2 = param.projection1(); - SID _tmp_3 = _tmp_2.projection2(); - BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET> _tmp_4 = _tmp_2.projection1(); - SOCKET _tmp_5 = _tmp_4.projection2(); - BTuple<INTERCONNECTNODE, INTERCONNECTNODE> _tmp_6 = _tmp_4.projection1(); - INTERCONNECTNODE _tmp_7 = _tmp_6.projection2(); - INTERCONNECTNODE _tmp_8 = _tmp_6.projection1(); - - nota_v2 copiedState = state._copy(); - copiedState.in_requestTargetSocket_NotGranted(_tmp_8, _tmp_7, _tmp_5, _tmp_3, _tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "in_requestTargetSocket_NotGranted"); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_rm_register", _trid_5); + for(BTuple<BTuple<RESOURCEMANAGER, SERVICE>, INTERCONNECTNODE> param : _trid_5) { + INTERCONNECTNODE _tmp_1 = param.projection2(); + BTuple<RESOURCEMANAGER, SERVICE> _tmp_2 = param.projection1(); + SERVICE _tmp_3 = _tmp_2.projection2(); + RESOURCEMANAGER _tmp_4 = _tmp_2.projection1(); + + nota_v2 copiedState = state._copy(); + copiedState.rm_register(_tmp_4, _tmp_3, _tmp_1); + copiedState.parent = state; + addCachedInfos("rm_register", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - result.add(copiedState); - transitions.getAndIncrement(); - } - BSet<SERVICE> _trid_14 = state._tr_svc_register(); - for(SERVICE param : _trid_14) { - SERVICE _tmp_1 = param; - - nota_v2 copiedState = state._copy(); - copiedState.svc_register(_tmp_1); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "svc_register"); - } + BSet<BTuple<BTuple<RESOURCEMANAGER, SERVICE>, INTERCONNECTNODE>> _trid_6; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_rm_deregister"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_rm_deregister"); } - result.add(copiedState); - transitions.getAndIncrement(); - } - - } - return result; - } - - public static boolean checkInvariants(Object guardLock, nota_v2 state, boolean isCaching, Map<nota_v2, Set<String>> dependentInvariant) { - if(isCaching) { - Set<String> dependentInvariantsOfState; - synchronized(guardLock) { - dependentInvariantsOfState = dependentInvariant.get(state); - } - if(dependentInvariantsOfState.contains("_check_inv_1")) { - if(!state._check_inv_1()) { - return false; + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_6 = state._tr_rm_deregister(); + } else { + _trid_6 = (BSet<BTuple<BTuple<RESOURCEMANAGER, SERVICE>, INTERCONNECTNODE>>) cachedValue; } - } - if(dependentInvariantsOfState.contains("_check_inv_2")) { - if(!state._check_inv_2()) { - return false; + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_rm_deregister", _trid_6); + for(BTuple<BTuple<RESOURCEMANAGER, SERVICE>, INTERCONNECTNODE> param : _trid_6) { + INTERCONNECTNODE _tmp_1 = param.projection2(); + BTuple<RESOURCEMANAGER, SERVICE> _tmp_2 = param.projection1(); + SERVICE _tmp_3 = _tmp_2.projection2(); + RESOURCEMANAGER _tmp_4 = _tmp_2.projection1(); + + nota_v2 copiedState = state._copy(); + copiedState.rm_deregister(_tmp_4, _tmp_3, _tmp_1); + copiedState.parent = state; + addCachedInfos("rm_deregister", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - } - if(dependentInvariantsOfState.contains("_check_inv_3")) { - if(!state._check_inv_3()) { - return false; + BSet<BTuple<RESOURCEMANAGER, SERVICE>> _trid_7; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_rm_getSid"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_rm_getSid"); } - } - if(dependentInvariantsOfState.contains("_check_inv_4")) { - if(!state._check_inv_4()) { - return false; + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_7 = state._tr_rm_getSid(); + } else { + _trid_7 = (BSet<BTuple<RESOURCEMANAGER, SERVICE>>) cachedValue; } - } - if(dependentInvariantsOfState.contains("_check_inv_5")) { - if(!state._check_inv_5()) { - return false; + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_rm_getSid", _trid_7); + for(BTuple<RESOURCEMANAGER, SERVICE> param : _trid_7) { + SERVICE _tmp_1 = param.projection2(); + RESOURCEMANAGER _tmp_2 = param.projection1(); + + nota_v2 copiedState = state._copy(); + copiedState.rm_getSid(_tmp_2, _tmp_1); + copiedState.parent = state; + addCachedInfos("rm_getSid", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - } - if(dependentInvariantsOfState.contains("_check_inv_6")) { - if(!state._check_inv_6()) { - return false; + BSet<BTuple<RESOURCEMANAGER, SERVICE>> _trid_8; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_rm_getSid_Not_Found"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_rm_getSid_Not_Found"); } - } - if(dependentInvariantsOfState.contains("_check_inv_7")) { - if(!state._check_inv_7()) { - return false; + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_8 = state._tr_rm_getSid_Not_Found(); + } else { + _trid_8 = (BSet<BTuple<RESOURCEMANAGER, SERVICE>>) cachedValue; } - } - if(dependentInvariantsOfState.contains("_check_inv_8")) { - if(!state._check_inv_8()) { - return false; + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_rm_getSid_Not_Found", _trid_8); + for(BTuple<RESOURCEMANAGER, SERVICE> param : _trid_8) { + SERVICE _tmp_1 = param.projection2(); + RESOURCEMANAGER _tmp_2 = param.projection1(); + + nota_v2 copiedState = state._copy(); + copiedState.rm_getSid_Not_Found(_tmp_2, _tmp_1); + copiedState.parent = state; + addCachedInfos("rm_getSid_Not_Found", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - } - if(dependentInvariantsOfState.contains("_check_inv_9")) { - if(!state._check_inv_9()) { - return false; + BSet<BTuple<INTERCONNECTNODE, RESOURCEMANAGER>> _trid_9; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_in_announceResourceManager"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_in_announceResourceManager"); } - } - if(dependentInvariantsOfState.contains("_check_inv_10")) { - if(!state._check_inv_10()) { - return false; + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_9 = state._tr_in_announceResourceManager(); + } else { + _trid_9 = (BSet<BTuple<INTERCONNECTNODE, RESOURCEMANAGER>>) cachedValue; } - } - if(dependentInvariantsOfState.contains("_check_inv_11")) { - if(!state._check_inv_11()) { - return false; + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_in_announceResourceManager", _trid_9); + for(BTuple<INTERCONNECTNODE, RESOURCEMANAGER> param : _trid_9) { + RESOURCEMANAGER _tmp_1 = param.projection2(); + INTERCONNECTNODE _tmp_2 = param.projection1(); + + nota_v2 copiedState = state._copy(); + copiedState.in_announceResourceManager(_tmp_2, _tmp_1); + copiedState.parent = state; + addCachedInfos("in_announceResourceManager", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - } - if(dependentInvariantsOfState.contains("_check_inv_12")) { - if(!state._check_inv_12()) { - return false; + BSet<BTuple<BTuple<INTERCONNECTNODE, SERVICE>, SID>> _trid_10; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_in_register_success"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_in_register_success"); } - } - if(dependentInvariantsOfState.contains("_check_inv_13")) { - if(!state._check_inv_13()) { - return false; + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_10 = state._tr_in_register_success(); + } else { + _trid_10 = (BSet<BTuple<BTuple<INTERCONNECTNODE, SERVICE>, SID>>) cachedValue; } - } - if(dependentInvariantsOfState.contains("_check_inv_14")) { - if(!state._check_inv_14()) { - return false; + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_in_register_success", _trid_10); + for(BTuple<BTuple<INTERCONNECTNODE, SERVICE>, SID> param : _trid_10) { + SID _tmp_1 = param.projection2(); + BTuple<INTERCONNECTNODE, SERVICE> _tmp_2 = param.projection1(); + SERVICE _tmp_3 = _tmp_2.projection2(); + INTERCONNECTNODE _tmp_4 = _tmp_2.projection1(); + + nota_v2 copiedState = state._copy(); + copiedState.in_register_success(_tmp_4, _tmp_3, _tmp_1); + copiedState.parent = state; + addCachedInfos("in_register_success", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - } - if(dependentInvariantsOfState.contains("_check_inv_15")) { - if(!state._check_inv_15()) { - return false; + BSet<BTuple<INTERCONNECTNODE, SERVICE>> _trid_11; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_in_register_failed"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_in_register_failed"); } - } - if(dependentInvariantsOfState.contains("_check_inv_16")) { - if(!state._check_inv_16()) { - return false; + + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_11 = state._tr_in_register_failed(); + } else { + _trid_11 = (BSet<BTuple<INTERCONNECTNODE, SERVICE>>) cachedValue; } - } - if(dependentInvariantsOfState.contains("_check_inv_17")) { - if(!state._check_inv_17()) { - return false; + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_in_register_failed", _trid_11); + for(BTuple<INTERCONNECTNODE, SERVICE> param : _trid_11) { + SERVICE _tmp_1 = param.projection2(); + INTERCONNECTNODE _tmp_2 = param.projection1(); + + nota_v2 copiedState = state._copy(); + copiedState.in_register_failed(_tmp_2, _tmp_1); + copiedState.parent = state; + addCachedInfos("in_register_failed", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - } - if(dependentInvariantsOfState.contains("_check_inv_18")) { - if(!state._check_inv_18()) { - return false; + BSet<BTuple<BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID>, SOCKET>> _trid_12; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_in_requestTargetSocket_Granted"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_in_requestTargetSocket_Granted"); } - } - return true; - } - return !(!state._check_inv_1() || !state._check_inv_2() || !state._check_inv_3() || !state._check_inv_4() || !state._check_inv_5() || !state._check_inv_6() || !state._check_inv_7() || !state._check_inv_8() || !state._check_inv_9() || !state._check_inv_10() || !state._check_inv_11() || !state._check_inv_12() || !state._check_inv_13() || !state._check_inv_14() || !state._check_inv_15() || !state._check_inv_16() || !state._check_inv_17() || !state._check_inv_18()); - } - private static void printResult(int states, int transitions, boolean deadlockDetected, boolean invariantViolated, List<nota_v2> counterExampleState, Map<nota_v2, nota_v2> parents, Map<nota_v2, String> stateAccessedVia) { + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_12 = state._tr_in_requestTargetSocket_Granted(); + } else { + _trid_12 = (BSet<BTuple<BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID>, SOCKET>>) cachedValue; + } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_in_requestTargetSocket_Granted", _trid_12); + for(BTuple<BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID>, SOCKET> param : _trid_12) { + SOCKET _tmp_1 = param.projection2(); + BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID> _tmp_2 = param.projection1(); + SID _tmp_3 = _tmp_2.projection2(); + BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID> _tmp_4 = _tmp_2.projection1(); + SID _tmp_5 = _tmp_4.projection2(); + BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET> _tmp_6 = _tmp_4.projection1(); + SOCKET _tmp_7 = _tmp_6.projection2(); + BTuple<INTERCONNECTNODE, INTERCONNECTNODE> _tmp_8 = _tmp_6.projection1(); + INTERCONNECTNODE _tmp_9 = _tmp_8.projection2(); + INTERCONNECTNODE _tmp_10 = _tmp_8.projection1(); + + nota_v2 copiedState = state._copy(); + copiedState.in_requestTargetSocket_Granted(_tmp_10, _tmp_9, _tmp_7, _tmp_5, _tmp_3, _tmp_1); + copiedState.parent = state; + addCachedInfos("in_requestTargetSocket_Granted", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - if(invariantViolated || deadlockDetected) { - if(deadlockDetected) { - System.out.println("DEADLOCK DETECTED"); - } - if(invariantViolated) { - System.out.println("INVARIANT VIOLATED"); - } - System.out.println("COUNTER EXAMPLE TRACE: "); - StringBuilder sb = new StringBuilder(); - if(counterExampleState.size() >= 1) { - nota_v2 currentState = counterExampleState.get(0); - while(currentState != null) { - sb.insert(0, currentState.toString()); - sb.insert(0, "\n"); - sb.insert(0, stateAccessedVia.get(currentState)); - sb.insert(0, "\n\n"); - currentState = parents.get(currentState); } - } - System.out.println(sb.toString()); + BSet<BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID>> _trid_13; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_in_requestTargetSocket_NotGranted"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_in_requestTargetSocket_NotGranted"); + } - } - if(!deadlockDetected && !invariantViolated) { - System.out.println("MODEL CHECKING SUCCESSFUL"); - } - System.out.println("Number of States: " + states); - System.out.println("Number of Transitions: " + transitions); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_13 = state._tr_in_requestTargetSocket_NotGranted(); + } else { + _trid_13 = (BSet<BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID>>) cachedValue; + } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_in_requestTargetSocket_NotGranted", _trid_13); + for(BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID> param : _trid_13) { + SID _tmp_1 = param.projection2(); + BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID> _tmp_2 = param.projection1(); + SID _tmp_3 = _tmp_2.projection2(); + BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET> _tmp_4 = _tmp_2.projection1(); + SOCKET _tmp_5 = _tmp_4.projection2(); + BTuple<INTERCONNECTNODE, INTERCONNECTNODE> _tmp_6 = _tmp_4.projection1(); + INTERCONNECTNODE _tmp_7 = _tmp_6.projection2(); + INTERCONNECTNODE _tmp_8 = _tmp_6.projection1(); + + nota_v2 copiedState = state._copy(); + copiedState.in_requestTargetSocket_NotGranted(_tmp_8, _tmp_7, _tmp_5, _tmp_3, _tmp_1); + copiedState.parent = state; + addCachedInfos("in_requestTargetSocket_NotGranted", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - private static nota_v2 next(LinkedList<nota_v2> collection, Object lock, Type type) { - synchronized(lock) { - return switch(type) { - case BFS -> collection.removeFirst(); - case DFS -> collection.removeLast(); - case MIXED -> collection.size() % 2 == 0 ? collection.removeFirst() : collection.removeLast(); - }; - } - } + } + BSet<SERVICE> _trid_14; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_svc_register"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_svc_register"); + } - private static void modelCheckSingleThreaded(Type type, boolean isCaching, boolean isDebug) { - Object lock = new Object(); - Object guardLock = new Object(); + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_14 = state._tr_svc_register(); + } else { + _trid_14 = (BSet<SERVICE>) cachedValue; + } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_svc_register", _trid_14); + for(SERVICE param : _trid_14) { + SERVICE _tmp_1 = param; - nota_v2 machine = new nota_v2(); + nota_v2 copiedState = state._copy(); + copiedState.svc_register(_tmp_1); + copiedState.parent = state; + addCachedInfos("svc_register", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } - AtomicBoolean invariantViolated = new AtomicBoolean(false); - AtomicBoolean deadlockDetected = new AtomicBoolean(false); - AtomicBoolean stopThreads = new AtomicBoolean(false); + state.guardCache = newCache; + } else { + BSet<INTERCONNECTNODE> _trid_1 = state._tr_constructor_interconnectNode(); + for(INTERCONNECTNODE param : _trid_1) { + INTERCONNECTNODE _tmp_1 = param; - Set<nota_v2> states = new HashSet<>(); - states.add(machine); - AtomicInteger numberStates = new AtomicInteger(1); + nota_v2 copiedState = state._copy(); + copiedState.constructor_interconnectNode(_tmp_1); + copiedState.parent = state; + addCachedInfos("constructor_interconnectNode", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - LinkedList<nota_v2> collection = new LinkedList<>(); - collection.add(machine); + } + BSet<RESOURCEMANAGER> _trid_2 = state._tr_constructor_resourceManager(); + for(RESOURCEMANAGER param : _trid_2) { + RESOURCEMANAGER _tmp_1 = param; - Map<String, Set<String>> invariantDependency = new HashMap<>(); - Map<String, Set<String>> guardDependency = new HashMap<>(); - Map<nota_v2, Set<String>> dependentInvariant = new HashMap<>(); - Map<nota_v2, Set<String>> dependentGuard = new HashMap<>(); - Map<nota_v2, PersistentHashMap> guardCache = new HashMap<>(); - Map<nota_v2, nota_v2> parents = new HashMap<>(); - Map<nota_v2, String> stateAccessedVia = new HashMap<>(); - if(isCaching) { - invariantDependency.put("in_register_success", new HashSet<>(Arrays.asList("_check_inv_5", "_check_inv_14", "_check_inv_13", "_check_inv_8", "_check_inv_12", "_check_inv_9"))); - invariantDependency.put("in_announceResourceManager", new HashSet<>(Arrays.asList("_check_inv_11"))); - invariantDependency.put("in_requestTargetSocket_Granted", new HashSet<>(Arrays.asList("_check_inv_15", "_check_inv_2", "_check_inv_10", "_check_inv_13", "_check_inv_12"))); - invariantDependency.put("constructor_service", new HashSet<>(Arrays.asList("_check_inv_17", "_check_inv_16", "_check_inv_15", "_check_inv_3", "_check_inv_6", "_check_inv_14", "_check_inv_8"))); - invariantDependency.put("constructor_socket", new HashSet<>(Arrays.asList("_check_inv_15", "_check_inv_2", "_check_inv_10", "_check_inv_13", "_check_inv_12"))); - invariantDependency.put("in_requestTargetSocket_NotGranted", new HashSet<>(Arrays.asList())); - invariantDependency.put("constructor_interconnectNode", new HashSet<>(Arrays.asList("_check_inv_16", "_check_inv_1", "_check_inv_10", "_check_inv_9", "_check_inv_11"))); - invariantDependency.put("rm_getSid", new HashSet<>(Arrays.asList())); - invariantDependency.put("rm_deregister", new HashSet<>(Arrays.asList())); - invariantDependency.put("constructor_resourceManager", new HashSet<>(Arrays.asList("_check_inv_18", "_check_inv_6", "_check_inv_7", "_check_inv_4", "_check_inv_11"))); - invariantDependency.put("in_register_failed", new HashSet<>(Arrays.asList())); - invariantDependency.put("rm_register", new HashSet<>(Arrays.asList())); - invariantDependency.put("rm_getSid_Not_Found", new HashSet<>(Arrays.asList())); - invariantDependency.put("svc_register", new HashSet<>(Arrays.asList("_check_inv_17"))); - guardDependency.put("in_register_success", new HashSet<>(Arrays.asList("_tr_in_register_success", "_tr_in_requestTargetSocket_Granted", "_tr_in_requestTargetSocket_NotGranted", "_tr_constructor_socket"))); - guardDependency.put("in_announceResourceManager", new HashSet<>(Arrays.asList("_tr_in_announceResourceManager"))); - guardDependency.put("in_requestTargetSocket_Granted", new HashSet<>(Arrays.asList("_tr_in_requestTargetSocket_Granted", "_tr_in_requestTargetSocket_NotGranted", "_tr_constructor_socket"))); - guardDependency.put("constructor_service", new HashSet<>(Arrays.asList("_tr_constructor_service", "_tr_rm_getSid", "_tr_in_register_success", "_tr_svc_register", "_tr_in_register_failed", "_tr_rm_register", "_tr_rm_getSid_Not_Found", "_tr_rm_deregister"))); - guardDependency.put("constructor_socket", new HashSet<>(Arrays.asList("_tr_in_requestTargetSocket_Granted", "_tr_in_requestTargetSocket_NotGranted", "_tr_constructor_socket"))); - guardDependency.put("in_requestTargetSocket_NotGranted", new HashSet<>(Arrays.asList())); - guardDependency.put("constructor_interconnectNode", new HashSet<>(Arrays.asList("_tr_constructor_service", "_tr_in_register_success", "_tr_in_requestTargetSocket_Granted", "_tr_in_register_failed", "_tr_rm_register", "_tr_in_requestTargetSocket_NotGranted", "_tr_constructor_socket", "_tr_rm_deregister", "_tr_constructor_interconnectNode", "_tr_in_announceResourceManager"))); - guardDependency.put("rm_getSid", new HashSet<>(Arrays.asList())); - guardDependency.put("rm_deregister", new HashSet<>(Arrays.asList())); - guardDependency.put("constructor_resourceManager", new HashSet<>(Arrays.asList("_tr_rm_getSid", "_tr_constructor_resourceManager", "_tr_rm_register", "_tr_rm_getSid_Not_Found", "_tr_rm_deregister", "_tr_in_announceResourceManager"))); - guardDependency.put("in_register_failed", new HashSet<>(Arrays.asList())); - guardDependency.put("rm_register", new HashSet<>(Arrays.asList())); - guardDependency.put("rm_getSid_Not_Found", new HashSet<>(Arrays.asList())); - guardDependency.put("svc_register", new HashSet<>(Arrays.asList("_tr_svc_register"))); - dependentInvariant.put(machine, new HashSet<>()); - } - List<nota_v2> counterExampleState = new ArrayList<>(); - parents.put(machine, null); + nota_v2 copiedState = state._copy(); + copiedState.constructor_resourceManager(_tmp_1); + copiedState.parent = state; + addCachedInfos("constructor_resourceManager", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - AtomicInteger transitions = new AtomicInteger(0); + } + BSet<BTuple<INTERCONNECTNODE, SERVICE>> _trid_3 = state._tr_constructor_service(); + for(BTuple<INTERCONNECTNODE, SERVICE> param : _trid_3) { + SERVICE _tmp_1 = param.projection2(); + INTERCONNECTNODE _tmp_2 = param.projection1(); + + nota_v2 copiedState = state._copy(); + copiedState.constructor_service(_tmp_2, _tmp_1); + copiedState.parent = state; + addCachedInfos("constructor_service", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - while(!collection.isEmpty() && !stopThreads.get()) { - nota_v2 state = next(collection, lock, type); + } + BSet<BTuple<BTuple<BTuple<INTERCONNECTNODE, SID>, SID>, SOCKET>> _trid_4 = state._tr_constructor_socket(); + for(BTuple<BTuple<BTuple<INTERCONNECTNODE, SID>, SID>, SOCKET> param : _trid_4) { + SOCKET _tmp_1 = param.projection2(); + BTuple<BTuple<INTERCONNECTNODE, SID>, SID> _tmp_2 = param.projection1(); + SID _tmp_3 = _tmp_2.projection2(); + BTuple<INTERCONNECTNODE, SID> _tmp_4 = _tmp_2.projection1(); + SID _tmp_5 = _tmp_4.projection2(); + INTERCONNECTNODE _tmp_6 = _tmp_4.projection1(); + + nota_v2 copiedState = state._copy(); + copiedState.constructor_socket(_tmp_6, _tmp_5, _tmp_3, _tmp_1); + copiedState.parent = state; + addCachedInfos("constructor_socket", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - Set<nota_v2> nextStates = generateNextStates(guardLock, state, isCaching, invariantDependency, dependentInvariant, guardDependency, dependentGuard, guardCache, parents, stateAccessedVia, transitions); + } + BSet<BTuple<BTuple<RESOURCEMANAGER, SERVICE>, INTERCONNECTNODE>> _trid_5 = state._tr_rm_register(); + for(BTuple<BTuple<RESOURCEMANAGER, SERVICE>, INTERCONNECTNODE> param : _trid_5) { + INTERCONNECTNODE _tmp_1 = param.projection2(); + BTuple<RESOURCEMANAGER, SERVICE> _tmp_2 = param.projection1(); + SERVICE _tmp_3 = _tmp_2.projection2(); + RESOURCEMANAGER _tmp_4 = _tmp_2.projection1(); + + nota_v2 copiedState = state._copy(); + copiedState.rm_register(_tmp_4, _tmp_3, _tmp_1); + copiedState.parent = state; + addCachedInfos("rm_register", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - nextStates.forEach(nextState -> { - if(!states.contains(nextState)) { - numberStates.getAndIncrement(); - states.add(nextState); - collection.add(nextState); - if(numberStates.get() % 5000 == 0) { - System.out.println("VISITED STATES: " + numberStates.get()); - System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); - System.out.println("-------------------"); - } } - }); + BSet<BTuple<BTuple<RESOURCEMANAGER, SERVICE>, INTERCONNECTNODE>> _trid_6 = state._tr_rm_deregister(); + for(BTuple<BTuple<RESOURCEMANAGER, SERVICE>, INTERCONNECTNODE> param : _trid_6) { + INTERCONNECTNODE _tmp_1 = param.projection2(); + BTuple<RESOURCEMANAGER, SERVICE> _tmp_2 = param.projection1(); + SERVICE _tmp_3 = _tmp_2.projection2(); + RESOURCEMANAGER _tmp_4 = _tmp_2.projection1(); + + nota_v2 copiedState = state._copy(); + copiedState.rm_deregister(_tmp_4, _tmp_3, _tmp_1); + copiedState.parent = state; + addCachedInfos("rm_deregister", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - if(!checkInvariants(guardLock, state, isCaching, dependentInvariant)) { - invariantViolated.set(true); - stopThreads.set(true); - counterExampleState.add(state); - } + } + BSet<BTuple<RESOURCEMANAGER, SERVICE>> _trid_7 = state._tr_rm_getSid(); + for(BTuple<RESOURCEMANAGER, SERVICE> param : _trid_7) { + SERVICE _tmp_1 = param.projection2(); + RESOURCEMANAGER _tmp_2 = param.projection1(); + + nota_v2 copiedState = state._copy(); + copiedState.rm_getSid(_tmp_2, _tmp_1); + copiedState.parent = state; + addCachedInfos("rm_getSid", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - if(nextStates.isEmpty()) { - deadlockDetected.set(true); - stopThreads.set(true); - } + } + BSet<BTuple<RESOURCEMANAGER, SERVICE>> _trid_8 = state._tr_rm_getSid_Not_Found(); + for(BTuple<RESOURCEMANAGER, SERVICE> param : _trid_8) { + SERVICE _tmp_1 = param.projection2(); + RESOURCEMANAGER _tmp_2 = param.projection1(); + + nota_v2 copiedState = state._copy(); + copiedState.rm_getSid_Not_Found(_tmp_2, _tmp_1); + copiedState.parent = state; + addCachedInfos("rm_getSid_Not_Found", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - } - printResult(numberStates.get(), transitions.get(), deadlockDetected.get(), invariantViolated.get(), counterExampleState, parents, stateAccessedVia); - } + } + BSet<BTuple<INTERCONNECTNODE, RESOURCEMANAGER>> _trid_9 = state._tr_in_announceResourceManager(); + for(BTuple<INTERCONNECTNODE, RESOURCEMANAGER> param : _trid_9) { + RESOURCEMANAGER _tmp_1 = param.projection2(); + INTERCONNECTNODE _tmp_2 = param.projection1(); + + nota_v2 copiedState = state._copy(); + copiedState.in_announceResourceManager(_tmp_2, _tmp_1); + copiedState.parent = state; + addCachedInfos("in_announceResourceManager", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } + BSet<BTuple<BTuple<INTERCONNECTNODE, SERVICE>, SID>> _trid_10 = state._tr_in_register_success(); + for(BTuple<BTuple<INTERCONNECTNODE, SERVICE>, SID> param : _trid_10) { + SID _tmp_1 = param.projection2(); + BTuple<INTERCONNECTNODE, SERVICE> _tmp_2 = param.projection1(); + SERVICE _tmp_3 = _tmp_2.projection2(); + INTERCONNECTNODE _tmp_4 = _tmp_2.projection1(); + + nota_v2 copiedState = state._copy(); + copiedState.in_register_success(_tmp_4, _tmp_3, _tmp_1); + copiedState.parent = state; + addCachedInfos("in_register_success", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - private static void modelCheckMultiThreaded(Type type, int threads, boolean isCaching, boolean isDebug) { - Object lock = new Object(); - Object guardLock = new Object(); - Object waitLock = new Object(); - ThreadPoolExecutor threadPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(threads); + } + BSet<BTuple<INTERCONNECTNODE, SERVICE>> _trid_11 = state._tr_in_register_failed(); + for(BTuple<INTERCONNECTNODE, SERVICE> param : _trid_11) { + SERVICE _tmp_1 = param.projection2(); + INTERCONNECTNODE _tmp_2 = param.projection1(); + + nota_v2 copiedState = state._copy(); + copiedState.in_register_failed(_tmp_2, _tmp_1); + copiedState.parent = state; + addCachedInfos("in_register_failed", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - nota_v2 machine = new nota_v2(); + } + BSet<BTuple<BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID>, SOCKET>> _trid_12 = state._tr_in_requestTargetSocket_Granted(); + for(BTuple<BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID>, SOCKET> param : _trid_12) { + SOCKET _tmp_1 = param.projection2(); + BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID> _tmp_2 = param.projection1(); + SID _tmp_3 = _tmp_2.projection2(); + BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID> _tmp_4 = _tmp_2.projection1(); + SID _tmp_5 = _tmp_4.projection2(); + BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET> _tmp_6 = _tmp_4.projection1(); + SOCKET _tmp_7 = _tmp_6.projection2(); + BTuple<INTERCONNECTNODE, INTERCONNECTNODE> _tmp_8 = _tmp_6.projection1(); + INTERCONNECTNODE _tmp_9 = _tmp_8.projection2(); + INTERCONNECTNODE _tmp_10 = _tmp_8.projection1(); + + nota_v2 copiedState = state._copy(); + copiedState.in_requestTargetSocket_Granted(_tmp_10, _tmp_9, _tmp_7, _tmp_5, _tmp_3, _tmp_1); + copiedState.parent = state; + addCachedInfos("in_requestTargetSocket_Granted", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); + } + BSet<BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID>> _trid_13 = state._tr_in_requestTargetSocket_NotGranted(); + for(BTuple<BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID>, SID> param : _trid_13) { + SID _tmp_1 = param.projection2(); + BTuple<BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET>, SID> _tmp_2 = param.projection1(); + SID _tmp_3 = _tmp_2.projection2(); + BTuple<BTuple<INTERCONNECTNODE, INTERCONNECTNODE>, SOCKET> _tmp_4 = _tmp_2.projection1(); + SOCKET _tmp_5 = _tmp_4.projection2(); + BTuple<INTERCONNECTNODE, INTERCONNECTNODE> _tmp_6 = _tmp_4.projection1(); + INTERCONNECTNODE _tmp_7 = _tmp_6.projection2(); + INTERCONNECTNODE _tmp_8 = _tmp_6.projection1(); + + nota_v2 copiedState = state._copy(); + copiedState.in_requestTargetSocket_NotGranted(_tmp_8, _tmp_7, _tmp_5, _tmp_3, _tmp_1); + copiedState.parent = state; + addCachedInfos("in_requestTargetSocket_NotGranted", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - AtomicBoolean invariantViolated = new AtomicBoolean(false); - AtomicBoolean deadlockDetected = new AtomicBoolean(false); - AtomicBoolean stopThreads = new AtomicBoolean(false); - AtomicInteger possibleQueueChanges = new AtomicInteger(0); + } + BSet<SERVICE> _trid_14 = state._tr_svc_register(); + for(SERVICE param : _trid_14) { + SERVICE _tmp_1 = param; - Set<nota_v2> states = new HashSet<>(); - states.add(machine); - AtomicInteger numberStates = new AtomicInteger(1); + nota_v2 copiedState = state._copy(); + copiedState.svc_register(_tmp_1); + copiedState.parent = state; + addCachedInfos("svc_register", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - LinkedList<nota_v2> collection = new LinkedList<>(); - collection.add(machine); + } - Map<String, Set<String>> invariantDependency = new HashMap<>(); - Map<String, Set<String>> guardDependency = new HashMap<>(); - Map<nota_v2, Set<String>> dependentInvariant = new HashMap<>(); - Map<nota_v2, Set<String>> dependentGuard = new HashMap<>(); - Map<nota_v2, PersistentHashMap> guardCache = new HashMap<>(); - Map<nota_v2, nota_v2> parents = new HashMap<>(); - Map<nota_v2, String> stateAccessedVia = new HashMap<>(); - if(isCaching) { - invariantDependency.put("in_register_success", new HashSet<>(Arrays.asList("_check_inv_5", "_check_inv_14", "_check_inv_13", "_check_inv_8", "_check_inv_12", "_check_inv_9"))); - invariantDependency.put("in_announceResourceManager", new HashSet<>(Arrays.asList("_check_inv_11"))); - invariantDependency.put("in_requestTargetSocket_Granted", new HashSet<>(Arrays.asList("_check_inv_15", "_check_inv_2", "_check_inv_10", "_check_inv_13", "_check_inv_12"))); - invariantDependency.put("constructor_service", new HashSet<>(Arrays.asList("_check_inv_17", "_check_inv_16", "_check_inv_15", "_check_inv_3", "_check_inv_6", "_check_inv_14", "_check_inv_8"))); - invariantDependency.put("constructor_socket", new HashSet<>(Arrays.asList("_check_inv_15", "_check_inv_2", "_check_inv_10", "_check_inv_13", "_check_inv_12"))); - invariantDependency.put("in_requestTargetSocket_NotGranted", new HashSet<>(Arrays.asList())); - invariantDependency.put("constructor_interconnectNode", new HashSet<>(Arrays.asList("_check_inv_16", "_check_inv_1", "_check_inv_10", "_check_inv_9", "_check_inv_11"))); - invariantDependency.put("rm_getSid", new HashSet<>(Arrays.asList())); - invariantDependency.put("rm_deregister", new HashSet<>(Arrays.asList())); - invariantDependency.put("constructor_resourceManager", new HashSet<>(Arrays.asList("_check_inv_18", "_check_inv_6", "_check_inv_7", "_check_inv_4", "_check_inv_11"))); - invariantDependency.put("in_register_failed", new HashSet<>(Arrays.asList())); - invariantDependency.put("rm_register", new HashSet<>(Arrays.asList())); - invariantDependency.put("rm_getSid_Not_Found", new HashSet<>(Arrays.asList())); - invariantDependency.put("svc_register", new HashSet<>(Arrays.asList("_check_inv_17"))); - guardDependency.put("in_register_success", new HashSet<>(Arrays.asList("_tr_in_register_success", "_tr_in_requestTargetSocket_Granted", "_tr_in_requestTargetSocket_NotGranted", "_tr_constructor_socket"))); - guardDependency.put("in_announceResourceManager", new HashSet<>(Arrays.asList("_tr_in_announceResourceManager"))); - guardDependency.put("in_requestTargetSocket_Granted", new HashSet<>(Arrays.asList("_tr_in_requestTargetSocket_Granted", "_tr_in_requestTargetSocket_NotGranted", "_tr_constructor_socket"))); - guardDependency.put("constructor_service", new HashSet<>(Arrays.asList("_tr_constructor_service", "_tr_rm_getSid", "_tr_in_register_success", "_tr_svc_register", "_tr_in_register_failed", "_tr_rm_register", "_tr_rm_getSid_Not_Found", "_tr_rm_deregister"))); - guardDependency.put("constructor_socket", new HashSet<>(Arrays.asList("_tr_in_requestTargetSocket_Granted", "_tr_in_requestTargetSocket_NotGranted", "_tr_constructor_socket"))); - guardDependency.put("in_requestTargetSocket_NotGranted", new HashSet<>(Arrays.asList())); - guardDependency.put("constructor_interconnectNode", new HashSet<>(Arrays.asList("_tr_constructor_service", "_tr_in_register_success", "_tr_in_requestTargetSocket_Granted", "_tr_in_register_failed", "_tr_rm_register", "_tr_in_requestTargetSocket_NotGranted", "_tr_constructor_socket", "_tr_rm_deregister", "_tr_constructor_interconnectNode", "_tr_in_announceResourceManager"))); - guardDependency.put("rm_getSid", new HashSet<>(Arrays.asList())); - guardDependency.put("rm_deregister", new HashSet<>(Arrays.asList())); - guardDependency.put("constructor_resourceManager", new HashSet<>(Arrays.asList("_tr_rm_getSid", "_tr_constructor_resourceManager", "_tr_rm_register", "_tr_rm_getSid_Not_Found", "_tr_rm_deregister", "_tr_in_announceResourceManager"))); - guardDependency.put("in_register_failed", new HashSet<>(Arrays.asList())); - guardDependency.put("rm_register", new HashSet<>(Arrays.asList())); - guardDependency.put("rm_getSid_Not_Found", new HashSet<>(Arrays.asList())); - guardDependency.put("svc_register", new HashSet<>(Arrays.asList("_tr_svc_register"))); - dependentInvariant.put(machine, new HashSet<>()); + } + return result; } - List<nota_v2> counterExampleState = new ArrayList<>(); - parents.put(machine, null); - stateAccessedVia.put(machine, null); - AtomicInteger transitions = new AtomicInteger(0); - - while(!collection.isEmpty() && !stopThreads.get()) { - possibleQueueChanges.incrementAndGet(); - nota_v2 state = next(collection, lock, type); - Runnable task = () -> { - Set<nota_v2> nextStates = generateNextStates(guardLock, state, isCaching, invariantDependency, dependentInvariant, guardDependency, dependentGuard, guardCache, parents, stateAccessedVia, transitions); - - nextStates.forEach(nextState -> { - synchronized(lock) { - if(!states.contains(nextState)) { - numberStates.getAndIncrement(); - states.add(nextState); - collection.add(nextState); - if(numberStates.get() % 5000 == 0) { - if( isDebug || numberStates.get() % 50000 == 0) { - System.out.println("VISITED STATES: " + numberStates.get()); - System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); - System.out.println("-------------------"); - } - } - } + private boolean invariantViolated(final nota_v2 state) { + if(isCaching) { + if(state.dependentInvariant.contains("_check_inv_1")) { + if(!state._check_inv_1()) { + return true; } - }); - - synchronized (lock) { - int running = possibleQueueChanges.decrementAndGet(); - if (!collection.isEmpty() || running == 0) { - synchronized (waitLock) { - waitLock.notify(); - } + } + if(state.dependentInvariant.contains("_check_inv_2")) { + if(!state._check_inv_2()) { + return true; } } - - if(nextStates.isEmpty()) { - deadlockDetected.set(true); - stopThreads.set(true); + if(state.dependentInvariant.contains("_check_inv_3")) { + if(!state._check_inv_3()) { + return true; + } } - - if(!checkInvariants(guardLock, state, isCaching, dependentInvariant)) { - invariantViolated.set(true); - stopThreads.set(true); - counterExampleState.add(state); + if(state.dependentInvariant.contains("_check_inv_4")) { + if(!state._check_inv_4()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_5")) { + if(!state._check_inv_5()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_6")) { + if(!state._check_inv_6()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_7")) { + if(!state._check_inv_7()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_8")) { + if(!state._check_inv_8()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_9")) { + if(!state._check_inv_9()) { + return true; + } } + if(state.dependentInvariant.contains("_check_inv_10")) { + if(!state._check_inv_10()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_11")) { + if(!state._check_inv_11()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_12")) { + if(!state._check_inv_12()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_13")) { + if(!state._check_inv_13()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_14")) { + if(!state._check_inv_14()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_15")) { + if(!state._check_inv_15()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_16")) { + if(!state._check_inv_16()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_17")) { + if(!state._check_inv_17()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_18")) { + if(!state._check_inv_18()) { + return true; + } + } + return false; + } + return !(state._check_inv_1() && state._check_inv_2() && state._check_inv_3() && state._check_inv_4() && state._check_inv_5() && state._check_inv_6() && state._check_inv_7() && state._check_inv_8() && state._check_inv_9() && state._check_inv_10() && state._check_inv_11() && state._check_inv_12() && state._check_inv_13() && state._check_inv_14() && state._check_inv_15() && state._check_inv_16() && state._check_inv_17() && state._check_inv_18()); + } + private void addCachedInfos(final String operation, final nota_v2 state, final nota_v2 copiedState) { + if(isCaching) { + copiedState.dependentInvariant = invariantDependency.get(operation); + copiedState.dependentGuard = guardDependency.get(operation); + } + copiedState.stateAccessedVia = operation; + } - }; - threadPool.submit(task); - synchronized(waitLock) { - if (collection.isEmpty() && possibleQueueChanges.get() > 0) { - try { - waitLock.wait(); - } catch (InterruptedException e) { - e.printStackTrace(); + private void printResult(final int states, final int transitions) { + if(invariantViolated.get() || deadlockDetected.get()) { + if(deadlockDetected.get()) { + System.out.println("DEADLOCK DETECTED"); + } else { + System.out.println("INVARIANT VIOLATED"); + } + + System.out.println("COUNTER EXAMPLE TRACE: "); + StringBuilder sb = new StringBuilder(); + while(counterExampleState != null) { + sb.insert(0, counterExampleState); + sb.insert(0, "\n"); + if(counterExampleState.stateAccessedVia != null) { + sb.insert(0, counterExampleState.stateAccessedVia); } + sb.insert(0, "\n\n"); + counterExampleState = counterExampleState.parent; } + System.out.println(sb); + } else { + System.out.println("MODEL CHECKING SUCCESSFUL"); } + System.out.println("Number of States: " + states); + System.out.println("Number of Transitions: " + transitions); } - threadPool.shutdown(); - try { - threadPool.awaitTermination(5, TimeUnit.SECONDS); - } catch (InterruptedException e) { - e.printStackTrace(); - } - printResult(numberStates.get(), transitions.get(), deadlockDetected.get(), invariantViolated.get(), counterExampleState, parents, stateAccessedVia); } - public static void debugPrint (String msg, Boolean isDebug) { - if (isDebug) { - System.out.println(msg); - } - } public static void main(String[] args) { if(args.length > 4) { @@ -2144,12 +1881,8 @@ public class nota_v2 { } } - debugPrint("Starting Modelchecking, STRATEGY=" + type + "THREADS=" + threads + ", CACHING=" + isCaching, isDebug); - if(threads == 1) { - modelCheckSingleThreaded(type, isCaching, isDebug); - } else { - modelCheckMultiThreaded(type, threads, isCaching, isDebug); - } + ModelChecker modelchecker = new ModelChecker(type, threads, isCaching, isDebug); + modelchecker.modelCheck(); } diff --git a/benchmarks/model_checking/Java/sort_m2_data1000_MC.java b/benchmarks/model_checking/Java/sort_m2_data1000_MC.java index 7925855f9ad48a8dc627b2335e9c4307e7dd6061..147e9f5fac7544451fa3e9c552987f945cfe782c 100644 --- a/benchmarks/model_checking/Java/sort_m2_data1000_MC.java +++ b/benchmarks/model_checking/Java/sort_m2_data1000_MC.java @@ -12,6 +12,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.Future; import java.util.concurrent.Executors; @@ -45,6 +46,12 @@ public class sort_m2_data1000_MC { MIXED } + public sort_m2_data1000_MC parent; + public Set<String> dependentGuard = new HashSet<>(); + public PersistentHashMap guardCache = PersistentHashMap.EMPTY; + public Set<String> dependentInvariant = new HashSet<>(); + public String stateAccessedVia; + private static BInteger n; @@ -76,6 +83,7 @@ public class sort_m2_data1000_MC { j = new BInteger(1); } + public sort_m2_data1000_MC(BInteger n, BRelation<BInteger, BInteger> f, BInteger j, BInteger k, BInteger l, BRelation<BInteger, BInteger> g) { this.n = n; this.f = f; @@ -85,6 +93,7 @@ public class sort_m2_data1000_MC { this.g = g; } + public void progress() { BRelation<BInteger, BInteger> _ld_g = g; BInteger _ld_k = k; @@ -220,318 +229,161 @@ public class sort_m2_data1000_MC { return String.join("\n", "_get_j: " + (this._get_j()).toString(), "_get_k: " + (this._get_k()).toString(), "_get_l: " + (this._get_l()).toString(), "_get_g: " + (this._get_g()).toString()); } - @SuppressWarnings("unchecked") - private static Set<sort_m2_data1000_MC> generateNextStates(Object guardLock, sort_m2_data1000_MC state, boolean isCaching, Map<String, Set<String>> invariantDependency, Map<sort_m2_data1000_MC, Set<String>> dependentInvariant, Map<String, Set<String>> guardDependency, Map<sort_m2_data1000_MC, Set<String>> dependentGuard, Map<sort_m2_data1000_MC, PersistentHashMap> guardCache, Map<sort_m2_data1000_MC, sort_m2_data1000_MC> parents, Map<sort_m2_data1000_MC, String> stateAccessedVia, AtomicInteger transitions) { - Set<sort_m2_data1000_MC> result = new HashSet<>(); - if(isCaching) { - PersistentHashMap parentsGuard = guardCache.get(parents.get(state)); - PersistentHashMap newCache = parentsGuard == null ? PersistentHashMap.EMPTY : parentsGuard; - Set<String> dependentGuardsOfState = dependentGuard.get(state); - Object cachedValue = null; - boolean dependentGuardsBoolean = true; - boolean _trid_1; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_progress"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_progress"); - } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_1 = state._tr_progress(); - } else { - _trid_1 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_progress", _trid_1); - if(_trid_1) { - sort_m2_data1000_MC copiedState = state._copy(); - copiedState.progress(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("progress")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("progress")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "progress"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_2; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_prog1"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_prog1"); - } + private static class ModelChecker { + private final Type type; + private final int threads; + private final boolean isCaching; + private final boolean isDebug; - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_2 = state._tr_prog1(); - } else { - _trid_2 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_prog1", _trid_2); - if(_trid_2) { - sort_m2_data1000_MC copiedState = state._copy(); - copiedState.prog1(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("prog1")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("prog1")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "prog1"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_3; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_prog2"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_prog2"); - } + private final LinkedList<sort_m2_data1000_MC> unvisitedStates = new LinkedList<>(); + private final Set<sort_m2_data1000_MC> states = ConcurrentHashMap.newKeySet(); + private AtomicInteger transitions = new AtomicInteger(0); + private ThreadPoolExecutor threadPool; + private Object waitLock = new Object(); - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_3 = state._tr_prog2(); - } else { - _trid_3 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_prog2", _trid_3); - if(_trid_3) { - sort_m2_data1000_MC copiedState = state._copy(); - copiedState.prog2(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("prog2")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("prog2")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "prog2"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - boolean _trid_4; - if(dependentGuardsOfState != null) { - cachedValue = GET.invoke(parentsGuard, "_tr_final_evt"); - dependentGuardsBoolean = dependentGuardsOfState.contains("_tr_final_evt"); + private AtomicBoolean invariantViolated = new AtomicBoolean(false); + private AtomicBoolean deadlockDetected = new AtomicBoolean(false); + private sort_m2_data1000_MC counterExampleState = null; + + private final Map<String, Set<String>> invariantDependency = new HashMap<>(); + private final Map<String, Set<String>> guardDependency = new HashMap<>(); + + public ModelChecker(final Type type, final int threads, final boolean isCaching, final boolean isDebug) { + this.type = type; + this.threads = threads; + this.isCaching = isCaching; + this.isDebug = isDebug; + } + + public void modelCheck() { + if (isDebug) { + System.out.println("Starting Modelchecking, STRATEGY=" + type + ", THREADS=" + threads + ", CACHING=" + isCaching); } - if(dependentGuardsOfState == null || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { - _trid_4 = state._tr_final_evt(); + if (threads <= 1) { + modelCheckSingleThreaded(); } else { - _trid_4 = (boolean) cachedValue; - } - newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_final_evt", _trid_4); - if(_trid_4) { - sort_m2_data1000_MC copiedState = state._copy(); - copiedState.final_evt(); - synchronized(guardLock) { - if(!dependentInvariant.containsKey(copiedState)) { - dependentInvariant.put(copiedState, invariantDependency.get("final_evt")); - } - if(!dependentGuard.containsKey(copiedState)) { - dependentGuard.put(copiedState, guardDependency.get("final_evt")); - } - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "final_evt"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); + this.threadPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(threads-1); + modelCheckMultiThreaded(); } + } - synchronized(guardLock) { - guardCache.put(state, newCache); - } - } else { - if(state._tr_progress()) { - sort_m2_data1000_MC copiedState = state._copy(); - copiedState.progress(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "progress"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_prog1()) { - sort_m2_data1000_MC copiedState = state._copy(); - copiedState.prog1(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "prog1"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_prog2()) { - sort_m2_data1000_MC copiedState = state._copy(); - copiedState.prog2(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "prog2"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); - } - if(state._tr_final_evt()) { - sort_m2_data1000_MC copiedState = state._copy(); - copiedState.final_evt(); - synchronized(guardLock) { - if(!parents.containsKey(copiedState)) { - parents.put(copiedState, state); - } - if(!stateAccessedVia.containsKey(copiedState)) { - stateAccessedVia.put(copiedState, "final_evt"); - } - } - result.add(copiedState); - transitions.getAndIncrement(); + private void modelCheckSingleThreaded() { + sort_m2_data1000_MC machine = new sort_m2_data1000_MC(); + states.add(machine); // TODO: store hashes instead of machine? + unvisitedStates.add(machine); + + if(isCaching) { + initCache(machine); } - } - return result; - } + while(!unvisitedStates.isEmpty()) { + sort_m2_data1000_MC state = next(); + Set<sort_m2_data1000_MC> nextStates = generateNextStates(state); - public static boolean checkInvariants(Object guardLock, sort_m2_data1000_MC state, boolean isCaching, Map<sort_m2_data1000_MC, Set<String>> dependentInvariant) { - if(isCaching) { - Set<String> dependentInvariantsOfState; - synchronized(guardLock) { - dependentInvariantsOfState = dependentInvariant.get(state); - } - if(dependentInvariantsOfState.contains("_check_inv_1")) { - if(!state._check_inv_1()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_2")) { - if(!state._check_inv_2()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_3")) { - if(!state._check_inv_3()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_4")) { - if(!state._check_inv_4()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_5")) { - if(!state._check_inv_5()) { - return false; - } - } - if(dependentInvariantsOfState.contains("_check_inv_6")) { - if(!state._check_inv_6()) { - return false; - } - } - return true; - } - return !(!state._check_inv_1() || !state._check_inv_2() || !state._check_inv_3() || !state._check_inv_4() || !state._check_inv_5() || !state._check_inv_6()); - } + nextStates.forEach(nextState -> { + if(!states.contains(nextState)) { + states.add(nextState); + unvisitedStates.add(nextState); + if(states.size() % 50000 == 0 && isDebug) { + System.out.println("VISITED STATES: " + states.size()); + System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); + System.out.println("-------------------"); + } + } + }); - private static void printResult(int states, int transitions, boolean deadlockDetected, boolean invariantViolated, List<sort_m2_data1000_MC> counterExampleState, Map<sort_m2_data1000_MC, sort_m2_data1000_MC> parents, Map<sort_m2_data1000_MC, String> stateAccessedVia) { + if(invariantViolated(state)) { + invariantViolated.set(true); + counterExampleState = state; + break; + } - if(invariantViolated || deadlockDetected) { - if(deadlockDetected) { - System.out.println("DEADLOCK DETECTED"); - } - if(invariantViolated) { - System.out.println("INVARIANT VIOLATED"); - } - System.out.println("COUNTER EXAMPLE TRACE: "); - StringBuilder sb = new StringBuilder(); - if(counterExampleState.size() >= 1) { - sort_m2_data1000_MC currentState = counterExampleState.get(0); - while(currentState != null) { - sb.insert(0, currentState.toString()); - sb.insert(0, "\n"); - sb.insert(0, stateAccessedVia.get(currentState)); - sb.insert(0, "\n\n"); - currentState = parents.get(currentState); + if(nextStates.isEmpty()) { + deadlockDetected.set(true); + counterExampleState = state; + break; } - } - System.out.println(sb.toString()); + } + printResult(states.size(), transitions.get()); } - if(!deadlockDetected && !invariantViolated) { - System.out.println("MODEL CHECKING SUCCESSFUL"); - } - System.out.println("Number of States: " + states); - System.out.println("Number of Transitions: " + transitions); - } - private static sort_m2_data1000_MC next(LinkedList<sort_m2_data1000_MC> collection, Object lock, Type type) { - synchronized(lock) { - return switch(type) { - case BFS -> collection.removeFirst(); - case DFS -> collection.removeLast(); - case MIXED -> collection.size() % 2 == 0 ? collection.removeFirst() : collection.removeLast(); - }; - } - } + private void modelCheckMultiThreaded() { + sort_m2_data1000_MC machine = new sort_m2_data1000_MC(); + states.add(machine); + unvisitedStates.add(machine); - private static void modelCheckSingleThreaded(Type type, boolean isCaching) { - Object lock = new Object(); - Object guardLock = new Object(); + AtomicBoolean stopThreads = new AtomicBoolean(false); + AtomicInteger possibleQueueChanges = new AtomicInteger(0); - sort_m2_data1000_MC machine = new sort_m2_data1000_MC(); + if(isCaching) { + initCache(machine); + } + while(!unvisitedStates.isEmpty() && !stopThreads.get()) { + possibleQueueChanges.incrementAndGet(); + sort_m2_data1000_MC state = next(); + Runnable task = () -> { + Set<sort_m2_data1000_MC> nextStates = generateNextStates(state); - AtomicBoolean invariantViolated = new AtomicBoolean(false); - AtomicBoolean deadlockDetected = new AtomicBoolean(false); - AtomicBoolean stopThreads = new AtomicBoolean(false); + nextStates.forEach(nextState -> { + if(states.add(nextState)) { + synchronized (unvisitedStates) { + unvisitedStates.add(nextState); + } + if(states.size() % 50000 == 0 && isDebug) { + System.out.println("VISITED STATES: " + states.size()); + System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); + System.out.println("-------------------"); + } + } + }); + + synchronized (unvisitedStates) { + int running = possibleQueueChanges.decrementAndGet(); + if (!unvisitedStates.isEmpty() || running == 0) { + synchronized (waitLock) { + waitLock.notify(); + } + } + } - Set<sort_m2_data1000_MC> states = new HashSet<>(); - states.add(machine); - AtomicInteger numberStates = new AtomicInteger(1); + if(invariantViolated(state)) { + invariantViolated.set(true); + counterExampleState = state; + stopThreads.set(true); + } - LinkedList<sort_m2_data1000_MC> collection = new LinkedList<>(); - collection.add(machine); + if(nextStates.isEmpty()) { + deadlockDetected.set(true); + counterExampleState = state; + stopThreads.set(true); + } + }; + threadPool.submit(task); + synchronized(waitLock) { + if (unvisitedStates.isEmpty() && possibleQueueChanges.get() > 0) { + try { + waitLock.wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } + threadPool.shutdown(); + try { + threadPool.awaitTermination(24, TimeUnit.HOURS); + } catch (InterruptedException e) { + e.printStackTrace(); + } + printResult(states.size(), transitions.get()); + } - Map<String, Set<String>> invariantDependency = new HashMap<>(); - Map<String, Set<String>> guardDependency = new HashMap<>(); - Map<sort_m2_data1000_MC, Set<String>> dependentInvariant = new HashMap<>(); - Map<sort_m2_data1000_MC, Set<String>> dependentGuard = new HashMap<>(); - Map<sort_m2_data1000_MC, PersistentHashMap> guardCache = new HashMap<>(); - Map<sort_m2_data1000_MC, sort_m2_data1000_MC> parents = new HashMap<>(); - Map<sort_m2_data1000_MC, String> stateAccessedVia = new HashMap<>(); - if(isCaching) { + private void initCache(final sort_m2_data1000_MC machine) { invariantDependency.put("prog2", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_3", "_check_inv_1", "_check_inv_4", "_check_inv_5"))); invariantDependency.put("prog1", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_3", "_check_inv_1", "_check_inv_4", "_check_inv_5"))); invariantDependency.put("progress", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_3", "_check_inv_1", "_check_inv_6", "_check_inv_4", "_check_inv_5"))); @@ -540,203 +392,287 @@ public class sort_m2_data1000_MC { guardDependency.put("prog1", new HashSet<>(Arrays.asList("_tr_progress", "_tr_prog1", "_tr_prog2"))); guardDependency.put("progress", new HashSet<>(Arrays.asList("_tr_final_evt", "_tr_progress", "_tr_prog1", "_tr_prog2"))); guardDependency.put("final_evt", new HashSet<>(Arrays.asList())); - dependentInvariant.put(machine, new HashSet<>()); } - List<sort_m2_data1000_MC> counterExampleState = new ArrayList<>(); - parents.put(machine, null); - AtomicInteger transitions = new AtomicInteger(0); - - while(!collection.isEmpty() && !stopThreads.get()) { - sort_m2_data1000_MC state = next(collection, lock, type); - - Set<sort_m2_data1000_MC> nextStates = generateNextStates(guardLock, state, isCaching, invariantDependency, dependentInvariant, guardDependency, dependentGuard, guardCache, parents, stateAccessedVia, transitions); + private sort_m2_data1000_MC next() { + synchronized(this.unvisitedStates) { + return switch(type) { + case BFS -> this.unvisitedStates.removeFirst(); + case DFS -> this.unvisitedStates.removeLast(); + case MIXED -> this.unvisitedStates.size() % 2 == 0 ? this.unvisitedStates.removeFirst() : this.unvisitedStates.removeLast(); + }; + } + } - nextStates.forEach(nextState -> { - if(!states.contains(nextState)) { - numberStates.getAndIncrement(); - states.add(nextState); - collection.add(nextState); - if(numberStates.get() % 50000 == 0) { - System.out.println("VISITED STATES: " + numberStates.get()); - System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); - System.out.println("-------------------"); - } + @SuppressWarnings("unchecked") + private Set<sort_m2_data1000_MC> generateNextStates(final sort_m2_data1000_MC state) { + Set<sort_m2_data1000_MC> result = new HashSet<>(); + if(isCaching) { + PersistentHashMap parentsGuard = state.guardCache; + PersistentHashMap newCache = parentsGuard == null ? PersistentHashMap.EMPTY : parentsGuard; + Object cachedValue = null; + boolean dependentGuardsBoolean = true; + boolean _trid_1; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_progress"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_progress"); } - }); - if(!checkInvariants(guardLock, state, isCaching, dependentInvariant)) { - invariantViolated.set(true); - stopThreads.set(true); - counterExampleState.add(state); - } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_1 = state._tr_progress(); + } else { + _trid_1 = (boolean) cachedValue; + } - if(nextStates.isEmpty()) { - deadlockDetected.set(true); - stopThreads.set(true); - } + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_progress", _trid_1); + if(_trid_1) { + sort_m2_data1000_MC copiedState = state._copy(); + copiedState.progress(); + copiedState.parent = state; + addCachedInfos("progress", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - } - printResult(numberStates.get(), transitions.get(), deadlockDetected.get(), invariantViolated.get(), counterExampleState, parents, stateAccessedVia); - } + } + boolean _trid_2; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_prog1"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_prog1"); + } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_2 = state._tr_prog1(); + } else { + _trid_2 = (boolean) cachedValue; + } - private static void modelCheckMultiThreaded(Type type, int threads, boolean isCaching) { - Object lock = new Object(); - Object guardLock = new Object(); - Object waitLock = new Object(); - ThreadPoolExecutor threadPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(threads); + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_prog1", _trid_2); + if(_trid_2) { + sort_m2_data1000_MC copiedState = state._copy(); + copiedState.prog1(); + copiedState.parent = state; + addCachedInfos("prog1", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - sort_m2_data1000_MC machine = new sort_m2_data1000_MC(); + } + boolean _trid_3; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_prog2"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_prog2"); + } + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_3 = state._tr_prog2(); + } else { + _trid_3 = (boolean) cachedValue; + } - AtomicBoolean invariantViolated = new AtomicBoolean(false); - AtomicBoolean deadlockDetected = new AtomicBoolean(false); - AtomicBoolean stopThreads = new AtomicBoolean(false); - AtomicInteger possibleQueueChanges = new AtomicInteger(0); + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_prog2", _trid_3); + if(_trid_3) { + sort_m2_data1000_MC copiedState = state._copy(); + copiedState.prog2(); + copiedState.parent = state; + addCachedInfos("prog2", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - Set<sort_m2_data1000_MC> states = new HashSet<>(); - states.add(machine); - AtomicInteger numberStates = new AtomicInteger(1); + } + boolean _trid_4; + if(!state.dependentGuard.isEmpty()) { + cachedValue = GET.invoke(parentsGuard, "_tr_final_evt"); + dependentGuardsBoolean = state.dependentGuard.contains("_tr_final_evt"); + } - LinkedList<sort_m2_data1000_MC> collection = new LinkedList<>(); - collection.add(machine); + if(state.dependentGuard.isEmpty() || dependentGuardsBoolean || parentsGuard == null || cachedValue == null) { + _trid_4 = state._tr_final_evt(); + } else { + _trid_4 = (boolean) cachedValue; + } - Map<String, Set<String>> invariantDependency = new HashMap<>(); - Map<String, Set<String>> guardDependency = new HashMap<>(); - Map<sort_m2_data1000_MC, Set<String>> dependentInvariant = new HashMap<>(); - Map<sort_m2_data1000_MC, Set<String>> dependentGuard = new HashMap<>(); - Map<sort_m2_data1000_MC, PersistentHashMap> guardCache = new HashMap<>(); - Map<sort_m2_data1000_MC, sort_m2_data1000_MC> parents = new HashMap<>(); - Map<sort_m2_data1000_MC, String> stateAccessedVia = new HashMap<>(); - if(isCaching) { - invariantDependency.put("prog2", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_3", "_check_inv_1", "_check_inv_4", "_check_inv_5"))); - invariantDependency.put("prog1", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_3", "_check_inv_1", "_check_inv_4", "_check_inv_5"))); - invariantDependency.put("progress", new HashSet<>(Arrays.asList("_check_inv_2", "_check_inv_3", "_check_inv_1", "_check_inv_6", "_check_inv_4", "_check_inv_5"))); - invariantDependency.put("final_evt", new HashSet<>(Arrays.asList())); - guardDependency.put("prog2", new HashSet<>(Arrays.asList("_tr_progress", "_tr_prog1", "_tr_prog2"))); - guardDependency.put("prog1", new HashSet<>(Arrays.asList("_tr_progress", "_tr_prog1", "_tr_prog2"))); - guardDependency.put("progress", new HashSet<>(Arrays.asList("_tr_final_evt", "_tr_progress", "_tr_prog1", "_tr_prog2"))); - guardDependency.put("final_evt", new HashSet<>(Arrays.asList())); - dependentInvariant.put(machine, new HashSet<>()); - } - List<sort_m2_data1000_MC> counterExampleState = new ArrayList<>(); - parents.put(machine, null); - stateAccessedVia.put(machine, null); + newCache = (PersistentHashMap) ASSOC.invoke(newCache, "_tr_final_evt", _trid_4); + if(_trid_4) { + sort_m2_data1000_MC copiedState = state._copy(); + copiedState.final_evt(); + copiedState.parent = state; + addCachedInfos("final_evt", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - AtomicInteger transitions = new AtomicInteger(0); + } - while(!collection.isEmpty() && !stopThreads.get()) { - possibleQueueChanges.incrementAndGet(); - sort_m2_data1000_MC state = next(collection, lock, type); - Runnable task = () -> { - Set<sort_m2_data1000_MC> nextStates = generateNextStates(guardLock, state, isCaching, invariantDependency, dependentInvariant, guardDependency, dependentGuard, guardCache, parents, stateAccessedVia, transitions); + state.guardCache = newCache; + } else { + if(state._tr_progress()) { + sort_m2_data1000_MC copiedState = state._copy(); + copiedState.progress(); + copiedState.parent = state; + addCachedInfos("progress", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - nextStates.forEach(nextState -> { - synchronized(lock) { - if(!states.contains(nextState)) { - numberStates.getAndIncrement(); - states.add(nextState); - collection.add(nextState); - if(numberStates.get() % 50000 == 0) { - System.out.println("VISITED STATES: " + numberStates.get()); - System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); - System.out.println("-------------------"); - } - } - } - }); + } + if(state._tr_prog1()) { + sort_m2_data1000_MC copiedState = state._copy(); + copiedState.prog1(); + copiedState.parent = state; + addCachedInfos("prog1", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - synchronized (lock) { - int running = possibleQueueChanges.decrementAndGet(); - if (!collection.isEmpty() || running == 0) { - synchronized (waitLock) { - waitLock.notify(); - } - } } + if(state._tr_prog2()) { + sort_m2_data1000_MC copiedState = state._copy(); + copiedState.prog2(); + copiedState.parent = state; + addCachedInfos("prog2", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - if(nextStates.isEmpty()) { - deadlockDetected.set(true); - stopThreads.set(true); } + if(state._tr_final_evt()) { + sort_m2_data1000_MC copiedState = state._copy(); + copiedState.final_evt(); + copiedState.parent = state; + addCachedInfos("final_evt", state, copiedState); + result.add(copiedState); + transitions.getAndIncrement(); - if(!checkInvariants(guardLock, state, isCaching, dependentInvariant)) { - invariantViolated.set(true); - stopThreads.set(true); - counterExampleState.add(state); } + } + return result; + } - }; - threadPool.submit(task); - synchronized(waitLock) { - if (collection.isEmpty() && possibleQueueChanges.get() > 0) { - try { - waitLock.wait(); - } catch (InterruptedException e) { - e.printStackTrace(); + private boolean invariantViolated(final sort_m2_data1000_MC state) { + if(isCaching) { + if(state.dependentInvariant.contains("_check_inv_1")) { + if(!state._check_inv_1()) { + return true; } } + if(state.dependentInvariant.contains("_check_inv_2")) { + if(!state._check_inv_2()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_3")) { + if(!state._check_inv_3()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_4")) { + if(!state._check_inv_4()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_5")) { + if(!state._check_inv_5()) { + return true; + } + } + if(state.dependentInvariant.contains("_check_inv_6")) { + if(!state._check_inv_6()) { + return true; + } + } + return false; } + return !(state._check_inv_1() && state._check_inv_2() && state._check_inv_3() && state._check_inv_4() && state._check_inv_5() && state._check_inv_6()); + } + private void addCachedInfos(final String operation, final sort_m2_data1000_MC state, final sort_m2_data1000_MC copiedState) { + if(isCaching) { + copiedState.dependentInvariant = invariantDependency.get(operation); + copiedState.dependentGuard = guardDependency.get(operation); + } + copiedState.stateAccessedVia = operation; } - threadPool.shutdown(); - try { - threadPool.awaitTermination(5, TimeUnit.SECONDS); - } catch (InterruptedException e) { - e.printStackTrace(); + + private void printResult(final int states, final int transitions) { + if(invariantViolated.get() || deadlockDetected.get()) { + if(deadlockDetected.get()) { + System.out.println("DEADLOCK DETECTED"); + } else { + System.out.println("INVARIANT VIOLATED"); + } + + System.out.println("COUNTER EXAMPLE TRACE: "); + StringBuilder sb = new StringBuilder(); + while(counterExampleState != null) { + sb.insert(0, counterExampleState); + sb.insert(0, "\n"); + if(counterExampleState.stateAccessedVia != null) { + sb.insert(0, counterExampleState.stateAccessedVia); + } + sb.insert(0, "\n\n"); + counterExampleState = counterExampleState.parent; + } + System.out.println(sb); + } else { + System.out.println("MODEL CHECKING SUCCESSFUL"); + } + + System.out.println("Number of States: " + states); + System.out.println("Number of Transitions: " + transitions); } - printResult(numberStates.get(), transitions.get(), deadlockDetected.get(), invariantViolated.get(), counterExampleState, parents, stateAccessedVia); } public static void main(String[] args) { - if(args.length != 3) { - System.out.println("Number of arguments errorneous"); - return; - } - String strategy = args[0]; - String numberThreads = args[1]; - String caching = args[2]; - - Type type; - - if("mixed".equals(strategy)) { - type = Type.MIXED; - } else if("bf".equals(strategy)) { - type = Type.BFS; - } else if ("df".equals(strategy)) { - type = Type.DFS; - } else { - System.out.println("Input for strategy is wrong."); + if(args.length > 4) { + System.out.println("Expecting 3 command-line arguments: STRATEGY THREADS CACHING DEBUG"); return; } - + Type type = Type.MIXED; int threads = 0; - try { - threads = Integer.parseInt(numberThreads); - } catch(NumberFormatException e) { - System.out.println("Input for number of threads is wrong."); - return; + boolean isCaching = false; + boolean isDebug = false; + + if(args.length > 0) { + if("mixed".equals(args[0])) { + type = Type.MIXED; + } else if("bf".equals(args[0])) { + type = Type.BFS; + } else if ("df".equals(args[0])) { + type = Type.DFS; + } else { + System.out.println("Value for command-line argument STRATEGY is wrong."); + System.out.println("Expecting mixed, bf or df."); + return; + } } - if(threads <= 0) { - System.out.println("Input for number of threads is wrong."); - return; + if(args.length > 1) { + try { + threads = Integer.parseInt(args[1]); + } catch(NumberFormatException e) { + System.out.println("Value for command-line argument THREADS is not a number."); + return; + } + if(threads <= 0) { + System.out.println("Value for command-line argument THREADS must be positive."); + return; + } } - - boolean isCaching = true; - try { - isCaching = Boolean.parseBoolean(caching); - } catch(Exception e) { - System.out.println("Input for caching is wrong."); - return; + if(args.length > 2) { + try { + isCaching = Boolean.parseBoolean(args[2]); + } catch(Exception e) { + System.out.println("Value for command-line argument CACHING is not a boolean."); + return; + } } - if(threads == 1) { - modelCheckSingleThreaded(type, isCaching); - } else { - modelCheckMultiThreaded(type, threads, isCaching); + if(args.length > 3) { + try { + isDebug = Boolean.parseBoolean(args[3]); + } catch(Exception e) { + System.out.println("Value for command-line argument DEBUG is not a boolean."); + return; + } } + + ModelChecker modelchecker = new ModelChecker(type, threads, isCaching, isDebug); + modelchecker.modelCheck(); } diff --git a/btypes_primitives/src/main/rust/btypes/src/bstring.rs b/btypes_primitives/src/main/rust/btypes/src/bstring.rs index 62a0ee4b3b32a8247dcf3a9b84c8d104091ecc1e..91b98ccca54dd0af2a5ab3042e79d1f575324d0f 100644 --- a/btypes_primitives/src/main/rust/btypes/src/bstring.rs +++ b/btypes_primitives/src/main/rust/btypes/src/bstring.rs @@ -20,6 +20,8 @@ impl Display for BString { impl BObject for BString {} impl BString { + #![allow(non_snake_case, dead_code)] + pub fn new(init: &str) -> BString { return BString { val: String::from(init) } } diff --git a/src/main/java/de/hhu/stups/codegenerator/CodeGenerator.java b/src/main/java/de/hhu/stups/codegenerator/CodeGenerator.java index 33ae84cf382832b9abf890dbe7e423e3cfbb0fbe..2fad2d5f5239be1aae39c2782eb8cdba3345bdf3 100755 --- a/src/main/java/de/hhu/stups/codegenerator/CodeGenerator.java +++ b/src/main/java/de/hhu/stups/codegenerator/CodeGenerator.java @@ -7,7 +7,6 @@ import de.hhu.stups.codegenerator.generators.CodeGenerationException; import de.hhu.stups.codegenerator.generators.MachineGenerator; import de.hhu.stups.codegenerator.generators.MachineReferenceGenerator; import de.hhu.stups.codegenerator.generators.VisualisationGenerator; -import de.hhu.stups.codegenerator.json.JSONASTBuilder; import de.hhu.stups.codegenerator.json.modelchecker.ModelCheckingInfo; import de.hhu.stups.codegenerator.json.simb.SimulationRewriter; import de.hhu.stups.codegenerator.json.visb.VisBFileHandler; @@ -114,6 +113,7 @@ public class CodeGenerator { DefaultParser parser = new DefaultParser(); return parser.parse(options, args); } catch (ParseException e) { + System.out.println(e.getMessage()); new HelpFormatter().printHelp("{-l <language> -bi <use_big_integer> -min <minint> -max <maxint> -dss <deferred_set_size> -cs <use_constraint_solving> -mc <forModelChecking> -f <filename> -v <visualisation> -a <additionalMain>} | -sim <simb_file>", options); } return null; @@ -142,7 +142,7 @@ public class CodeGenerator { } else if("rs".equals(languageOption)) { mode = GeneratorMode.RS; } else { - throw new RuntimeException("Wrong argument for language (must be java, python, c, cpp, clojure, ts)"); + throw new RuntimeException(String.format("Wrong argument '%s' for language (must be java, python, c, cpp, clojure, ts, rs)", languageOption)); } return mode; }