Skip to content

Commit 32a45f5

Browse files
committed
fixing toExpr instances
1 parent 44f1018 commit 32a45f5

7 files changed

Lines changed: 19 additions & 11 deletions

File tree

Auto/Embedding/LamBase.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import Auto.MathlibEmulator
1313
-- Simply Typed Lambda Calculus = HOL (without polymorphism)
1414
namespace Auto.Embedding.Lam
1515

16+
open ToExprExtra
17+
1618
/-- Interpreted sorts -/
1719
inductive LamBaseSort
1820
| prop : LamBaseSort -- GLift `Prop`

Auto/Embedding/LamChecker.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ open Lean
1010

1111
namespace Auto.Embedding.Lam
1212

13+
open ToExprExtra
14+
1315
/-- An entry of RTable -/
1416
inductive REntry where
1517
-- Well-formed formulas, with types

Auto/Lib/BinTree.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import Auto.Lib.ToExprExtra
1616

1717
namespace Auto
1818

19+
open ToExprExtra
20+
1921
namespace Bin
2022

2123
private theorem wfAux (n n' : Nat) : n = n' + 2 → n / 2 < n := by

Auto/Lib/ToExprExtra.lean

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ import Lean
22
import Auto.MathlibEmulator
33
open Lean
44

5-
namespace Auto
5+
namespace Auto.ToExprExtra
66

7-
attribute [-instance] Lean.instToExprNat
8-
instance : ToExpr Nat where
7+
scoped instance : ToExpr Nat where
98
toExpr := fun n => .lit (.natVal n)
109
toTypeExpr := .const ``Nat []
1110

12-
attribute [-instance] instToExprInt
13-
instance : ToExpr Int where
11+
scoped instance : ToExpr Int where
1412
toExpr := fun n =>
1513
match n with
1614
| .ofNat n => .app (.const ``Int.ofNat []) (.lit (.natVal n))
@@ -28,4 +26,4 @@ instance : ToExpr Int where
2826
def instExprToExprId (ty : Expr) : ToExpr Expr :=
2927
{ toExpr := id, toTypeExpr := ty}
3028

31-
end Auto
29+
end Auto.ToExprExtra

Auto/Tactic.lean

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@ def callNative_checker
380380
open LamReif Embedding.Lam in
381381
def callMkMVar_checker
382382
(nonempties : Array REntry) (valids : Array REntry) :
383-
ReifM (Array (REntry × DTr) × Array (REntry × DTr) × MVarId × Expr × LamTerm × Nat × Array Nat) := do
383+
ReifM (Array (REntry × DTr) × Array (REntry × DTr) × MVarId ×
384+
Expr × LamTerm × Array (FVarId × Expr) × Array Nat) := do
384385
let tyVal ← LamReif.getTyVal
385386
let varVal ← LamReif.getVarVal
386387
let lamEVarTy ← LamReif.getLamEVarTy
@@ -583,7 +584,7 @@ where
583584
let (exportFacts', _) ← LamReif.preprocess exportFacts exportInds
584585
exportFacts := exportFacts'.append (← LamReif.auxLemmas exportFacts)
585586
-- **Query the dummy prover which creates a metavariable**
586-
let (nonemptyWithDTrs, validWithDTrs, goalId, proof, proofLamTerm, natoms, etoms) ←
587+
let (nonemptyWithDTrs, validWithDTrs, goalId, proof, proofLamTerm, atoms, etoms) ←
587588
callMkMVar_checker exportInhs exportFacts
588589
LamReif.newAssertion proof (.leaf "by_native::queryNative") proofLamTerm
589590
let etomInstantiated ← LamReif.validOfInstantiateForall (.valid [] proofLamTerm) (etoms.map .etom)
@@ -593,7 +594,7 @@ where
593594
Reif.setDeclName? declName?
594595
let checker ← LamReif.buildCheckerExprFor contra
595596
let contra ← Meta.mkAppM ``Embedding.Lam.LamThmValid.getFalse #[checker]
596-
let (_, goalId) ← goalId.introN (natoms + etoms.size)
597+
let (_, goalId) ← goalId.introN (atoms.size + etoms.size)
597598
let (goalCtx, goalId) ← goalId.introN (exportInhs.size + exportFacts.size)
598599
let goalCtxWithDeriv := goalCtx.zip ((nonemptyWithDTrs ++ validWithDTrs).map Prod.snd)
599600
return (contra, goalId, goalCtxWithDeriv)

Auto/Translation/Lam2DAtomAsFVar.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def callNativeWithAtomAsFVar
230230
@[inherit_doc callNativeWithAtomAsFVar]
231231
def callMkMVarWithAtomAsFVar
232232
(nonemptiesWithDTr : Array (REntry × DTr)) (validsWithDTr : Array (REntry × DTr)) :
233-
ExternM (MVarId × Expr × LamTerm × Nat × Array Nat) := MetaState.withTemporaryLCtx {} {} <| do
233+
ExternM (MVarId × Expr × LamTerm × Array (FVarId × Expr) × Array Nat) := MetaState.withTemporaryLCtx {} {} <| do
234234
let (ss, ts, lemmas, inhLemmas) ← withAll nonemptiesWithDTr validsWithDTr
235235
let getFid (lem : Lemma) : ExternM FVarId := do
236236
match lem.proof with
@@ -261,6 +261,6 @@ def callMkMVarWithAtomAsFVar
261261
let proof ← Meta.mkLambdaFVars (fvars.map Expr.fvar) (← instantiateMVars (.mvar mProofId))
262262
let proof ← Meta.instantiateLambda proof (atomsToAbstract.map Prod.snd)
263263
return (proof, goalId))
264-
return (goalId, proof, proofLamTerm, atomsToAbstract.size, etomsToAbstract.map Prod.snd)
264+
return (goalId, proof, proofLamTerm, atomsToAbstract, etomsToAbstract.map Prod.snd)
265265

266266
end Auto.Lam2DAAF

Auto/Translation/LamReif.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ initialize
2020
registerTraceClass `auto.lamReif.prep.printResult
2121

2222
namespace Auto.LamReif
23+
2324
open Embedding.Lam
2425

26+
open ToExprExtra
27+
2528
/--
2629
We require that all instances of polymorphic constants,
2730
including `∀`, `∃`, `BitVec`, are turned into free variables

0 commit comments

Comments
 (0)