Skip to content

Commit 3137f1f

Browse files
committed
rename + slight erase modif
1 parent 8471301 commit 3137f1f

File tree

2 files changed

+27
-47
lines changed

2 files changed

+27
-47
lines changed

AesopTest/Forward/Benchmark.lean

+9-9
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ elab "bchmk " nIter:num " with " t:term " using " r:term : command => do
4646

4747
def pows (n : Nat) : List Nat := (List.range n).map (2 ^ ·)
4848
/- The old impl.'s premise order. -/
49-
def steps (n : Nat) : List Nat := (List.range n).reverse ++ [n]
50-
def isteps (n : Nat) : List Nat := (List.range' 1 (n - 1)).reverse ++ [0]
49+
def steps (n : Nat) : List Nat := (List.range' 1 (n - 1))
5150

5251
/-
5352
/-
@@ -60,12 +59,13 @@ def isteps (n : Nat) : List Nat := (List.range' 1 (n - 1)).reverse ++ [0]
6059
6160
6261
63-
**Uncomment to run tests**
62+
/-**Uncomment to run tests**-/
6463
local notation "k" => 6
6564
66-
bchmk 3 with [2,3,4,5,6] using fun n ↦ runTestTrans n 20
67-
bchmk 3 with isteps k using fun n ↦ runTestErase k 0 k n 0
68-
bchmk 3 with (pows 5) using fun n ↦ runTestIndep 6 n 0
69-
bchmk 3 with (pows 6) using fun n ↦ runTestCascade n
70-
bchmk 3 with (pows 6) using fun n ↦ runTestCluster n 3 (2 ^ 5 / n)
71-
-/
65+
set_option maxHeartbeats 100000000 in
66+
--bchmk 1 with [32] using fun n ↦ runTestTrans n 0
67+
bchmk 30 with steps k using fun n ↦ runTestDepth k 0 100 n 0
68+
--bchmk 1 with (pows 6) using fun n ↦ runTestIndep 6 n 100
69+
--bchmk 3 with (pows 6) using fun n ↦ runTestCascade n
70+
--bchmk 3 with (pows 6) using fun n ↦ runTestCluster n 3 (2 ^ 5 / n)
71+
--/

AesopTest/Forward/Synth.lean

+18-38
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@ import AesopTest.Forward.Definitions
1010
open Aesop
1111
open Lean Lean.Elab Lean.Elab.Command Lean.Elab.Term Lean.Parser
1212

13-
--set_option aesop.dev.statefulForward true
14-
15-
elab "test " nPremises:num nQs:num nLemmas:num erase:num a:num " by " ts:tacticSeq : command => do
13+
elab "test " nPremises:num nQs:num nLemmas:num depth:num a:num " by " ts:tacticSeq : command => do
1614
let some nPs := nPremises.raw.isNatLit?
1715
| throwUnsupportedSyntax
1816
let some nQs := nQs.raw.isNatLit?
1917
| throwUnsupportedSyntax
2018
let some nLemmas := nLemmas.raw.isNatLit?
2119
| throwUnsupportedSyntax
22-
let some erase := erase.raw.isNatLit?
20+
let some depth := depth.raw.isNatLit?
2321
| throwUnsupportedSyntax
2422
let some a := a.raw.isNatLit?
2523
| throwUnsupportedSyntax
@@ -43,25 +41,6 @@ elab "test " nPremises:num nQs:num nLemmas:num erase:num a:num " by " ts:tacticS
4341
$(mkIdent pName):ident $(mkIdent `n)))
4442
let sig : Term ← `(∀ $(mkIdent `n) $binders:bracketedBinder*, True)
4543

46-
/- Rule that we are able to complete. -/
47-
48-
let mut mNames := pNames
49-
let bindersM : TSyntaxArray ``Term.bracketedBinder
50-
(mNames.eraseIdxIfInBounds erase).mapIdxM λ i pName => do
51-
`(bracketedBinder| ($(mkIdent $ .mkSimple $ "p" ++ toString i) :
52-
$(mkIdent pName):ident $(mkIdent `n)))
53-
let sigM : Term ← `(∀ $(mkIdent `n) $bindersM:bracketedBinder*, True)
54-
elabCommand $ ← `(command|
55-
@[aesop safe]
56-
axiom $(mkIdent $ .mkSimple $ "lM"):ident : $sigM:term
57-
)
58-
59-
60-
-- ($(mkIdent $ .mkSimple $ "a") : $(mkIdent `A):ident $(mkIdent `n) $(mkIdent `n))
61-
-- Create `axiom li : ∀ n (p1 : P1 n) ... (pm : Pm n), Q → True` for
62-
-- i ∈ [0..nLemmas - 1] and m = nPs
63-
-- ($(mkIdent $ .mkSimple $ "q") : $(mkIdent `Q):ident $(mkIdent `n))
64-
-- ($(mkIdent $ .mkSimple $ "p" ++ toString i) : $(mkIdent pName):ident $(mkIdent `n))
6544
for i in [:nLemmas] do
6645
elabCommand $ ← `(command|
6746
@[aesop safe forward]
@@ -73,34 +52,37 @@ elab "test " nPremises:num nQs:num nLemmas:num erase:num a:num " by " ts:tacticS
7352
-/
7453
/- Active hyps -/
7554
let binders : TSyntaxArray ``Term.bracketedBinder
76-
--pNames.mapIdxM λ i pName => do
77-
(mNames.eraseIdxIfInBounds erase).mapIdxM λ i pName => do
55+
pNames.mapIdxM λ i pName => do
56+
let mut n := a
57+
if i + 1= nPs - depth then n := a + 1
7858
`(bracketedBinder| ($(mkIdent $ .mkSimple $ "p" ++ toString i) :
79-
$(mkIdent pName):ident (snat% $(Syntax.mkNatLit a))))
80-
-- Create `theorem t1 (p1 : P1 (snat% 0)) ... (pm : Pm (snat% 0)) : True := by ts`
59+
$(mkIdent pName):ident (snat% $(Syntax.mkNatLit n))))
60+
-- Create `theorem t1 (p1 : P1 (snat% a)) ... (pm : Pm (snat% a)) : True := by ts`
8161

8262
/- Inert hyps -/
8363
let bindersQ : TSyntaxArray ``Term.bracketedBinder
8464
--pNames.mapIdxM λ i pName => do
8565
(qNames).mapIdxM λ i qName => do
8666
`(bracketedBinder| ($(mkIdent $ .mkSimple $ "q" ++ toString i) :
8767
$(mkIdent qName):ident (snat% $(Syntax.mkNatLit a))))
88-
-- Create `theorem t1 (p1 : P1 (snat% 0)) ... (pm : Pm (snat% 0)) : True := by ts`
68+
-- Create `theorem t1 (p1 : P1 (snat% a)) ... (pm : Pm (snat% a)) : True := by ts`
8969
-- where m = nPs.
9070
elabCommand $ ← `(command|
9171
theorem $(mkIdent $ .mkSimple $ "t") $binders:bracketedBinder* $bindersQ:bracketedBinder*
92-
--($(mkIdent $ .mkSimple $ "a") : $(mkIdent `A):ident (snat% 0) (snat% 0))
9372
: True := by $ts
9473
)
9574

9675
/-
9776
**Uncomment for single test** :
98-
test 6 0 100 1 by
77+
test 6 0 100 1 0 by
9978
set_option maxHeartbeats 5000000 in
100-
set_option aesop.dev.statefulForward false in
79+
set_option aesop.dev.statefulForward true in
10180
set_option trace.profiler true in
10281
saturate
10382
trivial
83+
84+
#check l1
85+
10486
-/
10587

10688
/--
@@ -126,22 +108,20 @@ are saved regardless of their slot's position.
126108
- `nQs` : Number of hypotheses in the context which do not unify with any premise
127109
of any rule.
128110
- `nRs` : Number of rules; here they are all the same.
129-
- `e` : The number associated to the slot for which there is no hypothesis in
130-
the context that match this slot.
131-
If it is greater or equal to the number of premises, the context will contain
132-
hypotheses matching all the slots and the rules will be applied.
111+
- `d` : The depth: This is the number of slots considered before the procedure stops
112+
as the hypotheses are incompatible. This is well defined for `d ∈ [1,nPs]`.
133113
- `a` : Instantiation of the predicates in the rule.
134114
Note that this affects the run time as big number are designed to be much
135115
harder to unify.
136116
-/
137-
def runTestErase (nPs nQs nRs e a : Nat) : CommandElabM Nanos := do
117+
def runTestDepth (nPs nQs nRs d a : Nat) : CommandElabM Nanos := do
138118
let mut nPs := Syntax.mkNatLit nPs
139119
let mut nQs := Syntax.mkNatLit nQs
140120
let mut nRs := Syntax.mkNatLit nRs
141-
let mut e := Syntax.mkNatLit e
121+
let mut d := Syntax.mkNatLit d
142122
let mut a := Syntax.mkNatLit a
143123
liftCoreM $ withoutModifyingState $ liftCommandElabM do
144-
elabCommand <| ← `(test $nPs $nQs $nRs $e $a by
124+
elabCommand <| ← `(test $nPs $nQs $nRs $d $a by
145125
set_option maxRecDepth 1000000 in
146126
set_option maxHeartbeats 5000000 in
147127
time saturate

0 commit comments

Comments
 (0)