输入:命题公式的合式公式
输出:公式的主析取范式和主析取范式,输出形式为:“ mi ∨ mj ; Mi ∧ Mj” ,极小项和 ∨ 符号之间有一个空格,极大项和 ∧ 符号之间有一个空格;主析取范式和主合取范式之间用“ ; ”隔开,“ ; ”前后各有一个空格。 永真式的主合取范式为 1 ,永假式的主析取范式为 0 。
输入公式的符号说明:
! 非,相当于书面符号中的 “ ¬ ”
& 与,相当于书面符号中的 “ ∧ ”
| 或,相当于书面符号中的 “ ∨ ”
- 蕴含联结词,相当于书面符号中的 “ → ”
+ 等价联结词,相当于书面符号中的 “ ↔ ”
( 前括号
) 后括号
A-Z + is OR * is AND _ is → # is⊕(圆圈里加个bai+) @ is ⊙
$ is ↑ 命题的"与非" 运算du( "与非门zhi" )
% is ↓ 命题的"或非"运算( "或非门" )
Input the source formula:
A*!S+R
NORMALc: (!A*!B*!R)+(A*!B*!R)+(!A*B*!R)+(A*B*!R)+(!A*!B*R)+(!A*B*R)+(A*B*R)
NORMALd (!A+B+!R)
Error!
Input the source formula:
A#B
Here!
4countTerms
NORMALc: (A*!B)+(!A*B)
NORMALd (A+B)*(!A+!B)
Error!
Input the source formula:
stack<char> stk;
bool isVar(char ch)const;
void addMin(int minterm);
void addMax(int maxterm);
bool compute(int minterm);
void getInversePoland();
int countTerms(int n);
void assign(int minterm);
stack<bool> boolStk;
public:
formulaBase();
formulaBase(const formulaBase& rhs);
~formulaBase();
void getSource();
cout<<"Invalid input !"
"Operate again:"<<endl;
cin>>sourceFormula;*/
}
void formulaBase::getInversePoland()
{
char temp,temp1;
for(int i=0;sourceFormula[i]!='\0';i++)
stk.pop();
}
else break;
}
stk.push(temp);
break;
case '*':
while (!stk.empty())
//从键盘上任bai意输入一个主析取范式du,输出与之等值的zhi主合取范式。┐∧∨
# include <iostream>
# include <cmath>
# include <windows.h>
using namespace std ;
扩展资料:
(1)命题变项是命题公式。
(2)如果A是命题公式,则¬A是命题公式。
(3)如果A和B是命题公式,那么(A∧B)、(A∨B)、(A→B)和(A↔B)都是命题公式。
(4)当且仅当有限次地应用(1),(2),(3)所得到的包含命题变项,联结词和圆括号的符号串是命题公式。
命题公式的定义是一个递归定义形式。命题公式本身不是命题,没有真值,只有对其命题变项进行赋值后,它才有真值。
5个联结词运算儿有不同的优先级。当它们同时出现在一个命题公式里时,联结间运算的优先次序为、∧、∨、→、,如果有括号,则括号内的运算优先进行。
参考资料来源:百度百科-命题公式