import z3

from common.relations import relation

Node = z3.DeclareSort("Node")
type NodeType = z3.ExprRef

nil = z3.Const("nil", Node)

less_than = relation("less_than", Node, Node)

list_next = z3.Function("next", Node, Node)
is_list = relation("is_list", Node)
is_slist = relation("is_slist", Node)


def lte(x: NodeType, y: NodeType) -> z3.BoolRef:
    return z3.Or(x == y, less_than(x, y))
