text
stringlengths 0
3.34M
|
---|
theory tp89
imports Main "~~/src/HOL/Library/Code_Target_Nat"
begin
(*
transid
c identifie un client
m identifie un marchand
i numéro de transaction entre c et m
am transaction montant retenu pour la transaction
Client \<longrightarrow> Marchand
Pay (c,m,i) am \<longrightarrow> c accepte de payer le montant am à m pour la transaction id
Marchand \<longrightarrow> Client
Ack (c,m,i) am \<longrightarrow> m demande un montant am au client c pour la transaction id
Cancel (c,m,i) \<longrightarrow> m annule toutes les transactions pour transaction id
le marchand doit diminuer am
le client doit augmenter am
*)
type_synonym transid= "nat*nat*nat"
datatype message=
Pay transid nat
| Ack transid nat
| Cancel transid
datatype etatTrans=
Encours
| Ok
| Abort
datatype SomeTrans =
None
| Integer nat
datatype SomeEtat =
Nothing
| Etat etatTrans
type_synonym transaction= "transid * nat"
(* transid * am marchand * am client * etat *)
type_synonym ligneBdd = "(transid * SomeTrans *SomeTrans * etatTrans )"
type_synonym transBdd ="ligneBdd list"
(* select dans la bdd, l'etat de la transi*)
fun selectEtat ::"transid \<Rightarrow> transBdd \<Rightarrow> SomeEtat "
where
"selectEtat _ [] = Nothing"
|"selectEtat id1 ((id2::transid,sm2,sc2,etat2)#xs) =( if(id1=id2) then (Etat etat2) else selectEtat id1 xs )"
(* select dans la bdd de la proposition du marchand*)
fun selectMarch ::"transid \<Rightarrow> transBdd \<Rightarrow> SomeTrans "
where
"selectMarch _ [] = None"
|"selectMarch id1 ((id2::transid,sm2,sc2,etat2)#xs) =( if(id1=id2) then sm2 else selectMarch id1 xs )"
(* select dans la bdd de la proposition du client*)
fun selectClient ::"transid \<Rightarrow> transBdd \<Rightarrow> SomeTrans"
where
"selectClient _ [] = None"
|"selectClient id1 ((id2::transid,sm2,sc2,etat2)#xs) =( if(id1=id2) then sc2 else selectClient id1 xs )"
fun updateLignePay :: " nat \<Rightarrow> ligneBdd \<Rightarrow> ligneBdd"
where
"updateLignePay _ ((x2::transid),m2,c2,Abort) = ((x2::transid),m2,c2,Abort)"
|"updateLignePay v1 ((x2::transid),Integer m2,None,Encours) = (if (v1\<ge>m2) then ((x2::transid),Integer m2, Integer v1,Ok) else ((x2::transid),Integer m2,Integer v1,Encours) )"
|"updateLignePay v1 ((x2::transid),Integer m2,Integer v2,Encours) = (if (v1>v2) then (if(v1\<ge>m2) then ((x2::transid),Integer m2,Integer v1,Ok) else ((x2::transid),Integer m2,Integer v1,Encours)) else ( ((x2::transid),Integer m2,Integer v2,Encours)))"
|"updateLignePay _ ((x2::transid),m2,c2,Ok) = ((x2::transid),m2,c2,Ok)"
|"updateLignePay v1 (v,None, None, Encours) = (v,None, Integer v1, Encours)"
|"updateLignePay v1 (v,None, Integer v2, Encours) = (if (v1>v2) then (v,None, Integer v1, Encours) else (v,None, Integer v2, Encours)) "
fun updatePay:: "(transid * nat) \<Rightarrow> transBdd \<Rightarrow> transBdd"
where
"updatePay ((x1::transid),c1) [] = [((x1::transid),None,Integer c1,Encours)] "
|"updatePay ((x1::transid),c1) (((x2::transid),m2,c2,e2)#xs)= (if (x2=x1) then (updateLignePay (c1) ((x2::transid),m2,c2,e2) )#xs else (((x2::transid),m2,c2,e2)#(updatePay ((x1::transid),c1) xs )) )"
fun updateLigneAck :: "nat \<Rightarrow> ligneBdd \<Rightarrow> ligneBdd"
where
"updateLigneAck _ ((x2::transid),m2,c2,Abort) = ((x2::transid),m2,c2,Abort)"
|"updateLigneAck m1 ((x2::transid),Integer m2,None,Encours) = (if (m1\<le>m2) then ((x2::transid),Integer m1, None,Encours) else ((x2::transid),Integer m2,None,Encours) )"
|"updateLigneAck m1 ((x2::transid),Integer m2,Integer v2,Encours) = (if (m1\<le>m2) then (if(m1\<le>v2) then ((x2::transid),Integer m1,Integer v2,Ok) else ((x2::transid),Integer m1,Integer v2,Encours)) else ( ((x2::transid),Integer m2,Integer v2,Encours)))"
|"updateLigneAck _ ((x2::transid),m2,c2,Ok) = ((x2::transid),m2,c2,Ok)"
|"updateLigneAck m1 (v,None, None, Encours) = (v,Integer m1,None, Encours)"
|"updateLigneAck m1 (v,None, Integer v2, Encours) = (if (m1\<le>v2) then (v,Integer m1, Integer v2, Ok) else (v, Integer m1,Integer v2, Encours)) "
fun updateAck:: "(transid * nat) \<Rightarrow> transBdd \<Rightarrow> transBdd"
where
"updateAck ((x1::transid),c1) [] = [((x1::transid),Integer c1,None,Encours)] "
|"updateAck ((x1::transid),c1) (((x2::transid),m2,c2,e2)#xs)= (if (x2=x1) then (updateLigneAck (c1) ((x2::transid),m2,c2,e2) )#xs else (((x2::transid),m2,c2,e2)#(updateAck ((x1::transid),c1) xs )) )"
fun updateLigneCancel :: " ligneBdd \<Rightarrow> ligneBdd"
where
"updateLigneCancel ((x2::transid),m2,c2,e2) = ((x2::transid),m2,c2,Abort)"
fun updateCancel:: "transid \<Rightarrow> transBdd \<Rightarrow> transBdd"
where
"updateCancel (x1::transid) [] = [((x1::transid),None,None,Abort)] "
|"updateCancel (x1::transid) (((x2::transid),m2,c2,e2)#xs)= (if (x2=x1) then (updateLigneCancel ((x2::transid),m2,c2,e2) )#xs else (((x2::transid),m2,c2,e2)#(updateCancel ((x1::transid)) xs )) )"
fun traiterMessage ::"message \<Rightarrow> transBdd \<Rightarrow> transBdd "
where
"traiterMessage ( Pay transid am) tb = (if(am>0) then updatePay (transid, am) tb else tb)"
|"traiterMessage ( Ack transid am) tb = (if(am\<ge>0) then updateAck (transid, am) tb else tb)"
|"traiterMessage ( Cancel transid) tb = updateCancel transid tb "
fun export:: "transBdd \<Rightarrow> transaction list"
where
"export [] = []"
|"export (((x2::transid),m2,Integer c2,e2)#xs) = (if (e2=Ok) then (x2,c2)#(export xs ) else(export xs ) )"
|"export (((x2::transid),m2,c2,e2)#xs) = (export xs )"
fun traiMessList:: "message list \<Rightarrow> transBdd \<Rightarrow> transBdd"
where
"traiMessList [] tb = tb"
|"traiMessList (v # va) tb =traiMessList va (traiterMessage v tb) "
fun traiterMessageList:: "message list \<Rightarrow> transBdd"
where
"traiterMessageList ml = traiMessList ml []"
lemma lem1:"( (List.member (export (traiterMessageList lm)) (a,b)) \<longrightarrow> (b>0))"
apply (induct lm)
apply auto
apply (simp add: member_rec(2))
oops
oops
lemma lem3:"(selectEtat a (traiterMessage (Cancel a) (traiterMessageList lm))) = Etat Abort"
apply (induct lm)
apply auto
oops
lemma lem4:"(List.member (export (traiterMessage (Cancel a) (traiterMessageList lm))) (a,b)) = False"
apply (induct lm)
apply auto
apply (simp add: member_rec(2))
oops
lemma lem5:"pc\<ge>pm \<and> pc>0 \<and> \<not>(List.member lm (Cancel a )) \<longrightarrow> (\<exists> pc. List.member (export (traiterMessage (Pay a pc) (traiterMessage (Ack a pm) (traiterMessageList lm)))) (a,pc))"
apply (induct lm)
apply auto
apply (metis gr_implies_not0 member_rec(1))
apply (simp add: member_rec(1))
oops
lemma lem6:"(selectEtat a (traiterMessageList lm) = Etat Ok) \<longrightarrow>(\<exists> pc pm.(List.member lm (Ack a pm)) \<and> (List.member lm (Pay a pc)) \<and> pc \<ge> pm) "
apply (induct lm)
apply auto
oops
lemma lem71:"( selectClient a (traiterMessageList lm)) = Integer pm \<and> pm> mo \<longrightarrow> ( selectClient a (traiterMessage (Pay a mo) (traiterMessageList lm))) = Integer pm "
oops
lemma lem72:"( selectMarch a (traiterMessageList lm)) = Integer pm \<and> pm < mo \<longrightarrow> ( selectMarch a (traiterMessage (Ack a mo) (traiterMessageList lm))) = Integer pm "
oops
lemma lem81:"(selectEtat a (traiterMessageList lm) = Etat Ok) \<and> (selectClient a (traiterMessage (Pay a pm) (traiterMessageList lm)) = Integer pm) \<longrightarrow> (selectClient a (traiterMessage (Pay a autre) (traiterMessageList lm)) = Integer pm)"
oops
lemma lem82:"(selectEtat a (traiterMessageList lm) = Etat Ok) \<and> (selectMarch a (traiterMessageList lm) = Integer pm) \<longrightarrow> (selectMarch a (traiterMessage (Ack a autre) (traiterMessageList lm)) = Integer pm)"
oops
lemma lem9:"(selectEtat a (traiterMessageList lm) = Etat Ok) \<and> (selectMarch a (traiterMessageList lm) = Integer pm) \<and> (selectClient a (traiterMessageList lm) = Integer pc) \<longrightarrow> (List.member (export (traiterMessageList lm)) (a,pc)) "
oops
(* ----- Exportation en Scala (Isabelle 2014) -------*)
(* Directive d'exportation *)
export_code export traiterMessage in Scala
end
|
theory Datatypes
imports inc.Prelude
begin
default_sort type
datatype channel = cab | cin | cout
section \<open>Message Definition\<close>
text\<open>The same is true for the "Message" Datatype. Every kind of message has to be described here:\<close>
datatype M_pure = \<N> nat | \<B> bool
text \<open>Instantiate @{type M_pure} as countable. This is necessary for using @{type M_pure} streams. }\<close>
instance M_pure::countable
apply(countable_datatype)
done
lemma inj_B[simp]:"inj \<B>"
by (simp add: inj_def)
lemma inj_Bopt[simp]:"inj (map_option \<B>)"
by (simp add: option.inj_map)
text \<open>Then one describes the types of each channel. Only Messages included are allowed to be
transmitted\<close>
fun cMsg :: "channel \<Rightarrow> M_pure set" where
"cMsg cin = range \<N>" |
"cMsg cout = range \<N>" |
"cMsg _ = {}"
text\<open>Timing properties of each channel\<close>
fun cTime :: "channel \<Rightarrow> timeType" where
"cTime cin = TUntimed" |
"cTime cout = TUntimed" |
"cTime _ = undefined"
lemma cmsgempty_ex:"\<exists>c. cMsg c = {}"
using cMsg.simps by blast
end
|
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-}
module Light.Library.Relation where
open import Light.Level using (Level ; Setω)
open import Light.Variable.Sets
record Kind : Setω where
field
iℓ : Level
Index : Set iℓ
ℓf : Index → Level
Proposition : ∀ i → Set (ℓf i)
record Style (kind : Kind) : Setω where
open Kind kind
field
true‐i false‐i : Index
true : Proposition true‐i
false : Proposition false‐i
¬‐index‐f : Index → Index
¬_ : ∀ {i} → Proposition i → Proposition (¬‐index‐f i)
∧‐index‐f ∨‐index‐f ⇢‐index‐f : Index → Index → Index
_∧_ : ∀ {ia ib} → Proposition ia → Proposition ib → Proposition (∧‐index‐f ia ib)
_∨_ : ∀ {ia ib} → Proposition ia → Proposition ib → Proposition (∨‐index‐f ia ib)
_⇢_ : ∀ {ia ib} → Proposition ia → Proposition ib → Proposition (⇢‐index‐f ia ib)
true‐set‐ℓf false‐set‐ℓf : Index → Level
True : ∀ {i} → Proposition i → Set (true‐set‐ℓf i)
False : ∀ {i} → Proposition i → Set (false‐set‐ℓf i)
true‐is‐true : True true
false‐is‐false : False false
record Base : Setω where
field ⦃ kind ⦄ : Kind
field ⦃ style ⦄ : Style kind
open Kind ⦃ ... ⦄ public
open Style ⦃ ... ⦄ public
|
State Before: 𝕜 : Type u_1
inst✝⁴ : NontriviallyNormedField 𝕜
F : Type u_2
inst✝³ : NormedAddCommGroup F
inst✝² : NormedSpace 𝕜 F
E : Type ?u.162489
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace 𝕜 E
n : ℕ
f : 𝕜 → F
s : Set 𝕜
x : 𝕜
⊢ iteratedDeriv (n + 1) f = iteratedDeriv n (deriv f) State After: 𝕜 : Type u_1
inst✝⁴ : NontriviallyNormedField 𝕜
F : Type u_2
inst✝³ : NormedAddCommGroup F
inst✝² : NormedSpace 𝕜 F
E : Type ?u.162489
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace 𝕜 E
n : ℕ
f : 𝕜 → F
s : Set 𝕜
x : 𝕜
⊢ (deriv^[n + 1]) f = (deriv^[n]) (deriv f) Tactic: rw [iteratedDeriv_eq_iterate, iteratedDeriv_eq_iterate] State Before: 𝕜 : Type u_1
inst✝⁴ : NontriviallyNormedField 𝕜
F : Type u_2
inst✝³ : NormedAddCommGroup F
inst✝² : NormedSpace 𝕜 F
E : Type ?u.162489
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace 𝕜 E
n : ℕ
f : 𝕜 → F
s : Set 𝕜
x : 𝕜
⊢ (deriv^[n + 1]) f = (deriv^[n]) (deriv f) State After: no goals Tactic: rfl |
-- {-# OPTIONS -v tc.lhs.shadow:30 #-}
module PatternShadowsConstructor3 where
data Bool : Set where
true false : Bool
module A where
data B : Set where
x : B
data C : Set where
c : B → C
open A using (C; c)
T : Bool → Set
T true = C → C
T false = Bool
f : (b : Bool) → T b
f true (c x) = x
f false = true
|
[STATEMENT]
lemma decompose_com_ictxt:
assumes "(c', ictxt, fctxt) \<in> decompose_com c"
shows "ictxt c' = c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. ictxt c' = c
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
(c', ictxt, fctxt) \<in> decompose_com c
goal (1 subgoal):
1. ictxt c' = c
[PROOF STEP]
by (induct c arbitrary: c' ictxt fctxt) auto |
-- -------------------------------------------------------------- [ Values.idr ]
-- Module : Values.idr
-- Copyright : (c) Jan de Muijnck-Hughes
-- License : see LICENSE
-- --------------------------------------------------------------------- [ EOH ]
module Test.Random.Values
import Effects
import Effect.Random
%access export
-- --------------------------------------------------------- [ List Generators ]
genRndListE : (seed : Integer)
-> (len : Nat)
-> (generator : Eff a [RND])
-> Eff (List a) [RND]
genRndListE s l f = do srand s; pure !(doGen l f)
where
doGen : (len : Nat)
-> (generator : Eff a [RND])
-> Eff (List a) [RND]
doGen Z f = pure List.Nil
doGen (S n) f = pure $ (!f :: !(doGen n f))
genRndListUE : Eq a =>
(seed : Integer)
-> (len : Nat)
-> (generator : Eff a [RND])
-> Eff (List a) [RND]
genRndListUE s l f = do srand s; pure !(doGen l f)
where
genElem : Eq a => Eff a [RND] -> List a -> Eff a [RND]
genElem f xs = do
x <- f
if elem x xs
then genElem f xs
else pure x
doGen : Eq a => Nat -> Eff a [RND] -> Eff (List a) [RND]
doGen Z f = pure Nil
doGen (S n) f = do
xs <- doGen n f
x <- genElem f xs
pure (x::xs)
genKVPair : (genA : Eff a [RND])
-> (genB : Eff b [RND])
-> Eff (Pair a b) [RND]
genKVPair f g = pure (!f, !g)
genRndListKVE : (seed : Integer)
-> (len : Nat)
-> (genA : Eff a [RND])
-> (genB : Eff b [RND])
-> Eff (List (Pair a b)) [RND]
genRndListKVE s l f g = genRndListE s l (genKVPair f g)
genRndListKVUE : (Eq a, Eq b) =>
(seed : Integer)
-> (len : Nat)
-> (genA : Eff a [RND])
-> (genB : Eff b [RND])
-> Eff (List (Pair a b)) [RND]
genRndListKVUE s l f g = do srand s; pure !(doGen l (genKVPair f g))
where
genElem : (Eq a, Eq b) => Eff (Pair a b) [RND] -> List (Pair a b) -> Eff (Pair a b) [RND]
genElem f xs = do
x <- f
if elem x xs
then genElem f xs
else if isJust $ lookup (fst x) xs
then genElem f xs
else pure x
doGen : (Eq a, Eq b) => Nat -> Eff (Pair a b) [RND] -> Eff (List (Pair a b)) [RND]
doGen Z f = pure Nil
doGen (S n) f = do
xs <- doGen n f
x <- genElem f xs
pure (x::xs)
-- -------------------------------------------------------- [ Random Int Lists ]
rndListIntE : (seed : Integer)
-> (bounds : Pair Integer Integer)
-> (length : Nat)
-> Eff (List Integer) [RND]
rndListIntE s (l,u) n = genRndListE s n (rndInt l u)
rndListInt : (seed : Integer)
-> (bounds : Pair Integer Integer)
-> (length : Nat)
-> List (Integer)
rndListInt s bs n = runPure $ rndListIntE s bs n
-- ------------------------------------------------- [ Random Unique Int Lists ]
rndListIntUE : (seed : Integer)
-> (bounds : Pair Integer Integer)
-> (len : Nat)
-> Eff (List Integer) [RND]
rndListIntUE s (l,u) n = genRndListUE s n (rndInt l u)
rndListIntU : (seed : Integer)
-> (bounds : Pair Integer Integer)
-> (len : Nat)
-> List Integer
rndListIntU s bs n = runPure $ rndListIntUE s bs n
-- ------------------------------------------------- [ Random Int KV Pair List ]
genY : Integer -> Integer -> Eff Integer [RND]
genY l u = do
x <- rndInt l u
pure (x + 2*u)
rndListIntKVE : (seed : Integer)
-> (bounds : Pair Integer Integer)
-> (len : Nat)
-> Eff (List (Pair Integer Integer)) [RND]
rndListIntKVE s (l,u) n = genRndListKVE s n (rndInt l u) (genY l u)
rndListIntKV : (seed : Integer)
-> (bounds : Pair Integer Integer)
-> (len : Nat)
-> List (Pair Integer Integer)
rndListIntKV s bs n = runPure $ rndListIntKVE s bs n
rndListIntKVUE : (seed : Integer)
-> (bounds : Pair Integer Integer)
-> (len : Nat)
-> Eff (List (Pair Integer Integer)) [RND]
rndListIntKVUE s (l,u) n = genRndListKVUE s n (rndInt l u) (genY l u)
rndListIntKVU : (seed : Integer)
-> (bounds : Pair Integer Integer)
-> (len : Nat)
-> List (Pair Integer Integer)
rndListIntKVU s bs n = runPure $ rndListIntKVUE s bs n
-- --------------------------------------------------------------------- [ EOF ]
|
theory ex3_2
imports Main begin
type_synonym vname = string
type_synonym val = int
type_synonym state = "vname \<Rightarrow> val"
datatype aexp = N int | V vname | Plus aexp aexp
fun aval :: "aexp \<Rightarrow> state \<Rightarrow> val" where
"aval (N n) s = n" |
"aval (V x) s = s x" |
"aval (Plus a\<^sub>1 a\<^sub>2) s = aval a\<^sub>1 s + aval a\<^sub>2 s"
fun plus :: "aexp \<Rightarrow> aexp \<Rightarrow> aexp" where
"plus (N i\<^sub>1) (N i\<^sub>2) = N (i\<^sub>1+i\<^sub>2)"|
"plus (N i) a = (if i=0 then a else Plus (N i) a)"|
"plus a (N i) = (if i=0 then a else Plus a (N i))"|
"plus a\<^sub>1 a\<^sub>2 = Plus a\<^sub>1 a\<^sub>2"
fun asimp :: "aexp \<Rightarrow> aexp" where
"asimp (N n) = N n" |
"asimp (V x) = V x" |
"asimp (Plus a\<^sub>1 a\<^sub>2) = plus (asimp a\<^sub>1) (asimp a\<^sub>2)"
fun sum_n :: "aexp \<Rightarrow> int" where
"sum_n (N a) = a" |
"sum_n (Plus a b) = (sum_n a) + (sum_n b)" |
"sum_n (V x) = 0"
fun sum_v :: "aexp \<Rightarrow> aexp" where
"sum_v (N a) = N 0" |
"sum_v (Plus a b) = Plus (sum_v a) (sum_v b)" |
"sum_v (V x) = V x"
fun full_asimp :: "aexp \<Rightarrow> aexp" where
"full_asimp a = asimp (Plus (sum_v a) (N (sum_n a)))"
lemma aval_plus [simp]:"aval (plus a1 a2) s = aval a1 s + aval a2 s"
apply(induction a1 a2 rule: plus.induct)
apply(auto)
done
lemma "aval (full_asimp a) s = aval a s"
apply(induction a)
apply(auto)
done
value "full_asimp (Plus (Plus (N 0) (N 7)) (Plus (V x) (N 8)))"
end
|
-- @@stderr --
dtrace: failed to compile script test/unittest/actions/printf/err.D_PRINTF_ARG_FMT.d: [D_PRINTF_ARG_FMT] line 18: printf( ) argument #1 is incompatible with prototype:
prototype: string constant
argument: string
|
{-# OPTIONS --cubical --safe #-}
open import Prelude
open import Relation.Binary
open import Function.Injective
module Relation.Binary.Construct.On
{a b ℓ₁ ℓ₂} {A : Type a} {B : Type b}
(f : A → B) (f-inj : Injective f)
(ord : TotalOrder B ℓ₁ ℓ₂)
where
open TotalOrder ord renaming (refl to ≤-refl)
_<′_ : A → A → Type _
x <′ y = f x < f y
_≤′_ : A → A → Type _
x ≤′ y = f x ≤ f y
on-ord : TotalOrder A ℓ₁ ℓ₂
StrictPreorder._<_ (StrictPartialOrder.strictPreorder (TotalOrder.strictPartialOrder on-ord)) = _<′_
StrictPreorder.trans (StrictPartialOrder.strictPreorder (TotalOrder.strictPartialOrder on-ord)) = <-trans
StrictPreorder.irrefl (StrictPartialOrder.strictPreorder (TotalOrder.strictPartialOrder on-ord)) = irrefl
StrictPartialOrder.conn (TotalOrder.strictPartialOrder on-ord) p q = f-inj _ _ (conn p q)
Preorder._≤_ (PartialOrder.preorder (TotalOrder.partialOrder on-ord)) = _≤′_
Preorder.refl (PartialOrder.preorder (TotalOrder.partialOrder on-ord)) = ≤-refl
Preorder.trans (PartialOrder.preorder (TotalOrder.partialOrder on-ord)) = ≤-trans
PartialOrder.antisym (TotalOrder.partialOrder on-ord) p q = f-inj _ _ (antisym p q)
TotalOrder._<?_ on-ord x y = f x <? f y
TotalOrder.≰⇒> on-ord = ≰⇒>
TotalOrder.≮⇒≥ on-ord = ≮⇒≥
|
(* Property from Case-Analysis for Rippling and Inductive Proof,
Moa Johansson, Lucas Dixon and Alan Bundy, ITP 2010.
This Isabelle theory is produced using the TIP tool offered at the following website:
https://github.com/tip-org/tools
This file was originally provided as part of TIP benchmark at the following website:
https://github.com/tip-org/benchmarks
Yutaka Nagashima at CIIRC, CTU changed the TIP output theory file slightly
to make it compatible with Isabelle2017.
Some proofs were added by Yutaka Nagashima.*)
theory TIP_prop_67
imports "../../Test_Base"
begin
datatype 'a list = nil2 | cons2 "'a" "'a list"
datatype Nat = Z | S "Nat"
fun len :: "'a list => Nat" where
"len (nil2) = Z"
| "len (cons2 y xs) = S (len xs)"
fun butlast :: "'a list => 'a list" where
"butlast (nil2) = nil2"
| "butlast (cons2 y (nil2)) = nil2"
| "butlast (cons2 y (cons2 x2 x3)) =
cons2 y (butlast (cons2 x2 x3))"
fun t2 :: "Nat => Nat => Nat" where
"t2 (Z) y = Z"
| "t2 (S z) (Z) = S z"
| "t2 (S z) (S x2) = t2 z x2"
theorem property0 :
"((len (butlast xs)) = (t2 (len xs) (S Z)))"
oops
end
|
/-
Copyright (c) 2022 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser, Heather Macbeth
-/
import topology.uniform_space.pi
import data.matrix.basic
/-!
# Uniform space structure on matrices
-/
open_locale uniformity topology
variables (m n 𝕜 : Type*) [uniform_space 𝕜]
namespace matrix
instance : uniform_space (matrix m n 𝕜) :=
(by apply_instance : uniform_space (m → n → 𝕜))
lemma uniformity :
𝓤 (matrix m n 𝕜) = ⨅ (i : m) (j : n), (𝓤 𝕜).comap (λ a, (a.1 i j, a.2 i j)) :=
begin
erw [Pi.uniformity, Pi.uniformity],
simp_rw [filter.comap_infi, filter.comap_comap],
refl,
end
lemma uniform_continuous {β : Type*} [uniform_space β] {f : β → matrix m n 𝕜} :
uniform_continuous f ↔ ∀ i j, uniform_continuous (λ x, f x i j) :=
by simp only [uniform_continuous, matrix.uniformity, filter.tendsto_infi, filter.tendsto_comap_iff]
instance [complete_space 𝕜] : complete_space (matrix m n 𝕜) :=
(by apply_instance : complete_space (m → n → 𝕜))
instance [separated_space 𝕜] : separated_space (matrix m n 𝕜) :=
(by apply_instance : separated_space (m → n → 𝕜))
end matrix
|
/-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import topology.continuous_function.basic
/-!
# Continuous open maps
This file defines bundled continuous open maps.
We use the `fun_like` design, so each type of morphisms has a companion typeclass which is meant to
be satisfied by itself and all stricter types.
## Types of morphisms
* `continuous_open_map`: Continuous open maps.
## Typeclasses
* `continuous_open_map_class`
-/
open function
variables {F α β γ δ : Type*}
/-- The type of continuous open maps from `α` to `β`, aka Priestley homomorphisms. -/
structure continuous_open_map (α β : Type*) [topological_space α] [topological_space β]
extends continuous_map α β :=
(map_open' : is_open_map to_fun)
infixr ` →CO `:25 := continuous_open_map
/-- `continuous_open_map_class F α β` states that `F` is a type of continuous open maps.
You should extend this class when you extend `continuous_open_map`. -/
class continuous_open_map_class (F : Type*) (α β : out_param $ Type*) [topological_space α]
[topological_space β] extends continuous_map_class F α β :=
(map_open (f : F) : is_open_map f)
export continuous_open_map_class (map_open)
instance [topological_space α] [topological_space β] [continuous_open_map_class F α β] :
has_coe_t F (α →CO β) :=
⟨λ f, ⟨f, map_open f⟩⟩
/-! ### Continuous open maps -/
namespace continuous_open_map
variables [topological_space α] [topological_space β] [topological_space γ] [topological_space δ]
instance : continuous_open_map_class (α →CO β) α β :=
{ coe := λ f, f.to_fun,
coe_injective' := λ f g h, by { obtain ⟨⟨_, _⟩, _⟩ := f, obtain ⟨⟨_, _⟩, _⟩ := g, congr' },
map_continuous := λ f, f.continuous_to_fun,
map_open := λ f, f.map_open' }
/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
directly. -/
instance : has_coe_to_fun (α →CO β) (λ _, α → β) := fun_like.has_coe_to_fun
@[simp] lemma to_fun_eq_coe {f : α →CO β} : f.to_fun = (f : α → β) := rfl
@[ext] lemma ext {f g : α →CO β} (h : ∀ a, f a = g a) : f = g := fun_like.ext f g h
/-- Copy of a `continuous_open_map` with a new `continuous_map` equal to the old one. Useful to fix
definitional equalities. -/
protected def copy (f : α →CO β) (f' : α → β) (h : f' = f) : α →CO β :=
⟨f.to_continuous_map.copy f' $ by exact h, h.symm.subst f.map_open'⟩
variables (α)
/-- `id` as a `continuous_open_map`. -/
protected def id : α →CO α := ⟨continuous_map.id _, is_open_map.id⟩
instance : inhabited (α →CO α) := ⟨continuous_open_map.id _⟩
@[simp]
variables {α}
@[simp] lemma id_apply (a : α) : continuous_open_map.id α a = a := rfl
/-- Composition of `continuous_open_map`s as a `continuous_open_map`. -/
def comp (f : β →CO γ) (g : α →CO β) : continuous_open_map α γ :=
⟨f.to_continuous_map.comp g.to_continuous_map, f.map_open'.comp g.map_open'⟩
@[simp] lemma coe_comp (f : β →CO γ) (g : α →CO β) : (f.comp g : α → γ) = f ∘ g := rfl
@[simp] lemma comp_apply (f : β →CO γ) (g : α →CO β) (a : α) : (f.comp g) a = f (g a) := rfl
@[simp] lemma comp_assoc (f : γ →CO δ) (g : β →CO γ) (h : α →CO β) :
(f.comp g).comp h = f.comp (g.comp h) := rfl
@[simp] lemma comp_id (f : α →CO β) : f.comp (continuous_open_map.id α) = f := ext $ λ a, rfl
@[simp] lemma id_comp (f : α →CO β) : (continuous_open_map.id β).comp f = f := ext $ λ a, rfl
lemma cancel_right {g₁ g₂ : β →CO γ} {f : α →CO β} (hf : surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨λ h, ext $ hf.forall.2 $ fun_like.ext_iff.1 h, congr_arg _⟩
lemma cancel_left {g : β →CO γ} {f₁ f₂ : α →CO β} (hg : injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨λ h, ext $ λ a, hg $ by rw [←comp_apply, h, comp_apply], congr_arg _⟩
end continuous_open_map
|
proposition homeomorphic_ball_UNIV: fixes a ::"'a::real_normed_vector" assumes "0 < r" shows "ball a r homeomorphic (UNIV:: 'a set)" |
(*
Copyright (C) 2017 M.A.L. Marques
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)
(* type: work_gga_c *)
(* prefix:
gga_c_lyp_params *params;
assert(p->params != NULL);
params = (gga_c_lyp_params * )(p->params);
*)
Cf := 3/10 * (3*Pi^2)^(2/3):
omega := rs -> params_a_B*exp(-params_a_c*rs)/(1 + params_a_d*rs):
delta := rs -> (params_a_c + params_a_d/(1 + params_a_d*rs))*rs:
aux6 := 1/2^(8/3):
aux4 := aux6/4:
aux5 := aux4/(9*2):
t1 := (rs, z) ->
-(1 - z^2)/(1 + params_a_d*rs):
t2 := (rs, z, xt) ->
-xt^2*((1 - z^2)*(47 - 7*delta(rs))/(4*18) - 2/3):
t3 := (z) ->
-Cf/2*(1 - z^2)*((1 + z)^(8/3) + (1 - z)^(8/3)):
t4 := (rs, z, xs0, xs1) ->
aux4*(1 - z^2)*(5/2 - delta(rs)/18)*(xs0^2*(1 + z)^(8/3) + xs1^2*(1 - z)^(8/3)):
t5 := (rs, z, xs0, xs1) ->
aux5*(1 - z^2)*(delta(rs) - 11)*(xs0^2*(1 + z)^(11/3) + xs1^2*(1 - z)^(11/3)):
t6 := (z, xs0, xs1) ->
-aux6*(2/3*(xs0^2*(1 + z)^(8/3) + xs1^2*(1 - z)^(8/3))
-(1 + z)^2*xs1^2*(1 - z)^(8/3)/4 - (1 - z)^2*xs0^2*(1 + z)^(8/3)/4):
f_lyp := (rs, z, xt, xs0, xs1) -> params_a_A*(t1(rs/RS_FACTOR, z) + omega(rs/RS_FACTOR)*(
+ t2(rs/RS_FACTOR, z, xt) + t3(z) + t4(rs/RS_FACTOR, z, xs0, xs1)
+ t5(rs/RS_FACTOR, z, xs0, xs1) + t6(z, xs0, xs1)
)):
f := (rs, z, xt, xs0, xs1) -> f_lyp(rs, z, xt, xs0, xs1):
|
/-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import category_theory.category.Pointed
/-!
# The category of bipointed types
This defines `Bipointed`, the category of bipointed types.
## TODO
Monoidal structure
-/
open category_theory
universes u
variables {α β : Type*}
/-- The category of bipointed types. -/
structure Bipointed : Type.{u + 1} :=
(X : Type.{u})
(to_prod : X × X)
namespace Bipointed
instance : has_coe_to_sort Bipointed Type* := ⟨X⟩
attribute [protected] Bipointed.X
/-- Turns a bipointing into a bipointed type. -/
def of {X : Type*} (to_prod : X × X) : Bipointed := ⟨X, to_prod⟩
@[simp] lemma coe_of {X : Type*} (to_prod : X × X) : ↥(of to_prod) = X := rfl
alias of ← _root_.prod.Bipointed
instance : inhabited Bipointed := ⟨of ((), ())⟩
/-- Morphisms in `Bipointed`. -/
@[ext] protected structure hom (X Y : Bipointed.{u}) : Type u :=
(to_fun : X → Y)
(map_fst : to_fun X.to_prod.1 = Y.to_prod.1)
(map_snd : to_fun X.to_prod.2 = Y.to_prod.2)
namespace hom
/-- The identity morphism of `X : Bipointed`. -/
@[simps] def id (X : Bipointed) : hom X X := ⟨id, rfl, rfl⟩
instance (X : Bipointed) : inhabited (hom X X) := ⟨id X⟩
/-- Composition of morphisms of `Bipointed`. -/
@[simps] def comp {X Y Z : Bipointed.{u}} (f : hom X Y) (g : hom Y Z) : hom X Z :=
⟨g.to_fun ∘ f.to_fun, by rw [function.comp_apply, f.map_fst, g.map_fst],
by rw [function.comp_apply, f.map_snd, g.map_snd]⟩
end hom
instance large_category : large_category Bipointed :=
{ hom := hom,
id := hom.id,
comp := @hom.comp,
id_comp' := λ _ _ _, hom.ext _ _ rfl,
comp_id' := λ _ _ _, hom.ext _ _ rfl,
assoc' := λ _ _ _ _ _ _ _, hom.ext _ _ rfl }
instance concrete_category : concrete_category Bipointed :=
{ forget := { obj := Bipointed.X, map := @hom.to_fun },
forget_faithful := ⟨@hom.ext⟩ }
/-- Swaps the pointed elements of a bipointed type. `prod.swap` as a functor. -/
@[simps] def swap : Bipointed ⥤ Bipointed :=
{ obj := λ X, ⟨X, X.to_prod.swap⟩, map := λ X Y f, ⟨f.to_fun, f.map_snd, f.map_fst⟩ }
/-- The equivalence between `Bipointed` and itself induced by `prod.swap` both ways. -/
@[simps] def swap_equiv : Bipointed ≌ Bipointed :=
equivalence.mk swap swap
(nat_iso.of_components (λ X, { hom := ⟨id, rfl, rfl⟩, inv := ⟨id, rfl, rfl⟩ }) $ λ X Y f, rfl)
(nat_iso.of_components (λ X, { hom := ⟨id, rfl, rfl⟩, inv := ⟨id, rfl, rfl⟩ }) $ λ X Y f, rfl)
@[simp] lemma swap_equiv_symm : swap_equiv.symm = swap_equiv := rfl
end Bipointed
/-- The forgetful functor from `Bipointed` to `Pointed` which forgets about the second point. -/
def Bipointed_to_Pointed_fst : Bipointed ⥤ Pointed :=
{ obj := λ X, ⟨X, X.to_prod.1⟩, map := λ X Y f, ⟨f.to_fun, f.map_fst⟩ }
/-- The forgetful functor from `Bipointed` to `Pointed` which forgets about the first point. -/
def Bipointed_to_Pointed_snd : Bipointed ⥤ Pointed :=
{ obj := λ X, ⟨X, X.to_prod.2⟩, map := λ X Y f, ⟨f.to_fun, f.map_snd⟩ }
@[simp] lemma Bipointed_to_Pointed_fst_comp_forget :
Bipointed_to_Pointed_fst ⋙ forget Pointed = forget Bipointed := rfl
@[simp] lemma Bipointed_to_Pointed_snd_comp_forget :
Bipointed_to_Pointed_snd ⋙ forget Pointed = forget Bipointed := rfl
@[simp] lemma swap_comp_Bipointed_to_Pointed_fst :
Bipointed.swap ⋙ Bipointed_to_Pointed_fst = Bipointed_to_Pointed_snd := rfl
@[simp] lemma swap_comp_Bipointed_to_Pointed_snd :
Bipointed.swap ⋙ Bipointed_to_Pointed_snd = Bipointed_to_Pointed_fst := rfl
/-- The functor from `Pointed` to `Bipointed` which bipoints the point. -/
def Pointed_to_Bipointed : Pointed.{u} ⥤ Bipointed :=
{ obj := λ X, ⟨X, X.point, X.point⟩, map := λ X Y f, ⟨f.to_fun, f.map_point, f.map_point⟩ }
/-- The functor from `Pointed` to `Bipointed` which adds a second point. -/
def Pointed_to_Bipointed_fst : Pointed.{u} ⥤ Bipointed :=
{ obj := λ X, ⟨option X, X.point, none⟩,
map := λ X Y f, ⟨option.map f.to_fun, congr_arg _ f.map_point, rfl⟩,
map_id' := λ X, Bipointed.hom.ext _ _ option.map_id,
map_comp' := λ X Y Z f g, Bipointed.hom.ext _ _ (option.map_comp_map _ _).symm }
/-- The functor from `Pointed` to `Bipointed` which adds a first point. -/
def Pointed_to_Bipointed_snd : Pointed.{u} ⥤ Bipointed :=
{ obj := λ X, ⟨option X, none, X.point⟩,
map := λ X Y f, ⟨option.map f.to_fun, rfl, congr_arg _ f.map_point⟩,
map_id' := λ X, Bipointed.hom.ext _ _ option.map_id,
map_comp' := λ X Y Z f g, Bipointed.hom.ext _ _ (option.map_comp_map _ _).symm }
@[simp] lemma Pointed_to_Bipointed_fst_comp_swap :
Pointed_to_Bipointed_fst ⋙ Bipointed.swap = Pointed_to_Bipointed_snd := rfl
@[simp] lemma Pointed_to_Bipointed_snd_comp_swap :
Pointed_to_Bipointed_snd ⋙ Bipointed.swap = Pointed_to_Bipointed_fst := rfl
/-- `Bipointed_to_Pointed_fst` is inverse to `Pointed_to_Bipointed`. -/
@[simps] def Pointed_to_Bipointed_comp_Bipointed_to_Pointed_fst :
Pointed_to_Bipointed ⋙ Bipointed_to_Pointed_fst ≅ 𝟭 _ :=
nat_iso.of_components (λ X, { hom := ⟨id, rfl⟩, inv := ⟨id, rfl⟩ }) $ λ X Y f, rfl
/-- `Bipointed_to_Pointed_snd` is inverse to `Pointed_to_Bipointed`. -/
@[simps] def Pointed_to_Bipointed_comp_Bipointed_to_Pointed_snd :
Pointed_to_Bipointed ⋙ Bipointed_to_Pointed_snd ≅ 𝟭 _ :=
nat_iso.of_components (λ X, { hom := ⟨id, rfl⟩, inv := ⟨id, rfl⟩ }) $ λ X Y f, rfl
/-- The free/forgetful adjunction between `Pointed_to_Bipointed_fst` and `Bipointed_to_Pointed_fst`.
-/
def Pointed_to_Bipointed_fst_Bipointed_to_Pointed_fst_adjunction :
Pointed_to_Bipointed_fst ⊣ Bipointed_to_Pointed_fst :=
adjunction.mk_of_hom_equiv
{ hom_equiv := λ X Y, { to_fun := λ f, ⟨f.to_fun ∘ option.some, f.map_fst⟩,
inv_fun := λ f, ⟨λ o, o.elim Y.to_prod.2 f.to_fun, f.map_point, rfl⟩,
left_inv := λ f, by { ext, cases x, exact f.map_snd.symm, refl },
right_inv := λ f, Pointed.hom.ext _ _ rfl },
hom_equiv_naturality_left_symm' := λ X' X Y f g, by { ext, cases x; refl } }
/-- The free/forgetful adjunction between `Pointed_to_Bipointed_snd` and `Bipointed_to_Pointed_snd`.
-/
def Pointed_to_Bipointed_snd_Bipointed_to_Pointed_snd_adjunction :
Pointed_to_Bipointed_snd ⊣ Bipointed_to_Pointed_snd :=
adjunction.mk_of_hom_equiv
{ hom_equiv := λ X Y, { to_fun := λ f, ⟨f.to_fun ∘ option.some, f.map_snd⟩,
inv_fun := λ f, ⟨λ o, o.elim Y.to_prod.1 f.to_fun, rfl, f.map_point⟩,
left_inv := λ f, by { ext, cases x, exact f.map_fst.symm, refl },
right_inv := λ f, Pointed.hom.ext _ _ rfl },
hom_equiv_naturality_left_symm' := λ X' X Y f g, by { ext, cases x; refl } }
|
(* Property from Case-Analysis for Rippling and Inductive Proof,
Moa Johansson, Lucas Dixon and Alan Bundy, ITP 2010.
This Isabelle theory is produced using the TIP tool offered at the following website:
https://github.com/tip-org/tools
This file was originally provided as part of TIP benchmark at the following website:
https://github.com/tip-org/benchmarks
Yutaka Nagashima at CIIRC, CTU changed the TIP output theory file slightly
to make it compatible with Isabelle2017.
Some proofs were added by Yutaka Nagashima.*)
theory TIP_prop_75
imports "../../Test_Base"
begin
datatype 'a list = nil2 | cons2 "'a" "'a list"
datatype Nat = Z | S "Nat"
fun x :: "Nat => Nat => bool" where
"x (Z) (Z) = True"
| "x (Z) (S z2) = False"
| "x (S x2) (Z) = False"
| "x (S x2) (S y2) = x x2 y2"
fun count :: "Nat => Nat list => Nat" where
"count y (nil2) = Z"
| "count y (cons2 z2 ys) =
(if x y z2 then S (count y ys) else count y ys)"
fun t2 :: "Nat => Nat => Nat" where
"t2 (Z) z = z"
| "t2 (S z2) z = S (t2 z2 z)"
theorem property0 :
"((t2 (count n xs) (count n (cons2 m (nil2)))) =
(count n (cons2 m xs)))"
oops
end
|
(* Property from Case-Analysis for Rippling and Inductive Proof,
Moa Johansson, Lucas Dixon and Alan Bundy, ITP 2010.
This Isabelle theory is produced using the TIP tool offered at the following website:
https://github.com/tip-org/tools
This file was originally provided as part of TIP benchmark at the following website:
https://github.com/tip-org/benchmarks
Yutaka Nagashima at CIIRC, CTU changed the TIP output theory file slightly
to make it compatible with Isabelle2017.
Some proofs were added by Yutaka Nagashima.*)
theory TIP_prop_71
imports "../../Test_Base"
begin
datatype 'a list = nil2 | cons2 "'a" "'a list"
datatype Nat = Z | S "Nat"
fun x :: "Nat => Nat => bool" where
"x (Z) (Z) = True"
| "x (Z) (S z2) = False"
| "x (S x2) (Z) = False"
| "x (S x2) (S y2) = x x2 y2"
fun elem :: "Nat => Nat list => bool" where
"elem y (nil2) = False"
| "elem y (cons2 z2 xs) = (if x y z2 then True else elem y xs)"
fun t2 :: "Nat => Nat => bool" where
"t2 y (Z) = False"
| "t2 (Z) (S z2) = True"
| "t2 (S x2) (S z2) = t2 x2 z2"
fun ins :: "Nat => Nat list => Nat list" where
"ins y (nil2) = cons2 y (nil2)"
| "ins y (cons2 z2 xs) =
(if t2 y z2 then cons2 y (cons2 z2 xs) else cons2 z2 (ins y xs))"
theorem property0 :
"((~ (x y z)) ==> ((elem y (ins z xs)) = (elem y xs)))"
oops
end
|
Formal statement is: lemma content_dvd_coeffs: "c \<in> set (coeffs p) \<Longrightarrow> content p dvd c" Informal statement is: The content of a polynomial divides every coefficient of the polynomial. |
[STATEMENT]
lemma in_set_takeD: "x \<in> set(take n xs) \<Longrightarrow> x \<in> set xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. x \<in> set (take n xs) \<Longrightarrow> x \<in> set xs
[PROOF STEP]
using set_take_subset
[PROOF STATE]
proof (prove)
using this:
set (take ?n ?xs) \<subseteq> set ?xs
goal (1 subgoal):
1. x \<in> set (take n xs) \<Longrightarrow> x \<in> set xs
[PROOF STEP]
by fast |
import sheaves_of_modules.defs
/-
# Pushforward and pullback of sheaves of modules
-/
variables {X Y : RINGED_SPACE}
namespace SHEAF_OF_MODULES
section experiment
--#check @Top.sheaf.pushforward
variable (f : X ⟶ Y)
example : (X : TOP) ⟶ Y := f.base
end experiment
--#check Top.presheaf.pushforward_obj
--set_option pp.notation false
/-
instance (𝓜 : SHEAF_OF_MODULES X) (U : (opens (X : TOP))ᵒᵖ) :
module ((𝓞_ X) U) (𝓜.obj U) := 𝓜.module_structure U
-/
--instance (U) : module
--#print notation _*
--#check Top.presheaf.pushforward_obj
/-
/-- Pushforward a presheaf on `X` along a continuous map `f : X ⟶ Y`, obtaining a presheaf
on `Y`. -/
def pushforward_obj {X Y : Top.{w}} (f : X ⟶ Y) (ℱ : X.presheaf C) : Y.presheaf C :=
(opens.map f).op ⋙ ℱ
infix ` _* `: 80 := pushforward_obj
-/
--#where
def map (f : X ⟶ Y) (𝓜 : SHEAF_OF_MODULES X) : SHEAF_OF_MODULES Y :=
{ ab_sheaf := (Top.sheaf.pushforward.{0} f.base).obj 𝓜.ab_sheaf,
module_structure := λ U, by letI : module ↥((f.base _* X.to_PresheafedSpace.presheaf).obj U)
↥(((Top.sheaf.pushforward f.base).obj 𝓜.ab_sheaf).val.obj U) := obj.module 𝓜 ((topological_space.opens.map f.base).op.obj U); exact
module.comp_hom (𝓜.obj ((topological_space.opens.map f.base).op.obj U)) (f.c.app U),
-- module_structure := λ U, begin
-- -- delta Top.sheaf.pushforward,
-- -- dsimp only,
-- -- delta Top.presheaf.pushforward_obj,
-- -- change module _ (𝓜.obj _),
-- let V : (topological_space.opens (X : TOP))ᵒᵖ := (topological_space.opens.map f.base).op.obj U,
-- change module ((𝓞_ Y) U) (𝓜.obj V),
-- -- letI baz : module ((𝓞_ X) V) (𝓜.obj V) := infer_instance, -- show_term {apply_instance}
-- letI : module ↥((f.base _* X.to_PresheafedSpace.presheaf).obj U) ↥(𝓜.obj V) := obj.module 𝓜 V,
-- -- let foo : (𝓞_ Y) U →+* (𝓞_ X) V := f.c.app U,
-- exact module.comp_hom (𝓜.obj V) (f.c.app U),
-- end,
compatibility_bit := λ U V i, begin
rintro s (n : 𝓜.ab_sheaf.val.obj _),
change ↥((𝓞_ Y) U) at s,
have foo := f.c.naturality i,
let j : ((topological_space.opens.map f.base).op.obj U) ⟶ ((topological_space.opens.map f.base).op.obj V) :=
((topological_space.opens.map f.base).op.map i),
let r : (𝓞_ X) ((topological_space.opens.map f.base).op.obj U) := f.c.app U s,
--have bar := 𝓜.compatibility_bit _ _ j r n,
convert 𝓜.compatibility_bit _ _ j r n using 1,
rw fun_like.ext_iff at foo,
specialize foo s,
have moo : (f.base _* X.to_PresheafedSpace.presheaf).map i = X.to_PresheafedSpace.presheaf.map j,
refl,
rw fun_like.ext_iff at moo,
specialize moo r,
rw ← moo,
change _ = ((f.c.app U ≫ (f.base _* X.to_PresheafedSpace.presheaf).map i) s) • _,
rw ← foo,
refl,
-- need to pull back i; need to fix implicits
-- might need pen and paper here
--convert bar _ _,
/-
Have foo: O_Y(U)->O_Y(V)->f_*O_X(V) = O_Y(U)->f_*O_X(U)->f_*O_X(V)
have bar : ∀ r ∈ O_X(f⁻¹(U)), m ∈ 𝓜(f⁻¹(U)),
res(r•m) ∈ 𝓜(f⁻¹(V)) = (res(r) : O_X(f⁻¹(V)))•res(m)
Want: ∀ s ∈ O_Y(U), ∀ n ∈ f_*𝓜(U) := 𝓜(f⁻¹(U)), res(s•n)=res(s)•res(n)
Proof: define r=image of s in O_X(f⁻¹(U))=f_*O_X(U).
-/
--letI : module (Y.to_PresheafedSpace.presheaf.obj U)
-- (((Top.sheaf.pushforward f.base).obj 𝓜.ab_sheaf).val.obj U) := module_structure 𝓜 ((topological_space.opens.map f.base).op.obj U),
--calc
--(((Top.sheaf.pushforward f.base).obj 𝓜.ab_sheaf).val.map i) (s • n) =
--((Y.to_PresheafedSpace.presheaf.map i) s : (𝓞_ Y) V) • (((Top.sheaf.pushforward f.base).obj 𝓜.ab_sheaf).val.map i) n : sorry
end }
infix (name := hi) ` _* `: 80 := map
--#check Top.sheaf.pushforward
variables (f : X ⟶ Y) (𝓜 : SHEAF_OF_MODULES X)
def map_id (𝓜 : SHEAF_OF_MODULES X) : (𝟙 X) _* 𝓜 ≅ 𝓜 :=
{ hom :=
{ ab_sheaf :=
{ val :=
{ app := λ U, 𝓜.ab_sheaf.val.map $ category_theory.op_hom_of_le $ λ x hx, hx,
naturality' := begin
intros U V f,
ext,
simp only [category_theory.comp_apply],
sorry,
end } },
map_smul := begin
intros,
simp only [category_theory.op_hom_of_le],
sorry,
end },
inv :=
{ ab_sheaf :=
{ val :=
{ app := λ U, 𝓜.ab_sheaf.val.map $ category_theory.op_hom_of_le $ λ x hx, hx,
naturality' := begin
intros U V g,
ext,
simp only [category_theory.comp_apply],
sorry,
end } },
map_smul := sorry },
hom_inv_id' := begin
ext U m,
--dsimp only [category_theory.comp_apply],
unfold_coes,
dsimp only,
sorry,
end,
inv_hom_id' := sorry }
end SHEAF_OF_MODULES
example (Z : Type) [topological_space Z] (U V : (topological_space.opens Z)ᵒᵖ) (h : V.unop ⊆ U.unop):
U ⟶ V :=
begin
refine category_theory.op_hom_of_le h,
end
|
lemma finite_ball_include: fixes a :: "'a::metric_space" assumes "finite S" shows "\<exists>e>0. S \<subseteq> ball a e" |
module Automata.Nondeterministic where
-- Standard libraries imports ----------------------------------------
open import Level using ()
renaming (zero to ℓ₀)
open import Data.Nat using (ℕ)
open import Data.Product using (_×_)
open import Data.Vec using (Vec ; [] ; _∷_)
open import Relation.Unary using (Pred)
open import Relation.Binary.PropositionalEquality using (_≡_)
----------------------------------------------------------------------
-- Thesis imports ----------------------------------------------------
open import Utilities.ExistsSyntax using (∃-syntax)
----------------------------------------------------------------------
record NDA (Σ : Set) : Set₁ where
constructor ⟨_,_,_,_⟩
field
Q : Set
S : Pred Q ℓ₀
F : Pred Q ℓ₀
Δ : Q → Σ → Pred Q ℓ₀
Δ* : Q → {n : ℕ} → Vec Σ n → Pred Q ℓ₀
Δ* q [] = q ≡_
Δ* q (x ∷ xs) q′ = ∃ q₀ ∶ Q • ((Δ q x q₀) × (Δ* q₀ xs q′))
Accepts : {n : ℕ} → Pred (Vec Σ n) ℓ₀
Accepts xs = ∃ q ∶ Q • (S q
× ∃ q′ ∶ Q • ((F q′)
× (Δ* q xs q′)))
-- :TODO: are these useful?
_-Reachable : ℕ → Q → Pred Q ℓ₀
_-Reachable n q q′ = ∃ xs ∶ Vec Σ n • (Δ* q xs q′)
Reachable : Q → Pred Q ℓ₀
Reachable q q′ = ∃ n ∶ ℕ • (n -Reachable) q q′
|
[STATEMENT]
lemma lt_take: "n1 < n2 \<Longrightarrow> n2 \<le> length al \<Longrightarrow> take n1 al < take n2 al"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>n1 < n2; n2 \<le> length al\<rbrakk> \<Longrightarrow> take n1 al < take n2 al
[PROOF STEP]
by (metis inj_take le_less_trans le_take not_less_iff_gr_or_eq order.not_eq_order_implies_strict order.strict_implies_order) |
Formal statement is: lemma Bseq_eq_bounded: fixes f :: "nat \<Rightarrow> 'a::real_normed_vector" shows "Bseq f \<longleftrightarrow> bounded (range f)" Informal statement is: A sequence $f$ is bounded if and only if the range of $f$ is bounded. |
{-# OPTIONS --two-level --cubical-compatible #-}
open import Agda.Primitive
data D₁ : SSet → SSet (lsuc lzero) where
c : (@0 A : SSet) → A → D₁ A
data D₂ : Set → SSet (lsuc lzero) where
c : (@0 A : Set) → A → D₂ A
|
[STATEMENT]
lemma minus_cis: "-cis x = cis (x + pi)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. - cis x = cis (x + pi)
[PROOF STEP]
by (simp add: complex_eq_iff) |
Formal statement is: lemma isCont_has_Ub: fixes f :: "real \<Rightarrow> 'a::linorder_topology" shows "a \<le> b \<Longrightarrow> \<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x \<Longrightarrow> \<exists>M. (\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> f x \<le> M) \<and> (\<forall>N. N < M \<longrightarrow> (\<exists>x. a \<le> x \<and> x \<le> b \<and> N < f x))" Informal statement is: If $f$ is continuous on the closed interval $[a,b]$, then $f$ has a supremum on $[a,b]$. |
-- Andreas, 2013-03-15
-- Paolo Capriotti's formalization of Russell's paradox
{-# OPTIONS --cubical-compatible --type-in-type #-}
module Russell where
open import Common.Product
open import Common.Equality
data ⊥ : Set where
¬ : Set → Set
¬ A = A → ⊥
-- a model of set theory, uses Set : Set
data U : Set where
set : (I : Set) → (I → U) → U
-- a set is regular if it doesn't contain itself
regular : U → Set
regular (set I f) = (i : I) → ¬ (f i ≡ set I f)
-- Russell's set: the set of all regular sets
R : U
R = set (Σ U regular) proj₁
-- R is not regular
R-nonreg : ¬ (regular R)
R-nonreg reg = reg (R , reg) refl
-- R is regular
R-reg : regular R
R-reg (x , reg) p = subst regular p reg (x , reg) p
-- contradiction
absurd : ⊥
absurd = R-nonreg R-reg
|
-- Copyright 2017, the blau.io contributors
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
module API.Web.DOM.Node
import API.Web.DOM.Document
import API.Web.DOM.DocumentType
import API.Web.DOM.Element
%access public export
%default total
||| The original interface specification can be found at
||| https://dom.spec.whatwg.org/#interface-node
data Node : Type where
FromDocument : Document _ -> Node
FromDocumentType : DocumentType -> Node
FromElement : Element -> Node
|
-- @@stderr --
dtrace: failed to compile script test/unittest/begin/err.D_PDESC_ZERO.tick.d: [D_PDESC_ZERO] line 20: probe description ::BEGIN:tick-1 does not match any probes
|
-- @@stderr --
dtrace: failed to compile script test/unittest/printf/err.D_PRINTF_ARG_FMT.badfmt.d: [D_PRINTF_ARG_FMT] line 18: printf( ) argument #1 is incompatible with prototype:
prototype: string constant
argument: int
|
/-
Copyright (c) 2020 Yury Kudryashov All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import algebra.ring.prod
import algebra.module.basic
import group_theory.submonoid.membership
import group_theory.submonoid.center
import data.set.finite
import data.equiv.ring
/-!
# Bundled subsemirings
We define bundled subsemirings and some standard constructions: `complete_lattice` structure,
`subtype` and `inclusion` ring homomorphisms, subsemiring `map`, `comap` and range (`srange`) of
a `ring_hom` etc.
-/
open_locale big_operators
universes u v w
variables {R : Type u} {S : Type v} {T : Type w}
[non_assoc_semiring R] [non_assoc_semiring S] [non_assoc_semiring T]
(M : submonoid R)
set_option old_structure_cmd true
/-- A subsemiring of a semiring `R` is a subset `s` that is both a multiplicative and an additive
submonoid. -/
structure subsemiring (R : Type u) [non_assoc_semiring R] extends submonoid R, add_submonoid R
/-- Reinterpret a `subsemiring` as a `submonoid`. -/
add_decl_doc subsemiring.to_submonoid
/-- Reinterpret a `subsemiring` as an `add_submonoid`. -/
add_decl_doc subsemiring.to_add_submonoid
namespace subsemiring
instance : set_like (subsemiring R) R :=
⟨subsemiring.carrier, λ p q h, by cases p; cases q; congr'⟩
@[simp]
lemma mem_carrier {s : subsemiring R} {x : R} : x ∈ s.carrier ↔ x ∈ s := iff.rfl
/-- Two subsemirings are equal if they have the same elements. -/
@[ext] theorem ext {S T : subsemiring R} (h : ∀ x, x ∈ S ↔ x ∈ T) : S = T := set_like.ext h
/-- Copy of a subsemiring with a new `carrier` equal to the old one. Useful to fix definitional
equalities.-/
protected def copy (S : subsemiring R) (s : set R) (hs : s = ↑S) : subsemiring R :=
{ carrier := s,
..S.to_add_submonoid.copy s hs,
..S.to_submonoid.copy s hs }
@[simp] lemma coe_copy (S : subsemiring R) (s : set R) (hs : s = ↑S) :
(S.copy s hs : set R) = s := rfl
lemma copy_eq (S : subsemiring R) (s : set R) (hs : s = ↑S) : S.copy s hs = S :=
set_like.coe_injective hs
lemma to_submonoid_injective : function.injective (to_submonoid : subsemiring R → submonoid R)
| r s h := ext (set_like.ext_iff.mp h : _)
@[mono] lemma to_submonoid_strict_mono : strict_mono (to_submonoid : subsemiring R → submonoid R) :=
λ _ _, id
@[mono] lemma to_submonoid_mono : monotone (to_submonoid : subsemiring R → submonoid R) :=
to_submonoid_strict_mono.monotone
lemma to_add_submonoid_injective :
function.injective (to_add_submonoid : subsemiring R → add_submonoid R)
| r s h := ext (set_like.ext_iff.mp h : _)
@[mono] lemma to_add_submonoid_strict_mono :
strict_mono (to_add_submonoid : subsemiring R → add_submonoid R) := λ _ _, id
@[mono]
lemma to_add_submonoid_mono : monotone (to_add_submonoid : subsemiring R → add_submonoid R) :=
to_add_submonoid_strict_mono.monotone
/-- Construct a `subsemiring R` from a set `s`, a submonoid `sm`, and an additive
submonoid `sa` such that `x ∈ s ↔ x ∈ sm ↔ x ∈ sa`. -/
protected def mk' (s : set R) (sm : submonoid R) (hm : ↑sm = s)
(sa : add_submonoid R) (ha : ↑sa = s) :
subsemiring R :=
{ carrier := s,
zero_mem' := ha ▸ sa.zero_mem,
one_mem' := hm ▸ sm.one_mem,
add_mem' := λ x y, by simpa only [← ha] using sa.add_mem,
mul_mem' := λ x y, by simpa only [← hm] using sm.mul_mem }
@[simp] lemma coe_mk' {s : set R} {sm : submonoid R} (hm : ↑sm = s)
{sa : add_submonoid R} (ha : ↑sa = s) :
(subsemiring.mk' s sm hm sa ha : set R) = s := rfl
@[simp] lemma mem_mk' {s : set R} {sm : submonoid R} (hm : ↑sm = s)
{sa : add_submonoid R} (ha : ↑sa = s) {x : R} :
x ∈ subsemiring.mk' s sm hm sa ha ↔ x ∈ s :=
iff.rfl
@[simp] lemma mk'_to_submonoid {s : set R} {sm : submonoid R} (hm : ↑sm = s)
{sa : add_submonoid R} (ha : ↑sa = s) :
(subsemiring.mk' s sm hm sa ha).to_submonoid = sm :=
set_like.coe_injective hm.symm
@[simp] lemma mk'_to_add_submonoid {s : set R} {sm : submonoid R} (hm : ↑sm = s)
{sa : add_submonoid R} (ha : ↑sa =s) :
(subsemiring.mk' s sm hm sa ha).to_add_submonoid = sa :=
set_like.coe_injective ha.symm
end subsemiring
namespace subsemiring
variables (s : subsemiring R)
/-- A subsemiring contains the semiring's 1. -/
theorem one_mem : (1 : R) ∈ s := s.one_mem'
/-- A subsemiring contains the semiring's 0. -/
theorem zero_mem : (0 : R) ∈ s := s.zero_mem'
/-- A subsemiring is closed under multiplication. -/
theorem mul_mem : ∀ {x y : R}, x ∈ s → y ∈ s → x * y ∈ s := s.mul_mem'
/-- A subsemiring is closed under addition. -/
theorem add_mem : ∀ {x y : R}, x ∈ s → y ∈ s → x + y ∈ s := s.add_mem'
/-- Product of a list of elements in a `subsemiring` is in the `subsemiring`. -/
lemma list_prod_mem {R : Type*} [semiring R] (s : subsemiring R) {l : list R} :
(∀x ∈ l, x ∈ s) → l.prod ∈ s :=
s.to_submonoid.list_prod_mem
/-- Sum of a list of elements in a `subsemiring` is in the `subsemiring`. -/
lemma list_sum_mem {l : list R} : (∀x ∈ l, x ∈ s) → l.sum ∈ s :=
s.to_add_submonoid.list_sum_mem
/-- Product of a multiset of elements in a `subsemiring` of a `comm_semiring`
is in the `subsemiring`. -/
lemma multiset_prod_mem {R} [comm_semiring R] (s : subsemiring R) (m : multiset R) :
(∀a ∈ m, a ∈ s) → m.prod ∈ s :=
s.to_submonoid.multiset_prod_mem m
/-- Sum of a multiset of elements in a `subsemiring` of a `semiring` is
in the `add_subsemiring`. -/
lemma multiset_sum_mem (m : multiset R) :
(∀a ∈ m, a ∈ s) → m.sum ∈ s :=
s.to_add_submonoid.multiset_sum_mem m
/-- Product of elements of a subsemiring of a `comm_semiring` indexed by a `finset` is in the
subsemiring. -/
lemma prod_mem {R : Type*} [comm_semiring R] (s : subsemiring R)
{ι : Type*} {t : finset ι} {f : ι → R} (h : ∀c ∈ t, f c ∈ s) :
∏ i in t, f i ∈ s :=
s.to_submonoid.prod_mem h
/-- Sum of elements in an `subsemiring` of an `semiring` indexed by a `finset`
is in the `add_subsemiring`. -/
lemma sum_mem (s : subsemiring R)
{ι : Type*} {t : finset ι} {f : ι → R} (h : ∀c ∈ t, f c ∈ s) :
∑ i in t, f i ∈ s :=
s.to_add_submonoid.sum_mem h
lemma pow_mem {R : Type*} [semiring R] (s : subsemiring R) {x : R} (hx : x ∈ s) (n : ℕ) :
x^n ∈ s := s.to_submonoid.pow_mem hx n
lemma nsmul_mem {x : R} (hx : x ∈ s) (n : ℕ) :
n • x ∈ s := s.to_add_submonoid.nsmul_mem hx n
lemma coe_nat_mem (n : ℕ) : (n : R) ∈ s :=
by simp only [← nsmul_one, nsmul_mem, one_mem]
/-- A subsemiring of a `non_assoc_semiring` inherits a `non_assoc_semiring` structure -/
instance to_non_assoc_semiring : non_assoc_semiring s :=
{ mul_zero := λ x, subtype.eq $ mul_zero x,
zero_mul := λ x, subtype.eq $ zero_mul x,
right_distrib := λ x y z, subtype.eq $ right_distrib x y z,
left_distrib := λ x y z, subtype.eq $ left_distrib x y z,
.. s.to_submonoid.to_mul_one_class, .. s.to_add_submonoid.to_add_comm_monoid }
@[simp, norm_cast] lemma coe_one : ((1 : s) : R) = (1 : R) := rfl
@[simp, norm_cast] lemma coe_zero : ((0 : s) : R) = (0 : R) := rfl
@[simp, norm_cast] lemma coe_add (x y : s) : ((x + y : s) : R) = (x + y : R) := rfl
@[simp, norm_cast] lemma coe_mul (x y : s) : ((x * y : s) : R) = (x * y : R) := rfl
instance nontrivial [nontrivial R] : nontrivial s :=
nontrivial_of_ne 0 1 $ λ H, zero_ne_one (congr_arg subtype.val H)
instance no_zero_divisors [no_zero_divisors R] : no_zero_divisors s :=
{ eq_zero_or_eq_zero_of_mul_eq_zero := λ x y h,
or.cases_on (eq_zero_or_eq_zero_of_mul_eq_zero $ subtype.ext_iff.mp h)
(λ h, or.inl $ subtype.eq h) (λ h, or.inr $ subtype.eq h) }
/-- A subsemiring of a `semiring` is a `semiring`. -/
instance to_semiring {R} [semiring R] (s : subsemiring R) : semiring s :=
{ ..s.to_non_assoc_semiring, ..s.to_submonoid.to_monoid }
@[simp, norm_cast] lemma coe_pow {R} [semiring R] (s : subsemiring R) (x : s) (n : ℕ) :
((x^n : s) : R) = (x^n : R) :=
begin
induction n with n ih,
{ simp, },
{ simp [pow_succ, ih], },
end
/-- A subsemiring of a `comm_semiring` is a `comm_semiring`. -/
instance to_comm_semiring {R} [comm_semiring R] (s : subsemiring R) : comm_semiring s :=
{ mul_comm := λ _ _, subtype.eq $ mul_comm _ _, ..s.to_semiring}
/-- The natural ring hom from a subsemiring of semiring `R` to `R`. -/
def subtype : s →+* R :=
{ to_fun := coe, .. s.to_submonoid.subtype, .. s.to_add_submonoid.subtype }
@[simp] theorem coe_subtype : ⇑s.subtype = coe := rfl
/-- A subsemiring of an `ordered_semiring` is an `ordered_semiring`. -/
instance to_ordered_semiring {R} [ordered_semiring R] (s : subsemiring R) : ordered_semiring s :=
subtype.coe_injective.ordered_semiring coe rfl rfl (λ _ _, rfl) (λ _ _, rfl)
/-- A subsemiring of an `ordered_comm_semiring` is an `ordered_comm_semiring`. -/
instance to_ordered_comm_semiring {R} [ordered_comm_semiring R] (s : subsemiring R) :
ordered_comm_semiring s :=
subtype.coe_injective.ordered_comm_semiring coe rfl rfl (λ _ _, rfl) (λ _ _, rfl)
/-- A subsemiring of a `linear_ordered_semiring` is a `linear_ordered_semiring`. -/
instance to_linear_ordered_semiring {R} [linear_ordered_semiring R] (s : subsemiring R) :
linear_ordered_semiring s :=
subtype.coe_injective.linear_ordered_semiring coe rfl rfl (λ _ _, rfl) (λ _ _, rfl)
/-! Note: currently, there is no `linear_ordered_comm_semiring`. -/
@[simp] lemma mem_to_submonoid {s : subsemiring R} {x : R} : x ∈ s.to_submonoid ↔ x ∈ s := iff.rfl
@[simp] lemma coe_to_submonoid (s : subsemiring R) : (s.to_submonoid : set R) = s := rfl
@[simp] lemma mem_to_add_submonoid {s : subsemiring R} {x : R} :
x ∈ s.to_add_submonoid ↔ x ∈ s := iff.rfl
@[simp] lemma coe_to_add_submonoid (s : subsemiring R) : (s.to_add_submonoid : set R) = s := rfl
/-- The subsemiring `R` of the semiring `R`. -/
instance : has_top (subsemiring R) :=
⟨{ .. (⊤ : submonoid R), .. (⊤ : add_submonoid R) }⟩
@[simp] lemma mem_top (x : R) : x ∈ (⊤ : subsemiring R) := set.mem_univ x
@[simp] lemma coe_top : ((⊤ : subsemiring R) : set R) = set.univ := rfl
/-- The preimage of a subsemiring along a ring homomorphism is a subsemiring. -/
def comap (f : R →+* S) (s : subsemiring S) : subsemiring R :=
{ carrier := f ⁻¹' s,
.. s.to_submonoid.comap (f : R →* S), .. s.to_add_submonoid.comap (f : R →+ S) }
@[simp]
@[simp]
lemma mem_comap {s : subsemiring S} {f : R →+* S} {x : R} : x ∈ s.comap f ↔ f x ∈ s := iff.rfl
lemma comap_comap (s : subsemiring T) (g : S →+* T) (f : R →+* S) :
(s.comap g).comap f = s.comap (g.comp f) :=
rfl
/-- The image of a subsemiring along a ring homomorphism is a subsemiring. -/
def map (f : R →+* S) (s : subsemiring R) : subsemiring S :=
{ carrier := f '' s,
.. s.to_submonoid.map (f : R →* S), .. s.to_add_submonoid.map (f : R →+ S) }
@[simp] lemma coe_map (f : R →+* S) (s : subsemiring R) : (s.map f : set S) = f '' s := rfl
@[simp] lemma mem_map {f : R →+* S} {s : subsemiring R} {y : S} :
y ∈ s.map f ↔ ∃ x ∈ s, f x = y :=
set.mem_image_iff_bex
@[simp] lemma map_id : s.map (ring_hom.id R) = s :=
set_like.coe_injective $ set.image_id _
lemma map_map (g : S →+* T) (f : R →+* S) : (s.map f).map g = s.map (g.comp f) :=
set_like.coe_injective $ set.image_image _ _ _
lemma map_le_iff_le_comap {f : R →+* S} {s : subsemiring R} {t : subsemiring S} :
s.map f ≤ t ↔ s ≤ t.comap f :=
set.image_subset_iff
lemma gc_map_comap (f : R →+* S) : galois_connection (map f) (comap f) :=
λ S T, map_le_iff_le_comap
/-- A subsemiring is isomorphic to its image under an injective function -/
noncomputable def equiv_map_of_injective
(f : R →+* S) (hf : function.injective f) : s ≃+* s.map f :=
{ map_mul' := λ _ _, subtype.ext (f.map_mul _ _),
map_add' := λ _ _, subtype.ext (f.map_add _ _),
..equiv.set.image f s hf }
@[simp] lemma coe_equiv_map_of_injective_apply
(f : R →+* S) (hf : function.injective f) (x : s) :
(equiv_map_of_injective s f hf x : S) = f x := rfl
end subsemiring
namespace ring_hom
variables (g : S →+* T) (f : R →+* S)
/-- The range of a ring homomorphism is a subsemiring. See Note [range copy pattern]. -/
def srange : subsemiring S :=
((⊤ : subsemiring R).map f).copy (set.range f) set.image_univ.symm
@[simp] lemma coe_srange : (f.srange : set S) = set.range f := rfl
@[simp] lemma mem_srange {f : R →+* S} {y : S} : y ∈ f.srange ↔ ∃ x, f x = y :=
iff.rfl
lemma srange_eq_map (f : R →+* S) : f.srange = (⊤ : subsemiring R).map f :=
by { ext, simp }
lemma mem_srange_self (f : R →+* S) (x : R) : f x ∈ f.srange :=
mem_srange.mpr ⟨x, rfl⟩
lemma map_srange : f.srange.map g = (g.comp f).srange :=
by simpa only [srange_eq_map] using (⊤ : subsemiring R).map_map g f
/-- The range of a morphism of semirings is a fintype, if the domain is a fintype.
Note: this instance can form a diamond with `subtype.fintype` in the
presence of `fintype S`.-/
instance fintype_srange [fintype R] [decidable_eq S] (f : R →+* S) : fintype (srange f) :=
set.fintype_range f
end ring_hom
namespace subsemiring
instance : has_bot (subsemiring R) := ⟨(nat.cast_ring_hom R).srange⟩
instance : inhabited (subsemiring R) := ⟨⊥⟩
lemma coe_bot : ((⊥ : subsemiring R) : set R) = set.range (coe : ℕ → R) :=
(nat.cast_ring_hom R).coe_srange
lemma mem_bot {x : R} : x ∈ (⊥ : subsemiring R) ↔ ∃ n : ℕ, ↑n=x := ring_hom.mem_srange
/-- The inf of two subsemirings is their intersection. -/
instance : has_inf (subsemiring R) :=
⟨λ s t,
{ carrier := s ∩ t,
.. s.to_submonoid ⊓ t.to_submonoid,
.. s.to_add_submonoid ⊓ t.to_add_submonoid }⟩
@[simp] lemma coe_inf (p p' : subsemiring R) : ((p ⊓ p' : subsemiring R) : set R) = p ∩ p' := rfl
@[simp] lemma mem_inf {p p' : subsemiring R} {x : R} : x ∈ p ⊓ p' ↔ x ∈ p ∧ x ∈ p' := iff.rfl
instance : has_Inf (subsemiring R) :=
⟨λ s, subsemiring.mk' (⋂ t ∈ s, ↑t) (⨅ t ∈ s, subsemiring.to_submonoid t) (by simp)
(⨅ t ∈ s, subsemiring.to_add_submonoid t) (by simp)⟩
@[simp, norm_cast] lemma coe_Inf (S : set (subsemiring R)) :
((Inf S : subsemiring R) : set R) = ⋂ s ∈ S, ↑s := rfl
lemma mem_Inf {S : set (subsemiring R)} {x : R} : x ∈ Inf S ↔ ∀ p ∈ S, x ∈ p := set.mem_bInter_iff
@[simp] lemma Inf_to_submonoid (s : set (subsemiring R)) :
(Inf s).to_submonoid = ⨅ t ∈ s, subsemiring.to_submonoid t :=
mk'_to_submonoid _ _
@[simp] lemma Inf_to_add_submonoid (s : set (subsemiring R)) :
(Inf s).to_add_submonoid = ⨅ t ∈ s, subsemiring.to_add_submonoid t :=
mk'_to_add_submonoid _ _
/-- Subsemirings of a semiring form a complete lattice. -/
instance : complete_lattice (subsemiring R) :=
{ bot := (⊥),
bot_le := λ s x hx, let ⟨n, hn⟩ := mem_bot.1 hx in hn ▸ s.coe_nat_mem n,
top := (⊤),
le_top := λ s x hx, trivial,
inf := (⊓),
inf_le_left := λ s t x, and.left,
inf_le_right := λ s t x, and.right,
le_inf := λ s t₁ t₂ h₁ h₂ x hx, ⟨h₁ hx, h₂ hx⟩,
.. complete_lattice_of_Inf (subsemiring R)
(λ s, is_glb.of_image (λ s t,
show (s : set R) ≤ t ↔ s ≤ t, from set_like.coe_subset_coe) is_glb_binfi)}
lemma eq_top_iff' (A : subsemiring R) : A = ⊤ ↔ ∀ x : R, x ∈ A :=
eq_top_iff.trans ⟨λ h m, h $ mem_top m, λ h m _, h m⟩
section
/-- The center of a semiring `R` is the set of elements that commute with everything in `R` -/
def center (R) [semiring R] : subsemiring R :=
{ carrier := set.center R,
zero_mem' := set.zero_mem_center R,
add_mem' := λ a b, set.add_mem_center,
.. submonoid.center R }
lemma coe_center (R) [semiring R] : ↑(center R) = set.center R := rfl
@[simp]
lemma center_to_submonoid (R) [semiring R] : (center R).to_submonoid = submonoid.center R := rfl
lemma mem_center_iff {R} [semiring R] {z : R} : z ∈ center R ↔ ∀ g, g * z = z * g :=
iff.rfl
instance decidable_mem_center {R} [semiring R] [decidable_eq R] [fintype R] :
decidable_pred (∈ center R) :=
λ _, decidable_of_iff' _ mem_center_iff
@[simp] lemma center_eq_top (R) [comm_semiring R] : center R = ⊤ :=
set_like.coe_injective (set.center_eq_univ R)
/-- The center is commutative. -/
instance {R} [semiring R] : comm_semiring (center R) :=
{ ..submonoid.center.comm_monoid,
..(center R).to_semiring}
end
/-- The `subsemiring` generated by a set. -/
def closure (s : set R) : subsemiring R := Inf {S | s ⊆ S}
lemma mem_closure {x : R} {s : set R} : x ∈ closure s ↔ ∀ S : subsemiring R, s ⊆ S → x ∈ S :=
mem_Inf
/-- The subsemiring generated by a set includes the set. -/
@[simp] lemma subset_closure {s : set R} : s ⊆ closure s := λ x hx, mem_closure.2 $ λ S hS, hS hx
lemma not_mem_of_not_mem_closure {s : set R} {P : R} (hP : P ∉ closure s) : P ∉ s :=
λ h, hP (subset_closure h)
/-- A subsemiring `S` includes `closure s` if and only if it includes `s`. -/
@[simp]
lemma closure_le {s : set R} {t : subsemiring R} : closure s ≤ t ↔ s ⊆ t :=
⟨set.subset.trans subset_closure, λ h, Inf_le h⟩
/-- Subsemiring closure of a set is monotone in its argument: if `s ⊆ t`,
then `closure s ≤ closure t`. -/
lemma closure_mono ⦃s t : set R⦄ (h : s ⊆ t) : closure s ≤ closure t :=
closure_le.2 $ set.subset.trans h subset_closure
lemma closure_eq_of_le {s : set R} {t : subsemiring R} (h₁ : s ⊆ t) (h₂ : t ≤ closure s) :
closure s = t :=
le_antisymm (closure_le.2 h₁) h₂
lemma mem_map_equiv {f : R ≃+* S} {K : subsemiring R} {x : S} :
x ∈ K.map (f : R →+* S) ↔ f.symm x ∈ K :=
@set.mem_image_equiv _ _ ↑K f.to_equiv x
lemma map_equiv_eq_comap_symm (f : R ≃+* S) (K : subsemiring R) :
K.map (f : R →+* S) = K.comap f.symm :=
set_like.coe_injective (f.to_equiv.image_eq_preimage K)
lemma comap_equiv_eq_map_symm (f : R ≃+* S) (K : subsemiring S) :
K.comap (f : R →+* S) = K.map f.symm :=
(map_equiv_eq_comap_symm f.symm K).symm
end subsemiring
namespace submonoid
/-- The additive closure of a submonoid is a subsemiring. -/
def subsemiring_closure (M : submonoid R) : subsemiring R :=
{ one_mem' := add_submonoid.mem_closure.mpr (λ y hy, hy M.one_mem),
mul_mem' := λ x y, M.mul_mem_add_closure,
..add_submonoid.closure (M : set R)}
lemma subsemiring_closure_coe :
(M.subsemiring_closure : set R) = add_submonoid.closure (M : set R) := rfl
lemma subsemiring_closure_to_add_submonoid :
M.subsemiring_closure.to_add_submonoid = add_submonoid.closure (M : set R) := rfl
/-- The `subsemiring` generated by a multiplicative submonoid coincides with the
`subsemiring.closure` of the submonoid itself . -/
lemma subsemiring_closure_eq_closure : M.subsemiring_closure = subsemiring.closure (M : set R) :=
begin
ext,
refine ⟨λ hx, _, λ hx, (subsemiring.mem_closure.mp hx) M.subsemiring_closure (λ s sM, _)⟩;
rintros - ⟨H1, rfl⟩;
rintros - ⟨H2, rfl⟩,
{ exact add_submonoid.mem_closure.mp hx H1.to_add_submonoid H2 },
{ exact H2 sM }
end
end submonoid
namespace subsemiring
@[simp]
lemma closure_submonoid_closure (s : set R) : closure ↑(submonoid.closure s) = closure s :=
le_antisymm
(closure_le.mpr (λ y hy, (submonoid.mem_closure.mp hy) (closure s).to_submonoid subset_closure))
(closure_mono (submonoid.subset_closure))
/-- The elements of the subsemiring closure of `M` are exactly the elements of the additive closure
of a multiplicative submonoid `M`. -/
lemma coe_closure_eq (s : set R) :
(closure s : set R) = add_submonoid.closure (submonoid.closure s : set R) :=
by simp [← submonoid.subsemiring_closure_to_add_submonoid, submonoid.subsemiring_closure_eq_closure]
lemma mem_closure_iff {s : set R} {x} :
x ∈ closure s ↔ x ∈ add_submonoid.closure (submonoid.closure s : set R) :=
set.ext_iff.mp (coe_closure_eq s) x
@[simp]
lemma closure_add_submonoid_closure {s : set R} : closure ↑(add_submonoid.closure s) = closure s :=
begin
ext x,
refine ⟨λ hx, _, λ hx, closure_mono add_submonoid.subset_closure hx⟩,
rintros - ⟨H, rfl⟩,
rintros - ⟨J, rfl⟩,
refine (add_submonoid.mem_closure.mp (mem_closure_iff.mp hx)) H.to_add_submonoid (λ y hy, _),
refine (submonoid.mem_closure.mp hy) H.to_submonoid (λ z hz, _),
exact (add_submonoid.mem_closure.mp hz) H.to_add_submonoid (λ w hw, J hw),
end
/-- An induction principle for closure membership. If `p` holds for `0`, `1`, and all elements
of `s`, and is preserved under addition and multiplication, then `p` holds for all elements
of the closure of `s`. -/
@[elab_as_eliminator]
lemma closure_induction {s : set R} {p : R → Prop} {x} (h : x ∈ closure s)
(Hs : ∀ x ∈ s, p x) (H0 : p 0) (H1 : p 1)
(Hadd : ∀ x y, p x → p y → p (x + y)) (Hmul : ∀ x y, p x → p y → p (x * y)) : p x :=
(@closure_le _ _ _ ⟨p, H1, Hmul, H0, Hadd⟩).2 Hs h
lemma mem_closure_iff_exists_list {R} [semiring R] {s : set R} {x} : x ∈ closure s ↔
∃ L : list (list R), (∀ t ∈ L, ∀ y ∈ t, y ∈ s) ∧ (L.map list.prod).sum = x :=
⟨λ hx, add_submonoid.closure_induction (mem_closure_iff.1 hx)
(λ x hx, suffices ∃ t : list R, (∀ y ∈ t, y ∈ s) ∧ t.prod = x,
from let ⟨t, ht1, ht2⟩ := this in ⟨[t], list.forall_mem_singleton.2 ht1,
by rw [list.map_singleton, list.sum_singleton, ht2]⟩,
submonoid.closure_induction hx
(λ x hx, ⟨[x], list.forall_mem_singleton.2 hx, one_mul x⟩)
⟨[], list.forall_mem_nil _, rfl⟩
(λ x y ⟨t, ht1, ht2⟩ ⟨u, hu1, hu2⟩, ⟨t ++ u, list.forall_mem_append.2 ⟨ht1, hu1⟩,
by rw [list.prod_append, ht2, hu2]⟩))
⟨[], list.forall_mem_nil _, rfl⟩
(λ x y ⟨L, HL1, HL2⟩ ⟨M, HM1, HM2⟩, ⟨L ++ M, list.forall_mem_append.2 ⟨HL1, HM1⟩,
by rw [list.map_append, list.sum_append, HL2, HM2]⟩),
λ ⟨L, HL1, HL2⟩, HL2 ▸ list_sum_mem _ (λ r hr, let ⟨t, ht1, ht2⟩ := list.mem_map.1 hr in
ht2 ▸ list_prod_mem _ (λ y hy, subset_closure $ HL1 t ht1 y hy))⟩
variable (R)
/-- `closure` forms a Galois insertion with the coercion to set. -/
protected def gi : galois_insertion (@closure R _) coe :=
{ choice := λ s _, closure s,
gc := λ s t, closure_le,
le_l_u := λ s, subset_closure,
choice_eq := λ s h, rfl }
variable {R}
/-- Closure of a subsemiring `S` equals `S`. -/
lemma closure_eq (s : subsemiring R) : closure (s : set R) = s := (subsemiring.gi R).l_u_eq s
@[simp] lemma closure_empty : closure (∅ : set R) = ⊥ := (subsemiring.gi R).gc.l_bot
@[simp] lemma closure_univ : closure (set.univ : set R) = ⊤ := @coe_top R _ ▸ closure_eq ⊤
lemma closure_union (s t : set R) : closure (s ∪ t) = closure s ⊔ closure t :=
(subsemiring.gi R).gc.l_sup
lemma closure_Union {ι} (s : ι → set R) : closure (⋃ i, s i) = ⨆ i, closure (s i) :=
(subsemiring.gi R).gc.l_supr
lemma closure_sUnion (s : set (set R)) : closure (⋃₀ s) = ⨆ t ∈ s, closure t :=
(subsemiring.gi R).gc.l_Sup
lemma map_sup (s t : subsemiring R) (f : R →+* S) : (s ⊔ t).map f = s.map f ⊔ t.map f :=
(gc_map_comap f).l_sup
lemma map_supr {ι : Sort*} (f : R →+* S) (s : ι → subsemiring R) :
(supr s).map f = ⨆ i, (s i).map f :=
(gc_map_comap f).l_supr
lemma comap_inf (s t : subsemiring S) (f : R →+* S) : (s ⊓ t).comap f = s.comap f ⊓ t.comap f :=
(gc_map_comap f).u_inf
lemma comap_infi {ι : Sort*} (f : R →+* S) (s : ι → subsemiring S) :
(infi s).comap f = ⨅ i, (s i).comap f :=
(gc_map_comap f).u_infi
@[simp] lemma map_bot (f : R →+* S) : (⊥ : subsemiring R).map f = ⊥ :=
(gc_map_comap f).l_bot
@[simp] lemma comap_top (f : R →+* S) : (⊤ : subsemiring S).comap f = ⊤ :=
(gc_map_comap f).u_top
/-- Given `subsemiring`s `s`, `t` of semirings `R`, `S` respectively, `s.prod t` is `s × t`
as a subsemiring of `R × S`. -/
def prod (s : subsemiring R) (t : subsemiring S) : subsemiring (R × S) :=
{ carrier := (s : set R).prod t,
.. s.to_submonoid.prod t.to_submonoid, .. s.to_add_submonoid.prod t.to_add_submonoid}
@[norm_cast]
lemma coe_prod (s : subsemiring R) (t : subsemiring S) :
(s.prod t : set (R × S)) = (s : set R).prod (t : set S) :=
rfl
lemma mem_prod {s : subsemiring R} {t : subsemiring S} {p : R × S} :
p ∈ s.prod t ↔ p.1 ∈ s ∧ p.2 ∈ t := iff.rfl
@[mono] lemma prod_mono ⦃s₁ s₂ : subsemiring R⦄ (hs : s₁ ≤ s₂) ⦃t₁ t₂ : subsemiring S⦄
(ht : t₁ ≤ t₂) : s₁.prod t₁ ≤ s₂.prod t₂ :=
set.prod_mono hs ht
lemma prod_mono_right (s : subsemiring R) : monotone (λ t : subsemiring S, s.prod t) :=
prod_mono (le_refl s)
lemma prod_mono_left (t : subsemiring S) : monotone (λ s : subsemiring R, s.prod t) :=
λ s₁ s₂ hs, prod_mono hs (le_refl t)
lemma prod_top (s : subsemiring R) :
s.prod (⊤ : subsemiring S) = s.comap (ring_hom.fst R S) :=
ext $ λ x, by simp [mem_prod, monoid_hom.coe_fst]
lemma top_prod (s : subsemiring S) :
(⊤ : subsemiring R).prod s = s.comap (ring_hom.snd R S) :=
ext $ λ x, by simp [mem_prod, monoid_hom.coe_snd]
@[simp]
lemma top_prod_top : (⊤ : subsemiring R).prod (⊤ : subsemiring S) = ⊤ :=
(top_prod _).trans $ comap_top _
/-- Product of subsemirings is isomorphic to their product as monoids. -/
def prod_equiv (s : subsemiring R) (t : subsemiring S) : s.prod t ≃+* s × t :=
{ map_mul' := λ x y, rfl, map_add' := λ x y, rfl, .. equiv.set.prod ↑s ↑t }
lemma mem_supr_of_directed {ι} [hι : nonempty ι] {S : ι → subsemiring R} (hS : directed (≤) S)
{x : R} :
x ∈ (⨆ i, S i) ↔ ∃ i, x ∈ S i :=
begin
refine ⟨_, λ ⟨i, hi⟩, (set_like.le_def.1 $ le_supr S i) hi⟩,
let U : subsemiring R := subsemiring.mk' (⋃ i, (S i : set R))
(⨆ i, (S i).to_submonoid) (submonoid.coe_supr_of_directed $ hS.mono_comp _ (λ _ _, id))
(⨆ i, (S i).to_add_submonoid) (add_submonoid.coe_supr_of_directed $ hS.mono_comp _ (λ _ _, id)),
suffices : (⨆ i, S i) ≤ U, by simpa using @this x,
exact supr_le (λ i x hx, set.mem_Union.2 ⟨i, hx⟩),
end
lemma coe_supr_of_directed {ι} [hι : nonempty ι] {S : ι → subsemiring R} (hS : directed (≤) S) :
((⨆ i, S i : subsemiring R) : set R) = ⋃ i, ↑(S i) :=
set.ext $ λ x, by simp [mem_supr_of_directed hS]
lemma mem_Sup_of_directed_on {S : set (subsemiring R)} (Sne : S.nonempty)
(hS : directed_on (≤) S) {x : R} :
x ∈ Sup S ↔ ∃ s ∈ S, x ∈ s :=
begin
haveI : nonempty S := Sne.to_subtype,
simp only [Sup_eq_supr', mem_supr_of_directed hS.directed_coe, set_coe.exists, subtype.coe_mk]
end
lemma coe_Sup_of_directed_on {S : set (subsemiring R)} (Sne : S.nonempty) (hS : directed_on (≤) S) :
(↑(Sup S) : set R) = ⋃ s ∈ S, ↑s :=
set.ext $ λ x, by simp [mem_Sup_of_directed_on Sne hS]
end subsemiring
namespace ring_hom
variables [non_assoc_semiring T] {s : subsemiring R}
open subsemiring
/-- Restriction of a ring homomorphism to a subsemiring of the domain. -/
def srestrict (f : R →+* S) (s : subsemiring R) : s →+* S := f.comp s.subtype
@[simp] lemma srestrict_apply (f : R →+* S) (x : s) : f.srestrict s x = f x := rfl
/-- Restriction of a ring homomorphism to a subsemiring of the codomain. -/
def cod_srestrict (f : R →+* S) (s : subsemiring S) (h : ∀ x, f x ∈ s) : R →+* s :=
{ to_fun := λ n, ⟨f n, h n⟩,
.. (f : R →* S).cod_mrestrict s.to_submonoid h,
.. (f : R →+ S).cod_mrestrict s.to_add_submonoid h }
/-- Restriction of a ring homomorphism to its range interpreted as a subsemiring.
This is the bundled version of `set.range_factorization`. -/
def srange_restrict (f : R →+* S) : R →+* f.srange :=
f.cod_srestrict f.srange f.mem_srange_self
@[simp] lemma coe_srange_restrict (f : R →+* S) (x : R) :
(f.srange_restrict x : S) = f x :=
rfl
lemma srange_restrict_surjective (f : R →+* S) : function.surjective f.srange_restrict :=
λ ⟨y, hy⟩, let ⟨x, hx⟩ := mem_srange.mp hy in ⟨x, subtype.ext hx⟩
lemma srange_top_iff_surjective {f : R →+* S} :
f.srange = (⊤ : subsemiring S) ↔ function.surjective f :=
set_like.ext'_iff.trans $ iff.trans (by rw [coe_srange, coe_top]) set.range_iff_surjective
/-- The range of a surjective ring homomorphism is the whole of the codomain. -/
lemma srange_top_of_surjective (f : R →+* S) (hf : function.surjective f) :
f.srange = (⊤ : subsemiring S) :=
srange_top_iff_surjective.2 hf
/-- The subsemiring of elements `x : R` such that `f x = g x` -/
def eq_slocus (f g : R →+* S) : subsemiring R :=
{ carrier := {x | f x = g x}, .. (f : R →* S).eq_mlocus g, .. (f : R →+ S).eq_mlocus g }
/-- If two ring homomorphisms are equal on a set, then they are equal on its subsemiring closure. -/
lemma eq_on_sclosure {f g : R →+* S} {s : set R} (h : set.eq_on f g s) :
set.eq_on f g (closure s) :=
show closure s ≤ f.eq_slocus g, from closure_le.2 h
lemma eq_of_eq_on_stop {f g : R →+* S} (h : set.eq_on f g (⊤ : subsemiring R)) :
f = g :=
ext $ λ x, h trivial
lemma eq_of_eq_on_sdense {s : set R} (hs : closure s = ⊤) {f g : R →+* S} (h : s.eq_on f g) :
f = g :=
eq_of_eq_on_stop $ hs ▸ eq_on_sclosure h
lemma sclosure_preimage_le (f : R →+* S) (s : set S) :
closure (f ⁻¹' s) ≤ (closure s).comap f :=
closure_le.2 $ λ x hx, set_like.mem_coe.2 $ mem_comap.2 $ subset_closure hx
/-- The image under a ring homomorphism of the subsemiring generated by a set equals
the subsemiring generated by the image of the set. -/
lemma map_sclosure (f : R →+* S) (s : set R) :
(closure s).map f = closure (f '' s) :=
le_antisymm
(map_le_iff_le_comap.2 $ le_trans (closure_mono $ set.subset_preimage_image _ _)
(sclosure_preimage_le _ _))
(closure_le.2 $ set.image_subset _ subset_closure)
end ring_hom
namespace subsemiring
open ring_hom
/-- The ring homomorphism associated to an inclusion of subsemirings. -/
def inclusion {S T : subsemiring R} (h : S ≤ T) : S →* T :=
S.subtype.cod_srestrict _ (λ x, h x.2)
@[simp] lemma srange_subtype (s : subsemiring R) : s.subtype.srange = s :=
set_like.coe_injective $ (coe_srange _).trans subtype.range_coe
@[simp]
lemma range_fst : (fst R S).srange = ⊤ :=
(fst R S).srange_top_of_surjective $ prod.fst_surjective
@[simp]
lemma range_snd : (snd R S).srange = ⊤ :=
(snd R S).srange_top_of_surjective $ prod.snd_surjective
@[simp]
lemma prod_bot_sup_bot_prod (s : subsemiring R) (t : subsemiring S) :
(s.prod ⊥) ⊔ (prod ⊥ t) = s.prod t :=
le_antisymm (sup_le (prod_mono_right s bot_le) (prod_mono_left t bot_le)) $
assume p hp, prod.fst_mul_snd p ▸ mul_mem _
((le_sup_left : s.prod ⊥ ≤ s.prod ⊥ ⊔ prod ⊥ t) ⟨hp.1, set_like.mem_coe.2 $ one_mem ⊥⟩)
((le_sup_right : prod ⊥ t ≤ s.prod ⊥ ⊔ prod ⊥ t) ⟨set_like.mem_coe.2 $ one_mem ⊥, hp.2⟩)
end subsemiring
namespace ring_equiv
variables {s t : subsemiring R}
/-- Makes the identity isomorphism from a proof two subsemirings of a multiplicative
monoid are equal. -/
def subsemiring_congr (h : s = t) : s ≃+* t :=
{ map_mul' := λ _ _, rfl, map_add' := λ _ _, rfl, ..equiv.set_congr $ congr_arg _ h }
/-- Restrict a ring homomorphism with a left inverse to a ring isomorphism to its
`ring_hom.srange`. -/
def sof_left_inverse {g : S → R} {f : R →+* S} (h : function.left_inverse g f) :
R ≃+* f.srange :=
{ to_fun := λ x, f.srange_restrict x,
inv_fun := λ x, (g ∘ f.srange.subtype) x,
left_inv := h,
right_inv := λ x, subtype.ext $
let ⟨x', hx'⟩ := ring_hom.mem_srange.mp x.prop in
show f (g x) = x, by rw [←hx', h x'],
..f.srange_restrict }
@[simp] lemma sof_left_inverse_apply
{g : S → R} {f : R →+* S} (h : function.left_inverse g f) (x : R) :
↑(sof_left_inverse h x) = f x := rfl
@[simp] lemma sof_left_inverse_symm_apply
{g : S → R} {f : R →+* S} (h : function.left_inverse g f) (x : f.srange) :
(sof_left_inverse h).symm x = g x := rfl
end ring_equiv
/-! ### Actions by `subsemiring`s
These are just copies of the definitions about `submonoid` starting from `submonoid.mul_action`.
The only new result is `subsemiring.module`.
When `R` is commutative, `algebra.of_subsemiring` provides a stronger result than those found in
this file, which uses the same scalar action.
-/
section actions
namespace subsemiring
variables {R' α β : Type*} [semiring R']
/-- The action by a subsemiring is the action by the underlying semiring. -/
instance [mul_action R' α] (S : subsemiring R') : mul_action S α :=
S.to_submonoid.mul_action
lemma smul_def [mul_action R' α] {S : subsemiring R'} (g : S) (m : α) : g • m = (g : R') • m := rfl
instance smul_comm_class_left
[mul_action R' β] [has_scalar α β] [smul_comm_class R' α β] (S : subsemiring R') :
smul_comm_class S α β :=
S.to_submonoid.smul_comm_class_left
instance smul_comm_class_right
[has_scalar α β] [mul_action R' β] [smul_comm_class α R' β] (S : subsemiring R') :
smul_comm_class α S β :=
S.to_submonoid.smul_comm_class_right
/-- Note that this provides `is_scalar_tower S R R` which is needed by `smul_mul_assoc`. -/
instance
[has_scalar α β] [mul_action R' α] [mul_action R' β] [is_scalar_tower R' α β]
(S : subsemiring R') :
is_scalar_tower S α β :=
S.to_submonoid.is_scalar_tower
instance [mul_action R' α] [has_faithful_scalar R' α] (S : subsemiring R') :
has_faithful_scalar S α :=
S.to_submonoid.has_faithful_scalar
/-- The action by a subsemiring is the action by the underlying semiring. -/
instance [add_monoid α] [distrib_mul_action R' α] (S : subsemiring R') : distrib_mul_action S α :=
S.to_submonoid.distrib_mul_action
/-- The action by a subsemiring is the action by the underlying semiring. -/
instance [monoid α] [mul_distrib_mul_action R' α] (S : subsemiring R') :
mul_distrib_mul_action S α :=
S.to_submonoid.mul_distrib_mul_action
/-- The action by a subsemiring is the action by the underlying semiring. -/
instance [add_comm_monoid α] [module R' α] (S : subsemiring R') : module S α :=
{ smul := (•), .. module.comp_hom _ S.subtype }
end subsemiring
end actions
-- While this definition is not about `subsemiring`s, this is the earliest we have
-- both `ordered_semiring` and `submonoid` available.
/-- Submonoid of positive elements of an ordered semiring. -/
def pos_submonoid (R : Type*) [ordered_semiring R] [nontrivial R] : submonoid R :=
{ carrier := {x | 0 < x},
one_mem' := show (0 : R) < 1, from zero_lt_one,
mul_mem' := λ x y (hx : 0 < x) (hy : 0 < y), mul_pos hx hy }
@[simp] lemma mem_pos_monoid {R : Type*} [ordered_semiring R] [nontrivial R] (u : units R) :
↑u ∈ pos_submonoid R ↔ (0 : R) < u := iff.rfl
|
Formal statement is: corollary no_retraction_cball: fixes a :: "'a::euclidean_space" assumes "e > 0" shows "\<not> (frontier (cball a e) retract_of (cball a e))" Informal statement is: The boundary of a closed ball in a Euclidean space is not a retract of the ball. |
/-
Copyright (c) 2021 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import data.dfinsupp.basic
/-!
# Pointwise order on finitely supported dependent functions
This file lifts order structures on the `α i` to `Π₀ i, α i`.
## Main declarations
* `dfinsupp.order_embedding_to_fun`: The order embedding from finitely supported dependent functions
to functions.
## TODO
Add `is_well_order (Π₀ i, α i) (<)`.
-/
open_locale big_operators
open finset
variables {ι : Type*} {α : ι → Type*}
namespace dfinsupp
/-! ### Order structures -/
section has_zero
variables (α) [Π i, has_zero (α i)]
section has_le
variables [Π i, has_le (α i)]
instance : has_le (Π₀ i, α i) := ⟨λ f g, ∀ i, f i ≤ g i⟩
variables {α}
lemma le_def {f g : Π₀ i, α i} : f ≤ g ↔ ∀ i, f i ≤ g i := iff.rfl
/-- The order on `dfinsupp`s over a partial order embeds into the order on functions -/
def order_embedding_to_fun : (Π₀ i, α i) ↪o Π i, α i :=
{ to_fun := λ f, f,
inj' := λ f g h, dfinsupp.ext $ λ i, by { dsimp at h, rw h },
map_rel_iff' := λ a b, (@le_def _ _ _ _ a b).symm }
@[simp] lemma order_embedding_to_fun_apply {f : Π₀ i, α i} {i : ι} :
order_embedding_to_fun f i = f i := rfl
end has_le
section preorder
variables [Π i, preorder (α i)]
instance : preorder (Π₀ i, α i) :=
{ le_refl := λ f i, le_rfl,
le_trans := λ f g h hfg hgh i, (hfg i).trans (hgh i),
.. dfinsupp.has_le α }
end preorder
instance [Π i, partial_order (α i)] : partial_order (Π₀ i, α i) :=
{ le_antisymm := λ f g hfg hgf, ext $ λ i, (hfg i).antisymm (hgf i),
.. dfinsupp.preorder α}
instance [Π i, semilattice_inf (α i)] : semilattice_inf (Π₀ i, α i) :=
{ inf := zip_with (λ _, (⊓)) (λ _, inf_idem),
inf_le_left := λ f g i, by { rw zip_with_apply, exact inf_le_left },
inf_le_right := λ f g i, by { rw zip_with_apply, exact inf_le_right },
le_inf := λ f g h hf hg i, by { rw zip_with_apply, exact le_inf (hf i) (hg i) },
..dfinsupp.partial_order α }
@[simp] lemma inf_apply [Π i, semilattice_inf (α i)] (f g : Π₀ i, α i) (i : ι) :
(f ⊓ g) i = f i ⊓ g i :=
zip_with_apply _ _ _ _ _
instance [Π i, semilattice_sup (α i)] : semilattice_sup (Π₀ i, α i) :=
{ sup := zip_with (λ _, (⊔)) (λ _, sup_idem),
le_sup_left := λ f g i, by { rw zip_with_apply, exact le_sup_left },
le_sup_right := λ f g i, by { rw zip_with_apply, exact le_sup_right },
sup_le := λ f g h hf hg i, by { rw zip_with_apply, exact sup_le (hf i) (hg i) },
..dfinsupp.partial_order α }
@[simp] lemma sup_apply [Π i, semilattice_sup (α i)] (f g : Π₀ i, α i) (i : ι) :
(f ⊔ g) i = f i ⊔ g i :=
zip_with_apply _ _ _ _ _
instance lattice [Π i, lattice (α i)] : lattice (Π₀ i, α i) :=
{ .. dfinsupp.semilattice_inf α, .. dfinsupp.semilattice_sup α }
end has_zero
/-! ### Algebraic order structures -/
instance (α : ι → Type*) [Π i, ordered_add_comm_monoid (α i)] :
ordered_add_comm_monoid (Π₀ i, α i) :=
{ add_le_add_left := λ a b h c i,
by { rw [add_apply, add_apply], exact add_le_add_left (h i) (c i) },
.. dfinsupp.add_comm_monoid, .. dfinsupp.partial_order α }
instance (α : ι → Type*) [Π i, ordered_cancel_add_comm_monoid (α i)] :
ordered_cancel_add_comm_monoid (Π₀ i, α i) :=
{ le_of_add_le_add_left := λ f g h H i, begin
specialize H i,
rw [add_apply, add_apply] at H,
exact le_of_add_le_add_left H,
end,
add_left_cancel := λ f g h H, ext $ λ i, begin
refine add_left_cancel _,
exact f i,
rw [←add_apply, ←add_apply, H],
end,
.. dfinsupp.ordered_add_comm_monoid α }
instance [Π i, ordered_add_comm_monoid (α i)] [Π i, contravariant_class (α i) (α i) (+) (≤)] :
contravariant_class (Π₀ i, α i) (Π₀ i, α i) (+) (≤) :=
⟨λ f g h H i, by { specialize H i, rw [add_apply, add_apply] at H, exact le_of_add_le_add_left H }⟩
section canonically_ordered_add_monoid
variables (α) [Π i, canonically_ordered_add_monoid (α i)]
instance : order_bot (Π₀ i, α i) :=
{ bot := 0,
bot_le := by simp only [le_def, coe_zero, pi.zero_apply, implies_true_iff, zero_le] }
variables {α}
protected lemma bot_eq_zero : (⊥ : Π₀ i, α i) = 0 := rfl
@[simp] lemma add_eq_zero_iff (f g : Π₀ i, α i) : f + g = 0 ↔ f = 0 ∧ g = 0 :=
by simp [ext_iff, forall_and_distrib]
section le
variables [decidable_eq ι] [Π i (x : α i), decidable (x ≠ 0)] {f g : Π₀ i, α i} {s : finset ι}
lemma le_iff' (hf : f.support ⊆ s) : f ≤ g ↔ ∀ i ∈ s, f i ≤ g i :=
⟨λ h s hs, h s,
λ h s, if H : s ∈ f.support then h s (hf H) else (not_mem_support_iff.1 H).symm ▸ zero_le (g s)⟩
lemma le_iff : f ≤ g ↔ ∀ i ∈ f.support, f i ≤ g i := le_iff' $ subset.refl _
variables (α)
instance decidable_le [Π i, decidable_rel (@has_le.le (α i) _)] :
decidable_rel (@has_le.le (Π₀ i, α i) _) :=
λ f g, decidable_of_iff _ le_iff.symm
variables {α}
@[simp] lemma single_le_iff {i : ι} {a : α i} : single i a ≤ f ↔ a ≤ f i :=
(le_iff' support_single_subset).trans $ by simp
end le
variables (α) [Π i, has_sub (α i)] [Π i, has_ordered_sub (α i)] {f g : Π₀ i, α i} {i : ι}
{a b : α i}
/-- This is called `tsub` for truncated subtraction, to distinguish it with subtraction in an
additive group. -/
instance tsub : has_sub (Π₀ i, α i) := ⟨zip_with (λ i m n, m - n) (λ i, tsub_self 0)⟩
variables {α}
lemma tsub_apply (f g : Π₀ i, α i) (i : ι) : (f - g) i = f i - g i := zip_with_apply _ _ _ _ _
@[simp] lemma coe_tsub (f g : Π₀ i, α i) : ⇑(f - g) = f - g := by { ext i, exact tsub_apply f g i }
variables (α)
instance : has_ordered_sub (Π₀ i, α i) :=
⟨λ n m k, forall_congr $ λ i, by { rw [add_apply, tsub_apply], exact tsub_le_iff_right }⟩
instance : canonically_ordered_add_monoid (Π₀ i, α i) :=
{ le_iff_exists_add := λ f g, begin
refine ⟨λ h, ⟨g - f, _⟩, _⟩,
{ ext i,
rw [add_apply, tsub_apply],
exact (add_tsub_cancel_of_le $ h i).symm },
{ rintro ⟨g, rfl⟩ i,
rw add_apply,
exact self_le_add_right (f i) (g i) }
end,
.. dfinsupp.order_bot α,
.. dfinsupp.ordered_add_comm_monoid α }
variables {α} [decidable_eq ι]
@[simp] lemma single_tsub : single i (a - b) = single i a - single i b :=
begin
ext j,
obtain rfl | h := eq_or_ne i j,
{ rw [tsub_apply, single_eq_same, single_eq_same, single_eq_same] },
{ rw [tsub_apply, single_eq_of_ne h, single_eq_of_ne h, single_eq_of_ne h, tsub_self] }
end
variables [Π i (x : α i), decidable (x ≠ 0)]
lemma support_tsub : (f - g).support ⊆ f.support :=
by simp only [subset_iff, tsub_eq_zero_iff_le, mem_support_iff, ne.def, coe_tsub, pi.sub_apply,
not_imp_not, zero_le, implies_true_iff] {contextual := tt}
lemma subset_support_tsub : f.support \ g.support ⊆ (f - g).support :=
by simp [subset_iff] {contextual := tt}
end canonically_ordered_add_monoid
section canonically_linear_ordered_add_monoid
variables [Π i, canonically_linear_ordered_add_monoid (α i)] [decidable_eq ι] {f g : Π₀ i, α i}
@[simp] lemma support_inf : (f ⊓ g).support = f.support ∩ g.support :=
begin
ext,
simp only [inf_apply, mem_support_iff, ne.def,
finset.mem_union, finset.mem_filter, finset.mem_inter],
simp only [inf_eq_min, ←nonpos_iff_eq_zero, min_le_iff, not_or_distrib],
end
@[simp] lemma support_sup : (f ⊔ g).support = f.support ∪ g.support :=
begin
ext,
simp only [finset.mem_union, mem_support_iff, sup_apply, ne.def, ←bot_eq_zero],
rw [_root_.sup_eq_bot_iff, not_and_distrib],
end
lemma disjoint_iff : disjoint f g ↔ disjoint f.support g.support :=
begin
rw [disjoint_iff, disjoint_iff, dfinsupp.bot_eq_zero, ← dfinsupp.support_eq_empty,
dfinsupp.support_inf],
refl,
end
end canonically_linear_ordered_add_monoid
end dfinsupp
|
/-
Copyright (c) 2022 Rémi Bottinelli. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Rémi Bottinelli
! This file was ported from Lean 3 source module combinatorics.quiver.push
! leanprover-community/mathlib commit 2258b40dacd2942571c8ce136215350c702dc78f
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathlib.Combinatorics.Quiver.Basic
/-!
# Pushing a quiver structure along a map
Given a map `σ : V → W` and a `Quiver` instance on `V`, this files defines a `quiver` instance
on `W` by associating to each arrow `v ⟶ v'` in `V` an arrow `σ v ⟶ σ v'` in `W`.
-/
namespace Quiver
universe v v₁ v₂ u u₁ u₂
variable {V : Type _} [Quiver V] {W : Type _} (σ : V → W)
/-- The `Quiver` instance obtained by pushing arrows of `V` along the map `σ : V → W` -/
@[nolint unusedArguments]
def Push (_ : V → W) :=
W
#align quiver.push Quiver.Push
instance [h : Nonempty W] : Nonempty (Push σ) :=
h
/-- The quiver structure obtained by pushing arrows of `V` along the map `σ : V → W` -/
inductive PushQuiver {V : Type u} [Quiver.{v} V] {W : Type u₂} (σ : V → W) : W → W → Type max u u₂ v
| arrow {X Y : V} (f : X ⟶ Y) : PushQuiver σ (σ X) (σ Y)
#align quiver.push_quiver Quiver.PushQuiver
instance : Quiver (Push σ) :=
⟨PushQuiver σ⟩
namespace Push
/-- The prefunctor induced by pushing arrows via `σ` -/
def of : V ⥤q Push σ where
obj := σ
map f := PushQuiver.arrow f
#align quiver.push.of Quiver.Push.of
@[simp]
theorem of_obj : (of σ).obj = σ :=
rfl
#align quiver.push.of_obj Quiver.Push.of_obj
variable {W' : Type _} [Quiver W'] (φ : V ⥤q W') (τ : W → W') (h : ∀ x, φ.obj x = τ (σ x))
/-- Given a function `τ : W → W'` and a prefunctor `φ : V ⥤q W'`, one can extend `τ` to be
a prefunctor `W ⥤q W'` if `τ` and `σ` factorize `φ` at the level of objects, where `W` is given
the pushforward quiver structure `Push σ`. -/
noncomputable def lift : Push σ ⥤q W' where
obj := τ
map :=
@PushQuiver.rec V _ W σ (fun X Y _ => τ X ⟶ τ Y) @fun X Y f => by
dsimp only
rw [← h X, ← h Y]
exact φ.map f
#align quiver.push.lift Quiver.Push.lift
theorem lift_obj : (lift σ φ τ h).obj = τ :=
rfl
#align quiver.push.lift_obj Quiver.Push.lift_obj
theorem lift_comp : (of σ ⋙q lift σ φ τ h) = φ := by
fapply Prefunctor.ext
· rintro X
simp only [Prefunctor.comp_obj]
apply Eq.symm
exact h X
· rintro X Y f
simp only [Prefunctor.comp_map]
apply eq_of_heq
iterate 2 apply (cast_heq _ _).trans
apply HEq.symm
apply (eqRec_heq _ _).trans
have : ∀ {α γ} {β : α → γ → Sort _} {a a'} (p : a = a') g (b : β a g), HEq (p ▸ b) b := by
intros
subst_vars
rfl
apply this
#align quiver.push.lift_comp Quiver.Push.lift_comp
theorem lift_unique (Φ : Push σ ⥤q W') (Φ₀ : Φ.obj = τ) (Φcomp : (of σ ⋙q Φ) = φ) :
Φ = lift σ φ τ h := by
dsimp only [of, lift]
fapply Prefunctor.ext
· intro X
simp only
rw [Φ₀]
· rintro _ _ ⟨⟩
subst_vars
simp only [Prefunctor.comp_map, cast_eq]
rfl
#align quiver.push.lift_unique Quiver.Push.lift_unique
end Push
end Quiver
|
module BinaryFormats.Data.Bit
%default total
||| A binary digit (either 0 or 1)
public export
data Bit : Type where
||| The 0 digit
O : Bit
||| The 1 digit
I : Bit
|
/-
Copyright (c) 2020 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import algebra.module.equiv
import group_theory.group_action.opposite
/-!
# Module operations on `Mᵐᵒᵖ`
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
This file contains definitions that build on top of the group action definitions in
`group_theory.group_action.opposite`.
-/
namespace mul_opposite
universes u v
variables (R : Type u) {M : Type v} [semiring R] [add_comm_monoid M] [module R M]
/-- `mul_opposite.distrib_mul_action` extends to a `module` -/
instance : module R (mul_opposite M) :=
{ add_smul := λ r₁ r₂ x, unop_injective $ add_smul r₁ r₂ (unop x),
zero_smul := λ x, unop_injective $ zero_smul _ (unop x),
..mul_opposite.distrib_mul_action M R }
/-- The function `op` is a linear equivalence. -/
def op_linear_equiv : M ≃ₗ[R] Mᵐᵒᵖ :=
{ map_smul' := mul_opposite.op_smul, .. op_add_equiv }
@[simp] lemma coe_op_linear_equiv :
(op_linear_equiv R : M → Mᵐᵒᵖ) = op := rfl
@[simp] lemma coe_op_linear_equiv_symm :
((op_linear_equiv R).symm : Mᵐᵒᵖ → M) = unop := rfl
@[simp]
@[simp] lemma op_linear_equiv_to_add_equiv :
(op_linear_equiv R : M ≃ₗ[R] Mᵐᵒᵖ).to_add_equiv = op_add_equiv := rfl
@[simp] lemma op_linear_equiv_symm_to_add_equiv :
(op_linear_equiv R : M ≃ₗ[R] Mᵐᵒᵖ).symm.to_add_equiv = op_add_equiv.symm := rfl
end mul_opposite
|
[STATEMENT]
lemma (in group) derived_set_in_carrier:
assumes "H \<subseteq> carrier G" shows "derived_set G H \<subseteq> carrier G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. derived_set G H \<subseteq> carrier G
[PROOF STEP]
using derived_set_incl[OF assms subgroup_self]
[PROOF STATE]
proof (prove)
using this:
derived_set G H \<subseteq> carrier G
goal (1 subgoal):
1. derived_set G H \<subseteq> carrier G
[PROOF STEP]
. |
{-# OPTIONS --cubical --safe --no-import-sorts #-}
module Cubical.Algebra.Module.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.SIP
open import Cubical.Data.Sigma
open import Cubical.Structures.Axioms
open import Cubical.Structures.Auto
open import Cubical.Structures.Macro
open import Cubical.Algebra.Ring renaming (⟨_⟩ to ⟨_⟩r)
open import Cubical.Algebra.AbGroup hiding (⟨_⟩)
open import Cubical.Algebra.Group hiding (⟨_⟩)
open Iso
private
variable
ℓ : Level
record IsLeftModule (R : Ring {ℓ}) {M : Type ℓ}
(0m : M)
(_+_ : M → M → M)
(-_ : M → M)
(_⋆_ : ⟨ R ⟩r → M → M) : Type ℓ where
constructor ismodule
open Ring R using (_·_; 1r) renaming (_+_ to _+r_)
field
+-isAbGroup : IsAbGroup 0m _+_ -_
⋆-assoc : (r s : ⟨ R ⟩r) (x : M) → (r · s) ⋆ x ≡ r ⋆ (s ⋆ x)
⋆-ldist : (r s : ⟨ R ⟩r) (x : M) → (r +r s) ⋆ x ≡ (r ⋆ x) + (s ⋆ x)
⋆-rdist : (r : ⟨ R ⟩r) (x y : M) → r ⋆ (x + y) ≡ (r ⋆ x) + (r ⋆ y)
⋆-lid : (x : M) → 1r ⋆ x ≡ x
open IsAbGroup +-isAbGroup public
renaming
( assoc to +-assoc
; identity to +-identity
; lid to +-lid
; rid to +-rid
; inverse to +-inv
; invl to +-linv
; invr to +-rinv
; comm to +-comm
; isSemigroup to +-isSemigroup
; isMonoid to +-isMonoid
; isGroup to +-isGroup
)
record LeftModule (R : Ring {ℓ}) : Type (ℓ-suc ℓ) where
constructor leftmodule
field
Carrier : Type ℓ
0m : Carrier
_+_ : Carrier → Carrier → Carrier
-_ : Carrier → Carrier
_⋆_ : ⟨ R ⟩r → Carrier → Carrier
isLeftModule : IsLeftModule R 0m _+_ -_ _⋆_
open IsLeftModule isLeftModule public
module _ {R : Ring {ℓ}} where
⟨_⟩ : LeftModule R → Type ℓ
⟨_⟩ = LeftModule.Carrier
LeftModule→AbGroup : (M : LeftModule R) → AbGroup {ℓ}
LeftModule→AbGroup (leftmodule _ _ _ _ _ isLeftModule) =
abgroup _ _ _ _ (IsLeftModule.+-isAbGroup isLeftModule)
isSetLeftModule : (M : LeftModule R) → isSet ⟨ M ⟩
isSetLeftModule M = isSetAbGroup (LeftModule→AbGroup M)
open Ring R using (1r) renaming (_+_ to _+r_; _·_ to _·s_)
makeIsLeftModule : {M : Type ℓ} {0m : M}
{_+_ : M → M → M} { -_ : M → M} {_⋆_ : ⟨ R ⟩r → M → M}
(isSet-M : isSet M)
(+-assoc : (x y z : M) → x + (y + z) ≡ (x + y) + z)
(+-rid : (x : M) → x + 0m ≡ x)
(+-rinv : (x : M) → x + (- x) ≡ 0m)
(+-comm : (x y : M) → x + y ≡ y + x)
(⋆-assoc : (r s : ⟨ R ⟩r) (x : M) → (r ·s s) ⋆ x ≡ r ⋆ (s ⋆ x))
(⋆-ldist : (r s : ⟨ R ⟩r) (x : M) → (r +r s) ⋆ x ≡ (r ⋆ x) + (s ⋆ x))
(⋆-rdist : (r : ⟨ R ⟩r) (x y : M) → r ⋆ (x + y) ≡ (r ⋆ x) + (r ⋆ y))
(⋆-lid : (x : M) → 1r ⋆ x ≡ x)
→ IsLeftModule R 0m _+_ -_ _⋆_
makeIsLeftModule isSet-M
+-assoc +-rid +-rinv +-comm
⋆-assoc ⋆-ldist ⋆-rdist ⋆-lid =
ismodule (makeIsAbGroup isSet-M +-assoc +-rid +-rinv +-comm)
⋆-assoc ⋆-ldist ⋆-rdist ⋆-lid
record LeftModuleEquiv {R : Ring {ℓ}} (M N : LeftModule R) : Type ℓ where
constructor moduleiso
private
instance
_ : LeftModule R
_ = M
_ : LeftModule R
_ = N
open LeftModule {{...}}
field
e : ⟨ M ⟩ ≃ ⟨ N ⟩
isHom+ : (x y : ⟨ M ⟩) → equivFun e (x + y) ≡ equivFun e x + equivFun e y
comm⋆ : (r : ⟨ R ⟩r) (x : ⟨ M ⟩) → equivFun e (r ⋆ x) ≡ r ⋆ equivFun e x
module LeftModuleΣTheory (R : Ring {ℓ}) where
RawLeftModuleStructure = λ (M : Type ℓ) → (M → M → M) × (⟨ R ⟩r → M → M)
RawLeftModuleEquivStr = AutoEquivStr RawLeftModuleStructure
rawLeftModuleUnivalentStr : UnivalentStr _ RawLeftModuleEquivStr
rawLeftModuleUnivalentStr = autoUnivalentStr RawLeftModuleStructure
open Ring R using (_·_; 1r) renaming (_+_ to _+r_)
LeftModuleAxioms : (M : Type ℓ) (s : RawLeftModuleStructure M) → Type ℓ
LeftModuleAxioms M (_+_ , _⋆_) = AbGroupΣTheory.AbGroupAxioms M _+_
× ((r s : ⟨ R ⟩r) (x : M) → (r · s) ⋆ x ≡ r ⋆ (s ⋆ x))
× ((r s : ⟨ R ⟩r) (x : M) → (r +r s) ⋆ x ≡ (r ⋆ x) + (s ⋆ x))
× ((r : ⟨ R ⟩r) (x y : M) → r ⋆ (x + y) ≡ (r ⋆ x) + (r ⋆ y))
× ((x : M) → 1r ⋆ x ≡ x)
LeftModuleStructure : Type ℓ → Type ℓ
LeftModuleStructure = AxiomsStructure RawLeftModuleStructure LeftModuleAxioms
LeftModuleΣ : Type (ℓ-suc ℓ)
LeftModuleΣ = TypeWithStr ℓ LeftModuleStructure
LeftModuleEquivStr : StrEquiv LeftModuleStructure ℓ
LeftModuleEquivStr = AxiomsEquivStr RawLeftModuleEquivStr LeftModuleAxioms
open AbGroupΣTheory using (isSetAbGroupΣ)
isSetLeftModuleΣ : (M : LeftModuleΣ) → isSet _
isSetLeftModuleΣ (M , (_+_ , _) , (isAbGroup-M , _)) = isSetAbGroupΣ (M , _+_ , isAbGroup-M)
isPropLeftModuleAxioms : (M : Type ℓ) (s : RawLeftModuleStructure M)
→ isProp (LeftModuleAxioms M s)
isPropLeftModuleAxioms M (_+_ , _⋆_) =
isPropΣ (AbGroupΣTheory.isPropAbGroupAxioms M _+_)
λ isAbGroup-M →
isProp× (isPropΠ3 λ _ _ _ → (isSetAbGroupΣ (M , _+_ , isAbGroup-M)) _ _)
(isProp× (isPropΠ3 λ _ _ _ → (isSetAbGroupΣ (M , _+_ , isAbGroup-M)) _ _)
(isProp× (isPropΠ3 λ _ _ _ → (isSetAbGroupΣ (M , _+_ , isAbGroup-M)) _ _)
(isPropΠ λ _ → (isSetAbGroupΣ (M , _+_ , isAbGroup-M)) _ _)))
LeftModule→LeftModuleΣ : LeftModule R → LeftModuleΣ
LeftModule→LeftModuleΣ
(leftmodule M 0m _+_ -_ _⋆_ (ismodule +-isAbGroup ⋆-assoc ⋆-ldist ⋆-rdist ⋆-lid)) =
M , (_+_ , _⋆_) ,
AbGroupΣTheory.AbGroup→AbGroupΣ (abgroup _ _ _ _ +-isAbGroup) .snd .snd ,
⋆-assoc , ⋆-ldist , ⋆-rdist , ⋆-lid
LeftModuleΣ→LeftModule : LeftModuleΣ → LeftModule R
LeftModuleΣ→LeftModule (M , (_+_ , _⋆_) , isAbGroup-M , ⋆-assoc , ⋆-ldist , ⋆-rdist , ⋆-lid) =
let isAbGroup = AbGroupΣTheory.AbGroupΣ→AbGroup (_ , _ , isAbGroup-M ) .AbGroup.isAbGroup
in leftmodule M _ _+_ _ _⋆_
(ismodule isAbGroup ⋆-assoc ⋆-ldist ⋆-rdist ⋆-lid)
LeftModuleIsoLeftModuleΣ : Iso (LeftModule R) LeftModuleΣ
LeftModuleIsoLeftModuleΣ = iso LeftModule→LeftModuleΣ LeftModuleΣ→LeftModule
(λ _ → refl) helper
where
open AbGroupΣTheory
abgroup-helper : retract (AbGroup→AbGroupΣ {ℓ}) AbGroupΣ→AbGroup
abgroup-helper = Iso.leftInv AbGroupIsoAbGroupΣ
open LeftModule
open IsLeftModule
helper : _
Carrier (helper M i) = Carrier M
0m (helper M i) = 0m M
_+_ (helper M i) = _+_ M
-_ (helper M i) = -_ M
_⋆_ (helper M i) = _⋆_ M
+-isAbGroup (isLeftModule (helper M i)) =
AbGroup.isAbGroup (abgroup-helper (abgroup _ _ _ _ (+-isAbGroup M)) i)
⋆-assoc (isLeftModule (helper M i)) = ⋆-assoc M
⋆-ldist (isLeftModule (helper M i)) = ⋆-ldist M
⋆-rdist (isLeftModule (helper M i)) = ⋆-rdist M
⋆-lid (isLeftModule (helper M i)) = ⋆-lid M
leftModuleUnivalentStr : UnivalentStr LeftModuleStructure LeftModuleEquivStr
leftModuleUnivalentStr = axiomsUnivalentStr _ isPropLeftModuleAxioms rawLeftModuleUnivalentStr
LeftModuleΣPath : (M N : LeftModuleΣ) → (M ≃[ LeftModuleEquivStr ] N) ≃ (M ≡ N)
LeftModuleΣPath = SIP leftModuleUnivalentStr
LeftModuleEquivStrΣ : (M N : LeftModule R) → Type ℓ
LeftModuleEquivStrΣ M N = LeftModule→LeftModuleΣ M ≃[ LeftModuleEquivStr ] LeftModule→LeftModuleΣ N
LeftModuleEquivStrΣPath : {M N : LeftModule R} → Iso (LeftModuleEquiv M N) (LeftModuleEquivStrΣ M N)
fun LeftModuleEquivStrΣPath (moduleiso e isHom+ comm⋆) = e , isHom+ , comm⋆
inv LeftModuleEquivStrΣPath (e , isHom+ , comm⋆) = moduleiso e isHom+ comm⋆
rightInv LeftModuleEquivStrΣPath _ = refl
leftInv LeftModuleEquivStrΣPath _ = refl
LeftModulePath : (M N : LeftModule R) → (LeftModuleEquiv M N) ≃ (M ≡ N)
LeftModulePath M N =
LeftModuleEquiv M N ≃⟨ isoToEquiv LeftModuleEquivStrΣPath ⟩
LeftModuleEquivStrΣ M N ≃⟨ LeftModuleΣPath _ _ ⟩
LeftModule→LeftModuleΣ M ≡ LeftModule→LeftModuleΣ N ≃⟨ isoToEquiv
(invIso
(congIso
LeftModuleIsoLeftModuleΣ))
⟩
M ≡ N ■
LeftModulePath : {R : Ring {ℓ}} (M N : LeftModule R) → (LeftModuleEquiv M N) ≃ (M ≡ N)
LeftModulePath {ℓ} {R} = LeftModuleΣTheory.LeftModulePath R
|
Set Warnings "-notation-overridden".
Require Import Category.Lib.
Require Export Category.Theory.Functor.
Require Export Category.Construction.Comma.
Generalizable All Variables.
Set Primitive Projections.
Set Universe Polymorphism.
Unset Transparent Obligations.
Definition Arrow {C : Category} : Category := (Id[C] ↓ Id[C]).
Notation "C ⃗" := (@Arrow C) (at level 90) : category_scope.
|
Formal statement is: lemma Bseq_conv_Bfun: "Bseq X \<longleftrightarrow> Bfun X sequentially" Informal statement is: A sequence $x_n$ is bounded if and only if the function $n \mapsto x_n$ is bounded. |
Formal statement is: lemma eventually_subseq: "strict_mono r \<Longrightarrow> eventually P sequentially \<Longrightarrow> eventually (\<lambda>n. P (r n)) sequentially" Informal statement is: If $r$ is a strictly increasing sequence of natural numbers, and $P$ is an eventually true property of the natural numbers, then $P$ is also an eventually true property of $r$. |
module Replica.Command.Set
import Data.List
import Data.String
import Replica.Help
import Replica.Option.Parse
import Replica.Option.Types
import public Replica.Option.Filter
import public Replica.Option.Global
import Replica.Other.Decorated
import Language.JSON
%default total
public export
data TargetConfig = Local | Global
export
Show TargetConfig where
show Local = "Local"
show Global = "Global"
export
Eq TargetConfig where
Local == Local = True
Global == Global = True
_ == _ = False
public export
record Setter where
constructor MkSetter
key: String
value: JSON
export
Show Setter where
show (MkSetter key value) =
"MkSetter \{show key} \{show value}"
public export
record SetCommand' (f : Type -> Type) where
constructor MkSetCommand
target : f TargetConfig
setter : f Setter
public export
SetCommand : Type
SetCommand = Done SetCommand'
TyMap SetCommand' where
tyMap func x =
MkSetCommand (func x.target) (func x.setter)
TyTraversable SetCommand' where
tyTraverse func x =
[| MkSetCommand (func x.target) (func x.setter) |]
export
Show SetCommand where
show x = "MkSetCommand \{show x.target} (\{show x.setter})"
targetPart : Part (Builder SetCommand') TargetConfig
targetPart = inj $ MkOption
(toList1
[ MkMod (singleton "local") ['l'] (Left Local)
"Set a local config value (in `./.replica.json`) (default)"
, MkMod (singleton "global") ['g'] (Left Global)
"Set a global config value (in `$HOME/.replica.json`)"
])
Local
go
where
go : TargetConfig -> Builder SetCommand' -> Either String (Builder SetCommand')
go = ifSame target (\x => record {target = Right $ x})
(const $ const "Contradictory target")
setterPart : Part (Builder SetCommand') Setter
setterPart = inj $ MkParam1
"KEY=VALUE"
parseKV
go
where
go : Setter -> Builder SetCommand' -> Either String (Builder SetCommand')
go s x = Right $ record {setter = Right $ s} x
buildSetter : ConfigValue -> (String, String) -> Maybe Setter
buildSetter x = map (uncurry MkSetter) . jsonFor x
validateKV : String -> String -> Maybe Setter
validateKV x y with (strM x, strM y)
validateKV "" y | (StrNil, w) = Nothing
validateKV x (prim__strCons '=' t) | (w, StrCons '=' t) =
concatMap (flip buildSetter (x, t)) configValues
validateKV x y | (w, z) = Nothing
parseKV : String -> Maybe Setter
parseKV x = uncurry validateKV $ break (== '=') x
optParseSet : OptParse (Builder SetCommand') SetCommand
optParseSet =
[| MkSetCommand
(liftAp targetPart)
(liftAp setterPart)
|]
defaultSet : Default SetCommand'
defaultSet = MkSetCommand
(defaultPart targetPart)
(defaultPart setterPart)
export
parseSet : List1 String -> ParseResult SetCommand
parseSet ("set":::xs) = do
case parse (initBuilder $ defaultSet) optParseSet xs of
InvalidMix reason => InvalidMix reason
InvalidOption ys => InvalidMix $ "Unknown option: " ++ ys.head
Done builder => maybe (InvalidMix "No test file given") Done $ build builder
parseSet xs = InvalidOption xs
export
helpSet : Help
helpSet = record {lastWords = Just footer} baseCommand
where
baseCommand : Help
baseCommand = commandHelp {b = Builder SetCommand'}
"set" "Set a global configuration for replica commands"
(optParseSet)
(Just "KEY=VALUE")
footer : String
footer =
#"""
Available keys, and description:
replicaDir (or replica-dir, rDir) where replica stores internal information (default `./.replica`)
goldenDir (or golden-dir, gDir) where replica stores golden values (default `./.replica/tests`)
colour (or color) do we used colored output or not? (true or false, default `true`)
ascii do we keep away emojis or not? (true or false, default `false`)
diff command used to display diff
(known value: diff, git, native, other strings are considered as custom command)
(default: `native`)
log log level (default: `none`)
(known value: debug, info, warning, critical)
testFile (or jsonFile, test) the path of the test file to use (prefer a relative path)
(no default)
"""#
|
open import Algebra.Apartness using (HeytingField)
module Data.Real.Abstract.Bundles
c ℓ₁ ℓ₂ r
where
open import Relation.Binary using (Rel)
open import Data.Real.Abstract.Structures
open import Level using (_⊔_; suc)
record OrderedHeytingField : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂ ⊔ r)) where
field
f : HeytingField c ℓ₁ ℓ₂
open HeytingField f public
field
_<_ : Rel Carrier r
isOrderedHeytingField : IsOrderedHeytingField f _<_
record ArchimedanHeytingField : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂ ⊔ r)) where
field
f : HeytingField c ℓ₁ ℓ₂
open HeytingField f public
field
_<_ : Rel Carrier r
isArchimedanHeytingField : IsArchimedanHeytingField f _<_
|
Require Import Ashley.Axioms.
Require Import Ashley.PartialOrder.
Require Import Ashley.Set.
Require Import Ashley.Category.
(* set_type takes a set and turns it into a type *)
Inductive set_type {A:Type} (s:A -> Type) : Type :=
stc : forall (x:A), s x -> set_type s.
Definition val {A: Type} {s: A -> Type} (sv: set_type s): A.
destruct sv.
exact x.
Defined.
Definition stc' : forall {A:Type} {s:A -> Type} (x:A), s x -> set_type s.
intros.
apply (stc s x X).
Defined.
Lemma val_stc: forall {A:Type} (s:A -> Type) (v:A) (st:s v), val (stc s v st) = v.
unfold val.
trivial.
Qed.
Definition struct {A} {s:A -> Type} (st:set_type s): s (val st).
unfold val.
destruct st.
exact s0.
Defined.
(*
Inductive same (A B: Type) (a:A) (b:B): Type:=
is_same: forall (T:Type) (a' b':A), a' = b' -> same T T a' b'.
*)
Definition converter: forall {T:Type} {A B: T} {f: T -> Type}, (A = B) -> f A -> f B.
intros.
rewrite <- H.
exact X.
Defined.
Lemma converter_eq: forall {T} {A} {f: T -> Type} {proof} (x: f A), converter proof x = x.
intros.
unfold converter. unfold eq_rect.
cut (proof = eq_refl).
intro.
rewrite H.
trivial.
apply proof_irrelevance.
Qed.
Lemma exist_ext: forall {A} (s: A -> Type) (p q: set_type s) (proof: val p = val q),
((converter proof (struct p)) = struct q) -> p = q.
intros.
destruct p.
destruct q.
unfold val in proof.
subst x.
unfold converter in H.
unfold struct in H.
unfold val in H.
unfold eq_rect in H.
rewrite H.
trivial.
Defined.
Lemma set_type_ext: forall {A} (s: A -> Prop) (p q: set_type s), (val p = val q) -> p = q.
intros.
apply (exist_ext s p q H).
apply proof_irrelevance.
Defined.
Lemma set_type_ext_eq: forall {A} (s: A -> Prop) (p q: set_type s), (val p = val q) = (p = q).
intros.
apply prop_ext. split.
apply set_type_ext.
intros.
rewrite H.
trivial.
Qed.
Variable Te : Type.
Variable Ve : Te.
Definition Se : set Te := fun x => x = Ve.
Definition eConstruct: set_type Se.
apply (stc Se Ve).
unfold Se.
trivial.
Defined.
Lemma eCheck: val eConstruct = Ve.
unfold eConstruct.
unfold val.
trivial.
Qed.
Instance subset_category A : Category (set A) :=
{
hom sA sB := set_type sA -> set_type sB;
id A := (fun p => p);
compose A B C mbc mab a := mbc (mab a)
}.
intros.
apply fun_ext.
trivial.
intros.
apply fun_ext.
trivial.
intros.
apply fun_ext.
trivial.
Defined.
Lemma not_in_empty : forall A, forall a : set_type (empty : set A), False.
firstorder.
Qed.
Lemma subset_transitive : forall {A} {a b c: set A}, b <= c -> a <= b -> a <= c.
unfold subset.
intro.
intro.
intro.
intro.
apply within_trans.
Qed.
Instance inclusion_Preorder {A} (open : set (set A)) : Preorder (set_type open) :=
{
within sv1 sv2 := (val sv1) <= (val sv2)
}.
intros.
apply within_reflex.
intros.
apply (within_trans (val p) (val q) (val r)).
exact H.
exact H0.
Defined.
Instance inclusion_PartialOrder {A} (open : set (set A)) : PartialOrder (set_type open) :=
{
}.
intros.
apply set_type_ext.
apply within_antisym.
exact H.
exact H0.
Defined.
Definition inclusion_category {A} (open : set (set A)) : Category (set_type open) :=
Preorder_Category (inclusion_Preorder open).
Definition subset_type {A} (s : set A) : Type := set_type (superset s).
|
State Before: α : Type u_2
R : Type u_1
l : Filter α
f✝ : α → R
r : R
inst✝¹ : LinearOrderedCancelAddCommMonoid R
inst✝ : Archimedean R
f : α → ℕ
hr : 0 < r
hf : Tendsto f l atTop
⊢ Tendsto (fun x => f x • r) l atTop State After: α : Type u_2
R : Type u_1
l : Filter α
f✝ : α → R
r : R
inst✝¹ : LinearOrderedCancelAddCommMonoid R
inst✝ : Archimedean R
f : α → ℕ
hr : 0 < r
hf : Tendsto f l atTop
s : R
⊢ ∀ᶠ (a : α) in l, s ≤ f a • r Tactic: refine' tendsto_atTop.mpr fun s => _ State Before: α : Type u_2
R : Type u_1
l : Filter α
f✝ : α → R
r : R
inst✝¹ : LinearOrderedCancelAddCommMonoid R
inst✝ : Archimedean R
f : α → ℕ
hr : 0 < r
hf : Tendsto f l atTop
s : R
⊢ ∀ᶠ (a : α) in l, s ≤ f a • r State After: case intro
α : Type u_2
R : Type u_1
l : Filter α
f✝ : α → R
r : R
inst✝¹ : LinearOrderedCancelAddCommMonoid R
inst✝ : Archimedean R
f : α → ℕ
hr : 0 < r
hf : Tendsto f l atTop
s : R
n : ℕ
hn : s ≤ n • r
⊢ ∀ᶠ (a : α) in l, s ≤ f a • r Tactic: obtain ⟨n : ℕ, hn : s ≤ n • r⟩ := Archimedean.arch s hr State Before: case intro
α : Type u_2
R : Type u_1
l : Filter α
f✝ : α → R
r : R
inst✝¹ : LinearOrderedCancelAddCommMonoid R
inst✝ : Archimedean R
f : α → ℕ
hr : 0 < r
hf : Tendsto f l atTop
s : R
n : ℕ
hn : s ≤ n • r
⊢ ∀ᶠ (a : α) in l, s ≤ f a • r State After: no goals Tactic: exact (tendsto_atTop.mp hf n).mono fun a ha => hn.trans (nsmul_le_nsmul hr.le ha) |
Formal statement is: lemma Lim_at_zero: fixes a :: "'a::real_normed_vector" and l :: "'b::topological_space" shows "(f \<longlongrightarrow> l) (at a) \<longleftrightarrow> ((\<lambda>x. f(a + x)) \<longlongrightarrow> l) (at 0)" Informal statement is: If $f$ converges to $l$ at $a$, then $f(a + x)$ converges to $l$ at $0$. |
lemma complete_closed_subset: fixes S :: "'a::metric_space set" assumes "closed S" and "S \<subseteq> t" and "complete t" shows "complete S" |
[STATEMENT]
lemma "dist a d \<le> dist a b + dist b c + dist c d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. dist a d \<le> dist a b + dist b c + dist c d
[PROOF STEP]
by metric |
lemma islimpt_insert: fixes x :: "'a::t1_space" shows "x islimpt (insert a s) \<longleftrightarrow> x islimpt s" |
section "Projection functions for automata"
theory AutoProj
imports Main
begin
definition start :: "'a * 'b * 'c \<Rightarrow> 'a" where "start A = fst A"
definition "next" :: "'a * 'b * 'c \<Rightarrow> 'b" where "next A = fst(snd(A))"
definition fin :: "'a * 'b * 'c \<Rightarrow> 'c" where "fin A = snd(snd(A))"
lemma [simp]: "next(q,d,f) = d"
by(simp add:next_def)
lemma [simp]: "fin(q,d,f) = f"
by(simp add:fin_def)
end
|
[STATEMENT]
lemma GTT_trancl_complete:
"(gtt_lang G)\<^sup>+ \<subseteq> gtt_lang (GTT_trancl G)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (gtt_lang G)\<^sup>+ \<subseteq> gtt_lang (GTT_trancl G)
[PROOF STEP]
using GTT_trancl_base subset_trans[OF gtt_comp_lang_complete GTT_trancl_trans]
[PROOF STATE]
proof (prove)
using this:
gtt_lang ?G \<subseteq> gtt_lang (GTT_trancl ?G)
gtt_lang (GTT_trancl ?G1) O gtt_lang (GTT_trancl ?G1) \<subseteq> gtt_lang (GTT_trancl ?G1)
goal (1 subgoal):
1. (gtt_lang G)\<^sup>+ \<subseteq> gtt_lang (GTT_trancl G)
[PROOF STEP]
by (metis trancl_id trancl_mono_set trans_O_iff) |
library(lattice)
d = data.frame(iris)
d
xyplot(Rural.Male~Rural.Female,data=d)
splom(iris[1:3],data=d)
cloud(d$Sepal.Length~d$Sepal.Width*d$Petal.Length|Species, data=iris)
dotplot(d$Sepal.Length~d$Sepal.Width,data=iris)
histogram(d$Sepal.Length~d$Sepal.Width,data=iris,col=rainbow(55:10))
|
module Ex8
import Decidable.Equality
import Data.Nat
import Data.Vect
%default total
same_cons : { xs : List a } -> { ys : List a } -> xs = ys -> x :: xs = x :: ys
same_cons Refl = Refl
same_lists : { xs : List a } -> { ys : List a } -> x = y -> xs = ys -> x :: xs = y :: ys
same_lists Refl Refl = Refl
data ThreeEq : a -> b -> c -> Type where
AllSame : ThreeEq x x x
allSameS : (x, y, z : Nat) -> ThreeEq x y z -> ThreeEq (S x) (S y) (S z)
allSameS _ _ _ AllSame = AllSame
myPlusCommutes : (n : Nat) -> (m : Nat) -> n + m = m + n
myPlusCommutes Z m = rewrite plusZeroRightNeutral m in Refl
myPlusCommutes (S k) m = rewrite myPlusCommutes k m in
rewrite plusSuccRightSucc m k in Refl
reverseProof_nil : Vect n a -> Vect (plus n 0) a
reverseProof_nil {n} xs = rewrite plusZeroRightNeutral n in xs
reverseProof_xs : Vect (S n + k) a -> Vect (plus n (S k)) a
reverseProof_xs {n} {k} xs = rewrite sym (plusSuccRightSucc n k) in xs
myReverse : Vect n a -> Vect n a
myReverse xs = reverse' [] xs where
reverse' : forall n, m. Vect n a -> Vect m a -> Vect (n + m) a
reverse' acc [] = reverseProof_nil acc
reverse' acc (x :: xs) = reverseProof_xs (reverse' (x :: acc) xs)
headUnequal : DecEq a => { xs : Vect n a } -> { ys : Vect n a } ->
(contra : (x = y) -> Void) -> ((x :: xs) = (y :: ys)) -> Void
headUnequal contra Refl = contra Refl
tailUnequal : DecEq a => { xs : Vect n a } -> { ys : Vect n a } ->
(contra : (xs = ys) -> Void) -> ((x :: xs) = (y :: ys)) -> Void
tailUnequal contra Refl = contra Refl
|
import Data.Vect
%unbound_implicits off
append : forall n, m, a . Vect n a -> Vect m a -> Vect (n + m) a
append [] ys = ys
append (x :: xs) ys = x :: append xs ys
data Env : forall n . Vect n Type -> Type where
ENil : Env []
ECons : forall t, ts . t -> Env ts -> Env (t :: ts)
-- fine because the only name used in bound, and it'll infer types for
-- xs and its indices
len : forall xs . Env xs -> Nat
-- neither of these are fine
len': Env xs -> Nat
append' : Vect n a -> Vect m a -> Vect (n + m) a
|
-- @@stderr --
dtrace: failed to compile script test/unittest/probes/err.D_PDESC_ZERO.probestar.d: [D_PDESC_ZERO] line 21: probe description :::no_such_dtrace_probe* does not match any probes
|
/- TACTICS -/
namespace TBA
-- definitions from last week
-- NOTE: We renamed it from `Nat'` for consistency. The new namespace makes sure we don't use the
-- standard library `Nat`.
inductive Nat : Type
| zero : Nat
| succ (n : Nat) : Nat
open Nat
def add (m n : Nat) : Nat :=
match n with
| zero => m
| succ n => succ (add m n)
-- With this command we add a notation for `add`. From now on we will be able to write `m + n` for
-- `add m n`. The 65 denotes how strongly the operator should bind to what's adjacent to it.
-- The `priority` means that Lean will prefer it over the built-in `+`.
infix:65 (priority := high) " + " => add
def mul (m n : Nat) : Nat :=
match n with
| zero => zero
| succ n => (mul m n) + m
-- We also want a notation for `mul`, with a higher binding strength than addition so that
-- `a + b * c` means `a + (b * c`)`.
infix:70 (priority := high) " * " => mul
inductive LE : Nat → Nat → Prop where
| refl (n : Nat) : LE n n
| succ : LE m n → LE m (succ n)
-- lower binding strength than either addition or multiplication
infix:50 (priority := high) " ≤ " => LE
-- Let's start by reproving some theorems from last week, but this time with tactics!
-- useful tactics:
-- * `induction ... with ...`
-- * `simp only [f]` to unfold applications of a function `f`
-- * `rw [h]` to rewrite every `a` to `b` if `h : a = b`
-- * `apply/exact`
-- * `simp/simp_all`... are powerful and basically always useful, though make sure that you could also
-- do the proof without them
theorem zero_add : zero + n = n := by
induction n with
| zero =>
| succ n ih =>
theorem le_add : m ≤ m + n := by
-- Alright, let's start automating more!
attribute [simp] add mul
-- These definitions will now automatically be unfolded when you use `simp/simp_all`
-- This one is a bit more tricky, you might need to prove a helper lemma!
theorem add_comm : n + m = m + n := by
-- Associativity can be proven in a similar way.
theorem add_assoc : (m + n) + k = m + (n + k) := by
def one := succ zero
theorem mul_one : m * one = m := by
-- To prove associativity of multiplication, you might have to come up with
-- some more lemmas about multiplication first. Some are similar to the above laws of
-- addition, some use both addition and multiplication ("distributivity" is the keyword).
theorem mul_assoc : (m * n) * k = m * (n * k) := by
-- Remember the structures for semigroups and monoids which we defined last week?
structure Semigroup (α : Type) where
mul : α → α → α
assoc : mul (mul a b) c = mul a (mul b c)
structure Monoid (α : Type) extends Semigroup α where
e : α
e_mul : mul e a = a
mul_e : mul a e = a
-- You should now be able to instantiate two of them, including proofs!
def Nat_add_Monoid : Monoid Nat := _
def Nat_mul_Monoid : Monoid Nat := _
|
module EqNat
%default total
data EqNat : (num1 : Nat) -> (num2 : Nat) -> Type where
Same : (num : Nat) -> EqNat num num
sameS : (eq : EqNat k j) -> EqNat (S k) (S j)
sameS (Same k) = Same (S k)
checkEqNat : (num1 : Nat) -> (num2 : Nat) -> Maybe (EqNat num1 num2)
checkEqNat Z Z = Just (Same Z)
checkEqNat Z _ = Nothing
checkEqNat _ Z = Nothing
checkEqNat (S k) (S l) = case checkEqNat k l of
Nothing => Nothing
Just eq => Just (sameS eq)
|
Formal statement is: lemma open_closed: "open S \<longleftrightarrow> closed (- S)" Informal statement is: A set is open if and only if its complement is closed. |
[STATEMENT]
lemma eqButUIDl_trans:
assumes "eqButUIDl uid uidl uidl1" and "eqButUIDl uid uidl1 uidl2"
shows "eqButUIDl uid uidl uidl2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. eqButUIDl uid uidl uidl2
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
eqButUIDl uid uidl uidl1
eqButUIDl uid uidl1 uidl2
goal (1 subgoal):
1. eqButUIDl uid uidl uidl2
[PROOF STEP]
by auto |
/- TACTICS -/
namespace TBA
-- definitions from last week
-- NOTE: We renamed it from `Nat'` for consistency. The new namespace makes sure we don't use the
-- standard library `Nat`.
inductive Nat : Type where
| zero : Nat
| succ (n : Nat) : Nat
open Nat
def add (m n : Nat) : Nat :=
match n with
| zero => m
| succ n => succ (add m n)
-- With this command we add a notation for `add`. From now on we will be able to write `m + n` for
-- `add m n`. The 65 denotes how strongly the operator should bind to what's adjacent to it.
-- The `priority` means that Lean will prefer it over the built-in `+`.
infix:65 (priority := high) " + " => add
def mul (m n : Nat) : Nat :=
match n with
| zero => zero
| succ n => (mul m n) + m
-- We also want a notation for `mul`, with a higher binding strength than addition so that
-- `a + b * c` means `a + (b * c`)`.
infix:70 (priority := high) " * " => mul
inductive LE : Nat → Nat → Prop where
| refl (n : Nat) : LE n n
| succ : LE m n → LE m (succ n)
-- lower binding strength than either addition or multiplication
infix:50 (priority := high) " ≤ " => LE
-- Let's start by reproving some theorems from last week, but this time with tactics!
-- useful tactics:
-- * `induction ... with ...`
-- * `rw [f]` to unfold applications of a function `f`
-- * `rw [h]` to rewrite every `a` to `b` if `h : a = b`
-- * `apply/exact`
-- * `simp/simp_all`... are powerful and basically always useful, though make sure that you could also
-- do the proof without them
theorem zero_add : zero + n = n := by
induction n with
| zero =>
| succ n ih =>
theorem le_add : m ≤ m + n := by
-- Alright, let's start automating more!
attribute [simp] add mul
-- These definitions will now automatically be unfolded when you use `simp/simp_all`
-- This one is a bit more tricky, you might need to prove a helper lemma!
theorem add_comm : n + m = m + n := by
-- Associativity can be proven in a similar way.
theorem add_assoc : (m + n) + k = m + (n + k) := by
def one := succ zero
theorem mul_one : m * one = m := by
-- To prove associativity of multiplication, you might have to come up with
-- some more lemmas about multiplication first. Some are similar to the above laws of
-- addition, some use both addition and multiplication ("distributivity" is the keyword).
theorem mul_assoc : (m * n) * k = m * (n * k) := by
-- Remember the structures for semigroups and monoids which we defined last week?
structure Semigroup (α : Type) where
mul : α → α → α
assoc : mul (mul a b) c = mul a (mul b c)
structure Monoid (α : Type) extends Semigroup α where
e : α
e_mul : mul e a = a
mul_e : mul a e = a
-- You should now be able to instantiate two of them, including proofs!
def Nat_add_Monoid : Monoid Nat := _
def Nat_mul_Monoid : Monoid Nat := _
end TBA
|
/-
Copyright (c) 2019 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison, Bhavik Mehta
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.category_theory.monad.adjunction
import Mathlib.category_theory.adjunction.limits
import Mathlib.category_theory.limits.preserves.shapes.terminal
import Mathlib.PostPort
universes u₁ v₁ u₂
namespace Mathlib
namespace category_theory
namespace monad
namespace forget_creates_limits
/-- (Impl) The natural transformation used to define the new cone -/
@[simp] theorem γ_app {C : Type u₁} [category C] {T : C ⥤ C} [monad T] {J : Type v₁} [small_category J] (D : J ⥤ algebra T) (j : J) : nat_trans.app (γ D) j = algebra.a (functor.obj D j) :=
Eq.refl (nat_trans.app (γ D) j)
/-- (Impl) This new cone is used to construct the algebra structure -/
@[simp] theorem new_cone_X {C : Type u₁} [category C] {T : C ⥤ C} [monad T] {J : Type v₁} [small_category J] (D : J ⥤ algebra T) (c : limits.cone (D ⋙ forget T)) : limits.cone.X (new_cone D c) = functor.obj T (limits.cone.X c) :=
Eq.refl (limits.cone.X (new_cone D c))
/-- The algebra structure which will be the apex of the new limit cone for `D`. -/
@[simp] theorem cone_point_A {C : Type u₁} [category C] {T : C ⥤ C} [monad T] {J : Type v₁} [small_category J] (D : J ⥤ algebra T) (c : limits.cone (D ⋙ forget T)) (t : limits.is_limit c) : algebra.A (cone_point D c t) = limits.cone.X c :=
Eq.refl (algebra.A (cone_point D c t))
/-- (Impl) Construct the lifted cone in `algebra T` which will be limiting. -/
@[simp] theorem lifted_cone_X {C : Type u₁} [category C] {T : C ⥤ C} [monad T] {J : Type v₁} [small_category J] (D : J ⥤ algebra T) (c : limits.cone (D ⋙ forget T)) (t : limits.is_limit c) : limits.cone.X (lifted_cone D c t) = cone_point D c t :=
Eq.refl (limits.cone.X (lifted_cone D c t))
/-- (Impl) Prove that the lifted cone is limiting. -/
def lifted_cone_is_limit {C : Type u₁} [category C] {T : C ⥤ C} [monad T] {J : Type v₁} [small_category J] (D : J ⥤ algebra T) (c : limits.cone (D ⋙ forget T)) (t : limits.is_limit c) : limits.is_limit (lifted_cone D c t) :=
limits.is_limit.mk fun (s : limits.cone D) => algebra.hom.mk (limits.is_limit.lift t (functor.map_cone (forget T) s))
end forget_creates_limits
-- Theorem 5.6.5 from [Riehl][riehl2017]
/-- The forgetful functor from the Eilenberg-Moore category creates limits. -/
protected instance forget_creates_limits {C : Type u₁} [category C] {T : C ⥤ C} [monad T] : creates_limits (forget T) :=
creates_limits.mk
fun (J : Type v₁) (𝒥 : small_category J) =>
creates_limits_of_shape.mk
fun (D : J ⥤ algebra T) =>
creates_limit_of_reflects_iso
fun (c : limits.cone (D ⋙ forget T)) (t : limits.is_limit c) =>
lifts_to_limit.mk
(liftable_cone.mk sorry
(limits.cones.ext (iso.refl (limits.cone.X (functor.map_cone (forget T) sorry))) sorry))
sorry
/-- `D ⋙ forget T` has a limit, then `D` has a limit. -/
theorem has_limit_of_comp_forget_has_limit {C : Type u₁} [category C] {T : C ⥤ C} [monad T] {J : Type v₁} [small_category J] (D : J ⥤ algebra T) [limits.has_limit (D ⋙ forget T)] : limits.has_limit D :=
has_limit_of_created D (forget T)
namespace forget_creates_colimits
-- Let's hide the implementation details in a namespace
-- We have a diagram D of shape J in the category of algebras, and we assume that we are given a
-- colimit for its image D ⋙ forget T under the forgetful functor, say its apex is L.
-- We'll construct a colimiting coalgebra for D, whose carrier will also be L.
-- To do this, we must find a map TL ⟶ L. Since T preserves colimits, TL is also a colimit.
-- In particular, it is a colimit for the diagram `(D ⋙ forget T) ⋙ T`
-- so to construct a map TL ⟶ L it suffices to show that L is the apex of a cocone for this diagram.
-- In other words, we need a natural transformation from const L to `(D ⋙ forget T) ⋙ T`.
-- But we already know that L is the apex of a cocone for the diagram `D ⋙ forget T`, so it
-- suffices to give a natural transformation `((D ⋙ forget T) ⋙ T) ⟶ (D ⋙ forget T)`:
/--
(Impl)
The natural transformation given by the algebra structure maps, used to construct a cocone `c` with
apex `colimit (D ⋙ forget T)`.
-/
@[simp] theorem γ_app {C : Type u₁} [category C] {T : C ⥤ C} [monad T] {J : Type v₁} [small_category J] {D : J ⥤ algebra T} (j : J) : nat_trans.app γ j = algebra.a (functor.obj D j) :=
Eq.refl (nat_trans.app γ j)
/--
(Impl)
A cocone for the diagram `(D ⋙ forget T) ⋙ T` found by composing the natural transformation `γ`
with the colimiting cocone for `D ⋙ forget T`.
-/
@[simp] theorem new_cocone_X {C : Type u₁} [category C] {T : C ⥤ C} [monad T] {J : Type v₁} [small_category J] {D : J ⥤ algebra T} (c : limits.cocone (D ⋙ forget T)) : limits.cocone.X (new_cocone c) = limits.cocone.X c :=
Eq.refl (limits.cocone.X (new_cocone c))
/--
(Impl)
Define the map `λ : TL ⟶ L`, which will serve as the structure of the coalgebra on `L`, and
we will show is the colimiting object. We use the cocone constructed by `c` and the fact that
`T` preserves colimits to produce this morphism.
-/
def lambda {C : Type u₁} [category C] {T : C ⥤ C} [monad T] {J : Type v₁} [small_category J] {D : J ⥤ algebra T} (c : limits.cocone (D ⋙ forget T)) (t : limits.is_colimit c) [limits.preserves_colimit (D ⋙ forget T) T] : limits.cocone.X (functor.map_cocone T c) ⟶ limits.cocone.X c :=
limits.is_colimit.desc (limits.preserves_colimit.preserves t) (new_cocone c)
/-- (Impl) The key property defining the map `λ : TL ⟶ L`. -/
theorem commuting {C : Type u₁} [category C] {T : C ⥤ C} [monad T] {J : Type v₁} [small_category J] {D : J ⥤ algebra T} (c : limits.cocone (D ⋙ forget T)) (t : limits.is_colimit c) [limits.preserves_colimit (D ⋙ forget T) T] (j : J) : functor.map T (nat_trans.app (limits.cocone.ι c) j) ≫ lambda c t =
algebra.a (functor.obj D j) ≫ nat_trans.app (limits.cocone.ι c) j :=
limits.is_colimit.fac (limits.preserves_colimit.preserves t) (new_cocone c) j
/--
(Impl)
Construct the colimiting algebra from the map `λ : TL ⟶ L` given by `lambda`. We are required to
show it satisfies the two algebra laws, which follow from the algebra laws for the image of `D` and
our `commuting` lemma.
-/
@[simp] theorem cocone_point_A {C : Type u₁} [category C] {T : C ⥤ C} [monad T] {J : Type v₁} [small_category J] {D : J ⥤ algebra T} (c : limits.cocone (D ⋙ forget T)) (t : limits.is_colimit c) [limits.preserves_colimit (D ⋙ forget T) T] [limits.preserves_colimit ((D ⋙ forget T) ⋙ T) T] : algebra.A (cocone_point c t) = limits.cocone.X c :=
Eq.refl (algebra.A (cocone_point c t))
/-- (Impl) Construct the lifted cocone in `algebra T` which will be colimiting. -/
@[simp] theorem lifted_cocone_X {C : Type u₁} [category C] {T : C ⥤ C} [monad T] {J : Type v₁} [small_category J] {D : J ⥤ algebra T} (c : limits.cocone (D ⋙ forget T)) (t : limits.is_colimit c) [limits.preserves_colimit (D ⋙ forget T) T] [limits.preserves_colimit ((D ⋙ forget T) ⋙ T) T] : limits.cocone.X (lifted_cocone c t) = cocone_point c t :=
Eq.refl (limits.cocone.X (lifted_cocone c t))
/-- (Impl) Prove that the lifted cocone is colimiting. -/
@[simp] theorem lifted_cocone_is_colimit_desc_f {C : Type u₁} [category C] {T : C ⥤ C} [monad T] {J : Type v₁} [small_category J] {D : J ⥤ algebra T} (c : limits.cocone (D ⋙ forget T)) (t : limits.is_colimit c) [limits.preserves_colimit (D ⋙ forget T) T] [limits.preserves_colimit ((D ⋙ forget T) ⋙ T) T] (s : limits.cocone D) : algebra.hom.f (limits.is_colimit.desc (lifted_cocone_is_colimit c t) s) =
limits.is_colimit.desc t (functor.map_cocone (forget T) s) :=
Eq.refl (algebra.hom.f (limits.is_colimit.desc (lifted_cocone_is_colimit c t) s))
end forget_creates_colimits
-- TODO: the converse of this is true as well
/--
The forgetful functor from the Eilenberg-Moore category for a monad creates any colimit
which the monad itself preserves.
-/
protected instance forget_creates_colimit {C : Type u₁} [category C] {T : C ⥤ C} [monad T] {J : Type v₁} [small_category J] (D : J ⥤ algebra T) [limits.preserves_colimit (D ⋙ forget T) T] [limits.preserves_colimit ((D ⋙ forget T) ⋙ T) T] : creates_colimit D (forget T) :=
creates_colimit_of_reflects_iso
fun (c : limits.cocone (D ⋙ forget T)) (t : limits.is_colimit c) =>
lifts_to_colimit.mk
(liftable_cocone.mk
(limits.cocone.mk (forget_creates_colimits.cocone_point c t)
(nat_trans.mk fun (j : J) => algebra.hom.mk (nat_trans.app (limits.cocone.ι c) j)))
(limits.cocones.ext
(iso.refl
(limits.cocone.X
(functor.map_cocone (forget T)
(limits.cocone.mk (forget_creates_colimits.cocone_point c t)
(nat_trans.mk fun (j : J) => algebra.hom.mk (nat_trans.app (limits.cocone.ι c) j))))))
sorry))
(forget_creates_colimits.lifted_cocone_is_colimit c t)
protected instance forget_creates_colimits_of_shape {C : Type u₁} [category C] {T : C ⥤ C} [monad T] {J : Type v₁} [small_category J] [limits.preserves_colimits_of_shape J T] : creates_colimits_of_shape J (forget T) :=
creates_colimits_of_shape.mk fun (K : J ⥤ algebra T) => monad.forget_creates_colimit K
protected instance forget_creates_colimits {C : Type u₁} [category C] {T : C ⥤ C} [monad T] [limits.preserves_colimits T] : creates_colimits (forget T) :=
creates_colimits.mk fun (J : Type v₁) (𝒥₁ : small_category J) => monad.forget_creates_colimits_of_shape
/--
For `D : J ⥤ algebra T`, `D ⋙ forget T` has a colimit, then `D` has a colimit provided colimits
of shape `J` are preserved by `T`.
-/
theorem forget_creates_colimits_of_monad_preserves {C : Type u₁} [category C] {T : C ⥤ C} [monad T] {J : Type v₁} [small_category J] [limits.preserves_colimits_of_shape J T] (D : J ⥤ algebra T) [limits.has_colimit (D ⋙ forget T)] : limits.has_colimit D :=
has_colimit_of_created D (forget T)
end monad
protected instance comp_comparison_forget_has_limit {C : Type u₁} [category C] {D : Type u₂} [category D] {J : Type v₁} [small_category J] (F : J ⥤ D) (R : D ⥤ C) [monadic_right_adjoint R] [limits.has_limit (F ⋙ R)] : limits.has_limit ((F ⋙ monad.comparison R) ⋙ monad.forget (left_adjoint R ⋙ R)) :=
limits.has_limit_of_iso (iso_whisker_left F (iso.symm (monad.comparison_forget R)))
protected instance comp_comparison_has_limit {C : Type u₁} [category C] {D : Type u₂} [category D] {J : Type v₁} [small_category J] (F : J ⥤ D) (R : D ⥤ C) [monadic_right_adjoint R] [limits.has_limit (F ⋙ R)] : limits.has_limit (F ⋙ monad.comparison R) :=
monad.has_limit_of_comp_forget_has_limit (F ⋙ monad.comparison R)
/-- Any monadic functor creates limits. -/
def monadic_creates_limits {C : Type u₁} [category C] {D : Type u₂} [category D] (R : D ⥤ C) [monadic_right_adjoint R] : creates_limits R :=
creates_limits_of_nat_iso (monad.comparison_forget R)
/--
The forgetful functor from the Eilenberg-Moore category for a monad creates any colimit
which the monad itself preserves.
-/
def monadic_creates_colimit_of_preserves_colimit {C : Type u₁} [category C] {D : Type u₂} [category D] {J : Type v₁} [small_category J] (R : D ⥤ C) (K : J ⥤ D) [monadic_right_adjoint R] [limits.preserves_colimit (K ⋙ R) (left_adjoint R ⋙ R)] [limits.preserves_colimit ((K ⋙ R) ⋙ left_adjoint R ⋙ R) (left_adjoint R ⋙ R)] : creates_colimit K R :=
creates_colimit_of_nat_iso (monad.comparison_forget R)
/-- A monadic functor creates any colimits of shapes it preserves. -/
def monadic_creates_colimits_of_shape_of_preserves_colimits_of_shape {C : Type u₁} [category C] {D : Type u₂} [category D] {J : Type v₁} [small_category J] (R : D ⥤ C) [monadic_right_adjoint R] [limits.preserves_colimits_of_shape J R] : creates_colimits_of_shape J R :=
creates_colimits_of_shape_of_nat_iso (monad.comparison_forget R)
/-- A monadic functor creates colimits if it preserves colimits. -/
def monadic_creates_colimits_of_preserves_colimits {C : Type u₁} [category C] {D : Type u₂} [category D] (R : D ⥤ C) [monadic_right_adjoint R] [limits.preserves_colimits R] : creates_colimits R :=
creates_colimits.mk
fun (J : Type v₁) (𝒥₁ : small_category J) => monadic_creates_colimits_of_shape_of_preserves_colimits_of_shape R
theorem has_limit_of_reflective {C : Type u₁} [category C] {D : Type u₂} [category D] {J : Type v₁} [small_category J] (F : J ⥤ D) (R : D ⥤ C) [limits.has_limit (F ⋙ R)] [reflective R] : limits.has_limit F :=
has_limit_of_created F R
/-- If `C` has limits of shape `J` then any reflective subcategory has limits of shape `J`. -/
theorem has_limits_of_shape_of_reflective {C : Type u₁} [category C] {D : Type u₂} [category D] {J : Type v₁} [small_category J] [limits.has_limits_of_shape J C] (R : D ⥤ C) [reflective R] : limits.has_limits_of_shape J D :=
limits.has_limits_of_shape.mk fun (F : J ⥤ D) => has_limit_of_reflective F R
/-- If `C` has limits then any reflective subcategory has limits. -/
theorem has_limits_of_reflective {C : Type u₁} [category C] {D : Type u₂} [category D] (R : D ⥤ C) [limits.has_limits C] [reflective R] : limits.has_limits D :=
limits.has_limits.mk fun (J : Type v₁) (𝒥₁ : small_category J) => has_limits_of_shape_of_reflective R
/--
The reflector always preserves terminal objects. Note this in general doesn't apply to any other
limit.
-/
def left_adjoint_preserves_terminal_of_reflective {C : Type u₁} [category C] {D : Type u₂} [category D] (R : D ⥤ C) [reflective R] [limits.has_terminal C] : limits.preserves_limits_of_shape (discrete pempty) (left_adjoint R) :=
limits.preserves_limits_of_shape.mk
fun (K : discrete pempty ⥤ C) =>
let _inst : limits.has_terminal D := sorry;
let _inst_3 : creates_limits R := monadic_creates_limits R;
let _inst_6 : limits.preserves_limit (functor.empty D) R :=
category_theory.preserves_limit_of_creates_limit_and_has_limit (functor.empty D) R;
let _inst_7 : limits.preserves_limit (functor.empty C) (left_adjoint R) :=
limits.preserves_terminal_of_iso (left_adjoint R)
(functor.map_iso (left_adjoint R) (iso.symm (limits.preserves_terminal.iso R)) ≪≫
as_iso (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint R)) (⊤_D)));
limits.preserves_limit_of_iso_diagram (left_adjoint R) (iso.symm (functor.unique_from_empty K))
|
[STATEMENT]
lemma (in wf_digraph) sccs_verts_subsets: "S \<in> sccs_verts \<Longrightarrow> S \<subseteq> verts G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. S \<in> sccs_verts \<Longrightarrow> S \<subseteq> verts G
[PROOF STEP]
by (auto simp: sccs_verts_conv) |
import .def_coords
universe u
namespace o_minimal
open_locale finvec
variables {R : Type u} (S : struc R)
-- We set up a minimal theory of (literal) definable subsets of Rⁿ
-- and definable functions between them.
/-- A bundled definable subset of some Rⁿ. -/
structure Def : Type u :=
(ambdim : ℕ)
(to_set : set (finvec ambdim R))
(is_definable : S.definable to_set)
variables {S}
instance : has_coe_to_sort (Def S) :=
⟨Type u, λ X, X.to_set⟩
lemma Def.is_def_coords (X : Def S) : S.def_coords (set.univ : set X) :=
begin
unfold struc.def_coords,
convert X.is_definable,
simp
end
variables (S)
def struc.definable_fun {X Y : Def S} (f : X → Y) : Prop :=
S.def_coords {z : X × Y | f z.1 = z.2}
variables {S}
@[ext] structure Hom (X Y : Def S) : Type u :=
(to_fun : X → Y)
(is_definable : S.definable_fun to_fun)
instance {X Y : Def S} : has_coe_to_fun (Hom X Y) :=
⟨_, λ f, f.to_fun⟩
--instance : category_theory.has_hom (Def S) := { hom := Hom }
local infixr ` ⟶ `:10 := Hom
@[simp] lemma Hom.to_fun_eq_coe {X Y : Def S} (f : X ⟶ Y) :
f.to_fun = f :=
rfl
-- TODO float out proofs of definability of identity, composition
-- (useful later in presheaf stuff, notably representable instance)
def Def.id (X : Def S) : X ⟶ X :=
{ to_fun := id,
is_definable := struc.def_coords.diag X.is_def_coords }
def Hom.comp {X Y Z : Def S} (g : Y ⟶ Z) (f : X ⟶ Y) : X ⟶ Z :=
{ to_fun := g.to_fun ∘ f.to_fun,
is_definable := begin
suffices : S.def_coords {p : X × Z | ∃ y, f p.1 = y ∧ g y = p.2},
{ convert this,
ext ⟨x, z⟩,
simp [struc.definable_fun] },
have dXZY : S.def_coords (set.univ : set ((X × Z) × Y)) :=
(X.is_def_coords.prod_univ Z.is_def_coords).prod_univ Y.is_def_coords,
apply struc.def_coords.exists,
apply struc.def_coords.inter,
{ let φ : (X × Z) × Y → X × Y := λ p, (p.1.1, p.2),
have : is_reindexing R φ :=
is_reindexing.prod R ((is_reindexing.fst R).comp R (is_reindexing.fst R)) (is_reindexing.snd R),
refine struc.def_coords.reindex dXZY this f.is_definable },
{ let φ : (X × Z) × Y → Y × Z := λ p, (p.2, p.1.2),
have : is_reindexing R φ :=
is_reindexing.prod R (is_reindexing.snd R) ((is_reindexing.snd R).comp R (is_reindexing.fst R)),
refine struc.def_coords.reindex dXZY this g.is_definable },
end }
lemma Hom.comp_id {X Y : Def S} (f : X ⟶ Y) : f.comp (Def.id X) = f :=
by { ext, refl }
lemma Hom.id_comp {X Y : Def S} (f : X ⟶ Y) : (Def.id Y).comp f = f :=
by { ext, refl }
lemma Hom.comp_assoc {W X Y Z : Def S} (h : Y ⟶ Z) (g : X ⟶ Y) (f : W ⟶ X) :
(h.comp g).comp f = h.comp (g.comp f) :=
rfl
def pt : Def S :=
{ ambdim := 0,
to_set := set.univ,
is_definable := S.definable_univ 0 }
instance pt.unique : unique (pt : Def S) :=
⟨⟨⟨fin_zero_elim, trivial⟩⟩, λ x, by { ext i, fin_cases i }⟩
/-! ### Presheaf stuff -/
variables (S)
-- TODO: generalize to Sort?
class definable_psh (X : Type*) :=
(definable : Π {K : Def S}, (K → X) → Prop)
(definable_precomp : ∀ {L K : Def S} (φ : L ⟶ K) {f : K → X},
definable f → definable (f ∘ φ))
-- TODO: apply bug??
def definable {X : Type*} [definable_psh S X] (x : X) : Prop :=
definable_psh.definable (λ (_ : (pt : Def S)), x)
variables {S}
def definable_psh.definable' {X : Type*} (h : definable_psh S X) {K : Def S} (f : K → X) : Prop :=
definable_psh.definable f
instance Def.definable_psh (X : Def S) : definable_psh S X :=
{ definable := λ K f, S.definable_fun f,
definable_precomp := begin
rintros L K φ f h,
exact ((⟨f, h⟩ : K ⟶ X).comp φ).is_definable
end }
lemma pt.definable {K : Def S} {f : K → (pt : Def S)} : definable_psh.definable f :=
begin
change S.definable _,
convert K.is_def_coords using 1,
ext x,
split,
{ rintros ⟨⟨k, p⟩, -, rfl⟩,
refine ⟨k, trivial, _⟩,
simp },
{ rintros ⟨k, -, rfl⟩,
refine ⟨⟨k, default _⟩, show _ = _, by cc, _⟩,
simp }
end
instance {X Y : Type*} [definable_psh S X] [definable_psh S Y] : definable_psh S (X × Y) :=
{ definable := λ K f, definable_psh.definable (prod.fst ∘ f) ∧ definable_psh.definable (prod.snd ∘ f),
definable_precomp := begin
rintros L K φ _ ⟨h₁, h₂⟩,
exact ⟨definable_psh.definable_precomp φ h₁, definable_psh.definable_precomp φ h₂⟩,
end }
instance function.definable_psh {X Y : Type*} [hX : definable_psh S X] [hY : definable_psh S Y] :
definable_psh S (X → Y) :=
{ definable := λ K f, ∀ (M : Def S) {g : M → K × X} (h : definable_psh.definable g),
definable_psh.definable (function.uncurry f ∘ g),
definable_precomp := λ L K φ f hf M g hg, begin
suffices : definable_psh.definable (λ m, (φ (g m).1, (g m).2)),
{ apply hf M this },
split,
{ exact definable_psh.definable_precomp ⟨λ m, (g m).1, hg.1⟩
(show definable_psh.definable φ, from φ.is_definable) },
{ exact hg.2 }
end }
lemma definable_fun {X Y : Type*} [definable_psh S X] [definable_psh S Y]
{f : X → Y} : definable S f ↔
∀ {K : Def S} (φ : K → X), definable_psh.definable φ → definable_psh.definable (f ∘ φ) :=
begin
split; intro H,
{ intros K φ hφ,
-- TODO: This proof is awkward
specialize H K,
swap,
{ exact (λ k, (default _, φ k)) },
exact H ⟨pt.definable, hφ⟩ },
{ intros K φ hφ,
exact H _ hφ.2 }
end
lemma definable_app {X Y : Type*} [definable_psh S X] [definable_psh S Y]
{f : X → Y} (hf : definable S f) {x : X} (hx : definable S x) : definable S (f x) :=
begin
rw definable_fun at hf,
exact hf _ hx
end
lemma definable.app_ctx {Γ X Y : Type*} [definable_psh S Γ] [definable_psh S X] [definable_psh S Y]
{f : Γ → X → Y} (hf : definable S f) {x : Γ → X} (hx : definable S x) :
definable S (λ γ, f γ (x γ)) :=
begin
rw definable_fun at ⊢ hf hx,
intros K φ hφ,
change definable_psh.definable (λ k, f (φ k) (x (φ k))),
specialize hf φ hφ,
specialize hf K,
swap, { exact λ k, (k, x (φ k)) },
exact hf ⟨(Def.id K).is_definable, hx φ hφ⟩
end
lemma definable_yoneda {K : Def S} {X : Type*} [definable_psh S X]
{f : K → X} : definable_psh.definable f ↔ definable S f :=
begin
rw definable_fun,
split,
{ intros h L φ hφ,
exact definable_psh.definable_precomp ⟨φ, hφ⟩ h },
{ intros H,
refine H id _,
exact (Def.id K).is_definable }
end
lemma definable_prod_mk {X Y : Type*} [definable_psh S X] [definable_psh S Y] :
definable S (prod.mk : X → Y → X × Y) :=
-- I have no idea how to come up with these proofs.
-- Maybe we should tweak the type of definable_precomp (or write a lemma)
-- that takes the underlying map φ and its proof of definability separately
-- so that Lean has a better chance of guessing what's happening?
λ L g h L' g' h',
⟨definable_psh.definable_precomp ⟨λ x, (g' x).fst, h'.1⟩ h.2, h'.2⟩
lemma definable_fst {X Y : Type*} [definable_psh S X] [definable_psh S Y] :
definable S (prod.fst : X × Y → X) :=
begin
rw definable_fun,
intros K φ hφ,
exact hφ.1
end
lemma definable_snd {X Y : Type*} [definable_psh S X] [definable_psh S Y] :
definable S (prod.snd : X × Y → Y) :=
begin
rw definable_fun,
intros K φ hφ,
exact hφ.2
end
lemma definable.prod_mk {W X Y : Type*} [definable_psh S W] [definable_psh S X] [definable_psh S Y]
{f : W → X} (hf : definable S f) {g : W → Y} (hg : definable S g) :
definable S (λ w, (f w, g w)) :=
begin
rw definable_fun at ⊢ hf hg,
intros K φ hφ,
exact ⟨hf φ hφ, hg φ hφ⟩
end
lemma definable_fun₂ {X Y Z : Type*} [definable_psh S X] [definable_psh S Y] [definable_psh S Z]
{f : X → Y → Z} :
(∀ {L : Def S} (φ : L → X), definable S φ → definable S (f ∘ φ)) ↔
(∀ {L : Def S} (φ : L → X × Y), definable S φ → definable S (function.uncurry f ∘ φ)) :=
begin
split; intro H,
{ intros L φ hφ,
rw definable_fun at ⊢,
intros K ψ hψ,
have : definable S (prod.fst ∘ φ),
{ rw ←definable_yoneda at ⊢ hφ,
exact hφ.1 },
specialize H (λ l, (φ l).1) this,
rw definable_fun at H,
specialize H ψ hψ,
specialize H K,
swap, { exact λ k, (k, (φ (ψ k)).2) },
refine H ⟨(Def.id K).is_definable, _⟩, clear H,
rw ←definable_yoneda at hφ,
exact definable_psh.definable_precomp ⟨ψ, hψ⟩ hφ.2 },
{ intros L φ hφ,
rw definable_fun,
intros K ψ hψ,
intros K' ψ' hψ',
dsimp [function.uncurry, function.comp],
specialize H (λ k', (φ (ψ (ψ' k').1), (ψ' k').2)),
have : definable S (λ k', (φ (ψ (ψ' k').1), (ψ' k').2)),
{ rw ←definable_yoneda at ⊢ hφ,
split,
{ refine definable_psh.definable_precomp ⟨λ k', ψ (ψ' k').fst, _⟩ hφ,
exact (Hom.comp ⟨ψ, hψ⟩ ⟨_, hψ'.1⟩).is_definable },
{ exact hψ'.2 } },
specialize H this,
rw definable_fun at H,
exact H _ (Def.id _).is_definable }
end
lemma definable_comp {X Y Z : Type*} [definable_psh S X] [definable_psh S Y] [definable_psh S Z] :
definable S (function.comp : (Y → Z) → (X → Y) → (X → Z)) :=
begin
-- TODO: Make these 4 lines a lemma.
rw definable_fun,
intros L₁ φ₁ hφ₁,
rw definable_yoneda at ⊢ hφ₁,
revert L₁,
-- end lemma
rw definable_fun₂,
rw definable_fun₂,
rintros L φ hφ,
rw ←definable_yoneda at hφ,
obtain ⟨⟨hφ₁, hφ₂⟩, hφ₃⟩ := hφ,
rw definable_yoneda at hφ₁ hφ₂ hφ₃,
dsimp [function.uncurry, function.comp],
exact hφ₁.app_ctx (hφ₂.app_ctx hφ₃)
end
lemma definable.comp {X Y Z : Type*} [definable_psh S X] [definable_psh S Y] [definable_psh S Z]
{g : Y → Z} (hg : definable S g) {f : X → Y} (hf : definable S f) :
definable S (g ∘ f) :=
definable_app (definable_app definable_comp hg) hf
lemma definable.comp_ctx {Γ X Y Z : Type*} [definable_psh S Γ] [definable_psh S X] [definable_psh S Y] [definable_psh S Z]
{g : Γ → Y → Z} (hg : definable S g) {f : Γ → X → Y} (hf : definable S f) :
definable S (λ γ, g γ ∘ f γ) :=
definable.app_ctx (definable.comp definable_comp hg) hf
lemma definable_curry {X Y Z : Type*} [definable_psh S X] [definable_psh S Y] [definable_psh S Z] :
definable S (function.curry : (X × Y → Z) → X → Y → Z) :=
begin
-- TODO: Make these 4 lines a lemma.
rw definable_fun,
intros L₁ φ₁ hφ₁,
rw definable_yoneda at ⊢ hφ₁,
revert L₁,
-- end lemma
rw definable_fun₂,
rw definable_fun₂,
rintros L φ hφ,
rw ←definable_yoneda at hφ,
obtain ⟨⟨hφ₁, hφ₂⟩, hφ₃⟩ := hφ,
rw definable_yoneda at hφ₁ hφ₂ hφ₃,
exact definable.app_ctx hφ₁ (hφ₂.prod_mk hφ₃)
end
instance Prop.definable_psh : definable_psh S Prop :=
{ definable := λ K s, S.def_coords s,
definable_precomp := λ L K φ f hf, sorry } -- preimage
instance set.definable_psh {X : Type*} [definable_psh S X] : definable_psh S (set X) :=
show definable_psh S (X → Prop), by apply_instance
lemma definable_and : definable S (∧) :=
begin
suffices : definable S (λ r : Prop × Prop, r.1 ∧ r.2),
{ exact definable_app definable_curry this },
rw definable_fun,
rintros K φ ⟨hφ₁, hφ₂⟩,
exact hφ₁.inter hφ₂
end
lemma definable.and {W : Type*} [definable_psh S W]
{f : W → Prop} (hf : definable S f) {g : W → Prop} (hg : definable S g) :
definable S (λ w, f w ∧ g w) :=
definable.app_ctx (definable.comp definable_and hf) hg
lemma definable_inter {X : Type*} [definable_psh S X] :
definable S ((∩) : set X → set X → set X) :=
begin
suffices : definable S (λ (r : set X × set X) (x : X), r.1 x ∧ r.2 x),
{ exact (definable_app definable_curry this : _) },
-- TODO: Make these 4 lines a lemma.
rw definable_fun,
intros L₁ φ₁ hφ₁,
rw definable_yoneda at ⊢ hφ₁,
revert L₁,
-- end lemma
rw definable_fun₂,
intros L φ hφ,
rw ←definable_yoneda at hφ,
obtain ⟨⟨hφ₁, hφ₂⟩, hφ₃⟩ := hφ,
rw definable_yoneda at hφ₁ hφ₂ hφ₃,
apply definable.and,
{ exact hφ₁.app_ctx hφ₃ },
{ exact hφ₂.app_ctx hφ₃ }
end
/-
instance foo {X Y : Type*} [definable_psh S X] [definable_psh S Y]
{p : X → Prop}
: definable_psh S (Π (x : X) (h : p x), Y) :=
sorry
-/
lemma definable_definable {X : Type*} [definable_psh S X] :
definable S (definable S : X → Prop) :=
begin
rw definable_fun,
intros K φ hφ,
change S.def_coords _,
convert K.is_def_coords,
apply set.eq_univ_of_forall,
intro x,
change definable S (φ x),
apply definable_app,
{ rw ←definable_yoneda, exact hφ },
-- now we need to know that every point of a representable guy
-- is definable. this needs definable constants!
sorry
-- In general, the definable elements of a structure
-- might or might not form a definable set.
-- Counterexample: take (ℝ, +, *) without constants;
-- definable elements are the algebraic real numbers,
-- but only tame sets can be definable.
-- However, once the structure has definable constants,
-- then everything is definable and of course the set `univ` is definable.
end
-- Important note: it is definitely *not* true that
-- `definable S` = `set.univ` on *every* X with a definable_psh structure;
-- just represented guys.
/-
similarly, in an o-minimal structure:
lemma definable_finite [DUNLO R] [o_minimal S] :
definable S (set.finite : set R → Prop) := sorry
because "finite" is equivalent to "does not contain an interval"
on the tame = definable sets, which are the only ones that matter.
-/
instance self : definable_psh S R := sorry
variables (S)
#exit
class definable_fam {X : Type*} [definable_psh S X] (Y : X → Sort*) :=
(definable : Π {K : Def S} (x : K → X) (hx : definable_psh.definable x), (Π k, Y (x k)) → Prop)
-- s.t. blah blah blah...
instance moo {X : Type*} {Y : X → Type*} [definable_psh S X] [definable_fam S Y] :
definable_psh S (Π (x : X), Y x) :=
sorry
constant choice : Π (X : set R), X.nonempty → X
example : definable S (set.nonempty : set R → Prop) :=
sorry
instance : definable_fam S (set.nonempty : set R → Prop) := sorry
instance pi {X : Type*} [definable_psh S X] {Y Z : X → Sort*} [definable_fam S Y] [definable_fam S Z] :
definable_fam S (λ x, Y x → Z x) :=
sorry
instance subtype {X : Type*} [definable_psh S X] : definable_fam S (λ (s : set X), s) :=
sorry
example : definable S ((λ x hx₁ hx₂, choice x hx₁) : Π (X : set R), X.nonempty → X.nonempty → X) :=
sorry
-- can we do without this `definable_fam` stuff? even as a hack?
-- or maybe stick with this for now?
/- TODO:
* class represented [has_coordinates R X] expressing compatibility
* prove this notion of definability of functions, sets reduces
to the original one in the represented case
Then:
* prove stuff like `is_least : set R → R → Prop` is definable
-/
end o_minimal
|
#' exm
#'
#' @name exm
#' @docType package
NULL
|
Formal statement is: lemma LIM_zero_cancel: fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" shows "((\<lambda>x. f x - l) \<longlongrightarrow> 0) F \<Longrightarrow> (f \<longlongrightarrow> l) F" Informal statement is: If $f$ converges to $l$ in the sense that $f(x) - l$ converges to $0$, then $f$ converges to $l$. |
(* Property from Case-Analysis for Rippling and Inductive Proof,
Moa Johansson, Lucas Dixon and Alan Bundy, ITP 2010.
This Isabelle theory is produced using the TIP tool offered at the following website:
https://github.com/tip-org/tools
This file was originally provided as part of TIP benchmark at the following website:
https://github.com/tip-org/benchmarks
Yutaka Nagashima at CIIRC, CTU changed the TIP output theory file slightly
to make it compatible with Isabelle2017.
Some proofs were added by Yutaka Nagashima.*)
theory TIP_prop_86
imports "../../Test_Base"
begin
datatype 'a list = nil2 | cons2 "'a" "'a list"
datatype Nat = Z | S "Nat"
fun x :: "Nat => Nat => bool" where
"x (Z) (Z) = True"
| "x (Z) (S z2) = False"
| "x (S x2) (Z) = False"
| "x (S x2) (S y2) = x x2 y2"
fun elem :: "Nat => Nat list => bool" where
"elem y (nil2) = False"
| "elem y (cons2 z2 xs) = (if x y z2 then True else elem y xs)"
fun t2 :: "Nat => Nat => bool" where
"t2 y (Z) = False"
| "t2 (Z) (S z2) = True"
| "t2 (S x2) (S z2) = t2 x2 z2"
fun ins :: "Nat => Nat list => Nat list" where
"ins y (nil2) = cons2 y (nil2)"
| "ins y (cons2 z2 xs) =
(if t2 y z2 then cons2 y (cons2 z2 xs) else cons2 z2 (ins y xs))"
theorem property0 :
"((t2 y z) ==> ((elem y (ins z xs)) = (elem y xs)))"
oops
end
|
open import SOAS.Metatheory.Syntax
-- Metatheory of a second-order syntax
module SOAS.Metatheory {T : Set} (Syn : Syntax {T}) where
open import SOAS.Families.Core {T}
open import SOAS.Abstract.ExpStrength
open Syntax Syn
open CompatStrengths ⅀:CS public renaming (CoalgStr to ⅀:Str ; ExpStr to ⅀:ExpStr)
open import SOAS.Metatheory.Algebra ⅀F public
open import SOAS.Metatheory.Monoid ⅀F ⅀:Str public
module Theory (𝔛 : Familyₛ) where
open import SOAS.Metatheory.MetaAlgebra ⅀F 𝔛 public
open import SOAS.Metatheory.Semantics ⅀F ⅀:Str 𝔛 (𝕋:Init 𝔛) public
open import SOAS.Metatheory.Traversal ⅀F ⅀:Str 𝔛 (𝕋:Init 𝔛) public
open import SOAS.Metatheory.Renaming ⅀F ⅀:Str 𝔛 (𝕋:Init 𝔛) public
open import SOAS.Metatheory.Coalgebraic ⅀F ⅀:Str 𝔛 (𝕋:Init 𝔛) public
open import SOAS.Metatheory.Substitution ⅀F ⅀:Str 𝔛 (𝕋:Init 𝔛) public
|
Formal statement is: lemma homeomorphic_translation: fixes S :: "'a::real_normed_vector set" shows "S homeomorphic ((\<lambda>x. a + x) ` S)" Informal statement is: Any set $S$ is homeomorphic to its translation by any vector $a$. |
[STATEMENT]
lemma Sbis_Sym: "c \<approx>s d \<Longrightarrow> d \<approx>s c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. c \<approx>s d \<Longrightarrow> d \<approx>s c
[PROOF STEP]
using Sbis_sym
[PROOF STATE]
proof (prove)
using this:
sym Sbis
goal (1 subgoal):
1. c \<approx>s d \<Longrightarrow> d \<approx>s c
[PROOF STEP]
unfolding sym_def
[PROOF STATE]
proof (prove)
using this:
\<forall>x y. x \<approx>s y \<longrightarrow> y \<approx>s x
goal (1 subgoal):
1. c \<approx>s d \<Longrightarrow> d \<approx>s c
[PROOF STEP]
by blast |
Formal statement is: lemma convex_epigraphI: "convex_on S f \<Longrightarrow> convex S \<Longrightarrow> convex (epigraph S f)" Informal statement is: If $f$ is convex on $S$ and $S$ is convex, then the epigraph of $f$ is convex. |
Formal statement is: lemma dist_minus: fixes x y :: "'a::real_normed_vector" shows "dist (- x) (- y) = dist x y" Informal statement is: The distance between two points is the same as the distance between their negatives. |
lemma enn2real_plus:"a < top \<Longrightarrow> b < top \<Longrightarrow> enn2real (a + b) = enn2real a + enn2real b" |
-- ---------------------------------------------------------------- [ Util.idr ]
module Data.ML.Util
%access public export
||| Convert a Bool to an Integer, as in C99's <stdbool.h>.
||| @ bool a Bool to convert
boolToInteger : (bool : Bool) -> Integer
boolToInteger False = 0
boolToInteger True = 1
||| Cast Bools to Integers via `boolToInteger`.
implementation Cast Bool Integer where
cast = boolToInteger
||| Simplified clone of `numpy.unique`.
|||
||| Return the sorted unique elements of a list.
|||
||| ```
||| unique = sort . nub
||| ```
unique : Ord a => List a -> List a
unique = sort . nub
-- --------------------------------------------------------------------- [ EOF ]
|
Formal statement is: lemma (in order_topology) at_within_Icc_at: "a < x \<Longrightarrow> x < b \<Longrightarrow> at x within {a..b} = at x" Informal statement is: If $a < x < b$, then the filter of neighbourhoods of $x$ within the interval $[a,b]$ is the same as the filter of neighbourhoods of $x$ in the real line. |
-- @@stderr --
dtrace: failed to compile script test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithCopyOut.d: [D_ACT_SPEC] line 36: destructive actions may not follow speculate( )
|
Formal statement is: lemma infnorm_triangle: fixes x :: "'a::euclidean_space" shows "infnorm (x + y) \<le> infnorm x + infnorm y" Informal statement is: The infnorm of a sum of two vectors is less than or equal to the sum of the infnorms of the vectors. |
Formal statement is: lemma uniformly_continuous_on_closure: fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" assumes ucont: "uniformly_continuous_on S f" and cont: "continuous_on (closure S) f" shows "uniformly_continuous_on (closure S) f" Informal statement is: If $f$ is uniformly continuous on a set $S$ and continuous on the closure of $S$, then $f$ is uniformly continuous on the closure of $S$. |
lemma LIMSEQ_le_const: "X \<longlonglongrightarrow> x \<Longrightarrow> \<exists>N. \<forall>n\<ge>N. a \<le> X n \<Longrightarrow> a \<le> x" for a x :: "'a::linorder_topology" |
-- PalindromeMain.idr
-- App for checking palindromes
module Main
import Exercises
main : IO ()
main = repl "Enter a string: " (\s => format $ palindrome s)
where
format : Bool -> String
format x = (show x) ++ "\n"
|
lemma complete_eq_closed: fixes S :: "('a::complete_space) set" shows "complete S \<longleftrightarrow> closed S" |
Formal statement is: lemma in_components_connected: "c \<in> components s \<Longrightarrow> connected c" Informal statement is: If $c$ is a component of $s$, then $c$ is connected. |
Formal statement is: lemma limitin_topspace: "limitin X f l F \<Longrightarrow> l \<in> topspace X" Informal statement is: If $f$ converges to $l$ in $X$, then $l$ is in the topological space $X$. |
/-
Copyright (c) 2021 Nicolò Cavalleri. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Nicolò Cavalleri
-/
import topology.homeomorph
/-!
# Topological space structure on the opposite monoid and on the units group
In this file we define `topological_space` structure on `Mᵐᵒᵖ`, `Mᵃᵒᵖ`, `Mˣ`, and `add_units M`.
This file does not import definitions of a topological monoid and/or a continuous multiplicative
action, so we postpone the proofs of `has_continuous_mul Mᵐᵒᵖ` etc till we have these definitions.
## Tags
topological space, opposite monoid, units
-/
variables {M X : Type*}
open filter
open_locale topological_space
namespace mul_opposite
/-- Put the same topological space structure on the opposite monoid as on the original space. -/
@[to_additive] instance [topological_space M] : topological_space Mᵐᵒᵖ :=
topological_space.induced (unop : Mᵐᵒᵖ → M) ‹_›
variables [topological_space M]
@[continuity, to_additive] lemma continuous_unop : continuous (unop : Mᵐᵒᵖ → M) :=
continuous_induced_dom
@[continuity, to_additive] lemma continuous_op : continuous (op : M → Mᵐᵒᵖ) :=
continuous_induced_rng continuous_id
@[to_additive] instance [t2_space M] : t2_space Mᵐᵒᵖ :=
⟨λ x y h, separated_by_continuous mul_opposite.continuous_unop $ unop_injective.ne h⟩
/-- `mul_opposite.op` as a homeomorphism. -/
@[to_additive "`add_opposite.op` as a homeomorphism."]
def op_homeomorph : M ≃ₜ Mᵐᵒᵖ :=
{ to_equiv := op_equiv,
continuous_to_fun := continuous_op,
continuous_inv_fun := continuous_unop }
@[simp, to_additive] lemma map_op_nhds (x : M) : map (op : M → Mᵐᵒᵖ) (𝓝 x) = 𝓝 (op x) :=
op_homeomorph.map_nhds_eq x
@[simp, to_additive] lemma map_unop_nhds (x : Mᵐᵒᵖ) : map (unop : Mᵐᵒᵖ → M) (𝓝 x) = 𝓝 (unop x) :=
op_homeomorph.symm.map_nhds_eq x
@[simp, to_additive] lemma comap_op_nhds (x : Mᵐᵒᵖ) : comap (op : M → Mᵐᵒᵖ) (𝓝 x) = 𝓝 (unop x) :=
op_homeomorph.comap_nhds_eq x
@[simp, to_additive]
end mul_opposite
namespace units
open mul_opposite
variables [topological_space M] [monoid M]
/-- The units of a monoid are equipped with a topology, via the embedding into `M × M`. -/
@[to_additive] instance : topological_space Mˣ :=
topological_space.induced (embed_product M) prod.topological_space
@[to_additive] lemma continuous_embed_product : continuous (embed_product M) :=
continuous_induced_dom
@[to_additive] lemma continuous_coe : continuous (coe : Mˣ → M) :=
(@continuous_embed_product M _ _).fst
end units
|
Formal statement is: lemma upd_inj: "i < n \<Longrightarrow> j < n \<Longrightarrow> upd i = upd j \<longleftrightarrow> i = j" Informal statement is: If $i$ and $j$ are less than $n$, then the functions $upd_i$ and $upd_j$ are equal if and only if $i = j$. |
[STATEMENT]
lemma carrier_class: "x \<in> carrier cring_class_ops"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. x \<in> carrier cring_class_ops
[PROOF STEP]
by (simp add: cring_class_ops_def) |
-- Reverse.idr
-- Reversing string interactively, using 'repl'
module Main
main : IO ()
main = repl "> " reverse
|
Formal statement is: lemma measurable_const: "c \<in> space M' \<Longrightarrow> (\<lambda>x. c) \<in> measurable M M'" Informal statement is: If $c$ is in the space of the measure $M'$, then the constant function $x \mapsto c$ is measurable with respect to $M$. |
-- https://www.codewars.com/kata/50654ddff44f800200000004
module Multiply
%access export
%default total
multiply : Int -> Int -> Int
multiply a b = a * b
|
import data.sigma.basic
import tactic.ext
namespace sigma
universes u v
section
variables {α : Type u} {β β' : α → Type v}
theorem eq_fst {s₁ s₂ : sigma β} : s₁ = s₂ → s₁.1 = s₂.1 :=
by cases s₁; cases s₂; cc
theorem eq_snd {s₁ s₂ : sigma β} : s₁ = s₂ → s₁.2 == s₂.2 :=
by cases s₁; cases s₂; cc
end
section
variables {α₁ α₂ : Type u} {β₁ : α₁ → Type v} {β₂ : α₂ → Type v}
/-- A function on `sigma`s that is functional on `fst`s (preserves equality from
argument to result). -/
def fst_functional (f : sigma β₁ → sigma β₂) : Prop :=
∀ ⦃s t : sigma β₁⦄, s.1 = t.1 → (f s).1 = (f t).1
/-- A function on `sigma`s that is injective on `fst`s (preserves equality from
result to argument). -/
def fst_injective (f : sigma β₁ → sigma β₂) : Prop :=
∀ ⦃s t : sigma β₁⦄, (f s).1 = (f t).1 → s.1 = t.1
end
/-- A function on `sigma`s bundled with its `fst`-injectivity property. -/
structure embedding {α₁ α₂ : Type u} (β₁ : α₁ → Type v) (β₂ : α₂ → Type v) :=
(to_fun : sigma β₁ → sigma β₂)
(fst_inj : fst_injective to_fun)
infixr ` s↪ `:25 := embedding
namespace embedding
variables {α₁ α₂ : Type u} {β₁ : α₁ → Type v} {β₂ : α₂ → Type v}
instance : has_coe_to_fun (β₁ s↪ β₂) :=
⟨_, embedding.to_fun⟩
@[simp] theorem to_fun_eq_coe (f : β₁ s↪ β₂) : f.to_fun = f :=
rfl
@[simp] theorem coe_fn_mk (f : sigma β₁ → sigma β₂) (i : fst_injective f) :
(mk f i : sigma β₁ → sigma β₂) = f :=
rfl
theorem fst_inj' : ∀ (f : β₁ s↪ β₂), fst_injective f
| ⟨_, h⟩ := h
end embedding
section map_id
variables {α : Type u} {β₁ β₂ : α → Type v}
@[simp] theorem map_id_eq_fst {s : sigma β₁} (f : ∀ a, β₁ a → β₂ a) :
(s.map id f).1 = s.1 :=
by cases s; refl
theorem map_id_fst_functional (f : ∀ a, β₁ a → β₂ a) :
fst_functional (map id f) :=
λ _ _, by simp only [map_id_eq_fst]; exact id
theorem map_id_fst_injective (f : ∀ a, β₁ a → β₂ a) :
fst_injective (map id f) :=
λ _ _, by simp only [map_id_eq_fst]; exact id
/-- Construct an `embedding` with `id` on `fst`. -/
def embedding.mk₂ (f : ∀ a, β₁ a → β₂ a) : embedding β₁ β₂ :=
⟨_, map_id_fst_injective f⟩
end map_id
section
variables {α : Type u} {β : α → Type v} {R : α → α → Prop}
/-- A relation `R` on `fst` values lifted to the `sigma`. This is useful where
you might otherwise use the term `λ s₁ s₂, R s₁.1 s₂.1`. -/
def fst_rel (R : α → α → Prop) (s₁ s₂ : sigma β) : Prop :=
R s₁.1 s₂.1
@[simp] theorem fst_rel_def {s₁ s₂ : sigma β} : fst_rel R s₁ s₂ = R s₁.1 s₂.1 :=
rfl
instance fst_rel_decidable [d : decidable_rel R] : decidable_rel (@fst_rel _ β R)
| s₁ s₂ := @d s₁.1 s₂.1
theorem fst_rel.refl (h : reflexive R) : reflexive (@fst_rel _ β R) :=
λ s, h s.1
theorem fst_rel.symm (h : symmetric R) : symmetric (@fst_rel _ β R) :=
λ s₁ s₂ (p : R s₁.1 s₂.1), h p
theorem fst_rel.trans (h : transitive R) : transitive (@fst_rel _ β R) :=
λ s₁ s₂ s₃ (p : R s₁.1 s₂.1) (q : R s₂.1 s₃.1), h p q
end
section
variables {α : Type u} {β : α → Type v}
theorem fst_functional_id : fst_functional (@id (sigma β)) :=
λ s t h, h
theorem fst_injective_id : fst_injective (@id (sigma β)) :=
λ s t h, h
@[refl] protected def embedding.refl (β : α → Type v) : β s↪ β :=
⟨_, fst_injective_id⟩
@[simp] theorem embedding.refl_apply (s : sigma β) : embedding.refl β s = s :=
rfl
end
section
variables {α₁ α₂ α₃ : Type u}
variables {β₁ : α₁ → Type v} {β₂ : α₂ → Type v} {β₃ : α₃ → Type v}
variables {g : sigma β₂ → sigma β₃} {f : sigma β₁ → sigma β₂}
theorem fst_functional_comp (gf : fst_functional g) (ff : fst_functional f) :
fst_functional (g ∘ f) :=
λ s t h, gf (ff h)
theorem fst_injective_comp (gi : fst_injective g) (fi : fst_injective f) :
fst_injective (g ∘ f) :=
λ s t h, fi (gi h)
@[trans] protected def embedding.trans (f : β₁ s↪ β₂) (g : β₂ s↪ β₃) : β₁ s↪ β₃ :=
⟨_, fst_injective_comp g.fst_inj f.fst_inj⟩
@[simp] theorem embedding.trans_apply (f : β₁ s↪ β₂) (g : β₂ s↪ β₃) (s : sigma β₁) :
(f.trans g) s = g (f s) :=
rfl
@[extensionality]
lemma ext {x₀ x₁ : sigma β₁}
(h₀ : x₀.1 = x₁.1)
(h₁ : x₀.1 = x₁.1 → x₀.2 == x₁.2) :
x₀ = x₁ :=
by casesm* sigma _; cases h₀; cases h₁ h₀; refl
lemma eta (x : sigma β₁) : sigma.mk x.1 x.2 = x :=
by cases x; refl
end
end sigma
|
[STATEMENT]
lemma trim_gtt_lang:
"gtt_lang (trim_gtt G) = gtt_lang G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. gtt_lang (trim_gtt G) = gtt_lang G
[PROOF STEP]
unfolding trim_gtt_def comp_def gtt_only_prod_lang gtt_only_reach_lang
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. gtt_lang G = gtt_lang G
[PROOF STEP]
.. |
Formal statement is: lemma islimpt_insert: fixes x :: "'a::t1_space" shows "x islimpt (insert a s) \<longleftrightarrow> x islimpt s" Informal statement is: A point $x$ is a limit point of a set $S$ if and only if $x$ is a limit point of $S \cup \{a\}$. |
Formal statement is: lemma small_trans: "f \<in> l F (g) \<Longrightarrow> g \<in> l F (h) \<Longrightarrow> f \<in> l F (h)" Informal statement is: If $f$ is small with respect to $g$ and $g$ is small with respect to $h$, then $f$ is small with respect to $h$. |
(* Author: Tobias Nipkow *)
theory Abs_Int1_const
imports Abs_Int1
begin
subsection "Constant Propagation"
datatype const = Const val | Any
fun \<gamma>_const where
"\<gamma>_const (Const i) = {i}" |
"\<gamma>_const (Any) = UNIV"
fun plus_const where
"plus_const (Const i) (Const j) = Const(i+j)" |
"plus_const _ _ = Any"
lemma plus_const_cases: "plus_const a1 a2 =
(case (a1,a2) of (Const i, Const j) \<Rightarrow> Const(i+j) | _ \<Rightarrow> Any)"
by(auto split: prod.split const.split)
instantiation const :: semilattice_sup_top
begin
fun less_eq_const where "x \<le> y = (y = Any | x=y)"
definition "x < (y::const) = (x \<le> y & \<not> y \<le> x)"
fun sup_const where "x \<squnion> y = (if x=y then x else Any)"
definition "\<top> = Any"
instance
proof (standard, goal_cases)
case 1 thus ?case by (rule less_const_def)
next
case (2 x) show ?case by (cases x) simp_all
next
case (3 x y z) thus ?case by(cases z, cases y, cases x, simp_all)
next
case (4 x y) thus ?case by(cases x, cases y, simp_all, cases y, simp_all)
next
case (6 x y) thus ?case by(cases x, cases y, simp_all)
next
case (5 x y) thus ?case by(cases y, cases x, simp_all)
next
case (7 x y z) thus ?case by(cases z, cases y, cases x, simp_all)
next
case 8 thus ?case by(simp add: top_const_def)
qed
end
global_interpretation Val_semilattice
where \<gamma> = \<gamma>_const and num' = Const and plus' = plus_const
proof (standard, goal_cases)
case (1 a b) thus ?case
by(cases a, cases b, simp, simp, cases b, simp, simp)
next
case 2 show ?case by(simp add: top_const_def)
next
case 3 show ?case by simp
next
case 4 thus ?case by(auto simp: plus_const_cases split: const.split)
qed
global_interpretation Abs_Int
where \<gamma> = \<gamma>_const and num' = Const and plus' = plus_const
defines AI_const = AI and step_const = step' and aval'_const = aval'
..
subsubsection "Tests"
definition "steps c i = (step_const \<top> ^^ i) (bot c)"
value "show_acom (steps test1_const 0)"
value "show_acom (steps test1_const 1)"
value "show_acom (steps test1_const 2)"
value "show_acom (steps test1_const 3)"
value "show_acom (the(AI_const test1_const))"
value "show_acom (the(AI_const test2_const))"
value "show_acom (the(AI_const test3_const))"
value "show_acom (steps test4_const 0)"
value "show_acom (steps test4_const 1)"
value "show_acom (steps test4_const 2)"
value "show_acom (steps test4_const 3)"
value "show_acom (steps test4_const 4)"
value "show_acom (the(AI_const test4_const))"
value "show_acom (steps test5_const 0)"
value "show_acom (steps test5_const 1)"
value "show_acom (steps test5_const 2)"
value "show_acom (steps test5_const 3)"
value "show_acom (steps test5_const 4)"
value "show_acom (steps test5_const 5)"
value "show_acom (steps test5_const 6)"
value "show_acom (the(AI_const test5_const))"
value "show_acom (steps test6_const 0)"
value "show_acom (steps test6_const 1)"
value "show_acom (steps test6_const 2)"
value "show_acom (steps test6_const 3)"
value "show_acom (steps test6_const 4)"
value "show_acom (steps test6_const 5)"
value "show_acom (steps test6_const 6)"
value "show_acom (steps test6_const 7)"
value "show_acom (steps test6_const 8)"
value "show_acom (steps test6_const 9)"
value "show_acom (steps test6_const 10)"
value "show_acom (steps test6_const 11)"
value "show_acom (steps test6_const 12)"
value "show_acom (steps test6_const 13)"
value "show_acom (the(AI_const test6_const))"
text{* Monotonicity: *}
global_interpretation Abs_Int_mono
where \<gamma> = \<gamma>_const and num' = Const and plus' = plus_const
proof (standard, goal_cases)
case 1 thus ?case by(auto simp: plus_const_cases split: const.split)
qed
text{* Termination: *}
definition m_const :: "const \<Rightarrow> nat" where
"m_const x = (if x = Any then 0 else 1)"
global_interpretation Abs_Int_measure
where \<gamma> = \<gamma>_const and num' = Const and plus' = plus_const
and m = m_const and h = "1"
proof (standard, goal_cases)
case 1 thus ?case by(auto simp: m_const_def split: const.splits)
next
case 2 thus ?case by(auto simp: m_const_def less_const_def split: const.splits)
qed
thm AI_Some_measure
end
|
#' sistmr.
#'
#' @name sistmr
#' @docType package
#'
#' @description
#' This package contains functions common to members of the SISTM team.
NULL
|
theory MyList
imports Main
begin
fun itrev :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" where
"itrev [] ys = ys" |
"itrev (x#xs) ys = itrev xs (x#ys)"
lemma "itrev xs [] = rev xs"
apply(induction xs)
apply(auto)
done
fun add :: "nat \<Rightarrow> nat \<Rightarrow> nat" where
"add 0 n = n" |
"add (Suc m) n = Suc (add m n)"
fun iadd :: "nat \<Rightarrow> nat \<Rightarrow> nat" where
"iadd 0 n = n" |
"iadd (Suc m) n = iadd m (Suc n)"
value "iadd 3 2"
value "iadd 2 0"
value "iadd 0 0"
lemma [simp] : "add m (Suc n) = Suc (add m n)"
apply(induction m)
apply(auto)
done
lemma "iadd m n = add m n"
apply(induction m arbitrary: n)
apply(auto)
done
end |
[STATEMENT]
lemma funpow_fixpoint: "f x = x \<Longrightarrow> (f ^^ n) x = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. f x = x \<Longrightarrow> (f ^^ n) x = x
[PROOF STEP]
by (induct n) auto |
corollary open_bijective_linear_image_eq: fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space" assumes "linear f" "bij f" shows "open(f ` A) \<longleftrightarrow> open A" |
/-
Copyright (c) 2019 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Scott Morrison, Simon Hudon
-/
import algebra.hom.equiv.basic
import category_theory.groupoid
import category_theory.opposites
import group_theory.group_action.defs
/-!
# Endomorphisms
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
Definition and basic properties of endomorphisms and automorphisms of an object in a category.
For each `X : C`, we provide `End X := X ⟶ X` with a monoid structure,
and `Aut X := X ≅ X ` with a group structure.
-/
universes v v' u u'
namespace category_theory
/-- Endomorphisms of an object in a category. Arguments order in multiplication agrees with
`function.comp`, not with `category.comp`. -/
def End {C : Type u} [category_struct.{v} C] (X : C) := X ⟶ X
namespace End
section struct
variables {C : Type u} [category_struct.{v} C] (X : C)
instance has_one : has_one (End X) := ⟨𝟙 X⟩
instance inhabited : inhabited (End X) := ⟨𝟙 X⟩
/-- Multiplication of endomorphisms agrees with `function.comp`, not `category_struct.comp`. -/
instance has_mul : has_mul (End X) := ⟨λ x y, y ≫ x⟩
variable {X}
/-- Assist the typechecker by expressing a morphism `X ⟶ X` as a term of `End X`. -/
def of (f : X ⟶ X) : End X := f
/-- Assist the typechecker by expressing an endomorphism `f : End X` as a term of `X ⟶ X`. -/
def as_hom (f : End X) : X ⟶ X := f
@[simp] lemma one_def : (1 : End X) = 𝟙 X := rfl
@[simp] lemma mul_def (xs ys : End X) : xs * ys = ys ≫ xs := rfl
end struct
/-- Endomorphisms of an object form a monoid -/
instance monoid {C : Type u} [category.{v} C] {X : C} : monoid (End X) :=
{ mul_one := category.id_comp,
one_mul := category.comp_id,
mul_assoc := λ x y z, (category.assoc z y x).symm,
..End.has_mul X, ..End.has_one X }
section mul_action
variables {C : Type u} [category.{v} C]
open opposite
instance mul_action_right {X Y : C} : mul_action (End Y) (X ⟶ Y) :=
{ smul := λ r f, f ≫ r,
one_smul := category.comp_id,
mul_smul := λ r s f, eq.symm $ category.assoc _ _ _ }
instance mul_action_left {X : Cᵒᵖ} {Y : C} : mul_action (End X) (unop X ⟶ Y) :=
{ smul := λ r f, r.unop ≫ f,
one_smul := category.id_comp,
mul_smul := λ r s f, category.assoc _ _ _ }
lemma smul_right {X Y : C} {r : End Y} {f : X ⟶ Y} : r • f = f ≫ r := rfl
lemma smul_left {X : Cᵒᵖ} {Y : C} {r : (End X)} {f : unop X ⟶ Y} : r • f = r.unop ≫ f := rfl
end mul_action
/-- In a groupoid, endomorphisms form a group -/
instance group {C : Type u} [groupoid.{v} C] (X : C) : group (End X) :=
{ mul_left_inv := groupoid.comp_inv, inv := groupoid.inv, ..End.monoid }
end End
lemma is_unit_iff_is_iso {C : Type u} [category.{v} C] {X : C} (f : End X) :
is_unit (f : End X) ↔ is_iso f :=
⟨λ h, { out := ⟨h.unit.inv, ⟨h.unit.inv_val, h.unit.val_inv⟩⟩ },
λ h, by exactI ⟨⟨f, inv f, by simp, by simp⟩, rfl⟩⟩
variables {C : Type u} [category.{v} C] (X : C)
/--
Automorphisms of an object in a category.
The order of arguments in multiplication agrees with
`function.comp`, not with `category.comp`.
-/
def Aut (X : C) := X ≅ X
namespace Aut
instance inhabited : inhabited (Aut X) := ⟨iso.refl X⟩
instance : group (Aut X) :=
by refine_struct
{ one := iso.refl X,
inv := iso.symm,
mul := flip iso.trans,
div := _,
npow := @npow_rec (Aut X) ⟨iso.refl X⟩ ⟨flip iso.trans⟩,
zpow := @zpow_rec (Aut X) ⟨iso.refl X⟩ ⟨flip iso.trans⟩ ⟨iso.symm⟩ };
intros; try { refl }; ext;
simp [flip, (*), monoid.mul, mul_one_class.mul, mul_one_class.one, has_one.one, monoid.one,
has_inv.inv]
lemma Aut_mul_def (f g : Aut X) : f * g = g.trans f := rfl
lemma Aut_inv_def (f : Aut X) : f ⁻¹ = f.symm := rfl
/--
Units in the monoid of endomorphisms of an object
are (multiplicatively) equivalent to automorphisms of that object.
-/
def units_End_equiv_Aut : (End X)ˣ ≃* Aut X :=
{ to_fun := λ f, ⟨f.1, f.2, f.4, f.3⟩,
inv_fun := λ f, ⟨f.1, f.2, f.4, f.3⟩,
left_inv := λ ⟨f₁, f₂, f₃, f₄⟩, rfl,
right_inv := λ ⟨f₁, f₂, f₃, f₄⟩, rfl,
map_mul' := λ f g, by rcases f; rcases g; refl }
/-- Isomorphisms induce isomorphisms of the automorphism group -/
def Aut_mul_equiv_of_iso {X Y : C} (h : X ≅ Y) : Aut X ≃* Aut Y :=
{ to_fun := λ x, ⟨h.inv ≫ x.hom ≫ h.hom, h.inv ≫ x.inv ≫ h.hom⟩,
inv_fun := λ y, ⟨h.hom ≫ y.hom ≫ h.inv, h.hom ≫ y.inv ≫ h.inv⟩,
left_inv := by tidy,
right_inv := by tidy,
map_mul' := by simp [Aut_mul_def] }
end Aut
namespace functor
variables {D : Type u'} [category.{v'} D] (f : C ⥤ D) (X)
/-- `f.map` as a monoid hom between endomorphism monoids. -/
@[simps] def map_End : End X →* End (f.obj X) :=
{ to_fun := functor.map f,
map_mul' := λ x y, f.map_comp y x,
map_one' := f.map_id X }
/-- `f.map_iso` as a group hom between automorphism groups. -/
def map_Aut : Aut X →* Aut (f.obj X) :=
{ to_fun := f.map_iso,
map_mul' := λ x y, f.map_iso_trans y x,
map_one' := f.map_iso_refl X }
end functor
end category_theory
|