| 1 | Cycle when there is a lambda formula as a key in the RangeMap.
|
|---|
| 2 |
|
|---|
| 3 | in the process of forming a subcontext in which the parent context contains
|
|---|
| 4 | a rangeMap with a lambda formula key:
|
|---|
| 5 |
|
|---|
| 6 | the reduction of the range map goes through and simplifies each key.
|
|---|
| 7 | But it does not remove the key when it is being simplified.
|
|---|
| 8 | In the process of simplifying it collapses the sub-context.
|
|---|
| 9 | This entails forming a new Context with the same range map as the original parent.
|
|---|
| 10 | THis entails simplifying the key, which creates a new subcontext with the range map...
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 | Cycle in call stack:
|
|---|
| 15 | divideTest1:
|
|---|
| 16 |
|
|---|
| 17 | SubContext.init
|
|---|
| 18 | Context.initialize, addFact, extractOr, addSub, simplify
|
|---|
| 19 | IdealSimplifierWorker.simplifyExpressionWork, simplifyBoolean
|
|---|
| 20 | SubContext.init
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 | simplifyBoolean checks seenBefore, but seenBefore ignores
|
|---|
| 25 | a context if it's not initialized. None of these contexts are.
|
|---|
| 26 | Why?
|
|---|
| 27 |
|
|---|
| 28 | Context.simplify flattens "this" context, the result in this case
|
|---|
| 29 | is just "true". There is no deep hierarchy of context and no way
|
|---|
| 30 | to recognize the cycle.
|
|---|
| 31 |
|
|---|
| 32 | Why do we need to create a subcontext? How do we stop from doing
|
|---|
| 33 | it twice?
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 | extract(expression, context) : modifies context based on information
|
|---|
| 42 | in expression.
|
|---|
| 43 |
|
|---|
| 44 | simplify(context, expression) : Expression
|
|---|
| 45 | returns simplified version of expression based on context.
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 | for i=1..n
|
|---|
| 49 | C = new context;
|
|---|
| 50 | for j in 1..n-{i} :
|
|---|
| 51 | extract(p_j, C);
|
|---|
| 52 | p_i <- simplify(C,p_i)
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 | Example: (p||q)&&p
|
|---|
| 56 |
|
|---|
| 57 | 123456
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 | Only efficient way is to REMOVE one element at a time
|
|---|
| 61 | from the context and simplify it, then put it back.
|
|---|
| 62 | That takes care of the "and" problem.
|
|---|
| 63 |
|
|---|
| 64 | But how to simplify the assumption? This won't work.
|
|---|
| 65 | Unless you know the context is equivalent to the
|
|---|
| 66 | assumption.
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 | -----
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 | Figure out how to simplify "and".
|
|---|
| 73 | Then to simplify or
|
|---|
| 74 |
|
|---|
| 75 | simplify(or(p_i)) = not simplify(and(not p_i))
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 | ---
|
|---|
| 79 |
|
|---|
| 80 | To simplify and:
|
|---|
| 81 | Create a new context.
|
|---|
| 82 | same method used to addSub
|
|---|
| 83 | (and reduce the subMap).
|
|---|
| 84 | BUT: the "simplify" method should use union
|
|---|
| 85 | of the original (outer) context and this.
|
|---|
| 86 |
|
|---|
| 87 | simplify(C0, AND(p_i)):
|
|---|
| 88 | Let C1=C0
|
|---|
| 89 |
|
|---|
| 90 | make an interface for Context that can be used
|
|---|
| 91 | by the SimplifierWorker. The interface would
|
|---|
| 92 | only have get methods that are needed to perform
|
|---|
| 93 | simplification
|
|---|
| 94 |
|
|---|
| 95 | make two different kinds of Context.
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 | ----------------------------------------------
|
|---|
| 100 |
|
|---|
| 101 | Schwartz Zippel Lemma:
|
|---|
| 102 |
|
|---|
| 103 | Single point version:
|
|---|
| 104 |
|
|---|
| 105 | Multipoint version:
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 | # of roots over the set T^n (n=9 for us) is at most d*|T|^(n-1), where d is
|
|---|
| 109 | the total degree of the polynomial.
|
|---|
| 110 |
|
|---|
| 111 | prob of getting root: d/|T| < e
|
|---|
| 112 | |T|>d/e
|
|---|
| 113 |
|
|---|
| 114 | e=10^{-1000}
|
|---|
| 115 |
|
|---|
| 116 | |T|=2^32
|
|---|
| 117 |
|
|---|
| 118 | d*2^{-32} is prob of getting 0 if it is non-0
|
|---|
| 119 | (d*2^{-32})^k is upper bound on prob. of it being non=0 after k applications
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 | ----------------------------------------------
|
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 | subsumption:
|
|---|
| 136 |
|
|---|
| 137 | if a is a subset of b and a preceded b in dictionary order
|
|---|
| 138 | then a is a prefix of b
|
|---|
| 139 |
|
|---|
| 140 | if a is a subset of b then size(a)<size(b)
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 | 1 4 6 7 8
|
|---|
| 144 | 1 4 6 7 8 9
|
|---|
| 145 | 1 4 6 7 8 10
|
|---|
| 146 | 1 4 6 7 9
|
|---|
| 147 | 2 3 4
|
|---|
| 148 | 2 5 8 10
|
|---|
| 149 | 4 7 8 : determine if I am subset of any of above?
|
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 | Step 1:
|
|---|
| 153 | make concrete arrays instances of HomogeneousExpression<SymbolicExpression>
|
|---|
| 154 |
|
|---|
| 155 | Re-factor expressions/objects
|
|---|
| 156 |
|
|---|
| 157 | CURRENT:
|
|---|
| 158 | Symbolic Objects:
|
|---|
| 159 | current fields: kind, hashCode, hashed, id, order (5)
|
|---|
| 160 | current kinds of objects:
|
|---|
| 161 | BOOLEAN, CHAR, INT, NUMBER, STRING : make these primitive SymbolicExpressions
|
|---|
| 162 | TYPE, TYPE_SEQUENCE
|
|---|
| 163 | EXPRESSION_COLLECTION
|
|---|
| 164 | EXPRESSION
|
|---|
| 165 |
|
|---|
| 166 | NEW:
|
|---|
| 167 |
|
|---|
| 168 | interface SymbolicObject
|
|---|
| 169 | objectKind(): SymbolicObjectKind
|
|---|
| 170 | objectCategory(): TYPE, EXPRESSION, SEQUENCE, INT
|
|---|
| 171 | interface SymbolicType extends SymbolicObject
|
|---|
| 172 | interface Sequence<T> extends SymbolicObject
|
|---|
| 173 | interface SymbolicExpression extends SymbolicObject
|
|---|
| 174 | interface IntObject extends SymbolicObject
|
|---|
| 175 |
|
|---|
| 176 | class CommonObject implements SymbolicObject [hashCode, id]
|
|---|
| 177 | class CommonSymbolicType extends CommonObject
|
|---|
| 178 | class CommonSequence<T> extends SymbolicSequence<T>
|
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 | fields: hashCode, id (2)
|
|---|
| 182 | put hashed in id field:
|
|---|
| 183 | id=-2: not hashed
|
|---|
| 184 | id=-1: hashed, but not canonic
|
|---|
| 185 | id=0,1,2,... : canonic
|
|---|
| 186 | the object kind can be obtained by a method (not in field)
|
|---|
| 187 | equals: compare kinds, then go straight to the intrinsicEquals
|
|---|
| 188 | compare: can't just order by kind?
|
|---|
| 189 | hashCode:
|
|---|
| 190 |
|
|---|
| 191 | New kinds of objects:
|
|---|
| 192 | TYPE : a type, instanceof SymbolicType
|
|---|
| 193 | EXPRESSION : something representing a value, instanceof SymbolicExpression
|
|---|
| 194 | SEQUENCE : a sequence of objects of some kind, instanceof SequenceObject
|
|---|
| 195 | INT : a Java int
|
|---|
| 196 |
|
|---|
| 197 | interface SymbolicExpression: represents a value
|
|---|
| 198 | type(): SymbolicType
|
|---|
| 199 | kind(): ExpressionKind
|
|---|
| 200 | getArguments(): SymbolicObject[]
|
|---|
| 201 | numArguments(): int
|
|---|
| 202 | argument(int): SymbolicObject
|
|---|
| 203 | NOTE: not every symbolic expression is completely determined by the
|
|---|
| 204 | operator, type, and arguments. In particular, these are not:
|
|---|
| 205 |
|
|---|
| 206 | The following kinds of expressions have 0 args:
|
|---|
| 207 | CHAR: interface CharObject extends SymbolicExpression: getChar()
|
|---|
| 208 | STRING: interface StringObject extends SymbolicExpression: getString()
|
|---|
| 209 | BOOLEAN: interface BooleanObject extends SymbolicExpression: getBoolean()
|
|---|
| 210 | NUMBER: interface NumberObject extends SymbolicExpression: getNumber()
|
|---|
| 211 |
|
|---|
| 212 | The following kind of SymbolicExpression is completely determined by
|
|---|
| 213 | operator, type, and arguments:
|
|---|
| 214 |
|
|---|
| 215 | interface HomogeneousExpression<T extends SymbolicObject> extends SymbolicExpression
|
|---|
| 216 | getArguments(): T[]
|
|---|
| 217 | arguments(): Iterable<T>
|
|---|
| 218 | argument(int): T
|
|---|
| 219 |
|
|---|
| 220 |
|
|---|
| 221 | Other SymbolicExpressions have a positive number of arguments
|
|---|
| 222 | ADD, MULTIPLY, etc.
|
|---|
| 223 | DENSE_ARRAY_WRITE (keep track of NULLs)
|
|---|
| 224 | - make it a special class with its own fields (numNulls)
|
|---|
| 225 | APPLY
|
|---|
| 226 |
|
|---|
| 227 | Tuple types, function types may also have SEQUENCE objects.
|
|---|
| 228 |
|
|---|
| 229 | ----
|
|---|
| 230 |
|
|---|
| 231 |
|
|---|
| 232 | Design:
|
|---|
| 233 |
|
|---|
| 234 | universe
|
|---|
| 235 | uses: reason, preuniverse
|
|---|
| 236 |
|
|---|
| 237 | reason
|
|---|
| 238 | uses: simplify, prove, ....
|
|---|
| 239 |
|
|---|
| 240 | herbrand
|
|---|
| 241 | uses: like ideal?
|
|---|
| 242 |
|
|---|
| 243 | ideal
|
|---|
| 244 | uses: simplify, prove, ...
|
|---|
| 245 | ideal.simplify uses preuniverse
|
|---|
| 246 |
|
|---|
| 247 | prove
|
|---|
| 248 | uses: IF, cvc3, expr,
|
|---|
| 249 | preuniverse (to build expressions)
|
|---|
| 250 |
|
|---|
| 251 | simplify
|
|---|
| 252 | uses: IF, type, expr, object,
|
|---|
| 253 | preuniverse (by CommonSimplifier)
|
|---|
| 254 |
|
|---|
| 255 | preuniverse: everything in universe except reasoning
|
|---|
| 256 | uses: expr, type, collections, object, number, util, IF
|
|---|
| 257 |
|
|---|
| 258 | expr
|
|---|
| 259 | uses: IF
|
|---|
| 260 | object
|
|---|
| 261 | collections
|
|---|
| 262 | type
|
|---|
| 263 |
|
|---|
| 264 | type
|
|---|
| 265 | uses: IF (expr array len),
|
|---|
| 266 | object
|
|---|
| 267 |
|
|---|
| 268 | collections
|
|---|
| 269 | uses: IF
|
|---|
| 270 | object
|
|---|
| 271 |
|
|---|
| 272 | object: symbolic objects
|
|---|
| 273 | uses: IF
|
|---|
| 274 | collections (SymbolicCollection for comparator): CHANGE!
|
|---|
| 275 |
|
|---|
| 276 | number: arbitrary-precision integer and real numbers
|
|---|
| 277 | uses: IF (IF.number)
|
|---|
| 278 |
|
|---|
| 279 | util: utility classes
|
|---|
| 280 | uses: nothing
|
|---|
| 281 |
|
|---|
| 282 | IF: public interface
|
|---|
| 283 | uses: nothing
|
|---|
| 284 | comprises:
|
|---|
| 285 | IF.SymbolicUniverse
|
|---|
| 286 | IF.Reasoner
|
|---|
| 287 | IF.ValidityResult
|
|---|
| 288 | IF.ModelResult
|
|---|
| 289 | IF.SARLException, IF.SARLInternalException, IF.TheoremProverException
|
|---|
| 290 | IF.expr
|
|---|
| 291 | IF.number
|
|---|
| 292 | IF.object
|
|---|
| 293 | IF.type
|
|---|
| 294 |
|
|---|
| 295 | --------------------
|
|---|
| 296 |
|
|---|
| 297 | Design issues:
|
|---|
| 298 |
|
|---|
| 299 | - massive duplication between SymbolicUniverse and PreUniverse
|
|---|
| 300 | - cyclic dependency object<-->collections
|
|---|
| 301 |
|
|---|
| 302 | --------------------
|
|---|
| 303 |
|
|---|
| 304 | Heaps:
|
|---|
| 305 |
|
|---|
| 306 | /** This is the type for head IDs. Every heap has an unchanging
|
|---|
| 307 | * heap ID. As objects are added or removed from the heap, the
|
|---|
| 308 | * heap expression itself changes, but the underlying heap ID
|
|---|
| 309 | * is constant. References to heap objects always include the
|
|---|
| 310 | * heap ID indicating to which heap the reference points. This
|
|---|
| 311 | * is necessary so that when we canonicalize a heap, we can
|
|---|
| 312 | * determine which references refer to that heap and therefore
|
|---|
| 313 | * must be updated. */
|
|---|
| 314 | SymbolicType heapIdType();
|
|---|
| 315 |
|
|---|
| 316 | /** This is the type of a heap. */
|
|---|
| 317 | SymbolicType heapType();
|
|---|
| 318 |
|
|---|
| 319 | /** Returns the incomplete reference type, which is a super-type
|
|---|
| 320 | * of all reference types. Situation is analogous to array types.
|
|---|
| 321 | */
|
|---|
| 322 | SymbolicType referenceType();
|
|---|
| 323 |
|
|---|
| 324 | /** Returns type "reference-to-T", where T is the given type.
|
|---|
| 325 | * This is a complete reference type. */
|
|---|
| 326 | SymbolicType completeReferenceType(SymbolicType type);
|
|---|
| 327 |
|
|---|
| 328 | /** Returns a heap ID which simply wraps the given string object.
|
|---|
| 329 | * Two heapIds with equal names are equal. */
|
|---|
| 330 | SymbolicExpression heapId(StringObject name);
|
|---|
| 331 |
|
|---|
| 332 | /** Returns the empty heap with the given heap ID. */
|
|---|
| 333 | SymbolicExpression emptyHeap(SymbolicExpression heapId);
|
|---|
| 334 |
|
|---|
| 335 | /** Allocates an object on the heap. Returns a pair: the first
|
|---|
| 336 | * component is the new heap, the second is reference to the new
|
|---|
| 337 | * object in the new heap. */
|
|---|
| 338 | Pair<SymbolicExpression,SymbolicExpression>
|
|---|
| 339 | malloc(SymbolicExpression heap, SymbolicType type);
|
|---|
| 340 |
|
|---|
| 341 | /** Given an expression of heap type, returns
|
|---|
| 342 | * the heap ID; given an expression of reference type, returns
|
|---|
| 343 | * the heap ID of the referenced heap. */
|
|---|
| 344 | SymbolicExpression heapIdOf(SymbolicExpression expr);
|
|---|
| 345 |
|
|---|
| 346 | /** Deallocates an object on the heap. Given a heap and a reference
|
|---|
| 347 | * to an element on the heap, returns the new heap which is obtained
|
|---|
| 348 | * by removing the referenced object from the original. Result
|
|---|
| 349 | * is undefined if heapIdOf(ref) does not equal heapIdOf(heap).
|
|---|
| 350 | */
|
|---|
| 351 | SymbolicExpression free(SymbolicExpression heap, SymbolicExpression ref);
|
|---|
| 352 |
|
|---|
| 353 | /** Dereferences a reference to the heap. The given ref must
|
|---|
| 354 | * have a complete reference type, say "reference-to-T". The type
|
|---|
| 355 | * of the expression returned will then be T. The heaps ID of
|
|---|
| 356 | * the ref and the heap must be equal. */
|
|---|
| 357 | SymbolicExpression dereference(SymbolicExpression heap,
|
|---|
| 358 | SymbolicExpression ref);
|
|---|
| 359 |
|
|---|
| 360 | /** Canonicalize heap.
|
|---|
| 361 | * Given a heap and a collection of expressions, returns a pair.
|
|---|
| 362 | * The first component of the pair is the new heap, the second
|
|---|
| 363 | * element is the collection obtained by updating all references
|
|---|
| 364 | * to objects in the given heap to their new values. */
|
|---|
| 365 | Pair<SymbolicExpression, SymbolicCollection<SymbolicExpression>>
|
|---|
| 366 | canonic(SymbolicExpression heap,
|
|---|
| 367 | SymbolicCollection<SymbolicExpression>> expressions);
|
|---|