Skip to content

Commit

Permalink
collatz stated
Browse files Browse the repository at this point in the history
  • Loading branch information
archiebrowne committed Nov 16, 2023
1 parent d742928 commit 3ee7a21
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Game/Levels/Hard.lean
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import GameServer.Commands
import Game.Levels.LessOrEqual
import Game.Levels.Power
import Game.MyNat.Addition
import Game.MyNat.Multiplication

World "Hard"
Title "Hard World"
Expand Down
28 changes: 18 additions & 10 deletions Game/Levels/Hard/level_2.lean
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Game.Levels.Hard.level_1
import Game.MyNat.Multiplication




World "Hard"
Expand All @@ -23,16 +26,24 @@ LemmaDoc MyNat.Colatz as "Collatz" in "Hard" "
"

-- halving used for the sequence
def half (n : ℕ) :=
def half (n : ℕ) : ℕ :=
match n with
|0 => 0
|1 => 0
|(a + 2) => half a + 1

def even (n : ℕ) :=
match n with
| 0 => 0
| 1 => 0
| (a + 2) => half a + 1
| 1 => 1
| (a + 2) => even a

-- 'collatz function'
def f (x : ℕ) :=
match even x with
| true => half n
| false => 3 * n + 1
if (even x == 1) then
3 * x + 1
else
(half x)

-- kᵗʰ collatz term stariting at n
def collatz (n k : ℕ) :=
Expand All @@ -41,8 +52,5 @@ def collatz (n k : ℕ) :=
| succ b => f (collatz n b)


Statment Collatz : ∀ (n : ℕ), ∃ (k : ℕ), collatz n k = 1 := by
Statement Collatz : ∀ (n : ℕ), ∃ (k : ℕ), collatz n k = 1 := by
sorry


#eval half 4

0 comments on commit 3ee7a21

Please sign in to comment.