@@ -63,27 +63,23 @@ def pQuorum (pSuccessfulVote committeeSize τ : Float) : Float :=
6363 let ⟨ μ , σ ⟩ := committeeDistribution pSuccessfulVote committeeSize
6464 1 - cdfGaussian (τ * committeeSize) μ σ
6565
66- #eval pQuorum 0 .90 600 0 .75
67-
6866
6967structure Environment where
7068 activeSlotCoefficient : Probability
7169 Lheader : Nat
7270 Lvote : Nat
7371 Ldiff : Nat
7472 pSpacingOkay : Probability
75- pRbHeaderArrives : Probability
76- pEbValidates : Probability
73+ pQuorum : Probability
7774
78- def makeEnvironment (activeSlotCoefficient pRbHeaderArrives pEbValidates : Float) (Lheader Lvote Ldiff : Nat) : Environment :=
75+ def makeEnvironment (activeSlotCoefficient pRbHeaderArrives pEbValidates committeeSize τ : Float) (Lheader Lvote Ldiff : Nat) : Environment :=
7976 {
8077 activeSlotCoefficient := activeSlotCoefficient
8178 Lheader := Lheader
8279 Lvote := Lvote
8380 Ldiff := Ldiff
8481 pSpacingOkay := (1 - activeSlotCoefficient).pow (3 * Lheader + Lvote + Ldiff - 1 ).toFloat
85- pRbHeaderArrives := pRbHeaderArrives
86- pEbValidates := pEbValidates
82+ pQuorum := pQuorum (pRbHeaderArrives * pEbValidates) committeeSize τ
8783 }
8884
8985
@@ -93,9 +89,10 @@ structure State where
9389 canCertify : Bool
9490deriving Repr, BEq, Hashable, Inhabited
9591
96- example : (default : State).rbCount = 0 := rfl
97-
98- example : (default : State).ebCount = 0 := rfl
92+ theorem genesis : (default : State).rbCount = 0 ∧ (default : State).ebCount = 0 := by
93+ constructor
94+ rfl
95+ rfl
9996
10097
10198def Probabilities := HashMap State Probability
@@ -108,7 +105,7 @@ instance : Inhabited Probabilities where
108105abbrev Outcomes := List (State × Probability)
109106
110107
111- def forge {env : Environment} (state : State) : Outcomes :=
108+ def certify {env : Environment} (state : State) : Outcomes :=
112109 let state' :=
113110 {
114111 state with
@@ -122,14 +119,14 @@ def forge {env : Environment} (state : State) : Outcomes :=
122119 ]
123120 else [(state', 1 )]
124121
125- def validate {env : Environment} (state : State) : Outcomes :=
122+ def vote {env : Environment} (state : State) : Outcomes :=
126123 [
127- (state, env.pRbHeaderArrives * env.pEbValidates )
128- , ({state with canCertify := false }, 1 - env.pRbHeaderArrives * env.pEbValidates )
124+ (state, env.pQuorum )
125+ , ({state with canCertify := false }, 1 - env.pQuorum )
129126 ]
130127
131128def step {env : Environment} : List (State → Outcomes) :=
132- [@forge env, @validate env]
129+ [@certify env, @vote env]
133130
134131
135132def evolve (transition : State → Outcomes) : Probabilities → Probabilities :=
0 commit comments