-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSyntax.Unification.cs
More file actions
40 lines (39 loc) · 1.23 KB
/
Syntax.Unification.cs
File metadata and controls
40 lines (39 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
namespace Amateurlog
{
abstract partial record Type : IUnifiable<Type>
{
public abstract string? AsVariable();
public abstract bool Match(Type right);
}
partial record TypeVariable : Type
{
public override string? AsVariable() => Name;
public override bool Match(Type right) => right is TypeVariable v && v.Name == Name;
}
partial record TypeApplication : Type
{
public override string? AsVariable() => null;
public override bool Match(Type right)
=> right is TypeApplication a
&& a.Name == Name
&& a.Args.Length == Args.Length;
}
abstract partial record Term : IUnifiable<Term>
{
public abstract string? AsVariable();
public abstract bool Match(Term right);
}
partial record Variable : Term
{
public override string? AsVariable() => Name;
public override bool Match(Term right) => right is Variable v && v.Name == Name;
}
partial record Functor : Term
{
public override string? AsVariable() => null;
public override bool Match(Term right)
=> right is Functor f
&& f.Atom == Atom
&& f.Args.Length == Args.Length;
}
}