-
Notifications
You must be signed in to change notification settings - Fork 76
Added a primitive composition for Id types which reduces with refl on… #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
IanOrton
wants to merge
2
commits into
mortberg:master
Choose a base branch
from
IanOrton:idComp
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,6 +85,7 @@ instance Nominal Val where | |
| VIdPair u us -> support (u,us) | ||
| VId a u v -> support (a,u,v) | ||
| VIdJ a u c d x p -> support [a,u,c,d,x,p] | ||
| VIdComp a u v w p q -> support [a,u,v,w,p,q] | ||
|
|
||
| act u (i, phi) | i `notElem` support u = u | ||
| | otherwise = | ||
|
|
@@ -123,6 +124,8 @@ instance Nominal Val where | |
| VId a u v -> VId (acti a) (acti u) (acti v) | ||
| VIdJ a u c d x p -> | ||
| idJ (acti a) (acti u) (acti c) (acti d) (acti x) (acti p) | ||
| VIdComp a u v w p q -> | ||
| idComp (acti a) (acti u) (acti v) (acti w) (acti p) (acti q) | ||
|
|
||
| -- This increases efficiency as it won't trigger computation. | ||
| swap u ij@(i,j) = | ||
|
|
@@ -157,6 +160,8 @@ instance Nominal Val where | |
| VId a u v -> VId (sw a) (sw u) (sw v) | ||
| VIdJ a u c d x p -> | ||
| VIdJ (sw a) (sw u) (sw c) (sw d) (sw x) (sw p) | ||
| VIdComp a u v w p q -> | ||
| VIdComp (sw a) (sw u) (sw v) (sw w) (sw p) (sw q) | ||
|
|
||
| ----------------------------------------------------------------------- | ||
| -- The evaluator | ||
|
|
@@ -198,6 +203,8 @@ eval rho@(Env (_,_,_,Nameless os)) v = case v of | |
| IdPair b ts -> VIdPair (eval rho b) (evalSystem rho ts) | ||
| IdJ a t c d x p -> idJ (eval rho a) (eval rho t) (eval rho c) | ||
| (eval rho d) (eval rho x) (eval rho p) | ||
| IdComp a u v w p q -> idComp (eval rho a) (eval rho u) (eval rho v) | ||
| (eval rho w) (eval rho p) (eval rho q) | ||
| _ -> error $ "Cannot evaluate " ++ show v | ||
|
|
||
| evals :: Env -> [(Ident,Ter)] -> [(Ident,Val)] | ||
|
|
@@ -286,6 +293,7 @@ inferType v = case v of | |
| -- VUnGlueElem _ b _ -> b -- This is wrong! Store the type?? | ||
| VUnGlueElemU _ b _ -> b | ||
| VIdJ _ _ c _ x p -> app (app c x) p | ||
| VIdComp a u _ w _ _ -> VId a u w | ||
| _ -> error $ "inferType: not neutral " ++ show v | ||
|
|
||
| (@@) :: ToFormula a => Val -> a -> Val | ||
|
|
@@ -444,6 +452,22 @@ isIdPair :: Val -> Bool | |
| isIdPair VIdPair{} = True | ||
| isIdPair _ = False | ||
|
|
||
| idComp :: Val -> Val -> Val -> Val -> Val -> Val -> Val | ||
| idComp a u v w pId qId = case (pId, qId) of | ||
| (VIdPair p ps, qId) | eps `member` ps -> qId | ||
| (pId, VIdPair q qs) | eps `member` qs -> pId | ||
| (VIdPair p ps, VIdPair q qs) -> | ||
| let i:j:_ = freshs [a,u,v,w,pId,qId] in | ||
| let | ||
| rs = unionSystem | ||
| (unionSystem | ||
| (border (q @@ (Atom i :/\: Atom j)) ps) | ||
| (border (p @@ (Atom i :/\: NegAtom j)) qs)) | ||
|
||
| (mkSystem [((i ~> 0), p @@ NegAtom j), ((i ~> 1), q @@ Atom j)]) | ||
| in | ||
| VIdPair (VPLam i (comp j a v rs)) (joinSystem (border ps qs)) | ||
| _ -> VIdComp a u v w pId qId | ||
|
|
||
|
|
||
| ------------------------------------------------------------------------------- | ||
| -- | HITs | ||
|
|
@@ -897,6 +921,8 @@ instance Convertible Val where | |
| (VId a u v,VId a' u' v') -> conv ns (a,u,v) (a',u',v') | ||
| (VIdJ a u c d x p,VIdJ a' u' c' d' x' p') -> | ||
| conv ns [a,u,c,d,x,p] [a',u',c',d',x',p'] | ||
| (VIdComp a u b w p q,VIdComp a' u' b' w' p' q') -> | ||
| conv ns [a,u,b,w,p,q] [a',u',b',w',p',q'] | ||
| _ -> False | ||
|
|
||
| instance Convertible Ctxt where | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these two cases really needed? Isn't it possible to get the next case to cover them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would guess @IanOrton just wanted to take some shortcuts here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They seem a little dangerous to me, and if I comment them out the examples doesn't go through (even if one fixes the bug I found).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, I'm not sure. I think that they are needed to make sure that
refl . pwill reduce even whenpis just a variable. To hit the other case you need to know thatpis in fact aVIdPair. The behaviour should agree when the cases overlap so I've now moved these two cases after the third one. But maybe this behaviour is too strong? Do we wantrefl . pto reduce in the case whenpis an undetermined variables of typeId A a b?