Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
caisar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
caisar
Commits
bf96be22
Commit
bf96be22
authored
2 years ago
by
François Bobot
Committed by
Michele Alberti
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[interpretation] Interpret size of a dataset.
parent
2a409542
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/interpretation.ml
+20
-11
20 additions, 11 deletions
src/interpretation.ml
tests/dune
+3
-1
3 additions, 1 deletion
tests/dune
tests/interpretation.t
+4
-10
4 additions, 10 deletions
tests/interpretation.t
with
27 additions
and
22 deletions
src/interpretation.ml
+
20
−
11
View file @
bf96be22
...
@@ -25,12 +25,13 @@ open Why3
...
@@ -25,12 +25,13 @@ open Why3
open
Base
open
Base
type
dataset
=
{
dataset
:
string
}
[
@@
deriving
show
]
type
dataset
=
{
dataset
:
string
}
[
@@
deriving
show
]
type
caisar_op
=
Dataset
of
dataset
|
Size
of
dataset
[
@@
deriving
show
]
type
caisar_op
=
Dataset
of
dataset
[
@@
deriving
show
]
type
caisar_env
=
{
type
caisar_env
=
{
dataset_ty
:
Ty
.
ty
;
dataset_ty
:
Ty
.
ty
;
caisar_op_of_ls
:
caisar_op
Term
.
Hls
.
t
;
caisar_op_of_ls
:
caisar_op
Term
.
Hls
.
t
;
ls_of_caisar_op
:
(
caisar_op
,
Term
.
lsymbol
)
Hashtbl
.
t
;
ls_of_caisar_op
:
(
caisar_op
,
Term
.
lsymbol
)
Hashtbl
.
t
;
cwd
:
string
;
}
}
type
engine
=
caisar_env
Caisar_reduction_engine
.
engine
type
engine
=
caisar_env
Caisar_reduction_engine
.
engine
...
@@ -41,9 +42,7 @@ let ls_of_caisar_op (env : engine) op =
...
@@ -41,9 +42,7 @@ let ls_of_caisar_op (env : engine) op =
then
Hashtbl
.
find_exn
caisar_env
.
ls_of_caisar_op
op
then
Hashtbl
.
find_exn
caisar_env
.
ls_of_caisar_op
op
else
else
let
id
=
Ident
.
id_fresh
"caisar_op"
in
let
id
=
Ident
.
id_fresh
"caisar_op"
in
let
ty
=
let
ty
=
match
op
with
Dataset
_
->
caisar_env
.
dataset_ty
in
match
op
with
Dataset
_
->
caisar_env
.
dataset_ty
|
Size
_
->
Ty
.
ty_int
in
let
ls
=
Term
.
create_fsymbol
id
[]
ty
in
let
ls
=
Term
.
create_fsymbol
id
[]
ty
in
Hashtbl
.
Poly
.
add_exn
caisar_env
.
ls_of_caisar_op
~
key
:
op
~
data
:
ls
;
Hashtbl
.
Poly
.
add_exn
caisar_env
.
ls_of_caisar_op
~
key
:
op
~
data
:
ls
;
Term
.
Hls
.
add
caisar_env
.
caisar_op_of_ls
ls
op
;
Term
.
Hls
.
add
caisar_env
.
caisar_op_of_ls
ls
op
;
...
@@ -55,19 +54,24 @@ let caisar_op_of_ls env ls =
...
@@ -55,19 +54,24 @@ let caisar_op_of_ls env ls =
let
term_of_caisar_op
env
op
=
Term
.
t_app_infer
(
ls_of_caisar_op
env
op
)
[]
let
term_of_caisar_op
env
op
=
Term
.
t_app_infer
(
ls_of_caisar_op
env
op
)
[]
let
read_caisar_env
env
=
let
read_caisar_env
env
cwd
=
let
th
=
Env
.
read_theory
env
[
"caisar"
]
"Interpret"
in
let
th
=
Env
.
read_theory
env
[
"caisar"
]
"Interpret"
in
let
dataset_ts
=
Theory
.
ns_find_ts
th
.
Theory
.
th_export
[
"dataset"
]
in
let
dataset_ts
=
Theory
.
ns_find_ts
th
.
Theory
.
th_export
[
"dataset"
]
in
{
{
dataset_ty
=
Ty
.
ty_app
dataset_ts
[]
;
dataset_ty
=
Ty
.
ty_app
dataset_ts
[]
;
ls_of_caisar_op
=
Hashtbl
.
Poly
.
create
()
;
ls_of_caisar_op
=
Hashtbl
.
Poly
.
create
()
;
caisar_op_of_ls
=
Term
.
Hls
.
create
10
;
caisar_op_of_ls
=
Term
.
Hls
.
create
10
;
cwd
;
}
}
let
print_caisar_op
fmt
caisar_env
=
let
print_caisar_op
fmt
caisar_env
=
Pp
.
print_iter2
Term
.
Hls
.
iter
Pp
.
newline
Pp
.
comma
Pretty
.
print_ls
pp_caisar_op
Pp
.
print_iter2
Term
.
Hls
.
iter
Pp
.
newline
Pp
.
comma
Pretty
.
print_ls
pp_caisar_op
fmt
caisar_env
.
caisar_op_of_ls
fmt
caisar_env
.
caisar_op_of_ls
let
compute_size_of_dataset
~
cwd
s
=
let
d
=
Caml
.
Filename
.
concat
cwd
s
in
Array
.
length
(
Caml
.
Sys
.
readdir
d
)
let
built_in_caisar
:
caisar_env
Caisar_reduction_engine
.
built_in_theories
list
let
built_in_caisar
:
caisar_env
Caisar_reduction_engine
.
built_in_theories
list
=
=
let
open_dataset
:
_
Caisar_reduction_engine
.
builtin
=
let
open_dataset
:
_
Caisar_reduction_engine
.
builtin
=
...
@@ -82,8 +86,9 @@ let built_in_caisar : caisar_env Caisar_reduction_engine.built_in_theories list
...
@@ -82,8 +86,9 @@ let built_in_caisar : caisar_env Caisar_reduction_engine.built_in_theories list
match
l
with
match
l
with
|
[
Term
{
t_node
=
Tapp
(
ls
,
[]
);
_
}
]
->
(
|
[
Term
{
t_node
=
Tapp
(
ls
,
[]
);
_
}
]
->
(
match
caisar_op_of_ls
engine
ls
with
match
caisar_op_of_ls
engine
ls
with
|
Dataset
dataset
->
Term
(
term_of_caisar_op
engine
(
Size
dataset
))
|
Dataset
{
dataset
}
->
|
Size
_
->
invalid_arg
"We want a dataset! ;)"
)
let
cwd
=
(
Caisar_reduction_engine
.
user_env
engine
)
.
cwd
in
Int
(
BigInt
.
of_int
(
compute_size_of_dataset
~
cwd
dataset
)))
|
_
->
invalid_arg
"We want a string! ;)"
|
_
->
invalid_arg
"We want a string! ;)"
in
in
...
@@ -96,9 +101,9 @@ let built_in_caisar : caisar_env Caisar_reduction_engine.built_in_theories list
...
@@ -96,9 +101,9 @@ let built_in_caisar : caisar_env Caisar_reduction_engine.built_in_theories list
[
(
"open_dataset"
,
None
,
open_dataset
);
(
"size"
,
None
,
size
)
]
);
[
(
"open_dataset"
,
None
,
open_dataset
);
(
"size"
,
None
,
size
)
]
);
]
]
let
interpret_task
env
task
=
let
interpret_task
~
cwd
env
task
=
let
f
=
Task
.
task_goal_fmla
task
in
let
f
=
Task
.
task_goal_fmla
task
in
let
caisar_env
=
read_caisar_env
env
in
let
caisar_env
=
read_caisar_env
env
cwd
in
let
engine
=
let
engine
=
Caisar_reduction_engine
.
create
Caisar_reduction_engine
.
create
{
{
...
@@ -115,12 +120,16 @@ let interpret_task env task =
...
@@ -115,12 +120,16 @@ let interpret_task env task =
Fmt
.
pr
"%a : %a@.%a@."
Pretty
.
print_pr
(
Task
.
task_goal
task
)
Pretty
.
print_term
Fmt
.
pr
"%a : %a@.%a@."
Pretty
.
print_pr
(
Task
.
task_goal
task
)
Pretty
.
print_term
f
print_caisar_op
caisar_env
f
print_caisar_op
caisar_env
let
interpret
?
debug
?
format
~
loadpath
s
=
let
interpret
?
debug
?
format
~
loadpath
(
s
:
Verification
.
File
.
t
)
=
let
cwd
=
match
s
with
Stdin
->
Unix
.
getcwd
()
|
File
s
->
Caml
.
Filename
.
dirname
s
|
JSON
_
->
Unix
.
getcwd
()
(*todo *)
in
let
env
,
_config
,
mstr_theory
=
let
env
,
_config
,
mstr_theory
=
Verification
.
open_file
?
debug
?
format
~
loadpath
s
Verification
.
open_file
?
debug
?
format
~
loadpath
s
in
in
Wstdlib
.
Mstr
.
iter
Wstdlib
.
Mstr
.
iter
(
fun
_
theory
->
(
fun
_
theory
->
List
.
iter
(
Task
.
split_theory
theory
None
None
)
~
f
:
(
fun
task
->
List
.
iter
(
Task
.
split_theory
theory
None
None
)
~
f
:
(
fun
task
->
interpret_task
env
task
))
interpret_task
~
cwd
env
task
))
mstr_theory
mstr_theory
This diff is collapsed.
Click to expand it.
tests/dune
+
3
−
1
View file @
bf96be22
...
@@ -10,5 +10,7 @@
...
@@ -10,5 +10,7 @@
bin/aimos
bin/aimos
bin/cvc5
bin/cvc5
bin/nnenum.sh
bin/nnenum.sh
filter_tmpdir.sh)
filter_tmpdir.sh
(glob_files "datasets/a/*")
)
(package caisar))
(package caisar))
This diff is collapsed.
Click to expand it.
tests/interpretation.t
+
4
−
10
View file @
bf96be22
...
@@ -21,15 +21,9 @@ Test verify
...
@@ -21,15 +21,9 @@ Test verify
G2
:
false
G2
:
false
Reduction
engine
,
ident
not
found:
infix
=
G3
:
true
G3
:
caisar_op
=
2
caisar_op1
,
(
Interpretation
.
Dataset
{
Interpretation
.
dataset
=
"
datasets/a
"
})
caisar_op
,
caisar_op
,
(
Interpretation
.
Size
{
Interpretation
.
dataset
=
"
datasets/a
"
})
Reduction
engine
,
ident
not
found:
infix
=
G4
:
caisar_op2
=
2
caisar_op3
,
(
Interpretation
.
Dataset
{
Interpretation
.
dataset
=
"
datasets/a
"
})
(
Interpretation
.
Dataset
{
Interpretation
.
dataset
=
"
datasets/a
"
})
caisar_op2
,
G4
:
true
(
Interpretation
.
Size
{
Interpretation
.
dataset
=
"
datasets/a
"
})
caisar_op1
,
(
Interpretation
.
Dataset
{
Interpretation
.
dataset
=
"
datasets/a
"
})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment