AdaCore / RecordFlux

Formal specification and generation of verifiable binary parsers, message generators and protocol state machines
Apache License 2.0
104 stars 6 forks source link

Intermediate representation for sessions #1204

Closed treiher closed 1 year ago

treiher commented 1 year ago

Research

Concepts

Languages

Design

Approach

Specification ⇾ Model ⤵
                     Intermediate Representation ⇾ SPARK Model ⇾ SPARK Code
          Integration ⤴

Objectives

Instructions

Convertion from Model to IR

  1. Transform state actions into TAC format
  2. Transform model statements into IR instructions
  3. Infer and add assertions (e.g., preconditions of calls, checks to prevent overflows)

Mapping from Model to IR

Statements

Model Statement IR
VariableAssignment Assignment
MessageFieldAssignment Call?
Reset Call?
Append Call?
Extend Call?
Read Call?
Write Call?

Expressions (in VariableAssignment)

Model (in TAC format) IR
T := X T:= X
T := not X T := not X
T := X and Y T := X and Y
(Other boolean expressions) (Direct mapping)
(Mathematical expressions) (Direct mapping)
(Relations) (Direct mapping)
(Quantified expressions) (Direct mapping)
T := X'Size T := Type_Specific_Size_Func (X)
(Other attributes) (Equivalent mapping to call)
T := M.F T := Message_Type_Specific_Field_Func (M)
T := F (X, Y) (Direct mapping)
T := (1, 2, 3) (Direct mapping)
T := "FOO" (Direct mapping)
T := [for I in S if C => I.X] (Direct mapping or call)
T := M'(F1 => X, F2 => Y) (Direct mapping or call)
(Binding) (INVALID)

Implementation

treiher commented 1 year ago

Added in version 0.12.0.