Skip to content

Commit f3e8941

Browse files
committed
Extend test
1 parent b6a44f1 commit f3e8941

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

tests/lean/run/structuralEqn6.lean

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@ def trailingZeros (i : Int) : Nat :=
22
if h : i = 0 then 0 else aux i.natAbs i h (Nat.le_refl _) 0
33
where
44
aux (k : Nat) (i : Int) (hi : i ≠ 0) (hk : i.natAbs ≤ k) (acc : Nat) : Nat :=
5-
match k with
6-
| k + 1 =>
5+
match k, (by omega : k ≠ 0) with
6+
| k + 1, _ =>
77
if h : i % 2 = 0 then aux k (i / 2) (by omega) (by omega) (acc + 1)
88
else acc
9-
| 0 => by omega
109
termination_by structural k
1110

1211
/--
1312
info: equations:
14-
@[defeq] theorem trailingZeros.aux.eq_1 : ∀ (i : Int) (hi : i ≠ 0) (acc k_2 : Nat) (hk_2 : i.natAbs ≤ k_2 + 1),
13+
@[defeq] theorem trailingZeros.aux.eq_1 : ∀ (i : Int) (hi : i ≠ 0) (acc k_2 : Nat) (x_1 : k_2 + 1 ≠ 0)
14+
(hk_2 : i.natAbs ≤ k_2 + 1),
1515
trailingZeros.aux k_2.succ i hi hk_2 acc = if h : i % 2 = 0 then trailingZeros.aux k_2 (i / 2) ⋯ ⋯ (acc + 1) else acc
16-
@[defeq] theorem trailingZeros.aux.eq_2 : ∀ (i : Int) (hi : i ≠ 0) (acc : Nat) (hk_2 : i.natAbs ≤ 0),
17-
trailingZeros.aux 0 i hi hk_2 acc = acc
1816
-/
1917
#guard_msgs(pass trace, all) in
2018
#print equations trailingZeros.aux
@@ -44,9 +42,6 @@ theorem trailingZeros'.aux.eq_1 : ∀ (i : Int) (hi : i ≠ 0) (acc k_2 : Nat) (
4442
#guard_msgs(pass trace, all) in
4543
#print equations trailingZeros'.aux
4644

47-
48-
49-
/-- The number of trailing zeros in the binary representation of `i`. -/
5045
def trailingZeros2 (i : Int) : Nat :=
5146
if h : i = 0 then 0 else aux i.natAbs i h (Nat.le_refl _) 0
5247
where
@@ -68,3 +63,25 @@ info: equations:
6863
-/
6964
#guard_msgs(pass trace, all) in
7065
#print equations trailingZeros2.aux
66+
67+
def trailingZeros2' (i : Int) : Nat :=
68+
if h : i = 0 then 0 else aux i.natAbs i h (Nat.le_refl _) 0
69+
where
70+
aux (k : Nat) (i : Int) (hi : i ≠ 0) (hk : i.natAbs ≤ k) (acc : Nat) : Nat :=
71+
match k with
72+
| k + 1 =>
73+
if h : i % 2 = 0 then aux k (i / 2) (by omega) (by omega) (acc + 1)
74+
else acc
75+
| 0 => by omega
76+
termination_by k
77+
78+
/--
79+
info: equations:
80+
theorem trailingZeros2'.aux.eq_1 : ∀ (i : Int) (hi : i ≠ 0) (acc k_2 : Nat) (hk_2 : i.natAbs ≤ k_2 + 1),
81+
trailingZeros2'.aux k_2.succ i hi hk_2 acc =
82+
if h : i % 2 = 0 then trailingZeros2'.aux k_2 (i / 2) ⋯ ⋯ (acc + 1) else acc
83+
theorem trailingZeros2'.aux.eq_2 : ∀ (i : Int) (hi : i ≠ 0) (acc : Nat) (hk_2 : i.natAbs ≤ 0),
84+
trailingZeros2'.aux 0 i hi hk_2 acc = acc
85+
-/
86+
#guard_msgs(pass trace, all) in
87+
#print equations trailingZeros2'.aux

0 commit comments

Comments
 (0)