Skip to content

Commit e29f98f

Browse files
committed
Restore special cases to tuple operations in Heapster/SAWTranslation.
This avoids construction of 1-tuples. This makes many of the example proof scripts work again.
1 parent 454b0da commit e29f98f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

heapster-saw/src/Verifier/SAW/Heapster/SAWTranslation.hs

+11-2
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,27 @@ typeTransType1 (TypeTrans [] _) = unitTypeOpenTerm
133133
typeTransType1 (TypeTrans [tp] _) = tp
134134
typeTransType1 _ = error ("typeTransType1" ++ nlPrettyCallStack callStack)
135135

136-
-- | Build the tuple type @#(T1, T2, ... Tn-1, Tn)@ of @n@ types.
136+
-- | Build the tuple type @#(T1, T2, ... Tn-1, Tn)@ of @n@ types, with
137+
-- the special case that 0 types maps to the unit type @#()@ (and 1
138+
-- type just maps to itself).
137139
tupleOfTypes :: [OpenTerm] -> OpenTerm
140+
tupleOfTypes [] = unitTypeOpenTerm
141+
tupleOfTypes [tp] = tp
138142
tupleOfTypes tps = tupleTypeOpenTerm tps
139143

140-
-- | Build the tuple @(t1, t2, ..., tn-1, tn)@ of @n@ terms.
144+
-- | Build the tuple @(t1, t2, ..., tn-1, tn)@ of @n@ terms, with the
145+
-- special case that 0 types maps to the unit value @()@ (and 1 value
146+
-- just maps to itself).
141147
tupleOfTerms :: [OpenTerm] -> OpenTerm
148+
tupleOfTerms [] = unitOpenTerm
149+
tupleOfTerms [t] = t
142150
tupleOfTerms ts = tupleOpenTerm ts
143151

144152
-- | Project the @i@th element from a term of type @'tupleOfTypes' tps@. Note
145153
-- that this requires knowing the length of @tps@.
146154
projTupleOfTypes :: [OpenTerm] -> Integer -> OpenTerm -> OpenTerm
147155
projTupleOfTypes tps i tup
156+
| i == 0 && length tps == 1 = tup
148157
| i < toInteger (length tps) = projTupleOpenTerm i tup
149158
| otherwise = error "projTupleOfTypes: invalid tuple index"
150159

0 commit comments

Comments
 (0)