File: logic.chapt.txt

package info (click to toggle)
yacas 1.3.6-2
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 7,176 kB
  • ctags: 3,520
  • sloc: cpp: 13,960; java: 12,602; sh: 11,401; makefile: 552; perl: 517; ansic: 381
file content (87 lines) | stat: -rw-r--r-- 2,161 bytes parent folder | download | duplicates (6)
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

			Propositional logic theorem prover

*CMD CanProve --- try to prove statement
*STD
*CALL
	CanProve(proposition)

*PARMS

{proposition} -- an expression with logical operations

*DESC

Yacas has a small built-in propositional logic theorem prover.
It can be invoked with a call to {CanProve}.

An example of a proposition is: "if a implies b and b implies c then
a implies c". Yacas supports the following logical operations:

{Not} :     negation, read as "not"

{And}  :   conjunction, read as "and"

{Or}  :   disjunction, read as "or"

{=>}  : implication, read as "implies"

The abovementioned proposition would be represented by the following expression,

	( (a=>b) And (b=>c) ) => (a=>c)

Yacas can prove that is correct by applying {CanProve}
to it:

	In> CanProve(( (a=>b) And (b=>c) ) => (a=>c))
	Out> True;

It does this in the following way: in order to prove a proposition $p$, it
suffices to prove that  $Not p$ is false. It continues to simplify  $Not p$
using the rules:

	Not  ( Not x)      --> x
(eliminate double negation),
	x=>y  -->  Not x  Or  y
(eliminate implication),
	Not (x And y)  -->  Not x  Or  Not y
(De Morgan's law),
	Not (x Or y) -->  Not x  And  Not y
(De Morgan's law),
	(x And y) Or z --> (x Or z) And (y Or z)
(distribution),
	x Or (y And z) --> (x Or y) And (x Or z)
(distribution),
and the obvious other rules, such as,
	True Or x --> True
etc.
The above rules will translate a proposition into a form

	(p1  Or  p2  Or  ...)  And  (q1  Or  q2
	   Or  ...)  And ...
If any of the clauses is false, the entire expression will be false.
In the next step, clauses are scanned for situations of the form:

	(p Or Y)  And  ( Not p Or Z) --> (Y Or Z)
If this combination {(Y Or Z)} is empty, it is false, and
thus the entire proposition is false.

As a last step, the algorithm negates the result again. This has the
added advantage of simplifying the expression further.

*E.G.

	In> CanProve(a  Or   Not a)
	Out> True;
	In> CanProve(True  Or  a)
	Out> True;
	In> CanProve(False  Or  a)
	Out> a;
	In> CanProve(a  And   Not a)
	Out> False;
	In> CanProve(a  Or b Or (a And b))
	Out> a Or b;
	

*SEE True, False, And, Or, Not