<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../../../unit.xsl"?>
<KIVSPEC name="simple-AASM">
<SPECBODY>
<external/>asm specification 
   comment: approximate specification of the abstract level
            of the Mondex case study as an ASM: the ASM chooses
            which transfers to do arbitrarily instead of reading
            from an input stream.  Also we do not have an (empty)
            ABIGNORE operations, since ASM refinement does not 
            require 1:1 diagrams. A concrete operation
            can be verified using a 0:1 diagram instead.;
   using <a href="../../../specs/set-nat/export/unit.xml">set-nat</a> <a href="../../../specs/genname/export/unit.xml">genname</a>
   declaration 

      <syn>initial state</syn>
      lost := λ na. 0 

      <syn>final state</syn>
      false

      <syn>ASTEP</syn># 
           <syn>choose</syn>  fail?, value, from, to
           <syn>with</syn> (authentic(from) ∧ authentic(to) ∧ from ≠ to ∧ value ≤ balance(from))
           <syn>in</syn> <syn>if</syn> ¬ fail?
            <syn>then</syn> 
             balance(from) := balance(from) - value <syn>seq</syn>
             balance(to) := balance(to) + value
            <syn>else</syn> 
             balance(from) := balance(from) - value 
             lost(from) := lost(from) + value

end asm specification</SPECBODY>

<SPECBODY>
<internal/>asm specification 
   comment: approximate specification of the abstract level
            of the Mondex case study as an ASM: the ASM chooses
            which transfers to do arbitrarily instead of reading
            from an input stream.  Also we do not have an (empty)
            ABIGNORE operations, since ASM refinement does not 
            require 1:1 diagrams. A concrete operation
            can be verified using a 0:1 diagram instead.;
   using <a href="../../../specs/set-nat/export/unit.xml">set-nat</a> <a href="../../../specs/genname/export/unit.xml">genname</a>
    target 
         procedures 
            AASM#   : (name → nat) × (name → nat) nonfunctional indeterministic;
            ASTEP#   : (name → nat) × (name → nat) nonfunctional indeterministic;
         variables 
            balance, lost : name → nat; 
            fail? : bool; 
            value : nat; 
            from, to : name; 
   declaration 
      asm : AASM# (var balance, lost)
              begin 
                 lost := λ na. 0 ; while ¬ false do ASTEP#(; balance, lost)
              end;
      ASTEP# (var balance, lost)
        begin 
           var  fail?, value, from, to
           with (authentic(from) ∧ authentic(to) ∧ from ≠ to ∧ value ≤ balance(from))
           in if ¬ fail?
              then begin 
                      balance(from) := balance(from) - value ; balance(to) := balance(to) + value
                   end
              else balance(from) := balance(from) - value, lost(from) := lost(from) + value
        end;
end asm specification</SPECBODY></KIVSPEC>
