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

defproperty #123

Closed
joelburget opened this issue Jun 18, 2018 · 1 comment
Closed

defproperty #123

joelburget opened this issue Jun 18, 2018 · 1 comment
Assignees
Labels
enhancement FV Formal verification

Comments

@joelburget
Copy link
Contributor

joelburget commented Jun 18, 2018

We should add the ability to abstract over properties. Two motivating examples:

(defproperty pure
  [ (forall (table:table) (not (or (table-read table) (table-write table))))
    (not abort)
  ])

(defproperty (conserves-mass (table:table column:column)
  (= (column-delta table column) 0.0))

Notes:

  • Both examples assume abstraction over table and column names (Table quantification #122)
  • The first example assumes a more powerful property language which can speak of failure.
  • The second example is hardcoded to work over decimal columns. Though column-delta works over either decimal or integer columns, 0.0 is a decimal (and 0 is only an integer). We don't currently have any language feature which would allow us to specify a 0 that could be either.
  • Pact has a distinction between constants (defconst) and functions (defun). Do we want the equivalent for properties? My first example is a constant whereas the second is a function.
  • It's likely we'd also want abstraction for schema invariants, but this seems less useful, so my plan is to punt on this for now.
  • defined properties will be brought into scope via a use, like defined functions and constants.
@joelburget joelburget added enhancement FV Formal verification labels Jun 18, 2018
@joelburget joelburget mentioned this issue Jun 21, 2018
joelburget added a commit that referenced this issue Jun 22, 2018
Allow property abstraction.

fixes #123
joelburget added a commit that referenced this issue Jun 22, 2018
Allow property abstraction.

fixes #123
joelburget added a commit that referenced this issue Jul 8, 2018
Original commits:

* Generalize prenex normalization.
  - Previously only applicable to bool, now applicable to any ground type or
    object.
* Allow property abstraction.
* Allow properties to be imported.
* Warn when property names are shadowed.
* Update test for prenex normalization.

fixes #123
@joelburget
Copy link
Contributor Author

@slpopejoy I want to write out the design we discussed over the phone to make sure we all agree on how it should look concretely.

We introduce a model form, which can occur as a module top-level:

(module accounts 'accounts-admin-keyset
  "accounts module"
  (model
    ; TODO: abstract over table / column
    (defproperty conserves-mass
      (= (column-delta 'accounts 'balance) 0.0))

    (defproperty correct-auth
      (when
        (not (authorized-by 'accounts-admin-keyset))
        abort))
  )

  ...)

What's the syntax for function level properties? This doesn't read right:

  (defun transfer (src:string dest:string amount:decimal)
    "transfer AMOUNT from SRC to DEST"
    (model (property conserves-mass))
    (debit src amount)
    (credit dest amount))

Should it look like this?

  (defun transfer (src:string dest:string amount:decimal)
    (meta 
      "transfer AMOUNT from SRC to DEST"
      (model (property conserves-mass)))
    (debit src amount)
    (credit dest amount))

Additionally you can import properties only via (use properties 'properties). I think I like use model better. Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement FV Formal verification
Projects
None yet
Development

No branches or pull requests

2 participants