Stroke notation, propositional translation, and universal class chains
DefinitionLawsOfForm_LogicDefines stroke as crossing over adjacency and prime as self-stroke. Defines finite proposition formulas with atoms, negation, disjunction, conjunction and implication, their Boolean truth function, and their recursive translation into forms. Defines universal inclusion chains of predicates on arbitrary types, with zero links allowed. No completeness, postulate or inference theorem is assumed.
import Definitions.Def_LawsOfForm_Algebra
import Mathlib.Data.Fin.Basic
set_option autoImplicit false
namespace LawsOfForm
def stroke (a b : Expr) : Expr := .cross (.beside a b)
def prime (a : Expr) : Expr := stroke a a
inductive Proposition where
| atom : Nat → Proposition
| neg : Proposition → Proposition
| disj : Proposition → Proposition → Proposition
| conj : Proposition → Proposition → Proposition
| implies : Proposition → Proposition → Proposition
deriving DecidableEq, Repr
def truth (ρ : Nat → Bool) : Proposition → Bool
| .atom x => ρ x
| .neg p => !(truth ρ p)
| .disj p q => truth ρ p || truth ρ q
| .conj p q => truth ρ p && truth ρ q
| .implies p q => !(truth ρ p) || truth ρ q
def encode : Proposition → Expr
| .atom x => .var x
| .neg p => .cross (encode p)
| .disj p q => .beside (encode p) (encode q)
| .conj p q => .cross (.beside (.cross (encode p)) (.cross (encode q)))
| .implies p q => .beside (.cross (encode p)) (encode q)
def InclusionChain {α : Type} (n : Nat) (classes : Fin (n + 1) → α → Prop) : Prop :=
∀ i : Fin n, ∀ x : α, classes i.castSucc x → classes i.succ x
end LawsOfForm
Read-back
What the Lean code literally says, in plain math · Codex (GPT-6)
LawsOfForm.stroke. For every pair of expressions in the small data type of finite syntax trees freely generated by a blank symbol , a variable for every natural number , a unary constructor , and an ordered binary constructor , this definition assigns : first form the binary expression with on the left and on the right, and then apply the unary constructor. The arguments may be any such expressions, including blanks, variables indexed by zero, or identical expressions; no condition or identification of syntax trees is imposed.
LawsOfForm.prime. For every expression in the small data type of finite syntax trees freely generated by a blank symbol , variables indexed by all natural numbers , a unary constructor , and an ordered binary constructor , this definition assigns . Thus it places two copies of the same expression in the two positions of the binary constructor and applies the unary constructor, including when is blank or a variable indexed by zero; this is a definition of a syntax tree with no simplifying identification.
LawsOfForm.Proposition. This declaration introduces a small data type whose members are precisely finite formula trees built using five constructors: an atom for each natural number ; a unary formula for each ; and three ordered binary formulas , , and for every , named negation, disjunction, conjunction, and implication respectively. The constructors are distinct and their arguments are retained as syntax; there are no additional constant, empty, infinitary, or quantified-formula constructors. Equality of these formula trees is decidable, and a representation for displaying them is generated. This data type is in the lowest data-type universe, rather than being the universe of logical propositions, and the declaration itself supplies no truth interpretation.
LawsOfForm.truth. For every total assignment and every finite formula in the small data type generated by atoms for all , negations , disjunctions , conjunctions , and implications , this definition recursively returns a Boolean by the equations , , , , and . Here Boolean negation exchanges false and true, Boolean disjunction is true exactly when at least one input is true, and Boolean conjunction is true exactly when both inputs are true; consequently the implication constructor receives false exactly when its first input receives true and its second receives false. The assignment includes atom zero and all other natural-number indices, with no restriction on assigned values. Formulas have no empty or constant constructor, so the recursion has no empty-formula case.
LawsOfForm.encode. This definition sends each member of the small data type of finite formulas, generated by atoms for all natural numbers , negations , disjunctions , conjunctions , and implications , to the small data type of finite expression trees freely generated by a blank symbol , variables for all , a unary constructor , and an ordered binary constructor . Writing the translation as , its complete recursion is , , , , and . Atom zero is translated to variable zero, the order of binary inputs is retained in each displayed construction, and there is no empty-formula case or constant-formula case. The blank constructor belongs to the target type but does not occur in any translation clause; this declaration specifies a syntactic translation without a valuation parameter or a truth-preservation assertion.
LawsOfForm.InclusionChain. For every implicitly supplied type in the lowest data-type universe, every natural number , and every indexed family of predicates , this definition returns the proposition . More explicitly, an index is used first as the same integer in the index set and then as its successor in that same set, so the required inclusions are exactly , where each predicate is regarded as its class of satisfying elements. There is no requirement that an inclusion be strict, that any class be nonempty, or that the family exhaust the carrier. When , the family still contains one predicate , but there are no adjacent pairs and the proposition is true regardless of that predicate; when is empty it is true for every and every such family. The carrier is restricted to the specified lowest data-type universe and is not quantified over arbitrary higher universes.