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

Verusport #3

Merged
Show file tree
Hide file tree
Changes from 112 commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
ab9c4b6
comment out old trace reconstruction code
mmcloughlin Jun 12, 2024
6e69b8a
Start verusport branch
eobardthawne21p Jun 20, 2024
86dc91c
import string_hash_map axiomatization
pratapsingh1729 Jun 20, 2024
636e1d6
working on deep_view issue
eobardthawne21p Jun 21, 2024
bf21110
Merge branch 'verusport' into verus-string-hash-map
eobardthawne21p Jun 21, 2024
5598631
Merge pull request #1 from eobardthawne21p/verus-string-hash-map
eobardthawne21p Jun 21, 2024
8de1ff2
utilizing StringHashMap and showing it works
eobardthawne21p Jun 24, 2024
435a440
Added a couple of functions in impl Term
eobardthawne21p Jun 27, 2024
eaca976
created impl for Const with clone
eobardthawne21p Jul 1, 2024
03af4ad
saved file then pushed
eobardthawne21p Jul 1, 2024
00584a1
finished prop impl
eobardthawne21p Jul 1, 2024
9144ac3
symbloic verifies and working on valid
eobardthawne21p Jul 2, 2024
7887faf
fixed first version of valid
eobardthawne21p Jul 2, 2024
adc8350
Changed Rule enum to struct and did match exercise for valid()
eobardthawne21p Jul 8, 2024
4444aa9
added complete_subst and concrete fns for Rule impl
eobardthawne21p Jul 8, 2024
405f8ee
finished Rule impl
eobardthawne21p Jul 8, 2024
737d128
added enum for Proof
eobardthawne21p Jul 8, 2024
a600652
found issue with cloning vector
eobardthawne21p Jul 9, 2024
750f1d7
working on contains fn for RuleSet
eobardthawne21p Jul 10, 2024
7bda8f4
implemented PartialEq for StringHashmap
eobardthawne21p Jul 11, 2024
5f0c800
Cleaned up code and added additional cases for PartialEq match
eobardthawne21p Jul 12, 2024
eedf6ce
Merged redundant if statements
eobardthawne21p Jul 12, 2024
c11f999
add deep views
pratapsingh1729 Jul 12, 2024
23f4f27
Merge pull request #2 from eobardthawne21p/pratap-deepviews
eobardthawne21p Jul 13, 2024
9c89ca6
merged Pratap's changes
eobardthawne21p Jul 13, 2024
14b6fc8
fixed code on my branch
eobardthawne21p Jul 13, 2024
3b514eb
fixed
eobardthawne21p Jul 13, 2024
d71dd16
created playground and attempting to do spec stuff
eobardthawne21p Jul 15, 2024
f8d256f
added specterm fix
eobardthawne21p Jul 15, 2024
885ee17
Merge branch 'verusport' of https://github.com/eobardthawne21p/veri-d…
eobardthawne21p Jul 15, 2024
befd27d
fixed GitHub merging issue
eobardthawne21p Jul 15, 2024
645f34c
added spec versions of term and prop
eobardthawne21p Jul 15, 2024
48b6a81
added spec fns to prop
eobardthawne21p Jul 15, 2024
855ea5d
added spec impls up to proof
eobardthawne21p Jul 15, 2024
bad347e
added forall assertion
eobardthawne21p Jul 16, 2024
ae121cf
split code between exec and spec and removed playgrounds
eobardthawne21p Jul 16, 2024
951f595
refactored code to pass in spec versions of arguments for existing code
eobardthawne21p Jul 18, 2024
bde190f
got spec_subst for SpecTerm to verify after recent fixes
eobardthawne21p Jul 18, 2024
6f8227a
got spec_subst for SpecProp to verify
eobardthawne21p Jul 18, 2024
ed0519e
got spec_subst for SpecRule to verify
eobardthawne21p Jul 18, 2024
af99725
Proof now verifies
eobardthawne21p Jul 18, 2024
26feca8
added Thm
eobardthawne21p Jul 19, 2024
cb1f7b7
added ensures statements to exec functions
eobardthawne21p Jul 22, 2024
140bf3e
added ensures statements to exec functions
eobardthawne21p Jul 22, 2024
45a942d
added invariants for exec code with loops
eobardthawne21p Jul 22, 2024
5027b74
worked with Mike
eobardthawne21p Jul 23, 2024
acb103a
fixed invariants for Rule and Prop subst functions
eobardthawne21p Jul 23, 2024
2b4d52a
fixed bugs except for head
eobardthawne21p Jul 23, 2024
312b7e7
working on wf for RuleSet
eobardthawne21p Jul 23, 2024
ba963db
added exec functions for some spec functions
eobardthawne21p Jul 23, 2024
149b010
fixed mk_thm spec issues
eobardthawne21p Jul 24, 2024
acd3dc4
bug in mk_thm
eobardthawne21p Jul 24, 2024
26b6fbc
changed forall to loop
eobardthawne21p Jul 24, 2024
241f894
found equality issue for Prop
eobardthawne21p Jul 25, 2024
137d168
got to borrowing issues and fixed equality for now
eobardthawne21p Jul 25, 2024
bbe9d7f
added clone impls for rule and proof. Need to settle verification errors
eobardthawne21p Jul 25, 2024
4ace297
added fixes to mk_thm
eobardthawne21p Jul 29, 2024
59be6a0
added assertions in mk_thm
eobardthawne21p Jul 29, 2024
6f12483
ran verusfmt
eobardthawne21p Jul 29, 2024
5c3f00e
added fixes with help from Pratap
eobardthawne21p Jul 29, 2024
2f24b33
did some code cleanup
eobardthawne21p Jul 29, 2024
91df9fd
added new comments
eobardthawne21p Jul 30, 2024
a5a4bce
added axiom for deep_view for Proof
eobardthawne21p Jul 30, 2024
a646c74
finished porting kernel
eobardthawne21p Jul 30, 2024
eff6b8f
ran verusfmt on code
eobardthawne21p Jul 30, 2024
76b26ce
removed trash file
eobardthawne21p Jul 30, 2024
4b73636
removed unneccesary assert statements
eobardthawne21p Jul 30, 2024
1f1664e
added additional comments
eobardthawne21p Jul 31, 2024
5ffa67c
added comments and test for Rulesest construction
eobardthawne21p Jul 31, 2024
a1c9cd8
ran verusfmt on new test code
eobardthawne21p Jul 31, 2024
cf4d8cc
added REAMME.md to lcf
eobardthawne21p Jul 31, 2024
2a0cd6f
Update README.md
eobardthawne21p Jul 31, 2024
4a7d2db
added Const in doc
eobardthawne21p Jul 31, 2024
34021ec
added all comments for functions
eobardthawne21p Jul 31, 2024
a6c1de1
fixed typos
eobardthawne21p Jul 31, 2024
70f44ef
fixed example code
eobardthawne21p Jul 31, 2024
6dfc8ae
hack: rename StringHashMap to TmpStringHashMap for now
pratapsingh1729 Jul 31, 2024
c66b2e7
Merge pull request #3 from eobardthawne21p/pratap/tmp-string-hash-map
eobardthawne21p Jul 31, 2024
2421b3a
got example RuleSet to work
eobardthawne21p Jul 31, 2024
84208a1
start working on adding tst_connected_thm in Verus
eobardthawne21p Jul 31, 2024
ddb9c69
commented out code
eobardthawne21p Jul 31, 2024
ab6a044
fixed tst_connection thm
eobardthawne21p Jul 31, 2024
6cc0e7d
added additional comments
eobardthawne21p Aug 1, 2024
344a819
added to README
eobardthawne21p Aug 1, 2024
33f6657
added new headers to README
eobardthawne21p Aug 1, 2024
1f8534f
added headers
eobardthawne21p Aug 1, 2024
74911e1
finished comments
eobardthawne21p Aug 1, 2024
4b0c324
now it's finsihed
eobardthawne21p Aug 1, 2024
76e09e9
added to README
eobardthawne21p Aug 1, 2024
2087aff
added text
eobardthawne21p Aug 1, 2024
9fc44e8
fixed deep_view
eobardthawne21p Aug 1, 2024
f2c038a
fixed deep_view
eobardthawne21p Aug 1, 2024
be88990
fixed formatting
eobardthawne21p Aug 1, 2024
369ad65
worked on toy example
eobardthawne21p Aug 1, 2024
eb8dd74
fixed formatting
eobardthawne21p Aug 1, 2024
ad1b657
fixed formatting
eobardthawne21p Aug 1, 2024
c35a7e8
fixed formatting
eobardthawne21p Aug 1, 2024
c0a7d2e
fixed formatting
eobardthawne21p Aug 1, 2024
e9e3bf4
fixed formatting
eobardthawne21p Aug 1, 2024
4befc3c
fixed formatting
eobardthawne21p Aug 1, 2024
cbae708
added tst_connected_thm
eobardthawne21p Aug 1, 2024
caeade3
test
eobardthawne21p Aug 1, 2024
b27c932
ran verusfmt on code
eobardthawne21p Aug 1, 2024
cc0af36
added Const and Subst
eobardthawne21p Aug 1, 2024
54273fc
added Term
eobardthawne21p Aug 1, 2024
475ab79
added Prop
eobardthawne21p Aug 1, 2024
172e4f6
added Rule
eobardthawne21p Aug 1, 2024
75fc185
finished project
eobardthawne21p Aug 1, 2024
d0ab2ad
fixed error
eobardthawne21p Aug 1, 2024
f9d40f3
fixed error
eobardthawne21p Aug 1, 2024
19d6931
fixed error
eobardthawne21p Aug 1, 2024
c9f90a8
got last example to verify
eobardthawne21p Aug 1, 2024
cd1c9c2
fixed kernel
eobardthawne21p Aug 1, 2024
3154f67
fixed README
eobardthawne21p Aug 1, 2024
bf301bc
fixed headers
eobardthawne21p Aug 2, 2024
7f3650c
removed redundant code from README
eobardthawne21p Aug 2, 2024
6a1dba2
fixed more changes from comments on PR
eobardthawne21p Aug 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
266 changes: 136 additions & 130 deletions dafny/lcf/def.dfy
Original file line number Diff line number Diff line change
Expand Up @@ -328,125 +328,6 @@ function unify(r : Prop, g : Prop) : (res : Result<Subst>)

datatype Match = Match(s : Subst, thm : Thm)

function trace_expect(trace : Trace, port : Port) : (res : Result<(Event, Trace)>)
{
if |trace| == 0 || trace[0].port != port then Err
else Ok((trace[0], trace[1..]))
}

method trace_call(rs : RuleSet, g : Prop, trace : Trace, bound : nat) returns (res : Result<(Match, Trace)>)
ensures res.Ok? ==> res.val.0.thm.wf(rs)
decreases bound // TODO(mbm): use |trace| to prove termination
{
if bound == 0 {
print "exhausted bound\n";
return Err;
}

// Expect the first trace to be Unify.
// TODO(mbm): handle Call and Redo trace events
var maybe_next := trace_expect(trace, Unify);
if maybe_next.Err? {
return Err;
}
var u := maybe_next.val.0;
var trace := maybe_next.val.1;

// Unify port tells us which rule we are applying.
if u.i >= |rs| {
print "bad rule index\n";
return Err;
}
var r := rs[u.i];

// Expect to see traces for the rule body.
// NOTE: fragile assumption that the trace visits the rule body in the same order
var s: Subst := map[];
var args: seq<Thm> := [];
var i := 0;
while i < |r.body|
invariant forall j :: 0 <= j < |args| ==> args[j].wf(rs)
{
var subgoal := r.body[i];
var res := trace_call(rs, subgoal, trace, bound-1);
match res {
case Ok((m, rest)) => {
var maybe_subst := merge_subst(s, m.s);
match maybe_subst {
case Ok(subst) => s := subst;
case Err => {
print "failed to merge substitutions\n";
return Err;
}
}
args := args + [m.thm];
trace := rest;
}
case Err => {
print "failed subgoal trace\n";
return Err;
}
}
i := i+1;
}

// Exit.
// TODO(mbm): handle Fail and Redo
if |trace| == 0 {
print "empty trace\n";
return Err;
}

var exit := trace[0];
trace := trace[1..];
if exit.port != Exit {
print "unexpected trace port\n";
return Err;
}

if !exit.prop.concrete() {
print "expect concrete exit\n";
return Err;
}

// Unify exit with goal.
print "unify: g=", g, " exit=", exit.prop, "\n";
var goal_subst: Subst;
var maybe_subst := unify(g, exit.prop);
match maybe_subst {
case Ok(subst) => {
goal_subst := subst;
}
case Err => {
print "failed to unify with exit\n";
return Err;
}
}

var maybe_merged := merge_subst(s, goal_subst);
match maybe_merged {
case Ok(merged) => s := merged;
case Err => {
print "failed to merge substitution\n";
return Err;
}
}

// Deduce theorem.
print "mk_thm: i=", u.i, " s=", s, " args=", args, "\n";
var maybe_thm := mk_thm(rs, u.i, s, args);
match maybe_thm {
// TODO(mbm): trim down the subst?
case Ok(thm) => {
print "mk_thm: success\n";
return Ok((Match(goal_subst, thm), trace));
}
case Err => {
print "failed to deduce thm\n";
return Err;
}
}
}

//// Trace tree construction.

Expand Down Expand Up @@ -875,17 +756,6 @@ function connectivity_trace() : (trace : Trace)
]
}

method run_trace_reconstruction() {
var rs := connectivity_rules();
var trace := connectivity_trace();
var g := trace[0].prop;
var res := trace_call(rs, g, trace, 0x1000_0000_0000);
match res {
case Ok(thm) => print "ok\n";
case Err => print "FAIL\n";
}
}

method run_connectivity_example() {
var rs := connectivity_rules();
var trace := connectivity_trace();
Expand Down Expand Up @@ -1059,3 +929,139 @@ function bottom_up(rs : RuleSet, acc : seq<Thm>, bound : nat) : seq<Thm>
case Ok(new_thm) => bottom_up(rs, [new_thm] + acc, bound - 1)
}
*/

/*
///// Obsolete attempt at trace reconstruction.

function trace_expect(trace : Trace, port : Port) : (res : Result<(Event, Trace)>)
{
if |trace| == 0 || trace[0].port != port then Err
else Ok((trace[0], trace[1..]))
}

method trace_call(rs : RuleSet, g : Prop, trace : Trace, bound : nat) returns (res : Result<(Match, Trace)>)
ensures res.Ok? ==> res.val.0.thm.wf(rs)
decreases bound // TODO(mbm): use |trace| to prove termination
{
if bound == 0 {
print "exhausted bound\n";
return Err;
}

// Expect the first trace to be Unify.
// TODO(mbm): handle Call and Redo trace events
var maybe_next := trace_expect(trace, Unify);
if maybe_next.Err? {
return Err;
}
var u := maybe_next.val.0;
var trace := maybe_next.val.1;

// Unify port tells us which rule we are applying.
if u.i >= |rs| {
print "bad rule index\n";
return Err;
}
var r := rs[u.i];

// Expect to see traces for the rule body.
// NOTE: fragile assumption that the trace visits the rule body in the same order
var s: Subst := map[];
var args: seq<Thm> := [];
var i := 0;
while i < |r.body|
invariant forall j :: 0 <= j < |args| ==> args[j].wf(rs)
{
var subgoal := r.body[i];
var res := trace_call(rs, subgoal, trace, bound-1);
match res {
case Ok((m, rest)) => {
var maybe_subst := merge_subst(s, m.s);
match maybe_subst {
case Ok(subst) => s := subst;
case Err => {
print "failed to merge substitutions\n";
return Err;
}
}
args := args + [m.thm];
trace := rest;
}
case Err => {
print "failed subgoal trace\n";
return Err;
}
}
i := i+1;
}

// Exit.
// TODO(mbm): handle Fail and Redo
if |trace| == 0 {
print "empty trace\n";
return Err;
}

var exit := trace[0];
trace := trace[1..];
if exit.port != Exit {
print "unexpected trace port\n";
return Err;
}

if !exit.prop.concrete() {
print "expect concrete exit\n";
return Err;
}

// Unify exit with goal.
print "unify: g=", g, " exit=", exit.prop, "\n";
var goal_subst: Subst;
var maybe_subst := unify(g, exit.prop);
match maybe_subst {
case Ok(subst) => {
goal_subst := subst;
}
case Err => {
print "failed to unify with exit\n";
return Err;
}
}

var maybe_merged := merge_subst(s, goal_subst);
match maybe_merged {
case Ok(merged) => s := merged;
case Err => {
print "failed to merge substitution\n";
return Err;
}
}

// Deduce theorem.
print "mk_thm: i=", u.i, " s=", s, " args=", args, "\n";
var maybe_thm := mk_thm(rs, u.i, s, args);
match maybe_thm {
// TODO(mbm): trim down the subst?
case Ok(thm) => {
print "mk_thm: success\n";
return Ok((Match(goal_subst, thm), trace));
}
case Err => {
print "failed to deduce thm\n";
return Err;
}
}
}

method run_trace_reconstruction() {
var rs := connectivity_rules();
var trace := connectivity_trace();
var g := trace[0].prop;
var res := trace_call(rs, g, trace, 0x1000_0000_0000);
match res {
case Ok(thm) => print "ok\n";
case Err => print "FAIL\n";
}
}

*/
2 changes: 2 additions & 0 deletions verus/lcf/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.envrc
target/
7 changes: 7 additions & 0 deletions verus/lcf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions verus/lcf/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "lcf"
version = "0.1.0"
edition = "2021"

[dependencies]
Loading