-
Notifications
You must be signed in to change notification settings - Fork 0
/
inferences
41 lines (39 loc) · 1.81 KB
/
inferences
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
41
Inferences:
-----------
(len(a) = 1) => (Simplify(Terminal(a)) = Terminal(a))
Simplify(Terminal(a)) = Terminal(a[0]), Terminal(a[1:])
Simplify(EOF) = EOF
Simplify(EOF, ...) = ...
Simplify(A, ...) = Simplify(A), ...
(len(a) = 1) => (Simplify(Terminal(a), B | Terminal(a), C) = Terminal(a), (B | C)) # Could implement quicksort for the Terminals
(len(a) = 1) => (Simplify(Terminal(a) | Terminal(a), A) = Terminal(a), (EOF | A))
Simplify(EOF | EOF) = EOF
Simplify(EOF | EOF | ...) = EOF | ...
Simplify(... | EOF) = EOF | ...
Simplify(EOF | ...) = EOF | Simplify(...)
Simplify(Identifier(I), A | Identifier(I), B) = Identifier(I), (A | B) # Could implement quicksort for the Identifiers
Simplify(Identifier(I) | Identifier(I), A) = Identifier(I), (EOF | A)
Simplify(A | ...) = Simplify(A) | Simplify(...)
Simplify([EOF]) = EOF
Simplify([A]) = EOF | Simplify(A)
Simplify({EOF}) = EOF
Simplify({A}) = {A}
Simplify(Identifier(I)) = Identifier(I)
Expand({A}) = A, {A} | EOF
Expand({A}, ...) = A, {A}, ... | ...
Expand({A} | ...) = A, {A} | EOF | ...
Expand(A, ...) = Expand(A), ...
Expand(A | ...) = Expand(A) | Expand(...)
Expand(Identifier(I)) =
Expand(A) = Simplify(A)
Graph(A) = Graph(Simplify(A))
Graph(EOF) = {EOF: None}
(len(a) = 1) => (Graph(Terminal(a)) = {a: None})
(len(a) = 1) => (Graph(Terminal(a), ...) = {a: Graph(...)})
(len(a) = 1) && (len(b) = 1) => (Graph(Terminal(a) | Terminal(b), B) = {a: None, b: Graph(B)})
(len(a) = 1) => (Graph(EOF | Terminal(a), A) = {EOF: None, a: Graph(A)})
Graph(Identifier(I)) = {Identifier(I): None}
Graph(Identifier(I), ...) = {Identifier(I): Graph(...)}
(len(a) = 1) && cannot_start_with(I, a) => (Graph(a | Identifier(I), A) = {a: None, Identifier(I): Graph(A)})
cannot_be_empty(I) => (Graph(EOF | Identifier(I), A) = {EOF: None, Identifier(I): Graph(A)})
Graph(A) = SolveEquation(Graph(A) = Graph(Expand(A)))