(* *********************************************************************)
(*                                                                     *)
(*              The Compcert verified compiler                         *)
(*                                                                     *)
(*          Xavier Leroy, INRIA Paris-Rocquencourt                     *)
(*                                                                     *)
(*  Copyright Institut National de Recherche en Informatique et en     *)
(*  Automatique.  All rights reserved.  This file is distributed       *)
(*  under the terms of the GNU General Public License as published by  *)
(*  the Free Software Foundation, either version 2 of the License, or  *)
(*  (at your option) any later version.  This file is also distributed *)
(*  under the terms of the INRIA Non-Commercial License Agreement.     *)
(*                                                                     *)
(* *********************************************************************)
(** Tools for small-step operational semantics *)
(** This module defines generic operations and theorems over the one-step transition relations that are used to specify operational semantics in small-step style. *)
(*NEW*) Require Import AST. (*NEW*) Require Import Values. (*NEW*) Require Import Memory. (* To specify injections*)
Set Implicit Arguments.
(** * Closures of transitions relations *)
Section CLOSURES.
Variable genv: Type.
Variable state: Type.
(** A one-step transition relation has the following signature. It is parameterized by a global environment, which does not change during the transition.  It relates the initial state of the transition with its final state.  The [trace] parameter captures the observable events possibly generated during the transition. *)
Variable step: state -> trace -> state -> Prop.
(** No transitions: stuck state *)
Definition nostep (s: state) : Prop :=
forall t s', ~(step s t s').
(** Zero, one or several transitions.  Also known as Kleene closure, or reflexive transitive closure. *)
Inductive star : state -> trace -> state -> Prop :=
| star_refl: forall s,
star s E0 s
| star_step: forall s1 t1 s2 t2 s3 t,
step s1 t1 s2 -> star s2 t2 s3 -> t = t1 ** t2 ->
star s1 t s3.

Lemma star_one:
forall s1 t s2, step s1 t s2 -> star s1 t s2.