Timings for hprop_lattice.v
Require Import
HoTT.Classes.interfaces.abstract_algebra
HoTT.Universes.TruncType.
(** Demonstrate the [HProp] is a (bounded) lattice w.r.t. the logical
operations. This requires Univalence. *)
Instance join_hor : Join HProp := hor.
Definition hand (X Y : HProp) : HProp := Build_HProp (X * Y).
Instance meet_hprop : Meet HProp := hand.
Instance bottom_hprop : Bottom HProp := False_hp.
Instance top_hprop : Top HProp := Unit_hp.
(* We use this notation because [hor] can accept arguments of type [Type], which leads to minor confusion in the instances below *)
Notation lor := (hor : HProp -> HProp -> HProp).
(* This tactic attempts to destruct a truncated sum (disjunction) *)
Local Ltac hor_intros :=
let x := fresh in
intro x; repeat (strip_truncations; destruct x as [x | x]).
Instance commutative_hor : Commutative lor.
apply path_iff_hprop; hor_intros; apply tr; auto.
Instance commutative_hand : Commutative hand.
Instance associative_hor : Associative lor.
apply path_iff_hprop;
hor_intros; apply tr;
((by auto) || (left; apply tr) || (right; apply tr));
auto.
Instance associative_hand : Associative hand.
Instance idempotent_hor : BinaryIdempotent lor.
apply path_iff_hprop; hor_intros; auto.
Instance idempotent_hand : BinaryIdempotent hand.
intros a; apply (pair a a).
Instance leftidentity_hor : LeftIdentity lor False_hp.
apply path_iff_hprop; hor_intros; try contradiction || assumption.
Instance rightidentity_hor : RightIdentity lor False_hp.
apply path_iff_hprop; hor_intros; try contradiction || assumption.
Instance leftidentity_hand : LeftIdentity hand Unit_hp.
apply path_trunctype, prod_unit_l.
Instance rightidentity_hand : RightIdentity hand Unit_hp.
apply path_trunctype, prod_unit_r.
Instance absorption_hor_hand : Absorption lor hand.
intros X; strip_truncations.
destruct X as [? | [? _]]; assumption.
Instance absorption_hand_hor : Absorption hand lor.
intros [? _]; assumption.
#[export] Instance boundedlattice_hprop : IsBoundedLattice HProp.