Properties

{-# OPTIONS --safe #-}

open import Ledger.Conway.Gov.Base

module Ledger.Conway.Enact.Properties (gs : _) (open GovStructure gs) where

open import Ledger.Prelude

open import Ledger.Conway.Gov.Actions gs hiding (yes; no)
open import Ledger.Conway.Enact gs

open EnactState

open Computational ⦃...⦄

instance
  Computational-ENACT : Computational _⊢_⇀⦇_,ENACT⦈_ String
  Computational-ENACT .computeProof Γᵉ s =
    let open EnactEnv Γᵉ renaming (treasury to t; epoch to e) in
    λ where
    $\begin{pmatrix} \,\href{Ledger.Conway.Gov.Actions.html#1420}{\htmlId{506}{\htmlClass{InductiveConstructor}{\text{NoConfidence}}}}\, \\ \,\htmlId{521}{\htmlClass{Symbol}{\text{\_}}}\, \end{pmatrix}$                 success (_ , Enact-NoConf)
    $\begin{pmatrix} \,\href{Ledger.Conway.Gov.Actions.html#1455}{\htmlId{577}{\htmlClass{InductiveConstructor}{\text{UpdateCommittee}}}}\, \\ (\,\href{Ledger.Conway.Enact.Properties.html#596}{\htmlId{596}{\htmlClass{Bound}{\text{new}}}}\, , \,\href{Ledger.Conway.Enact.Properties.html#602}{\htmlId{602}{\htmlClass{Bound}{\text{rem}}}}\, , \,\href{Ledger.Conway.Enact.Properties.html#608}{\htmlId{608}{\htmlClass{Bound}{\text{q}}}}\,) \end{pmatrix}$ 
      case ¿ ∀[ term  range new ]
               term  ccMaxTermLengthOf s +ᵉ' e ¿ of λ where
      (yes p)  success (-, Enact-UpdComm
        (subst  x  ∀[ term  range new ] term  x) (sym +ᵉ≡+ᵉ') p))
      (no ¬p)  failure "ENACT failed at ∀[ term ∈ range new ] term ≤ (ccMaxTermLengthOf s +ᵉ e)"
    $\begin{pmatrix} \,\href{Ledger.Conway.Gov.Actions.html#1490}{\htmlId{930}{\htmlClass{InductiveConstructor}{\text{NewConstitution}}}}\, \\ \,\htmlId{948}{\htmlClass{Symbol}{\text{\_}}}\, \end{pmatrix}$  success (-, Enact-NewConst)
    $\begin{pmatrix} \,\href{Ledger.Conway.Gov.Actions.html#1525}{\htmlId{990}{\htmlClass{InductiveConstructor}{\text{TriggerHF}}}}\,       \\ \,\htmlId{1008}{\htmlClass{Symbol}{\text{\_}}}\, \end{pmatrix}$  success (-, Enact-HF)
    $\begin{pmatrix} \,\href{Ledger.Conway.Gov.Actions.html#1560}{\htmlId{1044}{\htmlClass{InductiveConstructor}{\text{ChangePParams}}}}\,   \\ \,\htmlId{1062}{\htmlClass{Symbol}{\text{\_}}}\, \end{pmatrix}$  success (-, Enact-PParams)
    $\begin{pmatrix} \,\href{Ledger.Conway.Gov.Actions.html#1630}{\htmlId{1103}{\htmlClass{InductiveConstructor}{\text{Info}}}}\,            \\ \,\htmlId{1121}{\htmlClass{Symbol}{\text{\_}}}\, \end{pmatrix}$  success (-, Enact-Info) 
    $\begin{pmatrix} \,\href{Ledger.Conway.Gov.Actions.html#1595}{\htmlId{1160}{\htmlClass{InductiveConstructor}{\text{TreasuryWdrl}}}}\, \\ \,\href{Ledger.Conway.Enact.Properties.html#1175}{\htmlId{1175}{\htmlClass{Bound}{\text{wdrl}}}}\, \end{pmatrix}$ 
      case ¿ ∑[ x  s .withdrawals ∪⁺ wdrl ] x  t ¿ of λ where
        (yes p)              success (-, Enact-Wdrl p)
        (no _)               failure "ENACT failed at ∑[ x ← (s .withdrawals ∪⁺ wdrl) ᶠᵐ ] x ≤ t"
  Computational-ENACT .completeness Γᵉ s action _ p
    with action | p
  ... | $\begin{pmatrix} \,\htmlId{1487}{\htmlClass{DottedPattern Symbol}{\text{.}}}\,\,\href{Ledger.Conway.Gov.Actions.html#1420}{\htmlId{1488}{\htmlClass{DottedPattern InductiveConstructor}{\text{NoConfidence}}}}\,    \\ \,\htmlId{1506}{\htmlClass{Symbol}{\text{\_}}}\,               \end{pmatrix}$ | Enact-NoConf   = refl
  ... | $\begin{pmatrix} \,\htmlId{1560}{\htmlClass{DottedPattern Symbol}{\text{.}}}\,\,\href{Ledger.Conway.Gov.Actions.html#1455}{\htmlId{1561}{\htmlClass{DottedPattern InductiveConstructor}{\text{UpdateCommittee}}}}\, \\ (\,\href{Ledger.Conway.Enact.Properties.html#1580}{\htmlId{1580}{\htmlClass{Bound}{\text{new}}}}\, , \,\href{Ledger.Conway.Enact.Properties.html#1586}{\htmlId{1586}{\htmlClass{Bound}{\text{rem}}}}\, , \,\href{Ledger.Conway.Enact.Properties.html#1592}{\htmlId{1592}{\htmlClass{Bound}{\text{q}}}}\,) \end{pmatrix}$ | Enact-UpdComm p
    rewrite dec-yes
      (¿ ∀[ term  range new ] term
            ccMaxTermLengthOf s +ᵉ' EnactEnv.epoch Γᵉ ¿)
      (subst  x  ∀[ term  range new ] term  x) +ᵉ≡+ᵉ' p) .proj₂
      = refl
  ... | $\begin{pmatrix} \,\htmlId{1823}{\htmlClass{DottedPattern Symbol}{\text{.}}}\,\,\href{Ledger.Conway.Gov.Actions.html#1490}{\htmlId{1824}{\htmlClass{DottedPattern InductiveConstructor}{\text{NewConstitution}}}}\, \\ \,\htmlId{1842}{\htmlClass{Symbol}{\text{\_}}}\, \end{pmatrix}$ | Enact-NewConst = refl
  ... | $\begin{pmatrix} \,\htmlId{1882}{\htmlClass{DottedPattern Symbol}{\text{.}}}\,\,\href{Ledger.Conway.Gov.Actions.html#1525}{\htmlId{1883}{\htmlClass{DottedPattern InductiveConstructor}{\text{TriggerHF}}}}\,       \\ \,\htmlId{1901}{\htmlClass{Symbol}{\text{\_}}}\, \end{pmatrix}$ | Enact-HF       = refl
  ... | $\begin{pmatrix} \,\htmlId{1941}{\htmlClass{DottedPattern Symbol}{\text{.}}}\,\,\href{Ledger.Conway.Gov.Actions.html#1560}{\htmlId{1942}{\htmlClass{DottedPattern InductiveConstructor}{\text{ChangePParams}}}}\,   \\ \,\htmlId{1960}{\htmlClass{Symbol}{\text{\_}}}\, \end{pmatrix}$ | Enact-PParams  = refl
  ... | $\begin{pmatrix} \,\htmlId{2000}{\htmlClass{DottedPattern Symbol}{\text{.}}}\,\,\href{Ledger.Conway.Gov.Actions.html#1630}{\htmlId{2001}{\htmlClass{DottedPattern InductiveConstructor}{\text{Info}}}}\,            \\ \,\htmlId{2019}{\htmlClass{Symbol}{\text{\_}}}\, \end{pmatrix}$ | Enact-Info     = refl
  ... | $\begin{pmatrix} \,\htmlId{2059}{\htmlClass{DottedPattern Symbol}{\text{.}}}\,\,\href{Ledger.Conway.Gov.Actions.html#1595}{\htmlId{2060}{\htmlClass{DottedPattern InductiveConstructor}{\text{TreasuryWdrl}}}}\, \\ \,\href{Ledger.Conway.Enact.Properties.html#2075}{\htmlId{2075}{\htmlClass{Bound}{\text{wdrl}}}}\, \end{pmatrix}$ | Enact-Wdrl p
    rewrite dec-yes (¿ ∑[ x  s .withdrawals ∪⁺ wdrl ] x  EnactEnv.treasury Γᵉ ¿) p .proj₂
    = refl