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

Implement grep and prove spec #239

Merged
merged 30 commits into from Mar 10, 2017
Merged

Implement grep and prove spec #239

merged 30 commits into from Mar 10, 2017

Conversation

xrchz
Copy link
Member

@xrchz xrchz commented Mar 10, 2017

Initial version of grep example (no compilation yet, and maybe the implementation can still be tweaked). The initial translation was done by @IlmariReissumies.

xrchz and others added 30 commits March 5, 2017 08:55
Also rename {testing,all} -> tests, and move target{Sem,Props} to
backend/semantics. These are changes towards the desired directory
structure expressed at https://wiki.cakeml.org/Conventions.

Tweak target{Sem,Props} script files so they build again after the move.
I don't entirely understand why this is necessary, or, more precisely,
what I should be changing (set_grammar_ancestry? Holmakefiles?
overloads?) since multiple fixes would work but the correct policy is
not clear.
Now that the relevant theorem is exported by regexp_compilerTheory
Use Basis functions where possible.
Use MEMBER_INTRO to avoid translating LIST_TO_SET.
Avoid name clashes.
Extend from ioProg and prepare to translate parser.
These functions are useful for rewriting away shifts in definitions to
be translated. The translator could perhaps be modified to support
variable-length shifts directly (either using these rewrites or some
other method).
Disturbingly, the interactive and non-interactive behaviour of the
parser seems to be quite different. I think it gets the overloads wrong
non-interactively, since preferring a constant in the current theory is
surely desirable.
for grep

this was trickier than I expected
This is work in progress. Bogged down in the spec, trying to prove
things about FIELDS (which I am using to split a string into lines).
Even if one is committed to including every possible ancestral theory
from HOL (via misc and/or preamble), one need not let their parsing
context influence the current one.

Currently, it's clearly far from ideal to depend on regexp_compiler
for the definition of the vector type; doing so brings in
balanced_map (which has its own notion of fromList).
Also define splitlines and prove some lemmas about it too. The
specification for operating over lines in a file is complicated because
file contents (string) might be empty and/or might not have a trailing
newline.
Lots of hacking to work around CF's poor support for higher-order
functions. I found a way to prove a custom specification for a partially
applied function, which maybe should be revisited on the original
(nicer) grep implementation.

The cheats are:
  1. regexp_matcher corresponds to regexp_lang
     This should have been proved as part of the regexp matching theory,
     but does not seem to be packaged up nicely.
  2. termination of the regexp matching algorithm. if we do not prove
     termination, then this will need to bubble up into the
     specification somehow.
Also fix the open'd theories list
@xrchz xrchz merged commit 718cf50 into master Mar 10, 2017
@xrchz xrchz deleted the grep branch March 10, 2017 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants