@@ -21,39 +21,46 @@ This diagram describes the extraction and verification workflow for KMIR:
2121![ kmir_env_diagram_march_2025] ( https://github.com/user-attachments/assets/bf426c8d-f241-4ad6-8cb2-86ca06d8d15b )
2222
2323
24- To understand how KMIR works the K Framework must first be understood, and the
25- best description can be found at [ kframework.org] ( https://kframework.org/ ) :
26-
27- > K is a rewrite-based executable semantic framework in which programming
28- > languages, type systems and formal analysis tools can be defined using
29- > configurations and rules. Configurations organize the state in units called
30- > cells, which are labeled and can be nested. K rewrite rules make it explicit
31- > which parts of the term are read-only, write-only, read-write, or unused. This
32- > makes K suitable for defining truly concurrent languages even in the presence
33- > of sharing. Computations are represented as syntactic extensions of the
34- > original language abstract syntax, using a nested list structure which
35- > sequentializes computational tasks, such as program fragments. Computations
36- > are like any other terms in a rewriting environment: they can be matched,
37- > moved from one place to another, modified, or deleted. This makes K suitable
38- > for defining control-intensive features such as abrupt termination,
39- > exceptions, or call/cc.
40-
41- K (and thus KMIR) verifies program correctness using the
42- symbolic execution engine and verifier derived from the
43- K encoding of the languages operational semantics, in this case the Stable MIR semantics.
44- The K semantics framework is based on
45- reachability logic, which is a theory describing transition systems in [ matching
46- logic] ( http://www.matching-logic.org/ ) . Transition rules of the semantics are
47- rewriting steps that match patterns and transform the current continuation and
48- state accordingly. An all-path-reachability proof in this system verifies that a
49- particular _ target_ end state is _ always_ reachable from a given starting
50- state. The rewrite rules branch on symbolic inputs covering the possible
51- transitions, creating a model that is provably complete, and requiring
52- unification on every leaf state. A one-path-reachability proof is similar to the
53- above, but the proof requirement is that at least one leaf state unifies with
54- the target state. One feature of such a system is that the requirement for an
55- SMT is minimized to determining completeness on path conditions when branching
56- would occur.
24+ The K Framework ([ kframework.org] ( https://kframework.org/ ) is the basis of how
25+ KMIR operates to guarantee properties of Rust programs. K is a rewrite-based
26+ semantic framework based on [ matching logic] ( http://www.matching-logic.org/ ) in
27+ which programming languages, their operational semantics and type systems, and
28+ formal analysis tools can be defined through syntax, configurations, and rules.
29+ The _ syntax_ definitions in KMIR model the AST of Stable MIR (e.g., the
30+ statements and terminator of a basic block in a function body) and configuration
31+ data that exists at runtime (e.g., the stack frame structure of a function
32+ call).
33+ The _ configuration_ of a KMIR program organizes the state of an executed program in
34+ nested configuration units called cells (e.g., a stack frame is part of a stack
35+ stored in the configuration).
36+ _ K Framework transition rules_ of the KMIR semantics are rewriting steps that
37+ match patterns and transform the current continuation and state accordingly.
38+ They describe how program configuration and its contained data changes when
39+ particular program statements or terminators are executed (e.g., a returning
40+ function modifies the call stack and writes a return value into the caller's
41+ local variables).
42+
43+ Using the K semantics of Stable MIR, the KMIR execution of an entire Rust
44+ program represented as Stable MIR breaks down to a series of configuration
45+ rewrites that compute data held in local variables, and the program may either
46+ terminate normally or reach an exception or construct with undefined behaviour,
47+ which terminates the execution abnormally. Programs modelled in K Framework can
48+ be executed _ symbolically_ , i.e., operating on abstract input which is not fully
49+ specified but characterised by _ path conditions_ (e.g., that an integer variable
50+ holds an unknown but non-negative value).
51+
52+ K (and thus KMIR) verifies program correctness by performing an
53+ _ all-path-reachability proof_ using the symbolic execution engine and verifier
54+ derived from the K encoding of the Stable MIR operational semantics.
55+ The K semantics framework is based on reachability logic, which is a theory
56+ describing transition systems in [ matching logic] ( http://www.matching-logic.org/ ) .
57+ An all-path-reachability proof in this system verifies that a particular
58+ _ target_ end state is _ always_ reached from a given starting state.
59+ The rewrite rules branch on symbolic inputs covering the possible transitions,
60+ creating a model that is provably complete. For all-path reachability, every
61+ leaf state is required to unify with the target state.
62+ A one-path-reachability proof is similar to the above, but the proof requirement
63+ is that _ at least one_ leaf state unifies with the target state.
5764
5865KMIR also prioritizes UI with interactive proof exploration available
5966out-of-the-box through the terminal KCFG (K Control Flow Graph) viewer, allowing
0 commit comments