{ "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 }