Skip to content

Sort Unification for Subsort Relations in Modules #5

@WilfredTA

Description

@WilfredTA

Athena rejects the use of unifiable sorts constructed via subsorts when in the context of a module.

Below are two code snippets, identical except that the second code snippet defines the BTree and related code inside of a Tree module, while the first snippet is defined in the top level Athena context.

datatype (BTree T) :=
    null |
    (leaf T) |
    (root (BTree T) (BTree T))

domains Sort1, Sort2, Sort

subsorts (Sort1 Sort2) Sort

declare data1: Sort1
declare data2: Sort2

define tree1 := (leaf data1)
define tree2 := (leaf data2)
define tree := (root tree1 tree2)
module Tree {

  datatype (BTree T) :=
      null |
      (leaf T) |
      (root (BTree T) (BTree T))
  
  domains Sort1, Sort2, Sort
  
  subsorts (Sort1 Sort2) Sort
  
  declare data1: Sort1
  declare data2: Sort2
  
  define tree1 := (leaf data1)
  define tree2 := (leaf data2)
  define tree := (root tree1 tree2)
}

Example 1 runs without error, while evaluating example 2 will cause Athena to report the following problem:

Error: Unable to infer a sort for the term: 

(Tree.root (Tree.leaf Tree.data1)

           (Tree.leaf Tree.data2))

(Failed to unify the sorts Tree.Sort2 and Tree.Sort1.).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions