public static void Initialize(AssertionBase Assertion, DefinitionRef Process, SpecificationBase spec) { Specification Spec = spec as Specification; //get the relevant global variables; remove irrelevant variables so as to save memory; Valuation GlobalEnv = Spec.SpecValuation.GetVariableChannelClone(Process.GetGlobalVariables(), Process.GetChannels()); //Initialize InitialStep Assertion.InitialStep = new Configuration(Process, Constants.INITIAL_EVENT, null, GlobalEnv, false); Assertion.MustAbstract = Process.MustBeAbstracted(); }
public static void Initialize(AssertionRefinement Assertion, DefinitionRef ImplementationProcess, DefinitionRef SpecificationProcess, SpecificationBase spec) { Specification Spec = spec as Specification; //get the relevant global variables; remove irrelevant variables so as to save memory; List <string> varList = ImplementationProcess.GetGlobalVariables(); varList.AddRange(SpecificationProcess.GetGlobalVariables()); Valuation GlobalEnv = Spec.SpecValuation.GetVariableChannelClone(varList, ImplementationProcess.GetChannels()); //Initialize InitialStep Assertion.InitialStep = new PNConfiguration(ImplementationProcess, Constants.INITIAL_EVENT, null, GlobalEnv, false, spec); Assertion.InitSpecStep = new PNConfiguration(SpecificationProcess, Constants.INITIAL_EVENT, null, GlobalEnv, false, spec); Assertion.MustAbstract = ImplementationProcess.MustBeAbstracted(); if (SpecificationProcess.MustBeAbstracted()) { throw new ParsingException( "Process " + Assertion.SpecProcess + " has infinite states and therefore can not be used as a property model for refinement checking!", Assertion.AssertToken); } }
public ADLAssertionDeadLock(DefinitionRef processDef) : base() { Process = processDef; }
public ADLAssertionDeadLock(DefinitionRef processDef, bool isNontermination) : base(isNontermination) { Process = processDef; }
public ADLAssertionAmbiguousInterface(DefinitionRef processDef) : base() { Process = processDef; }
public KWSNAssertionReachabilityWith(DefinitionRef processDef, string reachableState, QueryConstraintType cont, Expression constraintCondition) : base(reachableState, cont, constraintCondition) { Process = processDef; }
public KWSNAssertionReachability(DefinitionRef processDef, string reachableState) : base(reachableState) { Process = processDef; }
private void createRoleProcessSpec(Feature role, Feature linkedRole, String eventPrefixStr, Feature attachedPort, String componentName) { if (Spec.DefinitionDatabase.ContainsKey(eventPrefixStr + "_" + role.getName())) { return; } //Feature role = conn.getRoleByName(roleName); Spec.CompStateDatabase.TryGetValue(componentName, out List <string> statesList); if (statesList == null) { statesList = new List <string>(); Spec.CompStateDatabase.Add(componentName, statesList); } // create parameter of role process List <Expression> paramsExpr = new List <Expression>(); if (role.Params.Count > 0) { foreach (var param in role.Params) { paramsExpr.Add(new Variable(param)); } } // create main role process DefinitionRef process = new DefinitionRef(eventPrefixStr + "_" + role.getName(), paramsExpr.ToArray()); Process prev = null; Console.WriteLine(role.process.ElementAt(role.process.Count - 1).Name + "====" + role.getName()); if (role.process.ElementAt(role.process.Count - 1).getName() == role.getName()) { prev = process; } else if (role.process.ElementAt(role.process.Count - 1).Name.IndexOf("Skip") != -1) { prev = new Skip(); } else if (role.process.ElementAt(role.process.Count - 1).Name.IndexOf("Stop") != -1) { prev = new Stop(); } // copy list of event from the role process List <SysEvent> roleProcess = new List <SysEvent>(); roleProcess.AddRange(role.process); // intercept if there is a link to other role if (linkedRole != null) { for (int i = 0; i < roleProcess.Count; i++) { if (roleProcess.ElementAt(i).Name.IndexOf("_process") != -1) { // get rid of xxx() in linked role process if (linkedRole.process.ElementAt(linkedRole.process.Count - 1).Name == linkedRole.Name) { linkedRole.process.RemoveAt(linkedRole.process.Count - 1); } Console.WriteLine("##inserting " + roleProcess.ElementAt(i)); // combine process at where _process is roleProcess.InsertRange(i, linkedRole.process); // combine process after where _process is // roleProcess.InsertRange(i+1, linkedRole.process); break; } } } // insert component internal computation if (attachedPort.process.Count != 0) { for (int i = 0; i < roleProcess.Count; i++) { if (roleProcess.ElementAt(i).Name.IndexOf("_process") != -1) { if (attachedPort.process.ElementAt(attachedPort.process.Count - 1).Name == attachedPort.Name) { attachedPort.process.RemoveAt(attachedPort.process.Count - 1); } // insert event trail after process event // roleProcess.InsertRange(i+1, attachedPort.process); // insert event trail at process event roleProcess.InsertRange(i, attachedPort.process); break; } } } // construct a sequenc for the role process // start from the second event for (int i = roleProcess.Count - 2; i >= 0; i--) { var sysEvent = roleProcess.ElementAt(i); Process current = null; if (sysEvent is SysProcess) { // it is event current = new EventPrefix(new Common.Classes.LTS.Event(eventPrefixStr + "_" + sysEvent.getName()), prev); Console.WriteLine(" ->" + componentName + " addEvent " + eventPrefixStr + "_" + sysEvent.getName()); statesList.Add(eventPrefixStr + "_" + sysEvent.getName()); } else if (sysEvent is SysChannel) { // it is channel SysChannel channel = (SysChannel)sysEvent; // parse channel parameters List <Expression> chparamsExpr = new List <Expression>(); if (channel.Parameters.Count > 0) { foreach (var param in channel.Parameters) { chparamsExpr.Add(new Variable(param)); } } // add channelqueue to database, if still not exists if (!Spec.ChannelDatabase.ContainsKey(channel.getName())) { ChannelQueue queue = new ChannelQueue(1); Spec.ChannelDatabase.Add(channel.getName(), queue); } if (channel.ChannelType == SysChannel.Type.Input) { current = new ChannelInput(channel.getName(), null, chparamsExpr.ToArray(), prev); } else if (channel.ChannelType == SysChannel.Type.Output) { current = new ChannelOutput(channel.getName(), null, chparamsExpr.ToArray(), prev); } } prev = current; } //Spec.CompStateDatabase.Add(componentName, statesList); Spec.CompStateDatabase.TryGetValue(componentName, out List <string> outstatesList); Console.WriteLine(" -> outstate: " + outstatesList.Count); // create process definition Definition processDef = new Definition(eventPrefixStr + "_" + role.getName(), role.Params.ToArray(), prev); process.Def = processDef; // add role process to spec Console.WriteLine("............ create role process :" + role.getName()); Spec.DefinitionDatabase.Add(processDef.Name, processDef); }
public ADLAssertionLavaFlow(DefinitionRef processDef) : base() { Process = processDef; }
public ADLAssertionPoltergeist(DefinitionRef processDef) : base() { Process = processDef; }
public KWSNAssertionDivergence(DefinitionRef processDef) : base() { Process = processDef; }
public ADLAssertionDecomposition(DefinitionRef processDef) : base() { Process = processDef; }
public void parse(SystemConfig config) { Dictionary <string, Connector> connectorInstanceList = new Dictionary <string, Connector>(); // get connector instance to the dictionary foreach (var define in config.declareList) { Spec.ConnectorDatabase.TryGetValue(define.RightName, out Connector conn); if (conn == null) { throw new Exception("At define statement, cannot find connector :" + define.RightName); } // Console.WriteLine(".......... define: " + define.LeftName + ", conn:" + conn.Name); Connector connInst = conn.DeepClone(); connInst.setConfigName(define.LeftName); connectorInstanceList.Add(define.LeftName, connInst); } // create attach process // Dictionary<string, DefinitionRef> attachMap = new Dictionary<string, DefinitionRef>(); foreach (var attach in config.attachList) { Console.WriteLine("##loop on attach: " + attach.LeftName); if (!Spec.ComponentDatabase.ContainsKey(attach.LeftName)) { throw new Exception("No component " + attach.LeftName + " found"); } // find component Spec.ComponentDatabase.TryGetValue(attach.LeftName, out Component comp); // find internal process associated to the component Feature port = comp.getPortByName(attach.LeftFunction.Name); Spec.AttachmentDatabase.Add(port.Name, attach); Console.WriteLine("attach " + attach.LeftName + "port: " + port.Name + " portproc:" + attach.HeadFunction.getCountEventAfter()); SysProcess current = attach.HeadFunction; SysProcess prevProc = null; Feature prevRole = null; DefinitionRef atprocRef = null; Process headprocRef = null; // loop through trail of process of attachment String process_prefix = attach.LeftName + "_"; List <Feature> linkedRoles = new List <Feature>(); Feature headEmbedProcRole = null; SysProcess headEmbedProc = null; while (current != null) { Console.WriteLine("#loop on attach process " + current.getName()); atprocRef = new DefinitionRef(process_prefix + current.Super + "_" + current.Name, convertParamValues(current.Parameters)); // retrieve connector connectorInstanceList.TryGetValue(current.Super, out Connector conn); if (conn == null) { throw new Exception("At attach statement, " + current.Super + " is not defined"); } // Console.WriteLine("finding role process " + config.Name + "_" + current.Name + ": " + atprocRef.Args); Feature role = conn.getRoleByName(current.Name); if (headprocRef != null) { List <Process> coProcs = new List <Process>(); coProcs.Add(headprocRef); if (current.operation == SysProcess.Operation.Interleave) { this.createRoleProcessSpec(role, null, attach.LeftName, port, comp.Name); Spec.DefinitionDatabase.TryGetValue(process_prefix + current.Super + "_" + current.Name, out atprocRef.Def); coProcs.Add(atprocRef); IndexInterleave procs = new IndexInterleave(coProcs); headprocRef = procs; } else if (current.operation == SysProcess.Operation.Parallel) { this.createRoleProcessSpec(role, null, attach.LeftName, port, comp.Name); Spec.DefinitionDatabase.TryGetValue(process_prefix + current.Super + "_" + current.Name, out atprocRef.Def); coProcs.Add(atprocRef); IndexParallel procs = new IndexParallel(coProcs); headprocRef = procs; } else if (current.operation == SysProcess.Operation.Embed) { if (current.next != null && current.next.operation == SysProcess.Operation.Embed) { linkedRoles.Add(role.DeepClone <Feature>()); } else { linkedRoles.Add(role.DeepClone <Feature>()); Console.WriteLine(" #process: " + process_prefix + headEmbedProcRole.getName() + " headEmbedProc: " + headEmbedProc + " creating..."); atprocRef = new DefinitionRef(process_prefix + headEmbedProcRole.ConfigName + "_" + headEmbedProcRole.Name, convertParamValues(headEmbedProc.Parameters)); // create embed process this.createRoleProcessSpecWithMultipleLinked(headEmbedProcRole, linkedRoles, attach.LeftName, port, comp.Name); Spec.DefinitionDatabase.TryGetValue(process_prefix + headEmbedProcRole.getName(), out atprocRef.Def); headprocRef = atprocRef; } } } else { if (current.next != null && current.next.operation == SysProcess.Operation.Embed) { // this is head of embeded processs headEmbedProcRole = conn.getRoleByName(current.Name); headEmbedProc = current; } else { // other process rather than embeded process this.createRoleProcessSpec(role, null, attach.LeftName, port, comp.Name); } Console.WriteLine(" #create first sub process"); Spec.DefinitionDatabase.TryGetValue(process_prefix + current.Super + "_" + current.Name, out atprocRef.Def); // first sub process headprocRef = atprocRef; } prevProc = current; prevRole = conn.getRoleByName(current.Name); current = current.next; } Definition atprocDef = new Definition(attach.LeftName + "_" + attach.LeftFunction.Name, new String[] { }, headprocRef); Spec.DefinitionDatabase.Add(atprocDef.Name, atprocDef); // attachMap.Add(atprocRef.Name, atprocRef); } // find exec statement and create exec process SysProcess subproc = config.Exec; //loop through each function in the exec process Process head = null; while (subproc != null) { // find attachment process according to what is called in exec process DefinitionRef atprocRef = new DefinitionRef(subproc.Super + "_" + subproc.Name, new Expression[] { }); Spec.DefinitionDatabase.TryGetValue(subproc.Super + "_" + subproc.Name, out atprocRef.Def); if (atprocRef.Def == null) { throw new Exception("At exec statement, cannot find port" + subproc.Name + " on " + subproc.Super); } // Process atprocRef = def.Process; if (head != null) { List <Process> coProcs = new List <Process>(); coProcs.Add(head); coProcs.Add(atprocRef); if (subproc.operation == SysProcess.Operation.Interleave) { IndexInterleave interleaveProcs = new IndexInterleave(coProcs); head = interleaveProcs; } else if (subproc.operation == SysProcess.Operation.Parallel) { IndexParallel parallelProcs = new IndexParallel(coProcs); head = parallelProcs; } else if (subproc.operation == SysProcess.Operation.Choice) { IndexChoice choiceProcs = new IndexChoice(coProcs); head = choiceProcs; } } else { // first sub process head = atprocRef; } // go to next process subproc = subproc.next; } // create exec process DefinitionRef execRef = new DefinitionRef(config.Name, new Expression[] { }); //Console.WriteLine("exec proc: " + head.ToString()); Definition instanceDef = new Definition(execRef.Name, new String[] { }, head); execRef.Def = instanceDef; Spec.DefinitionDatabase.Add(instanceDef.Name, instanceDef); Spec.ExecProcessDatabase.Add(execRef.Name, execRef); }
public KWSNAssertionRefinement(DefinitionRef processDef, DefinitionRef target) : base() { ImplementationProcess = processDef; SpecificationProcess = target; }
public ADLAssertionCircular(DefinitionRef processDef) : base() { Process = processDef; }
public PNAssertionLTL(DefinitionRef processDef, string ltl) : base(ltl) { Process = processDef; }
public KWSNAssertionDeterminism(DefinitionRef processDef) : base() { Process = processDef; }