Compare commits

..

40 Commits

Author SHA1 Message Date
3fa305ef0b Update README.md 2024-04-01 18:29:44 +00:00
cuqmbr
2b410b9834
Update main.yml 2023-08-26 09:36:42 +00:00
cuqmbr
baf12a639b
add github action to mirror repository to Gitea 2023-08-26 09:35:18 +00:00
cuqmbr
3c2d74900c
docs: delete LICENSE.md 2022-12-25 10:47:44 +02:00
cuqmbr
9982f09e9f
docs: add LICENSE 2022-12-25 10:47:30 +02:00
cuqmbr
4a2028e7d7
docs: update README.md 2022-08-08 22:55:01 +03:00
cuqmbr
cde4b0072a
Create LICENSE.md 2022-08-03 14:00:09 +03:00
cuqmbr
69317bf073
Delete LICENSE 2022-08-03 13:58:26 +03:00
cuqmbr
1d04dff09d
docs: update README.md 2022-07-17 22:13:15 +03:00
cuqmbr
bfaf51ff26
docs: update README.md 2022-06-26 15:46:53 +03:00
cuqmbr
fe68e4c947
docs: add GPLv3 License 2022-03-19 08:58:49 +02:00
cuqmbr
38a47a6051
Update README.md 2022-02-23 10:36:31 +02:00
cuqmbr
99121e545e
Delete CNAME 2022-02-22 13:10:35 +02:00
cuqmbr
14b4d5748d
Update CNAME 2022-02-22 12:45:55 +02:00
cuqmbr
77eef3cd8a
Create CNAME 2022-02-22 12:42:51 +02:00
cuqmbr
d79fb37de3
added README 2022-02-22 12:33:38 +02:00
Shchoholiev
15f9065561 Update style.css 2021-12-15 17:19:43 +02:00
Shchoholiev
2a55494ff2 Update style.css 2021-12-15 17:18:20 +02:00
cuqmbr
304ad7eb8c link fix 2021-12-13 23:26:19 +02:00
cuqmbr
a9fffb0ea6 Knowledgebase update, Info page 2021-12-13 23:14:40 +02:00
Shchoholiev
a120cfe19e knowledgebase template 2021-12-13 09:07:07 +02:00
cuqmbr
257586d553 knowledgebase, github page, minor tweaks 2021-12-10 21:54:28 +02:00
cuqmbr
a02373ea94 minor tweaks 2021-12-10 20:35:19 +02:00
Shchoholiev
37282c8239 put it all together 2021-12-10 20:19:45 +02:00
Shchoholiev
ddfae96195 Merge branch 'set-algebra' 2021-12-10 19:56:37 +02:00
Shchoholiev
6c29061c8b css merge 2021-12-10 18:59:38 +02:00
cuqmbr
1a49d79d1f result text-overflow fix 2021-12-10 17:02:26 +02:00
cuqmbr
134eaa612a result field text-overflow fix 2021-12-10 16:56:54 +02:00
cuqmbr
6120d9f23d
Merge pull request #2 from cuqmbr/boolean-algebra
merged Boolean-algebra with Master (logic fixes, UX improvements)
2021-12-10 16:12:35 +02:00
cuqmbr
8bd3dc78c5 Merge branch 'master' into boolean-algebra 2021-12-10 15:55:15 +02:00
cuqmbr
0f3596b2b2 logic fixes, UX improvements 2021-12-10 15:35:45 +02:00
cuqmbr
00c8014aeb copied master branch 2021-12-07 17:41:06 +02:00
cuqmbr
1cbe8f76c7 step-by-step mobile fix 2021-12-05 13:22:17 +02:00
cuqmbr
832f5c1c9b undefined values stop calculation of the formula 2021-12-04 20:41:50 +02:00
cuqmbr
68e7827221 added PDNF, PCNF; reworked TruthTable, Steps, Calc 2021-12-04 16:37:28 +02:00
cuqmbr
8b42387219 truth tables 2021-12-03 16:19:06 +02:00
Shchoholiev
fad7e9eb9a Merge branch 'set-algebra' 2021-12-03 10:27:47 +02:00
Shchoholiev
110610a365 changes 2021-12-02 14:41:39 +02:00
cuqmbr
13e80e857b commit 2021-12-02 13:56:11 +02:00
cuqmbr
41c75cd99a changes 2021-12-02 13:02:22 +02:00
16 changed files with 1860 additions and 13 deletions

14
.github/workflows/main.yml vendored Normal file
View File

@ -0,0 +1,14 @@
name: Mirror to Gitea
on: [push]
jobs:
mirror:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: yesolutions/mirror-action@master
with:
REMOTE: 'https://git.cuqmbr.xyz/cuqmbr/cdm-utils.git'
GIT_USERNAME: cuqmbr
GIT_PASSWORD: ${{ secrets.GIT_PASSWORD }}

BIN
Boolean-Algebra/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 613 B

160
Boolean-Algebra/index.html Normal file
View File

@ -0,0 +1,160 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/x-icon" href="favicon.png">
<title>Boolean Algebra Calculator</title>
<link rel="stylesheet" href="../style.css">
</head>
<body>
<div class="gradient"></div>
<div class="container" id="container">
<header>
<div class="content">
<h3><a href="../">CDM Utils</a></h3>
<div class="theme">
<h3><a href="../Set-Algebra/">Set Algebra</a></h3>
<h3><a href="" class="current">Boolean Algebra</a></h3>
<h3><a href="../Knowledgebase/">Knowledgebase</a></h3>
<h3><a href="../Info/">Info</a></h3>
</div>
</div>
</header>
<h1 class="title">Boolean Algebra Calculator</h1>
<div class="wrapper no-top-margin">
<div class="wrap-side">
<h1>Values</h1>
<div id="values">
<div class="input-wrap">
<h1 class="text">Value A = </h1>
<div class="input"><input type="value" id="value0" onkeydown="return checkInputValue(event.key, this.value, this.id)" placeholder="e.g. 0 or 1" /></div>
</div>
<div class="input-wrap">
<h1 class="text">Value B = </h1>
<div class="input"><input type="value" id="value1" onkeydown="return checkInputValue(event.key, this.value, this.id)" placeholder="e.g. 0 or 1" /></div>
</div>
</div>
<input class="addValue" type="button" value="Add Value" onclick="AddValue()" />
</div>
<div class="wrap-side">
<h1>Formulua</h1>
<h2><input type="problem" id="formula" onkeydown="return checkInputProblem(event.key, this.id)" placeholder="e.g. !A*(B+C)" /></h2>
<div class="buttons">
<input class="button" type="button" id="calculate" value="Evaluate" onclick="Evaluate()" />
<input class="button" type="button" id="calculate" value="Step by step" onclick="StepByStep()" />
</div>
<div class="buttons">
<input class="button" type="button" id="calculate" value="Build a Truth Table" onclick="BuildTruthTable()" />
</div>
<div class="buttons">
<input class="button" type="button" id="calculate" value="Make PDNF" onclick="BuildPDNF()" />
<input class="button" type="button" id="calculate" value="Make PCNF" onclick="BuildPCNF()" />
</div>
<div class="wrap-result">
<div class="input-wrap">
<h1 class="text">Result </h1>
<div class="input"><input type="result" id="result" readonly/></div>
</div>
</div>
<h6 class="description">Define variables then write the formula you need to solve</h6>
<h6 class="operations">
<div class="operation">
<div class="operation-bg"> !</div>
<h6>Negation</h6>
</div>
<div class="operation">
<div class="operation-bg"> *</div>
<h6>Conjunction</h6>
</div>
<div class="operation">
<div class="operation-bg"> +</div>
<h6>Disjunction</h6>
</div>
<div class="operation">
<div class="operation-bg"> ></div>
<h6>Implication</h6>
</div>
<div class="operation">
<div class="operation-bg"> =</div>
<h6>Equivalence</h6>
</div>
</h6>
</div>
</div>
<div class="wrapper hide close" id="stepsNode">
<img src="../img/cross-close-icon.png" class="close-button" onclick="ToggleSteps(false)">
<div class="step-by-step" id="stepsWrapper">
<h1>Step by step
<a href="../Knowledgebase#boolean-algebra" title="Learn more about Algebra of 2-valued Boolean functions"><img src="../img/question-mark.png" class="question-mark-button"></a>
</h1>
<div class="input-wrap" id="input-wrap">
<h1 class="text">1.</h1>
<div class="input"><input type="result" id="step1" readonly/></div>
</div>
</div>
</div>
<div class="wrapper hide close" id="truthTableNode">
<img src="../img/cross-close-icon.png" class="close-button" onclick="ToggleTruthTable(false)">
<div class="step-by-step" id="truthTableWrapper">
<h1>Truth Table
<a href="../Knowledgebase#boolean-functions" title="Learn more about Boolean functions"><img src="../img/question-mark.png" class="question-mark-button"></a>
</h1>
<div class="input-wrap" id="input-wrap">
<div class="input"><input type="table-start" id="step1" readonly/></div>
</div>
<div class="input-wrap" id="input-wrap">
<div class="input"><input type="table-mid" id="step1" readonly/></div>
</div>
<div class="input-wrap" id="input-wrap">
<div class="input"><input type="table-end" id="step1" readonly/></div>
</div>
</div>
</div>
<div class="wrapper hide close" id="pdnfNode">
<img src="../img/cross-close-icon.png" class="close-button" onclick="TogglePDNF(false)">
<div class="step-by-step" id="pdnfWrapper">
<h1>Perfect Disjunctive Normal Form
<a href="../Knowledgebase#PDNF" title="Learn more about Perfect Disjunctive Normal Form"><img src="../img/question-mark.png" class="question-mark-button"></a>
</h1>
<div class="input-wrap" id="input-wrap">
<div class="input"><input type="result" id="step1" readonly/></div>
</div>
</div>
</div>
<div class="wrapper hide close" id="pcnfNode">
<img src="../img/cross-close-icon.png" class="close-button" onclick="TogglePCNF(false)">
<div class="step-by-step" id="pcnfWrapper">
<h1>Perfect Conjunctive Normal Form
<a href="../Knowledgebase#PCNF" title="Learn more about Perfect Conjunctive Normal Form"><img src="../img/question-mark.png" class="question-mark-button"></a>
</h1>
<div class="input-wrap" id="input-wrap">
<div class="input"><input type="result" id="step1" readonly/></div>
</div>
</div>
</div>
</div>
<!-- -----------------------------------JS---------------------------- -->
<script src="script.js"></script>
</body>
</html>

862
Boolean-Algebra/script.js Normal file
View File

@ -0,0 +1,862 @@
//#region Basic Functionallity
let maxNumOfValues = 26;
let currNumOfValues = 2;
function AddValue() {
if (currNumOfValues < 26) {
let charNum = 65 + currNumOfValues;
currNumOfValues++;
let delBtn = document.querySelectorAll('#delBtn');
if (delBtn[delBtn.length - 1]) {
delBtn[delBtn.length - 1].style = "display: none;";
}
node = document.getElementById('values');
node.insertAdjacentHTML('beforeend', ` <div class="input-wrap">
<h1 class="text">Value &#${charNum} = </h1>
<div class="input"><input type="value" onkeydown="return checkInputValue(event.key, this.value, this.id)" id="value${currNumOfValues - 1}" placeholder="e.g. 0 or 1"/></div>
</div>`);
} else {
alert('You have reached a limint of available values');
}
}
let VALUES = new Set();
let userValues = new Array();
function FetchValues() {
userValues = new Array();
for (let i = 0; i < currNumOfValues; i++) {
let inputField = document.getElementById(`value${i}`);
let currCharStr = String.fromCharCode(65 + i);
if (inputField.value === '1' || inputField.value === 'true' || inputField.value === 'True' || inputField.value === 'TRUE' || inputField.value === 't' || inputField.value === 'T') {
VALUES.add(currCharStr);
userValues.push([currCharStr, true]);
} else if (inputField.value === '0' || inputField.value === 'false' || inputField.value === 'False' || inputField.value === 'FALSE' || inputField.value === 'f' || inputField.value === 'F') {
VALUES.add(currCharStr);
userValues.push([currCharStr, false]);
}
}
for (const iterator in VALUES) {
console.log(iterator, VALUES[iterator]);
}
}
// Evaluate given formula and display the result
function Evaluate() {
// ToggleAll(false);
FetchValues();
let formulaField = document.getElementById('formula');
let formulaChraArray = formulaField.value.split('');
let formulaRPNArray = ConvertToRPNArray(formulaChraArray);
let formulaValuesRPNArray = ConvertCharsToValues(formulaRPNArray);
let result = SolveRPNFormula(formulaValuesRPNArray);
if (result == undefined || formulaValuesRPNArray.some(x => alphabet.indexOf(x) != -1) || formulaValuesRPNArray.some(x => x == undefined)) {
formulaField.style.backgroundColor = 'rgba(255, 255, 255, 0)';
formulaField.style.backgroundColor = 'rgba(235, 52, 116, 0.7)';
formulaField.style.transition = '0.2s';
setTimeout(() => formulaField.style.backgroundColor = 'rgba(255, 255, 255, 0)', 600);
return;
}
let readableResult = ConvertToReadableResult(result);
let resultField = document.getElementById('result');
resultField.value = readableResult;
}
//#endregion
//#region Boolean Operations
function Negation(value) {
if (value != undefined) { return !value; }
}
function Conjunction(firstValue, secondValue) {
if (firstValue === true && secondValue === true) {
return true;
} else if (firstValue === false && secondValue === true || firstValue === true && secondValue === false || firstValue === false && secondValue === false) {
return false;
}
}
function Disjunction(firstValue, secondValue) {
if (firstValue === true || secondValue === true) {
return true;
} else if (firstValue === false && secondValue === false) {
return false;
}
}
function Equivalence(firstValue, secondValue) {
if (firstValue === secondValue) {
return true;
} else if (firstValue !== secondValue) {
return false;
}
}
//#endregion
//#region Essential Functions
function ConvertToRPNArray(chars) {
let _values_stack = new Array();
let _actions_stack = new Array();
for (let i = 0; i < chars.length; i++) {
const element = chars[i];
if (!OPERATORS.has(element) && !BRACKETS.has(element)) {
_values_stack.push(element);
} else if (OPERATORS.has(element)) {
while (GetActionPriority(_actions_stack[_actions_stack.length - 1]) >= GetActionPriority(element)) {
let last = _actions_stack.pop();
if (last != '(') {
_values_stack.push(last);
} else {
break;
}
}
if (_actions_stack[0] == undefined || GetActionPriority(_actions_stack[_actions_stack.length - 1]) < GetActionPriority(element)) {
_actions_stack.push(element);
}
} else if (BRACKETS.has(element)) {
if (element == '(') {
_actions_stack.push(element);
}
if (element == ')') {
let _last = _actions_stack.pop();
while (_last != '(') {
_values_stack.push(_last);
_last = _actions_stack.pop();
}
}
} else {
Error('The programm cant solve given formula. Do you typed everything right? Maybe you forgot to define some value?');
}
}
while (_actions_stack[0] != undefined) {
_values_stack.push(_actions_stack.pop());
}
return _values_stack;
}
function ConvertCharsToValues(RPNArray) {
let valuesRNPArray = new Array();
RPNArray.forEach(element => {
if (VALUES.has(element)) {
valuesRNPArray.push(GetValueFromIndex(element));
} else if (element !== '(' || element !== ')') {
valuesRNPArray.push(element);
}
});
return valuesRNPArray;
}
function SolveRPNFormula(valuesRPNArray) {
let stepByStepResults = new Array();
let _stack = new Array();
for (let i = 0; i < valuesRPNArray.length; i++) {
const element = valuesRPNArray[i];
if (OPERATORS.has(element)) {
if (element == '!') {
let _currValue = _stack.pop();
let _result = Negation(_currValue);
_stack.push(_result);
stepByStepResults.push(ConvertToReadableResult(_result));
} else if (element == '*') {
let _secondValue = _stack.pop();
let _firstValue = _stack.pop();
let _result = Conjunction(_firstValue, _secondValue);
_stack.push(_result);
stepByStepResults.push(ConvertToReadableResult(_result));
} else if (element == '+') {
let _secondValue = _stack.pop();
let _firstValue = _stack.pop();
let _result = Disjunction(_firstValue, _secondValue);
_stack.push(_result);
stepByStepResults.push(ConvertToReadableResult(_result));
} else if (element == '>') {
let _secondValue = _stack.pop();
let _firstValue = _stack.pop();
let _result = Disjunction(Negation(_firstValue), _secondValue);
_stack.push(_result);
stepByStepResults.push(ConvertToReadableResult(_result));
} else if (element == '=') {
let _secondValue = _stack.pop();
let _firstValue = _stack.pop();
let _result = Equivalence(_firstValue, _secondValue);
_stack.push(_result);
stepByStepResults.push(ConvertToReadableResult(_result));
}
} else {
_stack.push(element);
}
}
return _stack[0];
}
//#endregion
//#region Step By Step
// Evalutae formula and display steps in the interface
function StepByStep() {
FetchValues();
let formulaField = document.getElementById('formula');
let formulaChraArray = formulaField.value.split('');
let formulaRPNArray = ConvertToRPNArray(formulaChraArray);
let formulaValuesRPNArray = ConvertCharsToValues(formulaRPNArray);
let result = SolveRPNFormula(formulaValuesRPNArray);
if (result == undefined || formulaValuesRPNArray.some(x => alphabet.indexOf(x) != -1) || formulaValuesRPNArray.some(x => x == undefined)) {
formulaField.style.backgroundColor = 'rgba(255, 255, 255, 0)';
formulaField.style.backgroundColor = 'rgba(235, 52, 116, 0.7)';
formulaField.style.transition = '0.2s';
setTimeout(() => formulaField.style.backgroundColor = 'rgba(255, 255, 255, 0)', 600);
return;
}
let readableResult = ConvertToReadableResult(result);
let resultField = document.getElementById('result');
resultField.value = readableResult;
let stepsActionsArray = GetCharSteps(formulaRPNArray);
let stepsResultsArray = GetStepsResults(formulaValuesRPNArray);
// console.log(stepsActionsArray);
// console.log(stepsResultsArray);
if (stepsResultsArray.length > 0) {
ToggleSteps(true);
for (let i = 0; i < stepsActionsArray.length; i++) {
const action = stepsActionsArray[i];
const result = stepsResultsArray[i];
stepsWrapper.insertAdjacentHTML('beforeend', ` <div class="input-wrap" id="input-wrap">
<h1 class="text">${i+1}. </h1>
<div class="input"><input type="result" value="${action} = ${result}" readonly/></div>
</div>`);
}
}
stepsWrapper.scrollIntoView({ behavior: 'smooth', block: 'center' });
// Get steps in form of characters
function GetCharSteps(RPNArray) {
let stepsArray = new Array();
let _stack = new Array();
for (let i = 0; i < RPNArray.length; i++) {
const element = RPNArray[i];
if (OPERATORS.has(element)) {
if (element == '!') {
let _currValue = _stack.pop();
let _result;
if (_currValue.length <= 2) {
_result = '!'.concat(_currValue);
} else {
_result = '!'.concat('(').concat(_currValue).concat(')');
}
_stack.push(_result);
stepsArray.push([_result]);
} else if (element == '*') {
let _secondValue = _stack.pop();
let _firstValue = _stack.pop();
let _result;
let _firstHasExclemMark = Boolean(_firstValue.split('').filter(x => x === '!').length);
let _secondHasExclemMark = Boolean(_secondValue.split('').filter(x => x === '!').length);
if (_firstValue.length <= 2 && _secondValue.length <= 2) {
_result = _firstValue.concat('*').concat(_secondValue);
} else if (_firstValue.length <= 2 && _secondValue.length > 2) {
if (_secondHasExclemMark) {
_result = _firstValue.concat('*').concat(_secondValue);
} else {
_result =
_firstValue.concat('*').concat('(').concat(_secondValue).concat(')');
}
} else if (_firstValue.length > 2 && _secondValue.length <= 2) {
if (_firstHasExclemMark) {
_result = _firstValue.concat('*').concat(_secondValue);
} else {
_result = '('.concat(_firstValue).concat(')').concat('*').concat(_secondValue);
}
} else if (_firstValue.length > 2 && _secondValue.length > 2) {
if (_firstHasExclemMark && _secondHasExclemMark) {
_result = _firstValue.concat('*').concat(_secondValue);
}
if (_firstHasExclemMark && !_secondHasExclemMark) {
_result = _firstValue.concat('*').concat('(').concat(_secondValue).concat(')');
} else if (!_firstHasExclemMark && _secondHasExclemMark) {
_result = '('.concat(_firstValue).concat(')').concat('*').concat(_secondValue);;
} else {
_result = '('.concat(_firstValue).concat(')').concat('*').concat('(').concat(_secondValue).concat(')');
}
}
_stack.push(_result);
stepsArray.push([_result]);
} else if (element == '+') {
let _secondValue = _stack.pop();
let _firstValue = _stack.pop();
let _result = _firstValue.concat('+').concat(_secondValue);
_stack.push(_result);
stepsArray.push([_result]);
} else if (element == '>') {
let _secondValue = _stack.pop();
let _firstValue = _stack.pop();
let _result = _firstValue.concat('>').concat(_secondValue);
_stack.push(_result);
stepsArray.push([_result]);
} else if (element == '=') {
let _secondValue = _stack.pop();
let _firstValue = _stack.pop();
let _result = _firstValue.concat('=').concat(_secondValue);
_stack.push(_result);
stepsArray.push([_result]);
}
} else {
_stack.push(element);
}
}
return stepsArray;
// return _stack[0];
}
// Get a result of each step
function GetStepsResults(valuesRPNArray) {
let stepByStepResults = new Array();
let _stack = new Array();
for (let i = 0; i < valuesRPNArray.length; i++) {
const element = valuesRPNArray[i];
if (OPERATORS.has(element)) {
if (element == '!') {
let _currValue = _stack.pop();
let _result = Negation(_currValue);
_stack.push(_result);
stepByStepResults.push(ConvertToReadableResult(_result));
} else if (element == '*') {
let _secondValue = _stack.pop();
let _firstValue = _stack.pop();
let _result = Conjunction(_firstValue, _secondValue);
_stack.push(_result);
stepByStepResults.push(ConvertToReadableResult(_result));
} else if (element == '+') {
let _secondValue = _stack.pop();
let _firstValue = _stack.pop();
let _result = Disjunction(_firstValue, _secondValue);
_stack.push(_result);
stepByStepResults.push(ConvertToReadableResult(_result));
} else if (element == '>') {
let _secondValue = _stack.pop();
let _firstValue = _stack.pop();
let _result = Disjunction(Negation(_firstValue), _secondValue);
_stack.push(_result);
stepByStepResults.push(ConvertToReadableResult(_result));
} else if (element == '=') {
let _secondValue = _stack.pop();
let _firstValue = _stack.pop();
let _result = Equivalence(_firstValue, _secondValue);
_stack.push(_result);
stepByStepResults.push(ConvertToReadableResult(_result));
}
} else {
_stack.push(element);
}
}
return stepByStepResults;
}
}
//#endregion
//#region Truth Table
// Generate truth table and display it in the interface
function BuildTruthTable() {
let header = document.getElementById('formula').value.match(/[A-Z]/g).filter((c, i) => document.getElementById('formula').value.match(/[A-Z]/g).indexOf(c) == i);
let matrix = GenerateTruthTable();
DisplayTruthTable(matrix, header);
}
// Generate truth table
function GenerateTruthTable() {
let formulaField = document.getElementById('formula');
let numColumns = formulaField.value.match(/[A-Z]/g).filter((c, i) => document.getElementById('formula').value.match(/[A-Z]/g).indexOf(c) == i).length;
let numRows = Math.pow(2, numColumns);
// Initializing the truthTable
let truthTable = new Array();
for (let i = 0; i < numRows; i++) {
truthTable.push(new Array(numColumns + 1));
}
for (let c = 0; c < numColumns; c++) {
let period = Math.pow(2, numColumns) / Math.pow(2, c + 1);
let zeros = true;
for (let r = 0; r < numRows; r++) {
if (zeros) {
truthTable[r][c] = false;
}
if (!zeros) {
truthTable[r][c] = true;
}
if ((r + 1) % period == 0) {
zeros = !zeros;
}
}
}
//Evaluate the result for each row
for (let r = 0; r < truthTable.length; r++) {
truthTable[r][numColumns] = SolveRPNFormula(ConvertToRPNArray(formulaField.value.split('').map(x => x = ConvertCharsToValues(x, r))));
}
//Additional functions
function ConvertCharsToValues(index, row) {
return formulaField.value.match(/[A-Z]/g).filter((c, i) => document.getElementById('formula').value.match(/[A-Z]/g).indexOf(c) == i).indexOf(index) != -1 ? truthTable[row][formulaField.value.match(/[A-Z]/g).filter((c, i) => document.getElementById('formula').value.match(/[A-Z]/g).indexOf(c) == i).indexOf(index)] : index;
}
return truthTable;
}
// Display truth table in the interface
function DisplayTruthTable(matrix, header) {
//Display the truth table in the interface
ToggleTruthTable(true);
let truthTableWrapper = document.querySelector('#truthTableWrapper');
truthTableWrapper.insertAdjacentHTML('beforeend', ` <div class="input-wrap" id="input-wrap">
<h1 class="text"></h1>
<div class="input"><input type="table-start" value="${header.join(' ')} : Result" readonly/></div>
</div>`);
let type = 'table-start';
for (let r = 0; r < matrix.length; r++) {
if (r == matrix.length - 1) {
type = 'table-end';
} else if (type != 0) {
type = 'table-mid';
}
let result = matrix[r].pop();
truthTableWrapper.insertAdjacentHTML('beforeend', ` <div class="input-wrap" id="input-wrap">
<h1 class="text"></h1>
<div class="input"><input type="${type}" value="${matrix[r].map(x => x = ConvertToReadableResult(x)).join(' ')} : ${ConvertToReadableResult(result)}" readonly/></div>
</div>`);
}
truthTableWrapper.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
//#endregion
//#region PDNF & PCNF
function BuildPDNF() {
DisplayPDNF(GeneratePDNF());
}
function GeneratePDNF() {
let pdnf = '';
let mintermCount = 0;
let header = document.getElementById('formula').value.match(/[A-Z]/g).filter((c, i) => document.getElementById('formula').value.match(/[A-Z]/g).indexOf(c) == i);
let matrix = GenerateTruthTable();
for (let r = 0; r < matrix.length; r++) {
if (matrix[r][matrix[r].length - 1] == 1) {
pdnf += mintermCount != 0 ? '+(' : '(';
for (let c = 0; c < matrix[r].length - 1; c++) {
pdnf += matrix[r][c] == 0 ? '!' + header[c] : header[c];
pdnf += c != matrix[r].length - 2 ? '*' : '';
}
pdnf += ')';
mintermCount++;
}
}
return pdnf;
}
function DisplayPDNF(pdnf) {
TogglePDNF(true);
let Wrapper = document.querySelector('#pdnfWrapper');
Wrapper.insertAdjacentHTML('beforeend', ` <div class="input-wrap" id="input-wrap">
<h1 class="text"></h1>
<div class="input"><input type="result" value="${pdnf}" readonly/></div>
</div>`);
Wrapper.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
function BuildPCNF() {
DisplayPCNF(GeneratePCNF());
}
function GeneratePCNF() {
let pcnf = '';
let maxtermCount = 0;
let header = document.getElementById('formula').value.match(/[A-Z]/g).filter((c, i) => document.getElementById('formula').value.match(/[A-Z]/g).indexOf(c) == i);
let matrix = GenerateTruthTable();
for (let r = 0; r < matrix.length; r++) {
if (matrix[r][matrix[r].length - 1] == 0) {
pcnf += maxtermCount != 0 ? '*(' : '(';
for (let c = 0; c < matrix[r].length - 1; c++) {
pcnf += matrix[r][c] == 1 ? '!' + header[c] : header[c];
pcnf += c != matrix[r].length - 2 ? '+' : '';
}
pcnf += ')';
maxtermCount++;
}
}
return pcnf;
}
function DisplayPCNF(pcnf) {
TogglePCNF(true);
let Wrapper = document.querySelector('#pcnfWrapper');
Wrapper.insertAdjacentHTML('beforeend', ` <div class="input-wrap" id="input-wrap">
<h1 class="text"></h1>
<div class="input"><input type="result" value="${pcnf}" readonly/></div>
</div>`);
Wrapper.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
//#endregion
//#region Additional Functions (Essential too)
function ToggleSteps(show) {
let Node = document.querySelector('#stepsNode');
let Wrapper = document.querySelector('#stepsWrapper');
if (show) {
Node.classList.remove('hide');
Node.classList.remove('close');
Wrapper.querySelectorAll('#input-wrap').forEach((element) => {
element.remove();
});
} else {
Node.classList.add('close');
setTimeout(() => Node.classList.add('hide'), 600);
document.body.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
}
function ToggleTruthTable(show) {
let Node = document.querySelector('#truthTableNode');
let Wrapper = document.querySelector('#truthTableWrapper');
if (show) {
Node.classList.remove('hide');
Node.classList.remove('close');
Wrapper.querySelectorAll('#input-wrap').forEach((element) => {
element.remove();
});
} else {
Node.classList.add('close');
setTimeout(() => Node.classList.add('hide'), 600);
document.body.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
}
function TogglePDNF(show) {
let Node = document.querySelector('#pdnfNode');
let Wrapper = document.querySelector('#pdnfWrapper');
if (show) {
Node.classList.remove('hide');
Node.classList.remove('close');
Wrapper.querySelectorAll('#input-wrap').forEach((element) => {
element.remove();
});
} else {
Node.classList.add('close');
setTimeout(() => Node.classList.add('hide'), 600);
document.body.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
}
function TogglePCNF(show) {
let Node = document.querySelector('#pcnfNode');
let Wrapper = document.querySelector('#pcnfWrapper');
if (show) {
Node.classList.remove('hide');
Node.classList.remove('close');
Wrapper.querySelectorAll('#input-wrap').forEach((element) => {
element.remove();
});
} else {
Node.classList.add('close');
setTimeout(() => Node.classList.add('hide'), 600);
document.body.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
}
// function ToggleAll(show) {
// ToggleSteps(show);
// ToggleTruthTable(show);
// TogglePDNF(show);
// TogglePCNF(show);
// }
const OPERATORS = new Set(['!', '*', '+', '>', '=']);
const BRACKETS = new Set(['(', ')']);
function GetActionPriority(action) {
if (action == '!') {
return 5;
} else if (action == '*') {
return 4;
} else if (action == '+' || action == '>' || action == '=') {
return 3;
} else if (action == '(') {
return 2;
} else {
return 0;
}
}
function GetValueFromIndex(valueIndex) {
for (let i = 0; i < userValues.length; i++) {
const element = userValues[i];
if (element[0] == valueIndex) {
return element[1];
}
}
}
function ConvertToReadableResult(unconverted) {
return unconverted === true ? '1' : '0';
}
function Error(errMsg) {
console.log(` [ERROR] ${errMsg}`);
}
//#endregion
//#region Check Input
const symbols = ['0', '1'];
const specialSymbols = ['!', '*', '+', '=', '>', '(', ')', 'Backspace', 'ArrowLeft', 'ArrowRight', 'Delete', 'Shift'];
function checkInputValue(key, value, id) {
if (value.length < 1 && symbols.indexOf(key) !== -1) {
return true;
} else if (value.length == 1 && specialSymbols.indexOf(key) !== -1) {
return true;
} else {
function backBg() { document.getElementById(id).style.backgroundColor = 'rgba(255, 255, 255, 0)' }
document.getElementById(id).style.backgroundColor = 'rgba(235, 52, 116, 0.7)';
document.getElementById(id).style.transition = '0.2s';
setTimeout(backBg, 600);
return false;
}
}
function checkInputProblem(key, id) {
if (alphabet.indexOf(key) != -1 || specialSymbols.indexOf(key) != -1) {
return true;
} else {
function backBg() { document.getElementById(id).style.backgroundColor = 'rgba(255, 255, 255, 0)' }
document.getElementById(id).style.backgroundColor = 'rgba(235, 52, 116, 0.7)';
document.getElementById(id).style.transition = '0.2s';
setTimeout(backBg, 600);
return false;
}
}
const alphabet = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z'
];
//#endregion

BIN
Info/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 527 B

55
Info/index.html Normal file
View File

@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/x-icon" href="favicon.png">
<title>Info</title>
<link rel="stylesheet" href="../style.css">
</head>
<body>
<div class="gradient"></div>
<div class="container">
<header>
<div class="content">
<h3><a href="../">CDM Utils</a></h3>
<div class="theme">
<h3><a href="../Set-Algebra/">Set Algebra</a></h3>
<h3><a href="../Boolean-Algebra/">Boolean Algebra</a></h3>
<h3><a href="../Knowledgebase/">Knowledgebase</a></h3>
<h3><a class="current" href="">Info</a></h3>
</div>
</div>
</header>
<h1 class="title">Info page</h1>
<div class="wrapper no-top-margin knowledge">
<div class="knowledge-wrap">
<h1 class="knowledge-main-title" id="set-theory">About the project</h1>
<!-- <h1 class="knowledge-title"></h1> -->
<h6 class="knowledge-desc" style="text-align: center;"> This web application is made by two freshmens as a firs semester project at a Kharkov National Uneversity of Radio Electronics </h6>
<h6 class="knowledge-desc" style="text-align: center;"> </h6>
<h1 class="knowledge-main-title" id="set-theory">Source code</h1>
<h6 class="knowledge-desc" style="text-align: center;"> All source code is available at <a href="https://github.com/cuqmbr/cdm-utils" target="_blank">this</a> GitHub page </h6>
<h6 class="knowledge-desc" style="text-align: center;"> </h6>
<h1 class="knowledge-main-title" id="set-theory">Credits</h1>
<h6 class="knowledge-desc" style="text-align: center;"> Designed by <a href="http://shchoholev.zzz.com.ua/" target="_blank">Serhii Shchoholev</a>, programmed by <a href="https://www.cuqmbr.pp.ua/" target="_blank">cuqmbr</a> </h6>
<h6 class="knowledge-desc" style="text-align: center;"> To be honest, we all did a little bit of everything ;) </h6>
</div>
</div>
</body>
</html>

BIN
Knowledgebase/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 527 B

295
Knowledgebase/index.html Normal file
View File

@ -0,0 +1,295 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Knowledgebase</title>
<link rel="icon" type="image/x-icon" href="favicon.png">
<link rel="stylesheet" href="../style.css">
</head>
<body>
<div class="gradient"></div>
<div class="container">
<header>
<div class="content">
<h3><a href="../">CDM Utils</a></h3>
<div class="theme">
<h3><a href="../Set-Algebra/">Set Algebra</a></h3>
<h3><a href="../Boolean-Algebra/">Boolean Algebra</a></h3>
<h3><a class="current" href="">Knowledgebase</a></h3>
<h3><a href="../Info">Info</a></h3>
</div>
</div>
</header>
<h1 class="title">Knowledgebase</h1>
<div class="wrapper no-top-margin knowledge">
<div class="knowledge-wrap">
<!-- Set Theory -->
<h1 class="knowledge-main-title" id="set-theory">Set Theory</h1>
<h1 class="knowledge-title">Basic concepts</h1>
<h6 class="knowledge-desc"> &emsp; The notion of a set is one of the initial notions of mathematics that cannot be defined quite formally. Synonyms of the term “set” are: a collection, a group, a class, etc. Approximately, one may say that a set is a collection of objects or ideas called elements of the set. </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; Sets are usually denoted by Latin capital letters and their elements by corresponding small letters: </h6>
<h6 class="knowledge-desc"> &emsp; A = {a, b, c, d}, B = {b, d}, C = {a, b, c, d}. </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; If set B contains only elements that belong to set A then B is said to be a <strong class="strong"> subset </strong> of A: </h6>
<h6 class="knowledge-desc"> &emsp; B ⊂ A (proper subset, not all elements of A are in B), C ⊆ A (C may have all elements of A or may not). </h6>
<h6 class="knowledge-desc"> &emsp; For any set A the following is true: Ø ⊆ A, A ⊆ A. </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; Two sets A and B are <strong class="strong"> equal </strong> (denoted by A = B) if they consist of the same elements. This is equivalent to the condition that, for arbitrary x, if it is contained in A then it follows that x is in set B as well, and vice versa. </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; The number of elements in a set A is called the <strong class="strong"> cardinality </strong> of A and is denoted |A|. If A = {a, b, c, d} then |A|= 4. </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; Set P(A) is a <strong class="strong"> power </strong> set of A. P(A) contains all possible subsets of set A. </h6>
<h6 class="knowledge-desc"> &emsp; Ex.: A = {a, b}. P(A) = {Ø, {a}, {b}, {a, b}}. Elements of a power set are sets themselves. </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; Sets A and B (finite or infinite) are called <strong class="strong"> equivalent </strong> (A ≈ B) if they have the same cardinality. </h6>
<h6 class="knowledge-desc"> &emsp; Ex.: A = {1, 7, 10, 15}, B = {a, b, c, d}. |A| = |B| ⇨ A ≈ B. </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h1 class="knowledge-title">Operations on sets</h1>
<h6 class="knowledge-desc"> &emsp; <strong class="strong"> Union </strong> of sets A and B is a set C that contains only elements belonging to A or B. </h6>
<h6 class="knowledge-desc"> &emsp; C = A B. A B = {x | x ∈ A or x ∈ B or both}. </h6>
<h6 class="knowledge-desc"> &emsp; Ex.: A = {a, b}, B = {b, c, d}. C = A B = {a, b} {b, c, d} = {a, b, c, d}. </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; <strong class="strong"> Intersection </strong> of sets A and B is a set C which contains elements that belong both to A and B. </h6>
<h6 class="knowledge-desc"> &emsp; C = A ∩ B. C = A ∩ B. C = {x | x ∈ A and x ∈ B}. </h6>
<h6 class="knowledge-desc"> &emsp; Ex.: A = {a, b, c, d}, B = {b, d, f, h}. C = A ∩ B = {a, b, c, d} ∩ {b, d, f, h} = {b, d}. </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; <strong class="strong"> Compliment </strong> of a set A is a set B that contains all the elements of the universal set that does not belong to A. </h6>
<h6 class="knowledge-desc"> &emsp; C = <strong class="overline">A</strong>. C = {x | x ∈ U and x ∉ A}. </h6>
<h6 class="knowledge-desc"> &emsp; Ex.: U = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, A = {0, 2, 4, 6, 8}. C = <strong class="overline">A</strong> = {1, 3, 5, 7, 9}. </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; <strong class="strong"> Difference </strong> of sets A and B is a set C that consists of the elements that belong to A and dont belong to B. </h6>
<h6 class="knowledge-desc"> &emsp; C = A B. C = {x │ x A ∈ and x ∉ B}. </h6>
<h6 class="knowledge-desc"> &emsp; Ex.: A = {0, 1, 2, 3, 4}, B = {0, 2, 4, 6}. C = A - B = {0, 1, 2, 3, 4} - {0, 2, 4, 6} = {1, 3}. </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<!-- Set albebra -->
<h1 class="knowledge-main-title" id="set-algebra">Algebra Of Sets</h1>
<h1 class="knowledge-title">Algebra of sets</h1>
<h6 class="knowledge-desc"> &emsp; <strong class="strong"> Definition: </strong> Set algebra is a set of all subsets of U plus {, /, ‾ }. </h6>
<h6 class="knowledge-desc"> &emsp; An algebra is a set of elements of an arbitrary nature together with a number of operations defined on the elements of the given set. The nature of the set elements, the number and the properties of the operations determine the specific type of an algebra.</h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h1 class="knowledge-title"> Laws of algebra of sets: </h6>
<h6 class="knowledge-desc"> &emsp; In our application there is no functionality for simplifying equations, but for manual calculations the following laws will be very useful </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; 1. Laws of simplification: </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;a) A A = A; </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;b) A ∩ A = A; </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; 2. Commutative laws: </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;a) A B = B A; </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;b) A ∩ B = B ∩ A; </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; 3. Associative laws: </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;a) A (B C) = (A B) C; </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;b) A ∩ (B ∩ C) = (A ∩ B) ∩ C; </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; 4. Distributive laws: </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;a) A ∩ (B C) = (A ∩ B) (A ∩ C); </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;b) A (B ∩ C) = (A B) ∩ (A C) </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; 5. Elimination laws: </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;a) A (A ∩ B) = A; </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;b) A ∩ (A B) = A; </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; 6. Laws for constants: </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;a) A U = U; A ∩ Ø = Ø; </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;b) A Ø = A; A ∩ U = A; </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; 7. The law of double complement: </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;A̿ = A; </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; 8. The law of the excluded middle: </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;A <strong class="overline">A</strong> = U; </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; 9. The law of contradiction: </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;A ∩ <strong class="overline">A</strong> = Ø; </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; 10. De Morgan's laws: </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;a) <strong class="overline">(A B)</strong> = <strong class="overline">A</strong><strong class="overline">B</strong>; </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;a) <strong class="overline">(A ∩ B)</strong> = <strong class="overline">A</strong> <strong class="overline">B</strong>; </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; All these variables A, B, C, ... represent not just individual sets but arbitrary formulas of the algebra of sets. All these laws can be used for equivalent transformations of the formulas of the set algebra usually in order to simplify them. </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; <strong class="strong"> Example: </strong> simplify the formula. </h6>
<h6 class="knowledge-desc"> &emsp; A B ∩ <strong class="overline">(A ∩ B)</strong> = A B ∩ (<strong class="overline">A</strong> <strong class="overline">B</strong>) = A (B ∩ <strong class="overline">A</strong> B ∩ <strong class="overline">B</strong>) = A (B ∩ <strong class="overline">A</strong>) = (A B) ∩ (A <strong class="overline">A</strong>) = A B </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<!-- Boolean functions -->
<h1 class="knowledge-main-title" id="boolean-functions">Boolean Functions</h1>
<h1 class="knowledge-title">Boolean functions</h1>
<h6 class="knowledge-desc"> &emsp; A function y = f(x<sub>1</sub>, x<sub>2</sub>, ..., x<sub>n</sub>) where y, x<sub>1</sub>, x<sub>2</sub>, ..., x<sub>n</sub> ∈ {0;1} is called an n-place Boolean function. Any Boolean function can be presented by a formula (an expression consisting of Boolean functions and their compositions).</h6>
<h6 class="knowledge-desc"> &emsp; It is possible to construct a truth table for a boolean function by its number and the number of arguments n. </h6>
<div class="step-by-step" style="margin-top: 0px; margin-bottom: 0px;">
<h1 class="knowledge-title" style="margin-bottom: 0px;"> &emsp; Ex.: Truth Tabel for: f(x<sub>1</sub>, x<sub>2</sub>) = x<sub>1</sub> ^ x<sub>2</sub> </h1>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-start" value="x₁ x₂ : f(x₁, x₂)" readonly/></div>
</div>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-mid" value="0 0 : 0" readonly/></div>
</div>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-mid" value="0 1 : 0" readonly/></div>
</div>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-mid" value="1 0 : 0" readonly/></div>
</div>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-end" value="1 1 : 1" readonly/></div>
</div>
</div>
<h6 class="knowledge-desc"> &emsp; </h6>
<!-- Algebra of 2-valued Boolean functions -->
<h1 class="knowledge-main-title" id="boolean-algebra">Algebra of 2-valued Boolean functions</h1>
<h1 class="knowledge-title">Algebra of 2-valued Boolean functions</h1>
<h6 class="knowledge-desc"> &emsp; Reminder: 2-element Boolean algebra = {0,1} + {^, , ‾ }. </h6>
<h6 class="knowledge-desc"> &emsp; Priority of Boolean functions in formulas: ( ), ‾, ^, . </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h1 class="knowledge-title"> Laws of 2-element Boolean algebra: </h6>
<h6 class="knowledge-desc"> &emsp; In our application there is no functionality for simplifying equations, but for manual calculations the following laws will be very useful </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; 1. Commutative laws: </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;a) a b = b b; </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;b) a ^ b = a ^ b; </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; 2. Associative laws: </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;a) a (b c) = (a b) c; </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;b) a ^ (b ^ c) = (a ^ b) ^ c; </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; 3. Distributive laws: </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;a) a (b c) = (a b) ^ (a c) </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;b) a ^ (b c) = a ^ b a ^ c; </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; 4. Elimination laws: </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;a) a a ^ b = a; </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;b) a ^ (a b) = a; </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; 5. Laws for constants: </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;a) a 0 = a; a 1 = 1; </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;b) a ^ 0 = 0; a ^ 1 = a; </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; 6. Double negation law: </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;a̿ = a; </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; 7. Idempotent laws: </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;a) a a = a; </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;a) a ^ a = a; </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; 8. Negations laws: </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;a) a <strong class="overline"> a </strong> = 1 (excluded middle); </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;a) a ^ <strong class="overline"> a </strong> = 0; </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; 9. De Morgans laws: </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;a) <strong class="overline">(a b)</strong> = <strong class="overline">a</strong> ^ <strong class="overline">b</strong>; </h6>
<h6 class="knowledge-desc"> &emsp; &nbsp;&nbsp;&nbsp;&nbsp;a) <strong class="overline">(a ^ b)</strong> = <strong class="overline">a</strong> <strong class="overline">b</strong>; </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h1 class="knowledge-title" id="PDNF">Perfect Disjunctive Normal Form (PDNF)</h1>
<h6 class="knowledge-desc"> &emsp; <strong class="strong"> Definition: </strong> A formula of a Boolean function which is a disjunction of its minterms is called its <strong class="strong"> Perfect Disjunctive Normal Form (PDNF)</strong>. In technical papers such a formula is called a <strong class="strong"> Complete Sum of Products Form (CSPF)</strong>. </h6>
<h6 class="knowledge-desc"> &emsp; <strong class="strong"> Minterm </strong> is a product of all the literals (with or without complement). </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; Building a formula by a truth table. A method based on 1-values of a Boolean function (Method for building PDNF): </h6>
<div class="step-by-step" style="margin-top: 0px; margin-bottom: 15px;">
<h1 class="knowledge-title" style="margin-bottom: 0px;"> &emsp; Given: a 2-values Boolean function: </h1>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-start" value="x y z : f(x, y, z)" readonly/></div>
</div>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-mid" value="0 0 0 0" readonly/></div>
</div>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-mid" value="0 0 1 1̲ ⟶ x̅ ^ y̅ ^ z̅ = 1 - minterm" readonly/></div>
</div>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-mid" value="0 1 0 0" readonly/></div>
</div>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-mid" value="0 1 1 1̲ ⟶ x̅ ^ y ^ z = 1 - minterm" readonly/></div>
</div>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-mid" value="1 0 0 1̲ ⟶ x̅ ^ y̅ ^ z = 1 - minterm" readonly/></div>
</div>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-mid" value="1 0 1 0" readonly/></div>
</div>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-mid" value="1 1 0 0" readonly/></div>
</div>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-end" value="1 1 1 0" readonly/></div>
</div>
</div>
<h6 class="knowledge-desc"> &emsp; x̅^y̅^z̅ x̅^y^z x̅^y̅^z = x̅y̅z̅ x̅yz x̅y̅z - PDNF </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h1 class="knowledge-title" id="PCNF">Perfect Conjunctive Normal Form (PCNF)</h1>
<h6 class="knowledge-desc"> &emsp; <strong class="strong"> Definition: </strong> A formula which is a conjunction of maxterms is called the <strong class="strong"> Perfect Conjunctive Normal Form (PCNF)</strong>. or, more frequently, <strong class="strong"> Complete Product-of-Sums Form (CPSF)</strong>. </h6>
<h6 class="knowledge-desc"> &emsp; <strong class="strong"> Maxterm </strong> is a product of all the literals (with or without complement). </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
<h6 class="knowledge-desc"> &emsp; Building a formula by a truth table. A method based on 1-values of a Boolean function (Method for building PCNF): </h6>
<div class="step-by-step" style="margin-top: 0px; margin-bottom: 15px;">
<h1 class="knowledge-title" style="margin-bottom: 0px;"> &emsp; Given: a 2-values Boolean function: </h1>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-start" value="x y z : f(x, y, z)" readonly/></div>
</div>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-mid" value="0 0 0 0̲ ⟶ x y z = 0 - maxterm" readonly/></div>
</div>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-mid" value="0 0 1 1" readonly/></div>
</div>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-mid" value="0 1 0 0̲ ⟶ x z = 0 - maxterm" readonly/></div>
</div>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-mid" value="0 1 1 1" readonly/></div>
</div>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-mid" value="1 0 0 1" readonly/></div>
</div>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-mid" value="1 0 1 0̲ ⟶ x̅ y z̅ = 0 - maxterm" readonly/></div>
</div>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-mid" value="1 1 0 0̲ ⟶ x̅ z = 0 - maxterm" readonly/></div>
</div>
<div class="input-wrap" style="width: 88%;">
<div class="input"><input type="table-end" value="1 1 1 0̲ ⟶ x̅ z̅ = 0 - maxterm" readonly/></div>
</div>
</div>
<h6 class="knowledge-desc"> &emsp; (xyz) ^ (xz) ^ (x̅yz̅) ^ (x̅z) ^ (x̅z̅) - PCNF </h6>
<h6 class="knowledge-desc"> &emsp; </h6>
</div>
</div>
</body>
</html>

339
LICENSE Normal file
View File

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

42
README.md Normal file
View File

@ -0,0 +1,42 @@
# cdm-utils Discrete Math web calculator
Available feature:
- Set calculus
- Boolean calculus including truth tables, PDNF and PCNF
- Setp by step calculus
<!--
## Project preview
<div style="display: flex;">
<img src="http://drive.google.com/uc?export=view&id=1tAZcarKvcVKFw90B3eLnDJpCp0zTzX4-" alt="Boolean algebra calculator page" width="480" height="233" border="10" />
</div>
Checkout github-pages deployment [here](https://cuqmbr.github.io/cdm-utils/)
-->
## How to install?
1. Clone this project
2. Done. These are pure html pages :)
## How to contribute?
If you want to add a feature, you should follow these steps:
1. Fork the project
2. Make some changes and commit them with [conventional commit message](https://www.freecodecamp.org/news/how-to-write-better-git-commit-messages/)
3. Submit a PR with a new feature/code
## Find a bug?
If you found an issue or would like to submit an improvement to this project, please submit an issue using the issues tab above. If you would like to submit a PR with a fix, reference the issue you created!
## Development status
Released Project is complete
## Authors' thought
- cuqmbr: it was my first collab, it helped me to get a few additional points to scholarship ranking :)

View File

@ -20,10 +20,12 @@
<header>
<div class="content">
<h3><a href="../index.html">CDM</a></h3>
<h3><a href="../">CDM Utils</a></h3>
<div class="theme">
<h3><a href="" class="current">Set Algebra</a></h3>
<h3><a href="../Boolean-Algebra/index.html">Boolean Algebra</a></h3>
<h3><a href="../Boolean-Algebra/">Boolean Algebra</a></h3>
<h3><a href="../Knowledgebase/">Knowledgebase</a></h3>
<h3><a href="../Info">Info</a></h3>
</div>
</div>
</header>
@ -83,6 +85,7 @@
</div>
<div class="wrapper hide" id="stepByStep">
<img src="../img/cross-close-icon.png" class="close-button" onclick="Close()">
<div class="step-by-step" id="steps">
<h1>Step by step</h1>
</div>

View File

@ -133,6 +133,7 @@ function Evaluate(hide = false) {
FetchSets();
let formulaString = document.getElementById('formula').value;
if (formulaString.length < 1) return;
let charArray = formulaString.split('');
let RPN_Array = ConvertFormulaCharArrayToRPN(charArray);
@ -335,8 +336,10 @@ function stepByStep() {
clear.remove();
step = 0;
stepByStep.classList.remove('hide');
stepByStep.classList.remove('close');
stepByStep.insertAdjacentHTML('beforeend', ` <div class="step-by-step" id="steps">
<h1>Step by step</h1>
<h1>Step by step
<a href="../Knowledgebase#set-algebra" title="Learn more about algebra of sets"><img src="../img/question-mark.png" class="question-mark-button"></a></h1>
</div>`);
Evaluate();
@ -398,3 +401,11 @@ function setToString(set) {
}
return '{ ' + str.slice(2, str.length) + ' }';
}
function Close() {
let wrapper = document.getElementById("stepByStep")
wrapper.classList.add('close');
setTimeout(() => wrapper.classList.add('hide'), 600);
document.body.scrollIntoView({ behavior: 'smooth', block: 'start' });
}

BIN
img/cross-close-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
img/question-mark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

@ -6,7 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/x-icon" href="img/favicon.png">
<title>CDM Calculator</title>
<title>CDM Utils</title>
<link rel="stylesheet" href="style.css">
@ -14,14 +14,18 @@
<body>
<div class="gradient"></div>
<div class="container">
<header>
<div class="content">
<h3><a href="">CDM</a></h3>
<h3><a href="" class="current">CDM Utils</a></h3>
<div class="theme">
<h3><a href="Set-Algebra/index.html">Set Algebra</a></h3>
<h3><a href="Boolean-Algebra/index.html">Boolean Algebra</a></h3>
<h3><a href="Set-Algebra/">Set Algebra</a></h3>
<h3><a href="Boolean-Algebra/">Boolean Algebra</a></h3>
<h3><a href="Knowledgebase/">Knowledgebase</a></h3>
<h3><a href="Info">Info</a></h3>
</div>
</div>

View File

@ -120,6 +120,9 @@ h6 {
h3 {
letter-spacing: 0.5px;
text-align: center;
display: grid;
align-self: center;
}
h2 {
@ -182,6 +185,7 @@ body {
border-radius: 12px;
filter: drop-shadow(0px 10px 20px rgba(0, 0, 0, 0.3));
padding: 0px 20px;
transition: 0.5s;
}
.wrap-side {
@ -225,7 +229,7 @@ input[type=value] {
width: 100%;
height: 44px;
background: none;
border: 3px solid rgba(255, 255, 255, 0.2);
border: 3px solid rgba(255, 255, 255, 0.5);
border-radius: 8px;
font-size: 18px;
font-family: Myriad-R;
@ -238,7 +242,7 @@ input[type=problem] {
width: 100%;
height: 44px;
background: none;
border: 3px solid rgba(255, 255, 255, 0.2);
border: 3px solid rgba(255, 255, 255, 0.5);
border-radius: 8px;
font-size: 18px;
color: #fff;
@ -375,6 +379,7 @@ input[type=table-end] {
.hide {
display: none;
transition: 0.5s;
}
.close {
@ -388,14 +393,26 @@ input[type=table-end] {
transform: translate(0, -3px);
margin: 25px 5px 0px 0px;
cursor: pointer;
width: 12px;
height: 12px;
opacity: 75%;
width: 20px;
height: 20px;
opacity: 85%;
transition: 0.5s;
}
.close-button:hover {
opacity: 95%;
opacity: 100%;
transition: 0.5s;
}
.question-mark-button {
width: 20px;
margin: -1px 10px 0px 10px;
opacity: 85%;
transition: 0.5s;
}
.question-mark-button:hover {
opacity: 100%;
transition: 0.5s;
}
@ -463,6 +480,41 @@ input[type=table-end] {
max-width: 22px;
}
/* ------------------Knowledgebase-------------- */
.knowledge {
flex-direction: column;
}
.knowledge-wrap {
width: 95%;
margin: 20px auto;
display: flex;
flex-direction: column;
}
.knowledge-main-title {
margin: 15px auto;
}
.knowledge-title {
text-align: left;
margin: 5px 0;
}
.knowledge-desc {
text-align: justify;
}
.strong {
color: white;
}
.overline {
text-decoration: overline;
}
@media screen and (max-device-width: 650px) and (min-device-width: 0px) {
.wrapper {
flex-direction: column;
@ -483,4 +535,14 @@ input[type=table-end] {
width: auto;
text-align: center;
}
.knowledge-wrap {
width: 80%;
}
h3 {
font-size: 14px;
}
.theme a {
margin-left: 15px;
font-size: 14px;
}
}