{-# OPTIONS --safe #-}
open import Prelude
open import Hash
open import Jolteon.Assumptions
module Jolteon.Properties.Safety.Consistency (⋯ : _) (open Assumptions ⋯) where
open import Jolteon ⋯
open import Jolteon.Properties.Core ⋯
open import Jolteon.Properties.Steps ⋯
open import Jolteon.Properties.Safety.Core ⋯
open import Jolteon.Properties.Safety.Lemma1 ⋯
open import Jolteon.Properties.Safety.Lemma3 ⋯
safety : ∀ {s} → Reachable s →
∙ GloballyDirectCommitted s b
∙ GloballyDirectCommitted s b′
────────────────────────────
(b ←—∗ b′) ⊎ (b′ ←—∗ b)
safety {b = b}{b′}{s} Rs dcb dcb′
with ¿ b ∙round ≤ b′ ∙round ¿
... | yes r≤ = inj₁ $ safetyLemma Rs cb′ r≤ dcb
where cb′ = GDB⇒GCB Rs dcb′
... | no r≰ = inj₂ $ safetyLemma Rs cb (Nat.≰⇒≥ r≰) dcb′
where cb = GDB⇒GCB Rs dcb
consistency′ : ∀ {s} → (Rs : Reachable s) →
∙ Rs ∋⋯ StepCommits b
∙ Rs ∋⋯ StepCommits b′
───────────────────────
(b ←—∗ b′) ⊎ (b′ ←—∗ b)
consistency′ {b = b}{b′}{s} Rs cb cb′ =
safety Rs (Commit⇒GlobalDirectCommit Rs cb) (Commit⇒GlobalDirectCommit Rs cb′)
consistency : ∀ {s} → (Rs : Reachable s) →
∙ (∃ λ p → ∃ λ (hp : Honest p) → b ∈ (s @ʰ hp) .finalChain)
∙ (∃ λ p → ∃ λ (hp : Honest p) → b′ ∈ (s @ʰ hp) .finalChain)
──────────────────────────────────
(b ←—∗ b′) ⊎ (b′ ←—∗ b)
consistency Rs cb cb′ =
let b̂ , cb̂ , b←b̂ = getCommitPoint Rs (ch∈⇒StepCommits∈ Rs cb)
b̂′ , cb̂′ , b′←b̂′ = getCommitPoint Rs (ch∈⇒StepCommits∈ Rs cb′)
in
case consistency′ Rs cb̂ cb̂′ of λ where
(inj₁ b̂←b̂′) → ←∗-factor (←∗-trans b←b̂ b̂←b̂′) b′←b̂′
(inj₂ b̂′←b̂) → ←∗-factor b←b̂ (←∗-trans b′←b̂′ b̂′←b̂)