Skip to content

Commit

Permalink
consider & uni: partly revert to v0.4.16 behaviour
Browse files Browse the repository at this point in the history
In consider we only use the normalization if it reduces the number of
variables, otherwise the equivalencesBetween are from the standard term.
(Part reversal: sometimes till _will_ use the normalization)

In criticalPairs / overlaps, we use the regular syntactic unification
and not syntactic unification modulo commutativity.
(Full reversal)
  • Loading branch information
rudymatela committed Feb 13, 2024
1 parent 8857f5f commit 0d9664c
Show file tree
Hide file tree
Showing 36 changed files with 37 additions and 36 deletions.
1 change: 1 addition & 0 deletions bench/list-t.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ tail (x:xs) == xs
equations:
head (xs ++ (x:zs)) == head (xs ++ (x:ys))
head (xs ++ [x]) == head (xs ++ (x:ys))
head (xs ++ (x:tail [])) == head (xs ++ (x:ys))

head (x:xs) == x
head (xs ++ (x:ys)) == head (xs ++ (x:zs))
Expand Down
1 change: 1 addition & 0 deletions bench/runtime/zero/bench/addition.runtime
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.45
2 changes: 1 addition & 1 deletion bench/runtime/zero/bench/arith-c.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.75
0.60
2 changes: 1 addition & 1 deletion bench/runtime/zero/bench/arith-t.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11.26
10.02
2 changes: 1 addition & 1 deletion bench/runtime/zero/bench/arithficial.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.44
0.60
2 changes: 1 addition & 1 deletion bench/runtime/zero/bench/bool-c.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.14
1.81
2 changes: 1 addition & 1 deletion bench/runtime/zero/bench/list-c.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.59
1.60
2 changes: 1 addition & 1 deletion bench/runtime/zero/bench/list-t.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.43
0.48
2 changes: 1 addition & 1 deletion bench/runtime/zero/bench/lowtests.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.48
0.46
2 changes: 1 addition & 1 deletion bench/runtime/zero/bench/minus-c.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.90
0.91
2 changes: 1 addition & 1 deletion bench/runtime/zero/bench/stats.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.28
0.30
2 changes: 1 addition & 1 deletion bench/runtime/zero/bench/trilean.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.04
0.05
2 changes: 1 addition & 1 deletion bench/runtime/zero/eg/arith-negate-abs.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.78
1.58
2 changes: 1 addition & 1 deletion bench/runtime/zero/eg/arith.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.28
0.26
2 changes: 1 addition & 1 deletion bench/runtime/zero/eg/binarytree.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.90
1.89
2 changes: 1 addition & 1 deletion bench/runtime/zero/eg/binarytree0.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.53
0.60
2 changes: 1 addition & 1 deletion bench/runtime/zero/eg/bool.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.49
2.42
2 changes: 1 addition & 1 deletion bench/runtime/zero/eg/digraphs.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.54
1.49
2 changes: 1 addition & 1 deletion bench/runtime/zero/eg/fun.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.07
1.08
2 changes: 1 addition & 1 deletion bench/runtime/zero/eg/insertsort.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.74
7.38
2 changes: 1 addition & 1 deletion bench/runtime/zero/eg/length.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.25
0.24
2 changes: 1 addition & 1 deletion bench/runtime/zero/eg/minus.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.52
0.65
2 changes: 1 addition & 1 deletion bench/runtime/zero/eg/monad.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.59
0.61
2 changes: 1 addition & 1 deletion bench/runtime/zero/eg/oddeven.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.87
6.85
2 changes: 1 addition & 1 deletion bench/runtime/zero/eg/plus-abs.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.77
3.50
2 changes: 1 addition & 1 deletion bench/runtime/zero/eg/ratio.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.34
7.64
2 changes: 1 addition & 1 deletion bench/runtime/zero/eg/sets.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.94
7.34
2 changes: 1 addition & 1 deletion bench/runtime/zero/eg/speculate-reason.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.98
2.95
2 changes: 1 addition & 1 deletion bench/runtime/zero/eg/string.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.92
0.87
2 changes: 1 addition & 1 deletion bench/runtime/zero/eg/tauts.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.12
4.13
2 changes: 1 addition & 1 deletion bench/runtime/zero/eg/tuples.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.28
1.27
2 changes: 1 addition & 1 deletion bench/runtime/zero/eg/zip.runtime
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.38
2.41
2 changes: 1 addition & 1 deletion eg/insertsort.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ sort :: [Int] -> [Int]
([] == insert x xs) == False
(xs == sort xs) == ordered xs
elem x (sort xs) == elem x xs
(xs == []) == ([] == sort xs)
(sort xs == []) == (xs == [])
all (x ==) (sort xs) == all (x ==) xs
all (x <) (sort xs) == all (x <) xs
all (x <=) xs == ordered (x:sort xs)
Expand Down
2 changes: 1 addition & 1 deletion eg/insertsort0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ False :: Bool

(xs == insert x xs) == False
([] == insert x xs) == False
(xs == []) == ([] == sort xs)
(sort xs == []) == (xs == [])
sort [] == []
sort (sort xs) == sort xs
insert x [] == [x]
Expand Down
4 changes: 2 additions & 2 deletions src/Test/Speculate/Engine.hs
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ consider (===) sz s (thy,sss)
where
ns = rehole $ normalizeE thy (fastMostGeneralVariation s)
-- between s and ns, choose the one with less holes to call equivalencesBetween
ms | length (holes s) < length (holes ns) = s
| otherwise = ns
ms | length (holes s) <= length (holes ns) = s
| otherwise = ns -- favour ns only if it reduces the number of variables
e1 -===- e2 = normalize thy e1 == normalize thy e2 || e1 === e2
ss = uptoT sz sss
sssWs = sss \/ wcons0 sz s
Expand Down
3 changes: 1 addition & 2 deletions src/Test/Speculate/Reason.hs
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,11 @@ criticalPairs thy@Thy{rules = rs} =
overlaps :: Expr -> Expr -> [Expr]
overlaps e1 e2 = nubSortBy compareQuickly
. map (canonicalize . (e2' //-))
$ (e1' `unifn`) `mapMaybe` nonVarSubexprs e2'
$ (e1' `unification`) `mapMaybe` nonVarSubexprs e2'
where
nonVarSubexprs = discard isVar . nubSubexprs
e1' = renameVarsBy (++ "1") e1
e2' = renameVarsBy (++ "2") e2
unifn = unificationC (commutativeOperators thy)

equivalent :: Thy -> Expr -> Expr -> Bool
equivalent thy e1 e2 = e1' == e2'
Expand Down

0 comments on commit 0d9664c

Please sign in to comment.