版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BooleanAlgebra.js 2.3 KiB

пре 1 година
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.getFunctionBooleanAlgebra = exports.booleanAlgebraBoolean = exports.getDualBooleanAlgebra = exports.booleanAlgebraVoid = exports.reverse = void 0;
  4. var function_1 = require("./function");
  5. // -------------------------------------------------------------------------------------
  6. // combinators
  7. // -------------------------------------------------------------------------------------
  8. /**
  9. * Every boolean algebras has a dual algebra, which involves reversing one/zero as well as join/meet.
  10. *
  11. * @since 2.10.0
  12. */
  13. var reverse = function (B) { return ({
  14. meet: function (x, y) { return B.join(x, y); },
  15. join: function (x, y) { return B.meet(x, y); },
  16. zero: B.one,
  17. one: B.zero,
  18. implies: function (x, y) { return B.join(B.not(x), y); },
  19. not: B.not
  20. }); };
  21. exports.reverse = reverse;
  22. // -------------------------------------------------------------------------------------
  23. // instances
  24. // -------------------------------------------------------------------------------------
  25. /**
  26. * @category instances
  27. * @since 2.0.0
  28. */
  29. exports.booleanAlgebraVoid = {
  30. meet: function () { return undefined; },
  31. join: function () { return undefined; },
  32. zero: undefined,
  33. one: undefined,
  34. implies: function () { return undefined; },
  35. not: function () { return undefined; }
  36. };
  37. // -------------------------------------------------------------------------------------
  38. // deprecated
  39. // -------------------------------------------------------------------------------------
  40. /**
  41. * Use [`reverse`](#reverse) instead.
  42. *
  43. * @category zone of death
  44. * @since 2.0.0
  45. * @deprecated
  46. */
  47. exports.getDualBooleanAlgebra = exports.reverse;
  48. /**
  49. * Use [`BooleanAlgebra`](./boolean.ts.html#booleanalgebra) instead.
  50. *
  51. * @category zone of death
  52. * @since 2.0.0
  53. * @deprecated
  54. */
  55. exports.booleanAlgebraBoolean = {
  56. meet: function (x, y) { return x && y; },
  57. join: function (x, y) { return x || y; },
  58. zero: false,
  59. one: true,
  60. implies: function (x, y) { return !x || y; },
  61. not: function (x) { return !x; }
  62. };
  63. /**
  64. * Use [`getBooleanAlgebra`](./function.ts.html#getbooleanalgebra) instead.
  65. *
  66. * @category zone of death
  67. * @since 2.0.0
  68. * @deprecated
  69. */
  70. exports.getFunctionBooleanAlgebra = function_1.getBooleanAlgebra;