File: logic.dem

package info (click to toggle)
maxima-sage 5.45.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 113,788 kB
  • sloc: lisp: 440,833; fortran: 14,665; perl: 14,369; tcl: 10,997; sh: 4,475; makefile: 2,520; ansic: 447; python: 262; xml: 59; awk: 37; sed: 17
file content (91 lines) | stat: -rw-r--r-- 2,725 bytes parent folder | download | duplicates (12)
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
/*
 * logic.mac--Logic algebra package for Maxima CAS.
 * Copyright (c) 2008--2009 Alexey Beshenov <al@beshenov.ru>.
 *
 * Version 2.1. Last modified 2009-01-07
 *
 * logic.mac is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation; either version 2.1 of the License,
 * or (at your option) any later version.
 *
 * logic.mac is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with the logic.mac; see the file COPYING. If not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */


load ("logic.mac")$

logic_simp (a or (b or false or (a or b)));
logic_simp (b eq a eq false eq true);
logic_simp ((a xor true) xor b xor true);
logic_simp ((a implies q) or (not (a implies q)) or b);

characteristic_vector (true);
characteristic_vector (a xor b);
characteristic_vector (a implies b);
characteristic_vector (a implies b, a, b);
characteristic_vector (a implies b, b, a);

zhegalkin_form (a or b or c);
zhegalkin_form ((a implies b) or c);

e : ((a or b) xor c) and d$
ezh : zhegalkin_form (e);
logic_equiv (ezh, e);
is (characteristic_vector(ezh) = characteristic_vector(e));
logic_equiv (x and y eq x, x implies y);

dual_function (x or y);
zhegalkin_form (%);

self_dual (a);
self_dual (not a);
self_dual (a eq b);

closed_under_f (x and y);
closed_under_f (x or y);
closed_under_t (x and y);
closed_under_t (x or y);

monotonic (a or b);
monotonic (a and b);
monotonic (a implies b);
monotonic (a xor b);

linear (a or b);
linear (a eq b);

functionally_complete (x and y, x xor y);
functionally_complete (x and y, x xor y, true);
functionally_complete (x and y, x or y, not x);

logic_basis (x and y, x or y, not x);
logic_basis (x and y, not x);
logic_basis (x or y, not x);

logic_functions : { not x, x nand y, x nor y,
                    x implies y, x and y, x or y,
                    x eq y, x xor y, true, false }$
logic_bases : subset (powerset(logic_functions), lambda ([s], apply ('logic_basis, listify(s))));

logic_diff (a or b or c, a);
logic_diff (a and b and c, a);
logic_diff (true, a);

boolean_form (a implies b implies c);
demorgan (%);
logic_equiv (boolean_form (a implies b implies c), zhegalkin_form (a implies b implies c));

demorgan (boolean_form (a nor b nor c));

pdnf (x implies y);
pcnf (x implies y);
logic_equiv (pdnf (x implies y), pcnf (x implies y));