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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
use std::ops::{Shl, Shr};

use bitflags::bitflags;

pub(crate) const EXPANDED: u64 = 0x0000000000000001;
pub(crate) const MUTABLE: u64 = 0x0000000000000002;

bitflags! {
    /// The property bits here assert facts about an FST. If individual bits are
    /// added, then the composite fst_properties below, the property functions and
    /// property names in fst_properties.cc, and TestProperties() in test-fst_properties.h
    /// should be updated.
    /// For each of these fst_properties below there is a pair of property bits, one
    /// positive and one negative. If the positive bit is set, the property is true.
    /// If the negative bit is set, the property is false. If neither is set, the
    /// property has unknown value. Both should never be simultaneously set. The
    /// individual positive and negative bit pairs should be adjacent with the
    /// positive bit at an odd and lower position.
    pub struct FstProperties: u64 {
        /// ilabel == olabel for each transition.
        const ACCEPTOR = 0x0000000000010000;
        /// ilabel != olabel for some transition.
        const NOT_ACCEPTOR = 0x0000000000020000;

        /// ilabels unique leaving each state.
        const I_DETERMINISTIC = 0x0000000000040000;
        /// ilabels not unique leaving some state.
        const NOT_I_DETERMINISTIC = 0x0000000000080000;

        /// olabels unique leaving each state.
        const O_DETERMINISTIC = 0x0000000000100000;
        /// olabels not unique leaving some state.
        const NOT_O_DETERMINISTIC = 0x0000000000200000;

        /// FST has input/output epsilons.
        const EPSILONS = 0x0000000000400000;
        /// FST has no input/output epsilons.
        const NO_EPSILONS = 0x0000000000800000;

        /// FST has input epsilons.
        const I_EPSILONS = 0x0000000001000000;
        /// FST has no input epsilons.
        const NO_I_EPSILONS = 0x0000000002000000;

        /// FST has output epsilons.
        const O_EPSILONS = 0x0000000004000000;
        /// FST has no output epsilons.
        const NO_O_EPSILONS = 0x0000000008000000;

        /// ilabels sorted wrt < for each state.
        const I_LABEL_SORTED = 0x0000000010000000;
        /// ilabels not sorted wrt < for some state.
        const NOT_I_LABEL_SORTED = 0x0000000020000000;

        /// olabels sorted wrt < for each state.
        const O_LABEL_SORTED = 0x0000000040000000;
        /// olabels not sorted wrt < for some state.
        const NOT_O_LABEL_SORTED = 0x0000000080000000;

        /// Non-trivial transition or final weights.
        const WEIGHTED = 0x0000000100000000;
        /// Only trivial transition and final weights.
        const UNWEIGHTED = 0x0000000200000000;

        /// FST has cycles.
        const CYCLIC = 0x0000000400000000;
        /// FST has no cycles.
        const ACYCLIC = 0x0000000800000000;

        /// FST has cycles containing the initial state.
        const INITIAL_CYCLIC = 0x0000001000000000;
        /// FST has no cycles containing the initial state.
        const INITIAL_ACYCLIC = 0x0000002000000000;

        /// FST is topologically sorted.
        const TOP_SORTED = 0x0000004000000000;
        /// FST is not topologically sorted.
        const NOT_TOP_SORTED = 0x0000008000000000;

        /// All states reachable from the initial state.
        const ACCESSIBLE = 0x0000010000000000;
        /// Not all states reachable from the initial state.
        const NOT_ACCESSIBLE = 0x0000020000000000;

        /// All states can reach a final state.
        const COACCESSIBLE = 0x0000040000000000;
        /// Not all states can reach a final state.
        const NOT_COACCESSIBLE = 0x0000080000000000;

        /// If NumStates() > 0, then state 0 is initial, state NumStates() - 1 is final,
        /// there is a transition from each non-final state i to state i + 1, and there
        /// are no other transitions.
        const STRING = 0x0000100000000000;

        /// Not a string FST.
        const NOT_STRING = 0x0000200000000000;

        /// FST has at least one weighted cycle.
        const WEIGHTED_CYCLES = 0x0000400000000000;

        /// Only unweighted cycles.
        const UNWEIGHTED_CYCLES = 0x0000800000000000;
    }

}

impl FstProperties {
    /// Properties of an empty machine.
    pub(crate) fn null_properties() -> FstProperties {
        FstProperties::ACCEPTOR
            | FstProperties::I_DETERMINISTIC
            | FstProperties::O_DETERMINISTIC
            | FstProperties::NO_EPSILONS
            | FstProperties::NO_I_EPSILONS
            | FstProperties::NO_O_EPSILONS
            | FstProperties::I_LABEL_SORTED
            | FstProperties::O_LABEL_SORTED
            | FstProperties::UNWEIGHTED
            | FstProperties::ACYCLIC
            | FstProperties::INITIAL_ACYCLIC
            | FstProperties::TOP_SORTED
            | FstProperties::ACCESSIBLE
            | FstProperties::COACCESSIBLE
            | FstProperties::STRING
            | FstProperties::UNWEIGHTED_CYCLES
    }

    /// Properties that are preserved when an FST is copied.
    pub(crate) fn copy_properties() -> FstProperties {
        FstProperties::ACCEPTOR
            | FstProperties::NOT_ACCEPTOR
            | FstProperties::I_DETERMINISTIC
            | FstProperties::NOT_I_DETERMINISTIC
            | FstProperties::O_DETERMINISTIC
            | FstProperties::NOT_O_DETERMINISTIC
            | FstProperties::EPSILONS
            | FstProperties::NO_EPSILONS
            | FstProperties::I_EPSILONS
            | FstProperties::NO_I_EPSILONS
            | FstProperties::O_EPSILONS
            | FstProperties::NO_O_EPSILONS
            | FstProperties::I_LABEL_SORTED
            | FstProperties::NOT_I_LABEL_SORTED
            | FstProperties::O_LABEL_SORTED
            | FstProperties::NOT_O_LABEL_SORTED
            | FstProperties::WEIGHTED
            | FstProperties::UNWEIGHTED
            | FstProperties::CYCLIC
            | FstProperties::ACYCLIC
            | FstProperties::INITIAL_CYCLIC
            | FstProperties::INITIAL_ACYCLIC
            | FstProperties::TOP_SORTED
            | FstProperties::NOT_TOP_SORTED
            | FstProperties::ACCESSIBLE
            | FstProperties::NOT_ACCESSIBLE
            | FstProperties::COACCESSIBLE
            | FstProperties::NOT_COACCESSIBLE
            | FstProperties::STRING
            | FstProperties::NOT_STRING
            | FstProperties::WEIGHTED_CYCLES
            | FstProperties::UNWEIGHTED_CYCLES
    }

    /// Properties that are preserved when an FST start state is set.
    pub(crate) fn set_start_properties() -> FstProperties {
        FstProperties::ACCEPTOR
            | FstProperties::NOT_ACCEPTOR
            | FstProperties::I_DETERMINISTIC
            | FstProperties::NOT_I_DETERMINISTIC
            | FstProperties::O_DETERMINISTIC
            | FstProperties::NOT_O_DETERMINISTIC
            | FstProperties::EPSILONS
            | FstProperties::NO_EPSILONS
            | FstProperties::I_EPSILONS
            | FstProperties::NO_I_EPSILONS
            | FstProperties::O_EPSILONS
            | FstProperties::NO_O_EPSILONS
            | FstProperties::I_LABEL_SORTED
            | FstProperties::NOT_I_LABEL_SORTED
            | FstProperties::O_LABEL_SORTED
            | FstProperties::NOT_O_LABEL_SORTED
            | FstProperties::WEIGHTED
            | FstProperties::UNWEIGHTED
            | FstProperties::CYCLIC
            | FstProperties::ACYCLIC
            | FstProperties::TOP_SORTED
            | FstProperties::NOT_TOP_SORTED
            | FstProperties::COACCESSIBLE
            | FstProperties::NOT_COACCESSIBLE
            | FstProperties::WEIGHTED_CYCLES
            | FstProperties::UNWEIGHTED_CYCLES
    }

    /// Properties that are preserved when an FST final weight is set.
    pub(crate) fn set_final_properties() -> FstProperties {
        FstProperties::ACCEPTOR
            | FstProperties::NOT_ACCEPTOR
            | FstProperties::I_DETERMINISTIC
            | FstProperties::NOT_I_DETERMINISTIC
            | FstProperties::O_DETERMINISTIC
            | FstProperties::NOT_O_DETERMINISTIC
            | FstProperties::EPSILONS
            | FstProperties::NO_EPSILONS
            | FstProperties::I_EPSILONS
            | FstProperties::NO_I_EPSILONS
            | FstProperties::O_EPSILONS
            | FstProperties::NO_O_EPSILONS
            | FstProperties::I_LABEL_SORTED
            | FstProperties::NOT_I_LABEL_SORTED
            | FstProperties::O_LABEL_SORTED
            | FstProperties::NOT_O_LABEL_SORTED
            | FstProperties::CYCLIC
            | FstProperties::ACYCLIC
            | FstProperties::INITIAL_CYCLIC
            | FstProperties::INITIAL_ACYCLIC
            | FstProperties::TOP_SORTED
            | FstProperties::NOT_TOP_SORTED
            | FstProperties::ACCESSIBLE
            | FstProperties::NOT_ACCESSIBLE
            | FstProperties::WEIGHTED_CYCLES
            | FstProperties::UNWEIGHTED_CYCLES
    }

    /// Properties that are preserved when an FST state is added.
    pub(crate) fn add_state_properties() -> FstProperties {
        FstProperties::ACCEPTOR
            | FstProperties::NOT_ACCEPTOR
            | FstProperties::I_DETERMINISTIC
            | FstProperties::NOT_I_DETERMINISTIC
            | FstProperties::O_DETERMINISTIC
            | FstProperties::NOT_O_DETERMINISTIC
            | FstProperties::EPSILONS
            | FstProperties::NO_EPSILONS
            | FstProperties::I_EPSILONS
            | FstProperties::NO_I_EPSILONS
            | FstProperties::O_EPSILONS
            | FstProperties::NO_O_EPSILONS
            | FstProperties::I_LABEL_SORTED
            | FstProperties::NOT_I_LABEL_SORTED
            | FstProperties::O_LABEL_SORTED
            | FstProperties::NOT_O_LABEL_SORTED
            | FstProperties::WEIGHTED
            | FstProperties::UNWEIGHTED
            | FstProperties::CYCLIC
            | FstProperties::ACYCLIC
            | FstProperties::INITIAL_CYCLIC
            | FstProperties::INITIAL_ACYCLIC
            | FstProperties::TOP_SORTED
            | FstProperties::NOT_TOP_SORTED
            | FstProperties::NOT_ACCESSIBLE
            | FstProperties::NOT_COACCESSIBLE
            | FstProperties::NOT_STRING
            | FstProperties::WEIGHTED_CYCLES
            | FstProperties::UNWEIGHTED_CYCLES
    }

    /// Properties that are preserved when an FST transition is added.
    pub(crate) fn add_arc_properties() -> FstProperties {
        FstProperties::NOT_ACCEPTOR
            | FstProperties::NOT_I_DETERMINISTIC
            | FstProperties::NOT_O_DETERMINISTIC
            | FstProperties::EPSILONS
            | FstProperties::I_EPSILONS
            | FstProperties::O_EPSILONS
            | FstProperties::NOT_I_LABEL_SORTED
            | FstProperties::NOT_O_LABEL_SORTED
            | FstProperties::WEIGHTED
            | FstProperties::CYCLIC
            | FstProperties::INITIAL_CYCLIC
            | FstProperties::NOT_TOP_SORTED
            | FstProperties::ACCESSIBLE
            | FstProperties::COACCESSIBLE
            | FstProperties::WEIGHTED_CYCLES
    }

    /// Properties that are preserved when an FST transition is set.
    pub(crate) fn set_arc_properties() -> FstProperties {
        FstProperties::empty()
    }

    /// Properties that are preserved when FST states are deleted.
    pub(crate) fn delete_states_properties() -> FstProperties {
        FstProperties::ACCEPTOR
            | FstProperties::I_DETERMINISTIC
            | FstProperties::O_DETERMINISTIC
            | FstProperties::NO_EPSILONS
            | FstProperties::NO_I_EPSILONS
            | FstProperties::NO_O_EPSILONS
            | FstProperties::I_LABEL_SORTED
            | FstProperties::O_LABEL_SORTED
            | FstProperties::UNWEIGHTED
            | FstProperties::ACYCLIC
            | FstProperties::INITIAL_ACYCLIC
            | FstProperties::TOP_SORTED
            | FstProperties::UNWEIGHTED_CYCLES
    }

    /// Properties that are preserved when FST trs are deleted.
    pub(crate) fn delete_arcs_properties() -> FstProperties {
        FstProperties::ACCEPTOR
            | FstProperties::I_DETERMINISTIC
            | FstProperties::O_DETERMINISTIC
            | FstProperties::NO_EPSILONS
            | FstProperties::NO_I_EPSILONS
            | FstProperties::NO_O_EPSILONS
            | FstProperties::I_LABEL_SORTED
            | FstProperties::O_LABEL_SORTED
            | FstProperties::UNWEIGHTED
            | FstProperties::ACYCLIC
            | FstProperties::INITIAL_ACYCLIC
            | FstProperties::TOP_SORTED
            | FstProperties::NOT_ACCESSIBLE
            | FstProperties::NOT_COACCESSIBLE
            | FstProperties::UNWEIGHTED_CYCLES
    }

    /// Properties that are preserved when an FST's states are reordered.
    pub(crate) fn statesort_properties() -> FstProperties {
        FstProperties::ACCEPTOR
            | FstProperties::NOT_ACCEPTOR
            | FstProperties::I_DETERMINISTIC
            | FstProperties::NOT_I_DETERMINISTIC
            | FstProperties::O_DETERMINISTIC
            | FstProperties::NOT_O_DETERMINISTIC
            | FstProperties::EPSILONS
            | FstProperties::NO_EPSILONS
            | FstProperties::I_EPSILONS
            | FstProperties::NO_I_EPSILONS
            | FstProperties::O_EPSILONS
            | FstProperties::NO_O_EPSILONS
            | FstProperties::I_LABEL_SORTED
            | FstProperties::NOT_I_LABEL_SORTED
            | FstProperties::O_LABEL_SORTED
            | FstProperties::NOT_O_LABEL_SORTED
            | FstProperties::WEIGHTED
            | FstProperties::UNWEIGHTED
            | FstProperties::CYCLIC
            | FstProperties::ACYCLIC
            | FstProperties::INITIAL_CYCLIC
            | FstProperties::INITIAL_ACYCLIC
            | FstProperties::ACCESSIBLE
            | FstProperties::NOT_ACCESSIBLE
            | FstProperties::COACCESSIBLE
            | FstProperties::NOT_COACCESSIBLE
            | FstProperties::WEIGHTED_CYCLES
            | FstProperties::UNWEIGHTED_CYCLES
    }

    /// Properties that are preserved when an FST's trs are reordered.
    pub(crate) fn arcsort_properties() -> FstProperties {
        FstProperties::ACCEPTOR
            | FstProperties::NOT_ACCEPTOR
            | FstProperties::I_DETERMINISTIC
            | FstProperties::NOT_I_DETERMINISTIC
            | FstProperties::O_DETERMINISTIC
            | FstProperties::NOT_O_DETERMINISTIC
            | FstProperties::EPSILONS
            | FstProperties::NO_EPSILONS
            | FstProperties::I_EPSILONS
            | FstProperties::NO_I_EPSILONS
            | FstProperties::O_EPSILONS
            | FstProperties::NO_O_EPSILONS
            | FstProperties::WEIGHTED
            | FstProperties::UNWEIGHTED
            | FstProperties::CYCLIC
            | FstProperties::ACYCLIC
            | FstProperties::INITIAL_CYCLIC
            | FstProperties::INITIAL_ACYCLIC
            | FstProperties::TOP_SORTED
            | FstProperties::NOT_TOP_SORTED
            | FstProperties::ACCESSIBLE
            | FstProperties::NOT_ACCESSIBLE
            | FstProperties::COACCESSIBLE
            | FstProperties::NOT_COACCESSIBLE
            | FstProperties::STRING
            | FstProperties::NOT_STRING
            | FstProperties::WEIGHTED_CYCLES
            | FstProperties::UNWEIGHTED_CYCLES
    }

    /// Properties that are preserved when an FST's input labels are changed.
    pub(crate) fn i_label_invariant_properties() -> FstProperties {
        FstProperties::O_DETERMINISTIC
            | FstProperties::NOT_O_DETERMINISTIC
            | FstProperties::O_EPSILONS
            | FstProperties::NO_O_EPSILONS
            | FstProperties::O_LABEL_SORTED
            | FstProperties::NOT_O_LABEL_SORTED
            | FstProperties::WEIGHTED
            | FstProperties::UNWEIGHTED
            | FstProperties::CYCLIC
            | FstProperties::ACYCLIC
            | FstProperties::INITIAL_CYCLIC
            | FstProperties::INITIAL_ACYCLIC
            | FstProperties::TOP_SORTED
            | FstProperties::NOT_TOP_SORTED
            | FstProperties::ACCESSIBLE
            | FstProperties::NOT_ACCESSIBLE
            | FstProperties::COACCESSIBLE
            | FstProperties::NOT_COACCESSIBLE
            | FstProperties::STRING
            | FstProperties::NOT_STRING
            | FstProperties::WEIGHTED_CYCLES
            | FstProperties::UNWEIGHTED_CYCLES
    }

    /// Properties that are preserved when an FST's output labels are changed.
    pub(crate) fn o_label_invariant_properties() -> FstProperties {
        FstProperties::I_DETERMINISTIC
            | FstProperties::NOT_I_DETERMINISTIC
            | FstProperties::I_EPSILONS
            | FstProperties::NO_I_EPSILONS
            | FstProperties::I_LABEL_SORTED
            | FstProperties::NOT_I_LABEL_SORTED
            | FstProperties::WEIGHTED
            | FstProperties::UNWEIGHTED
            | FstProperties::CYCLIC
            | FstProperties::ACYCLIC
            | FstProperties::INITIAL_CYCLIC
            | FstProperties::INITIAL_ACYCLIC
            | FstProperties::TOP_SORTED
            | FstProperties::NOT_TOP_SORTED
            | FstProperties::ACCESSIBLE
            | FstProperties::NOT_ACCESSIBLE
            | FstProperties::COACCESSIBLE
            | FstProperties::NOT_COACCESSIBLE
            | FstProperties::STRING
            | FstProperties::NOT_STRING
            | FstProperties::WEIGHTED_CYCLES
            | FstProperties::UNWEIGHTED_CYCLES
    }

    /// Properties that are preserved when an FST's weights are changed. This
    /// assumes that the set of states that are non-final is not changed.
    pub(crate) fn weight_invariant_properties() -> FstProperties {
        FstProperties::ACCEPTOR
            | FstProperties::NOT_ACCEPTOR
            | FstProperties::I_DETERMINISTIC
            | FstProperties::NOT_I_DETERMINISTIC
            | FstProperties::O_DETERMINISTIC
            | FstProperties::NOT_O_DETERMINISTIC
            | FstProperties::EPSILONS
            | FstProperties::NO_EPSILONS
            | FstProperties::I_EPSILONS
            | FstProperties::NO_I_EPSILONS
            | FstProperties::O_EPSILONS
            | FstProperties::NO_O_EPSILONS
            | FstProperties::I_LABEL_SORTED
            | FstProperties::NOT_I_LABEL_SORTED
            | FstProperties::O_LABEL_SORTED
            | FstProperties::NOT_O_LABEL_SORTED
            | FstProperties::CYCLIC
            | FstProperties::ACYCLIC
            | FstProperties::INITIAL_CYCLIC
            | FstProperties::INITIAL_ACYCLIC
            | FstProperties::TOP_SORTED
            | FstProperties::NOT_TOP_SORTED
            | FstProperties::ACCESSIBLE
            | FstProperties::NOT_ACCESSIBLE
            | FstProperties::COACCESSIBLE
            | FstProperties::NOT_COACCESSIBLE
            | FstProperties::STRING
            | FstProperties::NOT_STRING
    }

    /// Properties that are preserved when a superfinal state is added and an FST's
    /// final weights are directed to it via new transitions.
    pub(crate) fn add_super_final_properties() -> FstProperties {
        FstProperties::NOT_ACCEPTOR
            | FstProperties::NOT_I_DETERMINISTIC
            | FstProperties::NOT_O_DETERMINISTIC
            | FstProperties::EPSILONS
            | FstProperties::I_EPSILONS
            | FstProperties::O_EPSILONS
            | FstProperties::NOT_I_LABEL_SORTED
            | FstProperties::NOT_O_LABEL_SORTED
            | FstProperties::WEIGHTED
            | FstProperties::UNWEIGHTED
            | FstProperties::CYCLIC
            | FstProperties::ACYCLIC
            | FstProperties::INITIAL_CYCLIC
            | FstProperties::INITIAL_ACYCLIC
            | FstProperties::NOT_TOP_SORTED
            | FstProperties::NOT_ACCESSIBLE
            | FstProperties::COACCESSIBLE
            | FstProperties::NOT_COACCESSIBLE
            | FstProperties::NOT_STRING
            | FstProperties::WEIGHTED_CYCLES
            | FstProperties::UNWEIGHTED_CYCLES
    }

    /// Properties that are preserved when a superfinal state is removed and the
    /// epsilon transitions directed to it are made final weights.
    pub(crate) fn rm_super_final_properties() -> FstProperties {
        FstProperties::ACCEPTOR
            | FstProperties::NOT_ACCEPTOR
            | FstProperties::I_DETERMINISTIC
            | FstProperties::O_DETERMINISTIC
            | FstProperties::NO_EPSILONS
            | FstProperties::NO_I_EPSILONS
            | FstProperties::NO_O_EPSILONS
            | FstProperties::I_LABEL_SORTED
            | FstProperties::O_LABEL_SORTED
            | FstProperties::WEIGHTED
            | FstProperties::UNWEIGHTED
            | FstProperties::CYCLIC
            | FstProperties::ACYCLIC
            | FstProperties::INITIAL_CYCLIC
            | FstProperties::INITIAL_ACYCLIC
            | FstProperties::TOP_SORTED
            | FstProperties::ACCESSIBLE
            | FstProperties::COACCESSIBLE
            | FstProperties::NOT_COACCESSIBLE
            | FstProperties::STRING
            | FstProperties::WEIGHTED_CYCLES
            | FstProperties::UNWEIGHTED_CYCLES
    }

    // Binary properties are not stored here so should be useless.
    pub(crate) fn binary_properties() -> FstProperties {
        FstProperties::from_bits_truncate(0x0000000000000007)
    }
    pub(crate) fn trinary_properties() -> FstProperties {
        FstProperties::from_bits_truncate(0x0000ffffffff0000)
    }

    pub(crate) fn pos_trinary_properties() -> FstProperties {
        FstProperties::trinary_properties() & FstProperties::from_bits_truncate(0x5555555555555555)
    }
    pub(crate) fn neg_trinary_properties() -> FstProperties {
        FstProperties::trinary_properties() & FstProperties::from_bits_truncate(0xaaaaaaaaaaaaaaaa)
    }

    pub(crate) fn all_properties() -> FstProperties {
        FstProperties::binary_properties() | FstProperties::trinary_properties()
    }
}

impl Shl<usize> for FstProperties {
    type Output = FstProperties;

    fn shl(self, rhs: usize) -> Self::Output {
        Self::from_bits_truncate(self.bits() << rhs)
    }
}

impl Shr<usize> for FstProperties {
    type Output = FstProperties;

    fn shr(self, rhs: usize) -> Self::Output {
        Self::from_bits_truncate(self.bits() >> rhs)
    }
}