Helper functions for recognizing builtin literal values. This module focus on recognizing the standard representation used in Lean for these literals. It also provides support for the following exceptional cases.
- Raw natural numbers (i.e., natural numbers which are not encoded using
OfNat.ofNat). - Bit-vectors encoded using
OfNat.ofNatandBitVec.ofNat. - Negative integers encoded using raw natural numbers.
- Characters encoded
Char.ofNat nwherencan be a raw natural number or anOfNat.ofNat. - Nested
Expr.mdata.
Returns some n if e is a raw natural number, i.e., it is of the form .lit (.natVal n).
Equations
- Lean.Meta.getRawNatValue? e = match e.consumeMData with | Lean.Expr.lit (Lean.Literal.natVal n) => some n | x => none
Instances For
Return some (n, type) if e is an OfNat.ofNat-application encoding n for a type with name typeDeclName.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return some n if e is a raw natural number or an OfNat.ofNat-application encoding n.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns true if getNatValue? e is some _.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns true if getNatValue? e is some n with n ≠ 0.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return some i if e OfNat.ofNat-application encoding an integer, or Neg.neg-application of one.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns true if getIntValue? e is some _.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return some r if e is a rational OfNat or OfScientific literal, optionally negated,
or a division of an optionally negated OfNat literal by an OfNat literal.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return some c if e is a Char.ofNat-application that encodes the character c.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return some s if e is of the form .lit (.strVal s).
Equations
Instances For
Return some ⟨n, v⟩ if e is an OfNat.ofNat application encoding a Fin n with value v
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return some ⟨n, v⟩ if e is:
- an
OfNat.ofNatapplication - a
BitVec.ofNatapplication - a
BitVec.ofNatLTapplication that encode aBitVec nwith valuev.
Returns none if the width n is not safe to evaluate (see isSafeBitVecWidth).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return some n if e is an OfNat.ofNat-application encoding the UInt8 with value n.
Equations
- Lean.Meta.getUInt8Value? e = (do let __x ← Lean.Meta.getOfNatValue? e `UInt8 match __x with | (n, snd) => pure (UInt8.ofNat n)).run
Instances For
Return some n if e is an OfNat.ofNat-application encoding the UInt16 with value n.
Equations
- Lean.Meta.getUInt16Value? e = (do let __x ← Lean.Meta.getOfNatValue? e `UInt16 match __x with | (n, snd) => pure (UInt16.ofNat n)).run
Instances For
Return some n if e is an OfNat.ofNat-application encoding the UInt32 with value n.
Equations
- Lean.Meta.getUInt32Value? e = (do let __x ← Lean.Meta.getOfNatValue? e `UInt32 match __x with | (n, snd) => pure (UInt32.ofNat n)).run
Instances For
Return some n if e is an OfNat.ofNat-application encoding the UInt64 with value n.
Equations
- Lean.Meta.getUInt64Value? e = (do let __x ← Lean.Meta.getOfNatValue? e `UInt64 match __x with | (n, snd) => pure (UInt64.ofNat n)).run
Instances For
Return some i if e is an OfNat.ofNat-application encoding the Int8 with value i, or Neg.neg-application of one.
Equations
- Lean.Meta.getInt8Value? e = do let __do_lift ← Lean.Meta.getSignedOfNatValue?✝ e `Int8 pure (Option.map Int8.ofInt __do_lift)
Instances For
Return some i if e is an OfNat.ofNat-application encoding the Int16 with value i, or Neg.neg-application of one.
Equations
- Lean.Meta.getInt16Value? e = do let __do_lift ← Lean.Meta.getSignedOfNatValue?✝ e `Int16 pure (Option.map Int16.ofInt __do_lift)
Instances For
Return some i if e is an OfNat.ofNat-application encoding the Int32 with value i, or Neg.neg-application of one.
Equations
- Lean.Meta.getInt32Value? e = do let __do_lift ← Lean.Meta.getSignedOfNatValue?✝ e `Int32 pure (Option.map Int32.ofInt __do_lift)
Instances For
Return some i if e is an OfNat.ofNat-application encoding the Int64 with value i, or Neg.neg-application of one.
Equations
- Lean.Meta.getInt64Value? e = do let __do_lift ← Lean.Meta.getSignedOfNatValue?✝ e `Int64 pure (Option.map Int64.ofInt __do_lift)
Instances For
Return some v if e is a Float literal: an OfScientific or OfNat application, or Neg.neg
of either (e.g. -1.5).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return some v if e is a Float32 literal: an OfScientific or OfNat application, or Neg.neg
of either (e.g. -1.5).
Equations
- One or more equations did not get rendered due to their size.
Instances For
If a and b are both Float or both Float32 literals, returns whether they denote the same
value. Values are compared by bit pattern, consistent with the DecidableEq instances.
Equations
- One or more equations did not get rendered due to their size.
Instances For
If e is a literal value, ensure it is encoded using the standard representation.
Otherwise, just return e.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns true if e is a literal value, i.e., one of the get*Value? functions above returns some _.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Check if an expression is a list literal (i.e. a nested chain of List.cons, ending at a List.nil),
where each element is "recognised" by a given function f : Expr → MetaM (Option α),
and return the array of recognised values.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Check if an expression is a list literal (i.e. a nested chain of List.cons, ending at a List.nil),
returning the array of Expr values.
Equations
- Lean.Meta.getListLit? e = Lean.Meta.getListLitOf? e fun (s : Lean.Expr) => pure (some s)
Instances For
Check if an expression is an array literal
(i.e. List.toArray applied to a nested chain of List.cons, ending at a List.nil),
where each element is "recognised" by a given function f : Expr → MetaM (Option α),
and return the array of recognised values.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Check if an expression is an array literal
(i.e. List.toArray applied to a nested chain of List.cons, ending at a List.nil),
returning the array of Expr values.
Equations
- Lean.Meta.getArrayLit? e = Lean.Meta.getArrayLitOf? e fun (s : Lean.Expr) => pure (some s)