Constant folding for primitives that have special runtime support.
Equations
- Lean.Compiler.mkLcProof p = Lean.mkApp (Lean.mkConst `lcProof) p
Instances For
@[reducible, inline]
Instances For
@[reducible, inline]
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 = Lean.Compiler.numScalarTypes.any fun (info : Lean.Compiler.NumScalarTypeInfo) => info.ofNatFn == fn
Instances For
Equations
- Lean.Compiler.isToNat fn = Lean.Compiler.numScalarTypes.any 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 ((Lean.Expr.const fn us).app arg) = Lean.Compiler.getInfoFromFn fn Lean.Compiler.numScalarTypes
- Lean.Compiler.getInfoFromVal 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.const fn us).app 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.toDecidableExpr false pred true = Lean.mkConst `Bool.true
- Lean.Compiler.toDecidableExpr false pred false = Lean.mkConst `Bool.false
- Lean.Compiler.toDecidableExpr true pred true = Lean.mkDecIsTrue pred (Lean.Compiler.mkLcProof pred)
- Lean.Compiler.toDecidableExpr true pred false = Lean.mkDecIsFalse pred (Lean.Compiler.mkLcProof pred)
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 (Lean.Expr.const `Bool.true us) = some true
- Lean.Compiler.getBoolLit (Lean.Expr.const `Bool.false us) = some false
- Lean.Compiler.getBoolLit 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 size x a = do let n ← Lean.Compiler.getNumLit a pure (Lean.mkRawNatLit (n % size))
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]
Equations
- Lean.Compiler.foldBinOp beforeErasure (Lean.Expr.const fn us) a b = do let foldFn ← Lean.Compiler.findBinFoldFn fn foldFn beforeErasure a b
- Lean.Compiler.foldBinOp beforeErasure f a b = failure
Instances For
@[export lean_fold_un_op]
Equations
- Lean.Compiler.foldUnOp beforeErasure (Lean.Expr.const fn us) a = do let foldFn ← Lean.Compiler.findUnFoldFn fn foldFn beforeErasure a
- Lean.Compiler.foldUnOp beforeErasure f a = failure