fact stringlengths 4 7.31k | type stringclasses 10
values | library stringclasses 3
values | imports listlengths 0 35 | filename stringclasses 124
values | symbolic_name stringlengths 1 63 | docstring stringclasses 1
value |
|---|---|---|---|---|---|---|
expIsImplication(t : Expr) (b : Expr) : MetaM Bool :=
try
if (← Meta.inferType t).isProp && (← Meta.inferType b).isProp then return true
else return false
catch _ => -- If either of the inferType checks fail (e.g. because `b` has loose bvars), then return false
return false | def | Duper | [
"import Lean"
] | Duper/Expr.lean | expIsImplication | |
impAwareGetAppRevArgsAux: Expr → Array Expr → MetaM (Array Expr)
| app f a, as => impAwareGetAppRevArgsAux f (as.push a)
| forallE _ t b _, as => do
if (← expIsImplication t b) then return (as.push b).push t
else return as
| _, as => return as
/-- Same as `Lean.Expr.getAppRevArgs` but if the head is an i... | def | Duper | [
"import Lean"
] | Duper/Expr.lean | impAwareGetAppRevArgsAux | |
impAwareGetAppRevArgs(e : Expr) : MetaM (Array Expr) :=
impAwareGetAppRevArgsAux e (Array.mkEmpty e.getAppNumArgs)
/-- Same as `Lean.Expr.getAppArgs` but if the head is an implication (an expression of the form
`∀ _ : p, q` where `p` and `q` have type `Prop`), then it pretends the head has the form
`.app (.a... | def | Duper | [
"import Lean"
] | Duper/Expr.lean | impAwareGetAppRevArgs | |
impAwareGetAppArgs(e : Expr) : MetaM (Array Expr) := do
let revArgs ← impAwareGetAppRevArgs e
return revArgs.reverse
/-- Note: This function assumes that if the head is a forallE expression and the index given indicates
either the type or body of the forallE expression, then the head is actually an implication... | def | Duper | [
"import Lean"
] | Duper/Expr.lean | impAwareGetAppArgs | |
impAwareGetRevArg! : Expr → Nat → Expr
| app _ a, 0 => a
| app f _, i+1 => impAwareGetRevArg! f i
| forallE _ _ b _, 0 => b
| forallE _ t _ _, 1 => t
| e, i => panic! s!"invalid index {i} given to impAwareGetRevArg! for expression {e}" | def | Duper | [
"import Lean"
] | Duper/Expr.lean | impAwareGetRevArg | |
foldGreenM{β : Type} [Monad m] [MonadLiftT MetaM m]
(f : β → Expr → ExprPos → m β) (init : β) (e : Expr)
(pos : ExprPos := ExprPos.empty) (_ : Inhabited β := ⟨init⟩) : m β :=
do
let mut acc ← f init e pos
let args ← e.impAwareGetAppRevArgs
for i in [:args.size] do
acc ← foldGreenM f acc args[i]!... | def | Duper | [
"import Lean"
] | Duper/Expr.lean | foldGreenM | |
getAtPos! [Monad m] [MonadLiftT MetaM m] (e : Expr) (pos : ExprPos) : m Expr := do
let mut cur := e
for i in pos do
cur := cur.impAwareGetRevArg! i
return cur
/-- Returns the expression in e indiced by pos if it exists, and returns none if pos does not point to a valid
subexpression in e -/ | def | Duper | [
"import Lean"
] | Duper/Expr.lean | getAtPos | |
getAtUntypedPos[Monad m] [MonadLiftT MetaM m] (e : Expr) (pos : ExprPos) : m (Option Expr) := do
let mut cur := e
for i in pos do
match cur.getAppRevArgs[i]? with
| some e => cur := e
| none => return none
return cur
/-- Returns true if either the subexpression indiced by pos exists in e, or if it ma... | def | Duper | [
"import Lean"
] | Duper/Expr.lean | getAtUntypedPos | |
canInstantiateToGetAtPos[Monad m] [MonadLiftT MetaM m] (e : Expr) (pos : ExprPos) (startIndex := 0) : m Bool :=
if e.isMVar' then return true
else if pos.size ≤ startIndex then return true
else do
let e'_opt := (← e.impAwareGetAppRevArgs)[pos[startIndex]!]?
match e'_opt with
| none => return false
... | def | Duper | [
"import Lean"
] | Duper/Expr.lean | canInstantiateToGetAtPos | |
canInstantiateToGetAtUntypedPos(e : Expr) (pos : ExprPos) (startIndex := 0) : Bool :=
if e.isMVar' then true
else if pos.size ≤ startIndex then true
else
let e'_opt := (e.getAppRevArgs)[pos[startIndex]!]?
match e'_opt with
| none => false
| some e' => canInstantiateToGetAtUntypedPos e' pos (startI... | def | Duper | [
"import Lean"
] | Duper/Expr.lean | canInstantiateToGetAtUntypedPos | |
getTopSymbol(e : Expr) : Expr :=
match e.consumeMData with
| app f _ => getTopSymbol f
| _ => e
/-- Attempts to put replacement at pos in e. Returns some res if successful, and returns none otherwise -/
private partial def replaceAtPosHelper [Monad m] [MonadLiftT MetaM m] (e : Expr) (pos : List Nat) (replacement... | def | Duper | [
"import Lean"
] | Duper/Expr.lean | getTopSymbol | |
replaceAtPos? [Monad m] [MonadLiftT MetaM m] (e : Expr) (pos : ExprPos) (replacement : Expr) : m (Option Expr) :=
replaceAtPosHelper e pos.toList replacement
/-- Attempts to put replacement at pos in e. Returns the result if successful and throws and error otherwise -/ | def | Duper | [
"import Lean"
] | Duper/Expr.lean | replaceAtPos | |
replaceGreenWithPos[Monad m] [MonadLiftT MetaM m] (t₁ t₂ e : Expr) : m (Expr × (Array ExprPos)) := do
let (e, poses) ← replaceGreenWithPosHelper t₁ t₂ e
return (e, poses.map (fun x => x.reverse))
-- Return [t₂/t₁]e, along with positions where the term is replaced
-- TODO !! | def | Duper | [
"import Lean"
] | Duper/Expr.lean | replaceGreenWithPos | |
replaceWithPos(t₁ t₂ e : Expr) : Expr :=
if e == t₁ then
t₂
else
match e with
| .forallE _ d b _ => let d := replaceWithPos t₁ t₂ d; let b := replaceWithPos t₁ t₂ b; e.updateForallE! d b
| .lam _ d b _ => let d := replaceWithPos t₁ t₂ d; let b := replaceWithPos t₁ t₂ b; e.updateLambdaE... | def | Duper | [
"import Lean"
] | Duper/Expr.lean | replaceWithPos | |
abstractAtPos! [Monad m] [MonadLiftT MetaM m] [MonadError m] (e : Expr) (pos : ExprPos) : m Expr := do
abstractAtPosHelper! e pos.toList 0
private partial def abstractAtPosesHelper! [Monad m] [MonadLiftT MetaM m] [MonadError m] (e : Expr)
(poses : Array (List Nat)) (numBindersUnder : Nat) : m Expr := do
if poses... | def | Duper | [
"import Lean"
] | Duper/Expr.lean | abstractAtPos | |
abstractAtPoses! [Monad m] [MonadLiftT MetaM m] [MonadError m] (e : Expr) (poses : Array ExprPos) : m Expr :=
abstractAtPosesHelper! e (poses.map (fun x => x.toList)) 0
/-
Note: this function may require revision to be more similar to Zipperposition's ho_weight function once we actually
start working on higher o... | def | Duper | [
"import Lean"
] | Duper/Expr.lean | abstractAtPoses | |
weight: Expr → Nat
| Expr.bvar _ => 1
| Expr.fvar _ => 1
| Expr.mvar _ => 1
| Expr.sort _ => 1
| Expr.const _ _ => 1
| Expr.app a b => weight a + weight b
| Expr.lam _ _ b _ => 1 + weight b
| Expr.forallE _ _ b _ => 1 + weight b
| Expr.letE _ _ v b... | def | Duper | [
"import Lean"
] | Duper/Expr.lean | weight | |
expressionsAgreeExceptAtPos[Monad m] [MonadLiftT MetaM m] (e1 : Expr) (e2 : Expr) (p : ExprPos) : m Bool := do
-- e1 and e2 are identical except potentially at p iff e1 is identical with (replaceAtPos e2 pos (getAtPos e1 pos))
match ← e1.getAtPos? p with
| none => return false
| some e1Subterm =>
match ← e2... | def | Duper | [
"import Lean"
] | Duper/Expr.lean | expressionsAgreeExceptAtPos | |
isFullyAppliedLogicalSymbol(e : Expr) : Bool :=
match e.consumeMData with
| Expr.const ``False _ => true
| Expr.const ``True _ => true
| Expr.app (Expr.const ``Not _) _ => true
| Expr.app (Expr.app (Expr.const ``Exists _) _) _ => true
| Expr.app (Expr.app (Expr.app (Expr.const ``Eq _) _) _) _ => true
| Ex... | def | Duper | [
"import Lean"
] | Duper/Expr.lean | isFullyAppliedLogicalSymbol | |
FingerprintFeatureValuewhere
| F : Expr → FingerprintFeatureValue
| A : FingerprintFeatureValue
| B : FingerprintFeatureValue
| N : FingerprintFeatureValue | inductive | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | FingerprintFeatureValue | |
FingerprintFeatureValue.format: FingerprintFeatureValue → MessageData
| A => "A"
| B => "B"
| N => "N"
| F e => m!"F({e})" | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | FingerprintFeatureValue.format | |
Fingerprint:= List FingerprintFeatureValue | abbrev | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | Fingerprint | |
FingerprintTrie(α : Type) [BEq α] [Hashable α] where
| node
(childA : FingerprintTrie α) (childB : FingerprintTrie α)
(childN : FingerprintTrie α) (childF : Array (Expr × FingerprintTrie α)) : FingerprintTrie α
| leaf (vals : Array α)
deriving Inhabited
-- Nat is for clause id, eligibility is included ... | inductive | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | FingerprintTrie | |
ClauseFingerprintTrie:= FingerprintTrie (Nat × Clause × ClausePos × (Option Eligibility))
open FingerprintTrie
open FingerprintFeatureValue
-- Print functions ---------------------------------------------------------------------------------------- | abbrev | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | ClauseFingerprintTrie | |
FingerprintTrie.format[ToMessageData α] [BEq α] [Hashable α] (depth := 0) : FingerprintTrie α → MessageData
| leaf vals => m!"{spaces depth}· Leaf: {vals}"
| node childA childB childN childF =>
let childFMsg := childF.foldl (fun acc (e, t) => acc ++ m!"{spaces (depth+1)}· {e}:\n{t.format (depth+2)}") m!""
l... | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | FingerprintTrie.format | |
countElems[BEq α] [Hashable α] : FingerprintTrie α → Nat
| leaf vals => vals.size
| node childA childB childN childF =>
let childFElems := childF.foldl (fun acc (_, t) => acc + countElems t) 0
countElems childA + countElems childB + countElems childN + childFElems | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | countElems | |
foldMsgs(arr : Array MessageData) : MessageData := arr.foldl (fun acc m => acc ++ m!"\n" ++ m) m!""
private partial def printElemsHelper [ToMessageData α] [BEq α] [Hashable α] : FingerprintTrie α → Array MessageData
| leaf vals => vals.map (fun x => m!": {x}")
| node childA childB childN childF =>
let childAMs... | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | foldMsgs | |
FingerprintTrie.printElems[ToMessageData α] [BEq α] [Hashable α] (t : FingerprintTrie α) : MessageData :=
foldMsgs $ printElemsHelper t | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | FingerprintTrie.printElems | |
printVal(v : Nat × Clause × ClausePos × (Option Eligibility)) : MessageData := m!"({v.1}, " ++ m!"{v.2.1}, " ++ m!"{v.2.2.1}, " ++ m!"{v.2.2.2})" | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | printVal | |
fingerprintFeatures: List ExprPos := [
#[],
#[0],
#[1]
/- These fingerprint features are included in Zipperposition's default fingerprint function fp7m defined
at https://github.com/sneeuwballen/zipperposition/blob/master/src/core/Fingerprint.ml#L135, but testing
seems to indicate including these features... | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | fingerprintFeatures | |
numFingerprintFeatures: Nat := fingerprintFeatures.length
/-- Yields an empty ClauseFingerprintTrie with the given depth d -/ | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | numFingerprintFeatures | |
mkEmptyWithDepth(d : Nat) : ClauseFingerprintTrie :=
match d with
| 0 => leaf {}
| d' + 1 =>
let t := mkEmptyWithDepth d'
node t t t #[]
/-- Yields an empty ClauseFingerprintTrie with the correct depth -/ | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | mkEmptyWithDepth | |
emptyCFP: ClauseFingerprintTrie := mkEmptyWithDepth numFingerprintFeatures
/- The filterSet argument is a hack to simulate deletions from the FingerprintTrie. I currently think that this might
be not only easier, but also more efficient than actually deleting all entries relating to a particular clause, but
I co... | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | emptyCFP | |
RootCFPTriewhere
root : ClauseFingerprintTrie := emptyCFP
filterSet : Std.HashSet Clause := {} -- Keeps track of the set of clauses that should be filtered out (i.e. "removed" clauses)
deriving Inhabited | structure | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | RootCFPTrie | |
gfpf[Monad m] [MonadLiftT MetaM m] (e : Expr) (pos : ExprPos) : m FingerprintFeatureValue := do
match ← e.getAtUntypedPos pos with
| none =>
if e.canInstantiateToGetAtUntypedPos pos then return B
else return N
| some e' =>
if e'.isMVar' then return A
else return F e.getTopSymbol
/-- This implemen... | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | gfpf | |
transformToUntypedFirstOrderTerm[Monad m] [MonadLiftT MetaM m] (e : Expr) : m Expr := do
match e with
| Expr.forallE _ _ b _ => transformToUntypedFirstOrderTerm b
| Expr.lam _ _ b _ => transformToUntypedFirstOrderTerm b
| Expr.app f a =>
match e.getTopSymbol with
| Expr.mvar mvarId => return .mvar mvarI... | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | transformToUntypedFirstOrderTerm | |
getFingerprint[Monad m] [MonadLiftT MetaM m] (e : Expr) : m Fingerprint := do
let e ← transformToUntypedFirstOrderTerm e
fingerprintFeatures.mapM (fun pos => gfpf e pos)
/-- Given a fingerprint f, yields a ClauseFingerprintTrie whose depth equals the length of f and whose
only value is v (located at the positi... | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | getFingerprint | |
mkSingleton(f : Fingerprint) (v : (Nat × Clause × ClausePos × (Option Eligibility))) : ClauseFingerprintTrie :=
let childDepth := f.length - 1
let emptyChild := mkEmptyWithDepth childDepth
match f with
| [] => leaf #[v]
| A :: restFeatures => node (mkSingleton restFeatures v) emptyChild emptyChild #[]
| B :... | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | mkSingleton | |
insertHelper(t : ClauseFingerprintTrie) (f : Fingerprint)
(v : (Nat × Clause × ClausePos × (Option Eligibility))) : RuleM ClauseFingerprintTrie := do
match f, t with
| [], leaf vals => return leaf (vals.push v)
| A :: restFeatures, node childA childB childN childF =>
let childA' ← insertHelper childA restFe... | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | insertHelper | |
insert(t : RootCFPTrie) (e : Expr) (v : (Nat × Clause × ClausePos × (Option Eligibility))) : RuleM RootCFPTrie :=
return ⟨← insertHelper t.root (← getFingerprint e) v, t.filterSet.erase v.2.1⟩
/-- Adds c to t.filterSet so that Clause × ClausePos pairs with c as the clause are ignored going forward -/ | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | insert | |
delete(t : RootCFPTrie) (c : Clause) : RuleM RootCFPTrie :=
return ⟨t.root, t.filterSet.insert c⟩
/-- Obtains all values in t that are unification-compatible with f. Throws an error if the depth of t is not
equal to the length of f -/ | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | delete | |
getUnificationPartnersHelper(t : ClauseFingerprintTrie) (f : Fingerprint) :
RuleM (Array (Nat × Clause × ClausePos × (Option Eligibility))) := do
match f, t with
| [], leaf vals => return vals
| A :: restFeatures, node childA childB childN childF =>
let arrA ← getUnificationPartnersHelper childA restFeature... | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | getUnificationPartnersHelper | |
getUnificationPartners(t : RootCFPTrie) (e : Expr) : RuleM (Array (Nat × Clause × ClausePos × (Option Eligibility))) := do
trace[duper.fingerprint.debug] "About to call getUnificationPartnersHelper with {t.root} and {← getFingerprint e}"
let unfilteredRes ← getUnificationPartnersHelper t.root (← getFingerprint e)
... | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | getUnificationPartners | |
getMatchOntoPartnersHelper(t : ClauseFingerprintTrie) (f : Fingerprint) :
RuleM (Array (Nat × Clause × ClausePos × (Option Eligibility))) := do
match f, t with
| [], leaf vals => return vals
| A :: restFeatures, node childA childB childN childF =>
let arrA ← getMatchOntoPartnersHelper childA restFeatures
... | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | getMatchOntoPartnersHelper | |
getMatchOntoPartners(t : RootCFPTrie) (e : Expr) : RuleM (Array (Nat × Clause × ClausePos × (Option Eligibility))) := do
let unfilteredRes ← getMatchOntoPartnersHelper t.root (← getFingerprint e)
return Array.filter (fun c => not (t.filterSet.contains c.2.1)) unfilteredRes | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | getMatchOntoPartners | |
getMatchFromPartnersHelper(t : ClauseFingerprintTrie) (f : Fingerprint) :
RuleM (Array (Nat × Clause × ClausePos × (Option Eligibility))) := do
match f, t with
| [], leaf vals => return vals
| A :: restFeatures, node childA childB childN childF =>
let arrA ← getMatchFromPartnersHelper childA restFeatures
... | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | getMatchFromPartnersHelper | |
getMatchFromPartners(t : RootCFPTrie) (e : Expr) : RuleM (Array (Nat × Clause × ClausePos × (Option Eligibility))) := do
let unfilteredRes ← getMatchFromPartnersHelper t.root (← getFingerprint e)
return Array.filter (fun c => not (t.filterSet.contains c.2.1)) unfilteredRes | def | Duper | [
"import Lean",
"import Duper.RuleM",
"import Duper.Selection"
] | Duper/Fingerprint.lean | getMatchFromPartners | |
getPrintPortfolioInstance(opts : Options) : Bool :=
duper.printPortfolioInstance.get opts | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | getPrintPortfolioInstance | |
getThrowPortfolioErrors(opts : Options) : Bool :=
duper.throwPortfolioErrors.get opts | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | getThrowPortfolioErrors | |
getCollectDataTypes(opts : Options) : Bool :=
duper.collectDatatypes.get opts | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | getCollectDataTypes | |
getPrintPortfolioInstanceM: CoreM Bool := do
let opts ← getOptions
return getPrintPortfolioInstance opts | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | getPrintPortfolioInstanceM | |
getThrowPortfolioErrorsM: CoreM Bool := do
let opts ← getOptions
return getThrowPortfolioErrors opts | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | getThrowPortfolioErrorsM | |
getCollectDataTypesM: CoreM Bool := do
let opts ← getOptions
return getCollectDataTypes opts
declare_syntax_cat Duper.bool_lit (behavior := symbol)
syntax "true" : Duper.bool_lit
syntax "false" : Duper.bool_lit | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | getCollectDataTypesM | |
elabBoolLit[Monad m] [MonadError m] (stx : TSyntax `Duper.bool_lit) : m Bool :=
withRef stx do
match stx with
| `(bool_lit| true) => return true
| `(bool_lit| false) => return false
| _ => Elab.throwUnsupportedSyntax | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | elabBoolLit | |
boolToBoolLit[Monad m] [MonadQuotation m] (b : Bool) : m (TSyntax `Duper.bool_lit) := do
match b with
| true => `(bool_lit| true)
| false => `(bool_lit| false)
declare_syntax_cat Duper.preprocessing_option (behavior := symbol)
syntax "full" : Duper.preprocessing_option
syntax "monomorphization" : Duper.preproce... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | boolToBoolLit | |
PreprocessingOptionwhere
| FullPreprocessing
| Monomorphization
| NoPreprocessing
deriving DecidableEq
open PreprocessingOption | inductive | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | PreprocessingOption | |
elabPreprocessingOption[Monad m] [MonadError m] (stx : TSyntax `Duper.preprocessing_option) : m PreprocessingOption :=
withRef stx do
match stx with
| `(preprocessing_option| full) => return FullPreprocessing
| `(preprocessing_option| monomorphization) => return Monomorphization
| `(preprocessing_opti... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | elabPreprocessingOption | |
preprocessingOptionToStx[Monad m] [MonadQuotation m] (o : PreprocessingOption) : m (TSyntax `Duper.preprocessing_option) := do
match o with
| FullPreprocessing => `(preprocessing_option| full)
| Monomorphization => `(preprocessing_option| monomorphization)
| NoPreprocessing => `(preprocessing_option| no_preproc... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | preprocessingOptionToStx | |
ConfigurationOptionswhere
portfolioMode : Bool -- True by default (unless portfolio instance is specified)
portfolioInstance : Option Nat -- None by default (unless portfolioMode is false, in which case, some 0 is default)
inhabitationReasoning : Option Bool -- None by default
preprocessing : Option Preprocessi... | structure | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | ConfigurationOptions | |
portfolioInstanceToConfigOptionStx[Monad m] [MonadError m] [MonadQuotation m] (n : Nat) : m (TSyntax `Duper.configOption) := do
match n with
| 0 => `(configOption| portfolioInstance := 0)
| 1 => `(configOption| portfolioInstance := 1)
| 2 => `(configOption| portfolioInstance := 2)
| 3 => `(configOption| portf... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | portfolioInstanceToConfigOptionStx | |
selFunctionNumToConfigOptionStx[Monad m] [MonadError m] [MonadQuotation m] (n : Nat) : m (TSyntax `Duper.configOption) := do
match n with
| 0 => `(configOption| selFunction := 0)
| 1 => `(configOption| selFunction := 1)
| 2 => `(configOption| selFunction := 2)
| 3 => `(configOption| selFunction := 3)
| 4 =>... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | selFunctionNumToConfigOptionStx | |
mkDuperCallSuggestion(duperStxRef : Syntax) (origSpan : Syntax) (facts : Syntax.TSepArray `term ",") (extraFacts : Option (Syntax.TSepArray `term ","))
(withDuperStar : Bool) (portfolioInstance : Nat) (inhabitationReasoning : Option Bool := none) (preprocessing : Option PreprocessingOption := none)
(includeExpensiv... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | mkDuperCallSuggestion | |
withoutModifyingCoreEnv(m : MetaM α) : MetaM α :=
try
let env := (← liftM (get : CoreM Core.State)).env
let ret ← m
liftM (modify fun s => {s with env := env} : CoreM Unit)
return ret
catch e =>
throwError e.toMessageData
/-- `skSorryAx` has essentially the same type as `sorryAx`, but does not ... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | withoutModifyingCoreEnv | |
skSorryAx: ∀ {α : Sort u}, α
/-- Add the constant `skolemSorry` to the environment and add suitable postfix to avoid name conflict. -/ | axiom | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | skSorryAx | |
addSkolemSorry: CoreM Name := do
let nameS := "skS"
let env := (← get).env
let mut cnt := 0
let currNameSpace := (← read).currNamespace
while true do
let name :=
match env.asyncPrefix? with
| some p => Name.num (Name.str p nameS) cnt
| none => Name.num (Name.str currNameSpace nameS) cnt
... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | addSkolemSorry | |
unfoldDefinitions(formulas : List (Expr × Expr × Array Name × Bool × Bool)) : MetaM (List (Expr × Expr × Array Name × Bool × Bool)) := do
withTransparency .reducible do
let mut newFormulas := formulas
for (e, proof, paramNames, isFromGoal, includeInSetOfSupport) in formulas do
let update (ty lhs rhs : E... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | unfoldDefinitions | |
printSaturation(state : ProverM.State) : MetaM Unit := do
trace[duper.prover.saturate] "Final Active Set: {state.activeSet.toArray}"
trace[duper.saturate.debug] "Final active set numbers: {state.activeSet.toArray.map (fun c => (state.allClauses.get! c).number)}"
trace[duper.saturate.debug] "Final Active Set: {sta... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | printSaturation | |
formulasToMessageData: Expr × Expr × Array Name × Bool × Bool → MessageData
| (ty, term, names, _isFromGoal, _includeInSetOfSupport) => .compose (.compose m!"{names} @ " m!"{term} : ") m!"{ty}"
/-- Entry point for calling a single instance of duper using the options determined by (← getOptions).
Formulas should c... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | formulasToMessageData | |
runDuper(formulas : List (Expr × Expr × Array Name × Bool)) (extraFormulas : List (Expr × Expr × Array Name × Bool))
(instanceMaxHeartbeats : Nat) : MetaM Expr := do
let generateDatatypeExhaustivenessFacts ← getCollectDataTypesM
/- Add `true` to all facts from `formulas` to indicate that they should be included i... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuper | |
getLeavesFromDTr(t : Auto.DTr) : Array String :=
match t with
| Auto.DTr.node _ subTrees => (subTrees.map getLeavesFromDTr).flatten
| Auto.DTr.leaf s => #[s]
/-- Converts formulas/lemmas from the format used by Duper to the format used by Auto. Duper uses Auto's deriv DTr to keep
track of `isFromGoal` and op... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | getLeavesFromDTr | |
formulasToAutoLemmas(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (includeInSetOfSupport : Bool) : MetaM (Array Auto.Lemma) :=
formulas.toArray.mapM
(fun (fact, proof, params, isFromGoal, stxOption) =>
match stxOption with
| none => return {proof := ← Meta.mkAppM ``of_eq_true #[pro... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | formulasToAutoLemmas | |
formulasWithStringsToAutoLemmas(formulas : List (Expr × Expr × Array Name × Bool × Option String)) (includeInSetOfSupport : Bool) : MetaM (Array Auto.Lemma) := do
formulas.toArray.mapM
(fun (fact, proof, params, isFromGoal, stxOption) =>
match stxOption with
| none => return {proof := ← Meta.mkAppM ``... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | formulasWithStringsToAutoLemmas | |
derivInfo(lem : Auto.Lemma) : Bool × Bool :=
let derivLeaves := getLeavesFromDTr lem.deriv
let matchesFormat := derivLeaves.any (fun l => "true, true".isPrefixOf l || "false, true".isPrefixOf l || "true, false".isPrefixOf l || "false, false".isPrefixOf l)
if !matchesFormat then
(true, true)
else
let isF... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | derivInfo | |
autoLemmasToFormulas(lemmas : Array Auto.Lemma) : MetaM (List (Expr × Expr × Array Name × Bool) × List (Expr × Expr × Array Name × Bool)) := do
let monomorphizedFormulas ← lemmas.toList.filterMapM
(fun lem => do
trace[duper.setOfSupport.debug] "Auto lemma: {lem}, deriv: {lem.deriv}, leaves: {getLeavesFromDT... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | autoLemmasToFormulas | |
runDuperInstanceWithMonomorphization(formulas : List (Expr × Expr × Array Name × Bool × Option Term))
(extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term)) (instanceMaxHeartbeats : Nat)
(inst : List (Expr × Expr × Array Name × Bool) → List (Expr × Expr × Array Name × Bool) → Nat → MetaM Expr) : Met... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstanceWithMonomorphization | |
runDuperInstanceWithFullPreprocessing(formulas : List (Expr × Expr × Array Name × Bool × Option Term))
(extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term)) (declName? : Option Name) (instanceMaxHeartbeats : Nat)
(inst : List (Expr × Expr × Array Name × Bool) → List (Expr × Expr × Array Name × Bool... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstanceWithFullPreprocessing | |
mkDuperInstance(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) (inhabitationReasoning : Option Bool) (preprocessing : Option PreprocessingOption)
(includeExpensiveRules : ... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | mkDuperInstance | |
runDuperInstance1(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReason... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance1 | |
runDuperInstance2(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReason... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance2 | |
runDuperInstance3(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReason... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance3 | |
runDuperInstance4(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReason... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance4 | |
runDuperInstance5(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReason... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance5 | |
runDuperInstance6(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReason... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance6 | |
runDuperInstance7(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReason... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance7 | |
runDuperInstance8(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReason... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance8 | |
runDuperInstance9(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReason... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance9 | |
runDuperInstance10(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReaso... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance10 | |
runDuperInstance11(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReaso... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance11 | |
runDuperInstance12(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReaso... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance12 | |
runDuperInstance13(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReaso... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance13 | |
runDuperInstance14(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReaso... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance14 | |
runDuperInstance15(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReaso... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance15 | |
runDuperInstance16(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReaso... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance16 | |
runDuperInstance17(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReaso... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance17 | |
runDuperInstance18(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReaso... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance18 | |
runDuperInstance19(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReaso... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance19 | |
runDuperInstance20(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReaso... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance20 | |
runDuperInstance21(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReaso... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance21 | |
runDuperInstance22(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReaso... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance22 | |
runDuperInstance23(formulas : List (Expr × Expr × Array Name × Bool × Option Term)) (extraFormulas : List (Expr × Expr × Array Name × Bool × Option Term))
(declName? : Option Name) (instanceMaxHeartbeats : Nat) : MetaM Expr :=
mkDuperInstance formulas extraFormulas declName? instanceMaxHeartbeats (inhabitationReaso... | def | Duper | [
"import Duper.ProofReconstruction",
"import Auto.Tactic"
] | Duper/Interface.lean | runDuperInstance23 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.