ShotUn.Fragment (shot_un v0.1.5)

Copy Markdown View Source

Predicates that classify a unification problem into one of the decidable fragments handled by ShotUn.Pattern (Miller patterns) and ShotUn.Matching (Huet second-order matching), plus a helper for computing the order of a simple type.

Summary

Functions

Returns true when every free variable, constant and bound variable appearing in the term has a type of order at most max_order.

Returns true when the term has no free variables.

Returns true when every right-hand side is ground and every type in the problem has order at most 2 (Huet's second-order fragment).

If the term is the eta-long primitive of a single bound variable whose binder lies in the surrounding context (i.e. above the term's own abstractions), returns the index of that binder relative to the surrounding context. Otherwise returns :not_bvar.

Returns true when the term is a higher-order pattern: every occurrence of a free variable is applied to a list of pairwise distinct bound-variable arguments.

Returns true when every side of every pair is a higher-order pattern.

Returns the order of a simple type.

Functions

bounded_order?(term_id, max_order)

@spec bounded_order?(ShotDs.Data.Term.term_id(), non_neg_integer()) :: boolean()

Returns true when every free variable, constant and bound variable appearing in the term has a type of order at most max_order.

ground?(term_id)

@spec ground?(ShotDs.Data.Term.term_id()) :: boolean()

Returns true when the term has no free variables.

matching_problem?(pairs)

@spec matching_problem?([term_pair()]) :: boolean()

Returns true when every right-hand side is ground and every type in the problem has order at most 2 (Huet's second-order fragment).

outer_bvar_index(term_id)

@spec outer_bvar_index(ShotDs.Data.Term.term_id()) :: pos_integer() | :not_bvar

If the term is the eta-long primitive of a single bound variable whose binder lies in the surrounding context (i.e. above the term's own abstractions), returns the index of that binder relative to the surrounding context. Otherwise returns :not_bvar.

pattern?(term_id)

@spec pattern?(ShotDs.Data.Term.term_id()) :: boolean()

Returns true when the term is a higher-order pattern: every occurrence of a free variable is applied to a list of pairwise distinct bound-variable arguments.

pattern_problem?(pairs)

@spec pattern_problem?([term_pair()]) :: boolean()

Returns true when every side of every pair is a higher-order pattern.

type_order(type)

@spec type_order(ShotDs.Data.Type.t()) :: non_neg_integer()

Returns the order of a simple type.

$$ \text{order}(\beta) = 0 \quad\text{for base } \beta $$ $$ \text{order}(\tau_1 \to \dots \to \tau_n \to \beta) = \max_{i}(\text{order}(\tau_i) + 1) $$