Search in sources :

Example 1 with Thue

use of catdata.provers.Thue in project fql by CategoricalData.

the class KBViewer method translate.

private static String translate(String s) {
    Object o = PPParser.catConst().from(PPParser.TOKENIZER, PPParser.IGNORED).parse(s);
    Const c = PPParser.toCatConst(o);
    Signature<String, String> sig = new Signature<>(c.nodes, c.arrows, c.eqs);
    List<Pair<List<String>, List<String>>> rules = new LinkedList<>();
    for (Signature<String, String>.Eq eq : sig.eqs) {
        rules.add(new Pair<>(eq.lhs.path.stream().map(x -> x.name).collect(Collectors.toList()), eq.rhs.path.stream().map(x -> x.name).collect(Collectors.toList())));
    }
    Thue<String> kb = new Thue<>(rules, 16);
    kb.complete();
    return kb.toString();
}
Also used : Const(catdata.fqlpp.CatExp.Const) JSplitPane(javax.swing.JSplitPane) JDialog(javax.swing.JDialog) SwingConstants(javax.swing.SwingConstants) GridLayout(java.awt.GridLayout) Signature(catdata.fqlpp.cat.Signature) BorderLayout(java.awt.BorderLayout) LinkedList(java.util.LinkedList) JComboBox(javax.swing.JComboBox) JFrame(javax.swing.JFrame) Pair(catdata.Pair) Thue(catdata.provers.Thue) ScrollPaneConstants(javax.swing.ScrollPaneConstants) JButton(javax.swing.JButton) CodeTextPanel(catdata.ide.CodeTextPanel) BorderFactory(javax.swing.BorderFactory) JOptionPane(javax.swing.JOptionPane) ActionEvent(java.awt.event.ActionEvent) Collectors(java.util.stream.Collectors) JScrollPane(javax.swing.JScrollPane) Dimension(java.awt.Dimension) List(java.util.List) JLabel(javax.swing.JLabel) Example(catdata.ide.Example) JTextArea(javax.swing.JTextArea) JPanel(javax.swing.JPanel) Thue(catdata.provers.Thue) Const(catdata.fqlpp.CatExp.Const) LinkedList(java.util.LinkedList) Signature(catdata.fqlpp.cat.Signature) Pair(catdata.Pair)

Aggregations

Pair (catdata.Pair)1 Const (catdata.fqlpp.CatExp.Const)1 Signature (catdata.fqlpp.cat.Signature)1 CodeTextPanel (catdata.ide.CodeTextPanel)1 Example (catdata.ide.Example)1 Thue (catdata.provers.Thue)1 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 GridLayout (java.awt.GridLayout)1 ActionEvent (java.awt.event.ActionEvent)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 BorderFactory (javax.swing.BorderFactory)1 JButton (javax.swing.JButton)1 JComboBox (javax.swing.JComboBox)1 JDialog (javax.swing.JDialog)1 JFrame (javax.swing.JFrame)1 JLabel (javax.swing.JLabel)1 JOptionPane (javax.swing.JOptionPane)1