Commit Graph

42 Commits

Author SHA1 Message Date
Robby Findler
d94d479f15 added 'boolean' pattern to Redex
closes PR 13330
2012-11-30 19:17:27 -06:00
Robby Findler
7355c59fb1 added the ability to extract a derivation
from a judgment-form via build-derivation
(returns derivation structs)
2012-10-21 23:19:54 -05:00
Burke Fetscher
44dd4acb44 Additional random test generation capability for Redex.
This adds the option to generate random terms that satisfy
judgment-forms and metafunctions.

Currently functionality does not include:
- patterns/terms using: ellipses, in-hole/hole and relatives, side-conditions, unquotes
- define-relation
- redex-check integration
2012-10-17 16:30:51 -05:00
Robby Findler
676f744c1d add 'match-pattern?' 2012-03-27 12:21:17 -05:00
Jay McCarthy
99f1cc44df redex-match violates its documented contract
This patch fixes the problem that the hole matcher may return an empty
list rather than a #f that gets sent to the caller of redex-match. I
re-ran the Redex tests and found no violations. However, I am not
confident that there isn't a more correct place to put this '() -> #f
replacement.

I will be immediately forwarding this push email to Robby to have him
check it.
2012-03-23 06:39:14 -06:00
Eli Barzilay
c007c345f9 A bunch of more typos like the ones in David's commit. 2012-02-21 14:21:43 -05:00
Robby Findler
e4e4d70b6b added define-union-language 2012-02-10 17:10:47 -06:00
Robby Findler
55b3d99d78 adjust beaucoup places in redex where the source was being
included in the compiled files. (also, misc minor cleanups
notably a new exercise in tut.scrbl)

closes PR 12547 --- there are still a few uses left, but they do not
seem to be coming from Redex proper:

 - /Users/robby/git/plt/collects/racket/private/map.rkt still appears
   in a bunch of places (there is a separate PR for that I believe),
   and

 - /Users/robby/git/plt/collects/redex/../private/reduction-semantics.rkt
   appears in tl-test.rkt, but I do not see how it
   is coming in via Redex code, so hopefully one of the other
   PRs that Eli submitted is the real cause. If not, I'll revisit later
2012-02-08 09:59:44 -06:00
Robby Findler
b068d9583c Remove accidentally pushed commits
For the curious, this was an attempt to change the way context
matching works.  Currently, when matching a pattern, if 'hole' is
encountered, the match succeeds and the result just includes the term
at that point. This means that when matching (in-hole p1 p2), p1
generally returns multiple results and then those results are thinned
out by matching p2 against the thing actually at the hole.

Instead, one could pass along the function that does the matching and
then, when matching a hole pattern, it could decide right at that
point whether or not the match works.

This seems like it would be a win overall, but it interferes with
caching. Specifically, most reduction systems have lots of rules
that all begin

  (--> (in-hole E ...) ...)

and, in the strategy first described above, that matching can be cached.

But in the second, it cannot. Overall, this turns out to be a slight
lose in the current version of Redex. Maybe if other things change, however,
this tradeoff will change.

Revert "IN PROGRESS: more context speedup attempt"

This reverts commit 0134b8753d.

Revert "IN PROGRESS: a possible speed up attempt; match the thing in the hole before returning the context matches instead of afterwards"

This reverts commit 11059e2b5c.
2012-01-15 21:02:48 -06:00
Robby Findler
0134b8753d IN PROGRESS: more context speedup attempt 2012-01-11 13:16:47 -06:00
Robby Findler
11059e2b5c IN PROGRESS: a possible speed up attempt; match the thing in the hole before returning the context matches instead of afterwards 2012-01-11 13:16:46 -06:00
Robby Findler
6cacd57ebc add check-redundancy, a parameter that causes redex to print some
debugging information about ambiguous matching (when the ambiguity
matters)
2012-01-09 12:57:24 -06:00
Robby Findler
a12df9cea6 redex: misc cleanups:
- remove cache instrumentation code
 - make hole->not-hole parsimonous
 - change the cache size back to 63
2012-01-09 12:57:23 -06:00
Robby Findler
2afda360d0 redex: adjust the test suites to clean up a few things; also make the
hole and the-not-hole equal? to each other (like they used to be)
2012-01-09 12:57:20 -06:00
Robby Findler
fbed2d5af7 remove (broken) attempt at optimization Jay suggested
also clean up some test cases that I wasn't sure about earlier
2012-01-08 12:13:37 -06:00
Robby Findler
0459e4fbcd redex: when there are no duplicate names in a pattern, don't do the
same-name-same-bindings check

this seems to speed up the r6rs test suite by about 12% and the
lambdajs benchmark by about 25%
2012-01-08 12:13:36 -06:00
Robby Findler
160fcacad6 redex: fix bug introduced in recent optimization attempts 2012-01-02 22:21:21 -06:00
Robby Findler
83758881c3 Don't attempt to drop duplicates in the non-terminal case
This speeds up the lambdajs model considerably because the computation
to determine duplicates is expensive and no duplicates are really
ever dropped (and, in general, I think that duplicates will only
be dropped when the grammar is ambiguous; so maybe a better thing
is to just rewrite the grammar when that happens)
2012-01-02 10:08:34 -06:00
Robby Findler
6bf42855b8 adjust plug to be parsimonious and actually shortcircuit
when one hole has been found

This improves the lambdajs model example's running time, presumably
because the hole is generally found near the "beginning" of the
term
2012-01-02 10:08:33 -06:00
Robby Findler
5dcbedc768 redex: adjust the caching strategy
Instead of using a hash-table, use the equal-hash-code directly;
this lets me evict entries only when they clobber each other,
and generally keep good cache utilization.

Also, cut the cache size by a factor of 5 while still having a
slight performance improvement on the r6rs test suite benchmark.
On that same benchmark, there are 1714812 misses in the cache, but
only 3485 times is an entry in the cache clobbered
2012-01-02 10:08:31 -06:00
Robby Findler
a6a01fd7b8 redex: fix arity-1 cache key computation 2012-01-02 10:08:31 -06:00
Robby Findler
a7a70cbca9 redex: improved the definitely-not-list definitely-not-non-list
computation to be more accurate
2012-01-02 10:08:30 -06:00
Robby Findler
fe1df742b3 Tried to improve redex by detecting when a pattern does not
have any holes, hide-holes, or names and, in that case, just
combining booleans instead of building of mtch structs.

This does seem to work on a simple benchmark. The code below
gets about 6x faster. But on the r6rs test suite, there is
no substantial change (possibly because the caching obviates
this optimization?)

lang racket/base
(require redex/reduction-semantics)
(caching-enabled? #f)
(define-language L (e (+ e e) number))
(define t
  (let loop ([n 100])
    (cond
      [(zero? n) 1]
      [else `(+ 11 ,(loop (- n 1)))])))
(define f (redex-match L e))
(time (for ([x (in-range 1000)]) (f t)))
2012-01-02 10:08:29 -06:00
Robby Findler
6f97a3a783 disable attempt at Jay's optimization
When I enabled this, I don't see any speedup, on the R6RS test suite
benchmark (I see minor slowdown). Here are the numbers I get, on my
laptop:

   nt cache:  35537 msec
    neither: 844933 msec
 Jay's idea: 875306 msec

And with both on, I see a similar, minor slowdown (as compared to the
version with the nt cache).

The main difference seems to be that I'm getting about 6 "hits" per
test case on the nt-match structs (that is, I avoid work by finding an
nt-match struct) and I'm getting about 8,800 hits in the cache per
test case.
2012-01-02 10:08:29 -06:00
Robby Findler
424a535cf4 first attempt at Jay's optimization for redex
(only did enough to get the r6rs tests running)
2012-01-02 10:08:28 -06:00
Robby Findler
4c86e2fe86 redex: memoize only the non-terminal patterns
remarkably, this seems to cut the time for running
the r6rs test suite in about 1/2
2011-12-29 11:01:21 -06:00
Robby Findler
57f51cf5c8 redex: use predicate/c instead of (-> any/c boolean?)
and a few other, minor changes
2011-12-29 10:58:26 -06:00
Robby Findler
d6ce2b61bc redex: inline lookup-binding 2011-12-29 10:32:02 -06:00
Robby Findler
9bcb86eb0c redex: minor cleanup 2011-12-29 10:15:52 -06:00
Robby Findler
f1bacffbdc Adjusted rewrite-side-condition/check-errs so that it normalizes the internal
redex patterns a bunch:

- repeats are turned into wrappers in sequences,
- names are all explicit,
- non-terminals are wrapped with `nt',
- cross patterns always have the hyphens in them.
- ellipses names are normalized (so there are no "hidden"
  name equalities); this also means that repeat patterns
  can have both a regular name and a mismatch name

Also, added a match-a-pattern helper macro that checks to make sure
that functions that process patterns don't miss any cases
2011-12-28 09:46:43 -06:00
Robby Findler
41f68af64a delay the construction of the compatible-closure grammar (the 'cross' thing)
until it is actually used. (This can make a big difference for large grammars
in models that don't actually use the compatible closure stuff.)
2011-10-30 22:36:53 -05:00
Casey Klein
57a8ed5c79 Fixes matching of prefab struct literals
Fixes PR 12298
2011-10-17 19:37:16 -05:00
Eli Barzilay
3157955d40 ".ss" -> ".rkt" scan done. 2011-07-02 10:37:53 -04:00
Casey Klein
319ae5f825 Deletes code that should have been deleted when named holes went away 2011-04-14 18:32:05 -05:00
Casey Klein
1ad2b1b938 Makes cross' work better with hide-hole'
Fixes PR 11579
2011-04-06 10:17:15 -05:00
Casey Klein
d97a2b505c Fixes matching of ..._x and ..._!_x inside ellipses 2011-03-30 10:15:17 -05:00
David Van Horn
760a58b65d Fixes more spelling errors. 2011-02-04 19:44:13 -07:00
Robby Findler
5c94ca5b7c idle attempts to reduce allocation in the matcher 2010-10-19 18:41:19 -05:00
Casey Klein
85093fb536 Fixes a `plug' bug.
There are still problems with contexts, but this is an improvement.
2010-08-18 13:19:11 -05:00
Casey Klein
d6b20a51d2 Lifts mysterious restriction on patterns that now seems unnecessary. 2010-06-21 11:24:30 -05:00
Casey Klein
daa8507e51 Fixes matcher bug 2010-06-21 10:35:05 -05:00
Matthew Flatt
28b4043077 rename all files .ss -> .rkt 2010-04-27 16:50:15 -06:00