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
432b83da
Verified
Commit
432b83da
authored
7 years ago
by
Ogilvie, D.H. (Duncan)
Browse files
Options
Downloads
Patches
Plain Diff
add types in LogicIR
parent
36b02fba
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/LogicIR/Expr.hs
+17
-5
17 additions, 5 deletions
src/LogicIR/Expr.hs
src/LogicIR/Fold.hs
+5
-5
5 additions, 5 deletions
src/LogicIR/Fold.hs
with
22 additions
and
10 deletions
src/LogicIR/Expr.hs
+
17
−
5
View file @
432b83da
...
...
@@ -2,6 +2,18 @@ module LogicIR.Expr where
-- Based on my (Duncan's) previous work: https://github.com/mrexodia/wp/blob/master/Wp.hs
data
Primitive
=
PBool
|
PInt
deriving
(
Show
,
Eq
,
Read
)
data
Type
=
TPrim
Primitive
|
TArray
Type
deriving
(
Show
,
Eq
,
Read
)
-- Typed + named variable
data
Var
=
Var
Type
String
deriving
(
Show
,
Eq
,
Read
)
-- Numeral unary operators
data
NUnop
=
NNeg
|
NNot
...
...
@@ -22,10 +34,10 @@ data NBinop = NAdd
-- Numeral expressions
data
NExpr
=
NConst
Int
-- Integer constant
|
NVar
String
-- Named integer v
ariable
|
NVar
Var
-- V
ariable
|
NUnop
NUnop
NExpr
-- Unary operator
|
NBinop
NExpr
NBinop
NExpr
-- Binary operators
|
NArray
String
NExpr
-- Integer array access
|
NArray
Var
NExpr
-- Integer array access
deriving
(
Show
,
Eq
,
Read
)
-- Reference: https://en.wikipedia.org/wiki/First-order_logic#Logical_symbols
...
...
@@ -51,10 +63,10 @@ data COp = CEqual
-- Logical expressions
data
LExpr
=
LConst
Bool
-- True/False
|
LVar
String
-- Named boolean v
ariable
|
LVar
Var
-- V
ariable
|
LNot
LExpr
-- Logical negation/not
|
LBinop
LExpr
LBinop
LExpr
-- Logical operator
|
LComp
NExpr
COp
NExpr
-- Integer comparison
|
LQuant
QOp
[
String
]
LExpr
-- Logical quantifier
|
LArray
String
NExpr
-- Logical array access (TODO: remove?)
|
LQuant
QOp
[
Var
]
LExpr
-- Logical quantifier
|
LArray
Var
NExpr
-- Logical array access (TODO: remove?)
deriving
(
Show
,
Eq
,
Read
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/LogicIR/Fold.hs
+
5
−
5
View file @
432b83da
...
...
@@ -4,10 +4,10 @@ import LogicIR.Expr
-- Fold algrbra for numeral expressions
type
NExprAlgebra
r
=
(
Int
->
r
,
-- NConst
String
->
r
,
-- NVar
Var
->
r
,
-- NVar
NUnop
->
r
->
r
,
-- NUnop
r
->
NBinop
->
r
->
r
,
-- NBinop
String
->
r
->
r
-- NArray
Var
->
r
->
r
-- NArray
)
-- Fold for numeral expressions
...
...
@@ -22,12 +22,12 @@ foldNExpr (fConst, fVar, fUnop, fBinop, fArray) = fold where
-- Fold algebra for logical expressions
type
LExprAlgebra
r
=
(
Bool
->
r
,
-- LConst
String
->
r
,
-- LVar
Var
->
r
,
-- LVar
r
->
r
,
-- LNot
r
->
LBinop
->
r
->
r
,
-- LBinop
NExpr
->
COp
->
NExpr
->
r
,
-- LComp
QOp
->
[
String
]
->
r
->
r
,
-- LQuant
String
->
NExpr
->
r
-- LArray
QOp
->
[
Var
]
->
r
->
r
,
-- LQuant
Var
->
NExpr
->
r
-- LArray
)
-- Fold for logical expressions
...
...
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