hermod-recon-framework
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hermod.ReCon.LTL.Formula

Synopsis

Documentation

type PropName = Text Source #

A property name (e.g. "thread", "node", etc.).

type VariableIdentifier = Text Source #

The type of variable identifiers used throughout the framework (LTL property variables and polynomial integer variables).

type IntValue = Int64 Source #

The numeric type used for integer event property values and polynomial arithmetic throughout the framework.

type TextValue = Text Source #

Text event property value.

data TextTerm Source #

Text term: a constant string or a variable ranging over strings.

data BinRel Source #

Binary comparison relation on an ordered type.

Constructors

Eq 
Lt 
Lte 
Gt 
Gte 

Instances

Instances details
Show BinRel Source # 
Instance details

Defined in Hermod.ReCon.Common.Types

Eq BinRel Source # 
Instance details

Defined in Hermod.ReCon.Common.Types

Ord BinRel Source # 
Instance details

Defined in Hermod.ReCon.Common.Types

data Formula event ty Source #

Default name: φ.

Formulas of a discrete-time Linear Temporal Logic (LTL) enriched with first-order quantification over event properties.

Time model. Time is a sequence of abstract units indexed by natural numbers. Each unit carries a finite multiset of typed events (see Event). The temporal connectives advance through this sequence:

  • ◯ φ — next unit
  • ☐ ᪲ₖ φ — every (k+1)-th unit from now, forever
  • ☐ⁿ φ — for each of the next n units
  • ♢ⁿ φ — for some unit within the next n
  • φ |ⁿ ψφ until ψ, within n units

Parameterisation. The type parameter ty is the vocabulary of event types; event is the concrete event representation (see Event). Atoms (Atom ty cs) assert that the current unit contains an event of type ty whose properties satisfy the constraints cs.

First-order layer. Quantifiers ∀x ∈ ℤ, ∃x ∈ ℤ, ∀x ∈ Text, ∃x ∈ Text, and their finite-domain variants, bind variables that can appear in property constraints, integer comparison atoms (PropIntBinRel), and text equality atoms (PropTextEq). The resulting fragment is decidable: integer arithmetic is handled by Cooper's quantifier elimination; text quantifiers are decided by finite enumeration (see Hermod.ReCon.LTL.Internal.IR.HomogeneousFormula.FinFree).

Constructors

Forall Word (Formula event ty)

☐ ᪲ₖ φ ≡ φ ∧ ◯ (◯ᵏ (☐ ᪲ₖ)) For every (k+1)-th unit of time from now, φ For example: ☐ ᪲₁ φ means for every other unit of time from now, φ ☐ ᪲₃ φ means for every 4-th unit of time from now, φ ☐ ᪲₀ φ means for every unit of time from now, φ

ForallN Word (Formula event ty)

☐ⁿ φ ☐⁰ φ ≡ ⊤ ☐¹⁺ᵏ φ ≡ φ ∧ ◯ (☐ᵏ φ) For each of the n units of time from now, φ

ExistsN Word (Formula event ty)

♢ⁿ φ ♢⁰ φ ≡ ⊥ ♢¹⁺ᵏ φ ≡ φ ∨ ◯ (♢ᵏ φ) For one of the n units of time from now, φ

Next (Formula event ty)

◯ φ For the next unit of time from now, φ.

NextN Word (Formula event ty)

◯ⁿ φ ◯⁰ φ ≡ φ ◯¹⁺ᵏ φ ≡ ◯ (◯ᵏ φ) For the n-th unit of time from now, φ

UntilN Word (Formula event ty) (Formula event ty)

φ |ⁿ ψ φ |⁰ ψ ≡ ⊤ φ |¹⁺ᵏ ψ ≡ ψ ∨ ¬ ψ ∧ φ ∧ (φ |ᵏ ψ) φ until ψ in the n units of time from now

Atom ty (Set PropConstraint)

ty c̄

Or (Formula event ty) (Formula event ty)

φ ∨ ψ

And (Formula event ty) (Formula event ty)

φ ∧ ψ

Not (Formula event ty)

¬ φ

Implies (Formula event ty) (Formula event ty)

φ ⇒ ψ

Top

T

Bottom

PropIntForall VariableIdentifier (Formula event ty)

∀x ∈ ℤ. φ — x ranges over all integers

PropTextForall VariableIdentifier (Formula event ty)

∀x ∈ Text. φ — x ranges over all strings

PropIntForallN VariableIdentifier (Set IntValue) (Formula event ty)

∀x ∈ v̄. φ — x ranges over the given integers

PropTextForallN VariableIdentifier (Set TextValue) (Formula event ty)

∀x ∈ v̄. φ — x ranges over the given strings

PropIntExists VariableIdentifier (Formula event ty)

∃x ∈ ℤ. φ — x ranges over all integers

PropTextExists VariableIdentifier (Formula event ty)

∃x ∈ Text. φ — x ranges over all strings

PropIntExistsN VariableIdentifier (Set IntValue) (Formula event ty)

∃x ∈ v̄. φ — x ranges over the given integers

PropTextExistsN VariableIdentifier (Set TextValue) (Formula event ty)

∃x ∈ v̄. φ — x ranges over the given strings

PropIntBinRel BinRel (Relevance event ty) IntTerm IntTerm

t rel t (integer)

PropTextEq (Relevance event ty) TextTerm TextValue

t = v (text)

Instances

Instances details
(Show ty, Show event) => Show (Formula event ty) Source # 
Instance details

Defined in Hermod.ReCon.LTL.Formula

Methods

showsPrec :: Int -> Formula event ty -> ShowS Source #

show :: Formula event ty -> String Source #

showList :: [Formula event ty] -> ShowS Source #

(Eq ty, Eq event) => Eq (Formula event ty) Source # 
Instance details

Defined in Hermod.ReCon.LTL.Formula

Methods

(==) :: Formula event ty -> Formula event ty -> Bool Source #

(/=) :: Formula event ty -> Formula event ty -> Bool Source #

(Ord ty, Ord event) => Ord (Formula event ty) Source # 
Instance details

Defined in Hermod.ReCon.LTL.Formula

Methods

compare :: Formula event ty -> Formula event ty -> Ordering Source #

(<) :: Formula event ty -> Formula event ty -> Bool Source #

(<=) :: Formula event ty -> Formula event ty -> Bool Source #

(>) :: Formula event ty -> Formula event ty -> Bool Source #

(>=) :: Formula event ty -> Formula event ty -> Bool Source #

max :: Formula event ty -> Formula event ty -> Formula event ty Source #

min :: Formula event ty -> Formula event ty -> Formula event ty Source #

unfoldForall :: Word -> Formula event ty -> Formula event ty Source #

unfoldForallN :: Word -> Formula event ty -> Formula event ty Source #

unfoldExistsN :: Word -> Formula event ty -> Formula event ty Source #

unfoldNextN :: Word -> Formula event ty -> Formula event ty Source #

unfoldUntilN :: Word -> Formula event ty -> Formula event ty -> Formula event ty Source #

relevance :: (Ord event, Ord ty) => Formula event ty -> Relevance event ty Source #

Compute the total Relevance of the formula.

type Relevance event ty = Set (event, ty) Source #

Set of relevant events.

and :: [Formula event ty] -> Formula event ty Source #

interpTimeunit :: (Word -> Word) -> Formula event ty -> Formula event ty Source #

It's useful to express temporal aspect of the formulas in a familiar time unit (e.g milliseconds). Yet, the LTL machinery works with nameless abstract time units. This function can be used to convert one into the other.

data OnMissingKey Source #

Controls evaluator behaviour when a formula atom references a property key that is absent from the event being evaluated.

  • BottomOnMissingKey — treat the atom as unsatisfied (); evaluation continues silently. Useful when events may legally omit optional fields.
  • CrashOnMissingKey — throw an exception. Useful during development to catch formula/event-schema mismatches early.

class Event a ty | a -> ty where Source #

Default name: e.

Interface between a concrete event representation a and the LTL evaluator. The functional dependency a -> ty fixes the event-type vocabulary once the event type is known.

Semantics. Each time unit presents a sequence of events to the evaluator. An Atom ty cs is satisfied by unit t if there exists an event e in t such that:

  1. ofTy e ty holds, and
  2. every constraint c ∈ cs matches e against intProps e ty or textProps e ty (see satisfiability-semantics.txt).

Precondition. intProps and textProps are only called when ofTy e ty is True; their behaviour is unspecified otherwise.

Methods

ofTy :: a -> ty -> Bool Source #

ofTy e ty — is event e of type ty?

intProps :: a -> ty -> Map VariableIdentifier IntValue Source #

Integer-valued properties of e relevant to type ty, keyed by property name. Precondition: ofTy e ty.

textProps :: a -> ty -> Map VariableIdentifier TextValue Source #

Text-valued properties of e relevant to type ty, keyed by property name. Precondition: ofTy e ty.

beg :: a -> Word64 Source #

Timestamp of the event in microseconds. Used for diagnostics only; the LTL evaluator does not reason about wall-clock time.