All topics

Formal Models TL;DR

Dense summary of the most important concepts.

Automata

5-Tuple automaton spec = {States, Initial, alphabet, Faccept, Transitions}

Properties

Deterministic

  • At most one path per symbol

Complete

  • At least one path per symbol

Automata Types

Power automaton

  • Advantage: always deterministic & complete; same alphabet
  • Disadvantage: exponential state space
  • TODO: table of original; then make new table of all reachable states, including ∅ if original was incomplete

Oracle automaton

  • Advantage: linear state space; deterministic (if original has only 1 initial state)
  • Disadvantage: can become incomplete; has a different & bigger alphabet; needs external oracle for choices
  • TODO: just add the targets state to the transition name

Optimized oracle automaton

  • Advantage: linear state space; deterministic; smaller alphabet than unoptimized
  • Disadvantage: still different alphabet; can still be incomplete if original was incomplte; needs external oracle for choices
  • TODO: minimize oracle alphabet by mapping transition targets to the smallest possible set of numeric indices; n has to be minimal on a per-state and per-alphabet-symbol level

Complement automaton

  • If deterministic & complete
    • Just flip the final states
  • Else if deterministic & incomplete
    • make complete via a sink ∅
    • then just flip the final states
  • Else (assert nondeterministic)
    • Make power automaton
    • Then just flip the final states

Product automaton

  • TODO: make a merger of both, walking through all transitions simultaneously
    • A transition can only be taken if both have the transition
    • The product accepts only if both originals accept
    • Uses the synchronous parallel composition
    • NTS: takes a lot of time and thinking; do last in exam

Machines (Moore & Mealy)

Moore machine

  • Output bound to state (NTS: while stuck in a moor)
  • Convert to Mealy:
    • Make it deterministic and complete if necessary (power automaton)
    • Move the output (accept/reject) to all outgoing transitions (NTS: last step)
      • If a state accepts, all outgoing transitions have /1
      • If a state rejects, all outgoing transitions have /0

Mealy machine

  • Output bound to transition (NTS: while eating a meal)
  • Convert to Moore:
    • Determinism and completeness do not matter
    • The incoming accept/reject value is put into the states
    • This can require an extra state

Subset checking

L(A1)L(A2)    L(A1)L(A2)=L(A_1) \subseteq L(A_2) \iff L(A_1) \cap \overline{L(A_2)} = \varnothing

In words: A1A_1 is a subset of A2A_2 exactly when no word is accepted by A1A_1 and rejected by A2A_2.


Condition Event Nets (CEN)

4-Tuple CEN spec = {Conditions, Initial, Events, Graph}

Markings

A CEN with C|C| conditions has 2C2^{|C|} possible markings.

  • Each event consumes exactly 1 token
  • Each node can hold exactly 1 token

Conditions

  • Precondition G1G^{-1} of e: What needs to hold to make a transition possible (incoming arrows).
  • Postcondition G of e: What holds after a transition happened (outgoing arrows).

Place Transition Net (PTN)

5-Tuple PTN spec = {Places, Transitions, Flow relation, edge Weight mapping, Initial Markings}

PTN vs. CEN

  • Can have multiple tokens per place
    • The limit is the number next to the places
    • If a transition would exceed the limit, it is blocked
    • The default is ∞
  • Can consume and produce multiple tokens per event
    • The number is shown next to the edges
    • The default is 1

Labeled Transition System (LTS)

Just a graph of nodes (=states) whose directed edges (=state transitions) have labels (=actions/events) that trigger them.


Process Algebra (PA)

Terminology

SyntaxNameMeaning
a, b, cactionA step that can be performed.
P, Q, RprocessA behavior that may perform actions.
a.PprefixPerform a, then continue as P.
P + QchoiceChoose either P or Q, then discard the other.
P || QparallelDo P and Q simultaneously; if one is not affected, it is kept.
Σ(P)alphabetSet of all actions that can occur in P.
P -a-> QtransitionP can perform a and become Q.

Prefix

a.QaQa.Q \xrightarrow{a} Q

Choice

Choose to perform the action on one side; the other side can then be discarded.

a.P+b.QaPa.P+b.QbQ\begin{aligned} a.P + b.Q &\xrightarrow{a} P \\ a.P + b.Q &\xrightarrow{b} Q \end{aligned}

Parallel

For this example:

P0=a.b.P,Q0=b.c.CP_0 = a.b.P,\quad Q_0 = b.c.C
  1. compute the synchronization set:
Θ=Σ(P0)Σ(Q0)={a,b}{b,c}={b}\Theta = \Sigma(P_0) \cap \Sigma(Q_0) = \{a,b\} \cap \{b,c\} = \{b\}
  1. decide which rule applies.
  • Interleaving / Asynchronous

If the action is not in Θ\Theta, only one side performs the action. The other side stays unchanged.

a.b.Pb.c.Cab.Pb.c.C(aΘ)Pc.CcPC(cΘ)\begin{aligned} a.b.P \parallel b.c.C &\xrightarrow{a} b.P \parallel b.c.C \qquad (a \notin \Theta) \\ P \parallel c.C &\xrightarrow{c} P \parallel C \qquad (c \notin \Theta) \end{aligned}
  • Rendez-vous / Synchronization

If the action is in Θ\Theta, both sides must perform the action simultaneously.

b.Pb.c.CbPc.C(bΘ)b.P \parallel b.c.C \xrightarrow{b} P \parallel c.C \qquad (b \in \Theta)

Composition

Alphabet

Just a set of all action symbols of the given process.

P=a.b.b.PΣ(P)={a,b}Q=a.Rc.QΣ(Q)={a,c}S=a.P+c.RΣ(S)={a,b,c}Σ(P+Q)=Σ(PQ)=Σ(P)Σ(Q)={a,b}{a,c}={a,b,c}\begin{aligned} P &= a.b.b.P & \Sigma(P) &= \{a,b\} \\ Q &= a.R \parallel c.Q & \Sigma(Q) &= \{a,c\} \\ S &= a.P + c.R & \Sigma(S) &= \{a,b,c\} \\ \Sigma(P+Q) &= \Sigma(P\parallel Q) = \Sigma(P)\cup\Sigma(Q) = \{a,b\}\cup\{a,c\} = \{a,b,c\} \end{aligned}

Synchronization set

Forces all actions in it to happen in lockstep. If P and Q share a, this makes it a rendezvous point, meaning a can never happen in only one process. All other actions, such as b and c, can interleave freely.

Θpq=Σ(P)Σ(Q)={a,b}{a,c}={a}\Theta_{pq} = \Sigma(P)\cap\Sigma(Q) = \{a,b\}\cap\{a,c\} = \{a\}

Specifications

Satisfiable

  • For every allowed input, there exists at least one valid output.
  • NTS: At least one solution exists.

Underspecification

  • Multiple outputs are possible for the same input.
  • NTS: Too many solutions.

CTL Operators

Operators

Combined operators

FormulaMeaningNTS
EX φThere exists a successor with φone step reachable
AX φAll successors have φall next states
EF φThere exists a path where φ eventually occurscan reach φ
AF φOn every path φ eventually occursall must reach φ
EG φThere exists a path where φ holds foreverfind a φ-only cycle
AG φOn every path φ holds foreverφ is never violated
E(φ U ψ)There exists a path where φ holds until ψ occursstay in φ until ψ
A(φ U ψ)On every path φ holds until ψ occursmust stay in φ until ψ

Operator symbols

SymbolMeaning
Ethere exists a path
Aall paths
Xnext state
Feventually / future
Galways / globally
Uuntil

Equivalences

FormulaEquivalent
AG φ¬EF(¬φ)
AF φ¬EG(¬φ)
EG φ¬AF(¬φ)
EF φ¬AG(¬φ)

TLA+

TLA+ describes a state machine with logic: variables are the state, actions are the transitions.

Syntax

SyntaxMeaning
/\, \/and, or
xvalue in the current state (eg. precondition)
x'value in the next state (eg. postcondition)
UNCHANGED xshorthand for x' = x
Initallowed initial states
Nextdisjunction of all actions

Structure

---- MODULE Vending ----
EXTENDS Naturals

VARIABLES coins, brewing
vars == <<coins, brewing>>

Init == /\ coins = 0
        /\ brewing = FALSE

InsertCoin == /\ coins = 0
              /\ coins' = 1
              /\ UNCHANGED brewing

Next == \/ InsertCoin

Spec == Init /\ [][Next]_vars

Model checking

Invariants and reachability

TypeOK == coins \in 0..1 /\ brewing \in BOOLEAN
BrewingNotReachable == brewing = FALSE
  • Invariant:
    • Must hold in every reachable state.
  • Reachability:
    • Negate the target and check it as an invariant. A violation gives the path to the target.
  • Counterexample:
    • Read the error top-to-bottom
    • Each step shows the action and changed variables.
  • Deadlock:
    • The system is stuck because no actions in Next are enabled in this state.

Refinement

Abstract == INSTANCE Vending
THEOREM Spec1 => Abstract!Spec
  • A refinement adds detail but must preserve the abstract behavior.
  • Check Spec1 and add Abstract!Spec under Properties; THEOREM alone is not run by TLC.
  • Use INSTANCE ... WITH x <- expression when the refined representation differs.
  • Time is explicit: use a bounded counter in a wait action. More counter values mean more states.

Operators

SyntaxMeaningClassifies
[]Palways Psafety
<>Peventually Pliveness
P ~> Qwhenever P, eventually Qleads-to

Definitions

  • Stuttering: An enabled action may be ignored forever.
  • Fairness: May be required to prove liveness when the model contains non-deterministic transitions that allow the system to stall or stutter forever.
  • Liveness: Is the guarantee that progress eventually happens.

Fairness

  • No Fairness:
    • Use this when the action is optional for the liveness.
    • An external event that is not required to occur.
  • Weak fairness:
    • If an action is continuously enabled, it must eventually fire.
    • It is not enough when the precondition keeps becoming false and true.
  • Strong fairness:
    • If an action is infinitely often enabled, it must eventually fire.
    • Use if the action flickers between false and true.
Last updated: