-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAck.lean
32 lines (27 loc) · 870 Bytes
/
Ack.lean
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
def ack : Nat → Nat → Nat
| 0, n => n + 1
| m + 1, 0 => ack m 1
| m + 1, n + 1 => ack m (ack (m + 1) n)
def ack' : Nat → Nat → Nat :=
Nat.rec
(fun n => n + 1)
fun _m ack_m => Nat.rec
(ack_m 1)
fun _n ack_sm_n => ack_m ack_sm_n
def ack'' : Nat → Nat → Nat
| 0 => fun n => n + 1
| m + 1 =>
let ack_m := ack'' m
let rec ack_sm
| 0 => ack_m 1
| n + 1 => ack_m (ack_sm n)
ack_sm
example : ack 0 n = n + 1 := rfl
example : ack (m + 1) 0 = ack m 1 := rfl
example : ack (m + 1) (n + 1) = ack m (ack (m + 1) n) := rfl
example : ack' 0 n = n + 1 := rfl
example : ack' (m + 1) 0 = ack' m 1 := rfl
example : ack' (m + 1) (n + 1) = ack' m (ack' (m + 1) n) := rfl
example : ack'' 0 n = n + 1 := rfl
example : ack'' (m + 1) 0 = ack'' m 1 := rfl
example : ack'' (m + 1) (n + 1) = ack'' m (ack'' (m + 1) n) := rfl