RosettaCodeData/Task/Conditional-structures/Isabelle/conditional-structures.isabelle

23 lines
524 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
theory Scratch
imports Main
begin
textif-then-else
lemma "(if True then 42 else 0) = 42" by simp
textcase statement with pattern matching, which evaluates to the True-case
lemma "case [42] of
Nil ⇒ False
| [x] ⇒ True
| x#xs ⇒ False" by simp
textLoops are implemented via recursive functions
fun recurse :: "nat ⇒ nat" where
"recurse 0 = 0"
| "recurse (Suc n) = recurse n"
textThe function always returns zero.
lemma "recurse n = 0" by(induction n) simp+
end