Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
File renamed without changes.
4 changes: 2 additions & 2 deletions examples/matrix_search/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ PROJ_DEPS=../../src ../../tools ../../traq.cabal

all: matrix_search.qpl depth3_NAND_formula.qpl

matrix_search.qpl: matrix_search.qb $(PROJ_DEPS)
matrix_search.qpl: matrix_search.traq $(PROJ_DEPS)
cd ../../ && cabal run compile -- \
-i examples/matrix_search/$< \
-o examples/matrix_search/$@ \
-p 0.001 \
--arg N=20 --arg M=10

depth3_NAND_formula.qpl: depth3_NAND_formula.qb $(PROJ_DEPS)
depth3_NAND_formula.qpl: depth3_NAND_formula.traq $(PROJ_DEPS)
cd ../../ && cabal run compile -- \
-i examples/matrix_search/$< \
-o examples/matrix_search/$@ \
Expand Down
2 changes: 1 addition & 1 deletion examples/matrix_search/demo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ expectedCost ::
IO Double
expectedCost n m matrix eps = do
-- load the program
Right loaded_program <- parseFromFile (P.programParser @primT') "examples/matrix_search/matrix_search.qb"
Right loaded_program <- parseFromFile (P.programParser @primT') "examples/matrix_search/matrix_search.traq"
let program = P.mapSize (Sym.unSym . Sym.subst "M" (Sym.con m) . Sym.subst "N" (Sym.con n)) loaded_program
program_annotated <- either fail pure $ A.annotateProgWithErrorBudget (A.failProb eps) program

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions examples/tree_generator/demo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ worstCaseCost
-- worst case cost (ignores data)
worstCaseCost ctx eps = do
-- load the program
loaded_program <- either (fail . show) pure =<< parseFromFile (P.programParser @primT') "examples/tree_generator/tree_generator_01_knapsack.qb"
loaded_program <- either (fail . show) pure =<< parseFromFile (P.programParser @primT') "examples/tree_generator/tree_generator_01_knapsack.traq"
let program = P.mapSize (substCtx ctx) loaded_program
program_annotated <- either fail pure $ A.annotateProgWithErrorBudget (A.failProb eps) program

return $ getCost $ A.costQProg program_annotated
-- expected cost (depends on data)
expectedCost ctx@Ctx{..} eps = do
-- load the program
loaded_program <- either (fail . show) pure =<< parseFromFile (P.programParser @primT') "examples/tree_generator/tree_generator_01_knapsack.qb"
loaded_program <- either (fail . show) pure =<< parseFromFile (P.programParser @primT') "examples/tree_generator/tree_generator_01_knapsack.traq"
let program = P.mapSize (substCtx ctx) loaded_program
-- putStrLn $ replicate 80 '='
-- putStrLn $ PP.toCodeString program
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions experiments/compile_loc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ matSearch n eps =
runExpt
ExptConfig
{ expt_name = "Matrix Search"
, fname = "examples/matrix_search/matrix_search.qb"
, fname = "examples/matrix_search/matrix_search.traq"
, params = [("N", n), ("M", n)]
, precision = eps
, show_qpl = False
Expand All @@ -66,7 +66,7 @@ listSearch n eps =
runExpt
ExptConfig
{ expt_name = "List Search"
, fname = "examples/primitives/search.qb"
, fname = "examples/primitives/search.traq"
, params = [("N", n)]
, precision = eps
, show_qpl = False
Expand Down
6 changes: 3 additions & 3 deletions experiments/timing.hs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ matrixSearchExpt = do
depth3NAND :: IO ()
depth3NAND = do
putStrLn "\nDepth 3 NAND Tree:"
sprog <- loadProgramFromFile "examples/matrix_search/depth3_NAND_formula.qb"
sprog <- loadProgramFromFile "examples/matrix_search/depth3_NAND_formula.traq"
let eps = 0.001 :: Double
let ns = [10, 20 .. 120]
putStrLn "n, time, qubits"
Expand All @@ -111,7 +111,7 @@ depth3NAND = do
hillClimbExpt :: IO ()
hillClimbExpt = do
putStrLn "\nHillclimb:"
sprog <- loadProgramFromFile "examples/hillclimb/max_sat_hillclimb.qb"
sprog <- loadProgramFromFile "examples/hillclimb/max_sat_hillclimb.traq"
let eps = 0.001 :: Double
let ns = [10, 20 .. 100] ++ [200, 300 .. 1000]
putStrLn "n, time, qubits"
Expand All @@ -127,7 +127,7 @@ hillClimbExpt = do
triangleFinding :: IO ()
triangleFinding = do
putStrLn "\nTriangle Finding:"
sprog <- loadProgramFromFile "examples/triangle_finding.qb"
sprog <- loadProgramFromFile "examples/triangle_finding.traq"
let eps = 0.001 :: Double
let ns = [10, 20 .. 120]
putStrLn "N, time, qubits"
Expand Down
2 changes: 1 addition & 1 deletion test/Traq/Examples/ClusteringAlgorithmSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Test.Hspec
import TestHelpers (expectRight)

examplePath :: String
examplePath = "examples/clustering_algorithm.qb"
examplePath = "examples/clustering_algorithm.traq"

spec :: Spec
spec = describe "Clustering Algorithm" $ do
Expand Down
2 changes: 1 addition & 1 deletion test/Traq/Examples/DepthThreeNandFormulaSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Test.Hspec
import TestHelpers (expectRight)

examplePath :: String
examplePath = "examples/matrix_search/depth3_NAND_formula.qb"
examplePath = "examples/matrix_search/depth3_NAND_formula.traq"

spec :: Spec
spec = describe "Depth 3 NAND Formula" $ do
Expand Down
2 changes: 1 addition & 1 deletion test/Traq/Examples/EvanMansourSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Test.Hspec
import TestHelpers (assertRight, expectRight)

examplePath :: String
examplePath = "examples/cryptanalysis/evan_mansour.qb"
examplePath = "examples/cryptanalysis/evan_mansour.traq"

type SPrim size = Primitive (SimonsFindXorPeriod size Double)

Expand Down
2 changes: 1 addition & 1 deletion test/Traq/Examples/GroverMeetsSimonSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Test.Hspec
import TestHelpers

examplePath :: String
examplePath = "examples/cryptanalysis/grover_meets_simon.qb"
examplePath = "examples/cryptanalysis/grover_meets_simon.traq"

type P = WorstCasePrims (Sym.Sym SizeT) Double

Expand Down
2 changes: 1 addition & 1 deletion test/Traq/Examples/NonDetSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import TestHelpers
spec :: Spec
spec = do
describe "SimpleExample" $ do
let load = parseFromFile (PP.programParser @(DefaultPrims (Sym.Sym SizeT) Double)) "examples/primitives/nondet.qb"
let load = parseFromFile (PP.programParser @(DefaultPrims (Sym.Sym SizeT) Double)) "examples/primitives/nondet.traq"
it "parses" $ do
mEx <- load
assertRight mEx
Expand Down
2 changes: 1 addition & 1 deletion test/Traq/Examples/PeriodFindingSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import TestHelpers
type SPrim size = Primitive (SimonsFindXorPeriod size Double)

examplePath :: String
examplePath = "examples/cryptanalysis/period_finding.qb"
examplePath = "examples/cryptanalysis/period_finding.traq"

loadPeriodFinding ::
-- | bitsize @n@ of the inputs/outputs
Expand Down
2 changes: 1 addition & 1 deletion test/Traq/Examples/SteepMaxKSatSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import TestHelpers (expectRight)
type P = Primitive (QMax (Sym.Sym SizeT) Double)

examplePath :: String
examplePath = "examples/hillclimb/steep_max_sat.qb"
examplePath = "examples/hillclimb/steep_max_sat.traq"

spec :: Spec
spec = describe "Steep max-k-sat" $ do
Expand Down
2 changes: 1 addition & 1 deletion test/Traq/Examples/ThreeRoundFeistelAttackSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import TestHelpers (expectRight)
type P = Primitive (SimonsFindXorPeriod (Sym.Sym SizeT) Double)

examplePath :: String
examplePath = "examples/cryptanalysis/3_round_feistel.qb"
examplePath = "examples/cryptanalysis/3_round_feistel.traq"

spec :: Spec
spec = describe "3 round feistel attack" $ do
Expand Down
8 changes: 4 additions & 4 deletions test/Traq/Examples/TreeGeneratorSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ loadKnapsack ::
SizeT ->
IO (Program Prim')
loadKnapsack n w p k = do
Right prog <- parseFromFile (programParser @Prim) "examples/tree_generator/tree_generator_01_knapsack.qb"
Right prog <- parseFromFile (programParser @Prim) "examples/tree_generator/tree_generator_01_knapsack.traq"
return $
prog
& mapSize (Sym.subst "N" (Sym.con n))
Expand All @@ -93,13 +93,13 @@ spec :: Spec
spec = do
describe "Tree Generator Example" $ do
it "parses" $ do
expectRight =<< parseFromFile (programParser @Prim) "examples/tree_generator/tree_generator_01_knapsack.qb"
expectRight =<< parseFromFile (programParser @Prim) "examples/tree_generator/tree_generator_01_knapsack.traq"
-- p `shouldBe` treeGeneratorExample (Sym.var "N") (Sym.var "W") (Sym.var "P")
return ()

it "typechecks" $ do
p <-
parseFromFile (programParser @Prim) "examples/tree_generator/tree_generator_01_knapsack.qb"
parseFromFile (programParser @Prim) "examples/tree_generator/tree_generator_01_knapsack.traq"
>>= expectRight
assertRight $ (typeCheckProg @Prim) p

Expand All @@ -122,7 +122,7 @@ spec = do
describe "Loop example" $ do
it "parses" $ do
p <-
parseFromFile (programParser @(Core (Sym.Sym SizeT) Double)) "examples/tree_generator/loop_example.qb"
parseFromFile (programParser @(Core (Sym.Sym SizeT) Double)) "examples/tree_generator/loop_example.traq"
>>= expectRight
p `shouldBe` loopExample (Sym.var "N") (Sym.var "W")

Expand Down
2 changes: 1 addition & 1 deletion test/Traq/Examples/TriangleCycleSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import TestHelpers
type P = DefaultPrims (Sym.Sym SizeT) Double

examplePath :: String
examplePath = "examples/triangle_finding.qb"
examplePath = "examples/triangle_finding.traq"

spec :: Spec
spec = describe "Triangle Cycle Finding" $ do
Expand Down
6 changes: 3 additions & 3 deletions test/Traq/Primitives/Amplify/PreludeSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ spec = describe "amplify" $ do
p <-
parseFromFile
P.programParser
"examples/primitives/amplify/amplify1.qb"
"examples/primitives/amplify/amplify1.traq"
>>= expectRight
p `shouldBe` exampleProgram1 @(Sym.Sym Int) @Double (Sym.var "N")

Expand All @@ -263,7 +263,7 @@ spec = describe "amplify" $ do
p <-
parseFromFile
P.programParser
"examples/primitives/amplify/amplify2.qb"
"examples/primitives/amplify/amplify2.traq"
>>= expectRight
p `shouldBe` exampleProgram2 @(Sym.Sym Int) @Double (Sym.var "N")

Expand All @@ -286,7 +286,7 @@ spec = describe "amplify" $ do
p <-
parseFromFile
P.programParser
"examples/primitives/amplify/amplify3.qb"
"examples/primitives/amplify/amplify3.traq"
>>= expectRight
p `shouldBe` exampleProgram3 @(Sym.Sym Int) @Double (Sym.var "N")

Expand Down
2 changes: 1 addition & 1 deletion test/Traq/Primitives/TreeSearchSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ spec = do
p <-
parseFromFile
(programParser @(TreeSearch (Sym.Sym SizeT) Double))
"examples/primitives/treesearch.qb"
"examples/primitives/treesearch.traq"
>>= expectRight
p `shouldBe` exampleProgram (Sym.var "N") (Sym.con 2)

Expand Down
4 changes: 2 additions & 2 deletions test/Traq/ProtoLang/ParserSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ spec = do

describe "parse file" $ do
it "parses example" $ do
e <- parseFromFile (programParser @(DefaultPrims (Sym.Sym SizeT) Double)) "examples/matrix_search/matrix_search.qb" >>= expectRight
e <- parseFromFile (programParser @(DefaultPrims (Sym.Sym SizeT) Double)) "examples/matrix_search/matrix_search.traq" >>= expectRight
let e' = rewriteAST flattenSeq e
e' `shouldBe` mkMatrixExample (\ty f -> PrimCallE $ Primitive [f] $ QAny $ QSearchCFNW $ PrimSearch AnyK ty) (Sym.var "N") (Sym.var "M")

Expand All @@ -100,7 +100,7 @@ spec = do
roundTrip (matrixExampleS 4 5)
roundTrip (matrixExampleS 10 10)
it "max_sat_hillclimb" $ do
e_sym <- expectRight =<< parseFromFile (programParser @(DefaultPrims (Sym.Sym SizeT) Double)) "examples/hillclimb/max_sat_hillclimb.qb"
e_sym <- expectRight =<< parseFromFile (programParser @(DefaultPrims (Sym.Sym SizeT) Double)) "examples/hillclimb/max_sat_hillclimb.traq"
let e =
e_sym
& mapSize (Sym.subst "n" 10)
Expand Down
Loading