Require Import Relation_Operators List.
Import ListNotations.

Definition State := .
Definition Symbol := bool.

Definition Stack : Set := list Symbol.

Definition Config : Set := Stack * Stack * State.

Definition Instruction : Set := Config * Config.

Definition SMN : Set := list Instruction.

Inductive step (M : SMN) : Config Config Prop :=
  | transition (v w r s r' s': Stack) (x y: State) :
    In ((r, s, x), (r', s', y)) M
    step M (r v, s w, x) (r' v, s' w, y).

Definition deterministic (M: SMN) := (X Y Z: Config), step M X Y step M X Z Y = Z.

Definition reachable (M: SMN) : Config Config Prop := clos_refl_trans Config (step M).

Definition confluent (M: SMN) := (X Y1 Y2: Config), reachable M X reachable M X
   (Z: Config), reachable M Z reachable M Z.

Definition bounded (M: SMN) (n: ) : Prop :=
   (X: Config), (L: list Config), ( (Y: Config), reachable M X Y In Y L) length L n.

Definition length_preserving (M: SMN) : Prop :=
   s t X s' t' Y, In ((s, t, X), (s', t', Y)) M length (s t) = length (s' t') 1 length (s t).

Definition SMNdl_UB : { M : SMN | deterministic M length_preserving M } Prop :=
   '(exist _ M _) (n: ), bounded M n.