Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Javier Baliosian
Learning FSTs
Commits
0c3e8e94
Commit
0c3e8e94
authored
Dec 14, 2014
by
Javier Baliosian
Browse files
Simplification working well with knowledge
Signed-off-by:
baliosian
<
javierba@fing.edu.uy
>
parent
5990577d
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/uy/edu/fing/mina/fsa/logics/Knowledge.java
View file @
0c3e8e94
package
uy.edu.fing.mina.fsa.logics
;
import
java.util.HashSet
;
import
java.util.Set
;
public
class
Knowledge
{
public
static
Set
<
Implication
>
implications
;
public
static
Set
<
Implication
>
implications
=
new
HashSet
<
Implication
>()
;
public
boolean
verify
(){
return
true
;
//TODO to code verify implications
...
...
src/uy/edu/fing/mina/fsa/logics/Utils.java
View file @
0c3e8e94
...
...
@@ -63,7 +63,8 @@ public class Utils {
TfI
simplifiedTf
=
disjunctiveFormByMua
(
tf
);
List
<
Term
>
termList
=
toTermList
(
simplifiedTf
);
applyKnowledge
(
termList
);
if
(
Knowledge
.
implications
!=
null
)
applyKnowledge
(
termList
);
if
(
termList
.
size
()
>
0
)
{
// termList = expandDontCares(termList,0);
...
...
src/uy/edu/fing/mina/fsa/test/SimplificationWithKnowledge.java
View file @
0c3e8e94
...
...
@@ -6,6 +6,8 @@
* */
package
uy.edu.fing.mina.fsa.test
;
import
uy.edu.fing.mina.fsa.logics.Implication
;
import
uy.edu.fing.mina.fsa.logics.Knowledge
;
import
uy.edu.fing.mina.fsa.logics.Utils
;
import
uy.edu.fing.mina.fsa.tf.SimpleTf
;
...
...
@@ -25,59 +27,12 @@ public class SimplificationWithKnowledge {
public
static
void
main
(
String
[]
args
)
{
SimpleTf
tfa
=
new
SimpleTf
();
tfa
.
setName
(
"A"
);
SimpleTf
tfb
=
new
SimpleTf
();
tfb
.
setName
(
"B"
);
SimpleTf
tfc
=
new
SimpleTf
();
tfc
.
setName
(
"C"
);
SimpleTf
tfd
=
new
SimpleTf
();
tfd
.
setName
(
"D"
);
SimpleTf
tfa
=
new
SimpleTf
(
"A"
);
SimpleTf
tfb
=
new
SimpleTf
(
"B"
);
SimpleTf
tfc
=
new
SimpleTf
(
"C"
);
SimpleTf
tfd
=
new
SimpleTf
(
"D"
);
// System.out.println((
// tfa.not() .and(tfb.not() .and(tfc.not() .and(tfd.not())))
// .or(tfa.not() .and(tfb.not() .and(tfc.not() .and(tfd))))
// .or(tfa.not() .and(tfb.not() .and(tfc .and(tfd.not()))))
// .or(tfa.not() .and(tfb.not() .and(tfc .and(tfd))))
// .or(tfa.not() .and(tfb .and(tfc.not() .and(tfd))))
// .or(tfa.not() .and(tfb .and(tfc .and(tfd))))
// .or(tfa .and(tfb.not() .and(tfc.not() .and(tfd.not()))))
// .or(tfa .and(tfb.not() .and(tfc .and(tfd.not()))))
// .or(tfa .and(tfb .and(tfc.not() .and(tfd.not()))))
// .or(tfa .and(tfb .and(tfc.not() .and(tfd))))
// .or(tfa .and(tfb .and(tfc .and(tfd))))
// ));
//
// System.out.println(Utils.simplify(
// tfa.not() .and(tfb.not() .and(tfc.not() .and(tfd.not())))
// .or(tfa.not() .and(tfb.not() .and(tfc.not() .and(tfd))))
// .or(tfa.not() .and(tfb.not() .and(tfc .and(tfd.not()))))
// .or(tfa.not() .and(tfb.not() .and(tfc .and(tfd))))
// .or(tfa.not() .and(tfb .and(tfc.not() .and(tfd))))
// .or(tfa.not() .and(tfb .and(tfc .and(tfd))))
// .or(tfa .and(tfb.not() .and(tfc.not() .and(tfd.not()))))
// .or(tfa .and(tfb.not() .and(tfc .and(tfd.not()))))
// .or(tfa .and(tfb .and(tfc.not() .and(tfd.not()))))
// .or(tfa .and(tfb .and(tfc.not() .and(tfd))))
// .or(tfa .and(tfb .and(tfc .and(tfd))))
// ));
/*
*
{A0 B0 C0 }
{A0 B0 C1 }
{A0 B1 D1 }
{A1 B0 D0 }
{A1 B1 C0}
{A1 B1 C1 D1 }
*
*/
Knowledge
.
implications
.
add
(
new
Implication
(
tfa
,
tfb
));
System
.
out
.
println
(
tfa
.
not
()
.
and
(
tfb
.
not
()
.
and
(
tfc
.
not
()))
...
...
@@ -96,114 +51,6 @@ public class SimplificationWithKnowledge {
.
or
(
tfa
.
and
(
tfb
.
and
(
tfc
.
not
())))
.
or
(
tfa
.
and
(
tfb
.
and
(
tfc
.
and
(
tfd
))))
)));
// System.out.println((
// tfa.not() .and(tfb.not() .and(tfc.not() .and(tfd.not())))
// .or(tfa .and(tfb.not() .and(tfc.not() .and(tfd.not()))))
// .or(tfa.not() .and(tfb .and(tfc.not() .and(tfd.not()))))
// .or(tfa .and(tfb.not() .and(tfc .and(tfd.not()))))
// .or(tfa.not() .and(tfb .and(tfc .and(tfd.not()))))
// .or(tfa .and(tfb .and(tfc .and(tfd.not()))))
// .or(tfa.not() .and(tfb.not() .and(tfc.not() .and(tfd))))
// .or(tfa .and(tfb.not() .and(tfc.not() .and(tfd))))
// .or(tfa.not() .and(tfb.not() .and(tfc .and(tfd))))
// .or(tfa .and(tfb.not() .and(tfc .and(tfd))))
// .or(tfa.not() .and(tfb .and(tfc .and(tfd))))
// .or(tfa .and(tfb .and(tfc .and(tfd))))
// ));
//
// System.out.println(Utils.simplify(
// tfa.not() .and(tfb.not() .and(tfc.not() .and(tfd.not())))
// .or(tfa .and(tfb.not() .and(tfc.not() .and(tfd.not()))))
// .or(tfa.not() .and(tfb .and(tfc.not() .and(tfd.not()))))
// .or(tfa .and(tfb.not() .and(tfc .and(tfd.not()))))
// .or(tfa.not() .and(tfb .and(tfc .and(tfd.not()))))
// .or(tfa .and(tfb .and(tfc .and(tfd.not()))))
// .or(tfa.not() .and(tfb.not() .and(tfc.not() .and(tfd))))
// .or(tfa .and(tfb.not() .and(tfc.not() .and(tfd))))
// .or(tfa.not() .and(tfb.not() .and(tfc .and(tfd))))
// .or(tfa .and(tfb.not() .and(tfc .and(tfd))))
// .or(tfa.not() .and(tfb .and(tfc .and(tfd))))
// .or(tfa .and(tfb .and(tfc .and(tfd))))
// ));
/*
000
010
011
110
101
111
*/
// System.out.println(Utils.simplify(
// tfa.not() .and(tfb.not() .and(tfc.not()))
// .or(tfa.not() .and(tfb .and(tfc.not())))
// .or(tfa.not() .and(tfb .and(tfc)))
// .or(tfa .and(tfb .and(tfc.not())))
// .or(tfa .and(tfb.not() .and(tfc)))
// .or(tfa .and(tfb .and(tfc)))
// ));
//
// System.out.println(Utils.simplify(
// tfa.or(tfb)
// .and(tfa.or(tfb.not()))
// ));
//
//
//-----
// System.out.println(
// (tfb .and(tfc .and(tfd)))
// .or(tfa .and(tfb.not() .and(tfc .and(tfd))))
// .or(tfa.not() .and(tfb .and(tfc.not() .and(tfd))))
// .or((tfb.not() .and(tfc.not() .and(tfd))))
// .or((tfb .and(tfc .and(tfd.not()))))
// .or((tfb .and(tfc.not() .and(tfd.not()))))
// .or((tfb.not() .and(tfc.not() .and(tfd.not()))))
// );
//
// TfTerm tfterma = new TfTerm(tfa, (byte) 1);
// TfTerm tftermb = new TfTerm(tfb, (byte) 1);
//
// TfTerm tftermna = new TfTerm((SimpleTf) tfa.not(), (byte) 0);
// TfTerm tftermnb = new TfTerm((SimpleTf) tfb.not(), (byte) 0);
// ( A and((!A or D ) and((!D or !A ) and (D and ( !D or A)))))
// System.out.println(tfa.and((tfa.not().or(tfb)).and((tfb.not().or(tfa.not()).and(tfb.and(tfb.not().or(tfa)))))));
//
// System.out.println(Utils.disjunctiveForm(tfa.and((tfa.not().or(tfb)).and((tfb.not().or(tfa.not()).and(tfb.and(tfb.not().or(tfa))))))));
//
// TfTerm[] termarray1 = new TfTerm[2];
// termarray1[0] = tfterma;
// termarray1[1] = tftermb;
//
// TfTerm[] termarray2 = new TfTerm[2];
// termarray2[0] = tfterma;
// termarray2[1] = tftermnb;
//
// Term term1 = new Term(termarray1);
// Term term2 = new Term(termarray2);
//
// List<Term> termList = new ArrayList<Term>();
// termList.add(term1);
// termList.add(term2);
//
// QmcFormula qmcf = new QmcFormula(termList);
// System.out.println(qmcf);
// qmcf.reduceToPrimeImplicants();
// System.out.println(qmcf);
// qmcf.reducePrimeImplicantsToSubset();
// System.out.println(qmcf);
//
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment