ease the proof of coincidence count
[why3.git] / examples / coma / fact.coma
blob49e949554091a241c4dc28c6d6cce260cb264cf9
1 module Fact
3   use int.Int
4   use int.Fact
5   use coma.Std
7   let factorial (n: int) { n >= 0 } (return (m: int) { m = fact n })
8   = loop {1} {n}
9     [ loop (r: int) (k: int) =
10       { 0 <= k <= n }
11       { r * fact k = fact n }
12       (! if {k > 0} (-> loop {r * k} {k - 1})
13                     (-> return {r}) )]
15   let test (n: int) {} (o (m: int) { m = fact n })
16   = if {n >= 0 } (-> factorial {n} o)
17                  (-> halt)
18 end