Commit e19e9cf4 authored by Bruno Guillaume's avatar Bruno Guillaume

complete page grs

parent 0530ed26
HUGO=${hugo_old}
HUGO=hugo_old
selfdoc:
@echo " * make start --> run locally the server"
......
......@@ -10,9 +10,6 @@ Description = ""
# GRS syntax
The syntax descried here appeared in version 0.44.0 (2017/09/05).
For the previous syntax, view [old_grs](../old_grs) page.
## Global structure
A GRS is composed by a set of declarations that may be provided in several files.
These files are expected to used the `.grs` or the `.dom` file extension.
......@@ -121,7 +118,6 @@ With this operator, only one normal form is built, and so :
## Packages
Packages are used to organize the set of declarations and to define scopes of definitions.
Syntax of packages definition:
......@@ -198,15 +194,42 @@ Consider a folder with the five files:
* [`multi.grs`](../examples/strategies/multi.grs)
{{< grew file="/static/examples/strategies/multi.grs" >}}
### Single file declaration
The five files above define a GRS, equivalent to the one below:
* [`single.grs`](../examples/strategies/single.grs)
{{< grew file="/static/examples/strategies/single.grs" >}}
Note that all the rules consist in the changement of the label of one edge.
Package `p_1` rewrites the label `L` into `L_1` and `L_1` into either `L_11` or `L_12`.
Similarly, package `p_2` rewrites the label `L` into `L_2` and `L_2` into either `L_21` or `L_22`.
### Apply the GRS to a graph
Consider the graph defined in
Consider small graph with 3 nodes and 2 edges labeled `L` defined in
* [`input.gr`](../examples/strategies/input.gr):
[`input.gr`](../examples/strategies/input.gr):
{{< grew file="/static/examples/strategies/input.gr" >}}
Next commands rewrite the graph `input.gr`, following different strategies (:warning: the `-gr` options is needed to output graph in the native format instead of CoNLL)
#### strategy `p_1_nfs`
`grew transform -grs single.grs -strat p_1_nfs -i input.gr -gr` computes all normal forms for the input graph with rules of package `p_1`.
Each initial edges `L` can be rewritten either `L_11` or `L_12`, and so 4 graphs are produced:
{{< grew file="/static/examples/strategies/p_1_nfs.out" >}}
#### strategy `p_1_onf`
`grew transform -grs single.grs -strat p_1_onf -i input.gr -gr` produces one of the 4 graphs of the previous strategy.
{{< grew file="/static/examples/strategies/p_1_onf.out" >}}
#### strategy `union`
`grew transform -grs single.grs -strat union -i input.gr -gr` compute the application of the union of one step of rewriting with `p_1` (which produces 2 graphs, replacing one the two `L` edge by `L_1` and the same with `p_2`. In the end, 4 graphs are produced (there is no iteration of rule application).
{{< grew file="/static/examples/strategies/union.out" >}}
#### strategy `all_nfs`
`grew transform -grs single.grs -strat all_nfs -i input.gr -gr` computes all normal forms that can be obtained with these all the rules and produces 16 graphs.
{{< grew file="/static/examples/strategies/all_nfs.out" >}}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_11]-> N_1;
N_1 -[X_11]-> N_0;
}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_12]-> N_1;
N_1 -[X_11]-> N_0;
}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_21]-> N_1;
N_1 -[X_11]-> N_0;
}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_22]-> N_1;
N_1 -[X_11]-> N_0;
}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_11]-> N_1;
N_1 -[X_12]-> N_0;
}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_12]-> N_1;
N_1 -[X_12]-> N_0;
}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_21]-> N_1;
N_1 -[X_12]-> N_0;
}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_22]-> N_1;
N_1 -[X_12]-> N_0;
}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_11]-> N_1;
N_1 -[X_21]-> N_0;
}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_12]-> N_1;
N_1 -[X_21]-> N_0;
}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_21]-> N_1;
N_1 -[X_21]-> N_0;
}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_22]-> N_1;
N_1 -[X_21]-> N_0;
}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_11]-> N_1;
N_1 -[X_22]-> N_0;
}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_12]-> N_1;
N_1 -[X_22]-> N_0;
}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_21]-> N_1;
N_1 -[X_22]-> N_0;
}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_22]-> N_1;
N_1 -[X_22]-> N_0;
}
labels { E_1, E_11, E_12 }
labels { L_1, L_11, L_12 }
labels { E_2, E_21, E_22 }
labels { L_2, L_21, L_22 }
0 _ _ _ _ label=A _ _ _ _
1 _ _ _ _ label=B 0 E _ _
2 _ _ _ _ label=C 1 E _ _
1 _ _ _ _ label=B 0 L _ _
2 _ _ _ _ label=C 1 L _ _
graph {
A -[E]-> B;
B -[E]-> C;
A -[L]-> B;
B -[L]-> C;
}
\ No newline at end of file
labels { E }
labels { L }
include "d_1.dom"
include "d_2.dom"
......
rule r_1 { pattern { e:X -[E]-> Y} commands { del_edge e; add_edge X -[E_1]-> Y } }
rule r_11 { pattern { e:X -[E_1]-> Y} commands { del_edge e; add_edge X -[E_11]-> Y } }
rule r_12 { pattern { e:X -[E_1]-> Y} commands { del_edge e; add_edge X -[E_12]-> Y } }
rule r_1 { pattern { e:X -[L]-> Y} commands { del_edge e; add_edge X -[L_1]-> Y } }
rule r_11 { pattern { e:X -[L_1]-> Y} commands { del_edge e; add_edge X -[L_11]-> Y } }
rule r_12 { pattern { e:X -[L_1]-> Y} commands { del_edge e; add_edge X -[L_12]-> Y } }
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_11]-> N_1;
N_1 -[X_11]-> N_0;
}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_12]-> N_1;
N_1 -[X_11]-> N_0;
}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_11]-> N_1;
N_1 -[X_12]-> N_0;
}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_12]-> N_1;
N_1 -[X_12]-> N_0;
}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_12]-> N_1;
N_1 -[X_12]-> N_0;
}
rule r_2 { pattern { e:X -[E]-> Y} commands { del_edge e; add_edge X -[E_2]-> Y } }
rule r_21 { pattern { e:X -[E_2]-> Y} commands { del_edge e; add_edge X -[E_21]-> Y } }
rule r_22 { pattern { e:X -[E_2]-> Y} commands { del_edge e; add_edge X -[E_22]-> Y } }
rule r_2 { pattern { e:X -[L]-> Y} commands { del_edge e; add_edge X -[L_2]-> Y } }
rule r_21 { pattern { e:X -[L_2]-> Y} commands { del_edge e; add_edge X -[L_21]-> Y } }
rule r_22 { pattern { e:X -[L_2]-> Y} commands { del_edge e; add_edge X -[L_22]-> Y } }
labels { E, E_3, E_4, E_5 }
labels { L, L_3, L_4, L_5 }
labels { E_1, E_11, E_12 }
labels { E_2, E_21, E_22 }
labels { L_1, L_11, L_12 }
labels { L_2, L_21, L_22 }
package p_1 {
rule r_1 { pattern { e:X -[E]-> Y } commands { del_edge e; add_edge X -[E_1]-> Y } }
rule r_11 { pattern { e:X -[E_1]-> Y } commands { del_edge e; add_edge X -[E_11]-> Y } }
rule r_12 { pattern { e:X -[E_1]-> Y } commands { del_edge e; add_edge X -[E_12]-> Y } }
rule r_1 { pattern { e:X -[L]-> Y } commands { del_edge e; add_edge X -[L_1]-> Y } }
rule r_11 { pattern { e:X -[L_1]-> Y } commands { del_edge e; add_edge X -[L_11]-> Y } }
rule r_12 { pattern { e:X -[L_1]-> Y } commands { del_edge e; add_edge X -[L_12]-> Y } }
}
package p_2 {
rule r_2 { pattern { e:X -[E]-> Y } commands { del_edge e; add_edge X -[E_2]-> Y } }
rule r_21 { pattern { e:X -[E_2]-> Y } commands { del_edge e; add_edge X -[E_21]-> Y } }
rule r_22 { pattern { e:X -[E_2]-> Y } commands { del_edge e; add_edge X -[E_22]-> Y } }
rule r_2 { pattern { e:X -[L]-> Y } commands { del_edge e; add_edge X -[L_2]-> Y } }
rule r_21 { pattern { e:X -[L_2]-> Y } commands { del_edge e; add_edge X -[L_21]-> Y } }
rule r_22 { pattern { e:X -[L_2]-> Y } commands { del_edge e; add_edge X -[L_22]-> Y } }
}
strat p_1_nfs { Iter (p_1) } % all normal forms with package p_1
......@@ -22,13 +22,3 @@ strat union { Alt (p_1,p_2) } % union of the two set of rules
strat all_nfs { Iter (union)} % all normal forms
strat s_1 { Seq (Pick(p_1), Pick(p_2), all_nfs) }
package pp {
rule r_1 { pattern { X[cat=N, lemma=lex.lemma]; e:X -[E]-> Y } commands { del_edge e; add_edge X -[E_1]-> Y } }
rule r_2 { pattern { e:X -[E_1]-> Y } commands { del_edge e; add_edge X -[E_2]-> Y } }
rule r_3 { pattern { e:X -[E_2]-> Y } commands { del_edge e; add_edge X -[E_3]-> Y } }
rule r_4 { pattern { e:X -[E_3]-> Y } commands { del_edge e; add_edge X -[E_4]-> Y } }
rule r_5 { pattern { e:X -[E_4]-> Y } commands { del_edge e; add_edge X -[E_5]-> Y } }
}
strat main { Seq (Onf(pp.r_1),Onf(pp.r_2),Onf(pp.r_3),Onf(pp.r_4),Onf(pp.r_5))}
\ No newline at end of file
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X]-> N_1;
N_1 -[X_1]-> N_0;
}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X]-> N_1;
N_1 -[X_2]-> N_0;
}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_1]-> N_1;
N_1 -[X]-> N_0;
}
graph {
N_2 [label="A"] ;
N_1 [label="B"] ;
N_0 [label="C"] ;
N_2 -[X_2]-> N_1;
N_1 -[X]-> N_0;
}
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