(* ** Some Hoare Rules *)
From Undecidability Require Export TM.Compound.Multi TM.Combinators.Combinators.
From Undecidability.TM.Hoare Require Import HoareLogic HoareRegister.
(* *** Nop *)
(* A classic example for Hoare logic *)
(* *** [Relabel] *)
(* *** [Return] *)
(* *** Sequential Composition *)

(* Stronger version where we make a case-distinction, like in [If_TerminatesIn] *)
Lemma If_SpecT (sig : finType) (n : nat) (F : finType) (pM1 : pTM sig bool n) (pM2 pM3 : pTM sig F n)
(P : Assert sig n) (Q : bool -> Assert sig n) (R : F -> Assert sig n)
(k k1 k2 k3 : nat) :
TripleT P k1 pM1 Q ->
TripleT (Q true)  k2 pM2 R ->
TripleT (Q false) k3 pM3 R ->
(forall tin yout tout, P tin -> Q yout tout ->
(1 + k1 + if yout then k2 else k3) <= k) ->
TripleT P k (If pM1 pM2 pM3) R.