-
Notifications
You must be signed in to change notification settings - Fork 8
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
Integrate top down #155
Open
darya-ver
wants to merge
37
commits into
TyGuS:new_webapp
Choose a base branch
from
EpicOrange:integrate_top_down
base: new_webapp
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
Integrate top down #155
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
9895dba
Start integrating our synthesize
EpicOrange 4f37917
Fixed some type errors but stuck at implementing CheckMonad
EpicOrange be9d10e
got the code compiling to new branch, can't seem to test yet
EpicOrange 1630cb5
cleaned up the code
EpicOrange 317c083
moved files into our own TopDown directory
EpicOrange b64adcc
turned dfs into one function instead of dfsTop and dfs
EpicOrange 8b29f58
cleaned up code and changed dfsNew to dfs
EpicOrange 030f06f
Add some notes for using check
EpicOrange 2ca1807
Started changing getUnifiedFunctions to use LogicT
EpicOrange 6536214
Got LogicT version of dfs to lazily return the first valid result
EpicOrange a14c584
Changed it to evaluate solutions lazily
EpicOrange 2d5686f
Starting to rewrite dfs again using type holes
EpicOrange 59801bf
WIP writing the bfs
EpicOrange 7e639ab
Maybe solveTypeConstraint is broken since it doesn't unify Int,Int
EpicOrange b5b8efe
Merge new_webapp changes
EpicOrange 37de678
Moved code back to dfs and made check work
EpicOrange f7615ee
adding our timing stuff to synthesize
EpicOrange 3350bff
Add iterative deepening method for dfs
EpicOrange 6506802
right before changing dfs into logicT stuff
EpicOrange b53b7e6
doesn't compile... need to change dfs to one main function instead of 2
EpicOrange e60cc17
added comment files and copied things cuz we lazy
EpicOrange 40f1f6a
revereted back to compiling dfs, still have broken unifiedfuncs from …
EpicOrange c4682be
changed getUnified to return logicT, setting code up for zheng change…
EpicOrange 1c061ea
thought we fixed 'int /= bool' but we didnt
EpicOrange e54ff28
we think we are done????????????
EpicOrange fd0bf16
cleaned up code git add src/TopDown/Synthesize.hs git add src/TopDown…
EpicOrange b80d868
updated scrip stuff - arguments are in wrong order
EpicOrange 8051385
saving code before changing depth to size
EpicOrange a22e228
got search based on size working. running pretty fastgit add benchmar…
EpicOrange d92b747
testing depth and size into .tsv files
EpicOrange 6b7efb3
rerun depth tests
EpicOrange dce7a27
cleaned up code - ready for PR
EpicOrange fff4045
Added support for higher order functions
EpicOrange cb5333f
before cleaning... has some HO stuff
EpicOrange cd4ba26
Clean up top-down code used for tests
EpicOrange cc4b13a
Update test data
EpicOrange 575105d
attempting HO... getting stuck
EpicOrange 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 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 |
---|---|---|
@@ -0,0 +1,126 @@ | ||
module HooglePlus.SynthesizeTheirs(synthesize, envToGoal) where | ||
|
||
import Database.Environment | ||
import Database.Util | ||
import qualified HooglePlus.Abstraction as Abstraction | ||
import PetriNet.PNSolver | ||
import Synquid.Error | ||
import Synquid.Logic | ||
import Synquid.Parser | ||
import Synquid.Pretty | ||
import Synquid.Program | ||
import Synquid.Resolver | ||
import Synquid.Type | ||
import Synquid.Util | ||
import Types.Common | ||
import Types.Environment | ||
import Types.Experiments | ||
import Types.Program | ||
import Types.Solver | ||
import Types.TypeChecker | ||
import Types.Type | ||
import Types.IOFormat | ||
import HooglePlus.Utils | ||
import HooglePlus.IOFormat | ||
import Examples.ExampleChecker | ||
|
||
import Control.Applicative ((<$>)) | ||
import Control.Concurrent.Chan | ||
import Control.Exception | ||
import Control.Lens | ||
import Control.Monad | ||
import Control.Monad.Except | ||
import Control.Monad.Logic | ||
import Control.Monad.Reader | ||
import Control.Monad.State | ||
import Data.Either | ||
import Data.List | ||
import Data.List.Extra (nubOrdOn) | ||
import qualified Data.Map as Map | ||
import Data.Map (Map) | ||
import Data.Maybe | ||
import qualified Data.Set as Set | ||
import Data.Set (Set) | ||
import Data.Time.Clock | ||
import Data.Time.Format | ||
import System.Exit | ||
import Text.Parsec.Indent | ||
import Text.Parsec.Pos | ||
import Text.Printf (printf) | ||
|
||
|
||
envToGoal :: Environment -> String -> IO Goal | ||
envToGoal env queryStr = do | ||
let transformedSig = "goal :: " ++ queryStr ++ "\ngoal = ??" | ||
let parseResult = flip evalState (initialPos "goal") $ runIndentParserT parseProgram () "" transformedSig | ||
case parseResult of | ||
Left parseErr -> let e = toErrorMessage parseErr | ||
in putDoc (pretty e) >> putDoc linebreak >> error (prettyShow e) | ||
Right (funcDecl:decl:_) -> case decl of | ||
Pos _ (SynthesisGoal id uprog) -> do | ||
let Pos _ (FuncDecl _ sch) = funcDecl | ||
let goal = Goal id env sch uprog 3 $ initialPos "goal" | ||
let spec = runExcept $ evalStateT (resolveSchema (gSpec goal)) (initResolverState { _environment = env }) | ||
case spec of | ||
Right sp -> do | ||
let (env', monospec) = updateEnvWithBoundTyVars sp env | ||
let (env'', destinationType) = updateEnvWithSpecArgs monospec env' | ||
return $ goal { gEnvironment = env'', gSpec = sp } | ||
Left parseErr -> putDoc (pretty parseErr) >> putDoc linebreak >> error (prettyShow parseErr) | ||
_ -> error "parse a signature for a none goal declaration" | ||
|
||
synthesize :: SearchParams -> Goal -> [Example] -> Chan Message -> IO () | ||
synthesize searchParams goal examples messageChan = catch (do | ||
let rawEnv = gEnvironment goal | ||
let goalType = gSpec goal | ||
let destinationType = lastType (toMonotype goalType) | ||
let useHO = _useHO searchParams | ||
let rawSyms = rawEnv ^. symbols | ||
let hoCands = rawEnv ^. hoCandidates | ||
envWithHo <- if useHO -- add higher order query arguments | ||
then do | ||
let args = rawEnv ^. arguments | ||
let hoArgs = Map.filter (isFunctionType . toMonotype) args | ||
let hoFuns = map (\(k, v) -> (k ++ hoPostfix, withSchema toFunType v)) (Map.toList hoArgs) | ||
return $ rawEnv { | ||
_symbols = rawSyms `Map.union` Map.fromList hoFuns, | ||
_hoCandidates = hoCands ++ map fst hoFuns | ||
} | ||
else do | ||
let syms = Map.filter (not . isHigherOrder . toMonotype) rawSyms | ||
return $ rawEnv { | ||
_symbols = Map.withoutKeys syms $ Set.fromList hoCands, | ||
_hoCandidates = [] | ||
} | ||
-- putStrLn $ "Component number: " ++ show (Map.size $ allSymbols env) | ||
let args = Monotype destinationType : Map.elems (envWithHo ^. arguments) | ||
-- start with all the datatypes defined in the components, first level abstraction | ||
let rs = _refineStrategy searchParams | ||
let initCover = case rs of | ||
SypetClone -> Abstraction.firstLvAbs envWithHo (Map.elems (allSymbols envWithHo)) | ||
TyGar0 -> emptySolverState ^. (refineState . abstractionCover) | ||
TyGarQ -> Abstraction.specificAbstractionFromTypes envWithHo args | ||
NoGar -> Abstraction.specificAbstractionFromTypes envWithHo args | ||
NoGar0 -> emptySolverState ^. (refineState . abstractionCover) | ||
let is = | ||
emptySolverState | ||
{ _searchParams = searchParams | ||
, _refineState = emptyRefineState { _abstractionCover = initCover } | ||
, _messageChan = messageChan | ||
, _typeChecker = emptyChecker { _checkerChan = messageChan } | ||
} | ||
|
||
-- before synthesis, first check that user has provided valid examples | ||
let exWithOutputs = filter ((/=) "??" . output) examples | ||
checkResult <- checkExamples envWithHo goalType exWithOutputs messageChan | ||
-- preseedExamples <- augmentTestSet envWithHo goalType | ||
let augmentedExamples = examples -- nubOrdOn inputs $ examples ++ preseedExamples | ||
case checkResult of | ||
Right errs -> error (unlines ("examples does not type check" : errs)) | ||
Left _ -> evalStateT (runPNSolver envWithHo goalType augmentedExamples) is) | ||
(\e -> | ||
writeChan messageChan (MesgLog 0 "error" (show e)) >> | ||
writeChan messageChan (MesgClose (CSError e)) >> | ||
printResult (encodeWithPrefix (QueryOutput [] (show e) [])) >> | ||
error (show e)) | ||
-- return () |
This file contains 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 |
---|---|---|
|
@@ -22,7 +22,8 @@ import Database.Generate | |
import Database.Download | ||
import Database.Util | ||
import Synquid.Util (showme) | ||
import HooglePlus.Synthesize | ||
import TopDown.Synthesize | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See TopDown/Synthesize about how to change this |
||
-- import HooglePlus.Synthesize | ||
import HooglePlus.Stats | ||
import Types.Encoder | ||
import HooglePlus.GHCChecker | ||
|
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.
Please revert this file renaming