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

23 lines
524 B
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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