Documentation

CslibFrontier.Logics.RealArithmetic.Encoding

Binary encodings of real-arithmetic expressions and formulas #

The flat constructor-stream layout is the one used by the formal abstract of edemaine/lean-canny at 970f28a5ecefc1327402ade16c068aa4b1b2c183. Integer constants use binary magnitudes and variables use unary ranks. The dimension is a fixed parameter to each embedding; it is not a separate field in the encoded word. Constructor tokens are framed individually; comparisons carry complete encoded terms. The generated constructor, projection and injectivity APIs come from derive_encoding.

Main definitions #

Recognize this constructor on a typed value.

Extracting a recursive field has a native polynomial-time certificate. The machine scans constructor arities and copies the selected child stream.

Parse exactly one tree from typed tokens; reject trailing tokens.

theorem Cslib.Logic.RealArithmetic.encTerm_const_inO (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ : γ✝ → ℤ} {T0✝ S0✝ : γ✝ → ℕ} :
Turing.MultiTapeTM.ComputableInO f0✝ encIn✝ Turing.MultiTapeTM.encIntBin T0✝ S0✝ → Turing.MultiTapeTM.ComputableInO (fun (a : γ✝) => Term.const (f0✝ a)) encIn✝ (encTerm n) (fun (a : γ✝) => 2 * (encIn✝ a).length + T0✝ a) fun (a : γ✝) => 2 * (encIn✝ a).length + S0✝ a

Extracting a recursive field has a native polynomial-time certificate. The machine scans constructor arities and copies the selected child stream.

Number of constructor occurrences, including leaves.

Extracting a recursive field has a native polynomial-time certificate. The machine scans constructor arities and copies the selected child stream.

Reading recursive arities uses only finitely many constructor tag bits.

theorem Cslib.Logic.RealArithmetic.encTerm_length (n : ℕ) (value✝ : Term n) :
((encTerm n) value✝).length = (List.map (fun (token : ℤ ⊕ Fin n ⊕ Unit ⊕ Unit) => 2 * ((encTermTokenEncoding n) token).length + 1) (encTerm_tokens n value✝)).sum

Exact size: every token is framed once, independently of depth.

Recognize this constructor on a typed value.

Read a constructor token and its fixed number of operands.

theorem Cslib.Logic.RealArithmetic.encTerm_const_payload?_eq_some_iff (n : ℕ) (value✝ : Term n) (payload✝ : ℤ) :
encTerm_const_payload? n value✝ = some payload✝ ↔ value✝ = Term.const payload✝

The complete payload reconstructs exactly this constructor.

@[simp]
theorem Cslib.Logic.RealArithmetic.encTerm_mul_apply (n : ℕ) (x0✝ x1✝ : Term n) :
(encTerm n) (x0✝.mul x1✝) = Turing.MultiTapeTM.frame ((encTermTokenEncoding n) (Sum.inr (Sum.inr (Sum.inr ())))) ++ ((encTerm n) x0✝ ++ ((encTerm n) x1✝ ++ []))
theorem Cslib.Logic.RealArithmetic.encTerm_add_payload?_eq_some_iff (n : ℕ) (value✝ : Term n) (payload✝ : Term n × Term n) :
encTerm_add_payload? n value✝ = some payload✝ ↔ value✝ = payload✝.1.add payload✝.2

The complete payload reconstructs exactly this constructor.

def Cslib.Logic.RealArithmetic.encTerm_make (n : ℕ) (token✝ : ℤ ⊕ Fin n ⊕ Unit ⊕ Unit) :
(Fin (encTerm_arity n token✝) → Term n) → Term n

Reconstruct a node from its scalar token and recursive operands.

theorem Cslib.Logic.RealArithmetic.encTerm_mul_polyTime (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ f1✝ : γ✝ → Term n} :
Turing.MultiTapeTM.ComputableInPolyTime f0✝ encIn✝ (encTerm n) → Turing.MultiTapeTM.ComputableInPolyTime f1✝ encIn✝ (encTerm n) → Turing.MultiTapeTM.ComputableInPolyTime (fun (a : γ✝) => (f0✝ a).mul (f1✝ a)) encIn✝ (encTerm n)
theorem Cslib.Logic.RealArithmetic.encTerm_add_inO (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ : γ✝ → Term n} {T0✝ S0✝ : γ✝ → ℕ} {f1✝ : γ✝ → Term n} {T1✝ S1✝ : γ✝ → ℕ} :
Turing.MultiTapeTM.ComputableInO f0✝ encIn✝ (encTerm n) T0✝ S0✝ → Turing.MultiTapeTM.ComputableInO f1✝ encIn✝ (encTerm n) T1✝ S1✝ → Turing.MultiTapeTM.ComputableInO (fun (a : γ✝) => (f0✝ a).add (f1✝ a)) encIn✝ (encTerm n) (fun (a : γ✝) => 2 * (encIn✝ a).length + T0✝ a + T1✝ a) fun (a : γ✝) => 2 * (encIn✝ a).length + S0✝ a + S1✝ a
@[simp]
theorem Cslib.Logic.RealArithmetic.encTerm_add_apply (n : ℕ) (x0✝ x1✝ : Term n) :
(encTerm n) (x0✝.add x1✝) = Turing.MultiTapeTM.frame ((encTermTokenEncoding n) (Sum.inr (Sum.inr (Sum.inl ())))) ++ ((encTerm n) x0✝ ++ ((encTerm n) x1✝ ++ []))
theorem Cslib.Logic.RealArithmetic.encTerm_add_matches_iff (n : ℕ) (value✝ : Term n) :
encTerm_add_matches n value✝ = true ↔ ∃ (payload : Term n × Term n), value✝ = payload.1.add payload.2

This matcher recognizes the constructor's range.

theorem Cslib.Logic.RealArithmetic.encTerm_mul_inSpace (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ : γ✝ → Term n} {S0✝ : γ✝ → ℕ} {f1✝ : γ✝ → Term n} {S1✝ : γ✝ → ℕ} :
Turing.MultiTapeTM.ComputableInSpace f0✝ encIn✝ (encTerm n) S0✝ → Turing.MultiTapeTM.ComputableInSpace f1✝ encIn✝ (encTerm n) S1✝ → Turing.MultiTapeTM.ComputableInSpace (fun (a : γ✝) => (f0✝ a).mul (f1✝ a)) encIn✝ (encTerm n) fun (a : γ✝) => 2 * (encIn✝ a).length + S0✝ a + S1✝ a

Extract this constructor's fields, or return none on another case.

Extract this constructor's fields, or return none on another case.

Reencoding a decoded value recovers every input token; all other complete-word parses fail.

Extracting a recursive field has a native polynomial-time certificate. The machine scans constructor arities and copies the selected child stream.

Extract this constructor's fields, or return none on another case.

theorem Cslib.Logic.RealArithmetic.encTerm_mul_matches_iff (n : ℕ) (value✝ : Term n) :
encTerm_mul_matches n value✝ = true ↔ ∃ (payload : Term n × Term n), value✝ = payload.1.mul payload.2

This matcher recognizes the constructor's range.

theorem Cslib.Logic.RealArithmetic.encTerm_var_inO (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ : γ✝ → Fin n} {T0✝ S0✝ : γ✝ → ℕ} :
Turing.MultiTapeTM.ComputableInO f0✝ encIn✝ (Turing.MultiTapeTM.EncodingPolicy.BinaryIntUnaryFin.fin n) T0✝ S0✝ → Turing.MultiTapeTM.ComputableInO (fun (a : γ✝) => Term.var (f0✝ a)) encIn✝ (encTerm n) (fun (a : γ✝) => 2 * (encIn✝ a).length + T0✝ a) fun (a : γ✝) => 2 * (encIn✝ a).length + S0✝ a

Extract this constructor's fields, or return none on another case.

@[reducible, inline]

Constructor tags and scalar fields, in declaration order. Scalar tuples frame every field except the last. Recursive fields are omitted.

theorem Cslib.Logic.RealArithmetic.encTerm_mul_inO (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ : γ✝ → Term n} {T0✝ S0✝ : γ✝ → ℕ} {f1✝ : γ✝ → Term n} {T1✝ S1✝ : γ✝ → ℕ} :
Turing.MultiTapeTM.ComputableInO f0✝ encIn✝ (encTerm n) T0✝ S0✝ → Turing.MultiTapeTM.ComputableInO f1✝ encIn✝ (encTerm n) T1✝ S1✝ → Turing.MultiTapeTM.ComputableInO (fun (a : γ✝) => (f0✝ a).mul (f1✝ a)) encIn✝ (encTerm n) (fun (a : γ✝) => 2 * (encIn✝ a).length + T0✝ a + T1✝ a) fun (a : γ✝) => 2 * (encIn✝ a).length + S0✝ a + S1✝ a

Strict bit-word decoder, conditional on explicitly supplied native partial decoders for every scalar field. Empty scalar types are supported.

Extract this constructor's fields, or return none on another case.

Recognize this constructor on a typed value.

Serialized values are exactly complete one-root constructor streams.

theorem Cslib.Logic.RealArithmetic.encTerm_parseFuel_tokens (n : ℕ) (value✝ : Term n) (rest✝ : List (ℤ ⊕ Fin n ⊕ Unit ⊕ Unit)) (fuel✝ : ℕ) :
(encTerm_tokens n value✝).length ≤ fuel✝ → PrefixParser.parseFuel (encTerm_readToken n) fuel✝ (encTerm_tokens n value✝ ++ rest✝) = some (value✝, rest✝)

Prefix decoding preserves the entire following stream.

theorem Cslib.Logic.RealArithmetic.encTerm_add_length (n : ℕ) (x0✝ x1✝ : Term n) :
((encTerm n) (x0✝.add x1✝)).length = 2 * ((encTermTokenEncoding n) (Sum.inr (Sum.inr (Sum.inl ())))).length + 1 + ((encTerm n) x0✝ ++ ((encTerm n) x1✝ ++ [])).length
@[simp]
theorem Cslib.Logic.RealArithmetic.encTerm_tokens_length (n : ℕ) (value✝ : Term n) :
(encTerm_tokens n value✝).length = encTerm_nodes n value✝

Number of stream tokens equals the number of constructors.

Extract this constructor's fields, or return none on another case.

Extract this constructor's fields, or return none on another case.

Recursive arity of a constructor token.

Extract this constructor's fields, or return none on another case.

theorem Cslib.Logic.RealArithmetic.encTerm_add_inSpace (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ : γ✝ → Term n} {S0✝ : γ✝ → ℕ} {f1✝ : γ✝ → Term n} {S1✝ : γ✝ → ℕ} :
Turing.MultiTapeTM.ComputableInSpace f0✝ encIn✝ (encTerm n) S0✝ → Turing.MultiTapeTM.ComputableInSpace f1✝ encIn✝ (encTerm n) S1✝ → Turing.MultiTapeTM.ComputableInSpace (fun (a : γ✝) => (f0✝ a).add (f1✝ a)) encIn✝ (encTerm n) fun (a : γ✝) => 2 * (encIn✝ a).length + S0✝ a + S1✝ a
theorem Cslib.Logic.RealArithmetic.encTerm_length_le (n : ℕ) (value✝ : Term n) :
((encTerm n) value✝).length ≤ 11 * encTerm_nodes n value✝ + 4 * encTerm_leafSize n value✝

Linear bit size in constructor count plus scalar word lengths.

theorem Cslib.Logic.RealArithmetic.encTerm_mul_length (n : ℕ) (x0✝ x1✝ : Term n) :
((encTerm n) (x0✝.mul x1✝)).length = 2 * ((encTermTokenEncoding n) (Sum.inr (Sum.inr (Sum.inr ())))).length + 1 + ((encTerm n) x0✝ ++ ((encTerm n) x1✝ ++ [])).length
theorem Cslib.Logic.RealArithmetic.encTerm_var_matches_iff (n : ℕ) (value✝ : Term n) :
encTerm_var_matches n value✝ = true ↔ ∃ (payload : Fin n), value✝ = Term.var payload

This matcher recognizes the constructor's range.

Sum of the unframed scalar encoding lengths at all nodes.

Extract this constructor's fields, or return none on another case.

theorem Cslib.Logic.RealArithmetic.encTerm_add_polyTime (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ f1✝ : γ✝ → Term n} :
Turing.MultiTapeTM.ComputableInPolyTime f0✝ encIn✝ (encTerm n) → Turing.MultiTapeTM.ComputableInPolyTime f1✝ encIn✝ (encTerm n) → Turing.MultiTapeTM.ComputableInPolyTime (fun (a : γ✝) => (f0✝ a).add (f1✝ a)) encIn✝ (encTerm n)
theorem Cslib.Logic.RealArithmetic.encTerm_const_matches_iff (n : ℕ) (value✝ : Term n) :
encTerm_const_matches n value✝ = true ↔ ∃ (payload : ℤ), value✝ = Term.const payload

This matcher recognizes the constructor's range.

Recognize this constructor on a typed value.

theorem Cslib.Logic.RealArithmetic.encTerm_const_polyTime (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ : γ✝ → ℤ} :
theorem Cslib.Logic.RealArithmetic.encTerm_var_payload?_eq_some_iff (n : ℕ) (value✝ : Term n) (payload✝ : Fin n) :
encTerm_var_payload? n value✝ = some payload✝ ↔ value✝ = Term.var payload✝

The complete payload reconstructs exactly this constructor.

Extract this constructor's fields, or return none on another case.

Constructor arities are bounded independently of scalar fields.

theorem Cslib.Logic.RealArithmetic.encTerm_const_inSpace (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ : γ✝ → ℤ} {S0✝ : γ✝ → ℕ} :
Turing.MultiTapeTM.ComputableInSpace f0✝ encIn✝ Turing.MultiTapeTM.encIntBin S0✝ → Turing.MultiTapeTM.ComputableInSpace (fun (a : γ✝) => Term.const (f0✝ a)) encIn✝ (encTerm n) fun (a : γ✝) => 2 * (encIn✝ a).length + S0✝ a
theorem Cslib.Logic.RealArithmetic.encTerm_mul_payload?_eq_some_iff (n : ℕ) (value✝ : Term n) (payload✝ : Term n × Term n) :
encTerm_mul_payload? n value✝ = some payload✝ ↔ value✝ = payload✝.1.mul payload✝.2

The complete payload reconstructs exactly this constructor.

theorem Cslib.Logic.RealArithmetic.encTerm_tokens_make (n : ℕ) (token✝ : ℤ ⊕ Fin n ⊕ Unit ⊕ Unit) (children✝ : Fin (encTerm_arity n token✝) → Term n) :
encTerm_tokens n (encTerm_make n token✝ children✝) = token✝ :: List.flatMap (encTerm_tokens n) (List.ofFn children✝)

Node reconstruction writes its token followed by its children's streams.

theorem Cslib.Logic.RealArithmetic.encTerm_var_inSpace (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ : γ✝ → Fin n} {S0✝ : γ✝ → ℕ} :
Turing.MultiTapeTM.ComputableInSpace f0✝ encIn✝ (Turing.MultiTapeTM.EncodingPolicy.BinaryIntUnaryFin.fin n) S0✝ → Turing.MultiTapeTM.ComputableInSpace (fun (a : γ✝) => Term.var (f0✝ a)) encIn✝ (encTerm n) fun (a : γ✝) => 2 * (encIn✝ a).length + S0✝ a

Flat constructor stream with binary integer constants and unary variable ranks.

Preorder constructor stream; children occur in recursive-field order.

Extract this constructor's fields, or return none on another case.

Reconstruct a node from its scalar token and recursive operands.

theorem Cslib.Logic.RealArithmetic.encFormula_tokens_make (n : ℕ) (token✝ : Unit ⊕ Term n ⊕ Term n ⊕ Unit ⊕ Unit ⊕ Unit) (children✝ : Fin (encFormula_arity n token✝) → Formula n) :
encFormula_tokens n (encFormula_make n token✝ children✝) = token✝ :: List.flatMap (encFormula_tokens n) (List.ofFn children✝)

Node reconstruction writes its token followed by its children's streams.

Extract this constructor's fields, or return none on another case.

@[simp]

Number of stream tokens equals the number of constructors.

theorem Cslib.Logic.RealArithmetic.encFormula_or_inSpace (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ : γ✝ → Formula n} {S0✝ : γ✝ → ℕ} {f1✝ : γ✝ → Formula n} {S1✝ : γ✝ → ℕ} :
Turing.MultiTapeTM.ComputableInSpace f0✝ encIn✝ (encFormula n) S0✝ → Turing.MultiTapeTM.ComputableInSpace f1✝ encIn✝ (encFormula n) S1✝ → Turing.MultiTapeTM.ComputableInSpace (fun (a : γ✝) => (f0✝ a).or (f1✝ a)) encIn✝ (encFormula n) fun (a : γ✝) => 2 * (encIn✝ a).length + S0✝ a + S1✝ a

Extract this constructor's fields, or return none on another case.

Extract this constructor's fields, or return none on another case.

Preorder constructor stream; children occur in recursive-field order.

Flat Boolean constructor stream carrying complete binary-integer arithmetic term words.

Recognize this constructor on a typed value.

theorem Cslib.Logic.RealArithmetic.encFormula_eqZero_payload?_eq_some_iff (n : ℕ) (value✝ : Formula n) (payload✝ : Term n) :
encFormula_eqZero_payload? n value✝ = some payload✝ ↔ value✝ = Formula.eqZero payload✝

The complete payload reconstructs exactly this constructor.

Extract this constructor's fields, or return none on another case.

theorem Cslib.Logic.RealArithmetic.encFormula_not_inSpace (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ : γ✝ → Formula n} {S0✝ : γ✝ → ℕ} :
Turing.MultiTapeTM.ComputableInSpace f0✝ encIn✝ (encFormula n) S0✝ → Turing.MultiTapeTM.ComputableInSpace (fun (a : γ✝) => (f0✝ a).not) encIn✝ (encFormula n) fun (a : γ✝) => 2 * (encIn✝ a).length + S0✝ a
theorem Cslib.Logic.RealArithmetic.encFormula_false_inSpace (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} :
Turing.MultiTapeTM.ComputableInSpace (fun (a : γ✝) => Formula.false) encIn✝ (encFormula n) fun (a : γ✝) => 2 * (encIn✝ a).length
@[reducible, inline]

Constructor tags and scalar fields, in declaration order. Scalar tuples frame every field except the last. Recursive fields are omitted.

Number of constructor occurrences, including leaves.

Extracting a recursive field has a native polynomial-time certificate. The machine scans constructor arities and copies the selected child stream.

theorem Cslib.Logic.RealArithmetic.encFormula_ltZero_inSpace (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ : γ✝ → Term n} {S0✝ : γ✝ → ℕ} :
Turing.MultiTapeTM.ComputableInSpace f0✝ encIn✝ (encTerm n) S0✝ → Turing.MultiTapeTM.ComputableInSpace (fun (a : γ✝) => Formula.ltZero (f0✝ a)) encIn✝ (encFormula n) fun (a : γ✝) => 2 * (encIn✝ a).length + S0✝ a
theorem Cslib.Logic.RealArithmetic.encFormula_not_matches_iff (n : ℕ) (value✝ : Formula n) :
encFormula_not_matches n value✝ = true ↔ ∃ (payload : Formula n), value✝ = payload.not

This matcher recognizes the constructor's range.

theorem Cslib.Logic.RealArithmetic.encFormula_eqZero_inSpace (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ : γ✝ → Term n} {S0✝ : γ✝ → ℕ} :
Turing.MultiTapeTM.ComputableInSpace f0✝ encIn✝ (encTerm n) S0✝ → Turing.MultiTapeTM.ComputableInSpace (fun (a : γ✝) => Formula.eqZero (f0✝ a)) encIn✝ (encFormula n) fun (a : γ✝) => 2 * (encIn✝ a).length + S0✝ a
theorem Cslib.Logic.RealArithmetic.encFormula_false_inO (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} :
Turing.MultiTapeTM.ComputableInO (fun (a : γ✝) => Formula.false) encIn✝ (encFormula n) (fun (a : γ✝) => 2 * (encIn✝ a).length) fun (a : γ✝) => 2 * (encIn✝ a).length
theorem Cslib.Logic.RealArithmetic.encFormula_false_payload?_eq_some_iff (n : ℕ) (value✝ : Formula n) (payload✝ : Unit) :
encFormula_false_payload? n value✝ = some payload✝ ↔ value✝ = Formula.false

The complete payload reconstructs exactly this constructor.

Extract this constructor's fields, or return none on another case.

Recognize this constructor on a typed value.

Extracting a recursive field has a native polynomial-time certificate. The machine scans constructor arities and copies the selected child stream.

theorem Cslib.Logic.RealArithmetic.encFormula_and_inO (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ : γ✝ → Formula n} {T0✝ S0✝ : γ✝ → ℕ} {f1✝ : γ✝ → Formula n} {T1✝ S1✝ : γ✝ → ℕ} :
Turing.MultiTapeTM.ComputableInO f0✝ encIn✝ (encFormula n) T0✝ S0✝ → Turing.MultiTapeTM.ComputableInO f1✝ encIn✝ (encFormula n) T1✝ S1✝ → Turing.MultiTapeTM.ComputableInO (fun (a : γ✝) => (f0✝ a).and (f1✝ a)) encIn✝ (encFormula n) (fun (a : γ✝) => 2 * (encIn✝ a).length + T0✝ a + T1✝ a) fun (a : γ✝) => 2 * (encIn✝ a).length + S0✝ a + S1✝ a

Read a constructor token and its fixed number of operands.

Recursive arity of a constructor token.

theorem Cslib.Logic.RealArithmetic.encFormula_and_payload?_eq_some_iff (n : ℕ) (value✝ : Formula n) (payload✝ : Formula n × Formula n) :
encFormula_and_payload? n value✝ = some payload✝ ↔ value✝ = payload✝.1.and payload✝.2

The complete payload reconstructs exactly this constructor.

theorem Cslib.Logic.RealArithmetic.encFormula_ltZero_payload?_eq_some_iff (n : ℕ) (value✝ : Formula n) (payload✝ : Term n) :
encFormula_ltZero_payload? n value✝ = some payload✝ ↔ value✝ = Formula.ltZero payload✝

The complete payload reconstructs exactly this constructor.

theorem Cslib.Logic.RealArithmetic.encFormula_length (n : ℕ) (value✝ : Formula n) :
((encFormula n) value✝).length = (List.map (fun (token : Unit ⊕ Term n ⊕ Term n ⊕ Unit ⊕ Unit ⊕ Unit) => 2 * ((encFormulaTokenEncoding n) token).length + 1) (encFormula_tokens n value✝)).sum

Exact size: every token is framed once, independently of depth.

theorem Cslib.Logic.RealArithmetic.encFormula_or_payload?_eq_some_iff (n : ℕ) (value✝ : Formula n) (payload✝ : Formula n × Formula n) :
encFormula_or_payload? n value✝ = some payload✝ ↔ value✝ = payload✝.1.or payload✝.2

The complete payload reconstructs exactly this constructor.

Extract this constructor's fields, or return none on another case.

Extract this constructor's fields, or return none on another case.

Extract this constructor's fields, or return none on another case.

Serialized values are exactly complete one-root constructor streams.

Extract this constructor's fields, or return none on another case.

theorem Cslib.Logic.RealArithmetic.encFormula_and_matches_iff (n : ℕ) (value✝ : Formula n) :
encFormula_and_matches n value✝ = true ↔ ∃ (payload : Formula n × Formula n), value✝ = payload.1.and payload.2

This matcher recognizes the constructor's range.

theorem Cslib.Logic.RealArithmetic.encFormula_eqZero_polyTime (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ : γ✝ → Term n} :
theorem Cslib.Logic.RealArithmetic.encFormula_ltZero_polyTime (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ : γ✝ → Term n} :
theorem Cslib.Logic.RealArithmetic.encFormula_or_matches_iff (n : ℕ) (value✝ : Formula n) :
encFormula_or_matches n value✝ = true ↔ ∃ (payload : Formula n × Formula n), value✝ = payload.1.or payload.2

This matcher recognizes the constructor's range.

Reencoding a decoded value recovers every input token; all other complete-word parses fail.

theorem Cslib.Logic.RealArithmetic.encFormula_not_payload?_eq_some_iff (n : ℕ) (value✝ payload✝ : Formula n) :
encFormula_not_payload? n value✝ = some payload✝ ↔ value✝ = payload✝.not

The complete payload reconstructs exactly this constructor.

theorem Cslib.Logic.RealArithmetic.encFormula_eqZero_inO (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ : γ✝ → Term n} {T0✝ S0✝ : γ✝ → ℕ} :
Turing.MultiTapeTM.ComputableInO f0✝ encIn✝ (encTerm n) T0✝ S0✝ → Turing.MultiTapeTM.ComputableInO (fun (a : γ✝) => Formula.eqZero (f0✝ a)) encIn✝ (encFormula n) (fun (a : γ✝) => 2 * (encIn✝ a).length + T0✝ a) fun (a : γ✝) => 2 * (encIn✝ a).length + S0✝ a
theorem Cslib.Logic.RealArithmetic.encFormula_not_inO (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ : γ✝ → Formula n} {T0✝ S0✝ : γ✝ → ℕ} :
Turing.MultiTapeTM.ComputableInO f0✝ encIn✝ (encFormula n) T0✝ S0✝ → Turing.MultiTapeTM.ComputableInO (fun (a : γ✝) => (f0✝ a).not) encIn✝ (encFormula n) (fun (a : γ✝) => 2 * (encIn✝ a).length + T0✝ a) fun (a : γ✝) => 2 * (encIn✝ a).length + S0✝ a
theorem Cslib.Logic.RealArithmetic.encFormula_parseFuel_tokens (n : ℕ) (value✝ : Formula n) (rest✝ : List (Unit ⊕ Term n ⊕ Term n ⊕ Unit ⊕ Unit ⊕ Unit)) (fuel✝ : ℕ) :
(encFormula_tokens n value✝).length ≤ fuel✝ → PrefixParser.parseFuel (encFormula_readToken n) fuel✝ (encFormula_tokens n value✝ ++ rest✝) = some (value✝, rest✝)

Prefix decoding preserves the entire following stream.

Extract this constructor's fields, or return none on another case.

Extracting a recursive field has a native polynomial-time certificate. The machine scans constructor arities and copies the selected child stream.

Parse exactly one tree from typed tokens; reject trailing tokens.

theorem Cslib.Logic.RealArithmetic.encFormula_length_le (n : ℕ) (value✝ : Formula n) :
((encFormula n) value✝).length ≤ 15 * encFormula_nodes n value✝ + 4 * encFormula_leafSize n value✝

Linear bit size in constructor count plus scalar word lengths.

theorem Cslib.Logic.RealArithmetic.encFormula_or_inO (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ : γ✝ → Formula n} {T0✝ S0✝ : γ✝ → ℕ} {f1✝ : γ✝ → Formula n} {T1✝ S1✝ : γ✝ → ℕ} :
Turing.MultiTapeTM.ComputableInO f0✝ encIn✝ (encFormula n) T0✝ S0✝ → Turing.MultiTapeTM.ComputableInO f1✝ encIn✝ (encFormula n) T1✝ S1✝ → Turing.MultiTapeTM.ComputableInO (fun (a : γ✝) => (f0✝ a).or (f1✝ a)) encIn✝ (encFormula n) (fun (a : γ✝) => 2 * (encIn✝ a).length + T0✝ a + T1✝ a) fun (a : γ✝) => 2 * (encIn✝ a).length + S0✝ a + S1✝ a

This matcher recognizes the constructor's range.

Recognize this constructor on a typed value.

Extract this constructor's fields, or return none on another case.

Extract this constructor's fields, or return none on another case.

Sum of the unframed scalar encoding lengths at all nodes.

Extracting a recursive field has a native polynomial-time certificate. The machine scans constructor arities and copies the selected child stream.

Recognize this constructor on a typed value.

Recognize this constructor on a typed value.

Constructor arities are bounded independently of scalar fields.

Recognize this constructor on a typed value.

theorem Cslib.Logic.RealArithmetic.encFormula_ltZero_matches_iff (n : ℕ) (value✝ : Formula n) :
encFormula_ltZero_matches n value✝ = true ↔ ∃ (payload : Term n), value✝ = Formula.ltZero payload

This matcher recognizes the constructor's range.

theorem Cslib.Logic.RealArithmetic.encFormula_ltZero_inO (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ : γ✝ → Term n} {T0✝ S0✝ : γ✝ → ℕ} :
Turing.MultiTapeTM.ComputableInO f0✝ encIn✝ (encTerm n) T0✝ S0✝ → Turing.MultiTapeTM.ComputableInO (fun (a : γ✝) => Formula.ltZero (f0✝ a)) encIn✝ (encFormula n) (fun (a : γ✝) => 2 * (encIn✝ a).length + T0✝ a) fun (a : γ✝) => 2 * (encIn✝ a).length + S0✝ a

Strict bit-word decoder, conditional on explicitly supplied native partial decoders for every scalar field. Empty scalar types are supported.

theorem Cslib.Logic.RealArithmetic.encFormula_eqZero_matches_iff (n : ℕ) (value✝ : Formula n) :
encFormula_eqZero_matches n value✝ = true ↔ ∃ (payload : Term n), value✝ = Formula.eqZero payload

This matcher recognizes the constructor's range.

theorem Cslib.Logic.RealArithmetic.encFormula_not_polyTime (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ : γ✝ → Formula n} :
Turing.MultiTapeTM.ComputableInPolyTime f0✝ encIn✝ (encFormula n) → Turing.MultiTapeTM.ComputableInPolyTime (fun (a : γ✝) => (f0✝ a).not) encIn✝ (encFormula n)
theorem Cslib.Logic.RealArithmetic.encFormula_and_inSpace (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ : γ✝ → Formula n} {S0✝ : γ✝ → ℕ} {f1✝ : γ✝ → Formula n} {S1✝ : γ✝ → ℕ} :
Turing.MultiTapeTM.ComputableInSpace f0✝ encIn✝ (encFormula n) S0✝ → Turing.MultiTapeTM.ComputableInSpace f1✝ encIn✝ (encFormula n) S1✝ → Turing.MultiTapeTM.ComputableInSpace (fun (a : γ✝) => (f0✝ a).and (f1✝ a)) encIn✝ (encFormula n) fun (a : γ✝) => 2 * (encIn✝ a).length + S0✝ a + S1✝ a
theorem Cslib.Logic.RealArithmetic.encFormula_or_polyTime (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ f1✝ : γ✝ → Formula n} :
Turing.MultiTapeTM.ComputableInPolyTime f0✝ encIn✝ (encFormula n) → Turing.MultiTapeTM.ComputableInPolyTime f1✝ encIn✝ (encFormula n) → Turing.MultiTapeTM.ComputableInPolyTime (fun (a : γ✝) => (f0✝ a).or (f1✝ a)) encIn✝ (encFormula n)
theorem Cslib.Logic.RealArithmetic.encFormula_and_polyTime (n : ℕ) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {f0✝ f1✝ : γ✝ → Formula n} :
Turing.MultiTapeTM.ComputableInPolyTime f0✝ encIn✝ (encFormula n) → Turing.MultiTapeTM.ComputableInPolyTime f1✝ encIn✝ (encFormula n) → Turing.MultiTapeTM.ComputableInPolyTime (fun (a : γ✝) => (f0✝ a).and (f1✝ a)) encIn✝ (encFormula n)

Extracting a recursive field has a native polynomial-time certificate. The machine scans constructor arities and copies the selected child stream.

@[reducible, inline]

A prefix constructor token with a natural-number variable rank. The four alternatives are an integer constant, a variable, addition, and multiplication, in that order.

@[reducible, inline]

The term constructor tags, followed by a binary integer, unary rank, or empty payload.

@[reducible, match_pattern, inline]

Raw prefix token for an integer constant.

@[reducible, match_pattern, inline]

Raw prefix token for a variable with natural-number rank i.

@[reducible, match_pattern, inline]

Raw prefix token for addition.

@[reducible, match_pattern, inline]

Raw prefix token for multiplication.

Keep the constructor and payload of a typed token, reading a variable as its unary rank.

@[reducible, inline]

A prefix formula token. The alternatives are falsity, equality to zero, strict inequality to zero, negation, conjunction, and disjunction. Comparison tokens carry a complete term word.

@[reducible, inline]

Encode the formula constructor tags followed by the term word or empty payload.

@[reducible, match_pattern, inline]

Raw prefix token for falsity.

@[reducible, match_pattern, inline]

Raw prefix token for equality to zero, carrying an encoded term word.

@[reducible, match_pattern, inline]

Raw prefix token for strict inequality to zero, carrying an encoded term word.

@[reducible, match_pattern, inline]

Raw prefix token for negation.

@[reducible, match_pattern, inline]

Raw prefix token for conjunction.

@[reducible, match_pattern, inline]

Raw prefix token for disjunction.

Keep a typed formula token's constructor and encode any comparison term as a word.

theorem Cslib.Logic.RealArithmetic.encTerm_rename {n m : ℕ} (f : Fin n → Fin m) (hf : ∀ (i : Fin n), ↑(f i) = ↑i) (t : Term n) :
(encTerm m) (Term.rename f t) = (encTerm n) t

Preserving variable ranks preserves every bit of a term's encoding.

theorem Cslib.Logic.RealArithmetic.encFormula_rename {n m : ℕ} (f : Fin n → Fin m) (hf : ∀ (i : Fin n), ↑(f i) = ↑i) (p : Formula n) :

Preserving variable ranks preserves every bit of a formula's encoding.