⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fig23_16.pl

📁 超多的prolog源代码 具体内容见压缩包里面的programs.txt
💻 PL
字号:
%  Figure 23.16  Translating a propositional calculus formula into
%  a set of (asserted) clauses.


%  Translating a propositional formula into (asserted) clauses

:-  op( 100, fy, ~).        % Negation
:-  op( 110, xfy, &).       % Conjunction
:-  op( 120, xfy, v).       % Disjunction
:-  op( 130, xfy, =>).      % Implication

% translate( Formula): translate propositional Formula
%   into clauses and assert each resulting clause C as clause( C)

translate( F & G)  :-                    % Translate conjunctive formula
  !,                                     % Red cut
  translate( F),
  translate( G).

translate( Formula)  :-
  transform( Formula, NewFormula),       % Transformation step on Formula
  !,                                     % Red cut
  translate( NewFormula).

translate( Formula)  :-                  % No more transformation possible
  assert( clause( Formula)).

% Transformation rules for propositional formulas

% transform( Formula1, Formula2)  if
%   Formula2 is equivalent to Formula1, but closer to clause form

transform( ~(~X), X).                      % Eliminate double negation

transform( X => Y, ~X v Y).                % Eliminate implication

transform( ~ (X & Y), ~X v ~Y).            % De Morgan's law

transform( ~ (X v Y), ~X & ~Y).            % De Morgan's law

transform( X & Y v Z, (X v Z) & (Y v Z)).  % Distribution

transform( X v Y & Z, (X v Y) & (X v Z)).  % Distribution

transform( X v Y, X1 v Y)  :-
  transform( X, X1).                       % Transform subexpression

transform( X v Y, X v Y1)  :-
  transform( Y, Y1).                       % Transform subexpression

transform( ~ X, ~ X1)  :-              
  transform( X, X1).                       % Transform subexpression

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -