Notation sig := nat.Definition rule : Type := sig * list sig.Definition cfg : Type := sig * list rule.Definition rules (G : cfg) := snd G.Definition startsym (G : cfg) := fst G.Inductive rewt (S: cfg) (x: list sig) : list sig -> Prop :=
  |rewtRefl : rewt S x x
  |rewtRule y z : rewt S x y -> rew_cfg S y z -> rewt S x z.Inductive rewt (S: cfg) (x: list sig) : list sig -> Prop :=
  |rewtRefl : rewt S x x
  |rewtRule y z : rewt S x y -> rew_cfg S y z -> rewt S x z.Inductive rewt (S: cfg) (x: list sig) : list sig -> Prop :=
  |rewtRefl : rewt S x x
  |rewtRule y z : rewt S x y -> rew_cfg S y z -> rewt S x z.Global Instance rewtTrans R :
    PreOrder (rewt R).Global Instance subrel R :
    subrelation (rew_cfg R) (rewt R).Definition terminal G x := ~ exists y, rew_cfg G x y.

Lemma terminal_iff G x : terminal G x <-> forall s y, s el x -> ~ (s, y) el rules G.