Commit d8c1208f authored by FAGES Francois's avatar FAGES Francois
Browse files

reste 1 seul exemple d'indecision mais mon systeme de reecriture me laisse perplexe

parent 2ff72798
......@@ -205,95 +205,164 @@ simplify(Molecules):-
simpl(M),
!.
% Elimination of reaction catalyst M not produced in other reaction
% Elimination of species M isolated in reactions alpha_i => beta_i + M and M + gamma => delta
% if forall i alpha_i\cap\gamma=\emptyset and \alpha_i \= \delta
% by merging reactions resulting in alpha_i + gamma => beta_i + delta
simpl(M):-
reactions_with_reactant([M], [Reaction1]),
reactions_with_product([M], Reactions),
subtract(Reactions, [Reaction1], Reactions2),
Reactions2\=[],
delete(Reactions, Reaction1, Reactions2),
reaction(Reaction1, _, _, _, Products1),
forall(
member(Reaction2, Reactions2),
(
\+ (is_reactant(X, Reaction1), is_reactant(X, Reaction2)),
\+ reaction(Reaction2, _, Products1, _, _)
)
),
!,
delete_reaction(Reaction1),
(
Reactions=[Reaction1] % M catalyst not produced elsewhere
->
delete_reaction(Reaction1),
reaction(Reaction1, Kinetics1, Reactants1, Inhibitors1, Products1),
member((C*M), Reactants1),
delete(Reactants1, (C*M), Reac1),
member((D*M), Products1),
delete(Products1, (D*M), Prod1),
(
C<D
->
E is D-C,
add_reaction(Kinetics1, Reac1, Inhibitors1, [(E*M) | Prod1], false)
;
C>D
->
E is C-D,
add_reaction(Kinetics1, [(E*M) | Reac1], Inhibitors1, Prod1, false)
;
add_reaction(Kinetics1, Reac1, Inhibitors1, Prod1, false)
)
forall(
member(Reaction2, Reactions2),
(
delete_reaction(Reaction2),
add_merge_reactions(M, Reaction1, Reaction2)
; % M isolated
reaction(Reaction1, _, _, _, Products1),
forall(
member(Reaction2, Reactions2),
(
\+ (is_reactant(X, Reaction1), is_reactant(X, Reaction2)),
\+ reaction(Reaction2, _, Products1, _, _)
)
),
!,
delete_reaction(Reaction1),
forall(
member(Reaction2, Reactions2),
(
delete_reaction(Reaction2),
add_merge_reactions(M, Reaction1, Reaction2)
)
)
).
).
% Todo: accept reversible reactions with syntax <=>
% Elimination of M in 2 loops a 1<=>3 M (4<)=>2 b rewritten a (<)=> b
% WOULD NEED TO BE GENERALIZED TO alpha <=> beta <=> gamma in alpha<=>gamma FOR ELIMINATING ISOLATED beta
% Elimination of M in 2 loops alpha 1<=>3 M (4<)=>2 gamma rewritten alpha (<)=> gamma
% GENERALIZED TO alpha 1<=>3 beta+M (4<)=>2 gamma in alpha<=>gamma ELIMINATING M ISOLATED AND KEEPING REACTIONS WITH BETA
simpl(M):-
reactions_with_reactant([M], [Reaction1, Reaction2]),
reactions_with_reactant([M], [Reaction1, Reaction2]), % M isolated
reactions_with_product([M], [Reaction3 | Reactions]),
(
Reactions=[Reaction4]
Reactions=[Reaction4]
->
reaction(Reaction4, _, Reactants4, _, [S*M])
reaction(Reaction4, Kinetics4, Reactants4, Inhibitors4, Products4),
member((S*M), Products4),
delete(Products4, (S*M), Beta)
;
Reactions=[]
),
reaction(Reaction1, _, [S*M], _, Products1),
reaction(Reaction2, _, [S*M], _, Products2),
reaction(Reaction3, _, Reactants3, _, [S*M]),
reaction(Reaction1, Kinetics1, Reactants1, Inhibitors1, Products1),
member((S*M), Reactants1),
reaction(Reaction2, Kinetics2, Reactants2, Inhibitors2, Products2),
member((S*M), Reactants2),
reaction(Reaction3, Kinetics3, Reactants3, Inhibitors3, Products3),
member((S*M), Products3),
delete(Reactants1, (S*M), Beta),
delete(Reactants2, (S*M), Beta),
delete(Products3, (S*M), Beta),
(
Products1=Reactants3
->
add_merge_reactions(M, Reaction3, Reaction2),
Beta=[]
-> % merge reactions
(
Reactions=[]
Products1=Reactants3
->
true
;
Products2=Reactants4,
add_merge_reactions(M, Reaction4, Reaction1),
delete_reaction(Reaction4)
add_merge_reactions(M, Reaction3, Reaction2),
(
Reactions=[]
->
true
;
Products2=Reactants4,
add_merge_reactions(M, Reaction4, Reaction1),
delete_reaction(Reaction4)
)
; % 1 and 2 exchanged by pattern matching
Products2=Reactants3,
add_merge_reactions(M, Reaction3, Reaction1),
(
Reactions=[]
->
true
;
Products1=Reactants4,
add_merge_reactions(M, Reaction4, Reaction2),
delete_reaction(Reaction4)
)
)
;
Products2=Reactants3,
add_merge_reactions(M, Reaction3, Reaction1),
; % eliminate M from reactions
(Products1=Reactants3 ; Products2=Reactants3),
add_reaction(Kinetics1, Beta, Inhibitors1, Products1, false),
add_reaction(Kinetics2, Beta, Inhibitors2, Products2, false),
add_reaction(Kinetics3, Reactants3, Inhibitors3, Beta, false),
(
Reactions=[]
->
true
;
Products1=Reactants4,
add_merge_reactions(M, Reaction4, Reaction2),
(
Products1=Reactants3
->
Products2=Reactants4
;
Products1=Reactants4
),
add_reaction(Kinetics4, Reactants4, Inhibitors4, Beta, false),
delete_reaction(Reaction4)
)
),
),
delete_reaction(Reaction1),
delete_reaction(Reaction2),
delete_reaction(Reaction3).
add_merge_reactions(M, Reaction1, Reaction2):-
reaction(Reaction1, Kinetics1, Reactants1, Inhibitors1, Products1),
subtract(Reactants1, [_*M], Reac1),
subtract(Products1, [_*M], Prod1),
subtract(Inhibitors1, [M], Inhib1),
delete(Reactants1, (_*M), Reac1),
delete(Products1, (_*M), Prod1),
delete(Inhibitors1, M, Inhib1),
reaction(Reaction2, Kinetics2, Reactants2, Inhibitors2, Products2),
subtract(Reactants2, [_*M], Reac2),
subtract(Products2, [_*M], Prod2),
subtract(Inhibitors2, [M], Inhib2),
delete(Reactants2, (_*M), Reac2),
delete(Products2, (_*M), Prod2),
delete(Inhibitors2, M, Inhib2),
kinetics(Reac1, Inhib1, Kinetics1, Kin1),
kinetics(Reac1, Inhib1, Kinetics1, Kin1), % M remains in kinetics
kinetics(Reac2, Inhib2, Kinetics2, Kin2),
append(Reac1, Reac2, Reac),
append(Prod1, Prod2, Prod),
......
prolog('writeln("%%%%%%%% WRONG ANSWER %%%%%%%%%")').
prolog('writeln("%%%%%%%% UNDECIDED %%%%%%%%%")').
clear_model.
a+b=>c+d.
c+d=>a+b.
c+d=>e.
e=>c+f.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER YES: composite loop leakage with and-fork")'). prolog('writeln("============")').
clear_model.
MA(k1) for a+b => b.
MA(k2) for b+c=>d.
list_model.
test_rate_independence_inputs_sinks. % no
prolog('writeln("ANSWER YES: irrelevant input")'). prolog('writeln("============")').
prolog('writeln("%%%%%%% CORRECT ANSWER %%%%%%%%")').
clear_model.
MA(k1) for a+b => b.
MA(k2) for b+c=>d.
list_model.
test_rate_independence({b,c}, {d}). % no
prolog('writeln("ANSWER YES: declared irrelevant input")'). prolog('writeln("============")').
clear_model.
a+b=>c+d.
c+d=>a+b.
c+d=>e.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER YES: composite loop leakage with or-fork")'). prolog('writeln("============")').
clear_model.
a+b=>c+d.
c+d=>a+b.
c+d=>e.
e=>c+d.
e=>f+g.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER YES: composite double loop leakage with composite or-fork")'). prolog('writeln("============")').
clear_model.
a => x+c.
b => y+c.
......@@ -26,54 +81,66 @@ list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER YES: loop leakage with and-fork")'). prolog('writeln("============")').
clear_model.
a => b.
b => c.
b => d.
c => a.
c => d.
c => e.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER YES: loop leakage with or-fork")'). prolog('writeln("============")').
prolog('writeln("ANSWER NO: loop double leakage with or-forks")'). prolog('writeln("============")').
clear_model.
a => b.
b => a.
b => c.
b => c+d.
c => a+e.
list_model.
test_rate_independence_inputs_sinks. %
prolog('writeln("ANSWER YES: loop leakage with or-fork")'). prolog('writeln("============")').
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER NO: loop double leakage with and-fork")'). prolog('writeln("============")').
clear_model.
a+b=>c+d.
c+d=>a+b.
c+d=>e.
a => b.
b => c+d.
c => a.
c => e.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER YES: composite loop leakage with or-fork")'). prolog('writeln("============")').
prolog('writeln("ANSWER NO: loop double leakage with and-or-fork")'). prolog('writeln("============")').
clear_model.
a+b=>c+d.
c+d=>a+b.
c+d=>e.
e=>c+d.
e=>f+g.
a => b.
b => a.
b => c.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER YES: composite loop leakage with or-fork")'). prolog('writeln("============")').
prolog('writeln("ANSWER YES: short loop leakage with or-fork")'). prolog('writeln("============")').
clear_model.
a => b.
b => c.
c => a.
c => d.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER YES: loop leakage with or-fork")'). prolog('writeln("============")').
clear_model.
a+b=>c+d.
c+d=>a+b.
c+d=>e.
e=>c+f.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER YES: composite loop leakage with and-fork")'). prolog('writeln("============")').
prolog('writeln("ANSWER YES: partial loop leakage with or-fork")'). prolog('writeln("============")').
clear_model.
......@@ -85,12 +152,13 @@ test_rate_independence_inputs_sinks. % yes
prolog('writeln("ANSWER YES: closing and-fork with or-join")'). prolog('writeln("============")').
clear_model.
a=>b+c.
b+c=>d.
list_model.
test_rate_independence_inputs_sinks. % yes
prolog('writeln("ANSWER NO: closing and-fork with and-join")'). prolog('writeln("============")').
prolog('writeln("ANSWER YES: closing and-fork with and-join")'). prolog('writeln("============")').
clear_model.
......@@ -141,12 +209,4 @@ test_rate_independence_inputs_sinks. % no
prolog('writeln("ANSWER NO: output in loop equilibriuem")'). prolog('writeln("============")').
clear_model.
MA(k1) for a+b => b.
MA(k2) for b+c=>d.
list_model.
test_rate_independence_inputs_sinks. % no
prolog('writeln("ANSWER YES: irrelevant input")'). prolog('writeln("============")').
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment