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

CN: Do translation validation of resource inference steps in Rocq [work in progress] #898

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e628036
added missing Makefile dependnecy for `cn-with-coq`
vzaliva Feb 19, 2025
28b7f20
map_from_list implemented
vzaliva Feb 19, 2025
a159387
Switching to MSetWeakList from FSetAVL to avoid ordering.
vzaliva Feb 19, 2025
505932c
Reasoning module. Proof automation sketch. Correctnes theorem generated.
vzaliva Feb 20, 2025
ca0c884
enable CI on resource-reasoning branch
vzaliva Feb 20, 2025
08effbe
Record -> TRecord to avoid keyword name collision
vzaliva Feb 20, 2025
47217fc
decidable equality wip
vzaliva Feb 21, 2025
26fb170
do not export proof log in tests (to speed up)
vzaliva Feb 22, 2025
625d4f1
defining res. inf. simple case constraints
vzaliva Feb 22, 2025
9c84290
Ltac2 automation for resource inference
vzaliva Feb 25, 2025
f1f850e
more ltac2 automation
vzaliva Feb 26, 2025
a8c25cd
Switching to FSet from MSet (to take advantage of Ltac2.FSet)
vzaliva Feb 26, 2025
7069a78
admitting ResSet equality and proving submsumption
vzaliva Feb 26, 2025
f02f393
Latc2 automation
vzaliva Feb 27, 2025
336d062
new ProofAutomation module
vzaliva Feb 27, 2025
1649b99
generating theorem.
vzaliva Feb 27, 2025
6381661
debug messages removed
vzaliva Feb 27, 2025
fd61872
proving set equality
vzaliva Feb 27, 2025
80066b5
proof log unit tests enabled
vzaliva Feb 27, 2025
55fd5de
logging unfolding. unfolding correcntess predicate placeholder
vzaliva Feb 28, 2025
46936eb
deetecting do-nothing unfolding steps
vzaliva Feb 28, 2025
08e4757
--coq-check-proof-log command line option
vzaliva Feb 28, 2025
7508277
unfold_step predicate, shelving errors
vzaliva Mar 3, 2025
1a7099e
more verbose messages in automation
vzaliva Mar 3, 2025
42ba974
formatting
vzaliva Mar 3, 2025
45b5d62
do not export mucore AST unless --coq-mucore is specified
vzaliva Mar 4, 2025
d61a0b8
wip on resource unfolding predicate
vzaliva Mar 4, 2025
c1744d0
struct members bijection in resource_unfold (wip)
vzaliva Mar 4, 2025
16dd185
incorporating `resource_unfold` into `unfold_step`
vzaliva Mar 4, 2025
a1baefd
typo fixed
vzaliva Mar 4, 2025
313fd66
packing/unpacking reasoning wip
vzaliva Mar 5, 2025
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
5 changes: 2 additions & 3 deletions .github/workflows/ci-cn-coq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ on:
push:
branches:
- master
- cn-logging
- cn-resource-logging
- resource-reasoning

env:
CERBERUS_IMAGE_ID: ghcr.io/rems-project/cerberus/cn:release
Expand Down Expand Up @@ -78,4 +77,4 @@ jobs:
run: |
opam switch ${{ matrix.version }}-with-coq
eval $(opam env --switch=${{ matrix.version }}-with-coq )
./tests/run-cn-coq.sh -p -v
./tests/run-cn-coq.sh -v -p
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,13 @@ cn-coq-install: cn-coq
$(Q)dune install cn-coq

.PHONY: cn-with-coq
cn-with-coq:
cn-with-coq: prelude-src
@echo "[DUNE] cerberus-lib,cn,cn-coq"
$(Q)dune build -p cerberus-lib,cn,cn-coq

# Developement target to watch for changes in cn/lib and rebuild
# e.g. to be used with vscode IDE
.PHONY: cn-dev-watch
cn-dev-watch:
cn-dev-watch: prelude-src
@echo "[DUNE] cn-dev-watch"
$(Q)dune build --watch -p cerberus-lib,cn,cn-coq
1 change: 1 addition & 0 deletions _CoqProject
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# CN:
-R _build/default/backend/cn/coq/Cerberus/ Cerberus
-R _build/default/backend/cn/coq/Cn/ Cn
-R _build/default/backend/cn/coq/Reasoning/ Reasoning
# CHERI memory model
-R _build/default/coq/Common/ Common
-R _build/default/coq/Morello/ Morello
Expand Down
51 changes: 43 additions & 8 deletions backend/cn/bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ let with_well_formedness_check
~incl_dirs
~incl_files
~coq_export_file
~coq_mucore
~coq_proof_log
~coq_check_proof_log
~csv_times
~log_times
~astprints
Expand Down Expand Up @@ -174,14 +176,21 @@ let with_well_formedness_check
in
Result.iter_error handle_error (Typing.pause_to_result paused);
let@ _ = f ~cabs_tunit ~prog5 ~ail_prog ~statement_locs ~paused in
let steps = Prooflog.get_proof_log () in
Option.iter
(fun path ->
Pp.print_file
path
(Pp_mucore_coq.pp_unit_file_with_resource_inference
prog5
(if coq_proof_log then Some steps else None)))
let prologue = Pp_mucore_coq.pp_prologue () in
let mucore =
if coq_mucore then Pp_mucore_coq.pp_unit_file prog5 else PPrint.empty
in
let proof =
if coq_proof_log then (
let steps = Prooflog.get_proof_log () in
Pp_mucore_coq.pp_proof_log steps coq_check_proof_log)
else
PPrint.empty
in
let doc = PPrint.( ^^ ) prologue (PPrint.( ^^ ) mucore proof) in
Pp.print_file path doc)
coq_export_file;
return ()
in
Expand Down Expand Up @@ -259,7 +268,9 @@ let well_formed
~incl_dirs
~incl_files
~coq_export_file:None
~coq_mucore:false
~coq_proof_log:false
~coq_check_proof_log:false
~csv_times
~log_times
~astprints
Expand All @@ -286,7 +297,9 @@ let verify
diag
lemmata
coq_export_file
coq_mucore
coq_proof_log
coq_check_proof_log
only
skip
csv_times
Expand Down Expand Up @@ -337,7 +350,9 @@ let verify
~incl_dirs
~incl_files
~coq_export_file
~coq_mucore
~coq_proof_log
~coq_check_proof_log
~csv_times
~log_times
~astprints
Expand Down Expand Up @@ -431,7 +446,9 @@ let generate_executable_specs
~incl_dirs
~incl_files
~coq_export_file:None
~coq_mucore:false
~coq_proof_log:false
~coq_check_proof_log:false
~csv_times
~log_times
~astprints
Expand Down Expand Up @@ -496,7 +513,9 @@ let run_seq_tests
~incl_files
~csv_times
~coq_export_file:None
~coq_mucore:false
~coq_proof_log:false
~coq_check_proof_log:false
~log_times
~astprints
~no_inherit_loc
Expand Down Expand Up @@ -610,7 +629,9 @@ let run_tests
~incl_files
~csv_times
~coq_export_file:None
~coq_mucore:false
~coq_proof_log:false
~coq_check_proof_log:false
~log_times
~astprints
~no_inherit_loc
Expand Down Expand Up @@ -944,14 +965,26 @@ end

module CoqExport_flags = struct
let coq_export =
let doc = "export to coq" in
let doc = "File to export to coq defintions" in
Arg.(value & opt (some string) None & info [ "coq-export-file" ] ~docv:"FILE" ~doc)
end

module CoqMucore_flags = struct
let coq_mucore =
let doc = "include mu-core AST in coq export" in
Arg.(value & flag & info [ "coq-mucore" ] ~doc)
end

module CoqProofLog_flags = struct
let coq_proof_log =
let doc = "include proof log in coq export" in
Arg.(value & flag & info [ "coq-proof-log" ] ~docv:"FILE" ~doc)
Arg.(value & flag & info [ "coq-proof-log" ] ~doc)
end

module CoqCheckProofLog_flags = struct
let coq_check_proof_log =
let doc = "Include statements to check proof log in coq exported file" in
Arg.(value & flag & info [ "coq-check-proof-log" ] ~doc)
end

let wf_cmd =
Expand Down Expand Up @@ -1002,7 +1035,9 @@ let verify_t : unit Term.t =
$ Verify_flags.diag
$ Lemma_flags.lemmata
$ CoqExport_flags.coq_export
$ CoqMucore_flags.coq_mucore
$ CoqProofLog_flags.coq_proof_log
$ CoqCheckProofLog_flags.coq_check_proof_log
$ Verify_flags.only
$ Verify_flags.skip
$ Common_flags.csv_times
Expand Down
6 changes: 6 additions & 0 deletions backend/cn/coq/Cerberus/Utils.v
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,9 @@ Qed.
*)
Definition split_at {A:Type} (n:nat) (l:list A)
:= (List.firstn n l, List.skipn n l).

Definition option_map {A B:Type} (f: A -> B) (o: option A) : option B :=
match o with
| Some x => Some (f x)
| None => None
end.
Loading