Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Frontull Samuel
alpha
Commits
612c6131
Commit
612c6131
authored
Jul 15, 2021
by
Frontull Samuel
Browse files
bugfix in simp function
parent
08c457e3
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
823 additions
and
10 deletions
+823
-10
trs/main.ml
trs/main.ml
+6
-2
trslib/core.ml
trslib/core.ml
+24
-8
trslib/lexer.mll
trslib/lexer.mll
+7
-0
trslib/parser.mly
trslib/parser.mly
+8
-0
zmp.txt
zmp.txt
+778
-0
No files found.
trs/main.ml
View file @
612c6131
...
...
@@ -4,8 +4,12 @@ let tree_of_string s = Parser.input Lexer.token (Lexing.from_string s)
let
()
=
(* Printf.printf "%s\n" (Core.trs_term_to_string (Core.nf
(tree_of_string "
APPEND NIL (CONS NIL NIL)
\n"))); *)
(tree_of_string "
HDEQ SA SA
\n"))); *)
Printf
.
printf
"%s
\n
"
(
Core
.
trs_term_to_string
(
Core
.
nf
(
tree_of_string
"PCP NIL
\n
"
)))
(
tree_of_string
"PCP (CONS (PAIR SB SAA) (CONS ((PAIR SAAA SB)) (CONS (PAIR SA SAB) NIL)))
\n
"
)))
(* Printf.printf "%s\n" (Core.trs_term_to_string (Core.nf
(tree_of_string "EQ SB SB\n"))) *)
(* Printf.printf "%s\n" (Core.trs_term_to_string (Core.nf
(tree_of_string "TLL (CONS ((PAIR SA SB)) (CONS (PAIR SA SA) NIL))\n"))) *)
(* Printf.printf "%s\n" (Core.a_term_to_string (List.hd (List.rev reduction))); *)
trslib/core.ml
View file @
612c6131
...
...
@@ -9,7 +9,8 @@ type trs_symbol =
HDA
|
HDB
|
HDEQ
|
EQP
|
EQ
|
PREFIXP
|
PREFIX
|
NIL
|
CONS
|
HDL
|
TLL
|
ISNIL
|
APPENDP
|
APPEND
|
SIMPP
|
SIMP
|
PVALID
|
FINDEQP
|
FINDEQ
|
CMB
|
MAPCMBP
|
MAPCMB
|
CROSSCMBP
|
CROSSCMB
|
PCPP
|
PCP
MAPCMBP
|
MAPCMB
|
CROSSCMBP
|
CROSSCMB
|
PCPP
|
PCP
|
SA
|
SB
|
SAA
|
SAB
|
SBA
|
SBB
|
SAAA
type
trs_term
=
S
of
trs_symbol
|
FA
of
trs_term
*
trs_term
...
...
@@ -62,6 +63,13 @@ let trs_symbol_to_string symbol =
|
CROSSCMB
->
"CROSSCMB"
|
PCPP
->
"PCPP"
|
PCP
->
"PCP"
|
SA
->
"SA"
|
SB
->
"SB"
|
SAA
->
"SAA"
|
SAB
->
"SAB"
|
SBA
->
"SBA"
|
SBB
->
"SBB"
|
SAAA
->
"SAAA"
let
rec
_trs_term_to_string
term
=
match
term
with
...
...
@@ -69,6 +77,7 @@ let rec _trs_term_to_string term =
(
match
a
,
b
with
|
FA
_
,
FA
_
->
"("
^
(
_trs_term_to_string
a
)
^
") ("
^
(
_trs_term_to_string
b
)
^
")"
|
_
,
FA
_
->
(
_trs_term_to_string
a
)
^
" ("
^
(
_trs_term_to_string
b
)
^
")"
|
FA
_
,
_
->
"("
^
(
_trs_term_to_string
a
)
^
") "
^
(
_trs_term_to_string
b
)
|
_
,
_
->
(
_trs_term_to_string
a
)
^
" "
^
(
_trs_term_to_string
b
)
)
...
...
@@ -83,9 +92,10 @@ let itetruefalse = FA (FA (S ITE, S FALSE), S TRUE)
let
rec
_reduce_lo
term
=
match
term
with
|
FA
(
FA
(
S
TRUE
,
a
)
,
b
)
->
a
|
FA
(
FA
(
S
FALSE
,
a
)
,
b
)
->
b
|
FA
(
S
Y
,
a
)
->
(
FA
(
a
,
FA
(
S
Y
,
a
))
)
|
FA
(
S
NIL
,
x
)
->
x
|
FA
(
S
TLL
,
x
)
->
x
|
FA
(
S
AT
,
a
)
->
S
TRUE
|
FA
(
S
AF
,
a
)
->
S
FALSE
|
FA
(
S
ISNIL
,
a
)
->
(
FA
(
S
FST
,
a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View file @
612c6131
...
...
@@ -8,6 +8,7 @@
%
token
EMPTY
ISEMPTY
CONCAT
PREPA
PREPB
NEXTA
NEXTB
TLSTR
HDA
HDB
HDEQ
EQP
EQ
PREFIXP
PREFIX
%
token
NIL
CONS
HDL
TLL
ISNIL
APPENDP
APPEND
%
token
SIMPP
SIMP
PVALID
FINDEQP
FINDEQ
CMB
MAPCMBP
MAPCMB
CROSSCMBP
CROSSCMB
PCPP
PCP
%
token
SA
SB
SAA
SAB
SBA
SBB
SAAA
%
token
LPAREN
RPAREN
%
token
EOF
%
token
BLANK
...
...
@@ -71,6 +72,13 @@ T :
|
CROSSCMB
{
S
CROSSCMB
}
|
PCPP
{
S
PCPP
}
|
PCP
{
S
PCP
}
|
SAAA
{
S
SAAA
}
|
SBB
{
S
SBB
}
|
SBA
{
S
SBA
}
|
SAB
{
S
SAB
}
|
SAA
{
S
SAA
}
|
SB
{
S
SB
}
|
SA
{
S
SA
}
|
T
BLANK
T
{
FA
(
$
1
,
$
3
)
}
|
LPAREN
T
RPAREN
{
$
2
}
;
...
...
zmp.txt
0 → 100644
View file @
612c6131
This diff is collapsed.
Click to expand it.
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