Skip to content

Commit 8d12a79

Browse files
authored
Merge pull request #1409 from herbie-fp/why-egraph-big
Fix overly-aggressive deduplicator
2 parents e3ee454 + 6857554 commit 8d12a79

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/core/mainloop.rkt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,6 @@
165165

166166
;; Converts a patch to full alt with valid history
167167
(define (reconstruct! alts)
168-
;; extracts the base expressions of a patch as a batchref
169-
(define (get-starting-expr altn)
170-
(match (alt-prevs altn)
171-
[(list) (alt-expr altn)]
172-
[(list prev) (get-starting-expr prev)]))
173-
174168
;; takes a patch and converts it to a full alt
175169
(define (reconstruct-alt altn loc0 orig)
176170
(let loop ([altn altn])

src/core/patch.rkt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"rival.rkt"
1616
"taylor.rkt")
1717

18-
(provide generate-candidates)
18+
(provide generate-candidates
19+
get-starting-expr)
1920

2021
;;;;;;;;;;;;;;;;;;;;;;;;;;;; Taylor ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2122

@@ -197,6 +198,11 @@
197198

198199
;;;;;;;;;;;;;;;;;;;;;;;;;;;; Public API ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
199200

201+
(define (get-starting-expr altn)
202+
(match (alt-prevs altn)
203+
[(list) (alt-expr altn)]
204+
[(list prev) (get-starting-expr prev)]))
205+
200206
(define (generate-candidates batch brfs spec-batch reducer)
201207
; Starting alternatives
202208
(define start-altns
@@ -220,4 +226,5 @@
220226
(run-rr start-altns batch)
221227
'()))
222228

223-
(remove-duplicates (append evaluations rewritten approximations) #:key alt-expr))
229+
(remove-duplicates (append evaluations rewritten approximations)
230+
#:key (λ (altn) (cons (alt-expr altn) (get-starting-expr altn)))))

0 commit comments

Comments
 (0)