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
|
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Chapter 15: Boolean Algebra"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 15.1: Basic_definitions_in_boolean_algebra.sci"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"//0 denotes False and 1 denotes true\n",
"b=[0,1];\n",
"//binary operation + on the set of bits\n",
"for i=1:2\n",
"for j=1:2\n",
"k = b(i)& b(j);\n",
"disp(k)\n",
"end\n",
"end\n",
"//binary operation * on the set of bits\n",
"for i=1:2\n",
"for j=1:2\n",
"k = b(i)| b(j);\n",
"disp(k)\n",
"end\n",
"end\n",
"//unary operation ' on the set of bits\n",
"k=~b\n",
"clear;\n",
"D=[1,2,5,7,10,14,35,70];\n",
"a=35;\n",
"b=70;\n",
"V=int32([a,b]);\n",
"thelcm=lcm(V) //a+b=lcm(a,b)\n",
"V=int32([a,b]) \n",
"thegcd=gcd(V) //a*b=gcd(a,b)\n",
"abar=70/a //a'=70/a"
]
}
,
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 15.2: Boolean_algebra_as_lattices.sci"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"D=[1,2,5,7,10,14,35,70];\n",
"a = 2; //a and b belong to D\n",
"b = 14;\n",
"V=int32([a,b]);\n",
"thelcm=lcm(V)\n",
"V=int32([a,b]);\n",
"thegcd=gcd(V)\n",
"abar=70/a\n",
"bbar=70/b\n",
"j=[abar,b];\n",
"h=[a,bbar];\n",
"V=int32([j])\n",
"lcm1=lcm(V)\n",
"K=int32([h])\n",
"lcm2=lcm(K)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Scilab",
"language": "scilab",
"name": "scilab"
},
"language_info": {
"file_extension": ".sce",
"help_links": [
{
"text": "MetaKernel Magics",
"url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
}
],
"mimetype": "text/x-octave",
"name": "scilab",
"version": "0.7.1"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
|