/*----------------------------------------------------------------------
--  User rules for package UserEntry.
--
--  File name: userentry.rlu
--
--  Description:
--    Package rule file.
--
--  Author: Phil Thornley, April 2009.  See www.sparksure.com
--
-- Copyright (c) 2009, Phil Thornley
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions
-- are met:
--
--  * Redistributions of source code must retain the above copyright
--    notice, this list of conditions and the following disclaimer.
--
--  * Redistributions in binary form must reproduce the above copyright
--    notice, this list of conditions and the following disclaimer in
--    the documentation and/or other materials provided with the distribution.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------*/


/*----------------------------------------------------------------------
--  Rule 1
--
--  Justification:
--    The return annotation on
--      UserEntry.CurrentActivityPossible(State, UserToken.State) includes
--      return R => (R -> Status > Quiescent)
--              and (R -> (Status = WaitingRemoveTokenFail ->
--                           not UserToken.IsPresent(UserToken.State)))
--    where Status is a component of the refinement of the abstract own
--    variable State of type Prf_StateT.
----------------------------------------------------------------------*/

userentry_user(1): quiescent < fld_status(S)
                     may_be_deduced_from
                   [ userentry__currentactivitypossible(S, US),
                     goal(checktype(S, prf_statet)) ] .

userentry_user(2): fld_status(S) = waitingremovetokenfail ->
                     not usertoken__ispresent(US)
                   may_be_deduced_from
                   [ userentry__currentactivitypossible(S, US),
                     goal(checktype(S, prf_statet)) ] .


/*----------------------------------------------------------------------
--  Rule 3
--
--  Justification:
--    The code of function InProgress is
--      return Status > Quiescent and Status < WaitingRemoveTokenFail;
--    where Status is access globally.
----------------------------------------------------------------------*/
userentry_user(3): inprogress(St)
                     may_be_replaced_by
                   quiescent < St and St < waitingremovetokenfail
                     if
                   [ St >= statust__first,
                     St <= statust__last ] .


/*----------------------------------------------------------------------
--  Rule 4
--
--  Justification:
--    The code of function UserHasDeparted(Status, UserToken.State) is
--      return Status > Quiescent and not UserToken.IsPresent;
--    where Status and UserToken.State are accessed globally.
----------------------------------------------------------------------*/
userentry_user(4): userhasdeparted(St, US)
                     may_be_replaced_by
                   quiescent < St and not usertoken__ispresent(US)
                     if
                   [ St >= statust__first,
                     St <= statust__last ] .
