formal languages - Z into Isabelle -
i trying input , prove z specifications in isabelle.
say have vending machine specification written in latex format:
\begin{zed} price:\nat \end{zed} \begin{schema}{vmstate} stock, takings: \nat \end{schema} \begin{schema}{vm\_operation} \delta vmstate \\ cash\_tendered?, cash\_refunded!: \nat \\ bars\_delivered! : \nat \end{schema} \begin{schema}{exact\_cash} cash\_tendered?: \nat \where cash\_tendered? = price \end{schema}
i don't know if should put schema's lemmas or functions?
this have far:
theory vendingmachine imports main fact "~~/src/hol/hoare/hoare_logic" begin type_synonym price = nat type_synonym stock = nat type_synonym takings = nat type_synonym cash_tendered = nat function exact_cash "(cash_tendered:nat)" cash_tendered ≡ price; end
the type synonyms work fine when exact cash schema have translated exact_cash functions keep getting errors.
so in summary know how input schema's isabelle.
some people developed frameworks z-specifications in isabelle/hol (other link) decade ago. (as far know, not maintained anymore – maybe can still of you.)
usually, z-specifications can rewritten tla specifications quite easily. so, try use actively maintained hol-tla-session of isabelle.
but let's first stick common isabelle/hol.
encoding z-specification fragment in plain isabelle/hol like:
theory vendingmachine imports main begin --"record datatype state variables" record vmstate = stock :: nat takings :: nat --"a vending machine parameterized on price constant" locale vendingmachine = fixes price :: nat begin definition vm_operation :: "vmstate ⇒ vmstate ⇒ nat ⇒ nat ⇒ nat ⇒ bool" "vm_operation vmstate vmstate' cash_tendered cash_refunded bars_delivered ≡ true" --"todo: specify predicate" definition exact_cash :: "nat ⇒ bool" "exact_cash cash_tendered ≡ cash_tendered = price" end end
notice dropped distinction between in- , output variables. delta-variable vmstate
in vm_operation
split vmstate
, vmstate'
.
to work such specification, need more auxiliary definitions. instance, state space of specification defined inductive predicate like, e.g.:
inductive_set state_space :: "vmstate set" init: "⦇ stock = 10, takings = 0 ⦈ ∈ state_space" --"some initial state sake of meaningful definition...." | step: "vmstate ∈ state_space ∧ (∃ cash_tendered cash_refunded bars_delivered . vm_operation vmstate vmstate' cash_tendered cash_refunded bars_delivered) ⟹ vmstate' ∈ state_space"
Comments
Post a Comment