Proof wording for appointment
Consider the following code from assignment. The goal here is to prove that account transactions are commutative. From what I understand, there are two accounts e1 {cash 10} and e2 {cash 20}. So if I do a transaction on e1 giving 10 and then on e2 giving 10 and then I do it in reverse, then at the end the account state is the same. To do this, I have to prove that the account states between them are equivalent. as account status [e1 {10} e2 {20}] β [e1 {0} e2 {20}] β [e1 {0} e2 {10}] and [e1 {10} e2 {20}] β [e1 {10} e2 {10}] β [e1 {0} e2 {10}], i.e. the states in between lead to the same state. Am I correct? How to formulate this? At first glance, this looked trivial, but it is not that simple.
module Acc where
open import Data.Nat hiding (_β_; _+_; _β€_)
open import Data.Integer hiding (_β_; suc)
open import Data.String
open import Data.Product
open import Relation.Nullary
open import Relation.Nullary.Decidable
open import Relation.Binary.PropositionalEquality
-- Trivial example of an EDSL inspired by
-- http://www.lpenz.org/articles/hedsl-sharedexpenses/
-- We have n people who go on a trip
-- they pay for things
-- they give each other money
-- at the end we want to have the balance on each account
-- Syntax
infixr 10 _β’_
infixr 10 _and_
infix 20 _β_
data Person : Set where
P : String β Person
data Exp : Set where
_β_ : Person β β β Exp
_[_]β_ : Person β β β Person β Exp
_and_ : Exp β Exp β Exp
data Accounts : Set where
β‘ : Accounts
_,_ : (String Γ β€) β Accounts β Accounts
data _βα΅£_ : (String Γ β€) β Accounts β Set where
hereα΅£ : β {Ο s v} β (s , v) βα΅£ ((s , v) , Ο)
skipα΅£ : β {Ο s v s' v'} β
{Ξ± : False (s β s')} β (s , v) βα΅£ Ο β (s , v) βα΅£ ((s' , v') , Ο)
update : Accounts β String β β€ β Accounts
update β‘ s amount = (s , amount) , β‘
update ((sβ , amountβ) , accounts) sβ amountβ with (sβ β sβ)
... | yes _ = (sβ , (amountβ + amountβ)) , accounts
... | no _ = (sβ , amountβ) , update accounts sβ amountβ
data account : Exp β Accounts β Accounts β Set where
spend : β {s n Ο} β account (P s β (suc n)) Ο (update Ο s -[1+ n ])
give : β {sβ sβ n Ο} β account (P sβ [ suc n ]β P sβ) Ο
(update (update Ο sβ -[1+ n ]) sβ (+ (suc n)))
_β’_ : β {eβ eβ Οβ Οβ Οβ} β
account eβ Οβ Οβ β account eβ Οβ Οβ β account (eβ and eβ) Οβ Οβ
andComm : β {Ο Ο' Ο'' eβ eβ} β account (eβ and eβ) Ο Ο' β
account (eβ and eβ) Ο Ο'' β Ο' β‘ Ο''
andComm (aβ β’ a) (b β’ bβ) = {!!}
source to share
No one has answered this question yet
Check out similar questions: