Skip to content

Commit b816a89

Browse files
committed
Rename structured_type -> recursive_type
1 parent 12bacd3 commit b816a89

30 files changed

+460
-460
lines changed

example/boolean.ml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ open TypeOperations.Create
44

55
let true_lambda = typed_term (Const "True")
66
let false_lambda = typed_term (Const "False")
7-
let bool_type = type_union [ true_lambda.stype; false_lambda.stype ]
7+
let bool_type = type_union [ true_lambda.rtype; false_lambda.rtype ]
88
let unary_bool_op = func_type (bool_type.union, bool_type.union)
99

1010
let binary_bool_op =
@@ -20,34 +20,34 @@ let not_lambda =
2020
typed_term
2121
(Abstraction
2222
[
23-
(true_lambda.stype, false_lambda.term);
24-
(false_lambda.stype, true_lambda.term);
23+
(true_lambda.rtype, false_lambda.term);
24+
(false_lambda.rtype, true_lambda.term);
2525
])
2626

2727
let and_lambda =
2828
typed_term
2929
(Abstraction
3030
[
31-
(true_lambda.stype, identity_lambda.term);
32-
(false_lambda.stype, Abstraction [ (bool_type, false_lambda.term) ]);
31+
(true_lambda.rtype, identity_lambda.term);
32+
(false_lambda.rtype, Abstraction [ (bool_type, false_lambda.term) ]);
3333
])
3434

3535
let or_lambda =
3636
typed_term
3737
(Abstraction
3838
[
39-
(true_lambda.stype, Abstraction [ (bool_type, true_lambda.term) ]);
40-
(false_lambda.stype, identity_lambda.term);
39+
(true_lambda.rtype, Abstraction [ (bool_type, true_lambda.term) ]);
40+
(false_lambda.rtype, identity_lambda.term);
4141
])
4242

4343
let if_lambda =
4444
typed_term
4545
(Abstraction
4646
[
47-
( true_lambda.stype,
47+
( true_lambda.rtype,
4848
Abstraction [ (bool_type, Abstraction [ (bool_type, Variable 1) ]) ]
4949
);
50-
( false_lambda.stype,
50+
( false_lambda.rtype,
5151
Abstraction [ (bool_type, Abstraction [ (bool_type, Variable 0) ]) ]
5252
);
5353
])

example/exampleHelpers.ml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ open TypeOperations.Union
66
open TypeOperations.Context
77
open TermOperations.Helpers
88

9-
type typed_term = { term : term; stype : structured_type }
9+
type typed_term = { term : term; rtype : recursive_type }
1010

11-
let build_typed_term (term : term) (stype : structured_type) = { term; stype }
11+
let build_typed_term (term : term) (rtype : recursive_type) = { term; rtype }
1212
let get_type_unsafe term = Option.get (get_type term)
1313
let typed_term term = build_typed_term term (get_type_unsafe term)
1414

15-
let type_intersection (types : structured_type list) : structured_type =
15+
let type_intersection (types : recursive_type list) : recursive_type =
1616
let intersection =
1717
List.fold_left
1818
(fun acc_intersection next_type ->
@@ -23,7 +23,7 @@ let type_intersection (types : structured_type list) : structured_type =
2323
in
2424
base_type (Intersection intersection)
2525

26-
let get_flat_union_type (union_types : structured_type list) : flat_union_type =
26+
let get_flat_union_type (union_types : recursive_type list) : flat_union_type =
2727
let union_type = type_union union_types in
2828
List.map
2929
(function
@@ -36,14 +36,14 @@ let get_flat_union_type (union_types : structured_type list) : flat_union_type =
3636

3737
(* Constructs the Z-combinator for a function of a given type, a fixed-point
3838
combinator for call-by-value semantics *)
39-
let build_fix (arg_type : structured_type) (return_type : structured_type) =
39+
let build_fix (arg_type : recursive_type) (return_type : recursive_type) =
4040
(* First, construct a function type from the arg type to the return type, taking
4141
care to properly join the contexts of the two types *)
4242
let (new_arg_type, new_return_type), shared_context =
4343
get_unified_type_context_pair arg_type return_type
4444
in
4545
let func_type =
46-
build_structured_type
46+
build_recursive_type
4747
[ Intersection [ (new_arg_type, new_return_type) ] ]
4848
shared_context
4949
in
@@ -59,33 +59,33 @@ let build_fix (arg_type : structured_type) (return_type : structured_type) =
5959
typed_term
6060
(Abstraction
6161
[
62-
( build_structured_type
62+
( build_recursive_type
6363
[ Intersection [ (func_type.union, func_type.union) ] ]
6464
new_shared_context,
6565
Application
6666
( Abstraction
6767
[
68-
( build_structured_type [ RecTypeVar rec_var_num ]
68+
( build_recursive_type [ RecTypeVar rec_var_num ]
6969
new_shared_context,
7070
Application
7171
( Variable 1,
7272
Abstraction
7373
[
74-
( build_structured_type new_arg_type
74+
( build_recursive_type new_arg_type
7575
new_shared_context,
7676
binary_apply (Variable 1) (Variable 1)
7777
(Variable 0) );
7878
] ) );
7979
],
8080
Abstraction
8181
[
82-
( build_structured_type [ RecTypeVar rec_var_num ]
82+
( build_recursive_type [ RecTypeVar rec_var_num ]
8383
new_shared_context,
8484
Application
8585
( Variable 1,
8686
Abstraction
8787
[
88-
( build_structured_type new_arg_type
88+
( build_recursive_type new_arg_type
8989
new_shared_context,
9090
binary_apply (Variable 1) (Variable 1)
9191
(Variable 0) );
@@ -96,7 +96,7 @@ let build_fix (arg_type : structured_type) (return_type : structured_type) =
9696
fix
9797

9898
(* Fixes a provided abstraction with the given arg and return type *)
99-
let fix (arg_type : structured_type) (return_type : structured_type)
99+
let fix (arg_type : recursive_type) (return_type : recursive_type)
100100
(term : term) =
101101
let fix_term = build_fix arg_type return_type in
102102
Application (fix_term.term, term)

example/mixed.ml

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@ open TermOperations.Helpers
77

88
let is_even_label = typed_term (Const "isEven")
99
let is_odd_label = typed_term (Const "isOdd")
10-
let is_even_odd_label = type_union [ is_even_label.stype; is_odd_label.stype ]
10+
let is_even_odd_label = type_union [ is_even_label.rtype; is_odd_label.rtype ]
1111
let name = typed_term (Const "Name")
1212
let num_to_bool = func_type (three_bit_type.union, bool_type.union)
1313

1414
let is_zero =
1515
typed_term
1616
(Abstraction
1717
[
18-
(zero.stype, true_lambda.term);
18+
(zero.rtype, true_lambda.term);
1919
( type_union
2020
[
21-
one.stype;
22-
two.stype;
23-
three.stype;
24-
four.stype;
25-
five.stype;
26-
six.stype;
27-
seven.stype;
21+
one.rtype;
22+
two.rtype;
23+
three.rtype;
24+
four.rtype;
25+
five.rtype;
26+
six.rtype;
27+
seven.rtype;
2828
],
2929
false_lambda.term );
3030
])
@@ -39,36 +39,36 @@ let is_even_odd =
3939
( func_type (is_even_odd_label.union, num_to_bool.union),
4040
Abstraction
4141
[
42-
( is_even_label.stype,
42+
( is_even_label.rtype,
4343
Abstraction
4444
[
45-
(zero.stype, true_lambda.term);
45+
(zero.rtype, true_lambda.term);
4646
( type_union
4747
[
48-
one.stype;
49-
two.stype;
50-
three.stype;
51-
four.stype;
52-
five.stype;
53-
six.stype;
54-
seven.stype;
48+
one.rtype;
49+
two.rtype;
50+
three.rtype;
51+
four.rtype;
52+
five.rtype;
53+
six.rtype;
54+
seven.rtype;
5555
],
5656
binary_apply (Variable 2) is_odd_label.term
5757
(Application (decrement.term, Variable 0)) );
5858
] );
59-
( is_odd_label.stype,
59+
( is_odd_label.rtype,
6060
Abstraction
6161
[
62-
(zero.stype, false_lambda.term);
62+
(zero.rtype, false_lambda.term);
6363
( type_union
6464
[
65-
one.stype;
66-
two.stype;
67-
three.stype;
68-
four.stype;
69-
five.stype;
70-
six.stype;
71-
seven.stype;
65+
one.rtype;
66+
two.rtype;
67+
three.rtype;
68+
four.rtype;
69+
five.rtype;
70+
six.rtype;
71+
seven.rtype;
7272
],
7373
binary_apply (Variable 2) is_even_label.term
7474
(Application (decrement.term, Variable 0)) );

example/modularArithmetic.ml

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ let seven = typed_term (Const "Seven")
1515
let three_bit_type =
1616
type_union
1717
[
18-
zero.stype;
19-
one.stype;
20-
two.stype;
21-
three.stype;
22-
four.stype;
23-
five.stype;
24-
six.stype;
25-
seven.stype;
18+
zero.rtype;
19+
one.rtype;
20+
two.rtype;
21+
three.rtype;
22+
four.rtype;
23+
five.rtype;
24+
six.rtype;
25+
seven.rtype;
2626
]
2727

2828
let unary_num_op = func_type (three_bit_type.union, three_bit_type.union)
@@ -32,28 +32,28 @@ let increment =
3232
typed_term
3333
(Abstraction
3434
[
35-
(zero.stype, one.term);
36-
(one.stype, two.term);
37-
(two.stype, three.term);
38-
(three.stype, four.term);
39-
(four.stype, five.term);
40-
(five.stype, six.term);
41-
(six.stype, seven.term);
42-
(seven.stype, zero.term);
35+
(zero.rtype, one.term);
36+
(one.rtype, two.term);
37+
(two.rtype, three.term);
38+
(three.rtype, four.term);
39+
(four.rtype, five.term);
40+
(five.rtype, six.term);
41+
(six.rtype, seven.term);
42+
(seven.rtype, zero.term);
4343
])
4444

4545
let decrement =
4646
typed_term
4747
(Abstraction
4848
[
49-
(zero.stype, seven.term);
50-
(one.stype, zero.term);
51-
(two.stype, one.term);
52-
(three.stype, two.term);
53-
(four.stype, three.term);
54-
(five.stype, four.term);
55-
(six.stype, five.term);
56-
(seven.stype, six.term);
49+
(zero.rtype, seven.term);
50+
(one.rtype, zero.term);
51+
(two.rtype, one.term);
52+
(three.rtype, two.term);
53+
(four.rtype, three.term);
54+
(five.rtype, four.term);
55+
(six.rtype, five.term);
56+
(seven.rtype, six.term);
5757
])
5858

5959
let fix_binary_num_op = fix three_bit_type unary_num_op
@@ -67,16 +67,16 @@ let add =
6767
( binary_num_op,
6868
Abstraction
6969
[
70-
(zero.stype, Abstraction [ (three_bit_type, Variable 0) ]);
70+
(zero.rtype, Abstraction [ (three_bit_type, Variable 0) ]);
7171
( type_union
7272
[
73-
one.stype;
74-
two.stype;
75-
three.stype;
76-
four.stype;
77-
five.stype;
78-
six.stype;
79-
seven.stype;
73+
one.rtype;
74+
two.rtype;
75+
three.rtype;
76+
four.rtype;
77+
five.rtype;
78+
six.rtype;
79+
seven.rtype;
8080
],
8181
Abstraction
8282
[
@@ -96,15 +96,15 @@ let fib =
9696
( unary_num_op,
9797
Abstraction
9898
[
99-
(type_union [ zero.stype; one.stype ], one.term);
99+
(type_union [ zero.rtype; one.rtype ], one.term);
100100
( type_union
101101
[
102-
two.stype;
103-
three.stype;
104-
four.stype;
105-
five.stype;
106-
six.stype;
107-
seven.stype;
102+
two.rtype;
103+
three.rtype;
104+
four.rtype;
105+
five.rtype;
106+
six.rtype;
107+
seven.rtype;
108108
],
109109
binary_apply add.term
110110
(Application

0 commit comments

Comments
 (0)