-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathPTLTL.hs
46 lines (39 loc) · 1.32 KB
/
PTLTL.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
-- |
-- Module: PTLTL
-- Description: Past-Time Linear-Temporal Logic
-- Copyright: (c) 2011 National Institute of Aerospace / Galois, Inc.
--
-- Provides past-time linear-temporal logic (ptLTL operators).
--
-- /Interface:/ See @Examples/PTLTLExamples.hs@ in the
-- <https://github.com/Copilot-Language/copilot/blob/v2.2.1/Examples Copilot repository>.
--
-- You can embed a ptLTL specification within a Copilot specification using
-- the form:
--
-- @
-- operator stream
-- @
{-# LANGUAGE NoImplicitPrelude #-}
module Copilot.Library.PTLTL
( since, alwaysBeen, eventuallyPrev, previous ) where
import Prelude ()
import Copilot.Language
-- | Did @s@ hold in the previous period?
previous :: Stream Bool -> Stream Bool
previous s = [ False ] ++ s
-- | Has @s@ always held (up to and including the current state)?
alwaysBeen :: Stream Bool -> Stream Bool
alwaysBeen s = s && tmp
where
tmp = [ True ] ++ s && tmp
-- | Did @s@ hold at some time in the past (including the current state)?
eventuallyPrev :: Stream Bool -> Stream Bool
eventuallyPrev s = s || tmp
where
tmp = [ False ] ++ s || tmp
-- | Once @s2@ holds, in the following state (period), does @s1@ continuously hold?
since :: Stream Bool -> Stream Bool -> Stream Bool
since s1 s2 = alwaysBeen ( tmp ==> s1 )
where
tmp = eventuallyPrev $ [ False ] ++ s2