1 import Base 2 import ../../lib/logic.bend as L 3 import ../../../spec/containers/doubly_linked_list.bend as S 4 import ../../../src/containers/doubly_linked_list.bend as D 5 import ./state.bend as ST 6 7 # The refinement statement of one step: the implementation's result is the 8 # real list of a new shadow with an observation, the specification's the 9 # shadow's model with the same observation, and the shadow is good. 10 11 def POK(~T: Data, -X: Data, spec: S.DS & X, r: D.DList & X) -> Type: 12 Sigma<&1, &1, ST.Sh, sh2 => Sigma<&1, &1, X, o => {r == (ST.real(~T, sh2), o) : D.DList & X} & ({spec == (ST.model(~T, sh2), o) : S.DS & X} & {ST.good(~T, sh2) == True{} : Bool})>> 13 14 # both results rewritten 15 def pok_eq(~T: Data, -X: Data, -spec: S.DS & X, -spec2: S.DS & X, -r: D.DList & X, -r2: D.DList & X, +es: {spec == spec2 : S.DS & X}, +er: {r == r2 : D.DList & X}, p: POK(~T, X, spec2, r2)) -> POK(~T, X, spec, r): 16 p1 = L.subst(D.DList & X, z => POK(~T, X, spec2, z), r2, r, Equal.sym(D.DList & X, r, r2, er), p) 17 L.subst(S.DS & X, z => POK(~T, X, z, r), spec2, spec, Equal.sym(S.DS & X, spec, spec2, es), p1)