Skip to content
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

feat: Allow writing holes which are solved by BRAT #59

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
fec6dc4
Add holes(!)
croyzor Nov 8, 2024
3c1f4ec
WIP: Merge better nat solving
croyzor Nov 8, 2024
0f7d13d
Revert `run` namespacing changes
croyzor Nov 8, 2024
a53435b
Add defines
croyzor Nov 26, 2024
fec3263
rename some variables
croyzor Nov 26, 2024
c8cb33f
drive-by: Give everything created with anext a label
croyzor Nov 27, 2024
5b2cb45
Replace define -> instantiate
croyzor Nov 27, 2024
ed531ae
Define targets instead of sources (fixes unified.brat)
croyzor Nov 27, 2024
c48da2c
fix: Dodgy demandSucc logic
croyzor Nov 27, 2024
95a4c2d
Define tgts to respective srcs in invertNatVal
croyzor Nov 27, 2024
37ef790
Allow hopes to be removed from the set
croyzor Nov 27, 2024
7626077
Merge remote-tracking branch 'origin/main' into holes
croyzor Nov 27, 2024
cebc93b
Cleanup Error.hs
croyzor Nov 27, 2024
c6e7c3c
Add golden file for unsolved hope error
croyzor Nov 27, 2024
4e776cc
XFAIL infer.brat because we don't compile `Pow`
croyzor Nov 27, 2024
541f35a
Apply lints
croyzor Nov 27, 2024
8ad05de
Revert "drive-by: Give everything created with anext a label"
croyzor Nov 27, 2024
3fe88aa
Merge remote-tracking branch 'origin/main' into holes
croyzor Nov 28, 2024
0cef0d3
drive-by: Give labels to more `next` calls
croyzor Nov 28, 2024
ef85987
Merge remote-tracking branch 'origin/main' into holes
croyzor Dec 3, 2024
c4ebd8c
[cleanup] Remove News datatype from this PR
croyzor Dec 3, 2024
991e0dc
Update brat/Brat/Checker/Monad.hs
croyzor Dec 3, 2024
f82f25c
refactor: Move Nat building code to Helpers
croyzor Dec 3, 2024
f75ce8c
refactor: Replace mkStaticNum with a call to buildNatVal
croyzor Dec 3, 2024
da08608
Revert changes to FC
croyzor Dec 3, 2024
575474e
Apply suggestions from code review
croyzor Dec 3, 2024
c6555b9
rename HopeSet -> Hopes
croyzor Dec 3, 2024
d077d4c
refactor: Make GHC enforce that Hopes are InPorts
croyzor Dec 3, 2024
741d896
refactor: Curry ANewHope
croyzor Dec 3, 2024
bb431ef
refactor: Expose only a simpler version of typeEq
croyzor Dec 3, 2024
b846a62
cosmetic: Get rid of unused variable
croyzor Dec 3, 2024
8bee0d0
cleanup: Get rid of outdated comments
croyzor Dec 3, 2024
631509e
Don't reexport nat building from SolveHoles
croyzor Dec 3, 2024
5a3ffd8
[broken] New example
croyzor Dec 3, 2024
7286b0c
refactor: Make better use of `toEnd` function
croyzor Dec 3, 2024
787baed
Fill in the missing case for demandSucc
croyzor Dec 3, 2024
ca5df29
fix: Add missing unelab cases
croyzor Dec 6, 2024
837eeed
lint: Redundant brackets
croyzor Dec 6, 2024
722e610
Merge remote-tracking branch 'origin/main' into HEAD
acl-cqc Dec 9, 2024
da57ef6
Merge remote-tracking branch 'origin/main' into HEAD
acl-cqc Dec 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fill in the missing case for demandSucc
  • Loading branch information
croyzor committed Dec 6, 2024
commit 787baedce4d07f50fe31e9051b44f6b904d918c5
14 changes: 7 additions & 7 deletions brat/Brat/Checker/SolvePatterns.hs
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,13 @@ unifyNum (NumValue lup lgro) (NumValue rup rgro)
-- 2^k * x
-- = 2^k * (y + 1)
-- = 2^k + 2^k * y
demandSucc _sm@(StrictMono _k (Linear (VPar (ExEnd _x)))) = error "Todo..." {-do
-- This is sus because we don't have any tgt?
ySrc <- invertNatVal (NamedPort x "") (NumValue 1 (StrictMonoFun sm))
let y = nVar (VPar (toEnd ySrc))
solveNumMeta (ExEnd x) (nPlus 1 y)
pure $ nPlus ((2 ^ k) - 1) $ n2PowTimes k y
-}
demandSucc (StrictMono k (Linear (VPar (ExEnd x)))) = do
(_, [(yTgt, _)], [(ySrc, _)], _) <-
next "yId" Id (S0, Some (Zy :* S0)) (REx ("value", Nat) R0) (REx ("value", Nat) R0)

defineSrc ySrc (VNum (nVar (VPar (toEnd yTgt))))
instantiateMeta (ExEnd x) (VNum (nPlus 1 (nVar (VPar (toEnd yTgt)))))
pure $ nPlus ((2 ^ k) - 1) $ n2PowTimes k (nVar (VPar (toEnd ySrc)))
-- 2^k * x
-- = 2^k * (y + 1)
-- = 2^k + 2^k * y
Expand Down
9 changes: 6 additions & 3 deletions brat/examples/unified.brat
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ swapFront(_, _, []) = []
swapFront(_, _, [x]) = [x]
swapFront(X, _, cons(x, cons(y, zs))) = cons(y, cons(x, zs))

mapAndConquer(X :: *, Y :: *, n :: #, f :: { X -> Y }, Vec(X, succ(n))) -> Vec(Y, succ(n))
mapAndConquer(_, _, doub(n), f, xsl =, x ,= xsr) = mapAndConquer(!, !, !, f, xsl) =, f(x) ,= mapAndConquer(!, !, !, f, xsr)
mapAndConquer(_, _, succ(n), f, xsl =,= xsr) = mapAndConquer(!, !, !, f, xsl) =,= mapAndConquer(!, !, !, f, xsr)
filled(X :: *, n :: #, Vec(X, full(n))) -> Vec(X, full(n))
filled(_, n, xsl =, x ,= xsr) = xsl =, x ,= xsr

-- mapAndConquer(X :: *, Y :: *, n :: #, f :: { X -> Y }, Vec(X, succ(n))) -> Vec(Y, succ(n))
-- mapAndConquer(_, _, doub(n), f, xsl =, x ,= xsr) = mapAndConquer(!, !, n, f, xsl) =, f(x) ,= mapAndConquer(!, !, n, f, xsr)
-- mapAndConquer(_, _, succ(doub(n)), f, xsl =,= xsr) = mapAndConquer(!, !, n, f, xsl) =,= mapAndConquer(!, !, n, f, xsr)