tnelson / Forge

Forge: A Tool and Language for Teaching Formal Methods
https://forge-fm.org/
MIT License
67 stars 9 forks source link

Infer type of atoms sent from evaluator #249

Closed tnelson closed 7 months ago

tnelson commented 7 months ago

At present, the atom AST node is used by the evaluator to bind atoms used in queries. However, these atoms carry no typing information, requiring a workaround to avoid triggering the new typechecking on predicates. E.g.,

pred invariant[n: Node] { ... } 

// This evaluator query would fail in v. 3.3
// invariant[Node0]
// This workaround is needed in v. 3.3
// some n: Node | {invariant[n] and n = Node0}

With this PR, Forge looks at the Kodkod bounds for this atom and infers it must be a Node if it exists.

Note that the code also includes an experimental inference from the last Sterling instance. However, this isn't yet used because of questions about temporality (can an atom change most-specific sig membership across states? Very likely if the sigs are var).