Constant folding for primitives that have special runtime support.
Equations
- Lean.Compiler.mkLcProof p = Lean.mkApp (Lean.mkConst `lcProof) p
Instances For
@[inline, reducible]
Instances For
@[inline, reducible]
Instances For
Equations
- Lean.Compiler.mkUIntTypeName nbytes = Lean.Name.mkSimple ("UInt" ++ toString nbytes)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.Compiler.isOfNat fn = List.any Lean.Compiler.numScalarTypes fun (info : Lean.Compiler.NumScalarTypeInfo) => info.ofNatFn == fn
Instances For
Equations
- Lean.Compiler.isToNat fn = List.any Lean.Compiler.numScalarTypes fun (info : Lean.Compiler.NumScalarTypeInfo) => info.toNatFn == fn
Instances For
Equations
- Lean.Compiler.getInfoFromFn fn [] = none
- Lean.Compiler.getInfoFromFn fn (info :: infos) = if (info.ofNatFn == fn) = true then some info else Lean.Compiler.getInfoFromFn fn infos
Instances For
Equations
- Lean.Compiler.getInfoFromVal x = match x with | Lean.Expr.app (Lean.Expr.const fn us) arg => Lean.Compiler.getInfoFromFn fn Lean.Compiler.numScalarTypes | x => none
Instances For
@[export lean_get_num_lit]
Equations
- Lean.Compiler.getNumLit (Lean.Expr.lit (Lean.Literal.natVal n)) = some n
- Lean.Compiler.getNumLit (Lean.Expr.app (Lean.Expr.const fn us) a) = if Lean.Compiler.isOfNat fn = true then Lean.Compiler.getNumLit a else none
- Lean.Compiler.getNumLit x = none
Instances For
Equations
- Lean.Compiler.mkUIntLit info n = Lean.mkApp (Lean.mkConst info.ofNatFn) (Lean.mkRawNatLit (n % info.size))
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.Compiler.foldUIntAdd = Lean.Compiler.foldBinUInt fun (x : Lean.Compiler.NumScalarTypeInfo) (x : Bool) => Add.add
Instances For
Equations
- Lean.Compiler.foldUIntMul = Lean.Compiler.foldBinUInt fun (x : Lean.Compiler.NumScalarTypeInfo) (x : Bool) => Mul.mul
Instances For
Equations
- Lean.Compiler.foldUIntDiv = Lean.Compiler.foldBinUInt fun (x : Lean.Compiler.NumScalarTypeInfo) (x : Bool) => Div.div
Instances For
Equations
- Lean.Compiler.foldUIntMod = Lean.Compiler.foldBinUInt fun (x : Lean.Compiler.NumScalarTypeInfo) (x : Bool) => Mod.mod
Instances For
Equations
- Lean.Compiler.foldUIntSub = Lean.Compiler.foldBinUInt fun (info : Lean.Compiler.NumScalarTypeInfo) (x : Bool) (a b : Nat) => a + (info.size - b)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.Compiler.foldNatBinOp fn a₁ a₂ = do let n₁ ← Lean.Compiler.getNumLit a₁ let n₂ ← Lean.Compiler.getNumLit a₂ pure (Lean.mkRawNatLit (fn n₁ n₂))
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
- Lean.Compiler.mkNatEq a b = Lean.mkAppN (Lean.mkConst `Eq [Lean.levelOne]) #[Lean.mkConst `Nat, a, b]
Instances For
Equations
- Lean.Compiler.mkNatLt a b = Lean.mkAppN (Lean.mkConst `LT.lt [Lean.levelZero]) #[Lean.mkConst `Nat, Lean.mkConst `Nat.lt, a, b]
Instances For
Equations
- Lean.Compiler.mkNatLe a b = Lean.mkAppN (Lean.mkConst `LE.le [Lean.levelZero]) #[Lean.mkConst `Nat, Lean.mkConst `Nat.le, a, b]
Instances For
Equations
- Lean.Compiler.foldNatDecEq = Lean.Compiler.foldNatBinPred Lean.Compiler.mkNatEq fun (a b : Nat) => decide (a = b)
Instances For
Equations
- Lean.Compiler.foldNatDecLt = Lean.Compiler.foldNatBinPred Lean.Compiler.mkNatLt fun (a b : Nat) => decide (a < b)
Instances For
Equations
- Lean.Compiler.foldNatDecLe = Lean.Compiler.foldNatBinPred Lean.Compiler.mkNatLe fun (a b : Nat) => decide (a ≤ b)
Instances For
Equations
- Lean.Compiler.foldNatBeq x = Lean.Compiler.foldNatBinBoolPred fun (a b : Nat) => a == b
Instances For
Equations
- Lean.Compiler.foldNatBle x = Lean.Compiler.foldNatBinBoolPred fun (a b : Nat) => decide (a < b)
Instances For
Equations
- Lean.Compiler.foldNatBlt x = Lean.Compiler.foldNatBinBoolPred fun (a b : Nat) => decide (a ≤ b)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.Compiler.getBoolLit x = match x with | Lean.Expr.const `Bool.true us => some true | Lean.Expr.const `Bool.false us => some false | x => none
Instances For
Equations
- Lean.Compiler.boolFoldFns = [(`strictOr, Lean.Compiler.foldStrictOr), (`strictAnd, Lean.Compiler.foldStrictAnd)]
Instances For
Equations
- Lean.Compiler.foldNatSucc x a = do let n ← Lean.Compiler.getNumLit a pure (Lean.mkRawNatLit (n + 1))
Instances For
Equations
- Lean.Compiler.foldToNat x a = do let n ← Lean.Compiler.getNumLit a pure (Lean.mkRawNatLit n)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.Compiler.unFoldFns = [(`Nat.succ, Lean.Compiler.foldNatSucc), (`Char.ofNat, Lean.Compiler.foldCharOfNat)] ++ Lean.Compiler.uintFoldToNatFns
Instances For
Equations
Instances For
Equations
Instances For
@[export lean_fold_bin_op]
def
Lean.Compiler.foldBinOp
(beforeErasure : Bool)
(f : Lean.Expr)
(a : Lean.Expr)
(b : Lean.Expr)
:
Equations
- Lean.Compiler.foldBinOp beforeErasure f a b = match f with | Lean.Expr.const fn us => do let foldFn ← Lean.Compiler.findBinFoldFn fn foldFn beforeErasure a b | x => failure
Instances For
@[export lean_fold_un_op]
Equations
- Lean.Compiler.foldUnOp beforeErasure f a = match f with | Lean.Expr.const fn us => do let foldFn ← Lean.Compiler.findUnFoldFn fn foldFn beforeErasure a | x => failure