Skip to content
Snippets Groups Projects
Commit a285382b authored by Lennard Gäher's avatar Lennard Gäher
Browse files

Merge branch 'lennard/static' into 'main'

Support for statics

See merge request !25
parents 462dbdd4 335c558f
No related branches found
No related tags found
1 merge request!25Support for statics
Pipeline #98634 passed with warnings
Showing
with 34 additions and 25 deletions
...@@ -17,7 +17,7 @@ clean: clean_all ...@@ -17,7 +17,7 @@ clean: clean_all
frontend: frontend:
cd rr_frontend && ./refinedrust build && ./refinedrust install cd rr_frontend && ./refinedrust build && ./refinedrust install
RUST_SRC = stdlib/alloc stdlib/option stdlib/vec case_studies/paper-examples case_studies/tests case_studies/minivec RUST_SRC = stdlib/alloc stdlib/option stdlib/result stdlib/spin stdlib/vec case_studies/paper-examples case_studies/tests case_studies/minivec
%.gen: % phony %.gen: % phony
cd $< && cargo refinedrust cd $< && cargo refinedrust
......
...@@ -98,6 +98,15 @@ enum option<T> { ...@@ -98,6 +98,15 @@ enum option<T> {
In addition, enums also support the `export_as` attribute (same as structs). In addition, enums also support the `export_as` attribute (same as structs).
## Static attributes
RefinedRust supports `static` (but currently not `static mut`) variables.
They can be used as if they were behind a shared reference with `static` lifetime.
For a static variable to be used by the RefinedRust type checker, the respective function needs to require it to be initialized,
using the `initialized π "name" r` predicate, where `r` is the assumed refinement of the static variable.
To specify the name that is used to refer to the variable here, `static` variables can be annotated with a `rr::name` attribute:
- `#[rr::name("my_static_int")]` indicates that the name `my_static_int` should be used to refer to the static in specifications.
## Module attributes ## Module attributes
Inside a module, the following mod-level attributes can be specified: Inside a module, the following mod-level attributes can be specified:
- `#![rr::import("A.B.C", "D")]`: imports the file `D` from logical Coq path `A.B.C` in all spec and proof files - `#![rr::import("A.B.C", "D")]`: imports the file `D` from logical Coq path `A.B.C` in all spec and proof files
......
Section resolve_ghost. Section resolve_ghost.
Context `{!typeGS Σ}.
Context {T_rt : Type}. Context {T_rt : Type}.
Context (T_ty : type (T_rt)). Context (T_ty : type (T_rt)).
......
...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ra ...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ra
Set Default Proof Using "Type". Set Default Proof Using "Type".
Section proof. Section proof.
Context `{!typeGS Σ}. Context `{!refinedrustGS Σ}.
Lemma RawVec_T_cap_proof (π : thread_id) : Lemma RawVec_T_cap_proof (π : thread_id) :
RawVec_T_cap_lemma π. RawVec_T_cap_lemma π.
Proof. Proof.
...@@ -19,4 +19,4 @@ Proof. ...@@ -19,4 +19,4 @@ Proof.
Unshelve. all: sidecond_hammer. Unshelve. all: sidecond_hammer.
Unshelve. all: print_remaining_sidecond. Unshelve. all: print_remaining_sidecond.
Qed. Qed.
End proof. End proof.
\ No newline at end of file
...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ra ...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ra
Set Default Proof Using "Type". Set Default Proof Using "Type".
Section proof. Section proof.
Context `{!typeGS Σ}. Context `{!refinedrustGS Σ}.
Lemma RawVec_T_grow_proof (π : thread_id) : Lemma RawVec_T_grow_proof (π : thread_id) :
RawVec_T_grow_lemma π. RawVec_T_grow_lemma π.
Proof. Proof.
......
...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ra ...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ra
Set Default Proof Using "Type". Set Default Proof Using "Type".
Section proof. Section proof.
Context `{!typeGS Σ}. Context `{!refinedrustGS Σ}.
Lemma RawVec_T_new_proof (π : thread_id) : Lemma RawVec_T_new_proof (π : thread_id) :
RawVec_T_new_lemma π. RawVec_T_new_lemma π.
Proof. Proof.
......
...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ra ...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ra
Set Default Proof Using "Type". Set Default Proof Using "Type".
Section proof. Section proof.
Context `{!typeGS Σ}. Context `{!refinedrustGS Σ}.
Lemma RawVec_T_ptr_proof (π : thread_id) : Lemma RawVec_T_ptr_proof (π : thread_id) :
RawVec_T_ptr_lemma π. RawVec_T_ptr_lemma π.
Proof. Proof.
...@@ -19,4 +19,4 @@ Proof. ...@@ -19,4 +19,4 @@ Proof.
Unshelve. all: sidecond_hammer. Unshelve. all: sidecond_hammer.
Unshelve. all: print_remaining_sidecond. Unshelve. all: print_remaining_sidecond.
Qed. Qed.
End proof. End proof.
\ No newline at end of file
...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ve ...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ve
Set Default Proof Using "Type". Set Default Proof Using "Type".
Section proof. Section proof.
Context `{!typeGS Σ}. Context `{!refinedrustGS Σ}.
Lemma Vec_T_cap_proof (π : thread_id) : Lemma Vec_T_cap_proof (π : thread_id) :
Vec_T_cap_lemma π. Vec_T_cap_lemma π.
Proof. Proof.
...@@ -19,4 +19,4 @@ Proof. ...@@ -19,4 +19,4 @@ Proof.
Unshelve. all: sidecond_hammer. Unshelve. all: sidecond_hammer.
Unshelve. all: print_remaining_sidecond. Unshelve. all: print_remaining_sidecond.
Qed. Qed.
End proof. End proof.
\ No newline at end of file
...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ve ...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ve
Set Default Proof Using "Type". Set Default Proof Using "Type".
Section proof. Section proof.
Context `{!typeGS Σ}. Context `{!refinedrustGS Σ}.
Lemma Vec_T_get_proof (π : thread_id) : Lemma Vec_T_get_proof (π : thread_id) :
Vec_T_get_lemma π. Vec_T_get_lemma π.
Proof. Proof.
...@@ -19,4 +19,4 @@ Proof. ...@@ -19,4 +19,4 @@ Proof.
Unshelve. all: sidecond_hammer. Unshelve. all: sidecond_hammer.
Unshelve. all: print_remaining_sidecond. Unshelve. all: print_remaining_sidecond.
Qed. Qed.
End proof. End proof.
\ No newline at end of file
...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ve ...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ve
Set Default Proof Using "Type". Set Default Proof Using "Type".
Section proof. Section proof.
Context `{!typeGS Σ}. Context `{!refinedrustGS Σ}.
Lemma Vec_T_get_mut_proof (π : thread_id) : Lemma Vec_T_get_mut_proof (π : thread_id) :
Vec_T_get_mut_lemma π. Vec_T_get_mut_lemma π.
Proof. Proof.
......
...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ve ...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ve
Set Default Proof Using "Type". Set Default Proof Using "Type".
Section proof. Section proof.
Context `{!typeGS Σ}. Context `{!refinedrustGS Σ}.
Lemma Vec_T_get_unchecked_proof (π : thread_id) : Lemma Vec_T_get_unchecked_proof (π : thread_id) :
Vec_T_get_unchecked_lemma π. Vec_T_get_unchecked_lemma π.
Proof. Proof.
......
...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ve ...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ve
Set Default Proof Using "Type". Set Default Proof Using "Type".
Section proof. Section proof.
Context `{!typeGS Σ}. Context `{!refinedrustGS Σ}.
Lemma Vec_T_get_unchecked_mut_proof (π : thread_id) : Lemma Vec_T_get_unchecked_mut_proof (π : thread_id) :
Vec_T_get_unchecked_mut_lemma π. Vec_T_get_unchecked_mut_lemma π.
Proof. Proof.
......
...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ve ...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ve
Set Default Proof Using "Type". Set Default Proof Using "Type".
Section proof. Section proof.
Context `{!typeGS Σ}. Context `{!refinedrustGS Σ}.
Lemma Vec_T_len_proof (π : thread_id) : Lemma Vec_T_len_proof (π : thread_id) :
Vec_T_len_lemma π. Vec_T_len_lemma π.
Proof. Proof.
......
...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ve ...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ve
Set Default Proof Using "Type". Set Default Proof Using "Type".
Section proof. Section proof.
Context `{!typeGS Σ}. Context `{!refinedrustGS Σ}.
Lemma Vec_T_new_proof (π : thread_id) : Lemma Vec_T_new_proof (π : thread_id) :
Vec_T_new_lemma π. Vec_T_new_lemma π.
Proof. Proof.
...@@ -19,4 +19,4 @@ Proof. ...@@ -19,4 +19,4 @@ Proof.
Unshelve. all: sidecond_hammer. Unshelve. all: sidecond_hammer.
Unshelve. all: print_remaining_sidecond. Unshelve. all: print_remaining_sidecond.
Qed. Qed.
End proof. End proof.
\ No newline at end of file
...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ve ...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ve
Set Default Proof Using "Type". Set Default Proof Using "Type".
Section proof. Section proof.
Context `{!typeGS Σ}. Context `{!refinedrustGS Σ}.
Lemma Vec_T_pop_proof (π : thread_id) : Lemma Vec_T_pop_proof (π : thread_id) :
Vec_T_pop_lemma π. Vec_T_pop_lemma π.
Proof. Proof.
......
...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ve ...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ve
Set Default Proof Using "Type". Set Default Proof Using "Type".
Section proof. Section proof.
Context `{!typeGS Σ}. Context `{!refinedrustGS Σ}.
Lemma Vec_T_ptr_proof (π : thread_id) : Lemma Vec_T_ptr_proof (π : thread_id) :
Vec_T_ptr_lemma π. Vec_T_ptr_lemma π.
Proof. Proof.
...@@ -19,4 +19,4 @@ Proof. ...@@ -19,4 +19,4 @@ Proof.
Unshelve. all: sidecond_hammer. Unshelve. all: sidecond_hammer.
Unshelve. all: print_remaining_sidecond. Unshelve. all: print_remaining_sidecond.
Qed. Qed.
End proof. End proof.
\ No newline at end of file
...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ve ...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_Ve
Set Default Proof Using "Type". Set Default Proof Using "Type".
Section proof. Section proof.
Context `{!typeGS Σ}. Context `{!refinedrustGS Σ}.
Lemma Vec_T_push_proof (π : thread_id) : Lemma Vec_T_push_proof (π : thread_id) :
Vec_T_push_lemma π. Vec_T_push_lemma π.
Proof. Proof.
......
...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_cl ...@@ -6,7 +6,7 @@ From refinedrust.examples.minivec.generated Require Import generated_template_cl
Set Default Proof Using "Type". Set Default Proof Using "Type".
Section proof. Section proof.
Context `{!typeGS Σ}. Context `{!refinedrustGS Σ}.
Lemma client_get_mut_client_proof (π : thread_id) : Lemma client_get_mut_client_proof (π : thread_id) :
client_get_mut_client_lemma π. client_get_mut_client_lemma π.
Proof. Proof.
......
...@@ -6,7 +6,7 @@ From refinedrust.examples.tests.generated Require Import generated_template_vec_ ...@@ -6,7 +6,7 @@ From refinedrust.examples.tests.generated Require Import generated_template_vec_
Set Default Proof Using "Type". Set Default Proof Using "Type".
Section proof. Section proof.
Context `{!typeGS Σ}. Context `{!refinedrustGS Σ}.
Lemma vec_client_init_vec_proof (π : thread_id) : Lemma vec_client_init_vec_proof (π : thread_id) :
vec_client_init_vec_lemma π. vec_client_init_vec_lemma π.
Proof. Proof.
...@@ -15,7 +15,7 @@ Proof. ...@@ -15,7 +15,7 @@ Proof.
repeat liRStep; liShow. repeat liRStep; liShow.
liInst Hevar (int i32). liInst Hevar (int i32).
repeat liRStep; liShow. repeat liRStep; liShow.
all: print_remaining_goal. all: print_remaining_goal.
Unshelve. all: sidecond_solver. Unshelve. all: sidecond_solver.
Unshelve. all: sidecond_hammer. Unshelve. all: sidecond_hammer.
......
...@@ -6,5 +6,6 @@ mod enums; ...@@ -6,5 +6,6 @@ mod enums;
mod structs; mod structs;
mod char; mod char;
mod traits; mod traits;
mod statics;
mod vec_client; mod vec_client;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment