Liquid types proof of concept #825
Closed
zxq9 wants to merge 6 commits from
github/fork/radrow/hagia into master
pull from: github/fork/radrow/hagia
merge into: QPQ-AG:master
QPQ-AG:master
QPQ-AG:prh-docs-fix
QPQ-AG:uw-mldsa-crypto
QPQ-AG:uw-rename-fix-deps
QPQ-AG:bump_gmserialization
QPQ-AG:zomp
QPQ-AG:ceres
QPQ-AG:gh-pages
QPQ-AG:gh-485
QPQ-AG:dependabot/pip/dot-github/workflows/pygments-2.15.0
QPQ-AG:old_ceres
QPQ-AG:ghallak/split-typechecker
QPQ-AG:gh-400
QPQ-AG:new_ceres
QPQ-AG:loop-op
QPQ-AG:type-env
QPQ-AG:ghallak/229
QPQ-AG:option-force-msg
QPQ-AG:6.0.2
QPQ-AG:lima
QPQ-AG:call-fee
QPQ-AG:fix-ets
QPQ-AG:mergesort
QPQ-AG:lima-master-merge
QPQ-AG:optionally_generate_aci
QPQ-AG:changelog-update
QPQ-AG:make-return-reserved-word
QPQ-AG:radrow-patch-2
QPQ-AG:aens-subdomains
QPQ-AG:aens-at-full-node-ver
QPQ-AG:pt-166866806-claim-with-name-fee
QPQ-AG:extend-aci-interface
QPQ-AG:generalized_accounts_no_abi_move
QPQ-AG:roma
QPQ-AG:quickcheck-ci
No Reviewers
Labels
Clear labels
WIP
bug
consensus-breaking
dependencies
documentation
duplicate
effort: high
effort: low
effort: medium
effort: trivial
enhancement
good first issue
help wanted
invalid
maintenance
question
task/feature
todo-in-rewrite
wontfix
bug
duplicate
enhancement
help wanted
invalid
pig lipstick
question
wontfix
Something is not working
This issue or pull request already exists
New feature
Need some help
Something is wrong
Muggle-facing enhancements
More information is needed
This won't be fixed
No Label
WIP
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: QPQ-AG/sophia#825
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "github/fork/radrow/hagia"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Created by: radrow
Liquid types
This PR provides a proof of concept implementation of refinement types in Sophia. While this work is not production-ready, it can serve as an advanced starting point and inspiration for how such types could be added to the existing Sophia type system. The project has been written as a part of my research for my master's thesis at the University of Warsaw. The document is still work in progress and will be shared after it is defended.
For a reference what are liquid types and what is their value please refer to the
The work on this contribution and research is a subject of the 0135 ACF grant "Logic Qualified Data Types for Sophia".
Requirements
Erlang (of course) and a SMT solver that speaks SMT-lib language. I was using Z3 by Microsoft Research and I highly recommend it.
What is there
The project covers most of the Sophia expressions including but not limited to
Moreover, the following are featured
List.aesstdlibswitchexhaustion)Furthermore, it is able to infer judgements about the
stateand track it along imperative control flows. The contract's balance is being tracked as well and it is being entirely statically verified that there are no negative spends and every spend can be afforded at time. This however does not apply to balances of other contracts, but once maps are added it can be easily supported with some simple preprocessing (i.e. adding balance map to the contract state).There is some simple testing suite with examples of contracts utilizing the liquid types. The introduced syntax allows users to define custom liquid types and put manual assertions on the data.
What is to be done
In order to make this project eligible to face users, the following should be addressed:
Also, I was too lazy to write SMT library as a proper
gen_statemand I run it as a bare recurring process. It works fine tho, it's just ugly.Cool stuff
Just to give some view why it is cool and choco. Let us consider the following spend-split contract which distributes spends among addresses equally:
Looks fine, yeah? No. Try it in the refiner and you will see that
(messages are slightly redacted for readability). Indeed, there are two latent issues:
spend_to_allfunction could be potentially called under different conditions. Atm the use-case of functions are not considered, but technically could be, though).The contract needs a fixup then:
(This example uses some work in progress features and might not run at the current state of refinement. There are workarounds for that though).
This and other examples will be discussed in more details in my thesis.
Pull request closed