There are a number of aspects to your question.
-, -, fun definition, :
fun test :: "nat ⇒ nat" where
"test (Suc 0) = 1" |
"test (Suc (Suc 0)) = 4" |
"test (Suc (Suc (Suc 0))) = 2" |
"test _ = undefined"
definition, fun. , (1, 2, 3 ..) nat (0 Suc) .
definition, , case, :
definition test2 :: "nat ⇒ nat" where
"test2 x ≡
case x of
(Suc 0) ⇒ 1
| (Suc (Suc 0)) ⇒ 4
| (Suc (Suc (Suc 0))) ⇒ 2
| _ ⇒ undefined"
, , test2, , test2_def , test2 .
( , , ), typedef, nat.
EDIT: typedef, - :
typedef t1 = "{x::nat. x = 1 ∨ x = 2 ∨ x = 3}"
by auto
definition test :: "t1 ⇒ t1" where
"test x ≡
case (Rep_t1 x) of
| Suc 0 ⇒ Abs_t1 1
| Suc (Suc 0) ⇒ Abs_t1 4
| Suc (Suc (Suc 0)) ⇒ Abs_t1 2"
, typedef , , - . typedef , , . , auto, , , , naturals , t1, . , Abs_t1 Rep_t1, naturals . print_theorems typedef, t1that Isabelle automatically generated for you.
source
share