@@ -465,6 +465,15 @@ combine :: Int -> Int -> Int
465
465
combine h1 h2 = (h1 * 0x01000193 ) `xor` h2
466
466
467
467
instance Eq Term where
468
+ -- Note: we take some minor liberties with the contract of 'hashWithSalt' in
469
+ -- this implementation of 'Eq'. The contract states that if two values are
470
+ -- equal according to '==', then they must have the same hash. For terms
471
+ -- constructed by/within SAW, this will hold, because SAW's handling of index
472
+ -- generation and assignment ensures that equality of indices implies equality
473
+ -- of terms and term hashes (see 'Verifier.SAW.SharedTerm.getTerm'). However,
474
+ -- if terms are constructed outside this standard procedure or in a way that
475
+ -- does not respect index uniqueness rules, 'hashWithSalt''s contract could be
476
+ -- violated.
468
477
(==) = alphaEquiv
469
478
470
479
alphaEquiv :: Term -> Term -> Bool
@@ -474,8 +483,8 @@ alphaEquiv = term
474
483
term (Unshared tf1) (Unshared tf2) = termf tf1 tf2
475
484
term (Unshared tf1) (STApp {stAppTermF = tf2}) = termf tf1 tf2
476
485
term (STApp {stAppTermF = tf1}) (Unshared tf2) = termf tf1 tf2
477
- term (STApp {stAppIndex = i1, stAppHash = h1, stAppTermF = tf1})
478
- (STApp {stAppIndex = i2, stAppHash = h2, stAppTermF = tf2}) = ( i1 == i2 && h1 == h2) || termf tf1 tf2
486
+ term (STApp {stAppIndex = i1, stAppTermF = tf1})
487
+ (STApp {stAppIndex = i2, stAppTermF = tf2}) = i1 == i2 || termf tf1 tf2
479
488
480
489
termf :: TermF Term -> TermF Term -> Bool
481
490
termf (FTermF ftf1) (FTermF ftf2) = ftermf ftf1 ftf2
0 commit comments