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

Shape analysis #58

Draft
wants to merge 133 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
5958bc1
build: Generate tests for t/*.smt and t/*.kore (these are not part of…
nishantjr May 8, 2020
0ba6ffa
build: Replace ls_nonrec_entail_ls_{07 => 05}.sb.smt2 and add kore sm…
nishantjr May 8, 2020
7cbf5f9
configuration: strategies are now in the <k> cell. goals in <claim>
nishantjr May 8, 2020
d1a7233
build: Work around different extensions being used by kore and smt tests
nishantjr May 9, 2020
28fcf3d
build: uncomment out kore and smt tests, add some missing expected files
lucaspena Mar 11, 2020
69979e4
add footprint analysis rule. modify matching to handle heap variable
lucaspena Mar 11, 2020
6db13f4
move footprint analysis from unfolding to matching
lucaspena Mar 12, 2020
ff505cb
matching: footprint analysis uses match to find instance of pto on LHS
lucaspena Mar 12, 2020
98e3e03
testlists: dll-vc05: Use kt as part of the search instead of manually…
nishantjr Mar 17, 2020
004cdcb
matching: #matchStuck is own sort now, results in stuck configuration…
lucaspena Mar 17, 2020
7047989
matching: remove spurious side condition in matchAssocComm rule causi…
lucaspena Mar 17, 2020
3fadad9
begin nullity analysis strategy
lucaspena Mar 17, 2020
86f67d5
Fix claim vs strategy cell issues
nishantjr May 8, 2020
3eaf17a
add strategy to abstract away LHS spatial part
lucaspena Mar 17, 2020
74d2276
simplification: simplify substitute-equals-for-equals - call subst di…
lucaspena Mar 18, 2020
3d92359
modify nullity analysis, kt-solve-implications
lucaspena Mar 18, 2020
d1272d5
extra dnfPs case: and(not(and))
lucaspena Mar 23, 2020
504a007
and-split-rhs added
lucaspena Mar 23, 2020
411ab33
more general kt-collapse rule subsuming ad-hoc rule
lucaspena Mar 23, 2020
cbf688f
wip: somewhat ad-hoc strategy for abstract nil terms
lucaspena Mar 25, 2020
be3faf6
kt: added fail case for kt-collapse back
lucaspena Mar 25, 2020
14c2357
simplification: fix small bug in #getNewVariables
lucaspena Mar 25, 2020
7cedfc5
kt: ktForEachLRP(.Patterns) fails instead of noop
lucaspena Mar 25, 2020
54b1505
WIP: knaster-tarski: substituting keeps predicate information after k…
lucaspena Mar 30, 2020
e3bfe16
fix claim v strategy
nishantjr May 8, 2020
13c9849
kt: split kt-unfold into kt-unfold and kt-subst
lucaspena Mar 31, 2020
7890d3c
wip: lift-constraints has incorrect canonical form
lucaspena Mar 31, 2020
a043d9e
completely reimplement lift-constraints (correctly this time)
lucaspena Apr 1, 2020
061276f
alpha rename in RHS of kt-subst
lucaspena Apr 1, 2020
8fba1da
incomplete: resolution rule
nishantjr Apr 6, 2020
bc3c5b0
fix kt-collapse rule
nishantjr Apr 6, 2020
fbafbd5
knaster-tarski: dont call dnfPs until kt-collapse-unsat
lucaspena Apr 7, 2020
2b8837a
use substitution for kt-wrap, left-unfold instead of specialized FOL/…
lucaspena Apr 7, 2020
44d63ea
wip on kt-collapse with resolution
lucaspena Apr 7, 2020
20992c3
add test for matching over symbolic heap
lucaspena Apr 7, 2020
71b7f47
add constructor axiom
lucaspena Apr 13, 2020
01d6bb2
check-lhs-constraint-unsat-debug strategy
lucaspena Apr 13, 2020
11bfb87
wip on match-assoc-comm test of match within a conjunction of multipl…
lucaspena Apr 13, 2020
ebd3efe
rename instantiate-axiom to instantiate-heap-axiom
lucaspena Apr 13, 2020
a7eab4b
pto-is-injective strategy
lucaspena Apr 13, 2020
b4a48b1
wip on abstracting nil
lucaspena Apr 15, 2020
24b0f2d
nil no longer parameterized symbol
lucaspena Apr 15, 2020
471d841
matching with heap variable must be at end of pattern list
lucaspena Apr 15, 2020
edbed2f
move spatial-patterns-match strategy
lucaspena Apr 16, 2020
e7e21d3
footprint-analysis: symbolic heap must be at end of sep
lucaspena Apr 16, 2020
4895894
dll-vc07 goes through
lucaspena Apr 16, 2020
5282ea0
Fix codeblock formatting
nishantjr Apr 19, 2020
442c300
right-unfold-all: base case is noop, falls back on search-bound base …
lucaspena Apr 19, 2020
6d20f85
spatial-patterns-match: iterates on all heaps on LHS
lucaspena Apr 19, 2020
95df663
search-bound: add spatial-patterns-match before smt call
lucaspena Apr 19, 2020
6db2cf3
dll-vc11 goes through with footprint-analysis, abstract-nil
lucaspena Apr 19, 2020
569e212
filterVariablesBySort: move to kore-lang
lucaspena Apr 19, 2020
5d66a95
nullity-analysis: generalize to work over all location variables
lucaspena Apr 19, 2020
1042ffb
kt-collapse: failing rule does not rewrite claim cell
lucaspena Apr 21, 2020
826dc5e
kt-collapse-unsat: heap variable added at end of sep
lucaspena Apr 21, 2020
5fc083a
change #hole to VariableName instead of Variable
lucaspena Apr 22, 2020
913c121
kt-collapse: use subgoal to collapse context using full power of prover
lucaspena Apr 22, 2020
1db1f41
match: rotate heap variable when not at end of pattern list
lucaspena Apr 22, 2020
10ba462
match: lhs can have multiple seps
lucaspena Apr 22, 2020
4c7c0a0
spatial-patterns-equal: wip on multiple seps on LHS
lucaspena Apr 22, 2020
8e46aba
spatial-patterns-match: works with multiple seps anywhere on lhs
lucaspena Apr 22, 2020
69d7747
spatial-patterns-equal: handles case of multiple seps on RHS
lucaspena Apr 23, 2020
36a39e8
kt-collapse: add heap variable to rule 2a on LHS
lucaspena Apr 24, 2020
b492c30
matching: match on multiple heaps on RHS
lucaspena Apr 24, 2020
d241cdd
spatial-patterns-equal: lift-constraints after removing heaps
lucaspena Apr 24, 2020
9f80007
kt-collapse-resolve: still applies with empty constraints
lucaspena Apr 26, 2020
98726b5
match: terms can be and(.Patterns)
lucaspena Apr 27, 2020
882d4ff
frame: use spatial-patterns-match instead of subsumes-spatial
lucaspena Apr 27, 2020
e296cd3
abstract: more general abstraction of nil, dll-vc17 goes through
lucaspena Apr 27, 2020
642a4e1
kt-collapse: Remove unneeded sidecondition on Univerals
nishantjr Apr 29, 2020
05c95a5
re-parameterize nil with sort (needed for nll cases with multiple heaps)
lucaspena Apr 29, 2020
5afcbed
strategy for nll-vc03
lucaspena Apr 29, 2020
0dd7b7c
strategies/kt: Split kt into multiple modular strategies; fix broken …
nishantjr Apr 30, 2020
8d5cff5
simplification: lift-or: handle \implies(\and(\or()...)
nishantjr Apr 30, 2020
98aa0de
simplification: instantiate-existentials: also instantiate existentia…
nishantjr Apr 30, 2020
e741ab0
core: and-split: \and(.Patterns) => success
nishantjr Apr 30, 2020
c5d4c09
search-sl: Do a check-lhs-constraint-unsat since the kt-collapse-no-m…
nishantjr Apr 30, 2020
6438bf9
Update notes about `kt-collapse`
nishantjr May 1, 2020
0abcc10
abstract: additional case for #createDisequalities
lucaspena Apr 30, 2020
03426d9
strategy for nll-vc04
lucaspena Apr 30, 2020
51283de
frame of #hole goes to fail
lucaspena May 2, 2020
99eb5e7
strategy for nll_vc08 and nll_vc10
lucaspena May 2, 2020
0eb2f0d
lib/render-proof-tree
nishantjr May 3, 2020
c0916b3
match-debug
nishantjr May 3, 2020
30aea94
matching: match: Everything matches \top
nishantjr May 3, 2020
d2524b0
claim v strategy
nishantjr May 8, 2020
b3ff80d
matching: spatial-patterns-match: Fix non-termination; Use #match
nishantjr May 3, 2020
a58d508
kt: Number of fixes for:
nishantjr May 3, 2020
7bc0197
t/SL-COMP18/bench/qf_shid_entl/tseg_join_tree_entail_tseg.sb.smt2 pas…
nishantjr May 3, 2020
ed04d34
Remove tests without expected results
nishantjr May 5, 2020
46a07d8
claim v strategy
nishantjr May 9, 2020
3cd18de
strategy to remove constraints from lhs, lsegex4_slk-1 goes through
lucaspena May 4, 2020
44262ce
smt-driver: nil is a constructor
lucaspena May 4, 2020
3e7acb1
simplification: fix comment on remove constraints
lucaspena May 4, 2020
4b88e02
testlists: skl3-vc10 goes through
lucaspena May 5, 2020
e1f23e8
ltl test: until implies eventually
lucaspena May 5, 2020
f0418ba
t/: Place LTL test in own folder
nishantjr May 6, 2020
04d2bde
kt: Do not normalize in KT. This happens in the search in any case
nishantjr May 6, 2020
8461050
drivers/base: Fix typo in configuration format attribute
nishantjr May 9, 2020
18cb11d
begin work on mu/ltl
nishantjr May 6, 2020
8a73b72
kore: getReturnSort: Case of \mu, \or, \and
nishantjr May 6, 2020
3bc5c48
wip on adding support for \mu for ltl example
lucaspena May 6, 2020
b956ff0
fix spacing right-unfold-Nth
lucaspena May 6, 2020
44aed1e
fix typo
lucaspena May 7, 2020
90f3212
more wip on until implies eventually
lucaspena May 7, 2020
85bc0db
driver/base: configuration: Claim cell is \bottom rather than top ini…
nishantjr May 10, 2020
6691808
drivers/smt-driver: Rename `#rest` => `#mutualRecUnfold` to avoid amb…
nishantjr May 10, 2020
2b76620
lang/kore: Reimplement #dnf
nishantjr May 10, 2020
0b37030
t/unit/match-assoc: Fix missing { Data }
nishantjr May 10, 2020
7c9b6d4
matching: #match: Fix missing side condition
nishantjr May 10, 2020
1894ca5
!!! t/unit/match-assoc-comm: Regression test for match failing when i…
nishantjr May 10, 2020
39e7a6b
kore-helpers :#liftOr: combine multiple bases cases by using isDnfAtom
nishantjr May 10, 2020
8352db3
t/unit/match-assoc-comm: Test should be calling #match, not #matchAss…
nishantjr May 10, 2020
106ca3e
matching over mu
lucaspena May 10, 2020
b2dda5f
fix bugs in dnf, wip on until implies eventually
lucaspena May 10, 2020
c866c11
fix preprocessing for matching, until implies eventually goes through
lucaspena May 11, 2020
f58cc74
wip on gfp strategy for nu, base case for ltl ind rule goes through
lucaspena May 11, 2020
24f1fcf
kore: Extend subst and getFreeVariables to \nu
nishantjr May 14, 2020
d3eeec8
kore: #nnf handles \exists { .Patterns }
nishantjr May 14, 2020
cfb9c33
strategies/core: rhs-top: Add failure case
nishantjr May 14, 2020
f503385
strategy: constradiction: Look for a contradiction between the first …
nishantjr May 14, 2020
22631ad
matching: #matchAssoc: Syntactically match on `\not`
nishantjr May 14, 2020
94da501
matching: Use #nnf to allow handeling more cases such as \implies
nishantjr May 14, 2020
150e5a9
matching: #matchAssoc: Patterns may use set variables too
nishantjr May 14, 2020
286e3ca
t/ltl/always-propagates.kore
nishantjr May 14, 2020
9a34a4a
fix bugs in dnf, remove need for liftconstraints
lucaspena May 14, 2020
01904b6
Update README
nishantjr May 14, 2020
6f47f37
nu is not a predicate pattern
lucaspena May 15, 2020
5298d3f
fix match case with error, ind goes through again
lucaspena May 15, 2020
702d741
render-proof-tree env specifies python3
lucaspena May 15, 2020
34c4a6d
render-proof-tree: goals no longer have active cell, first goal is ac…
lucaspena May 15, 2020
74f6a1c
kt-collapse: fix bug where substitution in match case is not applied …
lucaspena May 15, 2020
0befca9
build: Uniform extensions for all tests
nishantjr May 15, 2020
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
87 changes: 56 additions & 31 deletions prover/README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,64 @@
Build Instructions
Building
========

Besides the normal K dependencies, the matching logic prover also depends on
`pandoc-tangle`, `python3` and `ninja-build`.
On an Ubuntu Bionic (18.04) system you can install the following packages:

```
apt install autoconf curl flex gcc libffi-dev libmpfr-dev libtool make \
maven ninja-build opam openjdk-8-jdk pandoc pkg-config python3 \
time zlib1g-dev
```

Source organization
===================

The source code is organized under the following directories:

* `drivers/`: Modules for reading input formats and converting them to the
matching logic `kore` format, and loading them into the configuration.
* `lang/`: Tools for working with the source languages (kore and smtlib)
* `strategies/`: The various proof rules are implemented as "strategies".

* `strategies/core.md`: Core strategies, such as composition and choice.
* `strategies/knaster-tarski.md`: Strategies relating to using the Knaster Tarki rule
and contexts.
* `strategies/unfolding.md`: Strategies relating to unfolding fixed points.
* `strategies/matching.md`: Strategies relating to pattern matching
* `strategies/smt.md`: Strategies that utilize an SMT solver.

Tests & Benchmarks
==================

Install these dependencies:
Organization
-------------

* pandoc
* ninja-build
* opam
* maven
* openjdk-11-jdk
The tests and benchmarks are stored under the `t/` directory in the following
subdirectories:

Run `./build` to run all tests.
Run `./build .build/t/TEST-NAME.smt2.prover-smt-krun` to run an individual test.
* `t/ltl`: LTL Tests.
* `t/sl`: Separation Logic tests and benchmarks.
* `t/sl/SL-COMP18/`: This is a git submodule containing all the `SL-COMP` tests.
* `t/sl/SL-COMP18/bench/qf_shid_entl/`: These are the benchmarks we aim to complete.
* `t/fol`: FOL Tests.

Repository Layout
=================
In addition, unit tests are stored under `t/unit/`

* `prover.md` contains the implementation
* `direct-proof.md` contains solutions to domain specific queries that
can be checked against an SMT solver.
* The `t/` directory contains a number of tests and experiments, detailed below.
File formats
------------

Tests & Experiments
===================
The prover accepts two file formats:

1. `.kore`: This is the "native" matching logic based format that the prover accepts.
2. `.smt`: This is the [SMT-LIB 2.6 format] with the [extensions for SL-COMP]

[SMT-LIB 2.6 format]: http://smtlib.cs.uiowa.edu/papers/smt-lib-reference-v2.6-r2017-07-18.pdf
[extensions for SL-COMP]: https://sl-comp.github.io/docs/smtlib-sl.pdf

Running tests
=============

In the `t/` directory, we have a number of tests. Each test consists of a
"claim" (the matching logic pattern that we are trying to prove), and a
strategy. The strategy directs the prover in choosing which axioms to apply. The
`search-bound(N)` strategy causes the prover to begin a bounded depth first
search for a proof of the claim. All lemmas named in the paper except one
(`t/lsegright-list-implies-list`; see below) are proved with a search depth of 5
or lower. The program verification example is proved with a search up to depth
3. In addition, there is an example of a coninductive proof
(`t/zip-zeros-ones-implies-alters.prover`; see below).

The `t/zip-zeros-ones-implies-alters.prover` test proof is at a depth of 17,
and so we specify the strategy to reduce the search space.
The `t/lsegright-list-implies-list` test needs some help in instantiating
existential variables, which is done by specifying a strategy as a substitution.
* To run a select group of tests, called the "smoke-tests", run: `./build smoke-tests`.
* To run a single kore test named "t/foo.kore", run `./build .build/t/foo.kore.prover-kore-run`
* To run a single smt test named "t/foo.smt", run `./build .build/t/foo.kore.prover-smt-run`
19 changes: 13 additions & 6 deletions prover/build
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ prover_smt = prover('prover-smt', '--main-module DRIVER-SMT --syntax-module D
# Functional tests
# ----------------

# prover_kore.tests(inputs = glob('t/*.kore'), implicit_inputs = glob('t/definitions/*.kore'), flags = '-cCOMMANDLINE=.CommandLine')
# prover_smt .tests(inputs = glob('t/*.smt2'), flags = '-cCOMMANDLINE=.CommandLine')
prover_kore.tests(inputs = glob('t/*.kore'), implicit_inputs = glob('t/definitions/*.kore'), flags = '-cCOMMANDLINE=.CommandLine')
prover_kore.tests(inputs = glob('t/ltl/*.kore'), implicit_inputs = glob('t/definitions/*.kore'), flags = '-cCOMMANDLINE=.CommandLine')
prover_smt .tests(inputs = glob('t/*.smt2'), flags = '-cCOMMANDLINE=.CommandLine')

def log_on_success(file, message):
return proj.rule( 'log-to-success'
Expand Down Expand Up @@ -105,7 +106,7 @@ def make_test(rule, test):

def sl_comp_test(test, log_file):
global tests_with_timeout
test_no_timeout = make_test(prover_smt.krun(), test)
test_no_timeout = make_test(prover_smt.krun().ext('prover-smt-run'), test)
test_with_timeout = make_test(krun_with_timeout(timeout_for_test(test)), test) \
.then(log_on_success(log_file, test))
return (test_no_timeout, test_with_timeout)
Expand All @@ -131,8 +132,11 @@ secondary_tests('qf_shidlia_entl_unsat_tests', 't/test-lists/qf_shidlia_entl.uns
secondary_tests('qf_shlid_entl_unsat_tests', 't/test-lists/qf_shlid_entl.unsat')
secondary_tests('shid_entl_unsat_tests', 't/test-lists/shid_entl.unsat')

# TODO: Why are smt tests `-krun` and kore tests `-run`?
def test_path(name, type):
return ".build/t/%s.%s" % (name, type)
def sl_comp_test_path(name):
return ".build/t/SL-COMP18/bench/qf_shid_entl/%s.prover-smt-krun" % (name)
return test_path("SL-COMP18/bench/qf_shid_entl/%s" % name, 'prover-smt-krun')

proj.alias('smoke-tests', list(map( sl_comp_test_path, [
"02.tst.smt2" , # RList trans
Expand All @@ -145,9 +149,12 @@ proj.alias('smoke-tests', list(map( sl_comp_test_path, [
"skl2-vc03.smt2" , # needs framing but not match-pto
"odd-lseg3_slk-5.smt2" , # needs framing and match-pto
"nll-vc01.smt2" , # needs large number of unfolding but no kt
"ls_nonrec_entail_ls_07.sb.smt2" , # 6 variable transitivity: ls_nonrec(x,x1) * ... * ls_nonrec(x4,x5) -> ls(x,x5) - needs large number of kts and unfolding
"ls_nonrec_entail_ls_05.sb.smt2" , # 4 variable transitivity: ls_nonrec(x,x1) * ... * ls_nonrec(x4,x5) -> ls(x,x5) - needs large number of kts and unfolding
"ls_lsrev_concat_entail_ls_1.sb.smt2" , # need unfolding within implication context
])))
])) +
[ test_path('listSegmentLeft-implies-listSegmentRight.kore', 'prover-kore-run')
]
)

# Unit Tests
# ----------
Expand Down
10 changes: 5 additions & 5 deletions prover/drivers/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Configuration
=============

The configuration consists of a list of goals. The first goal is considered
active. The `<k>` cell contains the Matching Logic Pattern for which we are
searching for a proof. The `<strategy>` cell contains an imperative language
active. The `<claim>` cell contains the Matching Logic Pattern for which we are
searching for a proof. The `<k>` cell contains an imperative language
that controls which (high-level) proof rules are used to complete the goal. The
`<trace>` cell stores a log of the strategies used in the search of a proof and
other debug information. Eventually, this could be used for constructing a proof
Expand All @@ -23,11 +23,11 @@ module PROVER-CONFIGURATION
<prover>
<exit-code exit=""> 1 </exit-code>
<goals>
<goal multiplicity="*" type="List" format="%1%i%n%2, %3%n%4%n%5n%6%n%7%n%d%8">
<goal multiplicity="*" type="List" format="%1%i%n%2, %3%n%4%n%5%n%6%n%7%n%d%8">
<id format="id: %2"> .K </id>
<parent format="parent: %2"> .K </parent>
<claim> \or(.Patterns) </claim> // TODO: make this optional instead?
<k> $COMMANDLINE:CommandLine ~> $PGM:Pgm </k>
<strategy> .K </strategy>
<expected> .K </expected>
<local-context>
<local-decl multiplicity="*" type="Set"> .K </local-decl>
Expand Down Expand Up @@ -91,7 +91,7 @@ module DRIVER-BASE
<goal>
<id> .K </id>
<expected> .K </expected>
<strategy> .K </strategy>
<k> .K </k>
...
</goal>
</goals>
Expand Down
1 change: 1 addition & 0 deletions prover/drivers/kore-driver.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ in the subgoal and the claim of the named goal remains intact.
=> subgoal(NAME, PATTERN, subgoal(PATTERN, STRAT))
...
</k>
rule <k> (success => .K) ~> D:Declarations ... </k>
```

```k
Expand Down
59 changes: 27 additions & 32 deletions prover/drivers/smt-driver.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,10 @@ module DRIVER-SMT
</k>
<declarations> ( .Bag
=> <declaration> symbol pto(SMTLIB2SortToSort(LOC), SMTLIB2SortToSort(DATA)) : Heap </declaration>
<declaration> symbol parameterizedSymbol(nil, SMTLIB2SortToSort(LOC)) ( .Sorts ) : SMTLIB2SortToSort(LOC) </declaration>
<declaration> symbol nil { SMTLIB2SortToSort(LOC) } (.Sorts) : SMTLIB2SortToSort(LOC) </declaration>
<declaration> axiom !N:AxiomName : heap(SMTLIB2SortToSort(LOC), SMTLIB2SortToSort(DATA)) </declaration>
<declaration> axiom !N:AxiomName : functional(parameterizedSymbol(nil, SMTLIB2SortToSort(LOC))) </declaration>
<declaration> axiom !M:AxiomName : functional(nil { SMTLIB2SortToSort(LOC) }) </declaration>
<declaration> axiom !P:AxiomName : constructor(nil { SMTLIB2SortToSort(LOC) }) </declaration>
) ...
</declarations>

Expand All @@ -159,6 +160,7 @@ module DRIVER-SMT
=> <declaration> sort SMTLIB2SortToSort(SORT1) </declaration>
<declaration> symbol SMTLIB2SimpleSymbolToSymbol(CTOR)(SelectorDecListToSorts(SELDECs)) : SMTLIB2SortToSort(SORT1) </declaration>
<declaration> axiom !N:AxiomName : functional(SMTLIB2SimpleSymbolToSymbol(CTOR)) </declaration>
<declaration> axiom !M:AxiomName : constructor(SMTLIB2SimpleSymbolToSymbol(CTOR)) </declaration>
) ...
</declarations>

Expand All @@ -185,18 +187,18 @@ module DRIVER-SMT
) ...
</declarations>

syntax K ::= #rest(SMTLIB2FunctionDecList, SMTLIB2TermList)
syntax K ::= #mutualRecUnfold(SMTLIB2FunctionDecList, SMTLIB2TermList)

rule <k> _:GoalBuilder
~> ( #rest(_, _)
~> ( #mutualRecUnfold(_, _)
~> (define-funs-rec ( .SMTLIB2FunctionDecList ) ( .SMTLIB2TermList ) )
=> .K
)
...
</k>

rule <k> #goal( goal: _, strategy: unfold-mut-recs . REST_STRAT, expected: _ )
~> (.K => #rest(FDs, BODIEs))
~> (.K => #mutualRecUnfold(FDs, BODIEs))
~> (define-funs-rec ( FDs ) ( BODIEs ) )
...
</k>
Expand All @@ -217,7 +219,7 @@ module DRIVER-SMT
</k>
requires notBool #matchesUnfoldMutRecs(STRAT)

rule <strategy> unfold-mut-recs => noop ... </strategy>
rule <k> unfold-mut-recs => noop ... </k>

syntax Bool ::= #matchesUnfoldMutRecs(Strategy) [function]
rule #matchesUnfoldMutRecs(unfold-mut-recs) => true
Expand All @@ -226,7 +228,7 @@ module DRIVER-SMT
[owise]

rule <k> _:GoalBuilder
~> #rest(FDALLs, BODYALLs)
~> #mutualRecUnfold(FDALLs, BODYALLs)
~> ( (define-funs-rec ( (ID (ARGs) RET) FDs ) ( BODY BODIEs ) )
=> unfoldMR( SMTLIB2SimpleSymbolToSymbol(ID)(SMTLIB2SortedVarListToPatterns(ARGs))
, SMTLIB2TermToPattern(BODY, SMTLIB2SortedVarListToPatterns(ARGs))
Expand All @@ -252,7 +254,7 @@ module DRIVER-SMT
), #gatherRest(FDs, BODIEs)

syntax K ::= unfoldMR(Pattern, Pattern, PatternTupleList)
rule <k> _:GoalBuilder ~> #rest(_, _)
rule <k> _:GoalBuilder ~> #mutualRecUnfold(_, _)
~> ( unfoldMR(ID:Symbol(ARGs), BODY, .PatternTupleList)
=> .K
)
Expand All @@ -267,14 +269,14 @@ module DRIVER-SMT
) ...
</declarations>

rule <k> _:GoalBuilder ~> #rest(_, _)
rule <k> _:GoalBuilder ~> #mutualRecUnfold(_, _)
~> ( unfoldMR(ID:Symbol(ARGs1), BODY1, ((ID:Symbol(ARGs2), BODY2), REST))
=> unfoldMR(ID:Symbol(ARGs1), BODY1, REST)
)
...
</k>

rule <k> _:GoalBuilder ~> #rest(_, _)
rule <k> _:GoalBuilder ~> #mutualRecUnfold(_, _)
~> ( unfoldMR(ID1:Symbol(ARGs1), BODY1, ((ID2:Symbol(ARGs2), BODY2), REST))
=> unfoldMR(ID1:Symbol(ARGs1), substituteBRPs(BODY1, ID2, ARGs2, BODY2), REST)
)
Expand Down Expand Up @@ -319,23 +321,20 @@ module DRIVER-SMT
rule #containsSpatialPatterns((P, Ps), S) => #containsSpatial(P, S) orBool #containsSpatialPatterns(Ps, S)

syntax KItem ::= "expect" TerminalStrategy
rule <strategy> S ~> expect S => .K ... </strategy>
rule <k> S ~> expect S => .K ... </k>

rule <goals>
<k> #goal( goal: (\exists{Vs} \and(Ps)) #as PATTERN, strategy: STRAT, expected: EXPECTED)
rule <k> ( #goal( goal: (\exists{Vs} \and(Ps)) #as PATTERN, strategy: STRAT, expected: EXPECTED)
~> (check-sat)
=> #goal( goal: PATTERN, strategy: STRAT, expected: EXPECTED)
...
</k>
<strategy> .K
=> subgoal(\implies(\and(#filterPositive(Ps)), \and(\or(#filterNegative(Ps))))
, STRAT
)
~> expect EXPECTED
</strategy>
...
</goals>
requires notBool PATTERN ==K \exists { .Patterns } \and ( .Patterns )
)
=> ( subgoal(\implies( \and(#filterPositive(Ps)), \and(\or(#filterNegative(Ps))))
, STRAT
)
~> #goal( goal: PATTERN, strategy: STRAT, expected: EXPECTED)
)
...
</k>
requires notBool PATTERN ==K \exists { .Patterns } \and ( .Patterns )
rule <k> (success => .K) ~> #goal( goal: _, strategy: _, expected: _) ... </k>
```

```k
Expand Down Expand Up @@ -404,13 +403,9 @@ Clear the `<k>` cell once we are done:
rule #removeExistentialsPatterns(P, Ps) => #removeExistentials(P) ++Patterns #removeExistentialsPatterns(Ps)
rule #removeExistentialsPatterns(.Patterns) => .Patterns

syntax Pattern ::= #normalizeQFree(Pattern) [function]
| #normalizeDefinition(Pattern) [function]
syntax Pattern ::= #normalizeDefinition(Pattern) [function]
| #pushExistentialsDisjunction(Pattern) [function]
rule #normalizeDefinition(P) => #pushExistentialsDisjunction(\exists { #getExistentialVariables(P) } #normalizeQFree(#removeExistentials(P)))
rule #normalizeQFree(\or(Ps)) => \or(#flattenOrs(#dnfPs(Ps)))
rule #normalizeQFree(P) => #normalizeQFree(\or(P, .Patterns))
[owise]
rule #normalizeDefinition(P) => #pushExistentialsDisjunction(\exists { #getExistentialVariables(P) } #flattenAssoc(#liftOr(#nnf(\or(\and(#removeExistentials(P)))))))
rule #pushExistentialsDisjunction(\exists{Vs} \or(Ps)) => \or(#exists(Ps, Vs))

syntax Strategy ::= #statusToTerminalStrategy(CheckSATResult) [function]
Expand All @@ -437,7 +432,7 @@ Clear the `<k>` cell once we are done:
rule SMTLIB2TermToPattern(I:Int, _) => I
rule SMTLIB2TermToPattern(#token("true", "LowerName"), _) => \top()
rule SMTLIB2TermToPattern(#token("false", "LowerName"), _) => \bottom()
rule SMTLIB2TermToPattern((as nil SORT), _) => parameterizedSymbol(nil, SMTLIB2SortToSort(SORT))(.Patterns)
rule SMTLIB2TermToPattern((as nil SORT), _) => nil { SMTLIB2SortToSort(SORT) } (.Patterns)
rule SMTLIB2TermToPattern((underscore emp _ _), _) => emp(.Patterns)

rule SMTLIB2TermToPattern((ID Ts), Vs) => SMTLIB2SimpleSymbolToSymbol(ID)(SMTLIB2TermListToPatterns(Ts, Vs))
Expand Down
4 changes: 3 additions & 1 deletion prover/drivers/unit-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ requires "t/unit/match-assoc-comm.k"
requires "t/unit/subst.k"
requires "t/unit/syntactic-match.k"
requires "t/unit/visitor.k"
requires "t/unit/dnf.k"
```

```k
module DRIVER-UNIT-TEST
imports TEST-CHECKSAT
imports TEST-DNF
imports TEST-MATCH-ASSOC
imports TEST-MATCH-ASSOC-COMM
imports TEST-SUBST
Expand All @@ -27,7 +29,7 @@ module UNIT-TEST

syntax Declaration ::= "suite" String
rule <k> suite(SUITE) => next-test(SUITE, 1) ... </k>

syntax Declaration ::= "next-test" "(" String "," Int ")"
rule <k> next-test(SUITE, N)
=> test(SUITE, N)
Expand Down
Loading