Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some utilities on invariant names #5

Merged
merged 5 commits into from
Feb 19, 2024
Merged

Some utilities on invariant names #5

merged 5 commits into from
Feb 19, 2024

Conversation

nikswamy
Copy link
Contributor

This PR provides three utilities for working with invariant names.

1 & 2. A form on injectivity on invariant names. Both these lemmas involve eliminating an inv p and so are in stt_atomic Unobservable, i.e., they are computation steps since they involve using the recall operator of underlying monotonic state monad. That's why I also provided it in two forms, since it's not possible to take the contrapositive of these computation steps.

val distinct_invariants_have_distinct_names
    (#p #q:vprop)
    (i:inv p)
    (j:inv q { (p =!= q) })
: stt_atomic (_:squash (name_of_inv i =!= name_of_inv j))
    #Unobservable
    emp_inames
    emp
    (fun _ -> emp)
val invariant_name_identifies_invariant
      (#p #q:vprop)
      (i:inv p)
      (j:inv q { name_of_inv i == name_of_inv j } )
: stt_atomic (squash (p == q /\ i == j))
    #Unobservable
    emp_inames
    emp
    (fun _ -> emp)
  1. Allocating invariants fresh w.r.t a given context:
val fresh_invariant
    (ctx:list allocated_name)
    (p:vprop)
: stt_atomic (i:inv p { name_of_inv i `fresh_wrt` ctx }) #Unobservable emp_inames p (fun _ -> emp)

Note, here I use a notion of allocated_name instead of just a raw iname, though the two are related like so:

val allocated_name : Type0
val allocated_name_of_inv #p (i : inv p) : allocated_name
val name_of_allocated_name (a:allocated_name) : GTot iname
val allocated_name_of_inv_equiv (#p:vprop) (i:inv p)
: Lemma (name_of_allocated_name (allocated_name_of_inv i) == name_of_inv i)
       [SMTPat (name_of_allocated_name (allocated_name_of_inv i))]

@nikswamy nikswamy merged commit 0fcc5cf into main Feb 19, 2024
2 checks passed
@nikswamy nikswamy deleted the nik_inv_utils branch February 19, 2024 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant