(* * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) * Copyright (c) 2022 Apple Inc. All rights reserved. * * SPDX-License-Identifier: BSD-2-Clause *) (* Termination for recursive functions. *) theory FactorialTest imports "AutoCorres2_Main.AutoCorres_Main" begin (* A fun fact *) function fact :: "('n :: len) word ⇒ ('n :: len) word" where "fact n = (if n = 0 then 1 else n * fact (n - 1))" by auto termination by (metis "termination" in_measure measure_unat wf_measure) declare fact.simps [simp del] lemma fact0 [simp]: "fact 0 = 1" by (subst fact.simps) simp (* Parse the input file. *)