Hello, I reproduce here Isabelle Newbie’s program, with minor changes that allow a first improvement of the output:
% :- use_module(library(clpb)).
% :- use_module(library(check)).
% :- set_prolog_flag(stack_limit, 2_147_483_648).
:- op( 300, fy, ~). % negation
:- op(400, xfy, &). % conjunction
:- op(500, xfy, v). % disjunction
:- op(600, xfy, =>). % conditional
:- op(700, xfy, <=>). % biconditional
formula_simpler(~ ~ P , P).
formula_simpler(~ ⊥, ⊤).
formula_simpler(~ ⊤, ⊥).
formula_simpler(_P & ⊥, ⊥).
formula_simpler(⊥ & _P, ⊥).
formula_simpler(P & ⊤, P).
formula_simpler(⊤ & P, P).
formula_simpler(P v ⊥, P).
formula_simpler(⊥ v P, P).
formula_simpler(_P v ⊤, ⊤).
formula_simpler(⊤ v _P, ⊤).
formula_simpler(P => ⊥, ~ P).
formula_simpler(_P => ⊤, ⊤).
formula_simpler(⊥ => _P, ⊤).
formula_simpler(⊤ => P, P).
formula_simpler(P <=> ⊥, ~ P).
formula_simpler(⊥ <=> P, ~ P).
formula_simpler(P <=> ⊤, P).
formula_simpler(⊤ <=> P, P).
formula_simpler(P <=> P, ⊤).
formula_simple2(Formula, Simple) :-
Formula =.. [Operator | Args],
maplist(formula_simple2, Args, SimpleArgs),
SimplerFormula =.. [Operator | SimpleArgs],
formula_rootsimple(SimplerFormula, Simple).
formula_rootsimple(Formula, Simple) :-
( formula_simpler(Formula, Simpler)
-> formula_rootsimple(Simpler, Simple)
; Simple = Formula ).
formula_variable(Variable, Variable) :-
atom(Variable),
dif(Variable, ⊤),!,
atom(Variable),
dif(Variable, ⊥).
formula_variable(Formula, Variable) :-
Formula =.. [_Operator | Args],
member(Arg, Args),
formula_variable(Arg, Variable),!.
variable_replacement_formula_replaced(Variable, Replacement, Variable, Replacement).
variable_replacement_formula_replaced(Variable, _Replacement, Formula, Formula) :-
atom(Formula),
dif(Formula, Variable).
variable_replacement_formula_replaced(Variable, Replacement, Formula, Replaced) :-
Formula =.. [Operator | Args],
Args = [_ | _],
maplist(variable_replacement_formula_replaced(Variable, Replacement), Args, ReplacedArgs),
Replaced =.. [Operator | ReplacedArgs].
quine(Formula) :-
formula_simple2(Formula, ⊤),
write(⊤),!.
quine(Formula) :-
formula_simple2(Formula, SimpleFormula),
formula_variable(SimpleFormula, Variable),
!,
variable_replacement_formula_replaced(Variable, ⊤, Formula, TopFormula),nl,
write('Let us replace '),write(Variable),write(' by ⊤ :'),nl,
write(TopFormula),nl,
quine(TopFormula),
variable_replacement_formula_replaced(Variable, ⊥, Formula, BotFormula),
nl,nl,write('Let us replace '),write(Variable),write(' by ⊥ :'),nl,
write(BotFormula),nl,
quine(BotFormula).
Example of output:
?- quine(((p v q) => r) <=> ((p => r) & (q => r))).
Let us replace p by ⊤ :
⊤v q=>r<=>(⊤ => r)&(q=>r)
Let us replace r by ⊤ :
⊤v q=> ⊤ <=> (⊤ => ⊤)&(q=> ⊤)
⊤
Let us replace r by ⊥ :
⊤v q=> ⊥ <=> (⊤ => ⊥)&(q=> ⊥)
⊤
Let us replace p by ⊥ :
⊥v q=>r<=>(⊥ => r)&(q=>r)
⊤
true
Comment:
It is not still an exact translation of Quine’s algorithm, because it should have been this one:
?- quine(((p v q) => r) <=> ((p => r) & (q => r))).
Let us replace p by ⊤ :
⊤v q=>r<=>(⊤ => r)&(q=>r)
(T => r) <=> r & (q => r)
r <=> r & (q => r) % Note: neither ⊥ nor T in the reduced formula
% therefore, new assignment in a new double
% table as follows:
Let us replace r by ⊤ :
⊤ <=> T &(q=> ⊤)
⊤ <=> T & T
T <=> T
T
Let us replace r by ⊥ :
r <=> r & (q => r)
⊥ <=> ⊥ & (q => ⊥)
⊥ <=> ⊥
T
Let us replace p by ⊥ :
⊥v q=>r<=>(⊥ => r)&(q=>r)
(q => r) <=> T & (q => r)
(q => r) <=> (q => r)
T
true
I would be surprised if this exact translation of Quine’s algorithm could not be given by another improvement of Isabelle Newbie program. But I do not know how to dot it. (Again, the interest of such a program is mainly pedagogical.