§ Decreasing Metric for Mutual Recursive Functions

mutual
def bar (fooN : Nat) (barN : Nat)  : Nat :=
  match barN with 
  | 0 => foo fooN
  | n'+ 1 => bar fooN n'
termination_by (fooN, barN + 1) -- when dropping from bar to foo, give yourself an extra point.
decreasing_by
  . simp_wf; apply Prod.Lex.right; omega
  . simp_wf; apply Prod.Lex.right; omega

def foo (fooN : Nat) : Nat :=
  match fooN with
  | 0 => 42
  | fooN' + 1 => bar fooN' fooN

termination_by (fooN, 0)
decreasing_by
  · simp_wf; apply Prod.Lex.left; omega
end