

{"id":338,"date":"2013-04-18T13:03:07","date_gmt":"2013-04-18T11:03:07","guid":{"rendered":"https:\/\/project.inria.fr\/pyecdar\/?page_id=338"},"modified":"2013-04-22T10:41:42","modified_gmt":"2013-04-22T08:41:42","slug":"queries","status":"publish","type":"page","link":"https:\/\/project.inria.fr\/pyecdar\/queries\/","title":{"rendered":"Queries"},"content":{"rendered":"<p>We describe PyECDAR fonctions that are called inside the Python shell.<\/p>\n<h3>Loading, system construction and saving<\/h3>\n<p style=\"text-align: justify;\">The tool is imported with the python command: <code>from pyecdar import loadModel<\/code><br \/>\nTo run it the shell must either be launched from pyecdar directory or the tool must have been installed in the system. See the section <a title=\"Installation\" href=\"https:\/\/project.inria.fr\/pyecdar\/installation\/\">Installation<\/a>.<\/p>\n<p>A XML model file is loaded inside a variable via the command:<br \/>\n<code>workspace = loadModel(<em>filename<\/em>)<\/code><\/p>\n<p>Each template in the model can be loaded in a separate variable:<\/p>\n<p><code>spec = workspace.getSpecification(<em>template_name<\/em>)<\/code> if the template is a timed specification, or<\/p>\n<p><code>game = workspace.getTimedGame(<em>template_name,objective<\/em>)<\/code> if the template is a timed game associated to a T-AdaCTL formula (see the syntax <a href=\"#tadactl\">below<\/a>).<\/p>\n<p>Complex systems of timed specifcations are build by combining the specifications already loaded using Python standard operators. The results of each operation is a new specification, which allows to use the operators in an algebraic expression.<\/p>\n<p style=\"padding-left: 30px;\"><code>spec1 | spec2<\/code>\u00a0\u00a0 computes the parallel composition<\/p>\n<p style=\"padding-left: 30px;\"><code><code>spec1<\/code>\u00a0&amp;\u00a0<\/code><code>spec2<\/code>\u00a0\u00a0 computes the conjunction<\/p>\n<p style=\"padding-left: 30px;\"><code><code>spec1<\/code>\u00a0\/\u00a0<\/code><code>spec2<\/code>\u00a0\u00a0 computes the quotient<\/p>\n<p>If needed the newly generated templates (games or specification) can be added to the workspace:<\/p>\n<p><code>workspace.addTemplate(template)<\/code><\/p>\n<p>This allows to save the model with the new templates in an XML file:<\/p>\n<p><code><code>workspace<\/code>.save(<em>filename<\/em>)<\/code><\/p>\n<p><em>filename<\/em> may be omitted if the user wants to overwrite the previous XML file. Note that the templates are saved without positions for graphical elements. Therefore if the model is open in Uppaal or Ecdar all the elements (locations and transitions will overlap).<\/p>\n<h3>Timed specification Checking<\/h3>\n<p><code>spec.isSpecification()<\/code> returns True or False, if the template syntax corresponds to a specification:<\/p>\n<ul>\n<li>no features<\/li>\n<li>all transitions are synchronized<\/li>\n<li>inputs and outputs are disjoint<\/li>\n<li>the automata is deterministic and input enabled.<\/li>\n<\/ul>\n<p><code><code>spec<\/code>.isDeterministic()<\/code> returns True or False, if the template is action deterministic.<\/p>\n<p><code><code>spec<\/code>.isInputEnabled()<\/code> returns True or False, if the template is input enabled.<\/p>\n<p><code>new_<code>spec<\/code> = <code>spec<\/code>.scale(self,factor)<\/code> computes a new model in which all the constants used in the DBMs are scaled by an integer factor.<\/p>\n<p style=\"text-align: justify;\"><code>spec.sameAlphabet(spec2)<\/code> Checks if the two specifications have the same alphabet of actions. This is a necessary condition to computes the conjunction.<\/p>\n<p style=\"text-align: justify;\"><code>spec.composable(spec2) <\/code> Checks if the two specifications have disjoint alphabet of output actions. This is a necessary condition to computes the parallel composition.<\/p>\n<p><code>spec.quotientable(spec2)<\/code> Checks if the specification spec1 can be quotiented by spec2.<\/p>\n<h6>Consistency checking<\/h6>\n<p style=\"text-align: justify;\"><code><code>spec<\/code>.isConsistent()<\/code> returns True or False, if the specification is consistent. This implies to solve a consistency game.<\/p>\n<p style=\"text-align: justify;\"><code><code>spec<\/code>.isRobustConsistent(<em>delta<\/em>)<\/code> where <em>delta<\/em> is a float value. Returns True or False, if the specification is robustly consistent for the value <em>delta<\/em>. This implies to solve a robust consistency game.<\/p>\n<p style=\"text-align: justify;\"><code><code>spec<\/code>.maxRobustConsistent(<em>delta_max<\/em>,<em>confidence<\/em>)<\/code> where <em>delta_max<\/em> is an integer value, sufficiently big to know that the specification is not robustly consistent for this value (e.g. the maximum constant used in the model), and <em>confidence<\/em> is a float value that defines the precision of the computation. Returns the value\u00a0<em>delta<\/em> such that the specification is robustly consistent. This function uses the CEGAR algorithm for parametric robustness.<\/p>\n<p style=\"text-align: justify;\"><code><code>spec<\/code>.maxRobustConsistentBS(<em>delta_max,confidence<\/em>)<\/code> same as previously, but using a binary search algorithm instead.<\/p>\n<p style=\"text-align: justify;\"><code><code>spec<\/code>.getConsistencyGame()<\/code> returns the timed game used to check the consistency of the specification.<\/p>\n<p style=\"text-align: justify;\"><code><code>spec<\/code>.getRobustConsistencyGame(<em>delta<\/em>,<em>param<\/em>)<\/code> returns the robust consistency game used to check robust consistency. <em>delta<\/em> is either an integer value, or a parameter name. By default <em>delta<\/em> is a parameter named &#8220;delta&#8221;. <em>param<\/em> is only useful if <em>delta<\/em> is a parameter, in which case <em>param<\/em> is the initial value of <em>delta<\/em>. By default <em>param<\/em>=0.<\/p>\n<p><strong>Compatibility (or usefulness checking)<\/strong><\/p>\n<p style=\"text-align: justify;\"><code><code>spec<\/code>.isUseful(<em>bad_locations<\/em>)<\/code> returns True or False, if the specification is useful, which means that its components are compatible. This solves a usefulness game whose objective is to avoid the set of <em>bad_locations.<\/em><\/p>\n<p style=\"text-align: justify;\"><code><code>spec<\/code>.isRobustUseful(<em>delta<\/em>,<code><em>bad_locations<\/em><\/code>)<\/code> where <em>delta<\/em> is a float value. Returns True or False, if the specification is robustly useful for the value <em>delta<\/em>. This implies to solve a robust usefulness game.<\/p>\n<p style=\"text-align: justify;\"><code><code>spec<\/code>.maxRobustUseful(<em>delta_max<\/em>,<em>confidence,<code><em>bad_locations<\/em><\/code><\/em>)<\/code> where <em>delta_max<\/em> is an integer value, sufficiently big to know that the specification is not robustly useful for this value (e.g. the maximum constant used in the model), and <em>confidence<\/em> is a float value that defines the precision of the computation. Returns the value\u00a0<em>delta<\/em> such that the specification is robustly useful. This function uses the CEGAR algorithm for parametric robustness.<\/p>\n<p style=\"text-align: justify;\"><code><code>spec<\/code>.<code>maxRobustUseful<\/code>BS(<em>delta_max<\/em>,<em>confidence<\/em>)<\/code> same as previously, but using a binary search algorithm instead.<\/p>\n<p><code><code>spec<\/code>.getUsefulnessGame()<\/code> returns the timed game used to check the usefulness of the specification.<\/p>\n<p style=\"text-align: justify;\"><code><code>spec<\/code>.getRobustUsefulnessGame(<em>delta<\/em>,<em>param<\/em>)<\/code> returns the robust consistency game used to check robust usefulness. <em>delta<\/em> is either an integer value, or a parameter name. By default <em>delta<\/em> is a parameter named &#8220;delta&#8221;. <em>param<\/em> is only useful if <em>delta<\/em> is a parameter, in which case <em>param<\/em> is the initial value of <em>delta<\/em>. By default <em>param<\/em>=0.<\/p>\n<h6 style=\"text-align: justify;\">Refinement and satisfaction checking<\/h6>\n<p style=\"text-align: justify;\"><code>spec.refine(big_spec)<\/code> return True or False, if the specification spec refines the specification big_spec. The refinement check is also used to check if an implementation satisfies a specification. The python operators &lt;= and &gt;= can also be used to check the refinement:<\/p>\n<p><code>spec &lt;= big_spec<\/code> or <code>big_spec &gt;= spec<\/code> are equivalent to the function call above.<\/p>\n<p style=\"text-align: justify;\"><code>spec.robSat(big_spec,<em>delta<\/em><em><\/em>)<\/code> checks if spec is a robust implementation of big_spec for a perturbation of <em>delta<\/em><\/p>\n<p style=\"text-align: justify;\"><code>spec.maxRobSat(big_spec,<em>delta_max<\/em>,<em>confidence<\/em>)<\/code> computes the maximum perturbation allowed by the implementation spec in order to robustly satisfies the specification big_spec. <em>delta_max<\/em> is an integer value, sufficiently big to know that the implementation is not robust, and <em>confidence<\/em> is a float value that defines the precision of the computation.<\/p>\n<p style=\"text-align: justify;\"><code>spec.implemPerturbation(<em>delta<\/em>,<em>param<\/em>)<\/code> Applies a perturbation to the guards of the implementation. <em>delta<\/em> is either an integer value, or a parameter name. By default <em>delta<\/em> is a parameter named &#8220;delta&#8221;. <em>param<\/em> is only useful if <em>delta<\/em> is a parameter, in which case <em>param<\/em> is the initial value of <em>delta<\/em>. By default <em>param<\/em>=0.<\/p>\n<h6>T-AdaCTL checking<\/h6>\n<p><a name=\"tadactl\"><\/a><\/p>\n<p>The logic T-AdaCTL is introduced in [CLST13]. The grammar of the logic used by PyECDAR is the following:<\/p>\n<p><code>tadactlformula := ( \"[\" <em>featureExpression<\/em> \"]\" )? stateFormula<br \/>\nstateFormula := \"A\" pathFormula | \"E\" pathFormula) | orFormula<br \/>\npathFormula := (\"(\"featureFormula \")\" [\"U\"|\"W\"] interval? \"(\" featureFormula \")\") |<br \/>\n(\"&lt;&gt;\" interval? \"(\" featureFormula \")\") |<br \/>\n(\"[]\" \"(\" featureFormula \")\")<br \/>\norFormula\u00a0:=\u00a0andFormula (\"or\" orFormula)*<br \/>\nandFormula := notFormula (\"and\" andFormula)*<br \/>\nnotFormula := (\"not\")? atomicFormula<br \/>\natomicFormula := \"true\" | \"false\" | <em>guard<\/em> | <em>location<\/em> | \"(\"\u00a0tadactlformula \")\"<\/code><\/p>\n<p><em>featureExpression<\/em> is an expression over feature variables, <em>guard<\/em> is an expression that defines a DBM and <em>location<\/em> is the name of a location in the template.<br \/>\nTo solve a timed game launch the command:<\/p>\n<p><code>game.solve() <\/code>This solves the game and prints the results.<\/p>\n<p><code>game.print_results(all_states)<\/code> Prints the result of the game. If the parameter all_states is true (by default it&#8217;s false) all the winning states are printed. Otherwise only the winning features for the initial state are printed.<br \/>\n<code><br \/>\ngame.get_winning_features()<\/code> Returns the BDD with the winning features for the initial state.<\/p>","protected":false},"excerpt":{"rendered":"<p>We describe PyECDAR fonctions that are called inside the Python shell. Loading, system construction and saving The tool is imported with the python command: from pyecdar import loadModel To run it the shell must either be launched from pyecdar directory or the tool must have been installed in the system. See the section Installation. A &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"https:\/\/project.inria.fr\/pyecdar\/queries\/\">Continue reading<\/a><\/p>\n","protected":false},"author":235,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-338","page","type-page","status-publish","hentry","nodate","item-wrap"],"_links":{"self":[{"href":"https:\/\/project.inria.fr\/pyecdar\/wp-json\/wp\/v2\/pages\/338","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/project.inria.fr\/pyecdar\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/project.inria.fr\/pyecdar\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/project.inria.fr\/pyecdar\/wp-json\/wp\/v2\/users\/235"}],"replies":[{"embeddable":true,"href":"https:\/\/project.inria.fr\/pyecdar\/wp-json\/wp\/v2\/comments?post=338"}],"version-history":[{"count":13,"href":"https:\/\/project.inria.fr\/pyecdar\/wp-json\/wp\/v2\/pages\/338\/revisions"}],"predecessor-version":[{"id":353,"href":"https:\/\/project.inria.fr\/pyecdar\/wp-json\/wp\/v2\/pages\/338\/revisions\/353"}],"wp:attachment":[{"href":"https:\/\/project.inria.fr\/pyecdar\/wp-json\/wp\/v2\/media?parent=338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}