Section CR.
Open Scope recurrence_scope.
Inductive CR :=
| liftBRToCR: BR -> CR
| recurCR: R -> (R -> R -> R) -> CR -> CR
.
(** Interpret a CR as nested BRs as described in section 2 - Chains of Recurrences *)
Fixpoint CR_to_BR (cr: CR): BR :=
match cr with
| liftBRToCR br =>  br
| recurCR r0 bop cr' => mkBR r0 bop (evalAtIx (CR_to_BR cr'))
end.
Definition evalCR(cr: CR) (n: nat): R := (CR_to_BR cr) # n.
(** Define what it means to evaluate a CR *)
Global Instance loopVariantCR : LoopVariant CR R :=
{
evalAtIx (cr: CR) (n: nat) := evalCR cr n
}.
Hint Resolve creval_lift_br_to_cr_inverses: Recurrence.

(** Show what happens at n = 0 *)
Lemma evalCR_zero: forall
`{Ring R}
(cr': CR) (r: R) (bop: R -> R -> R),
(recurCR r bop cr') # 0 = r.