Skip to content

Commit 0299def

Browse files
committed
Implemented simulation function
1 parent fc21fa8 commit 0299def

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

.github/workflows/lean_action_ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ on:
1313
jobs:
1414
build:
1515
runs-on: ubuntu-latest
16-
1716
steps:
1817
- uses: actions/checkout@v4
1918
- uses: leanprover/lean-action@v1

analysis/markov/Linleios/Evolve.lean

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def forge {env : Environment} (state : State) : List (State × Probability) :=
4949
state with
5050
rbCount := state.rbCount + 1
5151
}
52-
, env.pSpacingOkay
52+
, 1 - env.pSpacingOkay
5353
5454
, ⟨
5555
{
@@ -72,3 +72,10 @@ def evolve (transition : State → List (State × Probability)) : Probabilities
7272
$ transition state
7373
)
7474
75+
76+
def simulate (transition : State → List (State × Probability)) (start : Probabilities) : Nat → Probabilities
77+
| 0 => start
78+
| n + 1 => simulate transition (evolve transition start) n
79+
80+
def totalProbability (states : Probabilities) : Probability :=
81+
states.values.sum

analysis/markov/Main.lean

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import Linleios
55
def env : Environment := makeEnvironment 0.05 1 4 7
66

77
def s0 : Probabilities := default
8-
def s1 := evolve (@forge env) s0
8+
def sn := simulate (@forge env) s0 5
9+
def pn := totalProbability sn
910

1011
def main : IO Unit :=
11-
IO.println $ (reprPrec s1 0).pretty
12+
do
13+
IO.println $ (reprPrec sn 0).pretty
14+
IO.println $ (reprPrec pn 0).pretty

0 commit comments

Comments
 (0)