lean4-htt/tests/lean/run/wfSum.lean
2022-02-18 10:40:32 -08:00

9 lines
223 B
Text

def sum (as : Array Nat) : Nat :=
go 0 0
where
go (i : Nat) (s : Nat) : Nat :=
if h : i < as.size then
go (i+1) (s + as.get ⟨i, h⟩)
else
s
termination_by' measure (fun ⟨i, s⟩ => as.size - i)