Comments (4)
Inference of implicit binders
Today, we write:
fn test_read (r:ref U32.t)
(#n:erased U32.t)
(#p:perm)
requires pts_to r p n
returns x : U32.t
ensures pts_to r p x
Instead, I propose we write
fn test_read (r:ref U32.t)
requires pts_to r p 'n
returns x : U32.t
ensures pts_to r p x
Note the variables p
and 'n
are not bound.
p
is an implicitly bound variable'n
is an implicitly bound variable of erased type
The goal is to figure out the types of p
and 'n
and to add
binders for them.
We can do this by generated the type:
r:ref U32.t ->
#p:_ ->
#'n:erased _ ->
stt U32.t (pts_to r p n) (fun x -> pts_to r p x)
getting F* to typecheck the term, filling in the holes. We can
then read it back in the Pulse checker.
It should be possible to mix this with user annotated types. So, one could write something like this too:
fn read_nonzero (r:ref U32.t) (n:erased U32.t { n <> 0 })
requires pts_to r p n
returns x : U32.t
ensures pts_to r p x
DONE
from steel.
Done (#120)
Inference of implicit instantiations
We already solve implicit arguments using the prover to find solutions to existentials. But, this currently relies on the order of implicit binders. We should remove this restriction.
Given an application term e
(say f e1 #e2 e3
), potentially with some user-annotated implicit instantiations, we have to find the rest.
We ask F* to (lax) check and elaborate e
. F* would produce back a term f #t #?u1 e1 #e2 e3 ?u2
etc., where some implicits have been solved, but ?u1 and ?u2
have not been solved yet.
The Pulse checker reads back this term, replacing the unsolved uvars with fresh existential variables and then calls the prover to instantiate them with respect to the current vprop context, as it does today.
from steel.
Make handling of stateful application less syntactic
Currently, we rely on the front-end desugaring to identify stateful application and mark them as such in the AST.
While this works for handling application of top-level functions, it is not properly type-directed, leading to other uses to be awkward to work with, e.g., at higher order, see below.
Instead, let's not rely on the front-end to distinguish stateful applications. Rather, the Pulse typechecker can handle this itself, but computing the type of an application (using F*), then seeing if the computed type is an stt (and if so, instantiating implicit arguments as above), and then computing frames; otherwise handling it as a pure application.
module Test.HigherOrder
open Pulse.Lib.Pervasives
[@@expect_failure]
fn apply (#a:Type0) (#b:Type0) (f: (a -> stt b emp (fun _ -> emp))) (x:a)
requires emp
returns y:b
ensures emp
{
f x;
}
let perform (#a:Type0) (#b:Type0) (f: (a -> stt b emp (fun _ -> emp))) (x:a) : stt b emp (fun _ -> emp)=
f x
fn apply (#a:Type0) (#b:Type0) (f: (a -> stt b emp (fun _ -> emp))) (x:a)
requires emp
returns y:b
ensures emp
{
perform f x;
}
from steel.
Marking it complete.
from steel.
Related Issues (20)
- Unresolved uvar error on just using an unresolved identifier HOT 1
- Bad error localization on simple typing error HOT 1
- Inferring implicits arguments in return position (and error localization)
- Allow F* type abbreviations for Pulse function types (feature request) HOT 1
- Interpret `**` on both sides of `@==>` to allow inferring implicit arguments to stick lemmas HOT 1
- Inferred reveal is incorrectly accepted HOT 1
- "Unary transform" raises some typechecker problems HOT 4
- Eliminating pure underneath an exists* HOT 1
- Meta issue for syntax improvements in Pulse HOT 1
- Recursive calls fail to infer HOT 1
- Ghost, Unobservable, Atomic
- Stack references are freeable
- Bad error messages HOT 2
- admit seems to affect code before it HOT 1
- Calling lemmas in ghost code
- Make `inv` complete on its domain?
- Imprecise logical context in the match branch (cannot prove that the scrutinee is not a data constructor that is matched before this branch) HOT 1
- Incorrect joining of match branches allows masking invariant openings
- 'could not prove uvar' when there is existential in post HOT 1
- Crash when last two implicit arguments have dependency
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from steel.