package prbnmcn-basic-structures

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file intf_algebra.ml

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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
(** Basic algebraic structures. The [_no_std] variants do not require
    defining the contents of [Intf_std.Std]. *)

open Intf_std

(** Abelian group *)
module type Abelian_group = sig
  type t

  val zero : t

  val add : t -> t -> t

  val neg : t -> t
end

module type Abelian_group_std = sig
  include Abelian_group

  include Std with type t := t
end

(** Monoid *)
module type Monoid = sig
  type t

  val one : t

  val mul : t -> t -> t
end

module type Monoid_std = sig
  include Monoid

  include Std with type t := t
end

(** Ring *)
module type Ring = sig
  include Abelian_group

  include Monoid with type t := t

  (* [sub x y] = [add x (neg y)] *)
  val sub : t -> t -> t

  val of_int : int -> t
end

module type Ring_std = sig
  include Ring

  include Std with type t := t
end

(** Field, assuming the ring is commutative. *)
module type Field = sig
  include Ring

  val div : t -> t -> t
end

(** Field, assuming the ring is commutative. *)
module type Field_std = sig
  include Field

  include Std with type t := t
end

(** Modules over a ring [R]. *)
module type Module = sig
  module R : Ring

  type t

  include Abelian_group with type t := t

  val smul : R.t -> t -> t
end

(** Module over a ring [R]. *)
module type Module_std = sig
  module R : Ring_std

  type t

  include Abelian_group_std with type t := t

  val smul : R.t -> t -> t
end

(** Algebra over a ring *)
module type Algebra = sig
  include Module

  (** [mul] should distribute over addition. Not necessarily
      associative, nor commutative, nor unital. *)
  val mul : t -> t -> t
end

(** Free module *)
module type Free_module = sig
  include Module

  type basis

  (** "Dirac" delta *)
  val delta : basis -> t

  (** Project the coefficient corresponding to a basis vector. *)
  val eval : t -> basis -> R.t

  (** [bind] = canonical, "multilinear" extension *)
  val bind : t -> (basis -> t) -> t

  (** [of_list [(x1,r1);...;(xn,rn)]] is equivalent to
       add (smul r1 (delta x1))
        (add (smul r2 (delta x2))
           (add ... (smul rn (delta xn)))) *)
  val of_list : (basis * R.t) list -> t

  (** Fold over the elements of a vector. Order is not specified. *)
  val fold : (basis -> R.t -> 'a -> 'a) -> t -> 'a -> 'a
end

module type Free_module_std = sig
  include Module_std

  module Basis : Std

  type basis = Basis.t

  (** "Dirac" delta *)
  val delta : basis -> t

  (** Project the coefficient corresponding to a basis vector. *)
  val eval : t -> basis -> R.t

  (** [bind] = canonical, "multilinear" extension *)
  val bind : t -> (basis -> t) -> t

  (** [of_list [(x1,r1);...;(xn,rn)]] is equivalent to
       add (smul r1 (delta x1))
        (add (smul r2 (delta x2))
           (add ... (smul rn (delta xn)))) *)
  val of_list : (basis * R.t) list -> t

  (** Fold over the elements of a vector. Order is not specified. *)
  val fold : (basis -> R.t -> 'a -> 'a) -> t -> 'a -> 'a
end

module type Finitely_generated_free_module = sig
  include Free_module

  val generators : basis list

  (** List coefficients in the order of [generators] *)
  val coefficients : t -> R.t list
end

(** Partial order. *)
module type Partial_order = sig
  type t

  val equal : t -> t -> bool

  val lt : t -> t -> bool
end