Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
J
javawlp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
impresshs
javawlp
Commits
743bcb44
Verified
Commit
743bcb44
authored
7 years ago
by
Ogilvie, D.H. (Duncan)
Browse files
Options
Downloads
Patches
Plain Diff
Implement more free lambdas
Closes
#13
parent
af22f5be
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/LogicIR/Frontend/Java.hs
+13
-4
13 additions, 4 deletions
src/LogicIR/Frontend/Java.hs
src/SimpleFormulaChecker.hs
+2
-1
2 additions, 1 deletion
src/SimpleFormulaChecker.hs
src/javawlp_edsl/src/nl/uu/javawlp_edsl/Main.java
+6
-0
6 additions, 0 deletions
src/javawlp_edsl/src/nl/uu/javawlp_edsl/Main.java
with
21 additions
and
5 deletions
src/LogicIR/Frontend/Java.hs
+
13
−
4
View file @
743bcb44
...
...
@@ -46,14 +46,23 @@ javaExpToLExprAlgebra = (fLit, fClassLit, fThis, fThisClass, fInstanceCreation,
fMethodInv
inv
env
decls
=
case
inv
of
-- TODO: very hardcoded EDSL + lambdas cannot be { return expr; } + ranged
-- Java: forall(name, bound -> expr);
MethodCall
(
Name
[
Ident
"forall"
])
[
ExpName
name
,
Lambda
(
LambdaSingleParam
(
Ident
bound
))
(
LambdaExpression
expr
)]
->
let
(
i
,
arr
)
=
(
Var
(
TPrim
PInt32
)
bound
,
nameToVar
name
env
decls
)
in
LQuant
QAll
i
(
LBinop
(
LBinop
(
LComp
(
LVar
i
)
CGeq
(
NConst
0
))
LAnd
(
LComp
(
LVar
i
)
CLess
(
NLen
arr
)))
LImpl
(
foldExp
javaExpToLExprAlgebra
expr
env
decls
))
->
forall
name
bound
expr
-- Java: exists(name, bound -> expr);
MethodCall
(
Name
[
Ident
"exists"
])
[
ExpName
name
,
Lambda
(
LambdaSingleParam
(
Ident
bound
))
(
LambdaExpression
expr
)]
->
let
(
i
,
arr
)
=
(
Var
(
TPrim
PInt32
)
bound
,
nameToVar
name
env
decls
)
in
LQuant
QAny
i
(
LBinop
(
LBinop
(
LComp
(
LVar
i
)
CGeq
(
NConst
0
))
LAnd
(
LComp
(
LVar
i
)
CLess
(
NLen
arr
)))
LAnd
(
foldExp
javaExpToLExprAlgebra
expr
env
decls
))
->
exists
name
bound
expr
-- Java: forall(name, bound -> { return expr; });
MethodCall
(
Name
[
Ident
"forall"
])
[
ExpName
name
,
Lambda
(
LambdaSingleParam
(
Ident
bound
))
(
LambdaBlock
(
Block
[
BlockStmt
(
Return
(
Just
expr
))]))]
->
forall
name
bound
expr
-- Java: exists(name, bound -> { return expr; });
MethodCall
(
Name
[
Ident
"exists"
])
[
ExpName
name
,
Lambda
(
LambdaSingleParam
(
Ident
bound
))
(
LambdaBlock
(
Block
[
BlockStmt
(
Return
(
Just
expr
))]))]
->
exists
name
bound
expr
_
->
error
$
"Unimplemented fMethodInv: "
++
show
inv
where
forall
name
bound
expr
=
let
(
i
,
arr
)
=
(
Var
(
TPrim
PInt32
)
bound
,
nameToVar
name
env
decls
)
in
LQuant
QAll
i
(
LBinop
(
LBinop
(
LComp
(
LVar
i
)
CGeq
(
NConst
0
))
LAnd
(
LComp
(
LVar
i
)
CLess
(
NLen
arr
)))
LImpl
(
foldExp
javaExpToLExprAlgebra
expr
env
decls
))
exists
name
bound
expr
=
let
(
i
,
arr
)
=
(
Var
(
TPrim
PInt32
)
bound
,
nameToVar
name
env
decls
)
in
LQuant
QAny
i
(
LBinop
(
LBinop
(
LComp
(
LVar
i
)
CGeq
(
NConst
0
))
LAnd
(
LComp
(
LVar
i
)
CLess
(
NLen
arr
)))
LAnd
(
foldExp
javaExpToLExprAlgebra
expr
env
decls
))
fArrayAccess
arrayIndex
env
decls
=
case
arrayIndex
of
-- TODO: type checking
ArrayIndex
(
ExpName
name
)
[
expr
]
->
LArray
(
nameToVar
name
env
decls
)
(
javaExpToLExpr
expr
env
decls
)
...
...
This diff is collapsed.
Click to expand it.
src/SimpleFormulaChecker.hs
+
2
−
1
View file @
743bcb44
...
...
@@ -131,4 +131,5 @@ edslSrc = "javawlp_edsl/src/nl/uu/javawlp_edsl/Main.java"
testEq
=
compareSpec
(
edslSrc
,
"swap_spec1"
)
(
edslSrc
,
"swap_spec1"
)
testNeq
=
compareSpec
(
edslSrc
,
"swap_spec1"
)
(
edslSrc
,
"swap_spec2"
)
blub
=
compareSpec
(
edslSrc
,
"getMax_spec1"
)
(
edslSrc
,
"getMax_spec2"
)
blub2
=
compareSpec
(
edslSrc
,
"test1"
)
(
edslSrc
,
"test2"
)
\ No newline at end of file
blub2
=
compareSpec
(
edslSrc
,
"test1"
)
(
edslSrc
,
"test2"
)
blob
=
compareSpec
(
edslSrc
,
"blob1"
)
(
edslSrc
,
"blob1"
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/javawlp_edsl/src/nl/uu/javawlp_edsl/Main.java
+
6
−
0
View file @
743bcb44
...
...
@@ -107,6 +107,12 @@ public class Main {
post
(
a
[
i
]
==
oldaj
);
}
public
static
void
blob1
(
int
[]
a
)
{
pre
(
forall
(
a
,
i
->
{
return
a
[
i
]
==
0
;
}));
post
(
true
);
}
public
static
void
test1
(
int
[]
a
)
{
pre
(
exists
(
a
,
i
->
a
[
i
+
1
]
>
a
[
i
]));
...
...
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