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

EverParse+Pulse: Verified parsing and serialization with separation logic #155

Open
wants to merge 89 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
638269a
pts_to_serialized, validator, jumper, peek, CPS reader, read
tahina-pro Jul 3, 2024
9777ccf
WIP LowParse.Pulse.Combinators
tahina-pro Jul 8, 2024
573761d
integer readers
tahina-pro Jul 8, 2024
b084439
validate, jump int
tahina-pro Jul 8, 2024
de8c900
switch to CPS validators
tahina-pro Jul 8, 2024
2e9bf08
synth, filter
tahina-pro Jul 9, 2024
cf0534c
validate_nonempty
tahina-pro Jul 9, 2024
7209ceb
validate_nondep_then
tahina-pro Jul 9, 2024
cbf928e
common validate_dtuple2 and nondep_then
tahina-pro Jul 9, 2024
6352265
split_dtuple2, simplified split_nondep_then
tahina-pro Jul 9, 2024
53d8e8b
jump_nondep_then, jump_dtuple2
tahina-pro Jul 9, 2024
4fd8c75
validate_and_read
tahina-pro Jul 9, 2024
ad30058
validate_filter -> validate_and_read_filter
tahina-pro Jul 9, 2024
dc5e56b
validate_dtuple2 with validate_and_read tag, remove validate_nondep_then
tahina-pro Jul 9, 2024
fd887c5
restore validate_nondep_then
tahina-pro Jul 9, 2024
cb95617
validate_and_read_dtuple2
tahina-pro Jul 9, 2024
14f5bac
read_synth, read_filter
tahina-pro Jul 10, 2024
b44c18b
validate_and_read_synth
tahina-pro Jul 10, 2024
9383b8c
bitsum
tahina-pro Jul 10, 2024
4b29d00
validate_and_read integers; ret, empty; etc.
tahina-pro Jul 11, 2024
944b32d
ifthenelse_jumper, jump_ret, jump_empty
tahina-pro Jul 11, 2024
769d3b1
some extraction fixes: avoid pure lets in F* assemblies, replace reco…
tahina-pro Jul 11, 2024
376403d
mark more combinators inline_for_extraction
tahina-pro Jul 11, 2024
9d360cb
Karamel chokes on tuples. Use a custom slice_pair type instead
tahina-pro Jul 12, 2024
92f6343
Karamel chokes on local ghost functions, hoist them instead (mainly f…
tahina-pro Jul 12, 2024
5e76a3f
slice_pair moved to Pulse
tahina-pro Jul 12, 2024
39a4638
read then pure cont
tahina-pro Jul 12, 2024
f9a36f3
read with pure continuation
tahina-pro Jul 12, 2024
b5f83df
pure_read_ext, empty, dtuple, ifthenelse
tahina-pro Jul 12, 2024
ff928b0
properly normalize integer readers
tahina-pro Jul 12, 2024
5d088a0
replace CPS reader with pure_reader
tahina-pro Jul 13, 2024
cf0a5ba
restore validate_and_read_intro, jump_dtuple2, with leaf_reader this …
tahina-pro Jul 13, 2024
626d975
revert to non-CPS validators; jumpers with offsets instead of sizes
tahina-pro Jul 15, 2024
f85e1c0
eta-expand validate_synth because of the pure bind
tahina-pro Jul 15, 2024
0238383
ifthenelse_validator
tahina-pro Jul 16, 2024
fc169dd
bound offset on validator failure
tahina-pro Jul 16, 2024
d75f3b6
jump_vclist; dtuple2, nondep_then, nlist accessors
tahina-pro Jul 17, 2024
4c57be3
pts_to_serialized_nlist_1, pts_to_serialized_length, etc.
tahina-pro Jul 18, 2024
a8eb400
Util: stick -> trade
tahina-pro Jul 19, 2024
6dee4b9
move all trade lemmas to Pulse.Lib.Trade.Util
tahina-pro Jul 19, 2024
65945cb
LowParse.Pulse: stick -> trade
tahina-pro Jul 19, 2024
e93bb12
LowParse.Pulse: remove now implicit arguments to trade operations
tahina-pro Jul 19, 2024
709bf3b
LowParse.Pulse: stick -> trade in names
tahina-pro Jul 19, 2024
e1ff2c4
LowParse.Pulse: vprop -> slprop
tahina-pro Jul 19, 2024
1dc81c2
WIP write
tahina-pro Jul 22, 2024
f922d50
WIP ghost parsers
tahina-pro Jul 23, 2024
50ebfeb
convert LowParse.Pulse back to ghost parsers, serializers (WIP impl_p…
tahina-pro Jul 23, 2024
bd2955d
WIP serialize
tahina-pro Jul 25, 2024
a723657
writer, size lenses
tahina-pro Jul 25, 2024
0e7e174
compute_remaining_size_constant_size
tahina-pro Jul 26, 2024
6986044
fuse Write into Base
tahina-pro Jul 26, 2024
26891a1
compose writing lenses, write ints
tahina-pro Jul 26, 2024
caea2d3
WIP l2r_write_dtuple2
tahina-pro Jul 30, 2024
6d47866
write dtuple2, nondep_then
tahina-pro Jul 30, 2024
6b86b7a
l2r_write_synth
tahina-pro Aug 1, 2024
eca27ba
l2r_write_filter
tahina-pro Aug 1, 2024
5917d64
l2r_leaf_writer_ext
tahina-pro Aug 1, 2024
05e9b22
l2r_leaf_write_filter
tahina-pro Aug 2, 2024
8ca9313
WHY WHY WHY are lambdas no longer usable in slprops?
tahina-pro Aug 22, 2024
59e59a0
lowparse: remove LowParse.Pulse.Util
tahina-pro Sep 6, 2024
24f2db9
WIP more l2r_writer combinators
tahina-pro Sep 27, 2024
88251c3
serialization combinators with reverse handling of vmatch
tahina-pro Oct 1, 2024
4d569ba
l2r_writer_ifthenelse
tahina-pro Oct 1, 2024
a3ba19f
serialize seqbytes by copy
tahina-pro Oct 1, 2024
deb455c
extensionality with explicit type equality in vmatch
tahina-pro Oct 1, 2024
ef51cfd
vmatch should act on low-level data bundled with perm
tahina-pro Oct 2, 2024
bc979a7
WIP l2r_write_nlist_as_array
tahina-pro Oct 4, 2024
a03661d
l2r_write_nlist_as_array
tahina-pro Oct 4, 2024
e771aa9
nlist_match_array: make varray partial
tahina-pro Oct 4, 2024
7dd28f6
move nlist_match_array_intro to LowParse.Pulse.VCList
tahina-pro Oct 4, 2024
19ea2f5
nlist_sorted
tahina-pro Oct 9, 2024
a74cccc
l2r_leaf_writer_ifthenelse
tahina-pro Oct 10, 2024
c9e131f
test extraction of CBOR serializer
tahina-pro Oct 10, 2024
430fac5
write_header
tahina-pro Oct 10, 2024
ac651f1
adjust proofs to new official Pulse slices
tahina-pro Oct 11, 2024
da4929e
move lemmas to LowParse.Pulse
tahina-pro Oct 15, 2024
4caa9b9
WIP serialize tagged
tahina-pro Oct 16, 2024
6bd6456
compute_remaining_size combinators
tahina-pro Oct 16, 2024
1c6683f
extract the validator, the parser and the serializer
tahina-pro Oct 16, 2024
367716a
towards sharing of Makefiles
tahina-pro Oct 25, 2024
9a15bae
ignore response files
tahina-pro Oct 25, 2024
1b08afc
recover build of lowparse/pulse
tahina-pro Oct 25, 2024
9b78c60
use --ext context_pruning with new Makefiles
tahina-pro Oct 25, 2024
2c3edcc
CI: install pulse, build lowparse/pulse
tahina-pro Oct 25, 2024
2ae077b
also install Pulse to build the binary package (even though it's not …
tahina-pro Oct 26, 2024
bfeaa30
fix standalone CI
tahina-pro Oct 28, 2024
3593766
(TEMP) use FStarLang/pulse#247
tahina-pro Oct 29, 2024
28f4e3b
remove slice_pair
tahina-pro Oct 29, 2024
848ec7a
Revert "(TEMP) use FStarLang/pulse#247"
tahina-pro Oct 30, 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
1 change: 1 addition & 0 deletions .docker/build/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

"RepoVersions" : {
"mitls_version" : "origin/dev",
"pulse_version" : "origin/main",
"karamel_version" : "origin/master"
}
}
8 changes: 8 additions & 0 deletions .docker/build/install-other-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@ pushd $KRML_HOME
popd
OTHERFLAGS='--admit_smt_queries true' make -j 24 -C "$KRML_HOME"

# Identify the Pulse branch
PULSE_BRANCH=$(jq -c -r '.RepoVersions.pulse_version' "$build_home"/config.json | sed 's!^origin/!!')

# Install Pulse and its dependencies
[[ -n "$PULSE_HOME" ]]
git clone --branch $PULSE_BRANCH https://github.com/FStarLang/pulse "$PULSE_HOME"
OTHERFLAGS='--admit_smt_queries true' make -j 24 -C "$PULSE_HOME"

opam install hex re ctypes sha sexplib
1 change: 1 addition & 0 deletions .docker/hierarchic.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ WORKDIR $HOME/everparse

# Dependencies (opam packages)
ENV KRML_HOME=$HOME/everparse/karamel
ENV PULSE_HOME=$HOME/everparse/pulse
RUN sudo apt-get update && eval $(opam env) && .docker/build/install-other-deps.sh

# CI dependencies: sphinx (for the docs)
Expand Down
1 change: 1 addition & 0 deletions .docker/produce-binary.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ RUN sudo apt-get update && sudo apt-get install -y --no-install-recommends \
# Dependencies (F*, Karamel and opam packages)
ENV FSTAR_HOME=$HOME/FStar
ENV KRML_HOME=$HOME/karamel
ENV PULSE_HOME=$HOME/pulse
RUN eval $(opam env) && .docker/build/install-deps.sh

# CI proper
Expand Down
1 change: 1 addition & 0 deletions .docker/standalone.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN sudo apt-get update && sudo apt-get install -y --no-install-recommends \
# Dependencies (F*, Karamel and opam packages)
ENV FSTAR_HOME=$HOME/FStar
ENV KRML_HOME=$HOME/karamel
ENV PULSE_HOME=$HOME/pulse
RUN eval $(opam env) && .docker/build/install-deps.sh

# CI dependencies: sphinx (for the docs)
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ quackyducky-test: quackyducky-unit-test quackyducky-sample-test quackyducky-samp

test: all lowparse-test quackyducky-test 3d-test asn1-test

ci: test
lowparse-pulse: lowparse
+$(MAKE) -C src/lowparse/pulse

.PHONY: lowparse-pulse

ci: test lowparse-pulse

clean-3d:
+$(MAKE) -C src/3d clean
Expand Down
94 changes: 94 additions & 0 deletions src/common.Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
ifeq (,$(EVERPARSE_SRC_PATH))
$(error "EVERPARSE_SRC_PATH must be set to the absolute path of the src/ subdirectory of the EverParse repository")
endif

include $(EVERPARSE_SRC_PATH)/fstar.Makefile

# List the directories of all root files
SRC_DIRS += .

# List additional include paths
INCLUDE_PATHS += $(SRC_DIRS)

# A place to put all build artifacts
ifneq (,$(OUTPUT_DIRECTORY))
FSTAR_OPTIONS += --odir $(OUTPUT_DIRECTORY)
endif

# A place to put .checked files. If this variable is left empty, then
# each .checked file will be generated right next to its corresponding
# source file.
ifneq (,$(CACHE_DIRECTORY))
FSTAR_OPTIONS += --cache_dir $(CACHE_DIRECTORY)
INCLUDE_PATHS+=$(CACHE_DIRECTORY)
endif

# Used only for OCaml extraction, not krml extraction
# OCaml or Plugin
FSTAR_ML_CODEGEN ?= OCaml

# Uncomment the definition of PROFILE below, if you want some basic
# profiling of F* runs It will report the time spent
# on typechecking your file And the time spent in SMT, which is
# included in the total typechecking time

# PROFILE=--profile YOUR_FILE --profile_component 'FStar.Universal.tc_source_file FStar.SMTEncoding'
FSTAR_OPTIONS += $(PROFILE)

# List the roots from where all dependencies are computed
FSTAR_FILES ?= $(wildcard $(addsuffix /*.fst,$(SRC_DIRS)) $(addsuffix /*.fsti,$(SRC_DIRS)))

# `ALREADY_CACHED` expected to be empty or to end with a comma
FSTAR_OPTIONS += $(OTHERFLAGS) $(addprefix --include ,$(INCLUDE_PATHS)) --cache_checked_modules --warn_error @241 --already_cached $(ALREADY_CACHED)Prims,FStar,LowStar --cmi --ext context_pruning

# Passing RESOURCEMONITOR=1 will create .runlim files through the source tree with
# information about the time and space taken by each F* invocation.
ifneq ($(RESOURCEMONITOR),)
ifeq ($(shell which runlim),)
_ := $(error $(NO_RUNLIM_ERR)))
endif
ifneq ($(MONID),)
MONPREFIX=$(MONID).
endif
RUNLIM=runlim -p -o $@.$(MONPREFIX)runlim
endif

FSTAR=$(RUNLIM) $(FSTAR_HOME)/bin/fstar.exe $(SIL) $(FSTAR_OPTIONS)

FSTAR_DEP_FILE ?= .depend

$(FSTAR_DEP_FILE): $(FSTAR_FILES)
$(call msg, "DEPEND")
ifneq (,$(OUTPUT_DIRECTORY))
mkdir -p $(OUTPUT_DIRECTORY)
endif
ifneq (,$(CACHE_DIRECTORY))
mkdir -p $(CACHE_DIRECTORY)
endif
$(Q)true $(shell mkdir -p $(dir $@)) $(shell rm -f [email protected]) $(foreach f,$(FSTAR_FILES),$(shell echo $(f) >> [email protected]))
$(Q)$(FSTAR) $(FSTAR_DEP_OPTIONS) --dep full @[email protected] --output_deps_to [email protected]
mv [email protected] $@

include $(FSTAR_DEP_FILE)

$(ALL_CHECKED_FILES): %.checked:
$(call msg, "CHECK", $(basename $(notdir $@)))
$(Q)$(RUNLIM) $(FSTAR) $(SIL) $(COMPAT_INDEXED_EFFECTS) $<
touch -c $@

verify: $(ALL_CHECKED_FILES)

%.fst-in %.fsti-in:
@echo $(FSTAR_OPTIONS)

# Extraction

$(ALL_ML_FILES): %.ml:
$(FSTAR) $(subst .checked,,$(notdir $<)) --codegen $(FSTAR_ML_CODEGEN) --extract_module $(basename $(notdir $(subst .checked,,$<)))

$(ALL_KRML_FILES): %.krml:
$(FSTAR) $(notdir $(subst .checked,,$<)) --codegen krml \
--extract_module $(basename $(notdir $(subst .checked,,$<)))
touch -c $@

.PHONY: all verify %.fst-in %.fsti-in
9 changes: 9 additions & 0 deletions src/everparse.Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ifeq (,$(EVERPARSE_SRC_PATH))
$(error "EVERPARSE_SRC_PATH must be set to the absolute path of the src/ subdirectory of the EverParse repository")
endif

include $(EVERPARSE_SRC_PATH)/karamel.Makefile

ALREADY_CACHED := LowParse,$(ALREADY_CACHED)

INCLUDE_PATHS += $(EVERPARSE_SRC_PATH)/lowparse
29 changes: 29 additions & 0 deletions src/fstar.Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ifeq (,$(EVERPARSE_SRC_PATH))
$(error "EVERPARSE_SRC_PATH must be set to the absolute path of the src/ subdirectory of the EverParse repository")
endif

# Find fstar.exe and the fstar.lib OCaml package
ifeq (,$(FSTAR_HOME))
_check_fstar := $(shell which fstar.exe)
ifeq ($(.SHELLSTATUS),0)
FSTAR_HOME := $(realpath $(dir $(_check_fstar))/..)
else
# $(error "FSTAR_HOME is not defined and I cannot find fstar.exe in $(PATH). Please make sure fstar.exe is properly installed and in your PATH or FSTAR_HOME points to its prefix directory or the F* source repository.")
# assuming Everest layout
FSTAR_HOME := $(realpath $(EVERPARSE_SRC_PATH)/../../FStar)
endif
endif
ifeq ($(OS),Windows_NT)
FSTAR_HOME := $(shell cygpath -m $(FSTAR_HOME))
endif
export FSTAR_HOME
ifeq ($(OS),Windows_NT)
OCAMLPATH := $(shell cygpath -m $(FSTAR_HOME)/lib);$(OCAMLPATH)
else
OCAMLPATH := $(FSTAR_HOME)/lib:$(OCAMLPATH)
endif
export OCAMLPATH
_check_fstar_lib_package := $(shell env OCAMLPATH="$(OCAMLPATH)" ocamlfind query fstar.lib)
ifneq ($(.SHELLSTATUS),0)
$(error "Cannot find fstar.lib in $(OCAMLPATH). Please make sure fstar.exe is properly installed and in your PATH or FSTAR_HOME points to its prefix directory or the F* source repository.")
endif
17 changes: 17 additions & 0 deletions src/karamel.Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ifeq (,$(EVERPARSE_SRC_PATH))
$(error "EVERPARSE_SRC_PATH must be set to the absolute path of the src/ subdirectory of the EverParse repository")
endif

ifeq (,$(KRML_HOME))
# assuming Everest layout
KRML_HOME := $(realpath $(EVERPARSE_SRC_PATH)/../../karamel)
ifeq (,$(KRML_HOME))
$(error "KRML_HOME must be defined and set to the root directory of the Karamel repository")
endif
endif

ALREADY_CACHED := C,LowStar,$(ALREADY_CACHED)

INCLUDE_PATHS += $(KRML_HOME)/krmllib $(KRML_HOME)/krmllib/obj

CFLAGS += -I $(KRML_HOME)/include -I $(KRML_HOME)/krmllib/dist/generic
1 change: 1 addition & 0 deletions src/lowparse/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.checked*
*.source
*.depend
*.rsp
Loading
Loading